Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mysql-test/collections/buildbot_suites.bat
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ innodb,^
binlog_in_engine,^
versioning,^
plugins,^
ngram,^
mariabackup,^
roles,^
auth_gssapi,^
Expand Down
103 changes: 103 additions & 0 deletions mysql-test/main/fulltext_exclude_phrase.result
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;
52 changes: 52 additions & 0 deletions mysql-test/main/fulltext_exclude_phrase.test
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;
}
2 changes: 1 addition & 1 deletion mysql-test/main/mysqld--help.test
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ perl;
wsrep file-key-management cracklib-password-check user-variables
provider-bzip2 provider-lzma provider-lzo caching-sha2-password
thread-pool-groups thread-pool-queues thread-pool-stats
thread-pool-waits hashicorp provider gssapi parsec videx/;
thread-pool-waits hashicorp provider gssapi parsec videx ngram/;
Comment thread
gkodinov marked this conversation as resolved.
Resolved

# And substitute the content some environment variables with their
# names:
Expand Down
50 changes: 50 additions & 0 deletions mysql-test/suite/innodb_fts/r/alter_parser.result
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;
42 changes: 42 additions & 0 deletions mysql-test/suite/innodb_fts/r/innodb_fts_plugin.result
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ id title body
SELECT * FROM articles WHERE
MATCH(title, body) AGAINST('will go');
id title body
3 Optimizing MySQL In this tutorial we will show ...
5 Go MySQL Tricks How to use full text search engine
# Test plugin parser tokenizer difference
SELECT * FROM articles WHERE
MATCH(title, body) AGAINST('full-text');
Expand Down Expand Up @@ -79,6 +81,8 @@ id title body
SELECT * FROM articles WHERE
MATCH(title, body) AGAINST('will go');
id title body
3 Optimizing MySQL In this tutorial we will show ...
5 Go MySQL Tricks How to use full text search engine
# Test plugin parser tokenizer difference
SELECT * FROM articles WHERE
MATCH(title, body) AGAINST('full-text');
Expand Down Expand Up @@ -200,6 +204,8 @@ id title body
SELECT * FROM articles WHERE
MATCH(title, body) AGAINST('will go');
id title body
3 Optimizing MySQL In this tutorial we will show ...
5 Go MySQL Tricks How to use full text search engine
# Test plugin parser tokenizer difference
SELECT * FROM articles WHERE
MATCH(title, body) AGAINST('full-text');
Expand All @@ -219,3 +225,39 @@ ERROR HY000: Function 'simple_parser' is not defined
DROP TABLE articles;
UNINSTALL PLUGIN simple_parser;
ERROR 42000: PLUGIN simple_parser does not exist
#
# MDEV-35967 Server crashes when creating a fulltext index with
# simple_parser plugin
#
INSTALL PLUGIN simple_parser SONAME 'mypluglib';
CREATE TABLE t (title CHAR, body TEXT) ENGINE=InnoDB;
INSERT INTO t VALUES ('a', 'xyz xyz'), ('b', 'xyz uvw xyz uvw');
ALTER TABLE t ADD FULLTEXT INDEX (title, body) WITH PARSER simple_parser;
SELECT * FROM t WHERE MATCH(title, body) AGAINST('xyz');
title body
a xyz xyz
b xyz uvw xyz uvw
DROP TABLE t;
UNINSTALL PLUGIN simple_parser;
#
# MDEV-10267 Add "ngram" support to MariaDB
# Tokens of a parser plugin that do not fit into the index (more than
# 84 characters) are skipped, when the index is built and when rows
# are added
#
INSTALL PLUGIN simple_parser SONAME 'mypluglib';
CREATE TABLE t (a TEXT) ENGINE=InnoDB CHARSET=latin1;
INSERT INTO t VALUES (CONCAT(REPEAT('x', 400), ' short'));
ALTER TABLE t ADD FULLTEXT(a) WITH PARSER simple_parser;
INSERT INTO t VALUES (CONCAT(REPEAT('y', 85), ' ', REPEAT('z', 84)));
SELECT LEFT(a, 5) FROM t WHERE MATCH(a) AGAINST('short');
LEFT(a, 5)
xxxxx
SELECT COUNT(*) FROM t WHERE MATCH(a) AGAINST(REPEAT('y', 85));
COUNT(*)
0
SELECT LEFT(a, 5) FROM t WHERE MATCH(a) AGAINST(REPEAT('z', 84));
LEFT(a, 5)
yyyyy
DROP TABLE t;
UNINSTALL PLUGIN simple_parser;
Loading
Loading