1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 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.
SET GLOBAL innodb_max_purge_lag_wait=0;
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/%';
|