Skip to content

Commit 0c17a03

Browse files
futurewebclaude
andcommitted
MDEV-10267 Build the ngram parser into the server
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. The test suite enables the plugin whether it is built in or loaded, main.mysqld--help treats ngram as an optional plugin, and the Windows suite list (mysql-test/collections/buildbot_suites.bat) includes ngram. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent df7d893 commit 0c17a03

9 files changed

Lines changed: 53 additions & 6 deletions

File tree

‎debian/mariadb-server.install‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ usr/lib/mysql/plugin/auth_pam_v1.so
2929
usr/lib/mysql/plugin/auth_parsec.so
3030
usr/lib/mysql/plugin/disks.so
3131
usr/lib/mysql/plugin/file_key_management.so
32-
usr/lib/mysql/plugin/fulltext_ngram.so
3332
usr/lib/mysql/plugin/ha_archive.so
3433
usr/lib/mysql/plugin/ha_blackhole.so
3534
usr/lib/mysql/plugin/ha_federated.so

‎mysql-test/collections/buildbot_suites.bat‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ innodb,^
66
binlog_in_engine,^
77
versioning,^
88
plugins,^
9+
ngram,^
910
mariabackup,^
1011
roles,^
1112
auth_gssapi,^

‎mysql-test/main/mysqld--help.test‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ perl;
4141
wsrep file-key-management cracklib-password-check user-variables
4242
provider-bzip2 provider-lzma provider-lzo caching-sha2-password
4343
thread-pool-groups thread-pool-queues thread-pool-stats
44-
thread-pool-waits hashicorp provider gssapi parsec videx/;
44+
thread-pool-waits hashicorp provider gssapi parsec videx ngram/;
4545

4646
# And substitute the content some environment variables with their
4747
# names:

‎plugin/fulltext_ngram/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# along with this program; if not, write to the Free Software
1414
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA
1515

16-
MYSQL_ADD_PLUGIN(fulltext_ngram plugin_ngram.cc MODULE_ONLY)
16+
MYSQL_ADD_PLUGIN(fulltext_ngram plugin_ngram.cc DEFAULT)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#
2+
# MDEV-10267 Add "ngram" support to MariaDB
3+
# A table from a MySQL dump that uses WITH PARSER ngram loads
4+
#
5+
SET NAMES utf8mb4;
6+
CREATE TABLE `articles` (
7+
`id` int unsigned NOT NULL AUTO_INCREMENT,
8+
`title` varchar(200) DEFAULT NULL,
9+
`body` text,
10+
PRIMARY KEY (`id`),
11+
FULLTEXT KEY `ft` (`title`,`body`) /*!50100 WITH PARSER `ngram` */
12+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
13+
INSERT INTO `articles` VALUES (1,'数据库管理系统','计算机是处理大量数据的理想工具');
14+
SHOW CREATE TABLE articles;
15+
Table Create Table
16+
articles CREATE TABLE `articles` (
17+
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
18+
`title` varchar(200) DEFAULT NULL,
19+
`body` text DEFAULT NULL,
20+
PRIMARY KEY (`id`),
21+
FULLTEXT KEY `ft` (`title`,`body`) WITH PARSER `ngram`
22+
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
23+
SELECT id FROM articles WHERE MATCH(title, body) AGAINST('数据库' IN BOOLEAN MODE);
24+
id
25+
1
26+
DROP TABLE articles;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--source include/have_innodb.inc
2+
3+
--echo #
4+
--echo # MDEV-10267 Add "ngram" support to MariaDB
5+
--echo # A table from a MySQL dump that uses WITH PARSER ngram loads
6+
--echo #
7+
SET NAMES utf8mb4;
8+
# As written by mysqldump of MySQL 8.0
9+
CREATE TABLE `articles` (
10+
`id` int unsigned NOT NULL AUTO_INCREMENT,
11+
`title` varchar(200) DEFAULT NULL,
12+
`body` text,
13+
PRIMARY KEY (`id`),
14+
FULLTEXT KEY `ft` (`title`,`body`) /*!50100 WITH PARSER `ngram` */
15+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
16+
INSERT INTO `articles` VALUES (1,'数据库管理系统','计算机是处理大量数据的理想工具');
17+
SHOW CREATE TABLE articles;
18+
SELECT id FROM articles WHERE MATCH(title, body) AGAINST('数据库' IN BOOLEAN MODE);
19+
DROP TABLE articles;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
--plugin-load-add=$FULLTEXT_NGRAM_SO
2+
--loose-ngram

‎plugin/fulltext_ngram/mysql-test/ngram/suite.pm‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ package My::Suite::Ngram;
22

33
@ISA = qw(My::Suite);
44

5-
return "No fulltext_ngram plugin" unless $ENV{FULLTEXT_NGRAM_SO};
5+
return "No ngram plugin" unless $ENV{FULLTEXT_NGRAM_SO} or
6+
$::mysqld_variables{'ngram'} eq "ON";
67

78
sub is_default { 1 }
89

‎plugin/fulltext_ngram/plugin_ngram.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static struct st_mysql_sys_var *ngram_system_variables[]=
236236
NULL
237237
};
238238

239-
maria_declare_plugin(ngram_parser)
239+
maria_declare_plugin(fulltext_ngram)
240240
{
241241
MYSQL_FTPARSER_PLUGIN, // Type.
242242
&ngram_parser_descriptor, // Descriptor.
@@ -250,6 +250,6 @@ maria_declare_plugin(ngram_parser)
250250
NULL, // Status variables.
251251
ngram_system_variables, // System variables.
252252
"1.0", // String version representation.
253-
MariaDB_PLUGIN_MATURITY_EXPERIMENTAL, // Maturity.
253+
MariaDB_PLUGIN_MATURITY_BETA, // Maturity.
254254
}
255255
maria_declare_plugin_end;

0 commit comments

Comments
 (0)