diff options
Diffstat (limited to 'mysql-test/suite/innodb_fts')
84 files changed, 20366 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb_fts/r/basic.result b/mysql-test/suite/innodb_fts/r/basic.result new file mode 100644 index 00000000..a8ab0c04 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/basic.result @@ -0,0 +1,313 @@ +CREATE TEMPORARY TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +) ENGINE=InnoDB; +ERROR HY000: Cannot create FULLTEXT index on temporary InnoDB table +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +ANALYZE TABLE articles; +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT COUNT(*) FROM articles +WHERE MATCH (title,body) +AGAINST ('database' IN NATURAL LANGUAGE MODE); +COUNT(*) +2 +SELECT * FROM articles +WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT COUNT(IF(MATCH (title,body) +AGAINST ('database' IN NATURAL LANGUAGE MODE), 1, NULL)) +AS count FROM articles; +count +2 +SELECT id, body, MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE) AS score +FROM articles; +id body score +1 DBMS stands for DataBase ... 0.22764469683170319 +2 After you went through a ... 0 +3 In this tutorial we will show ... 0 +4 1. Never run mysqld as root. 2. ... 0 +5 In the following database comparison ... 0.22764469683170319 +6 When configured properly, MySQL ... 0 +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('MySQL' IN NATURAL LANGUAGE MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('DBMS Security' IN BOOLEAN MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL +YourSQL' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL YourSQL' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL ~YourSQL' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('t*' IN BOOLEAN MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('MY*' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('ru*' IN BOOLEAN MODE); +id title body +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+ MySQL >Well < stands' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +6 MySQL Security When configured properly, MySQL ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +1 MySQL Tutorial DBMS stands for DataBase ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+ MySQL - (Well stands)' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((((Security)))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR HY000: Table handler out of memory +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('((((((((((((((((((((((((((((((((Security))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((vs))))))))))))))))))))))))))))))),(((to)))' + IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('((((((((((((((((((((((((((((((((Security)))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR 42000: syntax error, unexpected $end +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((((Security))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR 42000: syntax error, unexpected $end +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+ MySQL + (>Well < stands)' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +1 MySQL Tutorial DBMS stands for DataBase ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('YourSQL + (+MySQL - (Tricks Security))' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('(+MySQL - (Tricks Security)) - YourSQL' IN BOOLEAN MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysql - Security&DBMS' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysql - (Security DBMS)' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST (' - Security&DBMS + YourSQL' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('+YourSQL - Security&DBMS' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT COUNT(*) FROM articles +WHERE MATCH (title,body) +AGAINST ('database' WITH QUERY EXPANSION); +COUNT(*) +6 +INSERT INTO articles (title,body) VALUES +('test query expansion','for database ...'); +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('test' WITH QUERY EXPANSION); +id title body +7 test query expansion for database ... +1 MySQL Tutorial DBMS stands for DataBase ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"following comparison"@3' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"following comparison"@2' IN BOOLEAN MODE); +id title body +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"following database"' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +INSERT INTO articles (title,body) VALUES +('test proximity search, test, proximity and phrase', +'search, with proximity innodb'); +INSERT INTO articles (title,body) VALUES +('test my proximity fts new search, test, proximity and phrase', +'search, with proximity innodb'); +INSERT INTO articles (title,body) VALUES +('test more of proximity fts search, test, more proximity and phrase', +'search, with proximity innodb'); +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"proximity search"@3' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"proximity search"@2' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"proximity search"@5' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@5' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@1' IN BOOLEAN MODE); +id title body +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@4' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@3' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"more test proximity"@4' IN BOOLEAN MODE); +id title body +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"more test proximity"@3' IN BOOLEAN MODE); +id title body +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"more test proximity"' IN BOOLEAN MODE); +id title body +drop table articles; +# +# Bug #22679185 INVALID INNODB FTS DOC ID DURING INSERT +# +create table t1 (f1 int not null primary key, f2 varchar(100), +FTS_DOC_ID bigint(20) unsigned not null, +unique key `FTS_DOC_ID_INDEX` (`FTS_DOC_ID`), +fulltext key (f2))engine=innodb; +insert into t1 values(1, "This is the first record", 20000); +insert into t1 values(2, "This is the second record", 40000); +select FTS_DOC_ID from t1; +FTS_DOC_ID +20000 +40000 +drop table t1; +create table t1 (f1 int not null primary key, f2 varchar(100), +FTS_DOC_ID bigint(20) unsigned not null auto_increment, +unique key `FTS_DOC_ID_INDEX` (`FTS_DOC_ID`), +fulltext key (f2))engine=innodb; +set auto_increment_increment = 65535; +insert into t1(f1, f2) values(1, "This is the first record"); +insert into t1(f1, f2) values(2, "This is the second record"); +insert into t1(f1, f2) values(3, "This is the third record"); +select FTS_DOC_ID from t1; +FTS_DOC_ID +1 +65536 +131071 +drop table t1; +CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), FULLTEXT(title)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL, NULL), (20030101000000, 20030102000000); +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/r/bug_32831765.result b/mysql-test/suite/innodb_fts/r/bug_32831765.result new file mode 100644 index 00000000..1d6ea187 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/bug_32831765.result @@ -0,0 +1,132 @@ +call mtr.add_suppression("InnoDB: Total InnoDB FTS size .* for the table .* exceeds the innodb_ft_cache_size .*"); +# +# Bug#32831765 SERVER HITS OOM CONDITION WHEN LOADING TWO +# INNODB TABLES WITH FTS INDEXES +# +create table t1 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text, +`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07` +text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text, +`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18` +text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text, +`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29` +text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY +(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY +(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY +(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY +(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY +(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY +(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY +(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY +(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY +(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY +(`col29`), FULLTEXT KEY (`col30`)) engine=innodb; +create table t2 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text, +`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07` +text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text, +`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18` +text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text, +`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29` +text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY +(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY +(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY +(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY +(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY +(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY +(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY +(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY +(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY +(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY +(`col29`), FULLTEXT KEY (`col30`)) engine=innodb; +create table t3 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text, +`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07` +text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text, +`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18` +text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text, +`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29` +text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY +(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY +(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY +(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY +(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY +(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY +(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY +(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY +(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY +(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY +(`col29`), FULLTEXT KEY (`col30`)) engine=innodb; +create table t4 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text, +`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07` +text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text, +`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18` +text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text, +`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29` +text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY +(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY +(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY +(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY +(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY +(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY +(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY +(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY +(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY +(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY +(`col29`), FULLTEXT KEY (`col30`)) engine=innodb; +#create procedure to inset into the table. +CREATE PROCEDURE `proc_insert`(IN tab_name VARCHAR(40)) +BEGIN +DECLARE i INT DEFAULT 1; +SET @insert_tbl =CONCAT('INSERT INTO ', tab_name, '( `col01`, `col02`, + `col03`, `col04`, `col05`, `col06`, `col07`, `col08`, `col09`, `col10`, + `col11`, `col12`, `col13`, `col14`, `col15`, `col16`, `col17`, `col18`, + `col19`, `col20`, `col21`, `col22`, `col23`, `col24`, `col25`, `col26`, + `col27`, `col28`, `col29`, `col30`) + VALUES ( MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), + MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), + MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), + MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), + MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), + MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), + MD5(RAND()))'); +PREPARE ins_stmt FROM @insert_tbl; +while (i <= 2000) DO +EXECUTE ins_stmt; +SET i = i + 1; +END WHILE; +DEALLOCATE PREPARE ins_stmt; +END | +SET @save_dbug= @@GLOBAL.debug_dbug; +SET GLOBAL debug_dbug="+d,fts_optimize_wq_count_check"; +connect con1,localhost,root,,; +call proc_insert('t1'); +connect con2,localhost,root,,; +call proc_insert('t1'); +connect con3,localhost,root,,; +call proc_insert('t2'); +connect con4,localhost,root,,; +call proc_insert('t2'); +connect con5,localhost,root,,; +call proc_insert('t3'); +connect con6,localhost,root,,; +call proc_insert('t3'); +connect con7,localhost,root,,; +call proc_insert('t4'); +connection default; +call proc_insert('t4'); +SET GLOBAL debug_dbug= @save_dbug; +connection con1; +disconnect con1; +connection con2; +disconnect con2; +connection con3; +disconnect con3; +connection con4; +disconnect con4; +connection con5; +disconnect con5; +connection con6; +disconnect con6; +connection con7; +disconnect con7; +connection default; +DROP TABLE t1,t2,t3,t4; +DROP PROCEDURE proc_insert; diff --git a/mysql-test/suite/innodb_fts/r/concurrent_insert.result b/mysql-test/suite/innodb_fts/r/concurrent_insert.result new file mode 100644 index 00000000..bc47511b --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/concurrent_insert.result @@ -0,0 +1,63 @@ +CREATE TABLE t1(a VARCHAR(5),FULLTEXT KEY(a)) ENGINE=InnoDB; +SET DEBUG_SYNC = 'get_next_FTS_DOC_ID SIGNAL prepared WAIT_FOR race'; +REPLACE INTO t1(a) values('aaa'); +connect dml, localhost, root, ,; +SET DEBUG_SYNC = 'now WAIT_FOR prepared'; +REPLACE INTO t1(a) VALUES('aaa'); +SET DEBUG_SYNC = 'now SIGNAL race'; +disconnect dml; +connection default; +SET DEBUG_SYNC = 'RESET'; +DROP TABLE t1; +# +# MDEV-19529 InnoDB hang on DROP FULLTEXT INDEX +# +CREATE TABLE t1(f1 CHAR(100), FULLTEXT(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES('test'); +CREATE TABLE t2 (f1 char(100), FULLTEXT idx1(f1))ENGINE=InnoDB; +INSERT INTO t2 VALUES('mariadb'); +connection default; +SET @saved_dbug = @@GLOBAL.debug_dbug; +SET GLOBAL debug_dbug ='+d,fts_instrument_sync_request,ib_optimize_wq_hang'; +SET DEBUG_SYNC= 'fts_instrument_sync_request + SIGNAL drop_index_start WAIT_FOR sync_op'; +INSERT INTO t1 VALUES('Keyword'); +connect con1,localhost,root,,,; +SET DEBUG_SYNC='now WAIT_FOR drop_index_start'; +SET DEBUG_SYNC= 'norebuild_fts_drop SIGNAL sync_op WAIT_FOR fts_drop_index'; +ALTER TABLE t2 drop index idx1; +connection default; +set DEBUG_SYNC= 'now SIGNAL fts_drop_index'; +connection con1; +drop table t1, t2; +connection default; +SET @@GLOBAL.debug_dbug = @saved_dbug; +disconnect con1; +# +# MDEV-25984 Assertion `max_doc_id > 0' failed in fts_init_doc_id() +# +call mtr.add_suppression("InnoDB: \\(Lock wait timeout\\) while getting next doc id for table `test`.`t1`"); +CREATE TABLE t1(f1 CHAR(100), f2 INT, fulltext(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES("mariadb", 1), ("innodb", 1); +# restart +SET DEBUG_SYNC='innodb_rollback_after_fts_lock SIGNAL insert_dml WAIT_FOR ddl_continue'; +ALTER TABLE t1 ADD UNIQUE INDEX(f2); +connect con1,localhost,root,,,; +SET DEBUG_SYNC='now WAIT_FOR insert_dml'; +SET DEBUG_SYNC='fts_cmp_set_sync_doc_id_retry SIGNAL ddl_continue WAIT_FOR dml_finish'; +INSERT INTO t1 VALUES("index", 2); +connection default; +ERROR 23000: Duplicate entry '1' for key 'f2' +SET DEBUG_SYNC="now SIGNAL dml_finish"; +connection con1; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` char(100) DEFAULT NULL, + `f2` int(11) DEFAULT NULL, + FULLTEXT KEY `f1` (`f1`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +connection default; +disconnect con1; +DROP TABLE t1; +set DEBUG_SYNC=RESET; diff --git a/mysql-test/suite/innodb_fts/r/crash_recovery.result b/mysql-test/suite/innodb_fts/r/crash_recovery.result new file mode 100644 index 00000000..c6fc9dfa --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/crash_recovery.result @@ -0,0 +1,171 @@ +FLUSH TABLES; +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +) ENGINE=InnoDB; +DROP INDEX title ON articles; +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +BEGIN; +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...'); +# Make durable the AUTO_INCREMENT in the above incomplete transaction. +connect ddl1, localhost, root,,; +CREATE TABLE t1(a TEXT,b TEXT,FULLTEXT INDEX(a)) ENGINE=InnoDB; +ALTER TABLE t1 ADD FULLTEXT INDEX(b); +connection default; +connect ddl2, localhost, root,,; +CREATE TABLE t2(a TEXT,b TEXT,FULLTEXT INDEX(a)) ENGINE=InnoDB; +ALTER TABLE t2 DROP INDEX a, ADD FULLTEXT INDEX(b), FORCE; +connection default; +connect ddl3, localhost, root,,; +CREATE TABLE t3(a TEXT,b TEXT,FULLTEXT INDEX(a)) ENGINE=InnoDB; +ALTER TABLE t3 DROP INDEX a, ADD FULLTEXT INDEX(b), ALGORITHM=COPY; +connection default; +# restart +disconnect ddl1; +disconnect ddl2; +disconnect ddl3; +InnoDB 0 transactions not purged +CHECK TABLE t1,t2,t3; +Table Op Msg_type Msg_text +test.t1 check status OK +test.t2 check status OK +test.t3 check status OK +DROP TABLE t1,t2,t3; +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...'); +CREATE FULLTEXT INDEX idx ON articles (title,body); +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +5 MySQL vs. YourSQL In the following database comparison ... +8 MySQL Tutorial DBMS stands for DataBase ... +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +connect dml, localhost, root,,; +BEGIN; +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...'); +connection default; +# Make durable the AUTO_INCREMENT in the above incomplete transaction. +connect flush_redo_log,localhost,root,,; +SET GLOBAL innodb_flush_log_at_trx_commit=1; +SET SQL_MODE = NO_AUTO_VALUE_ON_ZERO; +BEGIN; +UPDATE articles SET id=0 WHERE id=1; +UPDATE articles SET id=1 WHERE id=0; +COMMIT; +disconnect flush_redo_log; +connection default; +# restart +disconnect dml; +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...'); +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +5 MySQL vs. YourSQL In the following database comparison ... +8 MySQL Tutorial DBMS stands for DataBase ... +9 MySQL Tutorial DBMS stands for DataBase ... +13 MySQL vs. YourSQL In the following database comparison ... +16 MySQL Tutorial DBMS stands for DataBase ... +DROP TABLE articles; +CREATE TABLE articles ( +id int PRIMARY KEY, +FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +title VARCHAR(200), +body TEXT +) ENGINE=InnoDB; +CREATE FULLTEXT INDEX idx1 on articles (title, body); +INSERT INTO articles VALUES +(1, 10, 'MySQL Tutorial','DBMS stands for DataBase ...') , +(2, 1, 'How To Use MySQL Well','After you went through a ...'), +(3, 2, 'Optimizing MySQL','In this tutorial we will show ...'), +(4, 11, '1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +(5, 6, 'MySQL vs. YourSQL','In the following database comparison ...'), +(7, 4, 'MySQL Security','When configured properly, MySQL ...'); +connect dml, localhost, root,,; +BEGIN; +INSERT INTO articles VALUES +(100, 200, 'MySQL Tutorial','DBMS stands for DataBase ...'); +connect dml2, localhost, root,,; +# +# MDEV-19073 FTS row mismatch after crash recovery +# +CREATE TABLE mdev19073(id SERIAL, title VARCHAR(200), body TEXT, +FULLTEXT(title,body)) ENGINE=InnoDB; +INSERT INTO mdev19073 (title, body) VALUES +('MySQL Tutorial', 'DBMS stands for Database...'); +CREATE FULLTEXT INDEX idx ON mdev19073(title, body); +CREATE TABLE mdev19073_2 LIKE mdev19073; +INSERT INTO mdev19073_2 (title, body) VALUES +('MySQL Tutorial', 'DBMS stands for Database...'); +INSERT INTO mdev19073 (title, body) VALUES +('MariaDB Tutorial', 'DB means Database ...'); +INSERT INTO mdev19073_2 (title, body) VALUES +('MariaDB Tutorial', 'DB means Database ...'); +SELECT * FROM mdev19073 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for Database... +2 MariaDB Tutorial DB means Database ... +SELECT * FROM mdev19073_2 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for Database... +2 MariaDB Tutorial DB means Database ... +connection default; +# restart +disconnect dml; +disconnect dml2; +INSERT INTO articles VALUES (8, 12, 'MySQL Tutorial','DBMS stands for DataBase ...'); +SELECT * FROM articles WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id FTS_DOC_ID title body +3 2 Optimizing MySQL In this tutorial we will show ... +1 10 MySQL Tutorial DBMS stands for DataBase ... +8 12 MySQL Tutorial DBMS stands for DataBase ... +DROP TABLE articles; +SELECT * FROM mdev19073 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for Database... +2 MariaDB Tutorial DB means Database ... +SELECT * FROM mdev19073_2 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for Database... +2 MariaDB Tutorial DB means Database ... +DROP TABLE mdev19073, mdev19073_2; +# +# MDEV-28706 Redundant InnoDB table fails during alter +# +SET @@global.innodb_file_per_table = 0; +CREATE TABLE t1 ( +col_int INTEGER, col_text TEXT, +col_text_1 TEXT +) ENGINE = InnoDB ROW_FORMAT = Redundant ; +ALTER TABLE t1 ADD FULLTEXT KEY `ftidx` ( col_text ) ; +INSERT INTO t1 VALUES ( 1255, "mariadb", "InnoDB"); +# restart +ALTER TABLE t1 ADD FULLTEXT(col_text_1); +DROP TABLE t1; +SELECT * FROM information_schema.innodb_sys_tables WHERE name LIKE 'test/%'; +TABLE_ID NAME FLAG N_COLS SPACE ROW_FORMAT ZIP_PAGE_SIZE SPACE_TYPE diff --git a/mysql-test/suite/innodb_fts/r/create.result b/mysql-test/suite/innodb_fts/r/create.result new file mode 100644 index 00000000..4334344a --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/create.result @@ -0,0 +1,213 @@ +SET NAMES utf8mb4; +# +# MDEV-11233 CREATE FULLTEXT INDEX with a token +# longer than 127 bytes crashes server +# +CREATE TABLE t(t TEXT CHARACTER SET utf8mb3) ENGINE=InnoDB; +INSERT INTO t SET t=REPEAT(CONCAT(REPEAT(_utf8mb3 0xE0B987, 4), REPEAT(_utf8mb3 0xE0B989, 5)), 5); +INSERT INTO t SET t=REPEAT(_utf8 0xefbc90,84); +INSERT INTO t SET t=REPEAT('befor',17); +INSERT INTO t SET t='BeforeTheIndexCreation'; +CREATE FULLTEXT INDEX ft ON t(t); +INSERT INTO t SET t='this was inserted after creating the index'; +INSERT INTO t SET t=REPEAT(_utf8 0xefbc91,84); +INSERT INTO t SET t=REPEAT('after',17); +INSERT INTO t SET t=REPEAT(_utf8mb3 0xe794b2e9aaa8e69687, 15); +# The data below is not 3-byte UTF-8, but 4-byte chars. +INSERT IGNORE INTO t SET t=REPEAT(_utf8mb4 0xf09f9695, 84); +Warnings: +Warning 1366 Incorrect string value: '\xF0\x9F\x96\x95\xF0\x9F...' for column `test`.`t`.`t` at row 1 +INSERT IGNORE INTO t SET t=REPEAT(_utf8mb4 0xf09f9696, 85); +Warnings: +Warning 1366 Incorrect string value: '\xF0\x9F\x96\x96\xF0\x9F...' for column `test`.`t`.`t` at row 1 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST +(REPEAT(CONCAT(REPEAT(_utf8mb3 0xE0B987, 4), REPEAT(_utf8mb3 0xE0B989, 5)), 5)); +COUNT(*) +1 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST ('BeforeTheIndexCreation'); +COUNT(*) +1 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT('befor',17)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST ('after'); +COUNT(*) +1 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT('after',17)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc90, 83)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc90, 84)); +COUNT(*) +1 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc90, 85)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc91, 83)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc91, 84)); +COUNT(*) +1 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc91, 85)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9695, 83)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9695, 84)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9696, 84)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9696, 85)); +COUNT(*) +0 +SELECT * FROM t; +t +็็็็้้้้้็็็็้้้้้็็็็้้้้้็็็็้้้้้็็็็้้้้้ +ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ +beforbeforbeforbeforbeforbeforbeforbeforbeforbeforbeforbeforbeforbeforbeforbeforbefor +BeforeTheIndexCreation +this was inserted after creating the index +111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +afterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafter +甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文 +???????????????????????????????????????????????????????????????????????????????????? +????????????????????????????????????????????????????????????????????????????????????? +SELECT len,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS where name='word' GROUP BY len; +len COUNT(*) +252 6 +DROP TABLE t; +CREATE TABLE t(t TEXT CHARACTER SET utf8mb4) ENGINE=InnoDB; +INSERT INTO t SET t=REPEAT(_utf8mb3 0xe794b2e9aaa8e69687, 15); +INSERT INTO t SET t=REPEAT(_utf8 0xefbc90,84); +INSERT INTO t SET t=REPEAT('befor',17); +INSERT INTO t SET t='BeforeTheIndexCreation'; +CREATE FULLTEXT INDEX ft ON t(t); +INSERT INTO t SET t='this was inserted after creating the index'; +INSERT INTO t SET t=REPEAT(_utf8 0xefbc91,84); +INSERT INTO t SET t=REPEAT('after',17); +INSERT INTO t SET t=REPEAT(concat(repeat(_utf8mb3 0xE0B987, 4), repeat(_utf8mb3 0xE0B989, 5)), 5); +INSERT INTO t SET t=REPEAT(_utf8mb4 0xf09f9695, 84); +# The token below exceeds the 84-character limit. +INSERT INTO t SET t=REPEAT(_utf8mb4 0xf09f9696, 85); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb3 0xe794b2e9aaa8e69687, 15)); +COUNT(*) +1 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST ('BeforeTheIndexCreation'); +COUNT(*) +1 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT('befor',17)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST ('after'); +COUNT(*) +1 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT('after',17)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc90, 83)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc90, 84)); +COUNT(*) +1 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc90, 85)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc91, 83)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc91, 84)); +COUNT(*) +1 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc91, 85)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9695, 83)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9695, 84)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9696, 84)); +COUNT(*) +0 +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9696, 85)); +COUNT(*) +0 +SELECT * FROM t; +t +甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文甲骨文 +ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ +beforbeforbeforbeforbeforbeforbeforbeforbeforbeforbeforbeforbeforbeforbeforbeforbefor +BeforeTheIndexCreation +this was inserted after creating the index +111111111111111111111111111111111111111111111111111111111111111111111111111111111111 +afterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafterafter +็็็็้้้้้็็็็้้้้้็็็็้้้้้็็็็้้้้้็็็็้้้้้ +🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕🖕 +🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖🖖 +SELECT len,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS where name='word' GROUP BY len; +len COUNT(*) +336 6 +DROP TABLE t; +CREATE TABLE t(t TEXT CHARACTER SET latin1, FULLTEXT INDEX(t)) +ENGINE=InnoDB; +SELECT len,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS where name='word' GROUP BY len; +len COUNT(*) +84 6 +DROP TABLE t; +# +# MDEV-17923 Assertion memcmp(field, field_ref_zero, 7) failed in +# trx_undo_page_report_modify upon optimizing table +# under innodb_optimize_fulltext_only +# +CREATE TABLE t1 (f1 TEXT, f2 TEXT, FULLTEXT KEY (f2)) ENGINE=InnoDB; +INSERT INTO t1 (f1) VALUES ('foo'),('bar'); +DELETE FROM t1 LIMIT 1; +ALTER TABLE t1 ADD FULLTEXT KEY (f1); +SET @optimize_fulltext.save= @@innodb_optimize_fulltext_only; +SET GLOBAL innodb_optimize_fulltext_only= 1; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +DROP TABLE t1; +SET GLOBAL innodb_optimize_fulltext_only= @optimize_fulltext.save; +# +# MDEV-24403 Segfault on CREATE TABLE with explicit FTS_DOC_ID_INDEX by multiple fields +# +create table t1 ( +f1 int, f2 text, +FTS_DOC_ID bigint unsigned not null, +unique key FTS_DOC_ID_INDEX(FTS_DOC_ID, f1), +fulltext (f2)) +engine=innodb; +ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index +# +# MDEV-26938 Support descending indexes internally in InnoDB +# +CREATE TABLE t1(a INT PRIMARY KEY, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +UNIQUE KEY FTS_DOC_ID_INDEX(FTS_DOC_ID DESC), FULLTEXT(b)) +ENGINE=InnoDB; +ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index +CREATE TABLE t1(a INT PRIMARY KEY, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +UNIQUE KEY FTS_DOC_ID_INDEX(FTS_DOC_ID DESC)) ENGINE=InnoDB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) NOT NULL, + `b` text DEFAULT NULL, + `FTS_DOC_ID` bigint(20) unsigned NOT NULL, + PRIMARY KEY (`a`), + UNIQUE KEY `FTS_DOC_ID_INDEX` (`FTS_DOC_ID` DESC) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +ALTER TABLE t1 ADD FULLTEXT INDEX(b), ALGORITHM=INPLACE; +ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index +ALTER TABLE t1 ADD FULLTEXT INDEX(b), ALGORITHM=COPY; +ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/r/ft_result_cache_limit.result b/mysql-test/suite/innodb_fts/r/ft_result_cache_limit.result new file mode 100644 index 00000000..2dbdd5a0 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/ft_result_cache_limit.result @@ -0,0 +1,39 @@ +# +# Bug 1634932: Assertion failure in thread x in +# file fts0que.cc +# +SET @saved_innodb_ft_result_cache_limit= @@global.innodb_ft_result_cache_limit; +CREATE TABLE `t1` ( +`FTS_DOC_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, +`text_content` MEDIUMTEXT, PRIMARY KEY (`FTS_DOC_ID`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +CREATE UNIQUE INDEX FTS_DOC_ID_INDEX ON t1(FTS_DOC_ID); +SET autocommit=0; +CREATE PROCEDURE populate_t1() +BEGIN +DECLARE i INT DEFAULT 1; +WHILE (i <= 250) DO +INSERT INTO t1 (text_content) VALUES ("some_text_1234 aaa"); +SET i = i + 1; +END WHILE; +END// +CALL populate_t1; +SET autocommit=1; +SET SESSION debug="+d,fts_instrument_result_cache_limit"; +Warnings: +Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead +ALTER TABLE t1 ADD FULLTEXT INDEX `text_content_idx` (`text_content`); +SELECT FTS_DOC_ID, text_content +FROM t1 +WHERE MATCH text_content AGAINST ('+some_text_1234' IN BOOLEAN MODE); +ERROR HY000: Table handler out of memory +UPDATE t1 +SET text_content='some_text_12345' +where MATCH text_content AGAINST ('+some_text_1234' IN BOOLEAN MODE); +ERROR HY000: Table handler out of memory +DELETE FROM t1 +WHERE MATCH text_content AGAINST ('+some_text_1234' IN BOOLEAN MODE); +ERROR HY000: Table handler out of memory +SET GLOBAL innodb_ft_result_cache_limit = @saved_innodb_ft_result_cache_limit; +DROP TABLE t1; +DROP PROCEDURE populate_t1; diff --git a/mysql-test/suite/innodb_fts/r/fts_kill_query.result b/mysql-test/suite/innodb_fts/r/fts_kill_query.result new file mode 100644 index 00000000..53ad9b3a --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/fts_kill_query.result @@ -0,0 +1,9 @@ +CREATE TABLE t1 (a VARCHAR(7), b text, FULLTEXT KEY idx (a,b)) ENGINE=InnoDB; +COMMIT; +SELECT COUNT(*) FROM t1 +WHERE MATCH (a,b) AGAINST ('foo bar' IN BOOLEAN MODE); +connect con1,localhost,root,,; +KILL QUERY @id; +disconnect con1; +connection default; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/r/fulltext.result b/mysql-test/suite/innodb_fts/r/fulltext.result new file mode 100644 index 00000000..32dc87da --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/fulltext.result @@ -0,0 +1,786 @@ +CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'), +('Full-text indexes', 'are called collections'), +('Only MyISAM tables','support collections'), +('Function MATCH ... AGAINST()','is used to do a search'), +('Full-text search in MySQL', 'implements vector space model'); +ANALYZE TABLE t1; +SHOW INDEX FROM t1; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored +t1 1 a 1 a NULL NULL NULL NULL YES FULLTEXT NO +t1 1 a 2 b NULL NULL NULL NULL YES FULLTEXT NO +select * from t1 where MATCH(a,b) AGAINST ("collections"); +a b +Full-text indexes are called collections +Only MyISAM tables support collections +explain extended select * from t1 where MATCH(a,b) AGAINST ("collections"); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 fulltext a a 0 1 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (match `test`.`t1`.`a`,`test`.`t1`.`b` against ('collections')) +select * from t1 where MATCH(a,b) AGAINST ("indexes"); +a b +Full-text indexes are called collections +select * from t1 where MATCH(a,b) AGAINST ("indexes collections"); +a b +Full-text indexes are called collections +Only MyISAM tables support collections +select * from t1 where MATCH(a,b) AGAINST ("only"); +a b +Only MyISAM tables support collections +select * from t1 where MATCH(a,b) AGAINST ("collections" WITH QUERY EXPANSION); +a b +Only MyISAM tables support collections +Full-text indexes are called collections +MySQL has now support for full-text search +Full-text search in MySQL implements vector space model +select * from t1 where MATCH(a,b) AGAINST ("indexes" WITH QUERY EXPANSION); +a b +Full-text indexes are called collections +Only MyISAM tables support collections +MySQL has now support for full-text search +Full-text search in MySQL implements vector space model +select * from t1 where MATCH(a,b) AGAINST ("indexes collections" WITH QUERY EXPANSION); +a b +Only MyISAM tables support collections +Full-text indexes are called collections +MySQL has now support for full-text search +Full-text search in MySQL implements vector space model +select * from t1 where MATCH(a,b) AGAINST ("indexes" IN NATURAL LANGUAGE MODE); +a b +Full-text indexes are called collections +select * from t1 where MATCH(a,b) AGAINST ("indexes" IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION); +a b +Full-text indexes are called collections +Only MyISAM tables support collections +MySQL has now support for full-text search +Full-text search in MySQL implements vector space model +select * from t1 where MATCH(a,b) AGAINST ("indexes" IN BOOLEAN MODE WITH QUERY EXPANSION); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'WITH QUERY EXPANSION)' at line 1 +explain select * from t1 where MATCH(a,b) AGAINST ("collections"); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 1 Using where +explain select * from t1 where MATCH(a,b) AGAINST ("collections")>0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 1 Using where +explain select * from t1 where MATCH(a,b) AGAINST ("collections")>1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 1 Using where +explain select * from t1 where MATCH(a,b) AGAINST ("collections")>=0; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where +explain select * from t1 where MATCH(a,b) AGAINST ("collections")>=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 1 Using where +explain select * from t1 where 0<MATCH(a,b) AGAINST ("collections"); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 1 Using where +explain select * from t1 where 1<MATCH(a,b) AGAINST ("collections"); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 1 Using where +explain select * from t1 where 0<=MATCH(a,b) AGAINST ("collections"); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where +explain select * from t1 where 1<=MATCH(a,b) AGAINST ("collections"); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 1 Using where +explain select * from t1 where MATCH(a,b) AGAINST ("collections")>0 and a like '%ll%'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 1 Using where +select * from t1 where MATCH(a,b) AGAINST("support -collections" IN BOOLEAN MODE); +a b +MySQL has now support for full-text search +explain extended select * from t1 where MATCH(a,b) AGAINST("support -collections" IN BOOLEAN MODE); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 fulltext a a 0 1 100.00 Using where +Warnings: +Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (match `test`.`t1`.`a`,`test`.`t1`.`b` against ('support -collections' in boolean mode)) +select * from t1 where MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE); +a b +Only MyISAM tables support collections +MySQL has now support for full-text search +Full-text indexes are called collections +select * from t1 where MATCH(a,b) AGAINST("support +collections" IN BOOLEAN MODE); +a b +Only MyISAM tables support collections +Full-text indexes are called collections +select * from t1 where MATCH(a,b) AGAINST("sear*" IN BOOLEAN MODE); +a b +MySQL has now support for full-text search +Function MATCH ... AGAINST() is used to do a search +Full-text search in MySQL implements vector space model +select * from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +a b +Only MyISAM tables support collections +select * from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +a b +MySQL has now support for full-text search +Function MATCH ... AGAINST() is used to do a search +Full-text search in MySQL implements vector space model +select * from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +a b +Full-text search in MySQL implements vector space model +MySQL has now support for full-text search +select * from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +a b +Function MATCH ... AGAINST() is used to do a search +select *, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; +a b x +MySQL has now support for full-text search 0.15835624933242798 +Full-text indexes are called collections 0.15835624933242798 +Only MyISAM tables support collections 0.31671249866485596 +Function MATCH ... AGAINST() is used to do a search 0 +Full-text search in MySQL implements vector space model 0 +select *, MATCH(a,b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; +a b x +MySQL has now support for full-text search 0.15835624933242798 +Full-text indexes are called collections 0.15835624933242798 +Only MyISAM tables support collections 0.31671249866485596 +Function MATCH ... AGAINST() is used to do a search 0 +Full-text search in MySQL implements vector space model 0 +select * from t1 where MATCH a,b AGAINST ("+call* +coll*" IN BOOLEAN MODE); +a b +Full-text indexes are called collections +select * from t1 where MATCH a,b AGAINST ('"support now"' IN BOOLEAN MODE); +a b +select * from t1 where MATCH a,b AGAINST ('"Now sUPPort"' IN BOOLEAN MODE); +a b +MySQL has now support for full-text search +select * from t1 where MATCH a,b AGAINST ('"now support"' IN BOOLEAN MODE); +a b +MySQL has now support for full-text search +select * from t1 where MATCH a,b AGAINST ('"text search" "now support"' IN BOOLEAN MODE); +a b +MySQL has now support for full-text search +Full-text search in MySQL implements vector space model +select * from t1 where MATCH a,b AGAINST ('"text search" -"now support"' IN BOOLEAN MODE); +a b +Full-text search in MySQL implements vector space model +select * from t1 where MATCH a,b AGAINST ('"text search" +"now support"' IN BOOLEAN MODE); +a b +MySQL has now support for full-text search +select * from t1 where MATCH a,b AGAINST ('"text i"' IN BOOLEAN MODE); +a b +select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE); +a b +Full-text indexes are called collections +select * from t1 where MATCH a,b AGAINST ('+(support collections) +foobar*' IN BOOLEAN MODE); +a b +select * from t1 where MATCH a,b AGAINST ('+(+(support collections)) +foobar*' IN BOOLEAN MODE); +a b +select * from t1 where MATCH a,b AGAINST ('+collections -supp* -foobar*' IN BOOLEAN MODE); +a b +Full-text indexes are called collections +select * from t1 where MATCH a,b AGAINST('"space model' IN BOOLEAN MODE); +a b +Full-text search in MySQL implements vector space model +delete from t1 where a like "MySQL%"; +update t1 set a='some test foobar' where MATCH a,b AGAINST ('model'); +delete from t1 where MATCH(a,b) AGAINST ("indexes"); +select * from t1; +a b +Only MyISAM tables support collections +Function MATCH ... AGAINST() is used to do a search +some test foobar implements vector space model +drop table t1; +create table t1 (a varchar(200) not null, fulltext (a)) engine = innodb; +insert t1 values ("aaa10 bbb20"), ("aaa20 bbb15"), ("aaa30 bbb10"); +select * from t1 where match a against ("+aaa* +bbb*" in boolean mode); +a +aaa10 bbb20 +aaa20 bbb15 +aaa30 bbb10 +select * from t1 where match a against ("+aaa* +bbb1*" in boolean mode); +a +aaa20 bbb15 +aaa30 bbb10 +select * from t1 where match a against ("+aaa* +ccc*" in boolean mode); +a +select * from t1 where match a against ("+aaa10 +(bbb*)" in boolean mode); +a +aaa10 bbb20 +select * from t1 where match a against ("+(+aaa* +bbb1*)" in boolean mode); +a +aaa20 bbb15 +aaa30 bbb10 +select * from t1 where match a against ("(+aaa* +bbb1*)" in boolean mode); +a +aaa20 bbb15 +aaa30 bbb10 +drop table t1; +CREATE TABLE t1 ( +id int(11), +ticket int(11), +KEY ti (id), +KEY tit (ticket) +) ENGINE = InnoDB; +INSERT INTO t1 VALUES (2,3),(1,2); +CREATE TABLE t2 ( +ticket int(11), +inhalt text, +KEY tig (ticket), +fulltext index tix (inhalt) +) ENGINE = InnoDB; +INSERT INTO t2 VALUES (1,'foo'),(2,'bar'),(3,'foobar'); +INSERT INTO t1 VALUES (3,3); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +select ticket2.id FROM t2 as ttxt,t2 +INNER JOIN t1 as ticket2 ON ticket2.id = t2.ticket +WHERE ticket2.id = ticket2.ticket and +match(ttxt.inhalt) against ('foobar'); +id +3 +show keys from t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored +t2 1 tig 1 ticket A 3 NULL NULL YES BTREE NO +t2 1 tix 1 inhalt NULL NULL NULL NULL YES FULLTEXT NO +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `ticket` int(11) DEFAULT NULL, + `inhalt` text DEFAULT NULL, + KEY `tig` (`ticket`), + FULLTEXT KEY `tix` (`inhalt`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +select * from t2 where MATCH inhalt AGAINST (NULL); +ticket inhalt +select * from t2 where MATCH inhalt AGAINST ('foobar'); +ticket inhalt +3 foobar +select * from t2 having MATCH inhalt AGAINST ('foobar'); +ticket inhalt +3 foobar +CREATE TABLE t3 (t int(11),i text,fulltext tix (t,i)); +ERROR HY000: Column 't' cannot be part of FULLTEXT index +CREATE TABLE t3 (t int(11),i text, +j varchar(200) CHARACTER SET latin2, +fulltext tix (i,j)); +ERROR HY000: Column 'j' cannot be part of FULLTEXT index +CREATE TABLE t3 ( +ticket int(11), +inhalt text, +KEY tig (ticket), +fulltext index tix (inhalt) +) ENGINE = InnoDB; +select * from t2 where MATCH inhalt AGAINST (t2.inhalt); +ERROR HY000: Incorrect arguments to AGAINST +select * from t2 where MATCH ticket AGAINST ('foobar'); +ERROR HY000: Can't find FULLTEXT index matching the column list +select * from t2,t3 where MATCH (t2.inhalt,t3.inhalt) AGAINST ('foobar'); +ERROR HY000: Incorrect arguments to MATCH +drop table t1,t2,t3; +CREATE TABLE t1 ( +id int(11) auto_increment, +title varchar(100) default '', +PRIMARY KEY (id), +KEY ind5 (title) +) ENGINE = InnoDB; +CREATE FULLTEXT INDEX ft1 ON t1(title); +insert into t1 (title) values ('this is a test'); +select * from t1 where match title against ('test' in boolean mode); +id title +1 this is a test +update t1 set title='this is A test' where id=1; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +update t1 set title='this test once revealed a bug' where id=1; +select * from t1; +id title +1 this test once revealed a bug +update t1 set title=NULL where id=1; +drop table t1; +CREATE TABLE t1 (a int(11), b text, FULLTEXT KEY (b)) ENGINE = InnoDB; +insert into t1 values (1,"I wonder why the fulltext index doesnt work?"); +SELECT * from t1 where MATCH (b) AGAINST ('apples'); +a b +insert into t1 values (2,"fullaaa fullzzz"); +select * from t1 where match b against ('full*' in boolean mode); +a b +1 I wonder why the fulltext index doesnt work? +2 fullaaa fullzzz +drop table t1; +CREATE TABLE t1 ( id int(11) NOT NULL auto_increment primary key, mytext text NOT NULL, FULLTEXT KEY mytext (mytext)) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,'my small mouse'),(2,'la-la-la'),(3,'It is so funny'),(4,'MySQL Tutorial'); +select 8 from t1; +8 +8 +8 +8 +8 +drop table t1; +create table t1 (a text, fulltext key (a)) ENGINE = InnoDB; +insert into t1 values ('aaaa'); +select * from t1 where match (a) against ('aaaa'); +a +aaaa +drop table t1; +create table t1 ( ref_mag text not null, fulltext (ref_mag)) ENGINE = InnoDB; +insert into t1 values ('test'); +select ref_mag from t1 where match ref_mag against ('+test' in boolean mode); +ref_mag +test +alter table t1 change ref_mag ref_mag char (255) not null; +select ref_mag from t1 where match ref_mag against ('+test' in boolean mode); +ref_mag +test +drop table t1; +create table t1 (t1_id int(11) primary key, name varchar(32)) ENGINE = InnoDB; +insert into t1 values (1, 'data1'); +insert into t1 values (2, 'data2'); +create table t2 (t2_id int(11) primary key, t1_id int(11), name varchar(32)) ENGINE = InnoDB; +insert into t2 values (1, 1, 'xxfoo'); +insert into t2 values (2, 1, 'xxbar'); +insert into t2 values (3, 1, 'xxbuz'); +select * from t1 join t2 using(`t1_id`) where match (t1.name, t2.name) against('xxfoo' in boolean mode); +ERROR HY000: Incorrect arguments to MATCH +select * from t2 where match name against ('*a*b*c*d*e*f*' in boolean mode); +ERROR HY000: Can't find FULLTEXT index matching the column list +drop table t1,t2; +create table t1 (a text, fulltext key (a)) ENGINE = InnoDB; +insert into t1 select "xxxx yyyy zzzz"; +drop table t1; +SET NAMES latin1; +CREATE TABLE t1 (t text character set utf8 not null, fulltext(t)) ENGINE = InnoDB; +INSERT t1 VALUES ('Mit freundlichem Grüß'), ('aus Osnabrück'); +SET NAMES koi8r; +INSERT t1 VALUES ("üÔÏ ÍÙ - ÏÐÉÌËÉ"),("ïÔÌÅÚØ, ÇÎÉÄÁ!"), +("îÅ ×ÌÅÚÁÊ, ÕÂØÅÔ!"),("É ÂÕÄÅÔ ÐÒÁ×!"); +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('ïðéìëé'); +t collation(t) +üÔÏ ÍÙ - ÏÐÉÌËÉ utf8mb3_general_ci +DROP TABLE t1; +CREATE TABLE t1 (s varchar(255), FULLTEXT (s)) ENGINE = InnoDB DEFAULT CHARSET=utf8; +insert into t1 (s) values ('pära para para'),('para para para'); +select * from t1 where match(s) against('para' in boolean mode); +s +para para para +pära para para +select * from t1 where match(s) against('par*' in boolean mode); +s +para para para +pära para para +DROP TABLE t1; +CREATE TABLE t1 (h text, FULLTEXT (h)) ENGINE = InnoDB; +INSERT INTO t1 VALUES ('Jesses Hasse Ling and his syncopators of Swing'); +select count(*) from t1; +count(*) +1 +drop table t1; +CREATE TABLE t1 ( a TEXT, FULLTEXT (a) ) ENGINE = InnoDB; +INSERT INTO t1 VALUES ('testing ft_nlq_find_relevance'); +SELECT MATCH(a) AGAINST ('nosuchword') FROM t1; +MATCH(a) AGAINST ('nosuchword') +0 +DROP TABLE t1; +create table t1 (a int primary key, b text, fulltext(b)) ENGINE = InnoDB; +create table t2 (a int, b text) ENGINE = InnoDB; +insert t1 values (1, "aaaa"), (2, "bbbb"); +insert t2 values (10, "aaaa"), (2, "cccc"); +replace t1 select * from t2; +drop table t1, t2; +CREATE TABLE t1 (t VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci, FULLTEXT (t)) ENGINE = InnoDB; +SET NAMES latin1; +INSERT INTO t1 VALUES('Mit freundlichem Grüß aus Osnabrück'); +SELECT COUNT(*) FROM t1 WHERE MATCH(t) AGAINST ('"osnabrück"' IN BOOLEAN MODE); +COUNT(*) +1 +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(30), FULLTEXT(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t1 VALUES('testword\'\''); +SELECT a FROM t1 WHERE MATCH a AGAINST('testword' IN BOOLEAN MODE); +a +testword'' +SELECT a FROM t1 WHERE MATCH a AGAINST('testword\'\'' IN BOOLEAN MODE); +a +testword'' +INSERT INTO t1 VALUES('test\'s'); +SELECT a FROM t1 WHERE MATCH a AGAINST('test' IN BOOLEAN MODE); +a +test's +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(10000), FULLTEXT(a)) ENGINE = InnoDB; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(10000) DEFAULT NULL, + FULLTEXT KEY `a` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DROP TABLE t1; +CREATE TABLE t1 (a TEXT, FULLTEXT KEY(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('test'),('test1'),('test'); +ANALYZE TABLE t1; +PREPARE stmt from "SELECT a, FORMAT(MATCH(a) AGAINST('test1 test'),6) FROM t1 WHERE MATCH(a) AGAINST('test1 test')"; +EXECUTE stmt; +a FORMAT(MATCH(a) AGAINST('test1 test'),6) +test1 0.227645 +test 0.031008 +test 0.031008 +EXECUTE stmt; +a FORMAT(MATCH(a) AGAINST('test1 test'),6) +test1 0.227645 +test 0.031008 +test 0.031008 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(255), FULLTEXT(a)) ENGINE = InnoDB; +SELECT * FROM t1 IGNORE INDEX(a) WHERE MATCH(a) AGAINST('test'); +a +SELECT * FROM t1 WHERE MATCH(a) AGAINST('test'); +a +DROP TABLE t1; +CREATE TABLE t1(a TEXT, fulltext(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES(' aaaaa aaaa'); +SELECT * FROM t1 WHERE MATCH(a) AGAINST ('"aaaa"' IN BOOLEAN MODE); +a + aaaaa aaaa +DROP TABLE t1; +CREATE TABLE t1(a VARCHAR(20), FULLTEXT(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('Offside'),('City Of God'); +SELECT a FROM t1 WHERE MATCH a AGAINST ('+city of*' IN BOOLEAN MODE); +a +City Of God +SELECT a FROM t1 WHERE MATCH a AGAINST ('+city (of*)' IN BOOLEAN MODE); +a +Offside +City Of God +SELECT a FROM t1 WHERE MATCH a AGAINST ('+city* of*' IN BOOLEAN MODE); +a +City Of God +DROP TABLE t1; +create table t1(a text,b date,fulltext index(a)) ENGINE = InnoDB; +insert into t1 set a='water',b='2008-08-04'; +select 1 from t1 where match(a) against ('water' in boolean mode) and b>='2008-08-01'; +1 +1 +drop table t1; +show warnings; +Level Code Message +CREATE TABLE t1 (a VARCHAR(255), b INT, FULLTEXT(a), KEY(b)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('test', 1),('test', 1),('test', 1),('test', 1), +('test', 1),('test', 2),('test', 3),('test', 4); +ANALYZE TABLE t1; +EXPLAIN SELECT * FROM t1 +WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext b,a a 0 1 Using where +EXPLAIN SELECT * FROM t1 USE INDEX(a) +WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 1 Using where +EXPLAIN SELECT * FROM t1 FORCE INDEX(a) +WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext a a 0 1 Using where +EXPLAIN SELECT * FROM t1 IGNORE INDEX(a) +WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; +ERROR HY000: Can't find FULLTEXT index matching the column list +EXPLAIN SELECT * FROM t1 USE INDEX(b) +WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; +ERROR HY000: Can't find FULLTEXT index matching the column list +EXPLAIN SELECT * FROM t1 FORCE INDEX(b) +WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; +ERROR HY000: Can't find FULLTEXT index matching the column list +DROP TABLE t1; +CREATE TABLE t1(a CHAR(10), fulltext(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('aaa15'); +SELECT MATCH(a) AGAINST('aaa1* aaa14 aaa16' IN BOOLEAN MODE) FROM t1; +MATCH(a) AGAINST('aaa1* aaa14 aaa16' IN BOOLEAN MODE) +0.000000001885928302414186 +SELECT MATCH(a) AGAINST('aaa1* aaa14 aaa15 aaa16' IN BOOLEAN MODE) FROM t1; +MATCH(a) AGAINST('aaa1* aaa14 aaa15 aaa16' IN BOOLEAN MODE) +0.000000003771856604828372 +DROP TABLE t1; +CREATE TABLE t1(a TEXT) ENGINE = InnoDB; +SELECT GROUP_CONCAT(a) AS st FROM t1 HAVING MATCH(st) AGAINST('test' IN BOOLEAN MODE); +ERROR HY000: Incorrect arguments to MATCH +DROP TABLE t1; +CREATE TABLE t1(a VARCHAR(64), FULLTEXT(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('awrd bwrd cwrd'),('awrd bwrd cwrd'),('awrd bwrd cwrd'); +SELECT * FROM t1 WHERE MATCH(a) AGAINST('+awrd bwrd* +cwrd*' IN BOOLEAN MODE); +a +awrd bwrd cwrd +awrd bwrd cwrd +awrd bwrd cwrd +DROP TABLE t1; +CREATE TABLE t1 (col text, FULLTEXT KEY full_text (col)) ENGINE = InnoDB; +PREPARE s FROM +"SELECT MATCH (col) AGAINST('findme') FROM t1 ORDER BY MATCH (col) AGAINST('findme')" + ; +EXECUTE s; +MATCH (col) AGAINST('findme') +DEALLOCATE PREPARE s; +DROP TABLE t1; +# +# Bug #49250 : spatial btree index corruption and crash +# Part two : fulltext syntax check +# +CREATE TABLE t1(col1 TEXT, +FULLTEXT INDEX USING BTREE (col1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'USING BTREE (col1))' at line 2 +CREATE TABLE t2(col1 TEXT) ENGINE = InnoDB; +CREATE FULLTEXT INDEX USING BTREE ON t2(col); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'USING BTREE ON t2(col)' at line 1 +ALTER TABLE t2 ADD FULLTEXT INDEX USING BTREE (col1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'USING BTREE (col1)' at line 1 +DROP TABLE t2; +End of 5.0 tests +# +# Bug #47930: MATCH IN BOOLEAN MODE returns too many results +# inside subquery +# +CREATE TABLE t1 (a int) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1), (2); +CREATE TABLE t2 (a int, b2 char(10), FULLTEXT KEY b2 (b2)) ENGINE = InnoDB; +INSERT INTO t2 VALUES (1,'Scargill'); +CREATE TABLE t3 (a int, b int) ENGINE = InnoDB; +INSERT INTO t3 VALUES (1,1), (2,1); +# t2 should use full text index +EXPLAIN +SELECT count(*) FROM t1 WHERE +not exists( +SELECT 1 FROM t2, t3 +WHERE t3.a=t1.a AND MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE) +); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where +2 MATERIALIZED t2 fulltext b2 b2 0 1 Using where +2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 Using where +# should return 0 +SELECT count(*) FROM t1 WHERE +not exists( +SELECT 1 FROM t2, t3 +WHERE t3.a=t1.a AND MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE) +); +count(*) +0 +SELECT count(*) FROM t1 WHERE +not exists( +SELECT 1 FROM t2 IGNORE INDEX (b2), t3 +WHERE t3.a=t1.a AND MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE) +); +ERROR HY000: Can't find FULLTEXT index matching the column list +DROP TABLE t1,t2,t3; +CREATE TABLE t1 (a VARCHAR(4), FULLTEXT(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('awrd'),('cwrd'), +('awrd'); +SELECT COUNT(*) FROM t1 WHERE MATCH(a) AGAINST("+awrd bwrd* +cwrd*" IN BOOLEAN MODE); +COUNT(*) +0 +DROP TABLE t1; +# +# Bug #49445: Assertion failed: 0, file .\item_row.cc, line 55 with +# fulltext search and row op +# +CREATE TABLE t1(a CHAR(1),FULLTEXT(a)) ENGINE = InnoDB; +SELECT 1 FROM t1 WHERE MATCH(a) AGAINST ('') AND ROW(a,a) > ROW(1,1); +1 +DROP TABLE t1; +# +# BUG#51866 - crash with repair by sort and fulltext keys +# +CREATE TABLE t1(a CHAR(4), FULLTEXT(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('aaaa'); +DROP TABLE t1; +# +# Bug#54484 explain + prepared statement: crash and Got error -1 from storage engine +# +CREATE TABLE t1(f1 VARCHAR(6) NOT NULL, FULLTEXT KEY(f1), UNIQUE(f1)) ENGINE = InnoDB; +INSERT INTO t1 VALUES ('test'); +SELECT 1 FROM t1 WHERE 1 > +ALL((SELECT 1 FROM t1 JOIN t1 a +ON (MATCH(t1.f1) against ("")) +WHERE t1.f1 GROUP BY t1.f1)) xor f1; +1 +1 +PREPARE stmt FROM +'SELECT 1 FROM t1 WHERE 1 > + ALL((SELECT 1 FROM t1 RIGHT OUTER JOIN t1 a + ON (MATCH(t1.f1) against ("")) + WHERE t1.f1 GROUP BY t1.f1)) xor f1'; +EXECUTE stmt; +1 +1 +EXECUTE stmt; +1 +1 +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM +'SELECT 1 FROM t1 WHERE 1 > + ALL((SELECT 1 FROM t1 JOIN t1 a + ON (MATCH(t1.f1) against ("")) + WHERE t1.f1 GROUP BY t1.f1))'; +EXECUTE stmt; +1 +1 +EXECUTE stmt; +1 +1 +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +End of 5.1 tests +CREATE TABLE z(a INTEGER) engine=innodb; +CREATE TABLE q(b TEXT CHARSET latin1, fulltext(b)) engine=innodb; +EXPLAIN SELECT 1 FROM q WHERE (SELECT MATCH(b) AGAINST ('*') FROM z); +ERROR 42000: syntax error, unexpected $end, expecting FTS_TERM or FTS_NUMB or '*' +SELECT 1 FROM q WHERE (SELECT MATCH(b) AGAINST ('*') FROM z); +ERROR 42000: syntax error, unexpected $end, expecting FTS_TERM or FTS_NUMB or '*' +EXPLAIN SELECT MATCH(b) AGAINST ('*') FROM z; +ERROR 42S22: Unknown column 'b' in 'field list' +SELECT MATCH(b) AGAINST ('*') FROM z; +ERROR 42S22: Unknown column 'b' in 'field list' +EXPLAIN SELECT MATCH(a) AGAINST ('*') FROM z; +ERROR HY000: Can't find FULLTEXT index matching the column list +SELECT MATCH(a) AGAINST ('*') FROM z; +ERROR HY000: Can't find FULLTEXT index matching the column list +EXPLAIN SELECT MATCH(b) AGAINST ('*') FROM q; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE q ALL NULL NULL NULL NULL 1 +SELECT MATCH(b) AGAINST ('*') FROM q; +ERROR 42000: syntax error, unexpected $end, expecting FTS_TERM or FTS_NUMB or '*' +DROP TABLE z, q; +create table t ( +FTS_DOC_ID BIGINT UNSIGNED PRIMARY KEY, t TEXT, FULLTEXT KEY (t) +) ENGINE=InnoDB; +INSERT INTO t values (1, 'foo bar'), (2, 'foo bar'), (3, 'foo'); +SELECT * FROM t WHERE MATCH(t) AGAINST ('foo bar' IN BOOLEAN MODE) +LIMIT 0; +FTS_DOC_ID t +SELECT * FROM t WHERE MATCH(t) AGAINST ('foo bar' IN BOOLEAN MODE) +LIMIT 1; +FTS_DOC_ID t +1 foo bar +SELECT * FROM t WHERE MATCH(t) AGAINST ('foo bar' IN BOOLEAN MODE) +LIMIT 2; +FTS_DOC_ID t +1 foo bar +2 foo bar +SELECT * FROM t WHERE MATCH(t) AGAINST ('foo bar' IN BOOLEAN MODE) +LIMIT 3; +FTS_DOC_ID t +1 foo bar +2 foo bar +3 foo +SELECT * FROM t WHERE MATCH(t) AGAINST ('foo bar' IN BOOLEAN MODE) +LIMIT 4; +FTS_DOC_ID t +1 foo bar +2 foo bar +3 foo +SELECT * FROM t WHERE MATCH(t) AGAINST ('foo bar' IN BOOLEAN MODE) +LIMIT 5; +FTS_DOC_ID t +1 foo bar +2 foo bar +3 foo +DROP TABLE t; +# +# MDEV-25295 Aborted FTS_DOC_ID_INDEX considered as +# existing FTS_DOC_ID_INDEX during DDL +# +SET sql_mode=''; +CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL,title CHAR(1),body TEXT)engine=innodb; +INSERT INTO t1 (FTS_DOC_ID,title,body)VALUES(1,0,0), (1,0,0); +CREATE FULLTEXT INDEX idx1 ON t1 (title,body); +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +CREATE FULLTEXT INDEX idx1 ON t1 (title,body); +ERROR 23000: Duplicate entry '' for key '*UNKNOWN*' +DROP TABLE t1; +SET sql_mode = DEFAULT; +# +# MDEV-25070 SIGSEGV in fts_create_in_mem_aux_table +# +CREATE TABLE t1 (a CHAR, FULLTEXT KEY(a)) ENGINE=InnoDB; +ALTER TABLE t1 DISCARD TABLESPACE; +ALTER TABLE t1 ADD FULLTEXT INDEX (a); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(1) DEFAULT NULL, + FULLTEXT KEY `a` (`a`), + FULLTEXT KEY `a_2` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DROP TABLE t1; +# +# MDEV-25257 SEGV in fts_get_next_doc_id upon some INSERT +# +SET @save = @@global.innodb_file_per_table; +SET @@global.innodb_file_per_table = 0; +CREATE TABLE t1 ( +col_int INTEGER, col_text TEXT, +col_int_g INTEGER GENERATED ALWAYS AS (col_int) +) ENGINE = InnoDB ROW_FORMAT = Redundant ; +ALTER TABLE t1 ADD FULLTEXT KEY `ftidx` ( col_text ) ; +ALTER TABLE t1 DROP KEY `ftidx` ; +INSERT INTO t1 (col_int, col_text) VALUES ( 1255, NULL); +DROP TABLE t1; +SET @@global.innodb_file_per_table = @save; +# +# MDEV-20797 FULLTEXT search with apostrophe, +# and mandatory words +# +CREATE TABLE t1(f1 TINYTEXT NOT NULL, FULLTEXT(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES('O''Brien'), ('O Brien'), ('Ö''Brien'); +INSERT INTO t1 VALUES('Brien'), ('O ''Brien'), ('O'' Brien'); +INSERT INTO t1 VALUES('Doh''nuts'); +SELECT * FROM t1 WHERE MATCH (f1) AGAINST ("+O'Brien" IN BOOLEAN MODE); +f1 +O'Brien +O Brien +Ö'Brien +Brien +O 'Brien +O' Brien +SELECT * FROM t1 WHERE MATCH (f1) AGAINST ("+Doh'nuts" IN BOOLEAN MODE); +f1 +Doh'nuts +SELECT * FROM t1 WHERE MATCH (f1) AGAINST ("+Ö''Brien" IN BOOLEAN MODE); +f1 +O'Brien +O Brien +Ö'Brien +Brien +O 'Brien +O' Brien +DROP TABLE t1; +# +# MDEV-29058 Assertion `index->type == 32' failed +# in dict_index_build_internal_fts +# +call mtr.add_suppression("InnoDB: Index `f` of table `test`.`t2` is corrupted"); +call mtr.add_suppression("InnoDB: Skip adjustment of root pages for index `f`."); +CREATE TABLE t1 (f CHAR(8), FULLTEXT KEY (f)) ENGINE=InnoDB; +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 DISCARD TABLESPACE; +FLUSH TABLES t1 FOR EXPORT; +UNLOCK TABLES; +ALTER TABLE t1 DISCARD TABLESPACE; +ALTER TABLE t2 IMPORT TABLESPACE; +DROP TABLE t2, t1; +# +# MDEV-29778 Having Unique index interference with MATCH +# from a FULLTEXT +# +CREATE TABLE t1(f1 VARCHAR(100), FULLTEXT(f1), +UNIQUE INDEX(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES("test"); +SELECT f1, MATCH(f1) AGAINST ("test" IN BOOLEAN MODE) FROM t1; +f1 MATCH(f1) AGAINST ("test" IN BOOLEAN MODE) +test 0.000000001885928302414186 +DROP TABLE t1; +# End of 10.3 tests diff --git a/mysql-test/suite/innodb_fts/r/fulltext2.result b/mysql-test/suite/innodb_fts/r/fulltext2.result new file mode 100644 index 00000000..10fee848 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/fulltext2.result @@ -0,0 +1,298 @@ +CREATE TABLE t1 ( +i int(10) unsigned not null auto_increment primary key, +a varchar(255) not null, +FULLTEXT KEY (a) +) ENGINE = INNODB; +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +select count(*) from t1 where match a against ('aaaxxx'); +count(*) +260 +select count(*) from t1 where match a against ('aaayyy'); +count(*) +250 +select count(*) from t1 where match a against ('aaazzz'); +count(*) +255 +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +count(*) +260 +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +count(*) +250 +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +count(*) +255 +select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz'); +count(*) +765 +select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode); +count(*) +765 +select count(*) from t1 where match a against ('aaax*' in boolean mode); +count(*) +260 +select count(*) from t1 where match a against ('aaay*' in boolean mode); +count(*) +250 +select count(*) from t1 where match a against ('aaa*' in boolean mode); +count(*) +765 +insert t1 (a) values ('aaaxxx'),('aaayyy'); +insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx'); +count(*) +261 +select count(*) from t1 where match a against ('aaayyy'); +count(*) +251 +select count(*) from t1 where match a against ('aaazzz'); +count(*) +260 +insert t1 (a) values ('aaaxxx 000000'); +select count(*) from t1 where match a against ('000000'); +count(*) +1 +delete from t1 where match a against ('000000'); +select count(*) from t1 where match a against ('000000'); +count(*) +0 +select count(*) from t1 where match a against ('aaaxxx'); +count(*) +261 +delete from t1 where match a against ('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +count(*) +261 +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +count(*) +251 +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +count(*) +0 +select count(*) from t1 where a = 'aaaxxx'; +count(*) +261 +select count(*) from t1 where a = 'aaayyy'; +count(*) +251 +select count(*) from t1 where a = 'aaazzz'; +count(*) +0 +insert t1 (a) values ('aaaxxx 000000'); +select count(*) from t1 where match a against ('000000'); +count(*) +1 +update t1 set a='aaazzz' where match a against ('000000'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +count(*) +261 +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +count(*) +1 +update t1 set a='aaazzz' where a = 'aaaxxx'; +update t1 set a='aaaxxx' where a = 'aaayyy'; +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +count(*) +251 +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +count(*) +0 +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +count(*) +262 +drop table t1; +CREATE TABLE t1 ( +i int(10) unsigned not null auto_increment primary key, +a varchar(255) not null, +FULLTEXT KEY (a) +) ENGINE = INNODB; +select count(*) from t1 where match a against ('aaaxxx'); +count(*) +260 +select count(*) from t1 where match a against ('aaayyy'); +count(*) +250 +select count(*) from t1 where match a against ('aaazzz'); +count(*) +255 +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +count(*) +260 +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +count(*) +250 +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +count(*) +255 +select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz'); +count(*) +765 +select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode); +count(*) +765 +select count(*) from t1 where match a against ('aaax*' in boolean mode); +count(*) +260 +select count(*) from t1 where match a against ('aaay*' in boolean mode); +count(*) +250 +select count(*) from t1 where match a against ('aaa*' in boolean mode); +count(*) +765 +insert t1 (a) values ('aaaxxx'),('aaayyy'); +insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx'); +count(*) +261 +select count(*) from t1 where match a against ('aaayyy'); +count(*) +251 +select count(*) from t1 where match a against ('aaazzz'); +count(*) +260 +insert t1 (a) values ('aaaxxx 000000'); +select count(*) from t1 where match a against ('000000'); +count(*) +1 +delete from t1 where match a against ('000000'); +select count(*) from t1 where match a against ('000000'); +count(*) +0 +select count(*) from t1 where match a against ('aaaxxx'); +count(*) +261 +delete from t1 where match a against ('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +count(*) +261 +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +count(*) +251 +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +count(*) +0 +select count(*) from t1 where a = 'aaaxxx'; +count(*) +261 +select count(*) from t1 where a = 'aaayyy'; +count(*) +251 +select count(*) from t1 where a = 'aaazzz'; +count(*) +0 +insert t1 (a) values ('aaaxxx 000000'); +select count(*) from t1 where match a against ('000000'); +count(*) +1 +update t1 set a='aaazzz' where match a against ('000000'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +count(*) +261 +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +count(*) +1 +update t1 set a='aaazzz' where a = 'aaaxxx'; +update t1 set a='aaaxxx' where a = 'aaayyy'; +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +count(*) +251 +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +count(*) +0 +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +count(*) +262 +drop table t1; +set names utf8; +create table t1(a text,fulltext(a)) ENGINE = INNODB collate=utf8_swedish_ci; +insert into t1 values('test test '),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'); +delete from t1 limit 1; +truncate table t1; +insert into t1 values('ab c d'); +update t1 set a='ab c d'; +select * from t1 where match a against('ab c' in boolean mode); +a +select * from t1 where match a against('ab c' in boolean mode); +a +drop table t1; +set names latin1; +SET NAMES utf8; +CREATE TABLE t1(a VARCHAR(255), FULLTEXT(a)) ENGINE = INNODB DEFAULT CHARSET=utf8; +INSERT INTO t1 VALUES('„MySQL“'); +SELECT a FROM t1 WHERE MATCH a AGAINST('“MySQL„' IN BOOLEAN MODE); +a +„MySQL“ +DROP TABLE t1; +SET NAMES latin1; +CREATE TABLE t1 ( +FTS_DOC_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, +id int(10) not null , +first_name varchar(50) NOT NULL, +last_name varchar(50) NOT NULL, +PRIMARY KEY (FTS_DOC_ID), +UNIQUE KEY idx_1 (first_name, last_name), +FULLTEXT KEY `idx_2` (first_name) +) ENGINE=InnoDB; +INSERT INTO t1 (id, first_name, last_name) VALUES +(10, 'Bart', 'Simpson'), +(11, 'Homer', 'Simpson'), +(12, 'Marge', 'Simpson'), +(13, 'Lisa', 'Simpson'), +(14, 'Maggie', 'Simpson'), +(15, 'Ned', 'Flanders'), +(16, 'Nelson', 'Muntz'); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +SELECT fts_doc_id, first_name, last_name, MATCH(first_name) AGAINST('Homer' IN BOOLEAN MODE) AS score FROM t1; +fts_doc_id first_name last_name score +1 Bart Simpson 0 +2 Homer Simpson 0.7141907215118408 +4 Lisa Simpson 0 +5 Maggie Simpson 0 +3 Marge Simpson 0 +6 Ned Flanders 0 +7 Nelson Muntz 0 +DROP TABLE t1; +CREATE TABLE t1(a INT, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +KEY FTS_DOC_ID_INDEX(FTS_DOC_ID))ENGINE=InnoDB; +ALTER TABLE t1 ADD COLUMN c INT as (a) VIRTUAL; +ALTER TABLE t1 ADD d INT NULL; +ALTER TABLE t1 ADD FULLTEXT(b); +ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index +DROP TABLE t1; +# +# MDEV-29169 Using MATCH returns NULL for Virtual Column +# +CREATE TABLE t (a TEXT DEFAULT NULL, +b TEXT AS (a), +c TEXT AS (concat(a, '1')), +d int AS (111) VIRTUAL, +FULLTEXT KEY `a` (`a`) +) ENGINE=InnoDB; +INSERT INTO t (a) VALUES ('test'); +SELECT * FROM t; +a b c d +test test test1 111 +SELECT * FROM t WHERE MATCH(a) AGAINST('test'); +a b c d +test test test1 111 +DROP TABLE t; diff --git a/mysql-test/suite/innodb_fts/r/fulltext3.result b/mysql-test/suite/innodb_fts/r/fulltext3.result new file mode 100644 index 00000000..8d89cb74 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/fulltext3.result @@ -0,0 +1,18 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1(a VARCHAR(255) CHARACTER SET gbk, FULLTEXT(a)) ENGINE = InnoDB; +SET NAMES utf8; +DELETE FROM t1 LIMIT 1; +SET NAMES latin1; +DROP TABLE t1; +CREATE TABLE t1(a VARCHAR(2) CHARACTER SET big5 COLLATE big5_chinese_ci, +FULLTEXT(a)) ENGINE=<default_engine>; +DROP TABLE t1; +CREATE TABLE t1 (a SERIAL, t TEXT, FULLTEXT f1(t), FULLTEXT f2(t)) ENGINE=InnoDB; +Warnings: +Note 1831 Duplicate index `f2`. This is deprecated and will be disallowed in a future release +INSERT INTO t1 (a,t) VALUES (1,'1'),(2,'1'); +ALTER TABLE t1 ADD COLUMN g TEXT GENERATED ALWAYS AS (t) VIRTUAL; +DELETE FROM t1 WHERE a = 1; +ALTER TABLE t1 DROP INDEX f1; +INSERT INTO t1 (a,t) VALUES (1,'1'); +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/r/fulltext_cache.result b/mysql-test/suite/innodb_fts/r/fulltext_cache.result new file mode 100644 index 00000000..6e00d993 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/fulltext_cache.result @@ -0,0 +1,70 @@ +drop table if exists t1, t2; +CREATE TABLE t1 ( +id int(10) unsigned NOT NULL auto_increment, +q varchar(255) default NULL, +PRIMARY KEY (id) +) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,'aaaaaaaaa dsaass de'); +INSERT INTO t1 VALUES (2,'ssde df s fsda sad er'); +CREATE TABLE t2 ( +id int(10) unsigned NOT NULL auto_increment, +id2 int(10) unsigned default NULL, +item varchar(255) default NULL, +PRIMARY KEY (id), +FULLTEXT KEY item(item) +) ENGINE = InnoDB; +INSERT INTO t2 VALUES (1,1,'sushi'); +INSERT INTO t2 VALUES (2,1,'Bolo de Chocolate'); +INSERT INTO t2 VALUES (3,1,'Feijoada'); +INSERT INTO t2 VALUES (4,1,'Mousse de Chocolate'); +INSERT INTO t2 VALUES (5,2,'um copo de Vodka'); +INSERT INTO t2 VALUES (6,2,'um chocolate Snickers'); +INSERT INTO t2 VALUES (7,1,'Bife'); +INSERT INTO t2 VALUES (8,1,'Pizza de Salmao'); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +SELECT t1.q, t2.item, t2.id, round(MATCH t2.item AGAINST ('sushi'),6) +as x FROM t1, t2 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; +q item id x +aaaaaaaaa dsaass de sushi 1 0.815572 +aaaaaaaaa dsaass de Bolo de Chocolate 2 0.000000 +aaaaaaaaa dsaass de Feijoada 3 0.000000 +aaaaaaaaa dsaass de Mousse de Chocolate 4 0.000000 +ssde df s fsda sad er um copo de Vodka 5 0.000000 +ssde df s fsda sad er um chocolate Snickers 6 0.000000 +aaaaaaaaa dsaass de Bife 7 0.000000 +aaaaaaaaa dsaass de Pizza de Salmao 8 0.000000 +SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi' IN BOOLEAN MODE) +as x FROM t1, t2 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; +q item id x +aaaaaaaaa dsaass de sushi 1 0.8155715465545654 +aaaaaaaaa dsaass de Bolo de Chocolate 2 0 +aaaaaaaaa dsaass de Feijoada 3 0 +aaaaaaaaa dsaass de Mousse de Chocolate 4 0 +ssde df s fsda sad er um copo de Vodka 5 0 +ssde df s fsda sad er um chocolate Snickers 6 0 +aaaaaaaaa dsaass de Bife 7 0 +aaaaaaaaa dsaass de Pizza de Salmao 8 0 +SELECT t1.q, t2.item, t2.id, round(MATCH t2.item AGAINST ('sushi'),6) +as x FROM t2, t1 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; +q item id x +aaaaaaaaa dsaass de sushi 1 0.815572 +aaaaaaaaa dsaass de Bolo de Chocolate 2 0.000000 +aaaaaaaaa dsaass de Feijoada 3 0.000000 +aaaaaaaaa dsaass de Mousse de Chocolate 4 0.000000 +ssde df s fsda sad er um copo de Vodka 5 0.000000 +ssde df s fsda sad er um chocolate Snickers 6 0.000000 +aaaaaaaaa dsaass de Bife 7 0.000000 +aaaaaaaaa dsaass de Pizza de Salmao 8 0.000000 +SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi' IN BOOLEAN MODE) +as x FROM t2, t1 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; +q item id x +aaaaaaaaa dsaass de sushi 1 0.8155715465545654 +aaaaaaaaa dsaass de Bolo de Chocolate 2 0 +aaaaaaaaa dsaass de Feijoada 3 0 +aaaaaaaaa dsaass de Mousse de Chocolate 4 0 +ssde df s fsda sad er um copo de Vodka 5 0 +ssde df s fsda sad er um chocolate Snickers 6 0 +aaaaaaaaa dsaass de Bife 7 0 +aaaaaaaaa dsaass de Pizza de Salmao 8 0 +drop table t1, t2; diff --git a/mysql-test/suite/innodb_fts/r/fulltext_distinct.result b/mysql-test/suite/innodb_fts/r/fulltext_distinct.result new file mode 100644 index 00000000..e660b55c --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/fulltext_distinct.result @@ -0,0 +1,43 @@ +DROP TABLE IF EXISTS t1, t2; +CREATE TABLE t1 ( +id mediumint unsigned NOT NULL auto_increment, +tag char(6) NOT NULL default '', +value text NOT NULL default '', +PRIMARY KEY (id), +KEY kt(tag), +KEY kv(value(15)), +FULLTEXT KEY kvf(value) +) ENGINE = InnoDB; +CREATE TABLE t2 ( +id_t2 mediumint unsigned NOT NULL default '0', +id_t1 mediumint unsigned NOT NULL default '0', +field_number tinyint unsigned NOT NULL default '0', +PRIMARY KEY (id_t2,id_t1,field_number), +KEY id_t1(id_t1) +) ENGINE = InnoDB; +INSERT INTO t1 (tag,value) VALUES ('foo123','bar111'); +INSERT INTO t1 (tag,value) VALUES ('foo123','bar222'); +INSERT INTO t1 (tag,value) VALUES ('bar345','baz333 ar'); +INSERT INTO t2 VALUES (2231626,64280,0); +INSERT INTO t2 VALUES (2231626,64281,0); +INSERT INTO t2 VALUES (12346, 3, 1); +SELECT * FROM t1; +id tag value +1 foo123 bar111 +2 foo123 bar222 +3 bar345 baz333 ar +SELECT * FROM t2; +id_t2 id_t1 field_number +12346 3 1 +2231626 64280 0 +2231626 64281 0 +SELECT DISTINCT t2.id_t2 FROM t2, t1 +WHERE MATCH (t1.value) AGAINST ('baz333') AND t1.id = t2.id_t1; +id_t2 +12346 +SELECT DISTINCT t2.id_t2 FROM t2, t1 +WHERE MATCH (t1.value) AGAINST ('baz333' IN BOOLEAN MODE) +AND t1.id = t2.id_t1; +id_t2 +12346 +DROP TABLE t1, t2; diff --git a/mysql-test/suite/innodb_fts/r/fulltext_left_join.result b/mysql-test/suite/innodb_fts/r/fulltext_left_join.result new file mode 100644 index 00000000..fc8d29bb --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/fulltext_left_join.result @@ -0,0 +1,102 @@ +drop table if exists t1, t2; +CREATE TABLE t1 ( +id VARCHAR(255) NOT NULL PRIMARY KEY, +sujet VARCHAR(255), +motsclefs TEXT, +texte MEDIUMTEXT, +FULLTEXT(sujet, motsclefs, texte) +) ENGINE = InnoDB; +INSERT INTO t1 VALUES('123','toto','essai','test'); +INSERT INTO t1 VALUES('456','droit','penal','lawyer'); +INSERT INTO t1 VALUES('789','aaaaa','bbbbb','cccccc'); +CREATE TABLE t2 ( +id VARCHAR(255) NOT NULL, +author VARCHAR(255) NOT NULL +) ENGINE = InnoDB; +INSERT INTO t2 VALUES('123', 'moi'); +INSERT INTO t2 VALUES('123', 'lui'); +INSERT INTO t2 VALUES('456', 'lui'); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +select round(match(t1.texte,t1.sujet,t1.motsclefs) against('droit'),5) +from t1 left join t2 on t2.id=t1.id; +round(match(t1.texte,t1.sujet,t1.motsclefs) against('droit'),5) +0.00000 +0.00000 +0.22764 +0.00000 +select match(t1.texte,t1.sujet,t1.motsclefs) against('droit' IN BOOLEAN MODE) +from t1 left join t2 on t2.id=t1.id; +match(t1.texte,t1.sujet,t1.motsclefs) against('droit' IN BOOLEAN MODE) +0 +0 +0.22764469683170319 +0 +drop table t1, t2; +create table t1 (venue_id int(11) default null, venue_text varchar(255) default null, dt datetime default null) ENGINE = InnoDB; +insert into t1 (venue_id, venue_text, dt) values (1, 'a1', '2003-05-23 19:30:00'),(null, 'a2', '2003-05-23 19:30:00'); +create table t2 (name varchar(255) not null default '', entity_id int(11) not null auto_increment, primary key (entity_id), fulltext key name (name)) engine= innodb; +insert into t2 (name, entity_id) values ('aberdeen town hall', 1), ('glasgow royal concert hall', 2), ('queen\'s hall, edinburgh', 3); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +select * from t1 left join t2 on venue_id = entity_id where match(name) against('aberdeen' in boolean mode) and dt = '2003-05-23 19:30:00'; +venue_id venue_text dt name entity_id +1 a1 2003-05-23 19:30:00 aberdeen town hall 1 +select * from t1 left join t2 on venue_id = entity_id where match(name) against('aberdeen') and dt = '2003-05-23 19:30:00'; +venue_id venue_text dt name entity_id +1 a1 2003-05-23 19:30:00 aberdeen town hall 1 +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen' in boolean mode)) where dt = '2003-05-23 19:30:00'; +venue_id venue_text dt name entity_id +1 a1 2003-05-23 19:30:00 aberdeen town hall 1 +NULL a2 2003-05-23 19:30:00 NULL NULL +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen')) where dt = '2003-05-23 19:30:00'; +venue_id venue_text dt name entity_id +1 a1 2003-05-23 19:30:00 aberdeen town hall 1 +NULL a2 2003-05-23 19:30:00 NULL NULL +drop table t1,t2; +create table t1 (id int not null primary key, d char(200) not null, e char(200), fulltext (d, e)) ENGINE = InnoDB; +insert into t1 values (1, 'aword', null), (2, 'aword', 'bword'), (3, 'bword', null), (4, 'bword', 'aword'), (5, 'aword and bword', null); +ANALYZE TABLE t1; +select * from t1 where match(d, e) against ('+aword +bword' in boolean mode); +id d e +2 aword bword +4 bword aword +5 aword and bword NULL +create table t2 (m_id int not null, f char(200), key (m_id), fulltext (f)) engine = InnoDB; +insert into t2 values (1, 'bword'), (3, 'aword'), (5, ''); +ANALYZE TABLE t2; +select * from t1 left join t2 on m_id = id where match(d, e, f) against ('+aword +bword' in boolean mode); +ERROR HY000: Incorrect arguments to MATCH +drop table t1,t2; +CREATE TABLE t1 ( +id int(10) NOT NULL auto_increment, +link int(10) default NULL, +name mediumtext default NULL, +PRIMARY KEY (id), +FULLTEXT (name) +) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1, 1, 'string'); +INSERT INTO t1 VALUES (2, 0, 'string'); +CREATE TABLE t2 ( +id int(10) NOT NULL auto_increment, +name mediumtext default NULL, +PRIMARY KEY (id), +FULLTEXT (name) +) ENGINE = InnoDB; +INSERT INTO t2 VALUES (1, 'string'); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +SELECT t1.*, MATCH(t1.name) AGAINST('string') AS relevance +FROM t1 LEFT JOIN t2 ON t1.link = t2.id +WHERE MATCH(t1.name, t2.name) AGAINST('string' IN BOOLEAN MODE); +ERROR HY000: Incorrect arguments to MATCH +DROP TABLE t1,t2; +CREATE TABLE t1 (a INT) ENGINE = InnoDB; +CREATE TABLE t2 (b INT, c TEXT, KEY(b), FULLTEXT(c)) ENGINE = InnoDB; +INSERT INTO t1 VALUES(1); +INSERT INTO t2(b,c) VALUES(2,'castle'),(3,'castle'); +ANALYZE TABLE t1; +ANALYZE TABLE t2; +SELECT * FROM t1 LEFT JOIN t2 ON a=b WHERE MATCH(c) AGAINST('+castle' IN BOOLEAN MODE); +a b c +DROP TABLE t1, t2; diff --git a/mysql-test/suite/innodb_fts/r/fulltext_misc.result b/mysql-test/suite/innodb_fts/r/fulltext_misc.result new file mode 100644 index 00000000..69812ff8 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/fulltext_misc.result @@ -0,0 +1,196 @@ +drop table if exists t1; +# +# Bug#56814 Explain + subselect + fulltext crashes server +# +CREATE TABLE t1(f1 VARCHAR(6) NOT NULL,FULLTEXT KEY(f1),UNIQUE(f1)) ENGINE = InnoDB; +INSERT INTO t1 VALUES ('test'); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 > ALL((SELECT 1 FROM t1 JOIN t1 a ON (MATCH(t1.f1) AGAINST ("")) +WHERE t1.f1 GROUP BY t1.f1)); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 index NULL f1_2 8 NULL 1 Using index +2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +2 SUBQUERY a index NULL f1_2 8 NULL 1 Using index +PREPARE stmt FROM +'EXPLAIN SELECT 1 FROM t1 + WHERE 1 > ALL((SELECT 1 FROM t1 RIGHT OUTER JOIN t1 a + ON (MATCH(t1.f1) AGAINST ("")) + WHERE t1.f1 GROUP BY t1.f1))'; +EXECUTE stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 index NULL f1_2 8 NULL 1 Using index +2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +2 SUBQUERY a index NULL f1_2 8 NULL 1 Using index +EXECUTE stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 index NULL f1_2 8 NULL 1 Using index +2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +2 SUBQUERY a index NULL f1_2 8 NULL 1 Using index +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM +'EXPLAIN SELECT 1 FROM t1 + WHERE 1 > ALL((SELECT 1 FROM t1 JOIN t1 a + ON (MATCH(t1.f1) AGAINST ("")) + WHERE t1.f1 GROUP BY t1.f1))'; +EXECUTE stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 index NULL f1_2 8 NULL 1 Using index +2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +2 SUBQUERY a index NULL f1_2 8 NULL 1 Using index +EXECUTE stmt; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 index NULL f1_2 8 NULL 1 Using index +2 SUBQUERY t1 fulltext f1_2,f1 f1 0 1 Using where +2 SUBQUERY a index NULL f1_2 8 NULL 1 Using index +DEALLOCATE PREPARE stmt; +DROP TABLE t1; +drop table if exists t1; +CREATE TABLE t1 ( +kodoboru varchar(10) default NULL, +obor tinytext, +aobor tinytext, +UNIQUE INDEX kodoboru (kodoboru), +FULLTEXT KEY obor (obor), +FULLTEXT KEY aobor (aobor) +) ENGINE = InnoDB; +drop table t1; +CREATE TABLE t1 ( +kodoboru varchar(10) default NULL, +obor tinytext, +aobor tinytext, +UNIQUE INDEX kodoboru (kodoboru), +FULLTEXT KEY obor (obor) +) ENGINE = InnoDB; +INSERT INTO t1 VALUES ('0101000000','aaa','AAA'); +INSERT INTO t1 VALUES ('0102000000','bbb','BBB'); +INSERT INTO t1 VALUES ('0103000000','ccc','CCC'); +INSERT INTO t1 VALUES ('0104000000','xxx','XXX'); +select * from t1; +kodoboru obor aobor +0101000000 aaa AAA +0102000000 bbb BBB +0103000000 ccc CCC +0104000000 xxx XXX +drop table t1; +create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int, +c7 int, c8 int, c9 int, fulltext key (`c1`)) ENGINE = InnoDB; +select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8 +from t1 where c9=1 order by c2, c2; +match (`c1`) against ('z') c2 c3 c4 c5 c6 c7 c8 +drop table t1; +CREATE TABLE t1 (c1 int not null auto_increment primary key, c2 varchar(20), fulltext(c2)) ENGINE = InnoDB; +insert into t1 (c2) VALUES ('real Beer'),('Water'),('Kossu'),('Coca-Cola'),('Vodka'),('Wine'),('almost real Beer'); +select * from t1 WHERE match (c2) against ('Beer'); +c1 c2 +1 real Beer +7 almost real Beer +CREATE VIEW v1 AS SELECT * from t1 WHERE match (c2) against ('Beer'); +select * from v1; +c1 c2 +1 real Beer +7 almost real Beer +drop view v1; +drop table t1; +create table t1 (mytext text, FULLTEXT (mytext)) ENGINE = InnoDB; +insert t1 values ('aaabbb'); +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +check table t1; +Table Op Msg_type Msg_text +test.t1 check status OK +drop table t1; +create table t1 (a varchar(10), fulltext key(a)) ENGINE = InnoDB; +insert into t1 values ('a'); +select hex(concat(match (a) against ('a'))) from t1; +hex(concat(match (a) against ('a'))) +30 +create table t2 ENGINE = InnoDB as select concat(match (a) against ('a')) as a from t1; +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `a` varchar(23) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +drop table t1, t2; +CREATE TABLE t1(a TEXT CHARSET ucs2 COLLATE ucs2_unicode_ci) ENGINE = InnoDB; +INSERT INTO t1 VALUES('abcd'); +SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abcd' IN BOOLEAN MODE); +ERROR HY000: Can't find FULLTEXT index matching the column list +DROP TABLE t1; +create table t1 (a varchar(10), key(a), fulltext (a)) ENGINE = InnoDB; +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +select * from t1 where a like "abc%"; +a +abc +abcd +select * from t1 where a like "test%"; +a +test +select * from t1 where a like "te_t"; +a +test +select * from t1 where match a against ("te*" in boolean mode); +a +test +drop table t1; +# +# Bug #49734: Crash on EXPLAIN EXTENDED UNION ... ORDER BY +# <any non-const-function> +# +CREATE TABLE t1 (a VARCHAR(10), FULLTEXT KEY a (a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT) ENGINE = InnoDB; +INSERT INTO t2 VALUES (1),(2); +# Should not crash +EXPLAIN EXTENDED +SELECT * FROM t1 UNION SELECT * FROM t1 ORDER BY a + 12; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +2 UNION t1 ALL NULL NULL NULL NULL 2 100.00 +NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by `a` + 12 +# Should not crash +SELECT * FROM t1 UNION SELECT * FROM t1 ORDER BY a + 12; +a +1 +2 +# Should not crash +EXPLAIN EXTENDED +SELECT * FROM t1 UNION SELECT * FROM t1 +ORDER BY MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +2 UNION t1 ALL NULL NULL NULL NULL 2 100.00 +NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL Using filesort +Warnings: +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by (match `a` against ('+abc' in boolean mode)) +# Should not crash +SELECT * FROM t1 UNION SELECT * FROM t1 +ORDER BY MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE); +a +1 +2 +# Should not crash +EXPLAIN EXTENDED +SELECT * FROM t1 UNION SELECT * FROM t1 +ORDER BY (SELECT a FROM t2 WHERE b = 12); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 +2 UNION t1 ALL NULL NULL NULL NULL 2 100.00 +NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL NULL Using filesort +3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1276 Field or reference 'a' of SELECT #3 was resolved in SELECT #-1 +Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` union /* select#2 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` order by <expr_cache><`a`>((/* select#3 */ select `a` from `test`.`t2` where `test`.`t2`.`b` = 12)) +# Should not crash +SELECT * FROM t1 UNION SELECT * FROM t1 +ORDER BY (SELECT a FROM t2 WHERE b = 12); +# Should not crash +SELECT * FROM t2 UNION SELECT * FROM t2 +ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE)); +b +1 +2 +DROP TABLE t1,t2; +End of 5.1 tests diff --git a/mysql-test/suite/innodb_fts/r/fulltext_multi.result b/mysql-test/suite/innodb_fts/r/fulltext_multi.result new file mode 100644 index 00000000..4a3c2fb5 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/fulltext_multi.result @@ -0,0 +1,38 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +a int(11) NOT NULL auto_increment, +b text, +c varchar(254) default NULL, +PRIMARY KEY (a), +FULLTEXT KEY bb(b), +FULLTEXT KEY cc(c), +FULLTEXT KEY a(b,c) +) ENGINE = InnoDB; +drop table t1; +CREATE TABLE t1 ( +a int(11) NOT NULL auto_increment, +b text, +c varchar(254) default NULL, +PRIMARY KEY (a), +FULLTEXT KEY a(b,c) +) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,'lala lolo lili','oooo aaaa pppp'); +INSERT INTO t1 VALUES (2,'asdf fdsa','lkjh fghj'); +INSERT INTO t1 VALUES (3,'qpwoei','zmxnvb'); +ANALYZE TABLE t1; +SELECT a, round(MATCH b,c AGAINST ('lala lkjh'),5) FROM t1; +a round(MATCH b,c AGAINST ('lala lkjh'),5) +1 0.22764 +2 0.22764 +3 0.00000 +SELECT a, round(MATCH c,c AGAINST ('lala lkjh'),5) FROM t1; +a round(MATCH c,c AGAINST ('lala lkjh'),5) +1 0.22764 +2 0.22764 +3 0.00000 +SELECT a, round(MATCH b,c AGAINST ('lala lkjh'),5) FROM t1; +a round(MATCH b,c AGAINST ('lala lkjh'),5) +1 0.22764 +2 0.22764 +3 0.00000 +drop table t1; diff --git a/mysql-test/suite/innodb_fts/r/fulltext_order_by.result b/mysql-test/suite/innodb_fts/r/fulltext_order_by.result new file mode 100644 index 00000000..0d3a4a85 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/fulltext_order_by.result @@ -0,0 +1,179 @@ +DROP TABLE IF EXISTS t1,t2,t3; +CREATE TABLE t1 ( +a INT AUTO_INCREMENT PRIMARY KEY, +message CHAR(20), +FULLTEXT(message) +) ENGINE = InnoDB comment = 'original testcase by sroussey@network54.com'; +INSERT INTO t1 (message) VALUES ("Testing"),("table"),("testbug"), +("steve"),("is"),("cool"),("steve is cool"); +ANALYZE TABLE t1; +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve'); +a FORMAT(MATCH (message) AGAINST ('steve'),6) +4 0.296010 +7 0.296010 +SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve'); +a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) +4 0.2960100471973419 +7 0.2960100471973419 +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE); +a FORMAT(MATCH (message) AGAINST ('steve'),6) +4 0.296010 +7 0.296010 +SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE); +a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) +4 0.2960100471973419 +7 0.2960100471973419 +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY a; +a FORMAT(MATCH (message) AGAINST ('steve'),6) +4 0.296010 +7 0.296010 +SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a; +a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) +4 0.2960100471973419 +7 0.2960100471973419 +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve') ORDER BY a DESC; +a FORMAT(MATCH (message) AGAINST ('steve'),6) +7 0.296010 +4 0.296010 +SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a DESC; +a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) +7 0.2960100471973419 +4 0.2960100471973419 +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve') ORDER BY 1; +a FORMAT(MATCH (message) AGAINST ('steve'),6) +7 0.296010 +SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY 1; +a MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) +7 0.2960100471973419 +SELECT if(a in (4,7),2,1), FORMAT(MATCH (message) AGAINST ('steve'),6) as rel FROM t1 ORDER BY rel; +if(a in (4,7),2,1) rel +1 0.000000 +1 0.000000 +1 0.000000 +1 0.000000 +1 0.000000 +2 0.296010 +2 0.296010 +SELECT if(a in (4,7),2,1), MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel; +if(a in (4,7),2,1) rel +1 0 +1 0 +1 0 +1 0 +1 0 +2 0.2960100471973419 +2 0.2960100471973419 +alter table t1 add key m (message); +ANALYZE TABLE t1; +explain SELECT message FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY message; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 fulltext message message 0 1 Using where; Using filesort +SELECT message FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY message desc; +message +steve is cool +steve +drop table t1; +CREATE TABLE t1 ( +a INT AUTO_INCREMENT PRIMARY KEY, +message CHAR(20), +FULLTEXT(message) +) ENGINE = InnoDB; +INSERT INTO t1 (message) VALUES ("testbug"),("testbug foobar"); +ANALYZE TABLE t1; +SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1; +a rel +1 0.000000001885928302414186 +2 0.0906190574169159 +SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel,a; +a rel +1 0.000000001885928302414186 +2 0.0906190574169159 +drop table t1; +CREATE TABLE t1 ( +id int(11) NOT NULL auto_increment, +thread int(11) NOT NULL default '0', +beitrag longtext NOT NULL, +PRIMARY KEY (id), +KEY thread (thread), +FULLTEXT KEY beitrag (beitrag) +) ENGINE =InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=7923 ; +CREATE TABLE t2 ( +id int(11) NOT NULL auto_increment, +text varchar(100) NOT NULL default '', +PRIMARY KEY (id), +KEY text (text) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=63 ; +CREATE TABLE t3 ( +id int(11) NOT NULL auto_increment, +forum int(11) NOT NULL default '0', +betreff varchar(70) NOT NULL default '', +PRIMARY KEY (id), +KEY forum (forum), +FULLTEXT KEY betreff (betreff) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=996 ; +select a.text, b.id, b.betreff +from +t2 a inner join t3 b on a.id = b.forum inner join +t1 c on b.id = c.thread +where +match(b.betreff) against ('+abc' in boolean mode) +group by a.text, b.id, b.betreff +union +select a.text, b.id, b.betreff +from +t2 a inner join t3 b on a.id = b.forum inner join +t1 c on b.id = c.thread +where +match(c.beitrag) against ('+abc' in boolean mode) +group by +a.text, b.id, b.betreff +order by +match(b.betreff) against ('+abc' in boolean mode) desc; +ERROR 42000: Table 'b' from one of the SELECTs cannot be used in ORDER clause +select a.text, b.id, b.betreff +from +t2 a inner join t3 b on a.id = b.forum inner join +t1 c on b.id = c.thread +where +match(b.betreff) against ('+abc' in boolean mode) +union +select a.text, b.id, b.betreff +from +t2 a inner join t3 b on a.id = b.forum inner join +t1 c on b.id = c.thread +where +match(c.beitrag) against ('+abc' in boolean mode) +order by +match(b.betreff) against ('+abc' in boolean mode) desc; +ERROR 42000: Table 'b' from one of the SELECTs cannot be used in ORDER clause +select a.text, b.id, b.betreff +from +t2 a inner join t3 b on a.id = b.forum inner join +t1 c on b.id = c.thread +where +match(b.betreff) against ('+abc' in boolean mode) +union +select a.text, b.id, b.betreff +from +t2 a inner join t3 b on a.id = b.forum inner join +t1 c on b.id = c.thread +where +match(c.beitrag) against ('+abc' in boolean mode) +order by +match(betreff) against ('+abc' in boolean mode) desc; +text id betreff +(select b.id, b.betreff from t3 b) union +(select b.id, b.betreff from t3 b) +order by match(betreff) against ('+abc' in boolean mode) desc; +id betreff +(select b.id, b.betreff from t3 b) union +(select b.id, b.betreff from t3 b) +order by match(betreff) against ('+abc') desc; +ERROR HY000: Can't find FULLTEXT index matching the column list +select distinct b.id, b.betreff from t3 b +order by match(betreff) against ('+abc' in boolean mode) desc; +id betreff +select b.id, b.betreff from t3 b group by b.id+1 +order by match(betreff) against ('+abc' in boolean mode) desc; +id betreff +drop table t1,t2,t3; diff --git a/mysql-test/suite/innodb_fts/r/fulltext_update.result b/mysql-test/suite/innodb_fts/r/fulltext_update.result new file mode 100644 index 00000000..00d07773 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/fulltext_update.result @@ -0,0 +1,22 @@ +drop table if exists test; +CREATE TABLE test ( +gnr INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +url VARCHAR(80) DEFAULT '' NOT NULL, +shortdesc VARCHAR(200) DEFAULT '' NOT NULL, +longdesc text DEFAULT '' NOT NULL, +description VARCHAR(80) DEFAULT '' NOT NULL, +name VARCHAR(80) DEFAULT '' NOT NULL, +FULLTEXT(url,description,shortdesc,longdesc), +PRIMARY KEY(gnr) +) ENGINE = InnoDB; +insert into test (url,shortdesc,longdesc,description,name) VALUES +("http:/test.at", "kurz", "lang","desc", "name"); +insert into test (url,shortdesc,longdesc,description,name) VALUES +("http:/test.at", "kurz", "","desc", "name"); +update test set url='test', description='ddd', name='nam' where gnr=2; +update test set url='test', shortdesc='ggg', longdesc='mmm', +description='ddd', name='nam' where gnr=2; +check table test; +Table Op Msg_type Msg_text +test.test check status OK +drop table test; diff --git a/mysql-test/suite/innodb_fts/r/fulltext_var.result b/mysql-test/suite/innodb_fts/r/fulltext_var.result new file mode 100644 index 00000000..ee4ba98d --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/fulltext_var.result @@ -0,0 +1,34 @@ +show variables like "ft\_%"; +Variable_name Value +ft_boolean_syntax + -><()~*:""&| +ft_max_word_len 84 +ft_min_word_len 4 +ft_query_expansion_limit 20 +ft_stopword_file (built-in) +create table t1 (b text not null, fulltext(b)) engine = innodb; +insert t1 values ('aaaaaa bbbbbb cccccc'); +insert t1 values ('bbbbbb cccccc'); +insert t1 values ('aaaaaa cccccc'); +select * from t1 where match b against ('+aaaaaa bbbbbb' in boolean mode); +b +aaaaaa bbbbbb cccccc +aaaaaa cccccc +set ft_boolean_syntax=' +-><()~*:""&|'; +ERROR HY000: Variable 'ft_boolean_syntax' is a GLOBAL variable and should be set with SET GLOBAL +set global ft_boolean_syntax=' +-><()~*:""&|'; +select * from t1 where match b against ('+aaaaaa bbbbbb' in boolean mode); +b +aaaaaa bbbbbb cccccc +aaaaaa cccccc +set global ft_boolean_syntax='@ -><()~*:""&|'; +select * from t1 where match b against ('+aaaaaa bbbbbb' in boolean mode); +b +aaaaaa bbbbbb cccccc +aaaaaa cccccc +select * from t1 where match b against ('+aaaaaa @bbbbbb' in boolean mode); +ERROR 42000: syntax error, unexpected '@', expecting $end +set global ft_boolean_syntax='@ -><()~*:""@|'; +ERROR 42000: Variable 'ft_boolean_syntax' can't be set to the value of '@ -><()~*:""@|' +set global ft_boolean_syntax='+ -><()~*:""@!|'; +ERROR 42000: Variable 'ft_boolean_syntax' can't be set to the value of '+ -><()~*:""@!|' +drop table t1; diff --git a/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result b/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result new file mode 100644 index 00000000..15f5b295 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result @@ -0,0 +1,333 @@ +CREATE TABLE fts_test ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT +) ENGINE=InnoDB; +INSERT INTO fts_test (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=NOCOPY; +ERROR 0A000: ALGORITHM=NOCOPY is not supported for this operation. Try ALGORITHM=INPLACE +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=INPLACE; +SELECT * FROM fts_test WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +DROP INDEX idx ON fts_test; +INSERT INTO fts_test (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=NOCOPY; +SELECT * FROM fts_test WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +7 MySQL Tutorial DBMS stands for DataBase ... +9 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM fts_test WHERE MATCH (title,body) +AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +12 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +7 MySQL Tutorial DBMS stands for DataBase ... +8 How To Use MySQL Well After you went through a ... +9 Optimizing MySQL In this tutorial we will show ... +10 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +TRUNCATE TABLE fts_test; +DROP INDEX idx ON fts_test; +INSERT INTO fts_test (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +CREATE FULLTEXT INDEX idx on fts_test (title, body); +SELECT * FROM fts_test WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +DROP TABLE fts_test; +CREATE TABLE fts_test ( +FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT +) ENGINE=InnoDB; +INSERT INTO fts_test (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +CREATE FULLTEXT INDEX idx on fts_test (title, body) LOCK=NONE; +ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=NOCOPY; +ALTER TABLE fts_test ROW_FORMAT=REDUNDANT, LOCK=NONE; +ERROR 0A000: LOCK=NONE is not supported. Reason: Fulltext index creation requires a lock. Try LOCK=SHARED +ALTER TABLE fts_test ROW_FORMAT=REDUNDANT; +SELECT * FROM fts_test WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +FTS_DOC_ID title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +drop index idx on fts_test; +CREATE FULLTEXT INDEX idx on fts_test (title, body); +SELECT * FROM fts_test WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +FTS_DOC_ID title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +drop index idx on fts_test; +CREATE FULLTEXT INDEX idx on fts_test (title, body); +SELECT * FROM fts_test WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +FTS_DOC_ID title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +drop table fts_test; +CREATE TABLE fts_test ( +FTS_DOC_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, +title varchar(255) NOT NULL DEFAULT '', +text mediumtext NOT NULL, +PRIMARY KEY (FTS_DOC_ID), +UNIQUE KEY FTS_DOC_ID_INDEX (FTS_DOC_ID), +FULLTEXT KEY idx (title,text) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; +set @@auto_increment_increment=10; +INSERT INTO fts_test (title, text) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...'), +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +ANALYZE TABLE fts_test; +set @@auto_increment_increment=1; +select *, match(title, text) AGAINST ('database') as score +from fts_test order by score desc; +FTS_DOC_ID title text score +11 MySQL Tutorial DBMS stands for DataBase ... 0.22764469683170319 +51 MySQL vs. YourSQL In the following database comparison ... 0.22764469683170319 +21 How To Use MySQL Well After you went through a ... 0 +31 Optimizing MySQL In this tutorial we will show ... 0 +41 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... 0 +61 MySQL Security When configured properly, MySQL ... 0 +drop index idx on fts_test; +drop table fts_test; +CREATE TABLE fts_test ( +FTS_DOC_ID int(20) unsigned NOT NULL AUTO_INCREMENT, +title varchar(255) NOT NULL DEFAULT '', +text mediumtext NOT NULL, +PRIMARY KEY (FTS_DOC_ID), +UNIQUE KEY FTS_DOC_ID_INDEX (FTS_DOC_ID), +FULLTEXT KEY idx (title,text) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +CREATE TABLE fts_test ( +FTS_DOC_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, +title varchar(255) NOT NULL DEFAULT '', +text mediumtext NOT NULL, +PRIMARY KEY (FTS_DOC_ID), +KEY FTS_DOC_ID_INDEX (FTS_DOC_ID), +FULLTEXT KEY idx (title,text) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; +ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index +CREATE TABLE articles ( +FTS_DOC_ID BIGINT UNSIGNED NOT NULL , +title VARCHAR(200), +body TEXT +) ENGINE=InnoDB; +INSERT INTO articles (FTS_DOC_ID, title, body) VALUES +(9, 'MySQL Tutorial','DBMS stands for DataBase ...'), +(10, 'How To Use MySQL Well','After you went through a ...'), +(12, 'Optimizing MySQL','In this tutorial we will show ...'), +(14,'1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +(19, 'MySQL vs. YourSQL','In the following database comparison ...'), +(20, 'MySQL Security','When configured properly, MySQL ...'); +ALTER TABLE articles ADD FULLTEXT INDEX idx (title), +ADD FULLTEXT INDEX idx3 (title), ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY +ALTER TABLE articles ADD FULLTEXT INDEX idx (title), +ADD FULLTEXT INDEX idx3 (title); +affected rows: 6 +info: Records: 6 Duplicates: 0 Warnings: 1 +Warnings: +Note 1831 Duplicate index `idx3`. This is deprecated and will be disallowed in a future release +ALTER TABLE articles ADD INDEX t20 (title(20)), LOCK=NONE; +ALTER TABLE articles DROP INDEX t20; +INSERT INTO articles (FTS_DOC_ID, title, body) VALUES +(29, 'MySQL Tutorial','DBMS stands for DataBase ...'), +(30, 'How To Use MySQL Well','After you went through a ...'), +(32, 'Optimizing MySQL','In this tutorial we will show ...'), +(34,'1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +(39, 'MySQL vs. YourSQL','In the following database comparison ...'), +(40, 'MySQL Security','When configured properly, MySQL ...'); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +FTS_DOC_ID title body +9 MySQL Tutorial DBMS stands for DataBase ... +29 MySQL Tutorial DBMS stands for DataBase ... +DROP INDEX idx ON articles; +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +FTS_DOC_ID title body +9 MySQL Tutorial DBMS stands for DataBase ... +29 MySQL Tutorial DBMS stands for DataBase ... +CREATE FULLTEXT INDEX idx on articles (title, body); +SELECT * FROM articles WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +FTS_DOC_ID title body +9 MySQL Tutorial DBMS stands for DataBase ... +12 Optimizing MySQL In this tutorial we will show ... +29 MySQL Tutorial DBMS stands for DataBase ... +32 Optimizing MySQL In this tutorial we will show ... +DROP TABLE articles; +create table articles(`FTS_DOC_ID` serial, +`col32` timestamp not null,`col115` text) engine=innodb; +create fulltext index `idx5` on articles(`col115`) ; +alter ignore table articles add primary key (`col32`) ; +drop table articles; +CREATE TABLE articles ( +id INT UNSIGNED NOT NULL, +title VARCHAR(200), +body TEXT +) ENGINE=InnoDB; +INSERT INTO articles VALUES +(1, 'MySQL Tutorial','DBMS stands for DataBase ...') , +(2, 'How To Use MySQL Well','After you went through a ...'), +(3, 'Optimizing MySQL','In this tutorial we will show ...'), +(4, '1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +(5, 'MySQL vs. YourSQL','In the following database comparison ...'), +(6, 'MySQL Security','When configured properly, MySQL ...'); +CREATE FULLTEXT INDEX idx on articles (title, body); +DROP INDEX idx ON articles; +CREATE UNIQUE INDEX idx2 ON articles(id); +CREATE FULLTEXT INDEX idx on articles (title, body); +SELECT * FROM articles WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +DROP TABLE articles; +# +# MDEV-22811 DDL fails to drop and re-create FTS index +# +CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED PRIMARY KEY, +f1 VARCHAR(200),FULLTEXT fidx(f1))engine=innodb; +ALTER TABLE t1 DROP index fidx, ADD FULLTEXT INDEX(f1); +DROP TABLE t1; +# +# MDEV-21478 Inplace alter fails to report error when +# FTS_DOC_ID is added +SET NAMES utf8; +CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB; +ALTER TABLE t1 ADD FTS_DOC_ıD BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY; +ALTER TABLE t1 DROP COLUMN FTS_DOC_ıD; +ALTER TABLE t1 ADD FTS_DOC_ıD BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; +DROP TABLE t1; +CREATE TABLE t1 (f1 INT NOT NULL)ENGINE=InnoDB; +ALTER TABLE t1 ADD FTS_DOC_Ä°D BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'FTS_DOC_Ä°D' +ALTER TABLE t1 ADD FTS_DOC_Ä°D BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'FTS_DOC_Ä°D' +ALTER TABLE t1 ADD fts_doc_id INT, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'fts_doc_id' +ALTER TABLE t1 ADD fts_doc_id INT, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'fts_doc_id' +ALTER TABLE t1 ADD fts_doc_id BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'fts_doc_id' +ALTER TABLE t1 ADD fts_doc_id BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'fts_doc_id' +ALTER TABLE t1 ADD FTS_DOC_ID INT UNSIGNED NOT NULL, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1 ADD FTS_DOC_ID INT UNSIGNED NOT NULL, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DROP TABLE t1; +# +# MDEV-25271 Double free of table when inplace alter +# FTS add index fails +# +call mtr.add_suppression("InnoDB: Operating system error number .* in a file operation."); +call mtr.add_suppression("InnoDB: Error number .* means"); +call mtr.add_suppression("InnoDB: Cannot create file"); +call mtr.add_suppression("InnoDB: Failed to create"); +CREATE TABLE t1(a TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL UNIQUE) ENGINE=InnoDB; +ALTER TABLE t1 ADD FULLTEXT(a), ALGORITHM=INPLACE; +ERROR HY000: Got error 11 "Resource temporarily unavailable" from storage engine InnoDB +DROP TABLE t1; +CREATE TABLE t1 (a VARCHAR(3)) ENGINE=InnoDB; +ALTER TABLE t1 ADD FULLTEXT KEY(a), ADD COLUMN b VARCHAR(3), ADD FULLTEXT KEY(b); +DROP TABLE t1; +# +# MDEV-18152 Assertion 'num_fts_index <= 1' failed +# in prepare_inplace_alter_table_dict +# +CREATE TABLE t1 +(a VARCHAR(128), b VARCHAR(128), FULLTEXT INDEX(a), FULLTEXT INDEX(b)) +ENGINE=InnoDB; +ALTER TABLE t1 ADD c SERIAL; +DROP TABLE t1; +# End of 10.3 tests +# +# MDEV-27582 Fulltext DDL decrements the FTS_DOC_ID value +# +CREATE TABLE t1 ( +f1 INT NOT NULL PRIMARY KEY, +f2 VARCHAR(64), FULLTEXT ft(f2)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); +connect con1,localhost,root,,,; +START TRANSACTION WITH CONSISTENT SNAPSHOT; +connection default; +DELETE FROM t1 WHERE f1 = 2; +ALTER TABLE t1 DROP INDEX ft; +ALTER TABLE t1 ADD FULLTEXT INDEX ft (f2); +INSERT INTO t1 VALUES (3, 'innodb fts search'); +SET GLOBAL innodb_optimize_fulltext_only=ON; +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +SET GLOBAL innodb_ft_aux_table = 'test/t1'; +SELECT max(DOC_ID) FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +max(DOC_ID) +3 +SELECT * FROM t1 WHERE MATCH(f2) AGAINST("+innodb +search" IN BOOLEAN MODE); +f1 f2 +3 innodb fts search +DROP TABLE t1; +disconnect con1; +SET GLOBAL innodb_optimize_fulltext_only=OFF; +SET GLOBAL innodb_ft_aux_table = default; +# +# MDEV-32017 Auto-increment no longer works for +# explicit FTS_DOC_ID +# +CREATE TABLE t ( +FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, +f1 char(255), f2 char(255), f3 char(255), fulltext key (f3) +) ENGINE=InnoDB; +INSERT INTO t (f1,f2,f3) VALUES ('foo','bar','baz'); +ALTER TABLE t ADD FULLTEXT INDEX ft1(f1); +ALTER TABLE t ADD FULLTEXT INDEX ft2(f2); +INSERT INTO t (f1,f2,f3) VALUES ('bar','baz','qux'); +DROP TABLE t; diff --git a/mysql-test/suite/innodb_fts/r/innodb-fts-fic.result b/mysql-test/suite/innodb_fts/r/innodb-fts-fic.result new file mode 100644 index 00000000..f998881f --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/innodb-fts-fic.result @@ -0,0 +1,190 @@ +call mtr.add_suppression("\\[Warning\\] InnoDB: A new Doc ID must be supplied while updating FTS indexed columns."); +call mtr.add_suppression("\\[Warning\\] InnoDB: FTS Doc ID must be larger than [0-9]+ for table `test`.`articles`"); +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT +) ENGINE=InnoDB; +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +CREATE FULLTEXT INDEX idx on articles (title, body); +SELECT * FROM articles WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT COUNT(*) FROM articles +WHERE MATCH (title, body) +AGAINST ('database' IN NATURAL LANGUAGE MODE); +COUNT(*) +2 +SELECT * FROM articles +WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT COUNT(IF(MATCH (title, body) +AGAINST ('database' IN NATURAL LANGUAGE MODE), 1, NULL)) +AS count FROM articles; +count +2 +ANALYZE TABLE articles; +Table Op Msg_type Msg_text +test.articles analyze status Engine-independent statistics collected +test.articles analyze Warning Engine-independent statistics are not collected for column 'body' +test.articles analyze status OK +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('DBMS Security' IN BOOLEAN MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL +YourSQL' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +DROP INDEX idx ON articles; +CREATE FULLTEXT INDEX idx on articles (title, body); +CREATE FULLTEXT INDEX idx1 on articles (title); +SELECT * FROM articles WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +DROP INDEX idx ON articles; +DROP INDEX idx1 ON articles; +CREATE FULLTEXT INDEX idx1 on articles (title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +drop table articles; +CREATE TABLE articles ( +FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT +) ENGINE=InnoDB; +create unique index FTS_DOC_ID_INDEX on articles(FTS_DOC_ID); +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +CREATE FULLTEXT INDEX idx on articles (title, body); +SELECT * FROM articles WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +FTS_DOC_ID title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +drop table articles; +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT +) ENGINE=InnoDB; +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +CREATE FULLTEXT INDEX idx on articles (title); +CREATE FULLTEXT INDEX idx2 on articles (body); +SELECT * FROM articles WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +ERROR HY000: Can't find FULLTEXT index matching the column list +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +SELECT * FROM articles WHERE MATCH (body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +3 Optimizing MySQL In this tutorial we will show ... +drop index idx2 on articles; +SELECT * FROM articles WHERE MATCH (body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +ERROR HY000: Can't find FULLTEXT index matching the column list +CREATE FULLTEXT INDEX idx2 on articles (body); +SELECT * FROM articles WHERE MATCH (body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +3 Optimizing MySQL In this tutorial we will show ... +UPDATE articles set title = 'aaaa' +WHERE MATCH(title) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('aaaa' IN NATURAL LANGUAGE MODE); +id title body +1 aaaa DBMS stands for DataBase ... +drop table articles; +CREATE TABLE articles ( +FTS_DOC_ID BIGINT UNSIGNED NOT NULL , +title VARCHAR(200), +body TEXT +) ENGINE=InnoDB; +CREATE FULLTEXT INDEX idx on articles (title); +INSERT INTO articles VALUES (9, 'MySQL Tutorial','DBMS stands for DataBase ...'); +UPDATE articles set title = 'bbbb' WHERE MATCH(title) AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); +ERROR HY000: Invalid InnoDB FTS Doc ID +UPDATE articles set title = 'bbbb', FTS_DOC_ID=8 WHERE MATCH(title) AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); +ERROR HY000: Invalid InnoDB FTS Doc ID +UPDATE articles set title = 'bbbb', FTS_DOC_ID=10 WHERE MATCH(title) AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); +SELECT * FROM articles WHERE MATCH (title) AGAINST ('bbbb' IN NATURAL LANGUAGE MODE); +FTS_DOC_ID title body +10 bbbb DBMS stands for DataBase ... +SELECT * FROM articles WHERE MATCH (title) AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); +FTS_DOC_ID title body +CREATE FULLTEXT INDEX idx2 ON articles (body); +SELECT * FROM articles WHERE MATCH (body) AGAINST ('database' IN NATURAL LANGUAGE MODE); +FTS_DOC_ID title body +10 bbbb DBMS stands for DataBase ... +UPDATE articles set body = 'bbbb', FTS_DOC_ID=11 WHERE MATCH(body) AGAINST ('database' IN NATURAL LANGUAGE MODE); +drop table articles; +create table `articles`(`a` varchar(2) not null)engine=innodb; +create fulltext index `FTS_DOC_ID_INDEX` on `articles`(`a`); +ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index +create unique index `a` on `articles`(`a`); +drop table articles; +CREATE TABLE wp( +FTS_DOC_ID bigint PRIMARY KEY, +title VARCHAR(255) NOT NULL DEFAULT '', +text MEDIUMTEXT NOT NULL ) ENGINE=InnoDB; +INSERT INTO wp (FTS_DOC_ID, title, text) VALUES +(1, 'MySQL Tutorial','DBMS stands for DataBase ...'), +(2, 'How To Use MySQL Well','After you went through a ...'); +CREATE FULLTEXT INDEX idx ON wp(title, text); +ERROR HY000: Column 'FTS_DOC_ID' is of wrong type for an InnoDB FULLTEXT index +DROP TABLE wp; +CREATE TABLE wp( +FTS_DOC_ID bigint unsigned PRIMARY KEY, +title VARCHAR(255) NOT NULL DEFAULT '', +text MEDIUMTEXT NOT NULL ) ENGINE=InnoDB; +INSERT INTO wp (FTS_DOC_ID, title, text) VALUES +(1, 'MySQL Tutorial','DBMS stands for DataBase ...'), +(2, 'How To Use MySQL Well','After you went through a ...'); +CREATE FULLTEXT INDEX idx ON wp(title, text); +SELECT FTS_DOC_ID, MATCH(title, text) AGAINST ('database') +FROM wp; +FTS_DOC_ID MATCH(title, text) AGAINST ('database') +1 0.0906190574169159 +2 0 +DROP TABLE wp; diff --git a/mysql-test/suite/innodb_fts/r/innodb_ft_aux_table.result b/mysql-test/suite/innodb_fts/r/innodb_ft_aux_table.result new file mode 100644 index 00000000..a1ffb0a5 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/innodb_ft_aux_table.result @@ -0,0 +1,121 @@ +CREATE TABLE t1 (v VARCHAR(100), FULLTEXT INDEX (v)) ENGINE=InnoDB; +insert into t1 VALUES('First record'),('Second record'),('Third record'); +SET @save_ft_aux_table = @@GLOBAL.innodb_ft_aux_table; +connect con1,localhost,root,,; +SET GLOBAL innodb_ft_aux_table = 'test/t0'; +ERROR 42000: Variable 'innodb_ft_aux_table' can't be set to the value of 'test/t0' +connection default; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DEFAULT_STOPWORD; +value +a +about +an +are +as +at +be +by +com +de +en +for +from +how +i +in +is +it +la +of +on +or +that +the +this +to +was +what +when +where +who +will +with +und +the +www +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DELETED; +DOC_ID +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED; +DOC_ID +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_CONFIG; +KEY VALUE +connection con1; +SET GLOBAL innodb_ft_aux_table = 'test/t1'; +disconnect con1; +connection default; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DELETED; +DOC_ID +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED; +DOC_ID +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +first 1 1 1 1 0 +record 1 3 3 1 6 +record 1 3 3 2 7 +record 1 3 3 3 6 +second 2 2 1 2 0 +third 3 3 1 3 0 +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_CONFIG; +KEY VALUE +optimize_checkpoint_limit 180 +synced_doc_id 0 +stopword_table_name +use_stopword 1 +SELECT @@GLOBAL.innodb_ft_aux_table; +@@GLOBAL.innodb_ft_aux_table +test/t1 +RENAME TABLE t1 TO t2; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DELETED; +DOC_ID +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED; +DOC_ID +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +first 1 1 1 1 0 +record 1 3 3 1 6 +record 1 3 3 2 7 +record 1 3 3 3 6 +second 2 2 1 2 0 +third 3 3 1 3 0 +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_CONFIG; +KEY VALUE +optimize_checkpoint_limit 180 +synced_doc_id 0 +stopword_table_name +use_stopword 1 +SELECT @@GLOBAL.innodb_ft_aux_table; +@@GLOBAL.innodb_ft_aux_table +test/t1 +DROP TABLE t2; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DELETED; +DOC_ID +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED; +DOC_ID +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_CONFIG; +KEY VALUE +SELECT @@GLOBAL.innodb_ft_aux_table; +@@GLOBAL.innodb_ft_aux_table +test/t1 +SET GLOBAL innodb_ft_aux_table = @save_ft_aux_table; diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_large_records.result b/mysql-test/suite/innodb_fts/r/innodb_fts_large_records.result new file mode 100644 index 00000000..294bfcb0 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_large_records.result @@ -0,0 +1,305 @@ +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( +FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a TEXT, +b TEXT +) ENGINE = InnoDB; +CREATE UNIQUE INDEX FTS_DOC_ID_INDEX on t1(FTS_DOC_ID); +"Loading data using LOAD DATA Command , File <MYSQLTEST_VARDIR>/tmp/fts_input_data1.txt" +CREATE FULLTEXT INDEX idx on t1 (a,b); +SELECT COUNT(*) FROM t1; +COUNT(*) +49 +SELECT FTS_DOC_ID FROM t1 WHERE MATCH (a,b) +AGAINST ('row35col2word49' IN NATURAL LANGUAGE MODE); +FTS_DOC_ID +35 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row5col2word49 +row5col1word49" IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row5col2word49" IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row35col2word49 +(row35col1word49 row35col2word40)" IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row35col2word49 -(row45col2word49)" IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("row5col2word49 row5col2word40" IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH a,b AGAINST ("+row5col2word* +row5col1word49*" IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH a,b AGAINST ('"row35col2word49"' IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH a,b AGAINST ('"ROW35col2WORD49"' IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST ("row5col2word49" WITH QUERY EXPANSION); +COUNT(*) +1 +SELECT FTS_DOC_ID FROM t1 +WHERE MATCH (a,b) +AGAINST ('"row5col2word48 row5col2word49"@2' IN BOOLEAN MODE); +FTS_DOC_ID +5 +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"row5col2word48 row5col2word49"@1' IN BOOLEAN MODE); +FTS_DOC_ID a b +UPDATE t1 SET a = "using update" , b = "changing fulltext index record", FTS_DOC_ID = FTS_DOC_ID + 10000 +WHERE MATCH(a,b) AGAINST("+row5col2word49 +row5col1word49" IN BOOLEAN MODE); +SELECT a,b FROM t1 WHERE MATCH(a,b) AGAINST("+row5col2word49 +row5col1word49" IN BOOLEAN MODE); +a b +SELECT a,b FROM t1 WHERE MATCH(a,b) AGAINST("changing fulltext" IN BOOLEAN MODE); +a b +using update changing fulltext index record +SELECT a,b FROM t1 WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +a b +using update changing fulltext index record +DELETE FROM t1 WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +SELECT a,b FROM t1 WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +a b +DROP TABLE t1; +CREATE TABLE t1 ( +FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a TEXT, +b TEXT +) ENGINE = InnoDB; +CREATE UNIQUE INDEX FTS_DOC_ID_INDEX on t1(FTS_DOC_ID); +"Loading data using LOAD DATA Command , File <MYSQLTEST_VARDIR>/tmp/fts_input_data2.txt" +CREATE FULLTEXT INDEX idx on t1 (a,b); +SELECT COUNT(*) FROM t1; +COUNT(*) +100 +SELECT FTS_DOC_ID from t1 WHERE b like '%row300col2word30%'; +FTS_DOC_ID +SELECT FTS_DOC_ID FROM t1 WHERE MATCH (a,b) +AGAINST ('row35col2word49' IN NATURAL LANGUAGE MODE); +FTS_DOC_ID +35 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row5col2word49 +row5col1word49" IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row5col2word49" IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row35col2word49 +(row35col1word49 row35col2word40)" IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row35col2word49 -(row45col2word49)" IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("row5col2word49 row5col2word40" IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH a,b AGAINST ("+row5col2word* +row5col1word49*" IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH a,b AGAINST ('"row35col2word49"' IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 +WHERE MATCH a,b AGAINST ('"ROW35col2WORD49"' IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) from t1 WHERE MATCH(a,b) AGAINST ("row5col2word49" WITH QUERY EXPANSION); +COUNT(*) +1 +SELECT FTS_DOC_ID FROM t1 +WHERE MATCH (a,b) +AGAINST ('"row5col2word48 row5col2word49"@2' IN BOOLEAN MODE); +FTS_DOC_ID +5 +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"row5col2word48 row5col2word49"@1' IN BOOLEAN MODE); +FTS_DOC_ID a b +UPDATE t1 SET a = "using update" , b = "changing fulltext index record", FTS_DOC_ID = FTS_DOC_ID + 10000 +WHERE MATCH(a,b) AGAINST("+row5col2word49 +row5col1word49" IN BOOLEAN MODE); +SELECT a,b FROM t1 +WHERE MATCH(a,b) AGAINST("+row5col2word49 +row5col1word49" IN BOOLEAN MODE); +a b +SELECT a,b FROM t1 +WHERE MATCH(a,b) AGAINST("changing fulltext" IN BOOLEAN MODE); +a b +using update changing fulltext index record +SELECT a,b FROM t1 +WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +a b +using update changing fulltext index record +DELETE FROM t1 WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +SELECT a,b FROM t1 WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +a b +ALTER TABLE t1 DROP INDEX idx; +CREATE FULLTEXT INDEX idx on t1 (a,b); +UPDATE t1 SET a = NULL , b = NULL, FTS_DOC_ID= 6000 + FTS_DOC_ID; +SELECT COUNT(*) FROM t1 WHERE a IS NULL AND b IS NULL; +COUNT(*) +99 +ALTER TABLE t1 DROP INDEX idx; +SELECT COUNT(*) FROM t1 WHERE a IS NULL AND b IS NULL; +COUNT(*) +99 +DROP TABLE t1; +CREATE TABLE t1 ( +FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a TEXT, +b TEXT +) ENGINE = InnoDB; +CREATE UNIQUE INDEX FTS_DOC_ID_INDEX on t1(FTS_DOC_ID); +"Loading data using LOAD DATA Command , File <MYSQLTEST_VARDIR>/tmp/fts_input_data3.txt" +CREATE FULLTEXT INDEX idx on t1 (a,b); +SELECT COUNT(*) FROM t1; +COUNT(*) +100 +SELECT COUNT(*) from t1 WHERE b like '%samerowword%'; +COUNT(*) +100 +SELECT COUNT(*) FROM t1 WHERE MATCH (a,b) +AGAINST ('samerowword' IN NATURAL LANGUAGE MODE); +COUNT(*) +100 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+samerowword +samerowword" IN BOOLEAN MODE); +COUNT(*) +100 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+samerowword" IN BOOLEAN MODE); +COUNT(*) +100 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+samerowword -(row45col2word49)" IN BOOLEAN MODE); +COUNT(*) +100 +SELECT COUNT(*) from t1 +WHERE MATCH a,b AGAINST ("+sameroww" IN BOOLEAN MODE); +COUNT(*) +0 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST ("samerowword" WITH QUERY EXPANSION); +COUNT(*) +100 +UPDATE t1 SET a = "using update" , b = "changing fulltext index record", +FTS_DOC_ID = FTS_DOC_ID + 10000 +WHERE MATCH(a,b) AGAINST("+samerowword +samerowword" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+samerowword +samerowword" IN BOOLEAN MODE); +COUNT(*) +0 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+samerowword" IN BOOLEAN MODE); +COUNT(*) +0 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("changing fulltext" IN BOOLEAN MODE); +COUNT(*) +100 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +COUNT(*) +100 +DELETE FROM t1 WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +COUNT(*) +0 +ALTER TABLE t1 DROP INDEX idx; +CREATE FULLTEXT INDEX idx on t1 (a,b); +UPDATE t1 SET a = NULL , b = NULL ; +SELECT COUNT(*) FROM t1 WHERE a IS NULL AND b IS NULL; +COUNT(*) +0 +ALTER TABLE t1 DROP INDEX idx; +SELECT COUNT(*) FROM t1 WHERE a IS NULL AND b IS NULL; +COUNT(*) +0 +DROP TABLE t1; +CREATE TABLE t1 ( +FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a TEXT, +b TEXT +) ENGINE = InnoDB; +CREATE UNIQUE INDEX FTS_DOC_ID_INDEX on t1(FTS_DOC_ID); +"Loading data using LOAD DATA Command , File <MYSQLTEST_VARDIR>/tmp/fts_input_data4.txt" +CREATE FULLTEXT INDEX idx on t1 (a,b); +SELECT COUNT(*) FROM t1; +COUNT(*) +100 +SELECT COUNT(*) from t1 WHERE a like '%samerowword%'; +COUNT(*) +100 +SELECT COUNT(*) FROM t1 WHERE MATCH (a,b) +AGAINST ('samerowword' IN NATURAL LANGUAGE MODE); +COUNT(*) +100 +SELECT COUNT(*) from t1 WHERE MATCH(a,b) AGAINST("+samerowword +1050" IN BOOLEAN MODE); +COUNT(*) +100 +SELECT COUNT(*) from t1 WHERE MATCH(a,b) AGAINST("+samerowword" IN BOOLEAN MODE); +COUNT(*) +100 +SELECT COUNT(*) from t1 WHERE MATCH(a,b) AGAINST("+samerowword -(1050)" IN BOOLEAN MODE); +COUNT(*) +0 +SELECT COUNT(*) from t1 WHERE MATCH a,b AGAINST ("+2001" IN BOOLEAN MODE); +COUNT(*) +0 +SELECT COUNT(*) from t1 WHERE MATCH(a,b) AGAINST ("samerowword" WITH QUERY EXPANSION); +COUNT(*) +100 +UPDATE t1 SET a = "using update" , b = "changing fulltext index record", +FTS_DOC_ID = FTS_DOC_ID + 10000 +WHERE MATCH(a,b) AGAINST("+samerowword +1050" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+samerowword +1050" IN BOOLEAN MODE); +COUNT(*) +0 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+samerowword" IN BOOLEAN MODE); +COUNT(*) +0 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("changing fulltext" IN BOOLEAN MODE); +COUNT(*) +100 +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +COUNT(*) +100 +DELETE FROM t1 +WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +COUNT(*) +0 +ALTER TABLE t1 DROP INDEX idx; +CREATE FULLTEXT INDEX idx on t1 (a,b); +UPDATE t1 SET a = NULL , b = NULL ; +SELECT COUNT(*) FROM t1 WHERE a IS NULL AND b IS NULL; +COUNT(*) +0 +ALTER TABLE t1 DROP INDEX idx; +SELECT COUNT(*) FROM t1 WHERE a IS NULL AND b IS NULL; +COUNT(*) +0 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result b/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result new file mode 100644 index 00000000..2cc992be --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_misc.result @@ -0,0 +1,1395 @@ +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB; +INSERT INTO t1 (a,b) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'); +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `a` varchar(200) DEFAULT NULL, + `b` text DEFAULT NULL, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx` (`a`,`b`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO t1 (a,b) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id +1 +3 +select id from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +id +select id, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; +id x +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +select id, MATCH(a,b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; +id x +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +select id from t1 where MATCH a,b AGAINST ("+call* +coll*" IN BOOLEAN MODE); +id +select id from t1 where MATCH a,b AGAINST ('"support now"' IN BOOLEAN MODE); +id +select id from t1 where MATCH a,b AGAINST ('"Now sUPPort"' IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST ("collections" WITH QUERY EXPANSION); +id +select id from t1 where MATCH(a,b) AGAINST ("indexes" WITH QUERY EXPANSION); +id +select id from t1 where MATCH(a,b) AGAINST ("indexes collections" WITH QUERY EXPANSION); +id +ALTER TABLE t1 DROP INDEX idx; +CREATE FULLTEXT INDEX idx on t1 (a,b); +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id +1 +3 +select id from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +id +select id, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; +id x +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +select id, MATCH(a,b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; +id x +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +select id from t1 where MATCH a,b AGAINST ("+call* +coll*" IN BOOLEAN MODE); +id +select id from t1 where MATCH a,b AGAINST ('"support now"' IN BOOLEAN MODE); +id +select id from t1 where MATCH a,b AGAINST ('"Now sUPPort"' IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST ("collections" WITH QUERY EXPANSION); +id +select id from t1 where MATCH(a,b) AGAINST ("indexes" WITH QUERY EXPANSION); +id +select id from t1 where MATCH(a,b) AGAINST ("indexes collections" WITH QUERY EXPANSION); +id +INSERT INTO t1 (a,b) VALUES ('test query expansion','for database ...'); +INSERT INTO t1 (a,b) VALUES +('test proximity search, test, proximity and phrase', +'search, with proximity innodb'); +INSERT INTO t1 (a,b) VALUES +('test proximity fts search, test, proximity and phrase', +'search, with proximity innodb'); +INSERT INTO t1 (a,b) VALUES +('test more proximity fts search, test, more proximity and phrase', +'search, with proximity innodb'); +SELECT id FROM t1 +WHERE MATCH (a,b) +AGAINST ('"proximity search"@2' IN BOOLEAN MODE); +id +8 +SELECT id FROM t1 +WHERE MATCH (a,b) +AGAINST ('"proximity search"@1' IN BOOLEAN MODE); +id +SELECT id FROM t1 +WHERE MATCH (a,b) +AGAINST ('"proximity search"@3' IN BOOLEAN MODE); +id +8 +9 +10 +SELECT id FROM t1 +WHERE MATCH (a,b) +AGAINST ('"test proximity"@3' IN BOOLEAN MODE); +id +8 +9 +10 +SELECT id FROM t1 +WHERE MATCH (a,b) +AGAINST ('"more test proximity"@3' IN BOOLEAN MODE); +id +10 +SELECT id FROM t1 +WHERE MATCH (a,b) +AGAINST ('"more test proximity"@2' IN BOOLEAN MODE); +id +SELECT id FROM t1 +WHERE MATCH (a,b) +AGAINST ('"more fts proximity"@02' IN BOOLEAN MODE); +id +DROP TABLE t1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB; +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'); +INSERT INTO t1 (a,b) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id +1 +3 +SELECT id FROM t1 WHERE id = (SELECT MAX(id) FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)); +id +3 +SELECT id FROM t1 WHERE id = (SELECT MIN(id) FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)); +id +1 +SELECT id FROM t1 WHERE id = (SELECT MIN(id) FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)) OR id = 3 ; +id +1 +3 +SELECT id FROM t1 WHERE CONCAT(t1.a,t1.b) IN ( +SELECT CONCAT(a,b) FROM t1 AS t2 WHERE +MATCH (t2.a,t2.b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +) OR t1.id = 3 ; +id +1 +3 +SELECT id FROM t1 WHERE CONCAT(t1.a,t1.b) IN ( +SELECT CONCAT(a,b) FROM t1 AS t2 +WHERE MATCH (t2.a,t2.b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +AND t2.id != 3) ; +id +1 +SELECT id FROM t1 WHERE id IN (SELECT MIN(id) FROM t1 WHERE +MATCH (a,b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)) OR id = 3 ; +id +1 +3 +SELECT id FROM t1 WHERE id NOT IN (SELECT MIN(id) FROM t1 +WHERE MATCH (a,b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)) ; +id +2 +3 +4 +5 +6 +SELECT id FROM t1 WHERE EXISTS (SELECT t2.id FROM t1 AS t2 WHERE +MATCH (t2.a,t2.b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +AND t1.id = t2.id) ; +id +1 +3 +SELECT id FROM t1 WHERE NOT EXISTS (SELECT t2.id FROM t1 AS t2 WHERE +MATCH (t2.a,t2.b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +AND t1.id = t2.id) ; +id +2 +4 +5 +6 +DROP TABLE t1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT , +FULLTEXT (a,b) +) ENGINE = InnoDB; +INSERT INTO t1(a,b) VALUES('MySQL has now support', 'for full-text search'), +('Full-text indexes', 'are called collections'), +('Only MyISAM tables','support collections'), +('Function MATCH ... AGAINST()','is used to do a search'), +('Full-text search in MySQL', 'implements vector space model'); +SELECT id FROM t1 WHERE t1.id = (SELECT MAX(t2.id) FROM t1 AS t2 WHERE +MATCH(t2.a,t2.b) AGAINST("+support +collections" IN BOOLEAN MODE)); +id +3 +SELECT id FROM t1 WHERE t1.id != (SELECT MIN(t2.id) FROM t1 AS t2 WHERE +MATCH(t2.a,t2.b) AGAINST("+search" IN BOOLEAN MODE)); +id +2 +3 +4 +5 +SELECT id FROM t1 WHERE t1.id IN (SELECT t2.id FROM t1 AS t2 WHERE +MATCH (t2.a,t2.b) AGAINST ("+call* +coll*" IN BOOLEAN MODE)); +id +2 +SELECT id FROM t1 WHERE EXISTS (SELECT id FROM t1 AS t2 WHERE +MATCH t2.a,t2.b AGAINST ('"Now sUPPort"' IN BOOLEAN MODE) AND t2.id=t1.id); +id +1 +INSERT INTO t1 (a,b) VALUES ('test query expansion','for database ...'); +INSERT INTO t1 (a,b) VALUES +('test proximity search, test, proximity and phrase', +'search, with proximity innodb'); +INSERT INTO t1 (a,b) VALUES +('test proximity fts search, test, proximity and phrase', +'search, with proximity innodb'); +INSERT INTO t1 (a,b) VALUES +('test more proximity fts search, test, more proximity and phrase', +'search, with proximity innodb'); +SELECT id FROM t1 WHERE t1.id = (SELECT MAX(t2.id) FROM t1 AS t2 WHERE +MATCH(t2.a,t2.b) AGAINST ('"proximity search"@2' IN BOOLEAN MODE)); +id +7 +SELECT id FROM t1 WHERE t1.id > (SELECT MIN(t2.id) FROM t1 AS t2 WHERE +MATCH(t2.a,t2.b) AGAINST ('"proximity search"@2' IN BOOLEAN MODE)); +id +8 +9 +SELECT id FROM t1 WHERE t1.id IN (SELECT t2.id FROM t1 AS t2 WHERE +MATCH (t2.a,t2.b) AGAINST ('"proximity search"@2' IN BOOLEAN MODE)); +id +7 +SELECT id FROM t1 WHERE EXISTS (SELECT id FROM t1 AS t2 WHERE +MATCH t2.a,t2.b AGAINST ('"proximity search"@2' IN BOOLEAN MODE) +AND t2.id=t1.id); +id +7 +SELECT id FROM t1 WHERE EXISTS (SELECT id FROM t1 AS t2 WHERE +MATCH t2.a,t2.b AGAINST ('"more test proximity"@3' IN BOOLEAN MODE) +AND t2.id=t1.id); +id +9 +SELECT id FROM t1 WHERE EXISTS (SELECT id FROM t1 AS t2 WHERE +MATCH t2.a,t2.b AGAINST ('"more test proximity"@2' IN BOOLEAN MODE) +AND t2.id=t1.id); +id +CREATE TABLE t2 ENGINE = InnoDB AS SELECT id FROM t1 WHERE +MATCH a,b AGAINST ('support') ; +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(10) unsigned NOT NULL DEFAULT 0 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT id FROM t2; +id +1 +3 +DROP TABLE t2; +CREATE TABLE t2 ENGINE = InnoDB AS SELECT id FROM t1 WHERE +MATCH a,b AGAINST("+support +collections" IN BOOLEAN MODE); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(10) unsigned NOT NULL DEFAULT 0 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT id FROM t2; +id +3 +DROP TABLE t2; +CREATE TABLE t2 ENGINE = InnoDB AS SELECT id FROM t1 WHERE +MATCH a,b AGAINST ('"proximity search"@10' IN BOOLEAN MODE); +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `id` int(10) unsigned NOT NULL DEFAULT 0 +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +SELECT id FROM t2; +id +7 +8 +9 +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB; +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...'); +INSERT INTO t1 (a,b) VALUES +('when To Use MySQL Well','After that you went through a ...'); +INSERT INTO t1 (a,b) VALUES +('where will Optimizing MySQL','what In this tutorial we will show ...'); +INSERT INTO t1 (a,b) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL null...'); +SELECT COUNT(*) FROM t1; +COUNT(*) +106 +SELECT COUNT(*) FROM t1 WHERE a IS NULL; +COUNT(*) +100 +SELECT COUNT(*) FROM t1 WHERE b IS NOT NULL; +COUNT(*) +6 +SELECT id FROM t1 +WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id +1 +103 +SELECT id FROM t1 +WHERE MATCH (a,b) +AGAINST (NULL IN NATURAL LANGUAGE MODE); +id +SELECT id FROM t1 +WHERE MATCH (a,b) +AGAINST (NULL WITH QUERY EXPANSION); +id +SELECT id FROM t1 +WHERE MATCH (a,b) +AGAINST ('null' IN NATURAL LANGUAGE MODE); +id +106 +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); +id +106 +1 +52 +103 +104 +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE) AND (a IS NOT NULL OR b IS NOT NULL); +id +106 +1 +52 +103 +104 +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE) AND (a IS NULL AND b IS NOT NULL); +id +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('DBMS Security' IN BOOLEAN MODE); +id +1 +106 +SELECT COUNT(*) FROM t1 +WHERE MATCH (a,b) +AGAINST ('database' WITH QUERY EXPANSION); +COUNT(*) +6 +SELECT id FROM t1 +WHERE MATCH (a,b) +AGAINST ('"following database"@10' IN BOOLEAN MODE); +id +105 +DROP TABLE t1; +set names utf8; +"----------Test1---------" +create table t50 (s1 varchar(60) character set utf8 collate utf8_bin) engine = innodb; +create fulltext index i on t50 (s1); +insert into t50 values ('ABCDE'),('FGHIJ'),('KLMNO'),('VÃÆ·WÄ°'); +select * from t50 where match(s1) against ('VÃÆ·WÄ°'); +s1 +VÃÆ·WÄ° +drop table t50; +"----------Test2---------" +create table t50 (s1 int unsigned primary key auto_increment, s2 +varchar(60) character set utf8) engine = innodb; +create fulltext index i on t50 (s2); +insert into t50 (s2) values ('FGHIJ'),('KLMNO'),('VÃÆ·WÄ°'),('ABCDE'); +select * from t50 order by s2; +s1 s2 +4 ABCDE +1 FGHIJ +2 KLMNO +3 VÃÆ·WÄ° +drop table t50; +"----------Test3---------" +create table t50 (id int unsigned primary key auto_increment, s2 +varchar(60) character set utf8) engine = innodb; +create fulltext index i on t50 (s2); +insert into t50 (s2) values ('FGHIJ'),('KLMNO'),('VÃÆ·WÄ°'),('ABCDE'); +set @@autocommit=0; +update t50 set s2 = lower(s2); +update t50 set s2 = upper(s2); +commit; +select * from t50 where match(s2) against ('VÃÆ·WÄ° FGHIJ KLMNO ABCDE' in boolean mode); +id s2 +1 FGHIJ +2 KLMNO +3 VÃÆ·WI +4 ABCDE +select * from t50; +id s2 +1 FGHIJ +2 KLMNO +3 VÃÆ·WI +4 ABCDE +drop table t50; +set @@autocommit=1; +"----------Test4---------" +create table t50 (id int unsigned primary key auto_increment, s2 +varchar(60) character set utf8) engine = innodb; +create fulltext index i on t50 (s2); +insert into t50 (s2) values ('FGHIJ'),('KLMNO'),('VÃÆ·WÄ°'),('ABCD*'); +select * from t50 where match(s2) against ('abcd*' in natural language +mode); +id s2 +4 ABCD* +select * from t50 where match(s2) against ('abcd*' in boolean mode); +id s2 +4 ABCD* +drop table t50; +"----------Test5---------" +create table t50 (s1 int, s2 varchar(200), fulltext key(s2)) engine = innodb; +set @@autocommit=0; +insert into t50 values (1,'Sunshine'),(2,'Lollipops'); +select * from t50 where match(s2) against('Rainbows'); +s1 s2 +rollback; +select * from t50; +s1 s2 +drop table t50; +set @@autocommit=1; +"----------Test6---------" +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB; +INSERT INTO t1 (a,b) VALUES +('aab` MySQL Tutorial','DBMS stands for DataBase ...') , +('aas How To Use MySQL Well','After you went through a ...'), +('aac Optimizing MySQL','In this tutorial we will show ...'); +INSERT INTO t1 (a,b) VALUES +('aac 1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('aab MySQL vs. YourSQL','In the following database comparison ...'), +('aaa MySQL Security','When configured properly, MySQL ...'); +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); +SELECT * FROM t1 ORDER BY MATCH(a,b) AGAINST ('aac') DESC; +id a b +3 aac Optimizing MySQL In this tutorial we will show ... +4 aac 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +1 aab` MySQL Tutorial DBMS stands for DataBase ... +2 aas How To Use MySQL Well After you went through a ... +5 aab MySQL vs. YourSQL In the following database comparison ... +6 aaa MySQL Security When configured properly, MySQL ... +SELECT * FROM t1 ORDER BY MATCH(a,b) AGAINST ('aab') DESC; +id a b +1 aab` MySQL Tutorial DBMS stands for DataBase ... +5 aab MySQL vs. YourSQL In the following database comparison ... +2 aas How To Use MySQL Well After you went through a ... +3 aac Optimizing MySQL In this tutorial we will show ... +4 aac 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +6 aaa MySQL Security When configured properly, MySQL ... +"----------Test7---------" +select * from t1 where match(a,b) against ('aaa') +union select * from t1 where match(a,b) against ('aab') +union select * from t1 where match(a,b) against ('aac'); +id a b +6 aaa MySQL Security When configured properly, MySQL ... +1 aab` MySQL Tutorial DBMS stands for DataBase ... +5 aab MySQL vs. YourSQL In the following database comparison ... +3 aac Optimizing MySQL In this tutorial we will show ... +4 aac 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +select * from t1 where match(a,b) against ('aaa') +or match(a,b) against ('aab') +or match(a,b) against ('aac'); +id a b +1 aab` MySQL Tutorial DBMS stands for DataBase ... +3 aac Optimizing MySQL In this tutorial we will show ... +4 aac 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 aab MySQL vs. YourSQL In the following database comparison ... +6 aaa MySQL Security When configured properly, MySQL ... +DROP TABLE t1; +"----------Test8---------" +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB; +INSERT INTO t1 (a,b) VALUES +('MySQL Tutorial','DBMS stands for DataBase ... abcd') , +('How To Use MySQL Well','After you went through a q ...abdd'), +('Optimizing MySQL','In this tutorial we will show ...abed'); +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `a` varchar(200) DEFAULT NULL, + `b` text DEFAULT NULL, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx` (`a`,`b`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO t1 (a,b) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. q ...'), +('MySQL vs. YourSQL use','In the following database comparison ...'), +('MySQL Security','When run configured properly, MySQL ...'); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ('run'); +id a b +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. q ... +6 MySQL Security When run configured properly, MySQL ... +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ('use'); +id a b +2 How To Use MySQL Well After you went through a q ...abdd +5 MySQL vs. YourSQL use In the following database comparison ... +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ('went'); +id a b +2 How To Use MySQL Well After you went through a q ...abdd +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ('run') AND NOT MATCH(a,b) AGAINST ('q'); +id a b +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. q ... +6 MySQL Security When run configured properly, MySQL ... +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ('use') AND NOT MATCH(a,b) AGAINST ('q'); +id a b +2 How To Use MySQL Well After you went through a q ...abdd +5 MySQL vs. YourSQL use In the following database comparison ... +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ('went') AND NOT MATCH(a,b) AGAINST ('q'); +id a b +2 How To Use MySQL Well After you went through a q ...abdd +"----------Test9---------" +CREATE TABLE t2 AS SELECT * FROM t1; +ALTER TABLE t2 ENGINE=MYISAM; +CREATE FULLTEXT INDEX i ON t2 (a,b); +SET @x = (SELECT COUNT(*) FROM t1 WHERE MATCH(a,b) AGAINST ('run')); +SET @x = @x + (SELECT COUNT(*) FROM t1 WHERE MATCH(a,b) AGAINST ('use')); +SET @x = @x + (SELECT COUNT(*) FROM t1 WHERE MATCH(a,b) AGAINST ('went')); +SET @x = @x + (SELECT COUNT(*) FROM t1 WHERE MATCH(a,b) AGAINST ('run')); +SET @x2 = (SELECT COUNT(*) FROM t2 WHERE MATCH(a,b) AGAINST ('run')); +SET @x2 = @x2 + (SELECT COUNT(*) FROM t2 WHERE MATCH(a,b) AGAINST ('use')); +SET @x2 = @x2 + (SELECT COUNT(*) FROM t2 WHERE MATCH(a,b) AGAINST ('went')); +SET @x2 = @x2 + (SELECT COUNT(*) FROM t2 WHERE MATCH(a,b) AGAINST ('run')); +SELECT @x, @x2; +@x @x2 +7 0 +DROP TABLE t2; +"----------Test10---------" +CREATE TABLE t2 AS SELECT * FROM t1; +ALTER TABLE t2 ENGINE=MYISAM; +CREATE FULLTEXT INDEX i ON t2 (a,b); +SELECT COUNT(*) FROM t2 WHERE MATCH(a,b) AGAINST ('abc*' IN BOOLEAN MODE); +COUNT(*) +1 +SELECT COUNT(*) FROM t1 WHERE MATCH(a,b) AGAINST ('abc*' IN BOOLEAN MODE); +COUNT(*) +1 +DROP TABLE t2; +"----------Test11---------" +CREATE TABLE t2 AS SELECT * FROM t1; +ALTER TABLE t2 ENGINE = MYISAM; +CREATE FULLTEXT INDEX i ON t2 (a,b); +ALTER TABLE t2 ENGINE=InnoDB; +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ('run'); +id a b +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. q ... +6 MySQL Security When run configured properly, MySQL ... +SELECT COUNT(*) FROM t2 WHERE MATCH(a,b) AGAINST ('abc*' IN BOOLEAN MODE); +COUNT(*) +1 +DROP TABLE t2,t1; +"----------Test13---------" +set names utf8; +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8_SPANISH_CI) ENGINE = InnoDB; +CREATE FULLTEXT INDEX i ON t1 (s2); +INSERT INTO t1 VALUES (1,'aaCen'),(2,'aaCha'),(3,'aaCio'),(4,'aaçen'),(5,'aaçha'),(6,'aaçio'); +SELECT * FROM t1 WHERE MATCH(s2) AGAINST ('aach*' IN BOOLEAN MODE); +s1 s2 +2 aaCha +5 aaçha +SELECT * FROM t1 WHERE MATCH(s2) AGAINST ('aaC*' IN BOOLEAN MODE); +s1 s2 +1 aaCen +2 aaCha +3 aaCio +4 aaçen +5 aaçha +6 aaçio +DROP TABLE t1; +"----------Test14---------" +CREATE TABLE t1(s1 INT , s2 VARCHAR(100) CHARACTER SET sjis) ENGINE = InnoDB; +CREATE FULLTEXT INDEX i ON t1 (s2); +INSERT INTO t1 VALUES (1,'ペペペ'),(2,'テテテ'),(3,'ルルル'),(4,'ã‚°ã‚°ã‚°'); +DROP TABLE t1; +"----------Test15---------" +CREATE TABLE t1 (s1 VARCHAR (60) CHARACTER SET UTF8 COLLATE UTF8_UNICODE_520_CI) ENGINE = MyISAM; +CREATE FULLTEXT INDEX i ON t1 (s1); +INSERT INTO t1 VALUES +('a'),('b'),('c'),('d'),('ÅÅÅÅ'),('LLLL'),(NULL),('ÅÅÅÅ ÅÅÅÅ'),('LLLLLLLL'); +SELECT * FROM t1 WHERE MATCH(s1) AGAINST ('LLLL' COLLATE UTF8_UNICODE_520_CI); +s1 +ÅÅÅÅ +LLLL +ÅÅÅÅ ÅÅÅÅ +CREATE TABLE t2 (s1 VARCHAR(60) CHARACTER SET UTF8 COLLATE UTF8_POLISH_CI) ENGINE = InnoDB; +CREATE FULLTEXT INDEX i ON t2 ( s1); +INSERT INTO t2 VALUES +('a'),('b'),('c'),('d'),('ÅÅÅÅ'),('LLLL'),(NULL),('ÅÅÅÅ ÅÅÅÅ'),('LLLLLLLL'); +SELECT * FROM t2 WHERE MATCH(s1) AGAINST ('LLLL' COLLATE UTF8_UNICODE_520_CI); +s1 +LLLL +DROP TABLE t1,t2; +"----------Test16---------" +CREATE TABLE t1 (s1 INT, s2 VARCHAR(50) CHARACTER SET UTF8) ENGINE = InnoDB; +CREATE FULLTEXT INDEX i ON t1(s2); +INSERT INTO t1 VALUES (2, 'ÄŸÄ— DaÅ›i p '); +SELECT * FROM t1 WHERE MATCH(s2) AGAINST ('+p +"ÄŸÄ— DaÅ›i*"' IN BOOLEAN MODE); +s1 s2 +DROP TABLE t1; +"----------Test19---------" +CREATE TABLE t1 ( id INT , char_column VARCHAR(60) CHARACTER SET UTF8) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,'Ä°Ã³Ã«É '); +CREATE FULLTEXT INDEX i ON t1 (char_column); +SELECT * FROM t1 WHERE MATCH(char_column) AGAINST ('"Ä°Ã³Ã«É "' IN BOOLEAN MODE); +id char_column +1 Ä°Ã³Ã«É +DROP TABLE t1; +"----------Test20---------" +CREATE TABLE t1 ( id INT , char_column VARCHAR(60) CHARACTER SET UTF32, char_column2 VARCHAR(60) character set utf8) ENGINE = InnoDB; +INSERT INTO t1 (char_column) VALUES ('abcde'),('fghij'),('klmno'),('qrstu'); +UPDATE t1 SET char_column2 = char_column; +CREATE FULLTEXT INDEX i ON t1 (char_column2); +SELECT * FROM t1 WHERE MATCH(char_column) AGAINST ('abc*' IN BOOLEAN MODE); +ERROR HY000: Can't find FULLTEXT index matching the column list +DROP TABLE t1; +"----------Test22---------" +CREATE TABLE t1 ( id INT , char_column VARCHAR(60) CHARACTER SET UTF8) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,'aaa'),(2,'bbb'),(3,'ccc'); +CREATE FULLTEXT INDEX i ON t1 (char_column); +HANDLER t1 OPEN; +HANDLER t1 READ i = ('aaa'); +ERROR HY000: FULLTEXT index `i` does not support this operation +DROP TABLE t1; +"----------Test25---------" +CREATE TABLE t1 ( id INT , char_column VARCHAR(60) CHARACTER SET UTF8 COLLATE UTF8_CROATIAN_CI) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,'LJin'),(2,'ljin'),(3,'lmin'),(4,'LJLJLJLJLJ'); +CREATE FULLTEXT INDEX i ON t1 (char_column); +SELECT count(*) FROM t1 WHERE MATCH (char_column) AGAINST ('lj*' IN BOOLEAN MODE); +count(*) +3 +DROP TABLE t1; +"----------Test27---------" +CREATE TABLE t1 (id INT,char_column VARCHAR(60)); +CREATE TABLE t2 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, a TEXT)ENGINE=InnoDB; +ALTER TABLE t2 DROP a; +CREATE FULLTEXT INDEX i ON t1 (char_column); +INSERT INTO t1 values (1,'aaa'); +CREATE TABLE mdev20987_1(f1 INT NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB; +CREATE TABLE mdev20987_2(f1 INT NOT NULL, f2 CHAR(100), +FULLTEXT(f2), +FOREIGN KEY(f1) REFERENCES mdev20987_1(f1))ENGINE=InnoDB; +INSERT INTO mdev20987_1 VALUES(1); +INSERT INTO mdev20987_2 VALUES(1, 'mariadb'); +CREATE TABLE mdev22358 (a INT, b TEXT, FULLTEXT KEY ftidx (b)) ENGINE=InnoDB; +ALTER TABLE mdev22358 DROP KEY ftidx; +INSERT INTO mdev22358 (a) VALUES (2),(2); +ALTER TABLE mdev22358 ADD UNIQUE KEY uidx (a), ADD FULLTEXT KEY ftidx (b); +ERROR 23000: Duplicate entry '2' for key 'uidx' +# restart +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `FTS_DOC_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, + PRIMARY KEY (`FTS_DOC_ID`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb'); +DROP TABLE t1, t2, mdev20987_2, mdev20987_1, mdev22358; +"----------Test28---------" +create table `fts_test`(`a` text,fulltext key(`a`))engine=innodb; +set session autocommit=0; +insert into `fts_test` values (''); +savepoint `b`; +savepoint `b`; +set session autocommit=1; +DROP TABLE fts_test; +"----------Test29---------" +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +) ENGINE=InnoDB; +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...'); +start transaction; +INSERT INTO articles (title,body) VALUES +('How To Use MySQL Well','After you went through a ...'); +savepoint `a1`; +INSERT INTO articles (title,body) VALUES +('Optimizing MySQL','In this tutorial we will show ...'); +savepoint `a2`; +INSERT INTO articles (title,body) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'); +savepoint `a3`; +INSERT INTO articles (title,body) VALUES +('MySQL vs. YourSQL','In the following database comparison ...'); +savepoint `a4`; +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +rollback to savepoint a3; +select title, body from articles; +title body +MySQL Tutorial DBMS stands for DataBase ... +How To Use MySQL Well After you went through a ... +Optimizing MySQL In this tutorial we will show ... +1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +INSERT INTO articles (title,body) VALUES +('MySQL Security','When configured properly, MySQL ...'); +savepoint `a5`; +select title, body from articles; +title body +MySQL Tutorial DBMS stands for DataBase ... +How To Use MySQL Well After you went through a ... +Optimizing MySQL In this tutorial we will show ... +1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +MySQL Security When configured properly, MySQL ... +rollback to savepoint a2; +select title, body from articles; +title body +MySQL Tutorial DBMS stands for DataBase ... +How To Use MySQL Well After you went through a ... +Optimizing MySQL In this tutorial we will show ... +commit; +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +DROP TABLE articles; +"----------Test30---------" +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +) ENGINE=InnoDB; +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...'); +start transaction; +INSERT INTO articles (title,body) VALUES +('How To Use MySQL Well','After you went through a ...'); +savepoint `a1`; +INSERT INTO articles (title,body) VALUES +('Optimizing MySQL','In this tutorial we will show ...'); +savepoint `a2`; +INSERT INTO articles (title,body) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'); +savepoint `a3`; +INSERT INTO articles (title,body) VALUES +('MySQL vs. YourSQL','In the following database comparison ...'); +savepoint `a4`; +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +rollback to savepoint a3; +select title, body from articles; +title body +MySQL Tutorial DBMS stands for DataBase ... +How To Use MySQL Well After you went through a ... +Optimizing MySQL In this tutorial we will show ... +1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +INSERT INTO articles (title,body) VALUES +('MySQL Security','When configured properly, MySQL ...'); +savepoint `a5`; +select title, body from articles; +title body +MySQL Tutorial DBMS stands for DataBase ... +How To Use MySQL Well After you went through a ... +Optimizing MySQL In this tutorial we will show ... +1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +MySQL Security When configured properly, MySQL ... +rollback to savepoint a2; +select title, body from articles; +title body +MySQL Tutorial DBMS stands for DataBase ... +How To Use MySQL Well After you went through a ... +Optimizing MySQL In this tutorial we will show ... +rollback; +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +DROP TABLE articles; +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +) ENGINE=InnoDB; +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +ANALYZE TABLE articles; +SELECT *, MATCH(title, body) AGAINST ('-database +MySQL' IN BOOLEAN MODE) AS score from articles; +id title body score +1 MySQL Tutorial DBMS stands for DataBase ... 0 +2 How To Use MySQL Well After you went through a ... 0.000000001885928302414186 +3 Optimizing MySQL In this tutorial we will show ... 0.000000001885928302414186 +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... 0.000000001885928302414186 +5 MySQL vs. YourSQL In the following database comparison ... 0 +6 MySQL Security When configured properly, MySQL ... 0.000000003771856604828372 +SELECT *, MATCH(title, body) AGAINST ('+MySQL -database' IN BOOLEAN MODE) AS score FROM articles; +id title body score +1 MySQL Tutorial DBMS stands for DataBase ... 0 +2 How To Use MySQL Well After you went through a ... 0.000000001885928302414186 +3 Optimizing MySQL In this tutorial we will show ... 0.000000001885928302414186 +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... 0.000000001885928302414186 +5 MySQL vs. YourSQL In the following database comparison ... 0 +6 MySQL Security When configured properly, MySQL ... 0.000000003771856604828372 +SELECT * FROM articles where MATCH(title, body) AGAINST ('MySQL - (database - tutorial)' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles where MATCH(title, body) AGAINST ('MySQL - (- tutorial database)' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles where MATCH(title, body) AGAINST ('MySQL - (- tutorial database) -Tricks' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM articles where MATCH(title, body) AGAINST ('-Tricks MySQL - (- tutorial database)' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +DROP TABLE articles; +create table t1 (FTS_DOC_ID bigint unsigned auto_increment not null primary key, +title varchar(200),body text,fulltext(title,body)) engine=innodb; +insert into t1 set body='test'; +select * from t1 where match(title,body) against('%test'); +FTS_DOC_ID title body +1 NULL test +select * from t1 where match(title,body) against('%'); +FTS_DOC_ID title body +select * from t1 where match(title,body) against('%%%%'); +FTS_DOC_ID title body +drop table t1; +CREATE DATABASE `benu database`; +USE `benu database`; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB; +INSERT INTO t1 (a,b) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'); +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `a` varchar(200) DEFAULT NULL, + `b` text DEFAULT NULL, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx` (`a`,`b`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO t1 (a,b) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id +1 +3 +select id from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +id +select id, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; +id x +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +select id, MATCH(a,b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; +id x +1 0 +2 0 +3 0 +4 0 +5 0 +6 0 +select id from t1 where MATCH a,b AGAINST ("+call* +coll*" IN BOOLEAN MODE); +id +select id from t1 where MATCH a,b AGAINST ('"support now"' IN BOOLEAN MODE); +id +select id from t1 where MATCH a,b AGAINST ('"Now sUPPort"' IN BOOLEAN MODE); +id +DROP DATABASE `benu database`; +USE test; +CREATE TABLE `t21` (`a` text, `b` int not null, +fulltext key (`a`), fulltext key (`a`) +) ENGINE=INNODB DEFAULT CHARSET=LATIN1; +Warnings: +Note 1831 Duplicate index `a_2`. This is deprecated and will be disallowed in a future release +ALTER TABLE `t21` ADD UNIQUE INDEX (`b`), ALGORITHM=INPLACE; +ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY +ALTER TABLE `t21` ADD UNIQUE INDEX (`b`); +DROP TABLE t21; +CREATE TABLE `t21` (`a` text, `b` int not null, +fulltext key (`a`)) ENGINE=INNODB DEFAULT CHARSET=LATIN1; +ALTER TABLE `t21` ADD UNIQUE INDEX (`b`); +DROP TABLE t21; +CREATE TABLE t1 ( +id INT NOT NULL, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB; +INSERT INTO t1 VALUES +(1, 'MySQL Tutorial','DBMS stands for DataBase ...') , +(2, 'How To Use MySQL Well','After you went through a ...'), +(3, 'Optimizing MySQL','In this tutorial we will show ...'); +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); +ALTER TABLE t1 ADD UNIQUE INDEX (`id`); +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id +1 +3 +select id from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +id +select id, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; +id x +1 0 +2 0 +3 0 +DROP TABLE t1; +CREATE TABLE t1 ( +id INT NOT NULL, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB; +INSERT INTO t1 VALUES +(1, 'MySQL Tutorial','DBMS stands for DataBase ...') , +(2, 'How To Use MySQL Well','After you went through a ...'), +(3, 'Optimizing MySQL','In this tutorial we will show ...'); +ALTER TABLE t1 ADD UNIQUE INDEX (`id`), ADD FULLTEXT INDEX idx (a,b); +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id +1 +3 +select id from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +id +select id from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +id +DROP TABLE t1; +CREATE TABLE t1 ( +FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB; +INSERT INTO t1 VALUES +(1, 'MySQL Tutorial','DBMS stands for DataBase ...') , +(2, 'How To Use MySQL Well','After you went through a ...'), +(3, 'Optimizing MySQL','In this tutorial we will show ...'); +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); +ALTER TABLE t1 ADD UNIQUE INDEX (`FTS_DOC_ID`); +SELECT FTS_DOC_ID FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +FTS_DOC_ID +1 +3 +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +FTS_DOC_ID +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +FTS_DOC_ID +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +FTS_DOC_ID +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +FTS_DOC_ID +select FTS_DOC_ID, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; +FTS_DOC_ID x +1 0 +2 0 +3 0 +DROP TABLE t1; +CREATE TABLE t1 ( +FTS_DOC_ID BIGINT UNSIGNED NOT NULL, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB; +INSERT INTO t1 VALUES +(1, 'MySQL Tutorial','DBMS stands for DataBase ...') , +(2, 'How To Use MySQL Well','After you went through a ...'), +(3, 'Optimizing MySQL','In this tutorial we will show ...'); +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b), ADD UNIQUE INDEX FTS_DOC_ID_INDEX (FTS_DOC_ID); +SELECT FTS_DOC_ID FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +FTS_DOC_ID +1 +3 +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +FTS_DOC_ID +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +FTS_DOC_ID +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +FTS_DOC_ID +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +FTS_DOC_ID +select FTS_DOC_ID, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; +FTS_DOC_ID x +1 0 +2 0 +3 0 +DROP TABLE t1; +CREATE TABLE t2 (`b` char(2),fulltext(`b`)) ENGINE=INNODB +DEFAULT CHARSET=LATIN1; +CREATE TABLE t3 LIKE t2; +INSERT INTO `t2` VALUES(); +COMMIT WORK AND CHAIN; +INSERT INTO `t3` VALUES (); +UPDATE `t2` SET `b` = 'a'; +SAVEPOINT BATCH1; +DROP TABLE t2; +DROP TABLE t3; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB; +INSERT INTO t1 (a,b) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'); +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); +COMMIT WORK AND CHAIN; +INSERT INTO t1 (a,b) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +SAVEPOINT BATCH1; +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('MySQL' IN NATURAL LANGUAGE MODE); +id +1 +2 +3 +INSERT INTO t1 (a,b) VALUES +('1002 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +ROLLBACK TO SAVEPOINT BATCH1; +COMMIT; +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('MySQL' IN NATURAL LANGUAGE MODE); +id +6 +1 +2 +3 +4 +5 +DROP TABLE t1; +CREATE TABLE `t` (`a` char(20) character set utf8 default null, +fulltext key (`a`)) ENGINE=INNODB; +INSERT INTO `t` VALUES ('a'); +INSERT INTO `t` VALUES ('aaa'); +SELECT MATCH(`a`) AGAINST (0x22dd22) FROM `t`; +MATCH(`a`) AGAINST (0x22dd22) +0 +0 +SELECT MATCH(`a`) AGAINST (0x2222) FROM `t`; +MATCH(`a`) AGAINST (0x2222) +0 +0 +SELECT MATCH(`a`) AGAINST (0x22) FROM `t`; +MATCH(`a`) AGAINST (0x22) +0 +0 +SELECT MATCH(`a`) AGAINST (0x2261616122) FROM `t`; +MATCH(`a`) AGAINST (0x2261616122) +0 +0.0906190574169159 +SELECT MATCH(`a`) AGAINST (0x2261dd6122) FROM `t`; +MATCH(`a`) AGAINST (0x2261dd6122) +0 +0 +SELECT MATCH(`a`) AGAINST (0x2261dd612222226122) FROM `t`; +MATCH(`a`) AGAINST (0x2261dd612222226122) +0 +0 +DROP TABLE t; +CREATE TABLE t(a CHAR(1),FULLTEXT KEY(a)) ENGINE=INNODB; +HANDLER t OPEN; +HANDLER t READ a NEXT; +a +HANDLER t READ a PREV; +a +DROP TABLE t; +CREATE TABLE `%`(a TEXT, FULLTEXT INDEX(a)) ENGINE=INNODB; +CREATE TABLE `A B`(a TEXT, FULLTEXT INDEX(a)) ENGINE=INNODB; +DROP TABLE `%`; +DROP TABLE `A B`; +CREATE TABLE `t-26`(a VARCHAR(10),FULLTEXT KEY(a)) ENGINE=INNODB; +INSERT INTO `t-26` VALUES('117'); +DROP TABLE `t-26`; +CREATE TABLE `t1` ( +`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, +`content` TEXT NOT NULL, +PRIMARY KEY (`id`), +FULLTEXT INDEX `IDX_CONTEXT_FULLTEXT`(`content`) +) +ENGINE = InnoDB; +insert into t1 (content) +values +('This is a story which has has a complicated phrase structure here in the +middle'), +('This is a story which doesn''t have that text'), +('This is a story that has complicated the phrase structure'); +select * from t1 +where match(content) against('"complicated phrase structure"' in boolean +mode); +id content +1 This is a story which has has a complicated phrase structure here in the +middle +select * from t1 +where match(content) against('+"complicated phrase structure"' in boolean +mode); +id content +1 This is a story which has has a complicated phrase structure here in the +middle +select * from t1 +where match(content) against('"complicated the phrase structure"' in boolean +mode); +id content +3 This is a story that has complicated the phrase structure +select * from t1 where match(content) against('+"this is a story which" +"complicated the phrase structure"' in boolean mode); +id content +select * from t1 where match(content) against('"the complicated the phrase structure"' in boolean mode); +id content +3 This is a story that has complicated the phrase structure +select * from t1 where match(content) against('"complicated a phrase structure"' in boolean mode); +id content +DROP TABLE t1; +CREATE TABLE my (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, +c VARCHAR(32), FULLTEXT(c)) ENGINE = INNODB; +INSERT INTO my (c) VALUES ('green-iguana'); +SELECT * FROM my WHERE MATCH(c) AGAINST ('green-iguana'); +id c +1 green-iguana +DROP TABLE my; +CREATE TABLE ift ( +`a` int(11) NOT NULL, +`b` text, +PRIMARY KEY (`a`), +FULLTEXT KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +INSERT INTO ift values (1, "skip"); +INSERT INTO ift values (2, "skip and networking"); +INSERT INTO ift values (3, "--skip-networking"); +INSERT INTO ift values (4, "-donot--skip-networking"); +SELECT * FROM ift WHERE MATCH (b) AGAINST ('--skip-networking'); +a b +2 skip and networking +3 --skip-networking +4 -donot--skip-networking +1 skip +SELECT * FROM ift WHERE MATCH (b) AGAINST ('skip-networking'); +a b +2 skip and networking +3 --skip-networking +4 -donot--skip-networking +1 skip +SELECT * FROM ift WHERE MATCH (b) AGAINST ('----'); +a b +SELECT * FROM ift WHERE MATCH (b) AGAINST ('-donot--skip-networking'); +a b +4 -donot--skip-networking +2 skip and networking +3 --skip-networking +1 skip +DROP TABLE ift; +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +) ENGINE=InnoDB; +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('( that''s me )','When configured properly, MySQL ...'); +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('( yours''s* )' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('s*' IN BOOLEAN MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('stands\'] | * | show[@database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +5 MySQL vs. YourSQL In the following database comparison ... +DROP TABLE articles; +CREATE TABLE t1(a TEXT CHARACTER SET LATIN1, FULLTEXT INDEX(a)) ENGINE=INNODB; +SELECT * FROM t1 WHERE MATCH(a) AGAINST("*"); +ERROR 42000: syntax error, unexpected $end, expecting FTS_TERM or FTS_NUMB or '*' +DROP TABLE t1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +FULLTEXT (a) +) ENGINE= InnoDB; +INSERT INTO t1 (a) VALUES +('Do you know MySQL is a good database'), +('How to build a good database'), +('Do you know'), +('Do you know MySQL'), +('How to use MySQL'), +('Do you feel good'), +('MySQL is good'), +('MySQL is good to know'), +('What is database'); +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+"know mysql"' IN BOOLEAN MODE); +id a +1 Do you know MySQL is a good database +4 Do you know MySQL +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+("know mysql")' IN BOOLEAN MODE); +id a +1 Do you know MySQL is a good database +4 Do you know MySQL +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('("know mysql" good)' IN BOOLEAN MODE); +id a +1 Do you know MySQL is a good database +4 Do you know MySQL +2 How to build a good database +6 Do you feel good +7 MySQL is good +8 MySQL is good to know +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+("know mysql" good)' IN BOOLEAN MODE); +id a +1 Do you know MySQL is a good database +4 Do you know MySQL +2 How to build a good database +6 Do you feel good +7 MySQL is good +8 MySQL is good to know +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('(good "know mysql")' IN BOOLEAN MODE); +id a +1 Do you know MySQL is a good database +4 Do you know MySQL +2 How to build a good database +6 Do you feel good +7 MySQL is good +8 MySQL is good to know +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+(good "know mysql")' IN BOOLEAN MODE); +id a +1 Do you know MySQL is a good database +4 Do you know MySQL +2 How to build a good database +6 Do you feel good +7 MySQL is good +8 MySQL is good to know +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+("know mysql" "good database")' IN BOOLEAN MODE); +id a +1 Do you know MySQL is a good database +2 How to build a good database +4 Do you know MySQL +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+"know mysql" +"good database"' IN BOOLEAN MODE); +id a +1 Do you know MySQL is a good database +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+"know database"@4' IN BOOLEAN MODE); +id a +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+"know database"@8' IN BOOLEAN MODE); +id a +1 Do you know MySQL is a good database +DROP TABLE t1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +FULLTEXT (a) +) ENGINE= InnoDB; +INSERT INTO t1 (a) VALUES +('know mysql good database'); +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+"good database"' IN BOOLEAN MODE); +id a +1 know mysql good database +DROP TABLE t1; +CREATE TABLE t1(f1 TEXT, FULLTEXT KEY(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES(repeat("this is the test case", 500)); +ALTER TABLE t1 KEY_BLOCK_SIZE=4; +ALTER TABLE t1 KEY_BLOCK_SIZE=0; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result b/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result new file mode 100644 index 00000000..52cbede7 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_misc_1.result @@ -0,0 +1,995 @@ +set names utf8; +call mtr.add_suppression("\\[Warning\\] InnoDB: A new Doc ID must be supplied while updating FTS indexed columns."); +call mtr.add_suppression("\\[Warning\\] InnoDB: FTS Doc ID must be larger than [0-9]+ for table `test`.`t1`"); +CREATE TABLE t1 ( +id1 INT , +a1 VARCHAR(200) , +b1 TEXT , +FULLTEXT KEY (a1,b1), PRIMARY KEY (a1, id1) +) CHARACTER SET = utf8 , ENGINE = InnoDB; +CREATE TABLE t2 ( +id2 INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a2 VARCHAR(200), +b2 TEXT , +FOREIGN KEY (a2) REFERENCES t1(a1) ON UPDATE CASCADE, +FULLTEXT KEY (b2,a2) +) CHARACTER SET = utf8 ,ENGINE = InnoDB; +INSERT INTO t1 (id1,a1,b1) VALUES +(1,'MySQL Tutorial','DBMS stands for DataBase VÃÆ·WÄ°...') , +(2,'How To Use MySQL Well','After you went through a ...'), +(3,'Optimizing MySQL','In this tutorial we will show ...'); +INSERT INTO t1 (id1,a1,b1) VALUES +(4,'1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +(5,'MySQL vs. YourSQL','In the following database comparison ...'), +(6,'MySQL Security','When configured properly, MySQL ...'); +INSERT INTO t2 (a2,b2) VALUES +('MySQL Tutorial','DBMS stands for DataBase VÃÆ·WÄ°...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'); +INSERT INTO t2 (a2,b2) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +INSERT INTO t2 (a2,b2) VALUES +('MySQL Tricks','1. Never run mysqld as root. 2. ...'); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a2`) REFERENCES `t1` (`a1`) ON UPDATE CASCADE) +DELETE FROM t1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a2`) REFERENCES `t1` (`a1`) ON UPDATE CASCADE) +ANALYZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze Warning Engine-independent statistics are not collected for column 'b1' +test.t1 analyze status OK +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze Warning Engine-independent statistics are not collected for column 'b2' +test.t2 analyze status OK +SELECT id1 FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial') ORDER BY id1; +id1 +1 +3 +SELECT id2 FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial') ORDER BY id2; +id2 +1 +3 +SELECT id1 FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ORDER BY id1; +id1 +1 +2 +3 +4 +5 +6 +SELECT id2 FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ORDER BY id2; +id2 +1 +2 +3 +4 +5 +6 +SELECT id1 FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial' WITH QUERY EXPANSION) ORDER BY id1; +id1 +1 +2 +3 +4 +5 +6 +SELECT id2 FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial' WITH QUERY EXPANSION) ORDER BY id2; +id2 +1 +2 +3 +4 +5 +6 +SELECT id1 FROM t1 WHERE MATCH (a1,b1) AGAINST ('"dbms database"@4' IN BOOLEAN MODE) ; +id1 +1 +SELECT id2 FROM t2 WHERE MATCH (a2,b2) AGAINST ('"dbms database"@4' IN BOOLEAN MODE) ; +id2 +1 +set global innodb_optimize_fulltext_only=1; +optimize table t1; +Table Op Msg_type Msg_text +test.t1 optimize status OK +set global innodb_optimize_fulltext_only=0; +UPDATE t1 SET a1 = "changing column - on update cascade" , b1 = "to check foreign constraint" WHERE +MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; +SELECT id1 FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; +id1 +SELECT id2 FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; +id2 +3 +6 +SELECT id1 FROM t1 WHERE MATCH (a1,b1) AGAINST ('+update +cascade' IN BOOLEAN MODE) ORDER BY id1; +id1 +1 +2 +3 +4 +5 +6 +SELECT id2 FROM t2 WHERE MATCH (a2,b2) AGAINST ('+update +cascade' IN BOOLEAN MODE) ORDER BY id2; +id2 +1 +2 +3 +4 +5 +6 +SELECT id2 FROM t2 WHERE a2 LIKE '%UPDATE CASCADE%' ORDER BY id2; +id2 +1 +2 +3 +4 +5 +6 +DROP TABLE t2 , t1; +create table t1 (s1 int, s2 varchar(200), primary key (s1,s2)) ENGINE = InnoDB; +create table t2 (s1 int, s2 varchar(200), +fulltext key(s2), +foreign key (s1,s2) references t1 (s1,s2) on update cascade) ENGINE = InnoDB; +insert into t1 values (1,'Sunshine'),(2,'Lollipops'); +insert into t2 values (1,'Sunshine'),(2,'Lollipops'); +update t1 set s2 = 'Rainbows' where s2 <> 'Sunshine'; +commit; +select * from t2 where match(s2) against ('Lollipops'); +s1 s2 +DROP TABLE t2 , t1; +create table t1 (s1 int, s2 varchar(200), primary key (s1,s2)) ENGINE = InnoDB; +create table t2 (s1 int, s2 varchar(200), +fulltext key(s2), +foreign key (s1,s2) references t1 (s1,s2) on delete cascade) ENGINE = InnoDB; +insert into t1 values (1,'Sunshine'),(2,'Lollipops'); +insert into t2 values (1,'Sunshine'),(2,'Lollipops'); +delete from t1 where s2 <> 'Sunshine'; +select * from t2 where match(s2) against ('Lollipops'); +s1 s2 +DROP TABLE t2 , t1; +create table t1 (s1 int, s2 varchar(200), primary key (s1,s2)) ENGINE = InnoDB; +create table t2 (s1 int, s2 varchar(200), +fulltext key(s2), +foreign key (s1,s2) references t1 (s1,s2) on delete set null) ENGINE = InnoDB; +insert into t1 values (1,'Sunshine'),(2,'Lollipops'); +insert into t2 values (1,'Sunshine'),(2,'Lollipops'); +delete from t1 where s2 <> 'Sunshine'; +select * from t2 where match(s2) against ('Lollipops'); +s1 s2 +DROP TABLE t2 , t1; +create table t1 (s1 int, s2 varchar(200), primary key (s1,s2)) ENGINE = InnoDB; +create table t2 (s1 int, s2 varchar(200), +fulltext key(s2), +foreign key (s1,s2) references t1 (s1,s2) on update set null) ENGINE = InnoDB; +insert into t1 values (1,'Sunshine'),(2,'Lollipops'); +insert into t2 values (1,'Sunshine'),(2,'Lollipops'); +update t1 set s2 = 'Rainbows' where s2 <> 'Sunshine'; +commit; +select * from t2 where match(s2) against ('Lollipops'); +s1 s2 +DROP TABLE t2 , t1; +create table t1 (s1 bigint unsigned not null, s2 varchar(200), +primary key (s1,s2)) ENGINE = InnoDB; +create table t2 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL, s2 varchar(200), +foreign key (FTS_DOC_ID) references t1 (s1) +on update cascade) ENGINE = InnoDB; +create fulltext index idx on t2(s2); +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `FTS_DOC_ID` bigint(20) unsigned NOT NULL, + `s2` varchar(200) DEFAULT NULL, + KEY `FTS_DOC_ID` (`FTS_DOC_ID`), + FULLTEXT KEY `idx` (`s2`), + CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`FTS_DOC_ID`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +insert into t1 values (1,'Sunshine'),(2,'Lollipops'); +insert into t2 values (1,'Sunshine'),(2,'Lollipops'); +update t1 set s1 = 3 where s1=1; +select * from t2 where match(s2) against ('sunshine'); +FTS_DOC_ID s2 +3 Sunshine +update t1 set s1 = 1 where s1=3; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`FTS_DOC_ID`) REFERENCES `t1` (`s1`) ON UPDATE CASCADE) +DROP TABLE t2 , t1; +CREATE TABLE t1 ( +id1 INT , +a1 VARCHAR(200) PRIMARY KEY, +b1 TEXT character set utf8 , +FULLTEXT KEY (a1,b1) +) CHARACTER SET = utf8 ,ENGINE = InnoDB; +CREATE TABLE t2 ( +id2 INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a2 VARCHAR(200), +b2 TEXT character set utf8 , +FOREIGN KEY (a2) REFERENCES t1(a1) ON DELETE CASCADE, +FULLTEXT KEY (b2,a2) +) CHARACTER SET = utf8 ,ENGINE = InnoDB; +INSERT INTO t1 (id1,a1,b1) VALUES +(1,'MySQL Tutorial','DBMS stands for DataBase VÃÆ·WÄ°...') , +(2,'How To Use MySQL Well','After you went through a ...'), +(3,'Optimizing MySQL','In this tutorial we will show ...'), +(4,'1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +(5,'MySQL vs. YourSQL','In the following database comparison ...'), +(6,'MySQL Security','When configured properly, MySQL ...'); +INSERT INTO t2 (a2,b2) VALUES +('MySQL Tutorial','DBMS stands for DataBase VÃÆ·WÄ°...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +DELETE FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; +id1 a1 b1 +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; +id2 a2 b2 +SELECT * FROM t1 WHERE a1 LIKE '%tutorial%'; +id1 a1 b1 +SELECT * FROM t2 WHERE a2 LIKE '%tutorial%'; +id2 a2 b2 +DROP TABLE t2 , t1; +call mtr.add_suppression("\\[ERROR\\] InnoDB: FTS Doc ID must be larger than 3 for table `test`.`t2`"); +CREATE TABLE t1 ( +id1 INT , +a1 VARCHAR(200) , +b1 TEXT , +FULLTEXT KEY (a1,b1), PRIMARY KEY(a1, id1) +) CHARACTER SET = utf8 , ENGINE = InnoDB; +CREATE TABLE t2 ( +id2 INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a2 VARCHAR(200), +b2 TEXT , +FOREIGN KEY (a2) REFERENCES t1(a1) ON UPDATE CASCADE, +FULLTEXT KEY (b2,a2) +) CHARACTER SET = utf8 ,ENGINE = InnoDB; +INSERT INTO t1 (id1,a1,b1) VALUES +(1,'MySQL Tutorial','DBMS stands for DataBase VÃÆ·WÄ°...') , +(2,'How To Use MySQL Well','After you went through a ...'), +(3,'Optimizing MySQL','In this tutorial we will show ...'); +INSERT INTO t2 (a2,b2) VALUES +('MySQL Tutorial','DBMS stands for DataBase VÃÆ·WÄ°...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'); +START TRANSACTION; +INSERT INTO t1 (id1,a1,b1) VALUES +(4,'1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +(5,'MySQL vs. YourSQL','In the following database comparison ...'), +(6,'MySQL Security','When configured properly, MySQL ...'); +INSERT INTO t2 (a2,b2) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +INSERT INTO t2 (a2,b2) VALUES +('MySQL Tricks','1. Never run mysqld as root. 2. ...'); +ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a2`) REFERENCES `t1` (`a1`) ON UPDATE CASCADE) +DELETE FROM t1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`a2`) REFERENCES `t1` (`a1`) ON UPDATE CASCADE) +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial') ORDER BY id1; +id1 a1 b1 +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial') ORDER BY id2; +id2 a2 b2 +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ORDER BY id1; +id1 a1 b1 +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ORDER BY id2; +id2 a2 b2 +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial' WITH QUERY EXPANSION) ORDER BY id1; +id1 a1 b1 +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial' WITH QUERY EXPANSION) ORDER BY id2; +id2 a2 b2 +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('"dbms database"@4' IN BOOLEAN MODE) ; +id1 a1 b1 +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('"dbms database"@4' IN BOOLEAN MODE) ; +id2 a2 b2 +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('root') ; +id1 a1 b1 +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('root') ; +id2 a2 b2 +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('mysqld (+root)' IN BOOLEAN MODE) ; +id1 a1 b1 +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('mysqld (-root)' IN BOOLEAN MODE) ; +id2 a2 b2 +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('root' WITH QUERY EXPANSION) ; +id1 a1 b1 +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('root' WITH QUERY EXPANSION) ; +id2 a2 b2 +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('"database comparison"@02' IN BOOLEAN MODE) ; +id1 a1 b1 +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('"database comparison"@02' IN BOOLEAN MODE) ; +id2 a2 b2 +SELECT * FROM t1 ORDER BY id1; +id1 a1 b1 +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM t2 ORDER BY id2; +id2 a2 b2 +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +6 MySQL Security When configured properly, MySQL ... +COMMIT; +START TRANSACTION; +UPDATE t1 SET a1 = "changing column - on UPDATE cascade" , b1 = "to check foreign constraint" WHERE +MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; +COMMIT; +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; +id1 a1 b1 +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; +id2 a2 b2 +3 changing column - on UPDATE cascade In this tutorial we will show ... +6 changing column - on UPDATE cascade When configured properly, MySQL ... +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('+UPDATE +cascade' IN BOOLEAN MODE) ORDER BY id1; +id1 a1 b1 +1 changing column - on UPDATE cascade to check foreign constraint +2 changing column - on UPDATE cascade to check foreign constraint +3 changing column - on UPDATE cascade to check foreign constraint +4 changing column - on UPDATE cascade to check foreign constraint +5 changing column - on UPDATE cascade to check foreign constraint +6 changing column - on UPDATE cascade to check foreign constraint +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('+UPDATE +cascade' IN BOOLEAN MODE) ORDER BY id2; +id2 a2 b2 +1 changing column - on UPDATE cascade DBMS stands for DataBase VÃÆ·WÄ°... +2 changing column - on UPDATE cascade After you went through a ... +3 changing column - on UPDATE cascade In this tutorial we will show ... +4 changing column - on UPDATE cascade 1. Never run mysqld as root. 2. ... +5 changing column - on UPDATE cascade In the following database comparison ... +6 changing column - on UPDATE cascade When configured properly, MySQL ... +SELECT * FROM t2 WHERE a2 LIKE '%UPDATE CASCADE%' ORDER BY id2; +id2 a2 b2 +1 changing column - on UPDATE cascade DBMS stands for DataBase VÃÆ·WÄ°... +2 changing column - on UPDATE cascade After you went through a ... +3 changing column - on UPDATE cascade In this tutorial we will show ... +4 changing column - on UPDATE cascade 1. Never run mysqld as root. 2. ... +5 changing column - on UPDATE cascade In the following database comparison ... +6 changing column - on UPDATE cascade When configured properly, MySQL ... +DROP TABLE t2 , t1; +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), +FULLTEXT KEY(s2), +FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on UPDATE cascade) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +UPDATE t1 set s2 = 'Rainbows' WHERE s2 <> 'Sunshine'; +COMMIT; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +s1 s2 +DROP TABLE t2 , t1; +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), +FULLTEXT KEY(s2), +FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on DELETE cascade) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +DELETE FROM t1 WHERE s2 <> 'Sunshine'; +COMMIT; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +s1 s2 +DROP TABLE t2 , t1; +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), +FULLTEXT KEY(s2), +FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on DELETE SET NULL) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +DELETE FROM t1 WHERE s2 <> 'Sunshine'; +COMMIT; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +s1 s2 +DROP TABLE t2 , t1; +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), +FULLTEXT KEY(s2), +FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on UPDATE SET NULL) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +UPDATE t1 set s2 = 'Rainbows' WHERE s2 <> 'Sunshine'; +COMMIT; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +s1 s2 +DROP TABLE t2 , t1; +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), +FULLTEXT KEY(s2), +FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on UPDATE cascade) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +UPDATE t1 set s2 = 'Rainbows' WHERE s2 <> 'Sunshine'; +ROLLBACK; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +s1 s2 +DROP TABLE t2 , t1; +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), +FULLTEXT KEY(s2), +FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on DELETE cascade) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +DELETE FROM t1 WHERE s2 <> 'Sunshine'; +ROLLBACK; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +s1 s2 +DROP TABLE t2 , t1; +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), +FULLTEXT KEY(s2), +FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on DELETE SET NULL) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +DELETE FROM t1 WHERE s2 <> 'Sunshine'; +ROLLBACK; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +s1 s2 +DROP TABLE t2 , t1; +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), +FULLTEXT KEY(s2), +FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on UPDATE SET NULL) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +UPDATE t1 set s2 = 'Rainbows' WHERE s2 <> 'Sunshine'; +ROLLBACK; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +s1 s2 +DROP TABLE t2 , t1; +set global innodb_file_per_table=1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) CHARACTER SET = utf8, ROW_FORMAT=COMPRESSED, ENGINE = InnoDB; +INSERT INTO t1 (a,b) VALUES +('MySQL Tutorial','DBMS stands for DataBase VÃÆ·WÄ°...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'); +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `a` varchar(200) DEFAULT NULL, + `b` text DEFAULT NULL, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx` (`a`,`b`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci ROW_FORMAT=COMPRESSED +SELECT count(*) FROM information_schema.innodb_sys_tables WHERE name LIKE "%FTS_%" AND space !=0; +count(*) +11 +INSERT INTO t1 (a,b) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +ANALYZE TABLE t1; +SELECT * FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) ORDER BY id; +id a b +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +3 Optimizing MySQL In this tutorial we will show ... +select * from t1 where MATCH(a,b) AGAINST("+tutorial +VÃÆ·WÄ°" IN BOOLEAN MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +select * from t1 where MATCH(a,b) AGAINST("+-VÃÆ·WÄ°" IN BOOLEAN MODE); +ERROR 42000: syntax error, unexpected '-' +select * from t1 where MATCH(a,b) AGAINST("+Mysql +(tricks never)" IN BOOLEAN MODE); +id a b +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +select * from t1 where MATCH(a,b) AGAINST("+mysql -(tricks never)" IN BOOLEAN MODE) ORDER BY id; +id a b +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +5 MySQL vs. YourSQL In the following database comparison ... +6 MySQL Security When configured properly, MySQL ... +select *, MATCH(a,b) AGAINST("mysql stands" IN BOOLEAN MODE) as x from t1 ORDER BY id; +id a b x +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... 0.6055193543434143 +2 How To Use MySQL Well After you went through a ... 0.000000001885928302414186 +3 Optimizing MySQL In this tutorial we will show ... 0.000000001885928302414186 +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... 0.000000001885928302414186 +5 MySQL vs. YourSQL In the following database comparison ... 0.000000001885928302414186 +6 MySQL Security When configured properly, MySQL ... 0.000000003771856604828372 +select * from t1 where MATCH a,b AGAINST ("+database* +VÃÆ·W*" IN BOOLEAN MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +select * from t1 where MATCH a,b AGAINST ('"security mysql"' IN BOOLEAN MODE); +id a b +select * from t1 where MATCH(a,b) AGAINST ("VÃÆ·WÄ°" WITH QUERY EXPANSION) ORDER BY id; +id a b +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +6 MySQL Security When configured properly, MySQL ... +ALTER TABLE t1 DROP INDEX idx; +CREATE FULLTEXT INDEX idx on t1 (a,b); +SELECT * FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) ORDER BY id; +id a b +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +3 Optimizing MySQL In this tutorial we will show ... +select * from t1 where MATCH(a,b) AGAINST("+tutorial +VÃÆ·WÄ°" IN BOOLEAN MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +select * from t1 where MATCH(a,b) AGAINST("+dbms" IN BOOLEAN MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +select * from t1 where MATCH(a,b) AGAINST("+Mysql +(tricks never)" IN BOOLEAN MODE); +id a b +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +select * from t1 where MATCH(a,b) AGAINST("+mysql -(tricks never)" IN BOOLEAN MODE) ORDER BY id; +id a b +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +5 MySQL vs. YourSQL In the following database comparison ... +6 MySQL Security When configured properly, MySQL ... +select *, MATCH(a,b) AGAINST("mysql VÃÆ·WÄ°" IN BOOLEAN MODE) as x from t1 ORDER BY id; +id a b x +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... 0.6055193543434143 +2 How To Use MySQL Well After you went through a ... 0.000000001885928302414186 +3 Optimizing MySQL In this tutorial we will show ... 0.000000001885928302414186 +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... 0.000000001885928302414186 +5 MySQL vs. YourSQL In the following database comparison ... 0.000000001885928302414186 +6 MySQL Security When configured properly, MySQL ... 0.000000003771856604828372 +select * from t1 where MATCH a,b AGAINST ('"security mysql"' IN BOOLEAN MODE); +id a b +select * from t1 where MATCH(a,b) AGAINST ("VÃÆ·WÄ°" WITH QUERY EXPANSION) ORDER BY id; +id a b +1 MySQL Tutorial DBMS stands for DataBase VÃÆ·WÄ°... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +6 MySQL Security When configured properly, MySQL ... +INSERT INTO t1 (a,b) VALUES ('test query expansion','for database ...'); +INSERT INTO t1 (a,b) VALUES +('test proximity search, test, proximity and phrase', +'search, with proximity innodb'); +INSERT INTO t1 (a,b) VALUES +('test proximity fts search, test, proximity and phrase', +'search, with proximity innodb'); +INSERT INTO t1 (a,b) VALUES +('test more proximity fts search, test, more proximity and phrase', +'search, with proximity innodb'); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"proximity search"@2' IN BOOLEAN MODE); +id a b +8 test proximity search, test, proximity and phrase search, with proximity innodb +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"proximity search"@1' IN BOOLEAN MODE); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"proximity search"@3' IN BOOLEAN MODE) ORDER BY id; +id a b +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test proximity fts search, test, proximity and phrase search, with proximity innodb +10 test more proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"test proximity"@5' IN BOOLEAN MODE) ORDER BY id; +id a b +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test proximity fts search, test, proximity and phrase search, with proximity innodb +10 test more proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"more test proximity"@2' IN BOOLEAN MODE); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"more test proximity"@3' IN BOOLEAN MODE); +id a b +10 test more proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"more fts proximity"@03' IN BOOLEAN MODE); +id a b +10 test more proximity fts search, test, more proximity and phrase search, with proximity innodb +UPDATE t1 SET a = UPPER(a) , b = UPPER(b) ; +UPDATE t1 SET a = UPPER(a) , b = LOWER(b) ; +select * from t1 where MATCH(a,b) AGAINST("+tutorial +dbms" IN BOOLEAN MODE); +id a b +1 MYSQL TUTORIAL dbms stands for database vðʒwi... +select * from t1 where MATCH(a,b) AGAINST("+VÃÆ·WÄ°" IN BOOLEAN MODE); +id a b +1 MYSQL TUTORIAL dbms stands for database vðʒwi... +SELECT * FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) ORDER BY id; +id a b +1 MYSQL TUTORIAL dbms stands for database vðʒwi... +3 OPTIMIZING MYSQL in this tutorial we will show ... +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('"proximity search"@14' IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id a b +SELECT * FROM t1 ORDER BY id; +id a b +2 HOW TO USE MYSQL WELL after you went through a ... +4 1001 MYSQL TRICKS 1. never run mysqld as root. 2. ... +5 MYSQL VS. YOURSQL in the following database comparison ... +6 MYSQL SECURITY when configured properly, mysql ... +7 TEST QUERY EXPANSION for database ... +DROP TABLE t1; +SET GLOBAL innodb_file_per_table=1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) CHARACTER SET = utf8, ENGINE=InnoDB; +INSERT INTO t1 (a,b) VALUES +('Я могу еÑÑ‚ÑŒ Ñтекло', 'оно мне не вредит'), +('Мога да Ñм Ñтъкло', 'то не ми вреди'), +('ΜποÏῶ νὰ φάω σπασμÎνα' ,'γυαλιὰ χωÏὶς νὰ πάθω τίποτα'), +('PÅ™ÃliÅ¡ žluÅ¥ouÄký kůň', 'úpÄ›l Äábelské kódy'), +('Sævör grét', 'áðan þvà úlpan var ónýt'), +('ã†ã‚ã®ãŠãã‚„ã¾','ã‘ãµã“ãˆã¦'), +('ã„ã‚ã¯ã«ã»ã¸ã©ã€€ã¡ã‚Šã¬ã‚‹','ã‚ã•ãゆã‚ã¿ã˜ã€€ã‚‘ã²ã‚‚ã›ãš'); +INSERT INTO t1 (a,b) VALUES +('MySQL Tutorial','request docteam@oraclehelp.com ...') , +('Trial version','query performace @1255 minute on 2.1Hz Memory 2GB...') , +('when To Use MySQL Well','for free faq mail@xyz.com ...'); +CREATE FULLTEXT INDEX idx on t1 (a,b); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("вредит χωÏὶς") ORDER BY id; +id a b +1 Я могу еÑÑ‚ÑŒ Ñтекло оно мне не вредит +3 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("оно" WITH QUERY EXPANSION); +id a b +1 Я могу еÑÑ‚ÑŒ Ñтекло оно мне не вредит +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("вред*" IN BOOLEAN MODE) ORDER BY id; +id a b +1 Я могу еÑÑ‚ÑŒ Ñтекло оно мне не вредит +2 Мога да Ñм Ñтъкло то не ми вреди +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("+γυαλιὰ +tutorial" IN BOOLEAN MODE); +id a b +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("+tutorial +(Мога τίποτα)" IN BOOLEAN MODE); +id a b +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("ã‚ã•ãゆã‚ã¿ã˜ã€€ã‚‘ã²ã‚‚ã›ãš"); +id a b +7 ã„ã‚ã¯ã«ã»ã¸ã©ã€€ã¡ã‚Šã¬ã‚‹ ã‚ã•ãゆã‚ã¿ã˜ã€€ã‚‘ã²ã‚‚ã›ãš +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("ã¡ã‚Šã¬ã‚‹" WITH QUERY EXPANSION); +id a b +7 ã„ã‚ã¯ã«ã»ã¸ã©ã€€ã¡ã‚Šã¬ã‚‹ ã‚ã•ãゆã‚ã¿ã˜ã€€ã‚‘ã²ã‚‚ã›ãš +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("+ã‚ã•ãゆã‚ã¿ã˜ã€€+ã‚‘ã²ã‚‚ã›ãš" IN BOOLEAN MODE); +id a b +7 ã„ã‚ã¯ã«ã»ã¸ã©ã€€ã¡ã‚Šã¬ã‚‹ ã‚ã•ãゆã‚ã¿ã˜ã€€ã‚‘ã²ã‚‚ã›ãš +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("ã†ã‚ã®ãŠã*" IN BOOLEAN MODE); +id a b +6 ã†ã‚ã®ãŠãã‚„ã¾ ã‘ãµã“ãˆã¦ +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("+Sævör +úlpan" IN BOOLEAN MODE); +id a b +5 Sævör grét áðan þvà úlpan var ónýt +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"γυαλιὰ χωÏὶς"@2' IN BOOLEAN MODE); +id a b +3 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"query performace"@02' IN BOOLEAN MODE); +id a b +9 Trial version query performace @1255 minute on 2.1Hz Memory 2GB... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"πάθω τίποτα"@2' IN BOOLEAN MODE); +id a b +3 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"ã‚ã•ãゆã‚ã¿ã˜ ã‚‘ã²ã‚‚ã›ãš"@1' IN BOOLEAN MODE); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"ã‚ã•ãゆã‚ã¿ã˜ ã‚‘ã²ã‚‚ã›ãš"@2' IN BOOLEAN MODE); +id a b +7 ã„ã‚ã¯ã«ã»ã¸ã©ã€€ã¡ã‚Šã¬ã‚‹ ã‚ã•ãゆã‚ã¿ã˜ã€€ã‚‘ã²ã‚‚ã›ãš +ALTER TABLE t1 DROP INDEX idx; +CREATE FULLTEXT INDEX idx on t1 (a,b); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("ã‚ã•ãゆã‚ã¿ã˜ ã‚‘ã²ã‚‚ã›ãš"); +id a b +7 ã„ã‚ã¯ã«ã»ã¸ã©ã€€ã¡ã‚Šã¬ã‚‹ ã‚ã•ãゆã‚ã¿ã˜ã€€ã‚‘ã²ã‚‚ã›ãš +UPDATE t1 SET a = "Pchnąć w tÄ™ łódź jeża" , b = "lub osiem skrzyÅ„ fig" WHERE MATCH(a,b) AGAINST ("ã‚ã•ãゆã‚ã¿ã˜ ã‚‘ã²ã‚‚ã›ãš"); +UPDATE t1 SET a = "Ð’ чащах юга жил-был цитруÑ? Да", b = "но фальшивый ÑкземплÑÑ€! Ñ‘ÑŠ" WHERE MATCH(a,b) AGAINST ("вред*" IN BOOLEAN MODE); +DELETE FROM t1 WHERE MATCH(a,b) AGAINST("+Sævör +úlpan" IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("ã‚ã•ãゆã‚ã¿ã˜ã€€ã‚‘ã²ã‚‚ã›ãš"); +id a b +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("łódź osiem"); +id a b +7 Pchnąć w tÄ™ łódź jeża lub osiem skrzyÅ„ fig +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("вред*" IN BOOLEAN MODE); +id a b +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("фальшив*" IN BOOLEAN MODE) ORDER BY id; +id a b +1 Ð’ чащах юга жил-был цитруÑ? Да но фальшивый ÑкземплÑÑ€! Ñ‘ÑŠ +2 Ð’ чащах юга жил-был цитруÑ? Да но фальшивый ÑкземплÑÑ€! Ñ‘ÑŠ +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("+Sævör +úlpan" IN BOOLEAN MODE); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"łódź jeża"@2' IN BOOLEAN MODE); +id a b +7 Pchnąć w tÄ™ łódź jeża lub osiem skrzyÅ„ fig +SELECT * FROM t1 ORDER BY id; +id a b +1 Ð’ чащах юга жил-был цитруÑ? Да но фальшивый ÑкземплÑÑ€! Ñ‘ÑŠ +2 Ð’ чащах юга жил-был цитруÑ? Да но фальшивый ÑкземплÑÑ€! Ñ‘ÑŠ +3 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +4 PÅ™ÃliÅ¡ žluÅ¥ouÄký kůň úpÄ›l Äábelské kódy +6 ã†ã‚ã®ãŠãã‚„ã¾ ã‘ãµã“ãˆã¦ +7 Pchnąć w tÄ™ łódź jeża lub osiem skrzyÅ„ fig +8 MySQL Tutorial request docteam@oraclehelp.com ... +9 Trial version query performace @1255 minute on 2.1Hz Memory 2GB... +10 when To Use MySQL Well for free faq mail@xyz.com ... +DROP TABLE t1; +CREATE TABLE t1(ID INT PRIMARY KEY, +no_fts_field VARCHAR(10), +fts_field VARCHAR(10), +FULLTEXT INDEX f(fts_field)) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 'AAA', 'BBB'); +SELECT * FROM t1 WHERE MATCH(fts_field) against("BBB"); +ID no_fts_field fts_field +1 AAA BBB +UPDATE t1 SET fts_field='anychange' where id = 1; +SELECT * FROM t1 WHERE MATCH(fts_field) against("anychange"); +ID no_fts_field fts_field +1 AAA anychange +UPDATE t1 SET no_fts_field='anychange' where id = 1; +SELECT * FROM t1 WHERE MATCH(fts_field) against("anychange"); +ID no_fts_field fts_field +1 anychange anychange +UPDATE t1 SET no_fts_field='anychange', fts_field='other' where id = 1; +SELECT * FROM t1 WHERE MATCH(fts_field) against("other"); +ID no_fts_field fts_field +1 anychange other +SELECT * FROM t1 WHERE MATCH(fts_field) against("BBB"); +ID no_fts_field fts_field +DROP INDEX f on t1; +UPDATE t1 SET fts_field='anychange' where id = 1; +UPDATE t1 SET no_fts_field='anychange' where id = 1; +UPDATE t1 SET no_fts_field='anychange', fts_field='other' where id = 1; +CREATE FULLTEXT INDEX f ON t1(FTS_FIELD); +SELECT * FROM t1 WHERE MATCH(fts_field) against("other"); +ID no_fts_field fts_field +1 anychange other +DROP TABLE t1; +CREATE TABLE t1(`FTS_DOC_ID` serial, +no_fts_field VARCHAR(10), +fts_field VARCHAR(10), +FULLTEXT INDEX f(fts_field)) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 'AAA', 'BBB'); +UPDATE t1 SET fts_field='anychange' where FTS_DOC_ID = 1; +ERROR HY000: Invalid InnoDB FTS Doc ID +UPDATE t1 SET fts_field='anychange', FTS_DOC_ID = 2 where FTS_DOC_ID = 1; +SELECT * FROM t1 WHERE MATCH(fts_field) against("anychange"); +FTS_DOC_ID no_fts_field fts_field +2 AAA anychange +SELECT * FROM t1 WHERE MATCH(fts_field) against("BBB"); +FTS_DOC_ID no_fts_field fts_field +UPDATE t1 SET no_fts_field='anychange' where FTS_DOC_ID = 2; +SELECT * FROM t1 WHERE MATCH(fts_field) against("anychange"); +FTS_DOC_ID no_fts_field fts_field +2 anychange anychange +UPDATE t1 SET no_fts_field='anychange', fts_field='other' where FTS_DOC_ID = 2; +ERROR HY000: Invalid InnoDB FTS Doc ID +SELECT * FROM t1 WHERE MATCH(fts_field) against("other"); +FTS_DOC_ID no_fts_field fts_field +UPDATE t1 SET FTS_DOC_ID = 1 where FTS_DOC_ID = 2; +ERROR HY000: Invalid InnoDB FTS Doc ID +DROP INDEX f ON t1; +UPDATE t1 SET fts_field='newchange' where FTS_DOC_ID = 2; +UPDATE t1 SET no_fts_field='anychange' where FTS_DOC_ID = 2; +SELECT * FROM t1; +FTS_DOC_ID no_fts_field fts_field +2 anychange newchange +DROP TABLE t1; +CREATE TABLE t1(ID INT PRIMARY KEY, +no_fts_field VARCHAR(10), +fts_field VARCHAR(10), +FULLTEXT INDEX f(fts_field), index k(fts_field)) ENGINE=INNODB; +CREATE TABLE t2(ID INT PRIMARY KEY, +no_fts_field VARCHAR(10), +fts_field VARCHAR(10), +FULLTEXT INDEX f(fts_field), +INDEX k2(fts_field), +FOREIGN KEY(fts_field) REFERENCES +t1(fts_field) ON UPDATE CASCADE) ENGINE=INNODB; +INSERT INTO t1 VALUES (1, 'AAA', 'BBB'); +INSERT INTO t2 VALUES (1, 'AAA', 'BBB'); +update t1 set fts_field='newchange' where id =1; +SELECT * FROM t1 WHERE MATCH(fts_field) against("BBB"); +ID no_fts_field fts_field +SELECT * FROM t2 WHERE MATCH(fts_field) against("BBB"); +ID no_fts_field fts_field +SELECT * FROM t1 WHERE MATCH(fts_field) against("newchange"); +ID no_fts_field fts_field +1 AAA newchange +SELECT * FROM t2 WHERE MATCH(fts_field) against("newchange"); +ID no_fts_field fts_field +1 AAA newchange +DROP TABLE t2; +DROP TABLE t1; +CREATE TABLE t1(id INT PRIMARY KEY, +fts_field VARCHAR(10), +FULLTEXT INDEX f(fts_field)) ENGINE=INNODB; +CREATE TABLE t2(id INT PRIMARY KEY, +fts_field VARCHAR(10), +FULLTEXT INDEX f(fts_field)) ENGINE=INNODB; +INSERT INTO t1 values (1,'100'),(2,'200'),(3,'300'),(4,'400'),(5,'500'),(6,'600'), (7,'700'),(8,'800'),(9,'900'),(10,'1000'),(11,'1100'),(12,'1200'); +INSERT INTO t2 values (1,'100'),(2,'200'),(3,'300'),(4,'400'),(5,'500'),(6,'600'), (7,'700'),(8,'800'); +UPDATE t1, t2 set t1.fts_field = CONCAT(t1.fts_field, 'foo'); +UPDATE t1, t2 set t1.fts_field = CONCAT(t1.fts_field, 'foo') WHERE t1.fts_field = "100foo"; +UPDATE t1, t2 set t1.fts_field = CONCAT(t1.fts_field, 'xoo'), t2.fts_field = CONCAT(t1.fts_field, 'xoo') where t1.fts_field=CONCAT(t2.fts_field, 'foo'); +SELECT * FROM t1 WHERE MATCH(fts_field) against("100foofoo"); +id fts_field +1 100foofoo +SELECT * FROM t1 WHERE MATCH(fts_field) against("100foo"); +id fts_field +SELECT * FROM t1 WHERE MATCH(fts_field) against("100"); +id fts_field +SELECT * FROM t2 WHERE MATCH(fts_field) against("400fooxoo"); +id fts_field +4 400fooxoo +SELECT * FROM t2 WHERE MATCH(fts_field) against("100"); +id fts_field +1 100 +SELECT * FROM t2 WHERE MATCH(fts_field) against("200"); +id fts_field +SELECT * FROM t2 WHERE MATCH(fts_field) against("400"); +id fts_field +DROP TABLE t1; +DROP TABLE t2; + +BUG#13701973/64274: MYSQL THREAD WAS SUSPENDED WHEN EXECUTE UPDATE QUERY + +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; +CREATE TABLE t1 ( +t1_id INT(10) UNSIGNED NOT NULL, +t2_id INT(10) UNSIGNED DEFAULT NULL, +PRIMARY KEY (t1_id), +FOREIGN KEY (t2_id) REFERENCES t2 (t2_id) +ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB; +CREATE TABLE t2 ( +t1_id INT(10) UNSIGNED NOT NULL, +t2_id INT(10) UNSIGNED NOT NULL, +t3_id INT(10) UNSIGNED NOT NULL, +t4_id INT(10) UNSIGNED NOT NULL, +PRIMARY KEY (t2_id), +FOREIGN KEY (t1_id) REFERENCES t1 (t1_id), +FOREIGN KEY (t3_id) REFERENCES t3 (t3_id) +ON DELETE CASCADE ON UPDATE CASCADE, +FOREIGN KEY (t4_id) REFERENCES t4 (t4_id) +) ENGINE=InnoDB; +CREATE TABLE t3 ( +t3_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, +payload char(3), +PRIMARY KEY (t3_id) +) ENGINE=InnoDB; +INSERT INTO t3 VALUES (1, '100'); +CREATE TABLE t4 ( +t2_id INT(10) UNSIGNED DEFAULT NULL, +t4_id INT(10) UNSIGNED NOT NULL, +PRIMARY KEY (t4_id), +FOREIGN KEY (t2_id) REFERENCES t2 (t2_id) +ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB; +SET FOREIGN_KEY_CHECKS=1; +UPDATE t3 SET payload='101' WHERE t3_id=1; +SET FOREIGN_KEY_CHECKS=0; +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +DROP TABLE t4; +# +# InnoDB: Failing assertion: result != FTS_INVALID in +# fts_trx_row_get_new_state +# +SET FOREIGN_KEY_CHECKS=1; +CREATE TABLE t1 (pk INT PRIMARY KEY, +f1 VARCHAR(10), f2 VARCHAR(10), +f3 VARCHAR(10), f4 VARCHAR(10), +f5 VARCHAR(10), f6 VARCHAR(10), +f7 VARCHAR(10), f8 VARCHAR(10), +FULLTEXT(f1), FULLTEXT(f2), FULLTEXT(f3), FULLTEXT(f4), +FULLTEXT(f5), FULLTEXT(f6), FULLTEXT(f7), FULLTEXT(f8), +INDEX(f1), INDEX(f2), INDEX(f3), INDEX(f4), +INDEX(f5), INDEX(f6), INDEX(f7), INDEX(f8)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 'mariadb', 'mariadb', 'mariadb', 'mariadb', +'mariadb', 'mariadb', 'mariadb', 'mariadb'), +(2, 'mariadb', 'mariadb', 'mariadb', 'mariadb', +'mariadb', 'mariadb', 'mariadb', 'mariadb'), +(3, 'innodb', 'innodb', 'innodb', 'innodb', +'innodb', 'innodb', 'innodb', 'innodb'); +ALTER TABLE t1 ADD FOREIGN KEY (f1) REFERENCES t1 (f2) ON DELETE SET NULL; +START TRANSACTION; +DELETE FROM t1 where f1='mariadb'; +SELECT * FROM t1; +pk f1 f2 f3 f4 f5 f6 f7 f8 +2 NULL mariadb mariadb mariadb mariadb mariadb mariadb mariadb +3 innodb innodb innodb innodb innodb innodb innodb innodb +ROLLBACK; +ALTER TABLE t1 ADD FOREIGN KEY (f3) REFERENCES t1 (f4) ON DELETE CASCADE; +START TRANSACTION; +DELETE FROM t1 where f3='mariadb'; +SELECT * FROM t1; +pk f1 f2 f3 f4 f5 f6 f7 f8 +3 innodb innodb innodb innodb innodb innodb innodb innodb +ROLLBACK; +ALTER TABLE t1 ADD FOREIGN KEY (f5) REFERENCES t1 (f6) ON UPDATE SET NULL; +UPDATE t1 SET f6='update'; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_3` FOREIGN KEY (`f5`) REFERENCES `t1` (`f6`) ON UPDATE SET NULL) +ALTER TABLE t1 ADD FOREIGN KEY (f7) REFERENCES t1 (f8) ON UPDATE CASCADE; +UPDATE t1 SET f6='cascade'; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t1`, CONSTRAINT `t1_ibfk_3` FOREIGN KEY (`f5`) REFERENCES `t1` (`f6`) ON UPDATE SET NULL) +DROP TABLE t1; +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; +# +# MDEV-25536 sym_node->table != NULL in pars_retrieve_table_def +# +CREATE TABLE t1 (f1 TEXT,FULLTEXT (f1)) ENGINE=InnoDB; +ALTER TABLE t1 DISCARD TABLESPACE; +SET GLOBAL innodb_ft_aux_table='test/t1'; +SELECT * FROM information_schema.innodb_ft_deleted; +DOC_ID +DROP TABLE t1; +SET GLOBAL innodb_ft_aux_table=DEFAULT; +# +# MDEV-19522 InnoDB commit fails when FTS_DOC_ID value +# is greater than 4294967295 +# +CREATE TABLE t1( +FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, +f1 TEXT, f2 TEXT, PRIMARY KEY (FTS_DOC_ID), +FULLTEXT KEY (f1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,'txt','bbb'); +UPDATE t1 SET FTS_DOC_ID = 4294967298; +SELECT * FROM t1 WHERE match(f1) against("txt"); +FTS_DOC_ID f1 f2 +4294967298 txt bbb +SET @@session.insert_id = 100000000000; +INSERT INTO t1(f1, f2) VALUES ('aaa', 'bbb'); +CREATE FULLTEXT INDEX i ON t1 (f2); +SELECT * FROM t1 WHERE match(f2) against("bbb"); +FTS_DOC_ID f1 f2 +4294967298 txt bbb +100000000000 aaa bbb +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_multiple_index.result b/mysql-test/suite/innodb_fts/r/innodb_fts_multiple_index.result new file mode 100644 index 00000000..bbf6f3ee --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_multiple_index.result @@ -0,0 +1,211 @@ +drop table if exists t1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB STATS_PERSISTENT=0; +INSERT INTO t1 (a,b) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'); +ALTER TABLE t1 ADD FULLTEXT INDEX idx_1 (a); +ALTER TABLE t1 ADD FULLTEXT INDEX idx_2 (b); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `a` varchar(200) DEFAULT NULL, + `b` text DEFAULT NULL, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx_1` (`a`), + FULLTEXT KEY `idx_2` (`b`) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci STATS_PERSISTENT=0 +START TRANSACTION; +INSERT INTO t1 (a,b) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +ROLLBACK; +SELECT * FROM t1 WHERE MATCH (a) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +select * from t1 where MATCH(a) AGAINST("+mysql +Tutorial" IN BOOLEAN MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +select * from t1 where MATCH(b) AGAINST("+Tutorial" IN BOOLEAN MODE); +id a b +3 Optimizing MySQL In this tutorial we will show ... +select * from t1 where MATCH(b) AGAINST("+stands +(DataBase)" IN BOOLEAN MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +select * from t1 where MATCH(b) AGAINST("+DataBase -(comparison)" IN BOOLEAN MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +select *, MATCH(a) AGAINST("Optimizing MySQL" IN BOOLEAN MODE) as x from t1; +id a b x +1 MySQL Tutorial DBMS stands for DataBase ... 0.000000001885928302414186 +2 How To Use MySQL Well After you went through a ... 0.000000001885928302414186 +3 Optimizing MySQL In this tutorial we will show ... 0.22764469683170319 +select *, MATCH(b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; +id a b x +1 MySQL Tutorial DBMS stands for DataBase ... 0 +2 How To Use MySQL Well After you went through a ... 0 +3 Optimizing MySQL In this tutorial we will show ... 0 +select * from t1 where MATCH a AGAINST ("+Optimiz* +Optimiz*" IN BOOLEAN MODE); +id a b +3 Optimizing MySQL In this tutorial we will show ... +select * from t1 where MATCH b AGAINST ('"DBMS stands"' IN BOOLEAN MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +select * from t1 where MATCH b AGAINST ('"DBMS STANDS"' IN BOOLEAN MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +select * from t1 where MATCH(b) AGAINST ("DataBase" WITH QUERY EXPANSION); +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +select * from t1 where MATCH(a) AGAINST ("Security" WITH QUERY EXPANSION); +id a b +ALTER TABLE t1 DROP INDEX idx_1; +ALTER TABLE t1 DROP INDEX idx_2; +ALTER TABLE t1 ADD FULLTEXT INDEX idx_1 (a); +ALTER TABLE t1 ADD FULLTEXT INDEX idx_2 (b); +SELECT * FROM t1 WHERE MATCH (a) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +select * from t1 where MATCH(a) AGAINST("+mysql +Tutorial" IN BOOLEAN MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +select * from t1 where MATCH(b) AGAINST("+Tutorial" IN BOOLEAN MODE); +id a b +3 Optimizing MySQL In this tutorial we will show ... +select * from t1 where MATCH(b) AGAINST("+stands +(DataBase)" IN BOOLEAN MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +select * from t1 where MATCH(b) AGAINST("+DataBase -(comparison)" IN BOOLEAN MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +select *, MATCH(a) AGAINST("Optimizing MySQL" IN BOOLEAN MODE) as x from t1; +id a b x +1 MySQL Tutorial DBMS stands for DataBase ... 0.000000001885928302414186 +2 How To Use MySQL Well After you went through a ... 0.000000001885928302414186 +3 Optimizing MySQL In this tutorial we will show ... 0.22764469683170319 +select *, MATCH(b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; +id a b x +1 MySQL Tutorial DBMS stands for DataBase ... 0 +2 How To Use MySQL Well After you went through a ... 0 +3 Optimizing MySQL In this tutorial we will show ... 0 +select * from t1 where MATCH a AGAINST ("+Optimiz* +Optimiz*" IN BOOLEAN MODE); +id a b +3 Optimizing MySQL In this tutorial we will show ... +select * from t1 where MATCH b AGAINST ('"DBMS stands"' IN BOOLEAN MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +select * from t1 where MATCH b AGAINST ('"DBMS STANDS"' IN BOOLEAN MODE); +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +select * from t1 where MATCH(b) AGAINST ("DataBase" WITH QUERY EXPANSION); +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +select * from t1 where MATCH(a) AGAINST ("Security" WITH QUERY EXPANSION); +id a b +INSERT INTO t1 (a,b) VALUES ('test query expansion','for database ...'); +INSERT INTO t1 (a,b) VALUES +('test proximity search, test, proximity and phrase', +'search, with proximity innodb'); +INSERT INTO t1 (a,b) VALUES +('test proximity fts search, test, proximity and phrase', +'search, with proximity innodb'); +INSERT INTO t1 (a,b) VALUES +('test more of proximity for fts search, test, more proximity and phrase', +'search, with proximity innodb'); +SELECT * FROM t1 +WHERE MATCH (a) +AGAINST ('"proximity search"@3' IN BOOLEAN MODE); +id a b +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test proximity fts search, test, proximity and phrase search, with proximity innodb +SELECT * FROM t1 +WHERE MATCH (a) +AGAINST ('"proximity search"@2' IN BOOLEAN MODE); +id a b +8 test proximity search, test, proximity and phrase search, with proximity innodb +SELECT * FROM t1 +WHERE MATCH (b) +AGAINST ('"proximity innodb"@4' IN BOOLEAN MODE); +id a b +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test proximity fts search, test, proximity and phrase search, with proximity innodb +10 test more of proximity for fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM t1 +WHERE MATCH (a) +AGAINST ('"test proximity"@3' IN BOOLEAN MODE); +id a b +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test proximity fts search, test, proximity and phrase search, with proximity innodb +10 test more of proximity for fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM t1 +WHERE MATCH (a) +AGAINST ('"more test proximity"@3' IN BOOLEAN MODE); +id a b +10 test more of proximity for fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM t1 +WHERE MATCH (a) +AGAINST ('"more test proximity"@2' IN BOOLEAN MODE); +id a b +SELECT * FROM t1 +WHERE MATCH (a) +AGAINST ('"more fts proximity"@02' IN BOOLEAN MODE); +id a b +SELECT * FROM t1 WHERE CONCAT(t1.a,t1.b) IN ( +SELECT CONCAT(a,b) FROM t1 AS t2 WHERE +MATCH (t2.a) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +) OR t1.id = 3 ; +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM t1 WHERE CONCAT(t1.a,t1.b) IN ( +SELECT CONCAT(a,b) FROM t1 AS t2 +WHERE MATCH (t2.a) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +AND t2.id != 3) ; +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +SELECT * FROM t1 WHERE id IN (SELECT MIN(id) FROM t1 WHERE +MATCH (b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)) OR id = 3 ; +id a b +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM t1 WHERE id NOT IN (SELECT MIN(id) FROM t1 +WHERE MATCH (b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)) ; +id a b +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +7 test query expansion for database ... +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test proximity fts search, test, proximity and phrase search, with proximity innodb +10 test more of proximity for fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM t1 WHERE EXISTS (SELECT t2.id FROM t1 AS t2 WHERE +MATCH (t2.b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +AND t1.id = t2.id) ; +id a b +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM t1 WHERE NOT EXISTS (SELECT t2.id FROM t1 AS t2 WHERE +MATCH (t2.a) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +AND t1.id = t2.id) ; +id a b +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +7 test query expansion for database ... +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test proximity fts search, test, proximity and phrase search, with proximity innodb +10 test more of proximity for fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM t1 WHERE t1.id = (SELECT MAX(t2.id) FROM t1 AS t2 WHERE +MATCH(t2.a) AGAINST ('"proximity search"@3' IN BOOLEAN MODE)); +id a b +9 test proximity fts search, test, proximity and phrase search, with proximity innodb +SELECT * FROM t1 WHERE t1.id > (SELECT MIN(t2.id) FROM t1 AS t2 WHERE +MATCH(t2.b) AGAINST ('"proximity innodb"@3' IN BOOLEAN MODE)); +id a b +9 test proximity fts search, test, proximity and phrase search, with proximity innodb +10 test more of proximity for fts search, test, more proximity and phrase search, with proximity innodb +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_plugin.result b/mysql-test/suite/innodb_fts/r/innodb_fts_plugin.result new file mode 100644 index 00000000..b9b2350c --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_plugin.result @@ -0,0 +1,221 @@ +INSTALL PLUGIN simple_parser SONAME 'mypluglib'; +FLUSH TABLES; +# Test Part 1: Grammar Test +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +FULLTEXT (title) WITH PARSER simple_parser +) ENGINE=MyISAM; +ALTER TABLE articles ENGINE=InnoDB; +DROP TABLE articles; +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +comment TEXT, +FULLTEXT (title) WITH PARSER simple_parser +) ENGINE=InnoDB; +ALTER TABLE articles ADD FULLTEXT INDEX (body) WITH PARSER simple_parser; +CREATE FULLTEXT INDEX ft_index ON articles(comment) WITH PARSER simple_parser; +DROP TABLE articles; +# Test Part 2: Create Index Test(CREATE TABLE WITH FULLTEXT INDEX) +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title, body) WITH PARSER simple_parser +) ENGINE=InnoDB; +INSERT INTO articles (title, body) VALUES +('MySQL Tutorial','DBMS stands for MySQL DataBase ...'), +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','How to use full-text search engine'), +('Go MySQL Tricks','How to use full text search engine'); +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('mysql') ORDER BY id; +id title body +1 MySQL Tutorial DBMS stands for MySQL DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks How to use full-text search engine +5 Go MySQL Tricks How to use full text search engine +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('will go'); +id title body +# Test plugin parser tokenizer difference +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('full-text'); +id title body +4 1001 MySQL Tricks How to use full-text search engine +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('full text'); +id title body +5 Go MySQL Tricks How to use full text search engine +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('"mysql database"' IN BOOLEAN MODE); +id title body +DROP TABLE articles; +# Test Part 3: Row Merge Create Index Test(ALTER TABLE ADD FULLTEXT INDEX) +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT +) ENGINE=InnoDB; +INSERT INTO articles (title, body) VALUES +('MySQL Tutorial','DBMS stands for MySQL DataBase ...'), +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','How to use full-text search engine'), +('Go MySQL Tricks','How to use full text search engine'); +ALTER TABLE articles ADD FULLTEXT INDEX (title, body) WITH PARSER simple_parser; +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('mysql') ORDER BY id; +id title body +1 MySQL Tutorial DBMS stands for MySQL DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks How to use full-text search engine +5 Go MySQL Tricks How to use full text search engine +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('will go'); +id title body +# Test plugin parser tokenizer difference +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('full-text'); +id title body +4 1001 MySQL Tricks How to use full-text search engine +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('full text'); +id title body +5 Go MySQL Tricks How to use full text search engine +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('full-text' WITH QUERY EXPANSION) +ORDER BY id; +id title body +1 MySQL Tutorial DBMS stands for MySQL DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks How to use full-text search engine +5 Go MySQL Tricks How to use full text search engine +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('full text' WITH QUERY EXPANSION) +ORDER BY id; +id title body +1 MySQL Tutorial DBMS stands for MySQL DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks How to use full-text search engine +5 Go MySQL Tricks How to use full text search engine +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('"mysql database"' IN BOOLEAN MODE); +id title body +DROP TABLE articles; +# Test Part 3 END +# Test Part 4:crash on commit(before/after) +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title, body) WITH PARSER simple_parser +) ENGINE=InnoDB; +SET unique_checks=0, foreign_key_checks=0; +BEGIN; +INSERT INTO articles (title, body) VALUES +('MySQL Tutorial','DBMS stands for MySQL DataBase ...'), +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','How to use full-text search engine'), +('Go MySQL Tricks','How to use full text search engine'); +# restart +SELECT COUNT(*) FROM articles; +COUNT(*) +0 +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('mysql'); +id title body +INSERT INTO articles (title, body) VALUES +('MySQL Tutorial','DBMS stands for MySQL DataBase ...'), +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','How to use full-text search engine'), +('Go MariaDB Tricks','How to use full text search engine'); +# restart +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('MySQL') ORDER BY id; +id title body +1 MySQL Tutorial DBMS stands for MySQL DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks How to use full-text search engine +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('tutorial') ORDER BY id; +id title body +1 MySQL Tutorial DBMS stands for MySQL DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('Tricks') ORDER BY id; +id title body +4 1001 MySQL Tricks How to use full-text search engine +5 Go MariaDB Tricks How to use full text search engine +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('full text search') ORDER BY id; +id title body +4 1001 MySQL Tricks How to use full-text search engine +5 Go MariaDB Tricks How to use full text search engine +SELECT COUNT(*) FROM articles; +COUNT(*) +5 +INSERT INTO articles (title, body) VALUES ('111', '1234 1234 1234'); +DROP TABLE articles; +# Test Part 5: Test Uninstall Plugin After Index is Built +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title, body) WITH PARSER simple_parser +) ENGINE=InnoDB; +UNINSTALL PLUGIN simple_parser; +INSERT INTO articles (title, body) VALUES +('MySQL Tutorial','DBMS stands for MySQL DataBase ...'); +ERROR HY000: Plugin 'simple_parser' is not loaded +INSTALL PLUGIN simple_parser SONAME 'mypluglib'; +INSERT INTO articles (title, body) VALUES +('MySQL Tutorial','DBMS stands for MySQL DataBase ...'), +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','How to use full-text search engine'), +('Go MySQL Tricks','How to use full text search engine'); +UNINSTALL PLUGIN simple_parser; +Warnings: +Warning 1620 Plugin is busy and will be uninstalled on shutdown +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('mysql') +ORDER BY id; +id title body +1 MySQL Tutorial DBMS stands for MySQL DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks How to use full-text search engine +5 Go MySQL Tricks How to use full text search engine +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('will go'); +id title body +# Test plugin parser tokenizer difference +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('full-text'); +id title body +4 1001 MySQL Tricks How to use full-text search engine +SELECT * FROM articles WHERE +MATCH(title, body) AGAINST('full text'); +id title body +5 Go MySQL Tricks How to use full text search engine +CREATE TABLE articles2 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title, body) WITH PARSER simple_parser +) ENGINE=InnoDB; +ERROR HY000: Function 'simple_parser' is not defined +DROP TABLE articles; +UNINSTALL PLUGIN simple_parser; +ERROR 42000: PLUGIN simple_parser does not exist diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_proximity.result b/mysql-test/suite/innodb_fts/r/innodb_fts_proximity.result new file mode 100644 index 00000000..d67981e0 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_proximity.result @@ -0,0 +1,217 @@ +drop table if exists t1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) ENGINE= InnoDB; +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','what In this tutorial we will show ...'); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("where will"); +id a b +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("when"); +id a b +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("what" WITH QUERY EXPANSION); +id a b +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("whe*" IN BOOLEAN MODE); +id a b +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("+what +will" IN BOOLEAN MODE); +id a b +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("+from" IN BOOLEAN MODE); +id a b +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("+where +(show what)" IN BOOLEAN MODE); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"where will"@6' IN BOOLEAN MODE); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"where will"@9' IN BOOLEAN MODE); +id a b +INSERT INTO t1 (a,b) VALUES +('MySQL Tutorial','request docteam@oraclehelp.com ...') , +('Trial version','query performace @1255 minute on 2.1Hz Memory 2GB...') , +('when To Use MySQL Well','for free faq mail@xyz.com ...'); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"request"@10' IN BOOLEAN MODE); +id a b +4 MySQL Tutorial request docteam@oraclehelp.com ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"Trial version"@0' IN BOOLEAN MODE); +id a b +5 Trial version query performace @1255 minute on 2.1Hz Memory 2GB... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"request docteam@oraclehelp.com"@10' IN BOOLEAN MODE); +id a b +4 MySQL Tutorial request docteam@oraclehelp.com ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"1255 minute"@1' IN BOOLEAN MODE); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"1255 minute"@2' IN BOOLEAN MODE); +id a b +5 Trial version query performace @1255 minute on 2.1Hz Memory 2GB... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"1255"@10' IN BOOLEAN MODE); +id a b +5 Trial version query performace @1255 minute on 2.1Hz Memory 2GB... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('1255' WITH QUERY EXPANSION); +id a b +5 Trial version query performace @1255 minute on 2.1Hz Memory 2GB... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"request docteam"@2' IN BOOLEAN MODE); +id a b +4 MySQL Tutorial request docteam@oraclehelp.com ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"1255 minute"' IN BOOLEAN MODE); +id a b +5 Trial version query performace @1255 minute on 2.1Hz Memory 2GB... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request docteam@oraclehelp.com'); +id a b +4 MySQL Tutorial request docteam@oraclehelp.com ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"MySQL request"@3' IN BOOLEAN MODE); +id a b +4 MySQL Tutorial request docteam@oraclehelp.com ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"Trial memory"@10' IN BOOLEAN MODE); +id a b +5 Trial version query performace @1255 minute on 2.1Hz Memory 2GB... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"Trial memory"@9' IN BOOLEAN MODE); +id a b +DROP TABLE t1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) CHARACTER SET = UTF8, ENGINE= InnoDB; +INSERT INTO t1 (a,b) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','what In this tutorial we will show ...'); +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES +('MySQL Tutorial','request docteam@oraclehelp.com ...') , +('Trial version','query performace @1255 minute on 2.1Hz Memory 2GB...'), +('when To Use MySQL Well','for free faq mail@xyz.com ...'); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"mysql use"@2' IN BOOLEAN MODE); +id a b +2 when To Use MySQL Well After that you went through a ... +6 when To Use MySQL Well for free faq mail@xyz.com ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"mysql use"@1' IN BOOLEAN MODE); +id a b +INSERT INTO t1 (a,b) VALUES ('XYZ, long blob', repeat("a", 9000)); +INSERT IGNORE INTO t1 (a,b) VALUES (repeat("b", 9000), 'XYZ, long blob'); +Warnings: +Warning 1265 Data truncated for column 'a' at row 1 +SELECT count(*) FROM t1 +WHERE MATCH (a,b) +AGAINST ('"xyz blob"@3' IN BOOLEAN MODE); +count(*) +2 +DROP TABLE t1; +set global innodb_file_per_table=1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a TEXT, +b TEXT, +c TEXT +) CHARACTER SET = UTF8, ROW_FORMAT=DYNAMIC, ENGINE= InnoDB; +INSERT INTO t1 (a,b,c) VALUES (repeat("b", 19000), 'XYZ, long text', 'very long blob'); +INSERT INTO t1 (a,b,c) VALUES (repeat("b", 19000), 'XYZ, very little long blob very much blob', 'very long blob'); +INSERT INTO t1 (a,b,c) VALUES (repeat("b", 19000),"very 租车 ä¾› blob","new 供需分æžinformation"); +CREATE FULLTEXT INDEX idx on t1 (a,b,c); +INSERT INTO t1 (a,b,c) VALUES (repeat("x", 19000), 'new, long text', 'very new blob'); +INSERT INTO t1 (a,b,c) VALUES ('interesting, long text', repeat("x", 19000), 'very very good new blob'); +SELECT count(*) FROM t1 +WHERE MATCH (a,b,c) +AGAINST ('"very blob"@3' IN BOOLEAN MODE); +count(*) +3 +SELECT count(*) FROM t1 +WHERE MATCH (a,b,c) +AGAINST ('"very long blob"@0' IN BOOLEAN MODE); +count(*) +2 +SELECT count(*) FROM t1 +WHERE MATCH (a,b,c) +AGAINST ('"very blob"@4' IN BOOLEAN MODE); +count(*) +4 +SELECT count(*) FROM t1 +WHERE MATCH (a,b,c) +AGAINST ('"interesting blob"@9' IN BOOLEAN MODE); +count(*) +1 +SELECT COUNT(*) FROM t1 +WHERE MATCH (a,b,c) +AGAINST ('"interesting blob"@9 "very long blob"@0' IN BOOLEAN MODE); +COUNT(*) +3 +SELECT COUNT(*) FROM t1 +WHERE MATCH (a,b,c) +AGAINST ('"very blob"@4 - "interesting blob"@9' IN BOOLEAN MODE); +COUNT(*) +3 +DROP TABLE t1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) CHARACTER SET = UTF8, ENGINE= InnoDB; +INSERT INTO t1 (a,b) VALUES +('MySQL from Tutorial','DBMS stands for + DataBase ...'); +CREATE FULLTEXT INDEX idx on t1 (a,b); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"stands database"@3' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for + DataBase ... +DROP TABLE t1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a TEXT, +b TEXT, +c TEXT +) CHARACTER SET = UTF8, ROW_FORMAT=DYNAMIC, ENGINE= InnoDB; +INSERT INTO t1 (a,b,c) VALUES (repeat("b", 19000), 'XYZ, long text', 'very long blob'); +INSERT INTO t1 (a,b,c) VALUES ('XYZ, 租车 very little long blob very much blob', repeat("b", 19000), 'very long but smaller blob'); +CREATE FULLTEXT INDEX idx on t1 (a,b,c); +DELETE FROM t1; +INSERT INTO t1 (a,b,c) VALUES (repeat("b", 19000), 'XYZ, long text', 'very long blob'); +INSERT INTO t1 (a,b,c) VALUES ('XYZ, 租车 very little long blob is a very much longer blob', repeat("b", 19000), 'this is very long but smaller blob'); +SELECT count(*) FROM t1 +WHERE MATCH (a,b,c) +AGAINST ('"very blob"@4' IN BOOLEAN MODE); +count(*) +2 +SELECT count(*) FROM t1 +WHERE MATCH (a,b,c) +AGAINST ('"very blob"@3' IN BOOLEAN MODE); +count(*) +1 +DROP TABLE t1; +SET GLOBAL innodb_file_per_table=1; diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_result_cache_limit.result b/mysql-test/suite/innodb_fts/r/innodb_fts_result_cache_limit.result new file mode 100644 index 00000000..61eb5294 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_result_cache_limit.result @@ -0,0 +1,30 @@ +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) ENGINE= InnoDB; +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','what In this tutorial we will show ...'), +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','what In this tutorial we will show ...'), +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','what In this tutorial we will show ...'); +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET SESSION debug_dbug="+d,fts_instrument_result_cache_limit"; +SELECT COUNT(*) FROM t1 WHERE MATCH (a,b) AGAINST ('mysql' IN BOOLEAN MODE); +COUNT(*) +9 +SELECT COUNT(*) FROM t1 WHERE MATCH (a,b) AGAINST ('mysql' WITH QUERY EXPANSION); +ERROR HY000: Table handler out of memory +SELECT COUNT(*) FROM t1 WHERE MATCH (a,b) AGAINST ('"mysql database"' IN BOOLEAN MODE); +ERROR HY000: Table handler out of memory +SELECT COUNT(*) FROM t1 WHERE MATCH (a,b) AGAINST ('"mysql database" @ 5' IN BOOLEAN MODE); +ERROR HY000: Table handler out of memory +SET SESSION debug_dbug=@saved_debug_dbug; +DROP TABLE t1; +SET GLOBAL innodb_ft_result_cache_limit=default; diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_stopword_charset.result b/mysql-test/suite/innodb_fts/r/innodb_fts_stopword_charset.result new file mode 100644 index 00000000..f2cfcd93 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_stopword_charset.result @@ -0,0 +1,320 @@ +SELECT @@innodb_ft_server_stopword_table; +@@innodb_ft_server_stopword_table +NULL +SELECT @@innodb_ft_enable_stopword; +@@innodb_ft_enable_stopword +1 +SELECT @@innodb_ft_user_stopword_table; +@@innodb_ft_user_stopword_table +NULL +SET NAMES utf8; +# Test 1 : default latin1_swedish_ci +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200) +) ENGINE=InnoDB; +INSERT IGNORE INTO articles (title) VALUES +('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), +('lṓve'),('Lá¹’VE'); +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +1 love +2 LOVE +3 lòve +4 LÃ’VE +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('love' IN NATURAL LANGUAGE MODE); +id title +DROP TABLE articles; +DROP TABLE user_stopword; +# Test 2 : latin1_general_ci +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200) +) ENGINE=InnoDB DEFAULT CHARACTER SET latin1 COLLATE latin1_general_ci; +INSERT IGNORE INTO articles (title) VALUES +('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), +('lṓve'),('Lá¹’VE'); +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +3 lòve +4 LÃ’VE +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB +DEFAULT CHARACTER SET latin1 COLLATE latin1_general_ci; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('love' IN NATURAL LANGUAGE MODE); +id title +1 love +2 LOVE +DROP TABLE articles; +DROP TABLE user_stopword; +# Test 3 : latin1_spanish_ci +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200) +) ENGINE=InnoDB DEFAULT CHARACTER SET latin1 COLLATE latin1_spanish_ci; +INSERT IGNORE INTO articles (title) VALUES +('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), +('lṓve'),('Lá¹’VE'); +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +1 love +2 LOVE +3 lòve +4 LÃ’VE +5 löve +6 LÖVE +7 løve +8 LØVE +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB +DEFAULT CHARACTER SET latin1 COLLATE latin1_spanish_ci; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('love' IN NATURAL LANGUAGE MODE); +id title +DROP TABLE articles; +DROP TABLE user_stopword; +# Test 4 : utf8_general_ci +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200) +) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; +INSERT INTO articles (title) VALUES +('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), +('lṓve'),('Lá¹’VE'); +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +1 love +2 LOVE +3 lòve +4 LÃ’VE +5 löve +6 LÖVE +9 lṓve +10 Lá¹’VE +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB +DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('love' IN NATURAL LANGUAGE MODE); +id title +DROP TABLE articles; +DROP TABLE user_stopword; +# Test 5 : utf8_unicode_ci +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200) +) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_swedish_ci; +INSERT INTO articles (title) VALUES +('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), +('lṓve'),('Lá¹’VE'); +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +1 love +2 LOVE +3 lòve +4 LÃ’VE +9 lṓve +10 Lá¹’VE +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB +DEFAULT CHARACTER SET utf8 COLLATE utf8_swedish_ci; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('love' IN NATURAL LANGUAGE MODE); +id title +DROP TABLE articles; +DROP TABLE user_stopword; +# Test 6 : utf8_unicode_ci +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200) +) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; +INSERT INTO articles (title) VALUES +('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), +('lṓve'),('Lá¹’VE'); +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +1 love +2 LOVE +3 lòve +4 LÃ’VE +5 löve +6 LÖVE +9 lṓve +10 Lá¹’VE +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB +DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('love' IN NATURAL LANGUAGE MODE); +id title +DROP TABLE articles; +DROP TABLE user_stopword; +# Test 7 : gb2312_chinese_ci +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200) +) ENGINE=InnoDB DEFAULT CHARACTER SET gb2312 COLLATE gb2312_chinese_ci; +INSERT INTO articles (title) VALUES +('相亲相爱'),('怜香惜爱'),('充满å¯çˆ±'),('爱æ¨äº¤ç»‡'); +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('相亲相爱' IN NATURAL LANGUAGE MODE); +id title +1 相亲相爱 +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB +DEFAULT CHARACTER SET gb2312 COLLATE gb2312_chinese_ci; +INSERT INTO user_stopword VALUES('相亲相爱'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('相亲相爱' IN NATURAL LANGUAGE MODE); +id title +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('怜香惜爱' IN NATURAL LANGUAGE MODE); +id title +2 怜香惜爱 +DROP TABLE articles; +DROP TABLE user_stopword; +# Test 8 : test shutdown to check if stopword still works +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200) +) ENGINE=InnoDB; +INSERT IGNORE INTO articles (title) VALUES +('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), +('lṓve'),('Lá¹’VE'); +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +1 love +2 LOVE +3 lòve +4 LÃ’VE +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('love' IN NATURAL LANGUAGE MODE); +id title +# Shutdown and restart mysqld +# restart +SET NAMES utf8; +INSERT IGNORE INTO articles (title) VALUES +('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), +('lṓve'),('Lá¹’VE'); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('love' IN NATURAL LANGUAGE MODE); +id title +DROP TABLE articles; +DROP TABLE user_stopword; +# Test 9 : drop user stopwrod table,test shutdown to check if it works +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200) +) ENGINE=InnoDB; +INSERT IGNORE INTO articles (title) VALUES +('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), +('lṓve'),('Lá¹’VE'); +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +1 love +2 LOVE +3 lòve +4 LÃ’VE +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('love' IN NATURAL LANGUAGE MODE); +id title +DROP TABLE user_stopword; +# Shutdown and restart mysqld +# restart +SET NAMES utf8; +INSERT IGNORE INTO articles (title) VALUES +('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), +('lṓve'),('Lá¹’VE'); +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('lòve' IN NATURAL LANGUAGE MODE); +id title +11 love +12 LOVE +13 lòve +14 LÃ’VE +SELECT * FROM articles WHERE MATCH (title) +AGAINST ('love' IN NATURAL LANGUAGE MODE); +id title +11 love +12 LOVE +13 lòve +14 LÃ’VE +DROP TABLE articles; diff --git a/mysql-test/suite/innodb_fts/r/innodb_fts_transaction.result b/mysql-test/suite/innodb_fts/r/innodb_fts_transaction.result new file mode 100644 index 00000000..fc6a1d1a --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/innodb_fts_transaction.result @@ -0,0 +1,1047 @@ +drop table if exists t1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB STATS_PERSISTENT=0; +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','what In this tutorial we will show ...'); +START TRANSACTION; +INSERT INTO t1 (a,b) VALUES +('MySQL Tutorial','request docteam for oraclehelp.'); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +3 where will Optimizing MySQL what In this tutorial we will show ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request' IN NATURAL LANGUAGE MODE); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request MySQL' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('-request +MySQL' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+MySQL -(Tutorial Optimizing)' IN BOOLEAN MODE); +id a b +2 when To Use MySQL Well After that you went through a ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"stands Database"@11' IN BOOLEAN MODE) ORDER BY 1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('tutorial' WITH QUERY EXPANSION); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +3 where will Optimizing MySQL what In this tutorial we will show ... +2 when To Use MySQL Well After that you went through a ... +COMMIT; +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 MySQL Tutorial request docteam for oraclehelp. +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request MySQL' IN BOOLEAN MODE); +id a b +4 MySQL Tutorial request docteam for oraclehelp. +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('tutorial' WITH QUERY EXPANSION); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +4 MySQL Tutorial request docteam for oraclehelp. +3 where will Optimizing MySQL what In this tutorial we will show ... +2 when To Use MySQL Well After that you went through a ... +START TRANSACTION; +INSERT INTO t1 (a,b) VALUES (NULL,NULL); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+request +MySQL' IN BOOLEAN MODE); +id a b +4 MySQL Tutorial request docteam for oraclehelp. +UPDATE t1 SET a = 'Trial version' , b = 'query performace 1255 minute on 2.1Hz Memory 2GB...' +WHERE MATCH (a,b) AGAINST ('+request +MySQL' IN BOOLEAN MODE); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request'); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('query performace' IN BOOLEAN MODE); +id a b +UPDATE t1 SET a = 'when To Use MySQL Well' , b = 'for free faq xyz.com ...' +WHERE MATCH (a,b) AGAINST ('+query +performace' IN BOOLEAN MODE); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('performace'); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+mail +MySQL' IN BOOLEAN MODE); +id a b +COMMIT; +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('+MySQL' IN BOOLEAN MODE); +SELECT * FROM t1; +id a b +4 Trial version query performace 1255 minute on 2.1Hz Memory 2GB... +5 NULL NULL +INSERT INTO t1 (a,b) VALUES +('Trial version','query performace 1255 minute on 2.1Hz Memory 2GB...') , +('when To Use MySQL Well','for free faq mail@xyz.com ...'); +SELECT * FROM t1; +id a b +4 Trial version query performace 1255 minute on 2.1Hz Memory 2GB... +5 NULL NULL +6 Trial version query performace 1255 minute on 2.1Hz Memory 2GB... +7 when To Use MySQL Well for free faq mail@xyz.com ... +DROP TABLE t1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB; +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','what In this tutorial we will show ...'); +START TRANSACTION; +INSERT INTO t1 (a,b) VALUES +('MySQL Tutorial','request docteam for oraclehelp.'); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +3 where will Optimizing MySQL what In this tutorial we will show ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request' IN NATURAL LANGUAGE MODE); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request MySQL' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('-request +MySQL' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+MySQL -(Tutorial Optimizing)' IN BOOLEAN MODE); +id a b +2 when To Use MySQL Well After that you went through a ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('tutorial' WITH QUERY EXPANSION); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +3 where will Optimizing MySQL what In this tutorial we will show ... +2 when To Use MySQL Well After that you went through a ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('tutorial' WITH QUERY EXPANSION); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +3 where will Optimizing MySQL what In this tutorial we will show ... +2 when To Use MySQL Well After that you went through a ... +ROLLBACK; +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +3 where will Optimizing MySQL what In this tutorial we will show ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request MySQL' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('tutorial' WITH QUERY EXPANSION); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +3 where will Optimizing MySQL what In this tutorial we will show ... +2 when To Use MySQL Well After that you went through a ... +START TRANSACTION; +INSERT INTO t1 (a,b) VALUES (NULL,NULL); +UPDATE t1 SET a = 'Trial version' , b = 'query performace 1255 minute on 2.1Hz Memory 2GB...' +WHERE MATCH (a,b) AGAINST ('+request +MySQL' IN BOOLEAN MODE); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request'); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('query performace' IN BOOLEAN MODE); +id a b +UPDATE t1 SET a = 'when To Use MySQL Well' , b = 'for free faq xyz.com ...' +WHERE MATCH (a,b) AGAINST ('+query +performace' IN BOOLEAN MODE); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('performace'); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+mail +MySQL' IN BOOLEAN MODE); +id a b +ROLLBACK; +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('+MySQL' IN BOOLEAN MODE); +SELECT * FROM t1; +id a b +INSERT INTO t1 (a,b) VALUES +('Trial version','query performace 1255 minute on 2.1Hz Memory 2GB...') , +('when To Use MySQL Well','for free faq mail@xyz.com ...'); +SELECT * FROM t1; +id a b +6 Trial version query performace 1255 minute on 2.1Hz Memory 2GB... +7 when To Use MySQL Well for free faq mail@xyz.com ... +DROP TABLE t1; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) ENGINE = InnoDB; +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','what In this tutorial we will show ...'); +INSERT INTO t1 (a,b) VALUES +('MySQL Tutorial','request docteam for oraclehelp.'); +START TRANSACTION; +INSERT INTO t1 (a,b) VALUES (NULL,NULL); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+request +MySQL' IN BOOLEAN MODE); +id a b +4 MySQL Tutorial request docteam for oraclehelp. +UPDATE t1 SET a = 'Trial version' , b = 'query performace 1255 minute on 2.1Hz Memory 2GB...' WHERE MATCH (a,b) AGAINST ('+request +MySQL' IN BOOLEAN MODE); +SELECT * from t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Trial version query performace 1255 minute on 2.1Hz Memory 2GB... +5 NULL NULL +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request'); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('query performace' IN BOOLEAN MODE); +id a b +UPDATE t1 SET a = 'when To Use MySQL Well' , b = 'for free faq mail xyz.com ...' WHERE MATCH (a,b) AGAINST ('+query +performace' IN BOOLEAN MODE); +UPDATE t1 SET a = 'when To Use MySQL Well' , b = 'for free faq mail xyz.com ...' WHERE b like '%query performace%'; +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('performace'); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+mail +MySQL' IN BOOLEAN MODE); +id a b +SELECT * from t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 when To Use MySQL Well for free faq mail xyz.com ... +5 NULL NULL +COMMIT; +SELECT * from t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 when To Use MySQL Well for free faq mail xyz.com ... +5 NULL NULL +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('+MySQL' IN BOOLEAN MODE); +SELECT * FROM t1; +id a b +5 NULL NULL +INSERT INTO t1 (a,b) VALUES +('Trial version','query performace 1255 minute on 2.1Hz Memory 2GB...') , +('when To Use MySQL Well','for free faq mail@xyz.com ...'); +SELECT * FROM t1; +id a b +5 NULL NULL +6 Trial version query performace 1255 minute on 2.1Hz Memory 2GB... +7 when To Use MySQL Well for free faq mail@xyz.com ... +DROP TABLE t1; +SET NAMES UTF8; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) CHARACTER SET = UTF8,ENGINE = InnoDB; +connect con1,localhost,root,,; +SET NAMES UTF8; +INSERT INTO t1 (a,b) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','what In this tutorial we will show ...'), +('Я могу еÑÑ‚ÑŒ Ñтекло', 'оно мне Mне вредит'), +('ΜποÏῶ νὰ φάω σπασμÎνα' ,'γυαλιὰ χωÏὶς νὰ πάθω τίποτα'), +('Sævör grét', 'áðan þvà úlpan var ónýt'); +connect con2,localhost,root,,; +SET NAMES UTF8; +CREATE FULLTEXT INDEX idx on t1 (a,b); +connection con1; +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +3 where will Optimizing MySQL what In this tutorial we will show ... +INSERT INTO t1 (a,b) VALUES +('adding record using session 1','for verifying multiple concurrent transactions'), +('Мога да Ñм Ñтъкло', 'то Mне ми вреди'); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+γυαλιὰ +χωÏὶ*' IN BOOLEAN MODE); +id a b +5 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +START TRANSACTION; +INSERT INTO t1 (a,b) VALUES +('MySQL Tutorial','request docteam for oraclehelp.'), +('PÅ™ÃliÅ¡ žluÅ¥ouÄký kůň', 'úpÄ›l Äábelské kódy'); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request Äábelské' IN BOOLEAN MODE); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('tutorial' WITH QUERY EXPANSION) ORDER BY 1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +id a b +6 Sævör grét áðan þvà úlpan var ónýt +connection con2; +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+record +multiple' IN BOOLEAN MODE); +id a b +7 adding record using session 1 for verifying multiple concurrent transactions +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('tutor* Sævö*' IN BOOLEAN MODE) ORDER BY 1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +3 where will Optimizing MySQL what In this tutorial we will show ... +6 Sævör grét áðan þvà úlpan var ónýt +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('usin* multipl*' IN BOOLEAN MODE); +id a b +7 adding record using session 1 for verifying multiple concurrent transactions +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"request docteam"@08' IN BOOLEAN MODE); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request' IN NATURAL LANGUAGE MODE); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request MySQL' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('-request +MySQL' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+MySQL -(Tutorial Optimizing)' IN BOOLEAN MODE); +id a b +2 when To Use MySQL Well After that you went through a ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"stands Database"@11' IN BOOLEAN MODE) ORDER BY 1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('tutorial' WITH QUERY EXPANSION) ORDER BY 1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +connection con1; +COMMIT; +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+request +MySQL' IN BOOLEAN MODE); +id a b +9 MySQL Tutorial request docteam for oraclehelp. +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('PÅ™ÃliÅ¡ žluÅ¥ouÄký' IN BOOLEAN MODE); +id a b +10 PÅ™ÃliÅ¡ žluÅ¥ouÄký kůň úpÄ›l Äábelské kódy +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('PÅ™ÃliÅ¡'); +id a b +10 PÅ™ÃliÅ¡ žluÅ¥ouÄký kůň úpÄ›l Äábelské kódy +INSERT INTO t1 (a,b) VALUES (NULL,NULL); +SELECT * FROM t1 WHERE a IS NULL AND b IS NULL; +id a b +11 NULL NULL +connection con2; +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('usin* multipl*' IN BOOLEAN MODE); +id a b +7 adding record using session 1 for verifying multiple concurrent transactions +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+request +MySQL' IN BOOLEAN MODE); +id a b +9 MySQL Tutorial request docteam for oraclehelp. +SELECT * FROM t1 WHERE a IS NULL AND b IS NULL; +id a b +11 NULL NULL +ALTER TABLE t1 DROP INDEX idx; +CREATE FULLTEXT INDEX idx on t1 (a,b); +START TRANSACTION; +UPDATE t1 SET a = 'Trial version PÅ™ÃliÅ¡ žluÅ¥ouÄký' , b = 'query performace 1255 minute on 2.1Hz Memory 2GB...' +WHERE MATCH (a,b) AGAINST ('+request +MySQL' IN BOOLEAN MODE); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request'); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+query +performace' IN BOOLEAN MODE); +id a b +UPDATE t1 SET a = UPPER(a) WHERE MATCH (a,b) AGAINST ('+PÅ™ÃliÅ¡ +žluÅ¥ouÄký' IN BOOLEAN MODE); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+PÅ™ÃliÅ¡ +žluÅ¥ouÄký' IN BOOLEAN MODE); +id a b +UPDATE t1 SET a = UPPER(a) WHERE a LIKE '%version PÅ™ÃliÅ¡%'; +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+query +performace' IN BOOLEAN MODE); +id a b +SELECT * FROM t1 WHERE b LIKE '%query performace%'; +id a b +9 TRIAL VERSION PŘÃLIŠŽLUŤOUÄŒKà query performace 1255 minute on 2.1Hz Memory 2GB... +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('request'); +id a b +connection con1; +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('query performace' IN BOOLEAN MODE); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('performace'); +id a b +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+mail +MySQL' IN BOOLEAN MODE); +id a b +connection con2; +COMMIT; +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+query +performace' IN BOOLEAN MODE); +id a b +9 TRIAL VERSION PŘÃLIŠŽLUŤOUÄŒKà query performace 1255 minute on 2.1Hz Memory 2GB... +connection con1; +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('+query +performace' IN BOOLEAN MODE); +id a b +9 TRIAL VERSION PŘÃLIŠŽLUŤOUÄŒKà query performace 1255 minute on 2.1Hz Memory 2GB... +UPDATE t1 SET a = 'when To Use MySQL Well' , b = 'for free faq xyz.com ...' +WHERE MATCH (a,b) AGAINST ('+πάθω +τίποτα' IN BOOLEAN MODE); +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('well free') ORDER BY 1; +id a b +2 when To Use MySQL Well After that you went through a ... +5 when To Use MySQL Well for free faq xyz.com ... +disconnect con1; +disconnect con2; +connection default; +DROP TABLE t1; +SET NAMES UTF8; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) CHARACTER SET = UTF8,ENGINE = InnoDB; +connect con1,localhost,root,,; +SET NAMES UTF8; +INSERT INTO t1 (a,b) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','what In this tutorial we will show ...'), +('Я могу еÑÑ‚ÑŒ Ñтекло', 'оно мне Mне вредит'), +('ΜποÏῶ νὰ φάω σπασμÎνα' ,'γυαλιὰ χωÏὶς νὰ πάθω τίποτα'), +('Sævör grét', 'áðan þvà úlpan var ónýt'); +connect con2,localhost,root,,; +SET NAMES UTF8; +select @@session.tx_isolation; +@@session.tx_isolation +REPEATABLE-READ +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES +('adding record using session 1','for verifying multiple concurrent transactions'), +('Мога да Ñм Ñтъкло', 'то Mне ми вреди'); +connection con1; +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +6 Sævör grét áðan þvà úlpan var ónýt +7 adding record using session 1 for verifying multiple concurrent transactions +8 Мога да Ñм Ñтъкло то Mне ми вреди +START TRANSACTION; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Мога +Mне' IN BOOLEAN MODE); +id a b +8 Мога да Ñм Ñтъкло то Mне ми вреди +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('+Мога +Mне' IN BOOLEAN MODE); +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +7 adding record using session 1 for verifying multiple concurrent transactions +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +id a b +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +7 adding record using session 1 for verifying multiple concurrent transactions +connection con2; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +8 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +id a b +6 Sævör grét áðan þvà úlpan var ónýt +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +6 Sævör grét áðan þvà úlpan var ónýt +7 adding record using session 1 for verifying multiple concurrent transactions +8 Мога да Ñм Ñтъкло то Mне ми вреди +connection con1; +COMMIT; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +id a b +connection con2; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +id a b +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +7 adding record using session 1 for verifying multiple concurrent transactions +disconnect con1; +disconnect con2; +connection default; +DROP TABLE t1; +SET NAMES UTF8; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) CHARACTER SET = UTF8,ENGINE = InnoDB; +connect con1,localhost,root,,; +SET NAMES UTF8; +INSERT INTO t1 (a,b) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','what In this tutorial we will show ...'), +('Я могу еÑÑ‚ÑŒ Ñтекло', 'оно мне Mне вредит'); +connect con2,localhost,root,,; +SET NAMES UTF8; +select @@session.tx_isolation; +@@session.tx_isolation +REPEATABLE-READ +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES +('adding record using session 1','for verifying multiple concurrent transactions'), +('Мога да Ñм Ñтъкло', 'то Mне ми вреди'); +connection con1; +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 adding record using session 1 for verifying multiple concurrent transactions +6 Мога да Ñм Ñтъкло то Mне ми вреди +START TRANSACTION; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Мога +Mне' IN BOOLEAN MODE); +id a b +6 Мога да Ñм Ñтъкло то Mне ми вреди +UPDATE t1 SET a = 'ΜποÏῶ νὰ φάω σπασμÎνα' , b = 'γυαλιὰ χωÏὶς νὰ πάθω τίποτα' WHERE MATCH (a,b) AGAINST ('+могу +Mне' IN BOOLEAN MODE); +INSERT INTO t1(a,b) VALUES ('Sævör grét', 'áðan þvà úlpan var ónýt'); +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +5 adding record using session 1 for verifying multiple concurrent transactions +6 Мога да Ñм Ñтъкло то Mне ми вреди +7 Sævör grét áðan þvà úlpan var ónýt +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +id a b +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +5 adding record using session 1 for verifying multiple concurrent transactions +6 Мога да Ñм Ñтъкло то Mне ми вреди +7 Sævör grét áðan þvà úlpan var ónýt +connection con2; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +id a b +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +5 adding record using session 1 for verifying multiple concurrent transactions +6 Мога да Ñм Ñтъкло то Mне ми вреди +7 Sævör grét áðan þvà úlpan var ónýt +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 adding record using session 1 for verifying multiple concurrent transactions +6 Мога да Ñм Ñтъкло то Mне ми вреди +connection con1; +COMMIT; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +id a b +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +id a b +7 Sævör grét áðan þvà úlpan var ónýt +connection con2; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +id a b +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +id a b +7 Sævör grét áðan þvà úlpan var ónýt +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +5 adding record using session 1 for verifying multiple concurrent transactions +6 Мога да Ñм Ñтъкло то Mне ми вреди +7 Sævör grét áðan þvà úlpan var ónýt +disconnect con1; +disconnect con2; +connection default; +DROP TABLE t1; +SET NAMES UTF8; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) CHARACTER SET = UTF8,ENGINE = InnoDB; +connect con1,localhost,root,,; +SET NAMES UTF8; +INSERT INTO t1 (a,b) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','what In this tutorial we will show ...'), +('Я могу еÑÑ‚ÑŒ Ñтекло', 'оно мне Mне вредит'), +('ΜποÏῶ νὰ φάω σπασμÎνα' ,'γυαλιὰ χωÏὶς νὰ πάθω τίποτα'), +('Sævör grét', 'áðan þvà úlpan var ónýt'); +connect con2,localhost,root,,; +SET NAMES UTF8; +select @@session.tx_isolation; +@@session.tx_isolation +REPEATABLE-READ +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES +('adding record using session 1','for verifying multiple concurrent transactions'), +('Мога да Ñм Ñтъкло', 'то Mне ми вреди'); +connection con1; +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +6 Sævör grét áðan þvà úlpan var ónýt +7 adding record using session 1 for verifying multiple concurrent transactions +8 Мога да Ñм Ñтъкло то Mне ми вреди +START TRANSACTION; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Мога +Mне' IN BOOLEAN MODE); +id a b +8 Мога да Ñм Ñтъкло то Mне ми вреди +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('+Мога +Mне' IN BOOLEAN MODE); +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +7 adding record using session 1 for verifying multiple concurrent transactions +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +id a b +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +id a b +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +7 adding record using session 1 for verifying multiple concurrent transactions +connection con2; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +8 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +id a b +8 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +id a b +6 Sævör grét áðan þvà úlpan var ónýt +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +6 Sævör grét áðan þvà úlpan var ónýt +7 adding record using session 1 for verifying multiple concurrent transactions +8 Мога да Ñм Ñтъкло то Mне ми вреди +connection con1; +ROLLBACK; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +8 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +id a b +8 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +id a b +6 Sævör grét áðan þvà úlpan var ónýt +connection con2; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +8 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +id a b +8 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +id a b +6 Sævör grét áðan þvà úlpan var ónýt +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +6 Sævör grét áðan þvà úlpan var ónýt +7 adding record using session 1 for verifying multiple concurrent transactions +8 Мога да Ñм Ñтъкло то Mне ми вреди +disconnect con1; +disconnect con2; +connection default; +DROP TABLE t1; +SET NAMES UTF8; +CREATE TABLE t1 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +a VARCHAR(200), +b TEXT +) CHARACTER SET = UTF8,ENGINE = InnoDB; +connect con1,localhost,root,,; +SET NAMES UTF8; +INSERT INTO t1 (a,b) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','what In this tutorial we will show ...'), +('Я могу еÑÑ‚ÑŒ Ñтекло', 'оно мне Mне вредит'); +connect con2,localhost,root,,; +SET NAMES UTF8; +select @@session.tx_isolation; +@@session.tx_isolation +REPEATABLE-READ +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES +('adding record using session 1','for verifying multiple concurrent transactions'), +('Мога да Ñм Ñтъкло', 'то Mне ми вреди'); +connection con1; +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 adding record using session 1 for verifying multiple concurrent transactions +6 Мога да Ñм Ñтъкло то Mне ми вреди +START TRANSACTION; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+могу +Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +UPDATE t1 SET a = 'ΜποÏῶ νὰ φάω σπασμÎνα' , b = 'γυαλιὰ χωÏὶς νὰ πάθω τίποτα' WHERE MATCH (a,b) AGAINST ('+могу +Mне' IN BOOLEAN MODE); +INSERT INTO t1(a,b) VALUES ('Sævör grét', 'áðan þvà úlpan var ónýt'); +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +5 adding record using session 1 for verifying multiple concurrent transactions +6 Мога да Ñм Ñтъкло то Mне ми вреди +7 Sævör grét áðan þvà úlpan var ónýt +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +id a b +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +5 adding record using session 1 for verifying multiple concurrent transactions +6 Мога да Ñм Ñтъкло то Mне ми вреди +7 Sævör grét áðan þvà úlpan var ónýt +connection con2; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +id a b +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +id a b +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 ΜποÏῶ νὰ φάω σπασμÎνα γυαλιὰ χωÏὶς νὰ πάθω τίποτα +5 adding record using session 1 for verifying multiple concurrent transactions +6 Мога да Ñм Ñтъкло то Mне ми вреди +7 Sævör grét áðan þvà úlpan var ónýt +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +id a b +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 adding record using session 1 for verifying multiple concurrent transactions +6 Мога да Ñм Ñтъкло то Mне ми вреди +connection con1; +ROLLBACK; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +id a b +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +id a b +connection con2; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +id a b +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +id a b +6 Мога да Ñм Ñтъкло то Mне ми вреди +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); +id a b +SELECT * FROM t1; +id a b +1 MySQL from Tutorial DBMS stands for DataBase ... +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL what In this tutorial we will show ... +4 Я могу еÑÑ‚ÑŒ Ñтекло оно мне Mне вредит +5 adding record using session 1 for verifying multiple concurrent transactions +6 Мога да Ñм Ñтъкло то Mне ми вреди +disconnect con1; +disconnect con2; +connection default; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/r/misc_debug.result b/mysql-test/suite/innodb_fts/r/misc_debug.result new file mode 100644 index 00000000..cdfc4ff4 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/misc_debug.result @@ -0,0 +1,76 @@ +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +) ENGINE=InnoDB; +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET SESSION debug_dbug="+d,ib_dict_create_index_tree_fail"; +CREATE FULLTEXT INDEX idx ON articles(body); +ERROR HY000: Out of memory. +SET SESSION debug_dbug=@saved_debug_dbug; +ALTER TABLE articles STATS_PERSISTENT=DEFAULT; +DROP TABLE articles; +CREATE TABLE t (a INT, b TEXT) engine=innodb; +SET debug_dbug='+d,alter_table_rollback_new_index'; +ALTER TABLE t ADD FULLTEXT INDEX (b(64)); +ERROR HY000: Unknown error +SET SESSION debug_dbug=@saved_debug_dbug; +DROP TABLE t; +CREATE TABLE t1 (pk INT, a VARCHAR(8), PRIMARY KEY(pk), +FULLTEXT KEY(a)) ENGINE=InnoDB; +CREATE TABLE t2 (b INT, FOREIGN KEY(b) REFERENCES t1(pk)) ENGINE=InnoDB; +DROP TABLE/*foo*/ t1; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails +SET DEBUG_DBUG="+d,fts_instrument_sync"; +INSERT INTO t1 VALUES(1, "mariadb"); +ALTER TABLE t1 FORCE; +DROP TABLE t2, t1; +SET SESSION debug_dbug=@saved_debug_dbug; +# +# MDEV-25200 Index count mismatch due to aborted FULLTEXT INDEX +# +CREATE TABLE t1(a INT, b TEXT, c TEXT, FULLTEXT INDEX(b)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1, "test", "test_1"); +connect con1,localhost,root,,test; +SET DEBUG_DBUG="+d,innodb_OOM_inplace_alter"; +SET DEBUG_SYNC='innodb_commit_inplace_alter_table_enter SIGNAL s2 WAIT_FOR g2'; +ALTER TABLE t1 ADD FULLTEXT(c); +connection default; +SET DEBUG_SYNC='now WAIT_FOR s2'; +START TRANSACTION; +SELECT * FROM t1; +a b c +1 test test_1 +SET DEBUG_SYNC='now SIGNAL g2'; +connection con1; +ERROR HY000: Out of memory. +disconnect con1; +connection default; +SET DEBUG_SYNC=RESET; +ALTER TABLE t1 ADD bl INT AS (LENGTH(b)) VIRTUAL; +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check status OK +DROP TABLE t1; +# +# MDEV-25663 Double free of transaction during TRUNCATE +# +call mtr.add_suppression("InnoDB: \\(Too many concurrent transactions\\)"); +call mtr.add_suppression("InnoDB: Cannot save table statistics for table `test`\\.`t1`: Too many concurrent transactions"); +SET @saved_debug_dbug= @@debug_dbug; +CREATE TABLE t1 (b CHAR(12), FULLTEXT KEY(b)) engine=InnoDB; +SET debug_dbug='+d,ib_create_table_fail_too_many_trx'; +TRUNCATE t1; +SET debug_dbug=@saved_debug_dbug; +DROP TABLE t1; +# End of 10.3 tests +CREATE TABLE t1(f1 INT NOT NULL, f2 CHAR(100))ENGINE=InnoDB; +SET DEBUG_DBUG="+d,stats_lock_fail"; +ALTER TABLE t1 ADD FULLTEXT(f2); +ERROR HY000: Lock wait timeout exceeded; try restarting transaction +SET debug_dbug=@saved_debug_dbug; +ALTER TABLE t1 DISCARD TABLESPACE; +ALTER TABLE t1 ADD FULLTEXT(f2); +ERROR HY000: Tablespace has been discarded for table `t1` +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/r/misc_debug2.result b/mysql-test/suite/innodb_fts/r/misc_debug2.result new file mode 100644 index 00000000..9601e8fc --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/misc_debug2.result @@ -0,0 +1,23 @@ +call mtr.add_suppression("InnoDB: Table '.*' tablespace is set as discarded."); +call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded."); +CREATE TABLE mdev21563(f1 VARCHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB; +set debug_dbug="+d,fts_instrument_sync_request"; +INSERT INTO mdev21563 VALUES('This is a test'); +ALTER TABLE mdev21563 DISCARD TABLESPACE; +# restart +DROP TABLE mdev21563; +# +# MDEV-29342 Assertion failure in file que0que.cc line 728 +# +CREATE TABLE t1(f1 CHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES('mysql'), ('innodb'); +SET @save_dbug=@@debug_dbug; +set debug_dbug="+d,fts_instrument_sync_request"; +INSERT INTO t1 VALUES('test'); +set debug_dbug=@save_dbug; +INSERT INTO t1 VALUES('This is a fts issue'); +# restart +set debug_dbug="+d,fts_instrument_sync_request"; +UPDATE t1 SET f1="mariadb"; +set debug_dbug=@save_dbug; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/r/stopword,vers.rdiff b/mysql-test/suite/innodb_fts/r/stopword,vers.rdiff new file mode 100644 index 00000000..7405c47c --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/stopword,vers.rdiff @@ -0,0 +1,192 @@ +--- stopword.result ++++ stopword,vers.reject +@@ -46,7 +46,7 @@ + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) +-) ENGINE=InnoDB; ++) WITH SYSTEM VERSIONING ENGINE=InnoDB; + INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), +@@ -60,7 +60,7 @@ + set global innodb_ft_server_stopword_table = "not_defined"; + ERROR 42000: Variable 'innodb_ft_server_stopword_table' can't be set to the value of 'not_defined' + set global innodb_ft_server_stopword_table = NULL; +-create table user_stopword(value varchar(30)) engine = innodb; ++create table user_stopword(value varchar(30)) WITH SYSTEM VERSIONING engine = innodb; + set global innodb_ft_server_stopword_table = "test/user_stopword"; + drop index title on articles; + create fulltext index idx on articles(title, body); +@@ -73,7 +73,7 @@ + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) +-) ENGINE=InnoDB; ++) WITH SYSTEM VERSIONING ENGINE=InnoDB; + INSERT INTO articles_2 (title, body) + VALUES ('test for stopwords','this is it...'); + SELECT * FROM articles_2 WHERE MATCH (title,body) +@@ -88,13 +88,13 @@ + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) +-) ENGINE=InnoDB; ++) WITH SYSTEM VERSIONING ENGINE=InnoDB; + INSERT INTO articles_3 (title, body) + VALUES ('test for stopwords','this is it...'); + SELECT * FROM articles_3 WHERE MATCH (title,body) + AGAINST ('this' IN NATURAL LANGUAGE MODE); + id title body +-create table user_stopword_session(value varchar(30)) engine = innodb; ++create table user_stopword_session(value varchar(30)) WITH SYSTEM VERSIONING engine = innodb; + insert into user_stopword values("this"); + delete from user_stopword; + insert into user_stopword_session values("session"); +@@ -104,7 +104,7 @@ + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) +-) ENGINE=InnoDB; ++) WITH SYSTEM VERSIONING ENGINE=InnoDB; + INSERT INTO articles_4 (title, body) + VALUES ('test for session stopwords','this should also be excluded...'); + SELECT * FROM articles_4 WHERE MATCH (title,body) +@@ -120,7 +120,7 @@ + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) +-) ENGINE=InnoDB; ++) WITH SYSTEM VERSIONING ENGINE=InnoDB; + INSERT INTO articles_5 (title, body) + VALUES ('test for session stopwords','this should also be excluded...'); + SELECT * FROM articles_5 WHERE MATCH (title,body) +@@ -142,7 +142,7 @@ + title VARCHAR(200), + body TEXT, + FULLTEXT `idx` (title,body) +-) ENGINE=InnoDB; ++) WITH SYSTEM VERSIONING ENGINE=InnoDB; + SHOW CREATE TABLE articles; + Table Create Table + articles CREATE TABLE `articles` ( +@@ -151,7 +151,7 @@ + `body` text DEFAULT NULL, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx` (`title`,`body`) +-) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ++) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING + INSERT INTO articles (title,body) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), +@@ -248,7 +248,7 @@ + `title` varchar(200) DEFAULT NULL, + `body` text DEFAULT NULL, + PRIMARY KEY (`id`) +-) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ++) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING + ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); + ANALYZE TABLE articles; + Table Op Msg_type Msg_text +@@ -320,7 +320,7 @@ + title VARCHAR(200), + body TEXT, + FULLTEXT `idx` (title,body) +-) ENGINE=InnoDB; ++) WITH SYSTEM VERSIONING ENGINE=InnoDB; + INSERT INTO articles (title,body) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), +@@ -332,9 +332,9 @@ + id title body + SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); + id title body +-create table user_stopword(value varchar(30)) engine = innodb; ++create table user_stopword(value varchar(30)) WITH SYSTEM VERSIONING engine = innodb; + set session innodb_ft_user_stopword_table = "test/user_stopword"; +-create table server_stopword(value varchar(30)) engine = innodb; ++create table server_stopword(value varchar(30)) WITH SYSTEM VERSIONING engine = innodb; + set global innodb_ft_server_stopword_table = "test/server_stopword"; + insert into user_stopword values("when"),("where"); + delete from user_stopword; +@@ -419,7 +419,7 @@ + title VARCHAR(200), + body TEXT, + FULLTEXT `idx` (title,body) +-) ENGINE=InnoDB; ++) WITH SYSTEM VERSIONING ENGINE=InnoDB; + SHOW CREATE TABLE articles; + Table Create Table + articles CREATE TABLE `articles` ( +@@ -428,7 +428,7 @@ + `body` text DEFAULT NULL, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx` (`title`,`body`) +-) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ++) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING + INSERT INTO articles (title,body) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), +@@ -440,7 +440,7 @@ + id title body + SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); + id title body +-create table user_stopword(value varchar(30)) engine = innodb; ++create table user_stopword(value varchar(30)) WITH SYSTEM VERSIONING engine = innodb; + set session innodb_ft_user_stopword_table = "test/user_stopword"; + insert into user_stopword values("mysqld"),("DBMS"); + SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +@@ -466,7 +466,7 @@ + SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysqld'); + id title body + set session innodb_ft_user_stopword_table = default; +-create table server_stopword(value varchar(30)) engine = innodb; ++create table server_stopword(value varchar(30)) WITH SYSTEM VERSIONING engine = innodb; + set global innodb_ft_server_stopword_table = "test/server_stopword"; + insert into server_stopword values("root"),("properly"); + ALTER TABLE articles DROP INDEX idx; +@@ -530,7 +530,7 @@ + title VARCHAR(200), + body TEXT, + FULLTEXT `idx` (title,body) +-) ENGINE=InnoDB; ++) WITH SYSTEM VERSIONING ENGINE=InnoDB; + SHOW CREATE TABLE articles; + Table Create Table + articles CREATE TABLE `articles` ( +@@ -539,7 +539,7 @@ + `body` text DEFAULT NULL, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx` (`title`,`body`) +-) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ++) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING + INSERT INTO articles (title,body) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), +@@ -656,7 +656,7 @@ + "In connection 1" + connection con1; + SET SESSION innodb_ft_enable_stopword = 1; +-create table user_stopword(value varchar(30)) engine = innodb; ++create table user_stopword(value varchar(30)) WITH SYSTEM VERSIONING engine = innodb; + set session innodb_ft_user_stopword_table = "test/user_stopword"; + insert into user_stopword values("this"),("will"),("the"); + ALTER TABLE articles DROP INDEX idx; +@@ -674,7 +674,7 @@ + select @@innodb_ft_user_stopword_table; + @@innodb_ft_user_stopword_table + NULL +-create table user_stopword_1(value varchar(30)) engine = innodb; ++create table user_stopword_1(value varchar(30)) WITH SYSTEM VERSIONING engine = innodb; + set session innodb_ft_user_stopword_table = "test/user_stopword_1"; + insert into user_stopword_1 values("when"); + SET SESSION innodb_ft_enable_stopword = 1; +@@ -702,7 +702,7 @@ + select @@innodb_ft_server_stopword_table; + @@innodb_ft_server_stopword_table + NULL +-create table server_stopword(value varchar(30)) engine = innodb; ++create table server_stopword(value varchar(30)) WITH SYSTEM VERSIONING engine = innodb; + SET GLOBAL innodb_ft_server_stopword_table = "test/server_stopword"; + select @@innodb_ft_server_stopword_table; + @@innodb_ft_server_stopword_table diff --git a/mysql-test/suite/innodb_fts/r/stopword.result b/mysql-test/suite/innodb_fts/r/stopword.result new file mode 100644 index 00000000..aa6f51aa --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/stopword.result @@ -0,0 +1,754 @@ +SET @innodb_ft_server_stopword_table_orig=@@innodb_ft_server_stopword_table; +SET @innodb_ft_enable_stopword_orig=@@innodb_ft_enable_stopword; +SET @innodb_ft_user_stopword_table_orig=@@innodb_ft_user_stopword_table; +call mtr.add_suppression("\\[ERROR\\] InnoDB: user stopword table not_defined does not exist."); +call mtr.add_suppression("\\[ERROR\\] InnoDB: user stopword table test/user_stopword_session does not exist."); +select * from information_schema.innodb_ft_default_stopword; +value +a +about +an +are +as +at +be +by +com +de +en +for +from +how +i +in +is +it +la +of +on +or +that +the +this +to +was +what +when +where +who +will +with +und +the +www +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +) ENGINE=InnoDB; +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('the' IN NATURAL LANGUAGE MODE); +id title body +set global innodb_ft_server_stopword_table = "not_defined"; +ERROR 42000: Variable 'innodb_ft_server_stopword_table' can't be set to the value of 'not_defined' +set global innodb_ft_server_stopword_table = NULL; +create table user_stopword(value varchar(30)) engine = innodb; +set global innodb_ft_server_stopword_table = "test/user_stopword"; +drop index title on articles; +create fulltext index idx on articles(title, body); +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('the' IN NATURAL LANGUAGE MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +CREATE TABLE articles_2 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +) ENGINE=InnoDB; +INSERT INTO articles_2 (title, body) +VALUES ('test for stopwords','this is it...'); +SELECT * FROM articles_2 WHERE MATCH (title,body) +AGAINST ('this' IN NATURAL LANGUAGE MODE); +id title body +1 test for stopwords this is it... +insert into user_stopword values("the"); +delete from user_stopword; +insert into user_stopword values("this"); +CREATE TABLE articles_3 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +) ENGINE=InnoDB; +INSERT INTO articles_3 (title, body) +VALUES ('test for stopwords','this is it...'); +SELECT * FROM articles_3 WHERE MATCH (title,body) +AGAINST ('this' IN NATURAL LANGUAGE MODE); +id title body +create table user_stopword_session(value varchar(30)) engine = innodb; +insert into user_stopword values("this"); +delete from user_stopword; +insert into user_stopword_session values("session"); +set session innodb_ft_user_stopword_table="test/user_stopword_session"; +CREATE TABLE articles_4 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +) ENGINE=InnoDB; +INSERT INTO articles_4 (title, body) +VALUES ('test for session stopwords','this should also be excluded...'); +SELECT * FROM articles_4 WHERE MATCH (title,body) +AGAINST ('session' IN NATURAL LANGUAGE MODE); +id title body +SELECT * FROM articles_4 WHERE MATCH (title,body) +AGAINST ('this' IN NATURAL LANGUAGE MODE); +id title body +1 test for session stopwords this should also be excluded... +connect con1,localhost,root,,; +CREATE TABLE articles_5 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +) ENGINE=InnoDB; +INSERT INTO articles_5 (title, body) +VALUES ('test for session stopwords','this should also be excluded...'); +SELECT * FROM articles_5 WHERE MATCH (title,body) +AGAINST ('session' IN NATURAL LANGUAGE MODE); +id title body +1 test for session stopwords this should also be excluded... +connection default; +drop table articles; +drop table articles_2; +drop table articles_3; +drop table articles_4; +drop table articles_5; +drop table user_stopword; +drop table user_stopword_session; +SET GLOBAL innodb_ft_enable_stopword=@innodb_ft_enable_stopword_orig; +SET GLOBAL innodb_ft_server_stopword_table=default; +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT `idx` (title,body) +) ENGINE=InnoDB; +SHOW CREATE TABLE articles; +Table Create Table +articles CREATE TABLE `articles` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `title` varchar(200) DEFAULT NULL, + `body` text DEFAULT NULL, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx` (`title`,`body`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO articles (title,body) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','In what tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("where will"); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("when"); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("what" WITH QUERY EXPANSION); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("whe*" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+what +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+from" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+where +(show what)" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@6' IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@9' IN BOOLEAN MODE); +id title body +INSERT INTO articles(title,body) values ('the record will' , 'not index the , will words'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"the will"@11' IN BOOLEAN MODE); +id title body +UPDATE articles SET title = "update the record" , body = 'to see will is indexed or not' +WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +UPDATE articles SET title = "update the record" , body = 'to see will is indexed or not' +WHERE id = 7; +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +id title body +DELETE FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE id = 7; +id title body +7 update the record to see will is indexed or not +DELETE FROM articles WHERE id = 7; +SET global innodb_ft_server_stopword_table = NULL; +SET SESSION innodb_ft_enable_stopword = 0; +select @@innodb_ft_enable_stopword; +@@innodb_ft_enable_stopword +0 +SET global innodb_ft_user_stopword_table = NULL; +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("where will"); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("when"); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("what" WITH QUERY EXPANSION); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("whe*" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+what +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+from" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+where +(show what)" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@6' IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@9' IN BOOLEAN MODE); +id title body +INSERT INTO articles(title,body) values ('the record will' , 'not index the , will words'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"the will"@11' IN BOOLEAN MODE); +id title body +UPDATE articles SET title = "update the record" , body = 'to see will is indexed or not' +WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +UPDATE articles SET title = "update the record" , body = 'to see will is indexed or not' +WHERE id = 8; +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +id title body +SELECT * FROM articles WHERE id = 8; +id title body +8 update the record to see will is indexed or not +DELETE FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE id = 8; +id title body +8 update the record to see will is indexed or not +DELETE FROM articles WHERE id = 8; +ALTER TABLE articles DROP INDEX idx; +SHOW CREATE TABLE articles; +Table Create Table +articles CREATE TABLE `articles` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `title` varchar(200) DEFAULT NULL, + `body` text DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +ANALYZE TABLE articles; +Table Op Msg_type Msg_text +test.articles analyze status Engine-independent statistics collected +test.articles analyze Warning Engine-independent statistics are not collected for column 'body' +test.articles analyze status OK +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("where will"); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("when"); +id title body +2 when To Use MySQL Well After that you went through a ... +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("what" WITH QUERY EXPANSION); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +1 MySQL from Tutorial DBMS stands for DataBase ... +6 MySQL Security When configured properly, MySQL ... +2 when To Use MySQL Well After that you went through a ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("whe*" IN BOOLEAN MODE); +id title body +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL In what tutorial we will show ... +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+what +will" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+from" IN BOOLEAN MODE); +id title body +1 MySQL from Tutorial DBMS stands for DataBase ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+where +(show what)" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@6' IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@9' IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +INSERT INTO articles(title,body) values ('the record will' , 'not index the , will words'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +id title body +9 the record will not index the , will words +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"the will"@11' IN BOOLEAN MODE); +id title body +9 the record will not index the , will words +UPDATE articles SET title = "update the record" , body = 'to see will is indexed or not' +WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT COUNT(*),max(id) FROM articles; +COUNT(*) max(id) +7 9 +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +id title body +9 update the record to see will is indexed or not +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +9 update the record to see will is indexed or not +DELETE FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE id = 9; +id title body +DROP TABLE articles; +SET SESSION innodb_ft_enable_stopword=@innodb_ft_enable_stopword_orig; +SET GLOBAL innodb_ft_server_stopword_table=@innodb_ft_server_stopword_table_orig; +SET GLOBAL innodb_ft_user_stopword_table=@innodb_ft_user_stopword_table_orig; +SET SESSION innodb_ft_user_stopword_table=default; +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT `idx` (title,body) +) ENGINE=InnoDB; +INSERT INTO articles (title,body) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','In what tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +id title body +create table user_stopword(value varchar(30)) engine = innodb; +set session innodb_ft_user_stopword_table = "test/user_stopword"; +create table server_stopword(value varchar(30)) engine = innodb; +set global innodb_ft_server_stopword_table = "test/server_stopword"; +insert into user_stopword values("when"),("where"); +delete from user_stopword; +insert into user_stopword values("this"),("will"),("the"); +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +id title body +insert into server_stopword values("what"),("where"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +DELETE FROM user_stopword; +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +insert into user_stopword values("this"),("will"),("the"); +ALTER TABLE articles DROP INDEX idx; +SET SESSION innodb_ft_enable_stopword = 0; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SET SESSION innodb_ft_enable_stopword = 1; +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +id title body +SET SESSION innodb_ft_enable_stopword = 1; +SET SESSION innodb_ft_user_stopword_table = default; +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +DROP TABLE articles,user_stopword,server_stopword; +SET innodb_ft_enable_stopword=@innodb_ft_enable_stopword_orig; +SET GLOBAL innodb_ft_server_stopword_table=default; +SET SESSION innodb_ft_user_stopword_table=default; +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT `idx` (title,body) +) ENGINE=InnoDB; +SHOW CREATE TABLE articles; +Table Create Table +articles CREATE TABLE `articles` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `title` varchar(200) DEFAULT NULL, + `body` text DEFAULT NULL, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx` (`title`,`body`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO articles (title,body) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','In what tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +id title body +create table user_stopword(value varchar(30)) engine = innodb; +set session innodb_ft_user_stopword_table = "test/user_stopword"; +insert into user_stopword values("mysqld"),("DBMS"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+DBMS +mysql" IN BOOLEAN MODE); +id title body +1 MySQL from Tutorial DBMS stands for DataBase ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysqld'); +id title body +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+DBMS +mysql" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysqld'); +id title body +set session innodb_ft_user_stopword_table = default; +create table server_stopword(value varchar(30)) engine = innodb; +set global innodb_ft_server_stopword_table = "test/server_stopword"; +insert into server_stopword values("root"),("properly"); +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+root +mysql" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('properly'); +id title body +set session innodb_ft_user_stopword_table = "test/user_stopword"; +set global innodb_ft_server_stopword_table = "test/server_stopword"; +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+root +mysql" IN BOOLEAN MODE); +id title body +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('properly'); +id title body +6 MySQL Security When configured properly, MySQL ... +set session innodb_ft_user_stopword_table = "test/user_stopword"; +DELETE FROM user_stopword; +set global innodb_ft_server_stopword_table = "test/server_stopword"; +DELETE FROM server_stopword; +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+root +mysql" IN BOOLEAN MODE); +id title body +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('properly'); +id title body +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+DBMS +mysql" IN BOOLEAN MODE); +id title body +1 MySQL from Tutorial DBMS stands for DataBase ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysqld'); +id title body +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +DROP TABLE articles,user_stopword,server_stopword; +SET SESSION innodb_ft_enable_stopword=@innodb_ft_enable_stopword_orig; +SET GLOBAL innodb_ft_server_stopword_table=default; +SET SESSION innodb_ft_user_stopword_table=default; +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT `idx` (title,body) +) ENGINE=InnoDB; +SHOW CREATE TABLE articles; +Table Create Table +articles CREATE TABLE `articles` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `title` varchar(200) DEFAULT NULL, + `body` text DEFAULT NULL, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx` (`title`,`body`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO articles (title,body) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...') , +('when To Use MySQL Well','After that you went through a ...'), +('where will Optimizing MySQL','In what tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +SET SESSION innodb_ft_enable_stopword = 0; +select @@innodb_ft_enable_stopword; +@@innodb_ft_enable_stopword +0 +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +"In connection 1" +connection con1; +select @@innodb_ft_enable_stopword; +@@innodb_ft_enable_stopword +1 +ANALYZE TABLE articles; +Table Op Msg_type Msg_text +test.articles analyze status Engine-independent statistics collected +test.articles analyze Warning Engine-independent statistics are not collected for column 'body' +test.articles analyze status OK +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("where will"); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("when"); +id title body +2 when To Use MySQL Well After that you went through a ... +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("what" WITH QUERY EXPANSION); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +1 MySQL from Tutorial DBMS stands for DataBase ... +6 MySQL Security When configured properly, MySQL ... +2 when To Use MySQL Well After that you went through a ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("whe*" IN BOOLEAN MODE); +id title body +2 when To Use MySQL Well After that you went through a ... +3 where will Optimizing MySQL In what tutorial we will show ... +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+what +will" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+from" IN BOOLEAN MODE); +id title body +1 MySQL from Tutorial DBMS stands for DataBase ... +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+where +(show what)" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@6' IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@9' IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SET SESSION innodb_ft_enable_stopword = 1; +select @@innodb_ft_enable_stopword; +@@innodb_ft_enable_stopword +1 +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("where will"); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("when"); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("what" WITH QUERY EXPANSION); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("whe*" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+what +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+from" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+where +(show what)" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@6' IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@9' IN BOOLEAN MODE); +id title body +"In connection default" +connection default; +select @@innodb_ft_enable_stopword; +@@innodb_ft_enable_stopword +0 +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("where will"); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("when"); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("what" WITH QUERY EXPANSION); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("whe*" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+what +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+from" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+where +(show what)" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@6' IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@9' IN BOOLEAN MODE); +id title body +INSERT INTO articles(title,body) values ('the record will' , 'not index the , will words'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"the will"@11' IN BOOLEAN MODE); +id title body +SET SESSION innodb_ft_enable_stopword = 1; +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"the will"@11' IN BOOLEAN MODE); +id title body +"In connection 1" +connection con1; +SET SESSION innodb_ft_enable_stopword = 1; +create table user_stopword(value varchar(30)) engine = innodb; +set session innodb_ft_user_stopword_table = "test/user_stopword"; +insert into user_stopword values("this"),("will"),("the"); +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +id title body +"In connection default" +connection default; +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +id title body +select @@innodb_ft_user_stopword_table; +@@innodb_ft_user_stopword_table +NULL +create table user_stopword_1(value varchar(30)) engine = innodb; +set session innodb_ft_user_stopword_table = "test/user_stopword_1"; +insert into user_stopword_1 values("when"); +SET SESSION innodb_ft_enable_stopword = 1; +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+when" IN BOOLEAN MODE); +id title body +2 when To Use MySQL Well After that you went through a ... +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('when'); +id title body +2 when To Use MySQL Well After that you went through a ... +6 MySQL Security When configured properly, MySQL ... +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+when" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('when'); +id title body +"In connection 1" +connection con1; +SET SESSION innodb_ft_enable_stopword = 1; +SET SESSION innodb_ft_user_stopword_table=default; +select @@innodb_ft_user_stopword_table; +@@innodb_ft_user_stopword_table +NULL +select @@innodb_ft_server_stopword_table; +@@innodb_ft_server_stopword_table +NULL +create table server_stopword(value varchar(30)) engine = innodb; +SET GLOBAL innodb_ft_server_stopword_table = "test/server_stopword"; +select @@innodb_ft_server_stopword_table; +@@innodb_ft_server_stopword_table +test/server_stopword +insert into server_stopword values("when"),("the"); +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+when" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('the'); +id title body +disconnect con1; +"In connection default" +connection default; +SET SESSION innodb_ft_enable_stopword = 1; +SET SESSION innodb_ft_user_stopword_table=default; +select @@innodb_ft_server_stopword_table; +@@innodb_ft_server_stopword_table +test/server_stopword +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+will +where" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('where'); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +insert into server_stopword values("where"),("will"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+will +where" IN BOOLEAN MODE); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('where'); +id title body +3 where will Optimizing MySQL In what tutorial we will show ... +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+when" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('the'); +id title body +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+will +where" IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('where'); +id title body +DROP TABLE articles,user_stopword,user_stopword_1,server_stopword; +SET GLOBAL innodb_ft_user_stopword_table=@innodb_ft_user_stopword_table_orig; +SET GLOBAL innodb_ft_server_stopword_table=@innodb_ft_server_stopword_table_orig; diff --git a/mysql-test/suite/innodb_fts/r/sync.result b/mysql-test/suite/innodb_fts/r/sync.result new file mode 100644 index 00000000..928efffd --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/sync.result @@ -0,0 +1,157 @@ +connect con1,localhost,root,,; +connection default; +# Case 1: Test select and insert(row in both disk and cache) +CREATE TABLE t1 ( +FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +FULLTEXT(title) +) ENGINE = InnoDB; +INSERT INTO t1(title) VALUES('mysql'); +INSERT INTO t1(title) VALUES('database'); +connection con1; +SET @old_dbug = @@SESSION.debug_dbug; +SET debug_dbug = '+d,fts_instrument_sync_debug'; +SET DEBUG_SYNC= 'fts_write_node SIGNAL written WAIT_FOR selected'; +INSERT INTO t1(title) VALUES('mysql database'); +connection default; +SET DEBUG_SYNC= 'now WAIT_FOR written'; +SET GLOBAL innodb_ft_aux_table="test/t1"; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +database 2 3 2 2 0 +database 2 3 2 3 6 +mysql 1 3 2 1 0 +mysql 1 3 2 3 0 +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +SET GLOBAL innodb_ft_aux_table=default; +SELECT * FROM t1 WHERE MATCH(title) AGAINST('mysql database'); +FTS_DOC_ID title +1 mysql +2 database +SET DEBUG_SYNC= 'now SIGNAL selected'; +connection con1; +SET @old_dbug = @@SESSION.debug_dbug; +SET GLOBAL innodb_ft_aux_table="test/t1"; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +database 2 3 2 2 0 +database 2 3 2 3 6 +mysql 1 3 2 1 0 +mysql 1 3 2 3 0 +SET GLOBAL innodb_ft_aux_table=default; +SELECT * FROM t1 WHERE MATCH(title) AGAINST('mysql database'); +FTS_DOC_ID title +3 mysql database +1 mysql +2 database +connection default; +DROP TABLE t1; +# Case 2: Test insert and insert(sync) +CREATE TABLE t1 ( +FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +FULLTEXT(title) +) ENGINE = InnoDB; +INSERT INTO t1(title) VALUES('mysql'); +INSERT INTO t1(title) VALUES('database'); +connection con1; +SET debug_dbug = '+d,fts_instrument_sync_debug'; +SET DEBUG_SYNC= 'fts_write_node SIGNAL written WAIT_FOR inserted'; +INSERT INTO t1(title) VALUES('mysql database'); +connection default; +SET DEBUG_SYNC= 'now WAIT_FOR written'; +INSERT INTO t1(title) VALUES('mysql database'); +SET DEBUG_SYNC= 'now SIGNAL inserted'; +connection con1; +SET debug_dbug = @old_dbug; +SET GLOBAL innodb_ft_aux_table="test/t1"; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +database 2 3 2 2 0 +database 2 3 2 3 6 +database 4 4 1 4 6 +mysql 1 4 3 1 0 +mysql 1 4 3 3 0 +mysql 1 4 3 4 0 +SET GLOBAL innodb_ft_aux_table=default; +SELECT * FROM t1 WHERE MATCH(title) AGAINST('mysql database'); +FTS_DOC_ID title +3 mysql database +4 mysql database +1 mysql +2 database +connection default; +disconnect con1; +DROP TABLE t1; +# Case 3: Test insert crash recovery +CREATE TABLE t1 ( +FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +FULLTEXT(title) +) ENGINE = InnoDB; +INSERT INTO t1(title) VALUES('database'); +SET debug_dbug = '+d,fts_instrument_sync_debug,fts_write_node_crash'; +INSERT INTO t1(title) VALUES('mysql'); +ERROR HY000: Lost connection to server during query +# restart +After restart +SELECT title FROM t1 WHERE MATCH(title) AGAINST ('mysql database'); +title +database +SET @old_dbug = @@SESSION.debug_dbug; +SET debug_dbug = '+d,fts_instrument_sync_debug'; +INSERT INTO t1(title) VALUES('mysql'); +SET debug_dbug = @old_dbug; +SELECT title FROM t1 WHERE MATCH(title) AGAINST ('mysql database'); +title +database +mysql +DROP TABLE t1; +# Case 4: Test sync commit & rollback in background +CREATE TABLE t1( +id INT AUTO_INCREMENT, +title VARCHAR(100), +FULLTEXT(title), +PRIMARY KEY(id)) ENGINE=InnoDB; +SET debug_dbug = '+d,fts_instrument_sync'; +INSERT INTO t1(title) VALUES('mysql'); +SET debug_dbug = @old_dbug; +# restart +SET @old_global_dbug = @@GLOBAL.debug_dbug; +SET @old_dbug = @@SESSION.debug_dbug; +SET GLOBAL debug_dbug='+d,fts_instrument_sync,fts_instrument_sync_interrupted'; +INSERT INTO t1(title) VALUES('database'); +SET GLOBAL debug_dbug = @old_global_dbug; +SET debug_dbug = '+d,fts_instrument_sync_debug'; +INSERT INTO t1(title) VALUES('good'); +SET debug_dbug = @old_dbug; +SET GLOBAL innodb_ft_aux_table="test/t1"; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +database 2 2 1 2 0 +good 3 3 1 3 0 +mysql 1 1 1 1 0 +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION +SET GLOBAL innodb_ft_aux_table=default; +SELECT * FROM t1 WHERE MATCH(title) AGAINST ('mysql database good'); +id title +1 mysql +2 database +3 good +DROP TABLE t1; +# +# MDEV-26273 InnoDB fts DDL fails when +# innodb_force_recovery is set to 2 +# +# restart: --innodb_force_recovery=2 +CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED KEY, +f1 CHAR(200)) ENGINE=InnoDB; +ALTER TABLE t1 ADD FULLTEXT INDEX(f1); +DROP TABLE t1; +# restart diff --git a/mysql-test/suite/innodb_fts/r/sync_block.result b/mysql-test/suite/innodb_fts/r/sync_block.result new file mode 100644 index 00000000..65bee127 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/sync_block.result @@ -0,0 +1,83 @@ +SET @old_log_output = @@global.log_output; +SET @old_slow_query_log = @@global.slow_query_log; +SET @old_general_log = @@global.general_log; +SET @old_long_query_time = @@global.long_query_time; +SET @old_debug = @@global.debug_dbug; +SET GLOBAL log_output = 'TABLE'; +SET GLOBAL general_log = 1; +SET GLOBAL slow_query_log = 1; +SET GLOBAL long_query_time = 1; +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection default; +# Case 1: Sync blocks DML(insert) on the same table. +CREATE TABLE t1 ( +FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +FULLTEXT(title) +) ENGINE = InnoDB; +connection con1; +SET GLOBAL debug_dbug='+d,fts_instrument_sync_debug,fts_instrument_sync_sleep'; +SET DEBUG_SYNC= 'fts_sync_begin SIGNAL begin WAIT_FOR continue'; +INSERT INTO t1(title) VALUES('mysql database'); +connection con2; +SET DEBUG_SYNC= 'now WAIT_FOR begin'; +SELECT * FROM t1 WHERE MATCH(title) AGAINST('mysql database'); +connection default; +SET DEBUG_SYNC= 'now SIGNAL continue'; +connection con1; +/* connection con1 */ INSERT INTO t1(title) VALUES('mysql database'); +connection con2; +/* conneciton con2 */ SELECT * FROM t1 WHERE MATCH(title) AGAINST('mysql database'); +FTS_DOC_ID title +connection default; +# make con1 & con2 show up in mysql.slow_log +SELECT SLEEP(2); +SLEEP(2) +0 +# slow log results should only contain INSERT INTO t1. +SELECT sql_text FROM mysql.slow_log WHERE query_time >= '00:00:02'; +sql_text +INSERT INTO t1(title) VALUES('mysql database') +SET GLOBAL debug_dbug = @old_debug; +TRUNCATE TABLE mysql.slow_log; +DROP TABLE t1; +# Case 2: Sync blocks DML(insert) on other tables. +CREATE TABLE t1 ( +FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +FULLTEXT(title) +) ENGINE = InnoDB; +CREATE TABLE t2(id INT); +connection con1; +SET GLOBAL debug_dbug='+d,fts_instrument_sync_request,fts_instrument_sync_sleep'; +SET DEBUG_SYNC= 'fts_instrument_sync_request SIGNAL begin WAIT_FOR continue'; +INSERT INTO t1(title) VALUES('mysql database'); +connection con2; +SET DEBUG_SYNC= 'now WAIT_FOR begin'; +INSERT INTO t2 VALUES(1); +connection default; +SET DEBUG_SYNC= 'now SIGNAL continue'; +connection con1; +/* connection con1 */ INSERT INTO t1(title) VALUES('mysql database'); +connection con2; +/* conneciton con2 */ INSERT INTO t2 VALUES(1); +connection default; +SET DEBUG_SYNC = 'RESET'; +# make con1 & con2 show up in mysql.slow_log +SELECT SLEEP(2); +SLEEP(2) +0 +# slow log results should be empty here. +SELECT sql_text FROM mysql.slow_log WHERE query_time >= '00:00:02'; +sql_text +SET GLOBAL debug_dbug = @old_debug; +TRUNCATE TABLE mysql.slow_log; +DROP TABLE t1,t2; +disconnect con1; +disconnect con2; +# Restore slow log settings. +SET GLOBAL log_output = @old_log_output; +SET GLOBAL general_log = @old_general_log; +SET GLOBAL slow_query_log = @old_slow_query_log; +SET GLOBAL long_query_time = @old_long_query_time; diff --git a/mysql-test/suite/innodb_fts/r/sync_ddl.result b/mysql-test/suite/innodb_fts/r/sync_ddl.result new file mode 100644 index 00000000..441954dc --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/sync_ddl.result @@ -0,0 +1,105 @@ +CREATE TABLE t1 ( +id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, +value VARCHAR(1024) +) ENGINE=InnoDB; +CREATE FULLTEXT INDEX idx1 ON t1(value); +SET @save_debug = @@GLOBAL.debug_dbug; +SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_sync_before_syncing,ib_trunc_sleep_before_fts_cache_clear'; +INSERT INTO t1 (value) VALUES +('By default or with the IN NATURAL LANGUAGE MODE modifier') +; +TRUNCATE TABLE t1; +DROP TABLE t1; +SET GLOBAL debug_dbug = @save_debug; +CREATE TABLE t1 ( +id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, +value VARCHAR(1024) +) ENGINE=InnoDB; +CREATE FULLTEXT INDEX idx1 ON t1(value); +SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_write_words_before_select_index,ib_trunc_sleep_before_fts_cache_clear'; +INSERT INTO t1 (value) VALUES +('By default or with the IN NATURAL LANGUAGE MODE modifier'), +('performs a natural language search for a string'), +('collection is a set of one or more columns included'), +('returns a relevance value; that is, a similarity measure'), +('and the text in that row in the columns named in'), +('By default, the search is performed in case-insensitive'), +('sensitive full-text search, use a binary collation '), +('example, a column that uses the latin1 character'), +('collation of latin1_bin to make it case sensitive') +; +TRUNCATE TABLE t1; +DROP TABLE t1; +SET GLOBAL debug_dbug = @save_debug; +CREATE TABLE t1 ( +value VARCHAR(1024) +) ENGINE=InnoDB; +CREATE FULLTEXT INDEX idx1 ON t1(value); +SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep'; +INSERT INTO t1 (value) VALUES +('By default or with the IN NATURAL LANGUAGE MODE modifier'), +('performs a natural language search for a string'), +('collection is a set of one or more columns included'), +('returns a relevance value; that is, a similarity measure'), +('and the text in that row in the columns named in'), +('By default, the search is performed in case-insensitive'), +('sensitive full-text search, use a binary collation '), +('example, a column that uses the latin1 character'), +('collation of latin1_bin to make it case sensitive') +; +DROP INDEX idx1 ON t1; +DROP TABLE t1; +SET GLOBAL debug_dbug = @save_debug; +CREATE TABLE t1 ( +value VARCHAR(1024) +) ENGINE=InnoDB; +CREATE FULLTEXT INDEX idx1 ON t1(value); +SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep'; +INSERT INTO t1 (value) VALUES +('By default or with the IN NATURAL LANGUAGE MODE modifier'), +('performs a natural language search for a string'), +('collection is a set of one or more columns included'), +('returns a relevance value; that is, a similarity measure'), +('and the text in that row in the columns named in'), +('By default, the search is performed in case-insensitive'), +('sensitive full-text search, use a binary collation '), +('example, a column that uses the latin1 character'), +('collation of latin1_bin to make it case sensitive') +; +ALTER TABLE t1 +DROP INDEX idx1, +ALGORITHM=INPLACE; +DROP TABLE t1; +SET GLOBAL debug_dbug = @save_debug; +CREATE TABLE t1 ( +value VARCHAR(1024) +) ENGINE=InnoDB; +CREATE FULLTEXT INDEX idx1 ON t1(value); +SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep'; +INSERT INTO t1 (value) VALUES +('example, a column that uses the latin1 character'), +('collation of latin1_bin to make it case sensitive') +; +ALTER TABLE t1 +DROP INDEX idx1, +ALGORITHM=COPY; +DROP TABLE t1; +SET GLOBAL debug_dbug = @save_debug; +CREATE TABLE t1 ( +id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +value VARCHAR(1024) +) ENGINE=InnoDB; +CREATE FULLTEXT INDEX idx1 ON t1(value); +SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep'; +INSERT INTO t1 (value) VALUES +('example, a column that uses the latin1 character'), +('collation of latin1_bin to make it case sensitive') +; +ALTER TABLE t1 +DROP COLUMN id1, +ADD COLUMN id2 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, +DROP INDEX idx1, +ADD FULLTEXT INDEX idx2(value), +ALGORITHM=INPLACE; +DROP TABLE t1; +SET GLOBAL debug_dbug = @save_debug; diff --git a/mysql-test/suite/innodb_fts/r/versioning,prepare.result b/mysql-test/suite/innodb_fts/r/versioning,prepare.result new file mode 100644 index 00000000..ada4f30d --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/versioning,prepare.result @@ -0,0 +1,695 @@ +# Upgrade test +CREATE TEMPORARY TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +) ENGINE=InnoDB; +ERROR HY000: Cannot create FULLTEXT index on temporary InnoDB table +CREATE TABLE articles ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +)with system versioning ENGINE=InnoDB; +INSERT INTO articles (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +INSERT INTO articles (title,body) VALUES +('test query expansion','for database ...'); +INSERT INTO articles (title,body) VALUES +('test proximity search, test, proximity and phrase', +'search, with proximity innodb'); +INSERT INTO articles (title,body) VALUES +('test my proximity fts new search, test, proximity and phrase', +'search, with proximity innodb'); +INSERT INTO articles (title,body) VALUES +('test more of proximity fts search, test, more proximity and phrase', +'search, with proximity innodb'); +call mtr.add_suppression("\\[ERROR\\] InnoDB: user stopword table not_defined does not exist."); +call mtr.add_suppression("\\[ERROR\\] InnoDB: user stopword table test/user_stopword_session does not exist."); +select * from information_schema.innodb_ft_default_stopword; +value +a +about +an +are +as +at +be +by +com +de +en +for +from +how +i +in +is +it +la +of +on +or +that +the +this +to +was +what +when +where +who +will +with +und +the +www +CREATE TABLE articles2 ( +id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +title VARCHAR(200), +body TEXT, +FULLTEXT (title,body) +)with system versioning ENGINE=InnoDB; +INSERT INTO articles2 (title,body) VALUES +('MySQL Tutorial','DBMS stands for DataBase ...') , +('How To Use MySQL Well','After you went through a ...'), +('Optimizing MySQL','In this tutorial we will show ...'), +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL ...'); +SELECT * FROM articles2 WHERE MATCH (title,body) +AGAINST ('the' IN NATURAL LANGUAGE MODE); +id title body +set global innodb_ft_server_stopword_table = "not_defined"; +ERROR 42000: Variable 'innodb_ft_server_stopword_table' can't be set to the value of 'not_defined' +set global innodb_ft_server_stopword_table = NULL; +create table user_stopword(value varchar(30)) engine = innodb; +set global innodb_ft_server_stopword_table = "test/user_stopword"; +drop index title on articles2; +create fulltext index idx on articles2(title, body); +insert into articles2 (title, body) +values ('test for stopwords','this is it...'); +insert into user_stopword values("the"); +delete from user_stopword; +insert into user_stopword values("this"); +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +ERROR HY000: Index articles is corrupted +call mtr.add_suppression("test/articles.? contains 3 indexes inside InnoDB"); +alter table articles force; +Warnings: +Warning 1082 InnoDB: Table test/articles contains 3 indexes inside InnoDB, which is different from the number of indexes 2 defined in the MariaDB +flush tables; +show create table articles; +Table Create Table +articles CREATE TABLE `articles` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `title` varchar(200) DEFAULT NULL, + `body` text DEFAULT NULL, + PRIMARY KEY (`id`), + FULLTEXT KEY `title` (`title`,`body`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +5 MySQL vs. YourSQL In the following database comparison ... +7 test query expansion for database ... +SELECT COUNT(*) FROM articles +WHERE MATCH (title,body) +AGAINST ('database' IN NATURAL LANGUAGE MODE); +COUNT(*) +3 +SELECT * FROM articles +WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT COUNT(IF(MATCH (title,body) +AGAINST ('database' IN NATURAL LANGUAGE MODE), 1, NULL)) +AS count FROM articles; +count +3 +SELECT id, body, MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE) AS score +FROM articles; +id body score +1 DBMS stands for DataBase ... 0.2734021842479706 +2 After you went through a ... 0 +3 In this tutorial we will show ... 0 +4 1. Never run mysqld as root. 2. ... 0 +5 In the following database comparison ... 0.2734021842479706 +6 When configured properly, MySQL ... 0 +7 for database ... 0.2734021842479706 +8 search, with proximity innodb 0 +9 search, with proximity innodb 0 +10 search, with proximity innodb 0 +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('MySQL' IN NATURAL LANGUAGE MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('DBMS Security' IN BOOLEAN MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL +YourSQL' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL YourSQL' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL ~YourSQL' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('t*' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +7 test query expansion for database ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('MY*' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('ru*' IN BOOLEAN MODE); +id title body +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+ MySQL >Well < stands' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+ MySQL - (Well stands)' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((((Security)))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR HY000: Table handler out of memory +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('((((((((((((((((((((((((((((((((Security))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((vs))))))))))))))))))))))))))))))),(((to)))' + IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('((((((((((((((((((((((((((((((((Security)))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR 42000: syntax error, unexpected $end +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((((Security))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR 42000: syntax error, unexpected $end +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+ MySQL + (>Well < stands)' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +1 MySQL Tutorial DBMS stands for DataBase ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('YourSQL + (+MySQL - (Tricks Security))' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('(+MySQL - (Tricks Security)) - YourSQL' IN BOOLEAN MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysql - Security&DBMS' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysql - (Security DBMS)' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST (' - Security&DBMS + YourSQL' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('+YourSQL - Security&DBMS' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT COUNT(*) FROM articles +WHERE MATCH (title,body) +AGAINST ('database' WITH QUERY EXPANSION); +COUNT(*) +10 +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('test' WITH QUERY EXPANSION); +id title body +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +8 test proximity search, test, proximity and phrase search, with proximity innodb +7 test query expansion for database ... +1 MySQL Tutorial DBMS stands for DataBase ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"following comparison"@3' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"following comparison"@2' IN BOOLEAN MODE); +id title body +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"following database"' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"proximity search"@3' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"proximity search"@2' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"proximity search"@5' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@5' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@1' IN BOOLEAN MODE); +id title body +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@4' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@3' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"more test proximity"@4' IN BOOLEAN MODE); +id title body +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"more test proximity"@3' IN BOOLEAN MODE); +id title body +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"more test proximity"' IN BOOLEAN MODE); +id title body +set global innodb_ft_server_stopword_table= "test/user_stopword"; +SELECT * FROM articles2 WHERE MATCH (title,body) +AGAINST ('the' IN NATURAL LANGUAGE MODE); +SELECT * FROM articles2 WHERE MATCH (title,body) +AGAINST ('this' IN NATURAL LANGUAGE MODE); +drop index idx on articles2; +Warnings: +Warning 1082 InnoDB: Table test/articles2 contains 3 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MariaDB +create fulltext index idx on articles2(title, body); +SELECT * FROM articles2 WHERE MATCH (title,body) +AGAINST ('the' IN NATURAL LANGUAGE MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles2 WHERE MATCH (title,body) +AGAINST ('this' IN NATURAL LANGUAGE MODE); +id title body +# Downgrade test +alter table articles force; +Warnings: +Warning 1082 InnoDB: Table test/articles contains 3 indexes inside InnoDB, which is different from the number of indexes 2 defined in the MariaDB +Warning 1082 InnoDB: Table test/articles contains 3 indexes inside InnoDB, which is different from the number of indexes 2 defined in the MariaDB +flush tables; +show create table articles; +Table Create Table +articles CREATE TABLE `articles` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `title` varchar(200) DEFAULT NULL, + `body` text DEFAULT NULL, + PRIMARY KEY (`id`), + FULLTEXT KEY `title` (`title`,`body`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +5 MySQL vs. YourSQL In the following database comparison ... +7 test query expansion for database ... +SELECT COUNT(*) FROM articles +WHERE MATCH (title,body) +AGAINST ('database' IN NATURAL LANGUAGE MODE); +COUNT(*) +3 +SELECT * FROM articles +WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT COUNT(IF(MATCH (title,body) +AGAINST ('database' IN NATURAL LANGUAGE MODE), 1, NULL)) +AS count FROM articles; +count +3 +SELECT id, body, MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE) AS score +FROM articles; +id body score +1 DBMS stands for DataBase ... 0.2734021842479706 +2 After you went through a ... 0 +3 In this tutorial we will show ... 0 +4 1. Never run mysqld as root. 2. ... 0 +5 In the following database comparison ... 0.2734021842479706 +6 When configured properly, MySQL ... 0 +7 for database ... 0.2734021842479706 +8 search, with proximity innodb 0 +9 search, with proximity innodb 0 +10 search, with proximity innodb 0 +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('MySQL' IN NATURAL LANGUAGE MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('DBMS Security' IN BOOLEAN MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL +YourSQL' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL YourSQL' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL ~YourSQL' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('t*' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +7 test query expansion for database ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('MY*' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('ru*' IN BOOLEAN MODE); +id title body +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+ MySQL >Well < stands' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+ MySQL - (Well stands)' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((((Security)))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR HY000: Table handler out of memory +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('((((((((((((((((((((((((((((((((Security))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((vs))))))))))))))))))))))))))))))),(((to)))' + IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('((((((((((((((((((((((((((((((((Security)))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR 42000: syntax error, unexpected $end +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((((Security))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR 42000: syntax error, unexpected $end +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+ MySQL + (>Well < stands)' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +1 MySQL Tutorial DBMS stands for DataBase ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('YourSQL + (+MySQL - (Tricks Security))' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('(+MySQL - (Tricks Security)) - YourSQL' IN BOOLEAN MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysql - Security&DBMS' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysql - (Security DBMS)' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST (' - Security&DBMS + YourSQL' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('+YourSQL - Security&DBMS' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT COUNT(*) FROM articles +WHERE MATCH (title,body) +AGAINST ('database' WITH QUERY EXPANSION); +COUNT(*) +10 +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('test' WITH QUERY EXPANSION); +id title body +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +8 test proximity search, test, proximity and phrase search, with proximity innodb +7 test query expansion for database ... +1 MySQL Tutorial DBMS stands for DataBase ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"following comparison"@3' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"following comparison"@2' IN BOOLEAN MODE); +id title body +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"following database"' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"proximity search"@3' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"proximity search"@2' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"proximity search"@5' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@5' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@1' IN BOOLEAN MODE); +id title body +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@4' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@3' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"more test proximity"@4' IN BOOLEAN MODE); +id title body +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"more test proximity"@3' IN BOOLEAN MODE); +id title body +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"more test proximity"' IN BOOLEAN MODE); +id title body +set global innodb_ft_server_stopword_table= "test/user_stopword"; +drop index idx on articles2; +Warnings: +Warning 1082 InnoDB: Table test/articles2 contains 3 indexes inside InnoDB, which is different from the number of indexes 2 defined in the MariaDB +Warning 1082 InnoDB: Table test/articles2 contains 3 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MariaDB +create fulltext index idx on articles2(title, body); +SELECT * FROM articles2 WHERE MATCH (title,body) +AGAINST ('the' IN NATURAL LANGUAGE MODE); +id title body +SELECT * FROM articles2 WHERE MATCH (title,body) +AGAINST ('this' IN NATURAL LANGUAGE MODE); +id title body +# Cleanup +drop tables articles, articles2, user_stopword; +set global innodb_ft_server_stopword_table= default; diff --git a/mysql-test/suite/innodb_fts/r/versioning.result b/mysql-test/suite/innodb_fts/r/versioning.result new file mode 100644 index 00000000..baf25331 --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/versioning.result @@ -0,0 +1,304 @@ +# Upgrade test +DROP TABLE mysql.innodb_table_stats, mysql.innodb_index_stats; +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +ERROR HY000: Index articles is corrupted +call mtr.add_suppression("test/articles.? contains 3 indexes inside InnoDB"); +alter table articles force; +Warnings: +Warning 1082 InnoDB: Table test/articles contains 3 indexes inside InnoDB, which is different from the number of indexes 2 defined in the MariaDB +flush tables; +show create table articles; +Table Create Table +articles CREATE TABLE `articles` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `title` varchar(200) DEFAULT NULL, + `body` text DEFAULT NULL, + PRIMARY KEY (`id`), + FULLTEXT KEY `title` (`title`,`body`) +) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci WITH SYSTEM VERSIONING +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +5 MySQL vs. YourSQL In the following database comparison ... +7 test query expansion for database ... +SELECT COUNT(*) FROM articles +WHERE MATCH (title,body) +AGAINST ('database' IN NATURAL LANGUAGE MODE); +COUNT(*) +3 +SELECT * FROM articles +WHERE MATCH (title, body) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT COUNT(IF(MATCH (title,body) +AGAINST ('database' IN NATURAL LANGUAGE MODE), 1, NULL)) +AS count FROM articles; +count +3 +SELECT id, body, MATCH (title,body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE) AS score +FROM articles; +id body score +1 DBMS stands for DataBase ... 0.2734021842479706 +2 After you went through a ... 0 +3 In this tutorial we will show ... 0 +4 1. Never run mysqld as root. 2. ... 0 +5 In the following database comparison ... 0.2734021842479706 +6 When configured properly, MySQL ... 0 +7 for database ... 0.2734021842479706 +8 search, with proximity innodb 0 +9 search, with proximity innodb 0 +10 search, with proximity innodb 0 +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('MySQL' IN NATURAL LANGUAGE MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('DBMS Security' IN BOOLEAN MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL +YourSQL' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL YourSQL' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+MySQL ~YourSQL' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('t*' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +7 test query expansion for database ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('MY*' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('ru*' IN BOOLEAN MODE); +id title body +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+ MySQL >Well < stands' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +6 MySQL Security When configured properly, MySQL ... +1 MySQL Tutorial DBMS stands for DataBase ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+ MySQL - (Well stands)' IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((((Security)))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR HY000: Table handler out of memory +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('((((((((((((((((((((((((((((((((Security))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +id title body +6 MySQL Security When configured properly, MySQL ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((vs))))))))))))))))))))))))))))))),(((to)))' + IN BOOLEAN MODE); +id title body +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('((((((((((((((((((((((((((((((((Security)))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR 42000: syntax error, unexpected $end +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((((Security))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +ERROR 42000: syntax error, unexpected $end +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('+ MySQL + (>Well < stands)' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +1 MySQL Tutorial DBMS stands for DataBase ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('YourSQL + (+MySQL - (Tricks Security))' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) +AGAINST ('(+MySQL - (Tricks Security)) - YourSQL' IN BOOLEAN MODE); +id title body +1 MySQL Tutorial DBMS stands for DataBase ... +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysql - Security&DBMS' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysql - (Security DBMS)' IN BOOLEAN MODE); +id title body +2 How To Use MySQL Well After you went through a ... +3 Optimizing MySQL In this tutorial we will show ... +4 1001 MySQL Tricks 1. Never run mysqld as root. 2. ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST (' - Security&DBMS + YourSQL' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('+YourSQL - Security&DBMS' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT COUNT(*) FROM articles +WHERE MATCH (title,body) +AGAINST ('database' WITH QUERY EXPANSION); +COUNT(*) +10 +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('test' WITH QUERY EXPANSION); +id title body +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +8 test proximity search, test, proximity and phrase search, with proximity innodb +7 test query expansion for database ... +1 MySQL Tutorial DBMS stands for DataBase ... +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"following comparison"@3' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"following comparison"@2' IN BOOLEAN MODE); +id title body +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"following database"' IN BOOLEAN MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"proximity search"@3' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"proximity search"@2' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"proximity search"@5' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@5' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@1' IN BOOLEAN MODE); +id title body +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@4' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"test proximity"@3' IN BOOLEAN MODE); +id title body +8 test proximity search, test, proximity and phrase search, with proximity innodb +9 test my proximity fts new search, test, proximity and phrase search, with proximity innodb +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"more test proximity"@4' IN BOOLEAN MODE); +id title body +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"more test proximity"@3' IN BOOLEAN MODE); +id title body +10 test more of proximity fts search, test, more proximity and phrase search, with proximity innodb +SELECT * FROM articles +WHERE MATCH (title,body) +AGAINST ('"more test proximity"' IN BOOLEAN MODE); +id title body +set global innodb_ft_server_stopword_table= "test/user_stopword"; +SELECT * FROM articles2 WHERE MATCH (title,body) +AGAINST ('the' IN NATURAL LANGUAGE MODE); +SELECT * FROM articles2 WHERE MATCH (title,body) +AGAINST ('this' IN NATURAL LANGUAGE MODE); +drop index idx on articles2; +Warnings: +Warning 1082 InnoDB: Table test/articles2 contains 3 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MariaDB +create fulltext index idx on articles2(title, body); +SELECT * FROM articles2 WHERE MATCH (title,body) +AGAINST ('the' IN NATURAL LANGUAGE MODE); +id title body +5 MySQL vs. YourSQL In the following database comparison ... +SELECT * FROM articles2 WHERE MATCH (title,body) +AGAINST ('this' IN NATURAL LANGUAGE MODE); +id title body +# Cleanup +drop tables articles, articles2, user_stopword; +set global innodb_ft_server_stopword_table= default; diff --git a/mysql-test/suite/innodb_fts/t/basic.inc b/mysql-test/suite/innodb_fts/t/basic.inc new file mode 100644 index 00000000..fd7d0920 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/basic.inc @@ -0,0 +1,264 @@ +if ($basic_stage == create_table) +{ +# Create FTS table +--error ER_INNODB_NO_FT_TEMP_TABLE +CREATE TEMPORARY TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) + ) ENGINE=InnoDB; + +--disable_query_log +eval CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) + )$create_options ENGINE=InnoDB; +--enable_query_log +} + +if ($basic_stage == insert_1) +{ +# Insert six rows +INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); +} + +if ($basic_stage == select_1) +{ +# Look for 'Database' in table article +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('Database' IN NATURAL LANGUAGE MODE); + +SELECT COUNT(*) FROM articles + WHERE MATCH (title,body) + AGAINST ('database' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles + WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + + +SELECT COUNT(IF(MATCH (title,body) + AGAINST ('database' IN NATURAL LANGUAGE MODE), 1, NULL)) + AS count FROM articles; + +# Select Relevance Ranking +SELECT id, body, MATCH (title,body) + AGAINST ('Database' IN NATURAL LANGUAGE MODE) AS score + FROM articles; + +# 'MySQL' treated as stopword (stopword functionality not yet supported) +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('MySQL' IN NATURAL LANGUAGE MODE); + +# Boolean search +# Select rows contain "MySQL" but not "YourSQL" +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); + +# Select rows contain at least one of the two words +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('DBMS Security' IN BOOLEAN MODE); + +# Select rows contain both "MySQL" and "YourSQL" +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('+MySQL +YourSQL' IN BOOLEAN MODE); + +# Select rows contain "MySQL" but rank rows with "YourSQL" higher +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('+MySQL YourSQL' IN BOOLEAN MODE); + +# Test negation operator. Select rows contain MySQL, +# if the row contains "YourSQL", rank it lower +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('+MySQL ~YourSQL' IN BOOLEAN MODE); + +# Test wild card search operator +# Notice row with "the" will not get fetched due to +# stopword filtering +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('t*' IN BOOLEAN MODE); + +# Test wild card search, notice row 6 with 2 "MySQL" rank first +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('MY*' IN BOOLEAN MODE); + +# Another wild card search +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('ru*' IN BOOLEAN MODE); + +# Test ">" and "<" Operator, the ">" operator increases +# the word relevance rank and the "<" operator decreases it +# Following test puts rows with "Well" on top and rows +# with "stands" at the bottom +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('+ MySQL >Well < stands' IN BOOLEAN MODE); + +# Test sub-expression boolean search. Find rows contain +# "MySQL" but not "Well" or "stands". +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('+ MySQL - (Well stands)' IN BOOLEAN MODE); + +--error 128 +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((((Security)))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('((((((((((((((((((((((((((((((((Security))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((vs))))))))))))))))))))))))))))))),(((to)))' + IN BOOLEAN MODE); + +--error ER_PARSE_ERROR +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('((((((((((((((((((((((((((((((((Security)))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); +--error ER_PARSE_ERROR +SELECT * FROM articles WHERE MATCH (title,body) AGAINST +('(((((((((((((((((((((((((((((((((Security))))))))))))))))))))))))))))))))' + IN BOOLEAN MODE); + +# Test sub-expression boolean search. Find rows contain +# "MySQL" and "Well" or "MySQL" and "stands". But rank the +# doc with "Well" higher, and doc with "stands" lower. +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('+ MySQL + (>Well < stands)' IN BOOLEAN MODE); + +# Test nested sub-expression. +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('YourSQL + (+MySQL - (Tricks Security))' IN BOOLEAN MODE); + +# Find rows with "MySQL" but not "Tricks", "Security" nor "YourSQL" +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('(+MySQL - (Tricks Security)) - YourSQL' IN BOOLEAN MODE); + +# Test non-word delimiter combined with negate "-" operator +# This should return the same result as 'mysql - (Security DBMS)' +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysql - Security&DBMS' IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysql - (Security DBMS)' IN BOOLEAN MODE); + +# Again, the operator sequence should not matter +SELECT * FROM articles WHERE MATCH (title,body) AGAINST (' - Security&DBMS + YourSQL' IN BOOLEAN MODE); + +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('+YourSQL - Security&DBMS' IN BOOLEAN MODE); + +# Test query expansion +SELECT COUNT(*) FROM articles + WHERE MATCH (title,body) + AGAINST ('database' WITH QUERY EXPANSION); +} + +if ($basic_stage == insert_2) +{ +INSERT INTO articles (title,body) VALUES + ('test query expansion','for database ...'); +} + +if ($basic_stage == select_2) +{ +# This query will return result containing word "database" as +# the query expand from "test" to words in document just +# inserted above +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('test' WITH QUERY EXPANSION); + +# This is to test the proximity search, search two word +# "following" and "comparison" within 19 character space +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('"following comparison"@3' IN BOOLEAN MODE); + +# This is to test the proximity search, search two word +# "following" and "comparison" within 19 character space +# This search should come with no return result +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('"following comparison"@2' IN BOOLEAN MODE); + +# This is to test the phrase search, searching phrase +# "following database" +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('"following database"' IN BOOLEAN MODE); +} + +if ($basic_stage == insert_3) +{ +# Insert into table with similar word of different distances +INSERT INTO articles (title,body) VALUES + ('test proximity search, test, proximity and phrase', + 'search, with proximity innodb'); + +INSERT INTO articles (title,body) VALUES + ('test my proximity fts new search, test, proximity and phrase', + 'search, with proximity innodb'); + +INSERT INTO articles (title,body) VALUES + ('test more of proximity fts search, test, more proximity and phrase', + 'search, with proximity innodb'); +} + +if ($basic_stage == select_3) +{ +# This should only return the first document +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('"proximity search"@3' IN BOOLEAN MODE); + +# This would return no document +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('"proximity search"@2' IN BOOLEAN MODE); + +# This give you all three documents +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('"proximity search"@5' IN BOOLEAN MODE); + +# Similar boundary testing for the words +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('"test proximity"@5' IN BOOLEAN MODE); + +# No document will be returned +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('"test proximity"@1' IN BOOLEAN MODE); + +# All three documents will be returned +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('"test proximity"@4' IN BOOLEAN MODE); + +# Only two document will be returned. +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('"test proximity"@3' IN BOOLEAN MODE); + +# Test with more word The last document will return, please notice there +# is no ordering requirement for proximity search. +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('"more test proximity"@4' IN BOOLEAN MODE); + +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('"more test proximity"@3' IN BOOLEAN MODE); + +# The phrase search will not require exact word ordering +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('"more test proximity"' IN BOOLEAN MODE); +} diff --git a/mysql-test/suite/innodb_fts/t/basic.test b/mysql-test/suite/innodb_fts/t/basic.test new file mode 100644 index 00000000..df2e24fa --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/basic.test @@ -0,0 +1,64 @@ +# This is the basic function tests for innodb FTS + +-- source include/have_innodb.inc +--let $modify_create_table= 1 +-- source include/maybe_versioning.inc + +let $basic_stage= create_table; +--source basic.inc + +let $basic_stage= insert_1; +--source basic.inc + +-- disable_result_log +ANALYZE TABLE articles; +-- enable_result_log + +let $basic_stage= select_1; +--source basic.inc + +let $basic_stage= insert_2; +--source basic.inc + +let $basic_stage= select_2; +--source basic.inc + +let $basic_stage= insert_3; +--source basic.inc + +let $basic_stage= select_3; +--source basic.inc + +drop table articles; + +--echo # +--echo # Bug #22679185 INVALID INNODB FTS DOC ID DURING INSERT +--echo # + +create table t1 (f1 int not null primary key, f2 varchar(100), + FTS_DOC_ID bigint(20) unsigned not null, + unique key `FTS_DOC_ID_INDEX` (`FTS_DOC_ID`), + fulltext key (f2))engine=innodb; + +insert into t1 values(1, "This is the first record", 20000); +insert into t1 values(2, "This is the second record", 40000); +select FTS_DOC_ID from t1; +drop table t1; + + +create table t1 (f1 int not null primary key, f2 varchar(100), + FTS_DOC_ID bigint(20) unsigned not null auto_increment, + unique key `FTS_DOC_ID_INDEX` (`FTS_DOC_ID`), + fulltext key (f2))engine=innodb; + +set auto_increment_increment = 65535; +insert into t1(f1, f2) values(1, "This is the first record"); +insert into t1(f1, f2) values(2, "This is the second record"); +insert into t1(f1, f2) values(3, "This is the third record"); +select FTS_DOC_ID from t1; +drop table t1; + +CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), FULLTEXT(title)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (NULL, NULL), (20030101000000, 20030102000000); +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/bug_32831765.test b/mysql-test/suite/innodb_fts/t/bug_32831765.test new file mode 100644 index 00000000..80502f7f --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/bug_32831765.test @@ -0,0 +1,165 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/big_test.inc + +call mtr.add_suppression("InnoDB: Total InnoDB FTS size .* for the table .* exceeds the innodb_ft_cache_size .*"); +--echo # +--echo # Bug#32831765 SERVER HITS OOM CONDITION WHEN LOADING TWO +--echo # INNODB TABLES WITH FTS INDEXES +--echo # + +create table t1 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text, +`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07` +text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text, +`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18` +text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text, +`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29` +text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY +(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY +(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY +(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY +(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY +(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY +(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY +(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY +(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY +(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY +(`col29`), FULLTEXT KEY (`col30`)) engine=innodb; + +create table t2 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text, +`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07` +text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text, +`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18` +text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text, +`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29` +text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY +(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY +(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY +(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY +(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY +(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY +(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY +(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY +(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY +(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY +(`col29`), FULLTEXT KEY (`col30`)) engine=innodb; + + +create table t3 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text, +`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07` +text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text, +`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18` +text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text, +`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29` +text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY +(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY +(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY +(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY +(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY +(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY +(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY +(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY +(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY +(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY +(`col29`), FULLTEXT KEY (`col30`)) engine=innodb; + +create table t4 ( `id` int unsigned NOT NULL AUTO_INCREMENT, `col01` text, +`col02` text, `col03` text, `col04` text, `col05` text, `col06` text, `col07` +text, `col08` text, `col09` text, `col10` text, `col11` text, `col12` text, +`col13` text, `col14` text, `col15` text, `col16` text, `col17` text, `col18` +text, `col19` text, `col20` text, `col21` text, `col22` text, `col23` text, +`col24` text, `col25` text, `col26` text, `col27` text, `col28` text, `col29` +text, `col30` text, PRIMARY KEY (`id`), FULLTEXT KEY (`col01`), FULLTEXT KEY +(`col02`), FULLTEXT KEY (`col03`), FULLTEXT KEY (`col04`), FULLTEXT KEY +(`col05`), FULLTEXT KEY (`col06`), FULLTEXT KEY (`col07`), FULLTEXT KEY +(`col08`), FULLTEXT KEY (`col09`), FULLTEXT KEY (`col10`), FULLTEXT KEY +(`col11`), FULLTEXT KEY (`col12`), FULLTEXT KEY (`col13`), FULLTEXT KEY +(`col14`), FULLTEXT KEY (`col15`), FULLTEXT KEY (`col16`), FULLTEXT KEY +(`col17`), FULLTEXT KEY (`col18`), FULLTEXT KEY (`col19`), FULLTEXT KEY +(`col20`), FULLTEXT KEY (`col21`), FULLTEXT KEY (`col22`), FULLTEXT KEY +(`col23`), FULLTEXT KEY (`col24`), FULLTEXT KEY (`col25`), FULLTEXT KEY +(`col26`), FULLTEXT KEY (`col27`), FULLTEXT KEY (`col28`), FULLTEXT KEY +(`col29`), FULLTEXT KEY (`col30`)) engine=innodb; + +delimiter |; + +--echo #create procedure to inset into the table. +CREATE PROCEDURE `proc_insert`(IN tab_name VARCHAR(40)) +BEGIN + DECLARE i INT DEFAULT 1; + SET @insert_tbl =CONCAT('INSERT INTO ', tab_name, '( `col01`, `col02`, + `col03`, `col04`, `col05`, `col06`, `col07`, `col08`, `col09`, `col10`, + `col11`, `col12`, `col13`, `col14`, `col15`, `col16`, `col17`, `col18`, + `col19`, `col20`, `col21`, `col22`, `col23`, `col24`, `col25`, `col26`, + `col27`, `col28`, `col29`, `col30`) + VALUES ( MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), + MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), + MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), + MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), + MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), + MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), MD5(RAND()), + MD5(RAND()))'); + PREPARE ins_stmt FROM @insert_tbl; + while (i <= 2000) DO + EXECUTE ins_stmt; + SET i = i + 1; + END WHILE; + DEALLOCATE PREPARE ins_stmt; +END | + +delimiter ;| + +# Ensure that the number of SYNC requests will not exceed 1000. +SET @save_dbug= @@GLOBAL.debug_dbug; +SET GLOBAL debug_dbug="+d,fts_optimize_wq_count_check"; + +connect (con1,localhost,root,,); +send call proc_insert('t1'); +connect (con2,localhost,root,,); +send call proc_insert('t1'); +connect (con3,localhost,root,,); +send call proc_insert('t2'); +connect (con4,localhost,root,,); +send call proc_insert('t2'); +connect (con5,localhost,root,,); +send call proc_insert('t3'); +connect (con6,localhost,root,,); +send call proc_insert('t3'); +connect (con7,localhost,root,,); +send call proc_insert('t4'); + +connection default; +call proc_insert('t4'); +SET GLOBAL debug_dbug= @save_dbug; + +connection con1; +reap; +disconnect con1; + +connection con2; +reap; +disconnect con2; + +connection con3; +reap; +disconnect con3; + +connection con4; +reap; +disconnect con4; + +connection con5; +reap; +disconnect con5; + +connection con6; +reap; +disconnect con6; + +connection con7; +reap; +disconnect con7; + +connection default; +DROP TABLE t1,t2,t3,t4; +DROP PROCEDURE proc_insert; diff --git a/mysql-test/suite/innodb_fts/t/concurrent_insert.test b/mysql-test/suite/innodb_fts/t/concurrent_insert.test new file mode 100644 index 00000000..9b4d9517 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/concurrent_insert.test @@ -0,0 +1,80 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc + +CREATE TABLE t1(a VARCHAR(5),FULLTEXT KEY(a)) ENGINE=InnoDB; +SET DEBUG_SYNC = 'get_next_FTS_DOC_ID SIGNAL prepared WAIT_FOR race'; +--send +REPLACE INTO t1(a) values('aaa'); + +connect(dml, localhost, root, ,); +SET DEBUG_SYNC = 'now WAIT_FOR prepared'; +REPLACE INTO t1(a) VALUES('aaa'); +SET DEBUG_SYNC = 'now SIGNAL race'; +disconnect dml; + +connection default; +reap; +SET DEBUG_SYNC = 'RESET'; + +DROP TABLE t1; + +--echo # +--echo # MDEV-19529 InnoDB hang on DROP FULLTEXT INDEX +--echo # + +CREATE TABLE t1(f1 CHAR(100), FULLTEXT(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES('test'); +CREATE TABLE t2 (f1 char(100), FULLTEXT idx1(f1))ENGINE=InnoDB; +INSERT INTO t2 VALUES('mariadb'); + +connection default; +SET @saved_dbug = @@GLOBAL.debug_dbug; +SET GLOBAL debug_dbug ='+d,fts_instrument_sync_request,ib_optimize_wq_hang'; +SET DEBUG_SYNC= 'fts_instrument_sync_request + SIGNAL drop_index_start WAIT_FOR sync_op'; +send INSERT INTO t1 VALUES('Keyword'); + +connect(con1,localhost,root,,,); +SET DEBUG_SYNC='now WAIT_FOR drop_index_start'; +SET DEBUG_SYNC= 'norebuild_fts_drop SIGNAL sync_op WAIT_FOR fts_drop_index'; +send ALTER TABLE t2 drop index idx1; + +connection default; +reap; +set DEBUG_SYNC= 'now SIGNAL fts_drop_index'; + +connection con1; +reap; +drop table t1, t2; +connection default; +SET @@GLOBAL.debug_dbug = @saved_dbug; +disconnect con1; + +--echo # +--echo # MDEV-25984 Assertion `max_doc_id > 0' failed in fts_init_doc_id() +--echo # +call mtr.add_suppression("InnoDB: \\(Lock wait timeout\\) while getting next doc id for table `test`.`t1`"); + +CREATE TABLE t1(f1 CHAR(100), f2 INT, fulltext(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES("mariadb", 1), ("innodb", 1); +--source include/restart_mysqld.inc +SET DEBUG_SYNC='innodb_rollback_after_fts_lock SIGNAL insert_dml WAIT_FOR ddl_continue'; +SEND ALTER TABLE t1 ADD UNIQUE INDEX(f2); + +connect(con1,localhost,root,,,); +SET DEBUG_SYNC='now WAIT_FOR insert_dml'; +SET DEBUG_SYNC='fts_cmp_set_sync_doc_id_retry SIGNAL ddl_continue WAIT_FOR dml_finish'; +send INSERT INTO t1 VALUES("index", 2); + +connection default; +--error ER_DUP_ENTRY +reap; +SET DEBUG_SYNC="now SIGNAL dml_finish"; +connection con1; +reap; +SHOW CREATE TABLE t1; +connection default; +disconnect con1; +DROP TABLE t1; +set DEBUG_SYNC=RESET; diff --git a/mysql-test/suite/innodb_fts/t/crash_recovery.opt b/mysql-test/suite/innodb_fts/t/crash_recovery.opt new file mode 100644 index 00000000..e6ae8d0f --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/crash_recovery.opt @@ -0,0 +1 @@ +--enable-plugin-innodb-sys-tables diff --git a/mysql-test/suite/innodb_fts/t/crash_recovery.test b/mysql-test/suite/innodb_fts/t/crash_recovery.test new file mode 100644 index 00000000..dd8a07f8 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/crash_recovery.test @@ -0,0 +1,305 @@ +# Crash recovery tests for FULLTEXT INDEX. +# Note: These tests used to be part of a larger test, innodb_fts_misc_debug +# or innodb_fts.misc_debug. The part of the test that actually needs debug +# instrumentation been moved to innodb_fts.misc_debug. + +--source include/have_innodb.inc +# The embedded server tests do not support restarting. +--source include/not_embedded.inc +--source include/maybe_debug.inc +if ($have_debug) { source include/have_debug_sync.inc; } +--source include/maybe_versioning.inc + +FLUSH TABLES; +# Following are test for crash recovery on FTS index, the first scenario +# is for bug Bug #14586855 INNODB: FAILING ASSERTION: (DICT_INDEX_GET_N_UNIQUE( +# PLAN->INDEX) <= PLAN->N_EXAC + +# Scenario 1: Hidden FTS_DOC_ID column, and FTS index dropped +# Create FTS table +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) + ) ENGINE=InnoDB; + +let $vers= $MTR_COMBINATION_VERS + $MTR_COMBINATION_VERS_TRX; +if ($vers) +{ + --disable_query_log + INSERT INTO articles (title,body) VALUES + ('history','Deleted row ...'); + DELETE FROM articles; + --enable_query_log +} + +# Drop the FTS index before more insertion. The FTS_DOC_ID should +# be kept +DROP INDEX title ON articles; + +# Insert six rows +INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +BEGIN; +INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...'); + +--echo # Make durable the AUTO_INCREMENT in the above incomplete transaction. +--connect(ddl1, localhost, root,,) +CREATE TABLE t1(a TEXT,b TEXT,FULLTEXT INDEX(a)) ENGINE=InnoDB; +if ($have_debug) +{ +--disable_query_log +SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL 1 WAIT_FOR ever'; +--enable_query_log +} +send ALTER TABLE t1 ADD FULLTEXT INDEX(b); +--connection default +if ($have_debug) +{ +--disable_query_log +SET DEBUG_SYNC='now WAIT_FOR 1'; +--enable_query_log +} + +--connect(ddl2, localhost, root,,) +CREATE TABLE t2(a TEXT,b TEXT,FULLTEXT INDEX(a)) ENGINE=InnoDB; +if ($have_debug) +{ +--disable_query_log +SET DEBUG_SYNC='innodb_inplace_alter_table_enter SIGNAL 2 WAIT_FOR ever'; +--enable_query_log +} +send ALTER TABLE t2 DROP INDEX a, ADD FULLTEXT INDEX(b), FORCE; +--connection default +if ($have_debug) +{ +--disable_query_log +SET DEBUG_SYNC='now WAIT_FOR 2'; +--enable_query_log +} + +--connect(ddl3, localhost, root,,) +CREATE TABLE t3(a TEXT,b TEXT,FULLTEXT INDEX(a)) ENGINE=InnoDB; +if ($have_debug) +{ +--disable_query_log +SET DEBUG_SYNC='alter_table_before_rename_result_table SIGNAL 3 WAIT_FOR ever'; +--enable_query_log +} +send ALTER TABLE t3 DROP INDEX a, ADD FULLTEXT INDEX(b), ALGORITHM=COPY; + +--connection default +if ($have_debug) +{ +--disable_query_log +SET DEBUG_SYNC='now WAIT_FOR 3'; +--enable_query_log +} + +let $shutdown_timeout=0; +--source include/restart_mysqld.inc + +disconnect ddl1; +disconnect ddl2; +disconnect ddl3; + +# Wait for purge, so that any #sql-ib.ibd files from the previous kill +# will be deleted. +source ../../innodb/include/wait_all_purged.inc; + +CHECK TABLE t1,t2,t3; +DROP TABLE t1,t2,t3; + +# This insert will re-initialize the Doc ID counter, it should not crash +INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...'); + +# Recreate fulltext index to see if everything is OK +CREATE FULLTEXT INDEX idx ON articles (title,body); + +if ($vers) +{ + --disable_query_log + UPDATE articles SET id= id - 1; + --enable_query_log +} + +# Should return 3 rows +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('Database' IN NATURAL LANGUAGE MODE); + +# Scenario 2: Hidden FTS_DOC_ID column, with FTS index +# Now let's do more insertion and test a crash with FTS on +INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +connect(dml, localhost, root,,); +BEGIN; + +INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...'); +connection default; + +--echo # Make durable the AUTO_INCREMENT in the above incomplete transaction. +--connect (flush_redo_log,localhost,root,,) +SET GLOBAL innodb_flush_log_at_trx_commit=1; +SET SQL_MODE = NO_AUTO_VALUE_ON_ZERO; +BEGIN; +UPDATE articles SET id=0 WHERE id=1; +UPDATE articles SET id=1 WHERE id=0; +COMMIT; +--disconnect flush_redo_log +--connection default + +--source include/restart_mysqld.inc + +disconnect dml; + +# This insert will re-initialize the Doc ID counter, it should not crash +INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...'); + +if ($vers) +{ + --disable_query_log + UPDATE articles SET id= id - 1 WHERE id > 8; + --enable_query_log +} + +# Should return 6 rows +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('Database' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; + +# Scenario 3: explicit FTS_DOC_ID column with FTS index +# Now let's test user defined FTS_DOC_ID + +CREATE TABLE articles ( + id int PRIMARY KEY, + FTS_DOC_ID BIGINT UNSIGNED NOT NULL, + title VARCHAR(200), + body TEXT + ) ENGINE=InnoDB; + +CREATE FULLTEXT INDEX idx1 on articles (title, body); + +# Note the FTS_DOC_ID is not fully ordered with primary index +INSERT INTO articles VALUES + (1, 10, 'MySQL Tutorial','DBMS stands for DataBase ...') , + (2, 1, 'How To Use MySQL Well','After you went through a ...'), + (3, 2, 'Optimizing MySQL','In this tutorial we will show ...'), + (4, 11, '1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + (5, 6, 'MySQL vs. YourSQL','In the following database comparison ...'), + (7, 4, 'MySQL Security','When configured properly, MySQL ...'); + +connect(dml, localhost, root,,); +BEGIN; + +# Below we do not depend on the durability of the AUTO_INCREMENT sequence, +# so we can skip the above flush_redo_log trick. +INSERT INTO articles VALUES + (100, 200, 'MySQL Tutorial','DBMS stands for DataBase ...'); + +if ($vers) +{ + --disable_query_log + DELETE FROM articles WHERE id = 100; + INSERT INTO articles VALUES + (100, 200, 'MySQL Tutorial','DBMS stands for DataBase ...'); + --enable_query_log +} + +connect(dml2, localhost, root,,); + +--echo # +--echo # MDEV-19073 FTS row mismatch after crash recovery +--echo # + +CREATE TABLE mdev19073(id SERIAL, title VARCHAR(200), body TEXT, + FULLTEXT(title,body)) ENGINE=InnoDB; +INSERT INTO mdev19073 (title, body) VALUES + ('MySQL Tutorial', 'DBMS stands for Database...'); +CREATE FULLTEXT INDEX idx ON mdev19073(title, body); +CREATE TABLE mdev19073_2 LIKE mdev19073; +if ($have_debug) +{ +--disable_query_log +SET @saved_dbug = @@debug_dbug; +SET DEBUG_DBUG = '+d,fts_instrument_sync_debug'; +--enable_query_log +} +INSERT INTO mdev19073_2 (title, body) VALUES + ('MySQL Tutorial', 'DBMS stands for Database...'); +if ($have_debug) +{ +--disable_query_log +SET DEBUG_DBUG = @saved_dbug; +--enable_query_log +} + +INSERT INTO mdev19073 (title, body) VALUES + ('MariaDB Tutorial', 'DB means Database ...'); +INSERT INTO mdev19073_2 (title, body) VALUES + ('MariaDB Tutorial', 'DB means Database ...'); + +# Should return 2 rows +SELECT * FROM mdev19073 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +SELECT * FROM mdev19073_2 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); + +connection default; +--source include/restart_mysqld.inc +disconnect dml; +disconnect dml2; + +# This would re-initialize the FTS index and do the re-tokenization +# of above records +INSERT INTO articles VALUES (8, 12, 'MySQL Tutorial','DBMS stands for DataBase ...'); + +SELECT * FROM articles WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; + +# Should return 2 rows +SELECT * FROM mdev19073 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +SELECT * FROM mdev19073_2 WHERE MATCH (title, body) +AGAINST ('Database' IN NATURAL LANGUAGE MODE); +DROP TABLE mdev19073, mdev19073_2; + +let $shutdown_timeout=; + +--echo # +--echo # MDEV-28706 Redundant InnoDB table fails during alter +--echo # + +SET @@global.innodb_file_per_table = 0; +CREATE TABLE t1 ( + col_int INTEGER, col_text TEXT, + col_text_1 TEXT +) ENGINE = InnoDB ROW_FORMAT = Redundant ; +ALTER TABLE t1 ADD FULLTEXT KEY `ftidx` ( col_text ) ; +INSERT INTO t1 VALUES ( 1255, "mariadb", "InnoDB"); +--source include/restart_mysqld.inc +ALTER TABLE t1 ADD FULLTEXT(col_text_1); +DROP TABLE t1; + +SELECT * FROM information_schema.innodb_sys_tables WHERE name LIKE 'test/%'; diff --git a/mysql-test/suite/innodb_fts/t/create.opt b/mysql-test/suite/innodb_fts/t/create.opt new file mode 100644 index 00000000..3ad568c8 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/create.opt @@ -0,0 +1 @@ +--loose-innodb-sys-columns diff --git a/mysql-test/suite/innodb_fts/t/create.test b/mysql-test/suite/innodb_fts/t/create.test new file mode 100644 index 00000000..e6a7e993 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/create.test @@ -0,0 +1,138 @@ +--source include/have_innodb.inc +--source include/maybe_versioning.inc +SET NAMES utf8mb4; + +--echo # +--echo # MDEV-11233 CREATE FULLTEXT INDEX with a token +--echo # longer than 127 bytes crashes server +--echo # + +# This bug is the result of merging the Oracle MySQL follow-up fix +# BUG#22963169 MYSQL CRASHES ON CREATE FULLTEXT INDEX +# without merging a fix of Bug#79475 Insert a token of 84 4-bytes +# chars into fts index causes server crash. + +# Oracle did not publish tests for either of the above MySQL bugs. +# The tests below were developed for MariaDB Server. +# The maximum length of a fulltext-indexed word is 84 characters. + +CREATE TABLE t(t TEXT CHARACTER SET utf8mb3) ENGINE=InnoDB; +INSERT INTO t SET t=REPEAT(CONCAT(REPEAT(_utf8mb3 0xE0B987, 4), REPEAT(_utf8mb3 0xE0B989, 5)), 5); +INSERT INTO t SET t=REPEAT(_utf8 0xefbc90,84); +INSERT INTO t SET t=REPEAT('befor',17); # too long, will not be indexed +INSERT INTO t SET t='BeforeTheIndexCreation'; +CREATE FULLTEXT INDEX ft ON t(t); +INSERT INTO t SET t='this was inserted after creating the index'; +INSERT INTO t SET t=REPEAT(_utf8 0xefbc91,84); +INSERT INTO t SET t=REPEAT('after',17); # too long, will not be indexed +INSERT INTO t SET t=REPEAT(_utf8mb3 0xe794b2e9aaa8e69687, 15); +--echo # The data below is not 3-byte UTF-8, but 4-byte chars. +INSERT IGNORE INTO t SET t=REPEAT(_utf8mb4 0xf09f9695, 84); +INSERT IGNORE INTO t SET t=REPEAT(_utf8mb4 0xf09f9696, 85); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST +(REPEAT(CONCAT(REPEAT(_utf8mb3 0xE0B987, 4), REPEAT(_utf8mb3 0xE0B989, 5)), 5)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST ('BeforeTheIndexCreation'); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT('befor',17)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST ('after'); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT('after',17)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc90, 83)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc90, 84)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc90, 85)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc91, 83)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc91, 84)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc91, 85)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9695, 83)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9695, 84)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9696, 84)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9696, 85)); +SELECT * FROM t; + +# The column length should be 252 bytes (84 characters * 3 bytes/character). +SELECT len,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS where name='word' GROUP BY len; +DROP TABLE t; + +CREATE TABLE t(t TEXT CHARACTER SET utf8mb4) ENGINE=InnoDB; +INSERT INTO t SET t=REPEAT(_utf8mb3 0xe794b2e9aaa8e69687, 15); +INSERT INTO t SET t=REPEAT(_utf8 0xefbc90,84); +INSERT INTO t SET t=REPEAT('befor',17); # too long, will not be indexed +INSERT INTO t SET t='BeforeTheIndexCreation'; +CREATE FULLTEXT INDEX ft ON t(t); +INSERT INTO t SET t='this was inserted after creating the index'; +INSERT INTO t SET t=REPEAT(_utf8 0xefbc91,84); +INSERT INTO t SET t=REPEAT('after',17); # too long, will not be indexed +INSERT INTO t SET t=REPEAT(concat(repeat(_utf8mb3 0xE0B987, 4), repeat(_utf8mb3 0xE0B989, 5)), 5); +INSERT INTO t SET t=REPEAT(_utf8mb4 0xf09f9695, 84); +--echo # The token below exceeds the 84-character limit. +INSERT INTO t SET t=REPEAT(_utf8mb4 0xf09f9696, 85); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb3 0xe794b2e9aaa8e69687, 15)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST ('BeforeTheIndexCreation'); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT('befor',17)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST ('after'); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT('after',17)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc90, 83)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc90, 84)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc90, 85)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc91, 83)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc91, 84)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8 0xefbc91, 85)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9695, 83)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9695, 84)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9696, 84)); +SELECT COUNT(*) FROM t WHERE MATCH t AGAINST (REPEAT(_utf8mb4 0xf09f9696, 85)); +SELECT * FROM t; + +# The column length should be 336 bytes (84 characters * 4 bytes/character). +SELECT len,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS where name='word' GROUP BY len; +DROP TABLE t; + +CREATE TABLE t(t TEXT CHARACTER SET latin1, FULLTEXT INDEX(t)) +ENGINE=InnoDB; + +# The column length should be 84 bytes (84 characters * 1 byte/character). +SELECT len,COUNT(*) FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS where name='word' GROUP BY len; +DROP TABLE t; + +--echo # +--echo # MDEV-17923 Assertion memcmp(field, field_ref_zero, 7) failed in +--echo # trx_undo_page_report_modify upon optimizing table +--echo # under innodb_optimize_fulltext_only +--echo # + +CREATE TABLE t1 (f1 TEXT, f2 TEXT, FULLTEXT KEY (f2)) ENGINE=InnoDB; +INSERT INTO t1 (f1) VALUES ('foo'),('bar'); +DELETE FROM t1 LIMIT 1; +ALTER TABLE t1 ADD FULLTEXT KEY (f1); +SET @optimize_fulltext.save= @@innodb_optimize_fulltext_only; +SET GLOBAL innodb_optimize_fulltext_only= 1; +OPTIMIZE TABLE t1; +DROP TABLE t1; +SET GLOBAL innodb_optimize_fulltext_only= @optimize_fulltext.save; + +--echo # +--echo # MDEV-24403 Segfault on CREATE TABLE with explicit FTS_DOC_ID_INDEX by multiple fields +--echo # +--error ER_INNODB_FT_WRONG_DOCID_INDEX +create table t1 ( + f1 int, f2 text, + FTS_DOC_ID bigint unsigned not null, + unique key FTS_DOC_ID_INDEX(FTS_DOC_ID, f1), + fulltext (f2)) +engine=innodb; + +--echo # +--echo # MDEV-26938 Support descending indexes internally in InnoDB +--echo # + +--error ER_INNODB_FT_WRONG_DOCID_INDEX +CREATE TABLE t1(a INT PRIMARY KEY, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL, + UNIQUE KEY FTS_DOC_ID_INDEX(FTS_DOC_ID DESC), FULLTEXT(b)) +ENGINE=InnoDB; + +CREATE TABLE t1(a INT PRIMARY KEY, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL, + UNIQUE KEY FTS_DOC_ID_INDEX(FTS_DOC_ID DESC)) ENGINE=InnoDB; +SHOW CREATE TABLE t1; +--error ER_INNODB_FT_WRONG_DOCID_INDEX +ALTER TABLE t1 ADD FULLTEXT INDEX(b), ALGORITHM=INPLACE; +--error ER_INNODB_FT_WRONG_DOCID_INDEX +ALTER TABLE t1 ADD FULLTEXT INDEX(b), ALGORITHM=COPY; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/ft_result_cache_limit.test b/mysql-test/suite/innodb_fts/t/ft_result_cache_limit.test new file mode 100644 index 00000000..84254a18 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/ft_result_cache_limit.test @@ -0,0 +1,57 @@ +--echo # +--echo # Bug 1634932: Assertion failure in thread x in +--echo # file fts0que.cc +--echo # + +--source include/have_innodb.inc +--source include/have_debug.inc + +SET @saved_innodb_ft_result_cache_limit= @@global.innodb_ft_result_cache_limit; + +CREATE TABLE `t1` ( + `FTS_DOC_ID` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + `text_content` MEDIUMTEXT, PRIMARY KEY (`FTS_DOC_ID`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +CREATE UNIQUE INDEX FTS_DOC_ID_INDEX ON t1(FTS_DOC_ID); + +SET autocommit=0; + +DELIMITER //; +CREATE PROCEDURE populate_t1() +BEGIN + DECLARE i INT DEFAULT 1; + WHILE (i <= 250) DO + INSERT INTO t1 (text_content) VALUES ("some_text_1234 aaa"); + SET i = i + 1; + END WHILE; +END// + +DELIMITER ;// + +CALL populate_t1; +SET autocommit=1; + +SET SESSION debug="+d,fts_instrument_result_cache_limit"; + +ALTER TABLE t1 ADD FULLTEXT INDEX `text_content_idx` (`text_content`); + +# HA_ERR_FTS_EXCEED_RESULT_CACHE_LIMIT = 188 +--error 128 +SELECT FTS_DOC_ID, text_content +FROM t1 +WHERE MATCH text_content AGAINST ('+some_text_1234' IN BOOLEAN MODE); + +--error 128 +UPDATE t1 +SET text_content='some_text_12345' +where MATCH text_content AGAINST ('+some_text_1234' IN BOOLEAN MODE); + +--error 128 +DELETE FROM t1 +WHERE MATCH text_content AGAINST ('+some_text_1234' IN BOOLEAN MODE); + +SET GLOBAL innodb_ft_result_cache_limit = @saved_innodb_ft_result_cache_limit; + +DROP TABLE t1; +DROP PROCEDURE populate_t1; diff --git a/mysql-test/suite/innodb_fts/t/fts_kill_query.test b/mysql-test/suite/innodb_fts/t/fts_kill_query.test new file mode 100644 index 00000000..3dda29a3 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/fts_kill_query.test @@ -0,0 +1,30 @@ +--source include/have_innodb.inc + +CREATE TABLE t1 (a VARCHAR(7), b text, FULLTEXT KEY idx (a,b)) ENGINE=InnoDB; + +--disable_query_log +BEGIN; +let $n=1000; +while ($n) { +INSERT INTO t1 VALUES('foo bar','boo far'); +dec $n; +} +--enable_query_log +COMMIT; + +let $id = `SELECT CONNECTION_ID()`; +send SELECT COUNT(*) FROM t1 +WHERE MATCH (a,b) AGAINST ('foo bar' IN BOOLEAN MODE); + +connect (con1,localhost,root,,); +let $ignore= `SELECT @id := $ID`; +KILL QUERY @id; +disconnect con1; + +connection default; +# The following would return a result set if the KILL was not fast enough. +--disable_result_log +--error 0,ER_QUERY_INTERRUPTED,HA_ERR_ABORTED_BY_USER +reap; +--enable_result_log +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/fulltext.test b/mysql-test/suite/innodb_fts/t/fulltext.test new file mode 100644 index 00000000..3ddc1856 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/fulltext.test @@ -0,0 +1,805 @@ +# +# Test of fulltext index +# + +--source include/have_innodb.inc + +CREATE TABLE t1 (a VARCHAR(200), b TEXT, FULLTEXT (a,b)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('MySQL has now support', 'for full-text search'), + ('Full-text indexes', 'are called collections'), + ('Only MyISAM tables','support collections'), + ('Function MATCH ... AGAINST()','is used to do a search'), + ('Full-text search in MySQL', 'implements vector space model'); +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log +SHOW INDEX FROM t1; + +# nl search + +select * from t1 where MATCH(a,b) AGAINST ("collections"); +explain extended select * from t1 where MATCH(a,b) AGAINST ("collections"); +select * from t1 where MATCH(a,b) AGAINST ("indexes"); +select * from t1 where MATCH(a,b) AGAINST ("indexes collections"); +select * from t1 where MATCH(a,b) AGAINST ("only"); + +# query expansion + +select * from t1 where MATCH(a,b) AGAINST ("collections" WITH QUERY EXPANSION); +select * from t1 where MATCH(a,b) AGAINST ("indexes" WITH QUERY EXPANSION); +select * from t1 where MATCH(a,b) AGAINST ("indexes collections" WITH QUERY EXPANSION); + +# IN NATURAL LANGUAGE MODE +select * from t1 where MATCH(a,b) AGAINST ("indexes" IN NATURAL LANGUAGE MODE); +select * from t1 where MATCH(a,b) AGAINST ("indexes" IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION); +--error 1064 +select * from t1 where MATCH(a,b) AGAINST ("indexes" IN BOOLEAN MODE WITH QUERY EXPANSION); + +# add_ft_keys() tests + +explain select * from t1 where MATCH(a,b) AGAINST ("collections"); +explain select * from t1 where MATCH(a,b) AGAINST ("collections")>0; +explain select * from t1 where MATCH(a,b) AGAINST ("collections")>1; +explain select * from t1 where MATCH(a,b) AGAINST ("collections")>=0; +explain select * from t1 where MATCH(a,b) AGAINST ("collections")>=1; +explain select * from t1 where 0<MATCH(a,b) AGAINST ("collections"); +explain select * from t1 where 1<MATCH(a,b) AGAINST ("collections"); +explain select * from t1 where 0<=MATCH(a,b) AGAINST ("collections"); +explain select * from t1 where 1<=MATCH(a,b) AGAINST ("collections"); +explain select * from t1 where MATCH(a,b) AGAINST ("collections")>0 and a like '%ll%'; + +# boolean search + +select * from t1 where MATCH(a,b) AGAINST("support -collections" IN BOOLEAN MODE); +explain extended select * from t1 where MATCH(a,b) AGAINST("support -collections" IN BOOLEAN MODE); +select * from t1 where MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE); +select * from t1 where MATCH(a,b) AGAINST("support +collections" IN BOOLEAN MODE); +select * from t1 where MATCH(a,b) AGAINST("sear*" IN BOOLEAN MODE); +select * from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +select * from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +select * from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +select * from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +select *, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; +select *, MATCH(a,b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; + +select * from t1 where MATCH a,b AGAINST ("+call* +coll*" IN BOOLEAN MODE); + +select * from t1 where MATCH a,b AGAINST ('"support now"' IN BOOLEAN MODE); +select * from t1 where MATCH a,b AGAINST ('"Now sUPPort"' IN BOOLEAN MODE); +select * from t1 where MATCH a,b AGAINST ('"now support"' IN BOOLEAN MODE); +select * from t1 where MATCH a,b AGAINST ('"text search" "now support"' IN BOOLEAN MODE); +select * from t1 where MATCH a,b AGAINST ('"text search" -"now support"' IN BOOLEAN MODE); +select * from t1 where MATCH a,b AGAINST ('"text search" +"now support"' IN BOOLEAN MODE); +select * from t1 where MATCH a,b AGAINST ('"text i"' IN BOOLEAN MODE); +select * from t1 where MATCH a,b AGAINST ('"xt indexes"' IN BOOLEAN MODE); + +select * from t1 where MATCH a,b AGAINST ('+(support collections) +foobar*' IN BOOLEAN MODE); +select * from t1 where MATCH a,b AGAINST ('+(+(support collections)) +foobar*' IN BOOLEAN MODE); +select * from t1 where MATCH a,b AGAINST ('+collections -supp* -foobar*' IN BOOLEAN MODE); + +# bug#2708, bug#3870 crash + +select * from t1 where MATCH a,b AGAINST('"space model' IN BOOLEAN MODE); + +# INNODB_FTS: No FTS index on column a or b. InnoDB do now support +# FT type search when there is no FTS INDEX + +# select * from t1 where MATCH a AGAINST ("search" IN BOOLEAN MODE); +# select * from t1 where MATCH b AGAINST ("sear*" IN BOOLEAN MODE); + +# UNION of fulltext's +#select * from t1 where MATCH(a,b) AGAINST ("collections") UNION ALL select * from t1 where MATCH(a,b) AGAINST ("indexes"); + +#update/delete with fulltext index + +delete from t1 where a like "MySQL%"; +update t1 set a='some test foobar' where MATCH a,b AGAINST ('model'); +delete from t1 where MATCH(a,b) AGAINST ("indexes"); +select * from t1; +drop table t1; + +# +# why to scan strings for trunc* +# + +create table t1 (a varchar(200) not null, fulltext (a)) engine = innodb; +insert t1 values ("aaa10 bbb20"), ("aaa20 bbb15"), ("aaa30 bbb10"); +select * from t1 where match a against ("+aaa* +bbb*" in boolean mode); +select * from t1 where match a against ("+aaa* +bbb1*" in boolean mode); +select * from t1 where match a against ("+aaa* +ccc*" in boolean mode); +select * from t1 where match a against ("+aaa10 +(bbb*)" in boolean mode); + +# FTS_INNODB: INVESTIGATE +select * from t1 where match a against ("+(+aaa* +bbb1*)" in boolean mode); +select * from t1 where match a against ("(+aaa* +bbb1*)" in boolean mode); +drop table t1; + +# +# Check bug reported by Matthias Urlichs +# + +CREATE TABLE t1 ( + id int(11), + ticket int(11), + KEY ti (id), + KEY tit (ticket) +) ENGINE = InnoDB; +INSERT INTO t1 VALUES (2,3),(1,2); + +CREATE TABLE t2 ( + ticket int(11), + inhalt text, + KEY tig (ticket), + fulltext index tix (inhalt) +) ENGINE = InnoDB; +INSERT INTO t2 VALUES (1,'foo'),(2,'bar'),(3,'foobar'); + +#select t1.id FROM t2 as ttxt,t1,t1 as ticket2 +#WHERE ticket2.id = ttxt.ticket AND t1.id = ticket2.ticket and +#match(ttxt.inhalt) against ('foobar'); + +# In the following query MySQL didn't use the fulltext index +#select ticket2.id FROM t2 as ttxt,t2 INNER JOIN t1 as ticket2 ON +#ticket2.id = t2.ticket +#WHERE ticket2.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar'); + +INSERT INTO t1 VALUES (3,3); +-- disable_result_log +ANALYZE TABLE t1; +ANALYZE TABLE t2; +-- enable_result_log +select ticket2.id FROM t2 as ttxt,t2 +INNER JOIN t1 as ticket2 ON ticket2.id = t2.ticket +WHERE ticket2.id = ticket2.ticket and + match(ttxt.inhalt) against ('foobar'); + +# Check that we get 'fulltext' index in SHOW CREATE + +show keys from t2; +show create table t2; + +# check for bug reported by Stephan Skusa + +select * from t2 where MATCH inhalt AGAINST (NULL); + +# MATCH in HAVING (pretty useless, but still it should work) + +select * from t2 where MATCH inhalt AGAINST ('foobar'); + +# INNODB_FTS: INVESTIGATE +select * from t2 having MATCH inhalt AGAINST ('foobar'); + +# +# check of fulltext errors +# + +--error 1283 +CREATE TABLE t3 (t int(11),i text,fulltext tix (t,i)); +--error 1283 +CREATE TABLE t3 (t int(11),i text, + j varchar(200) CHARACTER SET latin2, + fulltext tix (i,j)); + +CREATE TABLE t3 ( + ticket int(11), + inhalt text, + KEY tig (ticket), + fulltext index tix (inhalt) +) ENGINE = InnoDB; + +--error 1210 +select * from t2 where MATCH inhalt AGAINST (t2.inhalt); +--error 1191 +select * from t2 where MATCH ticket AGAINST ('foobar'); +--error 1210 +select * from t2,t3 where MATCH (t2.inhalt,t3.inhalt) AGAINST ('foobar'); + +drop table t1,t2,t3; + +# +# three more bugtests +# + +CREATE TABLE t1 ( + id int(11) auto_increment, + title varchar(100) default '', + PRIMARY KEY (id), + KEY ind5 (title) +) ENGINE = InnoDB; + +CREATE FULLTEXT INDEX ft1 ON t1(title); +insert into t1 (title) values ('this is a test'); +select * from t1 where match title against ('test' in boolean mode); +update t1 set title='this is A test' where id=1; + +check table t1; +update t1 set title='this test once revealed a bug' where id=1; +select * from t1; +update t1 set title=NULL where id=1; + +drop table t1; + +# one more bug - const_table related + +CREATE TABLE t1 (a int(11), b text, FULLTEXT KEY (b)) ENGINE = InnoDB; +insert into t1 values (1,"I wonder why the fulltext index doesnt work?"); +SELECT * from t1 where MATCH (b) AGAINST ('apples'); + +insert into t1 values (2,"fullaaa fullzzz"); +select * from t1 where match b against ('full*' in boolean mode); + +drop table t1; + +CREATE TABLE t1 ( id int(11) NOT NULL auto_increment primary key, mytext text NOT NULL, FULLTEXT KEY mytext (mytext)) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,'my small mouse'),(2,'la-la-la'),(3,'It is so funny'),(4,'MySQL Tutorial'); +select 8 from t1; +drop table t1; + +# +# Check bug reported by Julian Ladisch +# ERROR 1030: Got error 127 from table handler +# + +create table t1 (a text, fulltext key (a)) ENGINE = InnoDB; +insert into t1 values ('aaaa'); + +# INNODB_FTS: InnoDB do not support "repair" command +# repair table t1; +select * from t1 where match (a) against ('aaaa'); +drop table t1; + +# +# bug #283 by jocelyn fournier <joc@presence-pc.com> +# FULLTEXT index on a TEXT filed converted to a CHAR field doesn't work anymore +# + +create table t1 ( ref_mag text not null, fulltext (ref_mag)) ENGINE = InnoDB; +insert into t1 values ('test'); +select ref_mag from t1 where match ref_mag against ('+test' in boolean mode); +alter table t1 change ref_mag ref_mag char (255) not null; +select ref_mag from t1 where match ref_mag against ('+test' in boolean mode); +drop table t1; + +# +# bug #942: JOIN +# NOTE: Not related to FTS, no FTS index created + +create table t1 (t1_id int(11) primary key, name varchar(32)) ENGINE = InnoDB; +insert into t1 values (1, 'data1'); +insert into t1 values (2, 'data2'); + +create table t2 (t2_id int(11) primary key, t1_id int(11), name varchar(32)) ENGINE = InnoDB; +insert into t2 values (1, 1, 'xxfoo'); +insert into t2 values (2, 1, 'xxbar'); +insert into t2 values (3, 1, 'xxbuz'); +# INNODB_FTS: InnoDB do not support MATCH expressions with arguments from +# different tables +--error ER_WRONG_ARGUMENTS +select * from t1 join t2 using(`t1_id`) where match (t1.name, t2.name) against('xxfoo' in boolean mode); + +# +# Bug #7858: bug with many short (< ft_min_word_len) words in boolean search +# +# INNODB_FTS: Note there is no fulltext index on table. InnoDB do not support +# Fulltext search in such case +--error ER_FT_MATCHING_KEY_NOT_FOUND +select * from t2 where match name against ('*a*b*c*d*e*f*' in boolean mode); +drop table t1,t2; + +# +# bug with repair-by-sort and incorrect records estimation +# + +create table t1 (a text, fulltext key (a)) ENGINE = InnoDB; +insert into t1 select "xxxx yyyy zzzz"; +drop table t1; + +# +# UTF8 +# INNODB_FTS: Charset Support (FIX) +SET NAMES latin1; +CREATE TABLE t1 (t text character set utf8 not null, fulltext(t)) ENGINE = InnoDB; +INSERT t1 VALUES ('Mit freundlichem Grüß'), ('aus Osnabrück'); +SET NAMES koi8r; +INSERT t1 VALUES ("üÔÏ ÍÙ - ÏÐÉÌËÉ"),("ïÔÌÅÚØ, ÇÎÉÄÁ!"), + ("îÅ ×ÌÅÚÁÊ, ÕÂØÅÔ!"),("É ÂÕÄÅÔ ÐÒÁ×!"); +SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('ïðéìëé'); +#SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('ðÒá*' IN BOOLEAN MODE); +#SELECT * FROM t1 WHERE MATCH t AGAINST ('ÜÔÏ' IN BOOLEAN MODE); +#SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); +#SET NAMES latin1; +#SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); +#SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrueck'); +#SELECT t, collation(t),FORMAT(MATCH t AGAINST ('Osnabruck'),6) FROM t1 WHERE MATCH t AGAINST ('Osnabruck'); +#alter table t1 modify t text character set latin1 collate latin1_german2_ci not null; +#alter table t1 modify t varchar(200) collate latin1_german2_ci not null; +#SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrück'); +#SELECT t, collation(t) FROM t1 WHERE MATCH t AGAINST ('Osnabrueck'); +DROP TABLE t1; + +# +# bug#3964 +# + +CREATE TABLE t1 (s varchar(255), FULLTEXT (s)) ENGINE = InnoDB DEFAULT CHARSET=utf8; +insert into t1 (s) values ('pära para para'),('para para para'); +select * from t1 where match(s) against('para' in boolean mode); +select * from t1 where match(s) against('par*' in boolean mode); +DROP TABLE t1; + +# +# icc -ip bug (ip = interprocedural optimization) +# bug#5528 +# +CREATE TABLE t1 (h text, FULLTEXT (h)) ENGINE = InnoDB; +INSERT INTO t1 VALUES ('Jesses Hasse Ling and his syncopators of Swing'); + +# INNODB_FTS: InnoDB do not support "repair" command +# REPAIR TABLE t1; +select count(*) from t1; +drop table t1; + +# +# testing out of bounds memory access in ft_nlq_find_relevance() +# (bug#8522); visible in valgrind. +# +CREATE TABLE t1 ( a TEXT, FULLTEXT (a) ) ENGINE = InnoDB; +INSERT INTO t1 VALUES ('testing ft_nlq_find_relevance'); +SELECT MATCH(a) AGAINST ('nosuchword') FROM t1; +DROP TABLE t1; +# +# bug#6784 +# mi_flush_bulk_insert (on dup key error in mi_write) +# was mangling info->dupp_key_pos +# + +create table t1 (a int primary key, b text, fulltext(b)) ENGINE = InnoDB; +create table t2 (a int, b text) ENGINE = InnoDB; +insert t1 values (1, "aaaa"), (2, "bbbb"); +insert t2 values (10, "aaaa"), (2, "cccc"); +replace t1 select * from t2; +drop table t1, t2; + +# +# bug#8351 +# +# INNODB_FTS: Charset Support +CREATE TABLE t1 (t VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci, FULLTEXT (t)) ENGINE = InnoDB; +SET NAMES latin1; +INSERT INTO t1 VALUES('Mit freundlichem Grüß aus Osnabrück'); +SELECT COUNT(*) FROM t1 WHERE MATCH(t) AGAINST ('"osnabrück"' IN BOOLEAN MODE); +DROP TABLE t1; + +# +# BUG#11684 - repair crashes mysql when table has fulltext index +# + +CREATE TABLE t1 (a VARCHAR(30), FULLTEXT(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); + +# INNODB_FTS: InnoDB do not support repair +#SET myisam_repair_threads=2; +#REPAIR TABLE t1; +#SET myisam_repair_threads=@@global.myisam_repair_threads; + +# +# BUG#5686 - #1034 - Incorrect key file for table - only utf8 +# +INSERT INTO t1 VALUES('testword\'\''); +SELECT a FROM t1 WHERE MATCH a AGAINST('testword' IN BOOLEAN MODE); +SELECT a FROM t1 WHERE MATCH a AGAINST('testword\'\'' IN BOOLEAN MODE); + +# +# BUG#14194: Problem with fulltext boolean search and apostrophe +# +# INNODB_FTS: Add "apostrophe" support +INSERT INTO t1 VALUES('test\'s'); +SELECT a FROM t1 WHERE MATCH a AGAINST('test' IN BOOLEAN MODE); +DROP TABLE t1; + +# +# BUG#13835: max key length is 1000 bytes when trying to create +# a fulltext index +# +CREATE TABLE t1 (a VARCHAR(10000), FULLTEXT(a)) ENGINE = InnoDB; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +# +# BUG#14496: Crash or strange results with prepared statement, +# MATCH and FULLTEXT +# +CREATE TABLE t1 (a TEXT, FULLTEXT KEY(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('test'),('test1'),('test'); +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log +PREPARE stmt from "SELECT a, FORMAT(MATCH(a) AGAINST('test1 test'),6) FROM t1 WHERE MATCH(a) AGAINST('test1 test')"; + +EXECUTE stmt; +EXECUTE stmt; +DEALLOCATE PREPARE stmt; +DROP TABLE t1; + +# +# BUG#25951 - ignore/use index does not work with fulltext +# +CREATE TABLE t1 (a VARCHAR(255), FULLTEXT(a)) ENGINE = InnoDB; +SELECT * FROM t1 IGNORE INDEX(a) WHERE MATCH(a) AGAINST('test'); +# INNODB_FTS: InnoDB do have have this option (disable keys) +# ALTER TABLE t1 DISABLE KEYS; +# --error 1191 +SELECT * FROM t1 WHERE MATCH(a) AGAINST('test'); +DROP TABLE t1; + +# +# BUG#11392 - fulltext search bug +# +CREATE TABLE t1(a TEXT, fulltext(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES(' aaaaa aaaa'); +SELECT * FROM t1 WHERE MATCH(a) AGAINST ('"aaaa"' IN BOOLEAN MODE); +DROP TABLE t1; + +# +# BUG#29445 - match ... against () never returns +# +CREATE TABLE t1(a VARCHAR(20), FULLTEXT(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('Offside'),('City Of God'); + +SELECT a FROM t1 WHERE MATCH a AGAINST ('+city of*' IN BOOLEAN MODE); +SELECT a FROM t1 WHERE MATCH a AGAINST ('+city (of*)' IN BOOLEAN MODE); +SELECT a FROM t1 WHERE MATCH a AGAINST ('+city* of*' IN BOOLEAN MODE); +DROP TABLE t1; + +# End of 4.1 tests + +# +# bug#34374 - mysql generates incorrect warning +# +create table t1(a text,b date,fulltext index(a)) ENGINE = InnoDB; +insert into t1 set a='water',b='2008-08-04'; +select 1 from t1 where match(a) against ('water' in boolean mode) and b>='2008-08-01'; +drop table t1; +show warnings; + +# +# BUG#38842 - Fix for 25951 seems incorrect +# +CREATE TABLE t1 (a VARCHAR(255), b INT, FULLTEXT(a), KEY(b)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('test', 1),('test', 1),('test', 1),('test', 1), + ('test', 1),('test', 2),('test', 3),('test', 4); + +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log +EXPLAIN SELECT * FROM t1 +WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; + +EXPLAIN SELECT * FROM t1 USE INDEX(a) +WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; + +EXPLAIN SELECT * FROM t1 FORCE INDEX(a) +WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; + +--error ER_FT_MATCHING_KEY_NOT_FOUND +EXPLAIN SELECT * FROM t1 IGNORE INDEX(a) +WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; + +--error ER_FT_MATCHING_KEY_NOT_FOUND +EXPLAIN SELECT * FROM t1 USE INDEX(b) +WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; + +--error ER_FT_MATCHING_KEY_NOT_FOUND +EXPLAIN SELECT * FROM t1 FORCE INDEX(b) +WHERE MATCH(a) AGAINST('test' IN BOOLEAN MODE) AND b=1; + +DROP TABLE t1; + +# +# BUG#37245 - Full text search problem +# +CREATE TABLE t1(a CHAR(10), fulltext(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('aaa15'); + +SELECT MATCH(a) AGAINST('aaa1* aaa14 aaa16' IN BOOLEAN MODE) FROM t1; +SELECT MATCH(a) AGAINST('aaa1* aaa14 aaa15 aaa16' IN BOOLEAN MODE) FROM t1; +DROP TABLE t1; + +# +# BUG#36737 - having + full text operator crashes mysql +# +CREATE TABLE t1(a TEXT) ENGINE = InnoDB; +--error ER_WRONG_ARGUMENTS +SELECT GROUP_CONCAT(a) AS st FROM t1 HAVING MATCH(st) AGAINST('test' IN BOOLEAN MODE); +DROP TABLE t1; + +# +# BUG#42907 - Multi-term boolean fulltext query containing a single +# quote fails in 5.1.x +# +CREATE TABLE t1(a VARCHAR(64), FULLTEXT(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('awrd bwrd cwrd'),('awrd bwrd cwrd'),('awrd bwrd cwrd'); +SELECT * FROM t1 WHERE MATCH(a) AGAINST('+awrd bwrd* +cwrd*' IN BOOLEAN MODE); +DROP TABLE t1; + +# +# BUG#37740 Server crashes on execute statement with full text search and match against +# +CREATE TABLE t1 (col text, FULLTEXT KEY full_text (col)) ENGINE = InnoDB; + +PREPARE s FROM + "SELECT MATCH (col) AGAINST('findme') FROM t1 ORDER BY MATCH (col) AGAINST('findme')" + ; + +EXECUTE s; +DEALLOCATE PREPARE s; +DROP TABLE t1; + + +--echo # +--echo # Bug #49250 : spatial btree index corruption and crash +--echo # Part two : fulltext syntax check +--echo # + +--error ER_PARSE_ERROR +CREATE TABLE t1(col1 TEXT, + FULLTEXT INDEX USING BTREE (col1)); +CREATE TABLE t2(col1 TEXT) ENGINE = InnoDB; +--error ER_PARSE_ERROR +CREATE FULLTEXT INDEX USING BTREE ON t2(col); +--error ER_PARSE_ERROR +ALTER TABLE t2 ADD FULLTEXT INDEX USING BTREE (col1); + +DROP TABLE t2; + + +--echo End of 5.0 tests + + +--echo # +--echo # Bug #47930: MATCH IN BOOLEAN MODE returns too many results +--echo # inside subquery +--echo # + +CREATE TABLE t1 (a int) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1), (2); + +CREATE TABLE t2 (a int, b2 char(10), FULLTEXT KEY b2 (b2)) ENGINE = InnoDB; +INSERT INTO t2 VALUES (1,'Scargill'); + +CREATE TABLE t3 (a int, b int) ENGINE = InnoDB; +INSERT INTO t3 VALUES (1,1), (2,1); + +--echo # t2 should use full text index +EXPLAIN +SELECT count(*) FROM t1 WHERE + not exists( + SELECT 1 FROM t2, t3 + WHERE t3.a=t1.a AND MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE) + ); + +# INNODB_FTS: INVESTIGATE +--echo # should return 0 +SELECT count(*) FROM t1 WHERE + not exists( + SELECT 1 FROM t2, t3 + WHERE t3.a=t1.a AND MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE) + ); + +--error ER_FT_MATCHING_KEY_NOT_FOUND +SELECT count(*) FROM t1 WHERE + not exists( + SELECT 1 FROM t2 IGNORE INDEX (b2), t3 + WHERE t3.a=t1.a AND MATCH(b2) AGAINST('scargill' IN BOOLEAN MODE) + ); + +DROP TABLE t1,t2,t3; + +# +# BUG#50351 - ft_min_word_len=2 Causes query to hang +# +CREATE TABLE t1 (a VARCHAR(4), FULLTEXT(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'), +('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('cwrd'),('awrd'),('cwrd'), +('awrd'); +SELECT COUNT(*) FROM t1 WHERE MATCH(a) AGAINST("+awrd bwrd* +cwrd*" IN BOOLEAN MODE); +DROP TABLE t1; + +--echo # +--echo # Bug #49445: Assertion failed: 0, file .\item_row.cc, line 55 with +--echo # fulltext search and row op +--echo # + +CREATE TABLE t1(a CHAR(1),FULLTEXT(a)) ENGINE = InnoDB; +SELECT 1 FROM t1 WHERE MATCH(a) AGAINST ('') AND ROW(a,a) > ROW(1,1); +DROP TABLE t1; + +--echo # +--echo # BUG#51866 - crash with repair by sort and fulltext keys +--echo # +CREATE TABLE t1(a CHAR(4), FULLTEXT(a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES('aaaa'); +# INNODB_FTS: Do not support "set myisam_sort_buffer" commands +#SET myisam_sort_buffer_size=4; +#REPAIR TABLE t1; +#SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size; +DROP TABLE t1; + +--echo # +--echo # Bug#54484 explain + prepared statement: crash and Got error -1 from storage engine +--echo # + +CREATE TABLE t1(f1 VARCHAR(6) NOT NULL, FULLTEXT KEY(f1), UNIQUE(f1)) ENGINE = InnoDB; +INSERT INTO t1 VALUES ('test'); +--disable_warnings +SELECT 1 FROM t1 WHERE 1 > + ALL((SELECT 1 FROM t1 JOIN t1 a + ON (MATCH(t1.f1) against ("")) + WHERE t1.f1 GROUP BY t1.f1)) xor f1; + +PREPARE stmt FROM +'SELECT 1 FROM t1 WHERE 1 > + ALL((SELECT 1 FROM t1 RIGHT OUTER JOIN t1 a + ON (MATCH(t1.f1) against ("")) + WHERE t1.f1 GROUP BY t1.f1)) xor f1'; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +PREPARE stmt FROM +'SELECT 1 FROM t1 WHERE 1 > + ALL((SELECT 1 FROM t1 JOIN t1 a + ON (MATCH(t1.f1) against ("")) + WHERE t1.f1 GROUP BY t1.f1))'; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; +--enable_warnings + +DROP TABLE t1; + +--echo End of 5.1 tests + +# This is an adapted and extended version of an Oracle test for +# Bug#21140111: Explain ... match against: Assertion failed: ret ... +# No bug was repeatable for MariaDB. + +CREATE TABLE z(a INTEGER) engine=innodb; +CREATE TABLE q(b TEXT CHARSET latin1, fulltext(b)) engine=innodb; + +--error ER_PARSE_ERROR +EXPLAIN SELECT 1 FROM q WHERE (SELECT MATCH(b) AGAINST ('*') FROM z); +--error ER_PARSE_ERROR +SELECT 1 FROM q WHERE (SELECT MATCH(b) AGAINST ('*') FROM z); +--error ER_BAD_FIELD_ERROR +EXPLAIN SELECT MATCH(b) AGAINST ('*') FROM z; +--error ER_BAD_FIELD_ERROR +SELECT MATCH(b) AGAINST ('*') FROM z; +--error ER_FT_MATCHING_KEY_NOT_FOUND +EXPLAIN SELECT MATCH(a) AGAINST ('*') FROM z; +--error ER_FT_MATCHING_KEY_NOT_FOUND +SELECT MATCH(a) AGAINST ('*') FROM z; +EXPLAIN SELECT MATCH(b) AGAINST ('*') FROM q; +--error ER_PARSE_ERROR +SELECT MATCH(b) AGAINST ('*') FROM q; + +DROP TABLE z, q; + +create table t ( + FTS_DOC_ID BIGINT UNSIGNED PRIMARY KEY, t TEXT, FULLTEXT KEY (t) +) ENGINE=InnoDB; + +INSERT INTO t values (1, 'foo bar'), (2, 'foo bar'), (3, 'foo'); +let $limit=0; +let $N=6; +while ($N) +{ + eval SELECT * FROM t WHERE MATCH(t) AGAINST ('foo bar' IN BOOLEAN MODE) + LIMIT $limit; + inc $limit; + dec $N; +} + +DROP TABLE t; + +--echo # +--echo # MDEV-25295 Aborted FTS_DOC_ID_INDEX considered as +--echo # existing FTS_DOC_ID_INDEX during DDL +--echo # +SET sql_mode=''; +CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL,title CHAR(1),body TEXT)engine=innodb; +INSERT INTO t1 (FTS_DOC_ID,title,body)VALUES(1,0,0), (1,0,0); +--error ER_DUP_ENTRY +CREATE FULLTEXT INDEX idx1 ON t1 (title,body); +--error ER_DUP_ENTRY +CREATE FULLTEXT INDEX idx1 ON t1 (title,body); +DROP TABLE t1; +SET sql_mode = DEFAULT; + +--echo # +--echo # MDEV-25070 SIGSEGV in fts_create_in_mem_aux_table +--echo # +CREATE TABLE t1 (a CHAR, FULLTEXT KEY(a)) ENGINE=InnoDB; +--disable_warnings +ALTER TABLE t1 DISCARD TABLESPACE; +ALTER TABLE t1 ADD FULLTEXT INDEX (a); +SHOW CREATE TABLE t1; +DROP TABLE t1; +--enable_warnings + +--echo # +--echo # MDEV-25257 SEGV in fts_get_next_doc_id upon some INSERT +--echo # +SET @save = @@global.innodb_file_per_table; +SET @@global.innodb_file_per_table = 0; + +CREATE TABLE t1 ( + col_int INTEGER, col_text TEXT, + col_int_g INTEGER GENERATED ALWAYS AS (col_int) +) ENGINE = InnoDB ROW_FORMAT = Redundant ; +ALTER TABLE t1 ADD FULLTEXT KEY `ftidx` ( col_text ) ; +ALTER TABLE t1 DROP KEY `ftidx` ; +INSERT INTO t1 (col_int, col_text) VALUES ( 1255, NULL); +DROP TABLE t1; +SET @@global.innodb_file_per_table = @save; + +--echo # +--echo # MDEV-20797 FULLTEXT search with apostrophe, +--echo # and mandatory words +--echo # +CREATE TABLE t1(f1 TINYTEXT NOT NULL, FULLTEXT(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES('O''Brien'), ('O Brien'), ('Ö''Brien'); +INSERT INTO t1 VALUES('Brien'), ('O ''Brien'), ('O'' Brien'); +INSERT INTO t1 VALUES('Doh''nuts'); +SELECT * FROM t1 WHERE MATCH (f1) AGAINST ("+O'Brien" IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH (f1) AGAINST ("+Doh'nuts" IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH (f1) AGAINST ("+Ö''Brien" IN BOOLEAN MODE); +DROP TABLE t1; + +--echo # +--echo # MDEV-29058 Assertion `index->type == 32' failed +--echo # in dict_index_build_internal_fts +--echo # +call mtr.add_suppression("InnoDB: Index `f` of table `test`.`t2` is corrupted"); +call mtr.add_suppression("InnoDB: Skip adjustment of root pages for index `f`."); +let $MYSQLD_DATADIR = `SELECT @@datadir`; +CREATE TABLE t1 (f CHAR(8), FULLTEXT KEY (f)) ENGINE=InnoDB; +CREATE TABLE t2 LIKE t1; +ALTER TABLE t2 DISCARD TABLESPACE; +--disable_warnings +FLUSH TABLES t1 FOR EXPORT; +--copy_file $MYSQLD_DATADIR/test/t1.ibd $MYSQLD_DATADIR/test/t2.ibd +--copy_file $MYSQLD_DATADIR/test/t1.cfg $MYSQLD_DATADIR/test/t2.cfg +UNLOCK TABLES; +ALTER TABLE t1 DISCARD TABLESPACE; +ALTER TABLE t2 IMPORT TABLESPACE; +--enable_warnings +DROP TABLE t2, t1; + +--echo # +--echo # MDEV-29778 Having Unique index interference with MATCH +--echo # from a FULLTEXT +--echo # +CREATE TABLE t1(f1 VARCHAR(100), FULLTEXT(f1), + UNIQUE INDEX(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES("test"); +SELECT f1, MATCH(f1) AGAINST ("test" IN BOOLEAN MODE) FROM t1; +DROP TABLE t1; + +--echo # End of 10.3 tests diff --git a/mysql-test/suite/innodb_fts/t/fulltext2.test b/mysql-test/suite/innodb_fts/t/fulltext2.test new file mode 100644 index 00000000..7efd9ade --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/fulltext2.test @@ -0,0 +1,297 @@ +# +# test of new fulltext search features +# + +# +# two-level tree +# + +--source include/have_innodb.inc +--source include/maybe_versioning.inc + +CREATE TABLE t1 ( + i int(10) unsigned not null auto_increment primary key, + a varchar(255) not null, + FULLTEXT KEY (a) +) ENGINE = INNODB; + +# two-level entry, second-level tree with depth 2 +--disable_query_log +let $1=260; +while ($1) +{ + eval insert t1 (a) values ('aaaxxx'); + dec $1; +} + +# two-level entry, second-level tree has only one page +let $1=255; +while ($1) +{ + eval insert t1 (a) values ('aaazzz'); + dec $1; +} + +# one-level entry (entries) +let $1=250; +while ($1) +{ + eval insert t1 (a) values ('aaayyy'); + dec $1; +} +--enable_query_log + +# converting to two-level +# INNODB_FTS: Do not support repair +#repair table t1 quick; +check table t1; +#optimize table t1; # BUG#5327 - mi_sort_index() of 2-level tree +#check table t1; + +select count(*) from t1 where match a against ('aaaxxx'); +select count(*) from t1 where match a against ('aaayyy'); +select count(*) from t1 where match a against ('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz'); +select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode); + +select count(*) from t1 where match a against ('aaax*' in boolean mode); +select count(*) from t1 where match a against ('aaay*' in boolean mode); +select count(*) from t1 where match a against ('aaa*' in boolean mode); + +# mi_write: + +insert t1 (a) values ('aaaxxx'),('aaayyy'); +# call to enlarge_root() below +insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx'); +select count(*) from t1 where match a against ('aaayyy'); +select count(*) from t1 where match a against ('aaazzz'); + +# mi_delete +insert t1 (a) values ('aaaxxx 000000'); +select count(*) from t1 where match a against ('000000'); +delete from t1 where match a against ('000000'); +select count(*) from t1 where match a against ('000000'); +select count(*) from t1 where match a against ('aaaxxx'); +delete from t1 where match a against ('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +# double-check without index +select count(*) from t1 where a = 'aaaxxx'; +select count(*) from t1 where a = 'aaayyy'; +select count(*) from t1 where a = 'aaazzz'; + +# update +insert t1 (a) values ('aaaxxx 000000'); +select count(*) from t1 where match a against ('000000'); +update t1 set a='aaazzz' where match a against ('000000'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +update t1 set a='aaazzz' where a = 'aaaxxx'; +update t1 set a='aaaxxx' where a = 'aaayyy'; +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +select count(*) from t1 where match a against ('aaazzz' in boolean mode); + +drop table t1; + +CREATE TABLE t1 ( + i int(10) unsigned not null auto_increment primary key, + a varchar(255) not null, + FULLTEXT KEY (a) +) ENGINE = INNODB; + +# +# now same as about but w/o repair table +# 2-level tree created by mi_write +# + +# two-level entry, second-level tree with depth 2 +--disable_query_log +let $1=260; +while ($1) +{ + eval insert t1 (a) values ('aaaxxx'); + dec $1; +} +let $1=255; +while ($1) +{ + eval insert t1 (a) values ('aaazzz'); + dec $1; +} +let $1=250; +while ($1) +{ + eval insert t1 (a) values ('aaayyy'); + dec $1; +} +--enable_query_log + +select count(*) from t1 where match a against ('aaaxxx'); +select count(*) from t1 where match a against ('aaayyy'); +select count(*) from t1 where match a against ('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz'); +select count(*) from t1 where match a against ('aaaxxx aaayyy aaazzz' in boolean mode); + +select count(*) from t1 where match a against ('aaax*' in boolean mode); +select count(*) from t1 where match a against ('aaay*' in boolean mode); +select count(*) from t1 where match a against ('aaa*' in boolean mode); + +# mi_write: + +insert t1 (a) values ('aaaxxx'),('aaayyy'); +insert t1 (a) values ('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'),('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx'); +select count(*) from t1 where match a against ('aaayyy'); +select count(*) from t1 where match a against ('aaazzz'); + +# mi_delete +insert t1 (a) values ('aaaxxx 000000'); +select count(*) from t1 where match a against ('000000'); +delete from t1 where match a against ('000000'); +select count(*) from t1 where match a against ('000000'); +select count(*) from t1 where match a against ('aaaxxx'); +delete from t1 where match a against ('aaazzz'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +# double-check without index +select count(*) from t1 where a = 'aaaxxx'; +select count(*) from t1 where a = 'aaayyy'; +select count(*) from t1 where a = 'aaazzz'; + +# update +insert t1 (a) values ('aaaxxx 000000'); +select count(*) from t1 where match a against ('000000'); +update t1 set a='aaazzz' where match a against ('000000'); +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +update t1 set a='aaazzz' where a = 'aaaxxx'; +update t1 set a='aaaxxx' where a = 'aaayyy'; +select count(*) from t1 where match a against ('aaaxxx' in boolean mode); +select count(*) from t1 where match a against ('aaayyy' in boolean mode); +select count(*) from t1 where match a against ('aaazzz' in boolean mode); +drop table t1; + +# +# BUG#11336 +# +# for uca collation isalnum and strnncollsp don't agree on whether +# 0xC2A0 is a space (strnncollsp is right, isalnum is wrong). +# +# they still don't, the bug was fixed by avoiding strnncollsp +# + +set names utf8; +eval create table t1(a text,fulltext(a)) ENGINE = INNODB collate=utf8_swedish_ci; +insert into t1 values('test test '),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'), +('test'),('test'),('test'),('test'),('test'),('test'),('test'),('test'); +delete from t1 limit 1; + +# +# BUG#16489: utf8 + fulltext leads to corrupt index file. +# +if ($MTR_COMBINATION_ORIG) +{ +truncate table t1; +} +if (!$MTR_COMBINATION_ORIG) +{ +--disable_query_log +delete from t1; +--enable_query_log +--echo truncate table t1; +} +insert into t1 values('ab c d'); +update t1 set a='ab c d'; +select * from t1 where match a against('ab c' in boolean mode); +select * from t1 where match a against('ab c' in boolean mode); +drop table t1; +set names latin1; + +# End of 4.1 tests + +# +# BUG#19580 - FULLTEXT search produces wrong results on UTF-8 columns +# INNODB_FTS: Investigate +SET NAMES utf8; +CREATE TABLE t1(a VARCHAR(255), FULLTEXT(a)) ENGINE = INNODB DEFAULT CHARSET=utf8; +INSERT INTO t1 VALUES('„MySQL“'); +SELECT a FROM t1 WHERE MATCH a AGAINST('“MySQL„' IN BOOLEAN MODE); +DROP TABLE t1; +SET NAMES latin1; + +# +# Bug #20597981 - WRONG RELEVANCE RANKING FOR FULL TEXT SEARCHES +# WHEN FTS_DOC_ID IS PRIMARY KEY +CREATE TABLE t1 ( + FTS_DOC_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, + id int(10) not null , + first_name varchar(50) NOT NULL, + last_name varchar(50) NOT NULL, + PRIMARY KEY (FTS_DOC_ID), + UNIQUE KEY idx_1 (first_name, last_name), + FULLTEXT KEY `idx_2` (first_name) +) ENGINE=InnoDB; + +INSERT INTO t1 (id, first_name, last_name) VALUES +(10, 'Bart', 'Simpson'), +(11, 'Homer', 'Simpson'), +(12, 'Marge', 'Simpson'), +(13, 'Lisa', 'Simpson'), +(14, 'Maggie', 'Simpson'), +(15, 'Ned', 'Flanders'), +(16, 'Nelson', 'Muntz'); + +analyze table t1; +SELECT fts_doc_id, first_name, last_name, MATCH(first_name) AGAINST('Homer' IN BOOLEAN MODE) AS score FROM t1; +DROP TABLE t1; + +# +# MDEV-28912 NON-UNIQUE FTS_DOC_ID mistaken as FTS_DOC_ID_INDEX +# +CREATE TABLE t1(a INT, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL, + KEY FTS_DOC_ID_INDEX(FTS_DOC_ID))ENGINE=InnoDB; +ALTER TABLE t1 ADD COLUMN c INT as (a) VIRTUAL; +ALTER TABLE t1 ADD d INT NULL; +--error ER_INNODB_FT_WRONG_DOCID_INDEX +ALTER TABLE t1 ADD FULLTEXT(b); +DROP TABLE t1; + +--echo # +--echo # MDEV-29169 Using MATCH returns NULL for Virtual Column +--echo # +CREATE TABLE t (a TEXT DEFAULT NULL, + b TEXT AS (a), + c TEXT AS (concat(a, '1')), + d int AS (111) VIRTUAL, + FULLTEXT KEY `a` (`a`) +) ENGINE=InnoDB; + +INSERT INTO t (a) VALUES ('test'); +SELECT * FROM t; +SELECT * FROM t WHERE MATCH(a) AGAINST('test'); + +DROP TABLE t; diff --git a/mysql-test/suite/innodb_fts/t/fulltext3.test b/mysql-test/suite/innodb_fts/t/fulltext3.test new file mode 100644 index 00000000..f28ca2c7 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/fulltext3.test @@ -0,0 +1,47 @@ +--source include/have_gbk.inc +# +# test of new fulltext search features +# +--source include/have_innodb.inc +--source include/maybe_versioning.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +let $default_engine = `select @@SESSION.default_storage_engine`; +# +# BUG#29299 - repeatable myisam fulltext index corruption +# +# INNODB_FTS: Not yet support gbk charset +CREATE TABLE t1(a VARCHAR(255) CHARACTER SET gbk, FULLTEXT(a)) ENGINE = InnoDB; +SET NAMES utf8; +# INSERT INTO t1 VALUES(0xF043616161),(0xBEF361616197C22061616161); +# SELECT HEX(a) FROM t1 WHERE MATCH(a) AGAINST(0x97C22061616161 IN BOOLEAN MODE); +DELETE FROM t1 LIMIT 1; +#CHECK TABLE t1; +SET NAMES latin1; +DROP TABLE t1; + +# End of 5.0 tests + +# +# BUG#29464 - load data infile into table with big5 chinese fulltext index +# hangs 100% cpu +# +--replace_result $default_engine <default_engine> +EVAL CREATE TABLE t1(a VARCHAR(2) CHARACTER SET big5 COLLATE big5_chinese_ci, +FULLTEXT(a)) ENGINE=$default_engine; +# INSERT INTO t1 VALUES(0xA3C2); +DROP TABLE t1; + +# End of 5.1 tests + + +CREATE TABLE t1 (a SERIAL, t TEXT, FULLTEXT f1(t), FULLTEXT f2(t)) ENGINE=InnoDB; +INSERT INTO t1 (a,t) VALUES (1,'1'),(2,'1'); +ALTER TABLE t1 ADD COLUMN g TEXT GENERATED ALWAYS AS (t) VIRTUAL; +DELETE FROM t1 WHERE a = 1; +ALTER TABLE t1 DROP INDEX f1; +INSERT INTO t1 (a,t) VALUES (1,'1'); +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/fulltext_cache.test b/mysql-test/suite/innodb_fts/t/fulltext_cache.test new file mode 100644 index 00000000..37926c1e --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/fulltext_cache.test @@ -0,0 +1,56 @@ +# +# Bugreport due to Roy Nasser <roy@vem.ca> +# +--source include/have_innodb.inc +--source include/maybe_versioning.inc + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + +CREATE TABLE t1 ( + id int(10) unsigned NOT NULL auto_increment, + q varchar(255) default NULL, + PRIMARY KEY (id) +) ENGINE = InnoDB; + +INSERT INTO t1 VALUES (1,'aaaaaaaaa dsaass de'); +INSERT INTO t1 VALUES (2,'ssde df s fsda sad er'); + +CREATE TABLE t2 ( + id int(10) unsigned NOT NULL auto_increment, + id2 int(10) unsigned default NULL, + item varchar(255) default NULL, + PRIMARY KEY (id), + FULLTEXT KEY item(item) +) ENGINE = InnoDB; + +INSERT INTO t2 VALUES (1,1,'sushi'); +INSERT INTO t2 VALUES (2,1,'Bolo de Chocolate'); +INSERT INTO t2 VALUES (3,1,'Feijoada'); +INSERT INTO t2 VALUES (4,1,'Mousse de Chocolate'); +INSERT INTO t2 VALUES (5,2,'um copo de Vodka'); +INSERT INTO t2 VALUES (6,2,'um chocolate Snickers'); +INSERT INTO t2 VALUES (7,1,'Bife'); +INSERT INTO t2 VALUES (8,1,'Pizza de Salmao'); + +-- disable_result_log +ANALYZE TABLE t1; +ANALYZE TABLE t2; +-- enable_result_log + +SELECT t1.q, t2.item, t2.id, round(MATCH t2.item AGAINST ('sushi'),6) +as x FROM t1, t2 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; + +SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi' IN BOOLEAN MODE) +as x FROM t1, t2 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; + +SELECT t1.q, t2.item, t2.id, round(MATCH t2.item AGAINST ('sushi'),6) +as x FROM t2, t1 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; + +SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi' IN BOOLEAN MODE) +as x FROM t2, t1 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; + +drop table t1, t2; + +# End of 4.1 tests diff --git a/mysql-test/suite/innodb_fts/t/fulltext_distinct.test b/mysql-test/suite/innodb_fts/t/fulltext_distinct.test new file mode 100644 index 00000000..bb390a08 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/fulltext_distinct.test @@ -0,0 +1,49 @@ +# +# Test of fulltext index +# bug reported by Tibor Simko <tibor.simko@cern.ch> +# +--source include/have_innodb.inc +--source include/maybe_versioning.inc + +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +CREATE TABLE t1 ( + id mediumint unsigned NOT NULL auto_increment, + tag char(6) NOT NULL default '', + value text NOT NULL default '', + PRIMARY KEY (id), + KEY kt(tag), + KEY kv(value(15)), + FULLTEXT KEY kvf(value) +) ENGINE = InnoDB; + +CREATE TABLE t2 ( + id_t2 mediumint unsigned NOT NULL default '0', + id_t1 mediumint unsigned NOT NULL default '0', + field_number tinyint unsigned NOT NULL default '0', + PRIMARY KEY (id_t2,id_t1,field_number), + KEY id_t1(id_t1) +) ENGINE = InnoDB; + +INSERT INTO t1 (tag,value) VALUES ('foo123','bar111'); +INSERT INTO t1 (tag,value) VALUES ('foo123','bar222'); +INSERT INTO t1 (tag,value) VALUES ('bar345','baz333 ar'); + +INSERT INTO t2 VALUES (2231626,64280,0); +INSERT INTO t2 VALUES (2231626,64281,0); +INSERT INTO t2 VALUES (12346, 3, 1); + +SELECT * FROM t1; SELECT * FROM t2; + +SELECT DISTINCT t2.id_t2 FROM t2, t1 +WHERE MATCH (t1.value) AGAINST ('baz333') AND t1.id = t2.id_t1; + +SELECT DISTINCT t2.id_t2 FROM t2, t1 +WHERE MATCH (t1.value) AGAINST ('baz333' IN BOOLEAN MODE) +AND t1.id = t2.id_t1; + +DROP TABLE t1, t2; + +# End of 4.1 tests diff --git a/mysql-test/suite/innodb_fts/t/fulltext_left_join.test b/mysql-test/suite/innodb_fts/t/fulltext_left_join.test new file mode 100644 index 00000000..0a1e1748 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/fulltext_left_join.test @@ -0,0 +1,134 @@ +# +# Test for bug from Jean-Cédric COSTA <jean-cedric.costa@ensmp.fr> +# +--source include/have_innodb.inc +--source include/maybe_versioning.inc + +--disable_warnings +drop table if exists t1, t2; +--enable_warnings + +CREATE TABLE t1 ( + id VARCHAR(255) NOT NULL PRIMARY KEY, + sujet VARCHAR(255), + motsclefs TEXT, + texte MEDIUMTEXT, + FULLTEXT(sujet, motsclefs, texte) +) ENGINE = InnoDB; + +INSERT INTO t1 VALUES('123','toto','essai','test'); +INSERT INTO t1 VALUES('456','droit','penal','lawyer'); +INSERT INTO t1 VALUES('789','aaaaa','bbbbb','cccccc'); + +CREATE TABLE t2 ( + id VARCHAR(255) NOT NULL, + author VARCHAR(255) NOT NULL +) ENGINE = InnoDB; + +INSERT INTO t2 VALUES('123', 'moi'); +INSERT INTO t2 VALUES('123', 'lui'); +INSERT INTO t2 VALUES('456', 'lui'); + +-- disable_result_log +ANALYZE TABLE t1; +ANALYZE TABLE t2; +-- enable_result_log + +select round(match(t1.texte,t1.sujet,t1.motsclefs) against('droit'),5) + from t1 left join t2 on t2.id=t1.id; +select match(t1.texte,t1.sujet,t1.motsclefs) against('droit' IN BOOLEAN MODE) + from t1 left join t2 on t2.id=t1.id; + +drop table t1, t2; + +# +# BUG#484, reported by Stephen Brandon <stephen@brandonitconsulting.co.uk> +# + +create table t1 (venue_id int(11) default null, venue_text varchar(255) default null, dt datetime default null) ENGINE = InnoDB; + +insert into t1 (venue_id, venue_text, dt) values (1, 'a1', '2003-05-23 19:30:00'),(null, 'a2', '2003-05-23 19:30:00'); +eval create table t2 (name varchar(255) not null default '', entity_id int(11) not null auto_increment, primary key (entity_id), fulltext key name (name)) engine= innodb; +insert into t2 (name, entity_id) values ('aberdeen town hall', 1), ('glasgow royal concert hall', 2), ('queen\'s hall, edinburgh', 3); +-- disable_result_log +ANALYZE TABLE t1; +ANALYZE TABLE t2; +-- enable_result_log +select * from t1 left join t2 on venue_id = entity_id where match(name) against('aberdeen' in boolean mode) and dt = '2003-05-23 19:30:00'; +select * from t1 left join t2 on venue_id = entity_id where match(name) against('aberdeen') and dt = '2003-05-23 19:30:00'; +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen' in boolean mode)) where dt = '2003-05-23 19:30:00'; +select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen')) where dt = '2003-05-23 19:30:00'; +drop table t1,t2; + +# +# BUG#14708 +# Inconsistent treatment of NULLs in LEFT JOINed FULLTEXT matching without index +# + +create table t1 (id int not null primary key, d char(200) not null, e char(200), fulltext (d, e)) ENGINE = InnoDB; +insert into t1 values (1, 'aword', null), (2, 'aword', 'bword'), (3, 'bword', null), (4, 'bword', 'aword'), (5, 'aword and bword', null); +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log +select * from t1 where match(d, e) against ('+aword +bword' in boolean mode); + +# INNODB_FTS: Investigate Full Text search on joined result +create table t2 (m_id int not null, f char(200), key (m_id), fulltext (f)) engine = InnoDB; +insert into t2 values (1, 'bword'), (3, 'aword'), (5, ''); +-- disable_result_log +ANALYZE TABLE t2; +-- enable_result_log +--error ER_WRONG_ARGUMENTS +select * from t1 left join t2 on m_id = id where match(d, e, f) against ('+aword +bword' in boolean mode); +drop table t1,t2; + +# +# BUG#25637: LEFT JOIN with BOOLEAN FULLTEXT loses left table matches +# (this is actually the same bug as bug #14708) +# + +CREATE TABLE t1 ( + id int(10) NOT NULL auto_increment, + link int(10) default NULL, + name mediumtext default NULL, + PRIMARY KEY (id), + FULLTEXT (name) +) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1, 1, 'string'); +INSERT INTO t1 VALUES (2, 0, 'string'); +CREATE TABLE t2 ( + id int(10) NOT NULL auto_increment, + name mediumtext default NULL, + PRIMARY KEY (id), + FULLTEXT (name) +) ENGINE = InnoDB; +INSERT INTO t2 VALUES (1, 'string'); + +-- disable_result_log +ANALYZE TABLE t1; +ANALYZE TABLE t2; +-- enable_result_log + +--error ER_WRONG_ARGUMENTS +SELECT t1.*, MATCH(t1.name) AGAINST('string') AS relevance + FROM t1 LEFT JOIN t2 ON t1.link = t2.id + WHERE MATCH(t1.name, t2.name) AGAINST('string' IN BOOLEAN MODE); + +DROP TABLE t1,t2; + +# End of 4.1 tests + +# +# BUG#25729 - boolean full text search is confused by NULLs produced by LEFT +# JOIN +# +CREATE TABLE t1 (a INT) ENGINE = InnoDB; +CREATE TABLE t2 (b INT, c TEXT, KEY(b), FULLTEXT(c)) ENGINE = InnoDB; +INSERT INTO t1 VALUES(1); +INSERT INTO t2(b,c) VALUES(2,'castle'),(3,'castle'); +-- disable_result_log +ANALYZE TABLE t1; +ANALYZE TABLE t2; +-- enable_result_log +SELECT * FROM t1 LEFT JOIN t2 ON a=b WHERE MATCH(c) AGAINST('+castle' IN BOOLEAN MODE); +DROP TABLE t1, t2; diff --git a/mysql-test/suite/innodb_fts/t/fulltext_misc.test b/mysql-test/suite/innodb_fts/t/fulltext_misc.test new file mode 100644 index 00000000..083953a4 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/fulltext_misc.test @@ -0,0 +1,213 @@ +# +# Fulltext configurable parameters +# +--source include/have_innodb.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +--echo # +--echo # Bug#56814 Explain + subselect + fulltext crashes server +--echo # + +CREATE TABLE t1(f1 VARCHAR(6) NOT NULL,FULLTEXT KEY(f1),UNIQUE(f1)) ENGINE = InnoDB; +INSERT INTO t1 VALUES ('test'); +EXPLAIN SELECT 1 FROM t1 +WHERE 1 > ALL((SELECT 1 FROM t1 JOIN t1 a ON (MATCH(t1.f1) AGAINST ("")) +WHERE t1.f1 GROUP BY t1.f1)); + +PREPARE stmt FROM +'EXPLAIN SELECT 1 FROM t1 + WHERE 1 > ALL((SELECT 1 FROM t1 RIGHT OUTER JOIN t1 a + ON (MATCH(t1.f1) AGAINST ("")) + WHERE t1.f1 GROUP BY t1.f1))'; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +PREPARE stmt FROM +'EXPLAIN SELECT 1 FROM t1 + WHERE 1 > ALL((SELECT 1 FROM t1 JOIN t1 a + ON (MATCH(t1.f1) AGAINST ("")) + WHERE t1.f1 GROUP BY t1.f1))'; + +EXECUTE stmt; +EXECUTE stmt; + +DEALLOCATE PREPARE stmt; + +DROP TABLE t1; + +#try to crash gcc 2.96 +--disable_warnings +drop table if exists t1; +--enable_warnings + +CREATE TABLE t1 ( + kodoboru varchar(10) default NULL, + obor tinytext, + aobor tinytext, + UNIQUE INDEX kodoboru (kodoboru), + FULLTEXT KEY obor (obor), + FULLTEXT KEY aobor (aobor) +) ENGINE = InnoDB; + +drop table t1; + +CREATE TABLE t1 ( + kodoboru varchar(10) default NULL, + obor tinytext, + aobor tinytext, + UNIQUE INDEX kodoboru (kodoboru), + FULLTEXT KEY obor (obor) +) ENGINE = InnoDB; +INSERT INTO t1 VALUES ('0101000000','aaa','AAA'); +INSERT INTO t1 VALUES ('0102000000','bbb','BBB'); +INSERT INTO t1 VALUES ('0103000000','ccc','CCC'); +INSERT INTO t1 VALUES ('0104000000','xxx','XXX'); + +select * from t1; +drop table t1; + +# End of 4.1 tests + + +# +# Bug#20503: Server crash due to the ORDER clause isn't taken into account +# while space allocation +# +create table t1 (c1 varchar(1), c2 int, c3 int, c4 int, c5 int, c6 int, +c7 int, c8 int, c9 int, fulltext key (`c1`)) ENGINE = InnoDB; +select distinct match (`c1`) against ('z') , c2, c3, c4,c5, c6,c7, c8 + from t1 where c9=1 order by c2, c2; +drop table t1; + + +# +# VIEW with full text +# +CREATE TABLE t1 (c1 int not null auto_increment primary key, c2 varchar(20), fulltext(c2)) ENGINE = InnoDB; +insert into t1 (c2) VALUES ('real Beer'),('Water'),('Kossu'),('Coca-Cola'),('Vodka'),('Wine'),('almost real Beer'); +select * from t1 WHERE match (c2) against ('Beer'); +CREATE VIEW v1 AS SELECT * from t1 WHERE match (c2) against ('Beer'); +select * from v1; +drop view v1; +drop table t1; + + +# Test case for bug 6447 +create table t1 (mytext text, FULLTEXT (mytext)) ENGINE = InnoDB; +insert t1 values ('aaabbb'); + +# INNODB_FTS: These variables are not support in InnoDB +check table t1; +# set @my_key_cache_block_size= @@global.key_cache_block_size; +# set GLOBAL key_cache_block_size=2048; +check table t1; +drop table t1; +# Restore the changed variable value +#set global key_cache_block_size= @my_key_cache_block_size; + + + +# +# BUG#12075 - FULLTEXT non-functional for big5 strings +# +# INNODB_FTS: Not yet support big5 +#CREATE TABLE t1 (a CHAR(50) CHARACTER SET big5 NOT NULL, FULLTEXT(a)) ENGINE = InnoDB; +#INSERT INTO t1 VALUES(0xA741ADCCA66EB6DC20A7DAADCCABDCA66E); +#SELECT HEX(a) FROM t1 WHERE MATCH(a) AGAINST (0xA741ADCCA66EB6DC IN BOOLEAN MODE); +#DROP TABLE t1; + +# + +create table t1 (a varchar(10), fulltext key(a)) ENGINE = InnoDB; +insert into t1 values ('a'); +select hex(concat(match (a) against ('a'))) from t1; +create table t2 ENGINE = InnoDB as select concat(match (a) against ('a')) as a from t1; +show create table t2; +drop table t1, t2; + + +# +# BUG#31159 - fulltext search on ucs2 column crashes server +# +CREATE TABLE t1(a TEXT CHARSET ucs2 COLLATE ucs2_unicode_ci) ENGINE = InnoDB; +INSERT INTO t1 VALUES('abcd'); + +# INNODB_FTS: Please Note this table do not have FTS. InnoDB return 1214 error +--error ER_FT_MATCHING_KEY_NOT_FOUND +SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abcd' IN BOOLEAN MODE); +DROP TABLE t1; + + +# +# Some other simple tests with the current character set +# +create table t1 (a varchar(10), key(a), fulltext (a)) ENGINE = InnoDB; +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +select * from t1 where a like "abc%"; +select * from t1 where a like "test%"; +select * from t1 where a like "te_t"; +select * from t1 where match a against ("te*" in boolean mode); +drop table t1; + + + +--echo # +--echo # Bug #49734: Crash on EXPLAIN EXTENDED UNION ... ORDER BY +--echo # <any non-const-function> +--echo # + +CREATE TABLE t1 (a VARCHAR(10), FULLTEXT KEY a (a)) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT) ENGINE = InnoDB; +INSERT INTO t2 VALUES (1),(2); + +--echo # Should not crash +EXPLAIN EXTENDED +SELECT * FROM t1 UNION SELECT * FROM t1 ORDER BY a + 12; + +--echo # Should not crash +SELECT * FROM t1 UNION SELECT * FROM t1 ORDER BY a + 12; + + +--echo # Should not crash +EXPLAIN EXTENDED +SELECT * FROM t1 UNION SELECT * FROM t1 + ORDER BY MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE); + +--echo # Should not crash +--sorted_result +SELECT * FROM t1 UNION SELECT * FROM t1 + ORDER BY MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE); + +# FIXME: Valgrind in MySQL code _MI_WRITE_BLOB_RECORD, bug #13389854 +#--echo # Should not crash +#(SELECT * FROM t1) UNION (SELECT * FROM t1) +# ORDER BY MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE); + + +--echo # Should not crash +EXPLAIN EXTENDED +SELECT * FROM t1 UNION SELECT * FROM t1 + ORDER BY (SELECT a FROM t2 WHERE b = 12); + +--echo # Should not crash +--disable_result_log +SELECT * FROM t1 UNION SELECT * FROM t1 + ORDER BY (SELECT a FROM t2 WHERE b = 12); +--enable_result_log + +--echo # Should not crash +SELECT * FROM t2 UNION SELECT * FROM t2 + ORDER BY (SELECT * FROM t1 WHERE MATCH(a) AGAINST ('+abc' IN BOOLEAN MODE)); + +DROP TABLE t1,t2; + + +--echo End of 5.1 tests + diff --git a/mysql-test/suite/innodb_fts/t/fulltext_multi.test b/mysql-test/suite/innodb_fts/t/fulltext_multi.test new file mode 100644 index 00000000..81ab7e1b --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/fulltext_multi.test @@ -0,0 +1,42 @@ +# several FULLTEXT indexes in one table test +--source include/have_innodb.inc +--source include/maybe_versioning.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 ( + a int(11) NOT NULL auto_increment, + b text, + c varchar(254) default NULL, + PRIMARY KEY (a), + FULLTEXT KEY bb(b), + FULLTEXT KEY cc(c), + FULLTEXT KEY a(b,c) +) ENGINE = InnoDB; + +drop table t1; + +CREATE TABLE t1 ( + a int(11) NOT NULL auto_increment, + b text, + c varchar(254) default NULL, + PRIMARY KEY (a), + FULLTEXT KEY a(b,c) +) ENGINE = InnoDB; + +INSERT INTO t1 VALUES (1,'lala lolo lili','oooo aaaa pppp'); +INSERT INTO t1 VALUES (2,'asdf fdsa','lkjh fghj'); +INSERT INTO t1 VALUES (3,'qpwoei','zmxnvb'); + +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log + +SELECT a, round(MATCH b,c AGAINST ('lala lkjh'),5) FROM t1; +SELECT a, round(MATCH c,c AGAINST ('lala lkjh'),5) FROM t1; +SELECT a, round(MATCH b,c AGAINST ('lala lkjh'),5) FROM t1; +drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/suite/innodb_fts/t/fulltext_order_by.test b/mysql-test/suite/innodb_fts/t/fulltext_order_by.test new file mode 100644 index 00000000..f14681b9 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/fulltext_order_by.test @@ -0,0 +1,168 @@ + +--source include/have_innodb.inc +--source include/maybe_versioning.inc + +--disable_warnings +DROP TABLE IF EXISTS t1,t2,t3; +--enable_warnings + +CREATE TABLE t1 ( + a INT AUTO_INCREMENT PRIMARY KEY, + message CHAR(20), + FULLTEXT(message) +) ENGINE = InnoDB comment = 'original testcase by sroussey@network54.com'; +INSERT INTO t1 (message) VALUES ("Testing"),("table"),("testbug"), + ("steve"),("is"),("cool"),("steve is cool"); +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log +# basic MATCH +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve'); +SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve'); +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE); +SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE); + +# MATCH + ORDER BY (with ft-ranges) +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY a; +SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a; + +# MATCH + ORDER BY (with normal ranges) + UNIQUE +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve') ORDER BY a DESC; +SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a in (2,7,4) and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY a DESC; + +# MATCH + ORDER BY + UNIQUE (const_table) +SELECT a, FORMAT(MATCH (message) AGAINST ('steve'),6) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve') ORDER BY 1; +SELECT a, MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) FROM t1 WHERE a=7 and MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) ORDER BY 1; + +# ORDER BY MATCH +# INNODB_FTS: INVESITGATE +SELECT if(a in (4,7),2,1), FORMAT(MATCH (message) AGAINST ('steve'),6) as rel FROM t1 ORDER BY rel; +SELECT if(a in (4,7),2,1), MATCH (message) AGAINST ('steve' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel; + +# +# BUG#6635 - test_if_skip_sort_order() thought it can skip filesort +# for fulltext searches too +# +alter table t1 add key m (message); +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log +explain SELECT message FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY message; +SELECT message FROM t1 WHERE MATCH (message) AGAINST ('steve') ORDER BY message desc; + +drop table t1; + +# +# reused boolean scan bug +# +CREATE TABLE t1 ( + a INT AUTO_INCREMENT PRIMARY KEY, + message CHAR(20), + FULLTEXT(message) +) ENGINE = InnoDB; +INSERT INTO t1 (message) VALUES ("testbug"),("testbug foobar"); +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log +SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1; +SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel,a; +drop table t1; + +# BUG#11869 +CREATE TABLE t1 ( + id int(11) NOT NULL auto_increment, + thread int(11) NOT NULL default '0', + beitrag longtext NOT NULL, + PRIMARY KEY (id), + KEY thread (thread), + FULLTEXT KEY beitrag (beitrag) +) ENGINE =InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=7923 ; + +CREATE TABLE t2 ( + id int(11) NOT NULL auto_increment, + text varchar(100) NOT NULL default '', + PRIMARY KEY (id), + KEY text (text) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=63 ; + +CREATE TABLE t3 ( + id int(11) NOT NULL auto_increment, + forum int(11) NOT NULL default '0', + betreff varchar(70) NOT NULL default '', + PRIMARY KEY (id), + KEY forum (forum), + FULLTEXT KEY betreff (betreff) +) ENGINE = InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=996 ; + +--error ER_TABLENAME_NOT_ALLOWED_HERE +select a.text, b.id, b.betreff +from + t2 a inner join t3 b on a.id = b.forum inner join + t1 c on b.id = c.thread +where + match(b.betreff) against ('+abc' in boolean mode) +group by a.text, b.id, b.betreff +union +select a.text, b.id, b.betreff +from + t2 a inner join t3 b on a.id = b.forum inner join + t1 c on b.id = c.thread +where + match(c.beitrag) against ('+abc' in boolean mode) +group by + a.text, b.id, b.betreff +order by + match(b.betreff) against ('+abc' in boolean mode) desc; + +--error ER_TABLENAME_NOT_ALLOWED_HERE +select a.text, b.id, b.betreff +from + t2 a inner join t3 b on a.id = b.forum inner join + t1 c on b.id = c.thread +where + match(b.betreff) against ('+abc' in boolean mode) +union +select a.text, b.id, b.betreff +from + t2 a inner join t3 b on a.id = b.forum inner join + t1 c on b.id = c.thread +where + match(c.beitrag) against ('+abc' in boolean mode) +order by + match(b.betreff) against ('+abc' in boolean mode) desc; + +select a.text, b.id, b.betreff +from + t2 a inner join t3 b on a.id = b.forum inner join + t1 c on b.id = c.thread +where + match(b.betreff) against ('+abc' in boolean mode) +union +select a.text, b.id, b.betreff +from + t2 a inner join t3 b on a.id = b.forum inner join + t1 c on b.id = c.thread +where + match(c.beitrag) against ('+abc' in boolean mode) +order by + match(betreff) against ('+abc' in boolean mode) desc; + +# BUG#11869 part2: used table type doesn't support FULLTEXT indexes error +(select b.id, b.betreff from t3 b) union +(select b.id, b.betreff from t3 b) +order by match(betreff) against ('+abc' in boolean mode) desc; + +--error ER_FT_MATCHING_KEY_NOT_FOUND +(select b.id, b.betreff from t3 b) union +(select b.id, b.betreff from t3 b) +order by match(betreff) against ('+abc') desc; + +select distinct b.id, b.betreff from t3 b +order by match(betreff) against ('+abc' in boolean mode) desc; + +select b.id, b.betreff from t3 b group by b.id+1 +order by match(betreff) against ('+abc' in boolean mode) desc; + +drop table t1,t2,t3; + +# End of 4.1 tests diff --git a/mysql-test/suite/innodb_fts/t/fulltext_update.test b/mysql-test/suite/innodb_fts/t/fulltext_update.test new file mode 100644 index 00000000..bda97cd4 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/fulltext_update.test @@ -0,0 +1,35 @@ +# +# Test for bug by voi@ims.at +# +--source include/have_innodb.inc +--source include/maybe_versioning.inc + +--disable_warnings +drop table if exists test; +--enable_warnings + +let $default_engine = `select @@SESSION.default_storage_engine`; +# --replace_result $default_engine <default_engine> +CREATE TABLE test ( + gnr INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + url VARCHAR(80) DEFAULT '' NOT NULL, + shortdesc VARCHAR(200) DEFAULT '' NOT NULL, + longdesc text DEFAULT '' NOT NULL, + description VARCHAR(80) DEFAULT '' NOT NULL, + name VARCHAR(80) DEFAULT '' NOT NULL, + FULLTEXT(url,description,shortdesc,longdesc), + PRIMARY KEY(gnr) +) ENGINE = InnoDB; + +insert into test (url,shortdesc,longdesc,description,name) VALUES +("http:/test.at", "kurz", "lang","desc", "name"); +insert into test (url,shortdesc,longdesc,description,name) VALUES +("http:/test.at", "kurz", "","desc", "name"); +update test set url='test', description='ddd', name='nam' where gnr=2; +update test set url='test', shortdesc='ggg', longdesc='mmm', +description='ddd', name='nam' where gnr=2; + +check table test; +drop table test; + +# End of 4.1 tests diff --git a/mysql-test/suite/innodb_fts/t/fulltext_var.test b/mysql-test/suite/innodb_fts/t/fulltext_var.test new file mode 100644 index 00000000..e8e4bf93 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/fulltext_var.test @@ -0,0 +1,40 @@ +# +# Fulltext configurable parameters +# +--source include/have_innodb.inc +--source include/maybe_versioning.inc + +# Save ft_boolean_syntax variable +let $saved_ft_boolean_syntax=`select @@global.ft_boolean_syntax`; + +show variables like "ft\_%"; + +# INNODB_FTS: Please note original table do not have fulltext index. +# InnoDB will return 1214. I added "fulltext(b)" to the create table statement +# In addition, we do not support MyISAM configure parameter +create table t1 (b text not null, fulltext(b)) engine = innodb; +insert t1 values ('aaaaaa bbbbbb cccccc'); +insert t1 values ('bbbbbb cccccc'); +insert t1 values ('aaaaaa cccccc'); +select * from t1 where match b against ('+aaaaaa bbbbbb' in boolean mode); +-- error 1229 +set ft_boolean_syntax=' +-><()~*:""&|'; +set global ft_boolean_syntax=' +-><()~*:""&|'; +select * from t1 where match b against ('+aaaaaa bbbbbb' in boolean mode); +set global ft_boolean_syntax='@ -><()~*:""&|'; +select * from t1 where match b against ('+aaaaaa bbbbbb' in boolean mode); + +--error ER_PARSE_ERROR +select * from t1 where match b against ('+aaaaaa @bbbbbb' in boolean mode); +-- error 1231 +set global ft_boolean_syntax='@ -><()~*:""@|'; +-- error 1231 +set global ft_boolean_syntax='+ -><()~*:""@!|'; +drop table t1; + +# Restore ft_boolean_syntax variable +--disable_query_log +eval set global ft_boolean_syntax='$saved_ft_boolean_syntax'; +--enable_query_log + +# End of 4.1 tests diff --git a/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.opt b/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.opt new file mode 100644 index 00000000..5d5cca1c --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.opt @@ -0,0 +1,2 @@ +--enable-plugin-innodb-sys-tables +--innodb_ft_index_table diff --git a/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test b/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test new file mode 100644 index 00000000..cef8df2d --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test @@ -0,0 +1,413 @@ +# This is the DDL function tests for innodb FTS + +-- source include/have_innodb.inc +-- source include/maybe_versioning.inc + +# Create FTS table +CREATE TABLE fts_test ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT + ) ENGINE=InnoDB; + +# Insert six rows +INSERT INTO fts_test (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# Table does rebuild when fts index builds for the first time +--error ER_ALTER_OPERATION_NOT_SUPPORTED +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=NOCOPY; + +# Create the FTS index +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=INPLACE; + +# Select word "tutorial" in the table +SELECT * FROM fts_test WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +# Drop the FTS idx +DROP INDEX idx ON fts_test; + +# Continue insert some rows +INSERT INTO fts_test (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# FTS_DOC_ID hidden column and FTS_DOC_ID index exist +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=NOCOPY; + +# Select word "tutorial" in the table +SELECT * FROM fts_test WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +# Boolean search +# Select rows contain "MySQL" but not "YourSQL" +SELECT * FROM fts_test WHERE MATCH (title,body) + AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); + +# Truncate table +let $vers=$MTR_COMBINATION_VERS+$MTR_COMBINATION_VERS_TRX; + +if ($vers) +{ +--disable_query_log +CREATE TABLE fts_test2 LIKE fts_test; +DROP TABLE fts_test; +RENAME TABLE fts_test2 TO fts_test; +--enable_query_log +--echo TRUNCATE TABLE fts_test; +} +if (!$vers) +{ +TRUNCATE TABLE fts_test; +} + +DROP INDEX idx ON fts_test; + +# Continue insert some rows +INSERT INTO fts_test (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# Recreate the FTS index +CREATE FULLTEXT INDEX idx on fts_test (title, body); + +# Select word "tutorial" in the table +SELECT * FROM fts_test WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +DROP TABLE fts_test; + +# Create FTS table +CREATE TABLE fts_test ( + FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT + ) ENGINE=InnoDB; + +# Insert six rows +INSERT INTO fts_test (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# Create the FTS index +# We could support online fulltext index creation when a FTS_DOC_ID +# column already exists. This has not been implemented yet. +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +CREATE FULLTEXT INDEX idx on fts_test (title, body) LOCK=NONE; +ALTER TABLE fts_test ADD FULLTEXT `idx` (title, body), ALGORITHM=NOCOPY; + +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE fts_test ROW_FORMAT=REDUNDANT, LOCK=NONE; +ALTER TABLE fts_test ROW_FORMAT=REDUNDANT; + +SELECT * FROM fts_test WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +# Drop and recreate +drop index idx on fts_test; + +CREATE FULLTEXT INDEX idx on fts_test (title, body); + +SELECT * FROM fts_test WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +# Drop the FTS_DOC_ID_INDEX and try again +drop index idx on fts_test; + +CREATE FULLTEXT INDEX idx on fts_test (title, body); + +SELECT * FROM fts_test WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +drop table fts_test; + +# Test FTS_DOC_ID and FTS_DOC_ID_INDEX all in the create table clause +CREATE TABLE fts_test ( + FTS_DOC_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, + title varchar(255) NOT NULL DEFAULT '', + text mediumtext NOT NULL, + PRIMARY KEY (FTS_DOC_ID), + UNIQUE KEY FTS_DOC_ID_INDEX (FTS_DOC_ID), + FULLTEXT KEY idx (title,text) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; + +set @@auto_increment_increment=10; + +INSERT INTO fts_test (title, text) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...'), + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); +-- disable_result_log +ANALYZE TABLE fts_test; +-- enable_result_log +set @@auto_increment_increment=1; + +select *, match(title, text) AGAINST ('database') as score +from fts_test order by score desc; + +drop index idx on fts_test; + +drop table fts_test; + +# This should fail: +# Create a FTS_DOC_ID of the wrong type (should be bigint) +--error 1166 +CREATE TABLE fts_test ( + FTS_DOC_ID int(20) unsigned NOT NULL AUTO_INCREMENT, + title varchar(255) NOT NULL DEFAULT '', + text mediumtext NOT NULL, + PRIMARY KEY (FTS_DOC_ID), + UNIQUE KEY FTS_DOC_ID_INDEX (FTS_DOC_ID), + FULLTEXT KEY idx (title,text) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; + +# This should fail: +# Create a FTS_DOC_ID_INDEX of the wrong type (should be unique) +--error ER_INNODB_FT_WRONG_DOCID_INDEX +CREATE TABLE fts_test ( + FTS_DOC_ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, + title varchar(255) NOT NULL DEFAULT '', + text mediumtext NOT NULL, + PRIMARY KEY (FTS_DOC_ID), + KEY FTS_DOC_ID_INDEX (FTS_DOC_ID), + FULLTEXT KEY idx (title,text) +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1; + +CREATE TABLE articles ( + FTS_DOC_ID BIGINT UNSIGNED NOT NULL , + title VARCHAR(200), + body TEXT +) ENGINE=InnoDB; + +INSERT INTO articles (FTS_DOC_ID, title, body) VALUES + (9, 'MySQL Tutorial','DBMS stands for DataBase ...'), + (10, 'How To Use MySQL Well','After you went through a ...'), + (12, 'Optimizing MySQL','In this tutorial we will show ...'), + (14,'1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + (19, 'MySQL vs. YourSQL','In the following database comparison ...'), + (20, 'MySQL Security','When configured properly, MySQL ...'); + +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE articles ADD FULLTEXT INDEX idx (title), + ADD FULLTEXT INDEX idx3 (title), ALGORITHM=INPLACE; +--enable_info +ALTER TABLE articles ADD FULLTEXT INDEX idx (title), + ADD FULLTEXT INDEX idx3 (title); +--disable_info + +ALTER TABLE articles ADD INDEX t20 (title(20)), LOCK=NONE; +ALTER TABLE articles DROP INDEX t20; + +INSERT INTO articles (FTS_DOC_ID, title, body) VALUES + (29, 'MySQL Tutorial','DBMS stands for DataBase ...'), + (30, 'How To Use MySQL Well','After you went through a ...'), + (32, 'Optimizing MySQL','In this tutorial we will show ...'), + (34,'1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + (39, 'MySQL vs. YourSQL','In the following database comparison ...'), + (40, 'MySQL Security','When configured properly, MySQL ...'); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +DROP INDEX idx ON articles; + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +CREATE FULLTEXT INDEX idx on articles (title, body); + +SELECT * FROM articles WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; + +create table articles(`FTS_DOC_ID` serial, +`col32` timestamp not null,`col115` text) engine=innodb; + +create fulltext index `idx5` on articles(`col115`) ; + +alter ignore table articles add primary key (`col32`) ; + +drop table articles; + +# Create a table with FTS index, this will create hidden column FTS_DOC_ID +CREATE TABLE articles ( + id INT UNSIGNED NOT NULL, + title VARCHAR(200), + body TEXT + ) ENGINE=InnoDB; + +INSERT INTO articles VALUES + (1, 'MySQL Tutorial','DBMS stands for DataBase ...') , + (2, 'How To Use MySQL Well','After you went through a ...'), + (3, 'Optimizing MySQL','In this tutorial we will show ...'), + (4, '1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + (5, 'MySQL vs. YourSQL','In the following database comparison ...'), + (6, 'MySQL Security','When configured properly, MySQL ...'); + +CREATE FULLTEXT INDEX idx on articles (title, body); + +# Drop the FTS index, however, this will keep the FTS_DOC_ID hidden +# column (to avoid a table rebuild) +DROP INDEX idx ON articles; + +# Now create cluster index on id online; The rebuild should still +# have the FTS_DOC_ID +CREATE UNIQUE INDEX idx2 ON articles(id); + +# Recreate FTS index, this should not require a rebuild, +# since the FTS_DOC_ID is still there +CREATE FULLTEXT INDEX idx on articles (title, body); + +SELECT * FROM articles WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; + +--echo # +--echo # MDEV-22811 DDL fails to drop and re-create FTS index +--echo # +CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED PRIMARY KEY, + f1 VARCHAR(200),FULLTEXT fidx(f1))engine=innodb; +ALTER TABLE t1 DROP index fidx, ADD FULLTEXT INDEX(f1); +DROP TABLE t1; + +--echo # +--echo # MDEV-21478 Inplace alter fails to report error when +--echo # FTS_DOC_ID is added + +SET NAMES utf8; + +CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB; +ALTER TABLE t1 ADD FTS_DOC_ıD BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY; +ALTER TABLE t1 DROP COLUMN FTS_DOC_ıD; +ALTER TABLE t1 ADD FTS_DOC_ıD BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; +DROP TABLE t1; + +CREATE TABLE t1 (f1 INT NOT NULL)ENGINE=InnoDB; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD FTS_DOC_Ä°D BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD FTS_DOC_Ä°D BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD fts_doc_id INT, ALGORITHM=COPY; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD fts_doc_id INT, ALGORITHM=INPLACE; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD fts_doc_id BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD fts_doc_id BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD FTS_DOC_ID INT UNSIGNED NOT NULL, ALGORITHM=COPY; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD FTS_DOC_ID INT UNSIGNED NOT NULL, ALGORITHM=INPLACE; + +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--echo # +--echo # MDEV-25271 Double free of table when inplace alter +--echo # FTS add index fails +--echo # +call mtr.add_suppression("InnoDB: Operating system error number .* in a file operation."); +call mtr.add_suppression("InnoDB: Error number .* means"); +call mtr.add_suppression("InnoDB: Cannot create file"); +call mtr.add_suppression("InnoDB: Failed to create"); + +let MYSQLD_DATADIR=`select @@datadir`; +CREATE TABLE t1(a TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL UNIQUE) ENGINE=InnoDB; +let $fts_aux_file= `select concat('FTS_',right(concat(repeat('0',16), lower(hex(TABLE_ID))),16),'_BEING_DELETED.ibd') FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE NAME='test/t1'`; +write_file $MYSQLD_DATADIR/test/$fts_aux_file; +EOF +--replace_regex /".*" from/"Resource temporarily unavailable" from/ +--error ER_GET_ERRNO +ALTER TABLE t1 ADD FULLTEXT(a), ALGORITHM=INPLACE; +DROP TABLE t1; +remove_file $MYSQLD_DATADIR/test/$fts_aux_file; + +# Add more than one FTS index +CREATE TABLE t1 (a VARCHAR(3)) ENGINE=InnoDB; +ALTER TABLE t1 ADD FULLTEXT KEY(a), ADD COLUMN b VARCHAR(3), ADD FULLTEXT KEY(b); + +# Cleanup +DROP TABLE t1; + +--echo # +--echo # MDEV-18152 Assertion 'num_fts_index <= 1' failed +--echo # in prepare_inplace_alter_table_dict +--echo # +CREATE TABLE t1 +(a VARCHAR(128), b VARCHAR(128), FULLTEXT INDEX(a), FULLTEXT INDEX(b)) +ENGINE=InnoDB; +ALTER TABLE t1 ADD c SERIAL; +DROP TABLE t1; + +--echo # End of 10.3 tests + +--echo # +--echo # MDEV-27582 Fulltext DDL decrements the FTS_DOC_ID value +--echo # +CREATE TABLE t1 ( + f1 INT NOT NULL PRIMARY KEY, + f2 VARCHAR(64), FULLTEXT ft(f2)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,'foo'),(2,'bar'); +connect(con1,localhost,root,,,); +START TRANSACTION WITH CONSISTENT SNAPSHOT; + +connection default; +DELETE FROM t1 WHERE f1 = 2; +ALTER TABLE t1 DROP INDEX ft; +ALTER TABLE t1 ADD FULLTEXT INDEX ft (f2); +INSERT INTO t1 VALUES (3, 'innodb fts search'); +SET GLOBAL innodb_optimize_fulltext_only=ON; +OPTIMIZE TABLE t1; +SET GLOBAL innodb_ft_aux_table = 'test/t1'; +SELECT max(DOC_ID) FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +SELECT * FROM t1 WHERE MATCH(f2) AGAINST("+innodb +search" IN BOOLEAN MODE); +DROP TABLE t1; +disconnect con1; +SET GLOBAL innodb_optimize_fulltext_only=OFF; +SET GLOBAL innodb_ft_aux_table = default; + +--echo # +--echo # MDEV-32017 Auto-increment no longer works for +--echo # explicit FTS_DOC_ID +--echo # +CREATE TABLE t ( + FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, + f1 char(255), f2 char(255), f3 char(255), fulltext key (f3) +) ENGINE=InnoDB; +INSERT INTO t (f1,f2,f3) VALUES ('foo','bar','baz'); +ALTER TABLE t ADD FULLTEXT INDEX ft1(f1); +ALTER TABLE t ADD FULLTEXT INDEX ft2(f2); +INSERT INTO t (f1,f2,f3) VALUES ('bar','baz','qux'); +DROP TABLE t; diff --git a/mysql-test/suite/innodb_fts/t/innodb-fts-fic.test b/mysql-test/suite/innodb_fts/t/innodb-fts-fic.test new file mode 100644 index 00000000..2d94c213 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb-fts-fic.test @@ -0,0 +1,234 @@ +# This is the basic function tests for innodb FTS + +-- source include/have_innodb.inc +-- source include/maybe_versioning.inc + +call mtr.add_suppression("\\[Warning\\] InnoDB: A new Doc ID must be supplied while updating FTS indexed columns."); +call mtr.add_suppression("\\[Warning\\] InnoDB: FTS Doc ID must be larger than [0-9]+ for table `test`.`articles`"); +# Create FTS table +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT + ) ENGINE=InnoDB; + +# Insert six rows +INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# Create the FTS index +CREATE FULLTEXT INDEX idx on articles (title, body); + +SELECT * FROM articles WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +SELECT COUNT(*) FROM articles + WHERE MATCH (title, body) + AGAINST ('database' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles + WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + + +SELECT COUNT(IF(MATCH (title, body) + AGAINST ('database' IN NATURAL LANGUAGE MODE), 1, NULL)) + AS count FROM articles; + +ANALYZE TABLE articles; + +# Boolean search +# Select rows contain "MySQL" but not "YourSQL" +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); + +# Select rows contain at least one of the two words +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('DBMS Security' IN BOOLEAN MODE); + +# Select rows contain both "MySQL" and "YourSQL" +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('+MySQL +YourSQL' IN BOOLEAN MODE); + +DROP INDEX idx ON articles; + +# Create the FTS index +CREATE FULLTEXT INDEX idx on articles (title, body); + +CREATE FULLTEXT INDEX idx1 on articles (title); + +SELECT * FROM articles WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +DROP INDEX idx ON articles; + +DROP INDEX idx1 ON articles; + +CREATE FULLTEXT INDEX idx1 on articles (title); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +drop table articles; + +# Create FTS table +CREATE TABLE articles ( + FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT + ) ENGINE=InnoDB; + +create unique index FTS_DOC_ID_INDEX on articles(FTS_DOC_ID); + +# Insert six rows +INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# Create the FTS index +CREATE FULLTEXT INDEX idx on articles (title, body); + +# "the" is in the default stopword, it would not be selected +SELECT * FROM articles WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +drop table articles; + +# Create FTS table +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT + ) ENGINE=InnoDB; + +# Insert six rows +INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +CREATE FULLTEXT INDEX idx on articles (title); +CREATE FULLTEXT INDEX idx2 on articles (body); + +# "the" is in the default stopword, it would not be selected +--error 1191 +SELECT * FROM articles WHERE MATCH (title, body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +drop index idx2 on articles; + +--error 1191 +SELECT * FROM articles WHERE MATCH (body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +CREATE FULLTEXT INDEX idx2 on articles (body); + +SELECT * FROM articles WHERE MATCH (body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +UPDATE articles set title = 'aaaa' +WHERE MATCH(title) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('aaaa' IN NATURAL LANGUAGE MODE); + +drop table articles; + +CREATE TABLE articles ( + FTS_DOC_ID BIGINT UNSIGNED NOT NULL , + title VARCHAR(200), + body TEXT + ) ENGINE=InnoDB; + +CREATE FULLTEXT INDEX idx on articles (title); + +INSERT INTO articles VALUES (9, 'MySQL Tutorial','DBMS stands for DataBase ...'); + +# This should fail since we did not supply a new Doc ID +-- error 182 +UPDATE articles set title = 'bbbb' WHERE MATCH(title) AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); + +# This should fail, since the Doc ID supplied is less than the old value 9 +-- error 182 +UPDATE articles set title = 'bbbb', FTS_DOC_ID=8 WHERE MATCH(title) AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); + +# This should be successful +UPDATE articles set title = 'bbbb', FTS_DOC_ID=10 WHERE MATCH(title) AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); + +# Check update to be successful +SELECT * FROM articles WHERE MATCH (title) AGAINST ('bbbb' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); + +CREATE FULLTEXT INDEX idx2 ON articles (body); + +SELECT * FROM articles WHERE MATCH (body) AGAINST ('database' IN NATURAL LANGUAGE MODE); + +UPDATE articles set body = 'bbbb', FTS_DOC_ID=11 WHERE MATCH(body) AGAINST ('database' IN NATURAL LANGUAGE MODE); + +drop table articles; + +create table `articles`(`a` varchar(2) not null)engine=innodb; + +# This create index should fail. FTS_DOC_ID_INDEX is reserved as a unique +# index on FTS_DOC_ID +--error ER_INNODB_FT_WRONG_DOCID_INDEX +create fulltext index `FTS_DOC_ID_INDEX` on `articles`(`a`); + +create unique index `a` on `articles`(`a`); + +drop table articles; + +# We will check validity of FTS_DOC_ID, which must be of an UNSIGNED +# NOT NULL bigint +CREATE TABLE wp( + FTS_DOC_ID bigint PRIMARY KEY, + title VARCHAR(255) NOT NULL DEFAULT '', + text MEDIUMTEXT NOT NULL ) ENGINE=InnoDB; + +INSERT INTO wp (FTS_DOC_ID, title, text) VALUES + (1, 'MySQL Tutorial','DBMS stands for DataBase ...'), + (2, 'How To Use MySQL Well','After you went through a ...'); + +--error ER_INNODB_FT_WRONG_DOCID_COLUMN +CREATE FULLTEXT INDEX idx ON wp(title, text); + +DROP TABLE wp; +CREATE TABLE wp( + FTS_DOC_ID bigint unsigned PRIMARY KEY, + title VARCHAR(255) NOT NULL DEFAULT '', + text MEDIUMTEXT NOT NULL ) ENGINE=InnoDB; + +INSERT INTO wp (FTS_DOC_ID, title, text) VALUES + (1, 'MySQL Tutorial','DBMS stands for DataBase ...'), + (2, 'How To Use MySQL Well','After you went through a ...'); + +CREATE FULLTEXT INDEX idx ON wp(title, text); + +SELECT FTS_DOC_ID, MATCH(title, text) AGAINST ('database') + +FROM wp; + +DROP TABLE wp; + diff --git a/mysql-test/suite/innodb_fts/t/innodb_ft_aux_table.opt b/mysql-test/suite/innodb_fts/t/innodb_ft_aux_table.opt new file mode 100644 index 00000000..f8558127 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb_ft_aux_table.opt @@ -0,0 +1,6 @@ +--innodb_ft_default_stopword +--innodb_ft_deleted +--innodb_ft_being_deleted +--innodb_ft_index_cache +--innodb_ft_index_table +--innodb_ft_config diff --git a/mysql-test/suite/innodb_fts/t/innodb_ft_aux_table.test b/mysql-test/suite/innodb_fts/t/innodb_ft_aux_table.test new file mode 100644 index 00000000..f9447aad --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb_ft_aux_table.test @@ -0,0 +1,44 @@ +--source include/have_innodb.inc +--source include/maybe_versioning.inc + +CREATE TABLE t1 (v VARCHAR(100), FULLTEXT INDEX (v)) ENGINE=InnoDB; + +insert into t1 VALUES('First record'),('Second record'),('Third record'); + +SET @save_ft_aux_table = @@GLOBAL.innodb_ft_aux_table; + +connect (con1,localhost,root,,); +--error ER_WRONG_VALUE_FOR_VAR +SET GLOBAL innodb_ft_aux_table = 'test/t0'; +connection default; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DEFAULT_STOPWORD; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DELETED; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_CONFIG; +connection con1; +SET GLOBAL innodb_ft_aux_table = 'test/t1'; +disconnect con1; +connection default; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DELETED; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_CONFIG; +SELECT @@GLOBAL.innodb_ft_aux_table; +RENAME TABLE t1 TO t2; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DELETED; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_CONFIG; +SELECT @@GLOBAL.innodb_ft_aux_table; +DROP TABLE t2; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_DELETED; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_BEING_DELETED; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_CONFIG; +SELECT @@GLOBAL.innodb_ft_aux_table; +SET GLOBAL innodb_ft_aux_table = @save_ft_aux_table; diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_large_records.test b/mysql-test/suite/innodb_fts/t/innodb_fts_large_records.test new file mode 100644 index 00000000..c84cd068 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_large_records.test @@ -0,0 +1,382 @@ +# This test for FTS index with big records +# case a) more words in single record +# b) more words across records + +--source include/have_innodb.inc +--source include/maybe_versioning.inc + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +# Create FTS table +EVAL CREATE TABLE t1 ( + FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a TEXT, + b TEXT + ) ENGINE = InnoDB; + +CREATE UNIQUE INDEX FTS_DOC_ID_INDEX on t1(FTS_DOC_ID); + +let $counter = 1; +--disable_query_log + +# Generate input file using perl +perl; +use strict; +my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/fts_input_data1.txt"; +open FH,">$fname"; +my $record_counter = 1; +while ($record_counter < 50) { + my $word_counter = 1; + my ($col1,$col2); + while ($word_counter < 51) { + $col1 = $col1. "row".$record_counter."col1"."word".$word_counter." "; + $col2 = $col2. "row".$record_counter."col2"."word".$word_counter." "; + $word_counter++; + } + print FH "$col1,$col2\n"; + $record_counter++; +} +close FH; +EOF + +EVAL LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/fts_input_data1.txt' INTO +TABLE t1 FIELDS TERMINATED BY ',' (a,b); +--enable_query_log +--echo "Loading data using LOAD DATA Command , File <MYSQLTEST_VARDIR>/tmp/fts_input_data1.txt" + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + +SELECT COUNT(*) FROM t1; + +# Select word "tutorial" in the table +SELECT FTS_DOC_ID FROM t1 WHERE MATCH (a,b) + AGAINST ('row35col2word49' IN NATURAL LANGUAGE MODE); + +# boolean mode +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row5col2word49 +row5col1word49" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row5col2word49" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row35col2word49 +(row35col1word49 row35col2word40)" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row35col2word49 -(row45col2word49)" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("row5col2word49 row5col2word40" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH a,b AGAINST ("+row5col2word* +row5col1word49*" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH a,b AGAINST ('"row35col2word49"' IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH a,b AGAINST ('"ROW35col2WORD49"' IN BOOLEAN MODE); + +# query expansion +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST ("row5col2word49" WITH QUERY EXPANSION); + +SELECT FTS_DOC_ID FROM t1 + WHERE MATCH (a,b) + AGAINST ('"row5col2word48 row5col2word49"@2' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"row5col2word48 row5col2word49"@1' IN BOOLEAN MODE); + +UPDATE t1 SET a = "using update" , b = "changing fulltext index record", FTS_DOC_ID = FTS_DOC_ID + 10000 +WHERE MATCH(a,b) AGAINST("+row5col2word49 +row5col1word49" IN BOOLEAN MODE); + +SELECT a,b FROM t1 WHERE MATCH(a,b) AGAINST("+row5col2word49 +row5col1word49" IN BOOLEAN MODE); +SELECT a,b FROM t1 WHERE MATCH(a,b) AGAINST("changing fulltext" IN BOOLEAN MODE); +SELECT a,b FROM t1 WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); + +DELETE FROM t1 WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +SELECT a,b FROM t1 WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); + +--remove_file '$MYSQLTEST_VARDIR/tmp/fts_input_data1.txt'; +DROP TABLE t1; + +#-------------------------------------------------------------------------------------------- +# Create FTS table +EVAL CREATE TABLE t1 ( + FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a TEXT, + b TEXT + ) ENGINE = InnoDB; + +CREATE UNIQUE INDEX FTS_DOC_ID_INDEX on t1(FTS_DOC_ID); + +let $counter = 1; +--disable_query_log + +# Generate input file using perl +perl; +use strict; +my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/fts_input_data2.txt"; +open FH,">$fname"; +my $record_counter = 1; +while ($record_counter < 101) { + my $word_counter = 1; + my ($col1,$col2); + while ($word_counter < 50) { + $col1 = $col1. "row".$record_counter."col1"."word".$word_counter." "; + $col2 = $col2. "row".$record_counter."col2"."word".$word_counter." "; + $word_counter++; + } + print FH "$col1,$col2\n"; + $record_counter++; +} +close FH; +EOF + +EVAL LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/fts_input_data2.txt' +INTO TABLE t1 FIELDS TERMINATED BY ',' (a,b); +--enable_query_log +--echo "Loading data using LOAD DATA Command , File <MYSQLTEST_VARDIR>/tmp/fts_input_data2.txt" + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + +SELECT COUNT(*) FROM t1; + +SELECT FTS_DOC_ID from t1 WHERE b like '%row300col2word30%'; + +SELECT FTS_DOC_ID FROM t1 WHERE MATCH (a,b) + AGAINST ('row35col2word49' IN NATURAL LANGUAGE MODE); + +# boolean mode +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row5col2word49 +row5col1word49" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row5col2word49" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row35col2word49 +(row35col1word49 row35col2word40)" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+row35col2word49 -(row45col2word49)" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("row5col2word49 row5col2word40" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH a,b AGAINST ("+row5col2word* +row5col1word49*" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH a,b AGAINST ('"row35col2word49"' IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH a,b AGAINST ('"ROW35col2WORD49"' IN BOOLEAN MODE); + +# query expansion +SELECT COUNT(*) from t1 WHERE MATCH(a,b) AGAINST ("row5col2word49" WITH QUERY EXPANSION); + +SELECT FTS_DOC_ID FROM t1 + WHERE MATCH (a,b) + AGAINST ('"row5col2word48 row5col2word49"@2' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"row5col2word48 row5col2word49"@1' IN BOOLEAN MODE); + +UPDATE t1 SET a = "using update" , b = "changing fulltext index record", FTS_DOC_ID = FTS_DOC_ID + 10000 +WHERE MATCH(a,b) AGAINST("+row5col2word49 +row5col1word49" IN BOOLEAN MODE); + +SELECT a,b FROM t1 +WHERE MATCH(a,b) AGAINST("+row5col2word49 +row5col1word49" IN BOOLEAN MODE); +SELECT a,b FROM t1 +WHERE MATCH(a,b) AGAINST("changing fulltext" IN BOOLEAN MODE); +SELECT a,b FROM t1 +WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); + +DELETE FROM t1 WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +SELECT a,b FROM t1 WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); + +ALTER TABLE t1 DROP INDEX idx; +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); +UPDATE t1 SET a = NULL , b = NULL, FTS_DOC_ID= 6000 + FTS_DOC_ID; + +SELECT COUNT(*) FROM t1 WHERE a IS NULL AND b IS NULL; +ALTER TABLE t1 DROP INDEX idx; +SELECT COUNT(*) FROM t1 WHERE a IS NULL AND b IS NULL; + +--remove_file '$MYSQLTEST_VARDIR/tmp/fts_input_data2.txt'; +DROP TABLE t1; + +#-------------------------------------------------------------------------------------------- +# Create FTS table +EVAL CREATE TABLE t1 ( + FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a TEXT, + b TEXT + ) ENGINE = InnoDB; + +CREATE UNIQUE INDEX FTS_DOC_ID_INDEX on t1(FTS_DOC_ID); + +let $counter = 1; +--disable_query_log + +# Generate input file using perl +perl; +use strict; +my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/fts_input_data3.txt"; +open FH,">$fname"; +my $record_counter = 1; +while ($record_counter < 101) { + my $word_counter = 1; + my ($col1,$col2); + while ($word_counter < 50) { + $col1 = $col1. "samerowword" ." "; + $col2 = $col2. "samerowword" ." "; + $word_counter++; + } + print FH "$col1,$col2\n"; + $record_counter++; +} +close FH; +EOF + +EVAL LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/fts_input_data3.txt' +INTO TABLE t1 FIELDS TERMINATED BY ',' (a,b); +--enable_query_log +--echo "Loading data using LOAD DATA Command , File <MYSQLTEST_VARDIR>/tmp/fts_input_data3.txt" + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + +SELECT COUNT(*) FROM t1; + +SELECT COUNT(*) from t1 WHERE b like '%samerowword%'; + +SELECT COUNT(*) FROM t1 WHERE MATCH (a,b) + AGAINST ('samerowword' IN NATURAL LANGUAGE MODE); + +# boolean mode +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+samerowword +samerowword" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+samerowword" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+samerowword -(row45col2word49)" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH a,b AGAINST ("+sameroww" IN BOOLEAN MODE); + +# query expansion +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST ("samerowword" WITH QUERY EXPANSION); + +UPDATE t1 SET a = "using update" , b = "changing fulltext index record", +FTS_DOC_ID = FTS_DOC_ID + 10000 +WHERE MATCH(a,b) AGAINST("+samerowword +samerowword" IN BOOLEAN MODE); + +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+samerowword +samerowword" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+samerowword" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("changing fulltext" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); + +DELETE FROM t1 WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); + +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); + +ALTER TABLE t1 DROP INDEX idx; +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); +UPDATE t1 SET a = NULL , b = NULL ; + +SELECT COUNT(*) FROM t1 WHERE a IS NULL AND b IS NULL; +ALTER TABLE t1 DROP INDEX idx; +SELECT COUNT(*) FROM t1 WHERE a IS NULL AND b IS NULL; + +--remove_file '$MYSQLTEST_VARDIR/tmp/fts_input_data3.txt'; +DROP TABLE t1; + +#-------------------------------------------------------------------------------------------- +# Create FTS with same word and numbers +EVAL CREATE TABLE t1 ( + FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a TEXT, + b TEXT + ) ENGINE = InnoDB; + +CREATE UNIQUE INDEX FTS_DOC_ID_INDEX on t1(FTS_DOC_ID); + + +let $counter = 1; +--disable_query_log + +# Generate input file using perl +perl; +use strict; +my $fname= "$ENV{'MYSQLTEST_VARDIR'}/tmp/fts_input_data4.txt"; +open FH,">$fname"; +my $record_counter = 1; +while ($record_counter < 101) { + my $word_counter = 1001; + my ($col1,$col2); + while ($word_counter < 1101) { + $col1 = $col1. "samerowword" ." "; + $col2 = $col2. "$word_counter" ." "; + $word_counter++; + } + print FH "$col1,$col2\n"; + $record_counter++; +} +close FH; +EOF + +EVAL LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/fts_input_data4.txt' +INTO TABLE t1 FIELDS TERMINATED BY ',' (a,b); +--enable_query_log +--echo "Loading data using LOAD DATA Command , File <MYSQLTEST_VARDIR>/tmp/fts_input_data4.txt" + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + +SELECT COUNT(*) FROM t1; + +SELECT COUNT(*) from t1 WHERE a like '%samerowword%'; + +SELECT COUNT(*) FROM t1 WHERE MATCH (a,b) + AGAINST ('samerowword' IN NATURAL LANGUAGE MODE); + +# boolean mode +SELECT COUNT(*) from t1 WHERE MATCH(a,b) AGAINST("+samerowword +1050" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 WHERE MATCH(a,b) AGAINST("+samerowword" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 WHERE MATCH(a,b) AGAINST("+samerowword -(1050)" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 WHERE MATCH a,b AGAINST ("+2001" IN BOOLEAN MODE); + +# query expansion +SELECT COUNT(*) from t1 WHERE MATCH(a,b) AGAINST ("samerowword" WITH QUERY EXPANSION); + +UPDATE t1 SET a = "using update" , b = "changing fulltext index record", +FTS_DOC_ID = FTS_DOC_ID + 10000 +WHERE MATCH(a,b) AGAINST("+samerowword +1050" IN BOOLEAN MODE); + +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+samerowword +1050" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+samerowword" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("changing fulltext" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); + +DELETE FROM t1 +WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); +SELECT COUNT(*) from t1 +WHERE MATCH(a,b) AGAINST("+chang* +fulltext" IN BOOLEAN MODE); + +ALTER TABLE t1 DROP INDEX idx; +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); +UPDATE t1 SET a = NULL , b = NULL ; + +SELECT COUNT(*) FROM t1 WHERE a IS NULL AND b IS NULL; +ALTER TABLE t1 DROP INDEX idx; +SELECT COUNT(*) FROM t1 WHERE a IS NULL AND b IS NULL; + +--remove_file '$MYSQLTEST_VARDIR/tmp/fts_input_data4.txt'; +DROP TABLE t1; + diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test b/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test new file mode 100644 index 00000000..c2d1d826 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_misc.test @@ -0,0 +1,1352 @@ +#----------------------------------------------------------------------------- +# Test With alter/create/drop index +#----------------------------------------------------------------------------- + +--source include/have_innodb.inc +--source include/no_valgrind_without_big.inc +--source include/default_charset.inc +let collation=UTF8_UNICODE_CI; +--source include/have_collation.inc + +# Create FTS table +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'); + +# Create the FTS index Using Alter Table +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); +EVAL SHOW CREATE TABLE t1; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# Select word "tutorial" in the table +SELECT id FROM t1 WHERE MATCH (a,b) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +# boolean mode +select id from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +select id, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; +select id, MATCH(a,b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; +select id from t1 where MATCH a,b AGAINST ("+call* +coll*" IN BOOLEAN MODE); +select id from t1 where MATCH a,b AGAINST ('"support now"' IN BOOLEAN MODE); +select id from t1 where MATCH a,b AGAINST ('"Now sUPPort"' IN BOOLEAN MODE); + +# query expansion +select id from t1 where MATCH(a,b) AGAINST ("collections" WITH QUERY EXPANSION); +select id from t1 where MATCH(a,b) AGAINST ("indexes" WITH QUERY EXPANSION); +select id from t1 where MATCH(a,b) AGAINST ("indexes collections" WITH QUERY EXPANSION); + +# Drop index +ALTER TABLE t1 DROP INDEX idx; + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + +# Select word "tutorial" in the table +SELECT id FROM t1 WHERE MATCH (a,b) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +# boolean mode +select id from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +select id, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; +select id, MATCH(a,b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; +select id from t1 where MATCH a,b AGAINST ("+call* +coll*" IN BOOLEAN MODE); +select id from t1 where MATCH a,b AGAINST ('"support now"' IN BOOLEAN MODE); +select id from t1 where MATCH a,b AGAINST ('"Now sUPPort"' IN BOOLEAN MODE); + +# query expansion +select id from t1 where MATCH(a,b) AGAINST ("collections" WITH QUERY EXPANSION); +select id from t1 where MATCH(a,b) AGAINST ("indexes" WITH QUERY EXPANSION); +select id from t1 where MATCH(a,b) AGAINST ("indexes collections" WITH QUERY EXPANSION); + +# insert for proximity search +INSERT INTO t1 (a,b) VALUES ('test query expansion','for database ...'); +# Insert into table with similar word of different distances +INSERT INTO t1 (a,b) VALUES + ('test proximity search, test, proximity and phrase', + 'search, with proximity innodb'); + +INSERT INTO t1 (a,b) VALUES + ('test proximity fts search, test, proximity and phrase', + 'search, with proximity innodb'); + +INSERT INTO t1 (a,b) VALUES + ('test more proximity fts search, test, more proximity and phrase', + 'search, with proximity innodb'); + +# This should only return the first document +SELECT id FROM t1 + WHERE MATCH (a,b) + AGAINST ('"proximity search"@2' IN BOOLEAN MODE); + +# This would return no document +SELECT id FROM t1 + WHERE MATCH (a,b) + AGAINST ('"proximity search"@1' IN BOOLEAN MODE); + +# This give you all three documents +SELECT id FROM t1 + WHERE MATCH (a,b) + AGAINST ('"proximity search"@3' IN BOOLEAN MODE); + +# Similar boundary testing for the words +SELECT id FROM t1 + WHERE MATCH (a,b) + AGAINST ('"test proximity"@3' IN BOOLEAN MODE); + +# Test with more word The last document will return, please notice there +# is no ordering requirement for proximity search. +SELECT id FROM t1 + WHERE MATCH (a,b) + AGAINST ('"more test proximity"@3' IN BOOLEAN MODE); + +SELECT id FROM t1 + WHERE MATCH (a,b) + AGAINST ('"more test proximity"@2' IN BOOLEAN MODE); + +# The phrase search will not require exact word ordering +SELECT id FROM t1 + WHERE MATCH (a,b) + AGAINST ('"more fts proximity"@02' IN BOOLEAN MODE); + +DROP TABLE t1; + + + +#------------------------------------------------------------------------------ +# Test with FTS condition in subquery +#------------------------------------------------------------------------------ + +# Create FTS table +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB; + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'); + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + + +# Select word "tutorial" in the table +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +# Select word "tutorial" in the table +SELECT id FROM t1 WHERE id = (SELECT MAX(id) FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)); + +# Select word "tutorial" in the table +SELECT id FROM t1 WHERE id = (SELECT MIN(id) FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)); + +# Select word "tutorial" in the table +SELECT id FROM t1 WHERE id = (SELECT MIN(id) FROM t1 WHERE MATCH (a,b) +AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)) OR id = 3 ; + + +# Select word "tutorial" in the table - innodb crash +SELECT id FROM t1 WHERE CONCAT(t1.a,t1.b) IN ( +SELECT CONCAT(a,b) FROM t1 AS t2 WHERE +MATCH (t2.a,t2.b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +) OR t1.id = 3 ; + + +# Select word "tutorial" in the table - innodb crash +SELECT id FROM t1 WHERE CONCAT(t1.a,t1.b) IN ( +SELECT CONCAT(a,b) FROM t1 AS t2 +WHERE MATCH (t2.a,t2.b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +AND t2.id != 3) ; + +# Select word "tutorial" in the table +SELECT id FROM t1 WHERE id IN (SELECT MIN(id) FROM t1 WHERE +MATCH (a,b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)) OR id = 3 ; + +# Select word except "tutorial" in the table +SELECT id FROM t1 WHERE id NOT IN (SELECT MIN(id) FROM t1 +WHERE MATCH (a,b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)) ; + + +# Select word "tutorial" in the table +SELECT id FROM t1 WHERE EXISTS (SELECT t2.id FROM t1 AS t2 WHERE +MATCH (t2.a,t2.b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +AND t1.id = t2.id) ; + + +# Select not word like "tutorial" using subquery +SELECT id FROM t1 WHERE NOT EXISTS (SELECT t2.id FROM t1 AS t2 WHERE +MATCH (t2.a,t2.b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +AND t1.id = t2.id) ; + +DROP TABLE t1; + +# boolean search +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT , + FULLTEXT (a,b) + ) ENGINE = InnoDB; + +INSERT INTO t1(a,b) VALUES('MySQL has now support', 'for full-text search'), +('Full-text indexes', 'are called collections'), +('Only MyISAM tables','support collections'), +('Function MATCH ... AGAINST()','is used to do a search'), +('Full-text search in MySQL', 'implements vector space model'); + +# Select word "tutorial" in the table +SELECT id FROM t1 WHERE t1.id = (SELECT MAX(t2.id) FROM t1 AS t2 WHERE + MATCH(t2.a,t2.b) AGAINST("+support +collections" IN BOOLEAN MODE)); +SELECT id FROM t1 WHERE t1.id != (SELECT MIN(t2.id) FROM t1 AS t2 WHERE + MATCH(t2.a,t2.b) AGAINST("+search" IN BOOLEAN MODE)); + +SELECT id FROM t1 WHERE t1.id IN (SELECT t2.id FROM t1 AS t2 WHERE +MATCH (t2.a,t2.b) AGAINST ("+call* +coll*" IN BOOLEAN MODE)); + +SELECT id FROM t1 WHERE EXISTS (SELECT id FROM t1 AS t2 WHERE +MATCH t2.a,t2.b AGAINST ('"Now sUPPort"' IN BOOLEAN MODE) AND t2.id=t1.id); + + +#query expansion search +# result differ for query expansion search even wo subquery +#SELECT id FROM t1 WHERE t1.id = ( SELECT MAX(t2.id) FROM t1 AS t2 WHERE +#MATCH(a,b) AGAINST ("collections" WITH QUERY EXPANSION)); +#SELECT id FROM t1 WHERE t1.id IN ( SELECT t2.id FROM t1 AS t2 WHERE +#MATCH(a,b) AGAINST ("indexes" WITH QUERY EXPANSION)); +#SELECT id FROM t1 WHERE ( SELECT COUNT(*) FROM t1 AS t2 WHERE +#MATCH(t2.a,t2.b) AGAINST ("indexes collections" WITH QUERY EXPANSION)) >= 1 +#AND t1.id <=3 ; + +# proximity search +# insert for proximity search +INSERT INTO t1 (a,b) VALUES ('test query expansion','for database ...'); +# Insert into table with similar word of different distances +INSERT INTO t1 (a,b) VALUES + ('test proximity search, test, proximity and phrase', + 'search, with proximity innodb'); + +INSERT INTO t1 (a,b) VALUES + ('test proximity fts search, test, proximity and phrase', + 'search, with proximity innodb'); + +INSERT INTO t1 (a,b) VALUES + ('test more proximity fts search, test, more proximity and phrase', + 'search, with proximity innodb'); + + +SELECT id FROM t1 WHERE t1.id = (SELECT MAX(t2.id) FROM t1 AS t2 WHERE +MATCH(t2.a,t2.b) AGAINST ('"proximity search"@2' IN BOOLEAN MODE)); +SELECT id FROM t1 WHERE t1.id > (SELECT MIN(t2.id) FROM t1 AS t2 WHERE +MATCH(t2.a,t2.b) AGAINST ('"proximity search"@2' IN BOOLEAN MODE)); + +SELECT id FROM t1 WHERE t1.id IN (SELECT t2.id FROM t1 AS t2 WHERE +MATCH (t2.a,t2.b) AGAINST ('"proximity search"@2' IN BOOLEAN MODE)); + +SELECT id FROM t1 WHERE EXISTS (SELECT id FROM t1 AS t2 WHERE +MATCH t2.a,t2.b AGAINST ('"proximity search"@2' IN BOOLEAN MODE) +AND t2.id=t1.id); + +SELECT id FROM t1 WHERE EXISTS (SELECT id FROM t1 AS t2 WHERE +MATCH t2.a,t2.b AGAINST ('"more test proximity"@3' IN BOOLEAN MODE) +AND t2.id=t1.id); + +SELECT id FROM t1 WHERE EXISTS (SELECT id FROM t1 AS t2 WHERE +MATCH t2.a,t2.b AGAINST ('"more test proximity"@2' IN BOOLEAN MODE) +AND t2.id=t1.id); + + +#------------------------------------------------------------------------------ +# create table AS SELECT from fts indexed table +#------------------------------------------------------------------------------ +CREATE TABLE t2 ENGINE = InnoDB AS SELECT id FROM t1 WHERE +MATCH a,b AGAINST ('support') ; +SHOW CREATE TABLE t2; +SELECT id FROM t2; +DROP TABLE t2; + +CREATE TABLE t2 ENGINE = InnoDB AS SELECT id FROM t1 WHERE +MATCH a,b AGAINST("+support +collections" IN BOOLEAN MODE); +SHOW CREATE TABLE t2; +SELECT id FROM t2; +DROP TABLE t2; + +CREATE TABLE t2 ENGINE = InnoDB AS SELECT id FROM t1 WHERE +MATCH a,b AGAINST ('"proximity search"@10' IN BOOLEAN MODE); +SHOW CREATE TABLE t2; +SELECT id FROM t2; +DROP TABLE t2; + +DROP TABLE t1; + + +#------------------------------------------------------------------------------ +# Verift FTS with NULL records +#------------------------------------------------------------------------------ +# Create FTS table +EVAL CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB; + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + + +# Insert rows +INSERT INTO t1 (a,b) VALUES +('MySQL from Tutorial','DBMS stands for DataBase ...'); + +let $counter = 50; +--disable_query_log +WHILE ($counter > 0) { + INSERT INTO t1 (a,b) VALUES (NULL,NULL); + dec $counter; +} +--enable_query_log +INSERT INTO t1 (a,b) VALUES +('when To Use MySQL Well','After that you went through a ...'); + +let $counter = 50; +--disable_query_log +WHILE ($counter > 0) { + INSERT INTO t1 (a,b) VALUES (NULL,NULL); + dec $counter; +} +--enable_query_log +INSERT INTO t1 (a,b) VALUES +('where will Optimizing MySQL','what In this tutorial we will show ...'); + +INSERT INTO t1 (a,b) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), +('MySQL vs. YourSQL','In the following database comparison ...'), +('MySQL Security','When configured properly, MySQL null...'); + +SELECT COUNT(*) FROM t1; +SELECT COUNT(*) FROM t1 WHERE a IS NULL; +SELECT COUNT(*) FROM t1 WHERE b IS NOT NULL; + +SELECT id FROM t1 + WHERE MATCH (a,b) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +SELECT id FROM t1 + WHERE MATCH (a,b) + AGAINST (NULL IN NATURAL LANGUAGE MODE); +SELECT id FROM t1 + WHERE MATCH (a,b) + AGAINST (NULL WITH QUERY EXPANSION); +SELECT id FROM t1 + WHERE MATCH (a,b) + AGAINST ('null' IN NATURAL LANGUAGE MODE); +# Boolean search +# Select rows contain "MySQL" but not "YourSQL" +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE); +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE) AND (a IS NOT NULL OR b IS NOT NULL); +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('+MySQL -YourSQL' IN BOOLEAN MODE) AND (a IS NULL AND b IS NOT NULL); + +# Select rows contain at least one of the two words +SELECT id FROM t1 WHERE MATCH (a,b) +AGAINST ('DBMS Security' IN BOOLEAN MODE); + +# Test query expansion +SELECT COUNT(*) FROM t1 +WHERE MATCH (a,b) +AGAINST ('database' WITH QUERY EXPANSION); + +# proximity +SELECT id FROM t1 +WHERE MATCH (a,b) +AGAINST ('"following database"@10' IN BOOLEAN MODE); + + +DROP TABLE t1; + + + +#------------------------------------------------------------------------------ +# More FTS test from peter's testing +#------------------------------------------------------------------------------ +set names utf8; + + +--echo "----------Test1---------" +# Create FTS table +create table t50 (s1 varchar(60) character set utf8 collate utf8_bin) engine = innodb; +create fulltext index i on t50 (s1); +# INNODB_FTS: Assert - fixed +# Assert : InnoDB: Failing assertion: rbt_validate(result_doc->tokens) +insert into t50 values ('ABCDE'),('FGHIJ'),('KLMNO'),('VÃÆ·WÄ°'); +# it was giving empty result set instead of one record +select * from t50 where match(s1) against ('VÃÆ·WÄ°'); +drop table t50; + + +--echo "----------Test2---------" +create table t50 (s1 int unsigned primary key auto_increment, s2 +varchar(60) character set utf8) engine = innodb; +create fulltext index i on t50 (s2); +insert into t50 (s2) values ('FGHIJ'),('KLMNO'),('VÃÆ·WÄ°'),('ABCDE'); +# INNODB_FTS: RESULT DIFF +# Order by does not sort result. +# Optimizer's Evgeny is investigate a similar issue. InnoDB FTS is used only +# for FT search, and should not be used as regular index for such order by query. +# Correct the result file when fixed. +select * from t50 order by s2; +drop table t50; + + +--echo "----------Test3---------" +create table t50 (id int unsigned primary key auto_increment, s2 +varchar(60) character set utf8) engine = innodb; +create fulltext index i on t50 (s2); +insert into t50 (s2) values ('FGHIJ'),('KLMNO'),('VÃÆ·WÄ°'),('ABCDE'); +set @@autocommit=0; +update t50 set s2 = lower(s2); +update t50 set s2 = upper(s2); +commit; +select * from t50 where match(s2) against ('VÃÆ·WÄ° FGHIJ KLMNO ABCDE' in boolean mode); +select * from t50; +drop table t50; +set @@autocommit=1; + +--echo "----------Test4---------" +create table t50 (id int unsigned primary key auto_increment, s2 +varchar(60) character set utf8) engine = innodb; +create fulltext index i on t50 (s2); +insert into t50 (s2) values ('FGHIJ'),('KLMNO'),('VÃÆ·WÄ°'),('ABCD*'); +select * from t50 where match(s2) against ('abcd*' in natural language +mode); +# INNODB_FTS: RESULT DIFF(Expected). InnoDB do not index "*", so +# word "ABCD" indexed, instead of "ABCD*" +select * from t50 where match(s2) against ('abcd*' in boolean mode); +drop table t50; + + +--echo "----------Test5---------" +create table t50 (s1 int, s2 varchar(200), fulltext key(s2)) engine = innodb; +set @@autocommit=0; +insert into t50 values (1,'Sunshine'),(2,'Lollipops'); +select * from t50 where match(s2) against('Rainbows'); +rollback; +select * from t50; +drop table t50; +set @@autocommit=1; + +--echo "----------Test6---------" +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('aab` MySQL Tutorial','DBMS stands for DataBase ...') , + ('aas How To Use MySQL Well','After you went through a ...'), + ('aac Optimizing MySQL','In this tutorial we will show ...'); +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('aac 1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('aab MySQL vs. YourSQL','In the following database comparison ...'), + ('aaa MySQL Security','When configured properly, MySQL ...'); +# Create the FTS index Using Alter Table +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); + +-- disable_query_log +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log +-- enable_query_log + +SELECT * FROM t1 ORDER BY MATCH(a,b) AGAINST ('aac') DESC; +SELECT * FROM t1 ORDER BY MATCH(a,b) AGAINST ('aab') DESC; + +--echo "----------Test7---------" +select * from t1 where match(a,b) against ('aaa') +union select * from t1 where match(a,b) against ('aab') +union select * from t1 where match(a,b) against ('aac'); + +select * from t1 where match(a,b) against ('aaa') + or match(a,b) against ('aab') + or match(a,b) against ('aac'); + +DROP TABLE t1; + +--echo "----------Test8---------" +# Create FTS table +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ... abcd') , + ('How To Use MySQL Well','After you went through a q ...abdd'), + ('Optimizing MySQL','In this tutorial we will show ...abed'); + +# Create the FTS index Using Alter Table +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); +EVAL SHOW CREATE TABLE t1; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. q ...'), + ('MySQL vs. YourSQL use','In the following database comparison ...'), + ('MySQL Security','When run configured properly, MySQL ...'); + +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ('run'); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ('use'); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ('went'); +# rows should be matched as 'q' is single char its not indexed +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ('run') AND NOT MATCH(a,b) AGAINST ('q'); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ('use') AND NOT MATCH(a,b) AGAINST ('q'); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ('went') AND NOT MATCH(a,b) AGAINST ('q'); + +--echo "----------Test9---------" +CREATE TABLE t2 AS SELECT * FROM t1; +ALTER TABLE t2 ENGINE=MYISAM; +CREATE FULLTEXT INDEX i ON t2 (a,b); +SET @x = (SELECT COUNT(*) FROM t1 WHERE MATCH(a,b) AGAINST ('run')); +SET @x = @x + (SELECT COUNT(*) FROM t1 WHERE MATCH(a,b) AGAINST ('use')); +SET @x = @x + (SELECT COUNT(*) FROM t1 WHERE MATCH(a,b) AGAINST ('went')); +SET @x = @x + (SELECT COUNT(*) FROM t1 WHERE MATCH(a,b) AGAINST ('run')); +SET @x2 = (SELECT COUNT(*) FROM t2 WHERE MATCH(a,b) AGAINST ('run')); +SET @x2 = @x2 + (SELECT COUNT(*) FROM t2 WHERE MATCH(a,b) AGAINST ('use')); +SET @x2 = @x2 + (SELECT COUNT(*) FROM t2 WHERE MATCH(a,b) AGAINST ('went')); +SET @x2 = @x2 + (SELECT COUNT(*) FROM t2 WHERE MATCH(a,b) AGAINST ('run')); +# Innodb returns value for x which is correct +SELECT @x, @x2; + + +DROP TABLE t2; + +--echo "----------Test10---------" +CREATE TABLE t2 AS SELECT * FROM t1; +ALTER TABLE t2 ENGINE=MYISAM; +CREATE FULLTEXT INDEX i ON t2 (a,b); +SELECT COUNT(*) FROM t2 WHERE MATCH(a,b) AGAINST ('abc*' IN BOOLEAN MODE); +SELECT COUNT(*) FROM t1 WHERE MATCH(a,b) AGAINST ('abc*' IN BOOLEAN MODE); + +DROP TABLE t2; + + +--echo "----------Test11---------" +CREATE TABLE t2 AS SELECT * FROM t1; +ALTER TABLE t2 ENGINE = MYISAM; +CREATE FULLTEXT INDEX i ON t2 (a,b); +ALTER TABLE t2 ENGINE=InnoDB; +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ('run'); +SELECT COUNT(*) FROM t2 WHERE MATCH(a,b) AGAINST ('abc*' IN BOOLEAN MODE); +DROP TABLE t2,t1; + + +--echo "----------Test13---------" +set names utf8; + +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200) CHARACTER SET UTF8 COLLATE UTF8_SPANISH_CI) ENGINE = InnoDB; +CREATE FULLTEXT INDEX i ON t1 (s2); +INSERT INTO t1 VALUES (1,'aaCen'),(2,'aaCha'),(3,'aaCio'),(4,'aaçen'),(5,'aaçha'),(6,'aaçio'); +SELECT * FROM t1 WHERE MATCH(s2) AGAINST ('aach*' IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH(s2) AGAINST ('aaC*' IN BOOLEAN MODE); +DROP TABLE t1; + +--echo "----------Test14---------" +CREATE TABLE t1(s1 INT , s2 VARCHAR(100) CHARACTER SET sjis) ENGINE = InnoDB; +CREATE FULLTEXT INDEX i ON t1 (s2); +INSERT INTO t1 VALUES (1,'ペペペ'),(2,'テテテ'),(3,'ルルル'),(4,'ã‚°ã‚°ã‚°'); +# Innodb Asset : file ha_innodb.cc line 4557 +#SELECT * FROM t1 WHERE MATCH(s2) AGAINST ('テテ*' IN BOOLEAN MODE); +DROP TABLE t1; + + +--echo "----------Test15---------" +CREATE TABLE t1 (s1 VARCHAR (60) CHARACTER SET UTF8 COLLATE UTF8_UNICODE_520_CI) ENGINE = MyISAM; +CREATE FULLTEXT INDEX i ON t1 (s1); +INSERT INTO t1 VALUES +('a'),('b'),('c'),('d'),('ÅÅÅÅ'),('LLLL'),(NULL),('ÅÅÅÅ ÅÅÅÅ'),('LLLLLLLL'); +SELECT * FROM t1 WHERE MATCH(s1) AGAINST ('LLLL' COLLATE UTF8_UNICODE_520_CI); +CREATE TABLE t2 (s1 VARCHAR(60) CHARACTER SET UTF8 COLLATE UTF8_POLISH_CI) ENGINE = InnoDB; +CREATE FULLTEXT INDEX i ON t2 ( s1); +INSERT INTO t2 VALUES +('a'),('b'),('c'),('d'),('ÅÅÅÅ'),('LLLL'),(NULL),('ÅÅÅÅ ÅÅÅÅ'),('LLLLLLLL'); +SELECT * FROM t2 WHERE MATCH(s1) AGAINST ('LLLL' COLLATE UTF8_UNICODE_520_CI); +--disable_warnings +DROP TABLE t1,t2; +--enable_warnings + +--echo "----------Test16---------" +CREATE TABLE t1 (s1 INT, s2 VARCHAR(50) CHARACTER SET UTF8) ENGINE = InnoDB; +CREATE FULLTEXT INDEX i ON t1(s2); +INSERT INTO t1 VALUES (2, 'ÄŸÄ— DaÅ›i p '); +SELECT * FROM t1 WHERE MATCH(s2) AGAINST ('+p +"ÄŸÄ— DaÅ›i*"' IN BOOLEAN MODE); +DROP TABLE t1; + + +--echo "----------Test19---------" +#19 Failure with Boolean quoted search +CREATE TABLE t1 ( id INT , char_column VARCHAR(60) CHARACTER SET UTF8) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,'Ä°Ã³Ã«É '); +CREATE FULLTEXT INDEX i ON t1 (char_column); +SELECT * FROM t1 WHERE MATCH(char_column) AGAINST ('"Ä°Ã³Ã«É "' IN BOOLEAN MODE); +DROP TABLE t1; + +--echo "----------Test20---------" +#20 Crash with utf32 and boolean mode. +CREATE TABLE t1 ( id INT , char_column VARCHAR(60) CHARACTER SET UTF32, char_column2 VARCHAR(60) character set utf8) ENGINE = InnoDB; +INSERT INTO t1 (char_column) VALUES ('abcde'),('fghij'),('klmno'),('qrstu'); +UPDATE t1 SET char_column2 = char_column; +CREATE FULLTEXT INDEX i ON t1 (char_column2); +--error ER_FT_MATCHING_KEY_NOT_FOUND +SELECT * FROM t1 WHERE MATCH(char_column) AGAINST ('abc*' IN BOOLEAN MODE); +DROP TABLE t1; + +--echo "----------Test22---------" +# case 22 +CREATE TABLE t1 ( id INT , char_column VARCHAR(60) CHARACTER SET UTF8) ENGINE = InnoDB; +INSERT INTO t1 VALUES (1,'aaa'),(2,'bbb'),(3,'ccc'); +CREATE FULLTEXT INDEX i ON t1 (char_column); +HANDLER t1 OPEN; +--error ER_KEY_DOESNT_SUPPORT +HANDLER t1 READ i = ('aaa'); +DROP TABLE t1; +#23. Duplicate key error when there are no unique indexes (procedure test) +#24 Failure after cascading update - already have tests + +--echo "----------Test25---------" +#25 Failure with Croatian boolean truncated search. +CREATE TABLE t1 ( id INT , char_column VARCHAR(60) CHARACTER SET UTF8 COLLATE UTF8_CROATIAN_CI) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,'LJin'),(2,'ljin'),(3,'lmin'),(4,'LJLJLJLJLJ'); +CREATE FULLTEXT INDEX i ON t1 (char_column); +#inndob:error incorrect result correct it after fix +SELECT count(*) FROM t1 WHERE MATCH (char_column) AGAINST ('lj*' IN BOOLEAN MODE); +DROP TABLE t1; + +#26. Index error when run procedure call from multiple clients + +--echo "----------Test27---------" +#27 Crash after server restart +CREATE TABLE t1 (id INT,char_column VARCHAR(60)); +CREATE TABLE t2 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, a TEXT)ENGINE=InnoDB; +ALTER TABLE t2 DROP a; +CREATE FULLTEXT INDEX i ON t1 (char_column); +INSERT INTO t1 values (1,'aaa'); + +CREATE TABLE mdev20987_1(f1 INT NOT NULL, PRIMARY KEY(f1))ENGINE=InnoDB; +CREATE TABLE mdev20987_2(f1 INT NOT NULL, f2 CHAR(100), + FULLTEXT(f2), + FOREIGN KEY(f1) REFERENCES mdev20987_1(f1))ENGINE=InnoDB; +INSERT INTO mdev20987_1 VALUES(1); +INSERT INTO mdev20987_2 VALUES(1, 'mariadb'); + +CREATE TABLE mdev22358 (a INT, b TEXT, FULLTEXT KEY ftidx (b)) ENGINE=InnoDB; +ALTER TABLE mdev22358 DROP KEY ftidx; +INSERT INTO mdev22358 (a) VALUES (2),(2); +--error ER_DUP_ENTRY +ALTER TABLE mdev22358 ADD UNIQUE KEY uidx (a), ADD FULLTEXT KEY ftidx (b); +--source include/restart_mysqld.inc +SHOW CREATE TABLE t2; +DELETE FROM t1 WHERE MATCH(char_column) AGAINST ('bbb'); +DROP TABLE t1, t2, mdev20987_2, mdev20987_1, mdev22358; + +--echo "----------Test28---------" +create table `fts_test`(`a` text,fulltext key(`a`))engine=innodb; +set session autocommit=0; +insert into `fts_test` values (''); +savepoint `b`; +savepoint `b`; +set session autocommit=1; +DROP TABLE fts_test; + +# Continue test savepoint related operations. With a commit after +# multiple rollback to savepoints +--echo "----------Test29---------" +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) + ) ENGINE=InnoDB; + +INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...'); + + +start transaction; + +INSERT INTO articles (title,body) VALUES +('How To Use MySQL Well','After you went through a ...'); + +savepoint `a1`; + +INSERT INTO articles (title,body) VALUES +('Optimizing MySQL','In this tutorial we will show ...'); + +savepoint `a2`; + +INSERT INTO articles (title,body) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'); + +savepoint `a3`; + +INSERT INTO articles (title,body) VALUES +('MySQL vs. YourSQL','In the following database comparison ...'); + +savepoint `a4`; + +# FTS do not parse those uncommitted rows, only one row should show up +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('Database' IN NATURAL LANGUAGE MODE); + +rollback to savepoint a3; + +# The last inserted row should not be there +select title, body from articles; + +INSERT INTO articles (title,body) VALUES +('MySQL Security','When configured properly, MySQL ...'); + +savepoint `a5`; + +select title, body from articles; + +rollback to savepoint a2; + +select title, body from articles; + +commit; + +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('Database' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; + +# Continue test savepoint related operations. With a rollback after +# multiple rollback to savepoints +--echo "----------Test30---------" +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) + ) ENGINE=InnoDB; + +INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...'); + +start transaction; + +INSERT INTO articles (title,body) VALUES +('How To Use MySQL Well','After you went through a ...'); + +savepoint `a1`; + +INSERT INTO articles (title,body) VALUES +('Optimizing MySQL','In this tutorial we will show ...'); + +savepoint `a2`; + +INSERT INTO articles (title,body) VALUES +('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'); + +savepoint `a3`; + +INSERT INTO articles (title,body) VALUES +('MySQL vs. YourSQL','In the following database comparison ...'); + +savepoint `a4`; + +# FTS do not parse those uncommitted rows, only one row should show up +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('Database' IN NATURAL LANGUAGE MODE); + +rollback to savepoint a3; + +# The last inserted row should not be there +select title, body from articles; + +INSERT INTO articles (title,body) VALUES +('MySQL Security','When configured properly, MySQL ...'); + +savepoint `a5`; + +select title, body from articles; + +rollback to savepoint a2; + +select title, body from articles; + +rollback; + +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('Database' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles + WHERE MATCH (title,body) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; + +# Test for Bug #13907075 - DIFFERENT RESULTS FOR DIFFERENT TERM ORDER +# WITH INNODB BOOLEAN FULLTEXT SEARCH. The FTS_IGNORE ("-") operation +# is orderless +# Create FTS table +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) + ) ENGINE=InnoDB; + +# Insert six rows +INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +-- disable_result_log +ANALYZE TABLE articles; +-- enable_result_log + +SELECT *, MATCH(title, body) AGAINST ('-database +MySQL' IN BOOLEAN MODE) AS score from articles; + +SELECT *, MATCH(title, body) AGAINST ('+MySQL -database' IN BOOLEAN MODE) AS score FROM articles; + +# With subquery +SELECT * FROM articles where MATCH(title, body) AGAINST ('MySQL - (database - tutorial)' IN BOOLEAN MODE); + +SELECT * FROM articles where MATCH(title, body) AGAINST ('MySQL - (- tutorial database)' IN BOOLEAN MODE); + +# More complex query +SELECT * FROM articles where MATCH(title, body) AGAINST ('MySQL - (- tutorial database) -Tricks' IN BOOLEAN MODE); + +SELECT * FROM articles where MATCH(title, body) AGAINST ('-Tricks MySQL - (- tutorial database)' IN BOOLEAN MODE); + +DROP TABLE articles; + +# Test for Bug 13940669 - 64901: INNODB: ASSERTION FAILURE IN +# THREAD 34387022112 IN FILE REM0CMP.CC LINE 5 + +create table t1 (FTS_DOC_ID bigint unsigned auto_increment not null primary key, +title varchar(200),body text,fulltext(title,body)) engine=innodb; + +insert into t1 set body='test'; + +select * from t1 where match(title,body) against('%test'); + +select * from t1 where match(title,body) against('%'); + +select * from t1 where match(title,body) against('%%%%'); + +drop table t1; + +# Test for Bug 13881758 - 64745: CREATE FULLTEXT INDEX CAUSES CRASH +# Create a database with empty space in its name +CREATE DATABASE `benu database`; + +USE `benu database`; + +# Create FTS table +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'); + +# Create the FTS index Using Alter Table +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); +EVAL SHOW CREATE TABLE t1; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# Select word "tutorial" in the table +SELECT id FROM t1 WHERE MATCH (a,b) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +# boolean mode +select id from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +select id, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; +select id, MATCH(a,b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; +select id from t1 where MATCH a,b AGAINST ("+call* +coll*" IN BOOLEAN MODE); +select id from t1 where MATCH a,b AGAINST ('"support now"' IN BOOLEAN MODE); +select id from t1 where MATCH a,b AGAINST ('"Now sUPPort"' IN BOOLEAN MODE); + +DROP DATABASE `benu database`; + +USE test; + +# Test for Bug #14101706 - CRASH WITH DDL IN ROW_MERGE_BUILD_INDEXES +# WHEN FULLTEXT INDEXES EXIST + +CREATE TABLE `t21` (`a` text, `b` int not null, +fulltext key (`a`), fulltext key (`a`) +) ENGINE=INNODB DEFAULT CHARSET=LATIN1; + +--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON +ALTER TABLE `t21` ADD UNIQUE INDEX (`b`), ALGORITHM=INPLACE; +ALTER TABLE `t21` ADD UNIQUE INDEX (`b`); + +DROP TABLE t21; + +CREATE TABLE `t21` (`a` text, `b` int not null, +fulltext key (`a`)) ENGINE=INNODB DEFAULT CHARSET=LATIN1; + +ALTER TABLE `t21` ADD UNIQUE INDEX (`b`); + +DROP TABLE t21; + +# Test primary index rebuild +CREATE TABLE t1 ( + id INT NOT NULL, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB; + +# Insert rows +INSERT INTO t1 VALUES + (1, 'MySQL Tutorial','DBMS stands for DataBase ...') , + (2, 'How To Use MySQL Well','After you went through a ...'), + (3, 'Optimizing MySQL','In this tutorial we will show ...'); + +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); + +ALTER TABLE t1 ADD UNIQUE INDEX (`id`); + +# Select word "tutorial" in the table +SELECT id FROM t1 WHERE MATCH (a,b) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +# boolean mode +select id from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +select id, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; + +DROP TABLE t1; + +# Test create the FTS and primary index in the same clause +CREATE TABLE t1 ( + id INT NOT NULL, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB; + +# Insert rows +INSERT INTO t1 VALUES + (1, 'MySQL Tutorial','DBMS stands for DataBase ...') , + (2, 'How To Use MySQL Well','After you went through a ...'), + (3, 'Optimizing MySQL','In this tutorial we will show ...'); + +ALTER TABLE t1 ADD UNIQUE INDEX (`id`), ADD FULLTEXT INDEX idx (a,b); + +# Select word "tutorial" in the table +SELECT id FROM t1 WHERE MATCH (a,b) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +# boolean mode +select id from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +select id from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); + +DROP TABLE t1; + +# Create FTS table with FTS_DOC_ID already existed +CREATE TABLE t1 ( + FTS_DOC_ID BIGINT UNSIGNED NOT NULL, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB; + +# Insert rows +INSERT INTO t1 VALUES + (1, 'MySQL Tutorial','DBMS stands for DataBase ...') , + (2, 'How To Use MySQL Well','After you went through a ...'), + (3, 'Optimizing MySQL','In this tutorial we will show ...'); + +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); + +ALTER TABLE t1 ADD UNIQUE INDEX (`FTS_DOC_ID`); + +# Select word "tutorial" in the table +SELECT FTS_DOC_ID FROM t1 WHERE MATCH (a,b) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +# boolean mode +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +select FTS_DOC_ID, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; + +DROP TABLE t1; + +# Create FTS table with FTS_DOC_ID and FTS_DOC_ID_INDEX +CREATE TABLE t1 ( + FTS_DOC_ID BIGINT UNSIGNED NOT NULL, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB; + +# Insert rows +INSERT INTO t1 VALUES + (1, 'MySQL Tutorial','DBMS stands for DataBase ...') , + (2, 'How To Use MySQL Well','After you went through a ...'), + (3, 'Optimizing MySQL','In this tutorial we will show ...'); + +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b), ADD UNIQUE INDEX FTS_DOC_ID_INDEX (FTS_DOC_ID); + +# Select word "tutorial" in the table +SELECT FTS_DOC_ID FROM t1 WHERE MATCH (a,b) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +# boolean mode +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+support +collections" IN BOOLEAN MODE); +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+search" IN BOOLEAN MODE); +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+search +(support vector)" IN BOOLEAN MODE); +select FTS_DOC_ID from t1 where MATCH(a,b) AGAINST("+search -(support vector)" IN BOOLEAN MODE); +select FTS_DOC_ID, MATCH(a,b) AGAINST("support collections" IN BOOLEAN MODE) as x from t1; + +DROP TABLE t1; + +# Test for bug #14079609 - FTS: CRASH IN FTS_TRX_TABLE_CMP WITH SAVEPOINTS, XA + +CREATE TABLE t2 (`b` char(2),fulltext(`b`)) ENGINE=INNODB +DEFAULT CHARSET=LATIN1; + +CREATE TABLE t3 LIKE t2; + +INSERT INTO `t2` VALUES(); + +COMMIT WORK AND CHAIN; + +INSERT INTO `t3` VALUES (); +UPDATE `t2` SET `b` = 'a'; + +SAVEPOINT BATCH1; + +DROP TABLE t2; +DROP TABLE t3; + +# Create FTS table +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'); + +# Create the FTS index Using Alter Table +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); + +COMMIT WORK AND CHAIN; + +INSERT INTO t1 (a,b) VALUES + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +SAVEPOINT BATCH1; + +SELECT id FROM t1 WHERE MATCH (a,b) + AGAINST ('MySQL' IN NATURAL LANGUAGE MODE); + +INSERT INTO t1 (a,b) VALUES + ('1002 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + + +ROLLBACK TO SAVEPOINT BATCH1; + +COMMIT; + +SELECT id FROM t1 WHERE MATCH (a,b) + AGAINST ('MySQL' IN NATURAL LANGUAGE MODE); + +DROP TABLE t1; + +# Test for Bug 14588091 - FTS: BUFFER OVERFLOW IN FTS_AST_CREATE_NODE_TEXT +CREATE TABLE `t` (`a` char(20) character set utf8 default null, +fulltext key (`a`)) ENGINE=INNODB; +INSERT INTO `t` VALUES ('a'); +INSERT INTO `t` VALUES ('aaa'); + +# 0x22 is the '"', 0xdd is not encoded in utf8 +SELECT MATCH(`a`) AGAINST (0x22dd22) FROM `t`; +SELECT MATCH(`a`) AGAINST (0x2222) FROM `t`; +SELECT MATCH(`a`) AGAINST (0x22) FROM `t`; + +# this should show one match +SELECT MATCH(`a`) AGAINST (0x2261616122) FROM `t`; + +# again 0xdd should be ignored +SELECT MATCH(`a`) AGAINST (0x2261dd6122) FROM `t`; + +SELECT MATCH(`a`) AGAINST (0x2261dd612222226122) FROM `t`; + +DROP TABLE t; + +# InnoDB FTS does not support index scan from handler +CREATE TABLE t(a CHAR(1),FULLTEXT KEY(a)) ENGINE=INNODB; +HANDLER t OPEN; +HANDLER t READ a NEXT; +HANDLER t READ a PREV; +DROP TABLE t; + +CREATE TABLE `%`(a TEXT, FULLTEXT INDEX(a)) ENGINE=INNODB; +CREATE TABLE `A B`(a TEXT, FULLTEXT INDEX(a)) ENGINE=INNODB; +DROP TABLE `%`; +DROP TABLE `A B`; + +CREATE TABLE `t-26`(a VARCHAR(10),FULLTEXT KEY(a)) ENGINE=INNODB; +INSERT INTO `t-26` VALUES('117'); +DROP TABLE `t-26`; + +# Test on phrase search with stopwords contained in the search string +CREATE TABLE `t1` ( + `id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, + `content` TEXT NOT NULL, + PRIMARY KEY (`id`), + FULLTEXT INDEX `IDX_CONTEXT_FULLTEXT`(`content`) +) +ENGINE = InnoDB; + +insert into t1 (content) +values +('This is a story which has has a complicated phrase structure here in the +middle'), +('This is a story which doesn''t have that text'), +('This is a story that has complicated the phrase structure'); + +select * from t1 +where match(content) against('"complicated phrase structure"' in boolean +mode); + +# Test single phrase search with "+" symbol, one row should be returned +select * from t1 +where match(content) against('+"complicated phrase structure"' in boolean +mode); + +# Test phrase search with stopwords in between, one row should be returned +select * from t1 +where match(content) against('"complicated the phrase structure"' in boolean +mode); + +# Test phrase search with multiple "+" symbols +select * from t1 where match(content) against('+"this is a story which" +"complicated the phrase structure"' in boolean mode); + +# Test phrase search with leading word is a stopword, such stopword would be +# ignored +select * from t1 where match(content) against('"the complicated the phrase structure"' in boolean mode); + +# Test phrase search with non-matching stopword in between, no row should be +# returned +select * from t1 where match(content) against('"complicated a phrase structure"' in boolean mode); + +DROP TABLE t1; + +CREATE TABLE my (id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, +c VARCHAR(32), FULLTEXT(c)) ENGINE = INNODB; + +INSERT INTO my (c) VALUES ('green-iguana'); + +SELECT * FROM my WHERE MATCH(c) AGAINST ('green-iguana'); + +DROP TABLE my; + +CREATE TABLE ift ( + `a` int(11) NOT NULL, + `b` text, + PRIMARY KEY (`a`), + FULLTEXT KEY `b` (`b`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +INSERT INTO ift values (1, "skip"); +INSERT INTO ift values (2, "skip and networking"); +INSERT INTO ift values (3, "--skip-networking"); +INSERT INTO ift values (4, "-donot--skip-networking"); + +SELECT * FROM ift WHERE MATCH (b) AGAINST ('--skip-networking'); +SELECT * FROM ift WHERE MATCH (b) AGAINST ('skip-networking'); +SELECT * FROM ift WHERE MATCH (b) AGAINST ('----'); +SELECT * FROM ift WHERE MATCH (b) AGAINST ('-donot--skip-networking'); + +DROP TABLE ift; + +# Test special cases of wildword. +# Create FTS table +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) + ) ENGINE=InnoDB; + +# Insert six rows +INSERT INTO articles (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('( that''s me )','When configured properly, MySQL ...'); + +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('( yours''s* )' IN BOOLEAN MODE); + +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('s*' IN BOOLEAN MODE); + +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('stands\'] | * | show[@database' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; + +# Test for BUG#16429688 - FTS: SYNTAX ERROR, UNEXPECTED '*', EXPECTING $END +CREATE TABLE t1(a TEXT CHARACTER SET LATIN1, FULLTEXT INDEX(a)) ENGINE=INNODB; + +--error ER_PARSE_ERROR +SELECT * FROM t1 WHERE MATCH(a) AGAINST("*"); + +DROP TABLE t1; + +# Test for BUG#16516193 - LITERAL PHRASES CANNOT BE COMBINED WITH + OR - OPERATOR +# Create FTS table +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + FULLTEXT (a) + ) ENGINE= InnoDB; + +# Insert rows +INSERT INTO t1 (a) VALUES + ('Do you know MySQL is a good database'), + ('How to build a good database'), + ('Do you know'), + ('Do you know MySQL'), + ('How to use MySQL'), + ('Do you feel good'), + ('MySQL is good'), + ('MySQL is good to know'), + ('What is database'); + +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+"know mysql"' IN BOOLEAN MODE); + +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+("know mysql")' IN BOOLEAN MODE); + +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('("know mysql" good)' IN BOOLEAN MODE); + +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+("know mysql" good)' IN BOOLEAN MODE); + +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('(good "know mysql")' IN BOOLEAN MODE); + +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+(good "know mysql")' IN BOOLEAN MODE); + +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+("know mysql" "good database")' IN BOOLEAN MODE); + +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+"know mysql" +"good database"' IN BOOLEAN MODE); + +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+"know database"@4' IN BOOLEAN MODE); + +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+"know database"@8' IN BOOLEAN MODE); + +# Drop table +DROP TABLE t1; + +# Test for BUG#16885178 - INNODB FULLTEXT PHRASE SEARCH VALGRIND ERROR +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + FULLTEXT (a) + ) ENGINE= InnoDB; + +# Insert a special row +INSERT INTO t1 (a) VALUES + ('know mysql good database'); + +# This phrase search fails in valgrind test before the fix. +SELECT * FROM t1 WHERE MATCH (a) AGAINST ('+"good database"' IN BOOLEAN MODE); + +DROP TABLE t1; + +# MDEV-19974 InnoDB: Cannot load compressed BLOB +--disable_query_log +SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed; +SET GLOBAL innodb_read_only_compressed=OFF; +--enable_query_log + +CREATE TABLE t1(f1 TEXT, FULLTEXT KEY(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES(repeat("this is the test case", 500)); +ALTER TABLE t1 KEY_BLOCK_SIZE=4; +ALTER TABLE t1 KEY_BLOCK_SIZE=0; +--disable_query_log +SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed; +--enable_query_log +DROP TABLE t1; + diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.opt b/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.opt new file mode 100644 index 00000000..b38416a0 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.opt @@ -0,0 +1 @@ +--innodb-ft-deleted diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test b/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test new file mode 100644 index 00000000..4eaf5b2e --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_misc_1.test @@ -0,0 +1,969 @@ +--source include/have_innodb.inc + +#------------------------------------------------------------------------------ +# FTS with FK and update cascade +#------------------------------------------------------------------------------- +set names utf8; + +call mtr.add_suppression("\\[Warning\\] InnoDB: A new Doc ID must be supplied while updating FTS indexed columns."); +call mtr.add_suppression("\\[Warning\\] InnoDB: FTS Doc ID must be larger than [0-9]+ for table `test`.`t1`"); + +# Create FTS table +CREATE TABLE t1 ( + id1 INT , + a1 VARCHAR(200) , + b1 TEXT , + FULLTEXT KEY (a1,b1), PRIMARY KEY (a1, id1) + ) CHARACTER SET = utf8 , ENGINE = InnoDB; + +CREATE TABLE t2 ( + id2 INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a2 VARCHAR(200), + b2 TEXT , + FOREIGN KEY (a2) REFERENCES t1(a1) ON UPDATE CASCADE, + FULLTEXT KEY (b2,a2) + ) CHARACTER SET = utf8 ,ENGINE = InnoDB; + +# Insert rows +INSERT INTO t1 (id1,a1,b1) VALUES + (1,'MySQL Tutorial','DBMS stands for DataBase VÃÆ·WÄ°...') , + (2,'How To Use MySQL Well','After you went through a ...'), + (3,'Optimizing MySQL','In this tutorial we will show ...'); + +# Insert rows +INSERT INTO t1 (id1,a1,b1) VALUES + (4,'1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + (5,'MySQL vs. YourSQL','In the following database comparison ...'), + (6,'MySQL Security','When configured properly, MySQL ...'); + +# Insert rows in t2 fk table +INSERT INTO t2 (a2,b2) VALUES + ('MySQL Tutorial','DBMS stands for DataBase VÃÆ·WÄ°...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'); + +# Insert rows t2 fk table +INSERT INTO t2 (a2,b2) VALUES + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# error on violating fk constraint +--error 1452 +INSERT INTO t2 (a2,b2) VALUES + ('MySQL Tricks','1. Never run mysqld as root. 2. ...'); + +# error on delete from parent table +--error 1451 +DELETE FROM t1; + +ANALYZE TABLE t1; +ANALYZE TABLE t2; + +SELECT id1 FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial') ORDER BY id1; +SELECT id2 FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial') ORDER BY id2; + +SELECT id1 FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ORDER BY id1; +SELECT id2 FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ORDER BY id2; + +SELECT id1 FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial' WITH QUERY EXPANSION) ORDER BY id1; +SELECT id2 FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial' WITH QUERY EXPANSION) ORDER BY id2; + + +SELECT id1 FROM t1 WHERE MATCH (a1,b1) AGAINST ('"dbms database"@4' IN BOOLEAN MODE) ; +SELECT id2 FROM t2 WHERE MATCH (a2,b2) AGAINST ('"dbms database"@4' IN BOOLEAN MODE) ; + +set global innodb_optimize_fulltext_only=1; +optimize table t1; +set global innodb_optimize_fulltext_only=0; +# Updating parent table hence child table should get updated due to 'update cascade' clause +UPDATE t1 SET a1 = "changing column - on update cascade" , b1 = "to check foreign constraint" WHERE +MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; + +# no records expected +SELECT id1 FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; +# InnoDB:Error child table shows records which is incorrect - UPADTE on Fix +SELECT id2 FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; + +# it shows updated record +SELECT id1 FROM t1 WHERE MATCH (a1,b1) AGAINST ('+update +cascade' IN BOOLEAN MODE) ORDER BY id1; +# InnoDB:Error child table does not show the expected record +SELECT id2 FROM t2 WHERE MATCH (a2,b2) AGAINST ('+update +cascade' IN BOOLEAN MODE) ORDER BY id2; +SELECT id2 FROM t2 WHERE a2 LIKE '%UPDATE CASCADE%' ORDER BY id2; + +DROP TABLE t2 , t1; + +# on update cascade +create table t1 (s1 int, s2 varchar(200), primary key (s1,s2)) ENGINE = InnoDB; +create table t2 (s1 int, s2 varchar(200), + fulltext key(s2), + foreign key (s1,s2) references t1 (s1,s2) on update cascade) ENGINE = InnoDB; +insert into t1 values (1,'Sunshine'),(2,'Lollipops'); +insert into t2 values (1,'Sunshine'),(2,'Lollipops'); +update t1 set s2 = 'Rainbows' where s2 <> 'Sunshine'; +commit; +select * from t2 where match(s2) against ('Lollipops'); +DROP TABLE t2 , t1; + +# on delete cascade +create table t1 (s1 int, s2 varchar(200), primary key (s1,s2)) ENGINE = InnoDB; +create table t2 (s1 int, s2 varchar(200), + fulltext key(s2), + foreign key (s1,s2) references t1 (s1,s2) on delete cascade) ENGINE = InnoDB; +insert into t1 values (1,'Sunshine'),(2,'Lollipops'); +insert into t2 values (1,'Sunshine'),(2,'Lollipops'); +delete from t1 where s2 <> 'Sunshine'; +select * from t2 where match(s2) against ('Lollipops'); +DROP TABLE t2 , t1; + +# on delete set NULL +create table t1 (s1 int, s2 varchar(200), primary key (s1,s2)) ENGINE = InnoDB; +create table t2 (s1 int, s2 varchar(200), + fulltext key(s2), + foreign key (s1,s2) references t1 (s1,s2) on delete set null) ENGINE = InnoDB; +insert into t1 values (1,'Sunshine'),(2,'Lollipops'); +insert into t2 values (1,'Sunshine'),(2,'Lollipops'); +delete from t1 where s2 <> 'Sunshine'; +select * from t2 where match(s2) against ('Lollipops'); +DROP TABLE t2 , t1; + + +# on update set NULL +create table t1 (s1 int, s2 varchar(200), primary key (s1,s2)) ENGINE = InnoDB; +create table t2 (s1 int, s2 varchar(200), + fulltext key(s2), + foreign key (s1,s2) references t1 (s1,s2) on update set null) ENGINE = InnoDB; +insert into t1 values (1,'Sunshine'),(2,'Lollipops'); +insert into t2 values (1,'Sunshine'),(2,'Lollipops'); +update t1 set s2 = 'Rainbows' where s2 <> 'Sunshine'; +commit; +select * from t2 where match(s2) against ('Lollipops'); +DROP TABLE t2 , t1; + +# When Doc ID is involved +create table t1 (s1 bigint unsigned not null, s2 varchar(200), + primary key (s1,s2)) ENGINE = InnoDB; +create table t2 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL, s2 varchar(200), + foreign key (FTS_DOC_ID) references t1 (s1) + on update cascade) ENGINE = InnoDB; + +create fulltext index idx on t2(s2); + +show create table t2; + +insert into t1 values (1,'Sunshine'),(2,'Lollipops'); +insert into t2 values (1,'Sunshine'),(2,'Lollipops'); + +update t1 set s1 = 3 where s1=1; + +select * from t2 where match(s2) against ('sunshine'); + +# FTS Doc ID cannot be reused +--error 1451 +update t1 set s1 = 1 where s1=3; + +DROP TABLE t2 , t1; + +#------------------------------------------------------------------------------ +# FTS with FK and delete casecade +#------------------------------------------------------------------------------ + +# Create FTS table +CREATE TABLE t1 ( + id1 INT , + a1 VARCHAR(200) PRIMARY KEY, + b1 TEXT character set utf8 , + FULLTEXT KEY (a1,b1) + ) CHARACTER SET = utf8 ,ENGINE = InnoDB; + +CREATE TABLE t2 ( + id2 INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a2 VARCHAR(200), + b2 TEXT character set utf8 , + FOREIGN KEY (a2) REFERENCES t1(a1) ON DELETE CASCADE, + FULLTEXT KEY (b2,a2) + ) CHARACTER SET = utf8 ,ENGINE = InnoDB; + +# Insert rows +INSERT INTO t1 (id1,a1,b1) VALUES + (1,'MySQL Tutorial','DBMS stands for DataBase VÃÆ·WÄ°...') , + (2,'How To Use MySQL Well','After you went through a ...'), + (3,'Optimizing MySQL','In this tutorial we will show ...'), + (4,'1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + (5,'MySQL vs. YourSQL','In the following database comparison ...'), + (6,'MySQL Security','When configured properly, MySQL ...'); + +# Insert rows in t2 +INSERT INTO t2 (a2,b2) VALUES + ('MySQL Tutorial','DBMS stands for DataBase VÃÆ·WÄ°...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# delete records from parent +DELETE FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; + +# no records expected +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; + +SELECT * FROM t1 WHERE a1 LIKE '%tutorial%'; +SELECT * FROM t2 WHERE a2 LIKE '%tutorial%'; + +DROP TABLE t2 , t1; + +#------------------------------------------------------------------------------ +# FTS with FK+transactions and UPDATE casecade with transaction +#------------------------------------------------------------------------------- + +call mtr.add_suppression("\\[ERROR\\] InnoDB: FTS Doc ID must be larger than 3 for table `test`.`t2`"); + +# Create FTS table +CREATE TABLE t1 ( + id1 INT , + a1 VARCHAR(200) , + b1 TEXT , + FULLTEXT KEY (a1,b1), PRIMARY KEY(a1, id1) + ) CHARACTER SET = utf8 , ENGINE = InnoDB; + +CREATE TABLE t2 ( + id2 INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a2 VARCHAR(200), + b2 TEXT , + FOREIGN KEY (a2) REFERENCES t1(a1) ON UPDATE CASCADE, + FULLTEXT KEY (b2,a2) + ) CHARACTER SET = utf8 ,ENGINE = InnoDB; + +# Insert rows +INSERT INTO t1 (id1,a1,b1) VALUES + (1,'MySQL Tutorial','DBMS stands for DataBase VÃÆ·WÄ°...') , + (2,'How To Use MySQL Well','After you went through a ...'), + (3,'Optimizing MySQL','In this tutorial we will show ...'); + +# Insert rows in t2 fk table +INSERT INTO t2 (a2,b2) VALUES + ('MySQL Tutorial','DBMS stands for DataBase VÃÆ·WÄ°...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'); + +START TRANSACTION; +# Insert rows +INSERT INTO t1 (id1,a1,b1) VALUES + (4,'1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + (5,'MySQL vs. YourSQL','In the following database comparison ...'), + (6,'MySQL Security','When configured properly, MySQL ...'); + +# Insert rows t2 fk table +INSERT INTO t2 (a2,b2) VALUES + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# error on violating fk constraint +--error 1452 +INSERT INTO t2 (a2,b2) VALUES + ('MySQL Tricks','1. Never run mysqld as root. 2. ...'); + +# error on DELETE FROM parent table +--error 1451 +DELETE FROM t1; + +# records expected +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial') ORDER BY id1; +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial') ORDER BY id2; +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ORDER BY id1; +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ORDER BY id2; +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial' WITH QUERY EXPANSION) ORDER BY id1; +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial' WITH QUERY EXPANSION) ORDER BY id2; +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('"dbms database"@4' IN BOOLEAN MODE) ; +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('"dbms database"@4' IN BOOLEAN MODE) ; + +# no records as data not COMMITted. +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('root') ; +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('root') ; +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('mysqld (+root)' IN BOOLEAN MODE) ; +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('mysqld (-root)' IN BOOLEAN MODE) ; +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('root' WITH QUERY EXPANSION) ; +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('root' WITH QUERY EXPANSION) ; +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('"database comparison"@02' IN BOOLEAN MODE) ; +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('"database comparison"@02' IN BOOLEAN MODE) ; + +SELECT * FROM t1 ORDER BY id1; +SELECT * FROM t2 ORDER BY id2; + +COMMIT; + +START TRANSACTION; +# Updating parent table hence child table should get updated due to 'UPDATE cascade' clause +UPDATE t1 SET a1 = "changing column - on UPDATE cascade" , b1 = "to check foreign constraint" WHERE +MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; +COMMIT; + +# no records expected +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('tutorial (+mysql -VÃÆ·WÄ°)' IN BOOLEAN MODE) ; + +# it shows updated record +SELECT * FROM t1 WHERE MATCH (a1,b1) AGAINST ('+UPDATE +cascade' IN BOOLEAN MODE) ORDER BY id1; +SELECT * FROM t2 WHERE MATCH (a2,b2) AGAINST ('+UPDATE +cascade' IN BOOLEAN MODE) ORDER BY id2; +SELECT * FROM t2 WHERE a2 LIKE '%UPDATE CASCADE%' ORDER BY id2; + +DROP TABLE t2 , t1; + + +# FTS with FK+transactions - UPDATE cascade +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), + FULLTEXT KEY(s2), + FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on UPDATE cascade) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +UPDATE t1 set s2 = 'Rainbows' WHERE s2 <> 'Sunshine'; +COMMIT; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +DROP TABLE t2 , t1; + +# FTS with FK+transactions - on DELETE cascade +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), + FULLTEXT KEY(s2), + FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on DELETE cascade) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +DELETE FROM t1 WHERE s2 <> 'Sunshine'; +COMMIT; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +DROP TABLE t2 , t1; + +# FTS with FK+transactions - DELETE SET NULL +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), + FULLTEXT KEY(s2), + FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on DELETE SET NULL) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +DELETE FROM t1 WHERE s2 <> 'Sunshine'; +COMMIT; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +DROP TABLE t2 , t1; + + +# FTS with FK+transactions - UPDATE SET NULL +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), + FULLTEXT KEY(s2), + FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on UPDATE SET NULL) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +UPDATE t1 set s2 = 'Rainbows' WHERE s2 <> 'Sunshine'; +COMMIT; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +DROP TABLE t2 , t1; + + +#----------------------------------------------------------------------------- + +# FTS with FK+transactions - UPDATE cascade +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), + FULLTEXT KEY(s2), + FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on UPDATE cascade) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +UPDATE t1 set s2 = 'Rainbows' WHERE s2 <> 'Sunshine'; +ROLLBACK; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +DROP TABLE t2 , t1; + +# FTS with FK+transactions - DELETE cascade +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), + FULLTEXT KEY(s2), + FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on DELETE cascade) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +DELETE FROM t1 WHERE s2 <> 'Sunshine'; +ROLLBACK; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +DROP TABLE t2 , t1; + +# FTS with FK+transactions - DELETE SET NULL +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), + FULLTEXT KEY(s2), + FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on DELETE SET NULL) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +DELETE FROM t1 WHERE s2 <> 'Sunshine'; +ROLLBACK; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +DROP TABLE t2 , t1; + + +# FTS with FK+transactions - UPDATE SET NULL +CREATE TABLE t1 (s1 INT, s2 VARCHAR(200), PRIMARY KEY (s1,s2)) ENGINE = InnoDB; +CREATE TABLE t2 (s1 INT, s2 VARCHAR(200), + FULLTEXT KEY(s2), + FOREIGN KEY (s1,s2) REFERENCES t1 (s1,s2) on UPDATE SET NULL) ENGINE = InnoDB; +START TRANSACTION; +INSERT INTO t1 VALUES (1,'Sunshine'),(2,'Lollipops'); +INSERT INTO t2 VALUES (1,'Sunshine'),(2,'Lollipops'); +UPDATE t1 set s2 = 'Rainbows' WHERE s2 <> 'Sunshine'; +ROLLBACK; +SELECT * FROM t2 WHERE MATCH(s2) AGAINST ('Lollipops'); +DROP TABLE t2 , t1; + + +#------------------------------------------------------------------------------ +# FTS index with compressed row format +#------------------------------------------------------------------------------ + +# Save innodb variables +let $innodb_file_per_table_orig=`select @@innodb_file_per_table`; + +set global innodb_file_per_table=1; + +--disable_query_log +SET @save_innodb_read_only_compressed=@@GLOBAL.innodb_read_only_compressed; +SET GLOBAL innodb_read_only_compressed=OFF; +--enable_query_log +# Create FTS table +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) CHARACTER SET = utf8, ROW_FORMAT=COMPRESSED, ENGINE = InnoDB; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL Tutorial','DBMS stands for DataBase VÃÆ·WÄ°...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'); + +# Create the FTS index Using Alter Table +ALTER TABLE t1 ADD FULLTEXT INDEX idx (a,b); +EVAL SHOW CREATE TABLE t1; + +# Check whether individual space id created for AUX tables +SELECT count(*) FROM information_schema.innodb_sys_tables WHERE name LIKE "%FTS_%" AND space !=0; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log + +# Select word "tutorial" in the table +SELECT * FROM t1 WHERE MATCH (a,b) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) ORDER BY id; + +# boolean mode +select * from t1 where MATCH(a,b) AGAINST("+tutorial +VÃÆ·WÄ°" IN BOOLEAN MODE); +--error ER_PARSE_ERROR +select * from t1 where MATCH(a,b) AGAINST("+-VÃÆ·WÄ°" IN BOOLEAN MODE); +select * from t1 where MATCH(a,b) AGAINST("+Mysql +(tricks never)" IN BOOLEAN MODE); +select * from t1 where MATCH(a,b) AGAINST("+mysql -(tricks never)" IN BOOLEAN MODE) ORDER BY id; +select *, MATCH(a,b) AGAINST("mysql stands" IN BOOLEAN MODE) as x from t1 ORDER BY id; +select * from t1 where MATCH a,b AGAINST ("+database* +VÃÆ·W*" IN BOOLEAN MODE); +select * from t1 where MATCH a,b AGAINST ('"security mysql"' IN BOOLEAN MODE); + +# query expansion +select * from t1 where MATCH(a,b) AGAINST ("VÃÆ·WÄ°" WITH QUERY EXPANSION) ORDER BY id; + +# Drop index +ALTER TABLE t1 DROP INDEX idx; + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + +-- disable_query_log +-- disable_result_log +ANALYZE TABLE t1; +-- enable_result_log +-- enable_query_log + +# Select word "tutorial" in the table +SELECT * FROM t1 WHERE MATCH (a,b) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) ORDER BY id; + +# boolean mode +select * from t1 where MATCH(a,b) AGAINST("+tutorial +VÃÆ·WÄ°" IN BOOLEAN MODE); +select * from t1 where MATCH(a,b) AGAINST("+dbms" IN BOOLEAN MODE); +select * from t1 where MATCH(a,b) AGAINST("+Mysql +(tricks never)" IN BOOLEAN MODE); +select * from t1 where MATCH(a,b) AGAINST("+mysql -(tricks never)" IN BOOLEAN MODE) ORDER BY id; +select *, MATCH(a,b) AGAINST("mysql VÃÆ·WÄ°" IN BOOLEAN MODE) as x from t1 ORDER BY id; +# Innodb:Assert eval0eval.c line 148 +#select * from t1 where MATCH a,b AGAINST ("+database* +VÃÆ·WÄ°*" IN BOOLEAN MODE); +select * from t1 where MATCH a,b AGAINST ('"security mysql"' IN BOOLEAN MODE); + +# query expansion +select * from t1 where MATCH(a,b) AGAINST ("VÃÆ·WÄ°" WITH QUERY EXPANSION) ORDER BY id; + + +# insert for proximity search +INSERT INTO t1 (a,b) VALUES ('test query expansion','for database ...'); +# Insert into table with similar word of different distances +INSERT INTO t1 (a,b) VALUES + ('test proximity search, test, proximity and phrase', + 'search, with proximity innodb'); + +INSERT INTO t1 (a,b) VALUES + ('test proximity fts search, test, proximity and phrase', + 'search, with proximity innodb'); + +INSERT INTO t1 (a,b) VALUES + ('test more proximity fts search, test, more proximity and phrase', + 'search, with proximity innodb'); + +# This should only return the first document +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"proximity search"@2' IN BOOLEAN MODE); + +# This would return no document +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"proximity search"@1' IN BOOLEAN MODE); + +# This give you all three documents +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"proximity search"@3' IN BOOLEAN MODE) ORDER BY id; + +# Similar boundary testing for the words +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"test proximity"@5' IN BOOLEAN MODE) ORDER BY id; + +# Test with more word The last document will return, please notice there +# is no ordering requirement for proximity search. +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"more test proximity"@2' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"more test proximity"@3' IN BOOLEAN MODE); + +# The phrase search will not require exact word ordering +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"more fts proximity"@03' IN BOOLEAN MODE); + + +UPDATE t1 SET a = UPPER(a) , b = UPPER(b) ; +UPDATE t1 SET a = UPPER(a) , b = LOWER(b) ; + +select * from t1 where MATCH(a,b) AGAINST("+tutorial +dbms" IN BOOLEAN MODE); +select * from t1 where MATCH(a,b) AGAINST("+VÃÆ·WÄ°" IN BOOLEAN MODE); + +SELECT * FROM t1 WHERE MATCH (a,b) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) ORDER BY id; + +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('"proximity search"@14' IN BOOLEAN MODE); + + +SELECT * FROM t1 WHERE MATCH (a,b) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +SELECT * FROM t1 ORDER BY id; + +DROP TABLE t1; +--disable_query_log +SET GLOBAL innodb_read_only_compressed=@save_innodb_read_only_compressed; +--enable_query_log +eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; + +#------------------------------------------------------------------------------ +# FTS index with utf8 character testcase +#------------------------------------------------------------------------------ + +# Create FTS table +EVAL CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) CHARACTER SET = utf8, ENGINE=InnoDB; + + +# Insert rows from different languages +INSERT INTO t1 (a,b) VALUES +('Я могу еÑÑ‚ÑŒ Ñтекло', 'оно мне не вредит'), +('Мога да Ñм Ñтъкло', 'то не ми вреди'), +('ΜποÏῶ νὰ φάω σπασμÎνα' ,'γυαλιὰ χωÏὶς νὰ πάθω τίποτα'), +('PÅ™ÃliÅ¡ žluÅ¥ouÄký kůň', 'úpÄ›l Äábelské kódy'), +('Sævör grét', 'áðan þvà úlpan var ónýt'), +('ã†ã‚ã®ãŠãã‚„ã¾','ã‘ãµã“ãˆã¦'), +('ã„ã‚ã¯ã«ã»ã¸ã©ã€€ã¡ã‚Šã¬ã‚‹','ã‚ã•ãゆã‚ã¿ã˜ã€€ã‚‘ã²ã‚‚ã›ãš'); + +# insert english text +INSERT INTO t1 (a,b) VALUES + ('MySQL Tutorial','request docteam@oraclehelp.com ...') , + ('Trial version','query performace @1255 minute on 2.1Hz Memory 2GB...') , + ('when To Use MySQL Well','for free faq mail@xyz.com ...'); + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + +# FTS Queries +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("вредит χωÏὶς") ORDER BY id; +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("оно" WITH QUERY EXPANSION); + +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("вред*" IN BOOLEAN MODE) ORDER BY id; +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("+γυαλιὰ +tutorial" IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("+tutorial +(Мога τίποτα)" IN BOOLEAN MODE); + +# Innodb:error - no result returned (update result of query once fixed) (innodb limit , does not understand character boundry for japanses like charcter set) +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("ã‚ã•ãゆã‚ã¿ã˜ã€€ã‚‘ã²ã‚‚ã›ãš"); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("ã¡ã‚Šã¬ã‚‹" WITH QUERY EXPANSION); + +# Innodb:error - no result returned (update result of query once fixed) (innodb limit , does not understand character boundry for japanses like charcter set) +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("+ã‚ã•ãゆã‚ã¿ã˜ã€€+ã‚‘ã²ã‚‚ã›ãš" IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("ã†ã‚ã®ãŠã*" IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("+Sævör +úlpan" IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"γυαλιὰ χωÏὶς"@2' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"query performace"@02' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"πάθω τίποτα"@2' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"ã‚ã•ãゆã‚ã¿ã˜ ã‚‘ã²ã‚‚ã›ãš"@1' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"ã‚ã•ãゆã‚ã¿ã˜ ã‚‘ã²ã‚‚ã›ãš"@2' IN BOOLEAN MODE); + +ALTER TABLE t1 DROP INDEX idx; +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + +# Innodb:error - no result returned (update result of query once fixed) (innodb limit , does not understand character boundry for japanses like charcter set) +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("ã‚ã•ãゆã‚ã¿ã˜ ã‚‘ã²ã‚‚ã›ãš"); +# Update fails because where condition do not succeed which is incorrect (update result of query once fixed) +UPDATE t1 SET a = "Pchnąć w tÄ™ łódź jeża" , b = "lub osiem skrzyÅ„ fig" WHERE MATCH(a,b) AGAINST ("ã‚ã•ãゆã‚ã¿ã˜ ã‚‘ã²ã‚‚ã›ãš"); +UPDATE t1 SET a = "Ð’ чащах юга жил-был цитруÑ? Да", b = "но фальшивый ÑкземплÑÑ€! Ñ‘ÑŠ" WHERE MATCH(a,b) AGAINST ("вред*" IN BOOLEAN MODE); +DELETE FROM t1 WHERE MATCH(a,b) AGAINST("+Sævör +úlpan" IN BOOLEAN MODE); + +# Innodb error - no result returned +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("ã‚ã•ãゆã‚ã¿ã˜ã€€ã‚‘ã²ã‚‚ã›ãš"); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("łódź osiem"); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("вред*" IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("фальшив*" IN BOOLEAN MODE) ORDER BY id; +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("+Sævör +úlpan" IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"łódź jeża"@2' IN BOOLEAN MODE); + +SELECT * FROM t1 ORDER BY id; +DROP TABLE t1; + +# This is to test the update operation on FTS indexed and non-indexed +# column +CREATE TABLE t1(ID INT PRIMARY KEY, + no_fts_field VARCHAR(10), + fts_field VARCHAR(10), + FULLTEXT INDEX f(fts_field)) ENGINE=INNODB; + +INSERT INTO t1 VALUES (1, 'AAA', 'BBB'); + +SELECT * FROM t1 WHERE MATCH(fts_field) against("BBB"); + +# Update FULLTEXT indexed column, Doc ID will be updated +UPDATE t1 SET fts_field='anychange' where id = 1; + +SELECT * FROM t1 WHERE MATCH(fts_field) against("anychange"); + +# Update non-FULLTEXT indexed column, Doc ID stay to be the same +UPDATE t1 SET no_fts_field='anychange' where id = 1; + +SELECT * FROM t1 WHERE MATCH(fts_field) against("anychange"); + +# Update both FULLTEXT indexed and non-indexed column, Doc ID will be updated +UPDATE t1 SET no_fts_field='anychange', fts_field='other' where id = 1; + +SELECT * FROM t1 WHERE MATCH(fts_field) against("other"); + +SELECT * FROM t1 WHERE MATCH(fts_field) against("BBB"); + +# FTS index dropped, the DOC_ID column is kept, however, the ID will not +# change +DROP INDEX f on t1; + +UPDATE t1 SET fts_field='anychange' where id = 1; + +UPDATE t1 SET no_fts_field='anychange' where id = 1; + +UPDATE t1 SET no_fts_field='anychange', fts_field='other' where id = 1; + +CREATE FULLTEXT INDEX f ON t1(FTS_FIELD); + +SELECT * FROM t1 WHERE MATCH(fts_field) against("other"); + +DROP TABLE t1; + +# Test on user supplied 'FTS_DOC_ID' +CREATE TABLE t1(`FTS_DOC_ID` serial, + no_fts_field VARCHAR(10), + fts_field VARCHAR(10), + FULLTEXT INDEX f(fts_field)) ENGINE=INNODB; + +INSERT INTO t1 VALUES (1, 'AAA', 'BBB'); + +# Doc ID must be updated as well (HA_FTS_INVALID_DOCID). +--error 182 +UPDATE t1 SET fts_field='anychange' where FTS_DOC_ID = 1; + +UPDATE t1 SET fts_field='anychange', FTS_DOC_ID = 2 where FTS_DOC_ID = 1; + +SELECT * FROM t1 WHERE MATCH(fts_field) against("anychange"); + +# "BBB" should be marked as deleted. +SELECT * FROM t1 WHERE MATCH(fts_field) against("BBB"); + +UPDATE t1 SET no_fts_field='anychange' where FTS_DOC_ID = 2; + +SELECT * FROM t1 WHERE MATCH(fts_field) against("anychange"); + +# "HA_FTS_INVALID_DOCID" +--error 182 +UPDATE t1 SET no_fts_field='anychange', fts_field='other' where FTS_DOC_ID = 2; + +SELECT * FROM t1 WHERE MATCH(fts_field) against("other"); + +# Doc ID must be monotonically increase (HA_FTS_INVALID_DOCID) +--error 182 +UPDATE t1 SET FTS_DOC_ID = 1 where FTS_DOC_ID = 2; + +DROP INDEX f ON t1; + +# After FULLTEXT index dropped, we can update the fields freely +UPDATE t1 SET fts_field='newchange' where FTS_DOC_ID = 2; + +UPDATE t1 SET no_fts_field='anychange' where FTS_DOC_ID = 2; + +SELECT * FROM t1; + +DROP TABLE t1; + +CREATE TABLE t1(ID INT PRIMARY KEY, + no_fts_field VARCHAR(10), + fts_field VARCHAR(10), + FULLTEXT INDEX f(fts_field), index k(fts_field)) ENGINE=INNODB; + +CREATE TABLE t2(ID INT PRIMARY KEY, + no_fts_field VARCHAR(10), + fts_field VARCHAR(10), + FULLTEXT INDEX f(fts_field), + INDEX k2(fts_field), + FOREIGN KEY(fts_field) REFERENCES + t1(fts_field) ON UPDATE CASCADE) ENGINE=INNODB; + +INSERT INTO t1 VALUES (1, 'AAA', 'BBB'); + +INSERT INTO t2 VALUES (1, 'AAA', 'BBB'); + +update t1 set fts_field='newchange' where id =1; + +SELECT * FROM t1 WHERE MATCH(fts_field) against("BBB"); +SELECT * FROM t2 WHERE MATCH(fts_field) against("BBB"); +SELECT * FROM t1 WHERE MATCH(fts_field) against("newchange"); +SELECT * FROM t2 WHERE MATCH(fts_field) against("newchange"); + +DROP TABLE t2; + +DROP TABLE t1; + +# Testcases adopted from innodb_multi_update.test + +CREATE TABLE t1(id INT PRIMARY KEY, + fts_field VARCHAR(10), + FULLTEXT INDEX f(fts_field)) ENGINE=INNODB; + + +CREATE TABLE t2(id INT PRIMARY KEY, + fts_field VARCHAR(10), + FULLTEXT INDEX f(fts_field)) ENGINE=INNODB; + +INSERT INTO t1 values (1,'100'),(2,'200'),(3,'300'),(4,'400'),(5,'500'),(6,'600'), (7,'700'),(8,'800'),(9,'900'),(10,'1000'),(11,'1100'),(12,'1200'); +INSERT INTO t2 values (1,'100'),(2,'200'),(3,'300'),(4,'400'),(5,'500'),(6,'600'), (7,'700'),(8,'800'); + +UPDATE t1, t2 set t1.fts_field = CONCAT(t1.fts_field, 'foo'); + +UPDATE t1, t2 set t1.fts_field = CONCAT(t1.fts_field, 'foo') WHERE t1.fts_field = "100foo"; + +# Update two tables in the same statement +UPDATE t1, t2 set t1.fts_field = CONCAT(t1.fts_field, 'xoo'), t2.fts_field = CONCAT(t1.fts_field, 'xoo') where t1.fts_field=CONCAT(t2.fts_field, 'foo'); + +# Following selects shows whether the correct Doc ID are updated + +# This row should present in table t1 +SELECT * FROM t1 WHERE MATCH(fts_field) against("100foofoo"); + +# Following rows should be dropped +SELECT * FROM t1 WHERE MATCH(fts_field) against("100foo"); +SELECT * FROM t1 WHERE MATCH(fts_field) against("100"); + +# This row should present in table t2 +SELECT * FROM t2 WHERE MATCH(fts_field) against("400fooxoo"); +SELECT * FROM t2 WHERE MATCH(fts_field) against("100"); + +# Follow rows should be marked as dropped +SELECT * FROM t2 WHERE MATCH(fts_field) against("200"); +SELECT * FROM t2 WHERE MATCH(fts_field) against("400"); + + +DROP TABLE t1; + +DROP TABLE t2; + + +--echo +--echo BUG#13701973/64274: MYSQL THREAD WAS SUSPENDED WHEN EXECUTE UPDATE QUERY +--echo +# FTS setup did not track which tables it had already looked at to see whether +# they need initialization. Hilarity ensued when hitting circular dependencies. + +SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; + +CREATE TABLE t1 ( + t1_id INT(10) UNSIGNED NOT NULL, + t2_id INT(10) UNSIGNED DEFAULT NULL, + PRIMARY KEY (t1_id), + FOREIGN KEY (t2_id) REFERENCES t2 (t2_id) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB; + +CREATE TABLE t2 ( + t1_id INT(10) UNSIGNED NOT NULL, + t2_id INT(10) UNSIGNED NOT NULL, + t3_id INT(10) UNSIGNED NOT NULL, + t4_id INT(10) UNSIGNED NOT NULL, + PRIMARY KEY (t2_id), + FOREIGN KEY (t1_id) REFERENCES t1 (t1_id), + FOREIGN KEY (t3_id) REFERENCES t3 (t3_id) + ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (t4_id) REFERENCES t4 (t4_id) +) ENGINE=InnoDB; + +CREATE TABLE t3 ( + t3_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, + payload char(3), + PRIMARY KEY (t3_id) +) ENGINE=InnoDB; + +INSERT INTO t3 VALUES (1, '100'); + +CREATE TABLE t4 ( + t2_id INT(10) UNSIGNED DEFAULT NULL, + t4_id INT(10) UNSIGNED NOT NULL, + PRIMARY KEY (t4_id), + FOREIGN KEY (t2_id) REFERENCES t2 (t2_id) + ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB; + +SET FOREIGN_KEY_CHECKS=1; + +UPDATE t3 SET payload='101' WHERE t3_id=1; + +SET FOREIGN_KEY_CHECKS=0; + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +DROP TABLE t4; + +--echo # +--echo # InnoDB: Failing assertion: result != FTS_INVALID in +--echo # fts_trx_row_get_new_state +--echo # +SET FOREIGN_KEY_CHECKS=1; +CREATE TABLE t1 (pk INT PRIMARY KEY, + f1 VARCHAR(10), f2 VARCHAR(10), + f3 VARCHAR(10), f4 VARCHAR(10), + f5 VARCHAR(10), f6 VARCHAR(10), + f7 VARCHAR(10), f8 VARCHAR(10), + FULLTEXT(f1), FULLTEXT(f2), FULLTEXT(f3), FULLTEXT(f4), + FULLTEXT(f5), FULLTEXT(f6), FULLTEXT(f7), FULLTEXT(f8), + INDEX(f1), INDEX(f2), INDEX(f3), INDEX(f4), + INDEX(f5), INDEX(f6), INDEX(f7), INDEX(f8)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1, 'mariadb', 'mariadb', 'mariadb', 'mariadb', + 'mariadb', 'mariadb', 'mariadb', 'mariadb'), + (2, 'mariadb', 'mariadb', 'mariadb', 'mariadb', + 'mariadb', 'mariadb', 'mariadb', 'mariadb'), + (3, 'innodb', 'innodb', 'innodb', 'innodb', + 'innodb', 'innodb', 'innodb', 'innodb'); +ALTER TABLE t1 ADD FOREIGN KEY (f1) REFERENCES t1 (f2) ON DELETE SET NULL; +START TRANSACTION; +DELETE FROM t1 where f1='mariadb'; +SELECT * FROM t1; +ROLLBACK; + +ALTER TABLE t1 ADD FOREIGN KEY (f3) REFERENCES t1 (f4) ON DELETE CASCADE; + +START TRANSACTION; +DELETE FROM t1 where f3='mariadb'; +SELECT * FROM t1; +ROLLBACK; + +ALTER TABLE t1 ADD FOREIGN KEY (f5) REFERENCES t1 (f6) ON UPDATE SET NULL; +--error ER_ROW_IS_REFERENCED_2 +UPDATE t1 SET f6='update'; + +ALTER TABLE t1 ADD FOREIGN KEY (f7) REFERENCES t1 (f8) ON UPDATE CASCADE; +--error ER_ROW_IS_REFERENCED_2 +UPDATE t1 SET f6='cascade'; +DROP TABLE t1; + +SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; + +--echo # +--echo # MDEV-25536 sym_node->table != NULL in pars_retrieve_table_def +--echo # +CREATE TABLE t1 (f1 TEXT,FULLTEXT (f1)) ENGINE=InnoDB; +ALTER TABLE t1 DISCARD TABLESPACE; +SET GLOBAL innodb_ft_aux_table='test/t1'; +SELECT * FROM information_schema.innodb_ft_deleted; +DROP TABLE t1; +SET GLOBAL innodb_ft_aux_table=DEFAULT; + +--echo # +--echo # MDEV-19522 InnoDB commit fails when FTS_DOC_ID value +--echo # is greater than 4294967295 +--echo # +CREATE TABLE t1( + FTS_DOC_ID BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + f1 TEXT, f2 TEXT, PRIMARY KEY (FTS_DOC_ID), + FULLTEXT KEY (f1)) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1,'txt','bbb'); +UPDATE t1 SET FTS_DOC_ID = 4294967298; +SELECT * FROM t1 WHERE match(f1) against("txt"); +SET @@session.insert_id = 100000000000; +INSERT INTO t1(f1, f2) VALUES ('aaa', 'bbb'); +CREATE FULLTEXT INDEX i ON t1 (f2); +SELECT * FROM t1 WHERE match(f2) against("bbb"); +# Cleanup +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_multiple_index.test b/mysql-test/suite/innodb_fts/t/innodb_fts_multiple_index.test new file mode 100644 index 00000000..f9535c72 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_multiple_index.test @@ -0,0 +1,175 @@ +#------------------------------------------------------------------------------ +# Test With two FTS index on same table + alter/create/drop index + tnx +#------------------------------------------------------------------------------ +--source include/have_innodb.inc +--source include/maybe_versioning.inc + +--disable_warnings +drop table if exists t1; +--enable_warnings + +# Create FTS table +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB STATS_PERSISTENT=0; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'); + +# Create the 2 FTS index Using Alter on same table +ALTER TABLE t1 ADD FULLTEXT INDEX idx_1 (a); +ALTER TABLE t1 ADD FULLTEXT INDEX idx_2 (b); +EVAL SHOW CREATE TABLE t1; + +# check multiple index with transaction +START TRANSACTION; +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); +ROLLBACK; + +# Select word "tutorial" in the table +SELECT * FROM t1 WHERE MATCH (a) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +# boolean mode +select * from t1 where MATCH(a) AGAINST("+mysql +Tutorial" IN BOOLEAN MODE); +select * from t1 where MATCH(b) AGAINST("+Tutorial" IN BOOLEAN MODE); +select * from t1 where MATCH(b) AGAINST("+stands +(DataBase)" IN BOOLEAN MODE); +select * from t1 where MATCH(b) AGAINST("+DataBase -(comparison)" IN BOOLEAN MODE); +select *, MATCH(a) AGAINST("Optimizing MySQL" IN BOOLEAN MODE) as x from t1; +select *, MATCH(b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; +select * from t1 where MATCH a AGAINST ("+Optimiz* +Optimiz*" IN BOOLEAN MODE); +select * from t1 where MATCH b AGAINST ('"DBMS stands"' IN BOOLEAN MODE); +select * from t1 where MATCH b AGAINST ('"DBMS STANDS"' IN BOOLEAN MODE); + +# query expansion +select * from t1 where MATCH(b) AGAINST ("DataBase" WITH QUERY EXPANSION); +select * from t1 where MATCH(a) AGAINST ("Security" WITH QUERY EXPANSION); + +# Drop index +ALTER TABLE t1 DROP INDEX idx_1; +ALTER TABLE t1 DROP INDEX idx_2; + +# Create the FTS index again +ALTER TABLE t1 ADD FULLTEXT INDEX idx_1 (a); +ALTER TABLE t1 ADD FULLTEXT INDEX idx_2 (b); + +# Select word "tutorial" in the table +SELECT * FROM t1 WHERE MATCH (a) + AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); + +# boolean mode +select * from t1 where MATCH(a) AGAINST("+mysql +Tutorial" IN BOOLEAN MODE); +select * from t1 where MATCH(b) AGAINST("+Tutorial" IN BOOLEAN MODE); +select * from t1 where MATCH(b) AGAINST("+stands +(DataBase)" IN BOOLEAN MODE); +select * from t1 where MATCH(b) AGAINST("+DataBase -(comparison)" IN BOOLEAN MODE); +select *, MATCH(a) AGAINST("Optimizing MySQL" IN BOOLEAN MODE) as x from t1; +select *, MATCH(b) AGAINST("collections support" IN BOOLEAN MODE) as x from t1; +select * from t1 where MATCH a AGAINST ("+Optimiz* +Optimiz*" IN BOOLEAN MODE); +select * from t1 where MATCH b AGAINST ('"DBMS stands"' IN BOOLEAN MODE); +select * from t1 where MATCH b AGAINST ('"DBMS STANDS"' IN BOOLEAN MODE); + +# query expansion +select * from t1 where MATCH(b) AGAINST ("DataBase" WITH QUERY EXPANSION); +select * from t1 where MATCH(a) AGAINST ("Security" WITH QUERY EXPANSION); + +# insert for proximity search +INSERT INTO t1 (a,b) VALUES ('test query expansion','for database ...'); +# Insert into table with similar word of different distances +INSERT INTO t1 (a,b) VALUES + ('test proximity search, test, proximity and phrase', + 'search, with proximity innodb'); + +INSERT INTO t1 (a,b) VALUES + ('test proximity fts search, test, proximity and phrase', + 'search, with proximity innodb'); + +INSERT INTO t1 (a,b) VALUES + ('test more of proximity for fts search, test, more proximity and phrase', + 'search, with proximity innodb'); + +# This should only return the first document +SELECT * FROM t1 + WHERE MATCH (a) + AGAINST ('"proximity search"@3' IN BOOLEAN MODE); + +# This would return no document +SELECT * FROM t1 + WHERE MATCH (a) + AGAINST ('"proximity search"@2' IN BOOLEAN MODE); + +# This give you all three documents +SELECT * FROM t1 + WHERE MATCH (b) + AGAINST ('"proximity innodb"@4' IN BOOLEAN MODE); + +# Similar boundary testing for the words +SELECT * FROM t1 + WHERE MATCH (a) + AGAINST ('"test proximity"@3' IN BOOLEAN MODE); + +# Test with more word The last document will return, please notice there +# is no ordering requirement for proximity search. +SELECT * FROM t1 + WHERE MATCH (a) + AGAINST ('"more test proximity"@3' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a) + AGAINST ('"more test proximity"@2' IN BOOLEAN MODE); + +# The phrase search will not require exact word ordering +SELECT * FROM t1 + WHERE MATCH (a) + AGAINST ('"more fts proximity"@02' IN BOOLEAN MODE); + + +# Select word "tutorial" in the table - innodb crash +SELECT * FROM t1 WHERE CONCAT(t1.a,t1.b) IN ( +SELECT CONCAT(a,b) FROM t1 AS t2 WHERE +MATCH (t2.a) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +) OR t1.id = 3 ; + + +# Select word "tutorial" in the table - innodb crash +SELECT * FROM t1 WHERE CONCAT(t1.a,t1.b) IN ( +SELECT CONCAT(a,b) FROM t1 AS t2 +WHERE MATCH (t2.a) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +AND t2.id != 3) ; + +# Select word "tutorial" in the table +SELECT * FROM t1 WHERE id IN (SELECT MIN(id) FROM t1 WHERE +MATCH (b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)) OR id = 3 ; + +# Select word except "tutorial" in the table +SELECT * FROM t1 WHERE id NOT IN (SELECT MIN(id) FROM t1 +WHERE MATCH (b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE)) ; + + +# Select word "tutorial" in the table +SELECT * FROM t1 WHERE EXISTS (SELECT t2.id FROM t1 AS t2 WHERE +MATCH (t2.b) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +AND t1.id = t2.id) ; + + +# Select not word like "tutorial" using subquery +SELECT * FROM t1 WHERE NOT EXISTS (SELECT t2.id FROM t1 AS t2 WHERE +MATCH (t2.a) AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE) +AND t1.id = t2.id) ; + + +SELECT * FROM t1 WHERE t1.id = (SELECT MAX(t2.id) FROM t1 AS t2 WHERE +MATCH(t2.a) AGAINST ('"proximity search"@3' IN BOOLEAN MODE)); +SELECT * FROM t1 WHERE t1.id > (SELECT MIN(t2.id) FROM t1 AS t2 WHERE +MATCH(t2.b) AGAINST ('"proximity innodb"@3' IN BOOLEAN MODE)); + +DROP TABLE t1; + diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_plugin.test b/mysql-test/suite/innodb_fts/t/innodb_fts_plugin.test new file mode 100644 index 00000000..7ff36b6f --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_plugin.test @@ -0,0 +1,229 @@ +--source include/have_innodb.inc +--source include/have_simple_parser.inc +--source include/no_valgrind_without_big.inc +# Restart is not supported in embedded +--source include/not_embedded.inc + +# Install fts parser plugin +INSTALL PLUGIN simple_parser SONAME 'mypluglib'; + +# Flush the table mysql.plugin in case the server shutdown would time out. +FLUSH TABLES; + +-- echo # Test Part 1: Grammar Test +# Create a myisam table and alter it to innodb table +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + FULLTEXT (title) WITH PARSER simple_parser + ) ENGINE=MyISAM; + +ALTER TABLE articles ENGINE=InnoDB; + +DROP TABLE articles; + +# Create a table having a full text index with parser +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + comment TEXT, + FULLTEXT (title) WITH PARSER simple_parser + ) ENGINE=InnoDB; + +# Alter table to add a full text index with parser +ALTER TABLE articles ADD FULLTEXT INDEX (body) WITH PARSER simple_parser; + +# Create a full text index with parser +CREATE FULLTEXT INDEX ft_index ON articles(comment) WITH PARSER simple_parser; + +DROP TABLE articles; + +-- echo # Test Part 2: Create Index Test(CREATE TABLE WITH FULLTEXT INDEX) +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title, body) WITH PARSER simple_parser + ) ENGINE=InnoDB; + +INSERT INTO articles (title, body) VALUES + ('MySQL Tutorial','DBMS stands for MySQL DataBase ...'), + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','How to use full-text search engine'), + ('Go MySQL Tricks','How to use full text search engine'); + +# Simple term search +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('mysql') ORDER BY id; + +# Test stopword and word len less than fts_min_token_size +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('will go'); + +-- echo # Test plugin parser tokenizer difference +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('full-text'); + +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('full text'); + +# No result here, we get '"mysql' 'database"' by simple parser +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('"mysql database"' IN BOOLEAN MODE); + +DROP TABLE articles; + +-- echo # Test Part 3: Row Merge Create Index Test(ALTER TABLE ADD FULLTEXT INDEX) +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT + ) ENGINE=InnoDB; + +INSERT INTO articles (title, body) VALUES + ('MySQL Tutorial','DBMS stands for MySQL DataBase ...'), + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','How to use full-text search engine'), + ('Go MySQL Tricks','How to use full text search engine'); + +# Create fulltext index +ALTER TABLE articles ADD FULLTEXT INDEX (title, body) WITH PARSER simple_parser; + +# Simple term search +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('mysql') ORDER BY id; + +# Test stopword and word len less than fts_min_token_size +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('will go'); + +-- echo # Test plugin parser tokenizer difference +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('full-text'); + +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('full text'); + +# Test query expansion +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('full-text' WITH QUERY EXPANSION) + ORDER BY id; + +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('full text' WITH QUERY EXPANSION) + ORDER BY id; + +# No result here, we get '"mysql' 'database"' by simple parser +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('"mysql database"' IN BOOLEAN MODE); + +DROP TABLE articles; +-- echo # Test Part 3 END + +-- echo # Test Part 4:crash on commit(before/after) +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title, body) WITH PARSER simple_parser +) ENGINE=InnoDB; + +# Enable MDEV-515 table-level undo logging when inserting into empty table +SET unique_checks=0, foreign_key_checks=0; +BEGIN; +INSERT INTO articles (title, body) VALUES + ('MySQL Tutorial','DBMS stands for MySQL DataBase ...'), + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','How to use full-text search engine'), + ('Go MySQL Tricks','How to use full text search engine'); + +--source include/restart_mysqld.inc + +SELECT COUNT(*) FROM articles; +# Simple term search - no records expected +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('mysql'); + +INSERT INTO articles (title, body) VALUES + ('MySQL Tutorial','DBMS stands for MySQL DataBase ...'), + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','How to use full-text search engine'), + ('Go MariaDB Tricks','How to use full text search engine'); + +--source include/restart_mysqld.inc + +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('MySQL') ORDER BY id; +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('tutorial') ORDER BY id; +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('Tricks') ORDER BY id; +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('full text search') ORDER BY id; +SELECT COUNT(*) FROM articles; + +INSERT INTO articles (title, body) VALUES ('111', '1234 1234 1234'); +DROP TABLE articles; + +-- echo # Test Part 5: Test Uninstall Plugin After Index is Built +# Note: this test should be the last one because we uninstall plugin +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title, body) WITH PARSER simple_parser + ) ENGINE=InnoDB; + +# Uninstall plugin +UNINSTALL PLUGIN simple_parser; + +-- error ER_PLUGIN_IS_NOT_LOADED +INSERT INTO articles (title, body) VALUES + ('MySQL Tutorial','DBMS stands for MySQL DataBase ...'); + +# Reinstall plugin +INSTALL PLUGIN simple_parser SONAME 'mypluglib'; + +INSERT INTO articles (title, body) VALUES + ('MySQL Tutorial','DBMS stands for MySQL DataBase ...'), + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','How to use full-text search engine'), + ('Go MySQL Tricks','How to use full text search engine'); + +# Get warning here +UNINSTALL PLUGIN simple_parser; + +# Simple term search +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('mysql') + ORDER BY id; + +# Test stopword and word len less than fts_min_token_size +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('will go'); + +-- echo # Test plugin parser tokenizer difference +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('full-text'); + +SELECT * FROM articles WHERE + MATCH(title, body) AGAINST('full text'); + +-- error ER_FUNCTION_NOT_DEFINED +CREATE TABLE articles2 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title, body) WITH PARSER simple_parser + ) ENGINE=InnoDB; + +DROP TABLE articles; +# Uninstall plugin +-- error ER_SP_DOES_NOT_EXIST +UNINSTALL PLUGIN simple_parser; diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_proximity.test b/mysql-test/suite/innodb_fts/t/innodb_fts_proximity.test new file mode 100644 index 00000000..e3d8eb0c --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_proximity.test @@ -0,0 +1,261 @@ +--source include/have_innodb.inc +--source include/maybe_versioning.inc + +# This is the DDL function tests for innodb FTS +# Functional testing with FTS proximity search using '@' +# and try search default words + +--disable_warnings +drop table if exists t1; +--enable_warnings + +--disable_query_log +let $innodb_file_per_table_orig = `select @@innodb_file_per_table`; +--enable_query_log + +# Create FTS table +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) ENGINE= InnoDB; + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','what In this tutorial we will show ...'); + +# Try to Search default stopword from innodb, "where", "will", "what" +# and "when" are all stopwords +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("where will"); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("when"); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST ("what" WITH QUERY EXPANSION); + +# boolean No result expected +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("whe*" IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("+what +will" IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("+from" IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH(a,b) AGAINST("+where +(show what)" IN BOOLEAN MODE); + +# no result expected. Words are filtered out as stopwords +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"where will"@6' IN BOOLEAN MODE); + +# no result expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"where will"@9' IN BOOLEAN MODE); + +# insert record with @ character which is used in proximity search +INSERT INTO t1 (a,b) VALUES + ('MySQL Tutorial','request docteam@oraclehelp.com ...') , + ('Trial version','query performace @1255 minute on 2.1Hz Memory 2GB...') , + ('when To Use MySQL Well','for free faq mail@xyz.com ...'); +# proximity search with @ charcter + +# We don't need more than one word in proximity search. Single word +# treated as single word search +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"request"@10' IN BOOLEAN MODE); + +# If the distance is 0, it is treated as "phrase search" +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"Trial version"@0' IN BOOLEAN MODE); + +# @ is word seperator +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"request docteam@oraclehelp.com"@10' IN BOOLEAN MODE); + +# This should not return any document +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"1255 minute"@1' IN BOOLEAN MODE); + +# This should return the first document. That is "1255" and "minutes" are +# in a two-word range (adjacent) +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"1255 minute"@2' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"1255"@10' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('1255' WITH QUERY EXPANSION); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"request docteam"@2' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"1255 minute"' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request docteam@oraclehelp.com'); + +# Test across fields search +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"MySQL request"@3' IN BOOLEAN MODE); + +# Two words are in 10 words range +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"Trial memory"@10' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"Trial memory"@9' IN BOOLEAN MODE); + +DROP TABLE t1; + +# test on utf8 encoded proximity search +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) CHARACTER SET = UTF8, ENGINE= InnoDB; + +INSERT INTO t1 (a,b) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','what In this tutorial we will show ...'); + +CREATE FULLTEXT INDEX idx on t1 (a,b); + +INSERT INTO t1 (a,b) VALUES + ('MySQL Tutorial','request docteam@oraclehelp.com ...') , + ('Trial version','query performace @1255 minute on 2.1Hz Memory 2GB...'), + ('when To Use MySQL Well','for free faq mail@xyz.com ...'); + +# Should have 2 rows. Note proximity search does require words in order +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"mysql use"@2' IN BOOLEAN MODE); + +# Should return 0 row +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"mysql use"@1' IN BOOLEAN MODE); + +INSERT INTO t1 (a,b) VALUES ('XYZ, long blob', repeat("a", 9000)); + +INSERT IGNORE INTO t1 (a,b) VALUES (repeat("b", 9000), 'XYZ, long blob'); + +# 2 rows match +SELECT count(*) FROM t1 + WHERE MATCH (a,b) + AGAINST ('"xyz blob"@3' IN BOOLEAN MODE); + +DROP TABLE t1; + +set global innodb_file_per_table=1; + +# Test fts with externally stored long column +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a TEXT, + b TEXT, + c TEXT + ) CHARACTER SET = UTF8, ROW_FORMAT=DYNAMIC, ENGINE= InnoDB; + +INSERT INTO t1 (a,b,c) VALUES (repeat("b", 19000), 'XYZ, long text', 'very long blob'); +INSERT INTO t1 (a,b,c) VALUES (repeat("b", 19000), 'XYZ, very little long blob very much blob', 'very long blob'); + +# Note 租车 is count as one word +INSERT INTO t1 (a,b,c) VALUES (repeat("b", 19000),"very 租车 ä¾› blob","new 供需分æžinformation"); +CREATE FULLTEXT INDEX idx on t1 (a,b,c); + +INSERT INTO t1 (a,b,c) VALUES (repeat("x", 19000), 'new, long text', 'very new blob'); +INSERT INTO t1 (a,b,c) VALUES ('interesting, long text', repeat("x", 19000), 'very very good new blob'); + +# 3 rows should match +SELECT count(*) FROM t1 + WHERE MATCH (a,b,c) + AGAINST ('"very blob"@3' IN BOOLEAN MODE); + +SELECT count(*) FROM t1 + WHERE MATCH (a,b,c) + AGAINST ('"very long blob"@0' IN BOOLEAN MODE); + +# 4 rows should match +SELECT count(*) FROM t1 + WHERE MATCH (a,b,c) + AGAINST ('"very blob"@4' IN BOOLEAN MODE); + +# 1 row should match +SELECT count(*) FROM t1 + WHERE MATCH (a,b,c) + AGAINST ('"interesting blob"@9' IN BOOLEAN MODE); + +# should have 3 rows +SELECT COUNT(*) FROM t1 + WHERE MATCH (a,b,c) + AGAINST ('"interesting blob"@9 "very long blob"@0' IN BOOLEAN MODE); + +# should have 3 rows +SELECT COUNT(*) FROM t1 + WHERE MATCH (a,b,c) + AGAINST ('"very blob"@4 - "interesting blob"@9' IN BOOLEAN MODE); + +DROP TABLE t1; + +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) CHARACTER SET = UTF8, ENGINE= InnoDB; + +# Space and special characters are not counted as word +INSERT INTO t1 (a,b) VALUES + ('MySQL from Tutorial','DBMS stands for + DataBase ...'); + +CREATE FULLTEXT INDEX idx on t1 (a,b); + +SELECT * FROM t1 +WHERE MATCH (a,b) +AGAINST ('"stands database"@3' IN BOOLEAN MODE); + +DROP TABLE t1; + +# Test fts with externally stored long column +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a TEXT, + b TEXT, + c TEXT + ) CHARACTER SET = UTF8, ROW_FORMAT=DYNAMIC, ENGINE= InnoDB; + +INSERT INTO t1 (a,b,c) VALUES (repeat("b", 19000), 'XYZ, long text', 'very long blob'); +INSERT INTO t1 (a,b,c) VALUES ('XYZ, 租车 very little long blob very much blob', repeat("b", 19000), 'very long but smaller blob'); + +CREATE FULLTEXT INDEX idx on t1 (a,b,c); + +DELETE FROM t1; + +INSERT INTO t1 (a,b,c) VALUES (repeat("b", 19000), 'XYZ, long text', 'very long blob'); +INSERT INTO t1 (a,b,c) VALUES ('XYZ, 租车 very little long blob is a very much longer blob', repeat("b", 19000), 'this is very long but smaller blob'); + +SELECT count(*) FROM t1 + WHERE MATCH (a,b,c) + AGAINST ('"very blob"@4' IN BOOLEAN MODE); + +SELECT count(*) FROM t1 + WHERE MATCH (a,b,c) + AGAINST ('"very blob"@3' IN BOOLEAN MODE); + +DROP TABLE t1; + +eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table_orig; diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_result_cache_limit.test b/mysql-test/suite/innodb_fts/t/innodb_fts_result_cache_limit.test new file mode 100644 index 00000000..1ec37532 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_result_cache_limit.test @@ -0,0 +1,53 @@ +# This is a basic test for innodb fts result cache limit. + +-- source include/have_innodb.inc + +# Must have debug code to use SET SESSION debug +--source include/have_debug.inc +--source include/maybe_versioning.inc + +# Create FTS table +CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) ENGINE= InnoDB; + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','what In this tutorial we will show ...'), + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','what In this tutorial we will show ...'), + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','what In this tutorial we will show ...'); + +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET SESSION debug_dbug="+d,fts_instrument_result_cache_limit"; + +# Simple term search +SELECT COUNT(*) FROM t1 WHERE MATCH (a,b) AGAINST ('mysql' IN BOOLEAN MODE); + +# Query expansion +--error 128 +SELECT COUNT(*) FROM t1 WHERE MATCH (a,b) AGAINST ('mysql' WITH QUERY EXPANSION); + +# Simple phrase search +--error 128 +SELECT COUNT(*) FROM t1 WHERE MATCH (a,b) AGAINST ('"mysql database"' IN BOOLEAN MODE); + +# Simple proximity search +--error 128 +SELECT COUNT(*) FROM t1 WHERE MATCH (a,b) AGAINST ('"mysql database" @ 5' IN BOOLEAN MODE); + +SET SESSION debug_dbug=@saved_debug_dbug; + +DROP TABLE t1; + +SET GLOBAL innodb_ft_result_cache_limit=default; diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_stopword_charset.test b/mysql-test/suite/innodb_fts/t/innodb_fts_stopword_charset.test new file mode 100644 index 00000000..3fe99dab --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_stopword_charset.test @@ -0,0 +1,409 @@ +# This is the basic function tests for innodb FTS stopword charset + +-- source include/have_innodb.inc + +# Embedded server tests do not support restarting +--source include/not_embedded.inc +--source include/maybe_versioning.inc + +SELECT @@innodb_ft_server_stopword_table; +SELECT @@innodb_ft_enable_stopword; +SELECT @@innodb_ft_user_stopword_table; + +SET NAMES utf8; + +-- echo # Test 1 : default latin1_swedish_ci +# Create FTS table with default charset latin1_swedish_ci +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200) + ) ENGINE=InnoDB; + +--disable_warnings +INSERT IGNORE INTO articles (title) VALUES + ('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), + ('lṓve'),('Lá¹’VE'); + +# Build full text index with default stopword +CREATE FULLTEXT INDEX ft_idx ON articles(title); +--enable_warnings + +# We can find 'lòve' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +# Define a user stopword table and set to it +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; + +# Rebuild the full text index with user stopword +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); + +# Now we will not find 'lòve' and check result with 'love' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('love' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; +DROP TABLE user_stopword; + +-- echo # Test 2 : latin1_general_ci +# Create FTS table with default charset latin1_swedish_ci +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200) + ) ENGINE=InnoDB DEFAULT CHARACTER SET latin1 COLLATE latin1_general_ci; + +--disable_warnings +INSERT IGNORE INTO articles (title) VALUES + ('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), + ('lṓve'),('Lá¹’VE'); + +# Build full text index with default stopword +CREATE FULLTEXT INDEX ft_idx ON articles(title); +--enable_warnings + +# We can find 'lòve' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +# Define a user stopword table and set to it +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB + DEFAULT CHARACTER SET latin1 COLLATE latin1_general_ci; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; + +# Rebuild the full text index with user stopword +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); + +# Now we will not find 'lòve' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('love' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; +DROP TABLE user_stopword; + +-- echo # Test 3 : latin1_spanish_ci +# Create FTS table with default charset latin1_swedish_ci +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200) + ) ENGINE=InnoDB DEFAULT CHARACTER SET latin1 COLLATE latin1_spanish_ci; + +--disable_warnings +INSERT IGNORE INTO articles (title) VALUES + ('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), + ('lṓve'),('Lá¹’VE'); + +# Build full text index with default stopword +CREATE FULLTEXT INDEX ft_idx ON articles(title); +--enable_warnings + +# We can find 'lòve' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +# Define a user stopword table and set to it +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB + DEFAULT CHARACTER SET latin1 COLLATE latin1_spanish_ci; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; + +# Rebuild the full text index with user stopword +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); + +# Now we will not find 'lòve' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('love' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; +DROP TABLE user_stopword; + +-- echo # Test 4 : utf8_general_ci +# Create FTS table with default charset utf8_general_ci +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200) + ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; + +--disable_warnings +INSERT INTO articles (title) VALUES + ('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), + ('lṓve'),('Lá¹’VE'); + +# Build full text index with default stopword +CREATE FULLTEXT INDEX ft_idx ON articles(title); +--enable_warnings + +# We can find 'lòve' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +# Define a user stopword table and set to it +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB + DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; + +# Rebuild the full text index with user stopword +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); + +# Now we will not find 'lòve' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('love' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; +DROP TABLE user_stopword; + +-- echo # Test 5 : utf8_unicode_ci +# Create FTS table with default charset utf8_swedish_ci +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200) + ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_swedish_ci; + +--disable_warnings +INSERT INTO articles (title) VALUES + ('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), + ('lṓve'),('Lá¹’VE'); + +# Build full text index with default stopword +CREATE FULLTEXT INDEX ft_idx ON articles(title); +--enable_warnings + +# We can find 'lòve' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +# Define a user stopword table and set to it +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB + DEFAULT CHARACTER SET utf8 COLLATE utf8_swedish_ci; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; + +# Rebuild the full text index with user stopword +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); + +# Now we will not find 'lòve' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('love' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; +DROP TABLE user_stopword; + +-- echo # Test 6 : utf8_unicode_ci +# Create FTS table with default charset utf8_unicode_ci +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200) + ) ENGINE=InnoDB DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; + +--disable_warnings +INSERT INTO articles (title) VALUES + ('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), + ('lṓve'),('Lá¹’VE'); + +# Build full text index with default stopword +CREATE FULLTEXT INDEX ft_idx ON articles(title); +--enable_warnings + +# We can find 'lòve' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +# Define a user stopword table and set to it +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB + DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; + +# Rebuild the full text index with user stopword +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); + +# Now we will not find 'lòve' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('love' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; +DROP TABLE user_stopword; + +-- echo # Test 7 : gb2312_chinese_ci +# Create FTS table with default charset gb2312_chinese_ci +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200) + ) ENGINE=InnoDB DEFAULT CHARACTER SET gb2312 COLLATE gb2312_chinese_ci; + +--disable_warnings +INSERT INTO articles (title) VALUES + ('相亲相爱'),('怜香惜爱'),('充满å¯çˆ±'),('爱æ¨äº¤ç»‡'); + +# Build full text index with default stopword +CREATE FULLTEXT INDEX ft_idx ON articles(title); +--enable_warnings + +# We can find '相亲相爱' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('相亲相爱' IN NATURAL LANGUAGE MODE); + +# Define a user stopword table and set to it +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB + DEFAULT CHARACTER SET gb2312 COLLATE gb2312_chinese_ci; +INSERT INTO user_stopword VALUES('相亲相爱'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; + +# Rebuild the full text index with user stopword +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); + +# Now we will not find '相亲相爱' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('相亲相爱' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('怜香惜爱' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; +DROP TABLE user_stopword; + +-- echo # Test 8 : test shutdown to check if stopword still works +# Create FTS table with default charset latin1_swedish_ci +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200) + ) ENGINE=InnoDB; + +--disable_warnings +INSERT IGNORE INTO articles (title) VALUES + ('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), + ('lṓve'),('Lá¹’VE'); + +# Build full text index with default stopword +CREATE FULLTEXT INDEX ft_idx ON articles(title); +--enable_warnings + +# We can find 'lòve' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +# Define a user stopword table and set to it +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; + +# Rebuild the full text index with user stopword +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); + +# Now we will not find 'lòve' and check result with 'love' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('love' IN NATURAL LANGUAGE MODE); + +--echo # Shutdown and restart mysqld +--source include/restart_mysqld.inc + +SET NAMES utf8; + +# Insert rows to check if it uses user stopword +--disable_warnings +INSERT IGNORE INTO articles (title) VALUES + ('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), + ('lṓve'),('Lá¹’VE'); +--enable_warnings + +# Now we will not find 'lòve' and check result with 'love' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('love' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; +DROP TABLE user_stopword; + +-- echo # Test 9 : drop user stopwrod table,test shutdown to check if it works +# Create FTS table with default charset latin1_swedish_ci +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200) + ) ENGINE=InnoDB; + +--disable_warnings +INSERT IGNORE INTO articles (title) VALUES + ('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), + ('lṓve'),('Lá¹’VE'); + +# Build full text index with default stopword +CREATE FULLTEXT INDEX ft_idx ON articles(title); +--enable_warnings + +# We can find 'lòve' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +# Define a user stopword table and set to it +CREATE TABLE user_stopword(value varchar(30)) ENGINE = InnoDB; +INSERT INTO user_stopword VALUES('lòve'); +SET GLOBAL innodb_ft_server_stopword_table = 'test/user_stopword'; + +# Rebuild the full text index with user stopword +DROP INDEX ft_idx ON articles; +CREATE FULLTEXT INDEX ft_idx ON articles(title); + +# Now we will not find 'lòve' and check result with 'love' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('love' IN NATURAL LANGUAGE MODE); + +# Drop user stopword table +DROP TABLE user_stopword; + +--echo # Shutdown and restart mysqld +--source include/restart_mysqld.inc + +SET NAMES utf8; + +# Insert rows to check if it uses user stopword +--disable_warnings +INSERT IGNORE INTO articles (title) VALUES + ('love'),('LOVE'),('lòve'),('LÃ’VE'),('löve'),('LÖVE'),('løve'),('LØVE'), + ('lṓve'),('Lá¹’VE'); +--enable_warnings + +# Now we will not find 'lòve' and check result with 'love' +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('lòve' IN NATURAL LANGUAGE MODE); + +SELECT * FROM articles WHERE MATCH (title) + AGAINST ('love' IN NATURAL LANGUAGE MODE); + +DROP TABLE articles; diff --git a/mysql-test/suite/innodb_fts/t/innodb_fts_transaction.test b/mysql-test/suite/innodb_fts/t/innodb_fts_transaction.test new file mode 100644 index 00000000..026aeb63 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/innodb_fts_transaction.test @@ -0,0 +1,1009 @@ +# FTS index with transaction +# Important Note: +# 1) Uncommitted records are not visible using FTS index - this is by FTS design +# 2) records will be seen using FTS index ONLY when transaction completes +# 3) UNCOMMITTED RECORDS CAN BE SEEN WITH QURIES WHICH DO NOT USE FTS INDEX +# this behavior do not break integratity of tables and "select" which do not use FTS still can view them. +--source include/have_innodb.inc +--source include/maybe_versioning.inc + + +--disable_warnings +drop table if exists t1; +--enable_warnings + +#------------------------------------------------------------------------------ +# FTS with transaction +#------------------------------------------------------------------------------ +# Create FTS table +EVAL CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB STATS_PERSISTENT=0; + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','what In this tutorial we will show ...'); + +START TRANSACTION; + +# this record is NOT seen with queries using FTS index until commit +INSERT INTO t1 (a,b) VALUES + ('MySQL Tutorial','request docteam for oraclehelp.'); + +# first and third record expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); + +# no records expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request' IN NATURAL LANGUAGE MODE); + +# all records with MySQL expected but record with 'request' not +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request MySQL' IN BOOLEAN MODE); + +# all records with MySQL expected but record with 'request' not +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('-request +MySQL' IN BOOLEAN MODE); + +# only 2nd record expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+MySQL -(Tutorial Optimizing)' IN BOOLEAN MODE); + +# one record expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"stands Database"@11' IN BOOLEAN MODE) ORDER BY 1; + +# all records expected except with 'request' +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('tutorial' WITH QUERY EXPANSION); + +# transaction commit ,now we will be able to see records with FTS index +COMMIT; + +# records having tutorial word +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); + +# records having tutorial and MySQL word +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request MySQL' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('tutorial' WITH QUERY EXPANSION); + +START TRANSACTION; + +# insert null values +INSERT INTO t1 (a,b) VALUES (NULL,NULL); + +# one record expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+request +MySQL' IN BOOLEAN MODE); + +# update record which is visible with FTS index as transaction completed +UPDATE t1 SET a = 'Trial version' , b = 'query performace 1255 minute on 2.1Hz Memory 2GB...' +WHERE MATCH (a,b) AGAINST ('+request +MySQL' IN BOOLEAN MODE); + +# no records expected as it is updated with new value +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request'); + +# no records expected as update tnx is not committed yet. +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('query performace' IN BOOLEAN MODE); + +# update will not able to find record as it uses FTS , so record will be updated +UPDATE t1 SET a = 'when To Use MySQL Well' , b = 'for free faq xyz.com ...' +WHERE MATCH (a,b) AGAINST ('+query +performace' IN BOOLEAN MODE); + +# no records expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('performace'); +# no records expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+mail +MySQL' IN BOOLEAN MODE); +COMMIT; +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('+MySQL' IN BOOLEAN MODE); +SELECT * FROM t1; + +# insert record with @ character which is used in proximity search +INSERT INTO t1 (a,b) VALUES + ('Trial version','query performace 1255 minute on 2.1Hz Memory 2GB...') , + ('when To Use MySQL Well','for free faq mail@xyz.com ...'); + +SELECT * FROM t1; +DROP TABLE t1; + + +#------------------------------------------------------------------------------ +# FTS with rollback +#------------------------------------------------------------------------------ +# Create FTS table +EVAL CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB; + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','what In this tutorial we will show ...'); + +START TRANSACTION; + +# insert record but it won't be visible using FTS index until tnx completes. +INSERT INTO t1 (a,b) VALUES + ('MySQL Tutorial','request docteam for oraclehelp.'); +# two records expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); +# no records expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request' IN NATURAL LANGUAGE MODE); +# only records with MySQL expected as record with 'request' word not committed yet. +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request MySQL' IN BOOLEAN MODE); + +# records with MySQL word +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('-request +MySQL' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+MySQL -(Tutorial Optimizing)' IN BOOLEAN MODE); + +# query expansion mode +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('tutorial' WITH QUERY EXPANSION); + +# query expansion mode +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('tutorial' WITH QUERY EXPANSION); + +# rollback transaction , record with 'request' word rollbacked. +ROLLBACK; + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request MySQL' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('tutorial' WITH QUERY EXPANSION); + +START TRANSACTION; +INSERT INTO t1 (a,b) VALUES (NULL,NULL); + +# no update as record with where condition is not present +UPDATE t1 SET a = 'Trial version' , b = 'query performace 1255 minute on 2.1Hz Memory 2GB...' +WHERE MATCH (a,b) AGAINST ('+request +MySQL' IN BOOLEAN MODE); + +# no records +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request'); + +# no records +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('query performace' IN BOOLEAN MODE); + +# no update as record with where condition is not present +UPDATE t1 SET a = 'when To Use MySQL Well' , b = 'for free faq xyz.com ...' +WHERE MATCH (a,b) AGAINST ('+query +performace' IN BOOLEAN MODE); + +# no records +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('performace'); + +# no records +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+mail +MySQL' IN BOOLEAN MODE); +ROLLBACK; +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('+MySQL' IN BOOLEAN MODE); +SELECT * FROM t1; + +# insert record with @ character which is used in proximity search +INSERT INTO t1 (a,b) VALUES + ('Trial version','query performace 1255 minute on 2.1Hz Memory 2GB...') , + ('when To Use MySQL Well','for free faq mail@xyz.com ...'); + +SELECT * FROM t1; +DROP TABLE t1; + +#------------------------------------------------------------------------------ +# FTS with transaction - +# Uncommitted records are visible using FTS index so try use normal query to +# update such records in active transaction +#------------------------------------------------------------------------------ +# Create FTS table +EVAL CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) ENGINE = InnoDB; + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','what In this tutorial we will show ...'); + +INSERT INTO t1 (a,b) VALUES + ('MySQL Tutorial','request docteam for oraclehelp.'); + +START TRANSACTION; +INSERT INTO t1 (a,b) VALUES (NULL,NULL); + +# only one record expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+request +MySQL' IN BOOLEAN MODE); + +# update record +UPDATE t1 SET a = 'Trial version' , b = 'query performace 1255 minute on 2.1Hz Memory 2GB...' WHERE MATCH (a,b) AGAINST ('+request +MySQL' IN BOOLEAN MODE); + +# updated record is visible as we do not use FTS index in following query +SELECT * from t1; + +# no records expected as it is updated with new value +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request'); + +# no record expected as transaction is not committed. +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('query performace' IN BOOLEAN MODE); + +# following update will not succeed as it uses FTS index in where clause and the record matching condition is not committe yet. +UPDATE t1 SET a = 'when To Use MySQL Well' , b = 'for free faq mail xyz.com ...' WHERE MATCH (a,b) AGAINST ('+query +performace' IN BOOLEAN MODE); +# update will succeed as it uses non FTS condition in where clause. Record in where clause is visible as it is accessed by NON FTS condition. +UPDATE t1 SET a = 'when To Use MySQL Well' , b = 'for free faq mail xyz.com ...' WHERE b like '%query performace%'; + +# no record expected as it is updated wih new value +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('performace'); + +# not visible with FTS as transaction not committed. +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+mail +MySQL' IN BOOLEAN MODE); + +SELECT * from t1; +COMMIT; +SELECT * from t1; + +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('+MySQL' IN BOOLEAN MODE); +SELECT * FROM t1; + +# insert record with @ character which is used in proximity search +INSERT INTO t1 (a,b) VALUES + ('Trial version','query performace 1255 minute on 2.1Hz Memory 2GB...') , + ('when To Use MySQL Well','for free faq mail@xyz.com ...'); + +SELECT * FROM t1; +DROP TABLE t1; + +#------------------------------------------------------------------------------ +# FTS with transaction - multiple connections +#------------------------------------------------------------------------------ + +#set names utf8; +SET NAMES UTF8; + +# Create FTS table +EVAL CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) CHARACTER SET = UTF8,ENGINE = InnoDB; + + +--connect (con1,localhost,root,,) +SET NAMES UTF8; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','what In this tutorial we will show ...'), + ('Я могу еÑÑ‚ÑŒ Ñтекло', 'оно мне Mне вредит'), + ('ΜποÏῶ νὰ φάω σπασμÎνα' ,'γυαλιὰ χωÏὶς νὰ πάθω τίποτα'), + ('Sævör grét', 'áðan þvà úlpan var ónýt'); + + +--connect (con2,localhost,root,,) +SET NAMES UTF8; + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + + +--connection con1 + +# first and third record expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('tutorial' IN NATURAL LANGUAGE MODE); + +INSERT INTO t1 (a,b) VALUES + ('adding record using session 1','for verifying multiple concurrent transactions'), + ('Мога да Ñм Ñтъкло', 'то Mне ми вреди'); + +# one records expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+γυαλιὰ +χωÏὶ*' IN BOOLEAN MODE); + +START TRANSACTION; + +# this record is NOT seen with queries using FTS index until commit +INSERT INTO t1 (a,b) VALUES + ('MySQL Tutorial','request docteam for oraclehelp.'), + ('PÅ™ÃliÅ¡ žluÅ¥ouÄký kůň', 'úpÄ›l Äábelské kódy'); + +# no records expected as its not committed yet +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request Äábelské' IN BOOLEAN MODE); + +# 3 record expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('tutorial' WITH QUERY EXPANSION) ORDER BY 1; + +# one record expected proximity +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + + +--connection con2 + +# one records expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+record +multiple' IN BOOLEAN MODE); + +# 3 rcords expected , two for tutor* and one for Sævö* +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('tutor* Sævö*' IN BOOLEAN MODE) ORDER BY 1; + + +# one record expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('usin* multipl*' IN BOOLEAN MODE); + +# no record expected as this record is not committed +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"request docteam"@08' IN BOOLEAN MODE); + +# no records expected as this record is not committed +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request' IN NATURAL LANGUAGE MODE); + +# all records with MySQL expected but record with 'request' is not committed so 'request' string not visible +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request MySQL' IN BOOLEAN MODE); + +# all records with MySQL expected but record with 'request' not +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('-request +MySQL' IN BOOLEAN MODE); + +# only one record expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+MySQL -(Tutorial Optimizing)' IN BOOLEAN MODE); + +# one record expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('"stands Database"@11' IN BOOLEAN MODE) ORDER BY 1; + +# all records expected except with 'request' +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('tutorial' WITH QUERY EXPANSION) ORDER BY 1; + +--connection con1 +# transaction commit ,now we will be able to see records with FTS index +COMMIT; +# records with MySQL,request string expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+request +MySQL' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('PÅ™ÃliÅ¡ žluÅ¥ouÄký' IN BOOLEAN MODE); + +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('PÅ™ÃliÅ¡'); + +# insert null values +INSERT INTO t1 (a,b) VALUES (NULL,NULL); +SELECT * FROM t1 WHERE a IS NULL AND b IS NULL; + +--connection con2 + +# one record expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('usin* multipl*' IN BOOLEAN MODE); + +# one record expected , b/c record is committed in connection 1 +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+request +MySQL' IN BOOLEAN MODE); + +SELECT * FROM t1 WHERE a IS NULL AND b IS NULL; + + + +ALTER TABLE t1 DROP INDEX idx; +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); + +START TRANSACTION; +# update record but do not commiit so latest upadted string not visible using FTS index but available with normal select +UPDATE t1 SET a = 'Trial version PÅ™ÃliÅ¡ žluÅ¥ouÄký' , b = 'query performace 1255 minute on 2.1Hz Memory 2GB...' +WHERE MATCH (a,b) AGAINST ('+request +MySQL' IN BOOLEAN MODE); + +# no records expected as it is updated with new value +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request'); + +# no records expected as it is not committed +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+query +performace' IN BOOLEAN MODE); + +# only one record will be updated as other is not committed hence not seen using FTS +UPDATE t1 SET a = UPPER(a) WHERE MATCH (a,b) AGAINST ('+PÅ™ÃliÅ¡ +žluÅ¥ouÄký' IN BOOLEAN MODE); + +# no records expected as it is not committed +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+PÅ™ÃliÅ¡ +žluÅ¥ouÄký' IN BOOLEAN MODE); + +UPDATE t1 SET a = UPPER(a) WHERE a LIKE '%version PÅ™ÃliÅ¡%'; + +# no records expected as it is not committed +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+query +performace' IN BOOLEAN MODE); + +SELECT * FROM t1 WHERE b LIKE '%query performace%'; + +# no records expected as it is updated with new value +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('request'); + +--connection con1 + +# no records expected as update tnx is not committed yet. +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('query performace' IN BOOLEAN MODE); + +# no records expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('performace'); +# no records expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+mail +MySQL' IN BOOLEAN MODE); + +--connection con2 +COMMIT; +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+query +performace' IN BOOLEAN MODE); + + + +--connection con1 +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('+query +performace' IN BOOLEAN MODE); +# Update +UPDATE t1 SET a = 'when To Use MySQL Well' , b = 'for free faq xyz.com ...' +WHERE MATCH (a,b) AGAINST ('+πάθω +τίποτα' IN BOOLEAN MODE); +# one record expected +SELECT * FROM t1 + WHERE MATCH (a,b) + AGAINST ('well free') ORDER BY 1; + +--disconnect con1 +--disconnect con2 +--source include/wait_until_disconnected.inc + +--connection default +DROP TABLE t1; + + +#------------------------------------------------------------------------------ +# FTS with delete transaction with multiple session +#------------------------------------------------------------------------------ + +SET NAMES UTF8; + +# Create FTS table +EVAL CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) CHARACTER SET = UTF8,ENGINE = InnoDB; + + +--connect (con1,localhost,root,,) +SET NAMES UTF8; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','what In this tutorial we will show ...'), + ('Я могу еÑÑ‚ÑŒ Ñтекло', 'оно мне Mне вредит'), + ('ΜποÏῶ νὰ φάω σπασμÎνα' ,'γυαλιὰ χωÏὶς νὰ πάθω τίποτα'), + ('Sævör grét', 'áðan þvà úlpan var ónýt'); + + +--connect (con2,localhost,root,,) +SET NAMES UTF8; +select @@session.tx_isolation; + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES + ('adding record using session 1','for verifying multiple concurrent transactions'), + ('Мога да Ñм Ñтъкло', 'то Mне ми вреди'); + + +--connection con1 + + +SELECT * FROM t1; + +START TRANSACTION; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Мога +Mне' IN BOOLEAN MODE); +# Delete rows +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('+Мога +Mне' IN BOOLEAN MODE); +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + +SELECT * FROM t1; + +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +# No record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + +SELECT * FROM t1; + +--connection con2 +# records expected due to repeatable read +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + + +SELECT * FROM t1; + +--connection con1 +COMMIT; +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +# No record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + +--connection con2 +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +# No record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + +SELECT * FROM t1; + + +--disconnect con1 +--disconnect con2 +--source include/wait_until_disconnected.inc + +--connection default +DROP TABLE t1; + + + +#------------------------------------------------------------------------------ +# FTS with update transaction with multiple session +#------------------------------------------------------------------------------ + +SET NAMES UTF8; + +# Create FTS table +EVAL CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) CHARACTER SET = UTF8,ENGINE = InnoDB; + + +--connect (con1,localhost,root,,) +SET NAMES UTF8; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','what In this tutorial we will show ...'), + ('Я могу еÑÑ‚ÑŒ Ñтекло', 'оно мне Mне вредит'); + + +--connect (con2,localhost,root,,) +SET NAMES UTF8; +select @@session.tx_isolation; + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES + ('adding record using session 1','for verifying multiple concurrent transactions'), + ('Мога да Ñм Ñтъкло', 'то Mне ми вреди'); + + +--connection con1 + + +SELECT * FROM t1; + +START TRANSACTION; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Мога +Mне' IN BOOLEAN MODE); +# Update row +UPDATE t1 SET a = 'ΜποÏῶ νὰ φάω σπασμÎνα' , b = 'γυαλιὰ χωÏὶς νὰ πάθω τίποτα' WHERE MATCH (a,b) AGAINST ('+могу +Mне' IN BOOLEAN MODE); +# Insert row +INSERT INTO t1(a,b) VALUES ('Sævör grét', 'áðan þvà úlpan var ónýt'); + +SELECT * FROM t1; + +# 1 record expected - records not seen +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# 1 record expected - records not seen +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); + +SELECT * FROM t1; + +--connection con2 +# 2 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# 1 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +# 1 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); + +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; + +# 1 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# no records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +# 1 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); + +SELECT * FROM t1; + +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; + +# 2 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# 1 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +# 1 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); + +SELECT * FROM t1; + +--connection con1 +COMMIT; +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# no record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + +--connection con2 +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# Innodb:error no record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтекло'); +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + +SELECT * FROM t1; + + +--disconnect con1 +--disconnect con2 +--source include/wait_until_disconnected.inc + +--connection default +DROP TABLE t1; + + +#------------------------------------------------------------------------------ +# FTS with delete/rollback transaction with multiple session +#------------------------------------------------------------------------------ + +SET NAMES UTF8; + +# Create FTS table +EVAL CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) CHARACTER SET = UTF8,ENGINE = InnoDB; + + +--connect (con1,localhost,root,,) +SET NAMES UTF8; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','what In this tutorial we will show ...'), + ('Я могу еÑÑ‚ÑŒ Ñтекло', 'оно мне Mне вредит'), + ('ΜποÏῶ νὰ φάω σπασμÎνα' ,'γυαλιὰ χωÏὶς νὰ πάθω τίποτα'), + ('Sævör grét', 'áðan þvà úlpan var ónýt'); + + +--connect (con2,localhost,root,,) +SET NAMES UTF8; +select @@session.tx_isolation; + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES + ('adding record using session 1','for verifying multiple concurrent transactions'), + ('Мога да Ñм Ñтъкло', 'то Mне ми вреди'); + + +--connection con1 + + +SELECT * FROM t1; + +START TRANSACTION; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Мога +Mне' IN BOOLEAN MODE); +# Delete rows +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('+Мога +Mне' IN BOOLEAN MODE); +DELETE FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + +SELECT * FROM t1; + +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# No record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +# No record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + +SELECT * FROM t1; + +--connection con2 +# records expected due to repeatable read +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + + +SELECT * FROM t1; + +--connection con1 +ROLLBACK; +# 2 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + +--connection con2 +# 2 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + +SELECT * FROM t1; + + +--disconnect con1 +--disconnect con2 +--source include/wait_until_disconnected.inc + +--connection default +DROP TABLE t1; + + + +#------------------------------------------------------------------------------ +# FTS with update/rollback transaction with multiple session +#------------------------------------------------------------------------------ + +SET NAMES UTF8; + +# Create FTS table +EVAL CREATE TABLE t1 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + a VARCHAR(200), + b TEXT + ) CHARACTER SET = UTF8,ENGINE = InnoDB; + + +--connect (con1,localhost,root,,) +SET NAMES UTF8; + +# Insert rows +INSERT INTO t1 (a,b) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','what In this tutorial we will show ...'), + ('Я могу еÑÑ‚ÑŒ Ñтекло', 'оно мне Mне вредит'); + + +--connect (con2,localhost,root,,) +SET NAMES UTF8; +select @@session.tx_isolation; + +# Create the FTS index again +CREATE FULLTEXT INDEX idx on t1 (a,b); +INSERT INTO t1 (a,b) VALUES + ('adding record using session 1','for verifying multiple concurrent transactions'), + ('Мога да Ñм Ñтъкло', 'то Mне ми вреди'); + + +--connection con1 + + +SELECT * FROM t1; + +START TRANSACTION; +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+могу +Mне' IN BOOLEAN MODE); +# Update row +UPDATE t1 SET a = 'ΜποÏῶ νὰ φάω σπασμÎνα' , b = 'γυαλιὰ χωÏὶς νὰ πάθω τίποτα' WHERE MATCH (a,b) AGAINST ('+могу +Mне' IN BOOLEAN MODE); +# Insert row +INSERT INTO t1(a,b) VALUES ('Sævör grét', 'áðan þvà úlpan var ónýt'); + +SELECT * FROM t1; + +# 1 record expected - records not seen +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); + +SELECT * FROM t1; + +--connection con2 +# 2 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# 1 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +# 1 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); + +SET SESSION TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; + +# 1 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +# 1 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); + +SELECT * FROM t1; + +SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ; + +# 2 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# 1 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +# 1 records expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"dbms stands"@05' IN BOOLEAN MODE); + +SELECT * FROM t1; + +--connection con1 +ROLLBACK; +# 2 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +# no record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + +--connection con2 +# 2 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('+Mне' IN BOOLEAN MODE); +# 1 record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('Ñтъкло'); +# no record expected +SELECT * FROM t1 WHERE MATCH (a,b) AGAINST ('"Sævör grét"@18' IN BOOLEAN MODE); + +SELECT * FROM t1; + + +--disconnect con1 +--disconnect con2 +--source include/wait_until_disconnected.inc + + +--connection default +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/misc_debug.test b/mysql-test/suite/innodb_fts/t/misc_debug.test new file mode 100644 index 00000000..08581768 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/misc_debug.test @@ -0,0 +1,117 @@ +# Miscellanous FULLTEXT INDEX tests for debug-instrumented servers. +# Note: These tests used to be part of a larger test, innodb_fts_misc_debug +# or innodb_fts.misc_debug. A large part of that test can be run on a +# non-debug server and has been renamed to innodb_fts.crash_recovery. + +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc +--source include/count_sessions.inc +--source include/maybe_versioning.inc + +# Following test is for Bug 14668777 - ASSERT ON IB_VECTOR_SIZE( +# TABLE->FTS->INDEXES, ALTER TABLE +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) + ) ENGINE=InnoDB; + +# Abort the operation in dict_create_index_step by setting +# return status of dict_create_index_tree_step() to DB_OUT_OF_MEMORY +# The newly create dict_index_t should be removed from fts cache +SET @saved_debug_dbug = @@SESSION.debug_dbug; +SET SESSION debug_dbug="+d,ib_dict_create_index_tree_fail"; +--error ER_OUT_OF_RESOURCES +CREATE FULLTEXT INDEX idx ON articles(body); +SET SESSION debug_dbug=@saved_debug_dbug; + +# This simply go through ha_innobase::commit_inplace_alter_table +# and do a fts_check_cached_index() +ALTER TABLE articles STATS_PERSISTENT=DEFAULT; + +DROP TABLE articles; + +# This test used to be called innodb_fts.innobase_drop_fts_index_table: + +CREATE TABLE t (a INT, b TEXT) engine=innodb; +SET debug_dbug='+d,alter_table_rollback_new_index'; +-- error ER_UNKNOWN_ERROR +ALTER TABLE t ADD FULLTEXT INDEX (b(64)); +SET SESSION debug_dbug=@saved_debug_dbug; + +DROP TABLE t; + +# MDEV-21550 Assertion `!table->fts->in_queue' failed in +# fts_optimize_remove_table +CREATE TABLE t1 (pk INT, a VARCHAR(8), PRIMARY KEY(pk), + FULLTEXT KEY(a)) ENGINE=InnoDB; +CREATE TABLE t2 (b INT, FOREIGN KEY(b) REFERENCES t1(pk)) ENGINE=InnoDB; +--error ER_ROW_IS_REFERENCED_2 +DROP TABLE/*foo*/ t1; +SET DEBUG_DBUG="+d,fts_instrument_sync"; +INSERT INTO t1 VALUES(1, "mariadb"); +ALTER TABLE t1 FORCE; +# Cleanup +DROP TABLE t2, t1; +SET SESSION debug_dbug=@saved_debug_dbug; + +--echo # +--echo # MDEV-25200 Index count mismatch due to aborted FULLTEXT INDEX +--echo # +CREATE TABLE t1(a INT, b TEXT, c TEXT, FULLTEXT INDEX(b)) ENGINE=InnoDB; +INSERT INTO t1 VALUES(1, "test", "test_1"); +connect(con1,localhost,root,,test); +SET DEBUG_DBUG="+d,innodb_OOM_inplace_alter"; +SET DEBUG_SYNC='innodb_commit_inplace_alter_table_enter SIGNAL s2 WAIT_FOR g2'; +send ALTER TABLE t1 ADD FULLTEXT(c); +connection default; +SET DEBUG_SYNC='now WAIT_FOR s2'; +START TRANSACTION; +SELECT * FROM t1; +SET DEBUG_SYNC='now SIGNAL g2'; +connection con1; +--error ER_OUT_OF_RESOURCES +reap; +disconnect con1; +connection default; +SET DEBUG_SYNC=RESET; +# Exploit MDEV-17468 to force the table definition to be reloaded +ALTER TABLE t1 ADD bl INT AS (LENGTH(b)) VIRTUAL; +CHECK TABLE t1; +DROP TABLE t1; +--source include/wait_until_count_sessions.inc + +--echo # +--echo # MDEV-25663 Double free of transaction during TRUNCATE +--echo # +call mtr.add_suppression("InnoDB: \\(Too many concurrent transactions\\)"); +call mtr.add_suppression("InnoDB: Cannot save table statistics for table `test`\\.`t1`: Too many concurrent transactions"); +SET @saved_debug_dbug= @@debug_dbug; + +CREATE TABLE t1 (b CHAR(12), FULLTEXT KEY(b)) engine=InnoDB; +SET debug_dbug='+d,ib_create_table_fail_too_many_trx'; +if ($MTR_COMBINATION_ORIG) +{ +TRUNCATE t1; +} +if (!$MTR_COMBINATION_ORIG) +{ +--echo TRUNCATE t1; +} +SET debug_dbug=@saved_debug_dbug; +DROP TABLE t1; +--echo # End of 10.3 tests + +# Fulltext fails in commit phase + +CREATE TABLE t1(f1 INT NOT NULL, f2 CHAR(100))ENGINE=InnoDB; +SET DEBUG_DBUG="+d,stats_lock_fail"; +--error ER_LOCK_WAIT_TIMEOUT +ALTER TABLE t1 ADD FULLTEXT(f2); +SET debug_dbug=@saved_debug_dbug; +ALTER TABLE t1 DISCARD TABLESPACE; +--error ER_TABLESPACE_DISCARDED +ALTER TABLE t1 ADD FULLTEXT(f2); +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/misc_debug2.test b/mysql-test/suite/innodb_fts/t/misc_debug2.test new file mode 100644 index 00000000..946700e3 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/misc_debug2.test @@ -0,0 +1,28 @@ +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/not_embedded.inc +call mtr.add_suppression("InnoDB: Table '.*' tablespace is set as discarded."); +call mtr.add_suppression("InnoDB: Tablespace for table .* is set as discarded."); + +CREATE TABLE mdev21563(f1 VARCHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB; +set debug_dbug="+d,fts_instrument_sync_request"; +INSERT INTO mdev21563 VALUES('This is a test'); +ALTER TABLE mdev21563 DISCARD TABLESPACE; +--source include/restart_mysqld.inc +DROP TABLE mdev21563; + +--echo # +--echo # MDEV-29342 Assertion failure in file que0que.cc line 728 +--echo # +CREATE TABLE t1(f1 CHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB; +INSERT INTO t1 VALUES('mysql'), ('innodb'); +SET @save_dbug=@@debug_dbug; +set debug_dbug="+d,fts_instrument_sync_request"; +INSERT INTO t1 VALUES('test'); +set debug_dbug=@save_dbug; +INSERT INTO t1 VALUES('This is a fts issue'); +--source include/restart_mysqld.inc +set debug_dbug="+d,fts_instrument_sync_request"; +UPDATE t1 SET f1="mariadb"; +set debug_dbug=@save_dbug; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/stopword.inc b/mysql-test/suite/innodb_fts/t/stopword.inc new file mode 100644 index 00000000..774501ad --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/stopword.inc @@ -0,0 +1,55 @@ +if ($stopword_stage == create_table) +{ +call mtr.add_suppression("\\[ERROR\\] InnoDB: user stopword table not_defined does not exist."); +call mtr.add_suppression("\\[ERROR\\] InnoDB: user stopword table test/user_stopword_session does not exist."); + +select * from information_schema.innodb_ft_default_stopword; + +# Create FTS table +eval CREATE TABLE $stopword_table ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) + )$create_options ENGINE=InnoDB; + +# Insert six rows +eval INSERT INTO $stopword_table (title,body) VALUES + ('MySQL Tutorial','DBMS stands for DataBase ...') , + ('How To Use MySQL Well','After you went through a ...'), + ('Optimizing MySQL','In this tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# "the" is in the default stopword, it would not be selected +eval SELECT * FROM $stopword_table WHERE MATCH (title,body) + AGAINST ('the' IN NATURAL LANGUAGE MODE); + +# Provide user defined stopword table, if not (correctly) defined, +# it will be rejected +--error ER_WRONG_VALUE_FOR_VAR +set global innodb_ft_server_stopword_table = "not_defined"; +set global innodb_ft_server_stopword_table = NULL; + +# Define a correct formatted user stopword table +eval create table user_stopword(value varchar(30))$create_options engine = innodb; + +# The set operation should be successful +set global innodb_ft_server_stopword_table = "test/user_stopword"; + +eval drop index title on $stopword_table; + +eval create fulltext index idx on $stopword_table(title, body); +} + +if ($stopword_stage == select_1) +{ +--error 0, ER_INDEX_CORRUPT +eval SELECT * FROM $stopword_table WHERE MATCH (title,body) + AGAINST ('the' IN NATURAL LANGUAGE MODE); +--error 0, ER_INDEX_CORRUPT +eval SELECT * FROM $stopword_table WHERE MATCH (title,body) + AGAINST ('this' IN NATURAL LANGUAGE MODE); + +} diff --git a/mysql-test/suite/innodb_fts/t/stopword.opt b/mysql-test/suite/innodb_fts/t/stopword.opt new file mode 100644 index 00000000..d6938c3b --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/stopword.opt @@ -0,0 +1 @@ +--innodb-ft-default-stopword diff --git a/mysql-test/suite/innodb_fts/t/stopword.test b/mysql-test/suite/innodb_fts/t/stopword.test new file mode 100644 index 00000000..9f8bd89b --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/stopword.test @@ -0,0 +1,627 @@ +# This is the basic function tests for innodb FTS + +-- source include/have_innodb.inc +-- let $modify_create_table= 1 +-- source include/maybe_versioning.inc + +SET @innodb_ft_server_stopword_table_orig=@@innodb_ft_server_stopword_table; +SET @innodb_ft_enable_stopword_orig=@@innodb_ft_enable_stopword; +SET @innodb_ft_user_stopword_table_orig=@@innodb_ft_user_stopword_table; + +let $stopword_table= articles; +let $stopword_stage= create_table; +--source stopword.inc + +# Now we should be able to find "the" +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('the' IN NATURAL LANGUAGE MODE); + +# Nothing inserted into the default stopword, so essentially +# nothing get screened. The new stopword could only be +# effective for table created thereafter +eval CREATE TABLE articles_2 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) + )$create_options ENGINE=InnoDB; + +INSERT INTO articles_2 (title, body) + VALUES ('test for stopwords','this is it...'); + +# Now we can find record with "this" +SELECT * FROM articles_2 WHERE MATCH (title,body) + AGAINST ('this' IN NATURAL LANGUAGE MODE); + +# Ok, let's instantiate some value into user supplied stop word +# table +insert into user_stopword values("the"); +delete from user_stopword; +insert into user_stopword values("this"); + +# Ok, let's repeat with the new table again. +eval CREATE TABLE articles_3 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) + )$create_options ENGINE=InnoDB; + +INSERT INTO articles_3 (title, body) + VALUES ('test for stopwords','this is it...'); + +# Now we should NOT find record with "this" +SELECT * FROM articles_3 WHERE MATCH (title,body) + AGAINST ('this' IN NATURAL LANGUAGE MODE); + +# Test session level stopword control "innodb_user_stopword_table" +eval create table user_stopword_session(value varchar(30))$create_options engine = innodb; + +insert into user_stopword values("this"); +delete from user_stopword; +insert into user_stopword_session values("session"); + +set session innodb_ft_user_stopword_table="test/user_stopword_session"; + +eval CREATE TABLE articles_4 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) + )$create_options ENGINE=InnoDB; + +INSERT INTO articles_4 (title, body) + VALUES ('test for session stopwords','this should also be excluded...'); + +# "session" is excluded +SELECT * FROM articles_4 WHERE MATCH (title,body) + AGAINST ('session' IN NATURAL LANGUAGE MODE); + +# But we can find record with "this" +SELECT * FROM articles_4 WHERE MATCH (title,body) + AGAINST ('this' IN NATURAL LANGUAGE MODE); + +--connect (con1,localhost,root,,) +eval CREATE TABLE articles_5 ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT (title,body) + )$create_options ENGINE=InnoDB; + +INSERT INTO articles_5 (title, body) + VALUES ('test for session stopwords','this should also be excluded...'); + +# "session" should be found since the stopword table is session specific +SELECT * FROM articles_5 WHERE MATCH (title,body) + AGAINST ('session' IN NATURAL LANGUAGE MODE); + +--connection default +drop table articles; +drop table articles_2; +drop table articles_3; +drop table articles_4; +drop table articles_5; +drop table user_stopword; +drop table user_stopword_session; + +SET GLOBAL innodb_ft_enable_stopword=@innodb_ft_enable_stopword_orig; +SET GLOBAL innodb_ft_server_stopword_table=default; + +#--------------------------------------------------------------------------------------- +# Behavior : +# The stopword is loaded into memory at +# 1) create fulltext index time, +# 2) boot server, +# 3) first time FTs is used +# So if you already created a FTS index, and then turn off stopword +# or change stopword table content it won't affect the FTS +# that already created since the stopword list are already loaded. +# It will only affect the new FTS index created after you changed +# the settings. + +# Create FTS table +eval CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT `idx` (title,body) + )$create_options ENGINE=InnoDB; + +SHOW CREATE TABLE articles; + +# Insert six rows +INSERT INTO articles (title,body) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','In what tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# Case : server_stopword=default +# Try to Search default stopword from innodb, "where", "will", "what" +# and "when" are all stopwords +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("where will"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("when"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("what" WITH QUERY EXPANSION); +# boolean No result expected +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("whe*" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+what +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+from" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+where +(show what)" IN BOOLEAN MODE); +# no result expected +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@6' IN BOOLEAN MODE); +# no result expected +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@9' IN BOOLEAN MODE); + +INSERT INTO articles(title,body) values ('the record will' , 'not index the , will words'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"the will"@11' IN BOOLEAN MODE); +# Not going to update as where condition can not find record +UPDATE articles SET title = "update the record" , body = 'to see will is indexed or not' +WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +# Update the record +UPDATE articles SET title = "update the record" , body = 'to see will is indexed or not' +WHERE id = 7; +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +# Delete will not work as where condition do not return +DELETE FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE id = 7; +DELETE FROM articles WHERE id = 7; + + + +# Case : Turn OFF stopword list variable and search stopword on OLD index. +# disable stopword list +SET global innodb_ft_server_stopword_table = NULL; +SET SESSION innodb_ft_enable_stopword = 0; +select @@innodb_ft_enable_stopword; +SET global innodb_ft_user_stopword_table = NULL; + +# search default stopword with innodb_ft_enable_stopword is OFF. +# No records expected even though we turned OFF stopwod filtering +# (refer Behavior (at the top of the test) for explanation ) +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("where will"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("when"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("what" WITH QUERY EXPANSION); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("whe*" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+what +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+from" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+where +(show what)" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@6' IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@9' IN BOOLEAN MODE); + +INSERT INTO articles(title,body) values ('the record will' , 'not index the , will words'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"the will"@11' IN BOOLEAN MODE); +# Not going to update as where condition can not find record +UPDATE articles SET title = "update the record" , body = 'to see will is indexed or not' +WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +# Update the record +UPDATE articles SET title = "update the record" , body = 'to see will is indexed or not' +WHERE id = 8; +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +SELECT * FROM articles WHERE id = 8; +# Delete will not work as where condition do not return +DELETE FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE id = 8; +DELETE FROM articles WHERE id = 8; + +# Case : Turn OFF stopword list variable and search stopword on NEW index. +# Drop index +ALTER TABLE articles DROP INDEX idx; +SHOW CREATE TABLE articles; + +# Create the FTS index Using Alter Table. +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); + +ANALYZE TABLE articles; + +# search default stopword with innodb_ft_enable_stopword is OFF. +# All records expected as stopwod filtering is OFF and we created +# new FTS index. +# (refer Behavior (at the top of the test) for explanation ) +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("where will"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("when"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("what" WITH QUERY EXPANSION); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("whe*" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+what +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+from" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+where +(show what)" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@6' IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@9' IN BOOLEAN MODE); + +INSERT INTO articles(title,body) values ('the record will' , 'not index the , will words'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"the will"@11' IN BOOLEAN MODE); +# Update will succeed. +UPDATE articles SET title = "update the record" , body = 'to see will is indexed or not' +WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); + +SELECT COUNT(*),max(id) FROM articles; +# Update the record - uncommet on fix +#UPDATE articles SET title = "update the record" , body = 'to see will is indexed or not' +#WHERE id = 9; +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +# Delete will succeed. +DELETE FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE id = 9; + + +DROP TABLE articles; + +SET SESSION innodb_ft_enable_stopword=@innodb_ft_enable_stopword_orig; +SET GLOBAL innodb_ft_server_stopword_table=@innodb_ft_server_stopword_table_orig; +SET GLOBAL innodb_ft_user_stopword_table=@innodb_ft_user_stopword_table_orig; +SET SESSION innodb_ft_user_stopword_table=default; + +# Create FTS table +eval CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT `idx` (title,body) + )$create_options ENGINE=InnoDB; + +# Insert six rows +INSERT INTO articles (title,body) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','In what tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# No records expeced for select +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +# Define a correct formatted user stopword table +eval create table user_stopword(value varchar(30))$create_options engine = innodb; +# The set operation should be successful +set session innodb_ft_user_stopword_table = "test/user_stopword"; +# Define a correct formatted server stopword table +eval create table server_stopword(value varchar(30))$create_options engine = innodb; +# The set operation should be successful +set global innodb_ft_server_stopword_table = "test/server_stopword"; +# Add values into user supplied stop word table +insert into user_stopword values("when"),("where"); +delete from user_stopword; +insert into user_stopword values("this"),("will"),("the"); + +# Drop existing index and create the FTS index Using Alter Table. +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); + +# Add values into server supplied stop word table +insert into server_stopword values("what"),("where"); +# Follwoing should return result as server stopword list was empty at create index time +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); + +# Delete stopword from user list +DELETE FROM user_stopword; +# Drop existing index and create the FTS index Using Alter Table. +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +# Follwoing should return result even though to server stopword list +# conatin these words. Session level stopword list takes priority +# Here user_stopword is set using innodb_ft_user_stopword_table +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); + +# Follwoing should return result as user stopword list was empty at create index time +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); + +# Add values into user supplied stop word table +insert into user_stopword values("this"),("will"),("the"); + +# Drop existing index and create the FTS index Using Alter Table. +ALTER TABLE articles DROP INDEX idx; +SET SESSION innodb_ft_enable_stopword = 0; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); + +# Session level stopword list takes priority +SET SESSION innodb_ft_enable_stopword = 1; +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); + +# Make user stopword list deafult so as to server stopword list takes priority +SET SESSION innodb_ft_enable_stopword = 1; +SET SESSION innodb_ft_user_stopword_table = default; +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); + + +DROP TABLE articles,user_stopword,server_stopword; + +# Restore Defaults +SET innodb_ft_enable_stopword=@innodb_ft_enable_stopword_orig; +SET GLOBAL innodb_ft_server_stopword_table=default; +SET SESSION innodb_ft_user_stopword_table=default; + +#--------------------------------------------------------------------------------------- +# Create FTS table +eval CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT `idx` (title,body) + )$create_options ENGINE=InnoDB; + +SHOW CREATE TABLE articles; + +# Insert six rows +INSERT INTO articles (title,body) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','In what tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# No records expeced for select +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +# Define a correct formatted user stopword table +eval create table user_stopword(value varchar(30))$create_options engine = innodb; +# The set operation should be successful +set session innodb_ft_user_stopword_table = "test/user_stopword"; +insert into user_stopword values("mysqld"),("DBMS"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+DBMS +mysql" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysqld'); + + +# Drop existing index and create the FTS index Using Alter Table. +# user stopword list will take effect. +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+DBMS +mysql" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysqld'); + +# set user stopword list empty +set session innodb_ft_user_stopword_table = default; +# Define a correct formatted user stopword table +eval create table server_stopword(value varchar(30))$create_options engine = innodb; +# The set operation should be successful +set global innodb_ft_server_stopword_table = "test/server_stopword"; +insert into server_stopword values("root"),("properly"); +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+root +mysql" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('properly'); + + +# set user stopword list empty +set session innodb_ft_user_stopword_table = "test/user_stopword"; +# The set operation should be successful +set global innodb_ft_server_stopword_table = "test/server_stopword"; +# user stopword list take effect as its session level +# Result expected for select +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+root +mysql" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('properly'); + +# set user stopword list +set session innodb_ft_user_stopword_table = "test/user_stopword"; +DELETE FROM user_stopword; +# The set operation should be successful +set global innodb_ft_server_stopword_table = "test/server_stopword"; +DELETE FROM server_stopword; +# user stopword list take affect as its session level +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+wha* +where" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('what'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+root +mysql" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('properly'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+DBMS +mysql" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('mysqld'); + +DROP TABLE articles,user_stopword,server_stopword; + +# Restore Values +SET SESSION innodb_ft_enable_stopword=@innodb_ft_enable_stopword_orig; +SET GLOBAL innodb_ft_server_stopword_table=default; +SET SESSION innodb_ft_user_stopword_table=default; + + +#------------------------------------------------------------------------------ +# FTS stopword list test - check varaibles across sessions + +# Create FTS table +eval CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT `idx` (title,body) + )$create_options ENGINE=InnoDB; + +SHOW CREATE TABLE articles; + +# Insert six rows +INSERT INTO articles (title,body) VALUES + ('MySQL from Tutorial','DBMS stands for DataBase ...') , + ('when To Use MySQL Well','After that you went through a ...'), + ('where will Optimizing MySQL','In what tutorial we will show ...'), + ('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), + ('MySQL vs. YourSQL','In the following database comparison ...'), + ('MySQL Security','When configured properly, MySQL ...'); + +# session varaible innodb_ft_enable_stopword=0 will take effect for new FTS index +SET SESSION innodb_ft_enable_stopword = 0; +select @@innodb_ft_enable_stopword; + +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); + + +--echo "In connection 1" +--connection con1 +select @@innodb_ft_enable_stopword; + +ANALYZE TABLE articles; + +# result expected as index created before setting innodb_ft_enable_stopword varaible off +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("where will"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("when"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("what" WITH QUERY EXPANSION); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("whe*" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+what +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+from" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+where +(show what)" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@6' IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@9' IN BOOLEAN MODE); + +SET SESSION innodb_ft_enable_stopword = 1; +select @@innodb_ft_enable_stopword; +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +# no result expected turned innodb_ft_enable_stopword is ON +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("where will"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("when"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("what" WITH QUERY EXPANSION); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("whe*" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+what +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+from" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+where +(show what)" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@6' IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@9' IN BOOLEAN MODE); + + +--echo "In connection default" +--connection default +select @@innodb_ft_enable_stopword; +# no result expected as word not indexed from connection 1 +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("where will"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("when"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST ("what" WITH QUERY EXPANSION); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("whe*" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+what +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+from" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+where +(show what)" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@6' IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"where will"@9' IN BOOLEAN MODE); + +INSERT INTO articles(title,body) values ('the record will' , 'not index the , will words'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"the will"@11' IN BOOLEAN MODE); + +SET SESSION innodb_ft_enable_stopword = 1; +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+the +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('"the will"@11' IN BOOLEAN MODE); + + +--echo "In connection 1" +--connection con1 +SET SESSION innodb_ft_enable_stopword = 1; +# Define a correct formatted user stopword table +eval create table user_stopword(value varchar(30))$create_options engine = innodb; +# The set operation should be successful +set session innodb_ft_user_stopword_table = "test/user_stopword"; +# Add values into user supplied stop word table +insert into user_stopword values("this"),("will"),("the"); +# Drop existing index and create the FTS index Using Alter Table. +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +# no result expected as innodb_ft_user_stopword_table filter it +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); + + +--echo "In connection default" +--connection default +# no result expected as innodb_ft_user_stopword_table filter it from connection1 +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+show +will" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('will'); +select @@innodb_ft_user_stopword_table; +# Define a correct formatted user stopword table +eval create table user_stopword_1(value varchar(30))$create_options engine = innodb; +# The set operation should be successful +set session innodb_ft_user_stopword_table = "test/user_stopword_1"; +insert into user_stopword_1 values("when"); +SET SESSION innodb_ft_enable_stopword = 1; +# result expected +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+when" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('when'); +# Drop existing index and create the FTS index Using Alter Table. +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +# no result expected +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+when" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('when'); + +--echo "In connection 1" +--connection con1 +SET SESSION innodb_ft_enable_stopword = 1; +SET SESSION innodb_ft_user_stopword_table=default; +select @@innodb_ft_user_stopword_table; +select @@innodb_ft_server_stopword_table; +# Define a correct formatted server stopword table +eval create table server_stopword(value varchar(30))$create_options engine = innodb; +# The set operation should be successful +SET GLOBAL innodb_ft_server_stopword_table = "test/server_stopword"; +select @@innodb_ft_server_stopword_table; +insert into server_stopword values("when"),("the"); +# Drop existing index and create the FTS index Using Alter Table. +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +# no result expected +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+when" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('the'); + +disconnect con1; +--source include/wait_until_disconnected.inc + +--echo "In connection default" +--connection default +SET SESSION innodb_ft_enable_stopword = 1; +SET SESSION innodb_ft_user_stopword_table=default; +select @@innodb_ft_server_stopword_table; +# result expected +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+will +where" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('where'); +insert into server_stopword values("where"),("will"); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+will +where" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('where'); +ALTER TABLE articles DROP INDEX idx; +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +# no result expected +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+when" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('the'); +SELECT * FROM articles WHERE MATCH(title,body) AGAINST("+will +where" IN BOOLEAN MODE); +SELECT * FROM articles WHERE MATCH (title,body) AGAINST ('where'); + + +DROP TABLE articles,user_stopword,user_stopword_1,server_stopword; + +# Restore Values +SET GLOBAL innodb_ft_user_stopword_table=@innodb_ft_user_stopword_table_orig; +SET GLOBAL innodb_ft_server_stopword_table=@innodb_ft_server_stopword_table_orig; diff --git a/mysql-test/suite/innodb_fts/t/sync.opt b/mysql-test/suite/innodb_fts/t/sync.opt new file mode 100644 index 00000000..7724f976 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/sync.opt @@ -0,0 +1,2 @@ +--innodb-ft-index-cache +--innodb-ft-index-table diff --git a/mysql-test/suite/innodb_fts/t/sync.test b/mysql-test/suite/innodb_fts/t/sync.test new file mode 100644 index 00000000..168309a5 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/sync.test @@ -0,0 +1,188 @@ +# +# BUG#22516559 MYSQL INSTANCE STALLS WHEN SYNCING FTS INDEX +# + +--source include/have_innodb.inc +--source include/have_debug_sync.inc +--source include/not_valgrind.inc +--source include/not_embedded.inc +--source include/not_crashrep.inc +--source include/maybe_versioning.inc + +connect (con1,localhost,root,,); +connection default; + +--echo # Case 1: Test select and insert(row in both disk and cache) +CREATE TABLE t1 ( + FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + FULLTEXT(title) +) ENGINE = InnoDB; + +INSERT INTO t1(title) VALUES('mysql'); +INSERT INTO t1(title) VALUES('database'); + +connection con1; + +SET @old_dbug = @@SESSION.debug_dbug; +SET debug_dbug = '+d,fts_instrument_sync_debug'; + +SET DEBUG_SYNC= 'fts_write_node SIGNAL written WAIT_FOR selected'; + +send INSERT INTO t1(title) VALUES('mysql database'); + +connection default; + +SET DEBUG_SYNC= 'now WAIT_FOR written'; + +SET GLOBAL innodb_ft_aux_table="test/t1"; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +SET GLOBAL innodb_ft_aux_table=default; + +SELECT * FROM t1 WHERE MATCH(title) AGAINST('mysql database'); + +SET DEBUG_SYNC= 'now SIGNAL selected'; + +connection con1; +--reap + +SET @old_dbug = @@SESSION.debug_dbug; + +SET GLOBAL innodb_ft_aux_table="test/t1"; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +SET GLOBAL innodb_ft_aux_table=default; + +SELECT * FROM t1 WHERE MATCH(title) AGAINST('mysql database'); + +connection default; + +DROP TABLE t1; + +--echo # Case 2: Test insert and insert(sync) +CREATE TABLE t1 ( + FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + FULLTEXT(title) +) ENGINE = InnoDB; + +INSERT INTO t1(title) VALUES('mysql'); +INSERT INTO t1(title) VALUES('database'); + +connection con1; + +SET debug_dbug = '+d,fts_instrument_sync_debug'; + +SET DEBUG_SYNC= 'fts_write_node SIGNAL written WAIT_FOR inserted'; + +send INSERT INTO t1(title) VALUES('mysql database'); + +connection default; + +SET DEBUG_SYNC= 'now WAIT_FOR written'; + +INSERT INTO t1(title) VALUES('mysql database'); + +SET DEBUG_SYNC= 'now SIGNAL inserted'; + +connection con1; +--reap + +SET debug_dbug = @old_dbug; + +SET GLOBAL innodb_ft_aux_table="test/t1"; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +SET GLOBAL innodb_ft_aux_table=default; + +SELECT * FROM t1 WHERE MATCH(title) AGAINST('mysql database'); + +connection default; +disconnect con1; + +DROP TABLE t1; + +--echo # Case 3: Test insert crash recovery +--let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')` +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect + +CREATE TABLE t1 ( + FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + FULLTEXT(title) +) ENGINE = InnoDB; + +INSERT INTO t1(title) VALUES('database'); + +--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect + +SET debug_dbug = '+d,fts_instrument_sync_debug,fts_write_node_crash'; + +--error 2013 +INSERT INTO t1(title) VALUES('mysql'); + +--source include/start_mysqld.inc + +-- echo After restart +# PAGE_ROOT_AUTO_INC could contain last failed autoinc value. Avoid +# doing show the result of auto increment field +SELECT title FROM t1 WHERE MATCH(title) AGAINST ('mysql database'); + +SET @old_dbug = @@SESSION.debug_dbug; + +SET debug_dbug = '+d,fts_instrument_sync_debug'; + +INSERT INTO t1(title) VALUES('mysql'); + +SET debug_dbug = @old_dbug; + +SELECT title FROM t1 WHERE MATCH(title) AGAINST ('mysql database'); + +DROP TABLE t1; + +--echo # Case 4: Test sync commit & rollback in background +CREATE TABLE t1( + id INT AUTO_INCREMENT, + title VARCHAR(100), + FULLTEXT(title), + PRIMARY KEY(id)) ENGINE=InnoDB; + +SET debug_dbug = '+d,fts_instrument_sync'; +INSERT INTO t1(title) VALUES('mysql'); +SET debug_dbug = @old_dbug; + +--source include/restart_mysqld.inc + +SET @old_global_dbug = @@GLOBAL.debug_dbug; +SET @old_dbug = @@SESSION.debug_dbug; +SET GLOBAL debug_dbug='+d,fts_instrument_sync,fts_instrument_sync_interrupted'; +INSERT INTO t1(title) VALUES('database'); +SET GLOBAL debug_dbug = @old_global_dbug; + +SET debug_dbug = '+d,fts_instrument_sync_debug'; +INSERT INTO t1(title) VALUES('good'); +SET debug_dbug = @old_dbug; + +SET GLOBAL innodb_ft_aux_table="test/t1"; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_TABLE; +SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE; +SET GLOBAL innodb_ft_aux_table=default; + +SELECT * FROM t1 WHERE MATCH(title) AGAINST ('mysql database good'); + +DROP TABLE t1; + +--echo # +--echo # MDEV-26273 InnoDB fts DDL fails when +--echo # innodb_force_recovery is set to 2 +--echo # + +let $restart_parameters=--innodb_force_recovery=2; +--source include/restart_mysqld.inc +CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED KEY, + f1 CHAR(200)) ENGINE=InnoDB; +ALTER TABLE t1 ADD FULLTEXT INDEX(f1); +DROP TABLE t1; +let $restart_parameters=; +--source include/restart_mysqld.inc diff --git a/mysql-test/suite/innodb_fts/t/sync_block.test b/mysql-test/suite/innodb_fts/t/sync_block.test new file mode 100644 index 00000000..895d2ba8 --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/sync_block.test @@ -0,0 +1,124 @@ +# +# BUG#22516559 MYSQL INSTANCE STALLS WHEN SYNCING FTS INDEX +# + +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/have_debug_sync.inc +--source include/have_log_bin.inc +--source include/count_sessions.inc + +SET @old_log_output = @@global.log_output; +SET @old_slow_query_log = @@global.slow_query_log; +SET @old_general_log = @@global.general_log; +SET @old_long_query_time = @@global.long_query_time; +SET @old_debug = @@global.debug_dbug; + +SET GLOBAL log_output = 'TABLE'; +SET GLOBAL general_log = 1; +SET GLOBAL slow_query_log = 1; +SET GLOBAL long_query_time = 1; + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); +connection default; + +--echo # Case 1: Sync blocks DML(insert) on the same table. +CREATE TABLE t1 ( + FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + FULLTEXT(title) +) ENGINE = InnoDB; + +connection con1; + +SET GLOBAL debug_dbug='+d,fts_instrument_sync_debug,fts_instrument_sync_sleep'; + +SET DEBUG_SYNC= 'fts_sync_begin SIGNAL begin WAIT_FOR continue'; + +send INSERT INTO t1(title) VALUES('mysql database'); + +connection con2; + +SET DEBUG_SYNC= 'now WAIT_FOR begin'; + +send SELECT * FROM t1 WHERE MATCH(title) AGAINST('mysql database'); + +connection default; +SET DEBUG_SYNC= 'now SIGNAL continue'; + +connection con1; +--echo /* connection con1 */ INSERT INTO t1(title) VALUES('mysql database'); +--reap + +connection con2; +--echo /* conneciton con2 */ SELECT * FROM t1 WHERE MATCH(title) AGAINST('mysql database'); +--reap + +connection default; +-- echo # make con1 & con2 show up in mysql.slow_log +SELECT SLEEP(2); +-- echo # slow log results should only contain INSERT INTO t1. +SELECT sql_text FROM mysql.slow_log WHERE query_time >= '00:00:02'; + +SET GLOBAL debug_dbug = @old_debug; +TRUNCATE TABLE mysql.slow_log; + +DROP TABLE t1; + +--echo # Case 2: Sync blocks DML(insert) on other tables. +CREATE TABLE t1 ( + FTS_DOC_ID BIGINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + FULLTEXT(title) +) ENGINE = InnoDB; + +CREATE TABLE t2(id INT); + +connection con1; + +SET GLOBAL debug_dbug='+d,fts_instrument_sync_request,fts_instrument_sync_sleep'; + +SET DEBUG_SYNC= 'fts_instrument_sync_request SIGNAL begin WAIT_FOR continue'; + +send INSERT INTO t1(title) VALUES('mysql database'); + +connection con2; + +SET DEBUG_SYNC= 'now WAIT_FOR begin'; + +send INSERT INTO t2 VALUES(1); + +connection default; +SET DEBUG_SYNC= 'now SIGNAL continue'; + +connection con1; +--echo /* connection con1 */ INSERT INTO t1(title) VALUES('mysql database'); +--reap + +connection con2; +--echo /* conneciton con2 */ INSERT INTO t2 VALUES(1); +--reap + +connection default; +SET DEBUG_SYNC = 'RESET'; +-- echo # make con1 & con2 show up in mysql.slow_log +SELECT SLEEP(2); +-- echo # slow log results should be empty here. +SELECT sql_text FROM mysql.slow_log WHERE query_time >= '00:00:02'; + +SET GLOBAL debug_dbug = @old_debug; +TRUNCATE TABLE mysql.slow_log; + +DROP TABLE t1,t2; + +disconnect con1; +disconnect con2; + +--source include/wait_until_count_sessions.inc + +-- echo # Restore slow log settings. +SET GLOBAL log_output = @old_log_output; +SET GLOBAL general_log = @old_general_log; +SET GLOBAL slow_query_log = @old_slow_query_log; +SET GLOBAL long_query_time = @old_long_query_time; diff --git a/mysql-test/suite/innodb_fts/t/sync_ddl.test b/mysql-test/suite/innodb_fts/t/sync_ddl.test new file mode 100644 index 00000000..6a16ecec --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/sync_ddl.test @@ -0,0 +1,194 @@ +# +# BUG#27082268 FTS synchronization issues +# + +--source include/have_innodb.inc +--source include/have_debug.inc +--source include/maybe_versioning.inc + +#-------------------------------------- +# Check FTS_sync vs TRUNCATE (1) +#-------------------------------------- + +CREATE TABLE t1 ( + id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, + value VARCHAR(1024) + ) ENGINE=InnoDB; + +CREATE FULLTEXT INDEX idx1 ON t1(value); + +SET @save_debug = @@GLOBAL.debug_dbug; +SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_sync_before_syncing,ib_trunc_sleep_before_fts_cache_clear'; + +INSERT INTO t1 (value) VALUES + ('By default or with the IN NATURAL LANGUAGE MODE modifier') + ; + +let $vers=$MTR_COMBINATION_VERS+$MTR_COMBINATION_VERS_TRX; + +if ($vers) +{ +--echo TRUNCATE TABLE t1; +} +if (!$vers) +{ +TRUNCATE TABLE t1; +} + +DROP TABLE t1; + +SET GLOBAL debug_dbug = @save_debug; + +#-------------------------------------- +# Check FTS sync vs DROP INDEX (2) +#-------------------------------------- + +CREATE TABLE t1 ( + id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, + value VARCHAR(1024) + ) ENGINE=InnoDB; + +CREATE FULLTEXT INDEX idx1 ON t1(value); + +SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_write_words_before_select_index,ib_trunc_sleep_before_fts_cache_clear'; + +INSERT INTO t1 (value) VALUES + ('By default or with the IN NATURAL LANGUAGE MODE modifier'), + ('performs a natural language search for a string'), + ('collection is a set of one or more columns included'), + ('returns a relevance value; that is, a similarity measure'), + ('and the text in that row in the columns named in'), + ('By default, the search is performed in case-insensitive'), + ('sensitive full-text search, use a binary collation '), + ('example, a column that uses the latin1 character'), + ('collation of latin1_bin to make it case sensitive') + ; + +if ($vers) +{ +--echo TRUNCATE TABLE t1; +} +if (!$vers) +{ +TRUNCATE TABLE t1; +} + +DROP TABLE t1; + +SET GLOBAL debug_dbug = @save_debug; + +#-------------------------------------- +# Check FTS sync vs DROP INDEX +#-------------------------------------- + +CREATE TABLE t1 ( + value VARCHAR(1024) + ) ENGINE=InnoDB; + +CREATE FULLTEXT INDEX idx1 ON t1(value); + +SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep'; + +INSERT INTO t1 (value) VALUES + ('By default or with the IN NATURAL LANGUAGE MODE modifier'), + ('performs a natural language search for a string'), + ('collection is a set of one or more columns included'), + ('returns a relevance value; that is, a similarity measure'), + ('and the text in that row in the columns named in'), + ('By default, the search is performed in case-insensitive'), + ('sensitive full-text search, use a binary collation '), + ('example, a column that uses the latin1 character'), + ('collation of latin1_bin to make it case sensitive') + ; + +DROP INDEX idx1 ON t1; + +DROP TABLE t1; + +SET GLOBAL debug_dbug = @save_debug; + +#-------------------------------------- +# Check FTS sync vs ALTER TABLE DROP INDEX (INPLACE) +#-------------------------------------- + +CREATE TABLE t1 ( + value VARCHAR(1024) + ) ENGINE=InnoDB; + +CREATE FULLTEXT INDEX idx1 ON t1(value); + +SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep'; + +INSERT INTO t1 (value) VALUES + ('By default or with the IN NATURAL LANGUAGE MODE modifier'), + ('performs a natural language search for a string'), + ('collection is a set of one or more columns included'), + ('returns a relevance value; that is, a similarity measure'), + ('and the text in that row in the columns named in'), + ('By default, the search is performed in case-insensitive'), + ('sensitive full-text search, use a binary collation '), + ('example, a column that uses the latin1 character'), + ('collation of latin1_bin to make it case sensitive') + ; + +ALTER TABLE t1 + DROP INDEX idx1, + ALGORITHM=INPLACE; + +DROP TABLE t1; + +SET GLOBAL debug_dbug = @save_debug; + +#-------------------------------------- +# Check FTS sync vs ALTER TABLE DROP INDEX (COPY) +#-------------------------------------- + +CREATE TABLE t1 ( + value VARCHAR(1024) + ) ENGINE=InnoDB; + +CREATE FULLTEXT INDEX idx1 ON t1(value); + +SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep'; + +INSERT INTO t1 (value) VALUES + ('example, a column that uses the latin1 character'), + ('collation of latin1_bin to make it case sensitive') + ; + +ALTER TABLE t1 + DROP INDEX idx1, + ALGORITHM=COPY; + +DROP TABLE t1; + +SET GLOBAL debug_dbug = @save_debug; + +#-------------------------------------- +# Check FTS sync vs ALTER TABLE (INPLACE, new cluster) +#-------------------------------------- + +CREATE TABLE t1 ( + id1 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + value VARCHAR(1024) + ) ENGINE=InnoDB; + +CREATE FULLTEXT INDEX idx1 ON t1(value); + +SET GLOBAL debug_dbug = '+d,fts_instrument_sync_request,fts_instrument_msg_sync_sleep'; + +INSERT INTO t1 (value) VALUES + ('example, a column that uses the latin1 character'), + ('collation of latin1_bin to make it case sensitive') + ; + +ALTER TABLE t1 + DROP COLUMN id1, + ADD COLUMN id2 INT NOT NULL AUTO_INCREMENT PRIMARY KEY, + DROP INDEX idx1, + ADD FULLTEXT INDEX idx2(value), + ALGORITHM=INPLACE; + +DROP TABLE t1; + +SET GLOBAL debug_dbug = @save_debug; |