Repository navigation
MDEV-10267 Add "ngram" support to MariaDB #6001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
futureweb
wants to merge
8
commits into
MariaDB:main
Choose a base branch
from
futureweb:MDEV-10267-ngram
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dfcc572
MDEV-41747 Aria: DROP TABLE warns "uses an extension that doesn't exi…
futureweb 874caa1
MDEV-35967 Server crashes when creating a fulltext index with simple_…
futureweb 22f8012
MDEV-41758 ALTER TABLE ignores a changed fulltext parser of an index
futureweb be2d787
MDEV-41759 MyISAM and Aria: an excluded phrase in boolean mode exclud…
futureweb 782cf08
MDEV-41752 Aria: RENAME TABLE, ALTER TABLE, REPAIR TABLE and crash re…
futureweb fd1901b
MDEV-10267 Lift InnoDB token length restrictions for fts plugins
i-rinat 3a515e7
MDEV-10267 Add ngram fulltext parser plugin
i-rinat a2dfd42
MDEV-10267 Build the ngram parser into the server
futureweb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ innodb,^ | |
| binlog_in_engine,^ | ||
| versioning,^ | ||
| plugins,^ | ||
| ngram,^ | ||
| mariabackup,^ | ||
| roles,^ | ||
| auth_gssapi,^ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| # | ||
| # MDEV-41759 MyISAM and Aria: an excluded phrase in boolean mode excludes all rows that contain its words, in any order | ||
| # | ||
| # MyISAM | ||
| CREATE TABLE t1 (id INT PRIMARY KEY, c TEXT, FULLTEXT(c)) | ||
| ENGINE=MyISAM; | ||
| INSERT INTO t1 VALUES | ||
| (1, 'xxxx alpha beta'), | ||
| (2, 'xxxx beta alpha'), | ||
| (3, 'xxxx alpha gamma beta'), | ||
| (4, 'xxxx'); | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c) AGAINST('+xxxx -"alpha beta"' IN BOOLEAN MODE); | ||
| id | ||
| 2 | ||
| 3 | ||
| 4 | ||
| # through an enclosing excluded group | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c) AGAINST('+xxxx -("alpha beta")' IN BOOLEAN MODE); | ||
| id | ||
| 2 | ||
| 3 | ||
| 4 | ||
| # inside a required group | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c) AGAINST('+xxxx +(+xxxx -"alpha beta")' IN BOOLEAN MODE); | ||
| id | ||
| 2 | ||
| 3 | ||
| 4 | ||
| # next to a required phrase | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c) AGAINST('+"xxxx beta" -"alpha beta"' IN BOOLEAN MODE); | ||
| id | ||
| 2 | ||
| DROP TABLE t1; | ||
| # several indexed columns, with NULLs | ||
| CREATE TABLE t1 | ||
| (id INT PRIMARY KEY, c1 TEXT, c2 TEXT, FULLTEXT(c1,c2)) ENGINE=MyISAM; | ||
| INSERT INTO t1 VALUES | ||
| (1, 'xxxx alpha', 'beta'), | ||
| (2, 'xxxx', 'alpha beta'), | ||
| (3, 'xxxx beta', 'alpha'), | ||
| (4, 'xxxx', NULL), | ||
| (5, NULL, 'xxxx alpha beta'); | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c1,c2) AGAINST('+xxxx -"alpha beta"' IN BOOLEAN MODE); | ||
| id | ||
| 1 | ||
| 3 | ||
| 4 | ||
| DROP TABLE t1; | ||
| # Aria | ||
| CREATE TABLE t1 (id INT PRIMARY KEY, c TEXT, FULLTEXT(c)) | ||
| ENGINE=Aria; | ||
| INSERT INTO t1 VALUES | ||
| (1, 'xxxx alpha beta'), | ||
| (2, 'xxxx beta alpha'), | ||
| (3, 'xxxx alpha gamma beta'), | ||
| (4, 'xxxx'); | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c) AGAINST('+xxxx -"alpha beta"' IN BOOLEAN MODE); | ||
| id | ||
| 2 | ||
| 3 | ||
| 4 | ||
| # through an enclosing excluded group | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c) AGAINST('+xxxx -("alpha beta")' IN BOOLEAN MODE); | ||
| id | ||
| 2 | ||
| 3 | ||
| 4 | ||
| # inside a required group | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c) AGAINST('+xxxx +(+xxxx -"alpha beta")' IN BOOLEAN MODE); | ||
| id | ||
| 2 | ||
| 3 | ||
| 4 | ||
| # next to a required phrase | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c) AGAINST('+"xxxx beta" -"alpha beta"' IN BOOLEAN MODE); | ||
| id | ||
| 2 | ||
| DROP TABLE t1; | ||
| # several indexed columns, with NULLs | ||
| CREATE TABLE t1 | ||
| (id INT PRIMARY KEY, c1 TEXT, c2 TEXT, FULLTEXT(c1,c2)) ENGINE=Aria; | ||
| INSERT INTO t1 VALUES | ||
| (1, 'xxxx alpha', 'beta'), | ||
| (2, 'xxxx', 'alpha beta'), | ||
| (3, 'xxxx beta', 'alpha'), | ||
| (4, 'xxxx', NULL), | ||
| (5, NULL, 'xxxx alpha beta'); | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c1,c2) AGAINST('+xxxx -"alpha beta"' IN BOOLEAN MODE); | ||
| id | ||
| 1 | ||
| 3 | ||
| 4 | ||
| DROP TABLE t1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| --source include/have_aria.inc | ||
|
|
||
| --echo # | ||
| --echo # MDEV-41759 MyISAM and Aria: an excluded phrase in boolean mode excludes all rows that contain its words, in any order | ||
| --echo # | ||
|
|
||
| let $engine= MyISAM; | ||
| let $engines= 2; | ||
| while ($engines) | ||
| { | ||
| --echo # $engine | ||
| eval CREATE TABLE t1 (id INT PRIMARY KEY, c TEXT, FULLTEXT(c)) | ||
| ENGINE=$engine; | ||
| INSERT INTO t1 VALUES | ||
| (1, 'xxxx alpha beta'), | ||
| (2, 'xxxx beta alpha'), | ||
| (3, 'xxxx alpha gamma beta'), | ||
| (4, 'xxxx'); | ||
| --sorted_result | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c) AGAINST('+xxxx -"alpha beta"' IN BOOLEAN MODE); | ||
| --echo # through an enclosing excluded group | ||
| --sorted_result | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c) AGAINST('+xxxx -("alpha beta")' IN BOOLEAN MODE); | ||
| --echo # inside a required group | ||
| --sorted_result | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c) AGAINST('+xxxx +(+xxxx -"alpha beta")' IN BOOLEAN MODE); | ||
| --echo # next to a required phrase | ||
| --sorted_result | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c) AGAINST('+"xxxx beta" -"alpha beta"' IN BOOLEAN MODE); | ||
| DROP TABLE t1; | ||
|
|
||
| --echo # several indexed columns, with NULLs | ||
| eval CREATE TABLE t1 | ||
| (id INT PRIMARY KEY, c1 TEXT, c2 TEXT, FULLTEXT(c1,c2)) ENGINE=$engine; | ||
| INSERT INTO t1 VALUES | ||
| (1, 'xxxx alpha', 'beta'), | ||
| (2, 'xxxx', 'alpha beta'), | ||
| (3, 'xxxx beta', 'alpha'), | ||
| (4, 'xxxx', NULL), | ||
| (5, NULL, 'xxxx alpha beta'); | ||
| --sorted_result | ||
| SELECT id FROM t1 | ||
| WHERE MATCH(c1,c2) AGAINST('+xxxx -"alpha beta"' IN BOOLEAN MODE); | ||
| DROP TABLE t1; | ||
|
|
||
| let $engine= Aria; | ||
| dec $engines; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| # | ||
| # MDEV-41758 ALTER TABLE ignores a changed fulltext parser of an index | ||
| # | ||
| INSTALL PLUGIN simple_parser SONAME 'mypluglib'; | ||
| # Adding a parser. The index is built with it: simple_parser keeps | ||
| # 'abc-def' as one word, so 'abc' does not match. | ||
| CREATE TABLE t (id INT PRIMARY KEY, c TEXT, FULLTEXT ft(c)) ENGINE=InnoDB; | ||
| INSERT INTO t VALUES (1, 'abc-def'); | ||
| ALTER TABLE t DROP INDEX ft, ADD FULLTEXT ft(c) WITH PARSER simple_parser; | ||
| SHOW CREATE TABLE t; | ||
| Table Create Table | ||
| t CREATE TABLE `t` ( | ||
| `id` int(11) NOT NULL, | ||
| `c` text DEFAULT NULL, | ||
| PRIMARY KEY (`id`), | ||
| FULLTEXT KEY `ft` (`c`) WITH PARSER `simple_parser` | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci | ||
| SELECT id FROM t WHERE MATCH(c) AGAINST('abc'); | ||
| id | ||
| DROP TABLE t; | ||
| # Removing it, which cannot be done instantly | ||
| CREATE TABLE t (id INT PRIMARY KEY, c TEXT, | ||
| FULLTEXT ft(c) WITH PARSER simple_parser) ENGINE=InnoDB; | ||
| ALTER TABLE t DROP INDEX ft, ADD FULLTEXT ft(c), ALGORITHM=INSTANT; | ||
| ERROR 0A000: ALGORITHM=INSTANT is not supported. Reason: ADD INDEX. Try ALGORITHM=NOCOPY | ||
| ALTER TABLE t DROP INDEX ft, ADD FULLTEXT ft(c); | ||
| SHOW CREATE TABLE t; | ||
| Table Create Table | ||
| t CREATE TABLE `t` ( | ||
| `id` int(11) NOT NULL, | ||
| `c` text DEFAULT NULL, | ||
| PRIMARY KEY (`id`), | ||
| FULLTEXT KEY `ft` (`c`) | ||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_uca1400_ai_ci | ||
| DROP TABLE t; | ||
| # Adding it under another name: the index is rebuilt, not just renamed, | ||
| # so 'abc' does not match. | ||
| CREATE TABLE t (id INT PRIMARY KEY, c TEXT, FULLTEXT ft(c)) ENGINE=InnoDB; | ||
| INSERT INTO t VALUES (1, 'abc-def'); | ||
| ALTER TABLE t DROP INDEX ft, ADD FULLTEXT ft2(c) WITH PARSER simple_parser; | ||
| SELECT id FROM t WHERE MATCH(c) AGAINST('abc'); | ||
| id | ||
| DROP TABLE t; | ||
| # The same parser, in any letter case, is no change | ||
| CREATE TABLE t (id INT PRIMARY KEY, c TEXT, | ||
| FULLTEXT ft(c) WITH PARSER simple_parser) ENGINE=InnoDB; | ||
| ALTER TABLE t DROP INDEX ft, | ||
| ADD FULLTEXT ft(c) WITH PARSER SIMPLE_PARSER, ALGORITHM=INSTANT; | ||
| DROP TABLE t; | ||
| UNINSTALL PLUGIN simple_parser; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.