| 1 |
#------------------------------------------------------------------------------ |
| 2 |
# Misc FTS test on debug servers only |
| 3 |
#------------------------------------------------------------------------------ |
| 4 |
--source include/no_valgrind_without_big.inc |
| 5 |
|
| 6 |
# Must have debug code to use SET SESSION debug |
| 7 |
--source include/have_debug.inc |
| 8 |
|
| 9 |
|
| 10 |
# Avoid CrashReporter popup on Mac |
| 11 |
--source include/not_crashrep.inc |
| 12 |
|
| 13 |
# Following are test for crash recovery on FTS index, the first scenario |
| 14 |
# is for bug Bug #14586855 INNODB: FAILING ASSERTION: (DICT_INDEX_GET_N_UNIQUE( |
| 15 |
# PLAN->INDEX) <= PLAN->N_EXAC |
| 16 |
|
| 17 |
# Scenario 1: Hidden FTS_DOC_ID column, and FTS index dropped |
| 18 |
# Create FTS table |
| 19 |
CREATE TABLE articles ( |
| 20 |
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, |
| 21 |
title VARCHAR(200), |
| 22 |
body TEXT, |
| 23 |
FULLTEXT (title,body) |
| 24 |
) ENGINE=InnoDB; |
| 25 |
|
| 26 |
# Drop the FTS index before more insertion. The FTS_DOC_ID should |
| 27 |
# be kept |
| 28 |
DROP INDEX title ON articles; |
| 29 |
|
| 30 |
# Insert six rows |
| 31 |
INSERT INTO articles (title,body) VALUES |
| 32 |
('MySQL Tutorial','DBMS stands for DataBase ...') , |
| 33 |
('How To Use MySQL Well','After you went through a ...'), |
| 34 |
('Optimizing MySQL','In this tutorial we will show ...'), |
| 35 |
('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), |
| 36 |
('MySQL vs. YourSQL','In the following database comparison ...'), |
| 37 |
('MySQL Security','When configured properly, MySQL ...'); |
| 38 |
|
| 39 |
BEGIN; |
| 40 |
|
| 41 |
INSERT INTO articles (title,body) VALUES |
| 42 |
('MySQL Tutorial','DBMS stands for DataBase ...'); |
| 43 |
|
| 44 |
--source include/kill_and_restart_mysqld.inc |
| 45 |
|
| 46 |
# This insert will re-initialize the Doc ID counter, it should not crash |
| 47 |
INSERT INTO articles VALUES |
| 48 |
(8, 'MySQL Tutorial','DBMS stands for DataBase ...'); |
| 49 |
|
| 50 |
# Recreate fulltext index to see if everything is OK |
| 51 |
CREATE FULLTEXT INDEX idx ON articles (title,body); |
| 52 |
|
| 53 |
# Should return 3 rows |
| 54 |
SELECT * FROM articles |
| 55 |
WHERE MATCH (title,body) |
| 56 |
AGAINST ('Database' IN NATURAL LANGUAGE MODE); |
| 57 |
|
| 58 |
# Scenario 2: Hidden FTS_DOC_ID column, with FTS index |
| 59 |
# Now let's do more insertion and test a crash with FTS on |
| 60 |
INSERT INTO articles (title,body) VALUES |
| 61 |
('MySQL Tutorial','DBMS stands for DataBase ...') , |
| 62 |
('How To Use MySQL Well','After you went through a ...'), |
| 63 |
('Optimizing MySQL','In this tutorial we will show ...'), |
| 64 |
('1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), |
| 65 |
('MySQL vs. YourSQL','In the following database comparison ...'), |
| 66 |
('MySQL Security','When configured properly, MySQL ...'); |
| 67 |
|
| 68 |
BEGIN; |
| 69 |
|
| 70 |
INSERT INTO articles (title,body) VALUES |
| 71 |
('MySQL Tutorial','DBMS stands for DataBase ...'); |
| 72 |
|
| 73 |
--source include/kill_and_restart_mysqld.inc |
| 74 |
|
| 75 |
# This insert will re-initialize the Doc ID counter, it should not crash |
| 76 |
INSERT INTO articles VALUES |
| 77 |
(16, 'MySQL Tutorial','DBMS stands for DataBase ...'); |
| 78 |
|
| 79 |
# Should return 6 rows |
| 80 |
SELECT * FROM articles |
| 81 |
WHERE MATCH (title,body) |
| 82 |
AGAINST ('Database' IN NATURAL LANGUAGE MODE); |
| 83 |
|
| 84 |
DROP TABLE articles; |
| 85 |
|
| 86 |
# Scenario 3: explicit FTS_DOC_ID column with FTS index |
| 87 |
# Now let's test user defined FTS_DOC_ID |
| 88 |
|
| 89 |
CREATE TABLE articles ( |
| 90 |
id int PRIMARY KEY, |
| 91 |
FTS_DOC_ID BIGINT UNSIGNED NOT NULL, |
| 92 |
title VARCHAR(200), |
| 93 |
body TEXT |
| 94 |
) ENGINE=InnoDB; |
| 95 |
|
| 96 |
CREATE FULLTEXT INDEX idx1 on articles (title, body); |
| 97 |
|
| 98 |
# Note the FTS_DOC_ID is not fully ordered with primary index |
| 99 |
INSERT INTO articles VALUES |
| 100 |
(1, 10, 'MySQL Tutorial','DBMS stands for DataBase ...') , |
| 101 |
(2, 1, 'How To Use MySQL Well','After you went through a ...'), |
| 102 |
(3, 2, 'Optimizing MySQL','In this tutorial we will show ...'), |
| 103 |
(4, 11, '1001 MySQL Tricks','1. Never run mysqld as root. 2. ...'), |
| 104 |
(5, 6, 'MySQL vs. YourSQL','In the following database comparison ...'), |
| 105 |
(7, 4, 'MySQL Security','When configured properly, MySQL ...'); |
| 106 |
|
| 107 |
BEGIN; |
| 108 |
|
| 109 |
INSERT INTO articles VALUES |
| 110 |
(100, 200, 'MySQL Tutorial','DBMS stands for DataBase ...'); |
| 111 |
|
| 112 |
--source include/kill_and_restart_mysqld.inc |
| 113 |
|
| 114 |
# This would re-initialize the FTS index and do the re-tokenization |
| 115 |
# of above records |
| 116 |
INSERT INTO articles VALUES (8, 12, 'MySQL Tutorial','DBMS stands for DataBase ...'); |
| 117 |
|
| 118 |
SELECT * FROM articles WHERE MATCH (title, body) |
| 119 |
AGAINST ('Tutorial' IN NATURAL LANGUAGE MODE); |
| 120 |
|
| 121 |
DROP TABLE articles; |
| 122 |
|
| 123 |
# Following test is for Bug 14668777 - ASSERT ON IB_VECTOR_SIZE( |
| 124 |
# TABLE->FTS->INDEXES, ALTER TABLE |
| 125 |
CREATE TABLE articles ( |
| 126 |
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, |
| 127 |
title VARCHAR(200), |
| 128 |
body TEXT, |
| 129 |
FULLTEXT (title,body) |
| 130 |
) ENGINE=InnoDB; |
| 131 |
|
| 132 |
# Abort the operation in dict_create_index_step by setting |
| 133 |
# return status of dict_create_index_tree_step() to DB_OUT_OF_MEMORY |
| 134 |
# The newly create dict_index_t should be removed from fts cache |
| 135 |
SET SESSION debug="+d,ib_dict_create_index_tree_fail"; |
| 136 |
--error ER_OUT_OF_RESOURCES |
| 137 |
CREATE FULLTEXT INDEX idx ON articles(body); |
| 138 |
SET SESSION debug="-d,ib_dict_create_index_tree_fail"; |
| 139 |
|
| 140 |
# This simply go through ha_innobase::commit_inplace_alter_table |
| 141 |
# and do a fts_check_cached_index() |
| 142 |
ALTER TABLE articles STATS_PERSISTENT=DEFAULT; |
| 143 |
|
| 144 |
DROP TABLE articles; |