Skip to content

MDEV-10267 Add "ngram" support to MariaDB - #6001

Open
futureweb wants to merge 8 commits into
MariaDB:mainfrom
futureweb:MDEV-10267-ngram
Open

futureweb wants to merge 8 commits into
MariaDB:mainfrom
futureweb:MDEV-10267-ngram

Conversation

@futureweb

@futureweb futureweb commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor
  • The Jira issue number for this PR is: MDEV-10267

Description

This adds the ngram fulltext parser, which splits text into overlapping n-grams of a fixed length (ngram_token_size, default 2), so that CJK text without spaces between words can be searched. It finishes the work on bb-12.3-MDEV-10267-ngram, Rinat Ibragimov's plugin and InnoDB change with Sergei Golubchik's post-review changes, as proposed in MDEV-10267 (design note attached there).

The parser implements the tokenization rules of MySQL's ngram parser (the same word separators, a boolean mode word becomes a phrase of its n-grams, ngram_token_size is 1 to 10 and read-only), and it is built into the server and enabled by default, so that tables, queries and dumps from MySQL (/*!50100 WITH PARSER ngram */) can be used with it. The intended difference: unlike in MySQL, n-grams that contain a stopword are not dropped. The commit messages have the details.

Please review the last three commits (all MDEV-10267):

  1. InnoDB applies the stopword list and innodb_ft_min_token_size/innodb_ft_max_token_size only to the built-in tokenizer, no longer to the tokens of a parser plugin (Rinat, with Serg's post-review changes; I added a length limit for tokens that do not fit into the index, and moved the stopword check of the built-in tokenizer back to fts_tokenizer_word_get(), where main has it, so that nothing changes for the built-in tokenizer).
  2. The ngram plugin: Rinat's plugin, reworked to follow MySQL's parser, with MySQL's ngram tests ported.
  3. Building it into the server.

The five commits before them are bug fixes that ngram needs (the table says why). Each fix has its own PR, and I rebase this PR as they are merged into main:

Commit PR Why ngram needs it
MDEV-41747 Aria DROP TABLE with a parser plugin #5963 Aria tables WITH PARSER ngram: without the code of these two Aria fixes, ngram.ngram_basic, ngram_edge and the ngram_random tests fail
MDEV-41752 Aria RENAME/ALTER/REPAIR/recovery with a parser plugin #5977 (see MDEV-41747)
MDEV-35967 token positions of parser plugins #5994 phrase search with any parser plugin
MDEV-41758 ALTER TABLE ignores a parser change #5978 moving an existing index to ngram with ALTER TABLE
MDEV-41759 MyISAM/Aria excluded phrase #5976 ngram.ngram_edge (+lion -gli on MyISAM and Aria) and the ngram_random tests

MDEV-41751 (#5995, 412003c) and MDEV-41757 (#5979, 707efb6) are merged into main, so they are no longer part of this PR. The MDEV-41759 commit here leaves out the w.pos/w.len initialization that #5976 has: main has it already from MDEV-39752 (813dbc8).

Rebased onto main b800539 (25 Nov). One test result changed with it: in ngram.mysql_ngram_1, the boolean mode query 's+ i*' now returns all five rows instead of none. ngram turns the word s into a phrase, and before MDEV-41022 a prefix search after a phrase missed the words that are still in the FTS cache; i* matches every n-gram that starts with "i", and each row has one. With MDEV-41022 reverted, the result is empty again. MySQL's test expects no row because MySQL's fts_query_phrase_search() does not reset query->flags either; the test and the commit message say so.

Not included, because the tests here pass without them: #5975 (MDEV-37370) and #5974 (MDEV-41754). They make phrase search linear, and they also fix wrong results in some cases (match lists that are not sorted by document ID; prefix search with some collations). In the benchmark in #5975 (main with this parser, n=2, 20,000 Latin documents, boolean mode queries), the queries took 37.2 s without MDEV-37370 and 10.1 s with it.

Notes for reviewers

Known compatibility regression in the InnoDB commit: for a parser plugin that leaves its stopwords out of the index and marks them FT_TOKEN_STOPWORD in a quoted phrase of a boolean query, phrase search now also looks up those words, and so finds no row. On main, phrase search skipped the words of InnoDB's own stopword list instead, whatever the plugin marked, so such a phrase was found where the two lists agree. No parser in the tree marks stopwords this way (simple_parser and ngram index every word, and InnoDB's own query tokenizer never returns FT_TOKEN_STOPWORD), so testing it needs a small parser fixture that marks its stopwords. If you'd like it fixed in this PR, fts_query_add_word_for_parser() can keep the mark in the query tree, so that fts_query_phrase_split() leaves such words out of the lookup but still checks them in the document; I'd add such a fixture for the test.

Release Notes

New fulltext parser plugin ngram for CJK text, with the tokenization rules of MySQL's ngram parser: FULLTEXT(...) WITH PARSER ngram, with the read-only server option ngram_token_size (1–10, default 2). It is built in and enabled by default; --ngram=OFF disables it. Unlike MySQL, it does not drop n-grams that contain stopwords. As in MySQL, characters outside the BMP (such as emoji) are part of the indexed n-grams, but the boolean mode query parser treats them as separators, so n-grams with such characters are only found in natural language mode.

InnoDB no longer applies its stopword list and innodb_ft_min_token_size/innodb_ft_max_token_size to the words of a fulltext parser plugin; the plugin decides which words to index, as with MyISAM and Aria. InnoDB FULLTEXT indexes that use a parser plugin should be rebuilt.

How can this PR be tested?

The new suite ngram (in plugin/fulltext_ngram/mysql-test):

  • ngram_basic and ngram_token_size (from Rinat's branch), ngram_edge (separators, a Big5 character without a Unicode mapping, words as phrases with + and -, natural language mode on MyISAM and Aria, UPDATE and DELETE), ngram_longest (ngram_token_size=10 with characters of 1 to 3 bytes), mysql_dump (a table as written by MySQL 8.0's mysqldump).
  • MySQL's ngram tests, ported as ngram.mysql_*; their adaptations are commented in the tests and listed in the commit message.
  • ngram_random, ngram_random_1 and ngram_random_3, big tests: they compare searches with the n-grams of random documents on InnoDB (index build, cache, OPTIMIZE, DML, restart, crash recovery), MyISAM and Aria, for ngram_token_size 2, 1 and 3.

For the InnoDB commit: innodb_fts.plugin_token_size (innodb_ft_min_token_size and innodb_ft_max_token_size apply to the built-in tokenizer only), innodb_fts.innodb_fts_plugin (tokens too long for the index) and innodb_fts.stopword_cache (the built-in tokenizer filters stopwords as before).

On this branch (main b800539, debug build): the ngram suite passes with --big-test, with --repeat=2 and with the ps, view, cursor and sp protocols; the innodb_fts, maria and plugins suites, the main fulltext, plugin, alter and mysqld--help tests and the sys_vars sysvars_server tests pass, and the new or changed InnoDB tests also with the ps, view and cursor protocols and --repeat=2. With the embedded server, so do the ngram tests that don't restart the server. Before the rebase (main c894d97), also: innodb_fts at the InnoDB commit, the ngram suite at the plugin commit built as a module, and under ASAN the ngram suite and the changed InnoDB tests.

Basing the PR against the correct MariaDB version

  • This is a new feature and the PR is based against the latest MariaDB development branch.
  • This is a bug fix and the PR is based against the earliest maintained branch in which the bug can be reproduced.

PR quality check

  • I checked the CODING_STANDARDS.md file and my PR conforms to this where appropriate.
  • For any trivial modifications to the PR, I am ok with the reviewer making the changes themselves.

🤖 Generated with Claude Code

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Oct 28, 2026

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution! This is a preliminary review.

I've taken the liberty of adding the dependent jiras as a explicit dependencies.

Another thing: I believe that instead of cramming tall the commits into this PR, you are probably better off with https://docs.github.com/en/pull-requests/how-tos/stacked-pull-requests. Because these will change as the reviews go along. And you don't want to maintain that manually.

I have some remarks on tests etc below to keep you going until the final reviewer is ready to pick it up.

Comment thread mysql-test/main/mysqld--help.test Resolved
--echo # Bug #31228694 FTS QUERY WITH LIMIT CRASH
--echo #

let $restart_parameters= --ngram_token_size=1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restarts mid-test should be avoided at all costs. In your case just put an .opt file for this and add the option in it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: --ngram-token-size=1 is in mysql_limit_union.opt.

@@ -0,0 +1 @@
--default-storage-engine=InnoDB

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like most of your tests require this. Why not add it to suite.opt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, done – it's in suite.opt now; the other tests name their engine anyway.


# Valid values are from 1 to 10
# ngram_token_size = 1 if we try to set ngram_token_size <= 0
let $restart_parameters= --ngram_token_size=0;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split these to avoid restarts and for better parallelization please.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: mysql_ngram_token_size_basic checks the variable, and mysql_ngram_token_size_0, _minus_1, _11 and _10 each start the server with their value in the .opt file.


--echo # Case 1 : test phrase search with ngram.

let $restart_parameters= --ngram_token_size=1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here: please put that into the .opt file.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: --ngram-token-size=1 is in the .opt file, and case 2 sets innodb_ft_enable_stopword for the session instead of restarting with it – CREATE FULLTEXT INDEX reads the session value.

@@ -0,0 +1,2 @@
--plugin-load-add=$FULLTEXT_NGRAM_SO
--loose-ngram

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why --loose-ngram?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mysql-test-run starts every server with --loose-skip-plugin-<name> for all optional plugins (ConfigFactory.pm), and built in, ngram is one of them, so the suite switches it back on. The loose- wasn't needed, though – suite.pm skips the suite if there's no ngram – so it's --plugin-ngram=ON now, as in the user_variables and query_response_time suites.

Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#include <my_global.h>
#include <m_ctype.h>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more of a note to @vuvova than to the submitter.

The only obstacle to this becoming a "pure" plugin (not dependent on server symbols and just using plugin APIs and services) is the above two headers.

I wonder if there's any way to lift that limitation?

I am aware that the st_mysql_ftparser_param comes complete with a cs pointer. So the whole point is kind of moot.

FWIW, mysql has a suite of charset handling services that untie this issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, from the plugin's side: it only uses the charset param->cs points to – my_ci_charlen() and my_ci_ctype() (both through cs->cset) and the _MY_* ctype flags of m_ctype.h – and no server symbols; on Linux, the module is linked with --no-undefined (except in sanitizer builds). my_global.h is there for m_ctype.h.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the CHARSET_INFO structure itself doesn't seem to be defined in the plugin API headers. This makes it an opaque structure similar to MYSQL_THD for example. This means there are no ABI checks on it. I guess it's a great example of how --no-undefined is not enough.

@gkodinov gkodinov self-assigned this Oct 28, 2026
@futureweb

Copy link
Copy Markdown
Contributor Author

Thanks for the review, and for adding the dependencies!

I've pushed the changes for your remarks (replies inline):

  • Every test has the MDEV-10267 header.
  • No restarts just to change a setting: mysql_limit_union and mysql_phrase_clear_no_match use .opt files, mysql_ngram_token_size_basic and mysql_ngram_2 are split into a test per value and per scenario, and, following the same idea, ngram_random into a test per ngram_token_size.
  • --default-storage-engine=InnoDB is in suite.opt.

The restarts that are left are what those tests check: an index built with another ngram_token_size (ngram_token_size, test case 7 of mysql_ngram), a table opened without its parser (scenario 1 of mysql_ngram_2), and restart and crash recovery (ngram_random).

About stacked PRs: good idea, and I looked into it, but GitHub doesn't support them for PRs from forks yet – the docs say "Cross-fork stacks are not supported", and the feature request for it (github/gh-stack#46) is still open. A stack would need its branches in MariaDB/server, where I can't push, and it lands on one branch, while the fixes go to 10.11, 11.4 and 11.8 and this PR to main. So for now I'll keep rebasing this PR as the fixes are merged up to main – only the last three commits are for review here.

@futureweb
futureweb requested a review from gkodinov October 28, 2026 16:42

@gkodinov gkodinov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Please stand by for the final review.

--source include/not_embedded.inc

#
# InnoDB FULLTEXT SEARCH: CJK support - ngram parser

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why two headers in this one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No good reason – it was the title of MySQL's original test, left over from porting. Removed, here and in mysql_ngram_debug and mysql_ngram_1.

Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

#include <my_global.h>
#include <m_ctype.h>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the CHARSET_INFO structure itself doesn't seem to be defined in the plugin API headers. This makes it an opaque structure similar to MYSQL_THD for example. This means there are no ABI checks on it. I guess it's a great example of how --no-undefined is not enough.

@gkodinov
gkodinov requested a review from vuvova October 29, 2026 11:36
@gkodinov gkodinov assigned vuvova and unassigned gkodinov Oct 29, 2026
futureweb and others added 6 commits November 25, 2026 19:55
…st" for a table with a fulltext parser plugin

maria_delete_table() opens the table to find out whether it is
transactional. A table whose fulltext index uses a parser plugin has
HA_OPTION_RELIES_ON_SQL_LAYER, so maria_open() refused it with
HA_ERR_UNSUPPORTED. DROP TABLE then warned "Table uses an extension
that doesn't exist in this MariaDB version" and skipped the
REDO_DROP_TABLE log record of a transactional table.

Opening for drop only reads the share, so allow it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…parser plugin

When a fulltext index with a parser plugin was built over existing
rows, row_merge_fts_doc_tokenize() gave every token of a field the
same position (the start of the field), because the plugin API has no
token position. A word repeated in a field other than the first then
failed the assertion pos > last_pos in fts_cache_node_add_positions().

Store the byte offset of the token in the document instead, as the
built-in tokenizer does. Do the same for rows inserted into an
existing index, where fts_tokenize_add_word_for_parser() has numbered
the tokens since MDEV-24088: phrase search (fts_query_match_phrase())
reads positions as byte offsets into the document, so with token
numbers it started matching at the wrong place, and with a multi-byte
character set it could miss rows. The positions of a document are
kept strictly increasing, also across its fields: a token that does
not point into the document (a parser may build words elsewhere), or
that does not come after the previous token, gets the position after
the previous token.

innodb_fts.plugin_debug, with fts_instrument_use_default_parser, indexes
and searches through the plugin interface with the built-in tokenizer.
Its phrase searches now find the rows they should and return the same
rows as MySQL, so the comments that explained the empty results are
removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
compare_keys_but_name() does not look at the fulltext parser. Before
062f8eb ("cleanup: key algorithm vs key flags") this did not
matter: a FULLTEXT index added by ALTER TABLE had the key algorithm
HA_KEY_ALG_UNDEF and the existing one HA_KEY_ALG_FULLTEXT, so the two
never compared equal, and the index was always rebuilt. Since then
both have HA_KEY_ALG_FULLTEXT. So an in-place
ALTER TABLE t DROP INDEX ft, ADD FULLTEXT ft(c) WITH PARSER p did
nothing, and with another index name it only renamed the index, whose
rows stayed tokenized by the old parser. Removing or replacing the
parser was ignored as well.

An index whose parser is added, removed or replaced is not equal. Parser
names are compared case-insensitively, like plugin names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…es all rows that contain its words, in any order

During the index search, _ftb_climb_the_tree() treated a phrase as
matched once all its indexed words were present. Phrase order and
adjacency were checked only by the final relevance check, which
rows rejected by an excluded phrase never reached. Thus
'+xxxx -"alpha beta"' also rejected rows containing "beta alpha" or
"alpha gamma beta".

Verify phrases that can exclude a row, directly or through an
enclosing excluded expression, before propagating their match in
the index search. Skip verification when an expression on the path
to the root already has nos set for the current document.

Remaining candidates still require a row read and phrase scan even
if the rest of the query later rejects the row. Queries without
required words or with truncation can therefore perform additional
random row reads.

Initialize the FT_WORD in Aria's ftb_parse_query_internal(), as
MDEV-33478 did for MyISAM. maria_ft_get_word() leaves it unset for
a leading operator such as '+"', and MemorySanitizer reports the
uninitialized arguments of mysql_add_word() for the new test.

Test MyISAM and Aria: an excluded phrase directly, through an enclosing
excluded group, inside a required group and next to a required phrase,
and over two indexed columns with NULLs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…covery fail for a table with a fulltext parser plugin

A table whose fulltext index uses a parser plugin has
HA_OPTION_RELIES_ON_SQL_LAYER, and maria_open() refuses it unless
HA_OPEN_FROM_SQL_LAYER is set, which only ha_maria::open() did. So
maria_rename() (RENAME TABLE, and the renames of ALTER TABLE ...
ALGORITHM=COPY), the second data handle of a ROW_FORMAT=PAGE repair
(create_new_data_handle()) and crash recovery (new_table()) failed for
such tables, and recovery skipped their REDO records.

Inside the server, open such tables with HA_OPEN_FROM_SQL_LAYER in
these places. Recovery can pass the flag for every table, because for
the others its only effect, the state LSN update, already follows from
maria_in_recovery. aria_chk and aria_read_log still refuse such
tables. Repair builds the fulltext keys through the handle that the
SQL layer opened, which has the parser of the table, and recovery
applies logged rows and key values without a parser.

Recovery cannot replay REDO_REPAIR_TABLE for such a table, because the
parser plugin is not loaded then. It skips the record and keeps the
files of the repair. To make that safe, write_log_record_for_repair()
now syncs the files of such a table before it logs the repair: flushing
the pages does not make them durable. Marking the table as crashed
instead would make recovery skip all later REDO records of the table,
which can be committed changes.

The debug points maria_crash_after_repair_log and
maria_before_repair_log are for maria.fulltext_parser_debug.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fulltext plugin API suggests that plugins themselves are expected
to filter out stopwords or words that are too short or too long. Remove
these checks from InnoDB's FTS engine for tokens that come from a
parser plugin: innodb_ft_min_token_size and innodb_ft_max_token_size,
which fts_add_token() applied to every token, now apply only to the
built-in tokenizer (fts_process_token()); fts_tokenizer_word_get() does
not check the stopword list for an index with a parser plugin;
row_merge_fts_doc_tokenize() applies neither to the tokens of a parser
plugin; and fts_query_phrase_split() does not apply them with a parser
plugin (innodb_fts.plugin_token_size). Nothing changes for the built-in
tokenizer (innodb_fts.stopword_cache).

The tokens of a parser plugin still have to fit into the index: the
word column of the auxiliary tables holds at most HA_FT_MAXCHARLEN
characters, and row_merge_fts_doc_tokenize() copies the token into a
CharBuffer<FTS_MAX_WORD_LEN>. fts_token_fits() skips longer tokens when
an index is built, when rows are added to the cache and in phrase
search; innodb_fts.innodb_fts_plugin checks the first two.

Short words and stopwords are now indexed through a parser plugin:
innodb_fts.innodb_fts_plugin and plugin_debug find more rows for
'will go' and '数据', and '"for mysql"' is now a phrase of two words,
for which plugin_debug finds two rows instead of five.

Co-authored-by: Sergei Golubchik <serg@mariadb.org>
Co-authored-by: Andreas Schnederle-Wagner <schnederle@futureweb.at>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
i-rinat and others added 2 commits November 25, 2026 20:48
Ngram is a fulltext parser plugin that splits words into overlapping
segments of fixed length. For example, if 3-grams are in use, string
"abcdef" is split into "abc", "bcd", "cde", "def", thus allowing an
efficient substring search for CJK texts where splitting by words is
not feasible.

The plugin implements the tokenization rules of MySQL's ngram parser,
so that tables and queries from MySQL can be used with it:
- A single-byte character that is not a letter, a digit or '_' (a
  space or punctuation) separates words, and n-grams do not span it.
  Multi-byte characters, CJK punctuation included, are part of
  n-grams. A word shorter than ngram_token_size gives no n-gram.
- In boolean mode, a word becomes a phrase of its n-grams, and a
  wildcard is ignored: 'abc' and 'abc*' both mean '"ab bc"'. A word
  with a wildcard that is shorter than ngram_token_size stays a prefix
  search. The n-grams of such a phrase get yesno=1, as the words of a
  quoted phrase do, because MyISAM and Aria check a phrase only for
  its required words.
- ngram_token_size (1 to 10, default 2) is read-only: n-grams of
  another size would not match an existing index.

In boolean mode the plugin leaves the query syntax to the engine, so
with MyISAM and Aria it follows ft_boolean_syntax, as the built-in
parser does; MySQL's ngram parser always uses the default syntax.

The length of a character is taken from charlen(), so that a
well-formed character without a Unicode mapping (for example Big5
C840) does not end the document, and the byte lengths of the last n
characters are kept in a ring buffer, so that the string is scanned
once. As a module, which on Linux is linked with --no-undefined
(except in sanitizer builds) and only gets the plugin services, the
plugin uses assert() rather than DBUG_ASSERT.

Unlike in MySQL, n-grams that contain a stopword are not dropped.

Tests: ngram.ngram_basic, ngram_token_size, ngram_edge and
ngram_longest, and MySQL's ngram tests ported as ngram.mysql_*
(innodb_fts.ngram, ngram_1, ngram_2, ngram_debug,
phrase_clear_no_match, the ngram cases of plugin_1 and limit_union,
innodb.innodb_fts_limit_check and sys_vars.ngram_token_size_basic).
Their adaptations are commented in the tests: the stopword rule above,
no gb18030 in MariaDB (MDEV-7495), RENAME TABLE needs the parser
plugin, DROP TABLE without it leaves the InnoDB table behind
(MDEV-41753), two FULLTEXT indexes can be added in one ALTER TABLE,
and after a phrase a prefix search also finds the words that are
still in the FTS cache (MDEV-41022; MySQL returns no row for
's+ i*' in mysql_ngram_1); FTS_DOC_ID values and error messages
differ in the results. Where
MySQL's test restarts the server only to change a setting, the ported
test sets it in an .opt file or with SET: ngram_token_size_basic is
split into a test per value, and ngram_2 into a test per scenario.
ngram.ngram_random, ngram_random_1 and ngram_random_3 (big tests)
compare searches with the n-grams of random documents, on InnoDB (index
build, cache, OPTIMIZE, DML, restart, crash recovery), MyISAM and Aria,
for ngram_token_size 2, 1 and 3.

Co-authored-by: Andreas Schnederle-Wagner <schnederle@futureweb.at>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
As in MySQL, ngram is compiled into the server and enabled by default,
so that tables from MySQL dumps with /*!50100 WITH PARSER `ngram` */
load without INSTALL SONAME; ngram.mysql_dump loads a table as written
by MySQL 8.0's mysqldump. --ngram=OFF disables it, and
-DPLUGIN_FULLTEXT_NGRAM=DYNAMIC still builds it as a module.

The declaration is renamed after the CMake target, as a static plugin
needs, and the maturity is BETA. As mysql-test-run disables optional
plugins, the test suite enables it (--plugin-ngram=ON), whether it is
built in or loaded; main.mysqld--help leaves out its options, which
depend on how it is built, as it does for the other optional plugins;
and the Windows suite list (mysql-test/collections/buildbot_suites.bat)
includes ngram.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

4 participants