From d956175d0d15e8c84e4e3ff5b0798143ce3ccfe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 27 Apr 2020 11:39:46 +0300 Subject: XtraDB 5.6.47-87.0 The only change is a change of the version number. As noted in commit 02af6278fb7c7889a02d617eb23e82fe7967abd7 there were no changes to InnoDB between MySQL 5.6.46 and 5.6.47 either. --- mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff | 2 +- mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff | 2 +- storage/xtradb/include/univ.i | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff index fe6ec0e6f33..47289d2887b 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,32bit,xtradb.rdiff @@ -1215,7 +1215,7 @@ VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL -GLOBAL_VALUE 5.6.47 -+GLOBAL_VALUE 5.6.46-86.2 ++GLOBAL_VALUE 5.6.47-87.0 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL diff --git a/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff b/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff index 5fab6de421a..4e630e5e56f 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff +++ b/mysql-test/suite/sys_vars/r/sysvars_innodb,xtradb.rdiff @@ -685,7 +685,7 @@ VARIABLE_NAME INNODB_VERSION SESSION_VALUE NULL -GLOBAL_VALUE 5.6.47 -+GLOBAL_VALUE 5.6.46-86.2 ++GLOBAL_VALUE 5.6.47-87.0 GLOBAL_VALUE_ORIGIN COMPILE-TIME DEFAULT_VALUE NULL VARIABLE_SCOPE GLOBAL diff --git a/storage/xtradb/include/univ.i b/storage/xtradb/include/univ.i index f5cc649f944..0b7ab3e389e 100644 --- a/storage/xtradb/include/univ.i +++ b/storage/xtradb/include/univ.i @@ -45,10 +45,10 @@ Created 1/20/1994 Heikki Tuuri #define INNODB_VERSION_MAJOR 5 #define INNODB_VERSION_MINOR 6 -#define INNODB_VERSION_BUGFIX 46 +#define INNODB_VERSION_BUGFIX 47 #ifndef PERCONA_INNODB_VERSION -#define PERCONA_INNODB_VERSION 86.2 +#define PERCONA_INNODB_VERSION 87.0 #endif /* Enable UNIV_LOG_ARCHIVE in XtraDB */ -- cgit v1.2.1 From d0150dc14e11f2e0b7ad60b9db40bd65e82e917e Mon Sep 17 00:00:00 2001 From: Vlad Lesin Date: Mon, 27 Apr 2020 21:46:05 +0300 Subject: MDEV-20230: mariabackup --ftwrl-wait-timeout never times out on explicit lock --ftwrl-wait-timeout does not finish mariabackup execution when acquired backup lock can't be grabbed for the certain amount of time, it just waits for a long queries finishing before acquiring the lock to avoid unnecessary locking. This commit extends --ftwrl-wait-timeout so, that mariabackup execution is finished if it waits for backup lock during certain amount of time. --- extra/mariabackup/backup_mysql.cc | 124 ++++++++++++--------- .../mariabackup/backup_lock_wait_timeout.result | 11 ++ .../mariabackup/backup_lock_wait_timeout.test | 28 +++++ 3 files changed, 108 insertions(+), 55 deletions(-) create mode 100644 mysql-test/suite/mariabackup/backup_lock_wait_timeout.result create mode 100644 mysql-test/suite/mariabackup/backup_lock_wait_timeout.test diff --git a/extra/mariabackup/backup_mysql.cc b/extra/mariabackup/backup_mysql.cc index d5d0c90376e..171c4407ed5 100644 --- a/extra/mariabackup/backup_mysql.cc +++ b/extra/mariabackup/backup_mysql.cc @@ -959,79 +959,93 @@ Function acquires either a backup tables lock, if supported by the server, or a global read lock (FLUSH TABLES WITH READ LOCK) otherwise. @returns true if lock acquired */ -bool -lock_tables(MYSQL *connection) +bool lock_tables(MYSQL *connection) { - if (have_lock_wait_timeout) { - /* Set the maximum supported session value for - lock_wait_timeout to prevent unnecessary timeouts when the - global value is changed from the default */ - xb_mysql_query(connection, - "SET SESSION lock_wait_timeout=31536000", false); - } + if (have_lock_wait_timeout || opt_lock_wait_timeout) + { + char buf[FN_REFLEN]; + /* Set the maximum supported session value for + lock_wait_timeout if opt_lock_wait_timeout is not set to prevent + unnecessary timeouts when the global value is changed from the default */ + snprintf(buf, sizeof(buf), "SET SESSION lock_wait_timeout=%u", + opt_lock_wait_timeout ? opt_lock_wait_timeout : 31536000); + xb_mysql_query(connection, buf, false); + } - if (have_backup_locks) { - msg("Executing LOCK TABLES FOR BACKUP..."); - xb_mysql_query(connection, "LOCK TABLES FOR BACKUP", false); - return(true); - } + if (have_backup_locks) + { + msg("Executing LOCK TABLES FOR BACKUP..."); + xb_mysql_query(connection, "LOCK TABLES FOR BACKUP", false); + return (true); + } - if (opt_lock_ddl_per_table) { - start_mdl_waiters_killer(); - } + if (opt_lock_ddl_per_table) + { + start_mdl_waiters_killer(); + } - if (!opt_lock_wait_timeout && !opt_kill_long_queries_timeout) { + if (!opt_lock_wait_timeout && !opt_kill_long_queries_timeout) + { - /* We do first a FLUSH TABLES. If a long update is running, the - FLUSH TABLES will wait but will not stall the whole mysqld, and - when the long update is done the FLUSH TABLES WITH READ LOCK - will start and succeed quickly. So, FLUSH TABLES is to lower - the probability of a stage where both mysqldump and most client - connections are stalled. Of course, if a second long update - starts between the two FLUSHes, we have that bad stall. + /* We do first a FLUSH TABLES. If a long update is running, the + FLUSH TABLES will wait but will not stall the whole mysqld, and + when the long update is done the FLUSH TABLES WITH READ LOCK + will start and succeed quickly. So, FLUSH TABLES is to lower + the probability of a stage where both mysqldump and most client + connections are stalled. Of course, if a second long update + starts between the two FLUSHes, we have that bad stall. - Option lock_wait_timeout serve the same purpose and is not - compatible with this trick. - */ + Option lock_wait_timeout serve the same purpose and is not + compatible with this trick. + */ - msg("Executing FLUSH NO_WRITE_TO_BINLOG TABLES..."); + msg("Executing FLUSH NO_WRITE_TO_BINLOG TABLES..."); - xb_mysql_query(connection, - "FLUSH NO_WRITE_TO_BINLOG TABLES", false); - } + xb_mysql_query(connection, "FLUSH NO_WRITE_TO_BINLOG TABLES", false); + } - if (opt_lock_wait_timeout) { - if (!wait_for_no_updates(connection, opt_lock_wait_timeout, - opt_lock_wait_threshold)) { - return(false); - } - } + if (opt_lock_wait_timeout) + { + if (!wait_for_no_updates(connection, opt_lock_wait_timeout, + opt_lock_wait_threshold)) + { + return (false); + } + } - msg("Executing FLUSH TABLES WITH READ LOCK..."); + msg("Executing FLUSH TABLES WITH READ LOCK..."); - if (opt_kill_long_queries_timeout) { - start_query_killer(); - } + if (opt_kill_long_queries_timeout) + { + start_query_killer(); + } - if (have_galera_enabled) { - xb_mysql_query(connection, - "SET SESSION wsrep_causal_reads=0", false); - } + if (have_galera_enabled) + { + xb_mysql_query(connection, "SET SESSION wsrep_causal_reads=0", false); + } - xb_mysql_query(connection, "FLUSH TABLES WITH READ LOCK", false); + xb_mysql_query(connection, "FLUSH TABLES WITH READ LOCK", false, true); + /* Set the maximum supported session value for + lock_wait_timeout to prevent unnecessary timeouts when the + global value is changed from the default */ + if (opt_lock_wait_timeout) + xb_mysql_query(connection, "SET SESSION lock_wait_timeout=31536000", + false); - if (opt_lock_ddl_per_table) { - stop_mdl_waiters_killer(); - } + if (opt_lock_ddl_per_table) + { + stop_mdl_waiters_killer(); + } - if (opt_kill_long_queries_timeout) { - stop_query_killer(); - } + if (opt_kill_long_queries_timeout) + { + stop_query_killer(); + } - return(true); + return (true); } - /*********************************************************************//** If backup locks are used, execute LOCK BINLOG FOR BACKUP provided that we are not in the --no-lock mode and the lock has not been acquired already. diff --git a/mysql-test/suite/mariabackup/backup_lock_wait_timeout.result b/mysql-test/suite/mariabackup/backup_lock_wait_timeout.result new file mode 100644 index 00000000000..9806bc29b47 --- /dev/null +++ b/mysql-test/suite/mariabackup/backup_lock_wait_timeout.result @@ -0,0 +1,11 @@ +CREATE TABLE t(i INT) ENGINE INNODB; +connect con1,localhost,root,,; +BEGIN; +LOCK TABLES t WRITE; +connection default; +# xtrabackup backup +connection con1; +COMMIT; +connection default; +disconnect con1; +DROP TABLE t; diff --git a/mysql-test/suite/mariabackup/backup_lock_wait_timeout.test b/mysql-test/suite/mariabackup/backup_lock_wait_timeout.test new file mode 100644 index 00000000000..e0f43910ef6 --- /dev/null +++ b/mysql-test/suite/mariabackup/backup_lock_wait_timeout.test @@ -0,0 +1,28 @@ +--source include/have_innodb.inc +--source include/count_sessions.inc + +CREATE TABLE t(i INT) ENGINE INNODB; + +connect (con1,localhost,root,,); +BEGIN; +LOCK TABLES t WRITE; + +--connection default + +echo # xtrabackup backup; +let $targetdir=$MYSQLTEST_VARDIR/tmp/backup; + +--disable_result_log +--error 1 +exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --ftwrl-wait-timeout=1 --target-dir=$targetdir; +--enable_result_log + +--connection con1 +COMMIT; + +--connection default +--disconnect con1 + +DROP TABLE t; +rmdir $targetdir; +--source include/wait_until_count_sessions.inc -- cgit v1.2.1 From cf64d27badc5c90ae72c590c9043a0e3ed837fc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 28 Apr 2020 11:40:04 +0300 Subject: Remove a duplicated copyright message --- storage/xtradb/handler/ha_innodb.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 2ec16280eb6..1593bf8ab46 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -1,7 +1,6 @@ /***************************************************************************** Copyright (c) 2000, 2019, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2018, MariaDB Corporation. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2012, Facebook Inc. -- cgit v1.2.1 From cce1b6e245a7ee30e6ebfcd45556e8caa6e754c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 28 Apr 2020 11:46:29 +0300 Subject: MDEV-22392 Race condition on SET GLOBAL innodb_buffer_pool_evict='uncompressed' innodb_buffer_pool_evict_uncompressed(): Restart the loop when prev_block might not enjoy mutex protection. This is based on mysql/mysql-server@eccaecac070b6747ecf14d6b9150791f8c3e8f6d --- storage/innobase/handler/ha_innodb.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index f9bad3a128c..a1505eecd29 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -1,6 +1,6 @@ /***************************************************************************** -Copyright (c) 2000, 2019, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2000, 2020, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2008, 2009 Google Inc. Copyright (c) 2009, Percona Inc. Copyright (c) 2012, Facebook Inc. @@ -17850,10 +17850,7 @@ static char* srv_buffer_pool_evict; Evict all uncompressed pages of compressed tables from the buffer pool. Keep the compressed pages in the buffer pool. @return whether all uncompressed pages were evicted */ -static MY_ATTRIBUTE((warn_unused_result)) -bool -innodb_buffer_pool_evict_uncompressed(void) -/*=======================================*/ +static bool innodb_buffer_pool_evict_uncompressed() { bool all_evicted = true; @@ -17874,9 +17871,13 @@ innodb_buffer_pool_evict_uncompressed(void) if (!buf_LRU_free_page(&block->page, false)) { all_evicted = false; + block = prev_block; + } else { + /* Because buf_LRU_free_page() may release + and reacquire buf_pool_t::mutex, prev_block + may be invalid. */ + block = UT_LIST_GET_LAST(buf_pool->unzip_LRU); } - - block = prev_block; } buf_pool_mutex_exit(buf_pool); -- cgit v1.2.1 From 704180747658019aa52173e44e99229b8ae56efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 28 Apr 2020 14:51:25 +0300 Subject: MDEV-22393 Corruption for SET GLOBAL innodb_ string variables Several MYSQL_SYSVAR_STR parameters that employ both a validate function callback fail to copy the string for saving the validated value. The affected variables include the following: innodb_ft_aux_table innodb_ft_server_stopword_table innodb_ft_user_stopword_table innodb_buffer_pool_filename The test case is an enhanced version of mysql/mysql-server@0b0c30641fd66336e87394ac28587e40864f8af9 and the code changes are inspired by their fixes. We are also importing and adjusting the test innodb_fts.stopword to get coverage for the variable innodb_ft_user_stopword_table. buf_dump(), buf_load(): Protect srv_buf_dump_filename with LOCK_global_system_variables. fts_load_user_stopword(): Minor cleanup fts_load_stopword(): Remove the parameter global_stopword_table. innobase_fts_load_stopword(): Protect innodb_server_stopword_table against concurrent SET GLOBAL. --- .../suite/innodb/r/innodb_sys_var_valgrind.result | 73 ++ .../suite/innodb/t/innodb_sys_var_valgrind.test | 70 ++ mysql-test/suite/innodb_fts/r/stopword.result | 735 +++++++++++++++++++++ mysql-test/suite/innodb_fts/t/stopword.opt | 1 + mysql-test/suite/innodb_fts/t/stopword.test | 657 ++++++++++++++++++ storage/innobase/buf/buf0dump.cc | 8 +- storage/innobase/fts/fts0fts.cc | 81 +-- storage/innobase/handler/ha_innodb.cc | 119 ++-- storage/innobase/include/fts0fts.h | 12 +- storage/xtradb/buf/buf0dump.cc | 8 +- storage/xtradb/fts/fts0fts.cc | 81 +-- storage/xtradb/handler/ha_innodb.cc | 119 ++-- storage/xtradb/include/fts0fts.h | 12 +- 13 files changed, 1762 insertions(+), 214 deletions(-) create mode 100644 mysql-test/suite/innodb/r/innodb_sys_var_valgrind.result create mode 100644 mysql-test/suite/innodb/t/innodb_sys_var_valgrind.test create mode 100644 mysql-test/suite/innodb_fts/r/stopword.result create mode 100644 mysql-test/suite/innodb_fts/t/stopword.opt create mode 100644 mysql-test/suite/innodb_fts/t/stopword.test diff --git a/mysql-test/suite/innodb/r/innodb_sys_var_valgrind.result b/mysql-test/suite/innodb/r/innodb_sys_var_valgrind.result new file mode 100644 index 00000000000..32d87b4668a --- /dev/null +++ b/mysql-test/suite/innodb/r/innodb_sys_var_valgrind.result @@ -0,0 +1,73 @@ +# +# Bug #29717909 MEMORY LIFETIME OF VARIABLES BETWEEN CHECK AND UPDATE INCORRECTLY MANAGED +# +select @@innodb_ft_server_stopword_table; +@@innodb_ft_server_stopword_table +NULL +create table user_stopword_1(value varchar(30)) engine = innodb; +create table user_stopword_2(value varchar(30)) engine = innodb; +set @blah = 'test/user_stopword_1'; +SET GLOBAL innodb_ft_server_stopword_table= @blah; +select @@innodb_ft_server_stopword_table; +@@innodb_ft_server_stopword_table +test/user_stopword_1 +set @blah = 'test/user_stopword_2'; +SET GLOBAL innodb_ft_server_stopword_table= @blah; +select @@innodb_ft_server_stopword_table; +@@innodb_ft_server_stopword_table +test/user_stopword_2 +SET GLOBAL innodb_ft_server_stopword_table= NULL; +select @@innodb_ft_server_stopword_table; +@@innodb_ft_server_stopword_table +NULL +SET GLOBAL innodb_ft_server_stopword_table= default; +select @@innodb_ft_server_stopword_table; +@@innodb_ft_server_stopword_table +NULL +drop table user_stopword_1, user_stopword_2; +select @@innodb_buffer_pool_filename; +@@innodb_buffer_pool_filename +ib_buffer_pool +set @blah='hello'; +set global innodb_buffer_pool_filename = @blah; +select @@innodb_buffer_pool_filename; +@@innodb_buffer_pool_filename +hello +set global innodb_buffer_pool_filename="bye"; +select @@innodb_buffer_pool_filename; +@@innodb_buffer_pool_filename +bye +set global innodb_buffer_pool_filename=NULL; +ERROR 42000: Variable 'innodb_buffer_pool_filename' can't be set to the value of 'NULL' +select @@innodb_buffer_pool_filename; +@@innodb_buffer_pool_filename +bye +set global innodb_buffer_pool_filename=default; +select @@innodb_buffer_pool_filename; +@@innodb_buffer_pool_filename +ib_buffer_pool +CREATE TABLE t1 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +opening_line TEXT(500), author VARCHAR(200), title VARCHAR(200), FULLTEXT idx +(opening_line)) ENGINE=InnoDB; +CREATE TABLE t2 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +opening_line TEXT(500), author VARCHAR(200), title VARCHAR(200), FULLTEXT idx +(opening_line)) ENGINE=InnoDB; +select @@innodb_ft_aux_table; +@@innodb_ft_aux_table +NULL +set @blah = 'test/t1'; +SET GLOBAL innodb_ft_aux_table = @blah; +select @@innodb_ft_aux_table; +@@innodb_ft_aux_table +test/t1 +set @blah = 'test/t2'; +SET GLOBAL innodb_ft_aux_table = @blah; +SET GLOBAL innodb_ft_aux_table = NULL; +select @@innodb_ft_aux_table; +@@innodb_ft_aux_table +NULL +SET GLOBAL innodb_ft_aux_table =default; +select @@innodb_ft_aux_table; +@@innodb_ft_aux_table +NULL +drop table t1,t2; diff --git a/mysql-test/suite/innodb/t/innodb_sys_var_valgrind.test b/mysql-test/suite/innodb/t/innodb_sys_var_valgrind.test new file mode 100644 index 00000000000..2e1391355b9 --- /dev/null +++ b/mysql-test/suite/innodb/t/innodb_sys_var_valgrind.test @@ -0,0 +1,70 @@ +--source include/have_innodb.inc + +--echo # +--echo # Bug #29717909 MEMORY LIFETIME OF VARIABLES BETWEEN CHECK AND UPDATE INCORRECTLY MANAGED +--echo # + +#Test innodb_ft_server_stopword_table (global variable) +select @@innodb_ft_server_stopword_table; +create table user_stopword_1(value varchar(30)) engine = innodb; +create table user_stopword_2(value varchar(30)) engine = innodb; + +set @blah = 'test/user_stopword_1'; +SET GLOBAL innodb_ft_server_stopword_table= @blah; +select @@innodb_ft_server_stopword_table; + +set @blah = 'test/user_stopword_2'; +SET GLOBAL innodb_ft_server_stopword_table= @blah; +select @@innodb_ft_server_stopword_table; + +SET GLOBAL innodb_ft_server_stopword_table= NULL; +select @@innodb_ft_server_stopword_table; + +SET GLOBAL innodb_ft_server_stopword_table= default; +select @@innodb_ft_server_stopword_table; + +drop table user_stopword_1, user_stopword_2; + +#Test innodb_buffer_pool_filename (global variable) + +select @@innodb_buffer_pool_filename; + +set @blah='hello'; +set global innodb_buffer_pool_filename = @blah; +select @@innodb_buffer_pool_filename; + +set global innodb_buffer_pool_filename="bye"; +select @@innodb_buffer_pool_filename; + +--error ER_WRONG_VALUE_FOR_VAR +set global innodb_buffer_pool_filename=NULL; +select @@innodb_buffer_pool_filename; + +set global innodb_buffer_pool_filename=default; +select @@innodb_buffer_pool_filename; + +#Test innodb_ft_aux_table (global variable) +CREATE TABLE t1 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +opening_line TEXT(500), author VARCHAR(200), title VARCHAR(200), FULLTEXT idx +(opening_line)) ENGINE=InnoDB; + +CREATE TABLE t2 ( id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, +opening_line TEXT(500), author VARCHAR(200), title VARCHAR(200), FULLTEXT idx +(opening_line)) ENGINE=InnoDB; + +select @@innodb_ft_aux_table; + +set @blah = 'test/t1'; +SET GLOBAL innodb_ft_aux_table = @blah; +select @@innodb_ft_aux_table; + +set @blah = 'test/t2'; +SET GLOBAL innodb_ft_aux_table = @blah; + +SET GLOBAL innodb_ft_aux_table = NULL; +select @@innodb_ft_aux_table; + +SET GLOBAL innodb_ft_aux_table =default; +select @@innodb_ft_aux_table; + +drop table t1,t2; 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 00000000000..51ededd675e --- /dev/null +++ b/mysql-test/suite/innodb_fts/r/stopword.result @@ -0,0 +1,735 @@ +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 @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; +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("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_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... +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... +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, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx` (`title`,`body`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +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, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=latin1 +ALTER TABLE articles ADD FULLTEXT INDEX idx (title,body); +ANALYZE TABLE articles; +Table Op Msg_type Msg_text +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("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, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx` (`title`,`body`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +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, + PRIMARY KEY (`id`), + FULLTEXT KEY `idx` (`title`,`body`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +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" +select @@innodb_ft_enable_stopword; +@@innodb_ft_enable_stopword +1 +ANALYZE TABLE articles; +Table Op Msg_type Msg_text +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" +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" +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" +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" +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 +"In 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/t/stopword.opt b/mysql-test/suite/innodb_fts/t/stopword.opt new file mode 100644 index 00000000000..d6938c3b1ea --- /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 00000000000..5105a6d2fec --- /dev/null +++ b/mysql-test/suite/innodb_fts/t/stopword.test @@ -0,0 +1,657 @@ +# This is the basic function tests for innodb FTS + +-- source include/have_innodb.inc + +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 +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 ...'); + +# "the" is in the default stopword, it would not be selected +SELECT * FROM articles WHERE MATCH (title,body) + AGAINST ('the' IN NATURAL LANGUAGE MODE); + +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; + +# 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 formated user stopword table +create table user_stopword(value varchar(30)) engine = innodb; + +# The set operation should be successful +set global innodb_ft_server_stopword_table = "test/user_stopword"; + +drop index title on articles; + +create fulltext index idx on articles(title, body); + +# 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 +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...'); + +# 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("this"); + +# Ok, let's repeat with the new table again. +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...'); + +# 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" +create table user_stopword_session(value varchar(30)) engine = innodb; + +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...'); + +# "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,,) +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...'); + +# "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 +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; + +# 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 +CREATE TABLE articles ( + id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, + title VARCHAR(200), + body TEXT, + FULLTEXT `idx` (title,body) + ) 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 formated user stopword table +create table user_stopword(value varchar(30)) engine = innodb; +# The set operation should be successful +set session innodb_ft_user_stopword_table = "test/user_stopword"; +# Define a correct formated server stopword table +create table server_stopword(value varchar(30)) 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("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 +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; + +# 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 formated user stopword table +create table user_stopword(value varchar(30)) 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 formated user stopword table +create table server_stopword(value varchar(30)) 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 +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; + +# 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 formated user stopword table +create table user_stopword(value varchar(30)) 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 formated user stopword table +create table user_stopword_1(value varchar(30)) 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 formated server stopword table +create table server_stopword(value varchar(30)) 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/storage/innobase/buf/buf0dump.cc b/storage/innobase/buf/buf0dump.cc index eabc554036a..a45a37a4b3c 100644 --- a/storage/innobase/buf/buf0dump.cc +++ b/storage/innobase/buf/buf0dump.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -176,7 +176,7 @@ get_buf_dump_dir() /* The dump file should be created in the default data directory if innodb_data_home_dir is set as an empty string. */ - if (strcmp(srv_data_home, "") == 0) { + if (!*srv_data_home) { dump_dir = fil_path_to_mysql_datadir; } else { dump_dir = srv_data_home; @@ -207,9 +207,11 @@ buf_dump( ulint i; int ret; + mysql_mutex_lock(&LOCK_global_system_variables); ut_snprintf(full_filename, sizeof(full_filename), "%s%c%s", get_buf_dump_dir(), SRV_PATH_SEPARATOR, srv_buf_dump_filename); + mysql_mutex_unlock(&LOCK_global_system_variables); ut_snprintf(tmp_filename, sizeof(tmp_filename), "%s.incomplete", full_filename); @@ -513,9 +515,11 @@ buf_load() /* Ignore any leftovers from before */ buf_load_abort_flag = FALSE; + mysql_mutex_lock(&LOCK_global_system_variables); ut_snprintf(full_filename, sizeof(full_filename), "%s%c%s", get_buf_dump_dir(), SRV_PATH_SEPARATOR, srv_buf_dump_filename); + mysql_mutex_unlock(&LOCK_global_system_variables); buf_load_status(STATUS_NOTICE, "Loading buffer pool(s) from %s", full_filename); diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 6dbe5e0e2a0..54cf2f11884 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2019, MariaDB Corporation. +Copyright (c) 2016, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -443,9 +443,9 @@ fts_read_stopword( /******************************************************************//** Load user defined stopword from designated user table -@return TRUE if load operation is successful */ +@return whether the operation is successful */ static -ibool +bool fts_load_user_stopword( /*===================*/ fts_t* fts, /*!< in: FTS struct */ @@ -453,27 +453,26 @@ fts_load_user_stopword( name */ fts_stopword_t* stopword_info) /*!< in: Stopword info */ { - pars_info_t* info; - que_t* graph; - dberr_t error = DB_SUCCESS; - ibool ret = TRUE; - trx_t* trx; - ibool has_lock = fts->dict_locked; - - trx = trx_allocate_for_background(); - trx->op_info = "Load user stopword table into FTS cache"; - - if (!has_lock) { + if (!fts->dict_locked) { mutex_enter(&dict_sys->mutex); } - /* Validate the user table existence and in the right - format */ + /* Validate the user table existence in the right format */ + bool ret= false; stopword_info->charset = fts_valid_stopword_table(stopword_table_name); if (!stopword_info->charset) { - ret = FALSE; - goto cleanup; - } else if (!stopword_info->cached_stopword) { +cleanup: + if (!fts->dict_locked) { + mutex_exit(&dict_sys->mutex); + } + + return ret; + } + + trx_t* trx = trx_allocate_for_background(); + trx->op_info = "Load user stopword table into FTS cache"; + + if (!stopword_info->cached_stopword) { /* Create the stopword RB tree with the stopword column charset. All comparison will use this charset */ stopword_info->cached_stopword = rbt_create_arg_cmp( @@ -482,14 +481,14 @@ fts_load_user_stopword( } - info = pars_info_create(); + pars_info_t* info = pars_info_create(); pars_info_bind_id(info, TRUE, "table_stopword", stopword_table_name); pars_info_bind_function(info, "my_func", fts_read_stopword, stopword_info); - graph = fts_parse_sql_no_dict_lock( + que_t* graph = fts_parse_sql_no_dict_lock( NULL, info, "DECLARE FUNCTION my_func;\n" @@ -508,14 +507,13 @@ fts_load_user_stopword( "CLOSE c;"); for (;;) { - error = fts_eval_sql(trx, graph); + dberr_t error = fts_eval_sql(trx, graph); if (error == DB_SUCCESS) { fts_sql_commit(trx); stopword_info->status = STOPWORD_USER_TABLE; break; } else { - fts_sql_rollback(trx); ut_print_timestamp(stderr); @@ -537,14 +535,9 @@ fts_load_user_stopword( } que_graph_free(graph); - -cleanup: - if (!has_lock) { - mutex_exit(&dict_sys->mutex); - } - trx_free_for_background(trx); - return(ret); + ret = true; + goto cleanup; } /******************************************************************//** @@ -3495,8 +3488,8 @@ fts_add_doc_by_id( if (table->fts->cache->stopword_info.status & STOPWORD_NOT_INIT) { - fts_load_stopword(table, NULL, NULL, - NULL, TRUE, TRUE); + fts_load_stopword(table, NULL, + NULL, true, true); } fts_cache_add_doc( @@ -7244,21 +7237,19 @@ This function loads the stopword into the FTS cache. It also records/fetches stopword configuration to/from FTS configure table, depending on whether we are creating or reloading the FTS. -@return TRUE if load operation is successful */ +@return true if load operation is successful */ UNIV_INTERN -ibool +bool fts_load_stopword( /*==============*/ const dict_table_t* table, /*!< in: Table with FTS */ trx_t* trx, /*!< in: Transactions */ - const char* global_stopword_table, /*!< in: Global stopword table - name */ const char* session_stopword_table, /*!< in: Session stopword table name */ - ibool stopword_is_on, /*!< in: Whether stopword + bool stopword_is_on, /*!< in: Whether stopword option is turned on/off */ - ibool reload) /*!< in: Whether it is + bool reload) /*!< in: Whether it is for reloading FTS table */ { fts_table_t fts_table; @@ -7274,9 +7265,8 @@ fts_load_stopword( cache = table->fts->cache; - if (!reload && !(cache->stopword_info.status - & STOPWORD_NOT_INIT)) { - return(TRUE); + if (!reload && !(cache->stopword_info.status & STOPWORD_NOT_INIT)) { + return true; } if (!trx) { @@ -7321,12 +7311,11 @@ fts_load_stopword( goto cleanup; } - if (strlen((char*) str.f_str) > 0) { + if (*str.f_str) { stopword_to_use = (const char*) str.f_str; } } else { - stopword_to_use = (session_stopword_table) - ? session_stopword_table : global_stopword_table; + stopword_to_use = session_stopword_table; } if (stopword_to_use @@ -7363,7 +7352,7 @@ cleanup: sizeof(fts_tokenizer_word_t), fts_utf8_string_cmp); } - return(error == DB_SUCCESS); + return error == DB_SUCCESS; } /**********************************************************************//** @@ -7569,7 +7558,7 @@ fts_init_index( } else { if (table->fts->cache->stopword_info.status & STOPWORD_NOT_INIT) { - fts_load_stopword(table, NULL, NULL, NULL, TRUE, TRUE); + fts_load_stopword(table, NULL, NULL, true, true); } for (ulint i = 0; i < ib_vector_size(cache->get_docs); ++i) { diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index a1505eecd29..c54dae220ae 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -11508,10 +11508,17 @@ innobase_fts_load_stopword( trx_t* trx, /*!< in: transaction */ THD* thd) /*!< in: current thread */ { - return(fts_load_stopword(table, trx, - innobase_server_stopword_table, - THDVAR(thd, ft_user_stopword_table), - THDVAR(thd, ft_enable_stopword), FALSE)); + const char *stopword_table= THDVAR(thd, ft_user_stopword_table); + if (!stopword_table) + { + mysql_mutex_lock(&LOCK_global_system_variables); + if (innobase_server_stopword_table) + stopword_table= thd_strdup(thd, innobase_server_stopword_table); + mysql_mutex_unlock(&LOCK_global_system_variables); + } + + return fts_load_stopword(table, trx, stopword_table, + THDVAR(thd, ft_enable_stopword), false); } /*****************************************************************//** @@ -17054,7 +17061,6 @@ innodb_stopword_table_validate( char buff[STRING_BUFFER_USUAL_SIZE]; int len = sizeof(buff); trx_t* trx; - int ret = 1; ut_a(save != NULL); ut_a(value != NULL); @@ -17067,14 +17073,22 @@ innodb_stopword_table_validate( /* Validate the stopword table's (if supplied) existence and of the right format */ - if (!stopword_table_name - || fts_valid_stopword_table(stopword_table_name)) { - *static_cast(save) = stopword_table_name; - ret = 0; - } + int ret = stopword_table_name && !fts_valid_stopword_table( + stopword_table_name); row_mysql_unlock_data_dictionary(trx); + if (!ret) { + if (stopword_table_name == buff) { + ut_ad(static_cast(len) < sizeof buff); + stopword_table_name = thd_strmake(thd, + stopword_table_name, + len); + } + + *static_cast(save) = stopword_table_name; + } + return(ret); } @@ -17082,9 +17096,10 @@ innodb_stopword_table_validate( static char* innodb_ft_aux_table; /** Update innodb_ft_aux_table_id on SET GLOBAL innodb_ft_aux_table. +@param[in,out] thd connection @param[out] save new value of innodb_ft_aux_table @param[in] value user-specified value */ -static int innodb_ft_aux_table_validate(THD*, st_mysql_sys_var*, +static int innodb_ft_aux_table_validate(THD *thd, st_mysql_sys_var*, void* save, st_mysql_value* value) { char buf[STRING_BUFFER_USUAL_SIZE]; @@ -17098,6 +17113,15 @@ static int innodb_ft_aux_table_validate(THD*, st_mysql_sys_var*, dict_table_close(table, FALSE, FALSE); if (id) { innodb_ft_aux_table_id = id; + if (table_name == buf) { + ut_ad(static_cast(len) + < sizeof buf); + table_name = thd_strmake(thd, + table_name, + len); + } + + *static_cast(save) = table_name; return 0; } @@ -17796,52 +17820,43 @@ exit: return; } -#ifdef __WIN__ -/*************************************************************//** -Validate if passed-in "value" is a valid value for -innodb_buffer_pool_filename. On Windows, file names with colon (:) -are not allowed. - +/** Validate SET GLOBAL innodb_buffer_pool_filename. +On Windows, file names with colon (:) are not allowed. +@param thd connection +@param save &srv_buf_dump_filename +@param value new value to be validated @return 0 for valid name */ -static -int -innodb_srv_buf_dump_filename_validate( -/*==================================*/ - THD* thd, /*!< in: thread handle */ - struct st_mysql_sys_var* var, /*!< in: pointer to system - variable */ - void* save, /*!< out: immediate result - for update function */ - struct st_mysql_value* value) /*!< in: incoming string */ +static int innodb_srv_buf_dump_filename_validate(THD *thd, st_mysql_sys_var*, + void *save, + st_mysql_value *value) { - const char* buf_name; - char buff[OS_FILE_MAX_PATH]; - int len= sizeof(buff); - - ut_a(save != NULL); - ut_a(value != NULL); + char buff[OS_FILE_MAX_PATH]; + int len= sizeof buff; - buf_name = value->val_str(value, buff, &len); - - if (buf_name) { - if (is_filename_allowed(buf_name, len, FALSE)){ - *static_cast(save) = buf_name; - return(0); - } else { - push_warning_printf(thd, - Sql_condition::WARN_LEVEL_WARN, - ER_WRONG_ARGUMENTS, - "InnoDB: innodb_buffer_pool_filename " - "cannot have colon (:) in the file name."); - - } - } + if (const char *buf_name= value->val_str(value, buff, &len)) + { +#ifdef __WIN__ + if (!is_filename_allowed(buf_name, len, FALSE)) + { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_WRONG_ARGUMENTS, + "InnoDB: innodb_buffer_pool_filename " + "cannot have colon (:) in the file name."); + return 1; + } +#endif /* __WIN__ */ + if (buf_name == buff) + { + ut_ad(static_cast(len) < sizeof buff); + buf_name= thd_strmake(thd, buf_name, len); + } + + *static_cast(save)= buf_name; + return 0; + } - return(1); + return 1; } -#else /* __WIN__ */ -# define innodb_srv_buf_dump_filename_validate NULL -#endif /* __WIN__ */ #ifdef UNIV_DEBUG static char* srv_buffer_pool_evict; diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h index 3beddd68722..886ac257f01 100644 --- a/storage/innobase/include/fts0fts.h +++ b/storage/innobase/include/fts0fts.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2019, MariaDB Corporation. +Copyright (c) 2016, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -899,21 +899,19 @@ fts_valid_stopword_table( name */ /****************************************************************//** This function loads specified stopword into FTS cache -@return TRUE if success */ +@return true if success */ UNIV_INTERN -ibool +bool fts_load_stopword( /*==============*/ const dict_table_t* table, /*!< in: Table with FTS */ trx_t* trx, /*!< in: Transaction */ - const char* global_stopword_table, /*!< in: Global stopword table - name */ const char* session_stopword_table, /*!< in: Session stopword table name */ - ibool stopword_is_on, /*!< in: Whether stopword + bool stopword_is_on, /*!< in: Whether stopword option is turned on/off */ - ibool reload); /*!< in: Whether it is during + bool reload); /*!< in: Whether it is during reload of FTS table */ /****************************************************************//** diff --git a/storage/xtradb/buf/buf0dump.cc b/storage/xtradb/buf/buf0dump.cc index 349e7d45ab8..20dec30d106 100644 --- a/storage/xtradb/buf/buf0dump.cc +++ b/storage/xtradb/buf/buf0dump.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2017, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -176,7 +176,7 @@ get_buf_dump_dir() /* The dump file should be created in the default data directory if innodb_data_home_dir is set as an empty string. */ - if (strcmp(srv_data_home, "") == 0) { + if (!*srv_data_home) { dump_dir = fil_path_to_mysql_datadir; } else { dump_dir = srv_data_home; @@ -208,9 +208,11 @@ buf_dump( ulint i; int ret; + mysql_mutex_lock(&LOCK_global_system_variables); ut_snprintf(full_filename, sizeof(full_filename), "%s%c%s", get_buf_dump_dir(), SRV_PATH_SEPARATOR, srv_buf_dump_filename); + mysql_mutex_unlock(&LOCK_global_system_variables); ut_snprintf(tmp_filename, sizeof(tmp_filename), format_name, full_filename); @@ -514,9 +516,11 @@ buf_load() /* Ignore any leftovers from before */ buf_load_abort_flag = FALSE; + mysql_mutex_lock(&LOCK_global_system_variables); ut_snprintf(full_filename, sizeof(full_filename), "%s%c%s", get_buf_dump_dir(), SRV_PATH_SEPARATOR, srv_buf_dump_filename); + mysql_mutex_unlock(&LOCK_global_system_variables); buf_load_status(STATUS_NOTICE, "Loading buffer pool(s) from %s", full_filename); diff --git a/storage/xtradb/fts/fts0fts.cc b/storage/xtradb/fts/fts0fts.cc index 6dbe5e0e2a0..54cf2f11884 100644 --- a/storage/xtradb/fts/fts0fts.cc +++ b/storage/xtradb/fts/fts0fts.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2019, MariaDB Corporation. +Copyright (c) 2016, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -443,9 +443,9 @@ fts_read_stopword( /******************************************************************//** Load user defined stopword from designated user table -@return TRUE if load operation is successful */ +@return whether the operation is successful */ static -ibool +bool fts_load_user_stopword( /*===================*/ fts_t* fts, /*!< in: FTS struct */ @@ -453,27 +453,26 @@ fts_load_user_stopword( name */ fts_stopword_t* stopword_info) /*!< in: Stopword info */ { - pars_info_t* info; - que_t* graph; - dberr_t error = DB_SUCCESS; - ibool ret = TRUE; - trx_t* trx; - ibool has_lock = fts->dict_locked; - - trx = trx_allocate_for_background(); - trx->op_info = "Load user stopword table into FTS cache"; - - if (!has_lock) { + if (!fts->dict_locked) { mutex_enter(&dict_sys->mutex); } - /* Validate the user table existence and in the right - format */ + /* Validate the user table existence in the right format */ + bool ret= false; stopword_info->charset = fts_valid_stopword_table(stopword_table_name); if (!stopword_info->charset) { - ret = FALSE; - goto cleanup; - } else if (!stopword_info->cached_stopword) { +cleanup: + if (!fts->dict_locked) { + mutex_exit(&dict_sys->mutex); + } + + return ret; + } + + trx_t* trx = trx_allocate_for_background(); + trx->op_info = "Load user stopword table into FTS cache"; + + if (!stopword_info->cached_stopword) { /* Create the stopword RB tree with the stopword column charset. All comparison will use this charset */ stopword_info->cached_stopword = rbt_create_arg_cmp( @@ -482,14 +481,14 @@ fts_load_user_stopword( } - info = pars_info_create(); + pars_info_t* info = pars_info_create(); pars_info_bind_id(info, TRUE, "table_stopword", stopword_table_name); pars_info_bind_function(info, "my_func", fts_read_stopword, stopword_info); - graph = fts_parse_sql_no_dict_lock( + que_t* graph = fts_parse_sql_no_dict_lock( NULL, info, "DECLARE FUNCTION my_func;\n" @@ -508,14 +507,13 @@ fts_load_user_stopword( "CLOSE c;"); for (;;) { - error = fts_eval_sql(trx, graph); + dberr_t error = fts_eval_sql(trx, graph); if (error == DB_SUCCESS) { fts_sql_commit(trx); stopword_info->status = STOPWORD_USER_TABLE; break; } else { - fts_sql_rollback(trx); ut_print_timestamp(stderr); @@ -537,14 +535,9 @@ fts_load_user_stopword( } que_graph_free(graph); - -cleanup: - if (!has_lock) { - mutex_exit(&dict_sys->mutex); - } - trx_free_for_background(trx); - return(ret); + ret = true; + goto cleanup; } /******************************************************************//** @@ -3495,8 +3488,8 @@ fts_add_doc_by_id( if (table->fts->cache->stopword_info.status & STOPWORD_NOT_INIT) { - fts_load_stopword(table, NULL, NULL, - NULL, TRUE, TRUE); + fts_load_stopword(table, NULL, + NULL, true, true); } fts_cache_add_doc( @@ -7244,21 +7237,19 @@ This function loads the stopword into the FTS cache. It also records/fetches stopword configuration to/from FTS configure table, depending on whether we are creating or reloading the FTS. -@return TRUE if load operation is successful */ +@return true if load operation is successful */ UNIV_INTERN -ibool +bool fts_load_stopword( /*==============*/ const dict_table_t* table, /*!< in: Table with FTS */ trx_t* trx, /*!< in: Transactions */ - const char* global_stopword_table, /*!< in: Global stopword table - name */ const char* session_stopword_table, /*!< in: Session stopword table name */ - ibool stopword_is_on, /*!< in: Whether stopword + bool stopword_is_on, /*!< in: Whether stopword option is turned on/off */ - ibool reload) /*!< in: Whether it is + bool reload) /*!< in: Whether it is for reloading FTS table */ { fts_table_t fts_table; @@ -7274,9 +7265,8 @@ fts_load_stopword( cache = table->fts->cache; - if (!reload && !(cache->stopword_info.status - & STOPWORD_NOT_INIT)) { - return(TRUE); + if (!reload && !(cache->stopword_info.status & STOPWORD_NOT_INIT)) { + return true; } if (!trx) { @@ -7321,12 +7311,11 @@ fts_load_stopword( goto cleanup; } - if (strlen((char*) str.f_str) > 0) { + if (*str.f_str) { stopword_to_use = (const char*) str.f_str; } } else { - stopword_to_use = (session_stopword_table) - ? session_stopword_table : global_stopword_table; + stopword_to_use = session_stopword_table; } if (stopword_to_use @@ -7363,7 +7352,7 @@ cleanup: sizeof(fts_tokenizer_word_t), fts_utf8_string_cmp); } - return(error == DB_SUCCESS); + return error == DB_SUCCESS; } /**********************************************************************//** @@ -7569,7 +7558,7 @@ fts_init_index( } else { if (table->fts->cache->stopword_info.status & STOPWORD_NOT_INIT) { - fts_load_stopword(table, NULL, NULL, NULL, TRUE, TRUE); + fts_load_stopword(table, NULL, NULL, true, true); } for (ulint i = 0; i < ib_vector_size(cache->get_docs); ++i) { diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 1593bf8ab46..c57870915dc 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -12056,10 +12056,17 @@ innobase_fts_load_stopword( trx_t* trx, /*!< in: transaction */ THD* thd) /*!< in: current thread */ { - return(fts_load_stopword(table, trx, - innobase_server_stopword_table, - THDVAR(thd, ft_user_stopword_table), - THDVAR(thd, ft_enable_stopword), FALSE)); + const char *stopword_table= THDVAR(thd, ft_user_stopword_table); + if (!stopword_table) + { + mysql_mutex_lock(&LOCK_global_system_variables); + if (innobase_server_stopword_table) + stopword_table= thd_strdup(thd, innobase_server_stopword_table); + mysql_mutex_unlock(&LOCK_global_system_variables); + } + + return fts_load_stopword(table, trx, stopword_table, + THDVAR(thd, ft_enable_stopword), false); } /*****************************************************************//** @@ -17766,7 +17773,6 @@ innodb_stopword_table_validate( char buff[STRING_BUFFER_USUAL_SIZE]; int len = sizeof(buff); trx_t* trx; - int ret = 1; ut_a(save != NULL); ut_a(value != NULL); @@ -17779,14 +17785,22 @@ innodb_stopword_table_validate( /* Validate the stopword table's (if supplied) existence and of the right format */ - if (!stopword_table_name - || fts_valid_stopword_table(stopword_table_name)) { - *static_cast(save) = stopword_table_name; - ret = 0; - } + int ret = stopword_table_name && !fts_valid_stopword_table( + stopword_table_name); row_mysql_unlock_data_dictionary(trx); + if (!ret) { + if (stopword_table_name == buff) { + ut_ad(static_cast(len) < sizeof buff); + stopword_table_name = thd_strmake(thd, + stopword_table_name, + len); + } + + *static_cast(save) = stopword_table_name; + } + return(ret); } @@ -17794,9 +17808,10 @@ innodb_stopword_table_validate( static char* innodb_ft_aux_table; /** Update innodb_ft_aux_table_id on SET GLOBAL innodb_ft_aux_table. +@param[in,out] thd connection @param[out] save new value of innodb_ft_aux_table @param[in] value user-specified value */ -static int innodb_ft_aux_table_validate(THD*, st_mysql_sys_var*, +static int innodb_ft_aux_table_validate(THD *thd, st_mysql_sys_var*, void* save, st_mysql_value* value) { char buf[STRING_BUFFER_USUAL_SIZE]; @@ -17810,6 +17825,15 @@ static int innodb_ft_aux_table_validate(THD*, st_mysql_sys_var*, dict_table_close(table, FALSE, FALSE); if (id) { innodb_ft_aux_table_id = id; + if (table_name == buf) { + ut_ad(static_cast(len) + < sizeof buf); + table_name = thd_strmake(thd, + table_name, + len); + } + + *static_cast(save) = table_name; return 0; } @@ -18508,52 +18532,43 @@ exit: return; } -#ifdef __WIN__ -/*************************************************************//** -Validate if passed-in "value" is a valid value for -innodb_buffer_pool_filename. On Windows, file names with colon (:) -are not allowed. - +/** Validate SET GLOBAL innodb_buffer_pool_filename. +On Windows, file names with colon (:) are not allowed. +@param thd connection +@param save &srv_buf_dump_filename +@param value new value to be validated @return 0 for valid name */ -static -int -innodb_srv_buf_dump_filename_validate( -/*==================================*/ - THD* thd, /*!< in: thread handle */ - struct st_mysql_sys_var* var, /*!< in: pointer to system - variable */ - void* save, /*!< out: immediate result - for update function */ - struct st_mysql_value* value) /*!< in: incoming string */ +static int innodb_srv_buf_dump_filename_validate(THD *thd, st_mysql_sys_var*, + void *save, + st_mysql_value *value) { - const char* buf_name; - char buff[OS_FILE_MAX_PATH]; - int len= sizeof(buff); - - ut_a(save != NULL); - ut_a(value != NULL); + char buff[OS_FILE_MAX_PATH]; + int len= sizeof buff; - buf_name = value->val_str(value, buff, &len); - - if (buf_name) { - if (is_filename_allowed(buf_name, len, FALSE)){ - *static_cast(save) = buf_name; - return(0); - } else { - push_warning_printf(thd, - Sql_condition::WARN_LEVEL_WARN, - ER_WRONG_ARGUMENTS, - "InnoDB: innodb_buffer_pool_filename " - "cannot have colon (:) in the file name."); - - } - } + if (const char *buf_name= value->val_str(value, buff, &len)) + { +#ifdef __WIN__ + if (!is_filename_allowed(buf_name, len, FALSE)) + { + push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, + ER_WRONG_ARGUMENTS, + "InnoDB: innodb_buffer_pool_filename " + "cannot have colon (:) in the file name."); + return 1; + } +#endif /* __WIN__ */ + if (buf_name == buff) + { + ut_ad(static_cast(len) < sizeof buff); + buf_name= thd_strmake(thd, buf_name, len); + } + + *static_cast(save)= buf_name; + return 0; + } - return(1); + return 1; } -#else /* __WIN__ */ -# define innodb_srv_buf_dump_filename_validate NULL -#endif /* __WIN__ */ #ifdef UNIV_DEBUG static char* srv_buffer_pool_evict; diff --git a/storage/xtradb/include/fts0fts.h b/storage/xtradb/include/fts0fts.h index 714f811db27..4d07ac1612f 100644 --- a/storage/xtradb/include/fts0fts.h +++ b/storage/xtradb/include/fts0fts.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2019, MariaDB Corporation. +Copyright (c) 2016, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -899,21 +899,19 @@ fts_valid_stopword_table( name */ /****************************************************************//** This function loads specified stopword into FTS cache -@return TRUE if success */ +@return true if success */ UNIV_INTERN -ibool +bool fts_load_stopword( /*==============*/ const dict_table_t* table, /*!< in: Table with FTS */ trx_t* trx, /*!< in: Transaction */ - const char* global_stopword_table, /*!< in: Global stopword table - name */ const char* session_stopword_table, /*!< in: Session stopword table name */ - ibool stopword_is_on, /*!< in: Whether stopword + bool stopword_is_on, /*!< in: Whether stopword option is turned on/off */ - ibool reload); /*!< in: Whether it is during + bool reload); /*!< in: Whether it is during reload of FTS table */ /****************************************************************//** -- cgit v1.2.1 From 01f8f33b43e5aa63752ccd71a6a63c5840207d3c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 23 Apr 2020 12:25:15 +0200 Subject: MDEV-21913 Add pam_user_map.so file to binary tarball package --- cmake/install_layout.cmake | 4 ++++ plugin/auth_pam/CMakeLists.txt | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake index e9413390172..b2d9b7734ce 100644 --- a/cmake/install_layout.cmake +++ b/cmake/install_layout.cmake @@ -128,6 +128,8 @@ SET(INSTALL_SUPPORTFILESDIR_STANDALONE "support-files") SET(INSTALL_MYSQLDATADIR_STANDALONE "data") SET(INSTALL_UNIX_ADDRDIR_STANDALONE "/tmp/mysql.sock") +SET(INSTALL_PAMDIR_STANDALONE "share") +SET(INSTALL_PAMDATADIR_STANDALONE "share") # # RPM layout # @@ -164,6 +166,7 @@ SET(INSTALL_SYSTEMD_UNITDIR_RPM "/usr/lib/systemd/system") SET(INSTALL_SYSTEMD_SYSUSERSDIR_RPM "/usr/lib/sysusers.d") SET(INSTALL_SYSTEMD_TMPFILESDIR_RPM "/usr/lib/tmpfiles.d") SET(INSTALL_PAMDIR_RPM "/${INSTALL_LIBDIR_RPM}/security") +SET(INSTALL_PAMDATADIR_RPM "/etc/security") # # DEB layout @@ -197,6 +200,7 @@ SET(INSTALL_SYSTEMD_UNITDIR_DEB "/lib/systemd/system") SET(INSTALL_SYSTEMD_SYSUSERSDIR_DEB "/usr/lib/sysusers.d") SET(INSTALL_SYSTEMD_TMPFILESDIR_DEB "/usr/lib/tmpfiles.d") SET(INSTALL_PAMDIR_DEB "/lib/${CMAKE_CXX_LIBRARY_ARCHITECTURE}/security") +SET(INSTALL_PAMDATADIR_DEB "/etc/security") # # SVR4 layout diff --git a/plugin/auth_pam/CMakeLists.txt b/plugin/auth_pam/CMakeLists.txt index c826b422240..ac598e4ffa6 100644 --- a/plugin/auth_pam/CMakeLists.txt +++ b/plugin/auth_pam/CMakeLists.txt @@ -22,7 +22,7 @@ IF(HAVE_PAM_APPL_H) IF(HAVE_STRNDUP) ADD_DEFINITIONS(-DHAVE_STRNDUP) ENDIF(HAVE_STRNDUP) - FIND_LIBRARY(PAM_LIBRARY pam) + FIND_LIBRARY(PAM_LIBRARY pam) # for srpm build-depends detection MYSQL_ADD_PLUGIN(auth_pam auth_pam.c LINK_LIBRARIES pam MODULE_ONLY) IF(TARGET auth_pam) @@ -31,7 +31,7 @@ IF(HAVE_PAM_APPL_H) SET_TARGET_PROPERTIES (pam_user_map PROPERTIES PREFIX "") IF(INSTALL_PAMDIR) INSTALL(TARGETS pam_user_map DESTINATION ${INSTALL_PAMDIR} COMPONENT Server) - INSTALL(FILES mapper/user_map.conf DESTINATION /etc/security COMPONENT Server) + INSTALL(FILES mapper/user_map.conf DESTINATION ${INSTALL_PAMDATADIR} COMPONENT Server) ENDIF() ENDIF() ENDIF(HAVE_PAM_APPL_H) -- cgit v1.2.1 From fb7c1b9415c9a8b0dc2e86ae44f0e7a2634e5d7e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 22 Apr 2020 15:39:40 +0200 Subject: MDEV-21331 installation fails on a server with containers when detecting running mysqld processes to stop, ignore processes in different namespaces. --- debian/mariadb-server-10.2.preinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/mariadb-server-10.2.preinst b/debian/mariadb-server-10.2.preinst index ed987507d18..161d9caee6e 100644 --- a/debian/mariadb-server-10.2.preinst +++ b/debian/mariadb-server-10.2.preinst @@ -25,7 +25,7 @@ stop_server() { # Return immediately if there are no mysql processes running # as there is no point in trying to shutdown in that case. - if ! pgrep mysqld > /dev/null; then return; fi + if ! pgrep --ns $$ mysqld > /dev/null; then return; fi set +e if [ -x /usr/sbin/invoke-rc.d ]; then -- cgit v1.2.1 From fae70d6b1c65c249c6b2927f1461f22b867a605c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 28 Apr 2020 09:47:40 +0300 Subject: Cleanup: Declare rtr_get_father_node() statically --- storage/innobase/gis/gis0sea.cc | 234 +++++++++++++++++------------------ storage/innobase/include/gis0rtree.h | 18 +-- 2 files changed, 117 insertions(+), 135 deletions(-) diff --git a/storage/innobase/gis/gis0sea.cc b/storage/innobase/gis/gis0sea.cc index 7ac529ed0db..e0dde1154b0 100644 --- a/storage/innobase/gis/gis0sea.cc +++ b/storage/innobase/gis/gis0sea.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2016, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -686,6 +686,121 @@ rtr_page_get_father( mem_heap_free(heap); } +/********************************************************************//** +Returns the upper level node pointer to a R-Tree page. It is assumed +that mtr holds an x-latch on the tree. */ +static void rtr_get_father_node( + dict_index_t* index, /*!< in: index */ + ulint level, /*!< in: the tree level of search */ + const dtuple_t* tuple, /*!< in: data tuple; NOTE: n_fields_cmp in + tuple must be set so that it cannot get + compared to the node ptr page number field! */ + btr_cur_t* sea_cur,/*!< in: search cursor */ + btr_cur_t* btr_cur,/*!< in/out: tree cursor; the cursor page is + s- or x-latched, but see also above! */ + ulint page_no,/*!< Current page no */ + mtr_t* mtr) /*!< in: mtr */ +{ + mem_heap_t* heap = NULL; + bool ret = false; + const rec_t* rec; + ulint n_fields; + bool new_rtr = false; + + /* Try to optimally locate the parent node. Level should always + less than sea_cur->tree_height unless the root is splitting */ + if (sea_cur && sea_cur->tree_height > level) { + + ut_ad(mtr_memo_contains_flagged(mtr, + dict_index_get_lock(index), + MTR_MEMO_X_LOCK + | MTR_MEMO_SX_LOCK)); + ret = rtr_cur_restore_position( + BTR_CONT_MODIFY_TREE, sea_cur, level, mtr); + + /* Once we block shrink tree nodes while there are + active search on it, this optimal locating should always + succeeds */ + ut_ad(ret); + + if (ret) { + btr_pcur_t* r_cursor = rtr_get_parent_cursor( + sea_cur, level, false); + + rec = btr_pcur_get_rec(r_cursor); + + ut_ad(r_cursor->rel_pos == BTR_PCUR_ON); + page_cur_position(rec, + btr_pcur_get_block(r_cursor), + btr_cur_get_page_cur(btr_cur)); + btr_cur->rtr_info = sea_cur->rtr_info; + btr_cur->tree_height = sea_cur->tree_height; + ut_ad(rtr_compare_cursor_rec( + index, btr_cur, page_no, &heap)); + goto func_exit; + } + } + + /* We arrive here in one of two scenario + 1) check table and btr_valide + 2) index root page being raised */ + ut_ad(!sea_cur || sea_cur->tree_height == level); + + if (btr_cur->rtr_info) { + rtr_clean_rtr_info(btr_cur->rtr_info, true); + } else { + new_rtr = true; + } + + btr_cur->rtr_info = rtr_create_rtr_info(false, false, btr_cur, index); + + if (sea_cur && sea_cur->tree_height == level) { + /* root split, and search the new root */ + btr_cur_search_to_nth_level( + index, level, tuple, PAGE_CUR_RTREE_LOCATE, + BTR_CONT_MODIFY_TREE, btr_cur, 0, + __FILE__, __LINE__, mtr); + + } else { + /* btr_validate */ + ut_ad(level >= 1); + ut_ad(!sea_cur); + + btr_cur_search_to_nth_level( + index, level, tuple, PAGE_CUR_RTREE_LOCATE, + BTR_CONT_MODIFY_TREE, btr_cur, 0, + __FILE__, __LINE__, mtr); + + rec = btr_cur_get_rec(btr_cur); + n_fields = dtuple_get_n_fields_cmp(tuple); + + if (page_rec_is_infimum(rec) + || (btr_cur->low_match != n_fields)) { + ret = rtr_pcur_getnext_from_path( + tuple, PAGE_CUR_RTREE_LOCATE, btr_cur, + level, BTR_CONT_MODIFY_TREE, + true, mtr); + + ut_ad(ret && btr_cur->low_match == n_fields); + } + } + + ret = rtr_compare_cursor_rec( + index, btr_cur, page_no, &heap); + + ut_ad(ret); + +func_exit: + if (heap) { + mem_heap_free(heap); + } + + if (new_rtr && btr_cur->rtr_info) { + rtr_clean_rtr_info(btr_cur->rtr_info, true); + btr_cur->rtr_info = NULL; + } +} + /** Returns the upper level node pointer to a R-Tree page. It is assumed that mtr holds an SX-latch or X-latch on the tree. @return rec_get_offsets() of the node pointer record */ @@ -806,123 +921,6 @@ rtr_page_get_father_block( cursor, mtr)); } -/********************************************************************//** -Returns the upper level node pointer to a R-Tree page. It is assumed -that mtr holds an x-latch on the tree. */ -void -rtr_get_father_node( -/*================*/ - dict_index_t* index, /*!< in: index */ - ulint level, /*!< in: the tree level of search */ - const dtuple_t* tuple, /*!< in: data tuple; NOTE: n_fields_cmp in - tuple must be set so that it cannot get - compared to the node ptr page number field! */ - btr_cur_t* sea_cur,/*!< in: search cursor */ - btr_cur_t* btr_cur,/*!< in/out: tree cursor; the cursor page is - s- or x-latched, but see also above! */ - ulint page_no,/*!< Current page no */ - mtr_t* mtr) /*!< in: mtr */ -{ - mem_heap_t* heap = NULL; - bool ret = false; - const rec_t* rec; - ulint n_fields; - bool new_rtr = false; - - /* Try to optimally locate the parent node. Level should always - less than sea_cur->tree_height unless the root is splitting */ - if (sea_cur && sea_cur->tree_height > level) { - - ut_ad(mtr_memo_contains_flagged(mtr, - dict_index_get_lock(index), - MTR_MEMO_X_LOCK - | MTR_MEMO_SX_LOCK)); - ret = rtr_cur_restore_position( - BTR_CONT_MODIFY_TREE, sea_cur, level, mtr); - - /* Once we block shrink tree nodes while there are - active search on it, this optimal locating should always - succeeds */ - ut_ad(ret); - - if (ret) { - btr_pcur_t* r_cursor = rtr_get_parent_cursor( - sea_cur, level, false); - - rec = btr_pcur_get_rec(r_cursor); - - ut_ad(r_cursor->rel_pos == BTR_PCUR_ON); - page_cur_position(rec, - btr_pcur_get_block(r_cursor), - btr_cur_get_page_cur(btr_cur)); - btr_cur->rtr_info = sea_cur->rtr_info; - btr_cur->tree_height = sea_cur->tree_height; - ut_ad(rtr_compare_cursor_rec( - index, btr_cur, page_no, &heap)); - goto func_exit; - } - } - - /* We arrive here in one of two scenario - 1) check table and btr_valide - 2) index root page being raised */ - ut_ad(!sea_cur || sea_cur->tree_height == level); - - if (btr_cur->rtr_info) { - rtr_clean_rtr_info(btr_cur->rtr_info, true); - } else { - new_rtr = true; - } - - btr_cur->rtr_info = rtr_create_rtr_info(false, false, btr_cur, index); - - if (sea_cur && sea_cur->tree_height == level) { - /* root split, and search the new root */ - btr_cur_search_to_nth_level( - index, level, tuple, PAGE_CUR_RTREE_LOCATE, - BTR_CONT_MODIFY_TREE, btr_cur, 0, - __FILE__, __LINE__, mtr); - - } else { - /* btr_validate */ - ut_ad(level >= 1); - ut_ad(!sea_cur); - - btr_cur_search_to_nth_level( - index, level, tuple, PAGE_CUR_RTREE_LOCATE, - BTR_CONT_MODIFY_TREE, btr_cur, 0, - __FILE__, __LINE__, mtr); - - rec = btr_cur_get_rec(btr_cur); - n_fields = dtuple_get_n_fields_cmp(tuple); - - if (page_rec_is_infimum(rec) - || (btr_cur->low_match != n_fields)) { - ret = rtr_pcur_getnext_from_path( - tuple, PAGE_CUR_RTREE_LOCATE, btr_cur, - level, BTR_CONT_MODIFY_TREE, - true, mtr); - - ut_ad(ret && btr_cur->low_match == n_fields); - } - } - - ret = rtr_compare_cursor_rec( - index, btr_cur, page_no, &heap); - - ut_ad(ret); - -func_exit: - if (heap) { - mem_heap_free(heap); - } - - if (new_rtr && btr_cur->rtr_info) { - rtr_clean_rtr_info(btr_cur->rtr_info, true); - btr_cur->rtr_info = NULL; - } -} - /*******************************************************************//** Create a RTree search info structure */ rtr_info_t* diff --git a/storage/innobase/include/gis0rtree.h b/storage/innobase/include/gis0rtree.h index ffb6beb922b..028014970f1 100644 --- a/storage/innobase/include/gis0rtree.h +++ b/storage/innobase/include/gis0rtree.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2014, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2017, 2018, MariaDB Corporation. +Copyright (c) 2017, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -166,22 +166,6 @@ rtr_ins_enlarge_mbr( que_thr_t* thr, /*!< in: query thread */ mtr_t* mtr); /*!< in: mtr */ -/********************************************************************//** -*/ -void -rtr_get_father_node( -/*================*/ - dict_index_t* index, /*!< in: index */ - ulint level, /*!< in: the tree level of search */ - const dtuple_t* tuple, /*!< in: data tuple; NOTE: n_fields_cmp in - tuple must be set so that it cannot get - compared to the node ptr page number field! */ - btr_cur_t* sea_cur,/*!< in: search cursor */ - btr_cur_t* cursor, /*!< in/out: tree cursor; the cursor page is - s- or x-latched */ - ulint page_no,/*!< in: current page no */ - mtr_t* mtr); /*!< in: mtr */ - /**************************************************************//** push a nonleaf index node to the search path */ UNIV_INLINE -- cgit v1.2.1 From 5a1d93152996952b7c26869ae1caa4262893dfce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 28 Apr 2020 19:05:56 +0300 Subject: Speed up innodb_gis.rtree_split INSERT...SELECT reading from an InnoDB table is slow due to creating explicit record locks. Use the sequence engine instead. Also, remove the space before rtr_page_need_second_split to actually make the debug injection work. --- mysql-test/suite/innodb_gis/r/rtree_split.result | 56 ++++++--------------- mysql-test/suite/innodb_gis/t/rtree_split.test | 64 ++++++------------------ 2 files changed, 30 insertions(+), 90 deletions(-) diff --git a/mysql-test/suite/innodb_gis/r/rtree_split.result b/mysql-test/suite/innodb_gis/r/rtree_split.result index 518319ff3d6..df88960ba3d 100644 --- a/mysql-test/suite/innodb_gis/r/rtree_split.result +++ b/mysql-test/suite/innodb_gis/r/rtree_split.result @@ -1,52 +1,24 @@ create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb; -insert into t1 values(1, Point(1,1)); -insert into t1 values(2, Point(2,2)); -insert into t1 values(3, Point(3,3)); -insert into t1 values(4, Point(4,4)); -insert into t1 values(5, Point(5,5)); -insert into t1 values(6, Point(6,6)); -insert into t1 values(7, Point(7,7)); -insert into t1 values(8, Point(8,8)); -insert into t1 values(9, Point(9,9)); -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; +begin; +insert into t1 select @s:=1+(seq mod 9), point(@s, @s) +from seq_1_to_576; SET @saved_dbug = @@SESSION.debug_dbug; -SET debug_dbug = '+d, rtr_page_need_second_split'; -insert into t1 select * from t1; +SET debug_dbug = '+d,rtr_page_need_second_split'; +insert into t1 select @s:=1+(seq mod 9), point(@s, @s) +from seq_1_to_576; SET debug_dbug = @saved_dbug; -delete from t1; -insert into t1 values(1, Point(1,1)); -insert into t1 values(2, Point(2,2)); -insert into t1 values(3, Point(3,3)); -insert into t1 values(4, Point(4,4)); -insert into t1 values(5, Point(5,5)); -insert into t1 values(6, Point(6,6)); -insert into t1 values(7, Point(7,7)); -insert into t1 values(8, Point(8,8)); -insert into t1 values(9, Point(9,9)); -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -start transaction; -insert into t1 select * from t1; +rollback; +insert into t1 select @s:=1+(seq mod 9), point(@s, @s) +from seq_1_to_2304; +begin; +insert into t1 select @s:=1+(seq mod 9), point(@s, @s) +from seq_1_to_2304; rollback; check table t1; Table Op Msg_type Msg_text test.t1 check status OK -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; +insert into t1 select @s:=1+(seq mod 9), point(@s, @s) +from seq_1_to_71424; check table t1; Table Op Msg_type Msg_text test.t1 check status OK diff --git a/mysql-test/suite/innodb_gis/t/rtree_split.test b/mysql-test/suite/innodb_gis/t/rtree_split.test index caf79becbd0..af626dba6b7 100644 --- a/mysql-test/suite/innodb_gis/t/rtree_split.test +++ b/mysql-test/suite/innodb_gis/t/rtree_split.test @@ -1,5 +1,5 @@ # WL#6745 InnoDB R-tree support -# This test case will test R-tree split, mostly on duplciate records. +# This test case will test R-tree split, mostly on duplicate records. # Not supported in embedded --source include/not_embedded.inc @@ -8,65 +8,33 @@ --source include/big_test.inc --source include/not_valgrind.inc --source include/have_debug.inc +--source include/have_sequence.inc # Create table with R-tree index. create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb; +begin; # Insert enough values to let R-tree split. -insert into t1 values(1, Point(1,1)); -insert into t1 values(2, Point(2,2)); -insert into t1 values(3, Point(3,3)); -insert into t1 values(4, Point(4,4)); -insert into t1 values(5, Point(5,5)); -insert into t1 values(6, Point(6,6)); -insert into t1 values(7, Point(7,7)); -insert into t1 values(8, Point(8,8)); -insert into t1 values(9, Point(9,9)); - -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; +insert into t1 select @s:=1+(seq mod 9), point(@s, @s) +from seq_1_to_576; #Check second round spliting. SET @saved_dbug = @@SESSION.debug_dbug; -SET debug_dbug = '+d, rtr_page_need_second_split'; -insert into t1 select * from t1; +SET debug_dbug = '+d,rtr_page_need_second_split'; +insert into t1 select @s:=1+(seq mod 9), point(@s, @s) +from seq_1_to_576; SET debug_dbug = @saved_dbug; +rollback; -delete from t1; - -insert into t1 values(1, Point(1,1)); -insert into t1 values(2, Point(2,2)); -insert into t1 values(3, Point(3,3)); -insert into t1 values(4, Point(4,4)); -insert into t1 values(5, Point(5,5)); -insert into t1 values(6, Point(6,6)); -insert into t1 values(7, Point(7,7)); -insert into t1 values(8, Point(8,8)); -insert into t1 values(9, Point(9,9)); - -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; - -insert into t1 select * from t1; -insert into t1 select * from t1; - -insert into t1 select * from t1; -insert into t1 select * from t1; -start transaction; -insert into t1 select * from t1; +insert into t1 select @s:=1+(seq mod 9), point(@s, @s) +from seq_1_to_2304; +begin; +insert into t1 select @s:=1+(seq mod 9), point(@s, @s) +from seq_1_to_2304; rollback; check table t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; -insert into t1 select * from t1; +insert into t1 select @s:=1+(seq mod 9), point(@s, @s) +from seq_1_to_71424; check table t1; select count(*) from t1; -- cgit v1.2.1 From 2644e52fdbb7943a549f467b4dfd97da2592039d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 28 Apr 2020 08:42:45 +0300 Subject: MDEV-22384 Wrong estimate of affected BLOB columns in update of PRIMARY KEY During the UPDATE of PRIMARY KEY columns, we may miscalculate the size of the clustered index record. row_upd_clust_rec_by_insert(): Pass the total number of off-page columns, which may include such columns that were inherited from the record and not created as part of the UPDATE operation. This is based on mysql/mysql-server@490c45e8c8e07197958dbb21214fd45ed668b559 which is a follow-up to mysql/mysql-server@1fa475b85d24de4b9ce2958c0eed738c221fc82c which we filed and fixed as MDEV-21511. No test case was provided by Oracle. --- storage/innobase/row/row0upd.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/storage/innobase/row/row0upd.cc b/storage/innobase/row/row0upd.cc index 31d4d31c1f9..3cd2a1ef04f 100644 --- a/storage/innobase/row/row0upd.cc +++ b/storage/innobase/row/row0upd.cc @@ -2805,8 +2805,7 @@ check_fk: mtr_commit(mtr); err = row_ins_clust_index_entry( - index, entry, thr, - node->upd_ext ? node->upd_ext->n_ext : 0); + index, entry, thr, dtuple_get_n_ext(entry)); node->state = UPD_NODE_INSERT_CLUSTERED; mem_heap_free(heap); -- cgit v1.2.1