Commit 9e8a3d16 authored by Alice Sherepa's avatar Alice Sherepa

innodb_fts.prase, subexpr

parent 0da50a3f
# Bug #18285007 COPY OF TABLES WITH INNODB FTS
# FROM WINDOWS TO LINUX CAUSES CRASH
# Simulating old non-windows(< 5.6.16) data directory
SET GLOBAL DEBUG='+d,innodb_test_wrong_fts_aux_table_name';
CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a, b))engine=innodb;
INSERT INTO t1 VALUES('TEST1', 'TEST2');
INSERT INTO t1 VALUES('TEXT1', 'TEXT2');
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b
TEST1 TEST2
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_INDEX_1
FTS_0 test/FTS_AUX_INDEX_2
FTS_0 test/FTS_AUX_INDEX_3
FTS_0 test/FTS_AUX_INDEX_4
FTS_0 test/FTS_AUX_INDEX_5
FTS_0 test/FTS_AUX_INDEX_6
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b
TEST1 TEST2
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_INDEX_1
FTS_0 test/FTS_AUX_INDEX_2
FTS_0 test/FTS_AUX_INDEX_3
FTS_0 test/FTS_AUX_INDEX_4
FTS_0 test/FTS_AUX_INDEX_5
FTS_0 test/FTS_AUX_INDEX_6
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
DROP TABLE t1;
# Simulating old windows (< 5.6.16) data directory
SET GLOBAL DEBUG='+d,innodb_test_wrong_fts_aux_table_name';
SET GLOBAL DEBUG='+d,innodb_test_wrong_windows_fts_aux_table_name';
CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a, b))engine=innodb;
INSERT INTO t1 VALUES('TEST1', 'TEST2');
INSERT INTO t1 VALUES('TEXT1', 'TEXT2');
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b
TEST1 TEST2
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_INDEX_1
FTS_0 test/FTS_AUX_INDEX_2
FTS_0 test/FTS_AUX_INDEX_3
FTS_0 test/FTS_AUX_INDEX_4
FTS_0 test/FTS_AUX_INDEX_5
FTS_0 test/FTS_AUX_INDEX_6
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b
TEST1 TEST2
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_INDEX_1
FTS_0 test/FTS_AUX_INDEX_2
FTS_0 test/FTS_AUX_INDEX_3
FTS_0 test/FTS_AUX_INDEX_4
FTS_0 test/FTS_AUX_INDEX_5
FTS_0 test/FTS_AUX_INDEX_6
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
DROP TABLE t1;
# Simulation current non windows data directory
CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a, b))engine=innodb;
INSERT INTO t1 VALUES('TEST1', 'TEST2');
INSERT INTO t1 VALUES('TEXT1', 'TEXT2');
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b
TEST1 TEST2
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_INDEX_1
FTS_0 test/FTS_AUX_INDEX_2
FTS_0 test/FTS_AUX_INDEX_3
FTS_0 test/FTS_AUX_INDEX_4
FTS_0 test/FTS_AUX_INDEX_5
FTS_0 test/FTS_AUX_INDEX_6
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b
TEST1 TEST2
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_INDEX_1
FTS_0 test/FTS_AUX_INDEX_2
FTS_0 test/FTS_AUX_INDEX_3
FTS_0 test/FTS_AUX_INDEX_4
FTS_0 test/FTS_AUX_INDEX_5
FTS_0 test/FTS_AUX_INDEX_6
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
DROP TABLE t1;
# Non windows aux table flag failure and rebuild the corrupted index.
call mtr.add_suppression("\\[Warning\\] InnoDB: Parent table of FTS auxiliary table .* not found.");
call mtr.add_suppression("\\[ERROR] InnoDB: Flagged corruption of .* in table .* in DROP ORPHANED TABLE");
call mtr.add_suppression("\\[Warning\\] InnoDB: Setting aux table .* to hex format failed.");
SET GLOBAL DEBUG='+d,innodb_test_wrong_fts_aux_table_name';
CREATE TABLE t1(a TEXT, b TEXT, c TEXT, FULLTEXT `AB` (a, b), FULLTEXT `C1` (c));
INSERT INTO t1 VALUES('TEST1', 'TEST2', 'TEXT3');
INSERT INTO t1 VALUES('TEXT1', 'TEXT2', 'TEXT5');
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b c
TEST1 TEST2 TEXT3
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
a b c
TEXT1 TEXT2 TEXT5
SET GLOBAL DEBUG='-d,innodb_test_wrong_fts_sys_table_name';
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
ERROR HY000: The table does not have FULLTEXT index to support this query
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
ERROR HY000: The table does not have FULLTEXT index to support this query
ALTER TABLE t1 ADD FULLTEXT(b);
ERROR HY000: Index corrupt: Fulltext index 'AB' is corrupt. you should drop this index first.
# Restart the server
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
ERROR HY000: The table does not have FULLTEXT index to support this query
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
ERROR HY000: The table does not have FULLTEXT index to support this query
# Drop the corrupted index.
ALTER TABLE t1 DROP INDEX `AB`;
ALTER TABLE t1 DROP INDEX `C1`;
# Rebuild the index.
ALTER TABLE t1 ADD FULLTEXT(a, b);
ALTER TABLE t1 ADD FULLTEXT(c);
# Read the record using fts index.
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b c
TEST1 TEST2 TEXT3
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
a b c
TEXT1 TEXT2 TEXT5
DROP TABLE t1;
# Non windows parent table flag failure.
SET GLOBAL DEBUG='+d,innodb_test_wrong_fts_aux_table_name';
CREATE TABLE t1(a TEXT, b TEXT, c TEXT, FULLTEXT(a, b), FULLTEXT(c));
INSERT INTO t1 VALUES('TEST1', 'TEST2', 'TEXT3');
INSERT INTO t1 VALUES('TEXT1', 'TEXT2', 'TEXT5');
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b c
TEST1 TEST2 TEXT3
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
a b c
TEXT1 TEXT2 TEXT5
SET GLOBAL DEBUG='-d,innodb_test_wrong_fts_sys_table_name';
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b c
TEST1 TEST2 TEXT3
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
a b c
TEXT1 TEXT2 TEXT5
DROP TABLE t1;
# Drop FTS table and rename the common tables.
SET GLOBAL DEBUG='+d,innodb_test_wrong_fts_aux_table_name';
SET GLOBAL DEBUG='+d,innodb_test_wrong_windows_fts_aux_table_name';
CREATE TABLE t1(a TEXT, b TEXT, c TEXT, FULLTEXT f1(a, b));
INSERT INTO t1 VALUES('TEST1', 'TEST2', 'TEXT3');
INSERT INTO t1 VALUES('TEXT1', 'TEXT2', 'TEXT5');
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b c
TEST1 TEST2 TEXT3
alter table t1 drop index f1;
SET SESSION debug='-d,innodb_test_wrong_fts_sys_table_name';
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
SELECT * FROM t1;
a b c
TEST1 TEST2 TEXT3
TEXT1 TEXT2 TEXT5
DROP TABLE t1;
# Rename failure for old windows data directory and rebuild the
# corrupted index
call mtr.add_suppression("\\[Warning\\] InnoDB: Failed to rename one aux table .* will revert all successful rename operations.");
call mtr.add_suppression("\\[Warning\\] InnoDB: Rollback operations on all aux tables of table .* All the fts index associated with the table are marked as corrupted. Please rebuild the index again.");
call mtr.add_suppression("\\[ERROR\\] InnoDB: Flagged corruption of .* in table .* in DROP ORPHANED TABLE");
SET GLOBAL DEBUG='+d,innodb_test_wrong_fts_aux_table_name';
SET GLOBAL DEBUG='+d,innodb_test_wrong_windows_fts_aux_table_name';
CREATE TABLE t1(a TEXT, b TEXT, c TEXT, FULLTEXT `AB`(a, b), FULLTEXT `C1`(c));
INSERT INTO t1 VALUES('TEST1', 'TEST2', 'TEXT3');
INSERT INTO t1 VALUES('TEXT1', 'TEXT2', 'TEXT5');
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b c
TEST1 TEST2 TEXT3
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
a b c
TEXT1 TEXT2 TEXT5
SET SESSION debug='-d,innodb_test_wrong_fts_sys_table_name';
# Restart server.
ALTER TABLE t1 ADD FULLTEXT(b);
ERROR HY000: Upgrade index name failed, please use create index(alter table) algorithm copy to rebuild index.
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
ERROR HY000: The table does not have FULLTEXT index to support this query
# Restart server.
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
ERROR HY000: The table does not have FULLTEXT index to support this query
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
ERROR HY000: The table does not have FULLTEXT index to support this query
# Drop the corrupted index.
ALTER TABLE t1 DROP INDEX `AB`;
ALTER TABLE t1 DROP INDEX `C1`;
# Rebuild the index.
ALTER TABLE t1 ADD FULLTEXT(a, b);
ALTER TABLE t1 ADD FULLTEXT(c);
# Read the record using fts index.
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b c
TEST1 TEST2 TEXT3
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
a b c
TEXT1 TEXT2 TEXT5
TRUNCATE TABLE t1;
DROP TABLE t1;
# Bug #18285007 COPY OF TABLES WITH INNODB FTS
# FROM WINDOWS TO LINUX CAUSES CRASH
# Simulating old non-windows(< 5.6.16) data directory
SET GLOBAL DEBUG='+d,innodb_test_wrong_fts_aux_table_name';
SET GLOBAL DEBUG='+d,innodb_test_wrong_non_windows_fts_aux_table_name';
CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a, b))engine=innodb;
INSERT INTO t1 VALUES('TEST1', 'TEST2');
INSERT INTO t1 VALUES('TEXT1', 'TEXT2');
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b
TEST1 TEST2
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_INDEX_1
FTS_0 test/FTS_AUX_INDEX_2
FTS_0 test/FTS_AUX_INDEX_3
FTS_0 test/FTS_AUX_INDEX_4
FTS_0 test/FTS_AUX_INDEX_5
FTS_0 test/FTS_AUX_INDEX_6
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b
TEST1 TEST2
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_INDEX_1
FTS_0 test/FTS_AUX_INDEX_2
FTS_0 test/FTS_AUX_INDEX_3
FTS_0 test/FTS_AUX_INDEX_4
FTS_0 test/FTS_AUX_INDEX_5
FTS_0 test/FTS_AUX_INDEX_6
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
DROP TABLE t1;
# Simulating old windows (< 5.6.16) data directory
SET GLOBAL DEBUG='+d,innodb_test_wrong_fts_aux_table_name';
CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a, b))engine=innodb;
INSERT INTO t1 VALUES('TEST1', 'TEST2');
INSERT INTO t1 VALUES('TEXT1', 'TEXT2');
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b
TEST1 TEST2
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_INDEX_1
FTS_0 test/FTS_AUX_INDEX_2
FTS_0 test/FTS_AUX_INDEX_3
FTS_0 test/FTS_AUX_INDEX_4
FTS_0 test/FTS_AUX_INDEX_5
FTS_0 test/FTS_AUX_INDEX_6
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b
TEST1 TEST2
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_INDEX_1
FTS_0 test/FTS_AUX_INDEX_2
FTS_0 test/FTS_AUX_INDEX_3
FTS_0 test/FTS_AUX_INDEX_4
FTS_0 test/FTS_AUX_INDEX_5
FTS_0 test/FTS_AUX_INDEX_6
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
DROP TABLE t1;
# Simulation current windows data directory
CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a, b))engine=innodb;
INSERT INTO t1 VALUES('TEST1', 'TEST2');
INSERT INTO t1 VALUES('TEXT1', 'TEXT2');
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b
TEST1 TEST2
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_INDEX_1
FTS_0 test/FTS_AUX_INDEX_2
FTS_0 test/FTS_AUX_INDEX_3
FTS_0 test/FTS_AUX_INDEX_4
FTS_0 test/FTS_AUX_INDEX_5
FTS_0 test/FTS_AUX_INDEX_6
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b
TEST1 TEST2
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_INDEX_1
FTS_0 test/FTS_AUX_INDEX_2
FTS_0 test/FTS_AUX_INDEX_3
FTS_0 test/FTS_AUX_INDEX_4
FTS_0 test/FTS_AUX_INDEX_5
FTS_0 test/FTS_AUX_INDEX_6
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
DROP TABLE t1;
# Non windows aux table flag failure and rebuild the corrupted index.
call mtr.add_suppression("\\[Warning\\] InnoDB: Parent table of FTS auxiliary table .* not found.");
call mtr.add_suppression("\\[ERROR] InnoDB: Flagged corruption of .* in table .* in DROP ORPHANED TABLE");
call mtr.add_suppression("\\[Warning\\] InnoDB: Setting aux table .* to hex format failed.");
SET GLOBAL DEBUG='+d,innodb_test_wrong_fts_aux_table_name';
SET GLOBAL DEBUG='+d,innodb_test_wrong_non_windows_fts_aux_table_name';
CREATE TABLE t1(a TEXT, b TEXT, c TEXT, FULLTEXT `AB` (a, b), FULLTEXT `C1`(c));
INSERT INTO t1 VALUES('TEST1', 'TEST2', 'TEXT3');
INSERT INTO t1 VALUES('TEXT1', 'TEXT2', 'TEXT5');
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b c
TEST1 TEST2 TEXT3
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
a b c
TEXT1 TEXT2 TEXT5
SET GLOBAL DEBUG='-d,innodb_test_wrong_fts_sys_table_name';
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
ERROR HY000: The table does not have FULLTEXT index to support this query
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
ERROR HY000: The table does not have FULLTEXT index to support this query
ALTER TABLE t1 ADD FULLTEXT(b);
ERROR HY000: Index corrupt: Fulltext index 'AB' is corrupt. you should drop this index first.
# Restart the server
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
ERROR HY000: The table does not have FULLTEXT index to support this query
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
ERROR HY000: The table does not have FULLTEXT index to support this query
# Drop the corrupted index.
ALTER TABLE t1 DROP INDEX `AB`;
ALTER TABLE t1 DROP INDEX `C1`;
# Rebuild the index.
ALTER TABLE t1 ADD FULLTEXT(a, b);
ALTER TABLE t1 ADD FULLTEXT(c);
# Read the record using fts index.
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b c
TEST1 TEST2 TEXT3
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
a b c
TEXT1 TEXT2 TEXT5
DROP TABLE t1;
# Non windows parent table flag failure.
SET GLOBAL DEBUG='+d,innodb_test_wrong_fts_aux_table_name';
SET GLOBAL DEBUG='+d,innodb_test_wrong_non_windows_fts_aux_table_name';
CREATE TABLE t1(a TEXT, b TEXT, c TEXT, FULLTEXT(a, b), FULLTEXT(c));
INSERT INTO t1 VALUES('TEST1', 'TEST2', 'TEXT3');
INSERT INTO t1 VALUES('TEXT1', 'TEXT2', 'TEXT5');
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b c
TEST1 TEST2 TEXT3
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
a b c
TEXT1 TEXT2 TEXT5
SET GLOBAL DEBUG='-d,innodb_test_wrong_fts_sys_table_name';
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b c
TEST1 TEST2 TEXT3
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
a b c
TEXT1 TEXT2 TEXT5
DROP TABLE t1;
# Drop FTS table and rename the common tables.
SET GLOBAL DEBUG='+d,innodb_test_wrong_fts_aux_table_name';
CREATE TABLE t1(a TEXT, b TEXT, c TEXT, FULLTEXT f1(a, b));
INSERT INTO t1 VALUES('TEST1', 'TEST2', 'TEXT3');
INSERT INTO t1 VALUES('TEXT1', 'TEXT2', 'TEXT5');
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b c
TEST1 TEST2 TEXT3
alter table t1 drop index f1;
SET SESSION debug='-d,innodb_test_wrong_fts_sys_table_name';
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
SELECT SUBSTRING(name, LOCATE('_', name) - 3, 5) AS prefix, name
FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES
WHERE name LIKE '%FTS_%' ORDER BY 1, 2;
prefix name
FTS_0 test/FTS_AUX_BEING_DELETED
FTS_0 test/FTS_AUX_BEING_DELETED_CACHE
FTS_0 test/FTS_AUX_CONFIG
FTS_0 test/FTS_AUX_DELETED
FTS_0 test/FTS_AUX_DELETED_CACHE
SELECT * FROM t1;
a b c
TEST1 TEST2 TEXT3
TEXT1 TEXT2 TEXT5
DROP TABLE t1;
# Rename failure for old windows data directory and rebuild the
# corrupted index
call mtr.add_suppression("\\[Warning\\] InnoDB: Failed to rename one aux table .* Will revert all successful rename operations.");
call mtr.add_suppression("\\[Warning\\] InnoDB: Rollback operations on all aux tables of table .* All the fts index associated with the table are marked as corrupted. Please rebuild the index again.");
call mtr.add_suppression("\\[ERROR\\] InnoDB: Flagged corruption of .* in table .* in DROP ORPHANED TABLE");
SET GLOBAL DEBUG='+d,innodb_test_wrong_fts_aux_table_name';
CREATE TABLE t1(a TEXT, b TEXT, c TEXT, FULLTEXT `AB`(a, b), FULLTEXT `C1`(c));
INSERT INTO t1 VALUES('TEST1', 'TEST2', 'TEXT3');
INSERT INTO t1 VALUES('TEXT1', 'TEXT2', 'TEXT5');
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b c
TEST1 TEST2 TEXT3
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
a b c
TEXT1 TEXT2 TEXT5
SET SESSION debug='-d,innodb_test_wrong_fts_sys_table_name';
# Restart server.
ALTER TABLE t1 ADD FULLTEXT(b);
ERROR HY000: Upgrade index name failed, please use create index(alter table) algorithm copy to rebuild index.
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
ERROR HY000: The table does not have FULLTEXT index to support this query
# Restart server.
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
ERROR HY000: The table does not have FULLTEXT index to support this query
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
ERROR HY000: The table does not have FULLTEXT index to support this query
# Drop the corrupted index.
ALTER TABLE t1 DROP INDEX `AB`;
ALTER TABLE t1 DROP INDEX `C1`;
# Rebuild the index.
ALTER TABLE t1 ADD FULLTEXT(a, b);
ALTER TABLE t1 ADD FULLTEXT(c);
# Read the record using fts index.
SELECT * FROM t1 WHERE MATCH(a, b) AGAINST ('TEST2');
a b c
TEST1 TEST2 TEXT3
SELECT * FROM t1 WHERE MATCH(c) AGAINST ('TEXT5');
a b c
TEXT1 TEXT2 TEXT5
TRUNCATE TABLE t1;
DROP TABLE t1;
CREATE TABLE wp(
FTS_DOC_ID BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
title VARCHAR(255) NOT NULL DEFAULT '',
text MEDIUMTEXT NOT NULL,
dummy INTEGER,
PRIMARY KEY (FTS_DOC_ID),
UNIQUE KEY FTS_DOC_ID_INDEX (FTS_DOC_ID),
FULLTEXT KEY idx (title,text)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Warnings:
Warning 1286 Unknown storage engine 'InnoDB'
Warning 1266 Using storage engine MyISAM for table 'wp'
INSERT INTO wp (title, text) 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','1. Never run mysqld as root. 2. ...'),
('MySQL vs. YourSQL','In the following database to database comparison ...'),
('MySQL Security','When configured properly, MySQL ...');
CREATE TABLE t1 (i INTEGER);
INSERT INTO t1 SELECT FTS_DOC_ID FROM wp;
ANALYZE TABLE t1;
ANALYZE TABLE wp;
SELECT FTS_DOC_ID, title, MATCH(title, text) AGAINST ('database') AS score1,
MATCH(title, text) AGAINST ('mysql') AS score2
FROM wp;
FTS_DOC_ID title score1 score2
1 MySQL Tutorial 0.5756555199623108 0
2 How To Use MySQL Well 0 0
3 Optimizing MySQL 0 0
4 1001 MySQL Tricks 0 0
5 MySQL vs. YourSQL 0.9562782645225525 0
6 MySQL Security 0 0
No sorting for this query
FLUSH STATUS;
SELECT title, MATCH(title, text) AGAINST ('database') AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database')
ORDER BY score DESC;
title score
MySQL vs. YourSQL 0.9562782645225525
MySQL Tutorial 0.5756555199623108
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 2
Sort_scan 1
No sorting for this query even if MATCH is part of an expression
FLUSH STATUS;
SELECT title, MATCH(title, text) AGAINST ('database') AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database') > 0.1
ORDER BY score DESC;
title score
MySQL vs. YourSQL 0.9562782645225525
MySQL Tutorial 0.5756555199623108
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 2
Sort_scan 1
No sorting even if there are several MATCH expressions as long as the
right one is used in ORDER BY
FLUSH STATUS;
SELECT title, MATCH(title, text) AGAINST ('database') AS score1,
MATCH(title, text) AGAINST ('mysql') AS score2
FROM wp
WHERE MATCH(title, text) AGAINST ('database')
ORDER BY score1 DESC;
title score1 score2
MySQL vs. YourSQL 0.9562782645225525 0
MySQL Tutorial 0.5756555199623108 0
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 2
Sort_scan 1
Sorting since it is not a single table query
FLUSH STATUS;
SELECT title, MATCH(title, text) AGAINST ('database') AS score
FROM wp, t1
WHERE MATCH(title, text) AGAINST ('database') AND FTS_DOC_ID = t1.i
ORDER BY score DESC;
title score
MySQL vs. YourSQL 0.9562782645225525
MySQL Tutorial 0.5756555199623108
SHOW SESSION STATUS LIKE 'Sort_rows%';
Variable_name Value
Sort_rows 2
Sorting since there is no WHERE clause
FLUSH STATUS;
SELECT title, MATCH(title, text) AGAINST ('database') AS score
FROM wp
ORDER BY score DESC;
title score
MySQL vs. YourSQL 0.9562782645225525
MySQL Tutorial 0.5756555199623108
How To Use MySQL Well 0
Optimizing MySQL 0
1001 MySQL Tricks 0
MySQL Security 0
SHOW SESSION STATUS LIKE 'Sort_rows%';
Variable_name Value
Sort_rows 6
Sorting since ordering on multiple columns
FLUSH STATUS;
SELECT title, MATCH(title, text) AGAINST ('database') AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database')
ORDER BY score DESC, FTS_DOC_ID;
title score
MySQL vs. YourSQL 0.9562782645225525
MySQL Tutorial 0.5756555199623108
SHOW SESSION STATUS LIKE 'Sort_rows%';
Variable_name Value
Sort_rows 2
Sorting since ordering is not descending
FLUSH STATUS;
SELECT title, MATCH(title, text) AGAINST ('database') AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database')
ORDER BY score ASC;
title score
MySQL Tutorial 0.5756555199623108
MySQL vs. YourSQL 0.9562782645225525
SHOW SESSION STATUS LIKE 'Sort_rows%';
Variable_name Value
Sort_rows 2
Sorting because one is ordering on a different MATCH expression
FLUSH STATUS;
SELECT title, MATCH(title, text) AGAINST ('mysql') AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database')
ORDER BY score DESC;
title score
MySQL Tutorial 0
MySQL vs. YourSQL 0
SHOW SESSION STATUS LIKE 'Sort_rows%';
Variable_name Value
Sort_rows 2
No sorting for this query
FLUSH STATUS;
SELECT title, MATCH(title, text) AGAINST ('database') AS score
FROM wp
ORDER BY score DESC LIMIT 2;
title score
MySQL vs. YourSQL 0.9562782645225525
MySQL Tutorial 0.5756555199623108
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 2
Sort_scan 1
Revert to table scan and sorting for this query since not
enough matching rows to satisfy LIMIT clause
FLUSH STATUS;
SELECT title, MATCH(title, text) AGAINST ('database') AS score
FROM wp
ORDER BY score DESC LIMIT 3;
title score
MySQL vs. YourSQL 0.9562782645225525
MySQL Tutorial 0.5756555199623108
How To Use MySQL Well 0
SHOW SESSION STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 3
Handler_read_rnd_deleted 0
Handler_read_rnd_next 14
SHOW SESSION STATUS LIKE 'Sort_rows%';
Variable_name Value
Sort_rows 3
Sorting since no LIMIT clause
FLUSH STATUS;
SELECT title, MATCH(title, text) AGAINST ('database') AS score
FROM wp
ORDER BY score DESC;
title score
MySQL vs. YourSQL 0.9562782645225525
MySQL Tutorial 0.5756555199623108
How To Use MySQL Well 0
Optimizing MySQL 0
1001 MySQL Tricks 0
MySQL Security 0
SHOW SESSION STATUS LIKE 'Sort_rows%';
Variable_name Value
Sort_rows 6
Sorting since there is a WHERE clause
FLUSH STATUS;
SELECT title, MATCH(title, text) AGAINST ('database') AS score
FROM wp
WHERE dummy IS NULL
ORDER BY score DESC LIMIT 2;
title score
MySQL vs. YourSQL 0.9562782645225525
MySQL Tutorial 0.5756555199623108
SHOW SESSION STATUS LIKE 'Sort_rows%';
Variable_name Value
Sort_rows 2
Sorting since ordering is not on a simple MATCH expressions
FLUSH STATUS;
SELECT title, (MATCH(title, text) AGAINST ('database')) * 100 AS score
FROM wp
ORDER BY score DESC LIMIT 2;
title score
MySQL vs. YourSQL 95.62782645225525
MySQL Tutorial 57.56555199623108
SHOW SESSION STATUS LIKE 'Sort_rows%';
Variable_name Value
Sort_rows 2
No ordinary handler accesses when only accessing FTS_DOC_ID and MATCH
FLUSH STATUS;
SELECT FTS_DOC_ID docid, MATCH(title, text) AGAINST ('database') AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database');
docid score
5 0.9562782645225525
1 0.5756555199623108
SHOW SESSION STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 3
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
Still no handler accesses when adding FTS_DOC_ID to WHERE clause
FLUSH STATUS;
SELECT FTS_DOC_ID docid, MATCH(title, text) AGAINST ('database') AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database') AND FTS_DOC_ID > 2;
docid score
5 0.9562782645225525
SHOW SESSION STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 3
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
Still no handler accesses when ordering by MATCH expression
FLUSH STATUS;
SELECT FTS_DOC_ID docid, MATCH(title, text) AGAINST ('database') AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database')
ORDER BY score;
docid score
1 0.5756555199623108
5 0.9562782645225525
SHOW SESSION STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 3
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 2
Handler_read_rnd_deleted 0
Handler_read_rnd_next 3
Optimization is disabled when ordering on FTS_DOC_ID
FLUSH STATUS;
SELECT FTS_DOC_ID docid, MATCH(title, text) AGAINST ('database') AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database')
ORDER BY 1 DESC;
docid score
5 0.9562782645225525
1 0.5756555199623108
SHOW SESSION STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 3
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 2
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
Optimization also work with several MATCH expressions
FLUSH STATUS;
SELECT FTS_DOC_ID docid, MATCH(title, text) AGAINST ('database') AS score1,
MATCH(title, text) AGAINST ('mysql') AS score2
FROM wp
WHERE MATCH(title, text) AGAINST ('database');
docid score1 score2
5 0.9562782645225525 0
1 0.5756555199623108 0
SHOW SESSION STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 3
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
Optimization does not apply if sorting on a different MATCH expressions
from the one used to access the
FLUSH STATUS;
SELECT FTS_DOC_ID docid, MATCH(title, text) AGAINST ('database') AS score1,
MATCH(title, text) AGAINST ('mysql') AS score2
FROM wp
WHERE MATCH(title, text) AGAINST ('database')
ORDER BY score2 DESC;
docid score1 score2
1 0.5756555199623108 0
5 0.9562782645225525 0
SHOW SESSION STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 3
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 2
Handler_read_rnd_deleted 0
Handler_read_rnd_next 3
FLUSH STATUS;
Optimization does not apply for GROUP BY
SELECT FTS_DOC_ID, MATCH(title, text) AGAINST ('database') AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database')
GROUP BY score;
FTS_DOC_ID score
1 0.5756555199623108
5 0.9562782645225525
SHOW SESSION STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 3
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 2
Handler_read_rnd_deleted 0
Handler_read_rnd_next 3
No sorting and no table access with LIMIT clause and only information
from FTS result
FLUSH STATUS;
SELECT FTS_DOC_ID docid, MATCH(title, text) AGAINST ('database') AS score
FROM wp
ORDER BY score DESC LIMIT 2;
docid score
5 0.9562782645225525
1 0.5756555199623108
SHOW STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 2
Handler_read_rnd_deleted 0
Handler_read_rnd_next 14
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 2
Sort_scan 1
If count optimization applies, EXPLAIN shows
"Select tables optimized away."
EXPLAIN SELECT COUNT(*)
FROM wp
WHERE MATCH(title,text) AGAINST ('database' IN NATURAL LANGUAGE MODE);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE wp fulltext idx idx 0 1 Using where
FLUSH STATUS;
SELECT COUNT(*)
FROM wp
WHERE MATCH(title,text) AGAINST ('database' IN NATURAL LANGUAGE MODE);
COUNT(*)
2
Verify that there was no table access
SHOW STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 3
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
Optimization applies also to COUNT(expr) as long as expr is not nullable
EXPLAIN SELECT COUNT(title)
FROM wp
WHERE MATCH(title,text) AGAINST ('database' IN NATURAL LANGUAGE MODE);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE wp fulltext idx idx 0 1 Using where
SELECT COUNT(title)
FROM wp
WHERE MATCH(title,text) AGAINST ('database' IN NATURAL LANGUAGE MODE);
COUNT(title)
2
Optimization does not apply if not a single table query.
EXPLAIN SELECT count(*)
FROM wp, t1
WHERE MATCH(title, text) AGAINST ('database');
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE wp fulltext idx idx 0 1 Using where
1 SIMPLE t1 ALL NULL NULL NULL NULL 6
SELECT count(*)
FROM wp, t1
WHERE MATCH(title, text) AGAINST ('database');
count(*)
12
Optimization does not apply if MATCH is part of an expression
EXPLAIN SELECT COUNT(title)
FROM wp
WHERE MATCH(title,text) AGAINST ('database' IN NATURAL LANGUAGE MODE) > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE wp fulltext idx idx 0 1 Using where
SELECT COUNT(title)
FROM wp
WHERE MATCH(title,text) AGAINST ('database' IN NATURAL LANGUAGE MODE) > 0;
COUNT(title)
2
Optimization does not apply if MATCH is part of an expression
EXPLAIN SELECT COUNT(title)
FROM wp
WHERE MATCH(title,text) AGAINST ('database' IN NATURAL LANGUAGE MODE) > 0;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE wp fulltext idx idx 0 1 Using where
SELECT COUNT(title)
FROM wp
WHERE MATCH(title,text) AGAINST ('database' IN NATURAL LANGUAGE MODE) > 0;
COUNT(title)
2
Optimization does not apply if COUNT expression is nullable
EXPLAIN SELECT COUNT(dummy)
FROM wp
WHERE MATCH(title,text) AGAINST ('database' IN NATURAL LANGUAGE MODE);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE wp fulltext idx idx 0 1 Using where
SELECT COUNT(dummy)
FROM wp
WHERE MATCH(title,text) AGAINST ('database' IN NATURAL LANGUAGE MODE);
COUNT(dummy)
0
FLUSH STATUS;
SELECT title,
MATCH(title, text) AGAINST ('database' WITH QUERY EXPANSION) AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database' WITH QUERY EXPANSION)
ORDER BY score DESC;
title score
MySQL vs. YourSQL 6.447932243347168
MySQL Tutorial 5.551538944244385
Optimizing MySQL 0.6626645922660828
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 3
Sort_scan 1
FLUSH STATUS;
SELECT title,
MATCH(title, text) AGAINST ('database' WITH QUERY EXPANSION) AS score
FROM wp
ORDER BY score DESC LIMIT 2;
title score
MySQL vs. YourSQL 6.447932243347168
MySQL Tutorial 5.551538944244385
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 2
Sort_scan 1
FLUSH STATUS;
SELECT FTS_DOC_ID docid,
MATCH(title, text) AGAINST ('database' WITH QUERY EXPANSION) AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database');
docid score
5 6.447932243347168
1 5.551538944244385
SHOW SESSION STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 3
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
FLUSH STATUS;
SELECT FTS_DOC_ID docid,
MATCH(title, text) AGAINST ('database' WITH QUERY EXPANSION) AS score
FROM wp
ORDER BY score DESC LIMIT 2;
docid score
5 6.447932243347168
1 5.551538944244385
SHOW STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 2
Handler_read_rnd_deleted 0
Handler_read_rnd_next 14
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 2
Sort_scan 1
EXPLAIN SELECT COUNT(*)
FROM wp
WHERE MATCH(title,text) AGAINST ('database' WITH QUERY EXPANSION);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE wp fulltext idx idx 0 1 Using where
FLUSH STATUS;
SELECT COUNT(*)
FROM wp
WHERE MATCH(title,text) AGAINST ('database' WITH QUERY EXPANSION);
COUNT(*)
3
SHOW STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 5
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
FLUSH STATUS;
SELECT title,
MATCH(title, text) AGAINST ('+MySQL -database' IN BOOLEAN MODE) AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('+MySQL -database' IN BOOLEAN MODE)
ORDER BY score DESC;
title score
How To Use MySQL Well 1
Optimizing MySQL 1
1001 MySQL Tricks 1
MySQL Security 1
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 4
Sort_scan 1
FLUSH STATUS;
SELECT title,
MATCH(title, text) AGAINST ('+MySQL -database' IN BOOLEAN MODE) AS score
FROM wp
ORDER BY score DESC LIMIT 2;
title score
How To Use MySQL Well 1
Optimizing MySQL 1
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 2
Sort_scan 1
FLUSH STATUS;
SELECT FTS_DOC_ID docid,
MATCH(title, text) AGAINST ('+MySQL -database' IN BOOLEAN MODE) AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('+MySQL -database');
docid score
5 0
1 0
SHOW SESSION STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 5
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
FLUSH STATUS;
SELECT FTS_DOC_ID docid,
MATCH(title, text) AGAINST ('+MySQL -database' IN BOOLEAN MODE) AS score
FROM wp
ORDER BY score DESC LIMIT 2;
docid score
2 1
3 1
SHOW STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 2
Handler_read_rnd_deleted 0
Handler_read_rnd_next 14
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 2
Sort_scan 1
EXPLAIN SELECT COUNT(*)
FROM wp
WHERE MATCH(title,text) AGAINST ('+MySQL -database' IN BOOLEAN MODE);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE wp fulltext idx idx 0 1 Using where
FLUSH STATUS;
SELECT COUNT(*)
FROM wp
WHERE MATCH(title,text) AGAINST ('+MySQL -database' IN BOOLEAN MODE);
COUNT(*)
4
SHOW STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 5
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
FLUSH STATUS;
SELECT title,
MATCH(title, text) AGAINST ('"MySQL database"@5' IN BOOLEAN MODE) AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('"MySQL database"@5' IN BOOLEAN MODE)
ORDER BY score DESC;
title score
MySQL Tutorial 1
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 1
Sort_scan 1
FLUSH STATUS;
SELECT title,
MATCH(title, text) AGAINST ('"MySQL database"@5' IN BOOLEAN MODE) AS score
FROM wp
ORDER BY score DESC LIMIT 1;
title score
MySQL Tutorial 1
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 1
Sort_scan 1
FLUSH STATUS;
SELECT FTS_DOC_ID docid,
MATCH(title, text) AGAINST ('"MySQL database"@5' IN BOOLEAN MODE) AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('"MySQL database"@5');
docid score
5 0
1 1
SHOW SESSION STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 5
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
FLUSH STATUS;
SELECT FTS_DOC_ID docid,
MATCH(title, text) AGAINST ('"MySQL database"@5' IN BOOLEAN MODE) AS score
FROM wp
ORDER BY score DESC LIMIT 1;
docid score
1 1
SHOW STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 1
Handler_read_rnd_deleted 0
Handler_read_rnd_next 14
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 1
Sort_scan 1
EXPLAIN SELECT COUNT(*)
FROM wp
WHERE MATCH(title,text) AGAINST ('"MySQL database"@5' IN BOOLEAN MODE);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE wp fulltext idx idx 0 1 Using where
FLUSH STATUS;
SELECT COUNT(*)
FROM wp
WHERE MATCH(title,text) AGAINST ('"MySQL database"@5' IN BOOLEAN MODE);
COUNT(*)
1
SHOW STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 2
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
SELECT title,
MATCH(title, text) AGAINST ('database') AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database' WITH QUERY EXPANSION)
ORDER BY score DESC;
title score
MySQL vs. YourSQL 0.9562782645225525
MySQL Tutorial 0.5756555199623108
Optimizing MySQL 0
SELECT title,
MATCH(title, text) AGAINST ('+MySQL -database' IN BOOLEAN MODE) AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('MySQL database' WITH QUERY EXPANSION)
ORDER BY score DESC;
title score
Optimizing MySQL 1
MySQL Tutorial 0
MySQL vs. YourSQL 0
SELECT title,
MATCH(title, text) AGAINST ('+MySQL -database' IN BOOLEAN MODE) AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('"MySQL database"@5' IN BOOLEAN MODE)
ORDER BY score DESC;
title score
MySQL Tutorial 0
ALTER TABLE wp ENGINE=myisam;
FLUSH STATUS;
SELECT title, MATCH(title, text) AGAINST ('database') AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database')
ORDER BY score DESC;
title score
MySQL vs. YourSQL 0.9562782645225525
MySQL Tutorial 0.5756555199623108
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 0
Sort_range 0
Sort_rows 2
Sort_scan 1
FLUSH STATUS;
SELECT title, MATCH(title, text) AGAINST ('database') AS score
FROM wp
ORDER BY score DESC LIMIT 2;
title score
MySQL vs. YourSQL 0.9562782645225525
MySQL Tutorial 0.5756555199623108
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 2
Sort_scan 1
FLUSH STATUS;
SELECT FTS_DOC_ID docid, MATCH(title, text) AGAINST ('database') AS score
FROM wp
WHERE MATCH(title, text) AGAINST ('database');
docid score
5 0.9562782645225525
1 0.5756555199623108
SHOW SESSION STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 3
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
FLUSH STATUS;
SELECT FTS_DOC_ID docid, MATCH(title, text) AGAINST ('database') AS score
FROM wp
ORDER BY score DESC LIMIT 2;
docid score
5 0.9562782645225525
1 0.5756555199623108
SHOW STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 0
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 2
Handler_read_rnd_deleted 0
Handler_read_rnd_next 14
SHOW SESSION STATUS LIKE 'Sort%';
Variable_name Value
Sort_merge_passes 0
Sort_priority_queue_sorts 1
Sort_range 0
Sort_rows 2
Sort_scan 1
EXPLAIN SELECT COUNT(*)
FROM wp
WHERE MATCH(title,text) AGAINST ('database' IN NATURAL LANGUAGE MODE);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE wp fulltext idx idx 0 1 Using where
FLUSH STATUS;
SELECT COUNT(*)
FROM wp
WHERE MATCH(title,text) AGAINST ('database' IN NATURAL LANGUAGE MODE);
COUNT(*)
2
SHOW STATUS LIKE 'Handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 0
Handler_read_last 0
Handler_read_next 3
Handler_read_prev 0
Handler_read_retry 0
Handler_read_rnd 0
Handler_read_rnd_deleted 0
Handler_read_rnd_next 0
DROP TABLE wp, t1;
CREATE TABLE articles (
id INT UNSIGNED NOT NULL PRIMARY KEY,
title VARCHAR(200),
FULLTEXT (title)
) ENGINE= InnoDB;
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
ROLLBACK TO SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
COMMIT;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
2 mysql
4 mysql
5 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
ROLLBACK TO SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
ROLLBACK TO SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(6, 'mysql');
COMMIT;
INSERT INTO articles(id, title) VALUES(7, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
2 mysql
4 mysql
6 mysql
7 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
ROLLBACK TO SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
COMMIT;
INSERT INTO articles(id, title) VALUES(6, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
2 mysql
5 mysql
6 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
ROLLBACK TO SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
ROLLBACK TO SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(6, 'mysql');
COMMIT;
INSERT INTO articles(id, title) VALUES(7, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
2 mysql
6 mysql
7 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
RELEASE SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
COMMIT;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
2 mysql
3 mysql
4 mysql
5 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
RELEASE SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
RELEASE SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(6, 'mysql');
COMMIT;
INSERT INTO articles(id, title) VALUES(7, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
2 mysql
3 mysql
4 mysql
5 mysql
6 mysql
7 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
RELEASE SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
COMMIT;
INSERT INTO articles(id, title) VALUES(6, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
2 mysql
3 mysql
4 mysql
5 mysql
6 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
RELEASE SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
RELEASE SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(6, 'mysql');
COMMIT;
INSERT INTO articles(id, title) VALUES(7, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
2 mysql
3 mysql
4 mysql
5 mysql
6 mysql
7 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
ROLLBACK TO SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
RELEASE SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(6, 'mysql');
COMMIT;
INSERT INTO articles(id, title) VALUES(7, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
2 mysql
4 mysql
5 mysql
6 mysql
7 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
RELEASE SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
ROLLBACK TO SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(6, 'mysql');
COMMIT;
INSERT INTO articles(id, title) VALUES(7, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
2 mysql
3 mysql
4 mysql
6 mysql
7 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
RELEASE SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
ROLLBACK TO SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(6, 'mysql');
COMMIT;
INSERT INTO articles(id, title) VALUES(7, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
2 mysql
6 mysql
7 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
ROLLBACK TO SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
RELEASE SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(6, 'mysql');
COMMIT;
INSERT INTO articles(id, title) VALUES(7, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
2 mysql
3 mysql
5 mysql
6 mysql
7 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
ROLLBACK;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
3 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
ROLLBACK;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
4 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
RELEASE SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
ROLLBACK;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
5 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
ROLLBACK TO SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
ROLLBACK;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
5 mysql
TRUNCATE TABLE articles;
INSERT INTO articles(id, title) VALUES(1, 'mysql');
BEGIN;
INSERT INTO articles(id, title) VALUES(2, 'mysql');
SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(3, 'mysql');
SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(4, 'mysql');
ROLLBACK TO SAVEPOINT sp2;
INSERT INTO articles(id, title) VALUES(5, 'mysql');
RELEASE SAVEPOINT sp1;
INSERT INTO articles(id, title) VALUES(6, 'mysql');
ROLLBACK;
INSERT INTO articles(id, title) VALUES(7, 'mysql');
SELECT * FROM articles WHERE MATCH(title) AGAINST('mysql');
id title
1 mysql
7 mysql
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
(NULL, 'mysql good database'),
(NULL, ' mysql good database'),
('', 'mysql good database'),
('', ' mysql good database'),
(' ', 'mysql good database'),
('mysql', 'good database'),
('mysql ', 'good database'),
('mysql', ' good database'),
('mysql good database', ''),
('mysql good database', NULL);
SET GLOBAL innodb_ft_aux_table="test/articles";
SELECT * FROM INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE;
WORD FIRST_DOC_ID LAST_DOC_ID DOC_COUNT DOC_ID POSITION
database 1 10 10 1 11
database 1 10 10 2 12
database 1 10 10 3 11
database 1 10 10 4 12
database 1 10 10 5 13
database 1 10 10 6 11
database 1 10 10 7 12
database 1 10 10 8 12
database 1 10 10 9 11
database 1 10 10 10 11
good 1 10 10 1 6
good 1 10 10 2 7
good 1 10 10 3 6
good 1 10 10 4 7
good 1 10 10 5 8
good 1 10 10 6 6
good 1 10 10 7 7
good 1 10 10 8 7
good 1 10 10 9 6
good 1 10 10 10 6
mysql 1 10 10 1 0
mysql 1 10 10 2 1
mysql 1 10 10 3 0
mysql 1 10 10 4 1
mysql 1 10 10 5 2
mysql 1 10 10 6 0
mysql 1 10 10 7 0
mysql 1 10 10 8 0
mysql 1 10 10 9 0
mysql 1 10 10 10 0
SET GLOBAL innodb_ft_aux_table=default;
SELECT * FROM articles;
id title body
1 NULL mysql good database
2 NULL mysql good database
3 mysql good database
4 mysql good database
5 mysql good database
6 mysql good database
7 mysql good database
8 mysql good database
9 mysql good database
10 mysql good database NULL
SELECT * FROM articles WHERE MATCH(title, body)
AGAINST('"mysql good database"' IN BOOLEAN MODE);
id title body
1 NULL mysql good database
2 NULL mysql good database
3 mysql good database
4 mysql good database
5 mysql good database
9 mysql good database
10 mysql good database NULL
SELECT * FROM articles WHERE MATCH(title, body)
AGAINST('("mysql good database")' IN BOOLEAN MODE);
id title body
1 NULL mysql good database
2 NULL mysql good database
3 mysql good database
4 mysql good database
5 mysql good database
9 mysql good database
10 mysql good database NULL
DROP TABLE articles;
#
# Bug #20028323 INNODB FULLTEXT BOOLEAN SEARCH INCORRECTLY HANDLES
# PARENTHESES
#
CREATE TABLE t1 (
f1 INT NOT NULL AUTO_INCREMENT,
f2 TEXT NOT NULL,
PRIMARY KEY (f1),
FULLTEXT (f2)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO t1 (f2) VALUES
('Pumpkin soup with cheese bread'),
('Yellow chicken curry'),
('Fresh green vegetables with garlic');
SELECT * FROM t1 WHERE MATCH(f2) AGAINST('+pumpkin' IN BOOLEAN MODE);
f1 f2
1 Pumpkin soup with cheese bread
SELECT * FROM t1 WHERE MATCH(f2) AGAINST('+cheese' IN BOOLEAN MODE);
f1 f2
1 Pumpkin soup with cheese bread
SELECT * FROM t1 WHERE MATCH(f2) AGAINST('+(pumpkin cheese)' IN BOOLEAN MODE);
f1 f2
1 Pumpkin soup with cheese bread
SELECT * FROM t1 WHERE MATCH(f2)
AGAINST('+pumpkin +(souffle)' IN BOOLEAN MODE);
f1 f2
SELECT * FROM t1 WHERE MATCH(f2)
AGAINST('+pumpkin +(souffle tart)' IN BOOLEAN MODE);
f1 f2
SELECT * FROM t1 WHERE MATCH(f2)
AGAINST('+pumpkin +(>souffle <tart)' IN BOOLEAN MODE);
f1 f2
SELECT * FROM t1 WHERE MATCH(f2)
AGAINST('+pumpkin +(souffle tart)' IN BOOLEAN MODE);
f1 f2
INSERT INTO t1 (f2) VALUES
('This row contains only souffle'),
('This row contains only tart'),
('This row contains only pumpkin'),
('This row contains only cheese'),
('This row contains pumpkin and souffle'),
('This row contains pumpkin and tart'),
('This row contains pumpkin and cheese'),
('This row contains both souffle and tart'),
('This row contains both souffle and cheese'),
('This row contains both tart and cheese'),
('This row contains all three souffle, pumpkin and tart'),
('This row contains all four cheese, souffle, pumpkin and tart');
SELECT * FROM t1 WHERE MATCH(f2) AGAINST('+pumpkin' IN BOOLEAN MODE);
f1 f2
1 Pumpkin soup with cheese bread
6 This row contains only pumpkin
8 This row contains pumpkin and souffle
9 This row contains pumpkin and tart
10 This row contains pumpkin and cheese
14 This row contains all three souffle, pumpkin and tart
15 This row contains all four cheese, souffle, pumpkin and tart
SELECT * FROM t1 WHERE MATCH(f2) AGAINST('+cheese' IN BOOLEAN MODE);
f1 f2
1 Pumpkin soup with cheese bread
7 This row contains only cheese
10 This row contains pumpkin and cheese
12 This row contains both souffle and cheese
13 This row contains both tart and cheese
15 This row contains all four cheese, souffle, pumpkin and tart
SELECT * FROM t1 WHERE MATCH(f2) AGAINST('+(pumpkin cheese)' IN BOOLEAN MODE);
f1 f2
1 Pumpkin soup with cheese bread
10 This row contains pumpkin and cheese
15 This row contains all four cheese, souffle, pumpkin and tart
7 This row contains only cheese
12 This row contains both souffle and cheese
13 This row contains both tart and cheese
6 This row contains only pumpkin
8 This row contains pumpkin and souffle
9 This row contains pumpkin and tart
14 This row contains all three souffle, pumpkin and tart
SELECT * FROM t1 WHERE MATCH(f2)
AGAINST('+pumpkin +(souffle)' IN BOOLEAN MODE);
f1 f2
8 This row contains pumpkin and souffle
14 This row contains all three souffle, pumpkin and tart
15 This row contains all four cheese, souffle, pumpkin and tart
SELECT * FROM t1 WHERE MATCH(f2)
AGAINST('+pumpkin +(souffle tart)' IN BOOLEAN MODE);
f1 f2
14 This row contains all three souffle, pumpkin and tart
15 This row contains all four cheese, souffle, pumpkin and tart
8 This row contains pumpkin and souffle
9 This row contains pumpkin and tart
SELECT * FROM t1 WHERE MATCH(f2)
AGAINST('+pumpkin +(>souffle <tart)' IN BOOLEAN MODE);
f1 f2
8 This row contains pumpkin and souffle
14 This row contains all three souffle, pumpkin and tart
15 This row contains all four cheese, souffle, pumpkin and tart
9 This row contains pumpkin and tart
SELECT * FROM t1 WHERE MATCH(f2)
AGAINST('+pumpkin +(souffle tart)' IN BOOLEAN MODE);
f1 f2
14 This row contains all three souffle, pumpkin and tart
15 This row contains all four cheese, souffle, pumpkin and tart
8 This row contains pumpkin and souffle
9 This row contains pumpkin and tart
DROP TABLE t1;
--innodb_ft_index_cache
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment