From a1adabdd5cd46e58040626136a4d45b9ebafd772 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Tue, 17 Sep 2024 08:44:20 +0400 Subject: [PATCH 01/62] MDEV-25900 Assertion `octets < 1024' failed in Binlog_type_info_fixed_string::Binlog_type_info_fixed_string OR Assertion `field_length < 1024' failed in Field_string::save_field_metadata A CHAR column cannot be longer than 1024, because Binlog_type_info_fixed_string::Binlog_type_info_fixed_string replies on this fact - it cannot store binlog metadata for longer columns. In case of the filename character set mbmaxlen is equal to 5, so only 1024/5=204 characters can fit into the 1024 limit. - In strict mode: Disallowing creation of a CHAR column with octet length grater than 1024. - In non-strict mode: Automatically convert CHAR with octet length>1024 into VARCHAR. --- mysql-test/main/ctype_filename.result | 27 +++++++++++++++++++++++++++ mysql-test/main/ctype_filename.test | 22 ++++++++++++++++++++++ sql/sql_table.cc | 27 +++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) diff --git a/mysql-test/main/ctype_filename.result b/mysql-test/main/ctype_filename.result index aaccea91793..9cf1c07e00d 100644 --- a/mysql-test/main/ctype_filename.result +++ b/mysql-test/main/ctype_filename.result @@ -132,4 +132,31 @@ a c @002d1 @002d1 DROP TABLE t1; SET NAMES utf8; +# +# MDEV-25900 Assertion `octets < 1024' failed in Binlog_type_info_fixed_string::Binlog_type_info_fixed_string OR Assertion `field_length < 1024' failed in Field_string::save_field_metadata +# +CREATE TABLE t1 (a CHAR(204)) CHARACTER SET filename; +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(204) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=filename COLLATE=filename +DROP TABLE t1; +CREATE TABLE t1 (a CHAR(205)) CHARACTER SET filename; +ERROR 42000: Column length too big for column 'a' (max = 204); use BLOB or TEXT instead +SET sql_mode=''; +CREATE TABLE t1 (a CHAR(205)) CHARACTER SET filename; +Warnings: +Note 1246 Converting column 'a' from CHAR to VARCHAR +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(205) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=filename COLLATE=filename +DROP TABLE t1; +SET sql_mode=DEFAULT; +CREATE TABLE t1 (a CHAR(205) CHARACTER SET latin1); +ALTER TABLE t1 CONVERT TO CHARACTER SET filename; +ERROR 42000: Column length too big for column 'a' (max = 204); use BLOB or TEXT instead +DROP TABLE t1; # End of 10.5 tests diff --git a/mysql-test/main/ctype_filename.test b/mysql-test/main/ctype_filename.test index bfafe4d437f..185d4ca641a 100644 --- a/mysql-test/main/ctype_filename.test +++ b/mysql-test/main/ctype_filename.test @@ -141,4 +141,26 @@ SET NAMES utf8; --enable_ps_protocol +--echo # +--echo # MDEV-25900 Assertion `octets < 1024' failed in Binlog_type_info_fixed_string::Binlog_type_info_fixed_string OR Assertion `field_length < 1024' failed in Field_string::save_field_metadata +--echo # + +CREATE TABLE t1 (a CHAR(204)) CHARACTER SET filename; +SHOW CREATE TABLE t1; +DROP TABLE t1; + +--error ER_TOO_BIG_FIELDLENGTH +CREATE TABLE t1 (a CHAR(205)) CHARACTER SET filename; + +SET sql_mode=''; +CREATE TABLE t1 (a CHAR(205)) CHARACTER SET filename; +SHOW CREATE TABLE t1; +DROP TABLE t1; +SET sql_mode=DEFAULT; + +CREATE TABLE t1 (a CHAR(205) CHARACTER SET latin1); +--error ER_TOO_BIG_FIELDLENGTH +ALTER TABLE t1 CONVERT TO CHARACTER SET filename; +DROP TABLE t1; + --echo # End of 10.5 tests diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 1ef0a6e3bef..0a0ea7acb2e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4734,6 +4734,33 @@ bool Column_definition::prepare_blob_field(THD *thd) { DBUG_ENTER("Column_definition::prepare_blob_field"); + if (real_field_type() == FIELD_TYPE_STRING && length > 1024) + { + DBUG_ASSERT(charset->mbmaxlen > 4); + /* + Convert long CHAR columns to VARCHAR. + CHAR has an octet length limit of 1024 bytes. + The code in Binlog_type_info_fixed_string::Binlog_type_info_fixed_string + relies on this limit. If octet length of a CHAR column is greater + than 1024, then it cannot write its metadata to binlog properly. + In case of the filename character set with mbmaxlen=5, + the maximum possible character length is 1024/5=204 characters. + Upgrade to VARCHAR if octet length is greater than 1024. + */ + char warn_buff[MYSQL_ERRMSG_SIZE]; + if (thd->is_strict_mode()) + { + my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), field_name.str, + static_cast(1024 / charset->mbmaxlen)); + DBUG_RETURN(1); + } + set_handler(&type_handler_varchar); + my_snprintf(warn_buff, sizeof(warn_buff), ER_THD(thd, ER_AUTO_CONVERT), + field_name.str, "CHAR", "VARCHAR"); + push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, ER_AUTO_CONVERT, + warn_buff); + } + if (length > MAX_FIELD_VARCHARLENGTH && !(flags & BLOB_FLAG)) { /* Convert long VARCHAR columns to TEXT or BLOB */ From 68938d2b42474a6ff1fced3b1495ec45de2f5c47 Mon Sep 17 00:00:00 2001 From: Brandon Nesterenko Date: Mon, 9 Sep 2024 08:50:02 -0600 Subject: [PATCH 02/62] MDEV-33500 (part 2): rpl.rpl_parallel_sbm can still fail MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The failing test case validates Seconds_Behind_Master for a delayed slave, while STOP SLAVE is executed during a delay. The test fixes initially added to the test (commit b04c8575967) added a table lock to ensure a transaction could not finish before validating the Seconds_Behind_Master field after SLAVE START, but did not address a possibility that the transaction could finish before running the STOP SLAVE command, which invalidates the validations for the rest of the test case. Specifically, this would result in 1) a timeout in “Waiting for table metadata lock” on the replica, which expects the transaction to retry after slave restart and hit a lock conflict on the locked tables (added in b04c8575967), and 2) that Seconds_Behind_Master should have increased, but did not. The failure can be reproduced by synchronizing the slave to the master before the MDEV-32265 echo statement (i.e. before the SLAVE STOP). This patch fixes the test by adding a mechanism to use DEBUG_SYNC to synchronize a MASTER_DELAY, rather than continually increase the duration of the delay each time the test fails on buildbot. This is to ensure that on slow machines, a delay does not pass before the test gets a chance to validate results. Additionally, it decreases overall test time because the test can continue immediately after validation, thereby bypassing the remainder of a full delay for each transaction. --- .../sync_with_master_sql_delay_debug_sync.inc | 82 +++++++++++++++++++ .../suite/rpl/r/rpl_parallel_sbm.result | 38 ++++++++- mysql-test/suite/rpl/t/rpl_parallel_sbm.test | 50 +++++++++-- sql/slave.cc | 19 ++++- 4 files changed, 177 insertions(+), 12 deletions(-) create mode 100644 mysql-test/suite/rpl/include/sync_with_master_sql_delay_debug_sync.inc diff --git a/mysql-test/suite/rpl/include/sync_with_master_sql_delay_debug_sync.inc b/mysql-test/suite/rpl/include/sync_with_master_sql_delay_debug_sync.inc new file mode 100644 index 00000000000..7f3602d6979 --- /dev/null +++ b/mysql-test/suite/rpl/include/sync_with_master_sql_delay_debug_sync.inc @@ -0,0 +1,82 @@ +# ==== Purpose ==== +# +# If using DEBUG_SYNC to coordinate a slave's SQL DELAY via the DEBUG_DBUG +# identifier "sql_delay_by_debug_sync", this helper file will help synchronize +# a slave with the master for statements which don't need to be delayed. This +# can be helpful, for example, for setup/cleanup statements, if they must be +# run in the same lifetime as the statements used for the test. +# +# The actual synchronization will take place based on the input parameter +# slave_sync_method, which can be "gtid", "file_coord", or "none"; and will use +# the helper files sync_with_master_gtid.inc or sync_with_master.inc (or none +# at all), respectively. +# +# +# ==== Requirements ==== +# +# --source include/have_debug.inc +# --source include/have_debug_sync.inc +# set @@GLOBAL.debug_dbug= "+d,sql_delay_by_debug_sync"; +# +# +# ==== Usage ==== +# +# --let $slave_sync_method= gtid|file_coord|none +# [--let $num_event_groups= NUMBER] +# --source include/sync_with_master_sql_delay_debug_sync.inc +# +# +# Parameters: +# $slave_sync_method +# Value can be gtid, file_coord, or none; and will synchronize the slave +# with the master via this method (i.e. using sync_with_master_gtid.inc +# or sync_with_master.inc, respectively), after synchronizing the SQL +# delay +# +# $num_event_groups +# Number of event groups to synchronize the SQL delay for. If unset, will +# be default to 1. +# + +--let $include_filename= sync_with_master_sql_delay_debug_sync.inc +--source include/begin_include_file.inc + +if (!$slave_sync_method) +{ + --die Parameter slave_sync_method must be set +} + +if (`select "$slave_sync_method" not like "gtid" and "$slave_sync_method" not like "file_coord" and "$slave_sync_method" not like "none"`) +{ + --die Parameter slave_sync_method must have value "gtid", "file_coord" or "none" +} + +if (`select "$slave_sync_method" not like "none" and strcmp("$master_pos", "") = 0`) +{ + --die sync_with_master.inc or sync_with_master_gtid.inc was not called to populate variable master_pos +} + +if (!$num_event_groups) +{ + --let $num_event_groups= 1 +} + +while ($num_event_groups) +{ + set debug_sync= "now WAIT_FOR at_sql_delay"; + set debug_sync= "now SIGNAL continue_sql_thread"; + --dec $num_event_groups +} + +if (`select "$slave_sync_method" LIKE "gtid"`) +{ + --source include/sync_with_master_gtid.inc +} + +if (`select "$slave_sync_method" LIKE "file_coord"`) +{ + --source include/sync_with_master.inc +} + +--let $include_filename= sync_with_master_sql_delay_debug_sync.inc +--source include/end_include_file.inc diff --git a/mysql-test/suite/rpl/r/rpl_parallel_sbm.result b/mysql-test/suite/rpl/r/rpl_parallel_sbm.result index 75012c93f3b..59a6955aa1b 100644 --- a/mysql-test/suite/rpl/r/rpl_parallel_sbm.result +++ b/mysql-test/suite/rpl/r/rpl_parallel_sbm.result @@ -5,14 +5,20 @@ include/master-slave.inc # connection slave; include/stop_slave.inc -set @@GLOBAL.debug_dbug= "d,negate_clock_diff_with_master"; set @@GLOBAL.slave_parallel_mode= CONSERVATIVE; -change master to master_delay=3, master_use_gtid=Slave_Pos; +set @@GLOBAL.debug_dbug= "d,negate_clock_diff_with_master,sql_delay_by_debug_sync"; +change master to master_delay=1, master_use_gtid=Slave_Pos; include/start_slave.inc connection master; create table t1 (a int); create table t2 (a int); -include/sync_slave_sql_with_master.inc +include/save_master_gtid.inc +connection slave; +include/sync_with_master_sql_delay_debug_sync.inc +set debug_sync= "now WAIT_FOR at_sql_delay"; +set debug_sync= "now SIGNAL continue_sql_thread"; +set debug_sync= "now WAIT_FOR at_sql_delay"; +set debug_sync= "now SIGNAL continue_sql_thread"; # # Pt 1) Ensure SBM is updated immediately upon arrival of the next event connection master; @@ -21,12 +27,23 @@ insert into t1 values (0); include/save_master_gtid.inc connection slave; # Waiting for transaction to arrive on slave and begin SQL Delay.. +set debug_sync= "now WAIT_FOR at_sql_delay"; # Validating SBM is updated on event arrival.. # ..done # MDEV-32265. At time of STOP SLAVE, if the SQL Thread is currently # delaying a transaction; then when the reciprocal START SLAVE occurs, # if the event is still to be delayed, SBM should resume accordingly -include/stop_slave.inc +connection server_2; +# Ensure the kill from STOP SLAVE will be received before continuing the +# SQL thread +set debug_sync="after_thd_awake_kill SIGNAL slave_notified_of_kill"; +STOP SLAVE; +connection slave; +set debug_sync= "now WAIT_FOR slave_notified_of_kill"; +set debug_sync= "now SIGNAL continue_sql_thread"; +connection server_2; +include/wait_for_slave_to_stop.inc +set debug_sync="RESET"; # Lock t1 on slave to ensure the event can't finish (and thereby update # Seconds_Behind_Master) so slow running servers don't accidentally # catch up to the master before checking SBM. @@ -34,6 +51,10 @@ connection server_2; LOCK TABLES t1 WRITE; include/start_slave.inc connection slave; +# SQL delay has no impact for the rest of the test case, so ignore it +include/sync_with_master_sql_delay_debug_sync.inc +set debug_sync= "now WAIT_FOR at_sql_delay"; +set debug_sync= "now SIGNAL continue_sql_thread"; # Waiting for replica to get blocked by the table lock # Sleeping 1s to increment SBM # Ensuring Seconds_Behind_Master increases after sleeping.. @@ -54,6 +75,13 @@ insert into t1 values (2); include/save_master_pos.inc connection slave; # Wait for first transaction to complete SQL delay and begin execution.. +include/sync_with_master_sql_delay_debug_sync.inc +set debug_sync= "now WAIT_FOR at_sql_delay"; +set debug_sync= "now SIGNAL continue_sql_thread"; +# Wait for second transaction to complete SQL delay.. +include/sync_with_master_sql_delay_debug_sync.inc +set debug_sync= "now WAIT_FOR at_sql_delay"; +set debug_sync= "now SIGNAL continue_sql_thread"; # Validate SBM calculation doesn't use the second transaction because worker threads shouldn't have gone idle.. # ..and that SBM wasn't calculated using prior committed transactions # ..done @@ -63,6 +91,8 @@ include/wait_for_slave_param.inc [Relay_Master_Log_File] include/wait_for_slave_param.inc [Exec_Master_Log_Pos] # Cleanup include/stop_slave.inc +set debug_sync= "RESET"; +set @@GLOBAL.debug_dbug= "-d,sql_delay_by_debug_sync"; CHANGE MASTER TO master_delay=0; include/start_slave.inc # diff --git a/mysql-test/suite/rpl/t/rpl_parallel_sbm.test b/mysql-test/suite/rpl/t/rpl_parallel_sbm.test index 90753caf143..6941a88f4d0 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_sbm.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_sbm.test @@ -3,6 +3,7 @@ # --source include/have_log_bin.inc --source include/have_debug.inc +--source include/have_debug_sync.inc --source include/master-slave.inc --echo # @@ -16,14 +17,23 @@ # Seconds_Behind_Master is based on the timestamp of the new transaction, # rather than the last committed transaction. # +# Note that the test doesn't actually use the value of MASTER_DELAY, but +# rather uses debug_sync to coordinate the end of the delay. This is to ensure +# that on slow machines, a delay doesn't pass before the test gets a chance to +# validate results. Additionally, it lets us continue testing after validation +# so we don't have to wait out a full delay unnecessarily. The debug_sync point +# is enabled via sql_delay_by_debug_sync, which will delay transactions based +# only on GTID events, so only one synchronization is needed per transaction. +# --connection slave --source include/stop_slave.inc --let $save_dbug= `SELECT @@GLOBAL.debug_dbug` --let $save_parallel_mode= `SELECT @@GLOBAL.slave_parallel_mode` -set @@GLOBAL.debug_dbug= "d,negate_clock_diff_with_master"; set @@GLOBAL.slave_parallel_mode= CONSERVATIVE; ---let $master_delay= 3 +set @@GLOBAL.debug_dbug= "d,negate_clock_diff_with_master,sql_delay_by_debug_sync"; + +--let $master_delay= 1 --eval change master to master_delay=$master_delay, master_use_gtid=Slave_Pos --source include/start_slave.inc @@ -31,7 +41,11 @@ set @@GLOBAL.slave_parallel_mode= CONSERVATIVE; --let insert_ctr= 0 create table t1 (a int); create table t2 (a int); ---source include/sync_slave_sql_with_master.inc +--source include/save_master_gtid.inc +--connection slave +--let $slave_sync_method= gtid +--let $num_event_groups= 2 +--source include/sync_with_master_sql_delay_debug_sync.inc --echo # --echo # Pt 1) Ensure SBM is updated immediately upon arrival of the next event @@ -48,8 +62,7 @@ sleep 2; --connection slave --echo # Waiting for transaction to arrive on slave and begin SQL Delay.. ---let $wait_condition= SELECT count(*) FROM information_schema.processlist WHERE state LIKE 'Waiting until MASTER_DELAY seconds after master executed event'; ---source include/wait_condition.inc +set debug_sync= "now WAIT_FOR at_sql_delay"; --echo # Validating SBM is updated on event arrival.. --let $sbm_trx1_arrive= query_get_value(SHOW SLAVE STATUS, Seconds_Behind_Master, 1) @@ -66,7 +79,20 @@ if (`SELECT $sbm_trx1_arrive > ($seconds_since_idling + 1)`) --echo # delaying a transaction; then when the reciprocal START SLAVE occurs, --echo # if the event is still to be delayed, SBM should resume accordingly ---source include/stop_slave.inc +--connection server_2 +--echo # Ensure the kill from STOP SLAVE will be received before continuing the +--echo # SQL thread +set debug_sync="after_thd_awake_kill SIGNAL slave_notified_of_kill"; +--send STOP SLAVE + +--connection slave +set debug_sync= "now WAIT_FOR slave_notified_of_kill"; +set debug_sync= "now SIGNAL continue_sql_thread"; + +--connection server_2 +--reap +--source include/wait_for_slave_to_stop.inc +set debug_sync="RESET"; --echo # Lock t1 on slave to ensure the event can't finish (and thereby update --echo # Seconds_Behind_Master) so slow running servers don't accidentally @@ -77,6 +103,11 @@ LOCK TABLES t1 WRITE; --source include/start_slave.inc --connection slave + +--echo # SQL delay has no impact for the rest of the test case, so ignore it +--let $slave_sync_method= none +--source include/sync_with_master_sql_delay_debug_sync.inc + --echo # Waiting for replica to get blocked by the table lock --let $wait_condition= SELECT count(*) FROM information_schema.processlist WHERE state LIKE 'Waiting for table metadata lock'; --source include/wait_condition.inc @@ -120,9 +151,14 @@ sleep 3; --connection slave --echo # Wait for first transaction to complete SQL delay and begin execution.. +--let $slave_sync_method= none +--source include/sync_with_master_sql_delay_debug_sync.inc --let $wait_condition= SELECT count(*) FROM information_schema.processlist WHERE state LIKE 'Waiting for table metadata lock%' AND command LIKE 'Slave_Worker'; --source include/wait_condition.inc +--echo # Wait for second transaction to complete SQL delay.. +--source include/sync_with_master_sql_delay_debug_sync.inc + --echo # Validate SBM calculation doesn't use the second transaction because worker threads shouldn't have gone idle.. --let $sbm_after_trx_no_idle= query_get_value(SHOW SLAVE STATUS, Seconds_Behind_Master, 1) --let $timestamp_trxpt2_arrive= `SELECT UNIX_TIMESTAMP()` @@ -147,6 +183,8 @@ UNLOCK TABLES; --echo # Cleanup --source include/stop_slave.inc +set debug_sync= "RESET"; +set @@GLOBAL.debug_dbug= "-d,sql_delay_by_debug_sync"; --eval CHANGE MASTER TO master_delay=0 --source include/start_slave.inc diff --git a/sql/slave.cc b/sql/slave.cc index f258f9f3595..1a6a5a6efdb 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1088,6 +1088,8 @@ terminate_slave_thread(THD *thd, mysql_mutex_unlock(&thd->LOCK_thd_kill); mysql_mutex_unlock(&thd->LOCK_thd_data); + DEBUG_SYNC(current_thd, "after_thd_awake_kill"); + /* There is a small chance that slave thread might miss the first alarm. To protect againts it, resend the signal until it reacts @@ -3794,13 +3796,26 @@ sql_delay_event(Log_event *ev, THD *thd, rpl_group_info *rgi) sql_delay, (long)ev->when, rli->mi->clock_diff_with_master, (long)now, (ulonglong)sql_delay_end, (long)nap_time)); - - if (sql_delay_end > now) + /* if using debug_sync for sql_delay, only delay once per event group */ + if (DBUG_EVALUATE_IF("sql_delay_by_debug_sync", type == GTID_EVENT, + sql_delay_end > now)) { DBUG_PRINT("info", ("delaying replication event %lu secs", nap_time)); rli->start_sql_delay(sql_delay_end); mysql_mutex_unlock(&rli->data_lock); + +#ifdef ENABLED_DEBUG_SYNC + DBUG_EXECUTE_IF("sql_delay_by_debug_sync", { + DBUG_ASSERT(!debug_sync_set_action( + thd, STRING_WITH_LEN( + "now SIGNAL at_sql_delay WAIT_FOR continue_sql_thread"))); + + // Skip the actual sleep if using DEBUG_SYNC to coordinate SQL_DELAY + DBUG_RETURN(0); + };); +#endif + DBUG_RETURN(slave_sleep(thd, nap_time, sql_slave_killed, rgi)); } } From 450040e0dad4448be6a3e8d330af7d2d943f4773 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 18 Sep 2024 16:41:57 +1000 Subject: [PATCH 03/62] MDEV-34952 main.log_slow test failure on opensuse builder The loose regex for the MDEV-34539 test ended up matching the opensuse in the path in buildbot. Adjust to more complete regex including space, backtick and \n, which becomes much less common as a path name. --- mysql-test/main/log_slow.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/main/log_slow.test b/mysql-test/main/log_slow.test index 9e21f9d3890..8997b95d72c 100644 --- a/mysql-test/main/log_slow.test +++ b/mysql-test/main/log_slow.test @@ -213,7 +213,7 @@ set log_slow_filter=default; set timestamp=default; let SEARCH_FILE=`select @@slow_query_log_file`; -let SEARCH_PATTERN=use.*2; +let SEARCH_PATTERN= use \`a\n.*2; let SEARCH_OUTPUT=matches; source include/search_pattern_in_file.inc; From ab569524dc73ed17cc0c8f142b23e228d7c89726 Mon Sep 17 00:00:00 2001 From: Lena Startseva Date: Tue, 21 May 2024 17:46:29 +0700 Subject: [PATCH 04/62] MDEV-31005: Make working cursor-protocol Added ability to disable/enable (--disable_cursor_protocol/ --enable_cursor_protocol) cursor-protocol in tests. If "--disable_cursor_protocol" is used then ps-protocol is also disabled. With cursor-protocol prepare statement is executed only once. For "--cursor-protocol" added filter for queries: it is executed only for "SELECT" queries. --- client/mysqltest.cc | 61 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/client/mysqltest.cc b/client/mysqltest.cc index 7a31c6d6802..b687ea416c3 100644 --- a/client/mysqltest.cc +++ b/client/mysqltest.cc @@ -165,6 +165,7 @@ static struct property prop_list[] = { { &ps_protocol_enabled, 0, 0, 0, "$ENABLED_PS_PROTOCOL" }, { &ps2_protocol_enabled, 0, 0, 0, "$ENABLED_PS2_PROTOCOL" }, { &view_protocol_enabled, 0, 0, 0, "$ENABLED_VIEW_PROTOCOL"}, + { &cursor_protocol_enabled, 0, 0, 0, "$ENABLED_CURSOR_PROTOCOL"}, { &service_connection_enabled, 0, 1, 0, "$ENABLED_SERVICE_CONNECTION"}, { &disable_query_log, 0, 0, 1, "$ENABLED_QUERY_LOG" }, { &disable_result_log, 0, 0, 1, "$ENABLED_RESULT_LOG" }, @@ -182,6 +183,7 @@ enum enum_prop { P_PS, P_PS2, P_VIEW, + P_CURSOR, P_CONN, P_QUERY, P_RESULT, @@ -274,6 +276,7 @@ static regex_t ps_re; /* the query can be run using PS protocol */ static regex_t ps2_re; /* the query can be run using PS protocol with second execution*/ static regex_t sp_re; /* the query can be run as a SP */ static regex_t view_re; /* the query can be run as a view*/ +static regex_t cursor_re; /* the query can be run with cursor protocol*/ static void init_re(void); static int match_re(regex_t *, char *); @@ -392,6 +395,7 @@ enum enum_commands { Q_CHARACTER_SET, Q_DISABLE_PS_PROTOCOL, Q_ENABLE_PS_PROTOCOL, Q_DISABLE_PS2_PROTOCOL, Q_ENABLE_PS2_PROTOCOL, Q_DISABLE_VIEW_PROTOCOL, Q_ENABLE_VIEW_PROTOCOL, + Q_DISABLE_CURSOR_PROTOCOL, Q_ENABLE_CURSOR_PROTOCOL, Q_DISABLE_SERVICE_CONNECTION, Q_ENABLE_SERVICE_CONNECTION, Q_ENABLE_NON_BLOCKING_API, Q_DISABLE_NON_BLOCKING_API, Q_DISABLE_RECONNECT, Q_ENABLE_RECONNECT, @@ -488,6 +492,8 @@ const char *command_names[]= "enable_ps2_protocol", "disable_view_protocol", "enable_view_protocol", + "disable_cursor_protocol", + "enable_cursor_protocol", "disable_service_connection", "enable_service_connection", "enable_non_blocking_api", @@ -8575,13 +8581,22 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command, #if MYSQL_VERSION_ID >= 50000 if (cursor_protocol_enabled) { + ps2_protocol_enabled = 0; + /* - Use cursor when retrieving result + Use cursor for queries matching the filter, + else reset cursor type */ - ulong type= CURSOR_TYPE_READ_ONLY; - if (mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type)) - die("mysql_stmt_attr_set(STMT_ATTR_CURSOR_TYPE) failed': %d %s", - mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); + if (match_re(&cursor_re, query)) + { + /* + Use cursor when retrieving result + */ + ulong type= CURSOR_TYPE_READ_ONLY; + if (mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type)) + die("mysql_stmt_attr_set(STMT_ATTR_CURSOR_TYPE) failed': %d %s", + mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); + } } #endif @@ -8623,9 +8638,10 @@ void run_query_stmt(struct st_connection *cn, struct st_command *command, /* When running in cursor_protocol get the warnings from execute here - and keep them in a separate string for later. + and keep them in a separate string for later. Cursor_protocol is used + only for queries matching the filter "cursor_re". */ - if (cursor_protocol_enabled && !disable_warnings) + if (cursor_protocol_enabled && match_re(&cursor_re, query) && !disable_warnings) append_warnings(&ds_execute_warnings, mysql); @@ -8767,6 +8783,16 @@ end: var_set_errno(mysql_stmt_errno(stmt)); + #if MYSQL_VERSION_ID >= 50000 + if (cursor_protocol_enabled) + { + ulong type= CURSOR_TYPE_NO_CURSOR; + if (mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (void*) &type)) + die("mysql_stmt_attr_set(STMT_ATTR_CURSOR_TYPE) failed': %d %s", + mysql_stmt_errno(stmt), mysql_stmt_error(stmt)); + } + #endif + revert_properties(); /* Close the statement if reconnect, need new prepare */ @@ -9609,10 +9635,19 @@ void init_re(void) "^(" "[[:space:]]*SELECT[[:space:]])"; + /* + Filter for queries that can be run with + cursor protocol + */ + const char *cursor_re_str = + "^(" + "[[:space:]]*SELECT[[:space:]])"; + init_re_comp(&ps_re, ps_re_str); init_re_comp(&ps2_re, ps2_re_str); init_re_comp(&sp_re, sp_re_str); init_re_comp(&view_re, view_re_str); + init_re_comp(&cursor_re, cursor_re_str); } @@ -9650,6 +9685,7 @@ void free_re(void) regfree(&ps2_re); regfree(&sp_re); regfree(&view_re); + regfree(&cursor_re); } /****************************************************************************/ @@ -10443,6 +10479,17 @@ int main(int argc, char **argv) case Q_ENABLE_VIEW_PROTOCOL: set_property(command, P_VIEW, view_protocol); break; + case Q_DISABLE_CURSOR_PROTOCOL: + set_property(command, P_CURSOR, 0); + if (cursor_protocol) + set_property(command, P_PS, 0); + /* Close any open statements */ + close_statements(); + break; + case Q_ENABLE_CURSOR_PROTOCOL: + set_property(command, P_CURSOR, cursor_protocol); + set_property(command, P_PS, ps_protocol); + break; case Q_DISABLE_SERVICE_CONNECTION: set_property(command, P_CONN, 0); /* Close only util connections */ From 0a5e4a0191ecedff7d57867b01864225615af430 Mon Sep 17 00:00:00 2001 From: Lena Startseva Date: Thu, 23 May 2024 08:54:14 +0700 Subject: [PATCH 05/62] MDEV-31005: Make working cursor-protocol Updated tests: cases with bugs or which cannot be run with the cursor-protocol were excluded with "--disable_cursor_protocol"/"--enable_cursor_protocol" Fix for v.10.5 --- mysql-test/include/commit.inc | 4 + mysql-test/include/ctype_like_range_f1f2.inc | 5 +- mysql-test/include/ctype_numconv.inc | 3 + mysql-test/include/diff_tables.inc | 2 + mysql-test/include/explain_utils.inc | 2 + mysql-test/include/function_defaults.inc | 4 + mysql-test/include/grant_cache.inc | 2 + mysql-test/include/ps_conv.inc | 2 + mysql-test/include/query_cache.inc | 4 + mysql-test/include/query_cache_partitions.inc | 6 ++ mysql-test/include/test_outfile.inc | 2 + .../include/type_temporal_zero_default.inc | 2 + mysql-test/include/write_var_to_file.inc | 2 + mysql-test/main/alter_table.test | 2 + mysql-test/main/alter_user.test | 2 + .../main/auto_increment_ranges_innodb.test | 2 + mysql-test/main/bootstrap.test | 2 + mysql-test/main/bug12427262.test | 4 + mysql-test/main/count_distinct2.test | 2 + mysql-test/main/ctype_big5.test | 2 + mysql-test/main/ctype_binary.test | 10 +++ mysql-test/main/ctype_filename.test | 3 + mysql-test/main/ctype_gbk.test | 2 + mysql-test/main/ctype_ucs.test | 4 + mysql-test/main/ctype_utf16.test | 3 + mysql-test/main/ctype_utf16le.test | 3 + mysql-test/main/ctype_utf32.test | 6 ++ mysql-test/main/ctype_utf8.test | 6 ++ mysql-test/main/ctype_utf8mb4.test | 5 ++ mysql-test/main/derived.test | 3 + mysql-test/main/derived_view.test | 10 +++ mysql-test/main/distinct.test | 2 + mysql-test/main/empty_table.test | 3 + mysql-test/main/events_bugs.test | 4 + mysql-test/main/explain.test | 4 + .../main/fast_prefix_index_fetch_innodb.test | 20 +++++ mysql-test/main/flush_ssl.test | 2 + mysql-test/main/func_analyse.test | 3 + mysql-test/main/func_des_encrypt.test | 6 ++ mysql-test/main/func_digest.test | 3 + mysql-test/main/func_gconcat.test | 6 ++ mysql-test/main/func_group_innodb.test | 2 + mysql-test/main/func_json.test | 34 +++++++- mysql-test/main/func_math.test | 3 + mysql-test/main/func_misc.test | 2 + mysql-test/main/func_str.test | 59 +++++++++++--- mysql-test/main/func_time.test | 13 +++ mysql-test/main/func_time_round.test | 6 ++ mysql-test/main/get_diagnostics.test | 4 + mysql-test/main/gis.test | 6 ++ mysql-test/main/grant.test | 2 + mysql-test/main/grant2.test | 7 ++ mysql-test/main/grant_4332.test | 6 ++ mysql-test/main/group_by.test | 7 +- mysql-test/main/group_min_max.test | 12 +++ mysql-test/main/handler_read_last.test | 2 + mysql-test/main/information_schema.test | 4 + mysql-test/main/init_file.test | 2 + mysql-test/main/innodb_ext_key.test | 4 + mysql-test/main/insert.test | 2 + mysql-test/main/invisible_field.test | 4 + mysql-test/main/join.test | 4 + mysql-test/main/join_outer.test | 9 ++- mysql-test/main/key_cache.test | 2 + mysql-test/main/last_value.test | 3 + mysql-test/main/limit_rows_examined.test | 5 ++ mysql-test/main/loaddata.test | 38 +++++++++ mysql-test/main/log_slow.test | 4 + mysql-test/main/log_tables.test | 5 ++ mysql-test/main/long_unique_bugs.test | 8 ++ mysql-test/main/lowercase_table_qcache.test | 2 + mysql-test/main/mdev-21101.test | 2 + mysql-test/main/myisam_debug.test | 2 + mysql-test/main/mysqldump-max.test | 2 + mysql-test/main/null.test | 3 + mysql-test/main/null_key.test | 2 + mysql-test/main/order_by.test | 8 ++ mysql-test/main/order_by_pack_big.test | 6 ++ mysql-test/main/outfile.test | 24 ++++++ mysql-test/main/outfile_loaddata.test | 36 +++++++++ mysql-test/main/parser.test | 2 + mysql-test/main/partition.test | 4 + mysql-test/main/partition_csv.test | 2 + mysql-test/main/partition_explicit_prune.test | 2 + mysql-test/main/plugin.test | 2 + mysql-test/main/processlist.test | 3 + mysql-test/main/ps.test | 11 +++ mysql-test/main/query_cache.test | 2 + mysql-test/main/query_cache_debug.test | 2 + mysql-test/main/query_cache_innodb.test | 6 ++ mysql-test/main/query_cache_merge.test | 4 + mysql-test/main/query_cache_notembedded.test | 6 ++ mysql-test/main/query_cache_with_views.test | 4 + mysql-test/main/range_vs_index_merge.test | 2 + mysql-test/main/select.test | 12 +++ mysql-test/main/select_found.test | 7 +- mysql-test/main/shutdown_not_windows.test | 2 + mysql-test/main/single_delete_update.test | 2 + mysql-test/main/sp-error.test | 2 + mysql-test/main/sp-no-valgrind.test | 6 ++ mysql-test/main/sp.test | 6 ++ mysql-test/main/sp_trans.test | 2 + mysql-test/main/statistics.test | 2 + mysql-test/main/status2.test | 2 + mysql-test/main/strict.test | 3 + mysql-test/main/subselect.test | 35 +++++++- mysql-test/main/subselect3.inc | 17 ++++ mysql-test/main/subselect_cache.test | 12 +++ .../main/subselect_exists2in_costmat.test | 2 + mysql-test/main/subselect_mat_cost.test | 2 + mysql-test/main/subselect_sj.test | 2 + mysql-test/main/tmp_table_count-7586.test | 2 + mysql-test/main/trigger-compat.test | 2 + mysql-test/main/trigger.test | 3 + mysql-test/main/type_binary.test | 3 + mysql-test/main/type_bit.test | 3 + mysql-test/main/type_date.test | 3 + mysql-test/main/type_enum.test | 3 + mysql-test/main/type_float.test | 5 ++ mysql-test/main/type_newdecimal.test | 7 +- mysql-test/main/type_timestamp.test | 5 ++ mysql-test/main/type_year.test | 3 + mysql-test/main/udf.test | 6 ++ mysql-test/main/union.test | 2 + mysql-test/main/update.test | 4 + mysql-test/main/user_var.test | 6 ++ mysql-test/main/userstat-badlogin-4824.test | 2 + mysql-test/main/userstat.test | 7 +- mysql-test/main/variables.test | 13 ++- mysql-test/main/view.test | 9 ++- mysql-test/main/view_grant.test | 4 + mysql-test/main/wl4435_generated.inc | 3 + mysql-test/suite/archive/rnd_pos.test | 4 + mysql-test/suite/binlog/include/database.test | 2 + .../suite/binlog/t/binlog_commit_wait.test | 2 + .../binlog/t/binlog_mysqlbinlog_row_frag.test | 2 + .../suite/compat/oracle/t/update_innodb.test | 2 + .../t/innodb_encrypt_temporary_tables.test | 2 + mysql-test/suite/engines/funcs/t/ld_null.test | 4 + .../suite/engines/funcs/t/ld_quote.test | 2 + .../suite/engines/iuds/t/insert_calendar.test | 45 +++++++++++ .../suite/engines/iuds/t/insert_decimal.test | 18 +++++ .../suite/engines/iuds/t/insert_time.test | 3 + .../federated/federatedx_create_handlers.test | 5 ++ .../suite/funcs_1/datadict/datadict.pre | 2 + .../suite/funcs_1/datadict/datadict_load.inc | 2 + .../suite/funcs_1/datadict/is_tables.inc | 4 + .../suite/funcs_1/storedproc/param_check.inc | 4 + .../suite/funcs_1/t/is_basics_mixed.test | 4 + .../suite/funcs_1/t/row_count_func.test | 4 + .../suite/funcs_1/triggers/triggers_08.inc | 7 +- .../suite/funcs_1/triggers/triggers_09.inc | 14 ++++ mysql-test/suite/gcol/inc/gcol_ins_upd.inc | 2 + mysql-test/suite/gcol/inc/gcol_keys.inc | 2 + mysql-test/suite/gcol/t/gcol_bugfixes.test | 6 ++ .../gcol/t/innodb_virtual_debug_purge.test | 4 + mysql-test/suite/handler/ps.test | 4 + .../innodb/t/alter_inplace_perfschema.test | 4 + mysql-test/suite/innodb/t/group_commit.test | 2 + .../t/group_commit_no_optimize_thread.test | 2 + .../t/innodb-page_compression_none.test | 3 +- .../innodb/t/innodb-system-table-view.test | 2 + .../innodb/t/innodb_buffer_pool_load_now.test | 2 + .../suite/innodb/t/innodb_bug51920.test | 2 + mysql-test/suite/innodb/t/innodb_mysql.test | 2 + .../innodb/t/innodb_stats_persistent.test | 2 + mysql-test/suite/innodb/t/instant_alter.test | 6 ++ .../suite/innodb/t/instant_alter_bugs.test | 2 + mysql-test/suite/innodb/t/restart.test | 2 + .../suite/innodb/t/temp_table_savepoint.test | 2 + mysql-test/suite/innodb_fts/t/opt.test | 2 + mysql-test/suite/innodb_gis/t/1.test | 3 + mysql-test/suite/innodb_gis/t/gis.test | 5 ++ mysql-test/suite/json/t/json_no_table.test | 79 ++++++++++++++++++- mysql-test/suite/parts/inc/partition.pre | 4 + .../suite/parts/inc/partition_alter3.inc | 2 + .../suite/parts/inc/partition_check.inc | 26 ++++++ .../suite/parts/inc/partition_check_read.inc | 6 ++ .../suite/parts/inc/partition_check_read1.inc | 6 ++ .../suite/parts/inc/partition_check_read2.inc | 6 ++ .../parts/inc/partition_layout_check2.inc | 2 + .../suite/parts/inc/partition_trigg1.inc | 4 + .../suite/parts/inc/partition_trigg3.inc | 2 + .../perfschema/t/alter_table_progress.test | 4 + .../suite/perfschema/t/dml_handler.test | 4 + .../perfschema/t/hostcache_ipv4_blocked.test | 2 + .../perfschema/t/hostcache_ipv4_max_con.test | 2 + .../perfschema/t/hostcache_ipv6_blocked.test | 2 + .../suite/perfschema/t/query_cache.test | 4 + .../suite/perfschema/t/rpl_threads.test | 6 ++ .../suite/perfschema/t/socket_connect.test | 2 + .../perfschema/t/socket_instances_func.test | 20 +++++ .../t/socket_instances_func_win.test | 12 +++ .../t/socket_summary_by_event_name_func.test | 5 +- .../suite/perfschema/t/table_schema.test | 8 ++ .../suite/perfschema/t/thread_cache.test | 8 ++ .../suite/perfschema/t/threads_mysql.test | 2 + mysql-test/suite/period/t/overlaps.test | 4 + mysql-test/suite/period/t/versioning.test | 6 ++ .../suite/plugins/t/feedback_plugin_load.test | 2 + mysql-test/suite/plugins/t/qc_info.test | 2 + mysql-test/suite/plugins/t/qc_info_init.inc | 4 + .../suite/roles/grant_revoke_current.test | 3 + .../suite/roles/set_default_role_ps-6960.test | 2 + mysql-test/suite/rpl/include/check_type.inc | 2 + .../rpl/include/rpl_innodb_rows_counters.inc | 2 + .../rpl/include/rpl_stop_middle_group.test | 6 ++ mysql-test/suite/rpl/t/rpl_binlog_errors.test | 4 + .../suite/rpl/t/rpl_checksum_cache.test | 4 + mysql-test/suite/rpl/t/rpl_do_grant.test | 2 + mysql-test/suite/rpl/t/rpl_drop_db.test | 2 + .../rpl/t/rpl_filter_tables_not_exist.test | 6 ++ mysql-test/suite/rpl/t/rpl_gtid_mdev4484.test | 2 + .../suite/rpl/t/rpl_innodb_bug68220.test | 2 + .../suite/rpl/t/rpl_loaddata_local.test | 14 ++++ mysql-test/suite/rpl/t/rpl_loaddata_map.test | 2 + mysql-test/suite/rpl/t/rpl_loadfile.test | 2 + mysql-test/suite/rpl/t/rpl_mdev12179.test | 2 + .../suite/rpl/t/rpl_misc_functions.test | 6 ++ mysql-test/suite/rpl/t/rpl_parallel_seq.test | 2 + .../suite/rpl/t/rpl_stm_found_rows.test | 8 ++ mysql-test/suite/rpl/t/rpl_temporary.test | 2 + mysql-test/suite/rpl/t/rpl_xa.inc | 5 +- .../t/innodb_buffer_pool_dump_now_basic.test | 2 + ...nnodb_fil_make_page_dirty_debug_basic.test | 2 + .../t/innodb_log_optimize_ddl_basic.test | 2 + .../innodb_saved_page_number_debug_basic.test | 2 + .../t/log_slow_disabled_statements_func.test | 8 ++ .../sys_vars/t/query_cache_limit_func.test | 4 + .../sys_vars/t/query_cache_type_func.test | 4 + .../suite/sys_vars/t/secure_file_priv.test | 3 + .../sys_vars/t/sql_buffer_result_func.test | 6 ++ mysql-test/suite/vcol/t/load_data.test | 2 + mysql-test/suite/vcol/t/vcol_keys_myisam.test | 2 + mysql-test/suite/versioning/common.inc | 2 + mysql-test/suite/versioning/t/alter.test | 2 + mysql-test/suite/versioning/t/commit_id.test | 14 ++++ mysql-test/suite/versioning/t/create.test | 8 ++ mysql-test/suite/versioning/t/cte.test | 4 + mysql-test/suite/versioning/t/delete.test | 2 + mysql-test/suite/versioning/t/foreign.test | 10 +++ mysql-test/suite/versioning/t/insert.test | 2 + mysql-test/suite/versioning/t/insert2.test | 2 + mysql-test/suite/versioning/t/load_data.test | 2 + mysql-test/suite/versioning/t/partition.test | 4 + mysql-test/suite/versioning/t/select.test | 12 +++ mysql-test/suite/versioning/t/select2.test | 4 + mysql-test/suite/versioning/t/simple.test | 4 + mysql-test/suite/versioning/t/trx_id.test | 12 +++ mysql-test/suite/versioning/t/update.test | 10 +++ mysql-test/suite/versioning/t/view.test | 4 + .../mysql-test/type_inet/type_inet6.test | 6 ++ .../mysql-test/connect/t/bson_udf.test | 3 + .../mysql-test/connect/t/json_udf.test | 6 ++ .../alter_table_add_column_flags_comment.test | 3 + ...lter_table_add_column_flags_parameter.test | 3 + ...table_add_column_groonga_type_comment.test | 3 + ...ble_add_column_groonga_type_parameter.test | 3 + ...lter_table_add_column_multibyte_cp932.test | 3 + ...alter_table_add_column_multibyte_utf8.test | 3 + .../alter_table_add_column_type_comment.test | 3 + ..._index_token_filters_one_token_filter.test | 3 + .../t/alter_table_change_token_filter.test | 3 + ...ter_table_disable_keys_fulltext_table.test | 3 + ...lter_table_enable_keys_fulltext_table.test | 3 + ...nga_index_fulltext_vector_other_table.test | 3 + .../column_groonga_index_int_other_table.test | 3 + .../storage/t/column_multibyte_cp932.test | 3 + .../storage/t/column_multibyte_utf8.test | 3 + .../t/create_table_column_flags_comment.test | 3 + .../create_table_column_flags_parameter.test | 3 + ...ate_table_column_groonga_type_comment.test | 3 + ...e_table_column_groonga_type_parameter.test | 3 + .../t/create_table_column_type_comment.test | 3 + .../t/create_table_default_tokenizer.test | 3 + ...eate_table_index_normalizer_index_bin.test | 3 + ..._token_filters_multiple_token_filters.test | 3 + ..._index_token_filters_one_token_filter.test | 3 + ...e_table_index_token_filters_parameter.test | 3 + ..._token_filters_multiple_token_filters.test | 3 + ..._table_token_filters_one_token_filter.test | 3 + .../t/foreign_key_delete_existent.test | 3 + .../t/foreign_key_delete_nonexistent.test | 3 + .../t/foreign_key_insert_existent.test | 3 + .../t/foreign_key_insert_nonexistent.test | 3 + .../t/foreign_key_update_existent.test | 3 + .../t/foreign_key_update_nonexistent.test | 3 + .../t/function_command_auto-escape.test | 3 + ...unction_command_special-database-name.test | 3 + ...nction_highlight_html_dynamic_keyword.test | 3 + ...tion_highlight_html_multiple_keywords.test | 3 + .../t/function_highlight_html_normalizer.test | 3 + .../storage/t/function_normalize_default.test | 3 + .../t/function_normalize_normalizer.test | 3 + ...function_snippet_html_dynamic_keyword.test | 3 + ...nction_snippet_html_multiple_keywords.test | 3 + ...lter_table_add_column_multibyte_cp932.test | 3 + ...alter_table_add_column_multibyte_utf8.test | 3 + .../wrapper/t/column_multibyte_cp932.test | 3 + .../wrapper/t/column_multibyte_utf8.test | 3 + .../t/create_table_comment_combined.test | 3 + ..._filters_index_multiple_token_filters.test | 3 + ..._token_filters_index_one_token_filter.test | 3 + ...e_table_token_filters_index_parameter.test | 3 + .../rocksdb/include/group_min_max.inc | 2 + .../rocksdb/t/2pc_group_commit.test | 12 +++ .../mysql-test/rocksdb/t/autoinc_debug.test | 8 ++ .../rocksdb/t/autoinc_vars_thread_2.test | 2 + .../mysql-test/rocksdb/t/bloomfilter3.test | 18 +++++ .../rocksdb/t/bloomfilter_bulk_load.test | 4 + .../mysql-test/rocksdb/t/cardinality.test | 6 ++ .../mysql-test/rocksdb/t/drop_table3.inc | 2 + .../mysql-test/rocksdb/t/handler_basic.test | 4 + .../mysql-test/rocksdb/t/hermitage.inc | 2 + .../mysql-test/rocksdb/t/no_merge_sort.test | 2 + .../mysql-test/rocksdb/t/perf_context.test | 4 + .../rocksdb/t/prefix_extractor_override.test | 10 +++ .../mysql-test/rocksdb/t/read_only_tx.test | 2 + .../mysql-test/rocksdb/t/rocksdb_qcache.test | 2 + .../rocksdb/t/rocksdb_row_stats.test | 2 + .../rocksdb/mysql-test/rocksdb/t/select.test | 2 + .../rocksdb/t/show_table_status.test | 6 ++ .../mysql-test/rocksdb/t/singledelete.test | 10 +++ .../mysql-test/rocksdb/t/ttl_primary.test | 4 + .../rocksdb/t/ttl_primary_read_filtering.test | 18 +++++ .../mysql-test/rocksdb/t/ttl_secondary.test | 4 + .../t/ttl_secondary_read_filtering.test | 4 + .../t/type_char_indexes_collation.test | 4 + .../mysql-test/rocksdb/t/type_float.inc | 3 + .../spider/regression/e1121/t/load_data.inc | 4 + .../regression/e112122/t/load_data_part.inc | 4 + .../rpl_tests/rpl_parallel_load_tokudb.test | 2 + .../r/rpl_tokudb_update_pk_uc1_lookup1.result | 2 + .../rpl/t/rpl_parallel_tokudb_delete_pk.test | 4 + .../rpl/t/rpl_tokudb_delete_pk.test | 4 + .../rpl/t/rpl_tokudb_delete_pk_lookup1.test | 4 + .../rpl/t/rpl_tokudb_read_only_ff.test | 2 + .../rpl/t/rpl_tokudb_read_only_ft.test | 2 + .../rpl/t/rpl_tokudb_read_only_tf.test | 2 + .../rpl/t/rpl_tokudb_read_only_tt.test | 2 + .../t/rpl_tokudb_update_pk_uc0_lookup0.test | 4 + .../t/rpl_tokudb_update_pk_uc0_lookup1.test | 4 + .../t/rpl_tokudb_update_pk_uc1_lookup0.test | 4 + .../t/rpl_tokudb_update_pk_uc1_lookup1.test | 4 + .../rpl_tokudb_update_unique_uc0_lookup0.test | 4 + .../rpl_tokudb_update_unique_uc0_lookup1.test | 4 + .../mysql-test/rpl/t/rpl_tokudb_write_pk.test | 2 + .../rpl/t/rpl_tokudb_write_pk_uc1.test | 2 + .../rpl/t/rpl_tokudb_write_unique.test | 2 + .../rpl/t/rpl_tokudb_write_unique_uc1.test | 2 + .../mysql-test/tokudb/t/ext_key_1_innodb.test | 3 + .../mysql-test/tokudb/t/ext_key_1_tokudb.test | 3 + .../mysql-test/tokudb/t/ext_key_2_innodb.test | 3 + .../mysql-test/tokudb/t/ext_key_2_tokudb.test | 3 + .../mysql-test/tokudb/t/rows-32m-0.test | 2 + .../mysql-test/tokudb/t/rows-32m-1.test | 2 + .../tokudb/t/rows-32m-rand-insert.test | 2 + .../tokudb/t/rows-32m-seq-insert.test | 2 + .../tokudb/mysql-test/tokudb/t/type_date.test | 3 + .../mysql-test/tokudb/t/type_float.test | 2 + .../mysql-test/tokudb/t/type_newdecimal.test | 6 ++ .../tokudb/t/type_temporal_fractional.test | 6 ++ .../tokudb/mysql-test/tokudb/t/type_year.test | 3 + .../t/falcon_bug_23818_A.test | 2 + .../t/falcon_bug_23818_B.test | 2 + .../t/falcon_bug_23818_C.test | 2 + 366 files changed, 1799 insertions(+), 30 deletions(-) diff --git a/mysql-test/include/commit.inc b/mysql-test/include/commit.inc index 132fdcff7bd..dbbd7459b52 100644 --- a/mysql-test/include/commit.inc +++ b/mysql-test/include/commit.inc @@ -258,8 +258,10 @@ select * from t2; insert into t2 (a) values (1025); --replace_result $MYSQLTEST_VARDIR .. +--disable_cursor_protocol --error ER_DUP_ENTRY eval select f2(25) into outfile "$MYSQLTEST_VARDIR/tmp/dml.out" from t1; +--enable_cursor_protocol select * from t2; rollback; select * from t2; @@ -279,8 +281,10 @@ select * from t2; --echo ======================================================================= insert into t2 (a) values (1027); +--disable_cursor_protocol --error ER_DUP_ENTRY select f2(27) into @foo; +--enable_cursor_protocol select * from t2; rollback; select * from t2; diff --git a/mysql-test/include/ctype_like_range_f1f2.inc b/mysql-test/include/ctype_like_range_f1f2.inc index def341e8d5e..59f668bfbba 100644 --- a/mysql-test/include/ctype_like_range_f1f2.inc +++ b/mysql-test/include/ctype_like_range_f1f2.inc @@ -17,6 +17,8 @@ INSERT INTO t1 (a, b) VALUES (2, repeat(0xF1F2,10)); INSERT INTO t1 (a, b) VALUES (3, repeat(0xF1F2,11)); INSERT INTO t1 (a, b) VALUES (4, repeat(0xF1F2,12)); +#enable after fix MDEV-31512 +--disable_cursor_protocol #check after fix MDEV-29290 --disable_view_protocol # Check pattern (important for ucs2, utf16, utf32) @@ -24,5 +26,6 @@ SELECT hex(concat(repeat(0xF1F2, 10), '%')); --echo 3 rows expected SELECT a, hex(b), c FROM t1 WHERE b LIKE concat(repeat(0xF1F2,10), '%'); -DROP TABLE t1; +--enable_cursor_protocol --enable_view_protocol +DROP TABLE t1; diff --git a/mysql-test/include/ctype_numconv.inc b/mysql-test/include/ctype_numconv.inc index ee60c9196e2..254868e1fd7 100644 --- a/mysql-test/include/ctype_numconv.inc +++ b/mysql-test/include/ctype_numconv.inc @@ -1646,7 +1646,10 @@ SELECT GROUP_CONCAT(IF(a,a,'')) FROM t1; SELECT GROUP_CONCAT(CASE WHEN a THEN a ELSE '' END) FROM t1; --disable_view_protocol --enable_metadata +#Check after fix MDEV-31512 +--disable_cursor_protocol SELECT COALESCE(a,'') FROM t1 GROUP BY 1; +--enable_cursor_protocol --disable_metadata --enable_view_protocol --echo # All columns must be VARCHAR(9) with the same length: diff --git a/mysql-test/include/diff_tables.inc b/mysql-test/include/diff_tables.inc index a566a4d79c2..331f5c18a02 100644 --- a/mysql-test/include/diff_tables.inc +++ b/mysql-test/include/diff_tables.inc @@ -168,7 +168,9 @@ while ($_dt_tables) --disable_ps2_protocol --let $_dt_outfile= `SELECT @@datadir` --let $_dt_outfile= $_dt_outfile/diff_table-$_dt_connection-$_dt_database-$_dt_table + --disable_cursor_protocol eval SELECT * INTO OUTFILE '$_dt_outfile' FROM $_dt_database.$_dt_table ORDER BY `$_dt_column_list`; + --enable_cursor_protocol --enable_ps2_protocol # Compare files. diff --git a/mysql-test/include/explain_utils.inc b/mysql-test/include/explain_utils.inc index d729be94f49..eb0558da3c8 100644 --- a/mysql-test/include/explain_utils.inc +++ b/mysql-test/include/explain_utils.inc @@ -28,6 +28,7 @@ --echo # --disable_ps2_protocol --disable_view_protocol +--disable_cursor_protocol if ($select) { --disable_query_log --eval $select INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/before_explain.txt' @@ -160,5 +161,6 @@ SHOW STATUS WHERE (Variable_name LIKE 'Sort%' OR --enable_query_log --echo +--enable_cursor_protocol --enable_view_protocol --enable_ps2_protocol diff --git a/mysql-test/include/function_defaults.inc b/mysql-test/include/function_defaults.inc index e8e1059f4be..86ccb697d28 100644 --- a/mysql-test/include/function_defaults.inc +++ b/mysql-test/include/function_defaults.inc @@ -824,6 +824,7 @@ eval CREATE TABLE t2 ( i $datetime DEFAULT $current_timestamp ON UPDATE $current_timestamp NOT NULL ); +--disable_cursor_protocol --disable_ps2_protocol SELECT 1 INTO OUTFILE 't3.dat' FROM dual; @@ -833,6 +834,7 @@ FROM dual; SELECT 1, 2 INTO OUTFILE 't5.dat' FROM dual; --enable_ps2_protocol +--enable_cursor_protocol --echo # Mon Aug 1 15:11:19 2011 UTC SET TIMESTAMP = 1312211479.918273; @@ -931,11 +933,13 @@ remove_file $MYSQLD_DATADIR/test/t5.dat; --echo # Mon Aug 1 15:11:19 2011 UTC SET TIMESTAMP = 1312211479.089786; +--disable_cursor_protocol --disable_ps2_protocol SELECT 1 INTO OUTFILE "file1.dat" FROM dual; SELECT NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL INTO OUTFILE "file2.dat" FROM dual; --enable_ps2_protocol +--enable_cursor_protocol --echo # Too short row diff --git a/mysql-test/include/grant_cache.inc b/mysql-test/include/grant_cache.inc index 69c520c3e61..5a9fa8f0ec0 100644 --- a/mysql-test/include/grant_cache.inc +++ b/mysql-test/include/grant_cache.inc @@ -55,6 +55,7 @@ set LOCAL query_cache_type=ON; set GLOBAL query_cache_size=1355776; --disable_ps2_protocol +--disable_cursor_protocol reset query cache; flush status; @@ -173,6 +174,7 @@ show status like "Qcache_queries_in_cache"; show status like "Qcache_hits"; show status like "Qcache_not_cached"; +--enable_cursor_protocol --enable_ps2_protocol # Cleanup diff --git a/mysql-test/include/ps_conv.inc b/mysql-test/include/ps_conv.inc index 2b7af82907c..9facff43ec9 100644 --- a/mysql-test/include/ps_conv.inc +++ b/mysql-test/include/ps_conv.inc @@ -206,6 +206,7 @@ execute full_info ; --error 1064 prepare stmt1 from "select ? := c1 from t9 where c1= 1" ; +--disable_cursor_protocol --disable_query_log select '------ select column, .. into @parm,.. ------' as test_sequence ; --enable_query_log @@ -243,6 +244,7 @@ into @arg01, @arg02, @arg03, @arg04, @arg05, @arg06, @arg07, @arg08, @arg17, @arg18, @arg19, @arg20, @arg21, @arg22, @arg23, @arg24, @arg25, @arg26, @arg27, @arg28, @arg29, @arg30, @arg31, @arg32 from t9 where c1= ?" ; +--enable_cursor_protocol set @my_key= 1 ; execute stmt1 using @my_key ; # get as much information about the parameters as possible diff --git a/mysql-test/include/query_cache.inc b/mysql-test/include/query_cache.inc index 0f52b70b7f2..ba9c256005a 100644 --- a/mysql-test/include/query_cache.inc +++ b/mysql-test/include/query_cache.inc @@ -28,6 +28,7 @@ drop table if exists t1,t2,t3; set @save_query_cache_size = @@global.query_cache_size; set GLOBAL query_cache_size = 1355776; +--disable_cursor_protocol # # Without auto_commit. # @@ -86,6 +87,7 @@ show status like "Qcache_hits"; commit; show status like "Qcache_queries_in_cache"; drop table t3,t2,t1; +--enable_cursor_protocol eval CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY (id))$partitions_id; select count(*) from t1; @@ -128,6 +130,7 @@ connection default; # This should be 'YES'. SHOW VARIABLES LIKE 'have_query_cache'; +--disable_cursor_protocol SET GLOBAL query_cache_size = 204800; flush status; SET @@autocommit=1; @@ -190,6 +193,7 @@ disconnect connection1; connection default; set @@global.query_cache_size = @save_query_cache_size; drop table t2; +--enable_cursor_protocol SET global query_cache_type=default; --enable_view_protocol diff --git a/mysql-test/include/query_cache_partitions.inc b/mysql-test/include/query_cache_partitions.inc index 6c51300a5d5..3e861b5fe29 100644 --- a/mysql-test/include/query_cache_partitions.inc +++ b/mysql-test/include/query_cache_partitions.inc @@ -45,9 +45,11 @@ show status like "Qcache_queries_in_cache"; show status like "Qcache_hits"; --disable_ps2_protocol +--disable_cursor_protocol SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1; SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1; SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1; +--enable_cursor_protocol show status like "Qcache_queries_in_cache"; show status like "Qcache_hits"; @@ -81,9 +83,11 @@ show status like "Qcache_queries_in_cache"; show status like "Qcache_hits"; --disable_ps2_protocol +--disable_cursor_protocol SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1; SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1; SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1; +--enable_cursor_protocol show status like "Qcache_queries_in_cache"; show status like "Qcache_hits"; @@ -118,6 +122,7 @@ show status like "Qcache_queries_in_cache"; show status like "Qcache_hits"; --disable_ps2_protocol +--disable_cursor_protocol BEGIN; UPDATE `t1` SET `cool` = 1 WHERE `id` = 1; SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1; @@ -127,6 +132,7 @@ BEGIN; SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1; ROLLBACK; SELECT cool FROM `t1` WHERE (`t1`.id = 1) LIMIT 1; +--enable_cursor_protocol show status like "Qcache_queries_in_cache"; show status like "Qcache_hits"; diff --git a/mysql-test/include/test_outfile.inc b/mysql-test/include/test_outfile.inc index e50847b67a3..af64cc6ba5f 100644 --- a/mysql-test/include/test_outfile.inc +++ b/mysql-test/include/test_outfile.inc @@ -1,3 +1,5 @@ +--disable_cursor_protocol --disable_ps2_protocol eval select "Outfile OK" into outfile "$MYSQLTEST_VARDIR/tmp/outfile.test"; --enable_ps2_protocol +--enable_cursor_protocol diff --git a/mysql-test/include/type_temporal_zero_default.inc b/mysql-test/include/type_temporal_zero_default.inc index 6553bfb6d86..4cc36ad572c 100644 --- a/mysql-test/include/type_temporal_zero_default.inc +++ b/mysql-test/include/type_temporal_zero_default.inc @@ -35,7 +35,9 @@ SET sql_mode=DEFAULT; --eval INSERT INTO t1 VALUES (DEFAULT,DEFAULT); --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --disable_ps2_protocol +--disable_cursor_protocol --eval SELECT a INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/mdev-7824.txt' FROM t1 +--enable_cursor_protocol DELETE FROM t1; --enable_ps2_protocol SET sql_mode=TRADITIONAL; diff --git a/mysql-test/include/write_var_to_file.inc b/mysql-test/include/write_var_to_file.inc index 58bdac6f09e..1579b5b21e7 100644 --- a/mysql-test/include/write_var_to_file.inc +++ b/mysql-test/include/write_var_to_file.inc @@ -46,9 +46,11 @@ if (`SELECT LENGTH(@@secure_file_priv) > 0`) --let $_wvtf_suffix= `SELECT UUID()` --let $_wvtf_tmp_file= $MYSQLTEST_VARDIR/_wvtf_$_wvtf_suffix + --disable_cursor_protocol --disable_ps2_protocol --eval SELECT '$write_var' INTO DUMPFILE '$_wvtf_tmp_file' --enable_ps2_protocol + --enable_cursor_protocol --copy_file $_wvtf_tmp_file $write_to_file --remove_file $_wvtf_tmp_file } diff --git a/mysql-test/main/alter_table.test b/mysql-test/main/alter_table.test index d3d588149e0..f6755ada733 100644 --- a/mysql-test/main/alter_table.test +++ b/mysql-test/main/alter_table.test @@ -985,6 +985,7 @@ while ($count) commit; --enable_query_log +--disable_cursor_protocol select index_length into @unpaked_keys_size from information_schema.tables where table_name='t1'; alter table t1 pack_keys=1; @@ -998,6 +999,7 @@ alter table t1 max_rows=100; select max_data_length into @changed_max_data_length from information_schema.tables where table_name='t1'; select (@orig_max_data_length > @changed_max_data_length); +--enable_cursor_protocol drop table t1; diff --git a/mysql-test/main/alter_user.test b/mysql-test/main/alter_user.test index 95e6d732907..6f4f9fb1e1e 100644 --- a/mysql-test/main/alter_user.test +++ b/mysql-test/main/alter_user.test @@ -1,6 +1,8 @@ --source include/not_embedded.inc +--disable_cursor_protocol select priv into @root_priv from mysql.global_priv where user='root' and host='localhost'; +--enable_cursor_protocol select * from mysql.user where user = 'root' and host = 'localhost'; --echo # Test syntax diff --git a/mysql-test/main/auto_increment_ranges_innodb.test b/mysql-test/main/auto_increment_ranges_innodb.test index 3abd8d4d482..927954216c7 100644 --- a/mysql-test/main/auto_increment_ranges_innodb.test +++ b/mysql-test/main/auto_increment_ranges_innodb.test @@ -11,9 +11,11 @@ set default_storage_engine=innodb; # create table t1 (pk int auto_increment primary key, f varchar(20)); insert t1 (f) values ('a'), ('b'), ('c'), ('d'); +--disable_cursor_protocol --disable_ps2_protocol select null, f into outfile 'load.data' from t1 limit 1; --enable_ps2_protocol +--enable_cursor_protocol load data infile 'load.data' into table t1; insert t1 (f) values ('<==='); select * from t1; diff --git a/mysql-test/main/bootstrap.test b/mysql-test/main/bootstrap.test index b334db504f9..b3c0494fc2b 100644 --- a/mysql-test/main/bootstrap.test +++ b/mysql-test/main/bootstrap.test @@ -45,9 +45,11 @@ remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_error.sql; --echo # --disable_query_log create table t1 select 2 as a, concat(repeat('MySQL', @@max_allowed_packet/10), ';') as b; +--disable_cursor_protocol --disable_ps2_protocol eval select * into outfile '$MYSQLTEST_VARDIR/tmp/long_query.sql' from t1; --enable_ps2_protocol +--enable_cursor_protocol --enable_query_log --source include/kill_mysqld.inc --error 1 diff --git a/mysql-test/main/bug12427262.test b/mysql-test/main/bug12427262.test index aca37a651c4..e1917aaa201 100644 --- a/mysql-test/main/bug12427262.test +++ b/mysql-test/main/bug12427262.test @@ -20,6 +20,7 @@ create table t9 (c1 int); create table t10 (c1 int); --enable_warnings +--disable_cursor_protocol # Query PS to know initial read count for frm file. select Sum(ALL(COUNT_READ)) from performance_schema.file_summary_by_instance where FILE_NAME like "%show_table_lw_db%" AND FILE_NAME like "%.frm%" AND EVENT_NAME='wait/io/file/sql/FRM' @@ -32,16 +33,19 @@ show tables; select Sum(ALL(COUNT_READ)) from performance_schema.file_summary_by_instance where FILE_NAME like "%show_table_lw_db%" AND FILE_NAME like "%.frm%" AND EVENT_NAME='wait/io/file/sql/FRM' into @count_read_after; +--enable_cursor_protocol select @count_read_after-@count_read_before; show full tables; +--disable_cursor_protocol # Query PS to know read count for frm file after above query. COUNT_READ # will be incremented by 1 as FRM file will be opened for above query. select Sum(ALL(COUNT_READ)) from performance_schema.file_summary_by_instance where FILE_NAME like "%show_table_lw_db%" AND FILE_NAME like "%.frm%" AND EVENT_NAME='wait/io/file/sql/FRM' into @count_read_after; +--enable_cursor_protocol select @count_read_after-@count_read_before; diff --git a/mysql-test/main/count_distinct2.test b/mysql-test/main/count_distinct2.test index f5d16527af3..0ab8169098f 100644 --- a/mysql-test/main/count_distinct2.test +++ b/mysql-test/main/count_distinct2.test @@ -62,6 +62,7 @@ while ($1) commit; --enable_query_log +--disable_cursor_protocol flush status; select count(distinct n) from t1; show status like 'Created_tmp_disk_tables'; @@ -83,6 +84,7 @@ flush status; select count(distinct s) from t1; show status like 'Created_tmp_disk_tables'; drop table t1; +--enable_cursor_protocol --enable_ps2_protocol # End of 4.1 tests diff --git a/mysql-test/main/ctype_big5.test b/mysql-test/main/ctype_big5.test index adea12eb6d0..4b6203a2577 100644 --- a/mysql-test/main/ctype_big5.test +++ b/mysql-test/main/ctype_big5.test @@ -77,9 +77,11 @@ select hex(convert(_big5 0xC84041 using ucs2)); set names big5; create table t1 (a blob); insert into t1 values (0xEE00); +--disable_cursor_protocol --disable_ps2_protocol select * into outfile 'test/t1.txt' from t1; --enable_ps2_protocol +--enable_cursor_protocol delete from t1; let $MYSQLD_DATADIR= `select @@datadir`; --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR diff --git a/mysql-test/main/ctype_binary.test b/mysql-test/main/ctype_binary.test index 26618ec235b..756c96fcf60 100644 --- a/mysql-test/main/ctype_binary.test +++ b/mysql-test/main/ctype_binary.test @@ -1,3 +1,4 @@ + set names binary; --source include/ctype_numconv.inc @@ -232,8 +233,11 @@ SELECT DATE_FORMAT('2004-02-02','%W'); SELECT HEX(DATE_FORMAT('2004-02-02','%W')); #Enable after fix MDEV-33936 --disable_view_protocol +#enable after fix MDEV-34215 +--disable_cursor_protocol SELECT DATE_FORMAT(TIME'-01:01:01','%h'); SELECT HEX(DATE_FORMAT(TIME'-01:01:01','%h')); +--enable_cursor_protocol --enable_view_protocol --echo # latin1 format, binary result @@ -241,8 +245,11 @@ SELECT DATE_FORMAT('2004-02-02',_latin1'%W'); SELECT HEX(DATE_FORMAT('2004-02-02',_latin1'%W')); #Enable after fix MDEV-33936 --disable_view_protocol +#enable after fix MDEV-34215 +--disable_cursor_protocol SELECT DATE_FORMAT(TIME'-01:01:01',_latin1'%h'); SELECT HEX(DATE_FORMAT(TIME'-01:01:01',_latin1'%h')); +--enable_cursor_protocol --enable_view_protocol --echo # Binary format, latin1 result @@ -251,8 +258,11 @@ SELECT DATE_FORMAT('2004-02-02',_binary'%W'); SELECT HEX(DATE_FORMAT('2004-02-02',_binary'%W')); #Enable after fix MDEV-33936 --disable_view_protocol +#enable after fix MDEV-34215 +--disable_cursor_protocol SELECT DATE_FORMAT(TIME'-01:01:01',_binary'%h'); SELECT HEX(DATE_FORMAT(TIME'-01:01:01',_binary'%h')); +--enable_cursor_protocol --enable_view_protocol --echo # --echo # End of 10.4 tests diff --git a/mysql-test/main/ctype_filename.test b/mysql-test/main/ctype_filename.test index 185d4ca641a..83d1a7a5d5b 100644 --- a/mysql-test/main/ctype_filename.test +++ b/mysql-test/main/ctype_filename.test @@ -20,10 +20,13 @@ drop table com1; create table `clock$` (a int); drop table `clock$`; +# Enable after fix MDEV-31553 +--disable_cursor_protocol # Enable after fix MDEV-29295 --disable_view_protocol select convert(convert(',' using filename) using binary); --enable_view_protocol +--enable_cursor_protocol --echo # --echo # MDEV-7677 my_charset_handler_filename has a wrong "ismbchar" member diff --git a/mysql-test/main/ctype_gbk.test b/mysql-test/main/ctype_gbk.test index ba41b177b44..9f6f6672952 100644 --- a/mysql-test/main/ctype_gbk.test +++ b/mysql-test/main/ctype_gbk.test @@ -64,8 +64,10 @@ CREATE TABLE t1(a MEDIUMTEXT CHARACTER SET gbk, INSERT INTO t1 VALUES (REPEAT(0x1125,200000), REPEAT(0x1125,200000)), ('', ''), ('', ''); +--disable_cursor_protocol SELECT a FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll; SELECT b FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll; +--enable_cursor_protocol DROP TABLES t1; diff --git a/mysql-test/main/ctype_ucs.test b/mysql-test/main/ctype_ucs.test index 708af6baf8a..7144f0af5cc 100644 --- a/mysql-test/main/ctype_ucs.test +++ b/mysql-test/main/ctype_ucs.test @@ -75,9 +75,11 @@ DROP TABLE t1; --echo # Problem # 1 (original report): wrong parsing of ucs2 data SET character_set_connection=ucs2; +--disable_cursor_protocol --disable_ps2_protocol SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp.txt'; --enable_ps2_protocol +--enable_cursor_protocol CREATE TABLE t1(a INT); LOAD DATA INFILE 'tmpp.txt' INTO TABLE t1 CHARACTER SET ucs2 (@b) SET a=REVERSE(@b); @@ -90,7 +92,9 @@ remove_file $MYSQLD_DATADIR/test/tmpp.txt; --disable_ps2_protocol --echo # Problem # 2 : if you write and read ucs2 data to a file they're lost +--disable_cursor_protocol SELECT '00' UNION SELECT '10' INTO OUTFILE 'tmpp2.txt' CHARACTER SET ucs2; +--enable_cursor_protocol --enable_ps2_protocol CREATE TABLE t1(a INT); LOAD DATA INFILE 'tmpp2.txt' INTO TABLE t1 CHARACTER SET ucs2 diff --git a/mysql-test/main/ctype_utf16.test b/mysql-test/main/ctype_utf16.test index 529b737fcfb..9f23f02b0fa 100644 --- a/mysql-test/main/ctype_utf16.test +++ b/mysql-test/main/ctype_utf16.test @@ -741,6 +741,8 @@ CREATE TABLE t1 ( s3 MEDIUMTEXT CHARACTER SET utf16, s4 LONGTEXT CHARACTER SET utf16 ); +#check after fix MDEV-31540 +--disable_cursor_protocol --disable_view_protocol --enable_metadata SET NAMES utf8, @@character_set_results=NULL; @@ -751,6 +753,7 @@ SET NAMES utf8; SELECT *, HEX(s1) FROM t1; --disable_metadata --enable_view_protocol +--enable_cursor_protocol CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1; SHOW CREATE TABLE t2; DROP TABLE t1, t2; diff --git a/mysql-test/main/ctype_utf16le.test b/mysql-test/main/ctype_utf16le.test index 537a456f7db..d0ccb2e8509 100644 --- a/mysql-test/main/ctype_utf16le.test +++ b/mysql-test/main/ctype_utf16le.test @@ -703,6 +703,8 @@ CREATE TABLE t1 ( s3 MEDIUMTEXT CHARACTER SET utf16le, s4 LONGTEXT CHARACTER SET utf16le ); +#check after fix MDEV-31540 +--disable_cursor_protocol --disable_view_protocol --enable_metadata SET NAMES utf8, @@character_set_results=NULL; @@ -713,6 +715,7 @@ SET NAMES utf8; SELECT *, HEX(s1) FROM t1; --disable_metadata --enable_view_protocol +--enable_cursor_protocol CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1; SHOW CREATE TABLE t2; DROP TABLE t1, t2; diff --git a/mysql-test/main/ctype_utf32.test b/mysql-test/main/ctype_utf32.test index 0e49302c776..f35a94e909c 100644 --- a/mysql-test/main/ctype_utf32.test +++ b/mysql-test/main/ctype_utf32.test @@ -795,6 +795,8 @@ CREATE TABLE t1 ( s3 MEDIUMTEXT CHARACTER SET utf32, s4 LONGTEXT CHARACTER SET utf32 ); +#check after fix MDEV-31540 +--disable_cursor_protocol --disable_view_protocol --enable_metadata SET NAMES utf8mb4, @@character_set_results=NULL; @@ -805,6 +807,7 @@ SET NAMES utf8mb4; SELECT *, HEX(s1) FROM t1; --disable_metadata --enable_view_protocol +--enable_cursor_protocol CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1; SHOW CREATE TABLE t2; DROP TABLE t1, t2; @@ -1131,8 +1134,11 @@ SELECT HEX(DATE_FORMAT(TIME'-01:01:01','%h')); --echo # utf8 format, utf32 result SELECT DATE_FORMAT('2004-02-02',_utf8'%W'); SELECT HEX(DATE_FORMAT('2004-02-02',_utf8'%W')); +#enable after fix MDEV-34215 +--disable_cursor_protocol SELECT DATE_FORMAT(TIME'-01:01:01',_utf8'%h'); SELECT HEX(DATE_FORMAT(TIME'-01:01:01',_utf8'%h')); +--enable_cursor_protocol --echo # utf32 format, utf8 result SET NAMES utf8; diff --git a/mysql-test/main/ctype_utf8.test b/mysql-test/main/ctype_utf8.test index 074a536f0f0..4bc01142b4c 100644 --- a/mysql-test/main/ctype_utf8.test +++ b/mysql-test/main/ctype_utf8.test @@ -1501,8 +1501,11 @@ SELECT HEX(LPAD(_utf8 0xD18F, 3, 0x20)); SELECT HEX(INSERT(_utf8 0xD18F, 2, 1, 0x20)); #Enable view-protocol after fix MDEV-33942 --disable_view_protocol +#Enable after fix MDEV-31512 +--disable_cursor_protocol SELECT HEX(INSERT(_utf8 0xD18FD18E, 2, 1, 0x20)); --enable_view_protocol +--enable_cursor_protocol --echo # --echo # Bug#11752408 - 43593: DUMP/BACKUP/RESTORE/UPGRADE TOOLS FAILS BECAUSE OF UTF8_GENERAL_CI @@ -1581,12 +1584,15 @@ CREATE TABLE t1 ( ); --disable_view_protocol --enable_metadata +#Check after fix MDEV-31512 +--disable_cursor_protocol SET NAMES utf8, @@character_set_results=NULL; SELECT *, HEX(s1) FROM t1; SET NAMES latin1; SELECT *, HEX(s1) FROM t1; SET NAMES utf8; SELECT *, HEX(s1) FROM t1; +--enable_cursor_protocol --disable_metadata --enable_view_protocol CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1; diff --git a/mysql-test/main/ctype_utf8mb4.test b/mysql-test/main/ctype_utf8mb4.test index 6361252ab80..3c6eab86126 100644 --- a/mysql-test/main/ctype_utf8mb4.test +++ b/mysql-test/main/ctype_utf8mb4.test @@ -1798,12 +1798,15 @@ CREATE TABLE t1 ( s4 LONGTEXT CHARACTER SET utf8mb4 ); --enable_metadata +#Check after fix MDEV-31512 +--disable_cursor_protocol SET NAMES utf8mb4, @@character_set_results=NULL; SELECT *, HEX(s1) FROM t1; SET NAMES latin1; SELECT *, HEX(s1) FROM t1; SET NAMES utf8mb4; SELECT *, HEX(s1) FROM t1; +--enable_cursor_protocol --disable_metadata CREATE TABLE t2 AS SELECT CONCAT(s1) FROM t1; SHOW CREATE TABLE t2; @@ -1953,7 +1956,9 @@ DROP TABLE t1; SET NAMES utf8mb4; SELECT COLUMN_JSON(COLUMN_CREATE(_utf8mb4 0xF09F988E, 1)); +--disable_cursor_protocol SELECT COLUMN_LIST(COLUMN_CREATE(_utf8mb4 0xF09F988E, 1)); +--enable_cursor_protocol SELECT COLUMN_GET(COLUMN_CREATE(_utf8mb4 0xF09F988E, 1), _utf8mb4 0xF09F988E as int); diff --git a/mysql-test/main/derived.test b/mysql-test/main/derived.test index 41ede6b440a..179cdd427d3 100644 --- a/mysql-test/main/derived.test +++ b/mysql-test/main/derived.test @@ -859,6 +859,8 @@ INSERT INTO example1463 VALUES ('David', 'Unknown', 100); INSERT INTO example1463 VALUES ('Edward', 'Success', 150); INSERT INTO example1463 VALUES ('Edward', 'Pending', 150); +#Enable after fix MDEV-31720 +--disable_cursor_protocol SELECT Customer, Success, SUM(OrderSize) FROM (SELECT Customer, CASE WHEN DeliveryStatus='Success' THEN 'Yes' ELSE 'No' END AS Success, @@ -866,6 +868,7 @@ SELECT Customer, Success, SUM(OrderSize) FROM example1463) as subQ GROUP BY Success, Customer WITH ROLLUP; +--enable_cursor_protocol SELECT Customer, Success, SUM(OrderSize) FROM (SELECT Customer, CASE WHEN DeliveryStatus='Success' THEN 'Yes' ELSE 'No' END AS Success, diff --git a/mysql-test/main/derived_view.test b/mysql-test/main/derived_view.test index 9747f1df61f..d26d2d6c535 100644 --- a/mysql-test/main/derived_view.test +++ b/mysql-test/main/derived_view.test @@ -42,6 +42,7 @@ explain extended select * from (select * from t1 where f1 in (2,3)) tt join (select * from t1 where f1 in (1,2)) aa on tt.f1=aa.f1; +--disable_cursor_protocol --disable_ps2_protocol flush status; explain extended @@ -51,6 +52,7 @@ flush status; select * from (select * from t1 where f1 in (2,3)) tt where f11=2; show status like 'Handler_read%'; --enable_ps2_protocol +--enable_cursor_protocol --echo for merged views create view v1 as select * from t1; @@ -72,12 +74,14 @@ explain extended select * from v3 join v4 on f1=f2; --disable_ps2_protocol +--disable_cursor_protocol flush status; explain extended select * from v4 where f2 in (1,3); show status like 'Handler_read%'; flush status; select * from v4 where f2 in (1,3); show status like 'Handler_read%'; +--enable_cursor_protocol --echo for materialized derived tables --echo explain for simple derived @@ -92,8 +96,10 @@ flush status; explain select * from t1 join (select * from t2 group by f2) tt on f1=f2; show status like 'Handler_read%'; flush status; +--disable_cursor_protocol select * from t1 join (select * from t2 group by f2) tt on f1=f2; show status like 'Handler_read%'; +--enable_cursor_protocol --enable_ps2_protocol --echo for materialized views @@ -110,6 +116,7 @@ explain extended select * from t1 join v2 on f1=f2; select * from t1 join v2 on f1=f2; explain extended select * from t1,v3 as v31,v3 where t1.f1=v31.f1 and t1.f1=v3.f1; +--disable_cursor_protocol --disable_ps2_protocol flush status; select * from t1,v3 as v31,v3 where t1.f1=v31.f1 and t1.f1=v3.f1; @@ -122,6 +129,7 @@ flush status; select * from t1 join v2 on f1=f2; show status like 'Handler_read%'; --enable_ps2_protocol +--enable_cursor_protocol explain extended select * from v1 join v4 on f1=f2; explain format=json select * from v1 join v4 on f1=f2; @@ -165,6 +173,7 @@ join (select * from (select * from t1 where f1 < 7 group by f1) tt where f1 > 2) z on x.f1 = z.f1; +--disable_cursor_protocol --disable_ps2_protocol flush status; select * from @@ -175,6 +184,7 @@ join show status like 'Handler_read%'; flush status; --enable_ps2_protocol +--enable_cursor_protocol --echo merged in merged derived join merged in merged derived explain extended select * from diff --git a/mysql-test/main/distinct.test b/mysql-test/main/distinct.test index 0658949597c..8935147e579 100644 --- a/mysql-test/main/distinct.test +++ b/mysql-test/main/distinct.test @@ -460,6 +460,7 @@ INSERT INTO t1 VALUES (2,2,'APPLE'); INSERT INTO t1 VALUES (3,2,'APPLE'); INSERT INTO t1 VALUES (4,3,'PEAR'); +--disable_cursor_protocol SELECT DISTINCT fruit_id, fruit_name INTO @v1, @v2 FROM t1 WHERE fruit_name = 'APPLE'; SELECT @v1, @v2; @@ -508,6 +509,7 @@ SELECT DISTINCT @v19:= fruit_id, @v20:= fruit_name INTO OUTFILE --enable_ps2_protocol LOAD DATA INFILE '../../tmp/data2.tmp' INTO TABLE t2; --remove_file $MYSQLTEST_VARDIR/tmp/data2.tmp +--enable_cursor_protocol SELECT @v19, @v20; SELECT * FROM t2; diff --git a/mysql-test/main/empty_table.test b/mysql-test/main/empty_table.test index 85638bc290b..3c6f418ccd4 100644 --- a/mysql-test/main/empty_table.test +++ b/mysql-test/main/empty_table.test @@ -6,6 +6,8 @@ drop table if exists t1; --enable_warnings +# Enable after fix MDEV-31721 +--disable_cursor_protocol create table t1 (nr int(5) not null auto_increment,b blob,str char(10), primary key (nr)); --disable_ps2_protocol select count(*) from t1; @@ -24,6 +26,7 @@ drop table t1; select * from t2; --enable_ps2_protocol show status like "Empty_queries"; +--enable_cursor_protocol --echo # End of 4.1 tests diff --git a/mysql-test/main/events_bugs.test b/mysql-test/main/events_bugs.test index fe744de86c9..3c4836af9e5 100644 --- a/mysql-test/main/events_bugs.test +++ b/mysql-test/main/events_bugs.test @@ -966,7 +966,9 @@ DROP USER evtest1@localhost; # scheduler to detect that --echo Sleep 4 seconds sleep 4; +--disable_cursor_protocol SELECT COUNT(*) INTO @row_cnt FROM events_test.event_log; +--enable_cursor_protocol # Give the event mechanism ~ 4 seconds to do something wrong # (execute the event of the dropped user -> inser rows). --echo Sleep 4 seconds @@ -1186,9 +1188,11 @@ drop procedure if exists p; set @old_mode= @@sql_mode; set @@sql_mode= cast(pow(2,32)-1 as unsigned integer); create event e1 on schedule every 1 day do select 1; +--disable_cursor_protocol select @@sql_mode into @full_mode; set @@sql_mode= @old_mode; select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mode; +--enable_cursor_protocol select name from mysql.event where name = 'e1' and sql_mode = @full_mode; drop event e1; diff --git a/mysql-test/main/explain.test b/mysql-test/main/explain.test index a546242d6aa..74459ce7bc3 100644 --- a/mysql-test/main/explain.test +++ b/mysql-test/main/explain.test @@ -48,7 +48,9 @@ set names latin1; # # Bug#15463: EXPLAIN SELECT..INTO hangs the client (QB, command line) # +--disable_cursor_protocol select 3 into @v1; +--enable_cursor_protocol explain select 3 into @v1; # @@ -154,7 +156,9 @@ DROP TABLE t1; CREATE TABLE t1 (f1 INT not null); +--disable_cursor_protocol SELECT @@session.sql_mode INTO @old_sql_mode; +--enable_cursor_protocol SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; # EXPLAIN EXTENDED (with subselect). used to crash. should give NOTICE. diff --git a/mysql-test/main/fast_prefix_index_fetch_innodb.test b/mysql-test/main/fast_prefix_index_fetch_innodb.test index 03b7275a1e3..98b1e4887c0 100644 --- a/mysql-test/main/fast_prefix_index_fetch_innodb.test +++ b/mysql-test/main/fast_prefix_index_fetch_innodb.test @@ -39,10 +39,12 @@ let $count = query_get_value($show_count_statement, Value, 1); let $opt = query_get_value($show_opt_statement, Value, 1); --disable_ps2_protocol +--disable_cursor_protocol --disable_query_log eval select $count - $base_count into @cluster_lookups; eval select $opt - $base_opt into @cluster_lookups_avoided; --enable_query_log +--enable_cursor_protocol select @cluster_lookups; select @cluster_lookups_avoided; @@ -56,10 +58,12 @@ select id, bigfield from prefixinno where bigfield = repeat('d', 31); let $count = query_get_value($show_count_statement, Value, 1); let $opt = query_get_value($show_opt_statement, Value, 1); +--disable_cursor_protocol --disable_query_log eval select $count - $base_count into @cluster_lookups; eval select $opt - $base_opt into @cluster_lookups_avoided; --enable_query_log +--enable_cursor_protocol select @cluster_lookups; select @cluster_lookups_avoided; @@ -73,10 +77,12 @@ select id, bigfield from prefixinno where fake_id = 1031; let $count = query_get_value($show_count_statement, Value, 1); let $opt = query_get_value($show_opt_statement, Value, 1); +--disable_cursor_protocol --disable_query_log eval select $count - $base_count into @cluster_lookups; eval select $opt - $base_opt into @cluster_lookups_avoided; --enable_query_log +--enable_cursor_protocol select @cluster_lookups; select @cluster_lookups_avoided; @@ -90,10 +96,12 @@ select id, bigfield from prefixinno where fake_id = 1033; let $count = query_get_value($show_count_statement, Value, 1); let $opt = query_get_value($show_opt_statement, Value, 1); +--disable_cursor_protocol --disable_query_log eval select $count - $base_count into @cluster_lookups; eval select $opt - $base_opt into @cluster_lookups_avoided; --enable_query_log +--enable_cursor_protocol select @cluster_lookups; select @cluster_lookups_avoided; @@ -107,10 +115,12 @@ select id, bigfield from prefixinno where bigfield = repeat('x', 32); let $count = query_get_value($show_count_statement, Value, 1); let $opt = query_get_value($show_opt_statement, Value, 1); +--disable_cursor_protocol --disable_query_log eval select $count - $base_count into @cluster_lookups; eval select $opt - $base_opt into @cluster_lookups_avoided; --enable_query_log +--enable_cursor_protocol select @cluster_lookups; select @cluster_lookups_avoided; @@ -124,10 +134,12 @@ select id, bigfield from prefixinno where bigfield = repeat('y', 33); let $count = query_get_value($show_count_statement, Value, 1); let $opt = query_get_value($show_opt_statement, Value, 1); +--disable_cursor_protocol --disable_query_log eval select $count - $base_count into @cluster_lookups; eval select $opt - $base_opt into @cluster_lookups_avoided; --enable_query_log +--enable_cursor_protocol select @cluster_lookups; select @cluster_lookups_avoided; @@ -141,10 +153,12 @@ select id, bigfield from prefixinno where bigfield = repeat('b', 8); let $count = query_get_value($show_count_statement, Value, 1); let $opt = query_get_value($show_opt_statement, Value, 1); +--disable_cursor_protocol --disable_query_log eval select $count - $base_count into @cluster_lookups; eval select $opt - $base_opt into @cluster_lookups_avoided; --enable_query_log +--enable_cursor_protocol select @cluster_lookups; select @cluster_lookups_avoided; @@ -158,10 +172,12 @@ select id, bigfield from prefixinno where bigfield = repeat('c', 24); let $count = query_get_value($show_count_statement, Value, 1); let $opt = query_get_value($show_opt_statement, Value, 1); +--disable_cursor_protocol --disable_query_log eval select $count - $base_count into @cluster_lookups; eval select $opt - $base_opt into @cluster_lookups_avoided; --enable_query_log +--enable_cursor_protocol select @cluster_lookups; select @cluster_lookups_avoided; @@ -175,10 +191,12 @@ select id, bigfield from prefixinno where bigfield = repeat('z', 128); let $count = query_get_value($show_count_statement, Value, 1); let $opt = query_get_value($show_opt_statement, Value, 1); +--disable_cursor_protocol --disable_query_log eval select $count - $base_count into @cluster_lookups; eval select $opt - $base_opt into @cluster_lookups_avoided; --enable_query_log +--disable_cursor_protocol select @cluster_lookups; select @cluster_lookups_avoided; @@ -193,10 +211,12 @@ select id, bigfield from prefixinno where fake_id = 1033; let $count = query_get_value($show_count_statement, Value, 1); let $opt = query_get_value($show_opt_statement, Value, 1); +--disable_cursor_protocol --disable_query_log eval select $count - $base_count into @cluster_lookups; eval select $opt - $base_opt into @cluster_lookups_avoided; --enable_query_log +--enable_cursor_protocol select @cluster_lookups; select @cluster_lookups_avoided; diff --git a/mysql-test/main/flush_ssl.test b/mysql-test/main/flush_ssl.test index e7bd57b156a..c8be2896815 100644 --- a/mysql-test/main/flush_ssl.test +++ b/mysql-test/main/flush_ssl.test @@ -23,7 +23,9 @@ let $restart_parameters=--ssl-key=$ssl_key --ssl-cert=$ssl_cert; --source include/start_mysqld.inc connect ssl_con,localhost,root,,,,,SSL; +--disable_cursor_protocol SELECT VARIABLE_VALUE INTO @ssl_not_after FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_server_not_after'; +--enable_cursor_protocol let $ssl_not_after=`SELECT @ssl_not_after`; remove_file $ssl_cert; diff --git a/mysql-test/main/func_analyse.test b/mysql-test/main/func_analyse.test index 17b6b49decc..8afc2ab34a6 100644 --- a/mysql-test/main/func_analyse.test +++ b/mysql-test/main/func_analyse.test @@ -24,7 +24,10 @@ EXPLAIN SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(); create table t1 (v varchar(128)); insert into t1 values ('abc'),('abc\'def\\hij\"klm\0opq'),('\''),('\"'),('\\'),('a\0'),('b\''),('c\"'),('d\\'),('\'b'),('\"c'),('\\d'),('a\0\0\0b'),('a\'\'\'\'b'),('a\"\"\"\"b'),('a\\\\\\\\b'),('\'\0\\\"'),('\'\''),('\"\"'),('\\\\'),('The\ZEnd'); +#Enable after fix MDEV-31538 +--disable_cursor_protocol select * from t1 procedure analyse(); +--enable_cursor_protocol drop table t1; #decimal-related test diff --git a/mysql-test/main/func_des_encrypt.test b/mysql-test/main/func_des_encrypt.test index 44fc30ff00f..b1e2a7f42ff 100644 --- a/mysql-test/main/func_des_encrypt.test +++ b/mysql-test/main/func_des_encrypt.test @@ -54,7 +54,13 @@ DROP TABLE t1; CREATE TABLE t1 (a INT); INSERT t1 VALUES (1),(2); +# There is a problem with cursor-protocol and DES_DECRYPT(), +# but DES_DECRYPT has been deprecated from MariaDB 10.10.0, +# and will be removed in a future release. That's why this +# case is excluded without bug +--disable_cursor_protocol SELECT CHAR_LENGTH(a), DES_DECRYPT(a) FROM (SELECT _utf8 0xC2A2 AS a FROM t1) AS t2; +--enable_cursor_protocol DROP TABLE t1; --Echo End of 10.5 tests diff --git a/mysql-test/main/func_digest.test b/mysql-test/main/func_digest.test index afc3941e1b3..9043f6534b9 100644 --- a/mysql-test/main/func_digest.test +++ b/mysql-test/main/func_digest.test @@ -489,6 +489,8 @@ SELECT LENGTH(SHA2( 'computed', 512 )) / 2 * 8 = 512; --echo # Bug#54661 sha2() returns BINARY result --echo # +#Check after fix MDEV-31540 +--disable_cursor_protocol --disable_view_protocol --enable_metadata SET NAMES binary; @@ -499,6 +501,7 @@ SET NAMES latin1; SELECT sha2('1',224); --disable_metadata --disable_view_protocol +--enable_cursor_protocol --echo # --echo # Start of 10.1 tests diff --git a/mysql-test/main/func_gconcat.test b/mysql-test/main/func_gconcat.test index 09703db334a..5694c245033 100644 --- a/mysql-test/main/func_gconcat.test +++ b/mysql-test/main/func_gconcat.test @@ -409,11 +409,14 @@ drop table t1; # create table t1 (f1 int unsigned, f2 varchar(255)); insert into t1 values (1,repeat('a',255)),(2,repeat('b',255)); +#Enable after fix MDEV-31540 +--disable_cursor_protocol --enable_metadata --disable_view_protocol select f2,group_concat(f1) from t1 group by f2; --enable_view_protocol --disable_metadata +--enable_cursor_protocol drop table t1; # End of 4.1 tests @@ -499,11 +502,14 @@ set names latin1; # create table t1 (f1 int unsigned, f2 varchar(255)); insert into t1 values (1,repeat('a',255)),(2,repeat('b',255)); +#Enable after fix MDEV-31540 +--disable_cursor_protocol --enable_metadata --disable_view_protocol select f2,group_concat(f1) from t1 group by f2; --enable_view_protocol --disable_metadata +--enable_cursor_protocol drop table t1; # diff --git a/mysql-test/main/func_group_innodb.test b/mysql-test/main/func_group_innodb.test index 6db7fdc2ad7..2f6935ec4a6 100644 --- a/mysql-test/main/func_group_innodb.test +++ b/mysql-test/main/func_group_innodb.test @@ -170,8 +170,10 @@ DROP TABLE t1; --echo # MDEV-4269: crash when grouping by values() --echo # +--disable_cursor_protocol SELECT @@default_storage_engine INTO @old_engine; set default_storage_engine=innodb; +--enable_cursor_protocol create table y select 1 b; select 1 from y group by b; diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index a1ac2368014..e0fcd192ca6 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -24,7 +24,10 @@ select json_array(1); --disable_view_protocol select json_array(1, "text", false, null); +#enable after fix MDEV-31554 +--disable_cursor_protocol select json_array_append('["a", "b"]', '$', FALSE); +--enable_cursor_protocol --enable_view_protocol select json_array_append('{"k1":1, "k2":["a", "b"]}', '$.k2', 2); select json_array_append('["a", ["b", "c"], "d"]', '$[0]', 2); @@ -87,12 +90,18 @@ select json_extract('[10, 20, [30, 40], 1, 10]', '$[1]') as exp; select json_extract('[10, 20, [30, 40], 1, 10]', '$[1]', '$[25]') as exp; select json_extract( '[{"a": [3, 4]}, {"b": 2}]', '$[0].a', '$[1].a') as exp; +#enable after fix MDEV-31554 +--disable_cursor_protocol select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word') as exp; +--enable_cursor_protocol select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.d[3]', 3) as exp; select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.a[2]', 2) as exp; select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.c', 'word') as exp; +#enable after fix MDEV-31554 +--disable_cursor_protocol select json_set('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.c', '[true, false]') as exp; +--enable_cursor_protocol select json_replace('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.c', '[true, false]') as exp; select json_replace('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.b', '[true, false]') as exp; @@ -134,11 +143,14 @@ select json_merge('a','b'); select json_merge('{"a":"b"}','{"c":"d"}'); SELECT JSON_MERGE('[1, 2]', '{"id": 47}'); +#enable after fix MDEV-31554 +--disable_cursor_protocol select json_type('{"k1":123, "k2":345}'); select json_type('[123, "k2", 345]'); select json_type("true"); select json_type('123'); select json_type('123.12'); +--enable_cursor_protocol select json_keys('{"a":{"c":1, "d":2}, "b":2}'); select json_keys('{"a":{"c":1, "d":2}, "b":2}', "$.a"); @@ -166,21 +178,30 @@ insert into t1 values select json_search( json_col, 'all', 'foot' ) as ex from t1; drop table t1; - +#enable after fix MDEV-31554 +--disable_cursor_protocol select json_unquote('"abc"'); select json_unquote('abc'); +--enable_cursor_protocol + # # MDEV-13703 Illegal mix of collations for operation 'json_object' on using JSON_UNQUOTE as an argument. # create table t1 (c VARCHAR(8)) DEFAULT CHARSET=latin1; insert into t1 values ('abc'),('def'); - + +#enable after fix MDEV-31554 +--disable_cursor_protocol select json_object('foo', json_unquote(json_object('bar', c)),'qux', c) as fld from t1; +--enable_cursor_protocol drop table t1; select json_object("a", json_object("b", "abcd")); +#enable after fix MDEV-31554 +--disable_cursor_protocol select json_object("a", '{"b": "abcd"}'); +--enable_cursor_protocol select json_object("a", json_compact('{"b": "abcd"}')); select json_compact(NULL); @@ -257,8 +278,11 @@ select json_merge('{"a":{"u":12, "x":"b"}}', '{"a":{"x":"c"}}') as ex ; select json_merge('{"a":{"u":12, "x":"b", "r":1}}', '{"a":{"x":"c", "r":2}}') as ex ; select json_compact('{"a":1, "b":[1,2,3], "c":{"aa":"v1", "bb": "v2"}}') as ex; +#enable after fix MDEV-31554 +--disable_cursor_protocol select json_loose('{"a":1, "b":[1,2,3], "c":{"aa":"v1", "bb": "v2"}}') as ex; select json_detailed('{"a":1, "b":[1,2,3], "c":{"aa":"v1", "bb": "v2"}}') as ex; +--enable_cursor_protocol # # MDEV-11856 json_search doesn't search for values with double quotes character (") @@ -450,9 +474,12 @@ drop table t1; --echo # MDEV-16750 JSON_SET mishandles unicode every second pair of arguments. --echo # +#enable after fix MDEV-31554 +--disable_cursor_protocol SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6) as exp; SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6) as exp; SELECT JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6') as exp; +--enable_cursor_protocol --echo # --echo # MDEV-17121 JSON_ARRAY_APPEND @@ -1029,12 +1056,15 @@ create table t1 (a varchar(254)); insert into t1 values (concat('x64-', repeat('a', 60))); insert into t1 values (concat('x64-', repeat('b', 60))); insert into t1 values (concat('x64-', repeat('c', 60))); +#enable after fix MDEV-31554 +--disable_cursor_protocol #enable after MDEV-32454 fix --disable_view_protocol --disable_ps2_protocol select json_arrayagg(a) from t1; --enable_ps2_protocol --enable_view_protocol +--enable_cursor_protocol drop table t1; SET group_concat_max_len= default; diff --git a/mysql-test/main/func_math.test b/mysql-test/main/func_math.test index dbeefa94d59..d16fc3bc37b 100644 --- a/mysql-test/main/func_math.test +++ b/mysql-test/main/func_math.test @@ -567,11 +567,14 @@ select (1.175494351E-37 div 1.7976931348623157E+308); select round(999999999, -9); select round(999999999.0, -9); +#enable after fix MDEV-31555 +--disable_cursor_protocol #enable after fix MDEV-29526 --disable_view_protocol select round(999999999999999999, -18); select round(999999999999999999.0, -18); --enable_view_protocol +--enable_cursor_protocol --echo # --echo # Bug#12537160 ASSERTION FAILED: diff --git a/mysql-test/main/func_misc.test b/mysql-test/main/func_misc.test index d0f622421bd..498c8a94df9 100644 --- a/mysql-test/main/func_misc.test +++ b/mysql-test/main/func_misc.test @@ -248,6 +248,7 @@ SELECT NAME_CONST('var', 'value') COLLATE latin1_general_cs; # # Bug #35848: UUID() returns UUIDs with the wrong time # +--disable_cursor_protocol select @@session.time_zone into @save_tz; # make sure all times are UTC so the DayNr won't differ @@ -259,6 +260,7 @@ select 24 * 60 * 60 * 1000 * 1000 * 10 into @my_uuid_one_day; select concat('0',mid(@my_uuid,16,3),mid(@my_uuid,10,4),left(@my_uuid,8)) into @my_uuidate; select floor(conv(@my_uuidate,16,10)/@my_uuid_one_day) into @my_uuid_date; select 141427 + datediff(curdate(),'1970-01-01') into @my_uuid_synthetic; +--enable_cursor_protocol # these should be identical; date part of UUID should be current date select @my_uuid_date - @my_uuid_synthetic; diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test index 39957aabe70..3c9360a9c40 100644 --- a/mysql-test/main/func_str.test +++ b/mysql-test/main/func_str.test @@ -92,9 +92,12 @@ SELECT CONCAT('"',CONCAT_WS('";"',repeat('a',60),repeat('b',60),repeat('c',60),r select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es'); select replace('aaaa','a','b'),replace('aaaa','aa','b'),replace('aaaa','a','bb'),replace('aaaa','','b'),replace('bbbb','a','c'); --disable_view_protocol +#chaeck after fix MDEV-31540 +--disable_cursor_protocol --enable_metadata select replace('aaaa','a','bbbb'); --disable_metadata +--enable_cursor_protocol --enable_view_protocol select replace(concat(lcase(concat('THIS',' ','IS',' ','A',' ')),ucase('false'),' ','test'),'FALSE','REAL') as exp; select soundex(''),soundex('he'),soundex('hello all folks'),soundex('#3556 in bugdb'); @@ -145,7 +148,10 @@ select length(unhex(md5("abrakadabra"))); # # Bug #6564: QUOTE(NULL # +#enable after fix MDEV-31587 +--disable_cursor_protocol select concat('a', quote(NULL)); +--enable_cursor_protocol # # Wrong usage of functions @@ -741,8 +747,11 @@ create table t1 (i int); insert into t1 values (1000000000),(1); --enable_metadata --disable_view_protocol +#check after fix MDEV-31540 +--disable_cursor_protocol select lpad(i, 7, ' ') as t from t1; select rpad(i, 7, ' ') as t from t1; +--enable_cursor_protocol --enable_view_protocol --disable_metadata drop table t1; @@ -893,6 +902,8 @@ select format(NULL, NULL); select format(pi(), NULL); select format(NULL, 2); +#check after fix MDEV-31587 +--disable_cursor_protocol #enable after fix MDEV-28585 --disable_view_protocol select benchmark(NULL, NULL); @@ -900,16 +911,20 @@ select benchmark(0, NULL); select benchmark(100, NULL); select benchmark(NULL, 1+1); --enable_view_protocol +--enable_cursor_protocol # # Bug #20752: BENCHMARK with many iterations returns too quickly # # not a string, but belongs with the above Bug#22684 +#check after fix MDEV-31587 +--disable_cursor_protocol #enable after fix MDEV-28585 --disable_view_protocol select benchmark(-1, 1); --enable_view_protocol +--enable_cursor_protocol # # Please note: # 1) The collation of the password is irrelevant, the encryption uses @@ -977,26 +992,26 @@ select left('hello', -1); select left('hello', -4294967295); #enable after fix MDEV-29552 --disable_view_protocol +#enable after fix MDEV-34213 +--disable_cursor_protocol select left('hello', 4294967295); ---enable_view_protocol select left('hello', -4294967296); -#enable after fix MDEV-29552 ---disable_view_protocol select left('hello', 4294967296); ---enable_view_protocol select left('hello', -4294967297); -#enable after fix MDEV-29552 ---disable_view_protocol select left('hello', 4294967297); +--enable_cursor_protocol --enable_view_protocol #view protocol generates additional warning --disable_view_protocol select left('hello', -18446744073709551615); select left('hello', 18446744073709551615); select left('hello', -18446744073709551616); +#enable after fix MDEV-34213 +--disable_cursor_protocol select left('hello', 18446744073709551616); select left('hello', -18446744073709551617); select left('hello', 18446744073709551617); +--enable_cursor_protocol --enable_view_protocol select right('hello', 10); @@ -1005,26 +1020,26 @@ select right('hello', -1); select right('hello', -4294967295); #enable after fix MDEV-29552 --disable_view_protocol +#enable after fix MDEV-34213 +--disable_cursor_protocol select right('hello', 4294967295); ---enable_view_protocol select right('hello', -4294967296); -#enable after fix MDEV-29552 ---disable_view_protocol select right('hello', 4294967296); ---enable_view_protocol select right('hello', -4294967297); -#enable after fix MDEV-29552 ---disable_view_protocol select right('hello', 4294967297); +--enable_cursor_protocol --enable_view_protocol #view protocol generates additional warning --disable_view_protocol select right('hello', -18446744073709551615); select right('hello', 18446744073709551615); select right('hello', -18446744073709551616); +#enable after fix MDEV-34213 +--disable_cursor_protocol select right('hello', 18446744073709551616); select right('hello', -18446744073709551617); select right('hello', 18446744073709551617); +--enable_cursor_protocol --enable_view_protocol select substring('hello', 2, -1); @@ -1049,6 +1064,8 @@ select substring('hello', 18446744073709551617, 1); #enable after fix MDEV-28652 --disable_view_protocol select substring('hello', 1, -1); +#check after fix MDEV-31587 +--disable_cursor_protocol select substring('hello', 1, -4294967295); select substring('hello', 1, 4294967295); select substring('hello', 1, -4294967296); @@ -1064,6 +1081,7 @@ select substring('hello', 1, -18446744073709551616); select substring('hello', 1, 18446744073709551616); select substring('hello', 1, -18446744073709551617); select substring('hello', 1, 18446744073709551617); +--enable_cursor_protocol --enable_view_protocol select substring('hello', -1, -1); select substring('hello', -4294967295, -4294967295); @@ -1395,7 +1413,10 @@ create table t1(a float); insert into t1 values (1.33); --enable_metadata --disable_view_protocol +#check after fix MDEV-31540 +--disable_cursor_protocol select format(a, 2) from t1; +--enable_cursor_protocol --enable_view_protocol --disable_metadata drop table t1; @@ -1510,9 +1531,11 @@ SELECT CONVERT(('' IN (REVERSE(CAST(('') AS DECIMAL)), '')), CHAR(3)); --echo # CREATE TABLE t1 ( a TEXT ); --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --disable_ps2_protocol --eval SELECT 'aaaaaaaaaaaaaa' INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug58165.txt'; --enable_ps2_protocol +--enable_cursor_protocol SELECT insert( substring_index( 'a', 'a', 'b' ), 1, 0, 'x' ); --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug58165.txt' INTO TABLE t1; @@ -1595,11 +1618,17 @@ SELECT format(12345678901234567890.123, 3, 'ar_AE'); SELECT format(12345678901234567890.123, 3, 'ar_SA'); SELECT format(12345678901234567890.123, 3, 'be_BY'); SELECT format(12345678901234567890.123, 3, 'de_DE'); +#check after fix MDEV-31512 +--disable_cursor_protocol SELECT format(12345678901234567890.123, 3, 'en_IN'); SELECT format(12345678901234567890.123, 3, 'en_US'); +--enable_cursor_protocol SELECT format(12345678901234567890.123, 3, 'it_CH'); SELECT format(12345678901234567890.123, 3, 'ru_RU'); +#checkafter fix MDEV-31512 +--disable_cursor_protocol SELECT format(12345678901234567890.123, 3, 'ta_IN'); +--enable_cursor_protocol CREATE TABLE t1 (fmt CHAR(5) NOT NULL); INSERT INTO t1 VALUES ('ar_AE'); @@ -1611,6 +1640,8 @@ INSERT INTO t1 VALUES ('en_US'); INSERT INTO t1 VALUES ('it_CH'); INSERT INTO t1 VALUES ('ru_RU'); INSERT INTO t1 VALUES ('ta_IN'); +#check after fix MDEV-31512 +--disable_cursor_protocol SELECT fmt, format(12345678901234567890.123, 3, fmt) FROM t1 ORDER BY fmt; SELECT fmt, format(12345678901234567890.123, 0, fmt) FROM t1 ORDER BY fmt; SELECT fmt, format(12345678901234567890, 3, fmt) FROM t1 ORDER BY fmt; @@ -1618,6 +1649,7 @@ SELECT fmt, format(-12345678901234567890, 3, fmt) FROM t1 ORDER BY fmt; SELECT fmt, format(-02345678901234567890, 3, fmt) FROM t1 ORDER BY fmt; SELECT fmt, format(-00345678901234567890, 3, fmt) FROM t1 ORDER BY fmt; SELECT fmt, format(-00045678901234567890, 3, fmt) FROM t1 ORDER BY fmt; +--enable_cursor_protocol DROP TABLE t1; SELECT format(123, 1, 'Non-existent-locale'); @@ -2062,7 +2094,10 @@ DROP TABLE t1; --disable_view_protocol CREATE TABLE t1 (a INT, b TIME, c TIME); INSERT INTO t1 VALUES (NULL,'22:56:45','22:56:45'),(4,'12:51:42','12:51:42'); +#check after fix MDEV-31512 +--disable_cursor_protocol SELECT REPLACE( BINARY c, a, b ) f FROM t1 GROUP BY f WITH ROLLUP; +--enable_cursor_protocol DROP TABLE t1; --enable_view_protocol diff --git a/mysql-test/main/func_time.test b/mysql-test/main/func_time.test index 4b046ac166a..51b2722d7a0 100644 --- a/mysql-test/main/func_time.test +++ b/mysql-test/main/func_time.test @@ -1294,7 +1294,10 @@ SET TIME_ZONE='+02:00'; --echo # CREATE TABLE t1 (a DATE); INSERT INTO t1 VALUES ('2005-05-04'),('2000-02-23'); +#check after fix MDEV-31495 +--disable_cursor_protocol SELECT a, FROM_UNIXTIME(CONCAT(a,'10')) AS f1, FROM_UNIXTIME(CONCAT(a,'10'))+0 AS f2 FROM t1; +--enable_cursor_protocol SELECT * FROM t1 GROUP BY FROM_UNIXTIME(CONCAT(a,'10'))+0; DROP TABLE t1; @@ -1608,7 +1611,10 @@ SELECT DATE_ADD('2001-01-01 10:20:30',INTERVAL 250000000000.0 SECOND) AS c1, DAT --echo # --enable_metadata --disable_view_protocol +#check after fix MDEV-31540 +--disable_cursor_protocol SELECT DATE_ADD('2011-01-02 12:13:14', INTERVAL 1 MINUTE); +--enable_cursor_protocol --enable_view_protocol --disable_metadata @@ -2241,11 +2247,13 @@ SET @sav_slow_query_log= @@session.slow_query_log; --disable_ps2_protocol # @@slow_query_log ON check SET @@session.slow_query_log= ON; +--disable_cursor_protocol SELECT current_timestamp(6),fn_sleep_before_now() INTO @ts_cur, @ts_func; --enable_ps2_protocol SELECT a FROM t_ts LIMIT 1 into @ts_func; SELECT a FROM t_trig LIMIT 1 into @ts_trig; +--enable_cursor_protocol if (!`SELECT @ts_cur = @ts_func and @ts_func = @ts_trig`) { SELECT @ts_cur, @ts_func, @ts_trig; @@ -2257,10 +2265,12 @@ DELETE FROM t_trig; --disable_ps2_protocol # @@slow_query_log OFF check SET @@session.slow_query_log= OFF; +--disable_cursor_protocol SELECT current_timestamp(6),fn_sleep_before_now() INTO @ts_cur, @func_ts; --enable_ps2_protocol SELECT a FROM t_ts LIMIT 1 into @ts_func; SELECT a FROM t_trig LIMIT 1 into @ts_trig; +--enable_cursor_protocol if (!`SELECT @ts_cur = @ts_func and @ts_func = @ts_trig`) { SELECT @ts_cur, @ts_func, @ts_trig; @@ -3196,7 +3206,10 @@ SELECT TIME('- 01:00:00'), TIME('- 1 01:00:00'); #enable after fix MDEV-29534 --disable_view_protocol SET time_zone='+00:00'; +#check after fix MDEV-31495 +--disable_cursor_protocol SELECT NULLIF(FROM_UNIXTIME('foo'), '2012-12-12 21:10:14'); +--enable_cursor_protocol SET time_zone=DEFAULT; --enable_view_protocol diff --git a/mysql-test/main/func_time_round.test b/mysql-test/main/func_time_round.test index 79f9ec289a0..fa13e7cb461 100644 --- a/mysql-test/main/func_time_round.test +++ b/mysql-test/main/func_time_round.test @@ -181,7 +181,10 @@ SELECT YEAR(a), CAST(a AS DATE), a FROM t1_datetime_in_varchar ORDER BY id; SELECT DAYNAME(a), CAST(a AS DATE), a FROM t1_datetime_in_varchar ORDER BY id; SELECT MONTHNAME(a), CAST(a AS DATE), a FROM t1_datetime_in_varchar ORDER BY id; +#check after fix MDEV-31555 +--disable_cursor_protocol SELECT LAST_DAY(a), CAST(a AS DATE), a FROM t1_datetime_in_varchar ORDER BY id; +--enable_cursor_protocol SELECT TO_DAYS(a), CAST(a AS DATE), a FROM t1_datetime_in_varchar ORDER BY id; SELECT DAYOFYEAR(a), CAST(a AS DATE), a FROM t1_datetime_in_varchar ORDER BY id; @@ -219,7 +222,10 @@ SELECT DAYNAME(a), CAST(a AS DATE), a FROM t1_datetime_in_decimal ORDER BY id; SELECT MONTHNAME(a), CAST(a AS DATE), a FROM t1_datetime_in_decimal ORDER BY id; SELECT YEARWEEK(a), CAST(a AS DATE), a FROM t1_datetime_in_decimal ORDER BY id; +#check after fix MDEV-31555 +--disable_cursor_protocol SELECT LAST_DAY(a), CAST(a AS DATE), a FROM t1_datetime_in_decimal ORDER BY id; +--enable_cursor_protocol SELECT TO_DAYS(a), CAST(a AS DATE), a FROM t1_datetime_in_decimal ORDER BY id; SELECT DAYOFYEAR(a), CAST(a AS DATE), a FROM t1_datetime_in_decimal ORDER BY id; SELECT DAYOFMONTH(a), CAST(a AS DATE), a FROM t1_datetime_in_decimal ORDER BY id; diff --git a/mysql-test/main/get_diagnostics.test b/mysql-test/main/get_diagnostics.test index 6b4227887b5..68b58a32e2b 100644 --- a/mysql-test/main/get_diagnostics.test +++ b/mysql-test/main/get_diagnostics.test @@ -282,6 +282,7 @@ GET DIAGNOSTICS CONDITION ABS(2) @var = CLASS_ORIGIN; GET DIAGNOSTICS CONDITION 1.1 @var = CLASS_ORIGIN; GET DIAGNOSTICS CONDITION "1" @var = CLASS_ORIGIN; +--disable_cursor_protocol # Reset warnings SELECT COUNT(max_questions) INTO @var FROM mysql.user; @@ -301,6 +302,7 @@ GET DIAGNOSTICS CONDITION @cond @var1 = CLASS_ORIGIN; # Reset warnings SELECT COUNT(max_questions) INTO @var FROM mysql.user; +--enable_cursor_protocol DELIMITER |; CREATE PROCEDURE p1() @@ -367,7 +369,9 @@ GET DIAGNOSTICS @var = NUMBER; SELECT @var; --enable_view_protocol +--disable_cursor_protocol SELECT COUNT(max_questions) INTO @var FROM mysql.user; +--enable_cursor_protocol GET DIAGNOSTICS @var = NUMBER; SELECT @var; diff --git a/mysql-test/main/gis.test b/mysql-test/main/gis.test index f160d8f1a10..6bac1e0c906 100644 --- a/mysql-test/main/gis.test +++ b/mysql-test/main/gis.test @@ -403,9 +403,12 @@ select (asWKT(geomfromwkb((0x010100000000000000000024400000000000002440)))) as e --enable_metadata --disable_view_protocol +#check after fix MDEV-31540 +--disable_cursor_protocol create table t1 (g GEOMETRY); select * from t1; select asbinary(g) from t1; +--enable_cursor_protocol --enable_view_protocol --disable_metadata drop table t1; @@ -3245,6 +3248,8 @@ CREATE TABLE t1 ( g GEOMETRY ) CHARACTER SET utf8; +#check after fix MDEV-31540 +--disable_cursor_protocol --disable_view_protocol --enable_metadata SELECT * FROM t1; @@ -3350,6 +3355,7 @@ FROM t1; --disable_metadata --enable_view_protocol +--enable_cursor_protocol DROP TABLE t1; --echo # diff --git a/mysql-test/main/grant.test b/mysql-test/main/grant.test index c9c74d7b877..c75da4f76a8 100644 --- a/mysql-test/main/grant.test +++ b/mysql-test/main/grant.test @@ -10,7 +10,9 @@ set GLOBAL sql_mode=""; set LOCAL sql_mode=""; SET @old_log_bin_trust_function_creators= @@global.log_bin_trust_function_creators; SET GLOBAL log_bin_trust_function_creators = 1; +--disable_cursor_protocol select priv into @root_priv from mysql.global_priv where user='root' and host='localhost'; +--enable_cursor_protocol connect (master,localhost,root,,); connection master; diff --git a/mysql-test/main/grant2.test b/mysql-test/main/grant2.test index 7efd9bdde78..19ad2d37472 100644 --- a/mysql-test/main/grant2.test +++ b/mysql-test/main/grant2.test @@ -4,7 +4,10 @@ # Save the initial number of concurrent sessions --source include/count_sessions.inc +--disable_cursor_protocol select priv into @root_priv from mysql.global_priv where user='root' and host='localhost'; +--enable_cursor_protocol + set GLOBAL sql_mode=""; set LOCAL sql_mode=""; SET NAMES binary; @@ -655,8 +658,10 @@ DROP DATABASE db1; # work out who we are. USE mysql; +--disable_cursor_protocol SELECT LEFT(CURRENT_USER(),INSTR(CURRENT_USER(),'@')-1) INTO @u; SELECT MID(CURRENT_USER(),INSTR(CURRENT_USER(),'@')+1) INTO @h; +--enable_cursor_protocol # show current privs. SELECT user,host,password,plugin,authentication_string,insert_priv FROM user WHERE user=@u AND host=@h; @@ -838,9 +843,11 @@ SHOW CREATE TABLE t1; --echo # INSERT INTO t1 VALUES (1), (2), (3); --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --disable_ps2_protocol --eval SELECT a INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug27480.txt' FROM t1 --enable_ps2_protocol +--enable_cursor_protocol --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --eval LOAD DATA INFILE '$MYSQLTEST_VARDIR/tmp/bug27480.txt' INTO TABLE t1 --remove_file $MYSQLTEST_VARDIR/tmp/bug27480.txt diff --git a/mysql-test/main/grant_4332.test b/mysql-test/main/grant_4332.test index 4a228b5c1a1..69566cb5e2e 100644 --- a/mysql-test/main/grant_4332.test +++ b/mysql-test/main/grant_4332.test @@ -21,7 +21,10 @@ flush privileges; --enable_metadata --disable_view_protocol +# Check after fix MDEV-31540 +--disable_cursor_protocol select user(); +--enable_cursor_protocol --enable_view_protocol --disable_metadata @@ -43,7 +46,10 @@ flush privileges; --enable_metadata --disable_view_protocol +# Check after fix MDEV-31540 +--disable_cursor_protocol select user(); +--enable_cursor_protocol --enable_view_protocol --disable_metadata diff --git a/mysql-test/main/group_by.test b/mysql-test/main/group_by.test index 340a6473eb7..6c2b99c90be 100644 --- a/mysql-test/main/group_by.test +++ b/mysql-test/main/group_by.test @@ -284,6 +284,7 @@ drop table t1; CREATE TABLE t1 (a char(1)); INSERT INTO t1 VALUES ('A'),('B'),('A'),('B'),('A'),('B'),(NULL),('a'),('b'),(NULL),('A'),('B'),(NULL); flush status; +--disable_cursor_protocol --disable_ps2_protocol SELECT a FROM t1 GROUP BY a; SELECT a,count(*) FROM t1 GROUP BY a; @@ -292,11 +293,13 @@ SELECT a,count(*) FROM t1 GROUP BY binary a; SELECT binary a FROM t1 GROUP BY 1; SELECT binary a,count(*) FROM t1 GROUP BY 1; --enable_ps2_protocol +--enable_cursor_protocol --disable_ps_protocol show status like 'Created%tables'; --enable_ps_protocol # Do the same tests with on-disk temporary tables set tmp_memory_table_size=0; +--disable_cursor_protocol --disable_ps2_protocol SELECT a FROM t1 GROUP BY a; SELECT a,count(*) FROM t1 GROUP BY a; @@ -305,6 +308,7 @@ SELECT a,count(*) FROM t1 GROUP BY binary a; SELECT binary a FROM t1 GROUP BY 1; SELECT binary a,count(*) FROM t1 GROUP BY 1; --enable_ps2_protocol +--enable_cursor_protocol --disable_ps_protocol show status like 'Created%tables'; --enable_ps_protocol @@ -1666,7 +1670,7 @@ DROP TABLE t1, t2; # an additional util connection and other statistics data --disable_ps2_protocol --disable_view_protocol - +--disable_cursor_protocol FLUSH STATUS; # this test case *must* use Aria temp tables CREATE TABLE t1 (f1 INT, f2 decimal(20,1), f3 blob); @@ -1676,6 +1680,7 @@ DROP TABLE t1; --echo the value below *must* be 1 show status like 'Created_tmp_disk_tables'; +--enable_cursor_protocol --enable_view_protocol --enable_ps2_protocol diff --git a/mysql-test/main/group_min_max.test b/mysql-test/main/group_min_max.test index ec4c5705b23..97de775f4c8 100644 --- a/mysql-test/main/group_min_max.test +++ b/mysql-test/main/group_min_max.test @@ -1726,6 +1726,8 @@ explain select and t1.PARENT_ID = t2.PARENT_ID and t2.CHILD_FIELD = "ZZZZ"; +#Enable after fix MDEV-31552 +--disable_cursor_protocol select t1.PARENT_ID, min(CHILD_FIELD) @@ -1733,6 +1735,7 @@ select where t1.PARENT_ID = 1 and t1.PARENT_ID = t2.PARENT_ID and t2.CHILD_FIELD = "ZZZZ"; +--enable_cursor_protocol select 1, @@ -1764,6 +1767,8 @@ explain select and t1.PARENT_ID = t2.PARENT_ID and t2.CHILD_FIELD = "ZZZZ"; +#Enable after fix MDEV-31552 +--disable_cursor_protocol select t1.PARENT_ID, min(CHILD_FIELD) @@ -1771,6 +1776,7 @@ select where t1.PARENT_ID = 1 and t1.PARENT_ID = t2.PARENT_ID and t2.CHILD_FIELD = "ZZZZ"; +--enable_cursor_protocol drop table t1,t2; @@ -1897,6 +1903,8 @@ explain select and t1.PARENT_ID = t2.PARENT_ID and t2.CHILD_FIELD = "ZZZZ"; +#Enable after fix MDEV-31552 +--disable_cursor_protocol select t1.PARENT_ID, min(CHILD_FIELD) @@ -1904,6 +1912,7 @@ select where t1.PARENT_ID = 1 and t1.PARENT_ID = t2.PARENT_ID and t2.CHILD_FIELD = "ZZZZ"; +--enable_cursor_protocol select 1, @@ -1935,6 +1944,8 @@ explain select and t1.PARENT_ID = t2.PARENT_ID and t2.CHILD_FIELD = "ZZZZ"; +#Enable after fix MDEV-31552 +--disable_cursor_protocol select t1.PARENT_ID, min(CHILD_FIELD) @@ -1942,6 +1953,7 @@ select where t1.PARENT_ID = 1 and t1.PARENT_ID = t2.PARENT_ID and t2.CHILD_FIELD = "ZZZZ"; +--enable_cursor_protocol drop table t1,t2; diff --git a/mysql-test/main/handler_read_last.test b/mysql-test/main/handler_read_last.test index 390d5f092fc..56e0b091e67 100644 --- a/mysql-test/main/handler_read_last.test +++ b/mysql-test/main/handler_read_last.test @@ -9,6 +9,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT, INDEX (a)); INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(); +--disable_cursor_protocol --disable_ps2_protocol FLUSH STATUS; SELECT a FROM t1 ORDER BY a LIMIT 1; @@ -26,6 +27,7 @@ FLUSH STATUS; SELECT a FROM t1 ORDER BY a DESC LIMIT 3; SHOW STATUS LIKE 'HANDLER_READ%'; --enable_ps2_protocol +--enable_cursor_protocol DROP TABLE t1; diff --git a/mysql-test/main/information_schema.test b/mysql-test/main/information_schema.test index cd118a17961..d3af60a32fb 100644 --- a/mysql-test/main/information_schema.test +++ b/mysql-test/main/information_schema.test @@ -1811,14 +1811,18 @@ drop database mysqltest; --disable_result_log SELECT * FROM INFORMATION_SCHEMA.TABLES; --enable_result_log +--disable_cursor_protocol SELECT VARIABLE_VALUE INTO @val1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'Opened_tables'; +--enable_cursor_protocol --disable_result_log SELECT ENGINE FROM INFORMATION_SCHEMA.TABLES; --enable_result_log --echo # The below SELECT query should give same output as above SELECT query. +--disable_cursor_protocol SELECT VARIABLE_VALUE INTO @val2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME LIKE 'Opened_tables'; +--enable_cursor_protocol --echo # The below select should return '1' SELECT @val1 = @val2; diff --git a/mysql-test/main/init_file.test b/mysql-test/main/init_file.test index 65e54db43ea..57acf7ce6e2 100644 --- a/mysql-test/main/init_file.test +++ b/mysql-test/main/init_file.test @@ -10,8 +10,10 @@ # Bug#23240 --init-file statements with NOW() reports '1970-01-01 11:00:00'as the date time # INSERT INTO init_file.startup VALUES ( NOW() ); +--disable_cursor_protocol SELECT * INTO @X FROM init_file.startup limit 0,1; SELECT * INTO @Y FROM init_file.startup limit 1,1; +--enable_cursor_protocol SELECT YEAR(@X)-YEAR(@Y); --echo ok diff --git a/mysql-test/main/innodb_ext_key.test b/mysql-test/main/innodb_ext_key.test index a37677411ad..fb47da1ccfb 100644 --- a/mysql-test/main/innodb_ext_key.test +++ b/mysql-test/main/innodb_ext_key.test @@ -29,6 +29,7 @@ ANALYZE TABLE lineitem PERSISTENT FOR COLUMNS() INDEXES(); --enable_result_log --enable_query_log +--disable_cursor_protocol --disable_ps2_protocol explain select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01'; @@ -153,6 +154,7 @@ select o_orderkey, p_partkey and o_orderkey=l_orderkey and p_partkey=l_partkey; show /*d*/ status like 'handler_read%'; --enable_ps2_protocol +--enable_cursor_protocol --echo # --echo # Bug mdev-3851: ref access used instead of expected eq_ref access @@ -326,7 +328,9 @@ from t1 A, t1 B; explain select * from t1, t2 where t2.a=t1.a and t2.b < 2; flush status; +--disable_cursor_protocol select * from t1, t2 where t2.a=t1.a and t2.b < 2; +--enable_cursor_protocol show /*e*/ status like 'handler_read%'; --enable_ps2_protocol diff --git a/mysql-test/main/insert.test b/mysql-test/main/insert.test index 0a1e63765a4..4b5a5181f09 100644 --- a/mysql-test/main/insert.test +++ b/mysql-test/main/insert.test @@ -596,9 +596,11 @@ CREATE ALGORITHM = MERGE VIEW v1 AS SELECT f1, f2 FROM t1 WHERE f1 = cast('' as REPLACE INTO v1 SET f2 = 1; SELECT * from t1; drop view v1; +--disable_cursor_protocol --disable_ps2_protocol SELECT 0,0 INTO OUTFILE 't1.txt'; --enable_ps2_protocol +--enable_cursor_protocol CREATE ALGORITHM = MERGE VIEW v1 AS SELECT f1, f2 FROM t1 WHERE f1 = 'x' WITH CHECK OPTION; --error ER_TRUNCATED_WRONG_VALUE LOAD DATA INFILE 't1.txt' INTO TABLE v1; diff --git a/mysql-test/main/invisible_field.test b/mysql-test/main/invisible_field.test index 0731c393399..67a5e62337a 100644 --- a/mysql-test/main/invisible_field.test +++ b/mysql-test/main/invisible_field.test @@ -251,9 +251,11 @@ DROP TABLE t1; create or replace table t1 (a int, b int invisible); insert into t1 values (1),(2); +--disable_cursor_protocol --disable_ps2_protocol select * from t1 into outfile 'f'; --enable_ps2_protocol +--enable_cursor_protocol load data infile 'f' into table t1; select a,b from t1; load data infile 'f' into table t1 (a,@v) SET b=@v; @@ -263,9 +265,11 @@ select a,b from t1; truncate table t1; insert into t1(a,b) values (1,1),(2,2); +--disable_cursor_protocol --disable_ps2_protocol select a,b from t1 into outfile 'a'; --enable_ps2_protocol +--enable_cursor_protocol load data infile 'a' into table t1(a,b); select a,b from t1; load data infile 'a' into table t1 (a,@v) SET b=@v; diff --git a/mysql-test/main/join.test b/mysql-test/main/join.test index f8abc3fac22..ac30e14f7ad 100644 --- a/mysql-test/main/join.test +++ b/mysql-test/main/join.test @@ -658,6 +658,7 @@ insert into t2 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t3 (a int not null, primary key(a)); insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +--disable_cursor_protocol flush status; --disable_ps2_protocol select * from t1, t2, t3 where t3.a=t1.a and t2.a=t1.b; @@ -665,6 +666,7 @@ select * from t1, t2, t3 where t3.a=t1.a and t2.a=t1.b; explain select * from t1, t2, t3 where t3.a=t1.a and t2.a=t1.b; --echo We expect rnd_next=5, and read_key must be 0 because of short-cutting: show status like 'Handler_read%'; +--enable_cursor_protocol drop table t1, t2, t3; # @@ -959,11 +961,13 @@ INSERT INTO t1 VALUES (3,'b'),(4,NULL),(5,'c'),(6,'cc'),(7,'d'), (8,'dd'),(9,'e'),(10,'ee'); INSERT INTO t2 VALUES (2,NULL); ANALYZE TABLE t1,t2; +--disable_cursor_protocol FLUSH STATUS; --disable_ps2_protocol SELECT * FROM t1 JOIN t2 ON t1.v = t2.v WHERE t2.v IS NULL ORDER BY 1; --enable_ps2_protocol SHOW STATUS LIKE 'Handler_read_%'; +--enable_cursor_protocol DROP TABLE t1, t2; --echo End of 5.1 tests diff --git a/mysql-test/main/join_outer.test b/mysql-test/main/join_outer.test index 83bb7fdeef3..d370a11967e 100644 --- a/mysql-test/main/join_outer.test +++ b/mysql-test/main/join_outer.test @@ -885,9 +885,11 @@ INSERT INTO t2 VALUES EXPLAIN SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; +--disable_cursor_protocol flush status; SELECT t1.id, a FROM t1 LEFT JOIN t2 ON t1.id=t2.id WHERE t2.b IS NULL; show status like 'Handler_read%'; +--enable_cursor_protocol DROP TABLE t1,t2; --enable_ps2_protocol @@ -1371,7 +1373,6 @@ drop table t1,t2,t3,t4; --echo # table is used in the on condition of an outer join --echo # --disable_ps2_protocol ---disable_view_protocol create table t1 (a int); insert into t1 values (NULL), (NULL), (NULL), (NULL); insert into t1 select * from t1; @@ -1403,16 +1404,18 @@ insert into t3 values (11, 100), (33, 301), (44, 402), (11, 102), (11, 101); insert into t3 values (22, 100), (53, 301), (64, 402), (22, 102), (22, 101); analyze table t1,t2,t3; - +--disable_view_protocol +--disable_cursor_protocol flush status; select sum(t3.b) from t1 left join t3 on t3.a=t1.a and t1.a is not null; show status like "handler_read%"; flush status; select sum(t3.b) from t2 left join t3 on t3.a=t2.a and t2.a <> 10; show status like "handler_read%"; +--enable_cursor_protocol +--enable_view_protocol drop table t1,t2,t3; ---enable_view_protocol --enable_ps2_protocol --echo # diff --git a/mysql-test/main/key_cache.test b/mysql-test/main/key_cache.test index 0829719a442..b25ff58bd1e 100644 --- a/mysql-test/main/key_cache.test +++ b/mysql-test/main/key_cache.test @@ -303,7 +303,9 @@ update t1 set p=3 where p=1; update t2 set i=2 where i=1; select * from information_schema.session_status where variable_name like 'key_%' and variable_name != 'Key_blocks_unused'; +--disable_cursor_protocol select variable_value into @key_blocks_unused from information_schema.session_status where variable_name = 'Key_blocks_unused'; +--enable_cursor_protocol --replace_column 7 # select * from information_schema.key_caches where segment_number is null; diff --git a/mysql-test/main/last_value.test b/mysql-test/main/last_value.test index 41cfdb5482d..9e90a8a25bb 100644 --- a/mysql-test/main/last_value.test +++ b/mysql-test/main/last_value.test @@ -33,6 +33,8 @@ DROP TABLE t1; SELECT LAST_VALUE(@last_a:=1,@last_b:=1); select @last_b; --enable_ps_protocol +#Check after fix MDEV-31540 +--disable_cursor_protocol SELECT LAST_VALUE(@last_a:=1,@last_b:=1.0); select @last_b; SELECT LAST_VALUE(@last_a:=1,@last_b:="hello"); @@ -41,6 +43,7 @@ SELECT date(LAST_VALUE(@last_a:=1,@last_b:="2001-02-03")); select @last_b; SELECT LAST_VALUE(@last_a:=1,@last_b:="2001-02-03",NULL); select @last_b; +--enable_cursor_protocol --disable_metadata --error ER_PARSE_ERROR SELECT LAST_VALUE(); diff --git a/mysql-test/main/limit_rows_examined.test b/mysql-test/main/limit_rows_examined.test index 16831a0cf5c..94bbf8e819a 100644 --- a/mysql-test/main/limit_rows_examined.test +++ b/mysql-test/main/limit_rows_examined.test @@ -23,6 +23,8 @@ insert into t2i values ('bb'), ('cc'), ('dd'), ('ff'); --echo Simple joins --echo ========================================================================= +#Check after fix MDEV-31522 +--disable_cursor_protocol --echo Simple nested loops join without blocking set @@join_cache_level=0; explain @@ -457,6 +459,7 @@ SELECT DISTINCT a FROM t1, t2 HAVING a > ' ' LIMIT ROWS EXAMINED 14; SELECT DISTINCT a FROM t1, t2 HAVING a > ' ' LIMIT ROWS EXAMINED 15; SELECT DISTINCT a FROM t1, t2 HAVING a > ' ' LIMIT ROWS EXAMINED 16; +--enable_cursor_protocol drop table t1,t2,t3; @@ -489,6 +492,7 @@ WHERE alias3.c IN ( SELECT 1 UNION SELECT 6 ) GROUP BY field1, field2, field3, field4, field5 LIMIT ROWS EXAMINED 120; +--disable_cursor_protocol --disable_ps2_protocol FLUSH STATUS; SELECT a AS field1, alias2.d AS field2, alias2.f AS field3, alias2.e AS field4, b AS field5 @@ -508,6 +512,7 @@ LIMIT ROWS EXAMINED 124; SHOW STATUS LIKE 'Handler_read%'; SHOW STATUS LIKE 'Handler_tmp%'; --enable_ps2_protocol +--enable_cursor_protocol drop table t1, t2; diff --git a/mysql-test/main/loaddata.test b/mysql-test/main/loaddata.test index 9c1a583831b..ef1496787d4 100644 --- a/mysql-test/main/loaddata.test +++ b/mysql-test/main/loaddata.test @@ -41,7 +41,9 @@ SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=NO_AUTO_VALUE_ON_ZERO; create table t1(id integer not null auto_increment primary key); insert into t1 values(0); disable_query_log; +--disable_cursor_protocol eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1' from t1; +--enable_cursor_protocol delete from t1; eval load data infile '$MYSQLTEST_VARDIR/tmp/t1' into table t1; enable_query_log; @@ -49,9 +51,11 @@ select * from t1; remove_file $MYSQLTEST_VARDIR/tmp/t1; disable_query_log; +--disable_cursor_protocol eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1' FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n' FROM t1; +--enable_cursor_protocol delete from t1; eval load data infile '$MYSQLTEST_VARDIR/tmp/t1' into table t1 FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n'; @@ -94,9 +98,11 @@ INSERT INTO t1 (c1) VALUES SELECT * FROM t1; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --disable_ps2_protocol eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1' FIELDS ENCLOSED BY 'r' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol cat_file $MYSQLTEST_VARDIR/tmp/t1; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR @@ -184,9 +190,11 @@ create table t1(f1 int); insert into t1 values(1),(null); create table t2(f2 int auto_increment primary key); disable_query_log; +--disable_cursor_protocol --disable_ps2_protocol eval select * into outfile '$MYSQLTEST_VARDIR/tmp/t1' from t1; --enable_ps2_protocol +--enable_cursor_protocol SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE=NO_AUTO_VALUE_ON_ZERO; eval load data infile '$MYSQLTEST_VARDIR/tmp/t1' into table t2; enable_query_log; @@ -203,20 +211,24 @@ create table t1(f1 int, f2 timestamp not null default current_timestamp); create table t2(f1 int); insert into t2 values(1),(2); disable_query_log; +--disable_cursor_protocol --disable_ps2_protocol eval select * into outfile '$MYSQLTEST_VARDIR/tmp/t2' from t2; --enable_ps2_protocol +--enable_cursor_protocol eval load data infile '$MYSQLTEST_VARDIR/tmp/t2' ignore into table t1; enable_query_log; select f1 from t1 where f2 <> '0000-00-00 00:00:00' order by f1; remove_file $MYSQLTEST_VARDIR/tmp/t2; delete from t1; disable_query_log; +--disable_cursor_protocol --disable_ps2_protocol eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t2' FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n' FROM t2; --enable_ps2_protocol +--enable_cursor_protocol eval load data infile '$MYSQLTEST_VARDIR/tmp/t2' ignore into table t1 FIELDS TERMINATED BY '' OPTIONALLY ENCLOSED BY '' LINES TERMINATED BY '\r\n'; enable_query_log; @@ -235,9 +247,11 @@ INSERT INTO t1 (c1, c2, c3, c4) VALUES (10, '1970-02-01 01:02:03', 1.1E-100, 1.1 SELECT * FROM t1; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --disable_ps2_protocol eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1' FIELDS ENCLOSED BY '-' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol cat_file $MYSQLTEST_VARDIR/tmp/t1; echo EOF; @@ -376,8 +390,10 @@ SET sql_mode = ''; --disable_ps2_protocol --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT '1 \\\\aa\n' INTO DUMPFILE '$file' --enable_ps2_protocol +--enable_cursor_protocol CREATE TABLE t1 (id INT, val1 CHAR(3)) ENGINE=MyISAM; @@ -389,17 +405,21 @@ SELECT * FROM t1; # show we can write this with OUTFILE, forcing the parameters for now --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --disable_ps2_protocol --eval SELECT * INTO OUTFILE '$file2' FIELDS ESCAPED BY '' TERMINATED BY ' ' FROM t1 --enable_ps2_protocol +--enable_cursor_protocol --diff_files $file $file2 --remove_file $file2 # now show the OUTFILE defaults are correct with NO_BACKSLASH_ESCAPES --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --disable_ps2_protocol --eval SELECT * INTO OUTFILE '$file2' FIELDS TERMINATED BY ' ' FROM t1 --enable_ps2_protocol +--enable_cursor_protocol --diff_files $file $file2 --remove_file $file2 @@ -432,9 +452,11 @@ INSERT INTO t1 (id, val1) VALUES (3, '\tx'); --echo 1.1 NO_BACKSLASH_ESCAPES, use defaults for ESCAPED BY --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --disable_ps2_protocol --eval SELECT * INTO OUTFILE '$file' FIELDS TERMINATED BY ' ' FROM t1 ORDER BY id --enable_ps2_protocol +--enable_cursor_protocol --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --eval LOAD DATA INFILE '$file' INTO TABLE t2 FIELDS TERMINATED BY ' ' @@ -451,9 +473,11 @@ eval SELECT LOAD_FILE("$file") as exp; --echo 1.2 NO_BACKSLASH_ESCAPES, override defaults for ESCAPED BY --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --disable_ps2_protocol --eval SELECT * INTO OUTFILE '$file' FIELDS ESCAPED BY '\' TERMINATED BY ' ' FROM t1 ORDER BY id --enable_ps2_protocol +--enable_cursor_protocol --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --eval LOAD DATA INFILE '$file' INTO TABLE t2 FIELDS ESCAPED BY '\' TERMINATED BY ' ' @@ -475,9 +499,11 @@ SET sql_mode = ''; --echo 2.1 !NO_BACKSLASH_ESCAPES, use defaults for ESCAPED BY --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --disable_ps2_protocol --eval SELECT * INTO OUTFILE '$file' FIELDS TERMINATED BY ' ' FROM t1 ORDER BY id --enable_ps2_protocol +--enable_cursor_protocol --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --eval LOAD DATA INFILE '$file' INTO TABLE t2 FIELDS TERMINATED BY ' ' @@ -500,9 +526,11 @@ SET sql_mode = ''; --echo 2.2 !NO_BACKSLASH_ESCAPES, override defaults for ESCAPED BY --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --disable_ps2_protocol --eval SELECT * INTO OUTFILE '$file' FIELDS ESCAPED BY '' TERMINATED BY ' ' FROM t1 ORDER BY id --enable_ps2_protocol +--enable_cursor_protocol --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --eval LOAD DATA INFILE '$file' INTO TABLE t2 FIELDS ESCAPED BY '' TERMINATED BY ' ' @@ -544,9 +572,11 @@ INSERT INTO t1 VALUES (1); SET NAMES latin1; SET character_set_filesystem=filename; select @@character_set_filesystem; +--disable_cursor_protocol --disable_ps2_protocol SELECT * INTO OUTFILE 't-1' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol DELETE FROM t1; LOAD DATA INFILE 't-1' INTO TABLE t1; SELECT * FROM t1; @@ -568,9 +598,11 @@ select @@character_set_filesystem; --echo # CREATE TABLE t1(col0 LONGBLOB); +--disable_cursor_protocol --disable_ps2_protocol SELECT 'test' INTO OUTFILE 't1.txt'; --enable_ps2_protocol +--enable_cursor_protocol LOAD DATA INFILE 't1.txt' IGNORE INTO TABLE t1 SET col0=col0; SELECT * FROM t1; @@ -639,9 +671,11 @@ disconnect con1; --echo # CREATE TABLE t1(f1 INT); +--disable_cursor_protocol --disable_ps2_protocol EVAL SELECT 0xE1BB30 INTO OUTFILE 't1.dat'; --enable_ps2_protocol +--enable_cursor_protocol --disable_warnings LOAD DATA INFILE 't1.dat' IGNORE INTO TABLE t1 CHARACTER SET utf8; --enable_warnings @@ -658,7 +692,9 @@ remove_file $MYSQLD_DATADIR/test/t1.dat; --disable_ps2_protocol --let $file=$MYSQLTEST_VARDIR/tmp/bug11735141.txt --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT '1\n' INTO DUMPFILE '$file' +--enable_cursor_protocol --enable_ps2_protocol create table t1(a point); @@ -745,9 +781,11 @@ CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE(b)); INSERT INTO t1 VALUES (1,1); CREATE TABLE t2 (c INT); CREATE VIEW v AS SELECT t1.* FROM t1 JOIN t2; +--disable_cursor_protocol --disable_ps2_protocol SELECT a, b INTO OUTFILE '15645.data' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol --error ER_WRONG_USAGE LOAD DATA INFILE '15645.data' IGNORE INTO TABLE v (a,b); --error ER_WRONG_USAGE diff --git a/mysql-test/main/log_slow.test b/mysql-test/main/log_slow.test index 8997b95d72c..1f33cff9f25 100644 --- a/mysql-test/main/log_slow.test +++ b/mysql-test/main/log_slow.test @@ -74,10 +74,12 @@ SET long_query_time=0.1; --echo # Although this query is disallowed by slow_query_log, it should still increment Slow_queries +--disable_cursor_protocol SELECT VARIABLE_VALUE INTO @global_slow_queries FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='SLOW_QUERIES'; SELECT sleep(0.2) INTO @tmp FROM DUAL; +--enable_cursor_protocol SELECT CAST(VARIABLE_VALUE AS UNSIGNED)-@global_slow_queries AS Slow_queries_increment FROM @@ -88,11 +90,13 @@ SELECT --echo # Although this query is disallowed by log_slow_filter, it should still increment Slow_queries SET log_slow_filter=filesort; +--disable_cursor_protocol SELECT sleep(0.2) INTO @tmp FROM DUAL; SELECT VARIABLE_VALUE INTO @global_slow_queries FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='SLOW_QUERIES'; SELECT sleep(0.2) INTO @tmp FROM DUAL; +--enable_cursor_protocol SELECT CAST(VARIABLE_VALUE AS UNSIGNED)-@global_slow_queries AS Slow_queries_increment FROM diff --git a/mysql-test/main/log_tables.test b/mysql-test/main/log_tables.test index 1169f2b094c..88211efa111 100644 --- a/mysql-test/main/log_tables.test +++ b/mysql-test/main/log_tables.test @@ -836,7 +836,9 @@ SET GLOBAL slow_query_log = @old_slow_query_log; --echo # Bug#21557 entries in the general query log truncated at 1000 characters. --echo # +--disable_cursor_protocol select CONNECTION_ID() into @thread_id; +--enable_cursor_protocol --disable_ps_protocol truncate table mysql.general_log; --enable_ps_protocol @@ -1006,9 +1008,12 @@ INSERT INTO t1 VALUES (3,3,3); INSERT INTO t1 VALUES (4,4,4); --disable_ps2_protocol +#Enable after fix MDEV-31522 +--disable_cursor_protocol SELECT SQL_NO_CACHE 'Bug#31700 - SCAN',f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f3=4; SELECT SQL_NO_CACHE 'Bug#31700 - KEY', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f2=3; SELECT SQL_NO_CACHE 'Bug#31700 - PK', f1,f2,f3,SLEEP(1.1) FROM t1 WHERE f1=2; +--enable_cursor_protocol --replace_column 1 TIMESTAMP SELECT start_time, rows_examined, rows_sent, sql_text FROM mysql.slow_log WHERE sql_text LIKE '%Bug#31700%' ORDER BY start_time; diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index aa89a78e0bd..2f85328bda3 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -12,9 +12,11 @@ insert into t1 () values (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(), (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(), (),(),(),(); +--disable_cursor_protocol --disable_ps2_protocol select * into outfile 'load.data' from t1; --enable_ps2_protocol +--enable_cursor_protocol create temporary table tmp (a varchar(1024), b int, c int, d int, e linestring, unique (e)); load data infile 'load.data' into table tmp; delete from tmp; @@ -226,9 +228,11 @@ drop table t1; --echo # CREATE TABLE t1 (data VARCHAR(4), unique(data) using hash) with system versioning; INSERT INTO t1 VALUES ('A'); +--disable_cursor_protocol --disable_ps2_protocol SELECT * INTO OUTFILE 'load.data' from t1; --enable_ps2_protocol +--enable_cursor_protocol --error ER_DUP_ENTRY LOAD DATA INFILE 'load.data' INTO TABLE t1; select * from t1; @@ -242,9 +246,11 @@ DROP TABLE t1; CREATE TABLE t1 (data VARCHAR(7961)) ENGINE=InnoDB; INSERT INTO t1 VALUES ('f'), ('o'), ('o'); +--disable_cursor_protocol --disable_ps2_protocol SELECT * INTO OUTFILE 'load.data' from t1; --enable_ps2_protocol +--enable_cursor_protocol ALTER IGNORE TABLE t1 ADD UNIQUE INDEX (data); SELECT * FROM t1; @@ -509,9 +515,11 @@ drop table t2; --echo # create table t1 (pk int primary key, f blob, unique(f)) engine=innodb; insert t1 values (1, null); +--disable_cursor_protocol --disable_ps2_protocol select * into outfile 't1.data' from t1; --enable_ps2_protocol +--enable_cursor_protocol load data infile 't1.data' replace into table t1; select * from t1; drop table t1; diff --git a/mysql-test/main/lowercase_table_qcache.test b/mysql-test/main/lowercase_table_qcache.test index b6047a98c74..ceff2719353 100644 --- a/mysql-test/main/lowercase_table_qcache.test +++ b/mysql-test/main/lowercase_table_qcache.test @@ -13,6 +13,7 @@ set LOCAL query_cache_type=ON; drop database if exists MySQLtesT; --enable_warnings +--disable_cursor_protocol create database MySQLtesT; create table MySQLtesT.t1 (a int); select * from MySQLtesT.t1; @@ -30,6 +31,7 @@ disable_result_log; select * from MySQL.db; enable_result_log; show status like "Qcache_queries_in_cache"; +--enable_cursor_protocol set GLOBAL query_cache_size=@save_query_cache_size; set GLOBAL query_cache_type=default; diff --git a/mysql-test/main/mdev-21101.test b/mysql-test/main/mdev-21101.test index 543b587c5e6..99a8c3006e5 100644 --- a/mysql-test/main/mdev-21101.test +++ b/mysql-test/main/mdev-21101.test @@ -10,12 +10,14 @@ # different connections simultaneously, to force queueing occurs. # Verify connections are intact, even if queueing time exceeds wait_timeout +--disable_cursor_protocol SELECT @@global.wait_timeout, @@global.thread_pool_max_threads, @@global.thread_pool_size, @@global.thread_pool_oversubscribe, @@global.thread_pool_stall_limit INTO @_wait_timeout,@_thread_pool_max_threads,@_thread_pool_size, @_thread_pool_oversubscribe,@_thread_pool_stall_limit; +--enable_cursor_protocol SET @@global.wait_timeout=1, @@global.thread_pool_max_threads=2, diff --git a/mysql-test/main/myisam_debug.test b/mysql-test/main/myisam_debug.test index fcb134c0400..3e73e0c7345 100644 --- a/mysql-test/main/myisam_debug.test +++ b/mysql-test/main/myisam_debug.test @@ -48,10 +48,12 @@ let $wait_condition= INFO = "INSERT INTO t1(id) SELECT id FROM t2"; --source include/wait_condition.inc +--disable_cursor_protocol SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE = 'wait_in_enable_indexes' AND INFO = "INSERT INTO t1(id) SELECT id FROM t2" INTO @thread_id; +--enable_cursor_protocol KILL QUERY @thread_id; CHECK TABLE t1; diff --git a/mysql-test/main/mysqldump-max.test b/mysql-test/main/mysqldump-max.test index 49e54d542b8..6ff2f6733c7 100644 --- a/mysql-test/main/mysqldump-max.test +++ b/mysql-test/main/mysqldump-max.test @@ -81,8 +81,10 @@ drop table t6; # type to avoid Inno's column-number limits (~1000 columns) etc. # Here because it needs Inno-engine. +--disable_cursor_protocol SELECT @@global.default_storage_engine INTO @old_engine; SET GLOBAL default_storage_engine=InnoDB; +--enable_cursor_protocol --disable_query_log CREATE TABLE `t1` ( diff --git a/mysql-test/main/null.test b/mysql-test/main/null.test index 35ffb01d3c7..824be41739f 100644 --- a/mysql-test/main/null.test +++ b/mysql-test/main/null.test @@ -326,7 +326,10 @@ SELECT NOT NOT NULLIF(2,3); CREATE TABLE t1 (a YEAR(2)); INSERT INTO t1 VALUES (0); SELECT a,NULLIF(a,2000),NULLIF(2000,a) FROM t1; +# Enable after fix MDEV-31722 +--disable_cursor_protocol SELECT a,NULLIF(a,2001),NULLIF(2001,a) FROM t1; +--enable_cursor_protocol DROP TABLE t1; --echo # diff --git a/mysql-test/main/null_key.test b/mysql-test/main/null_key.test index 0759e99b524..e1a3784afb2 100644 --- a/mysql-test/main/null_key.test +++ b/mysql-test/main/null_key.test @@ -234,11 +234,13 @@ EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b; FLUSH STATUS ; --disable_ps2_protocol +--disable_cursor_protocol SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a LEFT JOIN t3 ON t2.b=t3.b; --disable_view_protocol SELECT FOUND_ROWS(); +--enable_cursor_protocol SHOW STATUS LIKE "handler_read%"; --enable_view_protocol --enable_ps2_protocol diff --git a/mysql-test/main/order_by.test b/mysql-test/main/order_by.test index 47ead9e9e5e..9165a2e5beb 100644 --- a/mysql-test/main/order_by.test +++ b/mysql-test/main/order_by.test @@ -832,7 +832,10 @@ eval set @tmp_tables_before = CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED); --enable_query_log +#Enable after fix MDEV-31548 +--disable_cursor_protocol SELECT a FROM t1 IGNORE INDEX FOR GROUP BY (a, ab) GROUP BY a; +--enable_cursor_protocol # this query creates one temporary table in itself, which we are not # interested in. @@ -854,7 +857,10 @@ eval set @tmp_tables_before = CAST(REPLACE('$q', 'Created_tmp_tables', '') AS UNSIGNED); --enable_query_log +#Enable after fix MDEV-31548 +--disable_cursor_protocol SELECT a FROM t1 IGNORE INDEX FOR ORDER BY (a, ab) ORDER BY a; +--enable_cursor_protocol --disable_query_log --let $q = `show status like 'Created_tmp_tables';` @@ -1884,6 +1890,7 @@ insert into t1 analyze table t1; --enable_result_log +--disable_cursor_protocol --disable_view_protocol --disable_ps2_protocol explain @@ -1907,6 +1914,7 @@ select b, count(*) num_cnt from t1 show status like '%Handler_read%'; --enable_ps2_protocol --enable_view_protocol +--enable_cursor_protocol drop table t0, t1; diff --git a/mysql-test/main/order_by_pack_big.test b/mysql-test/main/order_by_pack_big.test index b83a5416e91..717027e3e5a 100644 --- a/mysql-test/main/order_by_pack_big.test +++ b/mysql-test/main/order_by_pack_big.test @@ -145,16 +145,20 @@ set sort_buffer_size= 2097152; --source include/analyze-format.inc eval ANALYZE FORMAT=JSON SELECT id, names, address FROM t3 ORDER BY names, address; flush status; +--disable_cursor_protocol --disable_ps2_protocol evalp SELECT id, names, address INTO OUTFILE '$file1' FROM t3 ORDER BY names, address; --enable_ps2_protocol +--enable_cursor_protocol --echo # Sort_merge_passes should be 0 show status like '%sort%'; +--disable_cursor_protocol --disable_ps2_protocol evalp SELECT id, names, address INTO OUTFILE '$file2' FROM t3 FORCE INDEX(idx) ORDER BY names, address; --enable_ps2_protocol +--enable_cursor_protocol diff_files $file1 $file2; @@ -171,9 +175,11 @@ set sort_buffer_size= 1097152; --source include/analyze-format.inc eval ANALYZE FORMAT=JSON SELECT id, names, address FROM t3 ORDER BY names, address; flush status; +--disable_cursor_protocol --disable_ps2_protocol evalp SELECT id, names, address INTO OUTFILE '$file1' FROM t3 ORDER BY names, address; --enable_ps2_protocol +--enable_cursor_protocol --echo # Sort_merge_passes should be 0 show status like '%sort%'; diff --git a/mysql-test/main/outfile.test b/mysql-test/main/outfile.test index 7f8f31bc748..f9bd76dcd95 100644 --- a/mysql-test/main/outfile.test +++ b/mysql-test/main/outfile.test @@ -21,29 +21,41 @@ drop table if exists t1; create table t1 (`a` blob); insert into t1 values("hello world"),("Hello mars"),(NULL); disable_query_log; +--disable_cursor_protocol eval select * into outfile "../../tmp/outfile-test.1" from t1; +--enable_cursor_protocol enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.1")); disable_query_log; +--disable_cursor_protocol eval select * into dumpfile "../../tmp/outfile-test.2" from t1 limit 1; +--enable_cursor_protocol enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.2")); disable_query_log; +--disable_cursor_protocol eval select * into dumpfile "../../tmp/outfile-test.3" from t1 where a is null; +--enable_cursor_protocol enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.3")); # the following should give errors disable_query_log; +--disable_cursor_protocol --error ER_FILE_EXISTS_ERROR eval select * into outfile "../../tmp/outfile-test.1" from t1; +--enable_cursor_protocol +--disable_cursor_protocol --error ER_FILE_EXISTS_ERROR eval select * into dumpfile "../../tmp/outfile-test.2" from t1; +--enable_cursor_protocol +--disable_cursor_protocol --error ER_FILE_EXISTS_ERROR eval select * into dumpfile "../../tmp/outfile-test.3" from t1; +--enable_cursor_protocol enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.not-exist")); --remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.1 @@ -53,7 +65,9 @@ drop table t1; # Bug#8191 SELECT INTO OUTFILE insists on FROM clause disable_query_log; +--disable_cursor_protocol eval select 1 into outfile "../../tmp/outfile-test.4"; +--enable_cursor_protocol enable_query_log; select load_file(concat(@tmpdir,"/outfile-test.4")); --remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4 @@ -76,17 +90,21 @@ DROP TABLE t1; # Bug#13202 SELECT * INTO OUTFILE ... FROM information_schema.schemata now fails # disable_query_log; +--disable_cursor_protocol eval SELECT * INTO OUTFILE "../../tmp/outfile-test.4" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM information_schema.schemata LIMIT 0, 5; +--enable_cursor_protocol # enable_query_log; --remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4 use information_schema; # disable_query_log; +--disable_cursor_protocol eval SELECT * INTO OUTFILE "../../tmp/outfile-test.4" FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' FROM schemata LIMIT 0, 5; +--enable_cursor_protocol enable_query_log; --remove_file $MYSQLTEST_VARDIR/tmp/outfile-test.4 use test; @@ -97,8 +115,10 @@ use test; # It should not be possible to write to a file outside of vardir create table t1(a int); --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR +--disable_cursor_protocol --error ER_OPTION_PREVENTS_STATEMENT eval select * into outfile "$MYSQL_TEST_DIR/outfile-test1" from t1; +--enable_cursor_protocol drop table t1; # @@ -110,6 +130,7 @@ create user user_1@localhost; grant all on mysqltest.* to user_1@localhost; connect (con28181_1,localhost,user_1,,mysqltest); +--disable_cursor_protocol --error ER_ACCESS_DENIED_ERROR eval select schema_name into outfile "../../tmp/outfile-test.4" @@ -117,18 +138,21 @@ fields terminated by ',' optionally enclosed by '"' lines terminated by '\n' from information_schema.schemata where schema_name like 'mysqltest'; +--enable_cursor_protocol connection default; disconnect con28181_1; grant file on *.* to user_1@localhost; connect (con28181_2,localhost,user_1,,mysqltest); +--disable_cursor_protocol eval select schema_name into outfile "../../tmp/outfile-test.4" fields terminated by ',' optionally enclosed by '"' lines terminated by '\n' from information_schema.schemata where schema_name like 'mysqltest'; +--enable_cursor_protocol connection default; disconnect con28181_2; diff --git a/mysql-test/main/outfile_loaddata.test b/mysql-test/main/outfile_loaddata.test index 64a40714b5a..f308aadecc4 100644 --- a/mysql-test/main/outfile_loaddata.test +++ b/mysql-test/main/outfile_loaddata.test @@ -15,7 +15,9 @@ INSERT INTO t1 VALUES (101, 202, '-r-', '=raker='); --echo # $clauses, warning: --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1 +--enable_cursor_protocol --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt') as exp --eval CREATE TABLE t2 SELECT $fields FROM t1 @@ -30,7 +32,9 @@ DROP TABLE t2; --echo # Only numeric fields, $clauses, no warnings: --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1 +--enable_cursor_protocol --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt') as exp --eval CREATE TABLE t2 SELECT $fields FROM t1 @@ -45,7 +49,9 @@ DROP TABLE t2; --echo # $clauses, warning: --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1 +--enable_cursor_protocol --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt') as exp --eval CREATE TABLE t2 SELECT $fields FROM t1 @@ -60,7 +66,9 @@ DROP TABLE t2; --echo # $clauses, warning: --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1 +--enable_cursor_protocol --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt') as exp --eval CREATE TABLE t2 SELECT $fields FROM t1 @@ -75,7 +83,9 @@ DROP TABLE t2; --echo # Only string fields, $clauses, no warnings: --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT $fields INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/bug31663.txt' $clauses FROM t1 +--enable_cursor_protocol --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --eval SELECT LOAD_FILE('$MYSQLTEST_VARDIR/tmp/bug31663.txt') as exp --eval CREATE TABLE t2 SELECT $fields FROM t1 @@ -98,7 +108,9 @@ SELECT HEX(c1) FROM t1; --let $file=$MYSQLTEST_VARDIR/tmp/bug32533.txt --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT * INTO OUTFILE '$file' FIELDS ENCLOSED BY 0xC3 FROM t1 +--enable_cursor_protocol TRUNCATE t1; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR @@ -133,13 +145,17 @@ INSERT INTO t1 VALUES (1, 'ABC-АБВ', 'DEF-ÂÃÄ'), (2, NULL, NULL); --echo # Error on multi-character ENCLOSED/ESCAPED BY --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --error 1083 --eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS ENCLOSED BY '12345' +--enable_cursor_protocol --remove_file $file --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --error 1083 --eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS ESCAPED BY '12345' +--enable_cursor_protocol --remove_file $file @@ -147,21 +163,27 @@ INSERT INTO t1 VALUES (1, 'ABC-АБВ', 'DEF-ÂÃÄ'), (2, NULL, NULL); --echo # LOAD DATA rises error or has unpredictable result -- to be fixed later --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS ENCLOSED BY 'ъ' +--enable_cursor_protocol --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --error 1083 # backward compatibility --eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary FIELDS ENCLOSED BY 'ъ' --remove_file $file --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS ESCAPED BY 'ъ' +--enable_cursor_protocol --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --error 1083 # backward compatibility --eval LOAD DATA INFILE '$file' INTO TABLE t2 CHARACTER SET binary FIELDS ESCAPED BY 'ъ' --remove_file $file --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT * FROM t1 INTO OUTFILE '$file' FIELDS TERMINATED BY 'ъ' +--enable_cursor_protocol --echo ################################################## --cat_file $file --echo ################################################## @@ -174,7 +196,9 @@ SELECT * FROM t1; SELECT * FROM t2; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT * FROM t1 INTO OUTFILE '$file' LINES STARTING BY 'ъ' +--enable_cursor_protocol --echo ################################################## --cat_file $file --echo ################################################## @@ -185,7 +209,9 @@ TRUNCATE t2; SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT * FROM t1 INTO OUTFILE '$file' LINES TERMINATED BY 'ъ' +--enable_cursor_protocol --echo ################################################## --cat_file $file --echo ################################################## @@ -200,7 +226,9 @@ SELECT * FROM t2; --echo # Default (binary) charset: --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT * INTO OUTFILE '$file' FROM t1 +--enable_cursor_protocol --echo ################################################## --cat_file $file --echo ################################################## @@ -214,7 +242,9 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; --echo # latin1 charset (INTO OUTFILE warning is expected): --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT * INTO OUTFILE '$file' CHARACTER SET latin1 FROM t1 +--enable_cursor_protocol --echo ################################################## --cat_file $file --echo ################################################## @@ -228,7 +258,9 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; --echo # KOI8-R charset (INTO OUTFILE warning is expected): --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT * INTO OUTFILE '$file' CHARACTER SET koi8r FROM t1 +--enable_cursor_protocol --echo ################################################## --cat_file $file --echo ################################################## @@ -242,7 +274,9 @@ SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a, b, c; --echo # UTF-8 charset: --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT * INTO OUTFILE '$file' CHARACTER SET utf8 FROM t1 +--enable_cursor_protocol --echo ################################################## --cat_file $file --echo ################################################## @@ -274,7 +308,9 @@ let $length= 800; --eval INSERT INTO t1 VALUES (REPEAT('.', $length)) --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --eval SELECT * INTO OUTFILE $file CHARACTER SET latin1 FROM t1 +--enable_cursor_protocol --echo # should be greater than $length --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index 8565667acdb..008e0c74bc1 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -896,6 +896,7 @@ SELECT 1 FROM t1 UNION SELECT 1 FROM t1 ORDER BY 1 LIMIT 1 FOR UPDATE; --echo # "INTO" clause tests +--disable_cursor_protocol SELECT 1 FROM t1 INTO @var17727401; SELECT 1 FROM DUAL INTO @var17727401; SELECT 1 INTO @var17727401; @@ -940,6 +941,7 @@ SELECT 1 INTO @var17727401 FROM t1 PROCEDURE ANALYSE(); --error ER_PARSE_ERROR SELECT 1 FROM t1 PROCEDURE ANALYSE() INTO @var17727401; +--enable_cursor_protocol --echo # ORDER and LIMIT clause combinations diff --git a/mysql-test/main/partition.test b/mysql-test/main/partition.test index cc23286b794..b3ea7f5c274 100644 --- a/mysql-test/main/partition.test +++ b/mysql-test/main/partition.test @@ -474,6 +474,7 @@ INSERT INTO `t2` VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13), EXPLAIN PARTITIONS SELECT c1 FROM t1 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20); +--disable_cursor_protocol --disable_ps2_protocol FLUSH STATUS; SELECT c1 FROM t1 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20); @@ -486,6 +487,7 @@ SELECT c1 FROM t2 WHERE (c1 > 10 AND c1 < 13) OR (c1 > 17 AND c1 < 20); SHOW STATUS LIKE 'Handler_read_%'; DROP TABLE t1,t2; --enable_ps2_protocol +--enable_cursor_protocol # Bug#37329 Range scan on partitioned tables shows higher Handler_read_next # (marked as duplicate of Bug#35931) @@ -507,6 +509,7 @@ INSERT INTO `t2` VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12),(13), EXPLAIN PARTITIONS SELECT c1 FROM t1 WHERE (c1 > 2 AND c1 < 5); +--disable_cursor_protocol --disable_ps2_protocol FLUSH STATUS; SELECT c1 FROM t1 WHERE (c1 > 2 AND c1 < 5); @@ -531,6 +534,7 @@ SELECT c1 FROM t2 WHERE (c1 > 12 AND c1 < 15); SHOW STATUS LIKE 'Handler_read_%'; DROP TABLE t1,t2; --enable_ps2_protocol +--enable_cursor_protocol --error ER_PARTITION_FUNCTION_IS_NOT_ALLOWED create table t1 (a int) partition by list ((a/3)*10 div 1) diff --git a/mysql-test/main/partition_csv.test b/mysql-test/main/partition_csv.test index 44013dd4b0a..2057d8cac3b 100644 --- a/mysql-test/main/partition_csv.test +++ b/mysql-test/main/partition_csv.test @@ -57,7 +57,9 @@ ALTER TABLE gl_partitioned PARTITION BY HASH (thread_id) PARTITIONS 10; ALTER TABLE general_log RENAME TO gl_nonpartitioned; ALTER TABLE gl_partitioned RENAME TO general_log; +--disable_cursor_protocol SELECT @@global.log_output INTO @old_glo; +--enable_cursor_protocol SET GLOBAL log_output='table'; SET GLOBAL general_log =1; diff --git a/mysql-test/main/partition_explicit_prune.test b/mysql-test/main/partition_explicit_prune.test index 610bdf4435b..3136cab4443 100644 --- a/mysql-test/main/partition_explicit_prune.test +++ b/mysql-test/main/partition_explicit_prune.test @@ -9,6 +9,7 @@ WHERE VARIABLE_NAME LIKE 'HANDLER_%' AND VARIABLE_VALUE > 0; --echo # --echo # Bug#13559657: PARTITION SELECTION DOES NOT WORK WITH VIEWS --echo # +--disable_cursor_protocol --disable_view_protocol --disable_ps2_protocol CREATE TABLE t1 (a int) @@ -623,6 +624,7 @@ SELECT * FROM t3 PARTITION (pNeg); DROP TABLE t1, t2, t3; --enable_ps2_protocol --enable_view_protocol +--enable_cursor_protocol --echo # Test from superseeded WL# 2682 # Partition select tests. # diff --git a/mysql-test/main/plugin.test b/mysql-test/main/plugin.test index 9151a6e905c..6d03f0fd8f8 100644 --- a/mysql-test/main/plugin.test +++ b/mysql-test/main/plugin.test @@ -87,7 +87,9 @@ UNINSTALL PLUGIN example; # INSTALL PLUGIN example SONAME 'ha_example'; +--disable_cursor_protocol select @@session.sql_mode into @old_sql_mode; +--enable_cursor_protocol # first, try normal sql_mode (no error, send OK) set session sql_mode=''; diff --git a/mysql-test/main/processlist.test b/mysql-test/main/processlist.test index 7e60f196f65..1d3827fd7a2 100644 --- a/mysql-test/main/processlist.test +++ b/mysql-test/main/processlist.test @@ -66,7 +66,10 @@ set debug_sync='reset'; SET NAMES utf8; --vertical_results +#Check after fix MDEV-31514 +--disable_cursor_protocol SELECT INFO, INFO_BINARY, 'xxx😎yyy' AS utf8mb4_string FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO LIKE '%xxx%yyy%'; +--enable_cursor_protocol --horizontal_results --echo # diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test index 99a479f854c..160c471154b 100644 --- a/mysql-test/main/ps.test +++ b/mysql-test/main/ps.test @@ -2002,7 +2002,10 @@ prepare stmt from "create view v1 as select * from `t1` `b`"; prepare stmt from "select ?"; set @arg= 123456789.987654321; +#Enable after fix MDEV-31495 +--disable_cursor_protocol select @arg; +--enable_cursor_protocol execute stmt using @arg; set @arg= "string"; select @arg; @@ -2011,7 +2014,10 @@ set @arg= 123456; select @arg; execute stmt using @arg; set @arg= cast(-12345.54321 as decimal(20, 10)); +#Enable after fix MDEV-31495 +--disable_cursor_protocol select @arg; +--enable_cursor_protocol execute stmt using @arg; deallocate prepare stmt; @@ -3335,6 +3341,8 @@ SELECT @x_str_1, @x_int_1, @x_int_2, @x_int_3; --echo --echo -- Testing decs... +#Enable after fix MDEV-31495 +--disable_cursor_protocol --echo EXECUTE stmt_dec USING @x_int_1, @x_dec_1, @x_dec_2, @x_dec_3; SELECT @x_int_1, @x_dec_1, @x_dec_2, @x_dec_3; @@ -3342,6 +3350,7 @@ SELECT @x_int_1, @x_dec_1, @x_dec_2, @x_dec_3; --echo EXECUTE stmt_dec USING @x_int_1, @x_dec_1, @x_dec_2, @x_dec_3; SELECT @x_int_1, @x_dec_1, @x_dec_2, @x_dec_3; +--enable_cursor_protocol --echo DEALLOCATE PREPARE stmt_str; @@ -3574,7 +3583,9 @@ execute st; show status like '%Handler_read%'; flush status; --disable_ps2_protocol +--disable_cursor_protocol select * from t1 use index() where a=3; +--enable_cursor_protocol show status like '%Handler_read%'; --enable_ps2_protocol flush status; diff --git a/mysql-test/main/query_cache.test b/mysql-test/main/query_cache.test index 88d226cdcc4..2a9f34c7cf1 100644 --- a/mysql-test/main/query_cache.test +++ b/mysql-test/main/query_cache.test @@ -21,6 +21,7 @@ SET LOCAL query_cache_type= ON; # Reset query cache variables. +--disable_cursor_protocol flush query cache; # This crashed in some versions flush query cache; # This crashed in some versions reset query cache; @@ -1802,6 +1803,7 @@ SELECT foo( LAST_INSERT_ID() ) from t1; show status like "Qcache_queries_in_cache"; DROP FUNCTION foo; drop table t1; +--enable_cursor_protocol --echo # --echo # MDEV-33861: main.query_cache fails with embedded after diff --git a/mysql-test/main/query_cache_debug.test b/mysql-test/main/query_cache_debug.test index 5942e6f42aa..d9c6cb1c94f 100644 --- a/mysql-test/main/query_cache_debug.test +++ b/mysql-test/main/query_cache_debug.test @@ -94,7 +94,9 @@ connection con1; --reap SHOW STATUS LIKE "Qcache_queries_in_cache"; --echo # Test that it's cacheable +--disable_cursor_protocol SELECT * FROM t1; +--enable_cursor_protocol SHOW STATUS LIKE "Qcache_queries_in_cache"; disconnect con1; diff --git a/mysql-test/main/query_cache_innodb.test b/mysql-test/main/query_cache_innodb.test index 7ac96220c11..143cc5ee6d6 100644 --- a/mysql-test/main/query_cache_innodb.test +++ b/mysql-test/main/query_cache_innodb.test @@ -20,7 +20,9 @@ create table t2 ( t2id int unsigned, id int unsigned, primary key(t2id, id), for --disable_view_protocol insert into t1 values (1); insert into t2 values (1,1); +--disable_cursor_protocol select * from t2; +--enable_cursor_protocol show status like "Qcache_queries_in_cache"; delete from t1; @@ -41,7 +43,9 @@ create table `t2$ї` ( t2id int unsigned, id int unsigned, primary key(t2id, id) insert into `t1$ї` values (1); insert into `t2$ї`values (1,1); +--disable_cursor_protocol select * from `t2$ї`; +--enable_cursor_protocol show status like "Qcache_queries_in_cache"; delete from `t1$ї`; @@ -63,7 +67,9 @@ create table `#mysql50#t-2` ( t2id int unsigned, id int unsigned, primary key(t2 insert into `#mysql50#t-1` values (1); insert into `#mysql50#t-2`values (1,1); +--disable_cursor_protocol select * from `#mysql50#t-2`; +--enable_cursor_protocol show status like "Qcache_queries_in_cache"; delete from `#mysql50#t-1`; diff --git a/mysql-test/main/query_cache_merge.test b/mysql-test/main/query_cache_merge.test index c3267d628b9..bca3fb352d1 100644 --- a/mysql-test/main/query_cache_merge.test +++ b/mysql-test/main/query_cache_merge.test @@ -40,6 +40,7 @@ while ($1) # --disable_ps2_protocol --disable_view_protocol +--disable_cursor_protocol set @save_table_definition_cache= @@global.table_definition_cache; set @@global.table_definition_cache=512; create table t00 (a int) engine=MERGE UNION=(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257) INSERT_METHOD=FIRST; @@ -54,6 +55,7 @@ drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t2 SET @@global.query_cache_size=0; set @@global.table_definition_cache=@save_table_definition_cache; +--enable_cursor_protocol --enable_view_protocol --enable_ps2_protocol @@ -88,8 +90,10 @@ eval CREATE TABLE t0 (a INT) ENGINE=MERGE UNION($str); SET GLOBAL query_cache_size = 1048576; FLUSH STATUS; --disable_view_protocol +--disable_cursor_protocol SELECT a FROM t0 WHERE a = 1; SHOW STATUS LIKE "Qcache_queries_in_cache"; +--enable_cursor_protocol --enable_view_protocol let $c= 255; diff --git a/mysql-test/main/query_cache_notembedded.test b/mysql-test/main/query_cache_notembedded.test index 5f97dc5c00d..73fc4340bf1 100644 --- a/mysql-test/main/query_cache_notembedded.test +++ b/mysql-test/main/query_cache_notembedded.test @@ -26,6 +26,7 @@ drop table if exists t1, t2, t3, t11, t21; # # FLUSH QUERY CACHE # +--disable_cursor_protocol create table t1 (a int not null); insert into t1 values (1),(2),(3); create table t2 (a int not null); @@ -85,6 +86,7 @@ flush query cache; show status like "Qcache_total_blocks"; show status like "Qcache_free_blocks"; drop table t1, t2, t3, t11, t21; +--enable_cursor_protocol # # do not use QC if tables locked (Bug#12385) @@ -114,6 +116,7 @@ disconnect root2; # improved to also test Bug#3583 and Bug#12990 # --disable_ps2_protocol +--disable_cursor_protocol flush query cache; reset query cache; flush status; @@ -186,6 +189,7 @@ call f1(); call f3(); call f3(); call f1(); +--enable_cursor_protocol drop procedure f1; drop procedure f2; @@ -248,6 +252,7 @@ SET @@global.log_bin_trust_function_creators = @old_log_bin_trust_function_creat # # Bug #30269 Query cache eats memory # +--disable_cursor_protocol --disable_warnings DROP DATABASE IF EXISTS bug30269; --enable_warnings @@ -269,6 +274,7 @@ SELECT id FROM test1 WHERE id>2; show status like 'Qcache_queries_in_cache'; SELECT id FROM view1 WHERE id>2; show status like 'Qcache_queries_in_cache'; +--enable_cursor_protocol connection default; USE test; diff --git a/mysql-test/main/query_cache_with_views.test b/mysql-test/main/query_cache_with_views.test index 6740c70883e..c1e3ed96cd3 100644 --- a/mysql-test/main/query_cache_with_views.test +++ b/mysql-test/main/query_cache_with_views.test @@ -18,6 +18,7 @@ set GLOBAL query_cache_size=1355776; flush status; create table t1 (a int, b int); +--disable_cursor_protocol # queries with following views should not be in query cache create view v1 (c,d) as select sql_no_cache a,b from t1; create view v2 (c,d) as select a+rand(),b from t1; @@ -66,6 +67,7 @@ show status like "Qcache_hits"; drop view v1; set query_cache_type=default; --enable_ps2_protocol +--enable_cursor_protocol drop table t1; @@ -110,6 +112,7 @@ drop table t1; # # BUG#15119: returning temptable view from the query cache. # +--disable_cursor_protocol --disable_ps2_protocol flush status; create table t1 (a int, b int); @@ -137,6 +140,7 @@ show status like "Qcache_inserts"; show status like "Qcache_hits"; drop table t1; --enable_ps2_protocol +--enable_cursor_protocol --echo # --echo # Bug46615 Assertion in Query_cache::invalidate in INSERT in a VIEW of a MERGE table diff --git a/mysql-test/main/range_vs_index_merge.test b/mysql-test/main/range_vs_index_merge.test index c71811fa74d..6b480e327dc 100644 --- a/mysql-test/main/range_vs_index_merge.test +++ b/mysql-test/main/range_vs_index_merge.test @@ -698,6 +698,7 @@ DROP INDEX CityName on City; CREATE INDEX Name ON City(Name); CREATE INDEX Population ON City(Population); +--disable_cursor_protocol --disable_ps2_protocol --disable_view_protocol --replace_column 9 # @@ -761,6 +762,7 @@ ORDER BY Population LIMIT 5; SHOW STATUS LIKE 'Handler_read_%'; --enable_view_protocol --enable_ps2_protocol +--enable_cursor_protocol set optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/main/select.test b/mysql-test/main/select.test index 14035f81590..ecded18dc76 100644 --- a/mysql-test/main/select.test +++ b/mysql-test/main/select.test @@ -1845,10 +1845,15 @@ select wss_type from t1 where wss_type ='102935229216544104'; select wss_type from t1 where wss_type ='102935229216544093'; select wss_type from t1 where wss_type =102935229216544093; drop table t1; +--disable_cursor_protocol select 1+2,"aaaa",3.13*2.0 into @a,@b,@c; +--enable_cursor_protocol select @a; select @b; +#Enable after fix MDEV-31495 +--disable_cursor_protocol select @c; +--enable_cursor_protocol # # Test of removing redundant braces in the FROM part @@ -2198,7 +2203,10 @@ INSERT INTO t1 (SELECT * FROM t1 WHERE a = 50 AND b = 3); select found_rows(); SELECT * FROM t1; +# Check after fix MDEV-31522 +--disable_cursor_protocol select count(*) from t1; +--enable_cursor_protocol select found_rows(); select count(*) from t1 limit 2,3; select found_rows(); @@ -3727,6 +3735,7 @@ DROP TABLE t1; # # Bug #32942 now() - interval '7200' second is NOT pre-calculated, causing "full table scan" # +--disable_cursor_protocol --disable_ps2_protocol --disable_view_protocol CREATE TABLE t1 (a INT, b INT); @@ -3744,6 +3753,7 @@ SHOW STATUS LIKE 'Handler_read%'; DROP TABLE t1, t2; --enable_view_protocol --enable_ps2_protocol +--enable_cursor_protocol # # Bug#40953 SELECT query throws "ERROR 1062 (23000): Duplicate entry..." error @@ -3820,10 +3830,12 @@ CREATE TABLE t1(a INT); INSERT INTO t1 VALUES (2),(3); --echo # Should not crash +--disable_cursor_protocol --error ER_SUBQUERY_NO_1_ROW SELECT 1 FROM t1 WHERE a <> 1 AND NOT ROW(1,a) <=> ROW(1,(SELECT 1 FROM t1)) INTO @var0; +--enable_cursor_protocol DROP TABLE t1; diff --git a/mysql-test/main/select_found.test b/mysql-test/main/select_found.test index dac16fdb727..abbfd6cc3ef 100644 --- a/mysql-test/main/select_found.test +++ b/mysql-test/main/select_found.test @@ -178,14 +178,19 @@ DROP TABLE t1; # # Bug #6089: queries which don't use any tables # - +# Check after fix MDEV-31522 +--disable_cursor_protocol SELECT 'foo'; +--enable_cursor_protocol SELECT FOUND_ROWS(); SELECT SQL_CALC_FOUND_ROWS 'foo'; SELECT FOUND_ROWS(); SELECT SQL_CALC_FOUND_ROWS 'foo' limit 0; +# Check after fix MDEV-31522 +--disable_cursor_protocol SELECT FOUND_ROWS(); SELECT FOUND_ROWS(); +--enable_cursor_protocol SELECT SQL_CALC_FOUND_ROWS 'foo' UNION SELECT 'bar' LIMIT 0; SELECT FOUND_ROWS(); diff --git a/mysql-test/main/shutdown_not_windows.test b/mysql-test/main/shutdown_not_windows.test index 43063ced494..9e5246cc3f8 100644 --- a/mysql-test/main/shutdown_not_windows.test +++ b/mysql-test/main/shutdown_not_windows.test @@ -9,7 +9,9 @@ source include/have_debug.inc; call mtr.add_suppression('Thread .* did not exit'); set @old_dbug=@@global.debug_dbug; set global debug_dbug='+d,CONNECT_wait'; +--disable_cursor_protocol select variable_value into @cons from information_schema.global_status where variable_name='connections'; +--enable_cursor_protocol exec $MYSQL -e 'select sleep(3600)' >/dev/null 2>&1 &; let $wait_condition= select variable_value>@cons from information_schema.global_status where variable_name='connections'; source include/wait_condition.inc; diff --git a/mysql-test/main/single_delete_update.test b/mysql-test/main/single_delete_update.test index 0f2dc189e94..49a1b6b758d 100644 --- a/mysql-test/main/single_delete_update.test +++ b/mysql-test/main/single_delete_update.test @@ -12,6 +12,7 @@ --echo # limit efficiently --echo # +--disable_cursor_protocol CREATE TABLE t1 (i INT); INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19), (20),(21),(22),(23),(24),(25); @@ -457,3 +458,4 @@ SELECT * FROM t2 WHERE c = 10 ORDER BY a DESC, b DESC; DROP TABLE t1, t2; --enable_ps2_protocol +--enable_cursor_protocol diff --git a/mysql-test/main/sp-error.test b/mysql-test/main/sp-error.test index 800a9b503b6..c471ffae99f 100644 --- a/mysql-test/main/sp-error.test +++ b/mysql-test/main/sp-error.test @@ -11,7 +11,9 @@ drop table if exists t1, t2; --disable_ps2_protocol # Backup the mysql.proc table --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol eval SELECT * FROM mysql.proc INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/proc.txt'; +--enable_cursor_protocol --enable_ps2_protocol # Make sure we don't have any procedures left. diff --git a/mysql-test/main/sp-no-valgrind.test b/mysql-test/main/sp-no-valgrind.test index 6bacc7b150c..10a238f9871 100644 --- a/mysql-test/main/sp-no-valgrind.test +++ b/mysql-test/main/sp-no-valgrind.test @@ -5,18 +5,24 @@ --echo # Warmup round, this might allocate some memory for session variable --echo # and the output +--disable_cursor_protocol SELECT VARIABLE_VALUE into @global_mem_used FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='MEMORY_USED'; SELECT VARIABLE_VALUE into @local_mem_used FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='MEMORY_USED'; +--enable_cursor_protocol CREATE PROCEDURE sp0() SELECT 1; SHOW CREATE PROCEDURE sp0; DROP PROCEDURE sp0; #Check that CREATE/SHOW does not use memory in caches. +--disable_cursor_protocol SELECT VARIABLE_VALUE into @global_mem_used FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='MEMORY_USED'; SELECT VARIABLE_VALUE into @local_mem_used FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='MEMORY_USED'; +--enable_cursor_protocol CREATE PROCEDURE sp1() SELECT 1; SHOW CREATE PROCEDURE sp1; +--disable_cursor_protocol SELECT VARIABLE_VALUE-@local_mem_used FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='MEMORY_USED'; +--enable_cursor_protocol # FIXME: MDEV-26754 main.sp test fails for embedded server #SELECT VARIABLE_VALUE-@global_mem_used FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='MEMORY_USED'; DROP PROCEDURE sp1; diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test index d417bc636d4..c1e107b69e1 100644 --- a/mysql-test/main/sp.test +++ b/mysql-test/main/sp.test @@ -3019,8 +3019,10 @@ create procedure bug5251() begin end| +--disable_cursor_protocol select created into @c1 from mysql.proc where db='test' and name='bug5251'| +--enable_cursor_protocol --sleep 2 alter procedure bug5251 comment 'foobar'| select count(*) from mysql.proc @@ -8256,12 +8258,16 @@ drop procedure if exists p; --enable_warnings set @old_mode= @@sql_mode; set @@sql_mode= cast(pow(2,32)-1 as unsigned integer); +--disable_cursor_protocol select @@sql_mode into @full_mode; +--enable_cursor_protocol create procedure p() as begin end; call p(); set @@sql_mode= @old_mode; # Rename SQL modes that differ in name between the server and the table definition. +--disable_cursor_protocol select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mode; +--enable_cursor_protocol select name from mysql.proc where name = 'p' and sql_mode = @full_mode; drop procedure p; diff --git a/mysql-test/main/sp_trans.test b/mysql-test/main/sp_trans.test index b991cd49f70..bb71c195a08 100644 --- a/mysql-test/main/sp_trans.test +++ b/mysql-test/main/sp_trans.test @@ -610,9 +610,11 @@ drop table t3| # BUG#11758414: Default default_storage_engine not honored when set # from within a stored procedure # +--disable_cursor_protocol SELECT @@GLOBAL.default_storage_engine INTO @old_engine| SET @@GLOBAL.default_storage_engine=InnoDB| SET @@SESSION.default_storage_engine=InnoDB| +--enable_cursor_protocol # show defaults at define-time SHOW GLOBAL VARIABLES LIKE 'default_storage_engine'| SHOW SESSION VARIABLES LIKE 'default_storage_engine'| diff --git a/mysql-test/main/statistics.test b/mysql-test/main/statistics.test index e6b300b5db2..c690d2bb3ca 100644 --- a/mysql-test/main/statistics.test +++ b/mysql-test/main/statistics.test @@ -318,6 +318,7 @@ SELECT * FROM mysql.column_stats; --sorted_result SELECT * FROM mysql.index_stats; +--disable_cursor_protocol --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --disable_ps2_protocol eval @@ -330,6 +331,7 @@ SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/save_index_stats' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM mysql.index_stats WHERE index_name IN ('idx1', 'idx4'); --enable_ps2_protocol +--enable_cursor_protocol ALTER TABLE t1 CHANGE COLUMN b x varchar(30); SHOW CREATE TABLE t1; diff --git a/mysql-test/main/status2.test b/mysql-test/main/status2.test index 339e853f2fc..bf35890722e 100644 --- a/mysql-test/main/status2.test +++ b/mysql-test/main/status2.test @@ -27,6 +27,7 @@ CREATE EVENT ev1 ON SCHEDULE EVERY 1 SECOND CREATE TABLE t1 (c1 INT); CREATE TABLE t2 (c1 INT); +--disable_cursor_protocol --echo Assert Questions == 7 SHOW STATUS LIKE 'Questions'; SELECT testQuestion(); @@ -38,6 +39,7 @@ SHOW STATUS LIKE 'Questions'; SELECT 1; --echo Assert Questions == 13 SHOW STATUS LIKE 'Questions'; +--enable_cursor_protocol connect (con1,localhost,root,,); connection con1; SELECT 1; diff --git a/mysql-test/main/strict.test b/mysql-test/main/strict.test index 830f051a5f6..90afdd1c854 100644 --- a/mysql-test/main/strict.test +++ b/mysql-test/main/strict.test @@ -60,7 +60,10 @@ INSERT INTO t1 VALUES ('2004-2-30'); set @@sql_mode='ansi,traditional'; INSERT IGNORE INTO t1 VALUES('2004-02-29'),('2004-13-15'),('0000-00-00'); +#Enable after fix MDEV-31516 +--disable_cursor_protocol select * from t1; +--enable_cursor_protocol drop table t1; # Test difference in behaviour with InnoDB and MyISAM tables diff --git a/mysql-test/main/subselect.test b/mysql-test/main/subselect.test index 3f01e984125..89e7d18b2b2 100644 --- a/mysql-test/main/subselect.test +++ b/mysql-test/main/subselect.test @@ -71,10 +71,13 @@ SELECT ROW(1,2,3) = (SELECT 1,2,3); SELECT ROW(1,2,3) = (SELECT 1,2,1); SELECT ROW(1,2,3) < (SELECT 1,2,1); SELECT ROW(1,2,3) > (SELECT 1,2,1); +#enable after fix MDEV-31728 +--disable_cursor_protocol #enable after fix MDEV-28585 --disable_view_protocol SELECT ROW(1,2,3) = (SELECT 1,2,NULL); --enable_view_protocol +--enable_cursor_protocol SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a') AS m; SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b') AS m; SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b') AS m; @@ -507,8 +510,11 @@ select 1 IN (SELECT * from t1); select 3 IN (SELECT * from t1); select 10 IN (SELECT * from t1); select 1 > ALL (SELECT * from t1); +#enable after fix MDEV-31728 +--disable_cursor_protocol select 10 > ALL (SELECT * from t1); select 1 > ANY (SELECT * from t1); +--enable_cursor_protocol select 10 > ANY (SELECT * from t1); drop table t1; create table t1 (a varchar(20)); @@ -521,8 +527,11 @@ select 'A' IN (SELECT * from t1); select 'DEF' IN (SELECT * from t1); select 'XYZS' IN (SELECT * from t1); select 'A' > ALL (SELECT * from t1); +#enable after fix MDEV-31728 +--disable_cursor_protocol select 'XYZS' > ALL (SELECT * from t1); select 'A' > ANY (SELECT * from t1); +--enable_cursor_protocol select 'XYZS' > ANY (SELECT * from t1); drop table t1; create table t1 (a float); @@ -535,15 +544,21 @@ select 1.5 IN (SELECT * from t1); select 3.5 IN (SELECT * from t1); select 10.5 IN (SELECT * from t1); select 1.5 > ALL (SELECT * from t1); +#enable after fix MDEV-31728 +--disable_cursor_protocol select 10.5 > ALL (SELECT * from t1); select 1.5 > ANY (SELECT * from t1); +--enable_cursor_protocol update t1 set a=NULL where a=2.5; select 1.5 IN (SELECT * from t1); select 3.5 IN (SELECT * from t1); select 10.5 IN (SELECT * from t1); select 1.5 > ALL (SELECT * from t1); +#enable after fix MDEV-31728 +--disable_cursor_protocol select 10.5 > ALL (SELECT * from t1); select 1.5 > ANY (SELECT * from t1); +--enable_cursor_protocol select 10.5 > ANY (SELECT * from t1); --enable_view_protocol explain extended select (select a+1) from t1; @@ -1177,7 +1192,9 @@ let $outfile_rel= ../../tmp/subselect.out.file.1; --error 0,1 --remove_file $outfile_abs --enable_warnings +--disable_cursor_protocol eval select a, (select max(b) from t1) into outfile "$outfile_rel" from t1; +--enable_cursor_protocol delete from t1; eval load data infile "$outfile_rel" into table t1; --remove_file $outfile_abs @@ -3583,7 +3600,9 @@ DROP TABLE t1,t2; CREATE TABLE t1(a1 int); INSERT INTO t1 VALUES (1),(2); +--disable_cursor_protocol SELECT @@session.sql_mode INTO @old_sql_mode; +--enable_cursor_protocol SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; ## First a simpler query, illustrating the transformation @@ -3621,7 +3640,9 @@ INSERT INTO t1 VALUES (1),(2); CREATE TABLE t2(a1 int); INSERT INTO t2 VALUES (3); +--disable_cursor_protocol SELECT @@session.sql_mode INTO @old_sql_mode; +--enable_cursor_protocol SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; ## All these are subject to the transformation @@ -3642,7 +3663,9 @@ DROP TABLE t1, t2; create table t2(i int); insert into t2 values(0); +--disable_cursor_protocol SELECT @@session.sql_mode INTO @old_sql_mode; +--enable_cursor_protocol SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; CREATE VIEW v1 AS @@ -5018,7 +5041,9 @@ INSERT INTO t1 VALUES (1),(2); CREATE TABLE t2(a1 int); INSERT INTO t2 VALUES (3); +--disable_cursor_protocol SELECT @@session.sql_mode INTO @old_sql_mode; +--enable_cursor_protocol SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; ## All these are subject to the transformation @@ -5035,7 +5060,9 @@ DROP TABLE t1, t2; create table t2(i int); insert into t2 values(0); +--disable_cursor_protocol SELECT @@session.sql_mode INTO @old_sql_mode; +--enable_cursor_protocol SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; CREATE VIEW v1 AS @@ -5427,8 +5454,10 @@ DROP TABLE t1,t2,t3; CREATE TABLE t1(a1 int); INSERT INTO t1 VALUES (1),(2); - + +--disable_cursor_protocol SELECT @@session.sql_mode INTO @old_sql_mode; +--enable_cursor_protocol SET SESSION sql_mode='ONLY_FULL_GROUP_BY'; ## First a simpler query, illustrating the transformation @@ -5855,10 +5884,12 @@ FROM t2 alias1, t1 alias2, t1 alias3; --disable_ps2_protocol flush status; +--disable_cursor_protocol SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; +--enable_cursor_protocol show status like "subquery_cache%"; show status like '%Handler_read%'; @@ -5873,10 +5904,12 @@ FROM t2 alias1, t1 alias2, t1 alias3; flush status; +--disable_cursor_protocol SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; +--enable_cursor_protocol show status like "subquery_cache%"; show status like '%Handler_read%'; diff --git a/mysql-test/main/subselect3.inc b/mysql-test/main/subselect3.inc index 2258456f355..6516c6a6ef0 100644 --- a/mysql-test/main/subselect3.inc +++ b/mysql-test/main/subselect3.inc @@ -57,9 +57,11 @@ select a, oref, a in ( create table t3 (a int); insert into t3 values (NULL), (NULL); flush status; +--disable_cursor_protocol --disable_ps2_protocol select a in (select max(ie) from t1 where oref=4 group by grp) from t3; --enable_ps2_protocol +--enable_cursor_protocol show status like 'Handler_read_rnd_next'; select ' ^ This must show 11' Z; @@ -96,7 +98,9 @@ select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2; --disable_ps2_protocol flush status; +--disable_cursor_protocol select oref, a from t2 where a in (select a from t1 where oref=t2.oref); +--enable_cursor_protocol # This will only show access to t2: show status like '%Handler_read_rnd_next'; @@ -106,7 +110,9 @@ insert into t2 values (NULL, 0),(NULL, 0), (NULL, 0), (NULL, 0); set optimizer_switch='subquery_cache=off'; flush status; +--disable_cursor_protocol select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2; +--enable_cursor_protocol show status like '%Handler_read%'; select 'No key lookups, seq reads: 29= 5 reads from t2 + 4 * 6 reads from t1.' Z; set @@optimizer_switch=@save_optimizer_switch; @@ -641,9 +647,11 @@ DROP TABLE t1, t2; create table t1 (a int, b decimal(13, 3)); insert into t1 values (1, 0.123); +--disable_cursor_protocol --disable_ps2_protocol select a, (select max(b) from t1) into outfile "../../tmp/subselect.out.file.1" from t1; --enable_ps2_protocol +--enable_cursor_protocol delete from t1; load data infile "../../tmp/subselect.out.file.1" into table t1; select * from t1; @@ -695,6 +703,8 @@ SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), DROP TABLE t1; +#enable after fix MDEV-31728 +--disable_cursor_protocol #enable after fix MDEV-28585 --disable_view_protocol --echo # both columns should be same @@ -705,6 +715,7 @@ SELECT ROW(1,2) = (SELECT NULL, 1), ROW(1,2) IN (SELECT NULL, 1); SELECT ROW(1,2) = (SELECT 1, 1), ROW(1,2) IN (SELECT 1, 1); SELECT ROW(1,2) = (SELECT 1, 2), ROW(1,2) IN (SELECT 1, 2); --enable_view_protocol +--enable_cursor_protocol # # Bug #37362 Crash in do_field_eq @@ -812,11 +823,13 @@ set @save_optimizer_switch2=@@optimizer_switch; set optimizer_switch='subquery_cache=off'; --disable_ps2_protocol +--disable_cursor_protocol --echo SELECT i1, i2 FROM t1 WHERE (i1, i2) NOT IN (SELECT i1, i2 FROM t2); +--enable_cursor_protocol --echo --echo # Check that the subquery only has to be evaluated once @@ -828,11 +841,13 @@ SHOW STATUS LIKE '%Handler_read_rnd_next'; INSERT INTO t1 VALUES (NULL, NULL); FLUSH STATUS; +--disable_cursor_protocol --echo SELECT i1, i2 FROM t1 WHERE (i1, i2) NOT IN (SELECT i1, i2 FROM t2); +--enable_cursor_protocol --echo --echo # Handler_read_rnd_next should be one more than baseline @@ -978,9 +993,11 @@ set @@max_heap_table_size= 16384; explain select count(*) from t0 A, t0 B, t0 C, t0 D where D.a in (select a from t1 E where a+1 < 10000 + A.a + B.a +C.a+D.a); flush status; --disable_ps2_protocol +--disable_cursor_protocol select count(*) from t0 A, t0 B, t0 C, t0 D where D.a in (select a from t1 E where a+1 < 10000 + A.a + B.a +C.a+D.a); --enable_ps2_protocol show status like 'Created_tmp_disk_tables'; +--enable_cursor_protocol set @save_max_heap_table_size=@@max_heap_table_size; set @@optimizer_switch=@save_optimizer_switch; drop table t0, t1; diff --git a/mysql-test/main/subselect_cache.test b/mysql-test/main/subselect_cache.test index 1af2825791e..6e63273cdcb 100644 --- a/mysql-test/main/subselect_cache.test +++ b/mysql-test/main/subselect_cache.test @@ -24,7 +24,9 @@ insert into t2 values (2,3),(3,4),(5,6),(4,1); --echo #single value subquery test (SELECT list) --disable_ps2_protocol flush status; +--disable_cursor_protocol select a, (select d from t2 where b=c) from t1; +--enable_cursor_protocol show status like "subquery_cache%"; show status like '%Handler_read%'; @@ -42,6 +44,7 @@ select a, (select d from t2 where b=c), (select d from t2 where b=c union select set optimizer_switch='subquery_cache=off'; flush status; +--disable_cursor_protocol select a, (select d from t2 where b=c) from t1; show status like "subquery_cache%"; @@ -172,6 +175,7 @@ select ta.a, tb.a from t1 ta left join t1 tb on (select d from t2 where tb.b=c); show status like "subquery_cache%"; show status like '%Handler_read%'; set optimizer_switch='subquery_cache=on'; +--enable_cursor_protocol --echo #single value subquery test (PS) prepare stmt1 from 'select a, (select d from t2 where b=c) + 1 from t1'; @@ -192,6 +196,7 @@ drop procedure p1; --echo #IN subquery test flush status; +--disable_cursor_protocol show status like "subquery_cache%"; select a, b , b in (select d from t2) as SUBS from t1; show status like "subquery_cache%"; @@ -342,6 +347,7 @@ flush status; select a, b, (select exists (select * from t2 where b=d) from t2 where b=c) as SUNS1 from t1; show status like "subquery_cache%"; show status like '%Handler_read%'; +--enable_cursor_protocol --enable_ps2_protocol --echo #clean up @@ -426,12 +432,14 @@ DROP TABLE t1; flush status; CREATE TABLE t1 (a int); INSERT INTO t1 VALUES (2), (4), (1), (3); +--disable_cursor_protocol select a, a in (select a from t1) from t1 as ext; show status like "subquery_cache%"; select a, a in (select a from t1 where -1 < rand()) from t1 as ext; show status like "subquery_cache%"; select a, a in (select a from t1 where -1 < benchmark(a,100)) from t1 as ext; show status like "subquery_cache%"; +--enable_cursor_protocol drop table t1; --enable_ps2_protocol @@ -459,6 +467,7 @@ insert into t1 values (2,1), (3,1), (2,4), (3,4), (10,2), (20,2), (2,5), (3,5), (100,3), (200,3), (10,6), (20,6), (20,7), (100,8), (200,8); insert into t2 values (1,1),(3,3),(20,20); +--disable_cursor_protocol --disable_ps2_protocol --echo aggregate function as parameter of subquery set optimizer_switch='subquery_cache=off'; @@ -485,6 +494,7 @@ select max(a), (select a from t2 where a=c) from t1 group by b; show status like "subquery_cache%"; show status like '%Handler_read%'; --enable_ps2_protocol +--enable_cursor_protocol drop table t1,t2; @@ -499,6 +509,7 @@ insert into t1 values create table t2 (pk int, a int, primary key(pk)); insert into t2 select a,a from t0; +--disable_cursor_protocol --disable_ps2_protocol set optimizer_switch='default,semijoin=on,materialization=on,subquery_cache=on'; flush status; @@ -532,6 +543,7 @@ select * from t1 where a in (select pk from t2); show status like "subquery_cache%"; show status like '%Handler_read%'; --enable_ps2_protocol +--enable_cursor_protocol drop table t0,t1,t2; diff --git a/mysql-test/main/subselect_exists2in_costmat.test b/mysql-test/main/subselect_exists2in_costmat.test index 5d5eeaee268..02e61e983b1 100644 --- a/mysql-test/main/subselect_exists2in_costmat.test +++ b/mysql-test/main/subselect_exists2in_costmat.test @@ -47,7 +47,9 @@ create index Language on CountryLanguage(Language); create index CityName on City(Name); alter table City change population population int(11) null default 0; +--disable_cursor_protocol select max(id) from City into @max_city_id; +--enable_cursor_protocol insert into City values (@max_city_id + 1,'Kilifarevo','BGR',NULL); diff --git a/mysql-test/main/subselect_mat_cost.test b/mysql-test/main/subselect_mat_cost.test index 73ba717a8dc..41010da7cb0 100644 --- a/mysql-test/main/subselect_mat_cost.test +++ b/mysql-test/main/subselect_mat_cost.test @@ -53,7 +53,9 @@ create index Language on CountryLanguage(Language); create index CityName on City(Name); alter table City change population population int(11) null default 0; +--disable_cursor_protocol select max(id) from City into @max_city_id; +--enable_cursor_protocol insert into City values (@max_city_id + 1,'Kilifarevo','BGR',NULL); diff --git a/mysql-test/main/subselect_sj.test b/mysql-test/main/subselect_sj.test index e4d02ed666c..e2edc31fa9c 100644 --- a/mysql-test/main/subselect_sj.test +++ b/mysql-test/main/subselect_sj.test @@ -2679,8 +2679,10 @@ CREATE TABLE t3 (i3 INT, KEY(i3)) engine=myisam; INSERT INTO t3 VALUES (0),(8),(1),(8),(9),(24),(6),(1),(6),(2),(4),(2),(1); +--disable_cursor_protocol select @@max_heap_table_size into @tmp_max_heap_table_size; select @@join_buffer_size into @tmp_join_buffer_size; +--enable_cursor_protocol set max_heap_table_size=16*1024; --disable_query_log diff --git a/mysql-test/main/tmp_table_count-7586.test b/mysql-test/main/tmp_table_count-7586.test index 0629e27f164..71eb5c37d0d 100644 --- a/mysql-test/main/tmp_table_count-7586.test +++ b/mysql-test/main/tmp_table_count-7586.test @@ -11,6 +11,7 @@ create table t2 (a int); insert into t2 values (1),(2),(3); create view v2 as select a from t2; +--disable_cursor_protocol flush status; select * from v2; --disable_ps_protocol @@ -23,6 +24,7 @@ select * from (select * from t2) T1; --disable_ps_protocol show status like '%Created_tmp%'; --enable_ps_protocol +--enable_cursor_protocol explain select * from (select * from t2) T1; diff --git a/mysql-test/main/trigger-compat.test b/mysql-test/main/trigger-compat.test index 9c102993a6f..a8ad20073d6 100644 --- a/mysql-test/main/trigger-compat.test +++ b/mysql-test/main/trigger-compat.test @@ -68,11 +68,13 @@ let $MYSQLD_DATADIR = `select @@datadir`; eval LOAD DATA LOCAL INFILE '$MYSQLD_DATADIR/mysqltest_db1/t1.TRG' INTO TABLE patch; # remove original t1.TRG file so SELECT INTO OUTFILE won't fail --remove_file $MYSQLD_DATADIR/mysqltest_db1/t1.TRG +--disable_cursor_protocol --disable_ps2_protocol eval SELECT SUBSTRING_INDEX(a,'definers=',1) INTO OUTFILE '$MYSQLD_DATADIR/mysqltest_db1/t1.TRG' FROM patch; --enable_ps2_protocol +--enable_cursor_protocol DROP TABLE patch; --connection wl2818_definer_con --enable_query_log diff --git a/mysql-test/main/trigger.test b/mysql-test/main/trigger.test index ae4ee2e04bc..5086215f751 100644 --- a/mysql-test/main/trigger.test +++ b/mysql-test/main/trigger.test @@ -634,7 +634,10 @@ set sql_mode=""; create trigger t1_bi before insert on t1 for each row set new.a = '2004-01-00'; set sql_mode="traditional"; insert into t1 values ('2004-01-01'); +#Check after fix MDEV-31516 +--disable_cursor_protocol select * from t1; +--enable_cursor_protocol set sql_mode=default; show create table t1; --replace_column 6 # diff --git a/mysql-test/main/type_binary.test b/mysql-test/main/type_binary.test index 04cdc94e6d8..d9b07563a28 100644 --- a/mysql-test/main/type_binary.test +++ b/mysql-test/main/type_binary.test @@ -135,6 +135,8 @@ DROP TABLE t1; --echo # CREATE TABLE t1 (a VARCHAR(39)); +#check after fix MDEV-31540 +--disable_cursor_protocol --disable_view_protocol --enable_metadata SELECT @@ -155,4 +157,5 @@ SELECT FROM t1; --disable_metadata --enable_view_protocol +--enable_cursor_protocol DROP TABLE t1; diff --git a/mysql-test/main/type_bit.test b/mysql-test/main/type_bit.test index ad7b6fbbd72..6c8be397938 100644 --- a/mysql-test/main/type_bit.test +++ b/mysql-test/main/type_bit.test @@ -461,7 +461,10 @@ SHOW CREATE TABLE t2; DROP TABLE t2; --enable_metadata --disable_view_protocol +#Check after fix MDEV-31540 +--disable_cursor_protocol SELECT COALESCE(val, 1) FROM t1; +--enable_cursor_protocol --enable_view_protocol --disable_metadata DROP TABLE t1; diff --git a/mysql-test/main/type_date.test b/mysql-test/main/type_date.test index 3566e427d50..3e136e56a5a 100644 --- a/mysql-test/main/type_date.test +++ b/mysql-test/main/type_date.test @@ -211,12 +211,15 @@ CREATE TABLE t2 (a DATE); CREATE INDEX i ON t1 (a); INSERT INTO t1 VALUES ('1000-00-00'),('1000-00-00'); INSERT INTO t2 VALUES ('1000-00-00'),('1000-00-00'); +#Check after fix MDEV-31516 +--disable_cursor_protocol SELECT * FROM t1 WHERE a = '1000-00-00'; SELECT * FROM t2 WHERE a = '1000-00-00'; SET SQL_MODE=TRADITIONAL; EXPLAIN SELECT * FROM t1 WHERE a = '1000-00-00'; SELECT * FROM t1 WHERE a = '1000-00-00'; SELECT * FROM t2 WHERE a = '1000-00-00'; +--enable_cursor_protocol --error ER_TRUNCATED_WRONG_VALUE INSERT INTO t1 VALUES ('1000-00-00'); SET SQL_MODE=DEFAULT; diff --git a/mysql-test/main/type_enum.test b/mysql-test/main/type_enum.test index bcbc4cc520e..cd157bae178 100644 --- a/mysql-test/main/type_enum.test +++ b/mysql-test/main/type_enum.test @@ -237,7 +237,10 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES (1),(2); --enable_metadata --disable_view_protocol +#check after fix MDEV-31540 +--disable_cursor_protocol SELECT AVG(f1) FROM t1; +--enable_cursor_protocol --enable_view_protocol --disable_metadata drop table t1; diff --git a/mysql-test/main/type_float.test b/mysql-test/main/type_float.test index 1cc5cc94267..ebf1883d301 100644 --- a/mysql-test/main/type_float.test +++ b/mysql-test/main/type_float.test @@ -320,8 +320,10 @@ let $nine_65= select format(-1.7976931348623157E+307,256) as foo; select least(-1.1111111111111111111111111, - group_concat(1.7976931348623157E+308)) as foo; +--disable_cursor_protocol eval select concat((truncate((-1.7976931348623157E+307),(0x1e))), ($nine_65)) into @a; +--enable_cursor_protocol --enable_result_log --echo End of 5.0 tests @@ -337,6 +339,8 @@ select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo; --echo # MDEV-17249 MAKETIME(-1e50,0,0) returns a wrong result --echo # +#enable after fix MDEV-34213 +--disable_cursor_protocol #enable after fix MDEV-29552 --disable_view_protocol SELECT LEFT('a',EXP(50)); @@ -347,6 +351,7 @@ CREATE TABLE t1 (a FLOAT); INSERT INTO t1 VALUES (1e30); SELECT LEFT('a',a), LEFT('a',1e30) FROM t1; DROP TABLE t1; +--enable_cursor_protocol PREPARE stmt FROM 'SELECT LEFT(111,?)'; SET @a=1e30; diff --git a/mysql-test/main/type_newdecimal.test b/mysql-test/main/type_newdecimal.test index 33e56da7da8..babfb4e1db8 100644 --- a/mysql-test/main/type_newdecimal.test +++ b/mysql-test/main/type_newdecimal.test @@ -609,12 +609,15 @@ select round(99999999999999999.999,3); select round(-99999999999999999.999,3); #-- should return -100000000000000000.000 # +#enable after fix MDEV-31729 +--disable_cursor_protocol #enable after fix MDEV-28660 --disable_view_protocol select truncate(99999999999999999999999999999999999999,49); #-- should return 99999999999999999999999999999999999999.000 # --enable_view_protocol +--enable_cursor_protocol select truncate(99.999999999999999999999999999999999999,49); #-- should return 99.9999999999999999999999999999999 # @@ -1266,11 +1269,12 @@ DROP TABLE t1; let $nine_81= 999999999999999999999999999999999999999999999999999999999999999999999999999999999; - #view protocol generates additional warning --disable_view_protocol eval SELECT substring(('M') FROM ($nine_81)) AS foo; --enable_view_protocol +#check after fix MDEV-31729 +--disable_cursor_protocol #enable after fix MDEV-28661 --disable_view_protocol eval SELECT min($nine_81) AS foo; @@ -1284,6 +1288,7 @@ eval SELECT date_sub(($nine_81), day_minute) AS foo; eval SELECT truncate($nine_81, 28) AS foo; +--enable_cursor_protocol --enable_view_protocol --echo End of 5.0 tests diff --git a/mysql-test/main/type_timestamp.test b/mysql-test/main/type_timestamp.test index 3f17f347a22..82193ee709a 100644 --- a/mysql-test/main/type_timestamp.test +++ b/mysql-test/main/type_timestamp.test @@ -742,9 +742,11 @@ FLUSH TABLES; # 0xFF - record flags # 0x77777777 - TIMESTAMP integer part # 0xFFFFFF - TIMESTAMP bad fractional part +--disable_cursor_protocol --disable_ps2_protocol --eval SELECT CONCAT(0xFF,0x77777777,0xFFFFFF) INTO OUTFILE '$MYSQLD_DATADIR/test/t1.MYD' FIELDS TERMINATED BY '' ESCAPED BY '' LINES TERMINATED BY '' --enable_ps2_protocol +--enable_cursor_protocol --eval SELECT HEX(LOAD_FILE('$MYSQLD_DATADIR/test/t1.MYD')) AS MYD --enable_query_log SELECT a, CAST(a AS DATETIME) AS dt0, CAST(a AS DATETIME(6)) AS dt6 FROM t1; @@ -859,7 +861,10 @@ DROP TABLE t1; CREATE TABLE t1 (a TIMESTAMP(4), b TIMESTAMP DEFAULT 0) ENGINE=MyISAM; INSERT IGNORE INTO t1 (a) VALUES ('2001-01-01'),('2003-01-01'); SELECT * FROM t1 WHERE (SELECT MIN(b) FROM t1) - a; +#Enable after fix MDEV-31730 +--disable_cursor_protocol SELECT (SELECT MIN(b) FROM t1) - a FROM t1; +--enable_cursor_protocol DROP TABLE t1; --echo # diff --git a/mysql-test/main/type_year.test b/mysql-test/main/type_year.test index 1e72fc08886..0f0af9c8b0c 100644 --- a/mysql-test/main/type_year.test +++ b/mysql-test/main/type_year.test @@ -158,7 +158,10 @@ DROP TABLE t1; CREATE TABLE t1(c1 YEAR(4)); INSERT INTO t1 VALUES (1901),(2155),(0000); SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol SELECT COUNT(*) AS total_rows, MIN(c1) AS min_value, MAX(c1) FROM t1; +--enable_cursor_protocol SELECT COUNT(*) AS total_rows, MIN(c1+0) AS min_value, MAX(c1+0) FROM t1; DROP TABLE t1; --enable_view_protocol diff --git a/mysql-test/main/udf.test b/mysql-test/main/udf.test index d87d446f733..11717eb43b1 100644 --- a/mysql-test/main/udf.test +++ b/mysql-test/main/udf.test @@ -250,6 +250,8 @@ DROP FUNCTION avgcost; #enable view prtotocol after fix MDEV-28677 --disable_view_protocol +#check after fix MDEV-31587 +--disable_cursor_protocol select * from mysql.func; --replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB eval CREATE FUNCTION is_const RETURNS STRING SONAME "$UDF_EXAMPLE_SO"; @@ -262,6 +264,7 @@ select * from mysql.func; --error 1305 select is_const(3); +--enable_cursor_protocol --enable_view_protocol # @@ -270,6 +273,8 @@ select is_const(3); --replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB eval CREATE FUNCTION is_const RETURNS STRING SONAME "$UDF_EXAMPLE_SO"; +#check after fix MDEV-31587 +--disable_cursor_protocol select is_const(3) as const, is_const(3.14) as const, @@ -297,6 +302,7 @@ select from bug18761; drop table bug18761; +--enable_cursor_protocol --error 1241 select is_const((1,2,3)); diff --git a/mysql-test/main/union.test b/mysql-test/main/union.test index 278958d800c..f1ffbf41ca2 100644 --- a/mysql-test/main/union.test +++ b/mysql-test/main/union.test @@ -1114,6 +1114,7 @@ DROP TABLE t1; CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1); +--disable_cursor_protocol -- echo # Tests fix in parser rule select_derived_union. SELECT a INTO @v FROM ( SELECT a FROM t1 @@ -1153,6 +1154,7 @@ SELECT a INTO DUMPFILE 'union.out.file8' FROM t1 UNION SELECT a FROM t1; SELECT ( SELECT a UNION SELECT a ) INTO @v FROM t1; SELECT ( SELECT a UNION SELECT a ) INTO OUTFILE 'union.out.file3' FROM t1; SELECT ( SELECT a UNION SELECT a ) INTO DUMPFILE 'union.out.file4' FROM t1; +--enable_cursor_protocol DROP TABLE t1; remove_files_wildcard $MYSQLTEST_VARDIR/mysqld.1/data/test union.out.fil*; diff --git a/mysql-test/main/update.test b/mysql-test/main/update.test index 0dbc3c333ee..144f89b0053 100644 --- a/mysql-test/main/update.test +++ b/mysql-test/main/update.test @@ -236,9 +236,11 @@ insert into t1 (a) values (0),(0),(0),(0),(0),(0),(0),(0); # the view protocol creates an additional statistics data --disable_ps2_protocol --disable_view_protocol +--disable_cursor_protocol flush status; select a from t1 order by a limit 1; show status like 'handler_read%'; +--enable_cursor_protocol --enable_view_protocol --enable_ps2_protocol @@ -346,6 +348,7 @@ INSERT INTO t1(user_id) SELECT user_id FROM t1; INSERT INTO t1(user_id) SELECT user_id FROM t1; INSERT INTO t1(user_id) SELECT user_id FROM t1; +--disable_cursor_protocol --disable_ps2_protocol flush status; SELECT user_id FROM t1 WHERE request_id=9999999999999; @@ -357,6 +360,7 @@ show status like '%Handler_read%'; UPDATE t1 SET user_id=null WHERE request_id=999999999999999999999999999999; show status like '%Handler_read%'; --enable_ps2_protocol +--enable_cursor_protocol DROP TABLE t1; diff --git a/mysql-test/main/user_var.test b/mysql-test/main/user_var.test index e69718243ed..135dd92fd29 100644 --- a/mysql-test/main/user_var.test +++ b/mysql-test/main/user_var.test @@ -290,7 +290,9 @@ drop table t1; # CREATE TABLE t1(a INT, b INT); INSERT INTO t1 VALUES (0, 0), (2, 1), (2, 3), (1, 1), (30, 20); +--disable_cursor_protocol SELECT a, b INTO @a, @b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; +--enable_cursor_protocol SELECT @a, @b; SELECT a, b FROM t1 WHERE a=2 AND b=3 GROUP BY a, b; DROP TABLE t1; @@ -384,7 +386,9 @@ DROP TABLE t1; # SAME USER VARIABLE = CRASH # SET @bug12408412=1; +--disable_cursor_protocol SELECT GROUP_CONCAT(@bug12408412 ORDER BY 1) INTO @bug12408412; +--enable_cursor_protocol --echo End of 5.1 tests @@ -459,7 +463,9 @@ DROP TABLE t1; --echo # SET @bug12408412=1; +--disable_cursor_protocol SELECT GROUP_CONCAT(@bug12408412 ORDER BY 1) INTO @bug12408412; +--enable_cursor_protocol # # MDEV-616 LP BUG#1002126 diff --git a/mysql-test/main/userstat-badlogin-4824.test b/mysql-test/main/userstat-badlogin-4824.test index 0a7490bc29c..f9d3e22bff0 100644 --- a/mysql-test/main/userstat-badlogin-4824.test +++ b/mysql-test/main/userstat-badlogin-4824.test @@ -14,7 +14,9 @@ set global userstat=1; --disable_ps2_protocol connect(foo, localhost, foo, foo); +--disable_cursor_protocol select 1; +--enable_cursor_protocol disconnect foo; connection default; diff --git a/mysql-test/main/userstat.test b/mysql-test/main/userstat.test index 4aa10819d33..686165223a5 100644 --- a/mysql-test/main/userstat.test +++ b/mysql-test/main/userstat.test @@ -8,7 +8,9 @@ -- source include/have_perfschema.inc --disable_ps2_protocol +--disable_cursor_protocol select variable_value from information_schema.global_status where variable_name="handler_read_key" into @global_read_key; +--enable_cursor_protocol show columns from information_schema.client_statistics; show columns from information_schema.user_statistics; show columns from information_schema.index_statistics; @@ -26,6 +28,7 @@ update t1 set b=1; update t1 set b=5 where a=2; delete from t1 where a=3; +--disable_cursor_protocol /* Empty query */ select * from t1 where a=999; @@ -35,11 +38,11 @@ drop table t1; --connect (ssl_con,localhost,root,,,,,SSL) SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher'; --connection default +--enable_cursor_protocol # # Test the commit and rollback are counted # - create table t1 (a int, primary key (a), b int default 0) engine=innodb; begin; insert into t1 values(1,1); @@ -52,11 +55,13 @@ insert into t1 values(3,3); rollback; drop table t1; +--disable_cursor_protocol select sleep(1); show status like "rows%"; show status like "ha%"; select variable_value - @global_read_key as "handler_read_key" from information_schema.global_status where variable_name="handler_read_key"; +--enable_cursor_protocol --disconnect ssl_con diff --git a/mysql-test/main/variables.test b/mysql-test/main/variables.test index 2f145a77d74..1e5302e6d42 100644 --- a/mysql-test/main/variables.test +++ b/mysql-test/main/variables.test @@ -65,7 +65,10 @@ set @test_int=null,@test_double=null,@test_string=null,@test_string2=null; select @test_int,@test_double,@test_string,@test_string2; select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3; explain extended select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3; +#Enable after fix MDEV-31495 +--disable_cursor_protocol select @t5; +--enable_cursor_protocol # # Test problem with WHERE and variables @@ -372,7 +375,9 @@ select @@key_buffer_size; select * from t1 where a=2; select * from t2 where a=3; check table t1,t2; +--disable_cursor_protocol select max(a) +1, max(a) +2 into @xx,@yy from t1; +--enable_cursor_protocol drop table t1,t2; # @@ -594,7 +599,9 @@ set global sql_mode=repeat('a',80); # create table t1 (a int); +--disable_cursor_protocol select a into @x from t1; +--enable_cursor_protocol show warnings; drop table t1; @@ -1129,7 +1136,9 @@ SET @@global.thread_stack= 7; # Bug #40657 - assertion with out of range variables and traditional sql_mode # +--disable_cursor_protocol SELECT @@global.expire_logs_days INTO @old_eld; +--enable_cursor_protocol SET GLOBAL expire_logs_days = -1; --echo needs to've been adjusted (0) @@ -1165,10 +1174,12 @@ SET GLOBAL auto_increment_offset=0; # # Bug#41030 Wrong meta data (incorrect fieldlen) # - +#Check after fix MDEV-31540 +--disable_cursor_protocol --enable_metadata select @@default_storage_engine; --disable_metadata +--enable_cursor_protocol # # Bug#36540: CREATE EVENT and ALTER EVENT statements fail with large server_id diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test index 16f752ecc41..6730e7f7111 100644 --- a/mysql-test/main/view.test +++ b/mysql-test/main/view.test @@ -2043,7 +2043,9 @@ drop view abc; flush status; create table t1(f1 char(1)); create view v1 as select * from t1; +--disable_cursor_protocol select * from (select f1 as f2, f1 as f3 from v1) v where v.f2='a'; +--enable_cursor_protocol --disable_ps_protocol show status like "Created_tmp%"; --enable_ps_protocol @@ -2054,9 +2056,11 @@ set @tmp=@@optimizer_switch; set @@optimizer_switch='derived_merge=OFF'; create table t1(f1 char(1)); create view v1 as select * from t1; +--disable_cursor_protocol --disable_ps2_protocol select * from (select f1 as f2, f1 as f3 from v1) v where v.f2='a'; --enable_ps2_protocol +--enable_cursor_protocol --disable_ps_protocol show status like "Created_tmp%"; --enable_ps_protocol @@ -3107,12 +3111,13 @@ DROP VIEW IF EXISTS v1; let $query = SELECT * FROM (SELECT 1) AS t into @w; +--disable_cursor_protocol eval $query; --error ER_PARSE_ERROR eval CREATE VIEW v1 AS $query; --echo # Previously the following would fail. eval $query; - +--enable_cursor_protocol # # Bug#24532 The return data type of IS TRUE is different from similar operations @@ -4150,6 +4155,7 @@ INSERT INTO t2 VALUES (9,90), (16, 160), (11,110), (1,10), (18,180), (2,20), (14,140), (15, 150), (12,120), (3,30), (17,170), (19,190); +--disable_cursor_protocol EXPLAIN EXTENDED SELECT t1.a,t2.c FROM t1,t2 WHERE t2.pk = t1.a AND t2.pk > 8; FLUSH STATUS; @@ -4163,6 +4169,7 @@ FLUSH STATUS; SELECT t1.a,v.c FROM t1,v WHERE v.pk = t1.a AND v.pk > 8; SHOW STATUS LIKE 'Handler_read_%'; DROP VIEW v; +--enable_cursor_protocol DROP TABLE t1, t2; --enable_ps2_protocol diff --git a/mysql-test/main/view_grant.test b/mysql-test/main/view_grant.test index 686a9428bf6..fc0521933cc 100644 --- a/mysql-test/main/view_grant.test +++ b/mysql-test/main/view_grant.test @@ -686,15 +686,19 @@ use test; create view v1 as select 42; show create view v1; +--disable_cursor_protocol select definer into @v1def1 from information_schema.views where table_schema = 'test' and table_name='v1'; +--enable_cursor_protocol drop view v1; create definer=`test14256`@`%` view v1 as select 42; show create view v1; +--disable_cursor_protocol select definer into @v1def2 from information_schema.views where table_schema = 'test' and table_name='v1'; +--enable_cursor_protocol drop view v1; select @v1def1, @v1def2, @v1def1=@v1def2; diff --git a/mysql-test/main/wl4435_generated.inc b/mysql-test/main/wl4435_generated.inc index 5ea05a89402..df039c6347e 100644 --- a/mysql-test/main/wl4435_generated.inc +++ b/mysql-test/main/wl4435_generated.inc @@ -288,7 +288,10 @@ CREATE TEMPORARY TABLE tmp1 AS SELECT @a AS c1; SHOW CREATE TABLE tmp1; +#Enable after fix MDEV-31495 +--disable_cursor_protocol SELECT @a, @a = 123.456789; +--enable_cursor_protocol DROP TEMPORARY TABLE tmp1; DROP PROCEDURE p1; diff --git a/mysql-test/suite/archive/rnd_pos.test b/mysql-test/suite/archive/rnd_pos.test index f0a8c9ad2f3..4ceb8a93656 100644 --- a/mysql-test/suite/archive/rnd_pos.test +++ b/mysql-test/suite/archive/rnd_pos.test @@ -11,9 +11,11 @@ explain partitions select c1,c3 from t1 order by c2; set max_length_for_sort_data = 4; explain partitions select c1,c3 from t1 order by c2; flush status; +--disable_cursor_protocol --disable_ps2_protocol select c1,c3 from t1 order by c2; --enable_ps2_protocol +--enable_cursor_protocol set max_length_for_sort_data = default; --disable_ps_protocol show status where variable_name like '%tmp%' and value != 0; @@ -24,9 +26,11 @@ explain partitions select c1,c3 from t1 order by c2; set max_length_for_sort_data = 4; explain partitions select c1,c3 from t1 order by c2; flush status; +--disable_cursor_protocol --disable_ps2_protocol select c1,c3 from t1 order by c2; --enable_ps2_protocol +--enable_cursor_protocol set max_length_for_sort_data = default; --disable_ps_protocol show status where variable_name like '%tmp%' and value != 0; diff --git a/mysql-test/suite/binlog/include/database.test b/mysql-test/suite/binlog/include/database.test index e61198b2da2..a55cd7c5002 100644 --- a/mysql-test/suite/binlog/include/database.test +++ b/mysql-test/suite/binlog/include/database.test @@ -44,9 +44,11 @@ CREATE TABLE t2(c1 INT); let $prefix= `SELECT UUID()`; --echo # Create a file in the database directory --replace_result $prefix FAKE_FILE +--disable_cursor_protocol --disable_ps2_protocol eval SELECT 'hello' INTO OUTFILE 'fake_file.$prefix'; --enable_ps2_protocol +--enable_cursor_protocol --echo --echo # 'DROP DATABASE' will fail if there is any other file in the the diff --git a/mysql-test/suite/binlog/t/binlog_commit_wait.test b/mysql-test/suite/binlog/t/binlog_commit_wait.test index 7d7af2a90e2..dbd0e41407f 100644 --- a/mysql-test/suite/binlog/t/binlog_commit_wait.test +++ b/mysql-test/suite/binlog/t/binlog_commit_wait.test @@ -15,6 +15,7 @@ connect(con3,localhost,root,,test); # Get Initial status measurements --connection default +--disable_cursor_protocol SELECT variable_value INTO @group_commits FROM information_schema.global_status WHERE variable_name = 'binlog_group_commits'; SELECT variable_value INTO @group_commit_trigger_count FROM information_schema.global_status @@ -23,6 +24,7 @@ SELECT variable_value INTO @group_commit_trigger_timeout FROM information_schema WHERE variable_name = 'binlog_group_commit_trigger_timeout'; SELECT variable_value INTO @group_commit_trigger_lock_wait FROM information_schema.global_status WHERE variable_name = 'binlog_group_commit_trigger_lock_wait'; +--enable_cursor_protocol # Note: binlog_group_commits is counted at the start of the group and group_commit_trigger_* is # counted near when the groups its finalised. diff --git a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_row_frag.test b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_row_frag.test index 3e18ef1e351..420a00462ee 100644 --- a/mysql-test/suite/binlog/t/binlog_mysqlbinlog_row_frag.test +++ b/mysql-test/suite/binlog/t/binlog_mysqlbinlog_row_frag.test @@ -7,7 +7,9 @@ CREATE TABLE t (a TEXT); # events of interest are guaranteed to stay in 000001 log RESET MASTER; --eval INSERT INTO t SET a=repeat('a', 1024) +--disable_cursor_protocol SELECT a into @a from t; +--enable_cursor_protocol FLUSH LOGS; DELETE FROM t; diff --git a/mysql-test/suite/compat/oracle/t/update_innodb.test b/mysql-test/suite/compat/oracle/t/update_innodb.test index 8af219584d6..d1ae0864dc2 100644 --- a/mysql-test/suite/compat/oracle/t/update_innodb.test +++ b/mysql-test/suite/compat/oracle/t/update_innodb.test @@ -8,7 +8,9 @@ SET sql_mode='ORACLE'; CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY) engine=innodb; INSERT INTO t1 VALUES (1); START TRANSACTION; +--disable_cursor_protocol SELECT a AS a_con1 FROM t1 INTO @a FOR UPDATE; +--enable_cursor_protocol --connect(con2,localhost,root,,) SET sql_mode='ORACLE'; diff --git a/mysql-test/suite/encryption/t/innodb_encrypt_temporary_tables.test b/mysql-test/suite/encryption/t/innodb_encrypt_temporary_tables.test index 83abb783c9e..c48e5cf5c73 100644 --- a/mysql-test/suite/encryption/t/innodb_encrypt_temporary_tables.test +++ b/mysql-test/suite/encryption/t/innodb_encrypt_temporary_tables.test @@ -2,6 +2,7 @@ --source include/have_innodb.inc --source include/have_file_key_management_plugin.inc +--disable_cursor_protocol SELECT CAST(variable_value AS INT) INTO @old_encrypted FROM information_schema.global_status WHERE variable_name = 'innodb_encryption_n_temp_blocks_encrypted'; @@ -9,6 +10,7 @@ WHERE variable_name = 'innodb_encryption_n_temp_blocks_encrypted'; SELECT CAST(variable_value AS INT) INTO @old_decrypted FROM information_schema.global_status WHERE variable_name = 'innodb_encryption_n_temp_blocks_decrypted'; +--enable_cursor_protocol CREATE TEMPORARY TABLE t1(f1 CHAR(200), f2 CHAR(200)) ENGINE=InnoDB; INSERT INTO t1 (f1,f2) SELECT '', '' FROM seq_1_to_8192; diff --git a/mysql-test/suite/engines/funcs/t/ld_null.test b/mysql-test/suite/engines/funcs/t/ld_null.test index 50cbce78044..e01c473baf3 100644 --- a/mysql-test/suite/engines/funcs/t/ld_null.test +++ b/mysql-test/suite/engines/funcs/t/ld_null.test @@ -3,7 +3,9 @@ DROP TABLE IF EXISTS t1; --enable_warnings CREATE TABLE t1 (c1 INTEGER NOT NULL PRIMARY KEY, c2 VARCHAR(10), c3 DATETIME); LOAD DATA LOCAL INFILE 'suite/engines/funcs/t/load_null.inc' INTO TABLE t1 FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'; +--disable_cursor_protocol eval SELECT * INTO OUTFILE '../../tmp/t1.dat' FROM t1; +--enable_cursor_protocol SELECT * FROM t1 ORDER BY c1; TRUNCATE TABLE t1; --disable_query_log @@ -15,7 +17,9 @@ DROP TABLE t1; CREATE TABLE t1 (c1 INTEGER NOT NULL PRIMARY KEY, c2 VARCHAR(10), c3 DATETIME); LOAD DATA LOCAL INFILE 'suite/engines/funcs/t/load_null2.inc' INTO TABLE t1 FIELDS TERMINATED BY ',' ESCAPED BY '\'' LINES TERMINATED BY '\n'; --disable_query_log +--disable_cursor_protocol eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1-2.dat' FIELDS ESCAPED BY '\'' FROM t1; +--enable_cursor_protocol --enable_query_log SELECT * FROM t1 ORDER BY c1; TRUNCATE TABLE t1; diff --git a/mysql-test/suite/engines/funcs/t/ld_quote.test b/mysql-test/suite/engines/funcs/t/ld_quote.test index 89636fff2bb..b66a5e24ed8 100644 --- a/mysql-test/suite/engines/funcs/t/ld_quote.test +++ b/mysql-test/suite/engines/funcs/t/ld_quote.test @@ -4,7 +4,9 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (c1 INTEGER NOT NULL PRIMARY KEY, c2 VARCHAR(10)); LOAD DATA LOCAL INFILE 'suite/engines/funcs/t/load_quote.inc' INTO TABLE t1 FIELDS TERMINATED BY ',' ENCLOSED BY '\'' LINES TERMINATED BY '\n'; --disable_query_log +--disable_cursor_protocol eval SELECT * INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/t1.dat' FIELDS ENCLOSED BY '\'' FROM t1; +--enable_cursor_protocol --enable_query_log SELECT * FROM t1 ORDER BY c1; TRUNCATE TABLE t1; diff --git a/mysql-test/suite/engines/iuds/t/insert_calendar.test b/mysql-test/suite/engines/iuds/t/insert_calendar.test index 5d8380a1496..f957891bb1e 100644 --- a/mysql-test/suite/engines/iuds/t/insert_calendar.test +++ b/mysql-test/suite/engines/iuds/t/insert_calendar.test @@ -78,8 +78,11 @@ SELECT * FROM t4; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '2007-05-24'; @@ -152,8 +155,11 @@ SELECT * FROM t1 WHERE c1 IS NOT NULL ORDER BY c1 DESC LIMIT 2; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '2007-05-26'; @@ -868,8 +874,11 @@ SELECT * FROM t4; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '2007-05-24 09:15:28'; @@ -942,8 +951,11 @@ SELECT * FROM t1 WHERE c1 IS NOT NULL ORDER BY c1 DESC LIMIT 2; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '2007-05-26 00:00:00'; @@ -1016,8 +1028,11 @@ SELECT * FROM t1 WHERE c1 IS NOT NULL ORDER BY c1 DESC LIMIT 2; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '1998-12-28 00:00:00'; @@ -2070,8 +2085,11 @@ SELECT * FROM t4; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '2007-05-24'; @@ -2144,8 +2162,11 @@ SELECT * FROM t1 WHERE c1 IS NOT NULL ORDER BY c1 DESC LIMIT 2; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '2007-05-26'; @@ -2864,8 +2885,11 @@ SELECT * FROM t4; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '2007-05-24'; @@ -2938,8 +2962,11 @@ SELECT * FROM t1 WHERE c1 IS NOT NULL ORDER BY c1 DESC LIMIT 2; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '2007-05-26'; @@ -3012,8 +3039,11 @@ SELECT * FROM t1 WHERE c1 IS NOT NULL ORDER BY c1 DESC LIMIT 2; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '1998-12-28'; @@ -4067,8 +4097,11 @@ SELECT * FROM t4; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '2007-05-24'; @@ -4141,8 +4174,11 @@ SELECT * FROM t1 WHERE c1 IS NOT NULL ORDER BY c1 DESC LIMIT 2; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '2007-05-26'; @@ -4854,8 +4890,11 @@ SELECT * FROM t4; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '2007-05-24'; @@ -4928,8 +4967,11 @@ SELECT * FROM t1 WHERE c1 IS NOT NULL ORDER BY c1 DESC LIMIT 2; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '2007-05-26'; @@ -5002,8 +5044,11 @@ SELECT * FROM t1 WHERE c1 IS NOT NULL ORDER BY c1 DESC LIMIT 2; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '1998-12-28'; diff --git a/mysql-test/suite/engines/iuds/t/insert_decimal.test b/mysql-test/suite/engines/iuds/t/insert_decimal.test index c75fa19506e..d6e1b43d0bf 100644 --- a/mysql-test/suite/engines/iuds/t/insert_decimal.test +++ b/mysql-test/suite/engines/iuds/t/insert_decimal.test @@ -60,8 +60,11 @@ SELECT count(*) as total_rows, min(c3) as min_value, max(c3) as max_value, sum(c ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '0.0'; @@ -134,8 +137,11 @@ SELECT * FROM t1 WHERE c1 IS NOT NULL ORDER BY c1,c2 DESC LIMIT 2; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '-0.0'; @@ -388,8 +394,11 @@ SELECT count(*) as total_rows, min(c3) as min_value, max(c3) as max_value, sum(c ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '0.0'; @@ -462,8 +471,11 @@ SELECT * FROM t1 WHERE c1 IS NOT NULL ORDER BY c1,c2 DESC LIMIT 2; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '-0.0'; @@ -711,8 +723,11 @@ SELECT count(*) as total_rows, min(c3) as min_value, max(c3) as max_value, sum(c ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '0.0'; @@ -785,8 +800,11 @@ SELECT * FROM t1 WHERE c1 IS NOT NULL ORDER BY c1,c2 DESC LIMIT 2; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '-0.0'; diff --git a/mysql-test/suite/engines/iuds/t/insert_time.test b/mysql-test/suite/engines/iuds/t/insert_time.test index 0e5e21507a9..8a7a822b934 100644 --- a/mysql-test/suite/engines/iuds/t/insert_time.test +++ b/mysql-test/suite/engines/iuds/t/insert_time.test @@ -77,8 +77,11 @@ SELECT * FROM t4; ## Full table scan ## --sorted_result SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol --sorted_result SELECT count(*) as total_rows, min(c1) as min_value, max(c1) FROM t1; +--enable_cursor_protocol --sorted_result SELECT * FROM t1 WHERE c3 = '2009-01-17'; diff --git a/mysql-test/suite/federated/federatedx_create_handlers.test b/mysql-test/suite/federated/federatedx_create_handlers.test index 8e504590282..9cf08a34931 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.test +++ b/mysql-test/suite/federated/federatedx_create_handlers.test @@ -7,6 +7,9 @@ connection default; set global federated_pushdown=1; +#Enable after fix MDEV-31846 or in v. 10.5 and later +--disable_cursor_protocol + connection slave; DROP TABLE IF EXISTS federated.t1; @@ -433,5 +436,7 @@ DEALLOCATE PREPARE stmt; set global federated_pushdown=0; +--enable_cursor_protocol + source include/federated_cleanup.inc; diff --git a/mysql-test/suite/funcs_1/datadict/datadict.pre b/mysql-test/suite/funcs_1/datadict/datadict.pre index cedc24aad13..4082ab7be31 100644 --- a/mysql-test/suite/funcs_1/datadict/datadict.pre +++ b/mysql-test/suite/funcs_1/datadict/datadict.pre @@ -21,11 +21,13 @@ # be able to use the correct --replace_result statement. Using this only the # one pair of 'wrong' values is replaced and not all occurrencies of all # possible pairs of values. See bug #12777 for details. +--disable_cursor_protocol SELECT character_maximum_length INTO @CML FROM information_schema.columns WHERE table_schema = 'information_schema' AND table_name = 'columns' AND column_name = 'table_catalog'; +--enable_cursor_protocol let $bug_12777_0512= `SELECT @CML = 512`; let $bug_12777_1023= `SELECT @CML = 1023`; diff --git a/mysql-test/suite/funcs_1/datadict/datadict_load.inc b/mysql-test/suite/funcs_1/datadict/datadict_load.inc index 9e3b87660f8..e3358588654 100644 --- a/mysql-test/suite/funcs_1/datadict/datadict_load.inc +++ b/mysql-test/suite/funcs_1/datadict/datadict_load.inc @@ -16,11 +16,13 @@ # be able to use the correct --replace_result statement. Using this only the # one pair of 'wrong' values is replaced and not all occurrencies of all # possible pairs of values. See bug #12777 for details. +--disable_cursor_protocol SELECT character_maximum_length INTO @CML FROM information_schema.columns WHERE table_schema = 'information_schema' AND table_name = 'columns' AND column_name = 'table_catalog'; +--enable_cursor_protocol let $bug_12777_0512= `SELECT @CML = 512`; let $bug_12777_1023= `SELECT @CML = 1023`; diff --git a/mysql-test/suite/funcs_1/datadict/is_tables.inc b/mysql-test/suite/funcs_1/datadict/is_tables.inc index b3d0ef4cca5..12257cad1ce 100644 --- a/mysql-test/suite/funcs_1/datadict/is_tables.inc +++ b/mysql-test/suite/funcs_1/datadict/is_tables.inc @@ -337,9 +337,11 @@ WHERE table_name = 't1_my_tablex'; ALTER TABLE db_datadict.t1_my_tablex CHECKSUM = 1; SELECT table_name, checksum IS NOT NULL FROM information_schema.tables WHERE table_name = 't1_my_tablex'; +--disable_cursor_protocol SELECT UPDATE_TIME, checksum INTO @UPDATE_TIME, @checksum FROM information_schema.tables WHERE table_name = 't1_my_tablex'; +--enable_cursor_protocol # Enforce a time difference bigger than the smallest unit (1 second). --real_sleep 1.1 INSERT INTO db_datadict.t1_my_tablex SET f1 = 3; @@ -354,8 +356,10 @@ FROM information_schema.tables WHERE table_name = 't1_my_tablex'; # # Information is used later +--disable_cursor_protocol SELECT CREATE_TIME INTO @CREATE_TIME FROM information_schema.tables WHERE table_name = 't1_my_tablex'; +--enable_cursor_protocol # # Check impact of DROP TABLE SELECT table_name FROM information_schema.tables diff --git a/mysql-test/suite/funcs_1/storedproc/param_check.inc b/mysql-test/suite/funcs_1/storedproc/param_check.inc index 203187f92b1..72c5ce15bc1 100644 --- a/mysql-test/suite/funcs_1/storedproc/param_check.inc +++ b/mysql-test/suite/funcs_1/storedproc/param_check.inc @@ -32,12 +32,16 @@ eval UPDATE t1_aux SET f1 = NULL; # Enforce that all user variables have the same data type and initial value. +--disable_cursor_protocol SELECT f1,f1,f1,f1 INTO @v1_tab,@v1_proc,@v2_proc,@v1_func FROM t1_aux; +--enable_cursor_protocol --disable_warnings eval UPDATE t1_aux SET f1 = $test_value; --enable_warnings +--disable_cursor_protocol SELECT f1 INTO @v1_tab FROM t1_aux; +--enable_cursor_protocol --disable_warnings eval CALL sproc_1($test_value, @v1_proc); eval SET @v1_func = func_1($test_value); diff --git a/mysql-test/suite/funcs_1/t/is_basics_mixed.test b/mysql-test/suite/funcs_1/t/is_basics_mixed.test index 591a5ca566b..dd0aa78d0f1 100644 --- a/mysql-test/suite/funcs_1/t/is_basics_mixed.test +++ b/mysql-test/suite/funcs_1/t/is_basics_mixed.test @@ -175,9 +175,11 @@ SELECT 1 AS my_col FROM information_schema.tables WHERE table_name = 't1_third'; # # SELECT INTO USER VARIABLE +--disable_cursor_protocol SELECT table_name,table_schema INTO @table_name,@table_schema FROM information_schema.tables WHERE table_schema = 'db_datadict' ORDER BY table_name LIMIT 1; +--enable_cursor_protocol SELECT @table_name,@table_schema; # # SELECT INTO OUTFILE @@ -185,6 +187,7 @@ let $OUTFILE = $MYSQLTEST_VARDIR/tmp/datadict.out; --error 0,1 remove_file $OUTFILE; --replace_result $OUTFILE +--disable_cursor_protocol --disable_ps2_protocol eval SELECT table_name,table_schema INTO OUTFILE '$OUTFILE' @@ -193,6 +196,7 @@ LINES TERMINATED BY '\n' FROM information_schema.tables WHERE table_schema = 'db_datadict' ORDER BY table_name; --enable_ps2_protocol +--enable_cursor_protocol cat_file $OUTFILE; remove_file $OUTFILE; # diff --git a/mysql-test/suite/funcs_1/t/row_count_func.test b/mysql-test/suite/funcs_1/t/row_count_func.test index fb207681bc6..4c3466f7a13 100644 --- a/mysql-test/suite/funcs_1/t/row_count_func.test +++ b/mysql-test/suite/funcs_1/t/row_count_func.test @@ -18,9 +18,11 @@ INSERT INTO t1 VALUES (1), (2), (3); --enable_info --echo SELECT * FROM t1 INTO OUTFILE "MYSQL_TMP_DIR/bug21818.txt"; --disable_query_log # to avoid $MYSQL_TMP_DIR in query log +--disable_cursor_protocol --disable_ps2_protocol --eval SELECT * FROM t1 INTO OUTFILE "$MYSQL_TMP_DIR/bug21818.txt" --enable_ps2_protocol +--enable_cursor_protocol --enable_query_log --disable_info @@ -32,9 +34,11 @@ SELECT ROW_COUNT(); --echo --echo # -- Check 2. +--disable_cursor_protocol --enable_info SELECT a FROM t1 LIMIT 1 INTO @a; --disable_info +--enable_cursor_protocol --echo --disable_ps2_protocol diff --git a/mysql-test/suite/funcs_1/triggers/triggers_08.inc b/mysql-test/suite/funcs_1/triggers/triggers_08.inc index 0aeb46896a6..e1c56cacf20 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_08.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_08.inc @@ -123,8 +123,10 @@ let $message= 3.5.8.4 - multiple SQL; select * from db_test.t1_u; --sorted_result select * from db_test.t1_d; +#Check after fix MDEV-31495 +--disable_cursor_protocol select @test_var; - +--enable_cursor_protocol let $message= 3.5.8.4 - single SQL - insert; --source include/show_msg.inc @@ -201,7 +203,10 @@ let $message= 3.5.8.3/4 - single SQL - select; f122='Test 3.5.8.4-Single Select' where f122='Test 3.5.8.4-Single Delete'; Select f120, f122, f136, f144, f163 from tb3 where f122 like 'Test 3.5.8.4%'; +#Check after fix MDEV-31495 +--disable_cursor_protocol select @test_var; +--enable_cursor_protocol #Cleanup connection default; diff --git a/mysql-test/suite/funcs_1/triggers/triggers_09.inc b/mysql-test/suite/funcs_1/triggers/triggers_09.inc index 93762b363df..92ea70240fc 100644 --- a/mysql-test/suite/funcs_1/triggers/triggers_09.inc +++ b/mysql-test/suite/funcs_1/triggers/triggers_09.inc @@ -93,10 +93,13 @@ let $message= Testcase 3.5.9.3:; Update tb3 Set f136=8 where f122='Test 3.5.9.3'; select f118, f121, f122, f136, f163 from tb3 where f122='Test 3.5.9.3' order by f136; +#Check after fix MDEV-31495 +--disable_cursor_protocol select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122, @tr_var_b4_136, @tr_var_b4_163; select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122, @tr_var_af_136, @tr_var_af_163; +--enable_cursor_protocol --disable_query_log set @tr_var_b4_118=0, @tr_var_b4_121=0, @tr_var_b4_122=0, @@ -112,10 +115,14 @@ let $message= Testcase 3.5.9.3:; delete from tb3 where f122='Test 3.5.9.3'; select f118, f121, f122, f136, f163 from tb3 where f122='Test 3.5.9.3' order by f136; +#Check after fix MDEV-31495 +--disable_cursor_protocol select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122, @tr_var_b4_136, @tr_var_b4_163; select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122, @tr_var_af_136, @tr_var_af_163; +--enable_cursor_protocol + #Cleanup --disable_warnings drop trigger trg2_a; @@ -167,10 +174,13 @@ let $message= Testcase 3.5.9.4:; select f118, f121, f122, f136, f151, f163 from tb3 where f122 like 'Test 3.5.9.4%' order by f163; +#Check after fix MDEV-31495 +--disable_cursor_protocol select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122, @tr_var_b4_136, @tr_var_b4_151, @tr_var_b4_163; select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122, @tr_var_af_136, @tr_var_af_151, @tr_var_af_163; +--enable_cursor_protocol --disable_query_log set @tr_var_b4_118=0, @tr_var_b4_121=0, @tr_var_b4_122=0, @@ -188,10 +198,14 @@ let $message= Testcase 3.5.9.4:; select f118, f121, f122, f136, f151, f163 from tb3 where f122 like 'Test 3.5.9.4-trig' order by f163; +#Check after fix MDEV-31495 +--disable_cursor_protocol select @tr_var_b4_118, @tr_var_b4_121, @tr_var_b4_122, @tr_var_b4_136, @tr_var_b4_151, @tr_var_b4_163; select @tr_var_af_118, @tr_var_af_121, @tr_var_af_122, @tr_var_af_136, @tr_var_af_151, @tr_var_af_163; +--enable_cursor_protocol + #Cleanup --disable_warnings drop trigger trg3_a; diff --git a/mysql-test/suite/gcol/inc/gcol_ins_upd.inc b/mysql-test/suite/gcol/inc/gcol_ins_upd.inc index f025752b5b1..7b6538a3085 100644 --- a/mysql-test/suite/gcol/inc/gcol_ins_upd.inc +++ b/mysql-test/suite/gcol/inc/gcol_ins_upd.inc @@ -626,9 +626,11 @@ CREATE TABLE t1 ( ); INSERT IGNORE INTO t1 (b) VALUES (b'101110001110100'),(b'011101'); +--disable_cursor_protocol --disable_ps2_protocol SELECT pk, b INTO OUTFILE 'load.data' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol --error ER_DATA_TOO_LONG LOAD DATA INFILE 'load.data' REPLACE INTO TABLE t1 (pk, b); diff --git a/mysql-test/suite/gcol/inc/gcol_keys.inc b/mysql-test/suite/gcol/inc/gcol_keys.inc index 473086f6e04..61116781a70 100644 --- a/mysql-test/suite/gcol/inc/gcol_keys.inc +++ b/mysql-test/suite/gcol/inc/gcol_keys.inc @@ -776,9 +776,11 @@ CREATE TABLE t1 ( ); INSERT IGNORE INTO t1 (b) VALUES (b'101110001110100'),(b'011101'); +--disable_cursor_protocol --disable_ps2_protocol SELECT pk, b INTO OUTFILE 'load.data' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol --error ER_DATA_TOO_LONG LOAD DATA INFILE 'load.data' REPLACE INTO TABLE t1 (pk, b); diff --git a/mysql-test/suite/gcol/t/gcol_bugfixes.test b/mysql-test/suite/gcol/t/gcol_bugfixes.test index 1edc9779d41..7ec4b3d4e35 100644 --- a/mysql-test/suite/gcol/t/gcol_bugfixes.test +++ b/mysql-test/suite/gcol/t/gcol_bugfixes.test @@ -674,9 +674,11 @@ DROP TABLE t1; CREATE TABLE t1 (id INT PRIMARY KEY, a VARCHAR(2333), va VARCHAR(171) AS (a)) ENGINE=InnoDB; INSERT INTO t1 (id,a) VALUES (1,REPEAT('x',200)); +--disable_cursor_protocol --disable_ps2_protocol SELECT id, va INTO OUTFILE 'load_t1' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol --error ER_DATA_TOO_LONG LOAD DATA INFILE 'load_t1' REPLACE INTO TABLE t1 (id,va); SELECT * FROM t1; @@ -689,9 +691,11 @@ DROP TABLE t1; CREATE TABLE t1 (id BIGINT PRIMARY KEY, a VARCHAR(2333), va VARCHAR(171) AS (a)) ENGINE=InnoDB; INSERT INTO t1 (id,a) VALUES (1,REPEAT('x',200)); +--disable_cursor_protocol --disable_ps2_protocol SELECT id, va INTO OUTFILE 'load_t1' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol --error ER_DATA_TOO_LONG LOAD DATA INFILE 'load_t1' REPLACE INTO TABLE t1 (id,va); SELECT * FROM t1; @@ -711,9 +715,11 @@ CREATE TABLE t1 (id INT PRIMARY KEY, ts TIMESTAMP DEFAULT '1971-01-01 00:00:00', c VARBINARY(8) DEFAULT '', vc VARCHAR(3) AS (c) STORED); INSERT IGNORE INTO t1 (id,c) VALUES (1,'foobar'); +--disable_cursor_protocol --disable_ps2_protocol SELECT id, ts, vc INTO OUTFILE 'load_t1' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol --error 0,ER_DATA_TOO_LONG LOAD DATA INFILE 'load_t1' REPLACE INTO TABLE t1 (id, ts, vc); INSERT IGNORE INTO t1 (id) VALUES (2); diff --git a/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test b/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test index 9184902a7d0..4f38e1a62a4 100644 --- a/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test +++ b/mysql-test/suite/gcol/t/innodb_virtual_debug_purge.test @@ -258,10 +258,14 @@ disconnect truncate; connection default; DROP TABLE t1, t2; +--disable_cursor_protocol --disable_ps2_protocol --enable_ps2_protocol +--enable_cursor_protocol +--disable_cursor_protocol --disable_ps2_protocol --enable_ps2_protocol +--enable_cursor_protocol --source include/wait_until_count_sessions.inc set debug_sync=reset; diff --git a/mysql-test/suite/handler/ps.test b/mysql-test/suite/handler/ps.test index 783d862435e..87f4cddf525 100644 --- a/mysql-test/suite/handler/ps.test +++ b/mysql-test/suite/handler/ps.test @@ -7,6 +7,10 @@ flush status; handler handler_a read first; # handler...read must be prepared in --ps-protocol mode --replace_result $PS_PROTOCOL OK +if($CURSOR_PROTOCOL) +{ + --replace_result $CURSOR_PROTOCOL OK +} --disable_ps_protocol show status like 'Com_stmt_prepare%'; --enable_ps_protocol diff --git a/mysql-test/suite/innodb/t/alter_inplace_perfschema.test b/mysql-test/suite/innodb/t/alter_inplace_perfschema.test index e0451e121a6..9abc198843b 100644 --- a/mysql-test/suite/innodb/t/alter_inplace_perfschema.test +++ b/mysql-test/suite/innodb/t/alter_inplace_perfschema.test @@ -4,7 +4,9 @@ --source include/have_debug_sync.inc --source include/not_embedded.inc +--disable_cursor_protocol select count_star into @init_count from performance_schema.events_waits_summary_global_by_event_name WHERE event_name LIKE '%wait%io%file%innodb%innodb_temp_file%'; +--enable_cursor_protocol connect (ddl, localhost, root,,); update performance_schema.setup_instruments set enabled='yes'; update performance_schema.setup_consumers set enabled='yes'; @@ -26,7 +28,9 @@ send ALTER TABLE t1 ADD INDEX(b), ALGORITHM=INPLACE; connection default; SET DEBUG_SYNC = 'now WAIT_FOR go'; +--disable_cursor_protocol select count_star into @final_count from performance_schema.events_waits_summary_global_by_event_name WHERE event_name LIKE '%wait%io%file%innodb%innodb_temp_file%'; +--enable_cursor_protocol SELECT @final_count - @init_count; diff --git a/mysql-test/suite/innodb/t/group_commit.test b/mysql-test/suite/innodb/t/group_commit.test index 692e06f38b8..24d7d1ee1fa 100644 --- a/mysql-test/suite/innodb/t/group_commit.test +++ b/mysql-test/suite/innodb/t/group_commit.test @@ -11,10 +11,12 @@ CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) ENGINE=innodb; +--disable_cursor_protocol SELECT variable_value INTO @commits FROM information_schema.global_status WHERE variable_name = 'binlog_commits'; SELECT variable_value INTO @group_commits FROM information_schema.global_status WHERE variable_name = 'binlog_group_commits'; +--enable_cursor_protocol connect(con1,localhost,root,,); connect(con2,localhost,root,,); diff --git a/mysql-test/suite/innodb/t/group_commit_no_optimize_thread.test b/mysql-test/suite/innodb/t/group_commit_no_optimize_thread.test index 85c0e295424..f7e1a5c0150 100644 --- a/mysql-test/suite/innodb/t/group_commit_no_optimize_thread.test +++ b/mysql-test/suite/innodb/t/group_commit_no_optimize_thread.test @@ -11,10 +11,12 @@ CREATE TABLE t1 (a VARCHAR(10) PRIMARY KEY) ENGINE=innodb; +--disable_cursor_protocol SELECT variable_value INTO @commits FROM information_schema.global_status WHERE variable_name = 'binlog_commits'; SELECT variable_value INTO @group_commits FROM information_schema.global_status WHERE variable_name = 'binlog_group_commits'; +--enable_cursor_protocol connect(con1,localhost,root,,); connect(con2,localhost,root,,); diff --git a/mysql-test/suite/innodb/t/innodb-page_compression_none.test b/mysql-test/suite/innodb/t/innodb-page_compression_none.test index e4eaae8bcb2..3ca0e1afe32 100644 --- a/mysql-test/suite/innodb/t/innodb-page_compression_none.test +++ b/mysql-test/suite/innodb/t/innodb-page_compression_none.test @@ -6,8 +6,9 @@ SET @save_compression_algorithm=@@GLOBAL.innodb_compression_algorithm; SET GLOBAL innodb_compression_algorithm=0; +--disable_cursor_protocol SELECT VARIABLE_VALUE INTO @compress_errors FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'Innodb_num_pages_page_compression_error'; - +--enable_cursor_protocol CREATE TABLE t (c INT) page_compressed=1 page_compression_level=4 ENGINE=InnoDB; INSERT INTO t VALUES (1); diff --git a/mysql-test/suite/innodb/t/innodb-system-table-view.test b/mysql-test/suite/innodb/t/innodb-system-table-view.test index ea620b398e5..e783deff4b7 100644 --- a/mysql-test/suite/innodb/t/innodb-system-table-view.test +++ b/mysql-test/suite/innodb/t/innodb-system-table-view.test @@ -12,10 +12,12 @@ LET $INNODB_PAGE_SIZE = `select @@innodb_page_size`; # The IDs of mysql.innodb_table_stats and mysql.innodb_index_stats may # vary depending on whether the tables have been rebuilt # by previously run tests. +--disable_cursor_protocol SELECT table_id INTO @table_stats_id FROM information_schema.innodb_sys_tables WHERE name = 'mysql/innodb_table_stats'; SELECT table_id INTO @index_stats_id FROM information_schema.innodb_sys_tables WHERE name = 'mysql/innodb_index_stats'; +--enable_cursor_protocol SELECT * FROM INFORMATION_SCHEMA.INNODB_SYS_TABLES WHERE table_id NOT IN (@table_stats_id, @index_stats_id) ORDER BY table_id; diff --git a/mysql-test/suite/innodb/t/innodb_buffer_pool_load_now.test b/mysql-test/suite/innodb/t/innodb_buffer_pool_load_now.test index baced6e9e11..1697c69d6e4 100644 --- a/mysql-test/suite/innodb/t/innodb_buffer_pool_load_now.test +++ b/mysql-test/suite/innodb/t/innodb_buffer_pool_load_now.test @@ -30,8 +30,10 @@ ENGINE=INNODB; SELECT PAGE_NUMBER FROM information_schema.innodb_buffer_page_lru WHERE table_name = '`test`.`ib_bp_test`'; +--disable_cursor_protocol SELECT SPACE INTO @space FROM information_schema.innodb_buffer_page_lru WHERE table_name = '`test`.`ib_bp_test`' AND PAGE_NUMBER=3; +--enable_cursor_protocol let SPACE=`SELECT @space`; diff --git a/mysql-test/suite/innodb/t/innodb_bug51920.test b/mysql-test/suite/innodb/t/innodb_bug51920.test index c83e00db22a..8037b20e592 100644 --- a/mysql-test/suite/innodb/t/innodb_bug51920.test +++ b/mysql-test/suite/innodb/t/innodb_bug51920.test @@ -22,9 +22,11 @@ let $wait_condition = WHERE INFO="UPDATE bug51920 SET i=2"; -- source include/wait_condition.inc +--disable_cursor_protocol SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO="UPDATE bug51920 SET i=2" INTO @thread_id; +--enable_cursor_protocol KILL @thread_id; let $wait_condition = diff --git a/mysql-test/suite/innodb/t/innodb_mysql.test b/mysql-test/suite/innodb/t/innodb_mysql.test index d495186db25..50ab6e8c1a8 100644 --- a/mysql-test/suite/innodb/t/innodb_mysql.test +++ b/mysql-test/suite/innodb/t/innodb_mysql.test @@ -625,7 +625,9 @@ CREATE TABLE t2 (a INT, b INT, --echo # set up our data elements INSERT INTO t1 (d) VALUES (1); INSERT INTO t2 (a,b) VALUES (1,1); +--disable_cursor_protocol SELECT SECOND(c) INTO @bug47453 FROM t2; +--enable_cursor_protocol SELECT SECOND(c)-@bug47453 FROM t1 JOIN t2 ON d=a; UPDATE t1 JOIN t2 ON d=a SET b=1 WHERE a=1; diff --git a/mysql-test/suite/innodb/t/innodb_stats_persistent.test b/mysql-test/suite/innodb/t/innodb_stats_persistent.test index cfcd7c2128d..4f952f2b3b8 100644 --- a/mysql-test/suite/innodb/t/innodb_stats_persistent.test +++ b/mysql-test/suite/innodb/t/innodb_stats_persistent.test @@ -102,8 +102,10 @@ ANALYZE TABLE bug12429573; # innodb_index_stats have been updated to the same value. If the bug is # present this check will fail. +--disable_cursor_protocol SELECT last_update INTO @last FROM mysql.innodb_table_stats WHERE table_name = 'bug12429573'; +--enable_cursor_protocol SELECT * FROM mysql.innodb_index_stats WHERE table_name = 'bug12429573' AND last_update!=@last; diff --git a/mysql-test/suite/innodb/t/instant_alter.test b/mysql-test/suite/innodb/t/instant_alter.test index 8e333e3bb72..bd0018f6173 100644 --- a/mysql-test/suite/innodb/t/instant_alter.test +++ b/mysql-test/suite/innodb/t/instant_alter.test @@ -807,18 +807,24 @@ SELECT * FROM t1; DROP TABLE t1; eval CREATE TABLE t1 (t TINYINT PRIMARY KEY, m MEDIUMINT UNIQUE) $engine; +--disable_cursor_protocol SELECT table_id INTO @table_id1 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS WHERE name = 'test/t1'; +--enable_cursor_protocol INSERT INTO t1 VALUES (-42, -123456); --enable_info ALTER TABLE t1 CHANGE t s SMALLINT; +--disable_cursor_protocol SELECT table_id INTO @table_id2 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS WHERE name = 'test/t1'; +--enable_cursor_protocol --error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON ALTER TABLE t1 CHANGE m i INT, ALGORITHM=INSTANT; ALTER TABLE t1 CHANGE m i INT; +--disable_cursor_protocol SELECT table_id INTO @table_id3 FROM INFORMATION_SCHEMA.INNODB_SYS_TABLESTATS WHERE name = 'test/t1'; +--enable_cursor_protocol --disable_info SELECT @table_id1 = @table_id2, @table_id2 = @table_id3; INSERT IGNORE INTO t1 VALUES (0, -123456); diff --git a/mysql-test/suite/innodb/t/instant_alter_bugs.test b/mysql-test/suite/innodb/t/instant_alter_bugs.test index c1b999dbc74..c5f16736656 100644 --- a/mysql-test/suite/innodb/t/instant_alter_bugs.test +++ b/mysql-test/suite/innodb/t/instant_alter_bugs.test @@ -129,9 +129,11 @@ INSERT INTO t1 (f1,f2,f3,f4,f5,f6,f7,f8) VALUES INSERT INTO t1 (f1,f2,f3,f4,f5,f6,f7,f8) VALUES ('impact', 'b', 'h', 185, 'fj', 7, 7, 3); ALTER TABLE t1 ADD COLUMN filler VARCHAR(255) DEFAULT ''; +--disable_cursor_protocol --disable_ps2_protocol SELECT * INTO OUTFILE 'load.data' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol UPDATE IGNORE t1 SET pk = 0; LOAD DATA INFILE 'load.data' REPLACE INTO TABLE t1; HANDLER t1 OPEN AS h; diff --git a/mysql-test/suite/innodb/t/restart.test b/mysql-test/suite/innodb/t/restart.test index 859d9325985..dba2c1e500b 100644 --- a/mysql-test/suite/innodb/t/restart.test +++ b/mysql-test/suite/innodb/t/restart.test @@ -93,8 +93,10 @@ let $wait_condition = FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_resize_status'; +--disable_cursor_protocol SELECT @@innodb_buffer_pool_size INTO @innodb_buffer_pool_size_orig; SELECT CEILING((256 + 64) * @@innodb_page_size / 1048576) * 1048576 INTO @min_pool_size; +--enable_cursor_protocol --error ER_WRONG_VALUE_FOR_VAR EXECUTE IMMEDIATE 'SET GLOBAL innodb_buffer_pool_size = ?' USING (@min_pool_size -1); diff --git a/mysql-test/suite/innodb/t/temp_table_savepoint.test b/mysql-test/suite/innodb/t/temp_table_savepoint.test index fd1d06b48f7..185fb252e93 100644 --- a/mysql-test/suite/innodb/t/temp_table_savepoint.test +++ b/mysql-test/suite/innodb/t/temp_table_savepoint.test @@ -141,9 +141,11 @@ update ignore t5 set c1 = 20 where c1 = 140 ; select count(*) from t5 where c1 = 140; --replace_result $MYSQLTEST_VARDIR VARDIR +--disable_cursor_protocol --disable_ps2_protocol eval select * into outfile "$MYSQLTEST_VARDIR/tmp/t5.outfile" from t5; --enable_ps2_protocol +--enable_cursor_protocol create temporary table temp_1 engine = innodb as select * from t5 where 1=2; diff --git a/mysql-test/suite/innodb_fts/t/opt.test b/mysql-test/suite/innodb_fts/t/opt.test index 19dfdcad8fd..efcc47af4a7 100644 --- a/mysql-test/suite/innodb_fts/t/opt.test +++ b/mysql-test/suite/innodb_fts/t/opt.test @@ -30,6 +30,7 @@ ANALYZE TABLE t1; SET STATEMENT use_stat_tables=never FOR ANALYZE TABLE wp; +--disable_cursor_protocol --disable_ps2_protocol # @@ -549,6 +550,7 @@ SHOW STATUS LIKE 'Handler_read%'; DROP TABLE wp, t1; --enable_ps2_protocol +--enable_cursor_protocol # Tests for FT hints. diff --git a/mysql-test/suite/innodb_gis/t/1.test b/mysql-test/suite/innodb_gis/t/1.test index 3a5103860e1..411cb10602b 100644 --- a/mysql-test/suite/innodb_gis/t/1.test +++ b/mysql-test/suite/innodb_gis/t/1.test @@ -408,7 +408,10 @@ select (ST_asWKT(ST_geomfromwkb((0x010100000000000000000024400000000000002440))) --enable_metadata create table t1 (g GEOMETRY); select * from t1; +#Check after fix MDEV-31540 +--disable_cursor_protocol select ST_asbinary(g) from t1; +--enable_cursor_protocol --disable_metadata --enable_view_protocol drop table t1; diff --git a/mysql-test/suite/innodb_gis/t/gis.test b/mysql-test/suite/innodb_gis/t/gis.test index ea9de7edfff..fbf7c93840a 100644 --- a/mysql-test/suite/innodb_gis/t/gis.test +++ b/mysql-test/suite/innodb_gis/t/gis.test @@ -400,11 +400,14 @@ select (ST_asWKT(ST_geomfromwkb((0x000000000140240000000000004024000000000000))) select (ST_asWKT(ST_geomfromwkb((0x010100000000000000000024400000000000002440)))) AS val; --disable_view_protocol +#check after fix MDEV-31540 +--disable_cursor_protocol --enable_metadata create table t1 (g GEOMETRY); select * from t1; select ST_asbinary(g) from t1; --disable_metadata +--enable_cursor_protocol --enable_view_protocol drop table t1; @@ -1442,7 +1445,9 @@ SELECT ST_Union('', ''), md5(1); --echo # fields after MDEV-25459 --echo # CREATE TABLE t1(l LINESTRING NOT NULL, SPATIAL INDEX(l))ENGINE=InnoDB ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=1; +--disable_cursor_protocol SELECT GROUP_CONCAT(CONCAT(seq, ' ', seq) SEPARATOR ',') INTO @g FROM seq_0_to_190; +--enable_cursor_protocol INSERT INTO t1 SET l=ST_GeomFromText(CONCAT('LINESTRING(',@g,',0 0)')); SELECT COUNT(*) FROM t1 WHERE MBRIntersects(GeomFromText('Polygon((0 0,0 10,10 10,10 0,0 0))'), l); DROP TABLE t1; diff --git a/mysql-test/suite/json/t/json_no_table.test b/mysql-test/suite/json/t/json_no_table.test index d7b302c98a6..4e4c6c842c4 100644 --- a/mysql-test/suite/json/t/json_no_table.test +++ b/mysql-test/suite/json/t/json_no_table.test @@ -330,8 +330,11 @@ SELECT JSON_DEPTH( json_compact( '"abc"') ); --echo error ER_INVALID_TYPE_FOR_JSON SELECT JSON_DEPTH( 1 ); +#Check after fix MDEV-31728 +--disable_cursor_protocol --echo error ER_INVALID_JSON_TEXT_IN_PARAM SELECT JSON_DEPTH( 'abc' ); +--enable_cursor_protocol # returns 1 SELECT JSON_DEPTH( json_compact( 1) ); @@ -372,11 +375,14 @@ SELECT JSON_DEPTH '[ "a", true, "b" , { "e" : false }, "c" , null ]' ); +#Check after fix MDEV-31728 +--disable_cursor_protocol --echo error ER_INVALID_JSON_TEXT_IN_PARAM SELECT JSON_DEPTH ( '[ "a", true, "b" , { "e" : false }, "c" , null' ); +--enable_cursor_protocol --echo # ---------------------------------------------------------------------- --echo # Test of JSON_REMOVE function. @@ -585,6 +591,8 @@ SELECT JSON_MERGE --echo error ER_INVALID_JSON_TEXT_IN_PARAM select json_type('abc'); +# Enable after fix MDEV-31554 +--disable_cursor_protocol #select i, json_type(j) from t1; select json_type('{"a": 2}'); select json_type('[1,2]'); @@ -651,6 +659,7 @@ select json_type(json_compact(ST_GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0) select json_type(json_compact(null)); select json_type(json_compact(null)) is null; # check that it is an SQL NULL select json_type(null) is null; # is an SQL NULL +--enable_cursor_protocol # # same, but now show the printable value: @@ -882,7 +891,10 @@ select json_extract( '[1]', '$**[0]' ); # should have same result select json_extract( '{ "a": 1 }', '$.a[0]' ); +# Enable after fix MDEV-31554 +--disable_cursor_protocol select json_extract( '{ "a": 1 }', '$**[0]' ); +--enable_cursor_protocol # should have same result select json_extract( '{ "a": 1 }', '$[0].a' ); @@ -890,7 +902,10 @@ select json_extract( '{ "a": 1 }', '$**.a' ); # should have same result select json_extract( '{ "a": 1 }', '$[0].a[0]' ); +# Enable after fix MDEV-31554 +--disable_cursor_protocol select json_extract( '{ "a": 1 }', '$**[0]' ); +--enable_cursor_protocol # should have the same result select json_extract( '{ "a": 1 }', '$[0].a' ); @@ -998,7 +1013,10 @@ select json_extract( '[ { "a": [3,4] }, { "b": 2 } ]', '$[0].a', '$[1].a' ) jdoc # NULLs select json_array_append(NULL, '$.b', json_compact(1)); select json_array_append('[1,2,3]', NULL, json_compact(1)); +# Enable after fix MDEV-31554 +--disable_cursor_protocol select json_array_append('[1,2,3]', '$', NULL); +--enable_cursor_protocol # wrong # args --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT @@ -1019,9 +1037,12 @@ select json_array_append(json_compact('{"a": {"b": [3]}}'), '$**[0]', 6); --echo # Auto-wrapping, since because the paths identify scalars. --echo # should return {"a": "foo", "b": ["bar", 4], "c": ["wibble", "grape"]} +# Enable after fix MDEV-31554 +--disable_cursor_protocol SELECT JSON_ARRAY_APPEND('{"a": "foo", "b": "bar", "c": "wibble"}', '$.b', json_compact(4), '$.c', json_compact('"grape"')); +--enable_cursor_protocol --echo # should return {"a": "foo", "b": [1, 2, 3, 4], --echo # "c": ["apple", "pear", "grape"]} @@ -1089,7 +1110,10 @@ select json_insert('[1,2,3]', '$[3]', 4); select json_insert('[1,2,3]', '$[10]', 4); select json_insert('{"c":4}', '$.c', 4); +# Enable after fix MDEV-31554 +--disable_cursor_protocol select json_insert('{"c":4}', '$.a', 4); +--enable_cursor_protocol select json_insert('1', '$', 4); select json_insert('1', '$[0]', 4); @@ -1297,9 +1321,12 @@ select json_set(NULL, NULL); --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT select json_set(NULL, NULL, NULL, NULL); +# Enable after fix MDEV-31554 +--disable_cursor_protocol # Detect errors in nested function calls. --echo error ER_INVALID_JSON_TEXT_IN_PARAM SELECT JSON_SET('{}', '$.name', JSON_EXTRACT('', '$')); +--enable_cursor_protocol # positive test cases @@ -1308,7 +1335,10 @@ select json_set('[1,2,3]', '$[3]', 4); select json_set('[1,2,3]', '$[10]', 4); select json_set('{"c":4}', '$.c', 5); +# Enable after fix MDEV-31554 +--disable_cursor_protocol select json_set('{"c":4}', '$.a', 5); +--enable_cursor_protocol select json_set('1', '$', 4); select json_set('1', '$[0]', 4); @@ -1355,10 +1385,13 @@ select json_set('{ "a" : "foo", "b" : [ 1, 2, 3 ] }', '$.a', json_compact('{}')); +# Enable after fix MDEV-31554 +--disable_cursor_protocol # returns { "a" : "foo", "b" : [ 1, 2, 3 ], "c" : [ true, false ] } select json_set('{ "a" : "foo", "b" : [ 1, 2, 3 ] }', '$.c', json_compact('[true, false]')); +--enable_cursor_protocol # returns [ 1, null, null, 2 ] select json_set('1', '$[3]', 2); @@ -1376,6 +1409,8 @@ SELECT JSON_SET JSON_OBJECT() ); +# Enable after fix MDEV-31554 +--disable_cursor_protocol # returns {"a": "foo", "b": [1, 2, 3], "c": [true, false]} SELECT JSON_SET ( @@ -1391,6 +1426,7 @@ SELECT JSON_SET '$.c', JSON_ARRAY( json_compact( 'true'), json_compact( 'false') ) ); +--enable_cursor_protocol # returns [1, 2] SELECT JSON_SET @@ -1473,6 +1509,8 @@ select json_array('[1,2,3]', NULL, json_compact(1)); select json_array('[1,2,3]', '$[3]', NULL); +# Enable after fix MDEV-31554 +--disable_cursor_protocol # positive test cases select json_array(); select json_array(3.14); @@ -1483,6 +1521,7 @@ select json_array(b'0', b'1', b'10'); # returns the empty array: [] SELECT JSON_ARRAY(); +--enable_cursor_protocol --echo # ---------------------------------------------------------------------- --echo # Test of JSON_OBJECT function. @@ -1498,9 +1537,12 @@ select json_object( 'a', 1, 'b' ); --echo error ER_JSON_DOCUMENT_NULL_KEY select json_object( null, 1 ); +# Enable after fix MDEV-31554 +--disable_cursor_protocol # positive tests select json_object(); select json_object( 'a', null ); +--enable_cursor_protocol select json_object( 'a', 1 ); select json_object( 'a', 1, 'b', 'foo' ); select json_object( 'a', 1, 'b', 'foo', 'c', json_compact( '{ "d": "wibble" }') ); @@ -1517,8 +1559,11 @@ select json_object( cast(json_array() as char), json_array()); select json_object( 1, json_array()); select json_object( cast(1 as char), json_array()); +# Enable after fix MDEV-31554 +--disable_cursor_protocol # returns the empty object: {} SELECT JSON_OBJECT(); +--enable_cursor_protocol --echo # ---------------------------------------------------------------------- --echo # Test of JSON_SEARCH function. @@ -1710,17 +1755,23 @@ select json_type(case (null is null) when 1 then json_compact('null') else json_compact('[1,2,3]') end); +# Enable after fix MDEV-31554 +--disable_cursor_protocol select json_type(case (null is not null) when 1 then json_compact('null') else json_compact('[1,2,3]') end); +--enable_cursor_protocol select json_type( if(null is null, json_compact('null'), json_compact('[1,2,3]')) ); +# Enable after fix MDEV-31554 +--disable_cursor_protocol select json_type( if(null is not null, json_compact('null'), json_compact('[1,2,3]'))); +--enable_cursor_protocol select cast(json_extract(json_compact(concat('[', json_compact('["A",2]'), ']')), '$[0][1]') as char) = 2; @@ -1765,8 +1816,11 @@ select json_quote(convert('abc' using utf8mb4)); select json_unquote('abc'); # should do nothing select json_unquote('"abc"'); +# Enable after fix MDEV-31554 +--disable_cursor_protocol select json_unquote(convert('"abc"' using ascii)); select json_unquote(convert('"abc"' using latin1)); +--enable_cursor_protocol select json_unquote(convert('"abc"' using utf8)); select json_unquote(convert('"abc"' using utf8mb4)); @@ -1775,8 +1829,11 @@ select json_unquote('"'); # should do nothing --echo error ER_INCORRECT_TYPE select json_quote(123); # integer not allowed +# Enable after fix MDEV-31554 +--disable_cursor_protocol --echo error ER_INCORRECT_TYPE select json_unquote(123); # integer not allowed +--enable_cursor_protocol select json_unquote('""'); # empty string select char_length(json_unquote('""')); # verify empty string @@ -1810,21 +1867,30 @@ select json_unquote(json_unquote(json_unquote( # long round trip of it # DATE/TIME will lose their quotes, too: select json_compact(cast('2015-01-15 23:24:25' as datetime)); +# Enable after fix MDEV-31554 +--disable_cursor_protocol select json_unquote(json_compact(cast('2015-01-15 23:24:25' as datetime))); +--enable_cursor_protocol # as well as opaque values: select json_compact(st_geomfromtext('point(1 1)')); +# Enable after fix MDEV-31554 +--disable_cursor_protocol select json_unquote(json_compact(st_geomfromtext('point(1 1)'))); +--enable_cursor_protocol # examples from the wl7909 spec # returns the SQL string literal abc SELECT JSON_UNQUOTE( '"abc"' ); +# Enable after fix MDEV-31554 +--disable_cursor_protocol # returns the SQL string literal "abc SELECT JSON_UNQUOTE( '"abc' ); --echo error ER_INCORRECT_TYPE SELECT JSON_UNQUOTE( 123 ); +--enable_cursor_protocol # returns the SQL string literal abc SELECT JSON_UNQUOTE @@ -1966,7 +2032,10 @@ SELECT JSON_CONTAINS('[1]', '[1]', '$', '$[0]'); select json_object("a", ifnull(json_quote('test'), json_compact('null'))); select json_compact(concat('[', json_quote('ab'), ']')); select json_compact(concat('[', json_unquote('"12"'), ']')); +# Enable after fix MDEV-31554 +--disable_cursor_protocol select json_compact(concat('["', json_type( json_compact(1)), '"]')); +--enable_cursor_protocol --echo # --echo # Bug#20912438: ITEM_TYPE_HOLDER::DISPLAY_LENGTH(ITEM*): ASSERTION `0' FAILED @@ -2125,7 +2194,10 @@ select json_quote( json_type( json_compact('{}') ) ); --echo # WHEN EXECUTED IN A VIEW OR JOIN --echo # +# Enable after fix MDEV-31554 +--disable_cursor_protocol SELECT JSON_TYPE(JSON_OBJECT()); +--enable_cursor_protocol CREATE VIEW v1 AS SELECT JSON_TYPE(JSON_OBJECT()); SELECT * FROM v1; drop view v1; @@ -2158,8 +2230,11 @@ SELECT * FROM (SELECT JSON_UNQUOTE(JSON_QUOTE('This is a string that should not --echo # FOR BOOL WHEN USED VIA VIEW --echo # +# Enable after fix MDEV-31554 +--disable_cursor_protocol SELECT JSON_OBJECT('key1', false, 'key2', true); SELECT JSON_ARRAY('key1', false, 'key2', true); +--enable_cursor_protocol CREATE VIEW v1 AS SELECT JSON_OBJECT('key1', false, 'key2', true); SELECT * FROM v1; CREATE VIEW v2 AS SELECT JSON_ARRAY('key1', false, 'key2', true); @@ -2282,7 +2357,9 @@ SELECT JSON_REPLACE('[[[1]]]', '$[0][0][0]', 100); # LEAST and GREATEST treat JSON arguments as strings for now. They used to hit # an assertion if used in a JSON context and all arguments were JSON values, or # a mix of NULLs and JSON values. +# Enable after fix MDEV-31554 +--disable_cursor_protocol SELECT JSON_ARRAY(LEAST(NULL, NULL), GREATEST(NULL, NULL), LEAST(j1, NULL), GREATEST(NULL, j2), LEAST(j1, j2), GREATEST(j1, j2)) AS j FROM (SELECT json_compact('1') AS j1, json_compact('2') AS j2) t; - +--enable_cursor_protocol diff --git a/mysql-test/suite/parts/inc/partition.pre b/mysql-test/suite/parts/inc/partition.pre index fba909687a0..96e1afbb5a5 100644 --- a/mysql-test/suite/parts/inc/partition.pre +++ b/mysql-test/suite/parts/inc/partition.pre @@ -57,7 +57,9 @@ let $ER_NO_PARTITION_FOR_GIVEN_VALUE= 1526; # Set the variable $engine_other to a storage engine <> $engine --disable_query_log +--disable_cursor_protocol eval SELECT UPPER($engine) = 'MEMORY' INTO @aux; +--enable_cursor_protocol let $aux= `SELECT @aux`; if ($aux) { @@ -69,6 +71,7 @@ if (!$aux) } --enable_query_log +--disable_cursor_protocol # Numbers used for # - partitioning Example: ... PARTITION part1 VALUES LESS THAN ($max_row_div2) # - INSERT/SELECT/UPDATE/DELETE Example: ... WHERE f_int1 > @max_row_div3 @@ -102,6 +105,7 @@ WHERE f_int1 BETWEEN 2 * @max_row_div3 AND @max_row; # let $insert_all= INSERT INTO t1(f_int1,f_int2,f_char1,f_char2,f_charbig) SELECT f_int1,f_int2,f_char1,f_char2,f_charbig FROM t0_template; +--enable_cursor_protocol # Column list with definition for all tables to be checked let $column_list= f_int1 INTEGER DEFAULT 0, diff --git a/mysql-test/suite/parts/inc/partition_alter3.inc b/mysql-test/suite/parts/inc/partition_alter3.inc index 395f93f44f6..feebcf4ffaa 100644 --- a/mysql-test/suite/parts/inc/partition_alter3.inc +++ b/mysql-test/suite/parts/inc/partition_alter3.inc @@ -28,8 +28,10 @@ SELECT CONCAT(CAST((f_int1 + 999) AS CHAR),'-02-10'), CAST(f_char1 AS CHAR) FROM t0_template WHERE f_int1 + 999 BETWEEN 1000 AND 9999; # 3. Calculate the number of inserted records. +--disable_cursor_protocol SELECT IF(9999 - 1000 + 1 > @max_row, @max_row , 9999 - 1000 + 1) INTO @exp_row_count; +--enable_cursor_protocol # DEBUG SELECT @exp_row_count; # 4. Print the layout, check Readability --source suite/parts/inc/partition_layout.inc diff --git a/mysql-test/suite/parts/inc/partition_check.inc b/mysql-test/suite/parts/inc/partition_check.inc index ed323dfa245..4dad6bff16f 100644 --- a/mysql-test/suite/parts/inc/partition_check.inc +++ b/mysql-test/suite/parts/inc/partition_check.inc @@ -64,6 +64,7 @@ if ($no_debug) { --disable_query_log } +--disable_cursor_protocol let $my_stmt= SELECT COUNT(*) <> 0 INTO @aux FROM t1 WHERE f_int1 <> f_int2 OR f_char1 <> CAST(f_int1 AS CHAR) OR f_char1 <> f_char2 OR f_charbig <> CONCAT('===',f_char1,'===') @@ -148,6 +149,7 @@ if ($run) --echo # Sorry, have to abort. exit; } +--enable_cursor_protocol # Give a success message like in the other following tests --echo # check MIN/MAX(f_int2) success: 1 @@ -368,17 +370,21 @@ AND (MIN(f_int1) = 1) AND (MAX(f_int1) = @max_row) AS "" FROM t1; if ($any_unique) { # Calculate the number of records, where we will try INSERT ..... or REPLACE + --disable_cursor_protocol SELECT COUNT(*) INTO @try_count FROM t0_template WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row; + --enable_cursor_protocol # # Calculate the number of records, where we will get DUPLICATE KEY # f_int1 is sufficient for calculating this, because 1.1 # checks, that f_int1 = f_int2 is valid for all rows. + --disable_cursor_protocol SELECT COUNT(*) INTO @clash_count FROM t1 INNER JOIN t0_template USING(f_int1) WHERE MOD(f_int1,3) = 0 AND f_int1 BETWEEN @max_row_div2 AND @max_row; + --enable_cursor_protocol if ($debug) { SELECT @try_count, @clash_count; @@ -390,7 +396,9 @@ if ($any_unique) # 4 Some operations with single records # 4.1 Insert one record with a value for f_int1 which is lower than in all # existing records. +--disable_cursor_protocol SELECT MIN(f_int1) - 1 INTO @cur_value FROM t1; +--enable_cursor_protocol INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), @@ -408,7 +416,9 @@ WHERE f_int1 = @cur_value AND f_int2 = @cur_value # # 4.2 Insert one record with a value for f_int1 which is higher than in all # existing records. +--disable_cursor_protocol SELECT MAX(f_int1) + 1 INTO @cur_value FROM t1; +--enable_cursor_protocol INSERT INTO t1 SET f_int1 = @cur_value , f_int2 = @cur_value, f_char1 = CAST(@cur_value AS CHAR), f_char2 = CAST(@cur_value AS CHAR), @@ -428,8 +438,10 @@ WHERE f_int1 = @cur_value AND f_int2 = @cur_value # the highest value of all existing records. # If f_int1 is used for the partitioning expression a movement of the # record to another partition/subpartition might appear. +--disable_cursor_protocol SELECT MIN(f_int1) INTO @cur_value1 FROM t1; SELECT MAX(f_int1) + 1 INTO @cur_value2 FROM t1; +--enable_cursor_protocol UPDATE t1 SET f_int1 = @cur_value2 WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; # Check of preceding statement via Select @@ -447,7 +459,9 @@ WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; # record to another partition/subpartition might appear. # f_int1 gets the delicate value '-1'. SET @cur_value1= -1; +--disable_cursor_protocol SELECT MAX(f_int1) INTO @cur_value2 FROM t1; +--enable_cursor_protocol # Bug#15968: Partitions: crash when INSERT with f_int1 = -1 into PARTITION BY HASH(f_int1) UPDATE t1 SET f_int1 = @cur_value1 WHERE f_int1 = @cur_value2 AND f_charbig = '#SINGLE#'; @@ -461,7 +475,9 @@ WHERE f_int1 = @cur_value1 AND f_charbig = '#SINGLE#'; --enable_query_log # # 4.5 Delete the record with the highest value of f_int1. +--disable_cursor_protocol SELECT MAX(f_int1) INTO @cur_value FROM t1; +--enable_cursor_protocol DELETE FROM t1 WHERE f_int1 = @cur_value AND f_charbig = '#SINGLE#'; # Check of preceding statements via Select if ($no_debug) @@ -751,8 +767,10 @@ if ($no_debug) { --disable_query_log } +--disable_cursor_protocol SELECT COUNT(f_int1) INTO @start_count FROM t1 WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; +--enable_cursor_protocol --enable_query_log let $run= `SELECT @start_count <> 0`; if ($run) @@ -770,7 +788,9 @@ if ($no_debug) { --disable_query_log } +--disable_cursor_protocol SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; +--enable_cursor_protocol --enable_query_log # 7.1 Successful INSERT + COMMIT INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) @@ -839,8 +859,10 @@ if ($no_debug) { --disable_query_log } +--disable_cursor_protocol SELECT COUNT(*) INTO @my_count FROM t1 WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; +--enable_cursor_protocol SELECT '# check transactions-6 success: ' AS "", @my_count IN (0,@exp_inserted_rows) AS ""; let $run= `SELECT @my_count = 0`; @@ -872,7 +894,9 @@ COMMIT WORK; # 7.3 Failing INSERT (in mid of statement processing) + COMMIT SET @@session.sql_mode = 'traditional'; # Number of records where a INSERT has to be tried +--disable_cursor_protocol SELECT @max_row_div2 + @max_row_div4 - @max_row_div4 + 1 INTO @exp_inserted_rows; +--enable_cursor_protocol # --disable_abort_on_error INSERT INTO t1 (f_int1, f_int2, f_char1, f_char2, f_charbig) @@ -890,8 +914,10 @@ if ($no_debug) { --disable_query_log } +--disable_cursor_protocol SELECT COUNT(*) INTO @my_count FROM t1 WHERE f_int1 BETWEEN @max_row_div4 AND @max_row_div2 + @max_row_div4; +--enable_cursor_protocol SELECT '# check transactions-8 success: ' AS "", @my_count IN (@max_row_div2 - 1 - @max_row_div4 + 1,0) AS ""; let $run= `SELECT @my_count = @max_row_div2 - 1 - @max_row_div4 + 1`; diff --git a/mysql-test/suite/parts/inc/partition_check_read.inc b/mysql-test/suite/parts/inc/partition_check_read.inc index e42bb9c90ab..280580d67a6 100644 --- a/mysql-test/suite/parts/inc/partition_check_read.inc +++ b/mysql-test/suite/parts/inc/partition_check_read.inc @@ -27,7 +27,9 @@ while ($num) { --disable_query_log } + --disable_cursor_protocol eval SELECT COUNT(*) <> 1 INTO @aux FROM t1 WHERE $col_to_check = $num; + --enable_cursor_protocol --enable_query_log let $run= `SELECT @aux`; if ($run) @@ -46,7 +48,9 @@ while ($num) { --disable_query_log } + --disable_cursor_protocol eval SELECT COUNT(*) = 1 INTO @aux FROM t1 WHERE $col_to_check = @max_row + $num; + --enable_cursor_protocol --enable_query_log let $run= `SELECT @aux`; if ($run) @@ -64,7 +68,9 @@ while ($num) { --disable_query_log } + --disable_cursor_protocol eval SELECT COUNT(*) = 1 INTO @aux FROM t1 WHERE $col_to_check = 1 - $num; + --enable_cursor_protocol --enable_query_log let $run= `SELECT @aux`; if ($run) diff --git a/mysql-test/suite/parts/inc/partition_check_read1.inc b/mysql-test/suite/parts/inc/partition_check_read1.inc index 0b8b800a371..cb6b839130a 100644 --- a/mysql-test/suite/parts/inc/partition_check_read1.inc +++ b/mysql-test/suite/parts/inc/partition_check_read1.inc @@ -26,7 +26,9 @@ if ($no_debug) { --disable_query_log } +--disable_cursor_protocol SELECT COUNT(*) <> 1 INTO @aux FROM t1 WHERE f_date = '1000-02-10'; +--enable_cursor_protocol --enable_query_log let $run= `SELECT @aux`; if ($run) @@ -43,7 +45,9 @@ if ($no_debug) { --disable_query_log } +--disable_cursor_protocol eval SELECT COUNT(*) <> @exp_row_count INTO @aux FROM t1; +--enable_cursor_protocol --enable_query_log let $run= `SELECT @aux`; if ($run) @@ -63,8 +67,10 @@ while ($num) { --disable_query_log } + --disable_cursor_protocol eval SELECT COUNT(*) <> 1 INTO @aux FROM t1 WHERE f_date = CONCAT(CAST(999 + $num AS CHAR),'-02-10'); + --enable_cursor_protocol --enable_query_log let $run= `SELECT @aux`; if ($run) diff --git a/mysql-test/suite/parts/inc/partition_check_read2.inc b/mysql-test/suite/parts/inc/partition_check_read2.inc index 60964355d14..36421dec115 100644 --- a/mysql-test/suite/parts/inc/partition_check_read2.inc +++ b/mysql-test/suite/parts/inc/partition_check_read2.inc @@ -22,7 +22,9 @@ if ($no_debug) { --disable_query_log } +--disable_cursor_protocol SELECT COUNT(*) <> 1 INTO @aux FROM t1 WHERE f_int1 = 3; +--enable_cursor_protocol --enable_query_log let $run= `SELECT @aux`; if ($run) @@ -39,7 +41,9 @@ if ($no_debug) { --disable_query_log } +--disable_cursor_protocol eval SELECT COUNT(*) <> @max_row INTO @aux FROM t1; +--enable_cursor_protocol --enable_query_log let $run= `SELECT @aux`; if ($run) @@ -59,8 +63,10 @@ while ($num) { --disable_query_log } + --disable_cursor_protocol eval SELECT COUNT(*) <> 1 INTO @aux FROM t1 WHERE f_int1 = 3; + --enable_cursor_protocol --enable_query_log let $run= `SELECT @aux`; if ($run) diff --git a/mysql-test/suite/parts/inc/partition_layout_check2.inc b/mysql-test/suite/parts/inc/partition_layout_check2.inc index 23e4a9e1e95..6e98eb16223 100644 --- a/mysql-test/suite/parts/inc/partition_layout_check2.inc +++ b/mysql-test/suite/parts/inc/partition_layout_check2.inc @@ -58,11 +58,13 @@ eval INSERT INTO t0_definition SET state = 'new', file_list = @aux; # Print the old and new table layout, if they differ +--disable_cursor_protocol SELECT COUNT(*) <> 1 INTO @aux FROM t0_definition tab1, t0_definition tab2 WHERE tab1.state = 'old' AND tab2.state = 'new' AND tab1.create_command = tab2.create_command AND tab1.file_list = tab2.file_list; +--enable_cursor_protocol let $run= `SELECT @aux`; if ($run) { diff --git a/mysql-test/suite/parts/inc/partition_trigg1.inc b/mysql-test/suite/parts/inc/partition_trigg1.inc index 7bb5aa162a9..c0d6ba4e867 100644 --- a/mysql-test/suite/parts/inc/partition_trigg1.inc +++ b/mysql-test/suite/parts/inc/partition_trigg1.inc @@ -24,7 +24,9 @@ if ($no_debug) { --disable_query_log } +--disable_cursor_protocol eval SELECT INSTR('$statement','DELETE') = 0 INTO @aux; +--enable_cursor_protocol let $run1= `SELECT @aux`; --enable_query_log if ($run1) @@ -72,7 +74,9 @@ if ($no_debug) { --disable_query_log } +--disable_cursor_protocol eval SELECT INSTR('$statement','INSERT') = 0 INTO @aux; +--enable_cursor_protocol let $run1= `SELECT @aux`; --enable_query_log if ($run1) diff --git a/mysql-test/suite/parts/inc/partition_trigg3.inc b/mysql-test/suite/parts/inc/partition_trigg3.inc index 34dbf4e2cd1..4d461a8a755 100644 --- a/mysql-test/suite/parts/inc/partition_trigg3.inc +++ b/mysql-test/suite/parts/inc/partition_trigg3.inc @@ -46,7 +46,9 @@ delimiter ;| # Additional statements because of Bug(limitation)#17704 SET @counter = 1; # Bug#18730 Partitions: crash on SELECT MIN() +--disable_cursor_protocol SELECT MAX(f_int1), MIN(f_int2) INTO @my_max1,@my_min2 FROM t1; +--enable_cursor_protocol # Additional statements end eval $statement; DROP TRIGGER trg_3; diff --git a/mysql-test/suite/perfschema/t/alter_table_progress.test b/mysql-test/suite/perfschema/t/alter_table_progress.test index d0a4055ad0e..d132ed53fa5 100644 --- a/mysql-test/suite/perfschema/t/alter_table_progress.test +++ b/mysql-test/suite/perfschema/t/alter_table_progress.test @@ -34,9 +34,11 @@ update performance_schema.threads truncate table performance_schema.events_statements_history_long; truncate table performance_schema.events_stages_history_long; +--disable_cursor_protocol --disable_query_log eval select $con1_THREAD_ID into @con1_thread_id; --enable_query_log +--enable_cursor_protocol --connection con1 @@ -52,8 +54,10 @@ SET DEBUG_SYNC='copy_data_between_tables_before SIGNAL found_row WAIT_FOR wait_r SET DEBUG_SYNC='now WAIT_FOR found_row'; # Find the statement id of the ALTER TABLE +--disable_cursor_protocol select event_id from performance_schema.events_statements_current where thread_id = @con1_thread_id into @con1_stmt_id; +--enable_cursor_protocol # completed 0 select EVENT_NAME, WORK_COMPLETED, WORK_ESTIMATED diff --git a/mysql-test/suite/perfschema/t/dml_handler.test b/mysql-test/suite/perfschema/t/dml_handler.test index 16810fcba82..791d2274598 100644 --- a/mysql-test/suite/perfschema/t/dml_handler.test +++ b/mysql-test/suite/perfschema/t/dml_handler.test @@ -21,7 +21,9 @@ CREATE TEMPORARY TABLE table_list (id INT AUTO_INCREMENT, PRIMARY KEY (id)) AS WHERE TABLE_SCHEMA='performance_schema' ORDER BY TABLE_NAME; +--disable_cursor_protocol SELECT COUNT(*) FROM table_list INTO @table_count; +--enable_cursor_protocol let $count=`SELECT @table_count`; @@ -32,7 +34,9 @@ let $count=`SELECT @table_count`; while ($count > 0) { + --disable_cursor_protocol eval SELECT TABLE_NAME INTO @table_name FROM table_list WHERE id=$count; + --enable_cursor_protocol let $table_name = `SELECT @table_name`; --error ER_ILLEGAL_HA eval HANDLER performance_schema.$table_name OPEN; diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_blocked.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_blocked.test index d304cc5a1b8..58077973248 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_blocked.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_blocked.test @@ -17,7 +17,9 @@ --source ../include/wait_for_pfs_thread_count.inc --source ../include/hostcache_set_state.inc +--disable_cursor_protocol select @@global.max_connect_errors into @saved_max_connect_errors; +--enable_cursor_protocol set global max_connect_errors = 3; diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con.test b/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con.test index 6420b8b5300..ab3fd73ab45 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv4_max_con.test @@ -17,8 +17,10 @@ --source ../include/wait_for_pfs_thread_count.inc --source ../include/hostcache_set_state.inc +--disable_cursor_protocol select @@global.max_connections into @saved_max_connections; select @@global.max_user_connections into @saved_max_user_connections; +--enable_cursor_protocol create user 'quota'@'santa.claus.ipv4.example.com'; grant select on test.* to 'quota'@'santa.claus.ipv4.example.com'; diff --git a/mysql-test/suite/perfschema/t/hostcache_ipv6_blocked.test b/mysql-test/suite/perfschema/t/hostcache_ipv6_blocked.test index 6da99e02444..9d845b5e296 100644 --- a/mysql-test/suite/perfschema/t/hostcache_ipv6_blocked.test +++ b/mysql-test/suite/perfschema/t/hostcache_ipv6_blocked.test @@ -17,7 +17,9 @@ --source ../include/wait_for_pfs_thread_count.inc --source ../include/hostcache_set_state.inc +--disable_cursor_protocol select @@global.max_connect_errors into @saved_max_connect_errors; +--enable_cursor_protocol set global max_connect_errors = 3; diff --git a/mysql-test/suite/perfschema/t/query_cache.test b/mysql-test/suite/perfschema/t/query_cache.test index 045c4628e9e..43c408a075f 100644 --- a/mysql-test/suite/perfschema/t/query_cache.test +++ b/mysql-test/suite/perfschema/t/query_cache.test @@ -23,13 +23,17 @@ reset query cache; flush status; --disable_ps2_protocol +--disable_cursor_protocol select * from t1; +--enable_cursor_protocol show global status like "Qcache_queries_in_cache"; show global status like "Qcache_inserts"; show global status like "Qcache_hits"; +--disable_cursor_protocol select * from t1; +--enable_cursor_protocol show global status like "Qcache_queries_in_cache"; show global status like "Qcache_inserts"; diff --git a/mysql-test/suite/perfschema/t/rpl_threads.test b/mysql-test/suite/perfschema/t/rpl_threads.test index 984939c21f8..f8438649cf0 100644 --- a/mysql-test/suite/perfschema/t/rpl_threads.test +++ b/mysql-test/suite/perfschema/t/rpl_threads.test @@ -29,9 +29,11 @@ connection master; # Read the ID of the binlog dump connection, # as exposed in PROCESSLIST. +--disable_cursor_protocol select ID from INFORMATION_SCHEMA.PROCESSLIST where COMMAND = "Binlog Dump" into @master_dump_pid; +--enable_cursor_protocol select COMMAND, STATE from INFORMATION_SCHEMA.PROCESSLIST @@ -47,9 +49,11 @@ sync_slave_with_master; # Read the ID of the SLAVE IO thread, # as exposed in PROCESSLIST. +--disable_cursor_protocol select ID from INFORMATION_SCHEMA.PROCESSLIST where STATE like "Waiting for master to send event%" into @slave_io_pid; +--enable_cursor_protocol select COMMAND, STATE from INFORMATION_SCHEMA.PROCESSLIST @@ -62,9 +66,11 @@ select NAME, TYPE, PROCESSLIST_COMMAND, PROCESSLIST_STATE # Read the ID of the SLAVE SQL thread, # as exposed in PROCESSLIST. +--disable_cursor_protocol select ID from INFORMATION_SCHEMA.PROCESSLIST where STATE like "Slave has read all relay log%" into @slave_sql_pid; +--enable_cursor_protocol select COMMAND, STATE from INFORMATION_SCHEMA.PROCESSLIST diff --git a/mysql-test/suite/perfschema/t/socket_connect.test b/mysql-test/suite/perfschema/t/socket_connect.test index 4ae9608cd0e..6b84ada964a 100644 --- a/mysql-test/suite/perfschema/t/socket_connect.test +++ b/mysql-test/suite/perfschema/t/socket_connect.test @@ -16,6 +16,7 @@ let $my_socket_debug_dbug=0; --echo #============================================================================== --source ../include/socket_ipv6.inc +--disable_cursor_protocol --echo #============================================================================== --echo # Get hostname, port number --echo #============================================================================== @@ -291,3 +292,4 @@ WHERE EVENT_NAME LIKE '%client_connection%' AND OBJECT_INSTANCE_BEGIN <> @default_object_instance_begin; --source include/wait_condition.inc exit; +--enable_cursor_protocol diff --git a/mysql-test/suite/perfschema/t/socket_instances_func.test b/mysql-test/suite/perfschema/t/socket_instances_func.test index 4cf58d42185..1541a402289 100644 --- a/mysql-test/suite/perfschema/t/socket_instances_func.test +++ b/mysql-test/suite/perfschema/t/socket_instances_func.test @@ -47,9 +47,11 @@ CREATE TEMPORARY TABLE my_socket_instances AS SELECT * FROM performance_schema.socket_instances; --echo # Get thread id of the default connection +--disable_cursor_protocol SELECT THREAD_ID INTO @thread_id FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID(); +--enable_cursor_protocol let $con0_thread_id= `SELECT @thread_id`; @@ -67,14 +69,18 @@ if($my_socket_debug) } --echo # Store the thread id of connection 1 (tcp/ip) +--disable_cursor_protocol SELECT THREAD_ID INTO @thread_id FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID(); +--enable_cursor_protocol --echo # Store the port of connection 1 (tcp/ip) +--disable_cursor_protocol eval SELECT PORT INTO @port FROM performance_schema.socket_instances WHERE THREAD_ID = @thread_id; +--enable_cursor_protocol let $con1_thread_id= `SELECT @thread_id`; let $con1_port= `SELECT @port`; @@ -95,14 +101,18 @@ if($my_socket_debug) } --echo # Store the thread_id of connection 2 (tcp/ip) +--disable_cursor_protocol SELECT THREAD_ID INTO @thread_id FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID(); +--enable_cursor_protocol --echo # Store the port of connection 2 (tcp/ip) +--disable_cursor_protocol eval SELECT PORT INTO @port FROM performance_schema.socket_instances WHERE THREAD_ID = @thread_id; +--enable_cursor_protocol let $con2_thread_id= `SELECT @thread_id`; let $con2_port= `SELECT @port`; @@ -123,14 +133,18 @@ if($my_socket_debug) } --echo # Store the thread id of connection 3 (unix domain) +--disable_cursor_protocol SELECT THREAD_ID INTO @thread_id FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID(); +--enable_cursor_protocol --echo # Store the port of connection 3 (unix domain) +--disable_cursor_protocol eval SELECT PORT INTO @port FROM performance_schema.socket_instances WHERE THREAD_ID = @thread_id; +--enable_cursor_protocol let $con3_port= `SELECT @port`; let $con3_thread_id= `SELECT @thread_id`; @@ -232,9 +246,11 @@ WHERE EVENT_NAME = 'wait/io/socket/sql/server_tcpip_socket'; # Store the thread id of server_tcpip_socket --echo # Get the 'server_tcpip_socket' thread id +--disable_cursor_protocol SELECT THREAD_ID INTO @thread_id FROM performance_schema.socket_instances WHERE EVENT_NAME = 'wait/io/socket/sql/server_tcpip_socket'; +--enable_cursor_protocol let $server_tcpip_thread_id= `SELECT @thread_id`; @@ -265,9 +281,11 @@ WHERE EVENT_NAME = 'wait/io/socket/sql/server_unix_socket'; # Store the thread id of 'server_unix_socket' --echo # Get the 'server_unix_socket' thread id +--disable_cursor_protocol SELECT THREAD_ID INTO @thread_id FROM performance_schema.socket_instances WHERE EVENT_NAME = 'wait/io/socket/sql/server_unix_socket'; +--enable_cursor_protocol let $server_unix_thread_id= `SELECT @thread_id`; @@ -301,7 +319,9 @@ WHERE THREAD_ID = @thread_id; --echo #Compare server listener socket thread ids --disable_query_log ONCE +--disable_cursor_protocol eval SELECT ($server_tcpip_thread_id = $server_unix_thread_id) into @match_thread_id; +--disable_cursor_protocol select @match_thread_id; diff --git a/mysql-test/suite/perfschema/t/socket_instances_func_win.test b/mysql-test/suite/perfschema/t/socket_instances_func_win.test index 5faf0d24ec4..24774a51fa2 100644 --- a/mysql-test/suite/perfschema/t/socket_instances_func_win.test +++ b/mysql-test/suite/perfschema/t/socket_instances_func_win.test @@ -47,9 +47,11 @@ CREATE TEMPORARY TABLE my_socket_instances AS SELECT * FROM performance_schema.socket_instances; --echo # Get thread id of the default connection +--disable_cursor_protocol SELECT THREAD_ID INTO @thread_id FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID(); +--enable_cursor_protocol let $con0_thread_id= `SELECT @thread_id`; @@ -70,14 +72,18 @@ if($my_socket_debug) } --echo # Store the thread id of connection 1 (tcp/ip) +--disable_cursor_protocol SELECT THREAD_ID INTO @thread_id FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID(); +--enable_cursor_protocol --echo # Store the port of connection 1 (tcp/ip) +--disable_cursor_protocol eval SELECT PORT INTO @port FROM performance_schema.socket_instances WHERE THREAD_ID = @thread_id; +--enable_cursor_protocol let $con1_thread_id= `SELECT @thread_id`; let $con1_port= `SELECT @port`; @@ -102,14 +108,18 @@ if($my_socket_debug) } --echo # Store the thread_id of connection 2 (tcp/ip) +--disable_cursor_protocol SELECT THREAD_ID INTO @thread_id FROM performance_schema.threads WHERE PROCESSLIST_ID = CONNECTION_ID(); +--enable_cursor_protocol --echo # Store the port of connection 2 (tcp/ip) +--disable_cursor_protocol eval SELECT PORT INTO @port FROM performance_schema.socket_instances WHERE THREAD_ID = @thread_id; +--enable_cursor_protocol let $con2_thread_id= `SELECT @thread_id`; let $con2_port = `SELECT @port`; @@ -216,9 +226,11 @@ WHERE EVENT_NAME = 'wait/io/socket/sql/server_tcpip_socket'; # Store the thread id of server_tcpip_socket --echo # Get the 'server_tcpip_socket' thread id +--disable_cursor_protocol SELECT THREAD_ID INTO @thread_id FROM performance_schema.socket_instances WHERE EVENT_NAME = 'wait/io/socket/sql/server_tcpip_socket'; +--enable_cursor_protocol let $server_tcpip_thread_id= `SELECT @thread_id`; diff --git a/mysql-test/suite/perfschema/t/socket_summary_by_event_name_func.test b/mysql-test/suite/perfschema/t/socket_summary_by_event_name_func.test index 4a6ee2b6277..aebe64e3f59 100644 --- a/mysql-test/suite/perfschema/t/socket_summary_by_event_name_func.test +++ b/mysql-test/suite/perfschema/t/socket_summary_by_event_name_func.test @@ -41,8 +41,10 @@ let $my_socket_debug_dbug= 0; --echo #============================================================================== --echo # Get hostname, port number --echo #============================================================================== +--disable_cursor_protocol SELECT @@hostname INTO @MY_HOSTNAME; SELECT @@port INTO @MY_MASTER_PORT; +--enable_cursor_protocol if ($my_socket_debug) { @@ -145,7 +147,7 @@ WHERE t_inst.event_name LIKE '%client%' --connection default UPDATE performance_schema.threads SET INSTRUMENTED='NO' WHERE PROCESSLIST_ID = CONNECTION_ID(); - +--disable_cursor_protocol --echo # --echo # 1.2 Get the default THREAD_ID; --echo # @@ -161,6 +163,7 @@ let $default_object_instance_begin= `SELECT @my_object_instance_begin`; --disable_query_log SELECT @my_object_instance_begin INTO @default_object_instance_begin; --enable_query_log +--enable_cursor_protocol if ($my_socket_debug) { diff --git a/mysql-test/suite/perfschema/t/table_schema.test b/mysql-test/suite/perfschema/t/table_schema.test index 935bd667f2d..6abbd403837 100644 --- a/mysql-test/suite/perfschema/t/table_schema.test +++ b/mysql-test/suite/perfschema/t/table_schema.test @@ -16,9 +16,11 @@ select * from information_schema.columns where table_schema="performance_schema" # Count the number of NUMBER_OF_BYTES columns. +--disable_cursor_protocol select count(*) into @count_byte_columns from information_schema.columns where table_schema="performance_schema" and data_type = "bigint" and column_name like "%number_of_bytes"; +--enable_cursor_protocol # Confirm that at least one column was found. @@ -26,10 +28,12 @@ select @count_byte_columns > 0; # Confirm that all NUMBER_OF_BYTES columns are BIGINT signed. +--disable_cursor_protocol select count(*) into @count_byte_signed from information_schema.columns where table_schema="performance_schema" and data_type="bigint" and column_name like "%number_of_bytes" and column_type not like "%unsigned"; +--enable_cursor_protocol select (@count_byte_columns - @count_byte_signed) = 0; @@ -38,9 +42,11 @@ select (@count_byte_columns - @count_byte_signed) = 0; # # Count the number of OBJECT_INSTANCE_BEGIN columns. +--disable_cursor_protocol select count(*) into @count_object_columns from information_schema.columns where table_schema="performance_schema" and data_type = "bigint" and column_name like "%object_instance_begin"; +--enable_cursor_protocol # Confirm that at least one column was found. @@ -48,10 +54,12 @@ select @count_object_columns > 0; # Confirm that all OBJECT_INSTANCE_BEGIN columns are BIGINT unsigned. +--disable_cursor_protocol select count(*) into @count_object_unsigned from information_schema.columns where table_schema="performance_schema" and data_type="bigint" and column_name like "%object_instance_begin" and column_type like "%unsigned"; +--enable_cursor_protocol select (@count_object_columns - @count_object_unsigned) = 0; diff --git a/mysql-test/suite/perfschema/t/thread_cache.test b/mysql-test/suite/perfschema/t/thread_cache.test index 92309bb9ca1..1bd52afbd01 100644 --- a/mysql-test/suite/perfschema/t/thread_cache.test +++ b/mysql-test/suite/perfschema/t/thread_cache.test @@ -36,8 +36,10 @@ let $con2_THREAD_ID=`select thread_id from performance_schema.threads --connection default --disable_query_log +--disable_cursor_protocol eval select ($con2_ID - $con1_ID) into @id_increment; eval select ($con2_THREAD_ID - $con1_THREAD_ID) into @thread_id_increment; +--enable_cursor_protocol --enable_query_log # Expect 1, connection_id() is incremented for each new connection @@ -82,8 +84,10 @@ let $wait_condition= --source include/wait_condition.inc --disable_query_log +--disable_cursor_protocol eval select ($con3_ID - $con2_ID) into @id_increment; eval select ($con3_THREAD_ID - $con2_THREAD_ID) into @thread_id_increment; +--enable_cursor_protocol --enable_query_log select @id_increment; @@ -110,8 +114,10 @@ let $con2_THREAD_ID=`select thread_id from performance_schema.threads --connection default --disable_query_log +--disable_cursor_protocol eval select ($con2_ID - $con1_ID) into @id_increment; eval select ($con2_THREAD_ID - $con1_THREAD_ID) into @thread_id_increment; +--enable_cursor_protocol --enable_query_log select @id_increment; @@ -154,8 +160,10 @@ let $wait_condition= --source include/wait_condition.inc --disable_query_log +--disable_cursor_protocol eval select ($con3_ID - $con2_ID) into @id_increment; eval select ($con3_THREAD_ID - $con2_THREAD_ID) into @thread_id_increment; +--enable_cursor_protocol --enable_query_log # When caching threads, the pthread that executed con2 was parked in the diff --git a/mysql-test/suite/perfschema/t/threads_mysql.test b/mysql-test/suite/perfschema/t/threads_mysql.test index e19b3664f21..cf0a1386b5f 100644 --- a/mysql-test/suite/perfschema/t/threads_mysql.test +++ b/mysql-test/suite/perfschema/t/threads_mysql.test @@ -64,7 +64,9 @@ TRUNCATE t1; INSERT INTO t1 SELECT thread_id FROM performance_schema.threads WHERE name LIKE 'thread/sql%'; +--disable_cursor_protocol SELECT COUNT(*) INTO @aux FROM t1; +--enable_cursor_protocol # Attention: # Just waiting for some new thread showing up is not sufficient because diff --git a/mysql-test/suite/period/t/overlaps.test b/mysql-test/suite/period/t/overlaps.test index b762743be24..aca1a9150de 100644 --- a/mysql-test/suite/period/t/overlaps.test +++ b/mysql-test/suite/period/t/overlaps.test @@ -253,18 +253,22 @@ insert into t values (1, '2020-03-03', '2020-03-10') on duplicate key update x = 2; select * from t; +--disable_cursor_protocol --disable_ps2_protocol select * into outfile 'tmp_t.txt' from t; --enable_ps2_protocol +--enable_cursor_protocol load data infile 'tmp_t.txt' into table t; --error ER_NOT_SUPPORTED_YET load data infile 'tmp_t.txt' replace into table t; remove_file $MYSQLD_DATADIR/test/tmp_t.txt; insert into t values (1, '2020-03-01', '2020-03-05'); +--disable_cursor_protocol --disable_ps2_protocol select * into outfile 'tmp_t.txt' from t; --enable_ps2_protocol +--enable_cursor_protocol --error ER_DUP_ENTRY load data infile 'tmp_t.txt' into table t; diff --git a/mysql-test/suite/period/t/versioning.test b/mysql-test/suite/period/t/versioning.test index 5d38d81349e..45ca12469df 100644 --- a/mysql-test/suite/period/t/versioning.test +++ b/mysql-test/suite/period/t/versioning.test @@ -12,7 +12,9 @@ eval create table t ( insert into t values('1999-01-01', '2018-12-12'), ('1999-01-01', '1999-12-12'); +--disable_cursor_protocol select row_start into @ins_time from t limit 1; +--enable_cursor_protocol select * from t order by s, e; delete from t for portion of apptime from '2000-01-01' to '2018-01-01'; @@ -28,7 +30,9 @@ insert into t values('1999-01-01', '2018-12-12'), --let $trig_table=t --source suite/period/create_triggers.inc +--disable_cursor_protocol select row_start into @ins_time from t limit 1; +--enable_cursor_protocol select * from t order by s, e; delete from t for portion of apptime from '2000-01-01' to '2018-01-01'; @@ -47,7 +51,9 @@ eval create or replace table t (x int, s date, e date, insert into t values(1, '1999-01-01', '2018-12-12'), (2, '1999-01-01', '1999-12-12'); +--disable_cursor_protocol select row_start into @ins_time from t limit 1; +--enable_cursor_protocol --sorted_result select * from t; diff --git a/mysql-test/suite/plugins/t/feedback_plugin_load.test b/mysql-test/suite/plugins/t/feedback_plugin_load.test index f67397afdfe..cb154cae7ad 100644 --- a/mysql-test/suite/plugins/t/feedback_plugin_load.test +++ b/mysql-test/suite/plugins/t/feedback_plugin_load.test @@ -18,7 +18,9 @@ select plugin_status from information_schema.plugins where plugin_name='feedback # so lets get back to it if it ever happens. # Lets say the plugin was used X times before this SELECT +--disable_cursor_protocol SELECT variable_value INTO @feedback_used FROM information_schema.feedback where variable_name = 'FEEDBACK used'; +--enable_cursor_protocol # Now $feedback_used == X+1, and 'FEEDBACK used' is also X+1. And variable_value is increased again when we run the next SELECT SELECT variable_value = @feedback_used + 1 as 'MUST BE 1' FROM information_schema.feedback where variable_name = 'FEEDBACK used'; diff --git a/mysql-test/suite/plugins/t/qc_info.test b/mysql-test/suite/plugins/t/qc_info.test index de3e9d59b01..5345bac12ff 100644 --- a/mysql-test/suite/plugins/t/qc_info.test +++ b/mysql-test/suite/plugins/t/qc_info.test @@ -4,10 +4,12 @@ set @save_query_cache_size=@@global.query_cache_size; # test that hits are correctly incremented reset query cache; +--disable_cursor_protocol --disable_ps2_protocol select * from t1; select * from t1; --enable_ps2_protocol +--enable_cursor_protocol select hits, statement_text from information_schema.query_cache_info; drop table t1; diff --git a/mysql-test/suite/plugins/t/qc_info_init.inc b/mysql-test/suite/plugins/t/qc_info_init.inc index c69ffa07ca8..8c2d4b6e227 100644 --- a/mysql-test/suite/plugins/t/qc_info_init.inc +++ b/mysql-test/suite/plugins/t/qc_info_init.inc @@ -9,11 +9,14 @@ set global query_cache_size=1355776; create table t1 (a int not null); insert into t1 values (1),(2),(3); +--disable_cursor_protocol --disable_ps2_protocol select * from t1; --enable_ps2_protocol +--enable_cursor_protocol select statement_schema, statement_text, result_blocks_count, result_blocks_size from information_schema.query_cache_info; +--disable_cursor_protocol select @@time_zone into @time_zone; select @@default_week_format into @default_week_format; select @@character_set_client into @character_set_client; @@ -32,6 +35,7 @@ select * from t1; --enable_ps2_protocol --enable_result_log set time_zone= @time_zone, default_week_format= @default_week_format, character_set_client= @character_set_client,character_set_results= @character_set_results, sql_mode= @sql_mode, div_precision_increment= @div_precision_increment, lc_time_names= @lc_time_names, autocommit= @autocommit, group_concat_max_len= @group_concat_max_len, max_sort_length= @max_sort_length; +--enable_cursor_protocol --sorted_result --replace_column 5 # 20 # 24 # diff --git a/mysql-test/suite/roles/grant_revoke_current.test b/mysql-test/suite/roles/grant_revoke_current.test index fda55358b20..1c7bb0402df 100644 --- a/mysql-test/suite/roles/grant_revoke_current.test +++ b/mysql-test/suite/roles/grant_revoke_current.test @@ -1,5 +1,8 @@ --source include/not_embedded.inc + +--disable_cursor_protocol select priv into @root_priv from mysql.global_priv where user='root' and host='localhost'; +--enable_cursor_protocol --error ER_MALFORMED_DEFINER grant select on *.* to current_role; diff --git a/mysql-test/suite/roles/set_default_role_ps-6960.test b/mysql-test/suite/roles/set_default_role_ps-6960.test index fd965c2aa75..ce7bb96b5bb 100644 --- a/mysql-test/suite/roles/set_default_role_ps-6960.test +++ b/mysql-test/suite/roles/set_default_role_ps-6960.test @@ -4,7 +4,9 @@ --source include/not_embedded.inc +--disable_cursor_protocol select priv into @root_priv from mysql.global_priv where user='root' and host='localhost'; +--enable_cursor_protocol create role r1; prepare stmt from "set password = '11111111111111111111111111111111111111111'"; diff --git a/mysql-test/suite/rpl/include/check_type.inc b/mysql-test/suite/rpl/include/check_type.inc index c72754cad4f..26276391a63 100644 --- a/mysql-test/suite/rpl/include/check_type.inc +++ b/mysql-test/suite/rpl/include/check_type.inc @@ -43,7 +43,9 @@ connection master; eval INSERT INTO t1 VALUES(1, $source_value); if ($can_convert) { sync_slave_with_master; + --disable_cursor_protocol eval SELECT a = $target_value into @compare FROM t1; + --enable_cursor_protocol eval INSERT INTO type_conversions SET Source = "$source_type", Target = "$target_type", diff --git a/mysql-test/suite/rpl/include/rpl_innodb_rows_counters.inc b/mysql-test/suite/rpl/include/rpl_innodb_rows_counters.inc index cb51058f0ae..9e4d468bb16 100644 --- a/mysql-test/suite/rpl/include/rpl_innodb_rows_counters.inc +++ b/mysql-test/suite/rpl/include/rpl_innodb_rows_counters.inc @@ -5,6 +5,7 @@ # Requirements: Having @[master|slave]_[system_]rows_[read|inserted|deleted|updated] counters already created ######################################### +--disable_cursor_protocol --connection master select variable_value into @rows_read from information_schema.global_status where variable_name = 'innodb_rows_read'; @@ -46,3 +47,4 @@ select variable_value into @system_rows_inserted from information_schema.global_ select @system_rows_inserted - @slave_system_rows_inserted; --connection master +--enable_cursor_protocol diff --git a/mysql-test/suite/rpl/include/rpl_stop_middle_group.test b/mysql-test/suite/rpl/include/rpl_stop_middle_group.test index 6bc872cabe5..0a436b28b20 100644 --- a/mysql-test/suite/rpl/include/rpl_stop_middle_group.test +++ b/mysql-test/suite/rpl/include/rpl_stop_middle_group.test @@ -37,9 +37,11 @@ source include/wait_for_slave_sql_to_stop.inc; let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1); let $read = query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1); let $exec = query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1); +--disable_cursor_protocol --disable_query_log eval SELECT $read = $exec into @check; --enable_query_log +--enable_cursor_protocol eval SELECT "NO$error" AS Last_SQL_Error, @check as `true`; select count(*) as one from tm; select count(*) as one from ti; @@ -91,9 +93,11 @@ source include/wait_for_slave_sql_error.inc; let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1); let $read = query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1); let $exec = query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1); +--disable_cursor_protocol --disable_query_log eval SELECT $read - $exec > 0 into @check; --enable_query_log +--enable_cursor_protocol eval SELECT "$error" AS Last_SQL_Error, @check as `true`; select count(*) as one from tm; select count(*) as zero from ti; @@ -130,9 +134,11 @@ source include/wait_for_slave_sql_error.inc; let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1); let $read = query_get_value("SHOW SLAVE STATUS", Read_Master_Log_Pos, 1); let $exec = query_get_value("SHOW SLAVE STATUS", Exec_Master_Log_Pos, 1); +--disable_cursor_protocol --disable_query_log eval SELECT $read - $exec > 0 into @check; --enable_query_log +--enable_cursor_protocol eval SELECT "$error" AS Last_SQL_Error, @check as `true`; select max(a) as two from tm; select max(a) as one from ti; diff --git a/mysql-test/suite/rpl/t/rpl_binlog_errors.test b/mysql-test/suite/rpl/t/rpl_binlog_errors.test index a5988efcb21..1c80f4f4b53 100644 --- a/mysql-test/suite/rpl/t/rpl_binlog_errors.test +++ b/mysql-test/suite/rpl/t/rpl_binlog_errors.test @@ -58,9 +58,11 @@ SET @old_debug= @@global.debug_dbug; -- let $load_file= $MYSQLTEST_VARDIR/tmp/bug_46166.data -- let $MYSQLD_DATADIR= `select @@datadir` -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --disable_ps2_protocol -- eval SELECT repeat('x',8192) INTO OUTFILE '$load_file' --enable_ps2_protocol +--enable_cursor_protocol ### ACTION: create a small file (< 4096 bytes) that will be later used ### in LOAD DATA INFILE to check for absence of binlog errors @@ -69,9 +71,11 @@ SET @old_debug= @@global.debug_dbug; -- let $load_file2= $MYSQLTEST_VARDIR/tmp/bug_46166-2.data -- let $MYSQLD_DATADIR= `select @@datadir` -- replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --disable_ps2_protocol -- eval SELECT repeat('x',10) INTO OUTFILE '$load_file2' --enable_ps2_protocol +--enable_cursor_protocol RESET MASTER; diff --git a/mysql-test/suite/rpl/t/rpl_checksum_cache.test b/mysql-test/suite/rpl/t/rpl_checksum_cache.test index e04f618b81e..63c40ac05da 100644 --- a/mysql-test/suite/rpl/t/rpl_checksum_cache.test +++ b/mysql-test/suite/rpl/t/rpl_checksum_cache.test @@ -119,7 +119,9 @@ let $1=100; begin; while ($1) { + --disable_cursor_protocol eval select round($t2_aver_size + RAND() * $t2_max_rand) into @act_size; + --enable_cursor_protocol set @data = repeat('a', @act_size); insert into t2 set data = @data; dec $1; @@ -162,7 +164,9 @@ let $1= 300; begin; while ($1) { + --disable_cursor_protocol eval select round($t3_aver_size + RAND() * $t3_max_rand) into @act_size; + --enable_cursor_protocol insert into t3 set data= repeat('a', @act_size); dec $1; } diff --git a/mysql-test/suite/rpl/t/rpl_do_grant.test b/mysql-test/suite/rpl/t/rpl_do_grant.test index 1350585ff93..2b757f57692 100644 --- a/mysql-test/suite/rpl/t/rpl_do_grant.test +++ b/mysql-test/suite/rpl/t/rpl_do_grant.test @@ -343,7 +343,9 @@ SELECT Grantor FROM mysql.tables_priv WHERE User='user_bug27606'; --connection master DROP USER user_bug27606@localhost; +--disable_cursor_protocol select priv into @root_priv from mysql.global_priv where user='root' and host='127.0.0.1'; +--enable_cursor_protocol update mysql.global_priv set priv=@root_priv where user='root' and host='localhost'; diff --git a/mysql-test/suite/rpl/t/rpl_drop_db.test b/mysql-test/suite/rpl/t/rpl_drop_db.test index 68d2ec46e4e..31da31f1c91 100644 --- a/mysql-test/suite/rpl/t/rpl_drop_db.test +++ b/mysql-test/suite/rpl/t/rpl_drop_db.test @@ -10,9 +10,11 @@ drop database if exists mysqltest1; create database mysqltest1; create table mysqltest1.t1 (n int); insert into mysqltest1.t1 values (1); +--disable_cursor_protocol --disable_ps2_protocol select * from mysqltest1.t1 into outfile 'mysqltest1/f1.txt'; --enable_ps2_protocol +--enable_cursor_protocol create table mysqltest1.t2 (n int); create table mysqltest1.t3 (n int); --replace_result \\ / 66 39 93 39 17 39 247 39 41 39 "File exists" "Directory not empty" diff --git a/mysql-test/suite/rpl/t/rpl_filter_tables_not_exist.test b/mysql-test/suite/rpl/t/rpl_filter_tables_not_exist.test index ee6daac71ea..1b93ddc3f0a 100644 --- a/mysql-test/suite/rpl/t/rpl_filter_tables_not_exist.test +++ b/mysql-test/suite/rpl/t/rpl_filter_tables_not_exist.test @@ -229,15 +229,19 @@ SET INSERT_ID=2; SET @c=2; SET @@rand_seed1=10000000, @@rand_seed2=1000000; INSERT INTO t5 VALUES (NULL, RAND(), @c); # to be ignored +--disable_cursor_protocol SELECT b into @b FROM test.t5; +--enable_cursor_protocol --let $b_master=`select @b` UPDATE test.t1 SET a=2; # to run trigger on slave --sync_slave_with_master # The proof: +--disable_cursor_protocol SELECT a AS 'ONE' into @a FROM test.t_slave; SELECT c AS 'NULL' into @c FROM test.t_slave; +--enable_cursor_protocol let $count= 1; let $table= test.t_slave; @@ -249,7 +253,9 @@ if (`SELECT @a != 2 and @c != NULL`) --die Intvar or user var from replication events unexpetedly escaped out to screw a following query applying context. } +--disable_cursor_protocol SELECT b into @b FROM test.t_slave; +--enable_cursor_protocol --let $b_slave=`select @b` --let $assert_text= Random values from master and slave must be different diff --git a/mysql-test/suite/rpl/t/rpl_gtid_mdev4484.test b/mysql-test/suite/rpl/t/rpl_gtid_mdev4484.test index 5c17653da8a..cc32220f5d7 100644 --- a/mysql-test/suite/rpl/t/rpl_gtid_mdev4484.test +++ b/mysql-test/suite/rpl/t/rpl_gtid_mdev4484.test @@ -67,8 +67,10 @@ EOF # Since we injected error in the cleanup code, the rows should remain in # mysql.gtid_slave_pos. Check that we have at least 20 (more robust against # non-deterministic cleanup and future changes than checking for exact number). +--disable_cursor_protocol SELECT COUNT(*), MAX(seq_no) INTO @pre_count, @pre_max_seq_no FROM mysql.gtid_slave_pos; +--disable_cursor_protocol SELECT IF(@pre_count >= 20, "OK", CONCAT("Error: too few rows seen while errors injected: ", @pre_count)); SET GLOBAL debug_dbug= @old_dbug; diff --git a/mysql-test/suite/rpl/t/rpl_innodb_bug68220.test b/mysql-test/suite/rpl/t/rpl_innodb_bug68220.test index 1e4f40a0019..c63db427f7f 100644 --- a/mysql-test/suite/rpl/t/rpl_innodb_bug68220.test +++ b/mysql-test/suite/rpl/t/rpl_innodb_bug68220.test @@ -7,6 +7,7 @@ # # created all the base variables at the beginning at the test +--disable_cursor_protocol --connection master select variable_value into @master_rows_read from information_schema.global_status where variable_name = 'innodb_rows_read'; select variable_value into @master_rows_updated from information_schema.global_status where variable_name = 'innodb_rows_updated'; @@ -26,6 +27,7 @@ select variable_value into @slave_system_rows_read from information_schema.globa select variable_value into @slave_system_rows_updated from information_schema.global_status where variable_name = 'innodb_system_rows_updated'; select variable_value into @slave_system_rows_deleted from information_schema.global_status where variable_name = 'innodb_system_rows_deleted'; select variable_value into @slave_system_rows_inserted from information_schema.global_status where variable_name = 'innodb_system_rows_inserted'; +--enable_cursor_protocol --connection master CREATE DATABASE testdb; diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_local.test b/mysql-test/suite/rpl/t/rpl_loaddata_local.test index 01f5607ba0b..975bd110739 100644 --- a/mysql-test/suite/rpl/t/rpl_loaddata_local.test +++ b/mysql-test/suite/rpl/t/rpl_loaddata_local.test @@ -27,9 +27,11 @@ set SQL_LOG_BIN=1; enable_query_log; let $MYSQLD_DATADIR= `select @@datadir`; --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--disable_cursor_protocol --disable_ps2_protocol eval select * into outfile '$MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' from t1; --enable_ps2_protocol +--enable_cursor_protocol #This will generate a 20KB file, now test LOAD DATA LOCAL truncate table t1; --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR @@ -52,9 +54,11 @@ connection master; create table t1(a int); insert into t1 values (1), (2), (2), (3); --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--disable_cursor_protocol --disable_ps2_protocol eval select * into outfile '$MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' from t1; --enable_ps2_protocol +--enable_cursor_protocol drop table t1; create table t1(a int primary key); --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR @@ -83,9 +87,11 @@ SET sql_mode='ignore_space'; CREATE TABLE t1(a int); insert into t1 values (1), (2), (3), (4); --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--disable_cursor_protocol --disable_ps2_protocol eval select * into outfile '$MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' from t1; --enable_ps2_protocol +--enable_cursor_protocol truncate table t1; --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR eval load data local infile '$MYSQLD_DATADIR/rpl_loaddatalocal.select_outfile' into table t1; @@ -109,7 +115,9 @@ sync_slave_with_master; connection master; let $MYSQLD_DATADIR= `select @@datadir`; +--disable_cursor_protocol SELECT @@SESSION.sql_mode INTO @old_mode; +--enable_cursor_protocol SET sql_mode='ignore_space'; @@ -117,9 +125,11 @@ CREATE TABLE t1(a int); INSERT INTO t1 VALUES (1), (2), (3), (4); --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--disable_cursor_protocol --disable_ps2_protocol eval SELECT * INTO OUTFILE '$MYSQLD_DATADIR/bug43746.sql' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol TRUNCATE TABLE t1; --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR @@ -167,9 +177,11 @@ sync_slave_with_master; connection master; --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--disable_cursor_protocol --disable_ps2_protocol eval SELECT * INTO OUTFILE '$MYSQLD_DATADIR/bug59267.sql' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol TRUNCATE TABLE t1; --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR @@ -214,9 +226,11 @@ CREATE VIEW v1 AS SELECT * FROM t2 WHERE f1 IN (SELECT f1 FROM t3 WHERE (t3.f2 IS NULL)); --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR +--disable_cursor_protocol --disable_ps2_protocol eval SELECT 1 INTO OUTFILE '$MYSQLD_DATADIR/bug60580.csv' FROM DUAL; --enable_ps2_protocol +--enable_cursor_protocol --replace_result $MYSQLD_DATADIR MYSQLD_DATADIR eval LOAD DATA LOCAL INFILE '$MYSQLD_DATADIR/bug60580.csv' INTO TABLE t1 (@f1) SET f2 = (SELECT f1 FROM v1 WHERE f1=@f1); diff --git a/mysql-test/suite/rpl/t/rpl_loaddata_map.test b/mysql-test/suite/rpl/t/rpl_loaddata_map.test index 0df424aa1ac..24477fa0230 100644 --- a/mysql-test/suite/rpl/t/rpl_loaddata_map.test +++ b/mysql-test/suite/rpl/t/rpl_loaddata_map.test @@ -37,9 +37,11 @@ while($rows) eval insert into t1 values (null); dec $rows; } +--disable_cursor_protocol --disable_ps2_protocol eval select * into outfile '$MYSQLTEST_VARDIR/tmp/bug30435_5k.txt' from t1; --enable_ps2_protocol +--enable_cursor_protocol DROP TABLE t1; SET @@sql_log_bin= 1; diff --git a/mysql-test/suite/rpl/t/rpl_loadfile.test b/mysql-test/suite/rpl/t/rpl_loadfile.test index a49b3c30b87..edb72dc9925 100644 --- a/mysql-test/suite/rpl/t/rpl_loadfile.test +++ b/mysql-test/suite/rpl/t/rpl_loadfile.test @@ -69,9 +69,11 @@ connection master; let $file= $MYSQLTEST_VARDIR/tmp/bug_39701.data; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--disable_cursor_protocol --disable_ps2_protocol --eval SELECT repeat('x',20) INTO OUTFILE '$file' --enable_ps2_protocol +--enable_cursor_protocol disable_warnings; DROP TABLE IF EXISTS t1; diff --git a/mysql-test/suite/rpl/t/rpl_mdev12179.test b/mysql-test/suite/rpl/t/rpl_mdev12179.test index fc3457252e1..0154cee3e81 100644 --- a/mysql-test/suite/rpl/t/rpl_mdev12179.test +++ b/mysql-test/suite/rpl/t/rpl_mdev12179.test @@ -277,7 +277,9 @@ EOF --connection server_2 --enable_reconnect --source include/wait_until_connected_again.inc +--disable_cursor_protocol SELECT max(seq_no) FROM mysql.gtid_slave_pos_InnoDB into @seq_no; +--enable_cursor_protocol --connection server_1 INSERT INTO t2(a) SELECT 1+MAX(a) FROM t2; diff --git a/mysql-test/suite/rpl/t/rpl_misc_functions.test b/mysql-test/suite/rpl/t/rpl_misc_functions.test index 7211acd508c..714488a3c3c 100644 --- a/mysql-test/suite/rpl/t/rpl_misc_functions.test +++ b/mysql-test/suite/rpl/t/rpl_misc_functions.test @@ -26,9 +26,11 @@ insert into t1 values(3, 0, 0, 0, password('does_this_work?')); --disable_warnings insert into t1 values(4, connection_id(), rand()*1000, rand()*1000, password('does_this_still_work?')); --enable_warnings +--disable_cursor_protocol --disable_ps2_protocol select * into outfile 'rpl_misc_functions.outfile' from t1; --enable_ps2_protocol +--enable_cursor_protocol let $MYSQLD_DATADIR= `select @@datadir`; sync_slave_with_master; create temporary table t2 like t1; @@ -92,9 +94,11 @@ INSERT INTO t1 (col_a) VALUES (test_replication_sf()); --sync_slave_with_master # Dump table on slave +--disable_cursor_protocol --disable_ps2_protocol select * from t1 into outfile "../../tmp/t1_slave.txt"; --enable_ps2_protocol +--enable_cursor_protocol # Load data from slave into temp table on master connection master; @@ -106,8 +110,10 @@ load data infile '../../tmp/t1_slave.txt' into table t1_slave; # Compare master and slave temp table, use subtraction # for floating point comparison of "double" +--disable_cursor_protocol select count(*) into @aux from t1 join t1_slave using (id) where ABS(t1.col_a - t1_slave.col_a) < 0.0000001 ; +--enable_cursor_protocol SELECT @aux; if (`SELECT @aux <> 12 OR @aux IS NULL`) { diff --git a/mysql-test/suite/rpl/t/rpl_parallel_seq.test b/mysql-test/suite/rpl/t/rpl_parallel_seq.test index cc361a7b35b..9522a976b89 100644 --- a/mysql-test/suite/rpl/t/rpl_parallel_seq.test +++ b/mysql-test/suite/rpl/t/rpl_parallel_seq.test @@ -147,7 +147,9 @@ if (`select $iter = 1`) --connection master CREATE OR REPLACE SEQUENCE s3 ENGINE=innodb; # select may return non-deterministically, don't print its result +--disable_cursor_protocol SELECT NEXT VALUE FOR s3 into @tmpvar; +--enable_cursor_protocol --source include/save_master_gtid.inc --connection slave diff --git a/mysql-test/suite/rpl/t/rpl_stm_found_rows.test b/mysql-test/suite/rpl/t/rpl_stm_found_rows.test index c1b7e02319b..5ca2f4edb8f 100644 --- a/mysql-test/suite/rpl/t/rpl_stm_found_rows.test +++ b/mysql-test/suite/rpl/t/rpl_stm_found_rows.test @@ -35,18 +35,22 @@ SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a > 5 ORDER BY a LIMIT 1; # Instead of # INSERT INTO logtbl VALUES(1, 1, FOUND_ROWS()); # we write +--disable_cursor_protocol --disable_ps2_protocol SELECT FOUND_ROWS() INTO @a; --enable_ps2_protocol +--enable_cursor_protocol INSERT INTO logtbl VALUES(1,1,@a); SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a < 5 ORDER BY a LIMIT 1; # Instead of # INSERT INTO logtbl VALUES(1, 2, FOUND_ROWS()); # we write +--disable_cursor_protocol --disable_ps2_protocol SELECT FOUND_ROWS() INTO @a; --enable_ps2_protocol +--enable_cursor_protocol INSERT INTO logtbl VALUES(1,2,@a); SELECT * FROM logtbl WHERE sect = 1 ORDER BY sect,test; @@ -82,9 +86,11 @@ END $$ --delimiter ; SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a > 5 ORDER BY a LIMIT 1; +--disable_cursor_protocol --disable_ps2_protocol SELECT FOUND_ROWS() INTO @found_rows; --enable_ps2_protocol +--enable_cursor_protocol CALL just_log(2,3,@found_rows); SELECT * FROM logtbl WHERE sect = 2 ORDER BY sect,test; @@ -105,7 +111,9 @@ END $$ SELECT SQL_CALC_FOUND_ROWS * FROM t1 WHERE a > 5 ORDER BY a LIMIT 1; --disable_ps2_protocol +--disable_cursor_protocol SELECT FOUND_ROWS() INTO @found_rows; +--enable_cursor_protocol SELECT log_rows(3,1,@found_rows), log_rows(3,2,@found_rows); --enable_ps2_protocol diff --git a/mysql-test/suite/rpl/t/rpl_temporary.test b/mysql-test/suite/rpl/t/rpl_temporary.test index 729f275bb0d..a2b21982a36 100644 --- a/mysql-test/suite/rpl/t/rpl_temporary.test +++ b/mysql-test/suite/rpl/t/rpl_temporary.test @@ -342,7 +342,9 @@ GRANT PROCESS ON *.* TO user43748@127.0.0.1; connect (cont43748,127.0.0.1,user43748,meow,test,$SLAVE_MYPORT,); connection cont43748; +--disable_cursor_protocol SELECT id INTO @id FROM information_schema.processlist WHERE user='system user' LIMIT 1; +--enable_cursor_protocol --error ER_KILL_DENIED_ERROR,ER_NO_SUCH_THREAD KILL @id; diff --git a/mysql-test/suite/rpl/t/rpl_xa.inc b/mysql-test/suite/rpl/t/rpl_xa.inc index d22d2d2ef3d..5925de24f44 100644 --- a/mysql-test/suite/rpl/t/rpl_xa.inc +++ b/mysql-test/suite/rpl/t/rpl_xa.inc @@ -94,7 +94,9 @@ while ($p_trx) --connection master --let $xid=ro_$p_trx --let $query=`SELECT @query$p_trx` + --disable_cursor_protocol --source rpl_create_xa_prepared.inc + --enable_cursor_protocol --let $complete=`select if(floor(rand()*10)%2,'COMMIT','ROLLBACK')` --error 0 --disable_query_log @@ -117,8 +119,9 @@ while ($p_trx) --connection master --let $xid=ro_$p_trx --let $query=`SELECT @query$p_trx` + --disable_cursor_protocol --source rpl_create_xa_prepared.inc - + --enable_cursor_protocol --disconnect master_$xid --source include/wait_until_disconnected.inc diff --git a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_dump_now_basic.test b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_dump_now_basic.test index 8c5f8fa7bf0..c33eb057cc6 100644 --- a/mysql-test/suite/sys_vars/t/innodb_buffer_pool_dump_now_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_buffer_pool_dump_now_basic.test @@ -11,8 +11,10 @@ SELECT @@global.innodb_buffer_pool_dump_now; -- error 0,1 -- remove_file $file +--disable_cursor_protocol SELECT variable_value INTO @old_dump_status FROM information_schema.global_status WHERE LOWER(variable_name) = 'innodb_buffer_pool_dump_status'; +--enable_cursor_protocol # A previous test could have run buffer pool dump already; # in this case we want to make sure that the current time is different diff --git a/mysql-test/suite/sys_vars/t/innodb_fil_make_page_dirty_debug_basic.test b/mysql-test/suite/sys_vars/t/innodb_fil_make_page_dirty_debug_basic.test index 23d9fcdddb2..e5b37d1bc63 100644 --- a/mysql-test/suite/sys_vars/t/innodb_fil_make_page_dirty_debug_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_fil_make_page_dirty_debug_basic.test @@ -23,8 +23,10 @@ set innodb_fil_make_page_dirty_debug = ON; --echo # An example usage. create table t1 (f1 int primary key) engine = innodb; +--disable_cursor_protocol select space from information_schema.innodb_sys_tables where name = 'test/t1' into @space_id; +--enable_cursor_protocol set global innodb_saved_page_number_debug = 0; set global innodb_fil_make_page_dirty_debug = @space_id; drop table t1; diff --git a/mysql-test/suite/sys_vars/t/innodb_log_optimize_ddl_basic.test b/mysql-test/suite/sys_vars/t/innodb_log_optimize_ddl_basic.test index b8983093414..36490e55bcb 100644 --- a/mysql-test/suite/sys_vars/t/innodb_log_optimize_ddl_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_log_optimize_ddl_basic.test @@ -21,7 +21,9 @@ SELECT COUNT(@@GLOBAL.innodb_log_optimize_ddl); SELECT COUNT(@@SESSION.innodb_log_optimize_ddl); --echo Expected error 'Variable is a GLOBAL variable' +--disable_cursor_protocol SELECT @@GLOBAL.innodb_log_optimize_ddl INTO @innodb_log_optimize_ddl_save; +--enable_cursor_protocol #### Check if the value can be set SET @@GLOBAL.innodb_log_optimize_ddl = ON; SET @@GLOBAL.innodb_log_optimize_ddl = OFF; diff --git a/mysql-test/suite/sys_vars/t/innodb_saved_page_number_debug_basic.test b/mysql-test/suite/sys_vars/t/innodb_saved_page_number_debug_basic.test index aa36010d810..ca8be38ddad 100644 --- a/mysql-test/suite/sys_vars/t/innodb_saved_page_number_debug_basic.test +++ b/mysql-test/suite/sys_vars/t/innodb_saved_page_number_debug_basic.test @@ -23,8 +23,10 @@ set innodb_saved_page_number_debug = ON; --echo # An example usage. create table t1 (f1 int primary key) engine = innodb; +--disable_cursor_protocol select space from information_schema.innodb_sys_tables where name = 'test/t1' into @space_id; +--enable_cursor_protocol set global innodb_saved_page_number_debug = 0; set global innodb_fil_make_page_dirty_debug = @space_id; drop table t1; diff --git a/mysql-test/suite/sys_vars/t/log_slow_disabled_statements_func.test b/mysql-test/suite/sys_vars/t/log_slow_disabled_statements_func.test index db9bc8fb48f..1be82f5380e 100644 --- a/mysql-test/suite/sys_vars/t/log_slow_disabled_statements_func.test +++ b/mysql-test/suite/sys_vars/t/log_slow_disabled_statements_func.test @@ -43,7 +43,9 @@ SELECT @@log_slow_disabled_statements; TRUNCATE TABLE mysql.slow_log; ALTER TABLE t1 add column extra int; CALL slow2(); +--disable_cursor_protocol SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b and part2'; +--enable_cursor_protocol --echo --> SELECT sql_text FROM mysql.slow_log where sql_text <> "Close stmt" and sql_text <> "Prepare"; @@ -53,7 +55,9 @@ SET SESSION log_slow_disabled_statements="call,admin"; TRUNCATE TABLE mysql.slow_log; ALTER TABLE t1 add column extra2 int; CALL slow2(); +--disable_cursor_protocol SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b and part3'; +--enable_cursor_protocol --echo --> SELECT sql_text FROM mysql.slow_log where sql_text <> "Close stmt" and sql_text <> "Prepare"; @@ -63,7 +67,9 @@ SET SESSION log_slow_disabled_statements=""; TRUNCATE TABLE mysql.slow_log; ALTER TABLE t1 add column extra3 int; CALL slow2(); +--disable_cursor_protocol SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b and part4'; +--enable_cursor_protocol --echo --> SELECT sql_text FROM mysql.slow_log where sql_text <> "Close stmt" and sql_text <> "Prepare"; @@ -73,7 +79,9 @@ SET SESSION log_slow_disabled_statements="call,admin,slave,sp"; TRUNCATE TABLE mysql.slow_log; ALTER TABLE t1 add column extra4 int; CALL slow2(); +--disable_cursor_protocol SELECT count(if(sleep(1) >= 0,0,NULL)) from t1 where j>'b and part5'; +--enable_cursor_protocol --echo --> SELECT sql_text FROM mysql.slow_log where sql_text <> "Close stmt" and sql_text <> "Prepare"; diff --git a/mysql-test/suite/sys_vars/t/query_cache_limit_func.test b/mysql-test/suite/sys_vars/t/query_cache_limit_func.test index e0105c89866..27b19934162 100644 --- a/mysql-test/suite/sys_vars/t/query_cache_limit_func.test +++ b/mysql-test/suite/sys_vars/t/query_cache_limit_func.test @@ -76,6 +76,8 @@ SET GLOBAL query_cache_size = 0; SET GLOBAL query_cache_size = 131072; SET GLOBAL query_cache_type = ON; +--disable_cursor_protocol + --echo '#---------------------FN_DYNVARS_132_01----------------------#' # #Check if results are cacheing on default value # @@ -168,6 +170,8 @@ SHOW STATUS LIKE 'Qcache_not_cached'; SHOW STATUS LIKE 'Qcache_queries_in_cache'; --echo 1 Expected +--enable_cursor_protocol + # # Cleanup # diff --git a/mysql-test/suite/sys_vars/t/query_cache_type_func.test b/mysql-test/suite/sys_vars/t/query_cache_type_func.test index e1b5f4d1a12..e31c949fef0 100644 --- a/mysql-test/suite/sys_vars/t/query_cache_type_func.test +++ b/mysql-test/suite/sys_vars/t/query_cache_type_func.test @@ -62,6 +62,8 @@ SET @@GLOBAL.query_cache_size = 65536; --echo ** TESTING SESSION SCOPE ** +--disable_cursor_protocol + --echo '#--------------------FN_DYNVARS_135_01-------------------------#' # # Testing default value it should be ON by default @@ -284,6 +286,8 @@ connection con3; SELECT @@query_cache_type; --echo ON Expected +--enable_cursor_protocol + --echo --echo ** Cleanup ** --echo diff --git a/mysql-test/suite/sys_vars/t/secure_file_priv.test b/mysql-test/suite/sys_vars/t/secure_file_priv.test index 74c07d160f1..e7f7043a0eb 100644 --- a/mysql-test/suite/sys_vars/t/secure_file_priv.test +++ b/mysql-test/suite/sys_vars/t/secure_file_priv.test @@ -17,6 +17,7 @@ SHOW VARIABLES LIKE 'secure_file_priv'; # If we run tests with --mem, it will be /dev/shm. # If we run tests with --parallel, it will be mysql-test/var # (because MYSQLTEST_VARDIR in this case is mysql-test/var/N). +--disable_cursor_protocol --perl use File::Basename; @@ -39,6 +40,8 @@ EOF --remove_file $MYSQL_TMP_DIR/bug50373.inc --enable_query_log +--enable_cursor_protocol + DROP TABLE t1; --perl diff --git a/mysql-test/suite/sys_vars/t/sql_buffer_result_func.test b/mysql-test/suite/sys_vars/t/sql_buffer_result_func.test index 77f947c9913..d398f711ad5 100644 --- a/mysql-test/suite/sys_vars/t/sql_buffer_result_func.test +++ b/mysql-test/suite/sys_vars/t/sql_buffer_result_func.test @@ -51,18 +51,22 @@ SHOW STATUS LIKE 'Created_tmp_tables'; --enable_ps_protocol --echo Expected value : 0. +--disable_cursor_protocol --disable_ps2_protocol SELECT * FROM t1; --enable_ps2_protocol +--enable_cursor_protocol --disable_ps_protocol SHOW STATUS LIKE 'Created_tmp_tables'; --enable_ps_protocol --echo Expected value : 1. +--disable_cursor_protocol --disable_ps2_protocol SELECT * FROM t1; --enable_ps2_protocol +--enable_cursor_protocol --disable_ps_protocol SHOW STATUS LIKE 'Created_tmp_tables'; @@ -81,7 +85,9 @@ SHOW STATUS LIKE 'Created_tmp_tables'; --enable_ps_protocol --echo Expected value : 2. +--disable_cursor_protocol SELECT * FROM t1; +--enable_cursor_protocol --disable_ps_protocol SHOW STATUS LIKE 'Created_tmp_tables'; diff --git a/mysql-test/suite/vcol/t/load_data.test b/mysql-test/suite/vcol/t/load_data.test index 1b662818cd2..be247d106b9 100644 --- a/mysql-test/suite/vcol/t/load_data.test +++ b/mysql-test/suite/vcol/t/load_data.test @@ -5,9 +5,11 @@ create table t1 ( c1 varchar(10), c2 varchar(10), c3 int ); insert into t1 values ("a" , "b", 1), ("a" , "b", 2); create table t2 like t1 ; alter table t2 add column c4 bigint unsigned as (CONV(LEFT(MD5(concat(c1,c2,c3)), 16), 16, 10)) persistent unique key; +--disable_cursor_protocol --disable_ps2_protocol select * into outfile 't1.csv' from t1; --enable_ps2_protocol +--enable_cursor_protocol load data infile 't1.csv' ignore into table t2 ; select * from t2; insert into t2 (c1,c2,c3) values ("a" , "b", 4); diff --git a/mysql-test/suite/vcol/t/vcol_keys_myisam.test b/mysql-test/suite/vcol/t/vcol_keys_myisam.test index bc8fcbd29c0..e9207d3bcdd 100644 --- a/mysql-test/suite/vcol/t/vcol_keys_myisam.test +++ b/mysql-test/suite/vcol/t/vcol_keys_myisam.test @@ -281,9 +281,11 @@ drop table t1; CREATE TABLE t1 (i INT, d1 DATE, d2 DATE NOT NULL, t TIMESTAMP, KEY(t)) ENGINE=MyISAM; INSERT INTO t1 VALUES (1,'2023-03-16','2023-03-15','2012-12-12 12:12:12'); ALTER TABLE t1 MODIFY t FLOAT AS (i) PERSISTENT; +--disable_cursor_protocol --disable_ps2_protocol SELECT i, d1, d2 INTO OUTFILE 'load_t1' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol DELETE FROM t1; LOAD DATA INFILE 'load_t1' INTO TABLE t1 (i,d1,d2); SELECT * FROM t1 WHERE d2 < d1; diff --git a/mysql-test/suite/versioning/common.inc b/mysql-test/suite/versioning/common.inc index f18f2d298f6..b09fc36319f 100644 --- a/mysql-test/suite/versioning/common.inc +++ b/mysql-test/suite/versioning/common.inc @@ -6,7 +6,9 @@ source include/have_innodb.inc; --disable_query_log set @@session.time_zone='+00:00'; +--disable_cursor_protocol select ifnull(max(transaction_id), 0) into @start_trx_id from mysql.transaction_registry; +--enable_cursor_protocol set @test_start=now(6); delimiter ~~; diff --git a/mysql-test/suite/versioning/t/alter.test b/mysql-test/suite/versioning/t/alter.test index 736cccb9cfb..4b484eb47a2 100644 --- a/mysql-test/suite/versioning/t/alter.test +++ b/mysql-test/suite/versioning/t/alter.test @@ -139,7 +139,9 @@ select * from t; update t set a=3 where a=1; select * from t; select * from t for system_time all; +--disable_cursor_protocol select row_start from t where a=3 into @tm; +--enable_cursor_protocol alter table t add column b int; select @tm=row_start from t where a=3; show create table t; diff --git a/mysql-test/suite/versioning/t/commit_id.test b/mysql-test/suite/versioning/t/commit_id.test index 0f9cf1eb391..646672bae76 100644 --- a/mysql-test/suite/versioning/t/commit_id.test +++ b/mysql-test/suite/versioning/t/commit_id.test @@ -17,19 +17,25 @@ insert into t1 values (); --real_sleep 0.01 set @ts0= now(6); insert into t1 values (); +--disable_cursor_protocol select sys_trx_start from t1 where id = last_insert_id() into @tx0; +--enable_cursor_protocol select transaction_id = @tx0 from mysql.transaction_registry order by transaction_id desc limit 1; set @ts1= now(6); insert into t1 values (); +--disable_cursor_protocol select sys_trx_start from t1 where id = last_insert_id() into @tx1; +--enable_cursor_protocol select transaction_id = @tx1 from mysql.transaction_registry order by transaction_id desc limit 1; set @ts2= now(6); insert into t1 values (); +--disable_cursor_protocol select sys_trx_start from t1 where id = last_insert_id() into @tx2; +--enable_cursor_protocol select transaction_id = @tx2 from mysql.transaction_registry order by transaction_id desc limit 1; @@ -69,22 +75,30 @@ select trt_trx_sees(0, @tx2); set transaction isolation level read uncommitted; insert into t1 values (); +--disable_cursor_protocol select sys_trx_start from t1 where id = last_insert_id() into @tx3; +--enable_cursor_protocol select isolation_level = 'READ-UNCOMMITTED' from mysql.transaction_registry where transaction_id = @tx3; set transaction isolation level read committed; insert into t1 values (); +--disable_cursor_protocol select sys_trx_start from t1 where id = last_insert_id() into @tx4; +--enable_cursor_protocol select isolation_level = 'READ-COMMITTED' from mysql.transaction_registry where transaction_id = @tx4; set transaction isolation level serializable; insert into t1 values (); +--disable_cursor_protocol select sys_trx_start from t1 where id = last_insert_id() into @tx5; +--enable_cursor_protocol select isolation_level = 'SERIALIZABLE' from mysql.transaction_registry where transaction_id = @tx5; set transaction isolation level repeatable read; insert into t1 values (); +--disable_cursor_protocol select sys_trx_start from t1 where id = last_insert_id() into @tx6; +--enable_cursor_protocol select isolation_level = 'REPEATABLE-READ' from mysql.transaction_registry where transaction_id = @tx6; diff --git a/mysql-test/suite/versioning/t/create.test b/mysql-test/suite/versioning/t/create.test index f50d75ded9e..1506ffaa378 100644 --- a/mysql-test/suite/versioning/t/create.test +++ b/mysql-test/suite/versioning/t/create.test @@ -212,9 +212,11 @@ show create table t3; --echo ## For versioned table insert into t1 values (1); +--disable_cursor_protocol select row_start from t1 into @row_start; insert into t0 (y) values (2); select st from t0 into @st; +--enable_cursor_protocol create or replace table t2 with system versioning as select * from t1; --replace_result $default_engine DEFAULT_ENGINE @@ -253,10 +255,12 @@ create or replace table t3 with system versioning select x23, row_start from t1; create or replace table t3 with system versioning select x23, row_end from t1; --echo # Prepare checking for historical row +--disable_cursor_protocol delete from t1; select row_end from t1 for system_time all into @row_end; delete from t0; select en from t0 for system_time all into @en; +--enable_cursor_protocol --echo ## Combinations of versioned + non-versioned create or replace table t2 (y int); @@ -272,9 +276,13 @@ insert into t2 (y) values (1), (2); delete from t2 where y = 2; create or replace table t3 select * from t2 for system_time all; +--disable_cursor_protocol select st, en from t3 where y = 1 into @st, @en; +--enable_cursor_protocol select y from t2 for system_time all where st = @st and en = @en; +--disable_cursor_protocol select st, en from t3 where y = 2 into @st, @en; +--enable_cursor_protocol select y from t2 for system_time all where st = @st and en = @en; --echo ## Default engine detection diff --git a/mysql-test/suite/versioning/t/cte.test b/mysql-test/suite/versioning/t/cte.test index 5a8fb1f8211..7d4e10ead9d 100644 --- a/mysql-test/suite/versioning/t/cte.test +++ b/mysql-test/suite/versioning/t/cte.test @@ -31,7 +31,9 @@ insert into emp (emp_id, name, salary, dept_id, mgr) values (20, "john", 500, 10, 1), (30, "jane", 750, 10,1 ); +--disable_cursor_protocol select row_start into @ts_1 from emp where name="jane"; +--enable_cursor_protocol update emp set mgr=30 where name ="john"; @@ -42,7 +44,9 @@ with ancestors as ( select e.emp_id, e.name, e.mgr, e.salary from emp as e ) select * from ancestors for system_time as of @ts_1; +--disable_cursor_protocol select row_start into @ts_2 from emp where name="john"; +--enable_cursor_protocol let $q= /* All report to 'Bill' */ diff --git a/mysql-test/suite/versioning/t/delete.test b/mysql-test/suite/versioning/t/delete.test index 9debdcfec8c..ded6f46762b 100644 --- a/mysql-test/suite/versioning/t/delete.test +++ b/mysql-test/suite/versioning/t/delete.test @@ -42,7 +42,9 @@ eval create or replace table t1( with system versioning; insert into t1(x) values (1); +--disable_cursor_protocol select sys_start into @sys_start from t1; +--disable_cursor_protocol delete from t1; select * from t1; select x = 1 as A, sys_start = @sys_start as B, sys_end > sys_start as C from t1 for system_time all; diff --git a/mysql-test/suite/versioning/t/foreign.test b/mysql-test/suite/versioning/t/foreign.test index 9489d90c55a..599a6a81298 100644 --- a/mysql-test/suite/versioning/t/foreign.test +++ b/mysql-test/suite/versioning/t/foreign.test @@ -314,7 +314,9 @@ create or replace table subchild ( ) engine=innodb; insert into parent (value) values (23); +--disable_cursor_protocol select id, value from parent into @id, @value; +--enable_cursor_protocol insert into child values (default, @id, @value); insert into subchild values (default, @id, @value); @@ -396,21 +398,27 @@ INSERT INTO t2 VALUES (1,'against'),(2,'q'); SET SQL_MODE= ''; SET timestamp = 2; +--disable_cursor_protocol --disable_ps2_protocol SELECT * INTO OUTFILE 't1.data' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol SET timestamp = 3; UPDATE t1 SET f13 = 'q'; SET timestamp = 4; LOAD DATA INFILE 't1.data' REPLACE INTO TABLE t1; +--disable_cursor_protocol --disable_ps2_protocol SELECT * INTO OUTFILE 't1.data.2' FROM t1; --enable_ps2_protocol +--enable_cursor_protocol SET timestamp = 5; LOAD DATA INFILE 't1.data.2' REPLACE INTO TABLE t1; +--disable_cursor_protocol --disable_ps2_protocol SELECT * INTO OUTFILE 't2.data' FROM t2; --enable_ps2_protocol +--enable_cursor_protocol SET timestamp = 6; LOAD DATA INFILE 't2.data' REPLACE INTO TABLE t2; SET FOREIGN_KEY_CHECKS = OFF; @@ -553,9 +561,11 @@ delete from t0; --error ER_ROW_IS_REFERENCED_2 replace t0 values (1); +--disable_cursor_protocol --disable_ps2_protocol select * into outfile 'load_t0' from t0 ; --enable_ps2_protocol +--enable_cursor_protocol --error ER_ROW_IS_REFERENCED_2 load data infile 'load_t0' replace into table t0; diff --git a/mysql-test/suite/versioning/t/insert.test b/mysql-test/suite/versioning/t/insert.test index 0324df64d0c..5e3d85423a7 100644 --- a/mysql-test/suite/versioning/t/insert.test +++ b/mysql-test/suite/versioning/t/insert.test @@ -52,7 +52,9 @@ drop view vt1_1; replace_result $sys_datatype_expl SYS_DATATYPE; eval create or replace table t1( id bigint primary key, a int, b int) with system versioning; insert into t1 values(1, 1, 1); +--disable_cursor_protocol select row_start, row_end from t1 into @sys_start, @sys_end; +--enable_cursor_protocol select id, a, b from t1; insert into t1 values(2, 2, 2); select id, a, b, row_start > @sys_start as C, row_end = @sys_end as D from t1 where id = 2; diff --git a/mysql-test/suite/versioning/t/insert2.test b/mysql-test/suite/versioning/t/insert2.test index 1e7d2166064..527a66e5f21 100644 --- a/mysql-test/suite/versioning/t/insert2.test +++ b/mysql-test/suite/versioning/t/insert2.test @@ -48,7 +48,9 @@ insert into t1 (row_start) select row_end from t1; set sql_mode=''; insert into t1 (row_start, row_end) values (DEFAULT, 1); set sql_mode=default; +--disable_cursor_protocol select @@sql_mode into @saved_mode; +--enable_cursor_protocol set sql_mode= ''; insert into t1 (x, row_start, row_end) values (3, 4, 5); set sql_mode= @saved_mode; diff --git a/mysql-test/suite/versioning/t/load_data.test b/mysql-test/suite/versioning/t/load_data.test index 6668a4ff9f7..aa4e2192113 100644 --- a/mysql-test/suite/versioning/t/load_data.test +++ b/mysql-test/suite/versioning/t/load_data.test @@ -4,9 +4,11 @@ CREATE TABLE t1 (a INT, b INT, c INT, vc INT AS (c), UNIQUE(a), UNIQUE(b)) WITH SYSTEM VERSIONING; INSERT IGNORE INTO t1 (a,b,c) VALUES (1,2,3); +--disable_cursor_protocol --disable_ps2_protocol SELECT a, b, c FROM t1 INTO OUTFILE '15330.data'; --enable_ps2_protocol +--enable_cursor_protocol LOAD DATA INFILE '15330.data' IGNORE INTO TABLE t1 (a,b,c); LOAD DATA INFILE '15330.data' REPLACE INTO TABLE t1 (a,b,c); diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test index a4f487aae29..840af2d6cec 100644 --- a/mysql-test/suite/versioning/t/partition.test +++ b/mysql-test/suite/versioning/t/partition.test @@ -995,6 +995,7 @@ create or replace table t1 ( insert into t1 () values (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); +--disable_cursor_protocol --disable_ps2_protocol select * into outfile 'load.data' from t1; --enable_ps2_protocol @@ -1003,6 +1004,7 @@ load data infile 'load.data' replace into table t1; load data infile 'load.data' replace into table t1; --error ER_RECORD_FILE_FULL load data infile 'load.data' replace into table t1; +--enable_cursor_protocol # Cleanup --let $datadir= `select @@datadir` @@ -1339,9 +1341,11 @@ partition by system_time limit 100 ( partition pn current); insert into t1 select seq from seq_0_to_49; +--disable_cursor_protocol --disable_ps2_protocol select x into outfile 'MDEV-20077.data' from t1; --enable_ps2_protocol +--enable_cursor_protocol load data infile 'MDEV-20077.data' replace into table t1 (x); load data infile 'MDEV-20077.data' replace into table t1 (x); diff --git a/mysql-test/suite/versioning/t/select.test b/mysql-test/suite/versioning/t/select.test index f28a3dddd89..27ff2ca35f6 100644 --- a/mysql-test/suite/versioning/t/select.test +++ b/mysql-test/suite/versioning/t/select.test @@ -29,7 +29,9 @@ set @t0= now(6); if ($MTR_COMBINATION_TRX_ID) { --disable_query_log +--disable_cursor_protocol select sys_trx_start from t1 limit 1 into @x0; +--enable_cursor_protocol --enable_query_log } @@ -37,12 +39,16 @@ delete from t1 where x = 3; delete from t1 where x > 7; insert into t1(x, y) values(3, 33); +--disable_cursor_protocol select sys_trx_start from t1 where x = 3 and y = 33 into @t1; +--enable_cursor_protocol if ($MTR_COMBINATION_TRX_ID) { --disable_query_log set @x1= @t1; +--disable_cursor_protocol select trt_commit_ts(@x1) into @t1; +--enable_cursor_protocol --enable_query_log } @@ -118,12 +124,14 @@ delete from t1; insert into t1 values (3); delete from t1; +--disable_cursor_protocol select row_start into @start1 from t1 for system_time all where x = 1; select row_end into @end1 from t1 for system_time all where x = 1; select row_start into @start2 from t1 for system_time all where x = 2; select row_end into @end2 from t1 for system_time all where x = 2; select row_start into @start3 from t1 for system_time all where x = 3; select row_end into @end3 from t1 for system_time all where x = 3; +--enable_cursor_protocol select x as ASOF_x from t1 for system_time as of @start2; select x as ASOF_x from t1 for system_time as of @end2; @@ -254,7 +262,9 @@ create or replace table t1 ( insert into t1 values (1); set @ts= now(6); delete from t1; +--disable_cursor_protocol select sys_trx_start from t1 for system_time all into @trx_start; +--enable_cursor_protocol --echo ## ensure @trx_start is much lower than unix timestamp select @trx_start < unix_timestamp(@ts) - 100 as trx_start_good; @@ -382,8 +392,10 @@ eval create or replace table t1 ( ) with system versioning; insert into t1 values (1); delete from t1; +--disable_cursor_protocol select row_start from t1 for system_time all into @t1; select row_end from t1 for system_time all into @t2; +--enable_cursor_protocol --disable_query_log if($MTR_COMBINATION_TRX_ID) { set @t1= trt_begin_ts(@t1); diff --git a/mysql-test/suite/versioning/t/select2.test b/mysql-test/suite/versioning/t/select2.test index 1ab7bcf27c1..a557f10501b 100644 --- a/mysql-test/suite/versioning/t/select2.test +++ b/mysql-test/suite/versioning/t/select2.test @@ -22,17 +22,21 @@ insert into t1 (x, y) values (8, 108), (9, 109); set @t0= now(6); +--disable_cursor_protocol select sys_start from t1 limit 1 into @x0; +--enable_cursor_protocol delete from t1 where x = 3; delete from t1 where x > 7; insert into t1(x, y) values(3, 33); +--disable_cursor_protocol select sys_start from t1 where x = 3 and y = 33 into @t1; if($MTR_COMBINATION_TRX_ID) { set @x1= @t1; select trt_commit_ts(@x1) into @t1; } +--enable_cursor_protocol select x, y from t1; select x as ASOF_x, y from t1 for system_time as of timestamp @t0; diff --git a/mysql-test/suite/versioning/t/simple.test b/mysql-test/suite/versioning/t/simple.test index b550b3967d9..6f0e52f4f5d 100644 --- a/mysql-test/suite/versioning/t/simple.test +++ b/mysql-test/suite/versioning/t/simple.test @@ -18,6 +18,7 @@ create or replace table emp ( ) with system versioning; +--disable_cursor_protocol select now() into @ts_0; insert into dept (dept_id, name) values (10, "accounting"); @@ -29,13 +30,16 @@ insert into emp (emp_id, name, salary, dept_id) values (1, "bill", 1000, 10); commit; select row_start into @ts_2 from emp where name="bill"; +--enable_cursor_protocol select * from emp; update emp set salary=2000 where name="bill"; commit; +--disable_cursor_protocol select row_start into @ts_3 from emp where name="bill"; +--enable_cursor_protocol select * from emp; select * from emp for system_time as of timestamp @ts_2; diff --git a/mysql-test/suite/versioning/t/trx_id.test b/mysql-test/suite/versioning/t/trx_id.test index a0da7714f50..098d85da999 100644 --- a/mysql-test/suite/versioning/t/trx_id.test +++ b/mysql-test/suite/versioning/t/trx_id.test @@ -38,11 +38,15 @@ alter table t1 add period for system_time(s, e), add system versioning, algorithm=inplace; +--disable_cursor_protocol select s from t1 into @trx_start; +--enable_cursor_protocol select count(*) = 1 from mysql.transaction_registry where transaction_id = @trx_start; create or replace table t1 (x int); +--disable_cursor_protocol select count(*) from mysql.transaction_registry into @tmp; +--enable_cursor_protocol alter table t1 add column s bigint unsigned as row start, add column e bigint unsigned as row end, @@ -59,11 +63,15 @@ alter table t1 add period for system_time(s, e), add system versioning, algorithm=copy; +--disable_cursor_protocol select s from t1 into @trx_start; +--enable_cursor_protocol select count(*) = 1 from mysql.transaction_registry where transaction_id = @trx_start; create or replace table t1 (x int); +--disable_cursor_protocol select count(*) from mysql.transaction_registry into @tmp; +--enable_cursor_protocol alter table t1 add column s bigint unsigned as row start, add column e bigint unsigned as row end, @@ -118,9 +126,11 @@ commit; --sleep 0.01 set @ts3= sysdate(6); +--disable_cursor_protocol select sys_start from t1 where x = 1 into @trx_id1; select sys_start from t1 where x = 2 into @trx_id2; select sys_start from t1 where x = 3 into @trx_id3; +--enable_cursor_protocol select @trx_id1 < @trx_id2, @trx_id2 < @trx_id3; select @ts1 < @ts2, @ts2 < @ts3; @@ -261,7 +271,9 @@ set @ts1= now(6); insert into t1 values (1); commit; +--disable_cursor_protocol select row_start from t1 into @trx_id; +--enable_cursor_protocol select trt_begin_ts(@trx_id) <= @ts1 as BEGIN_TS_GOOD; drop table t1; diff --git a/mysql-test/suite/versioning/t/update.test b/mysql-test/suite/versioning/t/update.test index 046a4ac149d..3c5e7c4315e 100644 --- a/mysql-test/suite/versioning/t/update.test +++ b/mysql-test/suite/versioning/t/update.test @@ -28,11 +28,15 @@ eval create table t1 ( with system versioning; set timestamp= unix_timestamp('2000-01-01 00:00:00'); insert into t1 values(1, 1, 1); +--disable_cursor_protocol select sys_trx_start into @tmp1 from t1; +--enable_cursor_protocol set timestamp= unix_timestamp('2000-01-01 01:00:00'); update t1 set x= 11, y= 11 where id = 1; select @tmp1 < sys_trx_start as A1, x, y from t1; +--disable_cursor_protocol select sys_trx_start into @tmp1 from t1; +--enable_cursor_protocol set timestamp= unix_timestamp('2000-01-01 02:00:00'); update t1 set y= 1 where id = 1; select @tmp1 = sys_trx_start as A2, x from t1; @@ -135,14 +139,18 @@ create table t2 like t1; insert into t1 values (1, "Jeremy", 3000); insert into t2 values (1, "Jeremy", 4000); +--disable_cursor_protocol select sys_trx_start into @tmp1 from t1; select sys_trx_start into @tmp2 from t2; +--enable_cursor_protocol update t1, t2 set t1.name= "Jerry", t2.name= "Jerry" where t1.id = t2.id and t1.name = "Jeremy"; select @tmp1 < sys_trx_start as A1, name from t1; select @tmp2 < sys_trx_start as A2, name from t2; +--disable_cursor_protocol select sys_trx_start into @tmp1 from t1; select sys_trx_start into @tmp2 from t2; +--enable_cursor_protocol update t1, t2 set t1.salary= 2500, t2.salary= 2500 where t1.id = t2.id and t1.name = "Jerry"; select @tmp1 = sys_trx_start as B1, salary from t1; select @tmp2 = sys_trx_start as B2, salary from t2; @@ -335,7 +343,9 @@ drop tables t1, t2, t3; create or replace table t1 (x int) with system versioning; insert t1 values (1); update t1 set x= 1; +--disable_cursor_protocol select row_start into @r from t1; +--enable_cursor_protocol select check_row_ts(row_start, row_end) from t1 for system_time all where row_start = @r; drop table t1; diff --git a/mysql-test/suite/versioning/t/view.test b/mysql-test/suite/versioning/t/view.test index 9bb915f7b77..e4c688fa859 100644 --- a/mysql-test/suite/versioning/t/view.test +++ b/mysql-test/suite/versioning/t/view.test @@ -5,10 +5,14 @@ create or replace table t1 (x int) with system versioning; insert into t1 values (1); +--disable_cursor_protocol select now(6) into @t1; +--enable_cursor_protocol update t1 set x= 2; +--disable_cursor_protocol select now(6) into @t2; +--enable_cursor_protocol delete from t1; set @vt1= concat("create or replace view vt1 as select * from t1 for system_time as of timestamp '", @t1, "'"); diff --git a/plugin/type_inet/mysql-test/type_inet/type_inet6.test b/plugin/type_inet/mysql-test/type_inet/type_inet6.test index 41cfa0b06ae..41fe8bd840e 100644 --- a/plugin/type_inet/mysql-test/type_inet/type_inet6.test +++ b/plugin/type_inet/mysql-test/type_inet/type_inet6.test @@ -19,7 +19,10 @@ CREATE TABLE t1 (a INET6); INSERT INTO t1 VALUES ('::1'); --enable_metadata SELECT * FROM t1; +#check after fix MDEV-31540 +--disable_cursor_protocol SELECT CAST('::' AS INET6) AS a; +--enable_cursor_protocol --disable_metadata DROP TABLE t1; @@ -1431,6 +1434,8 @@ DROP TABLE t1; --echo # CREATE TABLE t1 (a INET6); +#check after fix MDEV-31540 +--disable_cursor_protocol --enable_metadata SELECT CAST(a AS BINARY(0)), @@ -1449,6 +1454,7 @@ SELECT CAST(a AS BINARY(16777216)) FROM t1; --disable_metadata +--enable_cursor_protocol DROP TABLE t1; --echo # diff --git a/storage/connect/mysql-test/connect/t/bson_udf.test b/storage/connect/mysql-test/connect/t/bson_udf.test index 0da2de38864..584f8f25554 100644 --- a/storage/connect/mysql-test/connect/t/bson_udf.test +++ b/storage/connect/mysql-test/connect/t/bson_udf.test @@ -19,7 +19,10 @@ SELECT BsonValue(9223372036854775807); SELECT BsonValue(NULL); SELECT BsonValue(TRUE); SELECT BsonValue(FALSE); +#Check after fix MDEV-31587 +--disable_cursor_protocol SELECT BsonValue(); +--enable_cursor_protocol SELECT BsonValue('[11, 22, 33]' json_) FROM t1; # SELECT Bson_Make_Array(); diff --git a/storage/connect/mysql-test/connect/t/json_udf.test b/storage/connect/mysql-test/connect/t/json_udf.test index 96fe836e60b..82afd030f75 100644 --- a/storage/connect/mysql-test/connect/t/json_udf.test +++ b/storage/connect/mysql-test/connect/t/json_udf.test @@ -19,7 +19,10 @@ SELECT JsonValue(9223372036854775807); SELECT JsonValue(NULL); SELECT JsonValue(TRUE); SELECT JsonValue(FALSE); +#Check after fix MDEV-31587 +--disable_cursor_protocol SELECT JsonValue(); +--enable_cursor_protocol SELECT JsonValue('[11, 22, 33]' json_) FROM t1; # SELECT Json_Make_Array(); @@ -60,7 +63,10 @@ SELECT Json_Make_Object(56, 3.1416, 'foo', NULL); SELECT Json_Make_Object(56 qty, 3.1416 price, 'foo' truc, NULL garanty); SELECT Json_Make_Object(); SELECT Json_Make_Object(Json_Make_Array(56, 3.1416, 'foo'), NULL); +# Enable after fix MDEV-31554 +--disable_cursor_protocol SELECT Json_Make_Array(Json_Make_Object(56 "qty", 3.1416 "price", 'foo') ,NULL); +--enable_cursor_protocol SELECT Json_Object_Key('qty', 56, 'price', 3.1416, 'truc', 'machin', 'garanty', NULL); --error ER_CANT_INITIALIZE_UDF SELECT Json_Object_Key('qty', 56, 'price', 3.1416, 'truc', 'machin', 'garanty'); diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_flags_comment.test b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_flags_comment.test index ec9e3c9d4b9..1cd840a9690 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_flags_comment.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_flags_comment.test @@ -30,7 +30,10 @@ CREATE TABLE tags ( ALTER TABLE tags ADD COLUMN name VARCHAR(64) COMMENT 'flags "COLUMN_VECTOR"'; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE tags; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_flags_parameter.test b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_flags_parameter.test index e3b7df72cf9..b1276755a40 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_flags_parameter.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_flags_parameter.test @@ -33,7 +33,10 @@ CREATE TABLE tags ( ALTER TABLE tags ADD COLUMN name VARCHAR(64) FLAGS='COLUMN_VECTOR'; SHOW CREATE TABLE tags; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE tags; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_groonga_type_comment.test b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_groonga_type_comment.test index 964426b44bf..dbad49d67d2 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_groonga_type_comment.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_groonga_type_comment.test @@ -35,7 +35,10 @@ CREATE TABLE bugs ( ALTER TABLE bugs ADD COLUMN name VARCHAR(64) COMMENT 'groonga_type "tags"'; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE bugs; DROP TABLE tags; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_groonga_type_parameter.test b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_groonga_type_parameter.test index 0f92c024b7c..1f83d5d2df7 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_groonga_type_parameter.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_groonga_type_parameter.test @@ -38,7 +38,10 @@ CREATE TABLE bugs ( ALTER TABLE bugs ADD COLUMN name VARCHAR(64) GROONGA_TYPE='tags'; SHOW CREATE TABLE bugs; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE bugs; DROP TABLE tags; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_multibyte_cp932.test b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_multibyte_cp932.test index 0516186ba17..8377e9c5690 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_multibyte_cp932.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_multibyte_cp932.test @@ -45,7 +45,10 @@ SELECT * FROM users; SELECT * FROM users WHERE MATCH (O) AGAINST ('+Ȃ' IN BOOLEAN MODE); +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no --dump_records no"); +--enable_cursor_protocol DROP TABLE users; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_multibyte_utf8.test b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_multibyte_utf8.test index 0ed92333e29..ec185295891 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_multibyte_utf8.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_multibyte_utf8.test @@ -45,7 +45,10 @@ SELECT * FROM users; SELECT * FROM users WHERE MATCH (名前) AGAINST ('+たなか' IN BOOLEAN MODE); +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no --dump_records no"); +--enable_cursor_protocol DROP TABLE users; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_type_comment.test b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_type_comment.test index 54fb986a24f..19879bc57f1 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_type_comment.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_column_type_comment.test @@ -34,7 +34,10 @@ CREATE TABLE bugs ( ALTER TABLE bugs ADD COLUMN name VARCHAR(64) COMMENT 'type "tags"'; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE bugs; DROP TABLE tags; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_index_token_filters_one_token_filter.test b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_index_token_filters_one_token_filter.test index 8a63885a8e7..d68fb7c7362 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_index_token_filters_one_token_filter.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_add_index_token_filters_one_token_filter.test @@ -34,7 +34,10 @@ CREATE TABLE memos ( ALTER TABLE memos ADD FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord"'; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE memos; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_change_token_filter.test b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_change_token_filter.test index 8efaad2a4ce..00a09f952ec 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_change_token_filter.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_change_token_filter.test @@ -37,6 +37,8 @@ CREATE TABLE memos ( FULLTEXT INDEX (content) COMMENT 'table "terms"' ) DEFAULT CHARSET=utf8; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); ALTER TABLE terms COMMENT='default_tokenizer "TokenBigram", token_filters "TokenFilterStopWord"'; @@ -47,6 +49,7 @@ ALTER TABLE memos DISABLE KEYS; ALTER TABLE memos ENABLE KEYS; SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE memos; DROP TABLE terms; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_disable_keys_fulltext_table.test b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_disable_keys_fulltext_table.test index 83ce2ca786e..8237f2d83fb 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_disable_keys_fulltext_table.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_disable_keys_fulltext_table.test @@ -35,9 +35,12 @@ CREATE TABLE memos ( FULLTEXT INDEX content_index (content) COMMENT 'table "terms"' ) DEFAULT CHARSET=utf8; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); ALTER TABLE memos DISABLE KEYS; SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE memos; DROP TABLE terms; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_enable_keys_fulltext_table.test b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_enable_keys_fulltext_table.test index 424e51adaaa..27071e82c1d 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_enable_keys_fulltext_table.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/alter_table_enable_keys_fulltext_table.test @@ -35,10 +35,13 @@ CREATE TABLE memos ( FULLTEXT INDEX content_index (content) COMMENT 'table "terms"' ) DEFAULT CHARSET=utf8; +#Check after fix MDEV-31554 +--disable_cursor_protocol ALTER TABLE memos DISABLE KEYS; SELECT mroonga_command("dump --dump_plugins no"); ALTER TABLE memos ENABLE KEYS; SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE memos; DROP TABLE terms; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/column_groonga_index_fulltext_vector_other_table.test b/storage/mroonga/mysql-test/mroonga/storage/t/column_groonga_index_fulltext_vector_other_table.test index c23f35eef9a..11e524482be 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/column_groonga_index_fulltext_vector_other_table.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/column_groonga_index_fulltext_vector_other_table.test @@ -39,7 +39,10 @@ CREATE TABLE bugs ( INSERT INTO bugs (id, tags) VALUES (1, "Linux MySQL groonga"); +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no --dump_records no"); +--enable_cursor_protocol SELECT *, MATCH (tags) AGAINST ("+MySQL" IN BOOLEAN MODE) AS score FROM bugs diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/column_groonga_index_int_other_table.test b/storage/mroonga/mysql-test/mroonga/storage/t/column_groonga_index_int_other_table.test index 9e128a005bb..710b922d9da 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/column_groonga_index_int_other_table.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/column_groonga_index_int_other_table.test @@ -40,7 +40,10 @@ INSERT INTO bugs (id, priority) VALUES (1, 10); INSERT INTO bugs (id, priority) VALUES (2, 3); INSERT INTO bugs (id, priority) VALUES (3, -2); +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no --dump_records no"); +--enable_cursor_protocol SELECT * FROM bugs diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/column_multibyte_cp932.test b/storage/mroonga/mysql-test/mroonga/storage/t/column_multibyte_cp932.test index be26045ab89..5c94e43e2c8 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/column_multibyte_cp932.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/column_multibyte_cp932.test @@ -43,7 +43,10 @@ SELECT * FROM users; SELECT * FROM users WHERE MATCH (O) AGAINST ('+Ȃ' IN BOOLEAN MODE); +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no --dump_records no"); +--enable_cursor_protocol DROP TABLE users; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/column_multibyte_utf8.test b/storage/mroonga/mysql-test/mroonga/storage/t/column_multibyte_utf8.test index efbaf31fae5..4734d6d71bb 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/column_multibyte_utf8.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/column_multibyte_utf8.test @@ -43,7 +43,10 @@ SELECT * FROM users; SELECT * FROM users WHERE MATCH (名前) AGAINST ('+たなか' IN BOOLEAN MODE); +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no --dump_records no"); +--enable_cursor_protocol DROP TABLE users; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_flags_comment.test b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_flags_comment.test index 6bafebd8b9c..c3e4280390d 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_flags_comment.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_flags_comment.test @@ -29,7 +29,10 @@ CREATE TABLE bugs ( tags TEXT COMMENT 'flags "COLUMN_VECTOR"' ) DEFAULT CHARSET=utf8; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE bugs; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_flags_parameter.test b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_flags_parameter.test index 3baa576a9ea..3dd9bd81a08 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_flags_parameter.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_flags_parameter.test @@ -30,7 +30,10 @@ CREATE TABLE bugs ( tags TEXT FLAGS='COLUMN_VECTOR' ) DEFAULT CHARSET=utf8; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE bugs; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_groonga_type_comment.test b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_groonga_type_comment.test index 28f0f214935..aa2270d4926 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_groonga_type_comment.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_groonga_type_comment.test @@ -33,7 +33,10 @@ CREATE TABLE bugs ( tag VARCHAR(64) COMMENT 'groonga_type "tags"' ) DEFAULT CHARSET=utf8; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE bugs; DROP TABLE tags; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_groonga_type_parameter.test b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_groonga_type_parameter.test index a664287289b..6b1bd629337 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_groonga_type_parameter.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_groonga_type_parameter.test @@ -36,7 +36,10 @@ CREATE TABLE bugs ( ) DEFAULT CHARSET=utf8; SHOW CREATE TABLE bugs; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE bugs; DROP TABLE tags; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_type_comment.test b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_type_comment.test index bd4b268b081..4b308c196eb 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_type_comment.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_column_type_comment.test @@ -33,7 +33,10 @@ CREATE TABLE bugs ( tag VARCHAR(64) COMMENT 'type "tags"' ) DEFAULT CHARSET=utf8; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE bugs; DROP TABLE tags; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_default_tokenizer.test b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_default_tokenizer.test index ade4099a8d5..d1d4654460a 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_default_tokenizer.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_default_tokenizer.test @@ -30,7 +30,10 @@ CREATE TABLE tags ( COLLATE=utf8_bin COMMENT='default_tokenizer "TokenDelimit"'; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE tags; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_normalizer_index_bin.test b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_normalizer_index_bin.test index 4997dbf75f7..b2bc719d683 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_normalizer_index_bin.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_normalizer_index_bin.test @@ -29,7 +29,10 @@ CREATE TABLE diaries ( INDEX (content) COMMENT 'normalizer "NormalizerAuto"' ) DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE diaries; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_token_filters_multiple_token_filters.test b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_token_filters_multiple_token_filters.test index f7add5dbd60..5b2dcf00001 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_token_filters_multiple_token_filters.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_token_filters_multiple_token_filters.test @@ -33,7 +33,10 @@ CREATE TABLE memos ( FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord,TokenFilterStopWord"' ) DEFAULT CHARSET=utf8; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE memos; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_token_filters_one_token_filter.test b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_token_filters_one_token_filter.test index 2fc98e6103e..4f40cca47c0 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_token_filters_one_token_filter.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_token_filters_one_token_filter.test @@ -33,7 +33,10 @@ CREATE TABLE memos ( FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord"' ) DEFAULT CHARSET=utf8; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE memos; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_token_filters_parameter.test b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_token_filters_parameter.test index aaf60b02dc4..a4c844ba435 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_token_filters_parameter.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_index_token_filters_parameter.test @@ -36,7 +36,10 @@ CREATE TABLE memos ( ) DEFAULT CHARSET=utf8; SHOW CREATE TABLE memos; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE memos; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_table_token_filters_multiple_token_filters.test b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_table_token_filters_multiple_token_filters.test index dc0996d279c..a9de0b1101d 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_table_token_filters_multiple_token_filters.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_table_token_filters_multiple_token_filters.test @@ -37,7 +37,10 @@ CREATE TABLE memos ( FULLTEXT INDEX (content) COMMENT 'table "terms"' ) DEFAULT CHARSET=utf8; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE memos; DROP TABLE terms; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_table_token_filters_one_token_filter.test b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_table_token_filters_one_token_filter.test index ee1da6d09c3..30a21540c62 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/create_table_table_token_filters_one_token_filter.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/create_table_table_token_filters_one_token_filter.test @@ -37,7 +37,10 @@ CREATE TABLE memos ( FULLTEXT INDEX (content) COMMENT 'table "terms"' ) DEFAULT CHARSET=utf8; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE memos; DROP TABLE terms; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_delete_existent.test b/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_delete_existent.test index 37405696697..e9ab751dc0b 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_delete_existent.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_delete_existent.test @@ -44,7 +44,10 @@ DELETE FROM comments WHERE id = 100; SELECT * FROM entries; SELECT * FROM comments; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command('dump --dump_plugins no'); +--enable_cursor_protocol DROP TABLE entries; DROP TABLE comments; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_delete_nonexistent.test b/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_delete_nonexistent.test index 9322876badb..64a75843bfc 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_delete_nonexistent.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_delete_nonexistent.test @@ -44,7 +44,10 @@ DELETE FROM comments WHERE id = 200; SELECT * FROM entries; SELECT * FROM comments; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command('dump --dump_plugins no'); +--enable_cursor_protocol DROP TABLE entries; DROP TABLE comments; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_insert_existent.test b/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_insert_existent.test index 283efbd3a48..a0e27ea5618 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_insert_existent.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_insert_existent.test @@ -42,7 +42,10 @@ INSERT INTO entries (content, comment_id) VALUES ('Hello!', 100); SELECT * FROM entries; SELECT * FROM comments; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command('dump --dump_plugins no'); +--enable_cursor_protocol DROP TABLE entries; DROP TABLE comments; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_insert_nonexistent.test b/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_insert_nonexistent.test index 4b873f50cf0..ea9820ac6a6 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_insert_nonexistent.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_insert_nonexistent.test @@ -42,7 +42,10 @@ INSERT INTO entries (content, comment_id) VALUES ('Hello!', 1); SELECT * FROM entries; SELECT * FROM comments; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command('dump --dump_plugins no'); +--enable_cursor_protocol DROP TABLE entries; DROP TABLE comments; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_update_existent.test b/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_update_existent.test index fc3590f36ff..24cba6110fa 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_update_existent.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_update_existent.test @@ -44,7 +44,10 @@ UPDATE entries SET comment_id = 200 WHERE content = 'Hello!'; SELECT * FROM entries; SELECT * FROM comments; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command('dump --dump_plugins no'); +--enable_cursor_protocol DROP TABLE entries; DROP TABLE comments; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_update_nonexistent.test b/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_update_nonexistent.test index bcba6e75736..756c26bbfc2 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_update_nonexistent.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/foreign_key_update_nonexistent.test @@ -44,7 +44,10 @@ UPDATE entries SET comment_id = 200 WHERE content = 'Hello!'; SELECT * FROM entries; SELECT * FROM comments; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command('dump --dump_plugins no'); +--enable_cursor_protocol DROP TABLE entries; DROP TABLE comments; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/function_command_auto-escape.test b/storage/mroonga/mysql-test/mroonga/storage/t/function_command_auto-escape.test index e40a703b0a5..db2ee2b2203 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/function_command_auto-escape.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/function_command_auto-escape.test @@ -31,9 +31,12 @@ CREATE TABLE diaries ( INSERT INTO diaries VALUES('It is Groonga'); INSERT INTO diaries VALUES('It is Mroonga'); +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command('select', 'table', 'diaries', 'filter', 'title @ "Groonga"'); +--enable_cursor_protocol DROP TABLE diaries; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/function_command_special-database-name.test b/storage/mroonga/mysql-test/mroonga/storage/t/function_command_special-database-name.test index 720c547c0f7..1dcb143de29 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/function_command_special-database-name.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/function_command_special-database-name.test @@ -30,7 +30,10 @@ CREATE TABLE diaries ( FULLTEXT KEY (title) ) DEFAULT CHARSET=utf8; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command('dump --dump_plugins no'); +--enable_cursor_protocol DROP TABLE diaries; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/function_highlight_html_dynamic_keyword.test b/storage/mroonga/mysql-test/mroonga/storage/t/function_highlight_html_dynamic_keyword.test index 3958782a4bc..8f9013bc87b 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/function_highlight_html_dynamic_keyword.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/function_highlight_html_dynamic_keyword.test @@ -32,9 +32,12 @@ CREATE TABLE keywords ( INSERT INTO keywords VALUES ('Mroonga'); INSERT INTO keywords VALUES ('Groonga'); +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_highlight_html('Mroonga is the Groonga based storage engine.', keyword) AS highlighted FROM keywords; +--enable_cursor_protocol --disable_query_log DROP TABLE keywords; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/function_highlight_html_multiple_keywords.test b/storage/mroonga/mysql-test/mroonga/storage/t/function_highlight_html_multiple_keywords.test index 98643876058..bac040e69b3 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/function_highlight_html_multiple_keywords.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/function_highlight_html_multiple_keywords.test @@ -18,8 +18,11 @@ --source ../../include/mroonga/have_mroonga.inc --source ../../include/mroonga/load_mroonga_functions.inc +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_highlight_html('Mroonga is the Groonga based storage engine.', 'Mroonga', 'Groonga') AS highlighted; +--enable_cursor_protocol --source ../../include/mroonga/unload_mroonga_functions.inc --source ../../include/mroonga/have_mroonga_deinit.inc diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/function_highlight_html_normalizer.test b/storage/mroonga/mysql-test/mroonga/storage/t/function_highlight_html_normalizer.test index 83e5966d39e..a774f361fe3 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/function_highlight_html_normalizer.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/function_highlight_html_normalizer.test @@ -18,8 +18,11 @@ --source ../../include/mroonga/have_mroonga.inc --source ../../include/mroonga/load_mroonga_functions.inc +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_highlight_html('Mroonga is the Groonga based storage engine.', 'mroonga') AS highlighted; +--enable_cursor_protocol --source ../../include/mroonga/unload_mroonga_functions.inc --source ../../include/mroonga/have_mroonga_deinit.inc diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/function_normalize_default.test b/storage/mroonga/mysql-test/mroonga/storage/t/function_normalize_default.test index aa2eee53b53..108f28ce952 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/function_normalize_default.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/function_normalize_default.test @@ -18,7 +18,10 @@ --source ../../include/mroonga/have_mroonga.inc --source ../../include/mroonga/load_mroonga_functions.inc +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_normalize('aBcAbC㍑'); +--enable_cursor_protocol --source ../../include/mroonga/unload_mroonga_functions.inc --source ../../include/mroonga/have_mroonga_deinit.inc diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/function_normalize_normalizer.test b/storage/mroonga/mysql-test/mroonga/storage/t/function_normalize_normalizer.test index bb9199f012f..bcaec1fe4da 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/function_normalize_normalizer.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/function_normalize_normalizer.test @@ -18,7 +18,10 @@ --source ../../include/mroonga/have_mroonga.inc --source ../../include/mroonga/load_mroonga_functions.inc +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_normalize('aBcAbC㍑', "NormalizerAuto"); +--enable_cursor_protocol --source ../../include/mroonga/unload_mroonga_functions.inc --source ../../include/mroonga/have_mroonga_deinit.inc diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/function_snippet_html_dynamic_keyword.test b/storage/mroonga/mysql-test/mroonga/storage/t/function_snippet_html_dynamic_keyword.test index a92e651cfd4..69297ed3152 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/function_snippet_html_dynamic_keyword.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/function_snippet_html_dynamic_keyword.test @@ -32,9 +32,12 @@ CREATE TABLE keywords ( INSERT INTO keywords VALUES ('Mroonga'); INSERT INTO keywords VALUES ('Groonga'); +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_snippet_html('Mroonga is the Groonga based storage engine.', keyword) as snippet FROM keywords; +--enable_cursor_protocol --disable_query_log DROP TABLE keywords; diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/function_snippet_html_multiple_keywords.test b/storage/mroonga/mysql-test/mroonga/storage/t/function_snippet_html_multiple_keywords.test index 54953ebea59..a968c7b924e 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/function_snippet_html_multiple_keywords.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/function_snippet_html_multiple_keywords.test @@ -18,8 +18,11 @@ --source ../../include/mroonga/have_mroonga.inc --source ../../include/mroonga/load_mroonga_functions.inc +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_snippet_html('Mroonga is the Groonga based storage engine.', 'Mroonga', 'Groonga') as snippet; +--enable_cursor_protocol --source ../../include/mroonga/unload_mroonga_functions.inc --source ../../include/mroonga/have_mroonga_deinit.inc diff --git a/storage/mroonga/mysql-test/mroonga/wrapper/t/alter_table_add_column_multibyte_cp932.test b/storage/mroonga/mysql-test/mroonga/wrapper/t/alter_table_add_column_multibyte_cp932.test index 21e80a74fd6..ac828ddb1ac 100644 --- a/storage/mroonga/mysql-test/mroonga/wrapper/t/alter_table_add_column_multibyte_cp932.test +++ b/storage/mroonga/mysql-test/mroonga/wrapper/t/alter_table_add_column_multibyte_cp932.test @@ -46,7 +46,10 @@ SELECT * FROM users; SELECT * FROM users WHERE MATCH (O) AGAINST ('+Ȃ' IN BOOLEAN MODE); +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no --dump_records no"); +--enable_cursor_protocol DROP TABLE users; diff --git a/storage/mroonga/mysql-test/mroonga/wrapper/t/alter_table_add_column_multibyte_utf8.test b/storage/mroonga/mysql-test/mroonga/wrapper/t/alter_table_add_column_multibyte_utf8.test index f98d0e0da2c..d6d17396760 100644 --- a/storage/mroonga/mysql-test/mroonga/wrapper/t/alter_table_add_column_multibyte_utf8.test +++ b/storage/mroonga/mysql-test/mroonga/wrapper/t/alter_table_add_column_multibyte_utf8.test @@ -46,7 +46,10 @@ SELECT * FROM users; SELECT * FROM users WHERE MATCH (名前) AGAINST ('+たなか' IN BOOLEAN MODE); +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no --dump_records no"); +--enable_cursor_protocol DROP TABLE users; diff --git a/storage/mroonga/mysql-test/mroonga/wrapper/t/column_multibyte_cp932.test b/storage/mroonga/mysql-test/mroonga/wrapper/t/column_multibyte_cp932.test index 5898e3772c6..f06f6cfe94e 100644 --- a/storage/mroonga/mysql-test/mroonga/wrapper/t/column_multibyte_cp932.test +++ b/storage/mroonga/mysql-test/mroonga/wrapper/t/column_multibyte_cp932.test @@ -45,7 +45,10 @@ SELECT * FROM users; SELECT * FROM users WHERE MATCH (O) AGAINST ('+Ȃ' IN BOOLEAN MODE); +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no --dump_records no"); +--enable_cursor_protocol DROP TABLE users; diff --git a/storage/mroonga/mysql-test/mroonga/wrapper/t/column_multibyte_utf8.test b/storage/mroonga/mysql-test/mroonga/wrapper/t/column_multibyte_utf8.test index c646a1d2eba..a61382949fe 100644 --- a/storage/mroonga/mysql-test/mroonga/wrapper/t/column_multibyte_utf8.test +++ b/storage/mroonga/mysql-test/mroonga/wrapper/t/column_multibyte_utf8.test @@ -45,7 +45,10 @@ SELECT * FROM users; SELECT * FROM users WHERE MATCH (名前) AGAINST ('+たなか' IN BOOLEAN MODE); +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no --dump_records no"); +--enable_cursor_protocol DROP TABLE users; diff --git a/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_comment_combined.test b/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_comment_combined.test index e6dd9908002..c609df9d03d 100644 --- a/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_comment_combined.test +++ b/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_comment_combined.test @@ -27,7 +27,10 @@ CREATE TABLE bugs ( ) DEFAULT CHARSET=utf8 COMMENT='Free style normal comment, engine "InnoDB"'; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE bugs; diff --git a/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_token_filters_index_multiple_token_filters.test b/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_token_filters_index_multiple_token_filters.test index 45c758173d4..920fa63a46c 100644 --- a/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_token_filters_index_multiple_token_filters.test +++ b/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_token_filters_index_multiple_token_filters.test @@ -35,7 +35,10 @@ CREATE TABLE memos ( FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord,TokenFilterStopWord"' ) COMMENT='engine "InnoDB"' DEFAULT CHARSET=utf8; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE memos; diff --git a/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_token_filters_index_one_token_filter.test b/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_token_filters_index_one_token_filter.test index 64732efd8ec..55e31124c18 100644 --- a/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_token_filters_index_one_token_filter.test +++ b/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_token_filters_index_one_token_filter.test @@ -35,7 +35,10 @@ CREATE TABLE memos ( FULLTEXT INDEX (content) COMMENT 'token_filters "TokenFilterStopWord"' ) COMMENT='engine "InnoDB"' DEFAULT CHARSET=utf8; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE memos; diff --git a/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_token_filters_index_parameter.test b/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_token_filters_index_parameter.test index 3fb0caeadf8..e6b56bae1e0 100644 --- a/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_token_filters_index_parameter.test +++ b/storage/mroonga/mysql-test/mroonga/wrapper/t/create_table_token_filters_index_parameter.test @@ -38,7 +38,10 @@ CREATE TABLE memos ( ) COMMENT='ENGINE "InnoDB"' DEFAULT CHARSET=utf8; SHOW CREATE TABLE memos; +#Check after fix MDEV-31554 +--disable_cursor_protocol SELECT mroonga_command("dump --dump_plugins no"); +--enable_cursor_protocol DROP TABLE memos; diff --git a/storage/rocksdb/mysql-test/rocksdb/include/group_min_max.inc b/storage/rocksdb/mysql-test/rocksdb/include/group_min_max.inc index 40fabce0517..492343f2e47 100644 --- a/storage/rocksdb/mysql-test/rocksdb/include/group_min_max.inc +++ b/storage/rocksdb/mysql-test/rocksdb/include/group_min_max.inc @@ -1428,10 +1428,12 @@ INSERT INTO t1(c1,c2) VALUES (4,14), (4,15), (4,16), (4,17), (4,18), (4,19), (4,20),(5,5); ANALYZE TABLE t1; +--disable_cursor_protocol EXPLAIN SELECT MAX(c2), c1 FROM t1 WHERE c1 = 4 GROUP BY c1; FLUSH STATUS; SELECT MAX(c2), c1 FROM t1 WHERE c1 = 4 GROUP BY c1; SHOW SESSION STATUS LIKE 'Handler_read%'; +--enable_cursor_protocol DROP TABLE t1; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/2pc_group_commit.test b/storage/rocksdb/mysql-test/rocksdb/t/2pc_group_commit.test index aeadf5381b0..64d38a5e571 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/2pc_group_commit.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/2pc_group_commit.test @@ -35,9 +35,11 @@ SET GLOBAL rocksdb_flush_log_at_trx_commit=1; --echo ## --echo ## 2PC + durability + single thread --echo ## +--disable_cursor_protocol select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits'; select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits'; select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced'; +--enable_cursor_protocol --exec $MYSQL_SLAP --silent --concurrency=1 --number-of-queries=1000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)" select IF(variable_value - @b1 = 1000, 'OK', variable_value - @b1) as Binlog_commits from information_schema.global_status where variable_name='Binlog_commits'; @@ -63,9 +65,11 @@ set debug_dbug='-d,rocksdb_enable_delay_commits'; --echo ## --echo ## 2PC + durability + group commit --echo ## +--disable_cursor_protocol select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits'; select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits'; select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced'; +--enable_cursor_protocol --exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=10000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)" @@ -90,9 +94,11 @@ set debug_dbug='-d,rocksdb_disable_delay_commits'; SET GLOBAL rocksdb_enable_2pc=1; SET GLOBAL rocksdb_flush_log_at_trx_commit=0; +--disable_cursor_protocol select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits'; select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits'; select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced'; +--enable_cursor_protocol --exec $MYSQL_SLAP --silent --concurrency=1 --number-of-queries=1000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)" select IF(variable_value - @b1 = 1000, 'OK', variable_value - @b1) as Binlog_commits @@ -106,9 +112,11 @@ from information_schema.global_status where variable_name='Rocksdb_wal_synced'; --echo # 2PC enabled, MyRocks durability disabled, concurrent workload --echo ## +--disable_cursor_protocol select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits'; select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits'; select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced'; +--enable_cursor_protocol --exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=10000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)" @@ -132,9 +140,11 @@ from information_schema.global_status where variable_name='Rocksdb_wal_synced'; SET GLOBAL rocksdb_enable_2pc=0; SET GLOBAL rocksdb_flush_log_at_trx_commit=1; +--disable_cursor_protocol select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits'; select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits'; select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced'; +--enable_cursor_protocol --exec $MYSQL_SLAP --silent --concurrency=1 --number-of-queries=1000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)" @@ -148,9 +158,11 @@ from information_schema.global_status where variable_name='Rocksdb_wal_synced'; --echo ## --echo # 2PC disabled, MyRocks durability enabled, concurrent workload --echo ## +--disable_cursor_protocol select variable_value into @b1 from information_schema.global_status where variable_name='Binlog_commits'; select variable_value into @b2 from information_schema.global_status where variable_name='Binlog_group_commits'; select variable_value into @b3 from information_schema.global_status where variable_name='Rocksdb_wal_synced'; +--enable_cursor_protocol --exec $MYSQL_SLAP --silent --concurrency=50 --number-of-queries=10000 --query="INSERT INTO t1 (id, value) VALUES(NULL, 1)" select variable_value - @b1 as Binlog_commits diff --git a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_debug.test b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_debug.test index 99e28f3b55e..280c59a6a1d 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_debug.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_debug.test @@ -67,7 +67,9 @@ commit; --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/wait_until_connected_again.inc --disable_reconnect +--disable_cursor_protocol select max(i) into @row_max from t; +--enable_cursor_protocol select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't'; --echo # After engine prepare @@ -83,7 +85,9 @@ commit; --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/wait_until_connected_again.inc --disable_reconnect +--disable_cursor_protocol select max(i) into @row_max from t; +--enable_cursor_protocol select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't'; --echo # After binlog @@ -99,7 +103,9 @@ commit; --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/wait_until_connected_again.inc --disable_reconnect +--disable_cursor_protocol select max(i) into @row_max from t; +--enable_cursor_protocol select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't'; --echo # After everything @@ -115,7 +121,9 @@ commit; --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/wait_until_connected_again.inc --disable_reconnect +--disable_cursor_protocol select max(i) into @row_max from t; +--enable_cursor_protocol select table_schema, table_name, auto_increment > @row_max from information_schema.tables where table_name = 't'; drop table t; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars_thread_2.test b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars_thread_2.test index b64af16411b..83ef7c0ff29 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars_thread_2.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/autoinc_vars_thread_2.test @@ -99,10 +99,12 @@ while ($i > 0) # smallest value in the sequence for thread 'thr' that is greater than # the pk in the previous row. let $file = `SELECT CONCAT(@@datadir, "test_export.txt")`; +--disable_cursor_protocol --disable_query_log --echo SELECT * FROM t1 ORDER BY pk INTO OUTFILE ; eval SELECT * FROM t1 ORDER BY pk INTO OUTFILE "$file"; --enable_query_log +--enable_cursor_protocol let ROCKSDB_OUTFILE = $file; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter3.test b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter3.test index dc2a0da506d..41909a584ff 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter3.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter3.test @@ -29,7 +29,9 @@ while ($i <= 10000) { ## HA_READ_PREFIX_LAST_OR_PREV # BF len 21 +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; +--enable_cursor_protocol select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type`) where id1 = 100 and link_type = 1 and time >= 0 and time <= 9223372036854775807 and visibility = 1 order by time desc; select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; @@ -47,7 +49,9 @@ explain select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 and time >= 0 and time <= 9223372036854775807 order by time desc; +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; +--enable_cursor_protocol # MariaDB: no support for optimizer_force_index_for_range: #set @tmp_force_index_for_range=@@optimizer_force_index_for_range; #set optimizer_force_index_for_range=on; @@ -56,34 +60,46 @@ select case when variable_value-@c > 0 then 'true' else 'false' end from informa #set global optimizer_force_index_for_range=@tmp_force_index_for_range; # BF len 13 +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; +--enable_cursor_protocol select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type3`) where id1 = 100 and time >= 0 and time <= 9223372036854775807 and visibility = 1 order by time desc; select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; ## HA_READ_PREFIX_LAST_OR_PREV (no end range) # BF len 20 +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; +--enable_cursor_protocol select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type`) where id1 = 100 and link_type = 1 and visibility = 1 and time >= 0 order by time desc; select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; # BF len 19 +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; +--enable_cursor_protocol select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 and time >= 0 order by time desc; select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; --echo ## HA_READ_PREFIX_LAST --echo # BF len 20 +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; +--enable_cursor_protocol select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type`) where id1 = 100 and link_type = 1 and visibility = 1 order by time desc; select case when variable_value-@c > 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; --echo # BF len 19 +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; +--enable_cursor_protocol select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type2`) where id1 = 100 and link_type = 1 order by time desc; select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; --echo # BF len 12 +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; +--enable_cursor_protocol select id1, id2, link_type, visibility, data, time, version from linktable FORCE INDEX(`id1_type3`) where id1 = 100 and visibility = 1 order by time desc; select case when variable_value-@c = 0 then 'true' else 'false' end from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; @@ -125,7 +141,9 @@ explain select * from t1 where kp0=1 and kp1=1 and kp2=0x12FFFFFFFFFF order by kp3 desc; show status like '%rocksdb_bloom_filter_prefix%'; +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; +--enable_cursor_protocol select * from t1 where kp0=1 and kp1=1 and kp2=0x12FFFFFFFFFF order by kp3 desc; show status like '%rocksdb_bloom_filter_prefix%'; --echo # The following MUST show TRUE: diff --git a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_bulk_load.test b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_bulk_load.test index 09d9d734f9e..e159cab2f0c 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_bulk_load.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/bloomfilter_bulk_load.test @@ -21,12 +21,16 @@ while ($t <= 2) { set session rocksdb_bulk_load=0; # bloom filter should be useful on insert (calling GetForUpdate) +--disable_cursor_protocol select variable_value into @h from information_schema.global_status where variable_name='rocksdb_block_cache_filter_hit'; +--enable_cursor_protocol insert into r1 values (100, 100); select variable_value-@h from information_schema.global_status where variable_name='rocksdb_block_cache_filter_hit'; # cf2 has no bloo filter in the bottommost level +--disable_cursor_protocol select variable_value into @h from information_schema.global_status where variable_name='rocksdb_block_cache_filter_hit'; +--enable_cursor_protocol insert into r2 values (100, 100); select variable_value-@h from information_schema.global_status where variable_name='rocksdb_block_cache_filter_hit'; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test b/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test index 1dcb176e4fa..6dcea5ccc4e 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/cardinality.test @@ -21,8 +21,10 @@ column_name="a"; ANALYZE TABLE t0; --enable_result_log +--disable_cursor_protocol SELECT table_rows into @N FROM information_schema.tables WHERE table_name = "t0"; +--enable_cursor_protocol SELECT FLOOR(@N/cardinality) FROM information_schema.statistics where table_name="t0" and column_name="id"; SELECT FLOOR(@N/cardinality) FROM @@ -35,8 +37,10 @@ SET GLOBAL rocksdb_force_flush_memtable_now = 1; ANALYZE TABLE t0; --enable_result_log +--disable_cursor_protocol SELECT table_rows into @N FROM information_schema.tables WHERE table_name = "t0"; +--enable_cursor_protocol SELECT FLOOR(@N/cardinality) FROM information_schema.statistics where table_name="t0" and column_name="id"; SELECT FLOOR(@N/cardinality) FROM @@ -111,8 +115,10 @@ while ($i<100) # Cardinality of key c should be 1 for c, 10 for b, 100 for a and the other fields. SET GLOBAL rocksdb_force_flush_memtable_now = 1; ANALYZE TABLE t2; +--disable_cursor_protocol --echo cardinality of the columns after 'a' must be equal to the cardinality of column 'a' SELECT CARDINALITY INTO @c FROM information_schema.statistics WHERE TABLE_NAME='t2' AND INDEX_NAME='c' AND COLUMN_NAME='a'; +--enable_cursor_protocol SELECT COLUMN_NAME, CARDINALITY = @c FROM information_schema.statistics WHERE TABLE_NAME='t2' AND INDEX_NAME='c' AND SEQ_IN_INDEX > 3; drop table t1, t2; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/drop_table3.inc b/storage/rocksdb/mysql-test/rocksdb/t/drop_table3.inc index 1a044384a45..dd9a19a29cb 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/drop_table3.inc +++ b/storage/rocksdb/mysql-test/rocksdb/t/drop_table3.inc @@ -29,7 +29,9 @@ let $max = 50000; let $table = t1; --source drop_table3_repopulate_table.inc +--disable_cursor_protocol select variable_value into @a from information_schema.global_status where variable_name='rocksdb_compact_read_bytes'; +--enable_cursor_protocol if ($truncate_table) { truncate table t1; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test b/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test index 22b5d69780d..21ee4b9b3ba 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/handler_basic.test @@ -8,6 +8,8 @@ DROP TABLE IF EXISTS t1; --enable_warnings +--disable_cursor_protocol + FLUSH STATUS; CREATE TABLE t1 (id INT PRIMARY KEY, a VARCHAR(100), b INT, INDEX b(b)) ENGINE=rocksdb; @@ -49,5 +51,7 @@ FLUSH STATUS; SELECT * FROM t1 WHERE id < 8 ORDER BY id; SHOW SESSION STATUS LIKE 'Handler_read%'; +--enable_cursor_protocol + # Cleanup DROP TABLE t1; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/hermitage.inc b/storage/rocksdb/mysql-test/rocksdb/t/hermitage.inc index 17baf5b6c57..ba88c603568 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/hermitage.inc +++ b/storage/rocksdb/mysql-test/rocksdb/t/hermitage.inc @@ -111,7 +111,9 @@ commit; connection con1; update test set value = value + 10; connection con2; +--disable_cursor_protocol select variable_value into @a from information_schema.global_status where variable_name='rocksdb_snapshot_conflict_errors'; +--enable_cursor_protocol select * from test; send delete from test where value = 20; connection con1; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/no_merge_sort.test b/storage/rocksdb/mysql-test/rocksdb/t/no_merge_sort.test index ccef7182c11..cde1d4ef1fc 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/no_merge_sort.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/no_merge_sort.test @@ -21,8 +21,10 @@ while ($i < 30) { inc $j; } + --disable_cursor_protocol select variable_value into @s from information_schema.global_status where variable_name='Sort_merge_passes'; eval SELECT a, b, c FROM ti_nk ORDER BY a,b,c INTO OUTFILE '$datadir/select.out'; + --enable_cursor_protocol --remove_file $datadir/select.out select case when variable_value-@s = 0 then 'true' else 'false' end as skip_merge_sort from information_schema.global_status where variable_name='Sort_merge_passes'; inc $i; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/perf_context.test b/storage/rocksdb/mysql-test/rocksdb/t/perf_context.test index ee41324a34d..26bea857ed3 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/perf_context.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/perf_context.test @@ -72,8 +72,10 @@ AND VALUE > 0; SELECT COUNT(*) from INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT_GLOBAL WHERE STAT_TYPE = 'IO_WRITE_NANOS' AND VALUE > 0; +--disable_cursor_protocol SELECT VALUE INTO @a from INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT_GLOBAL WHERE STAT_TYPE = 'IO_WRITE_NANOS'; +--enable_cursor_protocol # Single statement writes do show up in per-table stats INSERT INTO t2 VALUES (5), (6), (7), (8); @@ -83,8 +85,10 @@ WHERE TABLE_NAME = 't2' AND STAT_TYPE = 'IO_WRITE_NANOS' AND VALUE > 0; +--disable_cursor_protocol SELECT VALUE INTO @b from INFORMATION_SCHEMA.ROCKSDB_PERF_CONTEXT_GLOBAL WHERE STAT_TYPE = 'IO_WRITE_NANOS'; +--enable_cursor_protocol SELECT CASE WHEN @b - @a > 0 THEN 'true' ELSE 'false' END; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/prefix_extractor_override.test b/storage/rocksdb/mysql-test/rocksdb/t/prefix_extractor_override.test index 8fa43e15827..ffad670a0bf 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/prefix_extractor_override.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/prefix_extractor_override.test @@ -22,7 +22,9 @@ set global rocksdb_force_flush_memtable_now = 1; SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%prefix_extractor%'; # BF used (4+8+8+8) +--disable_cursor_protocol select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; +--enable_cursor_protocol SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1; select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; @@ -48,7 +50,9 @@ SELECT * FROM information_schema.rocksdb_cf_options WHERE option_type like '%pre # Satisfies can_use_bloom_filter (4+8+8+8), but can't use because the old SST # files have old prefix extractor +--disable_cursor_protocol select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; +--enable_cursor_protocol SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1; select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; @@ -67,7 +71,9 @@ set global rocksdb_force_flush_memtable_now = 1; # BF used w/ new prefix extractor (4+8+8+8) (still increments once because it # needs to check the new SST file, but doesnt increment for SST file with old # extractor) +--disable_cursor_protocol select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; +--enable_cursor_protocol SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1; select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; @@ -81,7 +87,9 @@ set global rocksdb_force_flush_memtable_now = 1; # should have 3 sst files, one with old prefix extractor and two with new SELECT COUNT(*) FROM information_schema.rocksdb_index_file_map WHERE COLUMN_FAMILY != 1; +--disable_cursor_protocol select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; +--enable_cursor_protocol SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=1 AND id3=1; select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; @@ -89,7 +97,9 @@ SET @@global.rocksdb_update_cf_options = ''; set global rocksdb_compact_cf='cf1'; # Select the updated, make sure bloom filter is checked now +--disable_cursor_protocol select variable_value into @u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; +--enable_cursor_protocol SELECT COUNT(*) FROM t1 WHERE id1=1 AND id2=30 AND id3=30; select variable_value-@u from information_schema.global_status where variable_name='rocksdb_bloom_filter_prefix_checked'; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/read_only_tx.test b/storage/rocksdb/mysql-test/rocksdb/t/read_only_tx.test index 3a1025a3623..dfd119a0a8c 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/read_only_tx.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/read_only_tx.test @@ -18,8 +18,10 @@ CREATE TABLE t1 (id INT, value int, PRIMARY KEY (id), INDEX (value)) ENGINE=Rock INSERT INTO t1 VALUES (1,1); # Read-only, long-running transaction. SingleDelete/Put shouldn't increase much. +--disable_cursor_protocol select variable_value into @p from information_schema.global_status where variable_name='rocksdb_number_sst_entry_put'; select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete'; +--enable_cursor_protocol #-- replace_result $uuid uuid START TRANSACTION WITH CONSISTENT SNAPSHOT; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_qcache.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_qcache.test index 0369e758f5d..e2c13748386 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_qcache.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_qcache.test @@ -11,6 +11,7 @@ set @@global.query_cache_size=1024*1024; --enable_connect_log +--disable_cursor_protocol create table t1 (pk int primary key, c char(8)) engine=RocksDB; insert into t1 values (1,'new'),(2,'new'); @@ -35,6 +36,7 @@ show status like 'Qcache_not_cached'; show global status like 'Qcache_hits'; drop table t1; +--enable_cursor_protocol # # Cleanup diff --git a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_row_stats.test b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_row_stats.test index ebcc741fc17..ec99aa98278 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_row_stats.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/rocksdb_row_stats.test @@ -1,6 +1,7 @@ source include/have_rocksdb.inc; create table t1 (a int primary key) engine=rocksdb; +--disable_cursor_protocol -- echo Verify rocksdb_rows_inserted select variable_value into @old_rows_inserted from information_schema.global_status where variable_name = 'rocksdb_rows_inserted'; insert into t1 values(1); @@ -51,6 +52,7 @@ select variable_value into @old_system_rows_deleted from information_schema.glob delete from t1; select variable_value into @new_system_rows_deleted from information_schema.global_status where variable_name = 'rocksdb_system_rows_deleted'; select @new_system_rows_deleted - @old_system_rows_deleted; +--enable_cursor_protocol drop table t1; use test; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/select.test b/storage/rocksdb/mysql-test/rocksdb/t/select.test index 3d9bdc7b4b8..fc6cd7c5d10 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/select.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/select.test @@ -68,6 +68,7 @@ SELECT * FROM t2 WHERE a>0 PROCEDURE ANALYSE(); # SELECT INTO let $datadir = `SELECT @@datadir`; +--disable_cursor_protocol --replace_result $datadir eval SELECT t1.a, t2.b FROM t2, t1 WHERE t1.a = t2.a ORDER BY t2.b, t1.a @@ -94,6 +95,7 @@ SELECT t1.*, t2.* FROM t1, t2 ORDER BY t2.b, t1.a, t2.a, t1.b, t1.pk, t2.pk LIMI SELECT MIN(a), MAX(a) FROM t1 INTO @min, @max; SELECT @min, @max; +--enable_cursor_protocol # Joins diff --git a/storage/rocksdb/mysql-test/rocksdb/t/show_table_status.test b/storage/rocksdb/mysql-test/rocksdb/t/show_table_status.test index 55854710c31..5fc52a5142c 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/show_table_status.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/show_table_status.test @@ -81,9 +81,11 @@ flush tables; select create_time is not null, update_time is not null, check_time from information_schema.tables where table_schema=database() and table_name='t1'; +--disable_cursor_protocol select create_time, update_time into @create_tm, @update_tm from information_schema.tables where table_schema=database() and table_name='t1'; +--enable_cursor_protocol select sleep(3); insert into t1 values (2); @@ -109,9 +111,11 @@ where table_schema=database() and table_name='t1'; insert into t1 values (5,5); +--disable_cursor_protocol select create_time, update_time into @create_tm, @update_tm from information_schema.tables where table_schema=database() and table_name='t1'; +--enable_cursor_protocol --echo # Then, an in-place ALTER TABLE: select sleep(2); @@ -126,9 +130,11 @@ where table_schema=database() and table_name='t1'; --echo # Check TRUNCATE TABLE insert into t1 values (10,10); +--disable_cursor_protocol select create_time, update_time into @create_tm, @update_tm from information_schema.tables where table_schema=database() and table_name='t1'; +--enable_cursor_protocol select sleep(2); truncate table t1; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/singledelete.test b/storage/rocksdb/mysql-test/rocksdb/t/singledelete.test index 5a9d17e0255..9de2a899eda 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/singledelete.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/singledelete.test @@ -3,8 +3,10 @@ # only SingleDelete increases CREATE TABLE t1 (id INT, value int, PRIMARY KEY (id), INDEX (value)) ENGINE=RocksDB; INSERT INTO t1 VALUES (1,1); +--disable_cursor_protocol select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete'; select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete'; +--enable_cursor_protocol --disable_query_log let $i = 1; while ($i <= 10000) { @@ -21,8 +23,10 @@ select case when variable_value-@d < 10 then 'true' else 'false' end from inform # both SingleDelete and Delete increases CREATE TABLE t2 (id INT, value int, PRIMARY KEY (id), INDEX (value)) ENGINE=RocksDB; INSERT INTO t2 VALUES (1,1); +--disable_cursor_protocol select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete'; select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete'; +--enable_cursor_protocol --disable_query_log let $i = 1; while ($i <= 10000) { @@ -38,8 +42,10 @@ select case when variable_value-@d > 9000 then 'true' else 'false' end from info # only Delete increases CREATE TABLE t3 (id INT, value int, PRIMARY KEY (id)) ENGINE=RocksDB; INSERT INTO t3 VALUES (1,1); +--disable_cursor_protocol select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete'; select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete'; +--enable_cursor_protocol --disable_query_log let $i = 1; while ($i <= 10000) { @@ -55,8 +61,10 @@ select case when variable_value-@d > 9000 then 'true' else 'false' end from info # only SingleDelete increases CREATE TABLE t4 (id INT, PRIMARY KEY (id)) ENGINE=RocksDB; INSERT INTO t4 VALUES (1); +--disable_cursor_protocol select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete'; select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete'; +--enable_cursor_protocol --disable_query_log let $i = 1; while ($i <= 10000) { @@ -72,8 +80,10 @@ select case when variable_value-@d < 10 then 'true' else 'false' end from inform # only SingleDelete increases CREATE TABLE t5 (id1 INT, id2 INT, PRIMARY KEY (id1, id2), INDEX(id2)) ENGINE=RocksDB; INSERT INTO t5 VALUES (1, 1); +--disable_cursor_protocol select variable_value into @s from information_schema.global_status where variable_name='rocksdb_number_sst_entry_singledelete'; select variable_value into @d from information_schema.global_status where variable_name='rocksdb_number_sst_entry_delete'; +--enable_cursor_protocol --disable_query_log let $i = 1; while ($i <= 10000) { diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary.test b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary.test index 38bfb2eef8f..d8f17a7cbb9 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary.test @@ -516,7 +516,9 @@ set global rocksdb_enable_ttl=0; set global rocksdb_force_flush_memtable_now=1; set global rocksdb_compact_cf='default'; +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired'; +--enable_cursor_protocol set global rocksdb_enable_ttl=1; set global rocksdb_compact_cf='default'; @@ -537,7 +539,9 @@ INSERT INTO t1 values (1); INSERT INTO t1 values (2); INSERT INTO t1 values (3); +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired'; +--enable_cursor_protocol set global rocksdb_force_flush_memtable_now=1; set global rocksdb_compact_cf='default'; select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired'; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_read_filtering.test b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_read_filtering.test index 7a7609f456e..a452e932bb5 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_read_filtering.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_primary_read_filtering.test @@ -24,7 +24,9 @@ set global rocksdb_force_flush_memtable_now=1; --sorted_result SELECT * FROM t1; +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired'; +--enable_cursor_protocol set global rocksdb_compact_cf='default'; select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired'; @@ -78,7 +80,9 @@ INSERT INTO t1 values (7); set global rocksdb_debug_ttl_rec_ts = 0; # should return nothing. +--disable_cursor_protocol select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered'; +--enable_cursor_protocol --sorted_result SELECT * FROM t1; select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered'; @@ -87,7 +91,9 @@ select variable_value-@a from information_schema.global_status where variable_na set global rocksdb_enable_ttl_read_filtering=0; # should return everything +--disable_cursor_protocol select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered'; +--enable_cursor_protocol --sorted_result SELECT * FROM t1; select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered'; @@ -96,7 +102,9 @@ select variable_value-@a from information_schema.global_status where variable_na set global rocksdb_enable_ttl_read_filtering=1; # should return nothing. +--disable_cursor_protocol select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered'; +--enable_cursor_protocol --sorted_result SELECT * FROM t1; select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered'; @@ -125,7 +133,9 @@ INSERT INTO t1 values (1,2,2); INSERT INTO t1 values (1,2,3); set global rocksdb_debug_ttl_rec_ts = 0; +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired'; +--enable_cursor_protocol set global rocksdb_force_flush_memtable_now=1; @@ -301,27 +311,35 @@ set global rocksdb_compact_cf='default'; # this connection the records have 'expired' already so they are filtered out # even though they have not yet been removed by compaction +--disable_cursor_protocol select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered'; +--enable_cursor_protocol --sorted_result SELECT * FROM t1; select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered'; --echo # Switching to connection 1 connection con1; +--disable_cursor_protocol select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered'; +--enable_cursor_protocol --sorted_result SELECT * FROM t1; # <= shouldn't be filtered out here select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered'; UPDATE t1 set a = a + 1; +--disable_cursor_protocol select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered'; +--enable_cursor_protocol --sorted_result SELECT * FROM t1; # <= shouldn't be filtered out here select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered'; COMMIT; +--disable_cursor_protocol select variable_value into @a from information_schema.global_status where variable_name='rocksdb_rows_filtered'; +--enable_cursor_protocol --sorted_result # <= filtered out here because time has passed. SELECT * FROM t1; select variable_value-@a from information_schema.global_status where variable_name='rocksdb_rows_filtered'; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary.test b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary.test index fb439e109e7..49d097b1056 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary.test @@ -582,7 +582,9 @@ set global rocksdb_enable_ttl=0; set global rocksdb_force_flush_memtable_now=1; set global rocksdb_compact_cf='default'; +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired'; +--enable_cursor_protocol set global rocksdb_enable_ttl=1; set global rocksdb_compact_cf='default'; @@ -604,7 +606,9 @@ INSERT INTO t1 values (1, 1); INSERT INTO t1 values (2, 2); INSERT INTO t1 values (3, 3); +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired'; +--enable_cursor_protocol set global rocksdb_force_flush_memtable_now=1; set global rocksdb_compact_cf='default'; select variable_value-@c from information_schema.global_status where variable_name='rocksdb_rows_expired'; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering.test b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering.test index f6042cc517e..0e83a0f003e 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/ttl_secondary_read_filtering.test @@ -29,7 +29,9 @@ SELECT * FROM t1 FORCE INDEX (PRIMARY); --sorted_result SELECT * FROM t1 FORCE INDEX (kb); +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired'; +--enable_cursor_protocol set global rocksdb_debug_ttl_ignore_pk = 1; set global rocksdb_compact_cf='default'; set global rocksdb_debug_ttl_ignore_pk = 0; @@ -145,7 +147,9 @@ INSERT INTO t1 values (1,2,2); INSERT INTO t1 values (1,2,3); set global rocksdb_debug_ttl_rec_ts = 0; +--disable_cursor_protocol select variable_value into @c from information_schema.global_status where variable_name='rocksdb_rows_expired'; +--enable_cursor_protocol set global rocksdb_force_flush_memtable_now=1; diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation.test b/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation.test index d231236bd92..f5134b841aa 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation.test +++ b/storage/rocksdb/mysql-test/rocksdb/t/type_char_indexes_collation.test @@ -45,8 +45,10 @@ explain select hex(c2) from t IGNORE INDEX (sk1) order by c2; --let $file1=$MYSQLTEST_VARDIR/tmp/filesort_order --let $file2=$MYSQLTEST_VARDIR/tmp/sk_order --disable_query_log +--disable_cursor_protocol --eval select hex(weight_string(c1)) INTO OUTFILE '$file1' from t order by c1 --eval select hex(weight_string(c1)) INTO OUTFILE '$file2' from t IGNORE INDEX (sk1) order by c1 +--enable_cursor_protocol --enable_query_log --diff_files $file1 $file2 @@ -54,8 +56,10 @@ explain select hex(c2) from t IGNORE INDEX (sk1) order by c2; --remove_file $file2 --disable_query_log +--disable_cursor_protocol --eval select hex(weight_string(c2)) INTO OUTFILE '$file1' from t order by c2 --eval select hex(weight_string(c2)) INTO OUTFILE '$file2' from t IGNORE INDEX (sk1) order by c2 +--enable_cursor_protocol --enable_query_log --diff_files $file1 $file2 diff --git a/storage/rocksdb/mysql-test/rocksdb/t/type_float.inc b/storage/rocksdb/mysql-test/rocksdb/t/type_float.inc index ff58b73a91b..032a81a80cc 100644 --- a/storage/rocksdb/mysql-test/rocksdb/t/type_float.inc +++ b/storage/rocksdb/mysql-test/rocksdb/t/type_float.inc @@ -56,6 +56,8 @@ INSERT INTO t1 (f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10,pk) VALUES (-9999 --sorted_result --query_vertical SELECT f,f0,r1_1,f23_0,f20_3,d,d1_0,d10_10,d53,d53_10 FROM t1 +#Enable after fix MDEV-34624 +--disable_cursor_protocol --sorted_result query_vertical SELECT @@ -69,6 +71,7 @@ SELECT CONCAT('', MAX(d10_10)), CONCAT('', MAX(d53)), CONCAT('', MAX(d53_10)) FROM t1; +--enable_cursor_protocol # Invalid values diff --git a/storage/spider/mysql-test/spider/regression/e1121/t/load_data.inc b/storage/spider/mysql-test/spider/regression/e1121/t/load_data.inc index 080ba735a32..325a7523974 100644 --- a/storage/spider/mysql-test/spider/regression/e1121/t/load_data.inc +++ b/storage/spider/mysql-test/spider/regression/e1121/t/load_data.inc @@ -41,9 +41,11 @@ eval CREATE TABLE tbl_a ( INSERT INTO tbl_a (pkey,val) VALUES (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); --disable_query_log --echo SELECT pkey,val INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' FROM tbl_a ORDER BY pkey; +--disable_cursor_protocol --disable_ps2_protocol eval SELECT pkey,val INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' FROM tbl_a ORDER BY pkey; --enable_ps2_protocol +--enable_cursor_protocol --enable_query_log eval $COMMAND_BEFORE_LOAD_DATA; @@ -56,9 +58,11 @@ TRUNCATE TABLE mysql.general_log; --connection master_1 --disable_query_log --echo LOAD DATA $OPTION_LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' $OPTION_WORD INTO TABLE tbl_a; +--disable_cursor_protocol --disable_ps2_protocol eval LOAD DATA $OPTION_LOCAL INFILE '$MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' $OPTION_WORD INTO TABLE tbl_a; --enable_ps2_protocol +--enable_cursor_protocol --enable_query_log --remove_file $MYSQLTEST_VARDIR/tmp/spider_outfile.tsv diff --git a/storage/spider/mysql-test/spider/regression/e112122/t/load_data_part.inc b/storage/spider/mysql-test/spider/regression/e112122/t/load_data_part.inc index fd31047ab58..f52d415a032 100644 --- a/storage/spider/mysql-test/spider/regression/e112122/t/load_data_part.inc +++ b/storage/spider/mysql-test/spider/regression/e112122/t/load_data_part.inc @@ -54,9 +54,11 @@ eval CREATE TABLE tbl_a ( INSERT INTO tbl_a (pkey,val) VALUES (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); --disable_query_log --echo SELECT pkey,val INTO OUTFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' FROM tbl_a ORDER BY pkey; +--disable_cursor_protocol --disable_ps_protocol eval SELECT pkey,val INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' FROM tbl_a ORDER BY pkey; --enable_ps2_protocol +--enable_cursor_protocol --enable_query_log eval $COMMAND_BEFORE_LOAD_DATA; @@ -72,9 +74,11 @@ TRUNCATE TABLE mysql.general_log; --connection master_1 --disable_query_log --echo LOAD DATA $OPTION_LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' $OPTION_WORD INTO TABLE tbl_a; +--disable_cursor_protocol --disable_ps2_protocol eval LOAD DATA $OPTION_LOCAL INFILE '$MYSQLTEST_VARDIR/tmp/spider_outfile.tsv' $OPTION_WORD INTO TABLE tbl_a; --enable_ps2_protocol +--enable_cursor_protocol --enable_query_log --remove_file $MYSQLTEST_VARDIR/tmp/spider_outfile.tsv diff --git a/storage/tokudb/mysql-test/rpl/extra/rpl_tests/rpl_parallel_load_tokudb.test b/storage/tokudb/mysql-test/rpl/extra/rpl_tests/rpl_parallel_load_tokudb.test index f354d49190a..c1be155b70b 100644 --- a/storage/tokudb/mysql-test/rpl/extra/rpl_tests/rpl_parallel_load_tokudb.test +++ b/storage/tokudb/mysql-test/rpl/extra/rpl_tests/rpl_parallel_load_tokudb.test @@ -272,6 +272,7 @@ let $MYSQLD_DATADIR= `select @@datadir`; use test; let $benchmark_file= `select replace(concat("benchmark_",uuid(),".out"),"-","_")`; --replace_regex /benchmark_.*.out/benchmark.out/ +--disable_cursor_protocol --disable_ps2_protocol eval select * from test1.benchmark into outfile '$benchmark_file'; --enable_ps2_protocol @@ -289,6 +290,7 @@ eval select time_to_sec(@m_1) - time_to_sec(@m_0) as 'delta_m', time_to_sec(@s_1) - time_to_sec(@s_0) as 'delta_s', time_to_sec(@s_m1) - time_to_sec(@s_m0) as 'delta_sm' into outfile '$delta_file'; --enable_ps2_protocol +--enable_cursor_protocol # # Consistency verification diff --git a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc1_lookup1.result b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc1_lookup1.result index bfd640e52e9..b5d1251efef 100644 --- a/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc1_lookup1.result +++ b/storage/tokudb/mysql-test/rpl/r/rpl_tokudb_update_pk_uc1_lookup1.result @@ -21,8 +21,10 @@ update t set b=b+2 where a=1; update t set b=b+3 where a=4; update t set b=b+4 where a=3; update t set b=b+1 where 1<=a and a<=3; +--disable_cursor_protocol select unix_timestamp() into @tstart; select unix_timestamp() into @tend; +--enable_cursor_protocol select @tend-@tstart <= 5; @tend-@tstart <= 5 0 diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_delete_pk.test b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_delete_pk.test index bedeb9513be..2f776730506 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_delete_pk.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_parallel_tokudb_delete_pk.test @@ -39,14 +39,18 @@ source include/diff_tables.inc; # delete a row connection master; delete from t where a=2; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol # wait for the delete to finish on the slave connection master; sync_slave_with_master; # source include/sync_slave_sql_with_master.inc; connection master; +--disable_cursor_protocol select unix_timestamp() into @tend; +--enable_cursor_protocol select @tend-@tstart <= 5; # assert no delay in the delete time # diff tables diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk.test index bedeb9513be..2f776730506 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk.test @@ -39,14 +39,18 @@ source include/diff_tables.inc; # delete a row connection master; delete from t where a=2; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol # wait for the delete to finish on the slave connection master; sync_slave_with_master; # source include/sync_slave_sql_with_master.inc; connection master; +--disable_cursor_protocol select unix_timestamp() into @tend; +--enable_cursor_protocol select @tend-@tstart <= 5; # assert no delay in the delete time # diff tables diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk_lookup1.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk_lookup1.test index 9e9aaede416..076590696aa 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk_lookup1.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_delete_pk_lookup1.test @@ -40,7 +40,9 @@ source include/diff_tables.inc; # delete a row connection master; delete from t where a=2; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol # wait for the delete to finish on the slave connection master; @@ -48,7 +50,9 @@ sync_slave_with_master; # source include/sync_slave_sql_with_master.inc; connection master; +--disable_cursor_protocol select unix_timestamp() into @tend; +--enable_cursor_protocol select @tend-@tstart > 5; # assert big delay in the delete time # diff tables diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ff.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ff.test index 7b3e8f0c0d3..5b76669c4d1 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ff.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ff.test @@ -22,7 +22,9 @@ connection master; # select @@autocommit; eval create table t (a bigint not null, primary key(a)) engine=$engine; # show create table t; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol insert into t values (1); insert into t values (2),(3); insert into t values (4); diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ft.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ft.test index 7b3e8f0c0d3..5b76669c4d1 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ft.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_ft.test @@ -22,7 +22,9 @@ connection master; # select @@autocommit; eval create table t (a bigint not null, primary key(a)) engine=$engine; # show create table t; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol insert into t values (1); insert into t values (2),(3); insert into t values (4); diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tf.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tf.test index 7b3e8f0c0d3..5b76669c4d1 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tf.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tf.test @@ -22,7 +22,9 @@ connection master; # select @@autocommit; eval create table t (a bigint not null, primary key(a)) engine=$engine; # show create table t; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol insert into t values (1); insert into t values (2),(3); insert into t values (4); diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tt.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tt.test index 7b3e8f0c0d3..5b76669c4d1 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tt.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_read_only_tt.test @@ -22,7 +22,9 @@ connection master; # select @@autocommit; eval create table t (a bigint not null, primary key(a)) engine=$engine; # show create table t; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol insert into t values (1); insert into t values (2),(3); insert into t values (4); diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup0.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup0.test index 6dd9b660eed..38965783651 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup0.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup0.test @@ -42,14 +42,18 @@ update t set b=b+2 where a=1; update t set b=b+3 where a=4; update t set b=b+4 where a=3; update t set b=b+1 where 1<=a and a<=3; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol # wait for the delete to finish on the slave connection master; sync_slave_with_master; # source include/sync_slave_sql_with_master.inc; connection master; +--disable_cursor_protocol select unix_timestamp() into @tend; +--enable_cursor_protocol select @tend-@tstart <= 5; # assert no delay in the delete time connection slave; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup1.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup1.test index 6dd9b660eed..38965783651 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup1.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc0_lookup1.test @@ -42,14 +42,18 @@ update t set b=b+2 where a=1; update t set b=b+3 where a=4; update t set b=b+4 where a=3; update t set b=b+1 where 1<=a and a<=3; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol # wait for the delete to finish on the slave connection master; sync_slave_with_master; # source include/sync_slave_sql_with_master.inc; connection master; +--disable_cursor_protocol select unix_timestamp() into @tend; +--enable_cursor_protocol select @tend-@tstart <= 5; # assert no delay in the delete time connection slave; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup0.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup0.test index 6dd9b660eed..38965783651 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup0.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup0.test @@ -42,14 +42,18 @@ update t set b=b+2 where a=1; update t set b=b+3 where a=4; update t set b=b+4 where a=3; update t set b=b+1 where 1<=a and a<=3; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol # wait for the delete to finish on the slave connection master; sync_slave_with_master; # source include/sync_slave_sql_with_master.inc; connection master; +--disable_cursor_protocol select unix_timestamp() into @tend; +--enable_cursor_protocol select @tend-@tstart <= 5; # assert no delay in the delete time connection slave; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup1.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup1.test index 6dd9b660eed..38965783651 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup1.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_pk_uc1_lookup1.test @@ -42,14 +42,18 @@ update t set b=b+2 where a=1; update t set b=b+3 where a=4; update t set b=b+4 where a=3; update t set b=b+1 where 1<=a and a<=3; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol # wait for the delete to finish on the slave connection master; sync_slave_with_master; # source include/sync_slave_sql_with_master.inc; connection master; +--disable_cursor_protocol select unix_timestamp() into @tend; +--enable_cursor_protocol select @tend-@tstart <= 5; # assert no delay in the delete time connection slave; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup0.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup0.test index 93fef3699d9..ab012da4aaa 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup0.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup0.test @@ -42,14 +42,18 @@ update t set b=b+2 where a=1; update t set b=b+3 where a=4; update t set b=b+4 where a=3; update t set b=b+1 where 1<=a and a<=3; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol # wait for the delete to finish on the slave connection master; sync_slave_with_master; # source include/sync_slave_sql_with_master.inc; connection master; +--disable_cursor_protocol select unix_timestamp() into @tend; +--enable_cursor_protocol select @tend-@tstart <= 5; # assert no delay in the delete time connection slave; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup1.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup1.test index c8976db8ccd..3d6eeb9f4ef 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup1.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_update_unique_uc0_lookup1.test @@ -42,14 +42,18 @@ update t set b=b+2 where a=1; update t set b=b+3 where a=4; update t set b=b+4 where a=3; update t set b=b+1 where 1<=a and a<=3; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol # wait for the delete to finish on the slave connection master; sync_slave_with_master; # source include/sync_slave_sql_with_master.inc; connection master; +--disable_cursor_protocol select unix_timestamp() into @tend; +--enable_cursor_protocol select @tend-@tstart <= 5; # assert no delay in the delete time connection slave; diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk.test index 0ed12b34e1f..4bb41c7fba7 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk.test @@ -22,7 +22,9 @@ connection master; # select @@autocommit; eval create table t (a bigint not null, primary key(a)) engine=$engine; # show create table t; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol insert into t values (1); insert into t values (2),(3); insert into t values (4); diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk_uc1.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk_uc1.test index 0ed12b34e1f..4bb41c7fba7 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk_uc1.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_pk_uc1.test @@ -22,7 +22,9 @@ connection master; # select @@autocommit; eval create table t (a bigint not null, primary key(a)) engine=$engine; # show create table t; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol insert into t values (1); insert into t values (2),(3); insert into t values (4); diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique.test index fc4c9597dac..7ccaf72cdb7 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique.test @@ -22,7 +22,9 @@ connection master; # select @@autocommit; eval create table t (a bigint not null, b bigint not null, primary key(a), unique key(b)) engine=$engine; # show create table t; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol insert into t values (1,2); insert into t values (2,3),(3,4); insert into t values (4,5); diff --git a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique_uc1.test b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique_uc1.test index fc4c9597dac..7ccaf72cdb7 100644 --- a/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique_uc1.test +++ b/storage/tokudb/mysql-test/rpl/t/rpl_tokudb_write_unique_uc1.test @@ -22,7 +22,9 @@ connection master; # select @@autocommit; eval create table t (a bigint not null, b bigint not null, primary key(a), unique key(b)) engine=$engine; # show create table t; +--disable_cursor_protocol select unix_timestamp() into @tstart; +--enable_cursor_protocol insert into t values (1,2); insert into t values (2,3),(3,4); insert into t values (4,5); diff --git a/storage/tokudb/mysql-test/tokudb/t/ext_key_1_innodb.test b/storage/tokudb/mysql-test/tokudb/t/ext_key_1_innodb.test index 535f887c929..6b895578de6 100644 --- a/storage/tokudb/mysql-test/tokudb/t/ext_key_1_innodb.test +++ b/storage/tokudb/mysql-test/tokudb/t/ext_key_1_innodb.test @@ -9,7 +9,9 @@ create table t (id int not null, x int not null, y int not null, primary key(id) insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4); +--disable_cursor_protocol --disable_ps2_protocol + explain select x,id from t force index (x) where x=0 and id=0; flush status; select x,id from t force index (x) where x=0 and id=0; @@ -40,5 +42,6 @@ flush status; select x,id from t force index (x) where x=2 and id=0; show status like 'handler_read%'; --enable_ps2_protocol +--enable_cursor_protocol drop table t; diff --git a/storage/tokudb/mysql-test/tokudb/t/ext_key_1_tokudb.test b/storage/tokudb/mysql-test/tokudb/t/ext_key_1_tokudb.test index e9c82405262..e6e6d114698 100644 --- a/storage/tokudb/mysql-test/tokudb/t/ext_key_1_tokudb.test +++ b/storage/tokudb/mysql-test/tokudb/t/ext_key_1_tokudb.test @@ -8,7 +8,9 @@ create table t (id int not null, x int not null, y int not null, primary key(id) insert into t values (0,0,0),(1,1,1),(2,2,2),(3,2,3),(4,2,4); +--disable_cursor_protocol --disable_ps2_protocol + explain select x,id from t force index (x) where x=0 and id=0; flush status; select x,id from t force index (x) where x=0 and id=0; @@ -39,5 +41,6 @@ flush status; select x,id from t force index (x) where x=2 and id=0; show status like 'handler_read%'; --enable_ps2_protocol +--enable_cursor_protocol drop table t; diff --git a/storage/tokudb/mysql-test/tokudb/t/ext_key_2_innodb.test b/storage/tokudb/mysql-test/tokudb/t/ext_key_2_innodb.test index e5722dce563..89b021cbf34 100644 --- a/storage/tokudb/mysql-test/tokudb/t/ext_key_2_innodb.test +++ b/storage/tokudb/mysql-test/tokudb/t/ext_key_2_innodb.test @@ -9,7 +9,9 @@ create table t (a int not null, b int not null, c int not null, d int not null, insert into t values (0,0,0,0),(0,1,0,1); +--disable_cursor_protocol --disable_ps2_protocol + explain select c,a,b from t where c=0 and a=0 and b=1; flush status; select c,a,b from t where c=0 and a=0 and b=1; @@ -20,5 +22,6 @@ flush status; select c,a,b from t force index (c) where c=0 and a=0 and b=1; show status like 'handler_read%'; --enable_ps2_protocol +--enable_cursor_protocol drop table t; diff --git a/storage/tokudb/mysql-test/tokudb/t/ext_key_2_tokudb.test b/storage/tokudb/mysql-test/tokudb/t/ext_key_2_tokudb.test index d68a1bcf7f7..162a1cf624e 100644 --- a/storage/tokudb/mysql-test/tokudb/t/ext_key_2_tokudb.test +++ b/storage/tokudb/mysql-test/tokudb/t/ext_key_2_tokudb.test @@ -8,7 +8,9 @@ create table t (a int not null, b int not null, c int not null, d int not null, insert into t values (0,0,0,0),(0,1,0,1); +--disable_cursor_protocol --disable_ps2_protocol + explain select c,a,b from t where c=0 and a=0 and b=1; flush status; select c,a,b from t where c=0 and a=0 and b=1; @@ -19,5 +21,6 @@ flush status; select c,a,b from t force index (c) where c=0 and a=0 and b=1; show status like 'handler_read%'; --enable_ps2_protocol +--enable_cursor_protocol drop table t; diff --git a/storage/tokudb/mysql-test/tokudb/t/rows-32m-0.test b/storage/tokudb/mysql-test/tokudb/t/rows-32m-0.test index 58a5ac1b8e3..b3317f0c666 100644 --- a/storage/tokudb/mysql-test/tokudb/t/rows-32m-0.test +++ b/storage/tokudb/mysql-test/tokudb/t/rows-32m-0.test @@ -12,7 +12,9 @@ drop table if exists t; create table t (id int not null primary key, v longblob not null); +--disable_cursor_protocol select @@max_allowed_packet into @my_max_allowed_packet; +--enable_cursor_protocol --disable_warnings set global max_allowed_packet=100000000; --enable_warnings diff --git a/storage/tokudb/mysql-test/tokudb/t/rows-32m-1.test b/storage/tokudb/mysql-test/tokudb/t/rows-32m-1.test index 39feddf77be..8c2f29687d3 100644 --- a/storage/tokudb/mysql-test/tokudb/t/rows-32m-1.test +++ b/storage/tokudb/mysql-test/tokudb/t/rows-32m-1.test @@ -12,7 +12,9 @@ drop table if exists t; create table t (id int not null primary key, v0 longblob not null,v1 longblob not null); +--disable_cursor_protocol select @@max_allowed_packet into @my_max_allowed_packet; +--enable_cursor_protocol --disable_warnings set global max_allowed_packet=100000000; --enable_warnings diff --git a/storage/tokudb/mysql-test/tokudb/t/rows-32m-rand-insert.test b/storage/tokudb/mysql-test/tokudb/t/rows-32m-rand-insert.test index c26e79913d0..4c03852d280 100644 --- a/storage/tokudb/mysql-test/tokudb/t/rows-32m-rand-insert.test +++ b/storage/tokudb/mysql-test/tokudb/t/rows-32m-rand-insert.test @@ -10,7 +10,9 @@ drop table if exists t; create table t (id int not null primary key, v longblob not null); +--disable_cursor_protocol select @@max_allowed_packet into @my_max_allowed_packet; +--enable_cursor_protocol --disable_warnings set global max_allowed_packet=100000000; --enable_warnings diff --git a/storage/tokudb/mysql-test/tokudb/t/rows-32m-seq-insert.test b/storage/tokudb/mysql-test/tokudb/t/rows-32m-seq-insert.test index 7ee84c69eca..184ecdf26c4 100644 --- a/storage/tokudb/mysql-test/tokudb/t/rows-32m-seq-insert.test +++ b/storage/tokudb/mysql-test/tokudb/t/rows-32m-seq-insert.test @@ -10,7 +10,9 @@ drop table if exists t; create table t (id int not null auto_increment primary key, v longblob not null); +--disable_cursor_protocol select @@max_allowed_packet into @my_max_allowed_packet; +--enable_cursor_protocol --disable_warnings set global max_allowed_packet=100000000; --enable_warnings diff --git a/storage/tokudb/mysql-test/tokudb/t/type_date.test b/storage/tokudb/mysql-test/tokudb/t/type_date.test index ed330a2d748..9799dcebade 100644 --- a/storage/tokudb/mysql-test/tokudb/t/type_date.test +++ b/storage/tokudb/mysql-test/tokudb/t/type_date.test @@ -203,12 +203,15 @@ CREATE TABLE t2 (a DATE); CREATE INDEX i ON t1 (a); INSERT INTO t1 VALUES ('1000-00-00'),('1000-00-00'); INSERT INTO t2 VALUES ('1000-00-00'),('1000-00-00'); +#Check after fix MDEV-31516 +--disable_cursor_protocol SELECT * FROM t1 WHERE a = '1000-00-00'; SELECT * FROM t2 WHERE a = '1000-00-00'; SET SQL_MODE=TRADITIONAL; EXPLAIN SELECT * FROM t1 WHERE a = '1000-00-00'; SELECT * FROM t1 WHERE a = '1000-00-00'; SELECT * FROM t2 WHERE a = '1000-00-00'; +--enable_cursor_protocol --error ER_TRUNCATED_WRONG_VALUE INSERT INTO t1 VALUES ('1000-00-00'); SET SQL_MODE=DEFAULT; diff --git a/storage/tokudb/mysql-test/tokudb/t/type_float.test b/storage/tokudb/mysql-test/tokudb/t/type_float.test index 8c83913f1c8..7cd7f7cbe50 100644 --- a/storage/tokudb/mysql-test/tokudb/t/type_float.test +++ b/storage/tokudb/mysql-test/tokudb/t/type_float.test @@ -324,8 +324,10 @@ let $nine_65= select format(-1.7976931348623157E+307,256) as foo; select least(-1.1111111111111111111111111, - group_concat(1.7976931348623157E+308)) as foo; +--disable_cursor_protocol eval select concat((truncate((-1.7976931348623157E+307),(0x1e))), ($nine_65)) into @a; +--enable_cursor_protocol --enable_result_log --echo End of 5.0 tests diff --git a/storage/tokudb/mysql-test/tokudb/t/type_newdecimal.test b/storage/tokudb/mysql-test/tokudb/t/type_newdecimal.test index 3d44a5b78f4..bb5e7fd5568 100644 --- a/storage/tokudb/mysql-test/tokudb/t/type_newdecimal.test +++ b/storage/tokudb/mysql-test/tokudb/t/type_newdecimal.test @@ -611,7 +611,10 @@ select round(99999999999999999.999,3); select round(-99999999999999999.999,3); #-- should return -100000000000000000.000 # +#enable after fix MDEV-31729 +--disable_cursor_protocol select truncate(99999999999999999999999999999999999999,49); +--enable_cursor_protocol #-- should return 99999999999999999999999999999999999999.000 # select truncate(99.999999999999999999999999999999999999,49); @@ -1268,6 +1271,8 @@ let $nine_81= 999999999999999999999999999999999999999999999999999999999999999999999999999999999; eval SELECT substring(('M') FROM ($nine_81)) AS foo; +#enable after fix MDEV-31729 +--disable_cursor_protocol eval SELECT min($nine_81) AS foo; eval SELECT multipolygonfromtext(('4294967294.1'),($nine_81)) AS foo; eval SELECT convert(($nine_81), decimal(30,30)) AS foo; @@ -1279,6 +1284,7 @@ eval SELECT date_sub(($nine_81), day_minute) AS foo; eval SELECT truncate($nine_81, 28) AS foo; +--enable_cursor_protocol --echo End of 5.0 tests diff --git a/storage/tokudb/mysql-test/tokudb/t/type_temporal_fractional.test b/storage/tokudb/mysql-test/tokudb/t/type_temporal_fractional.test index 06794257969..00b3094f4dd 100644 --- a/storage/tokudb/mysql-test/tokudb/t/type_temporal_fractional.test +++ b/storage/tokudb/mysql-test/tokudb/t/type_temporal_fractional.test @@ -1907,7 +1907,9 @@ SELECT * FROM t1 WHERE a=@a; SET @a=112233.123456e0; SELECT * FROM t1 WHERE a=@a; SET @a=NULL; +--disable_cursor_protocol SELECT a INTO @a FROM t1 LIMIT 1; +--enable_cursor_protocol SELECT @a; DROP TABLE t1; @@ -3896,7 +3898,9 @@ SELECT * FROM t1 WHERE a=@a; SET @a=0.123456e0; SELECT * FROM t1 WHERE a=@a; SET @a=NULL; +--disable_cursor_protocol SELECT a INTO @a FROM t1 LIMIT 1; +--enable_cursor_protocol SELECT @a; DROP TABLE t1; # MEMORY does not support BLOB @@ -5716,7 +5720,9 @@ SELECT @a; # Nothing is found, not enough precision for DOUBLE SELECT * FROM t1 WHERE a=@a; SET @a=NULL; +--disable_cursor_protocol SELECT a INTO @a FROM t1 LIMIT 1; +--enable_cursor_protocol SELECT @a; DROP TABLE t1; # MEMORY does not support BLOB diff --git a/storage/tokudb/mysql-test/tokudb/t/type_year.test b/storage/tokudb/mysql-test/tokudb/t/type_year.test index 048758268c8..6abb53156cf 100644 --- a/storage/tokudb/mysql-test/tokudb/t/type_year.test +++ b/storage/tokudb/mysql-test/tokudb/t/type_year.test @@ -158,7 +158,10 @@ DROP TABLE t1; CREATE TABLE t1(c1 YEAR(4)); INSERT INTO t1 VALUES (1901),(2155),(0000); SELECT * FROM t1; +#Check after fix MDEV-31730 +--disable_cursor_protocol SELECT COUNT(*) AS total_rows, MIN(c1) AS min_value, MAX(c1) FROM t1; +--enable_cursor_protocol DROP TABLE t1; --echo # diff --git a/storage/tokudb/mysql-test/tokudb_add_index/t/falcon_bug_23818_A.test b/storage/tokudb/mysql-test/tokudb_add_index/t/falcon_bug_23818_A.test index f4a931dbe81..72b7aadf898 100644 --- a/storage/tokudb/mysql-test/tokudb_add_index/t/falcon_bug_23818_A.test +++ b/storage/tokudb/mysql-test/tokudb_add_index/t/falcon_bug_23818_A.test @@ -19,9 +19,11 @@ set @a = 32710; let $k = 200; while ($k) { + --disable_cursor_protocol SELECT @a + 1 into @a; SELECT rand(@a) * DEGREES(@a) into @b; SELECT FLOOR(MOD(@b,255)) into @c; + --enable_cursor_protocol SELECT @a, @b, @c; UPDATE t1 SET a = a + 1; UPDATE t1 SET b = repeat(hex(@c), rand(@c) * 550); diff --git a/storage/tokudb/mysql-test/tokudb_add_index/t/falcon_bug_23818_B.test b/storage/tokudb/mysql-test/tokudb_add_index/t/falcon_bug_23818_B.test index 96612a99804..725db98799b 100644 --- a/storage/tokudb/mysql-test/tokudb_add_index/t/falcon_bug_23818_B.test +++ b/storage/tokudb/mysql-test/tokudb_add_index/t/falcon_bug_23818_B.test @@ -19,9 +19,11 @@ set @a = 5510; let $k = 200; while ($k) { + --disable_cursor_protocol SELECT @a + 1 into @a; SELECT rand(@a) * DEGREES(@a) into @b; SELECT FLOOR(MOD(@b,255)) into @c; + --enable_cursor_protocol SELECT @a, @b, @c; UPDATE t1 SET a = a + 1; UPDATE t1 SET b = repeat(hex(@c), rand(@c) * 550); diff --git a/storage/tokudb/mysql-test/tokudb_add_index/t/falcon_bug_23818_C.test b/storage/tokudb/mysql-test/tokudb_add_index/t/falcon_bug_23818_C.test index 79f19c54d39..72fd4adfc9d 100644 --- a/storage/tokudb/mysql-test/tokudb_add_index/t/falcon_bug_23818_C.test +++ b/storage/tokudb/mysql-test/tokudb_add_index/t/falcon_bug_23818_C.test @@ -19,9 +19,11 @@ set @a = 28410; let $k = 200; while ($k) { + --disable_cursor_protocol SELECT @a + 1 into @a; SELECT rand(@a) * DEGREES(@a) into @b; SELECT FLOOR(MOD(@b,255)) into @c; + --enable_cursor_protocol SELECT @a, @b, @c; UPDATE t1 SET a = a + 1; UPDATE t1 SET b = repeat(hex(@c), rand(@c) * 550); From 841dc07ee112cc7a7a790690e94f4ea119af9c1e Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 20 Sep 2024 09:23:33 +0400 Subject: [PATCH 06/62] MDEV-28386 UBSAN: runtime error: negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strntoull_8bit on SELECT ... OCT The code in my_strntoull_8bit() and my_strntoull_mb2_or_mb4() could hit undefinite behavior by negating of LONGLONG_MIN. Fixing the code to avoid this. --- mysql-test/main/ctype_ucs.result | 9 +++++++++ mysql-test/main/ctype_ucs.test | 9 +++++++++ mysql-test/main/func_str.result | 13 +++++++++++++ mysql-test/main/func_str.test | 13 +++++++++++++ strings/ctype-simple.c | 5 ++++- strings/ctype-ucs2.c | 5 ++++- 6 files changed, 52 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/ctype_ucs.result b/mysql-test/main/ctype_ucs.result index 887c01df7e9..a603d07b08a 100644 --- a/mysql-test/main/ctype_ucs.result +++ b/mysql-test/main/ctype_ucs.result @@ -6540,5 +6540,14 @@ DROP VIEW v1; DROP TABLE t1; SET NAMES utf8mb3; # +# MDEV-28386 UBSAN: runtime error: negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strntoull_8bit on SELECT ... OCT +# +CREATE TABLE t1 (c TEXT CHARACTER SET ucs2); +INSERT INTO t1 VALUES ('-9223372036854775808.5'); +SELECT OCT(c) FROM t1; +OCT(c) +1000000000000000000000 +DROP TABLE t1; +# # End of 10.5 tests # diff --git a/mysql-test/main/ctype_ucs.test b/mysql-test/main/ctype_ucs.test index 7144f0af5cc..bf967ba7619 100644 --- a/mysql-test/main/ctype_ucs.test +++ b/mysql-test/main/ctype_ucs.test @@ -1217,6 +1217,15 @@ DROP VIEW v1; DROP TABLE t1; SET NAMES utf8mb3; +--echo # +--echo # MDEV-28386 UBSAN: runtime error: negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strntoull_8bit on SELECT ... OCT +--echo # + +CREATE TABLE t1 (c TEXT CHARACTER SET ucs2); +INSERT INTO t1 VALUES ('-9223372036854775808.5'); +SELECT OCT(c) FROM t1; +DROP TABLE t1; + --echo # --echo # End of 10.5 tests diff --git a/mysql-test/main/func_str.result b/mysql-test/main/func_str.result index 52bfd3f0e3e..7aa248bffd4 100644 --- a/mysql-test/main/func_str.result +++ b/mysql-test/main/func_str.result @@ -5317,5 +5317,18 @@ SELECT SUBSTR(0,@a) FROM t; SUBSTR(0,@a) DROP TABLE t; # +# MDEV-28386 UBSAN: runtime error: negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strntoull_8bit on SELECT ... OCT +# +CREATE TABLE t1 (c BLOB); +INSERT INTO t1 VALUES ('-9223372036854775808.5'); +SELECT OCT(c) FROM t1; +OCT(c) +1000000000000000000000 +SELECT BIN(c) FROM t1; +BIN(c) +1000000000000000000000000000000000000000000000000000000000000000 +DROP TABLE t1; +DO OCT(-9223372036854775808); +# # End of 10.5 tests # diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test index 3c9360a9c40..952d061c30f 100644 --- a/mysql-test/main/func_str.test +++ b/mysql-test/main/func_str.test @@ -2358,6 +2358,19 @@ CREATE TABLE t (c1 INT,c2 CHAR); SELECT SUBSTR(0,@a) FROM t; DROP TABLE t; +--echo # +--echo # MDEV-28386 UBSAN: runtime error: negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_strntoull_8bit on SELECT ... OCT +--echo # + +CREATE TABLE t1 (c BLOB); +INSERT INTO t1 VALUES ('-9223372036854775808.5'); +SELECT OCT(c) FROM t1; +SELECT BIN(c) FROM t1; +DROP TABLE t1; + +DO OCT(-9223372036854775808); + + --echo # --echo # End of 10.5 tests --echo # diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index a50c570ec6b..d40e3abdcc5 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -758,7 +758,10 @@ ulonglong my_strntoull_8bit(CHARSET_INFO *cs, return (~(ulonglong) 0); } - return (negative ? -((longlong) i) : (longlong) i); + /* Avoid undefinite behavior - negation of LONGLONG_MIN */ + return negative && (longlong) i != LONGLONG_MIN ? + -((longlong) i) : + (longlong) i; noconv: err[0]= EDOM; diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index d1ca32a8e62..fb33d8cc764 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -616,7 +616,10 @@ bs: return (~(ulonglong) 0); } - return (negative ? -((longlong) res) : (longlong) res); + /* Avoid undefinite behavior - negation of LONGLONG_MIN */ + return negative && (longlong) res != LONGLONG_MIN ? + -((longlong) res) : + (longlong) res; } From 9ac8172ac386c6506be3624121d672ec042c4ce2 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 20 Sep 2024 11:47:56 +0400 Subject: [PATCH 07/62] MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32 The code in my_strtoll10_mb2 and my_strtoll10_utf32 could hit undefinite behavior by negation of LONGLONG_MIN. Fixing to avoid this. Also, fixing my_strtoll10() in the same style. The previous reduction produced a redundant warning on CAST(_latin1'-9223372036854775808' AS SIGNED) --- mysql-test/main/ctype_latin1.result | 6 ++++++ mysql-test/main/ctype_latin1.test | 7 +++++++ mysql-test/main/ctype_ucs.result | 6 ++++++ mysql-test/main/ctype_ucs.test | 5 +++++ mysql-test/main/ctype_utf32.result | 9 +++++++++ mysql-test/main/ctype_utf32.test | 11 +++++++++++ strings/ctype-ucs2.c | 4 ++++ strings/my_strtoll10.c | 4 +++- 8 files changed, 51 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/ctype_latin1.result b/mysql-test/main/ctype_latin1.result index 4548c076c1b..7ebfcea6e90 100644 --- a/mysql-test/main/ctype_latin1.result +++ b/mysql-test/main/ctype_latin1.result @@ -8975,5 +8975,11 @@ CAST(_latin1 0x61FF62 AS INT) Warnings: Warning 1292 Truncated incorrect INTEGER value: 'ab' # +# MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32 +# +SELECT CAST(CONVERT('-9223372036854775808' USING latin1) AS SIGNED) AS c1; +c1 +-9223372036854775808 +# # End of 10.5 tests # diff --git a/mysql-test/main/ctype_latin1.test b/mysql-test/main/ctype_latin1.test index b00dc374a05..6b3d2dd744f 100644 --- a/mysql-test/main/ctype_latin1.test +++ b/mysql-test/main/ctype_latin1.test @@ -501,6 +501,13 @@ SELECT CAST(_latin1 0x617E62 AS INT); SELECT CAST(_latin1 0x61FF62 AS INT); +--echo # +--echo # MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32 +--echo # + +SELECT CAST(CONVERT('-9223372036854775808' USING latin1) AS SIGNED) AS c1; + + --echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/ctype_ucs.result b/mysql-test/main/ctype_ucs.result index a603d07b08a..de73f41c5a7 100644 --- a/mysql-test/main/ctype_ucs.result +++ b/mysql-test/main/ctype_ucs.result @@ -6549,5 +6549,11 @@ OCT(c) 1000000000000000000000 DROP TABLE t1; # +# MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32 +# +SELECT CAST(CONVERT('-9223372036854775808' USING ucs2) AS SIGNED) AS c1; +c1 +-9223372036854775808 +# # End of 10.5 tests # diff --git a/mysql-test/main/ctype_ucs.test b/mysql-test/main/ctype_ucs.test index bf967ba7619..84ee8c5387c 100644 --- a/mysql-test/main/ctype_ucs.test +++ b/mysql-test/main/ctype_ucs.test @@ -1226,6 +1226,11 @@ INSERT INTO t1 VALUES ('-9223372036854775808.5'); SELECT OCT(c) FROM t1; DROP TABLE t1; +--echo # +--echo # MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32 +--echo # + +SELECT CAST(CONVERT('-9223372036854775808' USING ucs2) AS SIGNED) AS c1; --echo # --echo # End of 10.5 tests diff --git a/mysql-test/main/ctype_utf32.result b/mysql-test/main/ctype_utf32.result index 46a8a5fed0f..546a7415603 100644 --- a/mysql-test/main/ctype_utf32.result +++ b/mysql-test/main/ctype_utf32.result @@ -3024,3 +3024,12 @@ HEX(DATE_FORMAT(TIME'11:22:33',@format)) # # End of 10.4 tests # +# +# MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32 +# +SELECT CAST(CONVERT('-9223372036854775808' USING utf32) AS SIGNED) AS c1; +c1 +-9223372036854775808 +# +# End of 10.5 tests +# diff --git a/mysql-test/main/ctype_utf32.test b/mysql-test/main/ctype_utf32.test index f35a94e909c..4a1f27260c6 100644 --- a/mysql-test/main/ctype_utf32.test +++ b/mysql-test/main/ctype_utf32.test @@ -1162,3 +1162,14 @@ SELECT HEX(DATE_FORMAT(TIME'11:22:33',@format)); --echo # --enable_service_connection + + +--echo # +--echo # MDEV-31221 UBSAN runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int' in my_strtoll10_utf32 +--echo # + +SELECT CAST(CONVERT('-9223372036854775808' USING utf32) AS SIGNED) AS c1; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index fb33d8cc764..99f4f73ff78 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1011,6 +1011,8 @@ end4: { if (li > MAX_NEGATIVE_NUMBER) goto overflow; + if (li == MAX_NEGATIVE_NUMBER) // Avoid undefinite behavior in negation + return LONGLONG_MIN; return -((longlong) li); } return (longlong) li; @@ -2574,6 +2576,8 @@ end4: { if (li > MAX_NEGATIVE_NUMBER) goto overflow; + if (li == MAX_NEGATIVE_NUMBER) // Avoid undefinite behavior in negation + return LONGLONG_MIN; return -((longlong) li); } return (longlong) li; diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c index 74baef080eb..6c4ccea0b21 100644 --- a/strings/my_strtoll10.c +++ b/strings/my_strtoll10.c @@ -241,8 +241,10 @@ end4: *endptr= (char*) s; if (negative) { - if (li >= MAX_NEGATIVE_NUMBER) // Avoid undefined behavior + if (li > MAX_NEGATIVE_NUMBER) goto overflow; + if (li == MAX_NEGATIVE_NUMBER) // Avoid undefined behavior + return LONGLONG_MIN; return -((longlong) li); } return (longlong) li; From 607fc153939fd6314dcde60d565cfd20676a01f9 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 20 Sep 2024 14:10:27 +0400 Subject: [PATCH 08/62] MDEV-31302 Assertion `mon > 0 && mon < 13' failed in my_time_t sec_since_epoch(int, int, int, int, int, int) The code erroneously called sec_since_epoch() for dates with zeros, e.g. '2024-00-01'. Fixi: adding a test that the date does not have zeros before calling TIME_to_native(). --- mysql-test/main/func_time.result | 11 +++++++++++ mysql-test/main/func_time.test | 11 +++++++++++ sql/sql_type.cc | 1 + 3 files changed, 23 insertions(+) diff --git a/mysql-test/main/func_time.result b/mysql-test/main/func_time.result index eaf30f5f925..3982342b4c5 100644 --- a/mysql-test/main/func_time.result +++ b/mysql-test/main/func_time.result @@ -6425,5 +6425,16 @@ Warning 1292 Truncated incorrect time value: '8390000' Warning 1292 Truncated incorrect time value: '8390000' SET @@timestamp= DEFAULT; # +# MDEV-31302 Assertion `mon > 0 && mon < 13' failed in my_time_t sec_since_epoch(int, int, int, int, int, int) +# +CREATE TABLE t1 (a DATE); +SET @@time_zone='+1:00'; +INSERT INTO t1 VALUES ('2024-00-01'); +SELECT UNIX_TIMESTAMP(MAX(a)) AS a FROM t1; +a +NULL +SET @@time_zone=DEFAULT; +DROP TABLE t1; +# # End of 10.5 tests # diff --git a/mysql-test/main/func_time.test b/mysql-test/main/func_time.test index 51b2722d7a0..25a7e31b54d 100644 --- a/mysql-test/main/func_time.test +++ b/mysql-test/main/func_time.test @@ -3262,6 +3262,17 @@ SELECT SET @@timestamp= DEFAULT; +--echo # +--echo # MDEV-31302 Assertion `mon > 0 && mon < 13' failed in my_time_t sec_since_epoch(int, int, int, int, int, int) +--echo # + +CREATE TABLE t1 (a DATE); +SET @@time_zone='+1:00'; +INSERT INTO t1 VALUES ('2024-00-01'); +SELECT UNIX_TIMESTAMP(MAX(a)) AS a FROM t1; +SET @@time_zone=DEFAULT; +DROP TABLE t1; + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql/sql_type.cc b/sql/sql_type.cc index 44475e29bcc..98abf154db4 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -9182,6 +9182,7 @@ Type_handler_timestamp_common::Item_val_native_with_conversion(THD *thd, Datetime dt(thd, item, Datetime::Options(TIME_NO_ZERO_IN_DATE, thd)); return !dt.is_valid_datetime() || + dt.check_date(TIME_NO_ZERO_IN_DATE | TIME_NO_ZERO_DATE) || TIME_to_native(thd, dt.get_mysql_time(), to, item->datetime_precision(thd)); } From 681609d8a045d98a5458dd72e7a6ef87d4298ccb Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 20 Sep 2024 15:07:39 +0400 Subject: [PATCH 09/62] MDEV-32891 Assertion `value <= ((ulonglong) 0xFFFFFFFFL) * 10000ULL' failed in str_to_DDhhmmssff_internal Fixing the wrong assert. --- mysql-test/main/func_extract.result | 8 ++++++++ mysql-test/main/func_extract.test | 7 +++++++ sql-common/my_time.c | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/func_extract.result b/mysql-test/main/func_extract.result index dc71f6ae27a..7c1fd5009ca 100644 --- a/mysql-test/main/func_extract.result +++ b/mysql-test/main/func_extract.result @@ -1470,5 +1470,13 @@ DROP FUNCTION params; DROP FUNCTION select01; DROP FUNCTION select02; # +# MDEV-32891 Assertion `value <= ((ulonglong) 0xFFFFFFFFL) * 10000ULL' failed in str_to_DDhhmmssff_internal +# +SELECT EXTRACT(HOUR_MICROSECOND FROM '42949672955000x1'); +EXTRACT(HOUR_MICROSECOND FROM '42949672955000x1') +NULL +Warnings: +Warning 1292 Incorrect interval value: '42949672955000x1' +# # End of 10.5 tests # diff --git a/mysql-test/main/func_extract.test b/mysql-test/main/func_extract.test index dd808443f58..6167780b9bf 100644 --- a/mysql-test/main/func_extract.test +++ b/mysql-test/main/func_extract.test @@ -511,6 +511,13 @@ DROP FUNCTION params; DROP FUNCTION select01; DROP FUNCTION select02; +--echo # +--echo # MDEV-32891 Assertion `value <= ((ulonglong) 0xFFFFFFFFL) * 10000ULL' failed in str_to_DDhhmmssff_internal +--echo # + +SELECT EXTRACT(HOUR_MICROSECOND FROM '42949672955000x1'); + + --echo # --echo # End of 10.5 tests --echo # diff --git a/sql-common/my_time.c b/sql-common/my_time.c index eff39cd5eae..2f74235614c 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -961,7 +961,7 @@ str_to_DDhhmmssff_internal(my_bool neg, const char *str, size_t length, { /* String given as one number; assume HHMMSS format */ date[0]= 0; - DBUG_ASSERT(value <= ((ulonglong) UINT_MAX32) * 10000ULL); + DBUG_ASSERT(value / 10000 <= ((ulonglong) UINT_MAX32)); date[1]= (ulong) (value/10000); date[2]= (ulong) (value/100 % 100); date[3]= (ulong) (value % 100); From 638c62acac25200aa87f1a10f4b146e9c1fe9ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 23 Sep 2024 12:51:27 +0300 Subject: [PATCH 10/62] MDEV-34983: Remove x86 asm from InnoDB Starting with GCC 7 and clang 15, single-bit operations such as fetch_or(1) & 1 are translated into 80386 instructions such as LOCK BTS, instead of using the generic translation pattern of emitting a loop around LOCK CMPXCHG. Given that the oldest currently supported GNU/Linux distributions ship GCC 7, and that older versions of GCC are out of support, let us remove some work-arounds that are not strictly necessary. If someone compiles the code using an older compiler, it will work but possibly less efficiently. srw_mutex_impl::HOLDER: Changed from 1U<<31 to 1 in order to work around https://github.com/llvm/llvm-project/issues/37322 which is specific to setting the most significant bit. srw_mutex_impl::WAITER: A multiplier of waiting requests. This used to be 1, which would now collide with HOLDER. fil_space_t::set_stopping(): Remove this unused function. In MSVC we need _interlockedbittestandset() for LOCK BTS. --- storage/innobase/include/fil0fil.h | 36 --------------- storage/innobase/include/rw_lock.h | 8 ---- storage/innobase/include/srw_lock.h | 27 +++++++---- storage/innobase/include/trx0rseg.h | 14 ------ storage/innobase/include/trx0trx.h | 16 ------- storage/innobase/sync/srw_lock.cc | 71 ++++++++++------------------- 6 files changed, 42 insertions(+), 130 deletions(-) diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 1be1126f071..ecdd386ffc1 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -528,9 +528,6 @@ public: /** Close each file. Only invoked on fil_system.temp_space. */ void close(); - /** Note that operations on the tablespace must stop. */ - inline void set_stopping(); - /** Drop the tablespace and wait for any pending operations to cease @param id tablespace identifier @param detached_handle pointer to file to be closed later, or nullptr @@ -589,32 +586,14 @@ public: /** Clear the NEEDS_FSYNC flag */ void clear_flush() { -#if defined __GNUC__ && (defined __i386__ || defined __x86_64__) - static_assert(NEEDS_FSYNC == 1U << 28, "compatibility"); - __asm__ __volatile__("lock btrl $28, %0" : "+m" (n_pending)); -#elif defined _MSC_VER && (defined _M_IX86 || defined _M_X64) - static_assert(NEEDS_FSYNC == 1U << 28, "compatibility"); - _interlockedbittestandreset(reinterpret_cast - (&n_pending), 28); -#else n_pending.fetch_and(~NEEDS_FSYNC, std::memory_order_release); -#endif } private: /** Clear the CLOSING flag */ void clear_closing() { -#if defined __GNUC__ && (defined __i386__ || defined __x86_64__) - static_assert(CLOSING == 1U << 29, "compatibility"); - __asm__ __volatile__("lock btrl $29, %0" : "+m" (n_pending)); -#elif defined _MSC_VER && (defined _M_IX86 || defined _M_X64) - static_assert(CLOSING == 1U << 29, "compatibility"); - _interlockedbittestandreset(reinterpret_cast - (&n_pending), 29); -#else n_pending.fetch_and(~CLOSING, std::memory_order_relaxed); -#endif } /** @return pending operations (and flags) */ @@ -1605,21 +1584,6 @@ inline void fil_space_t::reacquire() #endif /* SAFE_MUTEX */ } -/** Note that operations on the tablespace must stop. */ -inline void fil_space_t::set_stopping() -{ - mysql_mutex_assert_owner(&fil_system.mutex); -#if defined __GNUC__ && (defined __i386__ || defined __x86_64__) - static_assert(STOPPING_WRITES == 1U << 30, "compatibility"); - __asm__ __volatile__("lock btsl $30, %0" : "+m" (n_pending)); -#elif defined _MSC_VER && (defined _M_IX86 || defined _M_X64) - static_assert(STOPPING_WRITES == 1U << 30, "compatibility"); - _interlockedbittestandset(reinterpret_cast(&n_pending), 30); -#else - n_pending.fetch_or(STOPPING_WRITES, std::memory_order_relaxed); -#endif -} - /** Flush pending writes from the file system cache to the file. */ template inline void fil_space_t::flush() { diff --git a/storage/innobase/include/rw_lock.h b/storage/innobase/include/rw_lock.h index 4881f2f1d35..ecd994dbbcb 100644 --- a/storage/innobase/include/rw_lock.h +++ b/storage/innobase/include/rw_lock.h @@ -39,15 +39,7 @@ protected: /** Start waiting for an exclusive lock. */ void write_lock_wait_start() { -#if defined __GNUC__ && (defined __i386__ || defined __x86_64__) - static_assert(WRITER_WAITING == 1U << 30, "compatibility"); - __asm__ __volatile__("lock btsl $30, %0" : "+m" (lock)); -#elif defined _MSC_VER && (defined _M_IX86 || defined _M_X64) - static_assert(WRITER_WAITING == 1U << 30, "compatibility"); - _interlockedbittestandset(reinterpret_cast(&lock), 30); -#else lock.fetch_or(WRITER_WAITING, std::memory_order_relaxed); -#endif } /** Start waiting for an exclusive lock. @return current value of the lock word */ diff --git a/storage/innobase/include/srw_lock.h b/storage/innobase/include/srw_lock.h index 3f0fc997fbf..a601d09c91a 100644 --- a/storage/innobase/include/srw_lock.h +++ b/storage/innobase/include/srw_lock.h @@ -92,11 +92,13 @@ template class srw_mutex_impl final { friend ssux_lock_impl; - /** The lock word, containing HOLDER + 1 if the lock is being held, - plus the number of waiters */ + /** The lock word, containing HOLDER + WAITER if the lock is being held, + plus WAITER times the number of waiters */ std::atomic lock; /** Identifies that the lock is being held */ - static constexpr uint32_t HOLDER= 1U << 31; + static constexpr uint32_t HOLDER= 1; + /** Identifies a lock waiter */ + static constexpr uint32_t WAITER= 2; #ifdef SUX_LOCK_GENERIC public: @@ -144,7 +146,7 @@ public: bool wr_lock_try() { uint32_t lk= 0; - return lock.compare_exchange_strong(lk, HOLDER + 1, + return lock.compare_exchange_strong(lk, HOLDER + WAITER, std::memory_order_acquire, std::memory_order_relaxed); } @@ -152,8 +154,9 @@ public: void wr_lock() { if (!wr_lock_try()) wait_and_lock(); } void wr_unlock() { - const uint32_t lk= lock.fetch_sub(HOLDER + 1, std::memory_order_release); - if (lk != HOLDER + 1) + const uint32_t lk= + lock.fetch_sub(HOLDER + WAITER, std::memory_order_release); + if (lk != HOLDER + WAITER) { DBUG_ASSERT(lk & HOLDER); wake(); @@ -269,10 +272,14 @@ public: { writer.wr_lock(); #if defined __i386__||defined __x86_64__||defined _M_IX86||defined _M_X64 - /* On IA-32 and AMD64, this type of fetch_or() can only be implemented - as a loop around LOCK CMPXCHG. In this particular case, setting the - most significant bit using fetch_add() is equivalent, and is - translated into a simple LOCK XADD. */ + /* On IA-32 and AMD64, a fetch_XXX() that needs to return the + previous value of the word state can only be implemented + efficiently for fetch_add() or fetch_sub(), both of which + translate into a 80486 LOCK XADD instruction. Anything else would + translate into a loop around LOCK CMPXCHG. In this particular + case, we know that the bit was previously clear, and therefore + setting (actually toggling) the most significant bit using + fetch_add() or fetch_sub() is equivalent. */ static_assert(WRITER == 1U << 31, "compatibility"); if (uint32_t lk= readers.fetch_add(WRITER, std::memory_order_acquire)) wr_wait(lk); diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h index 24ba845271d..96f8d64eb66 100644 --- a/storage/innobase/include/trx0rseg.h +++ b/storage/innobase/include/trx0rseg.h @@ -85,26 +85,12 @@ private: /** Set the SKIP bit */ void ref_set_skip() { - static_assert(SKIP == 1U, "compatibility"); -#if defined __GNUC__ && (defined __i386__ || defined __x86_64__) - __asm__ __volatile__("lock btsl $0, %0" : "+m" (ref)); -#elif defined _MSC_VER && (defined _M_IX86 || defined _M_X64) - _interlockedbittestandset(reinterpret_cast(&ref), 0); -#else ref.fetch_or(SKIP, std::memory_order_relaxed); -#endif } /** Clear a bit in ref */ void ref_reset_skip() { - static_assert(SKIP == 1U, "compatibility"); -#if defined __GNUC__ && (defined __i386__ || defined __x86_64__) - __asm__ __volatile__("lock btrl $0, %0" : "+m" (ref)); -#elif defined _MSC_VER && (defined _M_IX86 || defined _M_X64) - _interlockedbittestandreset(reinterpret_cast(&ref), 0); -#else ref.fetch_and(~SKIP, std::memory_order_relaxed); -#endif } public: diff --git a/storage/innobase/include/trx0trx.h b/storage/innobase/include/trx0trx.h index 361d58f5663..8cd5996136f 100644 --- a/storage/innobase/include/trx0trx.h +++ b/storage/innobase/include/trx0trx.h @@ -345,15 +345,7 @@ struct trx_lock_t /** Flag the lock owner as a victim in Galera conflict resolution. */ void set_wsrep_victim() { -# if defined __GNUC__ && (defined __i386__ || defined __x86_64__) - /* There is no 8-bit version of the 80386 BTS instruction. - Technically, this is the wrong addressing mode (16-bit), but - there are other data members stored after the byte. */ - __asm__ __volatile__("lock btsw $1, %0" - : "+m" (was_chosen_as_deadlock_victim)); -# else was_chosen_as_deadlock_victim.fetch_or(2); -# endif } #else /* defined(UNIV_DEBUG) || !defined(DBUG_OFF) */ @@ -1038,15 +1030,7 @@ public: void reset_skip_lock_inheritance() { -#if defined __GNUC__ && (defined __i386__ || defined __x86_64__) - __asm__("lock btrl $31, %0" : : "m"(skip_lock_inheritance_and_n_ref)); -#elif defined _MSC_VER && (defined _M_IX86 || defined _M_X64) - _interlockedbittestandreset( - reinterpret_cast(&skip_lock_inheritance_and_n_ref), - 31); -#else skip_lock_inheritance_and_n_ref.fetch_and(~1U << 31); -#endif } /** @return whether the table has lock on diff --git a/storage/innobase/sync/srw_lock.cc b/storage/innobase/sync/srw_lock.cc index eac3db19152..71e3303736d 100644 --- a/storage/innobase/sync/srw_lock.cc +++ b/storage/innobase/sync/srw_lock.cc @@ -269,44 +269,10 @@ template void ssux_lock_impl::wake(); template void srw_mutex_impl::wake(); template void ssux_lock_impl::wake(); -/* - -Unfortunately, compilers targeting IA-32 or AMD64 currently cannot -translate the following single-bit operations into Intel 80386 instructions: - - m.fetch_or(1<(&mem), bit)) \ - goto label; -# define IF_NOT_FETCH_OR_GOTO(mem, bit, label) \ - if (!_interlockedbittestandset(reinterpret_cast(&mem), bit))\ - goto label; -#endif - template void srw_mutex_impl::wait_and_lock() { - uint32_t lk= 1 + lock.fetch_add(1, std::memory_order_relaxed); + uint32_t lk= WAITER + lock.fetch_add(WAITER, std::memory_order_relaxed); if (spinloop) { @@ -318,10 +284,16 @@ void srw_mutex_impl::wait_and_lock() lk= lock.load(std::memory_order_relaxed); if (!(lk & HOLDER)) { -#ifdef IF_NOT_FETCH_OR_GOTO - static_assert(HOLDER == (1U << 31), "compatibility"); - IF_NOT_FETCH_OR_GOTO(*this, 31, acquired); - lk|= HOLDER; +#if defined __i386__||defined __x86_64__||defined _M_IX86||defined _M_X64 + lk |= HOLDER; +# ifdef _MSC_VER + static_assert(HOLDER == (1U << 0), "compatibility"); + if (!_interlockedbittestandset + (reinterpret_cast(&lock), 0)) +# else + if (!(lock.fetch_or(HOLDER, std::memory_order_relaxed) & HOLDER)) +# endif + goto acquired; #else if (!((lk= lock.fetch_or(HOLDER, std::memory_order_relaxed)) & HOLDER)) goto acquired; @@ -339,16 +311,22 @@ void srw_mutex_impl::wait_and_lock() if (lk & HOLDER) { wait(lk); -#ifdef IF_FETCH_OR_GOTO +#if defined __i386__||defined __x86_64__||defined _M_IX86||defined _M_X64 reload: #endif lk= lock.load(std::memory_order_relaxed); } else { -#ifdef IF_FETCH_OR_GOTO - static_assert(HOLDER == (1U << 31), "compatibility"); - IF_FETCH_OR_GOTO(*this, 31, reload); +#if defined __i386__||defined __x86_64__||defined _M_IX86||defined _M_X64 +# ifdef _MSC_VER + static_assert(HOLDER == (1U << 0), "compatibility"); + if (_interlockedbittestandset + (reinterpret_cast(&lock), 0)) +# else + if (lock.fetch_or(HOLDER, std::memory_order_relaxed) & HOLDER) +# endif + goto reload; #else if ((lk= lock.fetch_or(HOLDER, std::memory_order_relaxed)) & HOLDER) continue; @@ -416,7 +394,8 @@ void ssux_lock_impl::rd_wait() /* Subscribe to writer.wake() or write.wake_all() calls by concurrently executing rd_wait() or writer.wr_unlock(). */ - uint32_t wl= 1 + writer.lock.fetch_add(1, std::memory_order_acquire); + uint32_t wl= writer.WAITER + + writer.lock.fetch_add(writer.WAITER, std::memory_order_acquire); for (;;) { @@ -440,13 +419,13 @@ void ssux_lock_impl::rd_wait() } /* Unsubscribe writer.wake() and writer.wake_all(). */ - wl= writer.lock.fetch_sub(1, std::memory_order_release); + wl= writer.lock.fetch_sub(writer.WAITER, std::memory_order_release); ut_ad(wl); /* Wake any other threads that may be blocked in writer.wait(). All other waiters than this rd_wait() would end up acquiring writer.lock and waking up other threads on unlock(). */ - if (wl > 1) + if (wl > writer.WAITER) writer.wake_all(); } From 99837b6df676665f27f758efec740966e1acd30c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 18 Sep 2024 20:54:38 +0200 Subject: [PATCH 11/62] restore --clent-rr after 7d86751de56 --- mysql-test/mysql-test-run.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 7127bedffdc..83d5fe088f8 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -5531,11 +5531,12 @@ sub start_check_testcase ($$$) { } my $errfile= "$opt_vardir/tmp/$name.err"; - My::Debugger::setup_client_args(\$args, \$exe_mysqltest); + my $exe= $exe_mysqltest; + My::Debugger::setup_client_args(\$args, \$exe); my $proc= My::SafeProcess->new ( name => $name, - path => $exe_mysqltest, + path => $exe, error => $errfile, output => $errfile, args => \$args, From bbc62b1b9ee93cd54301b6762aed31805691057b Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 6 Sep 2024 19:09:02 +0200 Subject: [PATCH 12/62] clarify --thread-pool-mode usage --- mysql-test/main/mysqld--help,win.rdiff | 25 ++++++++++++++----------- sql/sys_vars.cc | 3 ++- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/mysql-test/main/mysqld--help,win.rdiff b/mysql-test/main/mysqld--help,win.rdiff index bcfefbab1a8..07b7c87b5d4 100644 --- a/mysql-test/main/mysqld--help,win.rdiff +++ b/mysql-test/main/mysqld--help,win.rdiff @@ -1,4 +1,6 @@ -@@ -180,6 +180,7 @@ +--- a/mysql-test/main/mysqld--help.result ++++ b/mysql-test/main/mysqld--help.result +@@ -180,6 +180,7 @@ The following specify which files/extra groups are read (specified before remain --console Write error output on screen; don't remove the console window on windows. --core-file Write core on crashes @@ -6,7 +8,7 @@ -h, --datadir=name Path to the database root directory --date-format=name The DATE format (ignored) --datetime-format=name -@@ -650,6 +651,7 @@ +@@ -649,6 +650,7 @@ The following specify which files/extra groups are read (specified before remain Use MySQL-5.6 (instead of MariaDB-5.3) format for TIME, DATETIME, TIMESTAMP columns. (Defaults to on; use --skip-mysql56-temporal-format to disable.) @@ -14,7 +16,7 @@ --net-buffer-length=# Buffer length for TCP/IP and socket communication --net-read-timeout=# -@@ -1281,6 +1283,10 @@ +@@ -1280,6 +1282,10 @@ The following specify which files/extra groups are read (specified before remain Log slow queries to given log file. Defaults logging to 'hostname'-slow.log. Must be enabled to activate other slow log options @@ -25,7 +27,7 @@ --socket=name Socket file to use for connection --sort-buffer-size=# Each thread that needs to do a sort allocates a buffer of -@@ -1305,6 +1311,7 @@ +@@ -1304,6 +1310,7 @@ The following specify which files/extra groups are read (specified before remain deleting or updating every row in a table. --stack-trace Print a symbolic stack trace on failure (Defaults to on; use --skip-stack-trace to disable.) @@ -33,19 +35,20 @@ --standard-compliant-cte Allow only CTEs compliant to SQL standard (Defaults to on; use --skip-standard-compliant-cte to disable.) -@@ -1380,6 +1387,11 @@ +@@ -1379,6 +1386,12 @@ The following specify which files/extra groups are read (specified before remain --thread-pool-max-threads=# Maximum allowed number of worker threads in the thread pool + --thread-pool-min-threads=# + Minimum number of threads in the thread pool. + --thread-pool-mode=name -+ Chose implementation of the threadpool. One of: windows, -+ generic ++ Chose implementation of the threadpool. Use 'windows' ++ unless you have a workload with a lot of concurrent ++ connections and minimal contention --thread-pool-oversubscribe=# How many additional active worker threads in a group are allowed. -@@ -1418,8 +1430,8 @@ +@@ -1417,8 +1430,8 @@ The following specify which files/extra groups are read (specified before remain automatically convert it to an on-disk MyISAM or Aria table. -t, --tmpdir=name Path for temporary files. Several paths may be specified, @@ -56,7 +59,7 @@ --transaction-alloc-block-size=# Allocation block size for transactions to be stored in binary log -@@ -1634,6 +1646,7 @@ +@@ -1633,6 +1646,7 @@ myisam-sort-buffer-size 134216704 myisam-stats-method NULLS_UNEQUAL myisam-use-mmap FALSE mysql56-temporal-format TRUE @@ -64,7 +67,7 @@ net-buffer-length 16384 net-read-timeout 30 net-retry-count 10 -@@ -1788,6 +1801,7 @@ +@@ -1787,6 +1801,7 @@ slave-transaction-retry-interval 0 slave-type-conversions slow-launch-time 2 slow-query-log FALSE @@ -72,7 +75,7 @@ sort-buffer-size 2097152 sql-mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION sql-safe-updates FALSE -@@ -1814,6 +1828,8 @@ +@@ -1813,6 +1828,8 @@ thread-pool-dedicated-listener FALSE thread-pool-exact-stats FALSE thread-pool-idle-timeout 60 thread-pool-max-threads 65536 diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 2a6d0a52cfd..0af4b5e27fc 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -3947,7 +3947,8 @@ static Sys_var_on_access_global Sys_threadpool_mode( "thread_pool_mode", - "Chose implementation of the threadpool", + "Chose implementation of the threadpool. Use 'windows' unless you have a " + "workload with a lot of concurrent connections and minimal contention", READ_ONLY GLOBAL_VAR(threadpool_mode), CMD_LINE(REQUIRED_ARG), threadpool_mode_names, DEFAULT(TP_MODE_WINDOWS) ); From c9f54e20d4f25f80724c5254898004d6760b0f6b Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Thu, 19 Sep 2024 10:55:25 +0200 Subject: [PATCH 13/62] MDEV-33990: SHOW STATUS counts ER_CON_COUNT_ERROR as Connection_errors_internal Bring info about cause of closing connection in the place where we increment statistics to do it correctly. --- mysql-test/main/connect.result | 30 +++++++++++++++++++++++++++++ mysql-test/main/connect.test | 35 ++++++++++++++++++++++++++++++++++ sql/sql_connect.cc | 16 +++++++++++----- sql/sql_connect.h | 2 +- sql/threadpool_common.cc | 4 ++-- 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/mysql-test/main/connect.result b/mysql-test/main/connect.result index 229c2d9dafe..fb63b2d5175 100644 --- a/mysql-test/main/connect.result +++ b/mysql-test/main/connect.result @@ -444,3 +444,33 @@ FOUND 2 /This connection closed normally without authentication/ in mysqld.1.err SET GLOBAL log_warnings=default; SET GLOBAL connect_timeout= @save_connect_timeout; # End of 10.4 tests +# +# MDEV-33990: SHOW STATUS counts ER_CON_COUNT_ERROR as +# Connection_errors_internal +# +flush status; +show global status like 'Connection_errors%'; +Variable_name Value +Connection_errors_accept 0 +Connection_errors_internal 0 +Connection_errors_max_connections 0 +Connection_errors_peer_address 0 +Connection_errors_select 0 +Connection_errors_tcpwrap 0 +set @max_con.save= @@max_connections; +set global max_connections= 10; +# ERROR 1040 +# ERROR 1040 +connection default; +show global status like 'Connection_errors%'; +Variable_name Value +Connection_errors_accept 0 +Connection_errors_internal 0 +Connection_errors_max_connections 2 +Connection_errors_peer_address 0 +Connection_errors_select 0 +Connection_errors_tcpwrap 0 +set global max_connections= @max_con.save; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/connect.test b/mysql-test/main/connect.test index b115e0620ec..9a121384d6e 100644 --- a/mysql-test/main/connect.test +++ b/mysql-test/main/connect.test @@ -508,3 +508,38 @@ SET GLOBAL log_warnings=default; SET GLOBAL connect_timeout= @save_connect_timeout; --echo # End of 10.4 tests + +--echo # +--echo # MDEV-33990: SHOW STATUS counts ER_CON_COUNT_ERROR as +--echo # Connection_errors_internal +--echo # + +flush status; + +show global status like 'Connection_errors%'; + +set @max_con.save= @@max_connections; +set global max_connections= 10; + +--disable_result_log +--disable_query_log +--let $n= 12 +while ($n) +{ + --error 0,ER_CON_COUNT_ERROR + --connect (con$n,localhost,root) + if ($mysql_errno) { + --echo # ERROR $mysql_errno + } + --dec $n +} + +--enable_result_log +--enable_query_log +--connection default +show global status like 'Connection_errors%'; +set global max_connections= @max_con.save; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index b371e27eb3a..824f68890c0 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -1362,7 +1362,7 @@ void do_handle_one_connection(CONNECT *connect, bool put_in_cache) THD *thd; if (!(thd= connect->create_thd(NULL))) { - connect->close_and_delete(); + connect->close_and_delete(0); return; } @@ -1437,7 +1437,7 @@ end_thread: if (!(connect->create_thd(thd))) { /* Out of resources. Free thread to get more resources */ - connect->close_and_delete(); + connect->close_and_delete(0); break; } delete connect; @@ -1466,9 +1466,11 @@ end_thread: Close connection without error and delete the connect object This and close_with_error are only called if we didn't manage to create a new thd object. + + Note: err can be 0 if unknown/not inportant */ -void CONNECT::close_and_delete() +void CONNECT::close_and_delete(uint err) { DBUG_ENTER("close_and_delete"); @@ -1482,7 +1484,11 @@ void CONNECT::close_and_delete() vio_type= VIO_CLOSED; --*scheduler->connection_count; - statistic_increment(connection_errors_internal, &LOCK_status); + + if (err == ER_CON_COUNT_ERROR) + statistic_increment(connection_errors_max_connection, &LOCK_status); + else + statistic_increment(connection_errors_internal, &LOCK_status); statistic_increment(aborted_connects,&LOCK_status); delete this; @@ -1506,7 +1512,7 @@ void CONNECT::close_with_error(uint sql_errno, delete thd; set_current_thd(0); } - close_and_delete(); + close_and_delete(close_error); } diff --git a/sql/sql_connect.h b/sql/sql_connect.h index 8be6c1aecc0..ed8c0fb8753 100644 --- a/sql/sql_connect.h +++ b/sql/sql_connect.h @@ -61,7 +61,7 @@ public: count--; DBUG_ASSERT(vio_type == VIO_CLOSED); } - void close_and_delete(); + void close_and_delete(uint err); void close_with_error(uint sql_errno, const char *message, uint close_error); THD *create_thd(THD *thd); diff --git a/sql/threadpool_common.cc b/sql/threadpool_common.cc index 68875fb3a44..7c800696344 100644 --- a/sql/threadpool_common.cc +++ b/sql/threadpool_common.cc @@ -241,7 +241,7 @@ static THD* threadpool_add_connection(CONNECT *connect, void *scheduler_data) if (!mysys_var ||!(thd= connect->create_thd(NULL))) { /* Out of memory? */ - connect->close_and_delete(); + connect->close_and_delete(0); if (mysys_var) my_thread_end(); return NULL; @@ -417,7 +417,7 @@ static void tp_add_connection(CONNECT *connect) if (c) pool->add(c); else - connect->close_and_delete(); + connect->close_and_delete(0); } int tp_get_idle_thread_count() From 231900e5bb15e5d6d90b8a6daf38a0b21d1a19e7 Mon Sep 17 00:00:00 2001 From: Denis Protivensky Date: Mon, 9 Sep 2024 13:30:42 +0300 Subject: [PATCH 14/62] MDEV-34836: TOI on parent table must BF abort SR in progress on a child Applied SR transaction on the child table was not BF aborted by TOI running on the parent table for several reasons: Although SR correctly collected FK-referenced keys to parent, TOI in Galera disregards common certification index and simply sets itself to depend on the latest certified write set seqno. Since this write set was the fragment of SR transaction, TOI was allowed to run in parallel with SR presuming it would BF abort the latter. At the same time, DML transactions in the server don't grab MDL locks on FK-referenced tables, thus parent table wasn't protected by an MDL lock from SR and it couldn't provoke MDL lock conflict for TOI to BF abort SR transaction. In InnoDB, DDL transactions grab shared MDL locks on child tables, which is not enough to trigger MDL conflict in Galera. InnoDB-level Wsrep patch didn't contain correct conflict resolution logic due to the fact that it was believed MDL locking should always produce conflicts correctly. The fix brings conflict resolution rules similar to MDL-level checks to InnoDB, thus accounting for the problematic case. Apart from that, wsrep_thd_is_SR() is patched to return true only for executing SR transactions. It should be safe as any other SR state is either the same as for any single write set (thus making the two logically equivalent), or it reflects an SR transaction as being aborting or prepared, which is handled separately in BF-aborting logic, and for regular execution path it should not matter at all. Signed-off-by: Julius Goryavsky --- include/mysql/service_wsrep.h | 2 +- .../suite/galera_sr/r/MDEV-34836.result | 23 +++ mysql-test/suite/galera_sr/t/MDEV-34836.test | 56 ++++++ sql/service_wsrep.cc | 3 +- storage/innobase/lock/lock0lock.cc | 160 ++++++++++-------- 5 files changed, 171 insertions(+), 73 deletions(-) create mode 100644 mysql-test/suite/galera_sr/r/MDEV-34836.result create mode 100644 mysql-test/suite/galera_sr/t/MDEV-34836.test diff --git a/include/mysql/service_wsrep.h b/include/mysql/service_wsrep.h index a0d0a338a0e..cf94364c1cf 100644 --- a/include/mysql/service_wsrep.h +++ b/include/mysql/service_wsrep.h @@ -209,7 +209,7 @@ extern "C" my_bool wsrep_thd_is_local_toi(const MYSQL_THD thd); extern "C" my_bool wsrep_thd_is_in_rsu(const MYSQL_THD thd); /* Return true if thd is in BF mode, either high_priority or TOI */ extern "C" my_bool wsrep_thd_is_BF(const MYSQL_THD thd, my_bool sync); -/* Return true if thd is streaming */ +/* Return true if thd is streaming in progress */ extern "C" my_bool wsrep_thd_is_SR(const MYSQL_THD thd); extern "C" void wsrep_handle_SR_rollback(MYSQL_THD BF_thd, MYSQL_THD victim_thd); /* Return thd retry counter */ diff --git a/mysql-test/suite/galera_sr/r/MDEV-34836.result b/mysql-test/suite/galera_sr/r/MDEV-34836.result new file mode 100644 index 00000000000..10d302c415f --- /dev/null +++ b/mysql-test/suite/galera_sr/r/MDEV-34836.result @@ -0,0 +1,23 @@ +connection node_2; +connection node_1; +connection node_1; +CREATE TABLE parent (id INT AUTO_INCREMENT PRIMARY KEY, v INT) ENGINE=InnoDB; +INSERT INTO parent VALUES (1, 1),(2, 2),(3, 3); +CREATE TABLE child (id INT AUTO_INCREMENT PRIMARY KEY, parent_id INT, CONSTRAINT parent_fk +FOREIGN KEY (parent_id) REFERENCES parent (id)) ENGINE=InnoDB; +connection node_2; +SET SESSION wsrep_trx_fragment_size = 1; +START TRANSACTION; +INSERT INTO child (parent_id) VALUES (1),(2),(3); +connection node_1; +SET SESSION wsrep_sync_wait = 15; +SELECT COUNT(*) FROM child; +COUNT(*) +0 +ALTER TABLE parent AUTO_INCREMENT = 100; +connection node_2; +COMMIT; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +DROP TABLE child, parent; +disconnect node_2; +disconnect node_1; diff --git a/mysql-test/suite/galera_sr/t/MDEV-34836.test b/mysql-test/suite/galera_sr/t/MDEV-34836.test new file mode 100644 index 00000000000..840ebaede4c --- /dev/null +++ b/mysql-test/suite/galera_sr/t/MDEV-34836.test @@ -0,0 +1,56 @@ +# +# MDEV-34836: TOI transaction on FK-referenced parent table must BF abort +# SR transaction in progress on a child table. +# +# Applied SR transaction on the child table was not BF aborted by TOI running +# on the parent table for several reasons: +# Although SR correctly collected FK-referenced keys to parent, TOI in Galera +# disregards common certification index and simply sets itself to depend on the +# latest certified write set seqno. +# Since this write set was the fragment of SR transaction, TOI was allowed to run in +# parallel with SR presuming it would BF abort the latter. +# +# At the same time, DML transactions in the server don't grab MDL locks on FK-referenced +# tables, thus parent table wasn't protected by an MDL lock from SR and it couldn't +# provoke MDL lock conflict for TOI to BF abort SR transaction. +# In InnoDB, DDL transactions grab shared MDL locks on child tables, which is not enough +# to trigger MDL conflict in Galera. +# InnoDB-level Wsrep patch didn't contain correct conflict resolution logic due to the +# fact that it was believed MDL locking should always produce conflicts correctly. +# +# The fix brings conflict resolution rules similar to MDL-level checks to InnoDB, thus +# accounting for the problematic case. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +--connection node_1 +CREATE TABLE parent (id INT AUTO_INCREMENT PRIMARY KEY, v INT) ENGINE=InnoDB; +INSERT INTO parent VALUES (1, 1),(2, 2),(3, 3); + +CREATE TABLE child (id INT AUTO_INCREMENT PRIMARY KEY, parent_id INT, CONSTRAINT parent_fk + FOREIGN KEY (parent_id) REFERENCES parent (id)) ENGINE=InnoDB; + +--connection node_2 +# Start SR transaction and make it lock both parent and child tales. +SET SESSION wsrep_trx_fragment_size = 1; +START TRANSACTION; +INSERT INTO child (parent_id) VALUES (1),(2),(3); + +--connection node_1 +# Sync wait for SR transaction to replicate and apply fragments, thus +# locking parent table as well. +SET SESSION wsrep_sync_wait = 15; +SELECT COUNT(*) FROM child; +# Now run TOI on the parent, which BF-aborts the SR-transaction in progress. +ALTER TABLE parent AUTO_INCREMENT = 100; + +--connection node_2 +# Check that SR is BF-aborted. +--error ER_LOCK_DEADLOCK +COMMIT; + +# Cleanup +DROP TABLE child, parent; +--source include/galera_end.inc diff --git a/sql/service_wsrep.cc b/sql/service_wsrep.cc index 22ae84aa353..0a26951b47e 100644 --- a/sql/service_wsrep.cc +++ b/sql/service_wsrep.cc @@ -183,7 +183,8 @@ extern "C" my_bool wsrep_thd_is_BF(const THD *thd, my_bool sync) extern "C" my_bool wsrep_thd_is_SR(const THD *thd) { - return thd && thd->wsrep_cs().transaction().is_streaming(); + return thd && thd->wsrep_cs().transaction().is_streaming() && + thd->wsrep_cs().transaction().state() == wsrep::transaction::s_executing; } extern "C" void wsrep_handle_SR_rollback(THD *bf_thd, diff --git a/storage/innobase/lock/lock0lock.cc b/storage/innobase/lock/lock0lock.cc index c267e45ebe6..ecca8901c40 100644 --- a/storage/innobase/lock/lock0lock.cc +++ b/storage/innobase/lock/lock0lock.cc @@ -496,15 +496,13 @@ void lock_sys_t::close() #ifdef WITH_WSREP # ifdef UNIV_DEBUG -/** Check if both conflicting lock transaction and other transaction -requesting record lock are brute force (BF). If they are check is -this BF-BF wait correct and if not report BF wait and assert. +/** Check if this BF-BF wait is correct and if not report and abort. @param lock other waiting lock @param trx transaction requesting conflicting lock */ -static void wsrep_assert_no_bf_bf_wait(const lock_t *lock, const trx_t *trx, - const unsigned type_mode = LOCK_NONE) +static void wsrep_assert_valid_bf_bf_wait(const lock_t *lock, const trx_t *trx, + const unsigned type_mode) { ut_ad(!lock->is_table()); lock_sys.assert_locked(*lock); @@ -514,12 +512,8 @@ static void wsrep_assert_no_bf_bf_wait(const lock_t *lock, const trx_t *trx, not acquire THD::LOCK_thd_data mutex below to avoid latching order violation. */ - if (!trx->is_wsrep() || !lock_trx->is_wsrep()) - return; - if (UNIV_LIKELY(!wsrep_thd_is_BF(trx->mysql_thd, FALSE)) - || UNIV_LIKELY(!wsrep_thd_is_BF(lock_trx->mysql_thd, FALSE))) - return; - + ut_ad(wsrep_thd_is_BF(trx->mysql_thd, FALSE)); + ut_ad(wsrep_thd_is_BF(lock_trx->mysql_thd, FALSE)); ut_ad(trx->state == TRX_STATE_ACTIVE); switch (lock_trx->state) { @@ -536,16 +530,6 @@ static void wsrep_assert_no_bf_bf_wait(const lock_t *lock, const trx_t *trx, ut_ad("invalid state" == 0); } - /* If BF - BF order is honored, i.e. trx already holding - record lock should be ordered before this new lock request - we can keep trx waiting for the lock. If conflicting - transaction is already aborting or rolling back for replaying - we can also let new transaction waiting. */ - if (wsrep_thd_order_before(lock_trx->mysql_thd, trx->mysql_thd) - || wsrep_thd_is_aborting(lock_trx->mysql_thd)) { - return; - } - if (type_mode != LOCK_NONE) ib::error() << " Requested lock " << ((type_mode & LOCK_TABLE) ? "on table " : " on record ") @@ -573,8 +557,81 @@ static void wsrep_assert_no_bf_bf_wait(const lock_t *lock, const trx_t *trx, /* BF-BF wait is a bug */ ut_error; } + +void wsrep_report_error(const lock_t* victim_lock, const trx_t *bf_trx); # endif /* UNIV_DEBUG */ +/** Check if a high priority (BF) trx has to wait for the current +lock holder based on Wsrep transaction state relations. + +This code resembles the one in `wsrep_handle_mdl_conflict()`, but +it's specific to the storage engine and it doesn't perform any +BF aborts by itself. +The decision whether to BF abort a victim may depend on other conditions +like lock compatibility between InnoDB transactions. + +@param lock other waiting lock +@param trx BF transaction requesting conflicting lock +@return TRUE if BF trx has to wait for the lock to be removed +*/ +static bool wsrep_BF_has_to_wait(const lock_t *lock, const trx_t *trx, + bool report_bf_bf_wait, + const unsigned type_mode = LOCK_NONE) +{ + THD *request_thd= trx->mysql_thd; + THD *granted_thd= lock->trx->mysql_thd; + + ut_ad(wsrep_thd_is_BF(request_thd, false)); + ut_ad(lock->trx->is_wsrep()); + + /* Granted is aborting, let it complete. */ + if (wsrep_thd_is_aborting(granted_thd)) + return true; + + /* Granted is not BF, may BF abort it. */ + if (!wsrep_thd_is_BF(granted_thd, false)) + return false; + + /* Applying SR cannot BF abort other high priority (BF). */ + if (wsrep_thd_is_SR(request_thd)) + return true; + + /* Requester is truly BF and granted is applying SR in progress. */ + if (wsrep_thd_is_SR(granted_thd)) + return false; + +#ifdef UNIV_DEBUG + if (report_bf_bf_wait) + wsrep_report_error(lock, trx); + /* We very well can let BF to wait normally as other + BF will be replayed in case of conflict. For debug + builds we will do additional sanity checks to catch + unsupported BF wait if any. */ + ut_d(wsrep_assert_valid_bf_bf_wait(lock, trx, type_mode)); +#endif + return true; +} + +/** Determine whether BF abort on the lock holder is needed. + +@param lock other waiting lock +@param trx BF transaction requesting conflicting lock +@return TRUE if BF abort is needed +*/ +static bool wsrep_will_BF_abort(const lock_t *lock, const trx_t *trx) +{ + ut_ad(wsrep_thd_is_BF(trx->mysql_thd, false)); + + /* Don't BF abort system transactions. */ + if (!lock->trx->is_wsrep()) + return false; + + /* BF trx will wait for the lock, but it doesn't have to according + to Wsrep rules, meaning it must BF abort the lock holder. */ + return lock_has_to_wait(trx->lock.wait_lock, lock) && + !wsrep_BF_has_to_wait(lock, trx, true); +} + /** check if lock timeout was for priority thread, as a side effect trigger lock monitor @param trx transaction owning the lock @@ -648,19 +705,9 @@ bool lock_rec_has_to_wait_wsrep(const trx_t *trx, return false; } - if (wsrep_thd_order_before(trx->mysql_thd, trx2->mysql_thd)) - { - /* If two high priority threads have lock conflict, we look at the - order of these transactions and honor the earlier transaction. */ - - return false; - } - - /* We very well can let bf to wait normally as other - BF will be replayed in case of conflict. For debug - builds we will do additional sanity checks to catch - unsupported bf wait if any. */ - ut_d(wsrep_assert_no_bf_bf_wait(lock2, trx, type_mode)); + /* If two high priority threads have lock conflict, we check if + new lock request has to wait for the transaction holding the lock. */ + return wsrep_BF_has_to_wait(lock2, trx, false, type_mode); } return true; @@ -997,14 +1044,13 @@ void wsrep_report_error(const lock_t* victim_lock, const trx_t *bf_trx) lock_rec_print(stderr, bf_trx->lock.wait_lock, mtr); WSREP_ERROR("victim holding lock: "); lock_rec_print(stderr, victim_lock, mtr); - wsrep_assert_no_bf_bf_wait(victim_lock, bf_trx); } #endif /* WITH_DEBUG */ /** Kill the holders of conflicting locks. @param trx brute-force applier transaction running in the current thread */ ATTRIBUTE_COLD ATTRIBUTE_NOINLINE -static void lock_wait_wsrep(trx_t *trx) +static void wsrep_handle_lock_conflict(trx_t *trx) { DBUG_ASSERT(wsrep_on(trx->mysql_thd)); if (!wsrep_thd_is_BF(trx->mysql_thd, false)) @@ -1030,8 +1076,8 @@ func_exit: for (lock_t *lock= UT_LIST_GET_FIRST(table->locks); lock; lock= UT_LIST_GET_NEXT(un_member.tab_lock.locks, lock)) { - /* Victim trx needs to be different from BF trx and it has to have a - THD so that we can kill it. Victim might not have THD in two cases: + /* Victim trx has to have a THD so that we can kill it. + Victim might not have THD in two cases: (1) An incomplete transaction that was recovered from undo logs on server startup (and not yet rolled back). @@ -1039,8 +1085,8 @@ func_exit: (2) Transaction that is in XA PREPARE state and whose client connection was disconnected. - Neither of these can complete before lock_wait_wsrep() releases - lock_sys.latch. + Neither of these can complete before wsrep_handle_lock_conflict() + releases lock_sys.latch. (1) trx_t::commit_in_memory() is clearing both trx_t::state and trx_t::is_recovered before it invokes @@ -1051,24 +1097,9 @@ func_exit: (2) If is in XA PREPARE state, it would eventually be rolled back and the lock conflict would be resolved when an XA COMMIT or XA ROLLBACK statement is executed in some other connection. - - If victim has also BF status, but has earlier seqno, we have to wait. */ - if (lock->trx != trx && lock->trx->mysql_thd && - !(wsrep_thd_is_BF(lock->trx->mysql_thd, false) && - wsrep_thd_order_before(lock->trx->mysql_thd, trx->mysql_thd))) + if (lock->trx->mysql_thd && wsrep_will_BF_abort(lock, trx)) { - if (wsrep_thd_is_BF(lock->trx->mysql_thd, false)) - { - // There is no need to kill victim with compatible lock - if (!lock_has_to_wait(trx->lock.wait_lock, lock)) - continue; - -#ifdef UNIV_DEBUG - wsrep_report_error(lock, trx); -#endif - } - victims.emplace(lock->trx); } } @@ -1090,21 +1121,8 @@ func_exit: record-locks instead of table locks. See details from comment above. */ - if (lock->trx != trx && lock->trx->mysql_thd && - !(wsrep_thd_is_BF(lock->trx->mysql_thd, false) && - wsrep_thd_order_before(lock->trx->mysql_thd, trx->mysql_thd))) + if (lock->trx->mysql_thd && wsrep_will_BF_abort(lock, trx)) { - if (wsrep_thd_is_BF(lock->trx->mysql_thd, false)) - { - // There is no need to kill victim with compatible lock - if (!lock_has_to_wait(trx->lock.wait_lock, lock)) - continue; - -#ifdef UNIV_DEBUG - wsrep_report_error(lock, trx); -#endif - } - victims.emplace(lock->trx); } } while ((lock= lock_rec_get_next(heap_no, lock))); @@ -2015,7 +2033,7 @@ dberr_t lock_wait(que_thr_t *thr) ut_ad(!trx->dict_operation_lock_mode); - IF_WSREP(if (trx->is_wsrep()) lock_wait_wsrep(trx),); + IF_WSREP(if (trx->is_wsrep()) wsrep_handle_lock_conflict(trx),); const auto type_mode= wait_lock->type_mode; #ifdef HAVE_REPLICATION From dd1cad7e5f0e0f1924f34063600381ed565cb310 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 22 Sep 2024 08:45:26 +0200 Subject: [PATCH 15/62] galera_3nodes.MDEV-29171 fails set transferfmt in .cnf file like other galera tests do. otherwise it defaults to socat when mtr detected that only nc is available --- mysql-test/suite/galera_3nodes/galera_3nodes.cnf | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/galera_3nodes/galera_3nodes.cnf b/mysql-test/suite/galera_3nodes/galera_3nodes.cnf index abd778c482c..f23e1c65008 100644 --- a/mysql-test/suite/galera_3nodes/galera_3nodes.cnf +++ b/mysql-test/suite/galera_3nodes/galera_3nodes.cnf @@ -48,6 +48,7 @@ wsrep_sst_receive_address='127.0.0.1:@mysqld.3.#sst_port' [sst] sst-log-archive-dir=@ENV.MYSQLTEST_VARDIR/log +transferfmt=@ENV.MTR_GALERA_TFMT [ENV] NODE_MYPORT_1= @mysqld.1.port From 8fd1b060f870f0936d87c40d9b030f465abf6212 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Sun, 22 Sep 2024 08:46:35 +0200 Subject: [PATCH 16/62] reformat galera sst error messages put the command line at the end. so that when a very long command line is truncated, it doesn't take the actual error message with it --- sql/wsrep_sst.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/wsrep_sst.cc b/sql/wsrep_sst.cc index 34eda4e286d..e9d2e158e39 100644 --- a/sql/wsrep_sst.cc +++ b/sql/wsrep_sst.cc @@ -597,8 +597,8 @@ static void* sst_joiner_thread (void* a) if (!tmp || strlen(tmp) < (magic_len + 2) || strncasecmp (tmp, magic, magic_len)) { - WSREP_ERROR("Failed to read '%s ' from: %s\n\tRead: '%s'", - magic, arg->cmd, tmp); + WSREP_ERROR("Failed to read '%s ' (got '%s') from: %s", + magic, tmp, arg->cmd); proc.wait(); if (proc.error()) err= proc.error(); } @@ -610,8 +610,8 @@ static void* sst_joiner_thread (void* a) else { err= proc.error(); - WSREP_ERROR("Failed to execute: %s : %d (%s)", - arg->cmd, err, strerror(err)); + WSREP_ERROR("Failed to execute (%M): %s", + err, arg->cmd); } /* From 53f5ee7929545c745f950c18fdc8cbadd945ecdf Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 24 Sep 2024 08:44:52 +0200 Subject: [PATCH 17/62] MDEV-34994: sql/mysqld: stop accept() loop after the first EAGAIN Each time a listener socket becomes ready, MariaDB calls accept() ten times (MAX_ACCEPT_RETRY), even if all but the first one return EAGAIN because there are no more connections. This causes unnecessary CPU usage - on our server, the CPU load of that thread, which does nothing but accept(), saturates one CPU core by ~45%. The loop should stop after the first EAGAIN. Perf report: 11.01% mariadbd libc.so.6 [.] accept4 6.42% mariadbd [kernel.kallsyms] [k] finish_task_switch.isra.0 5.50% mariadbd [kernel.kallsyms] [k] _raw_spin_unlock_irqrestore 5.50% mariadbd [kernel.kallsyms] [k] syscall_enter_from_user_mode 4.59% mariadbd [kernel.kallsyms] [k] __fget_light 3.67% mariadbd [kernel.kallsyms] [k] kmem_cache_alloc 2.75% mariadbd [kernel.kallsyms] [k] fput 2.75% mariadbd [kernel.kallsyms] [k] mod_objcg_state 1.83% mariadbd [kernel.kallsyms] [k] __inode_wait_for_writeback 1.83% mariadbd [kernel.kallsyms] [k] __sys_accept4 1.83% mariadbd [kernel.kallsyms] [k] _raw_spin_unlock_irq 1.83% mariadbd [kernel.kallsyms] [k] alloc_inode 1.83% mariadbd [kernel.kallsyms] [k] call_rcu --- sql/mysqld.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d874a115bce..39d7f60527b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -6360,7 +6360,9 @@ void handle_connections_sockets() &length); if (mysql_socket_getfd(new_sock) != INVALID_SOCKET) handle_accepted_socket(new_sock, sock); - else if (socket_errno != SOCKET_EINTR && socket_errno != SOCKET_EAGAIN) + else if (socket_errno == SOCKET_EAGAIN || socket_errno == SOCKET_EWOULDBLOCK) + break; + else if (socket_errno != SOCKET_EINTR) { /* accept(2) failed on the listening port. From ad5b9c207c60d78a55ab0514432ef0421d017c1a Mon Sep 17 00:00:00 2001 From: Lena Startseva Date: Mon, 23 Sep 2024 17:53:11 +0700 Subject: [PATCH 18/62] MDEV-27944: View-protocol fails if database was changed This is a limitation of the view protocol. Tests were fixed with workaround (via disable/enable service connection) --- mysql-test/main/cte_nonrecursive.test | 12 ++++++------ mysql-test/main/ctype_recoding.test | 5 ++--- mysql-test/main/lowercase_table.test | 5 ++--- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/mysql-test/main/cte_nonrecursive.test b/mysql-test/main/cte_nonrecursive.test index bebf02eafd9..a56b89cf3c8 100644 --- a/mysql-test/main/cte_nonrecursive.test +++ b/mysql-test/main/cte_nonrecursive.test @@ -1048,14 +1048,14 @@ drop table t1; --echo # MDEV-16473: query with CTE when no database is set --echo # -# Enable view protocol after fix MDEV-27944 ---disable_view_protocol create database db_mdev_16473; use db_mdev_16473; drop database db_mdev_16473; +--disable_service_connection --echo # Now no default database is set select database(); +--enable_service_connection with cte as (select 1 as a) select * from cte; @@ -1073,7 +1073,6 @@ select * from cte, db_mdev_16473.t1 as t where cte.a=t.a; drop database db_mdev_16473; use test; ---enable_view_protocol --echo # --echo # MDEV-17154: using parameter markers for PS within CTEs more than once @@ -1220,8 +1219,6 @@ DROP TABLE test.t; --echo # MDEV-22781: create view with CTE without default database --echo # -# Enable view protocol after fix MDEV-27944 ---disable_view_protocol create database db; use db; drop database db; @@ -1231,7 +1228,9 @@ insert into db1.t1 values (3),(7),(1); create view db1.v1 as with t as (select * from db1.t1) select * from t; show create view db1.v1; +--disable_service_connection select * from db1.v1; +--enable_service_connection drop view db1.v1; prepare stmt from " @@ -1240,14 +1239,15 @@ create view db1.v1 as with t as (select * from db1.t1) select * from t; execute stmt; deallocate prepare stmt; show create view db1.v1; +--disable_service_connection select * from db1.v1; +--enable_service_connection drop view db1.v1; drop table db1.t1; drop database db1; use test; ---enable_view_protocol --echo # --echo # MDEV-24597: CTE with union used multiple times in query diff --git a/mysql-test/main/ctype_recoding.test b/mysql-test/main/ctype_recoding.test index 9b5f74d0b93..5c25d854137 100644 --- a/mysql-test/main/ctype_recoding.test +++ b/mysql-test/main/ctype_recoding.test @@ -74,13 +74,12 @@ SHOW TABLES IN SET CHARACTER SET koi8r; DROP DATABASE ; -# Enable view protocol after fix MDEV-27944 ---disable_view_protocol +--disable_service_connection SET NAMES koi8r; SELECT hex(''); SET character_set_connection=cp1251; SELECT hex(''); ---enable_view_protocol +--enable_service_connection USE test; # Bug#4417 diff --git a/mysql-test/main/lowercase_table.test b/mysql-test/main/lowercase_table.test index 8d493fff5cd..6af80f1c339 100644 --- a/mysql-test/main/lowercase_table.test +++ b/mysql-test/main/lowercase_table.test @@ -2,9 +2,6 @@ # Test of --lower-case-table-names # -#remove this include after fix MDEV-27944 ---source include/no_view_protocol.inc - create table T1 (id int primary key, Word varchar(40) not null, Index(Word)); create table t4 (id int primary key, Word varchar(40) not null); INSERT INTO T1 VALUES (1, 'a'), (2, 'b'), (3, 'c'); @@ -36,8 +33,10 @@ drop table t1; create database mysqltest; use MYSQLTEST; create table t1 (a int); +--disable_service_connection select T1.a from MYSQLTEST.T1; select t1.a from MYSQLTEST.T1; +--enable_service_connection select mysqltest.t1.* from MYSQLTEST.t1; select MYSQLTEST.t1.* from MYSQLTEST.t1; select MYSQLTEST.T1.* from MYSQLTEST.T1; From 42eb64e64df0961c77e57111b18f44589be2d5c8 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 24 Sep 2024 17:47:34 +1000 Subject: [PATCH 19/62] MDEV-34996 Buildbot MSAN options should be in server All the options that where in buildbot, should be in the server making it accessible to all without any special invocation. If WITH_MSAN=ON, we want to make sure that the compiler options are supported and it will result in an error if not supported. We make the -WITH_MSAN=ON append -stdlib=libc++ to the CXX_FLAGS if supported. With SECURITY_HARDENING options the bootstrap currently crashes, so for now, we disable SECRUITY_HARDENING if there is MSAN enable. Option WITH_DBUG_TRACE has no effect in MSAN builds. --- CMakeLists.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6897fee02af..36b6a91068d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,6 +244,19 @@ ENDIF() OPTION(WITH_MSAN "Enable memory sanitizer" OFF) IF (WITH_MSAN) MY_CHECK_AND_SET_COMPILER_FLAG("-fsanitize=memory -fsanitize-memory-track-origins -U_FORTIFY_SOURCE" DEBUG RELWITHDEBINFO) + IF(NOT (have_C__fsanitize_memory__fsanitize_memory_track_origins__U_FORTIFY_SOURCE + AND have_CXX__fsanitize_memory__fsanitize_memory_track_origins__U_FORTIFY_SOURCE)) + MESSAGE(FATAL_ERROR "Compiler doesn't support -fsanitize=memory flags") + ENDIF() + MY_CHECK_CXX_COMPILER_FLAG("-stdlib=libc++") + IF(NOT have_CXX__stdlib_libc__) + MESSAGE(FATAL_ERROR "C++ Compiler requires support for -stdlib=libc++") + ENDIF() + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") + MY_CHECK_AND_SET_LINKER_FLAG("-fsanitize=memory" DEBUG RELWITHDEBINFO) + IF(NOT HAVE_LINK_FLAG__fsanitize_memory) + MESSAGE(FATAL_ERROR "Linker doesn't support -fsanitize=memory flags") + ENDIF() ENDIF() OPTION(WITH_GPROF "Enable profiling with gprof" OFF) @@ -257,7 +270,7 @@ MY_CHECK_AND_SET_COMPILER_FLAG("-fno-omit-frame-pointer" RELWITHDEBINFO) # enable security hardening features, like most distributions do # in our benchmarks that costs about ~1% of performance, depending on the load OPTION(SECURITY_HARDENED "Use security-enhancing compiler features (stack protector, relro, etc)" ON) -IF(SECURITY_HARDENED AND NOT WITH_ASAN AND NOT WITH_UBSAN AND NOT WITH_TSAN AND NOT WITH_GPROF) +IF(SECURITY_HARDENED AND NOT WITH_ASAN AND NOT WITH_UBSAN AND NOT WITH_TSAN AND NOT WITH_GPROF AND NOT WITH_MSAN) # security-enhancing flags MY_CHECK_AND_SET_COMPILER_FLAG("-pie -fPIC") MY_CHECK_AND_SET_LINKER_FLAG("-Wl,-z,relro,-z,now") From d67c88946f1624ba1af45b2728442c1fb5d96e24 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Sun, 22 Sep 2024 21:35:19 +0300 Subject: [PATCH 20/62] Debugging: add dbug_print_join_prefix() to use in best_access_path A call to dbug_print_join_prefix(join_positions, idx, s) returns a const char* ponter to string with current join prefix, including the table being added to it. --- sql/sql_select.cc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ea690422eac..b995beb53e3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7550,6 +7550,30 @@ double adjust_quick_cost(double quick_cost, ha_rows records) } +#ifndef DBUG_OFF + +char dbug_join_prefix_buf[256]; + +const char* dbug_print_join_prefix(const POSITION *join_positions, + uint idx, + JOIN_TAB *s) +{ + char *buf= dbug_join_prefix_buf; + String str(buf, sizeof(dbug_join_prefix_buf), &my_charset_bin); + str.length(0); + for (uint i=0; i!=idx; i++) + { + str.append(join_positions[i].table->table->alias); + str.append(','); + } + str.append(s->table->alias); + if (str.c_ptr_safe() == buf) + return buf; + else + return "Couldn't fit into buffer"; +} +#endif + /** Find the best access path for an extension of a partial execution plan and add this path to the plan. @@ -7573,6 +7597,14 @@ double adjust_quick_cost(double quick_cost, ha_rows records) @param pos OUT Table access plan @param loose_scan_pos OUT Table plan that uses loosescan, or set cost to DBL_MAX if not possible. + @detail + Use this to print the current join prefix: + + dbug_print_join_prefix(join_positions, idx, s) + + Use this as breakpoint condition to stop at join prefix "t1,t2,t3": + + $_streq(dbug_print_join_prefix(join_positions, idx, s), "t1,t2,t3") @return None From f7c5182b7cb413455a0fbbfbb8b773e12139c0a6 Mon Sep 17 00:00:00 2001 From: Dave Gosselin Date: Wed, 18 Sep 2024 16:38:11 -0400 Subject: [PATCH 21/62] MDEV-31636 Memory leak in Sys_var_gtid_binlog_state::do_check() Move memory allocations performed during Sys_var_gtid_binlog_state::do_check to Sys_var_gtid_binlog_state::global_update where they will be freed before the latter method returns. --- mysql-test/main/mdev-31636.result | 8 +++++ mysql-test/main/mdev-31636.test | 7 ++++ sql/sys_vars.cc | 58 +++++++++++++++---------------- 3 files changed, 43 insertions(+), 30 deletions(-) create mode 100644 mysql-test/main/mdev-31636.result create mode 100644 mysql-test/main/mdev-31636.test diff --git a/mysql-test/main/mdev-31636.result b/mysql-test/main/mdev-31636.result new file mode 100644 index 00000000000..82dcd03027c --- /dev/null +++ b/mysql-test/main/mdev-31636.result @@ -0,0 +1,8 @@ +RESET MASTER; +SET +@@global.gtid_binlog_state='1-1-101,2-1-2002', +@@global.slave_parallel_mode=x; +ERROR 42000: Variable 'slave_parallel_mode' can't be set to the value of 'x' +SELECT @@global.gtid_binlog_state; +@@global.gtid_binlog_state + diff --git a/mysql-test/main/mdev-31636.test b/mysql-test/main/mdev-31636.test new file mode 100644 index 00000000000..b5affaef60c --- /dev/null +++ b/mysql-test/main/mdev-31636.test @@ -0,0 +1,7 @@ +--source include/have_log_bin.inc +RESET MASTER; +--error ER_WRONG_VALUE_FOR_VAR +SET + @@global.gtid_binlog_state='1-1-101,2-1-2002', + @@global.slave_parallel_mode=x; +SELECT @@global.gtid_binlog_state; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 0af4b5e27fc..44302b3a507 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2016,15 +2016,6 @@ struct gtid_binlog_state_data { rpl_gtid *list; uint32 list_len; }; bool Sys_var_gtid_binlog_state::do_check(THD *thd, set_var *var) { - String str, *res; - struct gtid_binlog_state_data *data; - rpl_gtid *list; - uint32 list_len; - - DBUG_ASSERT(var->type == OPT_GLOBAL); - - if (!(res= var->value->val_str(&str))) - return true; if (thd->in_active_multi_stmt_transaction()) { my_error(ER_CANT_DO_THIS_DURING_AN_TRANSACTION, MYF(0)); @@ -2040,6 +2031,31 @@ Sys_var_gtid_binlog_state::do_check(THD *thd, set_var *var) my_error(ER_BINLOG_MUST_BE_EMPTY, MYF(0)); return true; } + return false; +} + + +bool +Sys_var_gtid_binlog_state::global_update(THD *thd, set_var *var) +{ + DBUG_ASSERT(var->type == OPT_GLOBAL); + + if (!var->value) + { + my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str); + return true; + } + + bool result; + String str, *res; + struct gtid_binlog_state_data *data; + rpl_gtid *list; + uint32 list_len; + + DBUG_ASSERT(var->type == OPT_GLOBAL); + + if (!(res= var->value->val_str(&str))) + return true; if (res->length() == 0) { list= NULL; @@ -2061,31 +2077,13 @@ Sys_var_gtid_binlog_state::do_check(THD *thd, set_var *var) data->list= list; data->list_len= list_len; var->save_result.ptr= data; - return false; -} - - -bool -Sys_var_gtid_binlog_state::global_update(THD *thd, set_var *var) -{ - bool res; - - DBUG_ASSERT(var->type == OPT_GLOBAL); - - if (!var->value) - { - my_error(ER_NO_DEFAULT, MYF(0), var->var->name.str); - return true; - } - - struct gtid_binlog_state_data *data= - (struct gtid_binlog_state_data *)var->save_result.ptr; + mysql_mutex_unlock(&LOCK_global_system_variables); - res= (reset_master(thd, data->list, data->list_len, 0) != 0); + result= (reset_master(thd, data->list, data->list_len, 0) != 0); mysql_mutex_lock(&LOCK_global_system_variables); my_free(data->list); my_free(data); - return res; + return result; } From b2429e20252beaa500dc109b12f730dccaf3dd23 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Fri, 20 Sep 2024 18:06:38 +0300 Subject: [PATCH 22/62] MDEV-34976 Server crash report broken if Galera is not loaded The crash report terminates prematurely when Galera library was not loaded. As a fix, check whether the provider is loaded before shutting down Galera connections. Signed-off-by: Julius Goryavsky --- sql/wsrep_server_state.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/wsrep_server_state.cc b/sql/wsrep_server_state.cc index a936d9dd79d..3ed26d3381c 100644 --- a/sql/wsrep_server_state.cc +++ b/sql/wsrep_server_state.cc @@ -87,7 +87,7 @@ void Wsrep_server_state::destroy() void Wsrep_server_state::handle_fatal_signal() { - if (m_instance) + if (m_instance && m_instance->is_provider_loaded()) { /* Galera background threads are still running and the logging may be relatively verbose in case of networking error. Silence all wsrep From 0ce5603b86c2bd526c2b00af448b94f72bf8d1f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 3 Sep 2024 09:07:19 +0300 Subject: [PATCH 23/62] MDEV-33035 : Galera test case MDEV-16509 unstable Stabilize test by reseting DEBUG_SYNC and add wait_condition for expected table contents. Signed-off-by: Julius Goryavsky --- mysql-test/suite/galera/r/MDEV-16509.result | 10 ++++++++++ mysql-test/suite/galera/t/MDEV-16509.test | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/mysql-test/suite/galera/r/MDEV-16509.result b/mysql-test/suite/galera/r/MDEV-16509.result index b56622da2c0..fecb397994c 100644 --- a/mysql-test/suite/galera/r/MDEV-16509.result +++ b/mysql-test/suite/galera/r/MDEV-16509.result @@ -28,6 +28,11 @@ wsrep_last_seen_gtid_do_not_match 1 SET DEBUG_SYNC = "now SIGNAL after_group_continue"; connection node_1; +SELECT * from t1; +f1 +1 +connection ctrl; +SET DEBUG_SYNC = "RESET"; SET SESSION wsrep_sync_wait = 0; connection ctrl; connection node_1; @@ -69,6 +74,11 @@ SET DEBUG_SYNC = "now SIGNAL agac_continue_2"; connection node_1a; connection ctrl; SET DEBUG_SYNC = "RESET"; +SELECT * from t1; +f1 +1 +2 +3 DROP TABLE t1; disconnect ctrl; disconnect node_1a; diff --git a/mysql-test/suite/galera/t/MDEV-16509.test b/mysql-test/suite/galera/t/MDEV-16509.test index 078f1e95a99..3f3e2d88f1b 100644 --- a/mysql-test/suite/galera/t/MDEV-16509.test +++ b/mysql-test/suite/galera/t/MDEV-16509.test @@ -58,6 +58,12 @@ SET DEBUG_SYNC = "now SIGNAL after_group_continue"; --connection node_1 --reap +--let $wait_condition = SELECT COUNT(*) = 1 FROM test.t1; +--source include/wait_condition.inc +SELECT * from t1; + +--connection ctrl +SET DEBUG_SYNC = "RESET"; # # Scenario 2: Verify that two INSERTs from two different connections @@ -137,6 +143,10 @@ SET DEBUG_SYNC = "now SIGNAL agac_continue_2"; --connection ctrl SET DEBUG_SYNC = "RESET"; +--let $wait_condition = SELECT COUNT(*) = 3 FROM test.t1; +--source include/wait_condition.inc +SELECT * from t1; + DROP TABLE t1; --disconnect ctrl From 024e95128ba59a365c7b30858bd207bb59504662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Tue, 3 Sep 2024 12:11:05 +0300 Subject: [PATCH 24/62] MDEV-32996 : galera.galera_var_ignore_apply_errors -> [ERROR] WSREP: Inconsistency detected Add wait_until_ready waits after wsrep_on is set on again to make sure that node is ready for next step before continuing. Signed-off-by: Julius Goryavsky --- .../r/galera_var_ignore_apply_errors.result | 5 ++++- .../galera/t/galera_var_ignore_apply_errors.cnf | 2 +- .../galera/t/galera_var_ignore_apply_errors.test | 15 ++++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/galera/r/galera_var_ignore_apply_errors.result b/mysql-test/suite/galera/r/galera_var_ignore_apply_errors.result index ea8510581bb..17b06017287 100644 --- a/mysql-test/suite/galera/r/galera_var_ignore_apply_errors.result +++ b/mysql-test/suite/galera/r/galera_var_ignore_apply_errors.result @@ -208,7 +208,9 @@ DROP TABLE t1; connection node_2; SELECT * FROM t1; ERROR 42S02: Table 'test.t1' doesn't exist -SET GLOBAL wsrep_ignore_apply_errors = 7; +SET GLOBAL wsrep_ignore_apply_errors = 10; +Warnings: +Warning 1292 Truncated incorrect wsrep_ignore_apply_errors value: '10' CALL mtr.add_suppression("Can't find record in "); CALL mtr.add_suppression("Slave SQL: Could not execute Delete_rows event"); CALL mtr.add_suppression("Slave SQL: Error 'Unknown table 'test\\.t1'' on query\\. Default database: 'test'\\. Query: 'DROP TABLE t1', Error_code: 1051"); @@ -217,3 +219,4 @@ CALL mtr.add_suppression("Slave SQL: Error 'Can't DROP 'idx1'; check that column CALL mtr.add_suppression("Slave SQL: Error 'Can't DROP 'idx1'; check that column/key exists' on query\\. Default database: 'test'\\. Query: 'ALTER TABLE t1 DROP INDEX idx1', Error_code: 1091"); CALL mtr.add_suppression("Slave SQL: Error 'Can't DROP 'f2'; check that column/key exists' on query\\. Default database: 'test'\\. Query: 'ALTER TABLE t1 DROP COLUMN f2', Error_code: 1091"); CALL mtr.add_suppression("Slave SQL: Error 'Table 't1' already exists' on query\\."); +CALL mtr.add_suppression("Inconsistency detected: Inconsistent by consensus on "); diff --git a/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.cnf b/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.cnf index 1d02401decc..fdb73f1f052 100644 --- a/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.cnf +++ b/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.cnf @@ -2,5 +2,5 @@ [mysqld] wsrep_debug=1 -wsrep_sync_wait=15 +wsrep_sync_wait=0 loose-galera-var-ignore-apply-errors=1 diff --git a/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.test b/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.test index d5c6521add4..e5c13dddd29 100644 --- a/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.test +++ b/mysql-test/suite/galera/t/galera_var_ignore_apply_errors.test @@ -17,6 +17,7 @@ SET GLOBAL wsrep_ignore_apply_errors = 1; SET GLOBAL wsrep_on = OFF; CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = ON; +--source include/wait_until_ready.inc DROP TABLE t1; --connection node_2 @@ -27,6 +28,7 @@ SHOW TABLES; SET GLOBAL wsrep_on = OFF; CREATE SCHEMA s1; SET GLOBAL wsrep_on = ON; +--source include/wait_until_ready.inc DROP SCHEMA s1; --connection node_2 @@ -38,6 +40,7 @@ CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = OFF; CREATE INDEX idx1 ON t1 (f1); SET GLOBAL wsrep_on = ON; +--source include/wait_until_ready.inc DROP INDEX idx1 ON t1; --connection node_2 @@ -50,6 +53,7 @@ CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = OFF; CREATE INDEX idx1 ON t1 (f1); SET GLOBAL wsrep_on = ON; +--source include/wait_until_ready.inc ALTER TABLE t1 DROP INDEX idx1; --connection node_2 @@ -62,6 +66,7 @@ CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = OFF; ALTER TABLE t1 ADD COLUMN f2 INTEGER; SET GLOBAL wsrep_on = ON; +--source include/wait_until_ready.inc ALTER TABLE t1 DROP COLUMN f2; --connection node_2 @@ -82,6 +87,7 @@ CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = OFF; INSERT INTO t1 VALUES (1); SET GLOBAL wsrep_on = ON; +--source include/wait_until_ready.inc DELETE FROM t1 WHERE f1 = 1; SELECT COUNT(*) AS expect_0 FROM t1; @@ -96,6 +102,7 @@ INSERT INTO t1 VALUES (2); SET GLOBAL wsrep_on = OFF; INSERT INTO t1 VALUES (1); SET GLOBAL wsrep_on = ON; +--source include/wait_until_ready.inc START TRANSACTION; INSERT INTO t1 VALUES (3); DELETE FROM t1 WHERE f1 = 1; @@ -121,6 +128,7 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5); SET SESSION wsrep_on = OFF; DELETE FROM t1 WHERE f1 = 3; SET SESSION wsrep_on = ON; +--source include/wait_until_ready.inc --connection node_1 DELETE FROM t1; @@ -147,6 +155,7 @@ INSERT INTO t1 VALUES (1),(2),(3),(4),(5); SET SESSION wsrep_on = OFF; DELETE FROM t1 WHERE f1 = 3; SET SESSION wsrep_on = ON; +--source include/wait_until_ready.inc --connection node_1 SET AUTOCOMMIT=OFF; @@ -185,6 +194,7 @@ SET SESSION wsrep_on = OFF; DELETE FROM t2 WHERE f1 = 2; DELETE FROM t1 WHERE f1 = 3; SET SESSION wsrep_on = ON; +--source include/wait_until_ready.inc --connection node_1 DELETE t1, t2 FROM t1 JOIN t2 WHERE t1.f1 = t2.f1; @@ -214,6 +224,7 @@ INSERT INTO child VALUES (1,1),(2,2),(3,3); SET SESSION wsrep_on = OFF; DELETE FROM child WHERE parent_id = 2; SET SESSION wsrep_on = ON; +--source include/wait_until_ready.inc --connection node_1 DELETE FROM parent; @@ -240,6 +251,7 @@ SET GLOBAL wsrep_ignore_apply_errors = 4; SET GLOBAL wsrep_on = OFF; CREATE TABLE t1 (f1 INTEGER); SET GLOBAL wsrep_on = ON; +--source include/wait_until_ready.inc --connection node_1 CREATE TABLE t1 (f1 INTEGER, f2 INTEGER); @@ -248,7 +260,7 @@ DROP TABLE t1; --connection node_2 --error ER_NO_SUCH_TABLE SELECT * FROM t1; -SET GLOBAL wsrep_ignore_apply_errors = 7; +SET GLOBAL wsrep_ignore_apply_errors = 10; CALL mtr.add_suppression("Can't find record in "); CALL mtr.add_suppression("Slave SQL: Could not execute Delete_rows event"); @@ -258,3 +270,4 @@ CALL mtr.add_suppression("Slave SQL: Error 'Can't DROP 'idx1'; check that column CALL mtr.add_suppression("Slave SQL: Error 'Can't DROP 'idx1'; check that column/key exists' on query\\. Default database: 'test'\\. Query: 'ALTER TABLE t1 DROP INDEX idx1', Error_code: 1091"); CALL mtr.add_suppression("Slave SQL: Error 'Can't DROP 'f2'; check that column/key exists' on query\\. Default database: 'test'\\. Query: 'ALTER TABLE t1 DROP COLUMN f2', Error_code: 1091"); CALL mtr.add_suppression("Slave SQL: Error 'Table 't1' already exists' on query\\."); +CALL mtr.add_suppression("Inconsistency detected: Inconsistent by consensus on "); From 9f61aa4f8aeb3cf828b765855af80eac2543e7c2 Mon Sep 17 00:00:00 2001 From: Denis Protivensky Date: Fri, 16 Aug 2024 11:58:06 +0300 Subject: [PATCH 25/62] MDEV-34822 pre-fix: Make wsrep_ready flag read lock-free It's read for every command execution, and during slave replication for every applied event. It's also planned to be used during write set applying, so it means mostly every server thread is going to compete for the mutex covering this variable, especially considering how rarely it changes. Converting wsrep_ready to atomic relaxes the things. Signed-off-by: Julius Goryavsky --- sql/wsrep_mysqld.cc | 11 ++++++----- sql/wsrep_mysqld.h | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 83de938aa13..bc6c185c8d0 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -269,8 +269,8 @@ static char provider_vendor[256]= { 0, }; * Wsrep status variables. LOCK_status must be locked When modifying * these variables, */ +std::atomic wsrep_ready(false); my_bool wsrep_connected = FALSE; -my_bool wsrep_ready = FALSE; const char* wsrep_cluster_state_uuid= cluster_uuid_str; long long wsrep_cluster_conf_id = WSREP_SEQNO_UNDEFINED; const char* wsrep_cluster_status = "Disconnected"; @@ -565,10 +565,7 @@ void wsrep_verify_SE_checkpoint(const wsrep_uuid_t& uuid, */ my_bool wsrep_ready_get (void) { - if (mysql_mutex_lock (&LOCK_wsrep_ready)) abort(); - my_bool ret= wsrep_ready; - mysql_mutex_unlock (&LOCK_wsrep_ready); - return ret; + return wsrep_ready; } int wsrep_show_ready(THD *thd, SHOW_VAR *var, void *buff, @@ -3452,6 +3449,10 @@ bool wsrep_consistency_check(THD *thd) // Wait until wsrep has reached ready state void wsrep_wait_ready(THD *thd) { + // First check not locking the mutex. + if (wsrep_ready) + return; + mysql_mutex_lock(&LOCK_wsrep_ready); while(!wsrep_ready) { diff --git a/sql/wsrep_mysqld.h b/sql/wsrep_mysqld.h index ad2fede8922..d67f1fdf479 100644 --- a/sql/wsrep_mysqld.h +++ b/sql/wsrep_mysqld.h @@ -135,7 +135,6 @@ extern const char *wsrep_SR_store_types[]; // MySQL status variables extern my_bool wsrep_connected; -extern my_bool wsrep_ready; extern const char* wsrep_cluster_state_uuid; extern long long wsrep_cluster_conf_id; extern const char* wsrep_cluster_status; From be164fc401343ed81b9ebd1f6a3cbb31e364a016 Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Wed, 4 Sep 2024 00:58:59 +0000 Subject: [PATCH 26/62] ssl_cipher parameter cannot configure TLSv1.3 and TLSv1.2 ciphers at the same time SSL_CTX_set_ciphersuites() sets the TLSv1.3 cipher suites. SSL_CTX_set_cipher_list() sets the ciphers for TLSv1.2 and below. The current TLS configuration logic will not perform SSL_CTX_set_cipher_list() to configure TLSv1.2 ciphers if the call to SSL_CTX_set_ciphersuites() was successful. The call to SSL_CTX_set_ciphersuites() is successful if any TLSv1.3 cipher suite is passed into `--ssl-cipher`. This is a potential security vulnerability because users trying to restrict specific secure ciphers for TLSv1.3 and TLSv1.2, would unknowingly still have the database support insecure TLSv1.2 ciphers. For example: If setting `--ssl_cipher=TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256`, the database would still support all possible TLSv1.2 ciphers rather than only ECDHE-RSA-AES128-GCM-SHA256. The solution is to execute both SSL_CTX_set_ciphersuites() and SSL_CTX_set_cipher_list() even if the first call succeeds. This allows the configuration of exactly which TLSv1.3 and TLSv1.2 ciphers to support. Note that there is 1 behavior change with this. When specifying only TLSv1.3 ciphers to `--ssl-cipher`, the database will not support any TLSv1.2 cipher. However, this does not impose a security risk and considering TLSv1.3 is the modern protocol, this behavior should be fine. All TLSv1.3 ciphers are still supported if only TLSv1.2 ciphers are specified through `--ssl-cipher`. All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc. --- mysql-test/include/have_tlsv13.inc | 10 +++++++ mysql-test/main/tlsv13.result | 18 +++++++++++++ mysql-test/main/tlsv13.test | 43 ++++++++++++++++++++++++++++++ mysql-test/suite.pm | 3 +++ vio/viosslfactories.c | 20 +++++++++----- 5 files changed, 87 insertions(+), 7 deletions(-) create mode 100644 mysql-test/include/have_tlsv13.inc create mode 100644 mysql-test/main/tlsv13.result create mode 100644 mysql-test/main/tlsv13.test diff --git a/mysql-test/include/have_tlsv13.inc b/mysql-test/include/have_tlsv13.inc new file mode 100644 index 00000000000..ef897d92f97 --- /dev/null +++ b/mysql-test/include/have_tlsv13.inc @@ -0,0 +1,10 @@ +--disable_query_log +connect (ssl_connection,localhost,root,,,,,SSL); + +if (`SELECT VARIABLE_VALUE NOT LIKE 'TLSv1.3' FROM information_schema.SESSION_STATUS WHERE VARIABLE_NAME = 'ssl_version'`) { + skip Needs TLSv1.3; +} + +disconnect ssl_connection; +connection default; +--enable_query_log diff --git a/mysql-test/main/tlsv13.result b/mysql-test/main/tlsv13.result new file mode 100644 index 00000000000..772cfd85eae --- /dev/null +++ b/mysql-test/main/tlsv13.result @@ -0,0 +1,18 @@ +# restart: --ssl-cipher=TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES256-GCM-SHA384 +Variable_name Value +Ssl_cipher TLS_AES_128_GCM_SHA256 +Ssl_cipher_list TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES256-GCM-SHA384 +Variable_name Value +Ssl_cipher ECDHE-RSA-AES256-GCM-SHA384 +Ssl_cipher_list TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES256-GCM-SHA384 +ERROR 2026 (HY000): TLS/SSL error: ssl/tls alert handshake failure +ERROR 2026 (HY000): TLS/SSL error: ssl/tls alert handshake failure +# restart: --ssl-cipher=ECDHE-RSA-AES256-GCM-SHA384 +Variable_name Value +Ssl_cipher TLS_AES_128_GCM_SHA256 +Variable_name Value +Ssl_cipher ECDHE-RSA-AES256-GCM-SHA384 +# restart: --ssl-cipher=TLS_AES_128_GCM_SHA256 +Variable_name Value +Ssl_cipher TLS_AES_128_GCM_SHA256 +Ssl_cipher_list TLS_AES_128_GCM_SHA256 diff --git a/mysql-test/main/tlsv13.test b/mysql-test/main/tlsv13.test new file mode 100644 index 00000000000..f90b6849a86 --- /dev/null +++ b/mysql-test/main/tlsv13.test @@ -0,0 +1,43 @@ +--source include/have_ssl_communication.inc +--source include/require_openssl_client.inc +--source include/have_tlsv13.inc + +# +# BUG - SSL_CIPHER SYSTEM VARIABLE CANNOT CONFIGURE TLSV1.3 AND TLSV1.2 CIPHERS AT THE SAME TIME +# +# If users specify TLSv1.3 and TLSv1.2 ciphers, it will only configure the +# TLSv1.3 ciphers correctly but then it will keep all TLSv1.2 ciphers enabled. +# +# This is a potential security vulnerability because users trying to restrict +# secure TLSv1.3 and TLSv1.2 ciphers will unintentionally have insecure TLSv1.2 +# ciphers enabled on the database. +# +let $restart_parameters=--ssl-cipher=TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES256-GCM-SHA384; +source include/restart_mysqld.inc; + +--exec $MYSQL --host=localhost --ssl-cipher=TLS_AES_128_GCM_SHA256 --tls-version=TLSv1.3 -e "SHOW STATUS LIKE 'Ssl_cipher%';" +--exec $MYSQL --host=localhost --ssl-cipher=ECDHE-RSA-AES256-GCM-SHA384 --tls-version=TLSv1.2 -e "SHOW STATUS LIKE 'Ssl_cipher%';" + +# Check that other ciphers are correctly not supported by the server +--replace_regex /sslv3 alert handshake failure/ssl\/tls alert handshake failure/ +--error 1 +--exec $MYSQL --host=localhost --ssl-cipher=TLS_AES_256_GCM_SHA384 --tls-version=TLSv1.3 -e "SHOW STATUS LIKE 'Ssl_cipher';" 2>&1 + +--replace_regex /sslv3 alert handshake failure/ssl\/tls alert handshake failure/ +--error 1 +--exec $MYSQL --host=localhost --ssl-cipher=ECDHE-RSA-AES128-GCM-SHA256 --tls-version=TLSv1.2 -e "SHOW STATUS LIKE 'Ssl_cipher';" 2>&1 + +# TLSv1.3 ciphers are still supported if only TLSv1.2 ciphers are passed to --ssl-cipher +let $restart_parameters=--ssl-cipher=ECDHE-RSA-AES256-GCM-SHA384; +source include/restart_mysqld.inc; +--exec $MYSQL --host=localhost --ssl-cipher=TLS_AES_128_GCM_SHA256 --tls-version=TLSv1.3 -e "SHOW STATUS LIKE 'Ssl_cipher';" +--exec $MYSQL --host=localhost --ssl-cipher=ECDHE-RSA-AES256-GCM-SHA384 --tls-version=TLSv1.2 -e "SHOW STATUS LIKE 'Ssl_cipher';" +--error 1 +--exec $MYSQL --host=localhost --ssl-cipher=ECDHE-RSA-AES128-GCM-SHA256 --tls-version=TLSv1.2 -e "SHOW STATUS LIKE 'Ssl_cipher';" + +# TLSv1.2 ciphers are not supported if only TLSv1.3 ciphers are passed to --ssl-cipher +let $restart_parameters=--ssl-cipher=TLS_AES_128_GCM_SHA256; +source include/restart_mysqld.inc; +--exec $MYSQL --host=localhost --ssl-cipher=TLS_AES_128_GCM_SHA256 --tls-version=TLSv1.3 -e "SHOW STATUS LIKE 'Ssl_cipher%';" +--error 1 +--exec $MYSQL --host=localhost --ssl-cipher=ECDHE-RSA-AES128-GCM-SHA256 --tls-version=TLSv1.2 -e "SHOW STATUS LIKE 'Ssl_cipher';" diff --git a/mysql-test/suite.pm b/mysql-test/suite.pm index d5c4855ce6e..3270c62b37d 100644 --- a/mysql-test/suite.pm +++ b/mysql-test/suite.pm @@ -71,6 +71,9 @@ sub skip_combinations { $skip{'main/ssl_7937.combinations'} = [ 'x509v3' ] unless $ssl_lib =~ /WolfSSL/ or $openssl_ver ge "1.0.2"; + $skip{'main/tlsv13.test'} = 'does not work with OpenSSL <= 1.1.1' + unless $ssl_lib =~ /WolfSSL/ or $openssl_ver ge "3.0.0"; + $skip{'main/ssl_verify_ip.test'} = 'x509v3 support required' unless $openssl_ver ge "1.0.2"; diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c index 3d007cdd1d8..38dabba822a 100644 --- a/vio/viosslfactories.c +++ b/vio/viosslfactories.c @@ -295,16 +295,22 @@ new_VioSSLFd(const char *key_file, const char *cert_file, /* Set the ciphers that can be used - NOTE: SSL_CTX_set_cipher_list will return 0 if + NOTE: SSL_CTX_set_ciphersuites/SSL_CTX_set_cipher_list will return 0 if none of the provided ciphers could be selected */ - if (cipher && - SSL_CTX_set_ciphersuites(ssl_fd->ssl_context, cipher) == 0 && - SSL_CTX_set_cipher_list(ssl_fd->ssl_context, cipher) == 0) + if (cipher) { - *error= SSL_INITERR_CIPHERS; - DBUG_PRINT("error", ("%s", sslGetErrString(*error))); - goto err2; + int cipher_result= 0; + + cipher_result|= SSL_CTX_set_ciphersuites(ssl_fd->ssl_context, cipher); + cipher_result|= SSL_CTX_set_cipher_list(ssl_fd->ssl_context, cipher); + + if (cipher_result == 0) + { + *error= SSL_INITERR_CIPHERS; + DBUG_PRINT("error", ("%s", sslGetErrString(*error))); + goto err2; + } } /* Load certs from the trusted ca */ From d0a6a7886b9f8ac71f7a9989585c5446de208980 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 23 Jul 2024 14:33:33 +0300 Subject: [PATCH 27/62] MDEV-25822 JSON_TABLE: default values should allow non-string literals (Polished initial patch by Alexey Botchkov) Make the code handle DEFAULT values of any datatype - Make Json_table_column::On_response::m_default be Item*, not LEX_STRING. - Change the parser to use string literal non-terminals for producing the DEFAULT value -- Also, stop updating json_table->m_text_literal_cs for the DEFAULT value literals as it is not used. --- mysql-test/suite/json/r/json_table.result | 45 +++++++++++++++++++ .../suite/json/r/json_table_mysql.result | 12 +++-- mysql-test/suite/json/t/json_table.test | 24 ++++++++++ mysql-test/suite/json/t/json_table_mysql.test | 6 --- sql/json_table.cc | 22 ++++++--- sql/json_table.h | 3 +- sql/sql_yacc.yy | 32 ++++--------- 7 files changed, 101 insertions(+), 43 deletions(-) diff --git a/mysql-test/suite/json/r/json_table.result b/mysql-test/suite/json/r/json_table.result index 20e1a4b1225..2260b8c1f55 100644 --- a/mysql-test/suite/json/r/json_table.result +++ b/mysql-test/suite/json/r/json_table.result @@ -1036,5 +1036,50 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY jt ALL NULL NULL NULL NULL 40 Table function: json_table drop table t1; # +# MDEV-25822: JSON_TABLE: default values should allow non-string literals +# +select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default 0.5 on empty)) as T; +col1 +0.5 +select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default 5 on empty)) as T; +col1 +5 +select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default 'asdf' on empty)) as T; +col1 +asdf +select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default -0.5 on empty)) as T; +col1 +-0.5 +select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default 18446744073709551615 on empty)) as T; +col1 +18446744073709551615 +select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default DATE '2021-01-01' on empty)) as T; +col1 +2021-01-01 +create view v as select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default 5 on empty)) as T; +select * from v; +col1 +5 +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `T`.`col1` AS `col1` from JSON_TABLE('{"a": "b"}', '$' COLUMNS (`col1` varchar(32) PATH '$.fooo' DEFAULT 5 ON EMPTY)) `T` latin1 latin1_swedish_ci +drop view v; +create view v as select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default 18446744073709551615 on empty)) as T; +select * from v; +col1 +18446744073709551615 +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `T`.`col1` AS `col1` from JSON_TABLE('{"a": "b"}', '$' COLUMNS (`col1` varchar(32) PATH '$.fooo' DEFAULT 18446744073709551615 ON EMPTY)) `T` latin1 latin1_swedish_ci +drop view v; +create view v as select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default 'asdf' on empty)) as T; +select * from v; +col1 +asdf +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select `T`.`col1` AS `col1` from JSON_TABLE('{"a": "b"}', '$' COLUMNS (`col1` varchar(32) PATH '$.fooo' DEFAULT 'asdf' ON EMPTY)) `T` latin1 latin1_swedish_ci +drop view v; +# # End of 10.6 tests # diff --git a/mysql-test/suite/json/r/json_table_mysql.result b/mysql-test/suite/json/r/json_table_mysql.result index 699d5a8b4f3..5f9c437ee6b 100644 --- a/mysql-test/suite/json/r/json_table_mysql.result +++ b/mysql-test/suite/json/r/json_table_mysql.result @@ -545,10 +545,12 @@ Warning 1366 Incorrect double value: 'asdf' for column ``.`(temporary)`.`f` at r Warning 1366 Incorrect decimal value: 'asdf' for column ``.`(temporary)`.`d` at row 1 SELECT * FROM JSON_TABLE('{}', '$' COLUMNS (x INT PATH '$.x' DEFAULT NULL ON EMPTY)) jt; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NULL ON EMPTY)) jt' at line 2 +x +NULL SELECT * FROM JSON_TABLE('{}', '$' COLUMNS (x INT PATH '$.x' DEFAULT NULL ON ERROR)) jt; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'NULL ON ERROR)) jt' at line 2 +x +NULL SELECT * FROM JSON_TABLE('{}', '$' COLUMNS (x INT PATH '$.x' DEFAULT 0 ON EMPTY)) jt; x @@ -561,12 +563,14 @@ SELECT * FROM JSON_TABLE('{}', '$' COLUMNS (x DATE PATH '$.x' DEFAULT DATE'2020-01-01' ON EMPTY)) jt; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DATE'2020-01-01' ON EMPTY)) jt' at line 4 +x +2020-01-01 SELECT * FROM JSON_TABLE('{}', '$' COLUMNS (x DATE PATH '$.x' DEFAULT DATE'2020-01-01' ON ERROR)) jt; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DATE'2020-01-01' ON ERROR)) jt' at line 4 +x +NULL # # Bug#25413069: SIG11 IN CHECK_COLUMN_GRANT_IN_TABLE_REF # diff --git a/mysql-test/suite/json/t/json_table.test b/mysql-test/suite/json/t/json_table.test index 580a8507c8f..ae8deffc0fe 100644 --- a/mysql-test/suite/json/t/json_table.test +++ b/mysql-test/suite/json/t/json_table.test @@ -893,6 +893,30 @@ explain select c, drop table t1; +--echo # +--echo # MDEV-25822: JSON_TABLE: default values should allow non-string literals +--echo # +select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default 0.5 on empty)) as T; +select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default 5 on empty)) as T; +select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default 'asdf' on empty)) as T; +select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default -0.5 on empty)) as T; +select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default 18446744073709551615 on empty)) as T; +select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default DATE '2021-01-01' on empty)) as T; + +create view v as select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default 5 on empty)) as T; +select * from v; +show create view v; +drop view v; +create view v as select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default 18446744073709551615 on empty)) as T; +select * from v; +show create view v; +drop view v; +create view v as select * from json_table('{"a": "b"}', '$' columns(col1 varchar(32) path '$.fooo' default 'asdf' on empty)) as T; +select * from v; +show create view v; +drop view v; + + --echo # --echo # End of 10.6 tests --echo # diff --git a/mysql-test/suite/json/t/json_table_mysql.test b/mysql-test/suite/json/t/json_table_mysql.test index 9f77ad964f3..8595c0e15e8 100644 --- a/mysql-test/suite/json/t/json_table_mysql.test +++ b/mysql-test/suite/json/t/json_table_mysql.test @@ -445,11 +445,8 @@ SELECT * FROM JSON_TABLE('"asdf"', '$' COLUMNS( f FLOAT PATH '$', d DECIMAL PATH '$')) AS jt; -# DEFAULT NULL is not accepted syntax. ---error ER_PARSE_ERROR SELECT * FROM JSON_TABLE('{}', '$' COLUMNS (x INT PATH '$.x' DEFAULT NULL ON EMPTY)) jt; ---error ER_PARSE_ERROR SELECT * FROM JSON_TABLE('{}', '$' COLUMNS (x INT PATH '$.x' DEFAULT NULL ON ERROR)) jt; @@ -457,13 +454,10 @@ SELECT * FROM JSON_TABLE('{}', '$' COLUMNS (x INT PATH '$.x' DEFAULT 0 ON EMPTY)) jt; SELECT * FROM JSON_TABLE('{}', '$' COLUMNS (x INT PATH '$.x' DEFAULT 0 ON ERROR)) jt; -# We don't accept dates in DEFAULT ---error 1064 SELECT * FROM JSON_TABLE('{}', '$' COLUMNS (x DATE PATH '$.x' DEFAULT DATE'2020-01-01' ON EMPTY)) jt; ---error 1064 SELECT * FROM JSON_TABLE('{}', '$' COLUMNS (x DATE PATH '$.x' diff --git a/sql/json_table.cc b/sql/json_table.cc index d4ba9f88a78..86f565aa561 100644 --- a/sql/json_table.cc +++ b/sql/json_table.cc @@ -1030,8 +1030,7 @@ int Json_table_column::On_response::respond(Json_table_column *jc, Field *f, return 1; case Json_table_column::RESPONSE_DEFAULT: f->set_notnull(); - f->store(m_default.str, - m_default.length, jc->m_defaults_cs); + m_default->save_in_field(f, TRUE); break; } return 0; @@ -1041,7 +1040,11 @@ int Json_table_column::On_response::respond(Json_table_column *jc, Field *f, int Json_table_column::On_response::print(const char *name, String *str) const { LEX_CSTRING resp; - const LEX_CSTRING *ds= NULL; + + char valbuf[512]; + String val(valbuf, sizeof(valbuf), str->charset()); + String *ds= NULL; + if (m_response == Json_table_column::RESPONSE_NOT_SPECIFIED) return 0; @@ -1056,7 +1059,7 @@ int Json_table_column::On_response::print(const char *name, String *str) const case Json_table_column::RESPONSE_DEFAULT: { lex_string_set3(&resp, STRING_WITH_LEN("DEFAULT")); - ds= &m_default; + ds= m_default->val_str(&val); break; } default: @@ -1065,9 +1068,14 @@ int Json_table_column::On_response::print(const char *name, String *str) const } return (str->append(' ') || str->append(resp) || - (ds && (str->append(STRING_WITH_LEN(" '")) || - str->append_for_single_quote(ds->str, ds->length) || - str->append('\''))) || + (ds && + (str->append(' ') || + (m_default->result_type()==STRING_RESULT && str->append('\''))|| + + str->append_for_single_quote(ds) || + + (m_default->result_type()==STRING_RESULT && str->append('\''))))|| + str->append(STRING_WITH_LEN(" ON ")) || str->append(name, strlen(name))); } diff --git a/sql/json_table.h b/sql/json_table.h index 7316edd4ee6..545dfb0aa90 100644 --- a/sql/json_table.h +++ b/sql/json_table.h @@ -140,7 +140,7 @@ public: { public: Json_table_column::enum_on_response m_response; - LEX_CSTRING m_default; + Item *m_default; int respond(Json_table_column *jc, Field *f, uint error_num); int print(const char *name, String *str) const; bool specified() const { return m_response != RESPONSE_NOT_SPECIFIED; } @@ -154,7 +154,6 @@ public: Create_field *m_field; Json_table_nested_path *m_nest; CHARSET_INFO *m_explicit_cs; - CHARSET_INFO *m_defaults_cs; void set(enum_type ctype) { diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index ed2bcd5deb9..50a115a3201 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1328,7 +1328,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); TEXT_STRING NCHAR_STRING json_text_literal - json_text_literal_or_num %type opt_table_alias_clause @@ -1512,6 +1511,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); simple_target_specification condition_number opt_versioning_interval_start + json_default_literal %type param_marker @@ -11595,26 +11595,6 @@ json_text_literal: } ; -json_text_literal_or_num: - json_text_literal - | NUM - { - Lex->json_table->m_text_literal_cs= NULL; - } - | LONG_NUM - { - Lex->json_table->m_text_literal_cs= NULL; - } - | DECIMAL_NUM - { - Lex->json_table->m_text_literal_cs= NULL; - } - | FLOAT_NUM - { - Lex->json_table->m_text_literal_cs= NULL; - } - ; - join_table_list: derived_table_list { MYSQL_YYABORT_UNLESS($$=$1); } ; @@ -11720,6 +11700,12 @@ json_opt_on_empty_or_error: | json_on_empty_response json_on_error_response ; +json_default_literal: + literal + | signed_literal + ; + + json_on_response: ERROR_SYM { @@ -11729,12 +11715,10 @@ json_on_response: { $$.m_response= Json_table_column::RESPONSE_NULL; } - | DEFAULT json_text_literal_or_num + | DEFAULT json_default_literal { $$.m_response= Json_table_column::RESPONSE_DEFAULT; $$.m_default= $2; - Lex->json_table->m_cur_json_table_column->m_defaults_cs= - thd->variables.collation_connection; } ; From ce272f7c2959d4fcf1cefc9d048e7ff90f0b31a6 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 23 Jul 2024 14:58:24 +0300 Subject: [PATCH 28/62] Remove unused Table_function_json_table::m_text_literal_cs --- sql/json_table.h | 3 --- sql/sql_yacc.yy | 7 ------- 2 files changed, 10 deletions(-) diff --git a/sql/json_table.h b/sql/json_table.h index 545dfb0aa90..d228fdb1fad 100644 --- a/sql/json_table.h +++ b/sql/json_table.h @@ -260,9 +260,6 @@ public: /* SQL Parser: current column in JSON_TABLE (...) syntax */ Json_table_column *m_cur_json_table_column; - /* SQL Parser: charset of the current text literal */ - CHARSET_INFO *m_text_literal_cs; - private: /* Context to be used for resolving the first argument. */ Name_resolution_context *m_context; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 50a115a3201..9a21a93c788 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -11581,16 +11581,9 @@ table_ref: json_text_literal: TEXT_STRING - { - Lex->json_table->m_text_literal_cs= NULL; - } | NCHAR_STRING - { - Lex->json_table->m_text_literal_cs= national_charset_info; - } | UNDERSCORE_CHARSET TEXT_STRING { - Lex->json_table->m_text_literal_cs= $1; $$= $2; } ; From 2c0b7ff2b4b11fa82ff074ab1f4d24885c1dad47 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 27 Sep 2024 14:42:53 +0200 Subject: [PATCH 29/62] Windows : support Wix toolset 3.14 Chocolatey package manager installs this one. --- win/packaging/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/packaging/CMakeLists.txt b/win/packaging/CMakeLists.txt index ba4a631f5fd..191809aa96b 100644 --- a/win/packaging/CMakeLists.txt +++ b/win/packaging/CMakeLists.txt @@ -23,7 +23,7 @@ ENDIF() SET(MANUFACTURER "MariaDB Corporation Ab") SET(WIX_BIN_PATHS) -FOREACH(WIX_VER 3.9 3.10 3.11) +FOREACH(WIX_VER 3.9 3.10 3.11 3.14) LIST(APPEND WIX_BIN_PATHS "$ENV{ProgramFiles}/WiX Toolset v${WIX_VER}/bin") LIST(APPEND WIX_BIN_PATHS "$ENV{ProgramFiles} (x86)/WiX Toolset v${WIX_VER}/bin") ENDFOREACH() From 78e640ea3e02d1b2a4605c0fc78356eee6b4b87a Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Fri, 27 Sep 2024 14:44:20 +0200 Subject: [PATCH 30/62] MDEV-34808 Update HeidiSQL to v12.8 --- win/packaging/heidisql.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/packaging/heidisql.cmake b/win/packaging/heidisql.cmake index 681a4250e65..f745eeb060b 100644 --- a/win/packaging/heidisql.cmake +++ b/win/packaging/heidisql.cmake @@ -1,4 +1,4 @@ -SET(HEIDISQL_BASE_NAME "HeidiSQL_12.6_32_Portable") +SET(HEIDISQL_BASE_NAME "HeidiSQL_12.8_32_Portable") SET(HEIDISQL_ZIP "${HEIDISQL_BASE_NAME}.zip") SET(HEIDISQL_URL "http://www.heidisql.com/downloads/releases/${HEIDISQL_ZIP}") SET(HEIDISQL_DOWNLOAD_DIR ${THIRD_PARTY_DOWNLOAD_LOCATION}/${HEIDISQL_BASE_NAME}) From cf0c3ec27458523cdab9a756943db40bbdcad55f Mon Sep 17 00:00:00 2001 From: sjaakola Date: Wed, 28 Dec 2022 19:44:41 +0200 Subject: [PATCH 31/62] MDEV-30307 KILL command inside a transaction causes problem for galera replication Added new test scenario in galera.galera_bf_kill test to make the issue surface. The tetst scenario has a multi statement transaction containing a KILL command. When the KILL is submitted, another transaction is replicated, which causes BF abort for the KILL command processing. Handling BF abort rollback while executing KILL command causes node hanging, in this scenario. sql_kill() and sql_kill_user() functions have now fix, to perform implicit commit before starting the KILL command execution. BEcause of the implicit commit, the KILL execution will not happen inside transaction context anymore. Signed-off-by: Julius Goryavsky --- .../suite/galera/r/galera_bf_kill.result | 29 ++++++++ mysql-test/suite/galera/t/galera_bf_kill.test | 67 +++++++++++++++++++ sql/sql_parse.cc | 41 +++++++++++- 3 files changed, 136 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/r/galera_bf_kill.result b/mysql-test/suite/galera/r/galera_bf_kill.result index 71b0366081b..41e7f2b0db0 100644 --- a/mysql-test/suite/galera/r/galera_bf_kill.result +++ b/mysql-test/suite/galera/r/galera_bf_kill.result @@ -77,4 +77,33 @@ a b 5 2 disconnect node_2a; connection node_1; +connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; +connection node_2a; +truncate t1; +insert into t1 values (7,0); +connection node_2; +set wsrep_sync_wait=0; +begin; +update t1 set b=2 where a=7; +connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2; +set wsrep_sync_wait=0; +SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb"; +connection node_1; +update t1 set b=1 where a=7; +connection node_2b; +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; +connection node_2; +connection node_2b; +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; +connection node_2; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +commit; +select * from t1; +a b +7 1 +connection node_2a; +SET DEBUG_SYNC= 'RESET'; +SET GLOBAL debug_dbug = ""; drop table t1; +disconnect node_2a; +disconnect node_2b; diff --git a/mysql-test/suite/galera/t/galera_bf_kill.test b/mysql-test/suite/galera/t/galera_bf_kill.test index 1b35b609a96..b952d567556 100644 --- a/mysql-test/suite/galera/t/galera_bf_kill.test +++ b/mysql-test/suite/galera/t/galera_bf_kill.test @@ -154,4 +154,71 @@ select * from t1; --disconnect node_2a --connection node_1 + +# +# Test case 7: Start a transaction on node_2 and use KILL to abort +# a query in connection node_2a +# During the KILL execution replicate conflicting transaction from node_1 +# to BF abort the transaction executing the KILL +# + +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--connection node_2a +truncate t1; +insert into t1 values (7,0); + +--connection node_2 +set wsrep_sync_wait=0; + +# get the ID of connection to be later killed +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1 +--source include/wait_condition.inc +--let $k_thread = `SELECT ID FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND COMMAND = 'Sleep' LIMIT 1` + +# start a transaction +begin; +update t1 set b=2 where a=7; + +# set sync point for incoming applying +--connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2 +set wsrep_sync_wait=0; + +SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb"; + +# replicate conflicting transaction, should stopp in the sync point +--connection node_1 +update t1 set b=1 where a=7; + +# wait for the applier to reach the sync point +--connection node_2b +SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; + +# issue KILL inside the transacion, implicit commit is expected +--connection node_2 +--disable_query_log +--send_eval KILL QUERY $k_thread +--enable_query_log + +# wait for the KILL processing to be seen in processlist +--connection node_2b +--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE USER = 'root' AND INFO LIKE 'KILL QUERY%' +--source include/wait_condition.inc + +# resume applying, BF abort should follow +SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; + +--connection node_2 +--error ER_LOCK_DEADLOCK +--reap + +commit; + +select * from t1; + +--connection node_2a +SET DEBUG_SYNC= 'RESET'; +SET GLOBAL debug_dbug = ""; + drop table t1; +--disconnect node_2a +--disconnect node_2b diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 377d3051794..e0c87ec2117 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -9599,8 +9599,27 @@ static void sql_kill(THD *thd, my_thread_id id, killed_state state, killed_type type) { #ifdef WITH_WSREP + if (WSREP(thd)) + { + if (!(thd->variables.option_bits & OPTION_GTID_BEGIN)) + { + WSREP_DEBUG("implicit commit before KILL"); + /* Commit the normal transaction if one is active. */ + bool commit_failed= trans_commit_implicit(thd); + /* Release metadata locks acquired in this transaction. */ + thd->release_transactional_locks(); + if (commit_failed || wsrep_after_statement(thd)) + { + WSREP_DEBUG("implicit commit failed, MDL released: %lld", + (longlong) thd->thread_id); + return; + } + thd->transaction->stmt.mark_trans_did_ddl(); + } + } + bool wsrep_high_priority= false; -#endif +#endif /* WITH_WSREP */ uint error= kill_one_thread(thd, id, state, type #ifdef WITH_WSREP , wsrep_high_priority @@ -9632,6 +9651,26 @@ sql_kill_user(THD *thd, LEX_USER *user, killed_state state) { uint error; ha_rows rows; +#ifdef WITH_WSREP + if (WSREP(thd)) + { + if (!(thd->variables.option_bits & OPTION_GTID_BEGIN)) + { + WSREP_DEBUG("implicit commit before KILL"); + /* Commit the normal transaction if one is active. */ + bool commit_failed= trans_commit_implicit(thd); + /* Release metadata locks acquired in this transaction. */ + thd->release_transactional_locks(); + if (commit_failed || wsrep_after_statement(thd)) + { + WSREP_DEBUG("implicit commit failed, MDL released: %lld", + (longlong) thd->thread_id); + return; + } + thd->transaction->stmt.mark_trans_did_ddl(); + } + } +#endif /* WITH_WSREP */ switch (error= kill_threads_for_user(thd, user, state, &rows)) { case 0: From 95d285fb752dcf0f80045e7a24d9c417d6ffbb1b Mon Sep 17 00:00:00 2001 From: Julius Goryavsky Date: Mon, 30 Sep 2024 00:31:48 +0200 Subject: [PATCH 32/62] MDEV-30307 addendum: support for compilation in release mode --- .../suite/galera/r/galera_bf_kill,debug.rdiff | 37 +++++++++++++++++++ .../suite/galera/r/galera_bf_kill.result | 29 --------------- mysql-test/suite/galera/t/galera_bf_kill.test | 8 +++- 3 files changed, 44 insertions(+), 30 deletions(-) create mode 100644 mysql-test/suite/galera/r/galera_bf_kill,debug.rdiff diff --git a/mysql-test/suite/galera/r/galera_bf_kill,debug.rdiff b/mysql-test/suite/galera/r/galera_bf_kill,debug.rdiff new file mode 100644 index 00000000000..e02acc3de08 --- /dev/null +++ b/mysql-test/suite/galera/r/galera_bf_kill,debug.rdiff @@ -0,0 +1,37 @@ +--- a/home/panda/mariadb-10.5/mysql-test/suite/galera/r/galera_bf_kill.result ++++ b/home/panda/mariadb-10.5/mysql-test/suite/galera/r/galera_bf_kill.reject +@@ -77,4 +77,34 @@ a b + 5 2 + disconnect node_2a; + connection node_1; ++connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; ++connection node_2a; ++truncate t1; ++insert into t1 values (7,0); ++connection node_2; ++set wsrep_sync_wait=0; ++begin; ++update t1 set b=2 where a=7; ++connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2; ++set wsrep_sync_wait=0; ++SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb"; ++connection node_1; ++update t1 set b=1 where a=7; ++connection node_2b; ++SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; ++connection node_2; ++connection node_2b; ++SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; ++connection node_2; ++ERROR 40001: Deadlock found when trying to get lock; try restarting transaction ++commit; ++select * from t1; ++a b ++7 1 ++connection node_2a; ++SET DEBUG_SYNC= 'RESET'; ++SET GLOBAL debug_dbug = ""; ++disconnect node_2a; ++disconnect node_2b; ++connection node_1; + drop table t1; diff --git a/mysql-test/suite/galera/r/galera_bf_kill.result b/mysql-test/suite/galera/r/galera_bf_kill.result index 41e7f2b0db0..71b0366081b 100644 --- a/mysql-test/suite/galera/r/galera_bf_kill.result +++ b/mysql-test/suite/galera/r/galera_bf_kill.result @@ -77,33 +77,4 @@ a b 5 2 disconnect node_2a; connection node_1; -connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2; -connection node_2a; -truncate t1; -insert into t1 values (7,0); -connection node_2; -set wsrep_sync_wait=0; -begin; -update t1 set b=2 where a=7; -connect node_2b, 127.0.0.1, root, , test, $NODE_MYPORT_2; -set wsrep_sync_wait=0; -SET GLOBAL debug_dbug = "d,sync.wsrep_apply_cb"; -connection node_1; -update t1 set b=1 where a=7; -connection node_2b; -SET SESSION DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_cb_reached"; -connection node_2; -connection node_2b; -SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_cb"; -connection node_2; -ERROR 40001: Deadlock found when trying to get lock; try restarting transaction -commit; -select * from t1; -a b -7 1 -connection node_2a; -SET DEBUG_SYNC= 'RESET'; -SET GLOBAL debug_dbug = ""; drop table t1; -disconnect node_2a; -disconnect node_2b; diff --git a/mysql-test/suite/galera/t/galera_bf_kill.test b/mysql-test/suite/galera/t/galera_bf_kill.test index b952d567556..1cb2e866cb4 100644 --- a/mysql-test/suite/galera/t/galera_bf_kill.test +++ b/mysql-test/suite/galera/t/galera_bf_kill.test @@ -155,6 +155,8 @@ select * from t1; --connection node_1 +source include/maybe_debug.inc; +if ($have_debug) { # # Test case 7: Start a transaction on node_2 and use KILL to abort # a query in connection node_2a @@ -219,6 +221,10 @@ select * from t1; SET DEBUG_SYNC= 'RESET'; SET GLOBAL debug_dbug = ""; -drop table t1; --disconnect node_2a --disconnect node_2b + +--connection node_1 +} + +drop table t1; From 69874ee95c337cad36224ecd4b37293ea87caed4 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Mon, 30 Sep 2024 15:12:00 +1000 Subject: [PATCH 33/62] MDEV-34828 Remove some obsolete cmake code related to the removed spider handlersocket support A fixup of MDEV-26858 --- storage/spider/CMakeLists.txt | 5 -- storage/spider/Makefile.am | 89 ---------------------------- storage/spider/hs_client/hs_compat.h | 24 -------- storage/spider/spd_db_include.h | 5 +- 4 files changed, 4 insertions(+), 119 deletions(-) delete mode 100644 storage/spider/Makefile.am delete mode 100644 storage/spider/hs_client/hs_compat.h diff --git a/storage/spider/CMakeLists.txt b/storage/spider/CMakeLists.txt index 11304d05b18..cde6de6142b 100644 --- a/storage/spider/CMakeLists.txt +++ b/storage/spider/CMakeLists.txt @@ -1,6 +1,3 @@ -SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_HANDLERSOCKET") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_HANDLERSOCKET") - IF(HAVE_WVLA) SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-vla") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-vla") @@ -45,8 +42,6 @@ IF(EXISTS ${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake) ELSEIF(PLUGIN_PARTITION MATCHES "^NO$") MESSAGE(STATUS "Spider is skipped because partitioning is disabled") ELSE() - INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/spider/hs_client) - IF(DEB) SET(extra_options COMPONENT spider-engine) ELSE() diff --git a/storage/spider/Makefile.am b/storage/spider/Makefile.am deleted file mode 100644 index 3847b3f2332..00000000000 --- a/storage/spider/Makefile.am +++ /dev/null @@ -1,89 +0,0 @@ -HAVE_HANDLERSOCKET = "-DHAVE_HANDLERSOCKET" - -pkgplugindir = $(pkglibdir)/plugin -INCLUDES = -I$(SPD_MYSQL_INC)$(top_srcdir)/include \ - -I$(SPD_MYSQL_INC)$(top_srcdir)/regex \ - -I$(SPD_MYSQL_INC)$(top_srcdir)/sql \ - -I$(SPD_MYSQL_INC)$(top_srcdir)/extra/yassl/include \ - -I./hs_client \ - $(MYSQL_INCLUDE_PATH) \ - $(HANDLERSOCKET_INCLUDE_PATH) - -noinst_HEADERS = ha_spider.h spd_conn.h spd_db_conn.h \ - spd_db_include.h spd_err.h spd_sys_table.h \ - spd_table.h spd_trx.h spd_include.h spd_param.h \ - spd_direct_sql.h spd_udf.h spd_ping_table.h \ - spd_copy_tables.h spd_malloc.h \ - spd_db_mysql.h spd_db_handlersocket.h \ - hs_client/allocator.hpp hs_client/config.hpp \ - hs_client/mutex.hpp hs_client/string_util.hpp \ - hs_client/auto_addrinfo.hpp hs_client/escape.hpp \ - hs_client/socket.hpp hs_client/thread.hpp \ - hs_client/auto_file.hpp hs_client/fatal.hpp \ - hs_client/string_buffer.hpp hs_client/util.hpp \ - hs_client/auto_ptrcontainer.hpp \ - hs_client/hstcpcli.hpp hs_client/string_ref.hpp \ - hs_client/hs_compat.h - -lib_LTLIBRARIES = $(PLUGIN_SPIDER_LTLIBRARIES_TARGET) -EXTRA_LTLIBRARIES = ha_spider.la -pkgplugin_LTLIBRARIES = @plugin_spider_shared_target@ -ha_spider_la_LDFLAGS = -shared -module -rpath $(pkgplugindir) -ha_spider_la_CXXFLAGS = $(AM_CXXFLAGS) -DMYSQL_DYNAMIC_PLUGIN \ - $(HAVE_HANDLERSOCKET) -ha_spider_la_CFLAGS = $(AM_CFLAGS) -DMYSQL_DYNAMIC_PLUGIN \ - $(HAVE_HANDLERSOCKET) -ha_spider_la_SOURCES = \ - spd_param.cc \ - spd_sys_table.cc \ - spd_trx.cc \ - spd_db_conn.cc \ - spd_conn.cc \ - spd_table.cc \ - spd_direct_sql.cc \ - spd_udf.cc \ - spd_ping_table.cc \ - spd_copy_tables.cc \ - spd_i_s.cc \ - spd_malloc.cc \ - ha_spider.cc \ - spd_db_mysql.cc \ - spd_db_handlersocket.cc \ - hs_client/config.cpp \ - hs_client/escape.cpp \ - hs_client/fatal.cpp \ - hs_client/hstcpcli.cpp \ - hs_client/socket.cpp \ - hs_client/string_util.cpp - -lib_LIBRARIES = $(PLUGIN_SPIDER_LIBRARIES_TARGET) -EXTRA_LIBRARIES = libspider.a -noinst_LIBRARIES = @plugin_spider_static_target@ -libspider_a_CXXFLAGS = $(AM_CXXFLAGS) $(HAVE_HANDLERSOCKET) -libspider_a_CFLAGS = $(AM_CFLAGS) $(HAVE_HANDLERSOCKET) -libspider_a_SOURCES = \ - spd_param.cc \ - spd_sys_table.cc \ - spd_trx.cc \ - spd_db_conn.cc \ - spd_conn.cc \ - spd_table.cc \ - spd_direct_sql.cc \ - spd_udf.cc \ - spd_ping_table.cc \ - spd_copy_tables.cc \ - spd_i_s.cc \ - spd_malloc.cc \ - ha_spider.cc \ - spd_db_mysql.cc \ - spd_db_handlersocket.cc \ - hs_client/config.cpp \ - hs_client/escape.cpp \ - hs_client/fatal.cpp \ - hs_client/hstcpcli.cpp \ - hs_client/socket.cpp \ - hs_client/string_util.cpp - -EXTRA_DIST = plug.in -# Don't update the files from bitkeeper -%::SCCS/s.% diff --git a/storage/spider/hs_client/hs_compat.h b/storage/spider/hs_client/hs_compat.h deleted file mode 100644 index b12711fa3d1..00000000000 --- a/storage/spider/hs_client/hs_compat.h +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (C) 2013-2018 Kentoku Shiba - - 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 Foundation; version 2 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ - -#ifndef HS_COMPAT_H -#define HS_COMPAT_H - -#define SPD_INIT_DYNAMIC_ARRAY2(A, B, C, D, E, F) \ - my_init_dynamic_array2(PSI_INSTRUMENT_ME, A, B, C, D, E, F) -#define SPD_INIT_ALLOC_ROOT(A, B, C, D) \ - init_alloc_root(PSI_INSTRUMENT_ME, A, B, C, D) - -#endif diff --git a/storage/spider/spd_db_include.h b/storage/spider/spd_db_include.h index ac031dfe64d..17ae8a42704 100644 --- a/storage/spider/spd_db_include.h +++ b/storage/spider/spd_db_include.h @@ -14,7 +14,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ -#include "hs_compat.h" +#define SPD_INIT_DYNAMIC_ARRAY2(A, B, C, D, E, F) \ + my_init_dynamic_array2(PSI_INSTRUMENT_ME, A, B, C, D, E, F) +#define SPD_INIT_ALLOC_ROOT(A, B, C, D) \ + init_alloc_root(PSI_INSTRUMENT_ME, A, B, C, D) #define SPIDER_DBTON_SIZE 15 From f43ea935a1220c534f692ac85f85b654a9f2d15a Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 25 Jul 2024 17:24:13 +0800 Subject: [PATCH 34/62] MDEV-34636 Remove implementation of ha-spider::extra() with MERGE flags --- storage/spider/ha_spider.cc | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 1eb0dc6e53f..701d0c6eba3 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -1223,7 +1223,6 @@ int ha_spider::reset() int ha_spider::extra( enum ha_extra_function operation ) { - int error_num; DBUG_ENTER("ha_spider::extra"); DBUG_PRINT("info",("spider this=%p", this)); DBUG_PRINT("info",("spider operation=%d", (int) operation)); @@ -1273,16 +1272,6 @@ int ha_spider::extra( case HA_EXTRA_INSERT_WITH_UPDATE: wide_handler->insert_with_update = TRUE; break; - case HA_EXTRA_ATTACH_CHILDREN: - DBUG_PRINT("info",("spider HA_EXTRA_ATTACH_CHILDREN")); - if (!(wide_handler->trx = spider_get_trx(ha_thd(), TRUE, &error_num))) - DBUG_RETURN(error_num); - break; - case HA_EXTRA_ADD_CHILDREN_LIST: - DBUG_PRINT("info",("spider HA_EXTRA_ADD_CHILDREN_LIST")); - if (!(wide_handler->trx = spider_get_trx(ha_thd(), TRUE, &error_num))) - DBUG_RETURN(error_num); - break; case HA_EXTRA_STARTING_ORDERED_INDEX_SCAN: DBUG_PRINT("info",("spider HA_EXTRA_STARTING_ORDERED_INDEX_SCAN")); if (table_share->primary_key != MAX_KEY) From 42735c557e7f5f515684e649f112abfd59b18aba Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Fri, 2 Aug 2024 15:27:35 +1000 Subject: [PATCH 35/62] MDEV-34636 Spider: reset wide_handler->trx in two occasions ha_spider::update_create_info() ha_spider::append_lock_tables_list() --- storage/spider/ha_spider.cc | 11 +++---- .../spider/bugfix/r/mdev_34636.result | 20 +++++++++++++ .../spider/bugfix/t/mdev_34636.test | 29 +++++++++++++++++++ 3 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_34636.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_34636.test diff --git a/storage/spider/ha_spider.cc b/storage/spider/ha_spider.cc index 701d0c6eba3..b4be3c2fd8e 100644 --- a/storage/spider/ha_spider.cc +++ b/storage/spider/ha_spider.cc @@ -5746,13 +5746,6 @@ int ha_spider::info( DBUG_PRINT("info",("spider flag=%x", flag)); auto_inc_temporary = FALSE; wide_handler->sql_command = thd_sql_command(thd); -/* - if ( - sql_command == SQLCOM_DROP_TABLE || - sql_command == SQLCOM_ALTER_TABLE || - sql_command == SQLCOM_SHOW_CREATE - ) { -*/ if (flag & HA_STATUS_AUTO) { if (share->lgtm_tblhnd_share->auto_increment_value) @@ -8131,6 +8124,8 @@ void ha_spider::update_create_info( DBUG_PRINT("info",("spider this=%p", this)); if (wide_handler && wide_handler->sql_command == SQLCOM_ALTER_TABLE) { + if (!(wide_handler->trx = spider_get_trx(ha_thd(), TRUE, &store_error_num))) + DBUG_VOID_RETURN; SPIDER_TRX *trx = wide_handler->trx; THD *thd = trx->thd; if (trx->query_id != thd->query_id) @@ -11621,6 +11616,8 @@ int ha_spider::append_lock_tables_list() DBUG_PRINT("info",("spider lock_table_type=%u", wide_handler->lock_table_type)); + if (!(wide_handler->trx = spider_get_trx(ha_thd(), TRUE, &error_num))) + DBUG_RETURN(error_num); if ((error_num = spider_check_trx_and_get_conn(wide_handler->trx->thd, this, FALSE))) { diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_34636.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_34636.result new file mode 100644 index 00000000000..472a050a4f3 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_34636.result @@ -0,0 +1,20 @@ +for master_1 +for child2 +for child3 +set spider_same_server_link= 1; +CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); +CREATE TABLE t1 (c1 TIME) ENGINE=Spider PARTITION BY HASH(EXTRACT(HOUR_SECOND FROM c1)); +CREATE TABLE t2 (c1 INT) ENGINE=MyISAM; +CREATE TABLE t3 (c1 INT,c2 INT) ENGINE=Spider COMMENT='WRAPPER "mysql",SRV "srv",TABLE "t1"'; +INSERT INTO t2 SELECT * FROM t3; +ERROR 21S01: Column count doesn't match value count at row 1 +SELECT * FROM t3; +ERROR HY000: Unable to connect to foreign data source: localhost +ALTER TABLE t1 CHANGE COLUMN c1 d1 INT; +ERROR HY000: Constant, random or timezone-dependent expressions in (sub)partitioning function are not allowed +DROP TABLE t1,t2,t3; +drop server srv; +for master_1 +for child2 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_34636.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_34636.test new file mode 100644 index 00000000000..08a699b9370 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_34636.test @@ -0,0 +1,29 @@ +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log + +set spider_same_server_link= 1; +evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root'); + +CREATE TABLE t1 (c1 TIME) ENGINE=Spider PARTITION BY HASH(EXTRACT(HOUR_SECOND FROM c1)); +CREATE TABLE t2 (c1 INT) ENGINE=MyISAM; +CREATE TABLE t3 (c1 INT,c2 INT) ENGINE=Spider COMMENT='WRAPPER "mysql",SRV "srv",TABLE "t1"'; +--error ER_WRONG_VALUE_COUNT_ON_ROW +INSERT INTO t2 SELECT * FROM t3; +--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE +SELECT * FROM t3; +--error ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR +ALTER TABLE t1 CHANGE COLUMN c1 d1 INT; +# Cleanup +DROP TABLE t1,t2,t3; + +drop server srv; + +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log From 282b92f0a2b461e99d6d8876cdc4a1673a8b6b62 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 18 Jul 2024 17:26:27 +0800 Subject: [PATCH 36/62] MDEV-34589 Do not execute before queries in spider_db_mbase::rollback() Rollback is not supposed to fail. This prevents false failures in spider rollback. --- .../spider/bugfix/r/mdev_34589.result | 23 ++++++++++++++++++ .../spider/bugfix/t/mdev_34589.test | 24 +++++++++++++++++++ storage/spider/spd_db_mysql.cc | 14 ++++++++--- 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 storage/spider/mysql-test/spider/bugfix/r/mdev_34589.result create mode 100644 storage/spider/mysql-test/spider/bugfix/t/mdev_34589.test diff --git a/storage/spider/mysql-test/spider/bugfix/r/mdev_34589.result b/storage/spider/mysql-test/spider/bugfix/r/mdev_34589.result new file mode 100644 index 00000000000..557c9031330 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/r/mdev_34589.result @@ -0,0 +1,23 @@ +for master_1 +for child2 +for child3 +set spider_same_server_link= 1; +CREATE USER spider@localhost IDENTIFIED BY 'pwd'; +GRANT ALL ON test.* TO spider@localhost; +CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'spider',PASSWORD 'pwd'); +SET spider_internal_sql_log_off=0; +CREATE TABLE t1 (c INT) ENGINE=InnoDB; +CREATE TABLE t2 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql", SRV "srv", TABLE "t1"' PARTITION BY HASH (c) PARTITIONS 2; +CHECK TABLE t2; +Table Op Msg_type Msg_text +test.t2 check error Partition p0 returned error +test.t2 check Error Access denied; you need (at least one of) the SUPER privilege(s) for this operation +test.t2 check Error Access denied; you need (at least one of) the SUPER privilege(s) for this operation +test.t2 check error Unknown - internal error 1227 during operation +drop table t1, t2; +drop server srv; +drop user spider@localhost; +for master_1 +for child2 +for child3 diff --git a/storage/spider/mysql-test/spider/bugfix/t/mdev_34589.test b/storage/spider/mysql-test/spider/bugfix/t/mdev_34589.test new file mode 100644 index 00000000000..dd465b52db1 --- /dev/null +++ b/storage/spider/mysql-test/spider/bugfix/t/mdev_34589.test @@ -0,0 +1,24 @@ +--disable_query_log +--disable_result_log +--source ../../t/test_init.inc +--enable_result_log +--enable_query_log + +set spider_same_server_link= 1; +CREATE USER spider@localhost IDENTIFIED BY 'pwd'; +GRANT ALL ON test.* TO spider@localhost; +evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql +OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'spider',PASSWORD 'pwd'); +SET spider_internal_sql_log_off=0; +CREATE TABLE t1 (c INT) ENGINE=InnoDB; +CREATE TABLE t2 (c INT) ENGINE=Spider COMMENT='WRAPPER "mysql", SRV "srv", TABLE "t1"' PARTITION BY HASH (c) PARTITIONS 2; +CHECK TABLE t2; +drop table t1, t2; +drop server srv; +drop user spider@localhost; + +--disable_query_log +--disable_result_log +--source ../../t/test_deinit.inc +--enable_result_log +--enable_query_log diff --git a/storage/spider/spd_db_mysql.cc b/storage/spider/spd_db_mysql.cc index 9ab15058253..06dcee81462 100644 --- a/storage/spider/spd_db_mysql.cc +++ b/storage/spider/spd_db_mysql.cc @@ -2548,13 +2548,21 @@ int spider_db_mbase::commit( int spider_db_mbase::rollback( int *need_mon ) { - bool is_error; + bool is_error, save_in_before_query; int error_num= 0; DBUG_ENTER("spider_db_mbase::rollback"); DBUG_PRINT("info",("spider this=%p", this)); spider_lock_before_query(conn, need_mon); - if (spider_db_query(conn, SPIDER_SQL_ROLLBACK_STR, - SPIDER_SQL_ROLLBACK_LEN, -1, need_mon)) + save_in_before_query= conn->in_before_query; + /* + We do not execute the before queries to avoid unnecessary + failures in rollback + */ + conn->in_before_query= TRUE; + error_num= spider_db_query(conn, SPIDER_SQL_ROLLBACK_STR, + SPIDER_SQL_ROLLBACK_LEN, -1, need_mon); + conn->in_before_query= save_in_before_query; + if (error_num) { is_error= conn->thd->is_error(); error_num= spider_db_errorno(conn); From f199dffe3bf25640dbf7882bf9084ddcb4977fb7 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 27 Sep 2024 06:48:55 +1000 Subject: [PATCH 37/62] MDEV-34937 s3 engine no longer functional on non-gcc builds Last commit on libmarias3 broke non-gcc builds by excluding the most important aspect, the snprintf being executed. Reviewer: Andrew Hutchings Ref: https://github.com/mariadb-corporation/libmarias3/pull/130 --- storage/maria/libmarias3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/maria/libmarias3 b/storage/maria/libmarias3 index 5e6aa32f96e..0d5babbe46f 160000 --- a/storage/maria/libmarias3 +++ b/storage/maria/libmarias3 @@ -1 +1 @@ -Subproject commit 5e6aa32f96ebdbcaf32b90d6182685156f8198b5 +Subproject commit 0d5babbe46f17147ed51efd1f05a0001017a2aad From 20f57a8529ea61c505332208436375ae3b2ddb2f Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Thu, 19 Sep 2024 16:51:05 +0200 Subject: [PATCH 38/62] MDEV-33373 part 1: Unexpected ER_FILE_NOT_FOUND upon reading from logging table after crash recovery We have found that my_errno can be "passed" to the next commad in some cases. It is practically impossible to check/fix all cases of my_errno in the server, plugins and engines so we will reset it as we reset other errors. The test case will be fixed by CSV engine fix so will be added with it (see part2). --- sql/sql_class.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/sql_class.h b/sql/sql_class.h index 08a04665383..93c5850ae3d 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -4176,6 +4176,7 @@ public: is_slave_error= 0; if (killed == KILL_BAD_DATA) reset_killed(); + my_errno= 0; DBUG_VOID_RETURN; } From b88f1267e45123db83059d28171c35863b05abb7 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 19 Sep 2024 18:57:37 +0200 Subject: [PATCH 39/62] MDEV-33373 part 2: Unexpected ER_FILE_NOT_FOUND upon reading from logging table after crash recovery CSV engine shoud set my_errno if use it. --- mysql-test/main/log_crash.result | 17 +++++++++++++++++ mysql-test/main/log_crash.test | 25 +++++++++++++++++++++++++ storage/csv/ha_tina.cc | 4 ++-- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 mysql-test/main/log_crash.result create mode 100644 mysql-test/main/log_crash.test diff --git a/mysql-test/main/log_crash.result b/mysql-test/main/log_crash.result new file mode 100644 index 00000000000..5a820a1fd01 --- /dev/null +++ b/mysql-test/main/log_crash.result @@ -0,0 +1,17 @@ +# +# MDEV-33373: Unexpected ER_FILE_NOT_FOUND upon reading from logging +# table after crash recovery +# +call mtr.add_suppression("Table 'general_log' is marked as crashed and should be repaired"); +SET GLOBAL log_output="TABLE"; +CREATE TABLE t (a INT); +# restart +DROP TABLE t; +SELECT count(*) FROM mysql.general_log; +count(*) +5 +Warnings: +Error 1194 Table 'general_log' is marked as crashed and should be repaired +# +# End of 10.5 tests +# diff --git a/mysql-test/main/log_crash.test b/mysql-test/main/log_crash.test new file mode 100644 index 00000000000..3a6a2ff4454 --- /dev/null +++ b/mysql-test/main/log_crash.test @@ -0,0 +1,25 @@ + +--source include/not_embedded.inc +--source include/have_csv.inc + +--echo # +--echo # MDEV-33373: Unexpected ER_FILE_NOT_FOUND upon reading from logging +--echo # table after crash recovery +--echo # + +call mtr.add_suppression("Table 'general_log' is marked as crashed and should be repaired"); + +--disable_ps_protocol +SET GLOBAL log_output="TABLE"; +CREATE TABLE t (a INT); +--disable_ps_protocol +--let $shutdown_timeout= 0 +--source include/restart_mysqld.inc +DROP TABLE t; +--disable_ps_protocol +SELECT count(*) FROM mysql.general_log; +--enable_ps_protocol + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index 04e63530c0e..894fdf2f200 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -333,7 +333,7 @@ static int read_meta_file(File meta_file, ha_rows *rows) /* check crashed bit and magic number */ if ((meta_buffer[0] != (uchar)TINA_CHECK_HEADER) || ((bool)(*ptr)== TRUE)) - DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); + DBUG_RETURN(my_errno= HA_ERR_CRASHED_ON_USAGE); mysql_file_sync(meta_file, MYF(MY_WME)); @@ -974,7 +974,7 @@ int ha_tina::open(const char *name, int mode, uint open_options) if (share->crashed && !(open_options & HA_OPEN_FOR_REPAIR)) { free_share(share); - DBUG_RETURN(my_errno ? my_errno : HA_ERR_CRASHED_ON_USAGE); + DBUG_RETURN(my_errno); } local_data_file_version= share->data_file_version; From d28ac3f82d7259d165b8f41d549cb9846f99fe09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 30 Sep 2024 15:27:38 +0300 Subject: [PATCH 40/62] MDEV-34207: ALTER TABLE...STATS_PERSISTENT=0 fails to drop statistics commit_try_norebuild(): If the STATS_PERSISTENT attribute of the table is being changed to disabled, drop the persistent statistics of the table. --- mysql-test/suite/innodb/r/stat_tables.result | 18 +++++++++++ mysql-test/suite/innodb/t/stat_tables.test | 24 ++++++++++++++ storage/innobase/handler/handler0alter.cc | 34 ++++++++++++++++++-- 3 files changed, 74 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/innodb/r/stat_tables.result b/mysql-test/suite/innodb/r/stat_tables.result index d91b854d347..2a7eac01d73 100644 --- a/mysql-test/suite/innodb/r/stat_tables.result +++ b/mysql-test/suite/innodb/r/stat_tables.result @@ -82,4 +82,22 @@ WHERE database_name='test' AND table_name='t1' AND stat_name='size'; TIMESTAMPDIFF(DAY,last_update,now())<=1 1 DROP TABLE t1; +# +# MDEV-34207: ALTER TABLE...STATS_PERSISTENT=0 fails to drop statistics +# +CREATE TABLE t1 (c1 INT) ENGINE=InnoDB STATS_PERSISTENT 1; +ALTER TABLE t1 STATS_PERSISTENT 0; +DROP TABLE t1; +SET @save_persistent=@@GLOBAL.innodb_stats_persistent; +SET GLOBAL innodb_stats_persistent=1; +CREATE TABLE t2 (c1 INT) ENGINE=InnoDB; +RENAME TABLE t2 TO t1; +DROP TABLE t1; +SET GLOBAL innodb_stats_persistent=0; +CREATE TABLE t2 (c1 INT) ENGINE=InnoDB STATS_PERSISTENT 1; +RENAME TABLE t2 TO t1; +SET GLOBAL innodb_stats_persistent=@save_persistent; +DROP TABLE t1; +CREATE TABLE t1 (c1 INT) ENGINE=InnoDB STATS_PERSISTENT 1; +DROP TABLE t1; # End of 10.6 tests diff --git a/mysql-test/suite/innodb/t/stat_tables.test b/mysql-test/suite/innodb/t/stat_tables.test index 359fb1e00ec..602d05915a0 100644 --- a/mysql-test/suite/innodb/t/stat_tables.test +++ b/mysql-test/suite/innodb/t/stat_tables.test @@ -80,5 +80,29 @@ SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_index_stats WHERE database_name='test' AND table_name='t1' AND stat_name='size'; DROP TABLE t1; +--echo # +--echo # MDEV-34207: ALTER TABLE...STATS_PERSISTENT=0 fails to drop statistics +--echo # +CREATE TABLE t1 (c1 INT) ENGINE=InnoDB STATS_PERSISTENT 1; +ALTER TABLE t1 STATS_PERSISTENT 0; +DROP TABLE t1; + +SET @save_persistent=@@GLOBAL.innodb_stats_persistent; +SET GLOBAL innodb_stats_persistent=1; + +CREATE TABLE t2 (c1 INT) ENGINE=InnoDB; +RENAME TABLE t2 TO t1; + +DROP TABLE t1; +SET GLOBAL innodb_stats_persistent=0; + +CREATE TABLE t2 (c1 INT) ENGINE=InnoDB STATS_PERSISTENT 1; +RENAME TABLE t2 TO t1; + +SET GLOBAL innodb_stats_persistent=@save_persistent; +DROP TABLE t1; + +CREATE TABLE t1 (c1 INT) ENGINE=InnoDB STATS_PERSISTENT 1; +DROP TABLE t1; --echo # End of 10.6 tests diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index d2604533983..be721a51f3c 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -10597,6 +10597,16 @@ commit_try_norebuild( dict_index_t* index; const char *op = "rename index to add"; ulint num_fts_index = 0; + const bool statistics_drop = statistics_exist + && ((HA_OPTION_NO_STATS_PERSISTENT | + HA_OPTION_STATS_PERSISTENT) + & (old_table->s->db_create_options + ^ altered_table->s->db_create_options)) + && ((altered_table->s->db_create_options + & HA_OPTION_NO_STATS_PERSISTENT) + || (!(altered_table->s->db_create_options + & HA_OPTION_STATS_PERSISTENT) + && !srv_stats_persistent)); /* We altered the table in place. Mark the indexes as committed. */ for (ulint i = 0; i < ctx->num_to_add_index; i++) { @@ -10619,7 +10629,8 @@ commit_try_norebuild( } char db[MAX_DB_UTF8_LEN], table[MAX_TABLE_UTF8_LEN]; - if (ctx->num_to_drop_index) { + + if (statistics_exist && (statistics_drop || ctx->num_to_drop_index)) { dict_fs2utf8(ctx->old_table->name.m_name, db, sizeof db, table, sizeof table); } @@ -10654,7 +10665,7 @@ commit_try_norebuild( goto handle_error; } - if (!statistics_exist) { + if (!statistics_exist || statistics_drop) { continue; } @@ -10670,6 +10681,25 @@ commit_try_norebuild( } if (!statistics_exist) { + } else if (statistics_drop) { + error = dict_stats_delete_from_table_stats(db, table, trx); + switch (error) { + case DB_SUCCESS: + case DB_STATS_DO_NOT_EXIST: + break; + default: + goto handle_error; + } + error = dict_stats_delete_from_index_stats(db, table, trx); + switch (error) { + case DB_STATS_DO_NOT_EXIST: + error = DB_SUCCESS; + /* fall through */ + case DB_SUCCESS: + break; + default: + goto handle_error; + } } else if (const size_t size = ha_alter_info->rename_keys.size()) { char tmp_name[5]; char db[MAX_DB_UTF8_LEN], table[MAX_TABLE_UTF8_LEN]; From 45298b730b8aa99a1848e504908ed8a7c8847ab5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 20 Sep 2024 08:48:52 +0200 Subject: [PATCH 41/62] sql/handler: referenced_by_foreign_key() returns bool The method was declared to return an unsigned integer, but it is really a boolean (and used as such by all callers). A secondary change is the addition of "const" and "noexcept" to this method. In ha_mroonga.cpp, I also added "inline" to the two helper methods of referenced_by_foreign_key(). This allows the compiler to flatten the method. --- sql/ha_partition.h | 2 +- sql/handler.h | 2 +- storage/innobase/handler/ha_innodb.cc | 16 ++++++---------- storage/innobase/handler/ha_innodb.h | 2 +- storage/mroonga/ha_mroonga.cpp | 12 ++++++------ storage/mroonga/ha_mroonga.hpp | 6 +++--- 6 files changed, 18 insertions(+), 22 deletions(-) diff --git a/sql/ha_partition.h b/sql/ha_partition.h index f47cc3f8957..1c50dde348a 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -1464,7 +1464,7 @@ public: virtual int get_foreign_key_list(THD *thd, List *f_key_list) - virtual uint referenced_by_foreign_key() + bool referenced_by_foreign_key() const noexcept override */ bool can_switch_engines() override; /* diff --git a/sql/handler.h b/sql/handler.h index 91879010ff9..d7dddd95da5 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -4078,7 +4078,7 @@ public: virtual int get_parent_foreign_key_list(THD *thd, List *f_key_list) { return 0; } - virtual uint referenced_by_foreign_key() { return 0;} + virtual bool referenced_by_foreign_key() const noexcept { return false;} virtual void init_table_handle_for_HANDLER() { return; } /* prepare InnoDB for HANDLER */ virtual void free_foreign_key_create_info(char* str) {} diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 689cf76e1ce..2c24bbf4485 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -10052,8 +10052,8 @@ wsrep_append_key( static bool referenced_by_foreign_key2( /*=======================*/ - dict_table_t* table, - dict_index_t* index) + const dict_table_t* table, + const dict_index_t* index) noexcept { ut_ad(table != NULL); ut_ad(index != NULL); @@ -15451,16 +15451,12 @@ ha_innobase::can_switch_engines(void) DBUG_RETURN(can_switch); } -/*******************************************************************//** -Checks if a table is referenced by a foreign key. The MySQL manual states that -a REPLACE is either equivalent to an INSERT, or DELETE(s) + INSERT. Only a +/** Checks if a table is referenced by a foreign key. The MySQL manual states +that a REPLACE is either equivalent to an INSERT, or DELETE(s) + INSERT. Only a delete is then allowed internally to resolve a duplicate key conflict in REPLACE, not an update. -@return > 0 if referenced by a FOREIGN KEY */ - -uint -ha_innobase::referenced_by_foreign_key(void) -/*========================================*/ +@return whether the table is referenced by a FOREIGN KEY */ +bool ha_innobase::referenced_by_foreign_key() const noexcept { if (dict_table_is_referenced_by_foreign_key(m_prebuilt->table)) { diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index ba4f5b62f90..bd99b230a67 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -222,7 +222,7 @@ public: bool can_switch_engines() override; - uint referenced_by_foreign_key() override; + bool referenced_by_foreign_key() const noexcept override; void free_foreign_key_create_info(char* str) override; diff --git a/storage/mroonga/ha_mroonga.cpp b/storage/mroonga/ha_mroonga.cpp index 75f2387beab..442146fae95 100644 --- a/storage/mroonga/ha_mroonga.cpp +++ b/storage/mroonga/ha_mroonga.cpp @@ -16790,10 +16790,10 @@ int ha_mroonga::get_parent_foreign_key_list(THD *thd, DBUG_RETURN(res); } -uint ha_mroonga::wrapper_referenced_by_foreign_key() +inline bool ha_mroonga::wrapper_referenced_by_foreign_key() const noexcept { MRN_DBUG_ENTER_METHOD(); - uint res; + bool res; MRN_SET_WRAP_SHARE_KEY(share, table->s); MRN_SET_WRAP_TABLE_KEY(this, table); res = wrap_handler->referenced_by_foreign_key(); @@ -16802,17 +16802,17 @@ uint ha_mroonga::wrapper_referenced_by_foreign_key() DBUG_RETURN(res); } -uint ha_mroonga::storage_referenced_by_foreign_key() +inline bool ha_mroonga::storage_referenced_by_foreign_key() const noexcept { MRN_DBUG_ENTER_METHOD(); - uint res = handler::referenced_by_foreign_key(); + bool res = handler::referenced_by_foreign_key(); DBUG_RETURN(res); } -uint ha_mroonga::referenced_by_foreign_key() +bool ha_mroonga::referenced_by_foreign_key() const noexcept { MRN_DBUG_ENTER_METHOD(); - uint res; + bool res; if (share->wrapper_mode) { res = wrapper_referenced_by_foreign_key(); diff --git a/storage/mroonga/ha_mroonga.hpp b/storage/mroonga/ha_mroonga.hpp index 2bc5c2b30f3..7a5628a2b1f 100644 --- a/storage/mroonga/ha_mroonga.hpp +++ b/storage/mroonga/ha_mroonga.hpp @@ -618,7 +618,7 @@ protected: bool can_switch_engines() mrn_override; int get_foreign_key_list(THD *thd, List *f_key_list) mrn_override; int get_parent_foreign_key_list(THD *thd, List *f_key_list) mrn_override; - uint referenced_by_foreign_key() mrn_override; + bool referenced_by_foreign_key() const noexcept mrn_override; void init_table_handle_for_HANDLER() mrn_override; void free_foreign_key_create_info(char* str) mrn_override; #ifdef MRN_HAVE_HA_REBIND_PSI @@ -1268,8 +1268,8 @@ private: int storage_get_foreign_key_list(THD *thd, List *f_key_list); int wrapper_get_parent_foreign_key_list(THD *thd, List *f_key_list); int storage_get_parent_foreign_key_list(THD *thd, List *f_key_list); - uint wrapper_referenced_by_foreign_key(); - uint storage_referenced_by_foreign_key(); + bool wrapper_referenced_by_foreign_key() const noexcept; + bool storage_referenced_by_foreign_key() const noexcept; void wrapper_init_table_handle_for_HANDLER(); void storage_init_table_handle_for_HANDLER(); void wrapper_free_foreign_key_create_info(char* str); From cc810e64d40367208b3f3f35c0277f0c8586a293 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Mon, 30 Sep 2024 13:37:26 +0530 Subject: [PATCH 42/62] MDEV-34392 Inplace algorithm violates the foreign key constraint Don't allow the referencing key column from NULL TO NOT NULL when 1) Foreign key constraint type is ON UPDATE SET NULL 2) Foreign key constraint type is ON DELETE SET NULL 3) Foreign key constraint type is UPDATE CASCADE and referenced column declared as NULL Don't allow the referenced key column from NOT NULL to NULL when foreign key constraint type is UPDATE CASCADE and referencing key columns doesn't allow NULL values get_foreign_key_info(): InnoDB sends the information about nullability of the foreign key fields and referenced key fields. fk_check_column_changes(): Enforce the above rules for COPY algorithm innobase_check_foreign_drop_col(): Checks whether the dropped column exists in existing foreign key relation innobase_check_foreign_low() : Enforce the above rules for INPLACE algorithm dict_foreign_t::check_fk_constraint_valid(): This is used by CREATE TABLE statement to check nullability for foreign key relation. --- include/my_bit.h | 5 + .../galera/r/galera_fk_multicolumn.result | 2 +- .../suite/galera/t/galera_fk_multicolumn.test | 2 +- .../suite/innodb/r/foreign_null,COPY.rdiff | 18 ++ mysql-test/suite/innodb/r/foreign_null.result | 156 +++++++++++ mysql-test/suite/innodb/r/innodb-index.result | 8 +- mysql-test/suite/innodb/r/innodb.result | 2 +- .../suite/innodb/t/foreign_null.combinations | 2 + mysql-test/suite/innodb/t/foreign_null.test | 225 ++++++++++++++++ mysql-test/suite/innodb/t/innodb-index.test | 2 +- sql/sql_table.cc | 98 +++++-- sql/table.h | 65 +++++ storage/innobase/dict/dict0crea.cc | 12 +- storage/innobase/dict/dict0dict.cc | 28 +- storage/innobase/handler/ha_innodb.cc | 39 ++- storage/innobase/handler/handler0alter.cc | 255 +++++++++++------- storage/innobase/include/dict0mem.h | 189 +++++++++---- storage/innobase/row/row0ins.cc | 26 +- 18 files changed, 919 insertions(+), 215 deletions(-) create mode 100644 mysql-test/suite/innodb/r/foreign_null,COPY.rdiff create mode 100644 mysql-test/suite/innodb/r/foreign_null.result create mode 100644 mysql-test/suite/innodb/t/foreign_null.combinations create mode 100644 mysql-test/suite/innodb/t/foreign_null.test diff --git a/include/my_bit.h b/include/my_bit.h index 8ee8b41c8d4..e86c3ec883f 100644 --- a/include/my_bit.h +++ b/include/my_bit.h @@ -175,6 +175,11 @@ static inline uchar last_byte_mask(uint bits) return (uchar) ((2U << used) - 1); } +static inline uint my_bits_in_bytes(uint n) +{ + return ((n + 7) / 8); +} + #ifdef _MSC_VER #include #endif diff --git a/mysql-test/suite/galera/r/galera_fk_multicolumn.result b/mysql-test/suite/galera/r/galera_fk_multicolumn.result index b626d963af8..c10c0a5c702 100644 --- a/mysql-test/suite/galera/r/galera_fk_multicolumn.result +++ b/mysql-test/suite/galera/r/galera_fk_multicolumn.result @@ -2,7 +2,7 @@ connection node_2; connection node_1; CREATE TABLE t0 ( f1 INT PRIMARY KEY, -f2 INT UNIQUE +f2 INT UNIQUE NOT NULL ); CREATE TABLE t1 ( f1 INT PRIMARY KEY, diff --git a/mysql-test/suite/galera/t/galera_fk_multicolumn.test b/mysql-test/suite/galera/t/galera_fk_multicolumn.test index ad42f65924d..eeed46bca6c 100644 --- a/mysql-test/suite/galera/t/galera_fk_multicolumn.test +++ b/mysql-test/suite/galera/t/galera_fk_multicolumn.test @@ -7,7 +7,7 @@ CREATE TABLE t0 ( f1 INT PRIMARY KEY, - f2 INT UNIQUE + f2 INT UNIQUE NOT NULL ); CREATE TABLE t1 ( diff --git a/mysql-test/suite/innodb/r/foreign_null,COPY.rdiff b/mysql-test/suite/innodb/r/foreign_null,COPY.rdiff new file mode 100644 index 00000000000..e39d5c0e9db --- /dev/null +++ b/mysql-test/suite/innodb/r/foreign_null,COPY.rdiff @@ -0,0 +1,18 @@ +--- foreign_null.result ++++ foreign_null,COPY.result +@@ -139,6 +139,7 @@ + ALTER TABLE `t#2` DROP INDEX f1; + SET FOREIGN_KEY_CHECKS=1; + ALTER TABLE `t#1` MODIFY COLUMN f2 INT; ++ERROR HY000: Error on rename of './test/#sql-alter' to './test/t@00231' (errno: 150 "Foreign key constraint is incorrectly formed") + DROP TABLE `t#2`, `t#1`; + # Drop referenced index and modify column + CREATE TABLE `t#1`(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +@@ -147,6 +148,7 @@ + ALTER TABLE `t#1` DROP INDEX f2; + SET FOREIGN_KEY_CHECKS=1; + ALTER TABLE `t#2` MODIFY COLUMN f1 INT NOT NULL; ++ERROR HY000: Error on rename of './test/#sql-alter' to './test/t@00232' (errno: 150 "Foreign key constraint is incorrectly formed") + DROP TABLE `t#2`, `t#1`; + # Self referential modifying column + CREATE TABLE t1(f1 INT, f2 INT, index(f2), foreign key(f1) references t1(f2) ON UPDATE CASCADE)engine=innodb; diff --git a/mysql-test/suite/innodb/r/foreign_null.result b/mysql-test/suite/innodb/r/foreign_null.result new file mode 100644 index 00000000000..a5d1afc7e0c --- /dev/null +++ b/mysql-test/suite/innodb/r/foreign_null.result @@ -0,0 +1,156 @@ +call mtr.add_suppression("InnoDB: In ALTER TABLE .* has or is referenced in foreign key constraints which are not compatible with the new table definition."); +# modify child column NOT NULL on UPDATE CASCADE..parent column NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE CASCADE)ENGINE=InnoDB; +ALTER TABLE t2 MODIFY COLUMN f1 INT NOT NULL; +ERROR HY000: Column 'f1' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL +DROP TABLE t2, t1; +# modify child column NOT NULL ON DELETE CASCADE..parent column NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, FOREIGN KEY(f1) REFERENCES t1(f2) ON DELETE CASCADE)ENGINE=InnoDB; +ALTER TABLE t2 MODIFY COLUMN f1 INT NOT NULL; +DROP TABLE t2, t1; +# modify child column NOT NULL ON UPDATE SET NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY(f1) REFERENCES t1(f1) ON UPDATE SET NULL)ENGINE=InnoDB; +ALTER TABLE t2 MODIFY COLUMN f1 INT NOT NULL; +ERROR HY000: Column 'f1' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL +DROP TABLE t2, t1; +# modify child column NOT NULL ON DELETE SET NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON DELETE SET NULL)ENGINE=InnoDB; +ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL; +ERROR HY000: Column 'f2' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL +DROP TABLE t2, t1; +# modify child column NOT NULL ON UPDATE RESTRICT..parent column NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON UPDATE RESTRICT)ENGINE=InnoDB; +ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL; +DROP TABLE t2, t1; +# modify child column NOT NULL ON DELETE RESTRICT..parent column NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON DELETE RESTRICT)ENGINE=InnoDB; +ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL; +DROP TABLE t2, t1; +# modify child column NOT NULL ON UPDATE NO ACTION..PARENT COLUMN NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON UPDATE NO ACTION)ENGINE=InnoDB; +ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL; +DROP TABLE t2, t1; +# modify child column NOT NULL ON DELETE NO ACTION..PARENT COLUMN NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON DELETE NO ACTION)ENGINE=InnoDB; +ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL; +DROP TABLE t2, t1; +# modify parent column NULL ON UPDATE CASCADE child column NOT NULL +CREATE TABLE `t#1`(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE `t#2`(f1 INT NOT NULL, +FOREIGN KEY(f1) REFERENCES `t#1`(f2) +ON UPDATE CASCADE)ENGINE=InnoDB; +ALTER TABLE `t#1` MODIFY COLUMN f2 INT; +ERROR HY000: Cannot change column 'f2': used in a foreign key constraint 't#2_ibfk_1' of table 'test.t#2' +DROP TABLE `t#2`, `t#1`; +# modify parent column NULL ON DELETE CASCADE child column NOT NULL +CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON DELETE CASCADE)ENGINE=InnoDB; +ALTER TABLE t1 MODIFY COLUMN f2 INT; +DROP TABLE t2, t1; +# modify parent column NULL ON UPDATE SET NULL child column NOT NULL +CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE SET NULL)ENGINE=InnoDB; +ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed") +DROP TABLE t1; +# modify parent column NULL ON DELETE SET NULL child NOT NULL +CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON DELETE SET NULL)ENGINE=InnoDB; +ERROR HY000: Can't create table `test`.`t2` (errno: 150 "Foreign key constraint is incorrectly formed") +DROP TABLE t1; +# modify parent column NULL ON UPDATE RESTRICT child column NOT NULL +CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE RESTRICT)ENGINE=InnoDB; +ALTER TABLE t1 MODIFY COLUMN f2 INT; +DROP TABLE t2, t1; +# modify parent column NULL ON DELETE RESTRICT child column NOT NULL +CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE RESTRICT)ENGINE=InnoDB; +ALTER TABLE t1 MODIFY COLUMN f2 INT; +DROP TABLE t2, t1; +# modify parent column NULL ON UPDATE NO ACTION child column NOT NULL +CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE NO ACTION)ENGINE=InnoDB; +ALTER TABLE t1 MODIFY COLUMN f2 INT; +DROP TABLE t2, t1; +# modify parent column NULL ON DELETE NO ACTION child column NOT NULL +CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON DELETE NO ACTION)ENGINE=InnoDB; +ALTER TABLE t1 MODIFY COLUMN f2 INT; +DROP TABLE t2, t1; +# foreign key constraint for multiple columns +# modify parent column NULL ON UPDATE CASCADE child column NOT NULL +CREATE TABLE t1(f1 INT NOT NULL, f2 INT NOT NULL, +INDEX(f1, f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, +INDEX(f1, f2), +FOREIGN KEY(f1, f2) REFERENCES t1(f1, f2) ON +UPDATE CASCADE)ENGINE=InnoDB; +ALTER TABLE t1 MODIFY COLUMN f1 INT; +ERROR HY000: Cannot change column 'f1': used in a foreign key constraint 't2_ibfk_1' of table 'test.t2' +DROP TABLE t2, t1; +# modify child column NOT NULL ON UPDATE CASCADE parent column NULL +CREATE TABLE t1(f1 INT, f2 INT, INDEX(f1, f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, INDEX(f1, f2), +FOREIGN KEY(f1, f2) REFERENCES t1(f1, f2) ON +UPDATE CASCADE)ENGINE=InnoDB; +ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL; +ERROR HY000: Column 'f2' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL +DROP TABLE t2, t1; +# allow foreign key constraints when parent table created later +SET FOREIGN_KEY_CHECKS=0; +CREATE TABLE t2(f1 INT, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE CASCADE)ENGINE=InnoDB; +SET FOREIGN_KEY_CHECKS=1; +ALTER TABLE t2 MODIFY COLUMN f1 INT NOT NULL; +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +INSERT INTO t1 VALUES(1, 1); +INSERT INTO t2 VALUES(1); +UPDATE t1 SET f2= NULL; +ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`t2`, CONSTRAINT `t2_ibfk_1` FOREIGN KEY (`f1`) REFERENCES `t1` (`f2`) ON UPDATE CASCADE) +SELECT * FROM t2; +f1 +1 +SET FOREIGN_KEY_CHECKS=0; +UPDATE t1 SET f2= NULL; +SELECT * FROM t2; +f1 +1 +DROP TABLE t2, t1; +# Modify column + Drop column & Drop foreign key constraint +CREATE TABLE t1(f1 INT, f2 INT, KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, f3 INT, +FOREIGN KEY fdx(f2) REFERENCES t1(f1), +FOREIGN KEY fdx2(f3) REFERENCES t1(f2))ENGINE=InnoDB; +ALTER TABLE t2 MODIFY f2 INT NOT NULL, DROP FOREIGN KEY fdx; +ALTER TABLE t2 ADD FOREIGN KEY fdx (f2) REFERENCES t1(f1); +ALTER TABLE t2 DROP COLUMN f2, DROP FOREIGN KEY fdx; +DROP TABLE t2, t1; +# Drop foreign index & modify column +CREATE TABLE `t#1`(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE `t#2`(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES `t#1`(f2) ON UPDATE CASCADE)ENGINE=InnoDB; +SET FOREIGN_KEY_CHECKS=0; +ALTER TABLE `t#2` DROP INDEX f1; +SET FOREIGN_KEY_CHECKS=1; +ALTER TABLE `t#1` MODIFY COLUMN f2 INT; +DROP TABLE `t#2`, `t#1`; +# Drop referenced index and modify column +CREATE TABLE `t#1`(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE `t#2`(f1 INT, FOREIGN KEY(f1) REFERENCES `t#1`(f2) ON UPDATE CASCADE)ENGINE=InnoDB; +SET FOREIGN_KEY_CHECKS=0; +ALTER TABLE `t#1` DROP INDEX f2; +SET FOREIGN_KEY_CHECKS=1; +ALTER TABLE `t#2` MODIFY COLUMN f1 INT NOT NULL; +DROP TABLE `t#2`, `t#1`; +# Self referential modifying column +CREATE TABLE t1(f1 INT, f2 INT, index(f2), foreign key(f1) references t1(f2) ON UPDATE CASCADE)engine=innodb; +ALTER TABLE t1 MODIFY COLUMN f2 INT NOT NULL; +ALTER TABLE t1 MODIFY COLUMN f1 INT NOT NULL; +ALTER TABLE t1 MODIFY COLUMN f1 INT; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/r/innodb-index.result b/mysql-test/suite/innodb/r/innodb-index.result index ad169757571..a590d4f0953 100644 --- a/mysql-test/suite/innodb/r/innodb-index.result +++ b/mysql-test/suite/innodb/r/innodb-index.result @@ -455,11 +455,11 @@ ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint alter table t2 drop index b, drop index c, drop index d; ERROR HY000: Cannot drop index 'b': needed in a foreign key constraint alter table t2 MODIFY b INT NOT NULL, ALGORITHM=COPY; -ERROR HY000: Cannot change column 'b': used in a foreign key constraint 't2_ibfk_1' +ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL set @old_sql_mode = @@sql_mode; set @@sql_mode = 'STRICT_TRANS_TABLES'; alter table t2 MODIFY b INT NOT NULL, ALGORITHM=INPLACE; -ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 'test/t2_ibfk_1' SET NULL +ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL set @@sql_mode = @old_sql_mode; SET FOREIGN_KEY_CHECKS=0; alter table t2 DROP COLUMN b, ALGORITHM=COPY; @@ -480,10 +480,10 @@ info: Records: 0 Duplicates: 0 Warnings: 0 set @@sql_mode = 'STRICT_TRANS_TABLES'; alter table t2 add primary key (alpha), change a alpha int, change b beta int not null, change c charlie int not null; -ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 'test/t2_ibfk_1' SET NULL +ERROR HY000: Column 'b' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL alter table t2 add primary key (alpha), change a alpha int, change c charlie int not null, change d delta int not null; -ERROR HY000: Column 'd' cannot be NOT NULL: needed in a foreign key constraint 'test/t2_ibfk_3' SET NULL +ERROR HY000: Column 'd' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_3' SET NULL alter table t2 add primary key (alpha), change a alpha int, change b beta int, modify c int not null; affected rows: 0 diff --git a/mysql-test/suite/innodb/r/innodb.result b/mysql-test/suite/innodb/r/innodb.result index 168327d781e..e1d99c3b731 100644 --- a/mysql-test/suite/innodb/r/innodb.result +++ b/mysql-test/suite/innodb/r/innodb.result @@ -3057,7 +3057,7 @@ ALTER TABLE t2 ADD FOREIGN KEY (a) REFERENCES t1 (a) ON DELETE SET NULL; set @old_sql_mode = @@sql_mode; set @@sql_mode = 'STRICT_TRANS_TABLES'; ALTER TABLE t2 MODIFY a INT NOT NULL; -ERROR HY000: Column 'a' cannot be NOT NULL: needed in a foreign key constraint 'test/t2_ibfk_1' SET NULL +ERROR HY000: Column 'a' cannot be NOT NULL: needed in a foreign key constraint 't2_ibfk_1' SET NULL set @@sql_mode = @old_sql_mode; DELETE FROM t1; DROP TABLE t2,t1; diff --git a/mysql-test/suite/innodb/t/foreign_null.combinations b/mysql-test/suite/innodb/t/foreign_null.combinations new file mode 100644 index 00000000000..e84e17b06ac --- /dev/null +++ b/mysql-test/suite/innodb/t/foreign_null.combinations @@ -0,0 +1,2 @@ +[COPY] +[INPLACE] diff --git a/mysql-test/suite/innodb/t/foreign_null.test b/mysql-test/suite/innodb/t/foreign_null.test new file mode 100644 index 00000000000..6869154fc9f --- /dev/null +++ b/mysql-test/suite/innodb/t/foreign_null.test @@ -0,0 +1,225 @@ +--source include/have_innodb.inc +call mtr.add_suppression("InnoDB: In ALTER TABLE .* has or is referenced in foreign key constraints which are not compatible with the new table definition."); + +let $MYSQLD_DATADIR= `select @@datadir`; +let $algorithm=`select regexp_replace('$MTR_COMBINATIONS', 'innodb,\|,innodb', '')`; + +--echo # modify child column NOT NULL on UPDATE CASCADE..parent column NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE CASCADE)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +--error ER_FK_COLUMN_NOT_NULL +eval ALTER TABLE t2 MODIFY COLUMN f1 INT NOT NULL,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # modify child column NOT NULL ON DELETE CASCADE..parent column NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, FOREIGN KEY(f1) REFERENCES t1(f2) ON DELETE CASCADE)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t2 MODIFY COLUMN f1 INT NOT NULL,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # modify child column NOT NULL ON UPDATE SET NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY(f1) REFERENCES t1(f1) ON UPDATE SET NULL)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +--error ER_FK_COLUMN_NOT_NULL +eval ALTER TABLE t2 MODIFY COLUMN f1 INT NOT NULL,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # modify child column NOT NULL ON DELETE SET NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON DELETE SET NULL)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +--error ER_FK_COLUMN_NOT_NULL +eval ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # modify child column NOT NULL ON UPDATE RESTRICT..parent column NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON UPDATE RESTRICT)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # modify child column NOT NULL ON DELETE RESTRICT..parent column NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON DELETE RESTRICT)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # modify child column NOT NULL ON UPDATE NO ACTION..PARENT COLUMN NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON UPDATE NO ACTION)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # modify child column NOT NULL ON DELETE NO ACTION..PARENT COLUMN NULL +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, FOREIGN KEY (f2) REFERENCES t1(f2) ON DELETE NO ACTION)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # modify parent column NULL ON UPDATE CASCADE child column NOT NULL +CREATE TABLE `t#1`(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE `t#2`(f1 INT NOT NULL, + FOREIGN KEY(f1) REFERENCES `t#1`(f2) + ON UPDATE CASCADE)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +--error ER_FK_COLUMN_CANNOT_CHANGE_CHILD +eval ALTER TABLE `t#1` MODIFY COLUMN f2 INT,ALGORITHM=$algorithm; +DROP TABLE `t#2`, `t#1`; + +--echo # modify parent column NULL ON DELETE CASCADE child column NOT NULL +CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON DELETE CASCADE)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t1 MODIFY COLUMN f2 INT,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # modify parent column NULL ON UPDATE SET NULL child column NOT NULL +CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +--error ER_CANT_CREATE_TABLE +CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE SET NULL)ENGINE=InnoDB; +DROP TABLE t1; + +--echo # modify parent column NULL ON DELETE SET NULL child NOT NULL +CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +--error ER_CANT_CREATE_TABLE +CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON DELETE SET NULL)ENGINE=InnoDB; +DROP TABLE t1; + +--echo # modify parent column NULL ON UPDATE RESTRICT child column NOT NULL +CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE RESTRICT)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t1 MODIFY COLUMN f2 INT,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # modify parent column NULL ON DELETE RESTRICT child column NOT NULL +CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE RESTRICT)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t1 MODIFY COLUMN f2 INT,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # modify parent column NULL ON UPDATE NO ACTION child column NOT NULL +CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE NO ACTION)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t1 MODIFY COLUMN f2 INT,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # modify parent column NULL ON DELETE NO ACTION child column NOT NULL +CREATE TABLE t1(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES t1(f2) ON DELETE NO ACTION)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t1 MODIFY COLUMN f2 INT,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # foreign key constraint for multiple columns +--echo # modify parent column NULL ON UPDATE CASCADE child column NOT NULL +CREATE TABLE t1(f1 INT NOT NULL, f2 INT NOT NULL, + INDEX(f1, f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL, + INDEX(f1, f2), + FOREIGN KEY(f1, f2) REFERENCES t1(f1, f2) ON + UPDATE CASCADE)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +--error ER_FK_COLUMN_CANNOT_CHANGE_CHILD +eval ALTER TABLE t1 MODIFY COLUMN f1 INT,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # modify child column NOT NULL ON UPDATE CASCADE parent column NULL +CREATE TABLE t1(f1 INT, f2 INT, INDEX(f1, f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, INDEX(f1, f2), + FOREIGN KEY(f1, f2) REFERENCES t1(f1, f2) ON + UPDATE CASCADE)ENGINE=InnoDB; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +--error ER_FK_COLUMN_NOT_NULL +eval ALTER TABLE t2 MODIFY COLUMN f2 INT NOT NULL,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # allow foreign key constraints when parent table created later +SET FOREIGN_KEY_CHECKS=0; +CREATE TABLE t2(f1 INT, FOREIGN KEY(f1) REFERENCES t1(f2) ON UPDATE CASCADE)ENGINE=InnoDB; +SET FOREIGN_KEY_CHECKS=1; +ALTER TABLE t2 MODIFY COLUMN f1 INT NOT NULL; +CREATE TABLE t1(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +INSERT INTO t1 VALUES(1, 1); +INSERT INTO t2 VALUES(1); +--error ER_ROW_IS_REFERENCED_2 +UPDATE t1 SET f2= NULL; +SELECT * FROM t2; +SET FOREIGN_KEY_CHECKS=0; +UPDATE t1 SET f2= NULL; +SELECT * FROM t2; +DROP TABLE t2, t1; + +--echo # Modify column + Drop column & Drop foreign key constraint +CREATE TABLE t1(f1 INT, f2 INT, KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE t2(f1 INT, f2 INT, f3 INT, + FOREIGN KEY fdx(f2) REFERENCES t1(f1), + FOREIGN KEY fdx2(f3) REFERENCES t1(f2))ENGINE=InnoDB; + +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t2 MODIFY f2 INT NOT NULL, DROP FOREIGN KEY fdx,ALGORITHM=$algorithm; + +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t2 ADD FOREIGN KEY fdx (f2) REFERENCES t1(f1),ALGORITHM=$algorithm; + +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t2 DROP COLUMN f2, DROP FOREIGN KEY fdx,ALGORITHM=$algorithm; +DROP TABLE t2, t1; + +--echo # Drop foreign index & modify column +CREATE TABLE `t#1`(f1 INT, f2 INT NOT NULL, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE `t#2`(f1 INT NOT NULL, FOREIGN KEY(f1) REFERENCES `t#1`(f2) ON UPDATE CASCADE)ENGINE=InnoDB; + +SET FOREIGN_KEY_CHECKS=0; +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE `t#2` DROP INDEX f1,ALGORITHM=$algorithm; +SET FOREIGN_KEY_CHECKS=1; + +let $error_code=0; +if ($algorithm == "COPY") +{ + let $error_code= ER_ERROR_ON_RENAME; +} + +--replace_regex /#sql-alter-[0-9a-f_\-]*/#sql-alter/ +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE '' $MYSQLD_DATADIR ./; +--error $error_code +eval ALTER TABLE `t#1` MODIFY COLUMN f2 INT,ALGORITHM=$algorithm; +DROP TABLE `t#2`, `t#1`; + +--echo # Drop referenced index and modify column +CREATE TABLE `t#1`(f1 INT, f2 INT, PRIMARY KEY(f1), KEY(f2))ENGINE=InnoDB; +CREATE TABLE `t#2`(f1 INT, FOREIGN KEY(f1) REFERENCES `t#1`(f2) ON UPDATE CASCADE)ENGINE=InnoDB; +SET FOREIGN_KEY_CHECKS=0; + +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE `t#1` DROP INDEX f2,ALGORITHM=$algorithm; +SET FOREIGN_KEY_CHECKS=1; + +--replace_regex /#sql-alter-[0-9a-f_\-]*/#sql-alter/ +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE '' $MYSQLD_DATADIR ./; +--error $error_code +eval ALTER TABLE `t#2` MODIFY COLUMN f1 INT NOT NULL,ALGORITHM=$algorithm; +DROP TABLE `t#2`, `t#1`; + +--echo # Self referential modifying column +CREATE TABLE t1(f1 INT, f2 INT, index(f2), foreign key(f1) references t1(f2) ON UPDATE CASCADE)engine=innodb; + +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t1 MODIFY COLUMN f2 INT NOT NULL,ALGORITHM=$algorithm; + +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t1 MODIFY COLUMN f1 INT NOT NULL,ALGORITHM=$algorithm; + +replace_result ,ALGORITHM=COPY '' ,ALGORITHM=INPLACE ''; +eval ALTER TABLE t1 MODIFY COLUMN f1 INT,ALGORITHM=$algorithm; +DROP TABLE t1; diff --git a/mysql-test/suite/innodb/t/innodb-index.test b/mysql-test/suite/innodb/t/innodb-index.test index 9350672bee9..7495fc4d17e 100644 --- a/mysql-test/suite/innodb/t/innodb-index.test +++ b/mysql-test/suite/innodb/t/innodb-index.test @@ -168,7 +168,7 @@ alter table t4 drop index d; alter table t2 drop index b; --error ER_DROP_INDEX_FK alter table t2 drop index b, drop index c, drop index d; ---error ER_FK_COLUMN_CANNOT_CHANGE +--error ER_FK_COLUMN_NOT_NULL alter table t2 MODIFY b INT NOT NULL, ALGORITHM=COPY; # NULL -> NOT NULL only allowed INPLACE if strict sql_mode is on. set @old_sql_mode = @@sql_mode; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 0a0ea7acb2e..bd43a70324a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -9589,18 +9589,20 @@ static Create_field *get_field_by_old_name(Alter_info *alter_info, enum fk_column_change_type { FK_COLUMN_NO_CHANGE, FK_COLUMN_DATA_CHANGE, - FK_COLUMN_RENAMED, FK_COLUMN_DROPPED + FK_COLUMN_RENAMED, FK_COLUMN_DROPPED, FK_COLUMN_NOT_NULL }; /** Check that ALTER TABLE's changes on columns of a foreign key are allowed. @param[in] thd Thread context. + @param[in] table table to be altered @param[in] alter_info Alter_info describing changes to be done by ALTER TABLE. - @param[in] fk_columns List of columns of the foreign key to check. + @param[in] fk Foreign key information. @param[out] bad_column_name Name of field on which ALTER TABLE tries to do prohibited operation. + @param[in] referenced Check the referenced fields @note This function takes into account value of @@foreign_key_checks setting. @@ -9611,17 +9613,27 @@ enum fk_column_change_type change in foreign key column. @retval FK_COLUMN_RENAMED Foreign key column is renamed. @retval FK_COLUMN_DROPPED Foreign key column is dropped. + @retval FK_COLUMN_NOT_NULL Foreign key column cannot be null + if ON...SET NULL or ON UPDATE + CASCADE conflicts with NOT NULL */ static enum fk_column_change_type -fk_check_column_changes(THD *thd, Alter_info *alter_info, - List &fk_columns, - const char **bad_column_name) +fk_check_column_changes(THD *thd, const TABLE *table, + Alter_info *alter_info, + FOREIGN_KEY_INFO *fk, + const char **bad_column_name, + bool referenced=false) { + List &fk_columns= referenced + ? fk->referenced_fields + : fk->foreign_fields; List_iterator_fast column_it(fk_columns); LEX_CSTRING *column; + int n_col= 0; *bad_column_name= NULL; + enum fk_column_change_type result= FK_COLUMN_NO_CHANGE; while ((column= column_it++)) { @@ -9640,8 +9652,8 @@ fk_check_column_changes(THD *thd, Alter_info *alter_info, SE that foreign keys should be updated to use new name of column like it happens in case of in-place algorithm. */ - *bad_column_name= column->str; - return FK_COLUMN_RENAMED; + result= FK_COLUMN_RENAMED; + goto func_exit; } /* @@ -9654,17 +9666,55 @@ fk_check_column_changes(THD *thd, Alter_info *alter_info, new_field->flags&= ~AUTO_INCREMENT_FLAG; const bool equal_result= old_field->is_equal(*new_field); new_field->flags= flags; + const bool old_field_not_null= old_field->flags & NOT_NULL_FLAG; + const bool new_field_not_null= new_field->flags & NOT_NULL_FLAG; - if ((equal_result == IS_EQUAL_NO) || - ((new_field->flags & NOT_NULL_FLAG) && - !(old_field->flags & NOT_NULL_FLAG))) + if ((equal_result == IS_EQUAL_NO)) { /* Column in a FK has changed significantly and it may break referential intergrity. */ - *bad_column_name= column->str; - return FK_COLUMN_DATA_CHANGE; + result= FK_COLUMN_DATA_CHANGE; + goto func_exit; + } + + if (old_field_not_null != new_field_not_null) + { + if (referenced && !new_field_not_null) + { + /* + Don't allow referenced column to change from + NOT NULL to NULL when foreign key relation is + ON UPDATE CASCADE and the referencing column + is declared as NOT NULL + */ + if (fk->update_method == FK_OPTION_CASCADE && + !fk->is_nullable(false, n_col)) + { + result= FK_COLUMN_DATA_CHANGE; + goto func_exit; + } + } + else if (!referenced && new_field_not_null) + { + /* + Don't allow the foreign column to change + from NULL to NOT NULL when foreign key type is + 1) UPDATE SET NULL + 2) DELETE SET NULL + 3) UPDATE CASCADE and referenced column is declared as NULL + */ + if (fk->update_method == FK_OPTION_SET_NULL || + fk->delete_method == FK_OPTION_SET_NULL || + (fk->update_method == FK_OPTION_CASCADE && + fk->referenced_key_name && + fk->is_nullable(true, n_col))) + { + result= FK_COLUMN_NOT_NULL; + goto func_exit; + } + } } } else @@ -9678,12 +9728,15 @@ fk_check_column_changes(THD *thd, Alter_info *alter_info, field being dropped since it is easy to break referential integrity in this case. */ - *bad_column_name= column->str; - return FK_COLUMN_DROPPED; + result= FK_COLUMN_DROPPED; + goto func_exit; } + n_col++; } - return FK_COLUMN_NO_CHANGE; +func_exit: + *bad_column_name= column->str; + return result; } @@ -9775,9 +9828,8 @@ static bool fk_prepare_copy_alter_table(THD *thd, TABLE *table, enum fk_column_change_type changes; const char *bad_column_name; - changes= fk_check_column_changes(thd, alter_info, - f_key->referenced_fields, - &bad_column_name); + changes= fk_check_column_changes(thd, table, alter_info, f_key, + &bad_column_name, true); switch(changes) { @@ -9811,6 +9863,9 @@ static bool fk_prepare_copy_alter_table(THD *thd, TABLE *table, f_key->foreign_id->str, buff.c_ptr()); DBUG_RETURN(true); } + /* FK_COLUMN_NOT_NULL error happens only when changing + the foreign key column from NULL to NOT NULL */ + case FK_COLUMN_NOT_NULL: default: DBUG_ASSERT(0); } @@ -9849,8 +9904,7 @@ static bool fk_prepare_copy_alter_table(THD *thd, TABLE *table, enum fk_column_change_type changes; const char *bad_column_name; - changes= fk_check_column_changes(thd, alter_info, - f_key->foreign_fields, + changes= fk_check_column_changes(thd, table, alter_info, f_key, &bad_column_name); switch(changes) @@ -9872,6 +9926,10 @@ static bool fk_prepare_copy_alter_table(THD *thd, TABLE *table, my_error(ER_FK_COLUMN_CANNOT_DROP, MYF(0), bad_column_name, f_key->foreign_id->str); DBUG_RETURN(true); + case FK_COLUMN_NOT_NULL: + my_error(ER_FK_COLUMN_NOT_NULL, MYF(0), bad_column_name, + f_key->foreign_id->str); + DBUG_RETURN(true); default: DBUG_ASSERT(0); } diff --git a/sql/table.h b/sql/table.h index 6910ff0aff1..45fd8c01d9e 100644 --- a/sql/table.h +++ b/sql/table.h @@ -36,6 +36,7 @@ #include "sql_i_s.h" #include "sql_type.h" /* vers_kind_t */ #include "privilege.h" /* privilege_t */ +#include "my_bit.h" /* Buffer for unix timestamp in microseconds: @@ -1882,6 +1883,70 @@ typedef struct st_foreign_key_info LEX_CSTRING *referenced_key_name; List foreign_fields; List referenced_fields; +private: + unsigned char *fields_nullable= nullptr; + + /** + Get the number of fields exist in foreign key relationship + */ + unsigned get_n_fields() const noexcept + { + unsigned n_fields= foreign_fields.elements; + if (n_fields == 0) + n_fields= referenced_fields.elements; + return n_fields; + } + + /** + Assign nullable field for referenced and foreign fields + based on number of fields. This nullable fields + should be allocated by engine for passing the + foreign key information + @param thd thread to allocate the memory + @param num_fields number of fields + */ + void assign_nullable(THD *thd, unsigned num_fields) noexcept + { + fields_nullable= + (unsigned char *)thd_calloc(thd, + my_bits_in_bytes(2 * num_fields)); + } + +public: + /** + Set nullable bit for the field in the given field + @param referenced set null bit for referenced column + @param field field number + @param n_fields number of fields + */ + void set_nullable(THD *thd, bool referenced, + unsigned field, unsigned n_fields) noexcept + { + if (!fields_nullable) + assign_nullable(thd, n_fields); + DBUG_ASSERT(fields_nullable); + DBUG_ASSERT(field < n_fields); + size_t bit= size_t{field} + referenced * n_fields; + fields_nullable[bit / 8]|= (unsigned char)(1 << (bit % 8)); + } + + /** + Check whether the given field_no in foreign key field or + referenced key field + @param referenced check referenced field nullable value + @param field field number + @return true if the field is nullable or false if it is not + */ + bool is_nullable(bool referenced, unsigned field) const noexcept + { + if (!fields_nullable) + return false; + unsigned n_field= get_n_fields(); + DBUG_ASSERT(field < n_field); + size_t bit= size_t{field} + referenced * n_field; + return fields_nullable[bit / 8] & (1 << (bit % 8)); + } + } FOREIGN_KEY_INFO; LEX_CSTRING *fk_option_name(enum_fk_option opt); diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index e904c2e3e86..f0e47938178 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -1838,8 +1838,8 @@ dict_foreigns_has_s_base_col( foreign = *it; ulint type = foreign->type; - type &= ~(DICT_FOREIGN_ON_DELETE_NO_ACTION - | DICT_FOREIGN_ON_UPDATE_NO_ACTION); + type &= ~(foreign->DELETE_NO_ACTION + | foreign->UPDATE_NO_ACTION); if (type == 0) { continue; @@ -1897,8 +1897,12 @@ dict_create_add_foreigns_to_dictionary( foreign = *it; ut_ad(foreign->id != NULL); - error = dict_create_add_foreign_to_dictionary( - table->name.m_name, foreign, trx); + if (!foreign->check_fk_constraint_valid()) { + error = DB_CANNOT_ADD_CONSTRAINT; + } else { + error = dict_create_add_foreign_to_dictionary( + table->name.m_name, foreign, trx); + } if (error != DB_SUCCESS) { break; diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 1df848d259c..b5b0331b6d9 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -3037,8 +3037,8 @@ dict_foreign_add_to_cache( for_in_cache->n_fields, for_in_cache->referenced_index, check_charsets, for_in_cache->type - & (DICT_FOREIGN_ON_DELETE_SET_NULL - | DICT_FOREIGN_ON_UPDATE_SET_NULL)); + & (foreign->DELETE_SET_NULL + | foreign->UPDATE_SET_NULL)); if (index == NULL && !(ignore_err & DICT_ERR_IGNORE_FK_NOKEY)) { @@ -4003,27 +4003,27 @@ dict_print_info_on_foreign_key_in_create_format(const trx_t *trx, str.append(")"); - if (foreign->type & DICT_FOREIGN_ON_DELETE_CASCADE) { + if (foreign->type & foreign->DELETE_CASCADE) { str.append(" ON DELETE CASCADE"); } - if (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL) { + if (foreign->type & foreign->DELETE_SET_NULL) { str.append(" ON DELETE SET NULL"); } - if (foreign->type & DICT_FOREIGN_ON_DELETE_NO_ACTION) { + if (foreign->type & foreign->DELETE_NO_ACTION) { str.append(" ON DELETE NO ACTION"); } - if (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE) { + if (foreign->type & foreign->UPDATE_CASCADE) { str.append(" ON UPDATE CASCADE"); } - if (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL) { + if (foreign->type & foreign->UPDATE_SET_NULL) { str.append(" ON UPDATE SET NULL"); } - if (foreign->type & DICT_FOREIGN_ON_UPDATE_NO_ACTION) { + if (foreign->type & foreign->UPDATE_NO_ACTION) { str.append(" ON UPDATE NO ACTION"); } @@ -4086,27 +4086,27 @@ dict_print_info_on_foreign_keys( str.append(")"); - if (foreign->type == DICT_FOREIGN_ON_DELETE_CASCADE) { + if (foreign->type == foreign->DELETE_CASCADE) { str.append(" ON DELETE CASCADE"); } - if (foreign->type == DICT_FOREIGN_ON_DELETE_SET_NULL) { + if (foreign->type == foreign->DELETE_SET_NULL) { str.append(" ON DELETE SET NULL"); } - if (foreign->type & DICT_FOREIGN_ON_DELETE_NO_ACTION) { + if (foreign->type & foreign->DELETE_NO_ACTION) { str.append(" ON DELETE NO ACTION"); } - if (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE) { + if (foreign->type & foreign->UPDATE_CASCADE) { str.append(" ON UPDATE CASCADE"); } - if (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL) { + if (foreign->type & foreign->UPDATE_SET_NULL) { str.append(" ON UPDATE SET NULL"); } - if (foreign->type & DICT_FOREIGN_ON_UPDATE_NO_ACTION) { + if (foreign->type & foreign->UPDATE_NO_ACTION) { str.append(" ON UPDATE NO ACTION"); } } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 2c24bbf4485..1abf394c7bd 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -12524,13 +12524,13 @@ create_table_info_t::create_foreign_keys() case FK_OPTION_RESTRICT: break; case FK_OPTION_CASCADE: - foreign->type |= DICT_FOREIGN_ON_DELETE_CASCADE; + foreign->type |= foreign->DELETE_CASCADE; break; case FK_OPTION_SET_NULL: - foreign->type |= DICT_FOREIGN_ON_DELETE_SET_NULL; + foreign->type |= foreign->DELETE_SET_NULL; break; case FK_OPTION_NO_ACTION: - foreign->type |= DICT_FOREIGN_ON_DELETE_NO_ACTION; + foreign->type |= foreign->DELETE_NO_ACTION; break; case FK_OPTION_SET_DEFAULT: // TODO: MDEV-10393 Foreign keys SET DEFAULT action @@ -12545,13 +12545,13 @@ create_table_info_t::create_foreign_keys() case FK_OPTION_RESTRICT: break; case FK_OPTION_CASCADE: - foreign->type |= DICT_FOREIGN_ON_UPDATE_CASCADE; + foreign->type |= foreign->UPDATE_CASCADE; break; case FK_OPTION_SET_NULL: - foreign->type |= DICT_FOREIGN_ON_UPDATE_SET_NULL; + foreign->type |= foreign->UPDATE_SET_NULL; break; case FK_OPTION_NO_ACTION: - foreign->type |= DICT_FOREIGN_ON_UPDATE_NO_ACTION; + foreign->type |= foreign->UPDATE_NO_ACTION; break; case FK_OPTION_SET_DEFAULT: // TODO: MDEV-10393 Foreign keys SET DEFAULT action @@ -15266,28 +15266,43 @@ get_foreign_key_info( name = thd_make_lex_string(thd, name, ptr, strlen(ptr), 1); f_key_info.foreign_fields.push_back(name); + + if (dict_index_t* fidx = foreign->foreign_index) { + if (fidx->fields[i].col->is_nullable()) { + f_key_info.set_nullable(thd, false, i, + foreign->n_fields); + } + } ptr = foreign->referenced_col_names[i]; name = thd_make_lex_string(thd, name, ptr, strlen(ptr), 1); f_key_info.referenced_fields.push_back(name); + + if (dict_index_t* ref_idx = foreign->referenced_index) { + if (ref_idx->fields[i].col->is_nullable()) { + f_key_info.set_nullable(thd, true, i, + foreign->n_fields); + } + } + } while (++i < foreign->n_fields); - if (foreign->type & DICT_FOREIGN_ON_DELETE_CASCADE) { + if (foreign->type & foreign->DELETE_CASCADE) { f_key_info.delete_method = FK_OPTION_CASCADE; - } else if (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL) { + } else if (foreign->type & foreign->DELETE_SET_NULL) { f_key_info.delete_method = FK_OPTION_SET_NULL; - } else if (foreign->type & DICT_FOREIGN_ON_DELETE_NO_ACTION) { + } else if (foreign->type & foreign->DELETE_NO_ACTION) { f_key_info.delete_method = FK_OPTION_NO_ACTION; } else { f_key_info.delete_method = FK_OPTION_RESTRICT; } - if (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE) { + if (foreign->type & foreign->UPDATE_CASCADE) { f_key_info.update_method = FK_OPTION_CASCADE; - } else if (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL) { + } else if (foreign->type & foreign->UPDATE_SET_NULL) { f_key_info.update_method = FK_OPTION_SET_NULL; - } else if (foreign->type & DICT_FOREIGN_ON_UPDATE_NO_ACTION) { + } else if (foreign->type & foreign->UPDATE_NO_ACTION) { f_key_info.update_method = FK_OPTION_NO_ACTION; } else { f_key_info.update_method = FK_OPTION_RESTRICT; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index d3a7e3d3749..613ba560ab2 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -2759,8 +2759,8 @@ innobase_check_fk_option( return(true); } - if (foreign->type & (DICT_FOREIGN_ON_UPDATE_SET_NULL - | DICT_FOREIGN_ON_DELETE_SET_NULL)) { + if (foreign->type & (foreign->UPDATE_SET_NULL + | foreign->DELETE_SET_NULL)) { for (ulint j = 0; j < foreign->n_fields; j++) { if ((dict_index_get_nth_col( @@ -2795,13 +2795,13 @@ innobase_set_foreign_key_option( case FK_OPTION_NO_ACTION: case FK_OPTION_RESTRICT: case FK_OPTION_SET_DEFAULT: - foreign->type = DICT_FOREIGN_ON_DELETE_NO_ACTION; + foreign->type = foreign->DELETE_NO_ACTION; break; case FK_OPTION_CASCADE: - foreign->type = DICT_FOREIGN_ON_DELETE_CASCADE; + foreign->type = foreign->DELETE_CASCADE; break; case FK_OPTION_SET_NULL: - foreign->type = DICT_FOREIGN_ON_DELETE_SET_NULL; + foreign->type = foreign->DELETE_SET_NULL; break; case FK_OPTION_UNDEF: break; @@ -2811,13 +2811,13 @@ innobase_set_foreign_key_option( case FK_OPTION_NO_ACTION: case FK_OPTION_RESTRICT: case FK_OPTION_SET_DEFAULT: - foreign->type |= DICT_FOREIGN_ON_UPDATE_NO_ACTION; + foreign->type |= foreign->UPDATE_NO_ACTION; break; case FK_OPTION_CASCADE: - foreign->type |= DICT_FOREIGN_ON_UPDATE_CASCADE; + foreign->type |= foreign->UPDATE_CASCADE; break; case FK_OPTION_SET_NULL: - foreign->type |= DICT_FOREIGN_ON_UPDATE_SET_NULL; + foreign->type |= foreign->UPDATE_SET_NULL; break; case FK_OPTION_UNDEF: break; @@ -2968,8 +2968,8 @@ innobase_check_fk_stored( { ulint type = foreign->type; - type &= ~(DICT_FOREIGN_ON_DELETE_NO_ACTION - | DICT_FOREIGN_ON_UPDATE_NO_ACTION); + type &= ~(foreign->DELETE_NO_ACTION + | foreign->UPDATE_NO_ACTION); if (type == 0 || s_cols == NULL) { return(false); @@ -4220,103 +4220,157 @@ innobase_dropping_foreign( return(false); } -/** Determines if an InnoDB FOREIGN KEY constraint depends on a -column that is being dropped or modified to NOT NULL. +/** Determines if an InnoDB FOREIGN KEY constraint depends on +the nullability changes of a column. +Enforce the following rules: + +i) Don't allow the referencing column from NULL TO NOT NULL when + 1) Foreign key constraint type is ON UPDATE SET NULL + 2) Foreign key constraint type is ON DELETE SET NULL + 3) Foreign key constraint type is UPDATE CASCADE and referenced + column declared as NULL + +ii) Don't allow the referenced column from NOT NULL to NULL when +foreign key constraint type is UPDATE CASCADE and referencing column +declared as NOT NULL + @param user_table InnoDB table as it is before the ALTER operation -@param col_name Name of the column being altered @param drop_fk constraints being dropped @param n_drop_fk number of constraints that are being dropped -@param drop true=drop column, false=set NOT NULL +@param col_name modified column name +@param new_field_flags Modified field flags @retval true Not allowed (will call my_error()) @retval false Allowed */ -MY_ATTRIBUTE((pure, nonnull(1,4), warn_unused_result)) static -bool -innobase_check_foreigns_low( - const dict_table_t* user_table, - dict_foreign_t** drop_fk, - ulint n_drop_fk, - const char* col_name, - bool drop) +bool check_foreigns_nullability(const dict_table_t *user_table, + dict_foreign_t **drop_fk, ulint n_drop_fk, + const char *col_name, uint32_t new_field_flags) { - dict_foreign_t* foreign; - ut_ad(mutex_own(&dict_sys.mutex)); + ut_ad(mutex_own(&dict_sys.mutex)); - /* Check if any FOREIGN KEY constraints are defined on this - column. */ + /* Changing from NULL to NOT NULL. So check referenced set */ + if ((new_field_flags & NOT_NULL_FLAG)) + { + for (dict_foreign_t *foreign : user_table->foreign_set) + { + if (innobase_dropping_foreign(foreign, drop_fk, n_drop_fk)) + continue; - for (dict_foreign_set::const_iterator it = user_table->foreign_set.begin(); - it != user_table->foreign_set.end(); - ++it) { + if (foreign->on_update_cascade_null(col_name)) + goto non_null_error; - foreign = *it; + if (foreign->type & (foreign->DELETE_SET_NULL | + foreign->UPDATE_SET_NULL)) + { + if (foreign->foreign_index + && foreign->col_fk_exists(col_name) != UINT_MAX) + { +non_null_error: + const char* fid = strchr(foreign->id, '/'); + fid= fid ? fid + 1 : foreign->id; + my_error(ER_FK_COLUMN_NOT_NULL, MYF(0), col_name, fid); + return true; + } + } + } + } + else + { + for (dict_foreign_t *foreign : user_table->referenced_set) + { + if (foreign->on_update_cascade_not_null(col_name)) + { + char display_name[FN_REFLEN]; + const int dblen= int(table_name_t(const_cast(foreign-> + foreign_table_name)).dblen()); + char tbl_name[MAX_TABLE_NAME_LEN]; + uint errors; + ulint tbl_name_len= strlen(foreign->foreign_table_name) - dblen + 1; + strncpy(tbl_name, foreign->foreign_table_name + dblen + 1, + tbl_name_len); + tbl_name[tbl_name_len - 1]= '\0'; + innobase_convert_to_system_charset(tbl_name, + strchr(foreign->foreign_table_name, + '/') + 1, + MAX_TABLE_NAME_LEN, &errors); + if (errors) + { + strncpy(tbl_name, foreign->foreign_table_name + dblen + 1, + tbl_name_len); + tbl_name[tbl_name_len - 1]= '\0'; + } - if (!drop && !(foreign->type - & (DICT_FOREIGN_ON_DELETE_SET_NULL - | DICT_FOREIGN_ON_UPDATE_SET_NULL))) { - continue; - } + my_snprintf(display_name, FN_REFLEN - 1, "%.*s.%s", + dblen, foreign->foreign_table_name, tbl_name); - if (innobase_dropping_foreign(foreign, drop_fk, n_drop_fk)) { - continue; - } + display_name[FN_REFLEN - 1]= '\0'; + const char* fid = strchr(foreign->id, '/'); + fid= fid ? fid + 1 : foreign->id; + my_error(ER_FK_COLUMN_CANNOT_CHANGE_CHILD, MYF(0), col_name, + fid, display_name); + return true; + } + } + } - for (unsigned f = 0; f < foreign->n_fields; f++) { - if (!strcmp(foreign->foreign_col_names[f], - col_name)) { - my_error(drop - ? ER_FK_COLUMN_CANNOT_DROP - : ER_FK_COLUMN_NOT_NULL, MYF(0), - col_name, foreign->id); - return(true); - } - } - } + return false; +} - if (!drop) { - /* SET NULL clauses on foreign key constraints of - child tables affect the child tables, not the parent table. - The column can be NOT NULL in the parent table. */ - return(false); - } +/** Determines if an InnoDB FOREIGN KEY constraint depends on +the column when it is being dropped. +@param user_table InnoDB table as it is before the ALTER operation +@param drop_fk constraints being dropped +@param n_drop_fk number of constraints that are being dropped +@param col_name column name to be dropped +@retval true Not allowed (will call my_error()) +@retval false Allowed +*/ +static +bool check_foreign_drop_col(const dict_table_t *user_table, + dict_foreign_t **drop_fk, ulint n_drop_fk, + const char *col_name) +{ + ut_ad(mutex_own(&dict_sys.mutex)); - /* Check if any FOREIGN KEY constraints in other tables are - referring to the column that is being dropped. */ - for (dict_foreign_set::const_iterator it - = user_table->referenced_set.begin(); - it != user_table->referenced_set.end(); - ++it) { + /* Check if any FOREIGN KEY constraints are defined on this column. */ + for (dict_foreign_t *foreign : user_table->foreign_set) + { + if (innobase_dropping_foreign(foreign, drop_fk, n_drop_fk)) + continue; - foreign = *it; + for (unsigned f = 0; f < foreign->n_fields; f++) + if (!strcmp(foreign->foreign_col_names[f], col_name)) + { + my_error(ER_FK_COLUMN_CANNOT_DROP, MYF(0), + col_name, foreign->id); + return true; + } + } - if (innobase_dropping_foreign(foreign, drop_fk, n_drop_fk)) { - continue; - } + /* Check if any FOREIGN KEY constraints in other tables are + referring to the column that is being dropped. */ + for (dict_foreign_t *foreign : user_table->referenced_set) + { + if (innobase_dropping_foreign(foreign, drop_fk, n_drop_fk)) + continue; - for (unsigned f = 0; f < foreign->n_fields; f++) { - char display_name[FN_REFLEN]; - - if (strcmp(foreign->referenced_col_names[f], - col_name)) { - continue; - } - - char* buf_end = innobase_convert_name( - display_name, (sizeof display_name) - 1, - foreign->foreign_table_name, - strlen(foreign->foreign_table_name), - NULL); - *buf_end = '\0'; - my_error(ER_FK_COLUMN_CANNOT_DROP_CHILD, - MYF(0), col_name, foreign->id, - display_name); - - return(true); - } - } - - return(false); + for (unsigned f = 0; f < foreign->n_fields; f++) + { + char display_name[FN_REFLEN]; + if (strcmp(foreign->referenced_col_names[f], col_name)) + continue; + char* buf_end = innobase_convert_name( + display_name, (sizeof display_name) - 1, + foreign->foreign_table_name, + strlen(foreign->foreign_table_name), NULL); + *buf_end = '\0'; + my_error(ER_FK_COLUMN_CANNOT_DROP_CHILD, + MYF(0), col_name, foreign->id, display_name); + return true; + } + } + return false; } /** Determines if an InnoDB FOREIGN KEY constraint depends on a @@ -4351,16 +4405,25 @@ innobase_check_foreigns( return field.field == *fp; }); - if (it == end || (it->flags & NOT_NULL_FLAG)) { - if (innobase_check_foreigns_low( - user_table, drop_fk, n_drop_fk, - (*fp)->field_name.str, it == end)) { - return(true); + if (it == end) { + if (check_foreign_drop_col( + user_table, drop_fk, n_drop_fk, + (*fp)->field_name.str)) { + return true; + } + } else if ((it->flags & NOT_NULL_FLAG) + != ((*fp)->flags & NOT_NULL_FLAG)) { + + if (check_foreigns_nullability(user_table, drop_fk, + n_drop_fk, + (*fp)->field_name.str, + it->flags)) { + return true; } } } - return(false); + return false; } /** Convert a default value for ADD COLUMN. @@ -9836,8 +9899,8 @@ innobase_update_foreign_try( fk->foreign_col_names, fk->n_fields, fk->referenced_index, TRUE, fk->type - & (DICT_FOREIGN_ON_DELETE_SET_NULL - | DICT_FOREIGN_ON_UPDATE_SET_NULL), + & (fk->DELETE_SET_NULL + | fk->UPDATE_SET_NULL), NULL, NULL, NULL); if (!fk->foreign_index) { my_error(ER_FK_INCORRECT_OPTION, diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 6bf16bcbdc3..5cebfe6710d 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -1451,45 +1451,149 @@ typedef std::set, /** Data structure for a foreign key constraint; an example: FOREIGN KEY (A, B) REFERENCES TABLE2 (C, D). Most fields will be initialized to 0, NULL or FALSE in dict_mem_foreign_create(). */ -struct dict_foreign_t{ - mem_heap_t* heap; /*!< this object is allocated from - this memory heap */ - char* id; /*!< id of the constraint as a - null-terminated string */ - unsigned n_fields:10; /*!< number of indexes' first fields - for which the foreign key - constraint is defined: we allow the - indexes to contain more fields than - mentioned in the constraint, as long - as the first fields are as mentioned */ - unsigned type:6; /*!< 0 or DICT_FOREIGN_ON_DELETE_CASCADE - or DICT_FOREIGN_ON_DELETE_SET_NULL */ - char* foreign_table_name;/*!< foreign table name */ - char* foreign_table_name_lookup; - /*!< foreign table name used for dict lookup */ - dict_table_t* foreign_table; /*!< table where the foreign key is */ - const char** foreign_col_names;/*!< names of the columns in the - foreign key */ - char* referenced_table_name;/*!< referenced table name */ - char* referenced_table_name_lookup; - /*!< referenced table name for dict lookup*/ - dict_table_t* referenced_table;/*!< table where the referenced key - is */ - const char** referenced_col_names;/*!< names of the referenced - columns in the referenced table */ - dict_index_t* foreign_index; /*!< foreign index; we require that - both tables contain explicitly defined - indexes for the constraint: InnoDB - does not generate new indexes - implicitly */ - dict_index_t* referenced_index;/*!< referenced index */ +struct dict_foreign_t +{ + /* Object is allocated from this memory heap */ + mem_heap_t *heap; + /* id of the constraint as a null terminated string */ + char *id; + /* number of indexes first fields for which the foreign key + constraint is defined: We allow the indexes to contain more + fields than mentioned in the constraint, as long as the first + fields are as mentioned */ + unsigned n_fields:10; + /* 0 or DELETE_CASCADE OR DELETE_SET_NULL */ + unsigned type:6; + /* foreign table name */ + char *foreign_table_name; + /* Foreign table name used for dict lookup */ + char *foreign_table_name_lookup; + /* table where the foreign key is */ + dict_table_t *foreign_table; + /* names of the columns in the foreign key */ + const char **foreign_col_names; + /* referenced table name */ + char *referenced_table_name; + /* referenced table name for dict lookup */ + char *referenced_table_name_lookup; + /* Table where the referenced key is */ + dict_table_t *referenced_table; + /* Names of the referenced columns in the referenced table */ + const char **referenced_col_names; + /* foreign index; we require that both tables contain explicitly + defined indexes for the constraint: InnoDB does not generate + new indexes implicitly */ + dict_index_t *foreign_index; + /* referenced index */ + dict_index_t *referenced_index; + /* set of virtual columns affected by foreign key constraint */ + dict_vcol_set *v_cols; + /** Check whether the fulltext index gets affected by + foreign key constraint */ + bool affects_fulltext() const; + /** The flags for ON_UPDATE and ON_DELETE can be ORed; + the default is that a foreign key constraint is enforced, + therefore RESTRICT just means no flag */ + static constexpr unsigned DELETE_CASCADE= 1U; + static constexpr unsigned DELETE_SET_NULL= 2U; + static constexpr unsigned UPDATE_CASCADE= 4U; + static constexpr unsigned UPDATE_SET_NULL= 8U; + static constexpr unsigned DELETE_NO_ACTION= 16U; + static constexpr unsigned UPDATE_NO_ACTION= 32U; +private: + /** Check whether the name exists in given column names + @retval offset or UINT_MAX if name not found */ + unsigned col_exists(const char *name, const char **names) const noexcept + { + for (unsigned i= 0; i < n_fields; i++) + { + if (!strcmp(names[i], name)) + return i; + } + return UINT_MAX; + } - dict_vcol_set* v_cols; /*!< set of virtual columns affected - by foreign key constraint. */ +public: + /** Check whether the name exists in the foreign key column names + @retval offset in case of success + @retval UINT_MAX in case of failure */ + unsigned col_fk_exists(const char *name) const noexcept + { + return col_exists(name, foreign_col_names); + } - /** Check whether the fulltext index gets affected by - foreign key constraint */ - bool affects_fulltext() const; + /** Check whether the name exists in the referenced + key column names + @retval offset in case of success + @retval UINT_MAX in case of failure */ + unsigned col_ref_exists(const char *name) const noexcept + { + return col_exists(name, referenced_col_names); + } + + /** Check whether the foreign key constraint depends on + the nullability of the referenced column to be modified + @param name column to be modified + @return true in case of no conflict or false */ + bool on_update_cascade_not_null(const char *name) const noexcept + { + if (!foreign_index || type != UPDATE_CASCADE) + return false; + unsigned offset= col_ref_exists(name); + if (offset == UINT_MAX) + return false; + + ut_ad(offset < n_fields); + return foreign_index->fields[offset].col->prtype & DATA_NOT_NULL; + } + + /** Check whether the foreign key constraint depends on + the nullability of the foreign column to be modified + @param name column to be modified + @return true in case of no conflict or false */ + bool on_update_cascade_null(const char *name) const noexcept + { + if (!referenced_index || type != UPDATE_CASCADE) + return false; + unsigned offset= col_fk_exists(name); + if (offset == UINT_MAX) + return false; + + ut_ad(offset < n_fields); + return !(referenced_index->fields[offset].col->prtype & DATA_NOT_NULL); + } + + /** This is called during CREATE TABLE statement + to check the foreign key nullability constraint + @return true if foreign key constraint is valid + or else false */ + bool check_fk_constraint_valid() + { + if (!type || type & (DELETE_CASCADE | DELETE_NO_ACTION | + UPDATE_NO_ACTION)) + return true; + + if (!referenced_index) + return true; + + for (unsigned i= 0; i < n_fields; i++) + { + dict_col_t *col = foreign_index->fields[i].col; + if (col->prtype & DATA_NOT_NULL) + { + /* Foreign type is ON DELETE SET NULL + or ON UPDATE SET NULL */ + if (type & (DELETE_SET_NULL | UPDATE_SET_NULL)) + return false; + + dict_col_t *ref_col= referenced_index->fields[i].col; + /* Referenced index respective fields shouldn't be NULL */ + if (!(ref_col->prtype & DATA_NOT_NULL)) + return false; + } + } + return true; + } }; std::ostream& @@ -1667,17 +1771,6 @@ struct dict_foreign_set_free { const dict_foreign_set& m_foreign_set; }; -/** The flags for ON_UPDATE and ON_DELETE can be ORed; the default is that -a foreign key constraint is enforced, therefore RESTRICT just means no flag */ -/* @{ */ -#define DICT_FOREIGN_ON_DELETE_CASCADE 1U /*!< ON DELETE CASCADE */ -#define DICT_FOREIGN_ON_DELETE_SET_NULL 2U /*!< ON UPDATE SET NULL */ -#define DICT_FOREIGN_ON_UPDATE_CASCADE 4U /*!< ON DELETE CASCADE */ -#define DICT_FOREIGN_ON_UPDATE_SET_NULL 8U /*!< ON UPDATE SET NULL */ -#define DICT_FOREIGN_ON_DELETE_NO_ACTION 16U /*!< ON DELETE NO ACTION */ -#define DICT_FOREIGN_ON_UPDATE_NO_ACTION 32U /*!< ON UPDATE NO ACTION */ -/* @} */ - /** Display an identifier. @param[in,out] s output stream @param[in] id_name SQL identifier (other than table name) diff --git a/storage/innobase/row/row0ins.cc b/storage/innobase/row/row0ins.cc index 350a002f83f..4f14ccbd7ab 100644 --- a/storage/innobase/row/row0ins.cc +++ b/storage/innobase/row/row0ins.cc @@ -903,10 +903,10 @@ row_ins_foreign_fill_virtual( return DB_OUT_OF_MEMORY; } ut_ad(!node->is_delete - || (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL)); - ut_ad(foreign->type & (DICT_FOREIGN_ON_DELETE_SET_NULL - | DICT_FOREIGN_ON_UPDATE_SET_NULL - | DICT_FOREIGN_ON_UPDATE_CASCADE)); + || (foreign->type & foreign->DELETE_SET_NULL)); + ut_ad(foreign->type & (foreign->DELETE_SET_NULL + | foreign->UPDATE_SET_NULL + | foreign->UPDATE_CASCADE)); for (uint16_t i = 0; i < n_v_fld; i++) { @@ -1021,8 +1021,8 @@ row_ins_foreign_check_on_constraint( node = static_cast(thr->run_node); if (node->is_delete && 0 == (foreign->type - & (DICT_FOREIGN_ON_DELETE_CASCADE - | DICT_FOREIGN_ON_DELETE_SET_NULL))) { + & (foreign->DELETE_CASCADE + | foreign->DELETE_SET_NULL))) { row_ins_foreign_report_err("Trying to delete", thr, foreign, @@ -1032,8 +1032,8 @@ row_ins_foreign_check_on_constraint( } if (!node->is_delete && 0 == (foreign->type - & (DICT_FOREIGN_ON_UPDATE_CASCADE - | DICT_FOREIGN_ON_UPDATE_SET_NULL))) { + & (foreign->UPDATE_CASCADE + | foreign->UPDATE_SET_NULL))) { /* This is an UPDATE */ @@ -1056,7 +1056,7 @@ row_ins_foreign_check_on_constraint( cascade->foreign = foreign; if (node->is_delete - && (foreign->type & DICT_FOREIGN_ON_DELETE_CASCADE)) { + && (foreign->type & foreign->DELETE_CASCADE)) { cascade->is_delete = PLAIN_DELETE; } else { cascade->is_delete = NO_DELETE; @@ -1199,8 +1199,8 @@ row_ins_foreign_check_on_constraint( } if (node->is_delete - ? (foreign->type & DICT_FOREIGN_ON_DELETE_SET_NULL) - : (foreign->type & DICT_FOREIGN_ON_UPDATE_SET_NULL)) { + ? (foreign->type & foreign->DELETE_SET_NULL) + : (foreign->type & foreign->UPDATE_SET_NULL)) { /* Build the appropriate update vector which sets foreign->n_fields first fields in rec to SQL NULL */ @@ -1245,12 +1245,12 @@ row_ins_foreign_check_on_constraint( } } else if (table->fts && cascade->is_delete == PLAIN_DELETE && foreign->affects_fulltext()) { - /* DICT_FOREIGN_ON_DELETE_CASCADE case */ + /* dict_foreign_t::DELETE_CASCADE case */ fts_trx_add_op(trx, table, doc_id, FTS_DELETE, NULL); } if (!node->is_delete - && (foreign->type & DICT_FOREIGN_ON_UPDATE_CASCADE)) { + && (foreign->type & foreign->UPDATE_CASCADE)) { /* Build the appropriate update vector which sets changing foreign->n_fields first fields in rec to new values */ From 813123e3e020f2f2e8482000a7e87a8a23bd146e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 20 Sep 2024 10:19:44 +0200 Subject: [PATCH 43/62] MDEV-34973: innobase/lock0lock: add `noexcept` MariaDB is compiled with C++ exceptions enabled, and that disallows some optimizations (e.g. the stack must always be unwinding-safe). By adding `noexcept` to functions that are guaranteed to never throw, some of these optimizations can be regained. Low-level locking functions that are called often are a good candidate for this. This shrinks the executable a bit (tested with GCC 14 on aarch64): text data bss dec hex filename 24448910 2436488 9473185 36358583 22ac9b7 build/release/sql/mariadbd 24448622 2436488 9473537 36358647 22ac9f7 build/release/sql/mariadbd --- storage/innobase/include/lock0lock.h | 12 +- storage/innobase/include/srw_lock.h | 212 +++++++++--------- .../include/transactional_lock_guard.h | 32 +-- storage/innobase/sync/srw_lock.cc | 140 ++++++------ 4 files changed, 198 insertions(+), 198 deletions(-) diff --git a/storage/innobase/include/lock0lock.h b/storage/innobase/include/lock0lock.h index 08b9f4bcb35..085e2c78fbc 100644 --- a/storage/innobase/include/lock0lock.h +++ b/storage/innobase/include/lock0lock.h @@ -788,28 +788,28 @@ public: ATTRIBUTE_NOINLINE void rd_unlock(); #else /** Acquire exclusive lock_sys.latch */ - void wr_lock() + void wr_lock() noexcept { mysql_mutex_assert_not_owner(&wait_mutex); latch.wr_lock(); } /** Release exclusive lock_sys.latch */ - void wr_unlock() { latch.wr_unlock(); } + void wr_unlock() noexcept { latch.wr_unlock(); } /** Acquire shared lock_sys.latch */ - void rd_lock() + void rd_lock() noexcept { mysql_mutex_assert_not_owner(&wait_mutex); latch.rd_lock(); } /** Release shared lock_sys.latch */ - void rd_unlock() { latch.rd_unlock(); } + void rd_unlock() noexcept { latch.rd_unlock(); } #endif /** Try to acquire exclusive lock_sys.latch @return whether the latch was acquired */ - bool wr_lock_try() { return latch.wr_lock_try(); } + bool wr_lock_try() noexcept { return latch.wr_lock_try(); } /** Try to acquire shared lock_sys.latch @return whether the latch was acquired */ - bool rd_lock_try() { return latch.rd_lock_try(); } + bool rd_lock_try() noexcept { return latch.rd_lock_try(); } /** Assert that wr_lock() has been invoked by this thread */ void assert_locked() const { ut_ad(latch.have_wr()); } diff --git a/storage/innobase/include/srw_lock.h b/storage/innobase/include/srw_lock.h index a601d09c91a..94f76ab763e 100644 --- a/storage/innobase/include/srw_lock.h +++ b/storage/innobase/include/srw_lock.h @@ -44,10 +44,10 @@ class pthread_mutex_wrapper final /** whether the mutex is usable; set by init(); cleared by destroy() */ bool initialized{false}; public: - ~pthread_mutex_wrapper() { ut_ad(!initialized); } + ~pthread_mutex_wrapper() noexcept { ut_ad(!initialized); } #endif public: - void init() + void init() noexcept { ut_ad(!initialized); ut_d(initialized= true); @@ -56,31 +56,31 @@ public: else pthread_mutex_init(&lock, nullptr); } - void destroy() + void destroy() noexcept { ut_ad(initialized); ut_d(initialized=false); pthread_mutex_destroy(&lock); } # ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP - void wr_lock() { ut_ad(initialized); pthread_mutex_lock(&lock); } + void wr_lock() noexcept { ut_ad(initialized); pthread_mutex_lock(&lock); } # else private: - void wr_wait(); + void wr_wait() noexcept; public: - inline void wr_lock(); + inline void wr_lock() noexcept; # endif - void wr_unlock() { ut_ad(initialized); pthread_mutex_unlock(&lock); } - bool wr_lock_try() + void wr_unlock() noexcept { ut_ad(initialized); pthread_mutex_unlock(&lock); } + bool wr_lock_try() noexcept { ut_ad(initialized); return !pthread_mutex_trylock(&lock); } }; # ifndef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP -template<> void pthread_mutex_wrapper::wr_wait(); +template<> void pthread_mutex_wrapper::wr_wait() noexcept; template<> -inline void pthread_mutex_wrapper::wr_lock() +inline void pthread_mutex_wrapper::wr_lock() noexcept { ut_ad(initialized); pthread_mutex_lock(&lock); } template<> -inline void pthread_mutex_wrapper::wr_lock() +inline void pthread_mutex_wrapper::wr_lock() noexcept { if (!wr_lock_try()) wr_wait(); } # endif #endif @@ -110,22 +110,22 @@ private: #endif /** Wait until the mutex has been acquired */ - void wait_and_lock(); + void wait_and_lock() noexcept; /** Wait for lock!=lk */ - inline void wait(uint32_t lk); + inline void wait(uint32_t lk) noexcept; /** Wake up one wait() thread */ - void wake(); + void wake() noexcept; /** Wake up all wait() threads */ - inline void wake_all(); + inline void wake_all() noexcept; public: /** @return whether the mutex is being held or waited for */ - bool is_locked_or_waiting() const + bool is_locked_or_waiting() const noexcept { return lock.load(std::memory_order_acquire) != 0; } /** @return whether the mutex is being held by any thread */ - bool is_locked() const + bool is_locked() const noexcept { return (lock.load(std::memory_order_acquire) & HOLDER) != 0; } - void init() + void init() noexcept { DBUG_ASSERT(!is_locked_or_waiting()); #ifdef SUX_LOCK_GENERIC @@ -133,7 +133,7 @@ public: pthread_cond_init(&cond, nullptr); #endif } - void destroy() + void destroy() noexcept { DBUG_ASSERT(!is_locked_or_waiting()); #ifdef SUX_LOCK_GENERIC @@ -143,7 +143,7 @@ public: } /** @return whether the mutex was acquired */ - bool wr_lock_try() + bool wr_lock_try() noexcept { uint32_t lk= 0; return lock.compare_exchange_strong(lk, HOLDER + WAITER, @@ -151,8 +151,8 @@ public: std::memory_order_relaxed); } - void wr_lock() { if (!wr_lock_try()) wait_and_lock(); } - void wr_unlock() + void wr_lock() noexcept { if (!wr_lock_try()) wait_and_lock(); } + void wr_unlock() noexcept { const uint32_t lk= lock.fetch_sub(HOLDER + WAITER, std::memory_order_release); @@ -198,16 +198,16 @@ class ssux_lock_impl static constexpr uint32_t WRITER= 1U << 31; /** Wait for readers!=lk */ - inline void wait(uint32_t lk); + inline void wait(uint32_t lk) noexcept; /** Wait for readers!=lk|WRITER */ - void wr_wait(uint32_t lk); + void wr_wait(uint32_t lk) noexcept; /** Wake up wait() on the last rd_unlock() */ - void wake(); + void wake() noexcept; /** Acquire a read lock */ - void rd_wait(); + void rd_wait() noexcept; public: - void init() + void init() noexcept { writer.init(); DBUG_ASSERT(is_vacant()); @@ -215,7 +215,7 @@ public: pthread_cond_init(&readers_cond, nullptr); #endif } - void destroy() + void destroy() noexcept { DBUG_ASSERT(is_vacant()); writer.destroy(); @@ -224,17 +224,17 @@ public: #endif } /** @return whether any writer is waiting */ - bool is_waiting() const + bool is_waiting() const noexcept { return (readers.load(std::memory_order_relaxed) & WRITER) != 0; } #ifndef DBUG_OFF /** @return whether the lock is being held or waited for */ - bool is_vacant() const { return !is_locked_or_waiting(); } + bool is_vacant() const noexcept { return !is_locked_or_waiting(); } #endif /* !DBUG_OFF */ private: /** Try to acquire a shared latch. @return the lock word value if the latch was not acquired @retval 0 if the latch was acquired */ - uint32_t rd_lock_try_low() + uint32_t rd_lock_try_low() noexcept { uint32_t lk= 0; while (!readers.compare_exchange_weak(lk, lk + 1, @@ -246,11 +246,11 @@ private: } public: - bool rd_lock_try() { return rd_lock_try_low() == 0; } + bool rd_lock_try() noexcept { return rd_lock_try_low() == 0; } - bool u_lock_try() { return writer.wr_lock_try(); } + bool u_lock_try() noexcept { return writer.wr_lock_try(); } - bool wr_lock_try() + bool wr_lock_try() noexcept { if (!writer.wr_lock_try()) return false; @@ -263,12 +263,12 @@ public: return false; } - void rd_lock() { if (!rd_lock_try()) rd_wait(); } - void u_lock() + void rd_lock() noexcept { if (!rd_lock_try()) rd_wait(); } + void u_lock() noexcept { writer.wr_lock(); } - void wr_lock() + void wr_lock() noexcept { writer.wr_lock(); #if defined __i386__||defined __x86_64__||defined _M_IX86||defined _M_X64 @@ -289,23 +289,23 @@ public: #endif } - bool rd_u_upgrade_try() { return writer.wr_lock_try(); } + bool rd_u_upgrade_try() noexcept { return writer.wr_lock_try(); } - void u_wr_upgrade() + void u_wr_upgrade() noexcept { DBUG_ASSERT(writer.is_locked()); uint32_t lk= readers.fetch_add(WRITER, std::memory_order_acquire); if (lk) wr_wait(lk); } - void wr_u_downgrade() + void wr_u_downgrade() noexcept { DBUG_ASSERT(writer.is_locked()); DBUG_ASSERT(is_write_locked()); readers.store(0, std::memory_order_release); /* Note: Any pending rd_lock() will not be woken up until u_unlock() */ } - void u_rd_downgrade() + void u_rd_downgrade() noexcept { DBUG_ASSERT(writer.is_locked()); ut_d(uint32_t lk=) readers.fetch_add(1, std::memory_order_relaxed); @@ -313,18 +313,18 @@ public: u_unlock(); } - void rd_unlock() + void rd_unlock() noexcept { uint32_t lk= readers.fetch_sub(1, std::memory_order_release); ut_ad(~WRITER & lk); if (lk == WRITER + 1) wake(); } - void u_unlock() + void u_unlock() noexcept { writer.wr_unlock(); } - void wr_unlock() + void wr_unlock() noexcept { DBUG_ASSERT(is_write_locked()); readers.store(0, std::memory_order_release); @@ -340,10 +340,10 @@ public: bool is_locked_or_waiting() const noexcept { return is_locked() || writer.is_locked_or_waiting(); } - void lock_shared() { rd_lock(); } - void unlock_shared() { rd_unlock(); } - void lock() { wr_lock(); } - void unlock() { wr_unlock(); } + void lock_shared() noexcept { rd_lock(); } + void unlock_shared() noexcept { rd_unlock(); } + void lock() noexcept { wr_lock(); } + void unlock() noexcept { wr_unlock(); } }; #if defined _WIN32 || defined SUX_LOCK_GENERIC @@ -360,20 +360,20 @@ class srw_lock_ rw_lock_t lk; # endif - void rd_wait(); - void wr_wait(); + void rd_wait() noexcept; + void wr_wait() noexcept; public: - void init() { IF_WIN(,my_rwlock_init(&lk, nullptr)); } - void destroy() { IF_WIN(,rwlock_destroy(&lk)); } - inline void rd_lock(); - inline void wr_lock(); - bool rd_lock_try() + void init() noexcept { IF_WIN(,my_rwlock_init(&lk, nullptr)); } + void destroy() noexcept { IF_WIN(,rwlock_destroy(&lk)); } + inline void rd_lock() noexcept; + inline void wr_lock() noexcept; + bool rd_lock_try() noexcept { return IF_WIN(TryAcquireSRWLockShared(&lk), !rw_tryrdlock(&lk)); } - void rd_unlock() + void rd_unlock() noexcept { IF_WIN(ReleaseSRWLockShared(&lk), rw_unlock(&lk)); } - bool wr_lock_try() + bool wr_lock_try() noexcept { return IF_WIN(TryAcquireSRWLockExclusive(&lk), !rw_trywrlock(&lk)); } - void wr_unlock() + void wr_unlock() noexcept { IF_WIN(ReleaseSRWLockExclusive(&lk), rw_unlock(&lk)); } #ifdef _WIN32 /** @return whether any lock may be held by any thread */ @@ -387,27 +387,27 @@ public: return is_locked(); } - void lock_shared() { rd_lock(); } - void unlock_shared() { rd_unlock(); } - void lock() { wr_lock(); } - void unlock() { wr_unlock(); } + void lock_shared() noexcept { rd_lock(); } + void unlock_shared() noexcept { rd_unlock(); } + void lock() noexcept { wr_lock(); } + void unlock() noexcept { wr_unlock(); } #endif }; -template<> void srw_lock_::rd_wait(); -template<> void srw_lock_::wr_wait(); +template<> void srw_lock_::rd_wait() noexcept; +template<> void srw_lock_::wr_wait() noexcept; template<> -inline void srw_lock_::rd_lock() +inline void srw_lock_::rd_lock() noexcept { IF_WIN(AcquireSRWLockShared(&lk), rw_rdlock(&lk)); } template<> -inline void srw_lock_::wr_lock() +inline void srw_lock_::wr_lock() noexcept { IF_WIN(AcquireSRWLockExclusive(&lk), rw_wrlock(&lk)); } template<> -inline void srw_lock_::rd_lock() { if (!rd_lock_try()) rd_wait(); } +inline void srw_lock_::rd_lock() noexcept { if (!rd_lock_try()) rd_wait(); } template<> -inline void srw_lock_::wr_lock() { if (!wr_lock_try()) wr_wait(); } +inline void srw_lock_::wr_lock() noexcept { if (!wr_lock_try()) wr_wait(); } typedef srw_lock_ srw_lock_low; typedef srw_lock_ srw_spin_lock_low; @@ -433,17 +433,17 @@ class ssux_lock PSI_rwlock *pfs_psi; ssux_lock_impl lock; - ATTRIBUTE_NOINLINE void psi_rd_lock(const char *file, unsigned line); - ATTRIBUTE_NOINLINE void psi_wr_lock(const char *file, unsigned line); - ATTRIBUTE_NOINLINE void psi_u_lock(const char *file, unsigned line); - ATTRIBUTE_NOINLINE void psi_u_wr_upgrade(const char *file, unsigned line); + ATTRIBUTE_NOINLINE void psi_rd_lock(const char *file, unsigned line) noexcept; + ATTRIBUTE_NOINLINE void psi_wr_lock(const char *file, unsigned line) noexcept; + ATTRIBUTE_NOINLINE void psi_u_lock(const char *file, unsigned line) noexcept; + ATTRIBUTE_NOINLINE void psi_u_wr_upgrade(const char *file, unsigned line) noexcept; public: - void init(mysql_pfs_key_t key) + void init(mysql_pfs_key_t key) noexcept { pfs_psi= PSI_RWLOCK_CALL(init_rwlock)(key, this); lock.init(); } - void destroy() + void destroy() noexcept { if (psi_likely(pfs_psi != nullptr)) { @@ -452,56 +452,56 @@ public: } lock.destroy(); } - void rd_lock(const char *file, unsigned line) + void rd_lock(const char *file, unsigned line) noexcept { if (psi_likely(pfs_psi != nullptr)) psi_rd_lock(file, line); else lock.rd_lock(); } - void rd_unlock() + void rd_unlock() noexcept { if (psi_likely(pfs_psi != nullptr)) PSI_RWLOCK_CALL(unlock_rwlock)(pfs_psi); lock.rd_unlock(); } - void u_lock(const char *file, unsigned line) + void u_lock(const char *file, unsigned line) noexcept { if (psi_likely(pfs_psi != nullptr)) psi_u_lock(file, line); else lock.u_lock(); } - void u_unlock() + void u_unlock() noexcept { if (psi_likely(pfs_psi != nullptr)) PSI_RWLOCK_CALL(unlock_rwlock)(pfs_psi); lock.u_unlock(); } - void wr_lock(const char *file, unsigned line) + void wr_lock(const char *file, unsigned line) noexcept { if (psi_likely(pfs_psi != nullptr)) psi_wr_lock(file, line); else lock.wr_lock(); } - void wr_unlock() + void wr_unlock() noexcept { if (psi_likely(pfs_psi != nullptr)) PSI_RWLOCK_CALL(unlock_rwlock)(pfs_psi); lock.wr_unlock(); } - void u_wr_upgrade(const char *file, unsigned line) + void u_wr_upgrade(const char *file, unsigned line) noexcept { if (psi_likely(pfs_psi != nullptr)) psi_u_wr_upgrade(file, line); else lock.u_wr_upgrade(); } - bool rd_lock_try() { return lock.rd_lock_try(); } - bool u_lock_try() { return lock.u_lock_try(); } - bool wr_lock_try() { return lock.wr_lock_try(); } - bool is_waiting() const { return lock.is_waiting(); } + bool rd_lock_try() noexcept { return lock.rd_lock_try(); } + bool u_lock_try() noexcept { return lock.u_lock_try(); } + bool wr_lock_try() noexcept { return lock.wr_lock_try(); } + bool is_waiting() const noexcept { return lock.is_waiting(); } }; /** Slim reader-writer lock with PERFORMANCE_SCHEMA instrumentation */ @@ -515,15 +515,15 @@ class srw_lock_impl ssux_lock_impl lock; # endif - ATTRIBUTE_NOINLINE void psi_rd_lock(const char *file, unsigned line); - ATTRIBUTE_NOINLINE void psi_wr_lock(const char *file, unsigned line); + ATTRIBUTE_NOINLINE void psi_rd_lock(const char *file, unsigned line) noexcept; + ATTRIBUTE_NOINLINE void psi_wr_lock(const char *file, unsigned line) noexcept; public: - void init(mysql_pfs_key_t key) + void init(mysql_pfs_key_t key) noexcept { pfs_psi= PSI_RWLOCK_CALL(init_rwlock)(key, this); lock.init(); } - void destroy() + void destroy() noexcept { if (psi_likely(pfs_psi != nullptr)) { @@ -532,36 +532,36 @@ public: } lock.destroy(); } - void rd_lock(const char *file, unsigned line) + void rd_lock(const char *file, unsigned line) noexcept { if (psi_likely(pfs_psi != nullptr)) psi_rd_lock(file, line); else lock.rd_lock(); } - void rd_unlock() + void rd_unlock() noexcept { if (psi_likely(pfs_psi != nullptr)) PSI_RWLOCK_CALL(unlock_rwlock)(pfs_psi); lock.rd_unlock(); } - void wr_lock(const char *file, unsigned line) + void wr_lock(const char *file, unsigned line) noexcept { if (psi_likely(pfs_psi != nullptr)) psi_wr_lock(file, line); else lock.wr_lock(); } - void wr_unlock() + void wr_unlock() noexcept { if (psi_likely(pfs_psi != nullptr)) PSI_RWLOCK_CALL(unlock_rwlock)(pfs_psi); lock.wr_unlock(); } - bool rd_lock_try() { return lock.rd_lock_try(); } - bool wr_lock_try() { return lock.wr_lock_try(); } - void lock_shared() { return rd_lock(SRW_LOCK_CALL); } - void unlock_shared() { return rd_unlock(); } + bool rd_lock_try() noexcept { return lock.rd_lock_try(); } + bool wr_lock_try() noexcept { return lock.wr_lock_try(); } + void lock_shared() noexcept { return rd_lock(SRW_LOCK_CALL); } + void unlock_shared() noexcept { return rd_unlock(); } #ifndef SUX_LOCK_GENERIC /** @return whether any lock may be held by any thread */ bool is_locked_or_waiting() const noexcept @@ -591,11 +591,11 @@ class srw_lock_debug : private srw_lock std::atomic*> readers; /** Register a read lock. */ - void readers_register(); + void readers_register() noexcept; public: - void SRW_LOCK_INIT(mysql_pfs_key_t key); - void destroy(); + void SRW_LOCK_INIT(mysql_pfs_key_t key) noexcept; + void destroy() noexcept; #ifndef SUX_LOCK_GENERIC /** @return whether any lock may be held by any thread */ @@ -606,17 +606,17 @@ public: #endif /** Acquire an exclusive lock */ - void wr_lock(SRW_LOCK_ARGS(const char *file, unsigned line)); + void wr_lock(SRW_LOCK_ARGS(const char *file, unsigned line)) noexcept; /** @return whether an exclusive lock was acquired */ - bool wr_lock_try(); + bool wr_lock_try() noexcept; /** Release after wr_lock() */ - void wr_unlock(); + void wr_unlock() noexcept; /** Acquire a shared lock */ - void rd_lock(SRW_LOCK_ARGS(const char *file, unsigned line)); + void rd_lock(SRW_LOCK_ARGS(const char *file, unsigned line)) noexcept; /** @return whether a shared lock was acquired */ - bool rd_lock_try(); + bool rd_lock_try() noexcept; /** Release after rd_lock() */ - void rd_unlock(); + void rd_unlock() noexcept; /** @return whether this thread is between rd_lock() and rd_unlock() */ bool have_rd() const noexcept; /** @return whether this thread is between wr_lock() and wr_unlock() */ diff --git a/storage/innobase/include/transactional_lock_guard.h b/storage/innobase/include/transactional_lock_guard.h index 168a68977a7..c48bde87d72 100644 --- a/storage/innobase/include/transactional_lock_guard.h +++ b/storage/innobase/include/transactional_lock_guard.h @@ -41,7 +41,7 @@ static inline bool xtest() { return false; } #else # if defined __i386__||defined __x86_64__||defined _M_IX86||defined _M_X64 extern bool have_transactional_memory; -bool transactional_lock_enabled(); +bool transactional_lock_enabled() noexcept; # include # if defined __GNUC__ && !defined __INTEL_COMPILER @@ -52,7 +52,7 @@ bool transactional_lock_enabled(); # define TRANSACTIONAL_INLINE /* nothing */ # endif -TRANSACTIONAL_INLINE static inline bool xbegin() +TRANSACTIONAL_INLINE static inline bool xbegin() noexcept { return have_transactional_memory && _xbegin() == _XBEGIN_STARTED; } @@ -60,18 +60,18 @@ TRANSACTIONAL_INLINE static inline bool xbegin() # ifdef UNIV_DEBUG # ifdef __GNUC__ /** @return whether a memory transaction is active */ -bool xtest(); +bool xtest() noexcept; # else -static inline bool xtest() { return have_transactional_memory && _xtest(); } +static inline bool xtest() noexcept { return have_transactional_memory && _xtest(); } # endif # endif -TRANSACTIONAL_INLINE static inline void xabort() { _xabort(0); } +TRANSACTIONAL_INLINE static inline void xabort() noexcept { _xabort(0); } -TRANSACTIONAL_INLINE static inline void xend() { _xend(); } +TRANSACTIONAL_INLINE static inline void xend() noexcept { _xend(); } # elif defined __powerpc64__ || defined __s390__ extern bool have_transactional_memory; -bool transactional_lock_enabled(); +bool transactional_lock_enabled() noexcept; # define TRANSACTIONAL_TARGET __attribute__((hot)) # define TRANSACTIONAL_INLINE __attribute__((hot,always_inline)) @@ -89,9 +89,9 @@ bool transactional_lock_enabled(); could be implemented here, we keep the implementation the same as ppc64. */ -TRANSACTIONAL_TARGET bool xbegin(); -TRANSACTIONAL_TARGET void xabort(); -TRANSACTIONAL_TARGET void xend(); +TRANSACTIONAL_TARGET bool xbegin() noexcept; +TRANSACTIONAL_TARGET void xabort() noexcept; +TRANSACTIONAL_TARGET void xend() noexcept; # ifdef UNIV_DEBUG bool xtest(); # endif @@ -105,7 +105,7 @@ class transactional_lock_guard mutex &m; public: - TRANSACTIONAL_INLINE transactional_lock_guard(mutex &m) : m(m) + TRANSACTIONAL_INLINE transactional_lock_guard(mutex &m) noexcept : m(m) { #ifndef NO_ELISION if (xbegin()) @@ -117,8 +117,8 @@ public: #endif m.lock(); } - transactional_lock_guard(const transactional_lock_guard &)= delete; - TRANSACTIONAL_INLINE ~transactional_lock_guard() + transactional_lock_guard(const transactional_lock_guard &) noexcept= delete; + TRANSACTIONAL_INLINE ~transactional_lock_guard() noexcept { #ifndef NO_ELISION if (was_elided()) xend(); else @@ -144,7 +144,7 @@ class transactional_shared_lock_guard #endif public: - TRANSACTIONAL_INLINE transactional_shared_lock_guard(mutex &m) : m(m) + TRANSACTIONAL_INLINE transactional_shared_lock_guard(mutex &m) noexcept : m(m) { #ifndef NO_ELISION if (xbegin()) @@ -160,9 +160,9 @@ public: #endif m.lock_shared(); } - transactional_shared_lock_guard(const transactional_shared_lock_guard &)= + transactional_shared_lock_guard(const transactional_shared_lock_guard &) noexcept= delete; - TRANSACTIONAL_INLINE ~transactional_shared_lock_guard() + TRANSACTIONAL_INLINE ~transactional_shared_lock_guard() noexcept { #ifndef NO_ELISION if (was_elided()) xend(); else diff --git a/storage/innobase/sync/srw_lock.cc b/storage/innobase/sync/srw_lock.cc index 71e3303736d..4b380462189 100644 --- a/storage/innobase/sync/srw_lock.cc +++ b/storage/innobase/sync/srw_lock.cc @@ -25,7 +25,7 @@ this program; if not, write to the Free Software Foundation, Inc., #elif defined _MSC_VER && (defined _M_IX86 || defined _M_X64) # include bool have_transactional_memory; -bool transactional_lock_enabled() +bool transactional_lock_enabled() noexcept { int regs[4]; __cpuid(regs, 0); @@ -39,7 +39,7 @@ bool transactional_lock_enabled() #elif defined __GNUC__ && (defined __i386__ || defined __x86_64__) # include bool have_transactional_memory; -bool transactional_lock_enabled() +bool transactional_lock_enabled() noexcept { if (__get_cpuid_max(0, nullptr) < 7) return false; @@ -52,7 +52,7 @@ bool transactional_lock_enabled() # ifdef UNIV_DEBUG TRANSACTIONAL_TARGET -bool xtest() { return have_transactional_memory && _xtest(); } +bool xtest() noexcept { return have_transactional_memory && _xtest(); } # endif #elif defined __powerpc64__ || defined __s390__ # include @@ -60,21 +60,21 @@ bool xtest() { return have_transactional_memory && _xtest(); } # include __attribute__((target("htm"),hot)) -bool xbegin() +bool xbegin() noexcept { return have_transactional_memory && __TM_simple_begin() == _HTM_TBEGIN_STARTED; } __attribute__((target("htm"),hot)) -void xabort() { __TM_abort(); } +void xabort() noexcept { __TM_abort(); } __attribute__((target("htm"),hot)) -void xend() { __TM_end(); } +void xend() noexcept { __TM_end(); } bool have_transactional_memory; static sigjmp_buf ill_jmp; -static void ill_handler(int sig) +static void ill_handler(int sig) noexcept { siglongjmp(ill_jmp, sig); } @@ -83,7 +83,7 @@ static void ill_handler(int sig) and a 1 instruction store can succeed. */ __attribute__((noinline)) -static void test_tm(bool *r) +static void test_tm(bool *r) noexcept { if (__TM_simple_begin() == _HTM_TBEGIN_STARTED) { @@ -91,7 +91,7 @@ static void test_tm(bool *r) __TM_end(); } } -bool transactional_lock_enabled() +bool transactional_lock_enabled() noexcept { bool r= false; sigset_t oset; @@ -115,7 +115,7 @@ bool transactional_lock_enabled() # ifdef UNIV_DEBUG __attribute__((target("htm"),hot)) -bool xtest() +bool xtest() noexcept { # ifdef __s390x__ return have_transactional_memory && @@ -129,13 +129,13 @@ bool xtest() #endif /** @return the parameter for srw_pause() */ -static inline unsigned srw_pause_delay() +static inline unsigned srw_pause_delay() noexcept { return my_cpu_relax_multiplier / 4 * srv_spin_wait_delay; } /** Pause the CPU for some time, with no memory accesses. */ -static inline void srw_pause(unsigned delay) +static inline void srw_pause(unsigned delay) noexcept { HMT_low(); while (delay--) @@ -145,7 +145,7 @@ static inline void srw_pause(unsigned delay) #ifdef SUX_LOCK_GENERIC # ifndef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP -template<> void pthread_mutex_wrapper::wr_wait() +template<> void pthread_mutex_wrapper::wr_wait() noexcept { const unsigned delay= srw_pause_delay(); @@ -160,13 +160,13 @@ template<> void pthread_mutex_wrapper::wr_wait() } # endif -template void ssux_lock_impl::init(); -template void ssux_lock_impl::init(); -template void ssux_lock_impl::destroy(); -template void ssux_lock_impl::destroy(); +template void ssux_lock_impl::init() noexcept; +template void ssux_lock_impl::init() noexcept; +template void ssux_lock_impl::destroy() noexcept; +template void ssux_lock_impl::destroy() noexcept; template -inline void srw_mutex_impl::wait(uint32_t lk) +inline void srw_mutex_impl::wait(uint32_t lk) noexcept { pthread_mutex_lock(&mutex); while (lock.load(std::memory_order_relaxed) == lk) @@ -175,7 +175,7 @@ inline void srw_mutex_impl::wait(uint32_t lk) } template -inline void ssux_lock_impl::wait(uint32_t lk) +inline void ssux_lock_impl::wait(uint32_t lk) noexcept { pthread_mutex_lock(&writer.mutex); while (readers.load(std::memory_order_relaxed) == lk) @@ -184,21 +184,21 @@ inline void ssux_lock_impl::wait(uint32_t lk) } template -void srw_mutex_impl::wake() +void srw_mutex_impl::wake() noexcept { pthread_mutex_lock(&mutex); pthread_cond_signal(&cond); pthread_mutex_unlock(&mutex); } template -inline void srw_mutex_impl::wake_all() +inline void srw_mutex_impl::wake_all() noexcept { pthread_mutex_lock(&mutex); pthread_cond_broadcast(&cond); pthread_mutex_unlock(&mutex); } template -void ssux_lock_impl::wake() +void ssux_lock_impl::wake() noexcept { pthread_mutex_lock(&writer.mutex); pthread_cond_signal(&readers_cond); @@ -210,18 +210,18 @@ static_assert(4 == sizeof(rw_lock), "ABI"); # include template -inline void srw_mutex_impl::wait(uint32_t lk) +inline void srw_mutex_impl::wait(uint32_t lk) noexcept { WaitOnAddress(&lock, &lk, 4, INFINITE); } template -void srw_mutex_impl::wake() { WakeByAddressSingle(&lock); } +void srw_mutex_impl::wake() noexcept { WakeByAddressSingle(&lock); } template -inline void srw_mutex_impl::wake_all() { WakeByAddressAll(&lock); } +inline void srw_mutex_impl::wake_all() noexcept { WakeByAddressAll(&lock); } template -inline void ssux_lock_impl::wait(uint32_t lk) +inline void ssux_lock_impl::wait(uint32_t lk) noexcept { WaitOnAddress(&readers, &lk, 4, INFINITE); } template -void ssux_lock_impl::wake() { WakeByAddressSingle(&readers); } +void ssux_lock_impl::wake() noexcept { WakeByAddressSingle(&readers); } # else # ifdef __linux__ # include @@ -249,28 +249,28 @@ void ssux_lock_impl::wake() { WakeByAddressSingle(&readers); } # endif template -inline void srw_mutex_impl::wait(uint32_t lk) +inline void srw_mutex_impl::wait(uint32_t lk) noexcept { SRW_FUTEX(&lock, WAIT, lk); } template -void srw_mutex_impl::wake() { SRW_FUTEX(&lock, WAKE, 1); } +void srw_mutex_impl::wake() noexcept { SRW_FUTEX(&lock, WAKE, 1); } template -void srw_mutex_impl::wake_all() { SRW_FUTEX(&lock, WAKE, INT_MAX); } +void srw_mutex_impl::wake_all() noexcept { SRW_FUTEX(&lock, WAKE, INT_MAX); } template -inline void ssux_lock_impl::wait(uint32_t lk) +inline void ssux_lock_impl::wait(uint32_t lk) noexcept { SRW_FUTEX(&readers, WAIT, lk); } template -void ssux_lock_impl::wake() { SRW_FUTEX(&readers, WAKE, 1); } +void ssux_lock_impl::wake() noexcept { SRW_FUTEX(&readers, WAKE, 1); } # endif #endif -template void srw_mutex_impl::wake(); -template void ssux_lock_impl::wake(); -template void srw_mutex_impl::wake(); -template void ssux_lock_impl::wake(); +template void srw_mutex_impl::wake() noexcept; +template void ssux_lock_impl::wake() noexcept; +template void srw_mutex_impl::wake() noexcept; +template void ssux_lock_impl::wake() noexcept; template -void srw_mutex_impl::wait_and_lock() +void srw_mutex_impl::wait_and_lock() noexcept { uint32_t lk= WAITER + lock.fetch_add(WAITER, std::memory_order_relaxed); @@ -339,11 +339,11 @@ acquired: } } -template void srw_mutex_impl::wait_and_lock(); -template void srw_mutex_impl::wait_and_lock(); +template void srw_mutex_impl::wait_and_lock() noexcept; +template void srw_mutex_impl::wait_and_lock() noexcept; template -void ssux_lock_impl::wr_wait(uint32_t lk) +void ssux_lock_impl::wr_wait(uint32_t lk) noexcept { DBUG_ASSERT(writer.is_locked()); DBUG_ASSERT(lk); @@ -374,11 +374,11 @@ void ssux_lock_impl::wr_wait(uint32_t lk) while (lk != WRITER); } -template void ssux_lock_impl::wr_wait(uint32_t); -template void ssux_lock_impl::wr_wait(uint32_t); +template void ssux_lock_impl::wr_wait(uint32_t) noexcept; +template void ssux_lock_impl::wr_wait(uint32_t) noexcept; template -void ssux_lock_impl::rd_wait() +void ssux_lock_impl::rd_wait() noexcept { const unsigned delay= srw_pause_delay(); @@ -429,11 +429,11 @@ void ssux_lock_impl::rd_wait() writer.wake_all(); } -template void ssux_lock_impl::rd_wait(); -template void ssux_lock_impl::rd_wait(); +template void ssux_lock_impl::rd_wait() noexcept; +template void ssux_lock_impl::rd_wait() noexcept; #if defined _WIN32 || defined SUX_LOCK_GENERIC -template<> void srw_lock_::rd_wait() +template<> void srw_lock_::rd_wait() noexcept { const unsigned delay= srw_pause_delay(); @@ -447,7 +447,7 @@ template<> void srw_lock_::rd_wait() IF_WIN(AcquireSRWLockShared(&lk), rw_rdlock(&lk)); } -template<> void srw_lock_::wr_wait() +template<> void srw_lock_::wr_wait() noexcept { const unsigned delay= srw_pause_delay(); @@ -463,13 +463,13 @@ template<> void srw_lock_::wr_wait() #endif #ifdef UNIV_PFS_RWLOCK -template void srw_lock_impl::psi_rd_lock(const char*, unsigned); -template void srw_lock_impl::psi_wr_lock(const char*, unsigned); -template void srw_lock_impl::psi_rd_lock(const char*, unsigned); -template void srw_lock_impl::psi_wr_lock(const char*, unsigned); +template void srw_lock_impl::psi_rd_lock(const char*, unsigned) noexcept; +template void srw_lock_impl::psi_wr_lock(const char*, unsigned) noexcept; +template void srw_lock_impl::psi_rd_lock(const char*, unsigned) noexcept; +template void srw_lock_impl::psi_wr_lock(const char*, unsigned) noexcept; template -void srw_lock_impl::psi_rd_lock(const char *file, unsigned line) +void srw_lock_impl::psi_rd_lock(const char *file, unsigned line) noexcept { PSI_rwlock_locker_state state; const bool nowait= lock.rd_lock_try(); @@ -486,7 +486,7 @@ void srw_lock_impl::psi_rd_lock(const char *file, unsigned line) } template -void srw_lock_impl::psi_wr_lock(const char *file, unsigned line) +void srw_lock_impl::psi_wr_lock(const char *file, unsigned line) noexcept { PSI_rwlock_locker_state state; # if defined _WIN32 || defined SUX_LOCK_GENERIC @@ -525,7 +525,7 @@ void srw_lock_impl::psi_wr_lock(const char *file, unsigned line) # endif } -void ssux_lock::psi_rd_lock(const char *file, unsigned line) +void ssux_lock::psi_rd_lock(const char *file, unsigned line) noexcept { PSI_rwlock_locker_state state; const bool nowait= lock.rd_lock_try(); @@ -541,7 +541,7 @@ void ssux_lock::psi_rd_lock(const char *file, unsigned line) lock.rd_lock(); } -void ssux_lock::psi_u_lock(const char *file, unsigned line) +void ssux_lock::psi_u_lock(const char *file, unsigned line) noexcept { PSI_rwlock_locker_state state; if (PSI_rwlock_locker *locker= PSI_RWLOCK_CALL(start_rwlock_wrwait) @@ -554,7 +554,7 @@ void ssux_lock::psi_u_lock(const char *file, unsigned line) lock.u_lock(); } -void ssux_lock::psi_wr_lock(const char *file, unsigned line) +void ssux_lock::psi_wr_lock(const char *file, unsigned line) noexcept { PSI_rwlock_locker_state state; # if defined _WIN32 || defined SUX_LOCK_GENERIC @@ -594,7 +594,7 @@ void ssux_lock::psi_wr_lock(const char *file, unsigned line) # endif } -void ssux_lock::psi_u_wr_upgrade(const char *file, unsigned line) +void ssux_lock::psi_u_wr_upgrade(const char *file, unsigned line) noexcept { PSI_rwlock_locker_state state; DBUG_ASSERT(lock.writer.is_locked()); @@ -616,14 +616,14 @@ void ssux_lock::psi_u_wr_upgrade(const char *file, unsigned line) lock.u_wr_upgrade(); } #else /* UNIV_PFS_RWLOCK */ -template void ssux_lock_impl::rd_lock(); -template void ssux_lock_impl::rd_unlock(); -template void ssux_lock_impl::u_unlock(); -template void ssux_lock_impl::wr_unlock(); +template void ssux_lock_impl::rd_lock() noexcept; +template void ssux_lock_impl::rd_unlock() noexcept; +template void ssux_lock_impl::u_unlock() noexcept; +template void ssux_lock_impl::wr_unlock() noexcept; #endif /* UNIV_PFS_RWLOCK */ #ifdef UNIV_DEBUG -void srw_lock_debug::SRW_LOCK_INIT(mysql_pfs_key_t key) +void srw_lock_debug::SRW_LOCK_INIT(mysql_pfs_key_t key) noexcept { srw_lock::SRW_LOCK_INIT(key); readers_lock.init(); @@ -631,7 +631,7 @@ void srw_lock_debug::SRW_LOCK_INIT(mysql_pfs_key_t key) ut_ad(!have_any()); } -void srw_lock_debug::destroy() +void srw_lock_debug::destroy() noexcept { ut_ad(!writer); if (auto r= readers.load(std::memory_order_relaxed)) @@ -644,7 +644,7 @@ void srw_lock_debug::destroy() srw_lock::destroy(); } -bool srw_lock_debug::wr_lock_try() +bool srw_lock_debug::wr_lock_try() noexcept { ut_ad(!have_any()); if (!srw_lock::wr_lock_try()) @@ -654,7 +654,7 @@ bool srw_lock_debug::wr_lock_try() return true; } -void srw_lock_debug::wr_lock(SRW_LOCK_ARGS(const char *file, unsigned line)) +void srw_lock_debug::wr_lock(SRW_LOCK_ARGS(const char *file, unsigned line)) noexcept { ut_ad(!have_any()); srw_lock::wr_lock(SRW_LOCK_ARGS(file, line)); @@ -662,14 +662,14 @@ void srw_lock_debug::wr_lock(SRW_LOCK_ARGS(const char *file, unsigned line)) writer.store(pthread_self(), std::memory_order_relaxed); } -void srw_lock_debug::wr_unlock() +void srw_lock_debug::wr_unlock() noexcept { ut_ad(have_wr()); writer.store(0, std::memory_order_relaxed); srw_lock::wr_unlock(); } -void srw_lock_debug::readers_register() +void srw_lock_debug::readers_register() noexcept { readers_lock.wr_lock(); auto r= readers.load(std::memory_order_relaxed); @@ -682,7 +682,7 @@ void srw_lock_debug::readers_register() readers_lock.wr_unlock(); } -bool srw_lock_debug::rd_lock_try() +bool srw_lock_debug::rd_lock_try() noexcept { ut_ad(!have_any()); if (!srw_lock::rd_lock_try()) @@ -691,14 +691,14 @@ bool srw_lock_debug::rd_lock_try() return true; } -void srw_lock_debug::rd_lock(SRW_LOCK_ARGS(const char *file, unsigned line)) +void srw_lock_debug::rd_lock(SRW_LOCK_ARGS(const char *file, unsigned line)) noexcept { ut_ad(!have_any()); srw_lock::rd_lock(SRW_LOCK_ARGS(file, line)); readers_register(); } -void srw_lock_debug::rd_unlock() +void srw_lock_debug::rd_unlock() noexcept { const pthread_t self= pthread_self(); ut_ad(writer != self); From 6715e4dfe1f9484cf6a686459eb3fdbef4f37d30 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 20 Sep 2024 10:34:44 +0200 Subject: [PATCH 44/62] MDEV-34973: innobase/dict0dict: add `noexcept` to lock/unlock methods Another chance for cutting back overhead due to C++ exceptions being enabled; the `dict_sys_t` class is a good candidate because its locking methods are called frequently. Binary size reduction this time: text data bss dec hex filename 24448622 2436488 9473537 36358647 22ac9f7 build/release/sql/mariadbd 24448474 2436488 9473601 36358563 22ac9a3 build/release/sql/mariadbd --- storage/innobase/dict/dict0dict.cc | 8 ++++---- storage/innobase/include/dict0dict.h | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 3c6d1ce9e48..70afa0a30f3 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -955,7 +955,7 @@ void dict_sys_t::create() } -void dict_sys_t::lock_wait(SRW_LOCK_ARGS(const char *file, unsigned line)) +void dict_sys_t::lock_wait(SRW_LOCK_ARGS(const char *file, unsigned line)) noexcept { ulonglong now= my_hrtime_coarse().val, old= 0; if (latch_ex_wait_start.compare_exchange_strong @@ -981,17 +981,17 @@ void dict_sys_t::lock_wait(SRW_LOCK_ARGS(const char *file, unsigned line)) } #ifdef UNIV_PFS_RWLOCK -ATTRIBUTE_NOINLINE void dict_sys_t::unlock() +ATTRIBUTE_NOINLINE void dict_sys_t::unlock() noexcept { latch.wr_unlock(); } -ATTRIBUTE_NOINLINE void dict_sys_t::freeze(const char *file, unsigned line) +ATTRIBUTE_NOINLINE void dict_sys_t::freeze(const char *file, unsigned line) noexcept { latch.rd_lock(file, line); } -ATTRIBUTE_NOINLINE void dict_sys_t::unfreeze() +ATTRIBUTE_NOINLINE void dict_sys_t::unfreeze() noexcept { latch.rd_unlock(); } diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index a62a1ec004e..b9a8c0e70e7 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -1493,24 +1493,24 @@ public: #ifdef UNIV_DEBUG /** @return whether the current thread is holding the latch */ - bool frozen() const { return latch.have_any(); } + bool frozen() const noexcept { return latch.have_any(); } /** @return whether the current thread is holding a shared latch */ - bool frozen_not_locked() const { return latch.have_rd(); } + bool frozen_not_locked() const noexcept { return latch.have_rd(); } /** @return whether the current thread holds the exclusive latch */ - bool locked() const { return latch.have_wr(); } + bool locked() const noexcept { return latch.have_wr(); } #endif private: /** Acquire the exclusive latch */ ATTRIBUTE_NOINLINE - void lock_wait(SRW_LOCK_ARGS(const char *file, unsigned line)); + void lock_wait(SRW_LOCK_ARGS(const char *file, unsigned line)) noexcept; public: /** @return the my_hrtime_coarse().val of the oldest lock_wait() start, assuming that requests are served on a FIFO basis */ - ulonglong oldest_wait() const + ulonglong oldest_wait() const noexcept { return latch_ex_wait_start.load(std::memory_order_relaxed); } /** Exclusively lock the dictionary cache. */ - void lock(SRW_LOCK_ARGS(const char *file, unsigned line)) + void lock(SRW_LOCK_ARGS(const char *file, unsigned line)) noexcept { if (!latch.wr_lock_try()) lock_wait(SRW_LOCK_ARGS(file, line)); @@ -1518,18 +1518,18 @@ public: #ifdef UNIV_PFS_RWLOCK /** Unlock the data dictionary cache. */ - ATTRIBUTE_NOINLINE void unlock(); + ATTRIBUTE_NOINLINE void unlock() noexcept; /** Acquire a shared lock on the dictionary cache. */ - ATTRIBUTE_NOINLINE void freeze(const char *file, unsigned line); + ATTRIBUTE_NOINLINE void freeze(const char *file, unsigned line) noexcept; /** Release a shared lock on the dictionary cache. */ - ATTRIBUTE_NOINLINE void unfreeze(); + ATTRIBUTE_NOINLINE void unfreeze() noexcept; #else /** Unlock the data dictionary cache. */ - void unlock() { latch.wr_unlock(); } + void unlock() noexcept { latch.wr_unlock(); } /** Acquire a shared lock on the dictionary cache. */ - void freeze() { latch.rd_lock(); } + void freeze() noexcept { latch.rd_lock(); } /** Release a shared lock on the dictionary cache. */ - void unfreeze() { latch.rd_unlock(); } + void unfreeze() noexcept { latch.rd_unlock(); } #endif /** Estimate the used memory occupied by the data dictionary From 753e7d6d7ce7770d3c98beb6fdcb97e0e8d1ec9f Mon Sep 17 00:00:00 2001 From: Rucha Deodhar Date: Tue, 23 Jul 2024 16:09:10 +0530 Subject: [PATCH 45/62] MDEV-27412: JSON_TABLE doesn't properly unquote strings Analysis: The value gets appended as string instead of unescaped json value Fix: Append the value of json in a temporary string and then store it in the field instead of directly storing as string. --- mysql-test/main/func_json.result | 9 +++++++++ mysql-test/main/func_json.test | 12 ++++++++++++ sql/item_func.h | 2 ++ sql/item_jsonfunc.cc | 2 +- sql/json_table.cc | 5 ++++- 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 8a4405ac22d..d8d87b53672 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1757,5 +1757,14 @@ JSON_INSERT(JSON_OBJECT(l1, l2, l3, l4), '$.k3', 'v3') JSON_SET(JSON_OBJECT(l1, {"k1": "v1", "k2": "v2", "k3": "v3"} {"k1": "v1", "k2": "new v2"} {"k1": "v1", "k2": "new v2"} DROP TABLE t; # +# MDEV-27412: JSON_TABLE doesn't properly unquote strings +# +SET @data = '[{"Data": ""}]'; +SELECT +data +FROM JSON_TABLE (@data, '$[*]' COLUMNS (data text PATH '$.Data')) AS t; +data + +# # End of 10.6 tests # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index dcbbd6055b1..195f487879d 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -1189,6 +1189,18 @@ SELECT JSON_ARRAY_APPEND(JSON_ARRAY(l1, l2, l3, l4), '$[0]', 'k3'), JSON_ARRAY_I SELECT JSON_INSERT(JSON_OBJECT(l1, l2, l3, l4), '$.k3', 'v3'),JSON_SET(JSON_OBJECT(l1, l2, l3, l4), '$.k2', 'new v2'),JSON_REPLACE(JSON_OBJECT(l1, l2, l3, l4), '$.k2', 'new v2') from t; DROP TABLE t; + +--echo # +--echo # MDEV-27412: JSON_TABLE doesn't properly unquote strings +--echo # + + +SET @data = '[{"Data": ""}]'; + +SELECT + data +FROM JSON_TABLE (@data, '$[*]' COLUMNS (data text PATH '$.Data')) AS t; + --echo # --echo # End of 10.6 tests --echo # diff --git a/sql/item_func.h b/sql/item_func.h index 592bcb65a0e..bf3582ded03 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -35,6 +35,8 @@ extern "C" /* Bug in BSDI include file */ #include +extern int st_append_json(String *s, + CHARSET_INFO *json_cs, const uchar *js, uint js_len); class Item_func :public Item_func_or_sum { void sync_with_sum_func_and_with_field(List &list); diff --git a/sql/item_jsonfunc.cc b/sql/item_jsonfunc.cc index fc485c182cb..3755b880247 100644 --- a/sql/item_jsonfunc.cc +++ b/sql/item_jsonfunc.cc @@ -79,7 +79,7 @@ static inline bool append_simple(String *s, const uchar *a, size_t a_len) Appends JSON string to the String object taking charsets in consideration. */ -static int st_append_json(String *s, +int st_append_json(String *s, CHARSET_INFO *json_cs, const uchar *js, uint js_len) { int str_len= js_len * s->charset()->mbmaxlen; diff --git a/sql/json_table.cc b/sql/json_table.cc index 86f565aa561..8a3ca39f883 100644 --- a/sql/json_table.cc +++ b/sql/json_table.cc @@ -380,6 +380,8 @@ int ha_json_table::rnd_init(bool scan) static void store_json_in_field(Field *f, const json_engine_t *je) { + String res_tmp("", 0, je->s.cs); + switch (je->value_type) { case JSON_VALUE_NULL: @@ -400,7 +402,8 @@ static void store_json_in_field(Field *f, const json_engine_t *je) default: break; }; - f->store((const char *) je->value, (uint32) je->value_len, je->s.cs); + st_append_json(&res_tmp, je->s.cs, je->value, je->value_len); + f->store((const char *) res_tmp.ptr(), (uint32) res_tmp.length(), je->s.cs); } From 8d810e9426573cdcbcc60c7577ffd4f3f29ce391 Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Fri, 20 Sep 2024 14:58:23 +0200 Subject: [PATCH 46/62] MDEV-29537 Creation of view with UNION and SELECT ... FOR UPDATE in definition is failed with error lock_type is writen in the last SELECT of the unit even if it parsed last, so it should be printed last from the last select of the unit. --- mysql-test/main/view.result | 31 +++++++++++++++++++++++++++++++ mysql-test/main/view.test | 32 ++++++++++++++++++++++++++++++++ sql/sql_lex.cc | 18 ++++++++++++++++++ sql/sql_lex.h | 2 ++ sql/sql_select.cc | 17 +++++++++++++---- 5 files changed, 96 insertions(+), 4 deletions(-) diff --git a/mysql-test/main/view.result b/mysql-test/main/view.result index bc319d3c5b7..74f64388b4a 100644 --- a/mysql-test/main/view.result +++ b/mysql-test/main/view.result @@ -6970,3 +6970,34 @@ DROP VIEW v1; DROP VIEW v2; DROP TABLE t; # End of 10.4 tests +# +# MDEV-29537: Creation of view with UNION and SELECT ... FOR UPDATE +# in definition is failed with error +# +CREATE TABLE t1 (i INT); +CREATE VIEW v1 AS SELECT 1 FROM t1 +UNION +SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 +FOR UPDATE; +SELECT * FROM v1; +1 +1 +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` from `t1` union select 1 AS `1` from DUAL where 1 group by 1 having 1 order by 1 for update latin1 latin1_swedish_ci +DROP VIEW v1; +DROP TABLE t1; +CREATE TABLE t1 (i INT); +CREATE VIEW v1 AS SELECT 1 FROM t1 +UNION +(SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 +FOR UPDATE); +SELECT * FROM v1; +1 +1 +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 AS `1` from `t1` union (select 1 AS `1` from DUAL where 1 group by 1 having 1 for update) latin1 latin1_swedish_ci +DROP VIEW v1; +DROP TABLE t1; +# End of 10.5 tests diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test index 6730e7f7111..229fedddb5c 100644 --- a/mysql-test/main/view.test +++ b/mysql-test/main/view.test @@ -6726,3 +6726,35 @@ DROP VIEW v2; DROP TABLE t; --echo # End of 10.4 tests + +--echo # +--echo # MDEV-29537: Creation of view with UNION and SELECT ... FOR UPDATE +--echo # in definition is failed with error +--echo # + +CREATE TABLE t1 (i INT); +CREATE VIEW v1 AS SELECT 1 FROM t1 +UNION +SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 + FOR UPDATE; + +SELECT * FROM v1; +SHOW CREATE VIEW v1; + +DROP VIEW v1; +DROP TABLE t1; + + +CREATE TABLE t1 (i INT); +CREATE VIEW v1 AS SELECT 1 FROM t1 + UNION + (SELECT 1 FROM DUAL WHERE 1 GROUP BY 1 HAVING 1 ORDER BY 1 + FOR UPDATE); +SELECT * FROM v1; + +SHOW CREATE VIEW v1; + +DROP VIEW v1; +DROP TABLE t1; + +--echo # End of 10.5 tests diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index fc39bd858f8..385131642b0 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -3788,6 +3788,8 @@ void st_select_lex_unit::print(String *str, enum_query_type query_type) } else if (saved_fake_select_lex) saved_fake_select_lex->print_limit(thd, str, query_type); + + print_lock_from_the_last_select(str); } @@ -10612,6 +10614,22 @@ bool SELECT_LEX_UNIT::set_lock_to_the_last_select(Lex_select_lock l) return FALSE; } + +void SELECT_LEX_UNIT::print_lock_from_the_last_select(String *str) +{ + SELECT_LEX *sel= first_select(); + while (sel->next_select()) + sel= sel->next_select(); + if(sel->braces) + return; // braces processed in st_select_lex::print + + // lock type + sel->print_lock_type(str); + + return; +} + + /** Generate unique name for generated derived table for this SELECT */ diff --git a/sql/sql_lex.h b/sql/sql_lex.h index e0cb336de5a..1dbd839ac53 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1042,6 +1042,7 @@ public: bool check_parameters(SELECT_LEX *main_select); bool set_lock_to_the_last_select(Lex_select_lock l); + void print_lock_from_the_last_select(String *str); bool can_be_merged(); @@ -1465,6 +1466,7 @@ public: bool setup_ref_array(THD *thd, uint order_group_num); uint get_cardinality_of_ref_ptrs_slice(uint order_group_num_arg); void print(THD *thd, String *str, enum_query_type query_type); + void print_lock_type(String *str); void print_item_list(THD *thd, String *str, enum_query_type query_type); void print_set_clause(THD *thd, String *str, enum_query_type query_type); void print_on_duplicate_key_clause(THD *thd, String *str, diff --git a/sql/sql_select.cc b/sql/sql_select.cc index b995beb53e3..e0eb7bec3e4 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -28787,6 +28787,16 @@ void st_select_lex::print_on_duplicate_key_clause(THD *thd, String *str, } } + +void st_select_lex::print_lock_type(String *str) +{ + if (lock_type == TL_READ_WITH_SHARED_LOCKS) + str->append(" lock in share mode"); + else if (lock_type == TL_WRITE) + str->append(" for update"); +} + + void st_select_lex::print(THD *thd, String *str, enum_query_type query_type) { DBUG_ASSERT(thd); @@ -29059,10 +29069,9 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type) print_limit(thd, str, query_type); // lock type - if (lock_type == TL_READ_WITH_SHARED_LOCKS) - str->append(" lock in share mode"); - else if (lock_type == TL_WRITE) - str->append(" for update"); + if (braces) /* no braces processed in + SELECT_LEX_UNIT::print_lock_from_the_last_select */ + print_lock_type(str); if ((sel_type == INSERT_CMD || sel_type == REPLACE_CMD) && thd->lex->update_list.elements) From 2d031f4a71205fcd89f73febe9e09efc0954e611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 1 Oct 2024 13:29:59 +0300 Subject: [PATCH 47/62] MDEV-34973 fixup for POWER,s390x xtest(): Correct the declaration. --- storage/innobase/include/transactional_lock_guard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/innobase/include/transactional_lock_guard.h b/storage/innobase/include/transactional_lock_guard.h index c48bde87d72..40519f513b2 100644 --- a/storage/innobase/include/transactional_lock_guard.h +++ b/storage/innobase/include/transactional_lock_guard.h @@ -93,7 +93,7 @@ TRANSACTIONAL_TARGET bool xbegin() noexcept; TRANSACTIONAL_TARGET void xabort() noexcept; TRANSACTIONAL_TARGET void xend() noexcept; # ifdef UNIV_DEBUG -bool xtest(); +bool xtest() noexcept; # endif # endif From a298dfb84c532009be43055be4b2b7bbe56c6e83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 1 Oct 2024 15:03:04 +0300 Subject: [PATCH 48/62] MDEV-35053 Crash in purge_sys_t::iterator::free_history_rseg() purge_sys_t::get_page(): Avoid accessing a freed reference to pages[id] after pages.erase(id). This heap-use-after-free would sometimes be caught by AddressSanitizer. purge_sys_t::iterator::free_history_rseg(): Do not crash if undo=nullptr (the database is corrupted). Reviewed by: Debarun Banerjee --- storage/innobase/trx/trx0purge.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/storage/innobase/trx/trx0purge.cc b/storage/innobase/trx/trx0purge.cc index d9550a19cc6..eead5118eb7 100644 --- a/storage/innobase/trx/trx0purge.cc +++ b/storage/innobase/trx/trx0purge.cc @@ -493,16 +493,18 @@ loop: if (undo->hdr_page_no == hdr_addr.page) goto found_cached; ut_ad("inconsistent undo logs" == 0); - if (false) - found_cached: - UT_LIST_REMOVE(rseg.undo_cached, undo); + found_cached: static_assert(FIL_NULL == 0xffffffff, ""); if (UNIV_UNLIKELY(mach_read_from_4(TRX_RSEG + TRX_RSEG_FORMAT + rseg_hdr->page.frame))) trx_rseg_format_upgrade(rseg_hdr, &mtr); - mtr.memset(rseg_hdr, TRX_RSEG + TRX_RSEG_UNDO_SLOTS + - undo->id * TRX_RSEG_SLOT_SIZE, 4, 0xff); - ut_free(undo); + if (UNIV_LIKELY(undo != nullptr)) + { + UT_LIST_REMOVE(rseg.undo_cached, undo); + mtr.memset(rseg_hdr, TRX_RSEG + TRX_RSEG_UNDO_SLOTS + + undo->id * TRX_RSEG_SLOT_SIZE, 4, 0xff); + ut_free(undo); + } mtr.write<8,mtr_t::MAYBE_NOP>(*rseg_hdr, TRX_RSEG + TRX_RSEG_MAX_TRX_ID + rseg_hdr->page.frame, trx_sys.get_max_trx_id() - 1); @@ -778,13 +780,16 @@ buf_block_t *purge_sys_t::get_page(page_id_t id) { ut_ad(!recv_sys.recovery_on); - buf_block_t*& undo_page= pages[id]; + buf_block_t *&h= pages[id]; + buf_block_t *undo_page= h; if (!undo_page) { undo_page= buf_pool.page_fix(id); // batch_cleanup() will unfix() if (!undo_page) pages.erase(id); + else + h= undo_page; } return undo_page; From 464055fe655d70e7191f4bd9f5709bc64b26b942 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Tue, 1 Oct 2024 18:35:39 +0300 Subject: [PATCH 49/62] MDEV-34078 Memory leak in InnoDB purge with 32-column PRIMARY KEY row_purge_reset_trx_id(): Reserve large enough offsets for accomodating the maximum width PRIMARY KEY followed by DB_TRX_ID,DB_ROLL_PTR. Reviewed by: Thirunarayanan Balathandayuthapani --- mysql-test/suite/innodb/r/purge.result | 23 ++++++++++++++++++++ mysql-test/suite/innodb/t/purge.test | 29 +++++++++++++++++++++++++- storage/innobase/row/row0purge.cc | 2 +- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/innodb/r/purge.result b/mysql-test/suite/innodb/r/purge.result index a71d0afdcbe..5eedbc4ad9d 100644 --- a/mysql-test/suite/innodb/r/purge.result +++ b/mysql-test/suite/innodb/r/purge.result @@ -116,6 +116,29 @@ t12963823 CREATE TABLE `t12963823` ( KEY `ndx_o` (`o`(500)), KEY `ndx_p` (`p`(500)) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci ROW_FORMAT=DYNAMIC +BEGIN NOT ATOMIC +DECLARE c TEXT DEFAULT(SELECT CONCAT('CREATE TABLE t1(c', +GROUP_CONCAT(seq SEPARATOR +' INT DEFAULT 0, c'), +' INT DEFAULT 0, PRIMARY KEY(c', +GROUP_CONCAT(seq SEPARATOR ', c'), +')) ENGINE=InnoDB;') FROM seq_1_to_33); +EXECUTE IMMEDIATE c; +END; +$$ +ERROR 42000: Too many key parts specified; max 32 parts allowed +BEGIN NOT ATOMIC +DECLARE c TEXT DEFAULT(SELECT CONCAT('CREATE TABLE t1(c', +GROUP_CONCAT(seq SEPARATOR +' INT DEFAULT 0, c'), +' INT DEFAULT 0, PRIMARY KEY(c', +GROUP_CONCAT(seq SEPARATOR ', c'), +')) ENGINE=InnoDB;') FROM seq_1_to_32); +EXECUTE IMMEDIATE c; +END; +$$ +INSERT INTO t1() VALUES(); InnoDB 0 transactions not purged +DROP TABLE t1; DROP TABLE t1_purge, t2_purge, t3_purge, t4_purge, t12637786, t12963823; SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency; diff --git a/mysql-test/suite/innodb/t/purge.test b/mysql-test/suite/innodb/t/purge.test index 63312e50fd8..3caa3f065aa 100644 --- a/mysql-test/suite/innodb/t/purge.test +++ b/mysql-test/suite/innodb/t/purge.test @@ -1,5 +1,6 @@ --source include/have_innodb.inc --source include/have_innodb_16k.inc +--source include/have_sequence.inc SET @save_frequency = @@GLOBAL.innodb_purge_rseg_truncate_frequency; SET GLOBAL innodb_purge_rseg_truncate_frequency=1; @@ -110,8 +111,34 @@ CREATE INDEX ndx_n ON t12963823 (n(500)); CREATE INDEX ndx_o ON t12963823 (o(500)); CREATE INDEX ndx_p ON t12963823 (p(500)); SHOW CREATE TABLE t12963823; -# We need to activate the purge thread before DROP TABLE. +DELIMITER $$; +--error ER_TOO_MANY_KEY_PARTS +BEGIN NOT ATOMIC + DECLARE c TEXT DEFAULT(SELECT CONCAT('CREATE TABLE t1(c', + GROUP_CONCAT(seq SEPARATOR + ' INT DEFAULT 0, c'), + ' INT DEFAULT 0, PRIMARY KEY(c', + GROUP_CONCAT(seq SEPARATOR ', c'), + ')) ENGINE=InnoDB;') FROM seq_1_to_33); + EXECUTE IMMEDIATE c; +END; +$$ +BEGIN NOT ATOMIC + DECLARE c TEXT DEFAULT(SELECT CONCAT('CREATE TABLE t1(c', + GROUP_CONCAT(seq SEPARATOR + ' INT DEFAULT 0, c'), + ' INT DEFAULT 0, PRIMARY KEY(c', + GROUP_CONCAT(seq SEPARATOR ', c'), + ')) ENGINE=InnoDB;') FROM seq_1_to_32); + EXECUTE IMMEDIATE c; +END; +$$ +DELIMITER ;$$ +INSERT INTO t1() VALUES(); + +# We need to activate the purge thread before DROP TABLE. -- source include/wait_all_purged.inc +DROP TABLE t1; DROP TABLE t1_purge, t2_purge, t3_purge, t4_purge, t12637786, t12963823; SET GLOBAL innodb_purge_rseg_truncate_frequency=@save_frequency; diff --git a/storage/innobase/row/row0purge.cc b/storage/innobase/row/row0purge.cc index 6942f5b7af8..f9b30b6a0a9 100644 --- a/storage/innobase/row/row0purge.cc +++ b/storage/innobase/row/row0purge.cc @@ -678,7 +678,7 @@ static void row_purge_reset_trx_id(purge_node_t* node, mtr_t* mtr) mem_heap_t* heap = NULL; /* Reserve enough offsets for the PRIMARY KEY and 2 columns so that we can access DB_TRX_ID, DB_ROLL_PTR. */ - rec_offs offsets_[REC_OFFS_HEADER_SIZE + MAX_REF_PARTS + 2]; + rec_offs offsets_[REC_OFFS_HEADER_SIZE + MAX_REF_PARTS + 3]; rec_offs_init(offsets_); rec_offs* offsets = rec_get_offsets( rec, index, offsets_, index->n_core_fields, From 2cdcfb644ce7e1c3324543c1ee5504db14363297 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 24 Sep 2024 14:40:04 +0200 Subject: [PATCH 50/62] MDEV-26314 ST_EQUALS listed twice in information_schema.SQL_FUNCTIONS --- sql/item_geofunc.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/item_geofunc.cc b/sql/item_geofunc.cc index 5160bfdc4bb..86965bcfe78 100644 --- a/sql/item_geofunc.cc +++ b/sql/item_geofunc.cc @@ -4012,7 +4012,6 @@ static Native_func_registry func_array_geom[] = { { STRING_WITH_LEN("ST_ENDPOINT") }, GEOM_BUILDER(Create_func_endpoint)}, { { STRING_WITH_LEN("ST_ENVELOPE") }, GEOM_BUILDER(Create_func_envelope)}, { { STRING_WITH_LEN("ST_EQUALS") }, GEOM_BUILDER(Create_func_equals)}, - { { STRING_WITH_LEN("ST_EQUALS") }, GEOM_BUILDER(Create_func_equals)}, { { STRING_WITH_LEN("ST_EXTERIORRING") }, GEOM_BUILDER(Create_func_exteriorring)}, { { STRING_WITH_LEN("ST_GEOMCOLLFROMTEXT") }, GEOM_BUILDER(Create_func_geometry_from_text)}, { { STRING_WITH_LEN("ST_GEOMCOLLFROMWKB") }, GEOM_BUILDER(Create_func_geometry_from_wkb)}, From 5bf543fd43ce6bb26a14c93f5058dd23edf1dc54 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 24 Sep 2024 19:08:24 +0200 Subject: [PATCH 51/62] MDEV-24193 UBSAN: sql/sql_acl.cc:9985:29: runtime error: member access within null pointer of type 'struct TABLE' , ASAN: use-after-poison in handle_grant_table privilege tables do not always have to exist --- mysql-test/main/create_user.result | 9 +++++++++ mysql-test/main/create_user.test | 12 ++++++++++++ sql/sql_acl.cc | 5 ++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/create_user.result b/mysql-test/main/create_user.result index 8bd0ca88335..477d4d53bbe 100644 --- a/mysql-test/main/create_user.result +++ b/mysql-test/main/create_user.result @@ -70,3 +70,12 @@ select * from mysql.user where user like 'foo'; Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time % foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 10 20 30 40 mysql_native_password N N 0.000000 drop user foo; +# End of 10.2 tests +# +# MDEV-24193 UBSAN: sql/sql_acl.cc:9985:29: runtime error: member access within null pointer of type 'struct TABLE' , ASAN: use-after-poison in handle_grant_table +# +RENAME TABLE mysql.procs_priv TO mysql.temp; +CREATE USER a IDENTIFIED WITH 'a'; +ERROR HY000: Plugin 'a' is not loaded +RENAME TABLE mysql.temp TO mysql.procs_priv; +# End of 10.5 tests diff --git a/mysql-test/main/create_user.test b/mysql-test/main/create_user.test index f04cb3e302a..ef855ed5e86 100644 --- a/mysql-test/main/create_user.test +++ b/mysql-test/main/create_user.test @@ -56,3 +56,15 @@ create user foo with MAX_QUERIES_PER_HOUR 10 MAX_USER_CONNECTIONS 40; select * from mysql.user where user like 'foo'; drop user foo; + +--echo # End of 10.2 tests + +--echo # +--echo # MDEV-24193 UBSAN: sql/sql_acl.cc:9985:29: runtime error: member access within null pointer of type 'struct TABLE' , ASAN: use-after-poison in handle_grant_table +--echo # +RENAME TABLE mysql.procs_priv TO mysql.temp; +--error ER_PLUGIN_IS_NOT_LOADED +CREATE USER a IDENTIFIED WITH 'a'; +RENAME TABLE mysql.temp TO mysql.procs_priv; + +--echo # End of 10.5 tests diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index acbb9fa6d38..d0fa2ff9c1f 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -10192,6 +10192,10 @@ static int handle_grant_table(THD *thd, const Grant_table_base& grant_table, int result= 0; int error; TABLE *table= grant_table.table(); + DBUG_ENTER("handle_grant_table"); + if (!table) + DBUG_RETURN(0); + Field *host_field= table->field[0]; Field *user_field= table->field[which_table == USER_TABLE || which_table == PROXIES_PRIV_TABLE ? 1 : 2]; @@ -10201,7 +10205,6 @@ static int handle_grant_table(THD *thd, const Grant_table_base& grant_table, const char *user; uchar user_key[MAX_KEY_LENGTH]; uint key_prefix_length; - DBUG_ENTER("handle_grant_table"); if (which_table == ROLES_MAPPING_TABLE) { From 813e5927630c440b636e1de293fc153b93bb142e Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 27 Sep 2024 13:10:17 +0200 Subject: [PATCH 52/62] compilation failure in CONNECT storage/connect/tabfmt.cpp:419:24: error: '%.3d' directive writing between 3 and 10 bytes into a region of size 5 [-Werror=format-overflow=] 419 | sprintf(buf, "COL%.3d", i+1); --- storage/connect/tabfmt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage/connect/tabfmt.cpp b/storage/connect/tabfmt.cpp index 037a465af13..05799cb3d87 100644 --- a/storage/connect/tabfmt.cpp +++ b/storage/connect/tabfmt.cpp @@ -93,7 +93,7 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info) char sep, q; int rc, mxr; bool hdr; - char *p, *colname[MAXCOL], dechar, buf[8]; + char *p, *colname[MAXCOL], dechar, buf[16]; int i, imax, hmax, n, nerr, phase, blank, digit, dec, type; int ncol = sizeof(buftyp) / sizeof(int); int num_read = 0, num_max = 10000000; // Statistics From b1bbdbab9e13c0b947ec1a0dd882da7b2f197de1 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Fri, 27 Sep 2024 12:58:15 +0200 Subject: [PATCH 53/62] cleanup: remove redundant if() likely, a result of auto-merge of two fixes in different versions --- sql/sql_select.cc | 10 +--------- storage/innobase/handler/ha_innodb.cc | 12 ++---------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index e0eb7bec3e4..001053e0ed7 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13904,13 +13904,6 @@ void JOIN_TAB::cleanup() delete filesort->select; delete filesort; filesort= NULL; - /* Skip non-existing derived tables/views result tables */ - if (table && - (table->s->tmp_table != INTERNAL_TMP_TABLE || table->is_created())) - { - table->file->ha_end_keyread(); - table->file->ha_index_or_rnd_end(); - } if (table) { table->file->ha_end_keyread(); @@ -13919,8 +13912,7 @@ void JOIN_TAB::cleanup() else table->file->ha_index_or_rnd_end(); preread_init_done= FALSE; - if (table->pos_in_table_list && - table->pos_in_table_list->jtbm_subselect) + if (table->pos_in_table_list && table->pos_in_table_list->jtbm_subselect) { if (table->pos_in_table_list->jtbm_subselect->is_jtbm_const_tab) { diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 1abf394c7bd..37b2d9ad7bd 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -15929,10 +15929,10 @@ ha_innobase::external_lock( } DBUG_RETURN(0); - } else { - DEBUG_SYNC_C("ha_innobase_end_statement"); } + DEBUG_SYNC_C("ha_innobase_end_statement"); + /* MySQL is releasing a table lock */ trx->n_mysql_tables_in_use--; @@ -15959,14 +15959,6 @@ ha_innobase::external_lock( } } - if (!trx_is_started(trx) - && lock_type != F_UNLCK - && (m_prebuilt->select_lock_type != LOCK_NONE - || m_prebuilt->stored_select_lock_type != LOCK_NONE)) { - - trx->will_lock = true; - } - DBUG_RETURN(0); } From 9021f40b8ebfa9a9e0b01029a62742b7cdde5be5 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 30 Sep 2024 18:08:00 +0200 Subject: [PATCH 54/62] MDEV-35050 Found wrong usage of mutex upon setting plugin session variables --- mysql-test/suite/plugins/r/fulltext_plugin.result | 11 +++++++++++ mysql-test/suite/plugins/t/fulltext_plugin.test | 15 ++++++++++++--- sql/session_tracker.cc | 4 ++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/mysql-test/suite/plugins/r/fulltext_plugin.result b/mysql-test/suite/plugins/r/fulltext_plugin.result index 2c104c98676..6fcba7735c9 100644 --- a/mysql-test/suite/plugins/r/fulltext_plugin.result +++ b/mysql-test/suite/plugins/r/fulltext_plugin.result @@ -1,3 +1,6 @@ +# +# BUG#39746 - Debug flag breaks struct definition (server crash) +# INSTALL PLUGIN simple_parser SONAME 'mypluglib.so'; CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a) WITH PARSER simple_parser); ALTER TABLE t1 ADD FULLTEXT(b) WITH PARSER simple_parser; @@ -5,3 +8,11 @@ DROP TABLE t1; UNINSTALL PLUGIN simple_parser; show status like 'a%status'; Variable_name Value +# +# MDEV-35050 Found wrong usage of mutex upon setting plugin session variables +# +install soname 'mypluglib'; +set session_track_system_variables="*"; +set session simple_parser_simple_thdvar_one = 10; +uninstall soname 'mypluglib'; +# End of 10.5 tests diff --git a/mysql-test/suite/plugins/t/fulltext_plugin.test b/mysql-test/suite/plugins/t/fulltext_plugin.test index e9b4343e0dc..8a3a9d62e9c 100644 --- a/mysql-test/suite/plugins/t/fulltext_plugin.test +++ b/mysql-test/suite/plugins/t/fulltext_plugin.test @@ -1,8 +1,8 @@ --source include/have_simple_parser.inc -# -# BUG#39746 - Debug flag breaks struct definition (server crash) -# +--echo # +--echo # BUG#39746 - Debug flag breaks struct definition (server crash) +--echo # --replace_result .dll .so eval INSTALL PLUGIN simple_parser SONAME '$MYPLUGLIB_SO'; CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a) WITH PARSER simple_parser); @@ -15,3 +15,12 @@ UNINSTALL PLUGIN simple_parser; # show status like 'a%status'; +--echo # +--echo # MDEV-35050 Found wrong usage of mutex upon setting plugin session variables +--echo # +install soname 'mypluglib'; +set session_track_system_variables="*"; +set session simple_parser_simple_thdvar_one = 10; +uninstall soname 'mypluglib'; + +--echo # End of 10.5 tests diff --git a/sql/session_tracker.cc b/sql/session_tracker.cc index 10d0267326e..cd3491ca9f3 100644 --- a/sql/session_tracker.cc +++ b/sql/session_tracker.cc @@ -428,6 +428,7 @@ bool Session_sysvars_tracker::vars_list::store(THD *thd, String *buf) SHOW_VAR show; CHARSET_INFO *charset; size_t val_length, length; + mysql_mutex_lock(&LOCK_global_system_variables); mysql_mutex_lock(&LOCK_plugin); if (!*node->test_load) { @@ -444,13 +445,12 @@ bool Session_sysvars_tracker::vars_list::store(THD *thd, String *buf) show.name= svar->name.str; show.value= (char *) svar; - mysql_mutex_lock(&LOCK_global_system_variables); const char *value= get_one_variable(thd, &show, OPT_SESSION, SHOW_SYS, NULL, &charset, val_buf, &val_length); - mysql_mutex_unlock(&LOCK_global_system_variables); if (is_plugin) mysql_mutex_unlock(&LOCK_plugin); + mysql_mutex_unlock(&LOCK_global_system_variables); length= net_length_size(svar->name.length) + svar->name.length + From 8166a5d33dda510f3c51341112742064d581a6c3 Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 24 Sep 2024 09:44:39 +0300 Subject: [PATCH 55/62] MDEV-34993: Incorrect cardinality estimation causes poor query plan When calculate_cond_selectivity_for_table() takes into account multi- column selectivities from range access, it tries to take-into account that selectivity for some columns may have been already taken into account. For example, for range access on IDX1 using {kp1, kp2}, the selectivity of restrictions on "kp2" might have already been taken into account to some extent. So, the code tries to "discount" that using rec_per_key[] estimates. This seems to be wrong and unreliable: the "discounting" may produce a rselectivity_multiplier number that hints that the overall selectivity of range access on IDX1 was greater than 1. Do a conservative fix: if we arrive at conclusion that selectivity of range access on condition in IDX1 >1.0, clip it down to 1. --- .../selectivity_innodb_notembedded.result | 74 +++++++++++++++++++ .../main/selectivity_innodb_notembedded.test | 1 + .../main/selectivity_notembedded.result | 74 +++++++++++++++++++ mysql-test/main/selectivity_notembedded.test | 39 ++++++++++ .../sys_vars/r/sysvars_server_embedded.result | 10 +++ sql/opt_range.cc | 26 ++++++- 6 files changed, 223 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/selectivity_innodb_notembedded.result b/mysql-test/main/selectivity_innodb_notembedded.result index 95da1decd5e..5f8e9e85d5e 100644 --- a/mysql-test/main/selectivity_innodb_notembedded.result +++ b/mysql-test/main/selectivity_innodb_notembedded.result @@ -208,6 +208,80 @@ JS set optimizer_trace=@trace_tmp; drop table t1; # +# MDEV-34993: Incorrect cardinality estimation causes poor query plan +# +create table t1 ( +pk int, +key1 int, +filler char(100), +index (key1, pk), +primary key (pk) +); +insert into t1 +select +seq, FLOOR(seq/100), 'filler' +from +seq_1_to_1000; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +set optimizer_trace=1; +explain select * from t1 +where +pk in (1,2,3,4,5) and +key1 <= 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY,key1 PRIMARY 4 NULL 5 Using where +# Must have a note that "multiplier is too high": +select +json_detailed(json_extract(trace,'$**.selectivity_for_indexes')) as JS +from +information_schema.optimizer_trace; +JS +[ + [ + { + "index_name": "PRIMARY", + "selectivity_from_index": 0.005 + }, + { + "index_name": "key1", + "selectivity_from_index": 0.399, + "selectivity_multiplier": 90.9091, + "note": "multiplier too high, clipping", + "clipped_multiplier": 2.506265664 + } + ] +] +# Must not include 1.79...e308 as cost: +select +json_detailed(json_extract(trace,'$**.best_access_path')) as JS +from +information_schema.optimizer_trace; +JS +[ + { + "considered_access_paths": + [ + { + "access_type": "range", + "resulting_rows": 5, + "cost": 6.666533161, + "chosen": true + } + ], + "chosen_access_method": + { + "type": "range", + "records": 5, + "cost": 6.666533161, + "uses_join_buffering": false + } + } +] +drop table t1; +# # Clean up # set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; diff --git a/mysql-test/main/selectivity_innodb_notembedded.test b/mysql-test/main/selectivity_innodb_notembedded.test index 387f7dcb7de..bc07bcad464 100644 --- a/mysql-test/main/selectivity_innodb_notembedded.test +++ b/mysql-test/main/selectivity_innodb_notembedded.test @@ -3,6 +3,7 @@ --source include/big_test.inc --source include/default_optimizer_switch.inc --source include/not_embedded.inc +--source ./include/innodb_stable_estimates.inc SET SESSION STORAGE_ENGINE='InnoDB'; diff --git a/mysql-test/main/selectivity_notembedded.result b/mysql-test/main/selectivity_notembedded.result index ef3f6bb9bf3..995ef1681a4 100644 --- a/mysql-test/main/selectivity_notembedded.result +++ b/mysql-test/main/selectivity_notembedded.result @@ -203,6 +203,80 @@ JS set optimizer_trace=@trace_tmp; drop table t1; # +# MDEV-34993: Incorrect cardinality estimation causes poor query plan +# +create table t1 ( +pk int, +key1 int, +filler char(100), +index (key1, pk), +primary key (pk) +); +insert into t1 +select +seq, FLOOR(seq/100), 'filler' +from +seq_1_to_1000; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status Table is already up to date +set optimizer_trace=1; +explain select * from t1 +where +pk in (1,2,3,4,5) and +key1 <= 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY,key1 PRIMARY 4 NULL 5 Using index condition; Using where +# Must have a note that "multiplier is too high": +select +json_detailed(json_extract(trace,'$**.selectivity_for_indexes')) as JS +from +information_schema.optimizer_trace; +JS +[ + [ + { + "index_name": "PRIMARY", + "selectivity_from_index": 0.005 + }, + { + "index_name": "key1", + "selectivity_from_index": 0.391, + "selectivity_multiplier": 90.9091, + "note": "multiplier too high, clipping", + "clipped_multiplier": 2.557544757 + } + ] +] +# Must not include 1.79...e308 as cost: +select +json_detailed(json_extract(trace,'$**.best_access_path')) as JS +from +information_schema.optimizer_trace; +JS +[ + { + "considered_access_paths": + [ + { + "access_type": "range", + "resulting_rows": 5, + "cost": 6.647684891, + "chosen": true + } + ], + "chosen_access_method": + { + "type": "range", + "records": 5, + "cost": 6.647684891, + "uses_join_buffering": false + } + } +] +drop table t1; +# # Clean up # set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; diff --git a/mysql-test/main/selectivity_notembedded.test b/mysql-test/main/selectivity_notembedded.test index 323e4ca6bd6..b5f004502eb 100644 --- a/mysql-test/main/selectivity_notembedded.test +++ b/mysql-test/main/selectivity_notembedded.test @@ -220,6 +220,45 @@ from set optimizer_trace=@trace_tmp; drop table t1; +--echo # +--echo # MDEV-34993: Incorrect cardinality estimation causes poor query plan +--echo # + +create table t1 ( + pk int, + key1 int, + filler char(100), + index (key1, pk), + primary key (pk) +); + +insert into t1 +select + seq, FLOOR(seq/100), 'filler' +from + seq_1_to_1000; +analyze table t1; + +set optimizer_trace=1; +explain select * from t1 +where + pk in (1,2,3,4,5) and + key1 <= 4; + +--echo # Must have a note that "multiplier is too high": +select + json_detailed(json_extract(trace,'$**.selectivity_for_indexes')) as JS +from + information_schema.optimizer_trace; + +--echo # Must not include 1.79...e308 as cost: +select + json_detailed(json_extract(trace,'$**.best_access_path')) as JS +from + information_schema.optimizer_trace; + +drop table t1; + --echo # --echo # Clean up --echo # diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result index 67c9b40ea2d..a5a02bfa1bc 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -2242,6 +2242,16 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME OPTIMIZER_ADJUST_SECONDARY_KEY_COSTS +VARIABLE_SCOPE SESSION +VARIABLE_TYPE SET +VARIABLE_COMMENT A bit field with the following values: fix_card_multiplier = Fix the computation in selectivity_for_indexes. selectivity_multiplier. This variable will be deleted in MariaDB 11.0 as it is not needed with the new 11.0 optimizer. +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST fix_card_multiplier +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_MAX_SEL_ARG_WEIGHT VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED diff --git a/sql/opt_range.cc b/sql/opt_range.cc index ac3b2d6f339..15a9dfb2e0f 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3503,9 +3503,33 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) */ selectivity_mult= ((double)(i+1)) / i; } - table->cond_selectivity*= selectivity_mult; selectivity_for_index.add("selectivity_multiplier", selectivity_mult); + + /* + Ok, now we assume that selectivity that range condition on + this index adds over selectivities on indexes that we've already + examined is + + $SEL= (quick_cond_selectivity * selectivity_mult) + + The heuristic that we used to obtain selectivity_mult may not be + correct (actually is known to be incorrect in simple cases), so + we make sure here that $SEL <= 1.0. + + We adjust selectivity_mult (table->cond_selectivity was already + multiplied by quick_cond_selectivity above, so we will only + multiply it with selectivity_mult). + */ + if (selectivity_mult > 1.0 / quick_cond_selectivity) + { + selectivity_for_index.add("note", "multiplier too high, clipping"); + selectivity_mult= 1.0/quick_cond_selectivity; + selectivity_for_index.add("clipped_multiplier", selectivity_mult); + DBUG_ASSERT(quick_cond_selectivity * selectivity_mult <= 1.0); + } + + table->cond_selectivity*= selectivity_mult; } /* We need to set selectivity for fields supported by indexes. From 1cda4726ca6bc4d43c3545c744a5b0a4357e7dba Mon Sep 17 00:00:00 2001 From: Sergei Petrunia Date: Tue, 24 Sep 2024 10:23:34 +0300 Subject: [PATCH 56/62] MDEV-34993, part2: backport optimizer_adjust_secondary_key_costs ...and make the fix for MDEV-34993 switchable. It is enabled by default and controlled with @optimizer_adjust_secondary_key_costs=fix_card_multiplier --- mysql-test/main/mysqld--help.result | 7 +++ .../selectivity_innodb_notembedded.result | 54 +++++++++++++++++++ .../main/selectivity_notembedded.result | 54 +++++++++++++++++++ mysql-test/main/selectivity_notembedded.test | 18 +++++++ .../r/sysvars_server_notembedded.result | 10 ++++ sql/opt_range.cc | 4 +- sql/sql_class.h | 5 ++ sql/sql_priv.h | 5 ++ sql/sys_vars.cc | 19 +++++++ 9 files changed, 175 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 43377506eba..83a93a197a6 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -682,6 +682,12 @@ The following specify which files/extra groups are read (specified before remain max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of file descriptors (Automatically configured unless set explicitly) + --optimizer-adjust-secondary-key-costs=name + A bit field with the following values: + fix_card_multiplier = Fix the computation in + selectivity_for_indexes. selectivity_multiplier. This + variable will be deleted in MariaDB 11.0 as it is not + needed with the new 11.0 optimizer. --optimizer-max-sel-arg-weight=# The maximum weight of the SEL_ARG graph. Set to 0 for no limit @@ -1642,6 +1648,7 @@ old-alter-table DEFAULT old-mode old-passwords FALSE old-style-user-limits FALSE +optimizer-adjust-secondary-key-costs fix_card_multiplier optimizer-max-sel-arg-weight 32000 optimizer-prune-level 1 optimizer-search-depth 62 diff --git a/mysql-test/main/selectivity_innodb_notembedded.result b/mysql-test/main/selectivity_innodb_notembedded.result index 5f8e9e85d5e..0ed8908063e 100644 --- a/mysql-test/main/selectivity_innodb_notembedded.result +++ b/mysql-test/main/selectivity_innodb_notembedded.result @@ -280,7 +280,61 @@ JS } } ] +# Disable the fix and try the same: +set @@optimizer_adjust_secondary_key_costs=''; +explain select * from t1 +where +pk in (1,2,3,4,5) and +key1 <= 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY,key1 PRIMARY 4 NULL 5 Using where drop table t1; +# Shows a high multiplier, without a "note": +select +json_detailed(json_extract(trace,'$**.selectivity_for_indexes')) as JS +from +information_schema.optimizer_trace; +JS +[ + [ + { + "index_name": "PRIMARY", + "selectivity_from_index": 0.005 + }, + { + "index_name": "key1", + "selectivity_from_index": 0.399, + "selectivity_multiplier": 90.9091 + } + ] +] +# Includes 1.79...e308 as cost: +select +json_detailed(json_extract(trace,'$**.best_access_path')) as JS +from +information_schema.optimizer_trace; +JS +[ + { + "considered_access_paths": + [ + { + "access_type": "range", + "resulting_rows": 181.3636545, + "cost": 1.79769e308, + "chosen": true + } + ], + "chosen_access_method": + { + "type": "range", + "records": 181.3636545, + "cost": 1.79769e308, + "uses_join_buffering": false + } + } +] +set optimizer_adjust_secondary_key_costs=default; # # Clean up # diff --git a/mysql-test/main/selectivity_notembedded.result b/mysql-test/main/selectivity_notembedded.result index 995ef1681a4..77ae626f567 100644 --- a/mysql-test/main/selectivity_notembedded.result +++ b/mysql-test/main/selectivity_notembedded.result @@ -275,7 +275,61 @@ JS } } ] +# Disable the fix and try the same: +set @@optimizer_adjust_secondary_key_costs=''; +explain select * from t1 +where +pk in (1,2,3,4,5) and +key1 <= 4; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range PRIMARY,key1 PRIMARY 4 NULL 5 Using index condition; Using where drop table t1; +# Shows a high multiplier, without a "note": +select +json_detailed(json_extract(trace,'$**.selectivity_for_indexes')) as JS +from +information_schema.optimizer_trace; +JS +[ + [ + { + "index_name": "PRIMARY", + "selectivity_from_index": 0.005 + }, + { + "index_name": "key1", + "selectivity_from_index": 0.391, + "selectivity_multiplier": 90.9091 + } + ] +] +# Includes 1.79...e308 as cost: +select +json_detailed(json_extract(trace,'$**.best_access_path')) as JS +from +information_schema.optimizer_trace; +JS +[ + { + "considered_access_paths": + [ + { + "access_type": "range", + "resulting_rows": 177.7272905, + "cost": 1.79769e308, + "chosen": true + } + ], + "chosen_access_method": + { + "type": "range", + "records": 177.7272905, + "cost": 1.79769e308, + "uses_join_buffering": false + } + } +] +set optimizer_adjust_secondary_key_costs=default; # # Clean up # diff --git a/mysql-test/main/selectivity_notembedded.test b/mysql-test/main/selectivity_notembedded.test index b5f004502eb..2c4431adb23 100644 --- a/mysql-test/main/selectivity_notembedded.test +++ b/mysql-test/main/selectivity_notembedded.test @@ -257,7 +257,25 @@ select from information_schema.optimizer_trace; +--echo # Disable the fix and try the same: +set @@optimizer_adjust_secondary_key_costs=''; +explain select * from t1 +where + pk in (1,2,3,4,5) and + key1 <= 4; drop table t1; +--echo # Shows a high multiplier, without a "note": +select + json_detailed(json_extract(trace,'$**.selectivity_for_indexes')) as JS +from + information_schema.optimizer_trace; + +--echo # Includes 1.79...e308 as cost: +select + json_detailed(json_extract(trace,'$**.best_access_path')) as JS +from + information_schema.optimizer_trace; +set optimizer_adjust_secondary_key_costs=default; --echo # --echo # Clean up diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index ea1dd7af53b..50dd4ae23a3 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -2402,6 +2402,16 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME OPTIMIZER_ADJUST_SECONDARY_KEY_COSTS +VARIABLE_SCOPE SESSION +VARIABLE_TYPE SET +VARIABLE_COMMENT A bit field with the following values: fix_card_multiplier = Fix the computation in selectivity_for_indexes. selectivity_multiplier. This variable will be deleted in MariaDB 11.0 as it is not needed with the new 11.0 optimizer. +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST fix_card_multiplier +READ_ONLY NO +COMMAND_LINE_ARGUMENT REQUIRED VARIABLE_NAME OPTIMIZER_MAX_SEL_ARG_WEIGHT VARIABLE_SCOPE SESSION VARIABLE_TYPE BIGINT UNSIGNED diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 15a9dfb2e0f..8d36fdb4a18 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -3521,7 +3521,9 @@ bool calculate_cond_selectivity_for_table(THD *thd, TABLE *table, Item **cond) multiplied by quick_cond_selectivity above, so we will only multiply it with selectivity_mult). */ - if (selectivity_mult > 1.0 / quick_cond_selectivity) + if ((thd->variables.optimizer_adjust_secondary_key_costs & + OPTIMIZER_ADJ_FIX_CARD_MULT) && + selectivity_mult > 1.0 / quick_cond_selectivity) { selectivity_for_index.add("note", "multiplier too high, clipping"); selectivity_mult= 1.0/quick_cond_selectivity; diff --git a/sql/sql_class.h b/sql/sql_class.h index 93c5850ae3d..3048e27daf8 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -672,6 +672,11 @@ typedef struct system_variables ulonglong sortbuff_size; ulonglong default_regex_flags; ulonglong max_mem_used; + /* + A bitmap of OPTIMIZER_ADJ_* flags (defined in sql_priv.h). + See sys_vars.cc:adjust_secondary_key_cost for symbolic names. + */ + ulonglong optimizer_adjust_secondary_key_costs; /** Place holders to store Multi-source variables in sys_var.cc during diff --git a/sql/sql_priv.h b/sql/sql_priv.h index 2335c6ba516..f7367e93edf 100644 --- a/sql/sql_priv.h +++ b/sql/sql_priv.h @@ -266,6 +266,11 @@ OPTIMIZER_SWITCH_COND_PUSHDOWN_FROM_HAVING | \ OPTIMIZER_SWITCH_OPTIMIZE_JOIN_BUFFER_SIZE) +/* + See adjust_secondary_key_cost in sys_vars.cc for symbolic names. +*/ +#define OPTIMIZER_ADJ_FIX_CARD_MULT (1) + /* Replication uses 8 bytes to store SQL_MODE in the binary log. The day you use strictly more than 64 bits by adding one more define above, you should diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 44302b3a507..93298ff7b04 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -2777,6 +2777,25 @@ static Sys_var_ulong Sys_optimizer_trace_max_mem_size( SESSION_VAR(optimizer_trace_max_mem_size), CMD_LINE(REQUIRED_ARG), VALID_RANGE(0, ULONG_MAX), DEFAULT(1024 * 1024), BLOCK_SIZE(1)); +/* + Symbolic names for OPTIMIZER_ADJ_* flags in sql_priv.h +*/ +static const char *adjust_secondary_key_cost[]= +{ + "fix_card_multiplier", 0 +}; + +static Sys_var_set Sys_optimizer_adjust_secondary_key_costs( + "optimizer_adjust_secondary_key_costs", + "A bit field with the following values: " + "fix_card_multiplier = Fix the computation in selectivity_for_indexes." + " selectivity_multiplier. " + "This variable will be deleted in MariaDB 11.0 as it is not needed with the " + "new 11.0 optimizer.", + SESSION_VAR(optimizer_adjust_secondary_key_costs), CMD_LINE(REQUIRED_ARG), + adjust_secondary_key_cost, DEFAULT(OPTIMIZER_ADJ_FIX_CARD_MULT)); + + static Sys_var_charptr_fscs Sys_pid_file( "pid_file", "Pid file used by safe_mysqld", READ_ONLY GLOBAL_VAR(pidfile_name_ptr), CMD_LINE(REQUIRED_ARG), From cc70ca7eab449912b6e2f99c56265eab826e5645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Wed, 2 Oct 2024 11:09:31 +0300 Subject: [PATCH 57/62] MDEV-35059 ALTER TABLE...IMPORT TABLESPACE with FULLTEXT SEARCH may corrupt the adaptive hash index build_fts_hidden_table(): Correct a mistake that had been made in commit 903ae300697786d11f300cd0289ab1dcb6da3b9b (MDEV-30655). --- mysql-test/suite/innodb/r/import_hidden_fts.result | 6 +++++- mysql-test/suite/innodb/t/import_hidden_fts.test | 11 ++++++++++- storage/innobase/row/row0import.cc | 4 +++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/innodb/r/import_hidden_fts.result b/mysql-test/suite/innodb/r/import_hidden_fts.result index 69120898d4d..e08558cdc89 100644 --- a/mysql-test/suite/innodb/r/import_hidden_fts.result +++ b/mysql-test/suite/innodb/r/import_hidden_fts.result @@ -1,3 +1,5 @@ +SET @save_adaptive=@@GLOBAL.innodb_adaptive_hash_index; +SET GLOBAL innodb_adaptive_hash_index=ON; call mtr.add_suppression("InnoDB: Added system generated FTS_DOC_ID and FTS_DOC_ID_INDEX while importing the tablespace"); CREATE TABLE t1(f1 INT NOT NULL PRIMARY KEY, f2 CHAR(2) not null, fulltext f_idx(f2), @@ -9,7 +11,7 @@ INSERT INTO t1(f1, f2) SELECT seq, "si" FROM seq_2_to_256; ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL; ALTER TABLE t1 DROP COLUMN f6; ALTER TABLE t1 DROP INDEX f_idx; -connect con1,localhost,root,,; +connect block_purge,localhost,root,,; START TRANSACTION WITH CONSISTENT SNAPSHOT; connection default; DELETE FROM t1 WHERE f1 > 1; @@ -22,6 +24,7 @@ UNLOCK TABLES; Warnings: Warning 1235 This version of MariaDB doesn't yet support 'FLUSH TABLES on a table that had an FTS index, created on a hidden column, the auxiliary tables haven't been dropped as yet. FTS auxiliary tables will not be flushed.' DROP TABLE t1; +disconnect block_purge; CREATE TABLE t1(f1 INT NOT NULL PRIMARY KEY, f2 CHAR(2) not null, f3 INT as (f1) VIRTUAL, INDEX(f3), @@ -43,3 +46,4 @@ t1 CREATE TABLE `t1` ( KEY `f4` (`f4`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci DROP TABLE t1; +SET GLOBAL innodb_adaptive_hash_index=@save_adaptive; diff --git a/mysql-test/suite/innodb/t/import_hidden_fts.test b/mysql-test/suite/innodb/t/import_hidden_fts.test index 4129e258fe1..406f11f7642 100644 --- a/mysql-test/suite/innodb/t/import_hidden_fts.test +++ b/mysql-test/suite/innodb/t/import_hidden_fts.test @@ -1,5 +1,11 @@ --source include/have_innodb.inc --source include/have_sequence.inc + +--error 0,ER_UNKNOWN_SYSTEM_VARIABLE +SET @save_adaptive=@@GLOBAL.innodb_adaptive_hash_index; +--error 0,ER_UNKNOWN_SYSTEM_VARIABLE +SET GLOBAL innodb_adaptive_hash_index=ON; + # Table with virtual, fulltext, instant add, instant drop column # and purgeable rows call mtr.add_suppression("InnoDB: Added system generated FTS_DOC_ID and FTS_DOC_ID_INDEX while importing the tablespace"); @@ -13,7 +19,7 @@ INSERT INTO t1(f1, f2) SELECT seq, "si" FROM seq_2_to_256; ALTER TABLE t1 ADD COLUMN f6 INT NOT NULL; ALTER TABLE t1 DROP COLUMN f6; ALTER TABLE t1 DROP INDEX f_idx; -connect(con1,localhost,root,,); +connect(block_purge,localhost,root,,); START TRANSACTION WITH CONSISTENT SNAPSHOT; connection default; @@ -26,6 +32,7 @@ ib_backup_tablespaces("test", "t1"); EOF UNLOCK TABLES; DROP TABLE t1; +disconnect block_purge; CREATE TABLE t1(f1 INT NOT NULL PRIMARY KEY, f2 CHAR(2) not null, @@ -44,3 +51,5 @@ ALTER TABLE t1 IMPORT TABLESPACE; --enable_warnings SHOW CREATE TABLE t1; DROP TABLE t1; +--error 0,ER_UNKNOWN_SYSTEM_VARIABLE +SET GLOBAL innodb_adaptive_hash_index=@save_adaptive; diff --git a/storage/innobase/row/row0import.cc b/storage/innobase/row/row0import.cc index 4d5f3592b5a..0be420147c0 100644 --- a/storage/innobase/row/row0import.cc +++ b/storage/innobase/row/row0import.cc @@ -3335,7 +3335,9 @@ static dict_table_t *build_fts_hidden_table( new_index->fields[old_index->n_fields].fixed_len= sizeof(doc_id_t); } - new_index->search_info= old_index->search_info; +#ifdef BTR_CUR_HASH_ADAPT + new_index->search_info= btr_search_info_create(new_index->heap); +#endif /* BTR_CUR_HASH_ADAPT */ UT_LIST_ADD_LAST(new_index->table->indexes, new_index); old_index= UT_LIST_GET_NEXT(indexes, old_index); if (UT_LIST_GET_LEN(new_table->indexes) From 3723fd1573b465886abf18d8b95cd82b40d8d4ed Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 25 Sep 2024 11:06:11 +1000 Subject: [PATCH 58/62] MDEV-35007 mroonga should modify source files during build CMake rewriting the tests causes Mroonga to be un-buildable on build environments where there source directory is read only. In the test results, the version wasn't particularly important. Remove the version dependence of tests. --- .gitignore | 2 -- storage/mroonga/CMakeLists.txt | 8 -------- .../mroonga/storage/r/information_schema_plugins.result | 4 ++++ .../storage/r/information_schema_plugins.result.in | 4 ---- ...variable_version.result.in => variable_version.result} | 2 +- .../mroonga/storage/t/information_schema_plugins.test | 2 +- .../mysql-test/mroonga/storage/t/variable_version.test | 1 + 7 files changed, 7 insertions(+), 16 deletions(-) create mode 100644 storage/mroonga/mysql-test/mroonga/storage/r/information_schema_plugins.result delete mode 100644 storage/mroonga/mysql-test/mroonga/storage/r/information_schema_plugins.result.in rename storage/mroonga/mysql-test/mroonga/storage/r/{variable_version.result.in => variable_version.result} (66%) diff --git a/.gitignore b/.gitignore index f67226125a9..27b32471c1e 100644 --- a/.gitignore +++ b/.gitignore @@ -307,8 +307,6 @@ storage/mroonga/vendor/groonga/src/grnslap storage/mroonga/vendor/groonga/src/groonga storage/mroonga/vendor/groonga/src/groonga-benchmark storage/mroonga/vendor/groonga/src/suggest/groonga-suggest-create-dataset -storage/mroonga/mysql-test/mroonga/storage/r/information_schema_plugins.result -storage/mroonga/mysql-test/mroonga/storage/r/variable_version.result zlib/zconf.h xxx/* yyy/* diff --git a/storage/mroonga/CMakeLists.txt b/storage/mroonga/CMakeLists.txt index fffcd80c971..11eec13d520 100644 --- a/storage/mroonga/CMakeLists.txt +++ b/storage/mroonga/CMakeLists.txt @@ -431,14 +431,6 @@ set(MRN_TEST_SUITE_DIR "${CMAKE_SOURCE_DIR}/mysql-test/suite/mroonga") if(NOT EXISTS "${MRN_TEST_SUITE_DIR}") set(MRN_TEST_SUITE_DIR "${PROJECT_SOURCE_DIR}/mysql-test/mroonga") endif() -configure_file( - "${MRN_TEST_SUITE_DIR}/storage/r/information_schema_plugins.result.in" - "${MRN_TEST_SUITE_DIR}/storage/r/information_schema_plugins.result" - NEWLINE_STYLE LF) -configure_file( - "${MRN_TEST_SUITE_DIR}/storage/r/variable_version.result.in" - "${MRN_TEST_SUITE_DIR}/storage/r/variable_version.result" - NEWLINE_STYLE LF) configure_file( "${PROJECT_SOURCE_DIR}/data/install.sql.in" diff --git a/storage/mroonga/mysql-test/mroonga/storage/r/information_schema_plugins.result b/storage/mroonga/mysql-test/mroonga/storage/r/information_schema_plugins.result new file mode 100644 index 00000000000..ef47d228da4 --- /dev/null +++ b/storage/mroonga/mysql-test/mroonga/storage/r/information_schema_plugins.result @@ -0,0 +1,4 @@ +select PLUGIN_NAME, PLUGIN_TYPE +from information_schema.plugins where plugin_name = "Mroonga"; +PLUGIN_NAME PLUGIN_TYPE +Mroonga STORAGE ENGINE diff --git a/storage/mroonga/mysql-test/mroonga/storage/r/information_schema_plugins.result.in b/storage/mroonga/mysql-test/mroonga/storage/r/information_schema_plugins.result.in deleted file mode 100644 index f1020453183..00000000000 --- a/storage/mroonga/mysql-test/mroonga/storage/r/information_schema_plugins.result.in +++ /dev/null @@ -1,4 +0,0 @@ -select PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_TYPE -from information_schema.plugins where plugin_name = "Mroonga"; -PLUGIN_NAME PLUGIN_VERSION PLUGIN_TYPE -Mroonga @MRN_PLUGIN_VERSION@ STORAGE ENGINE diff --git a/storage/mroonga/mysql-test/mroonga/storage/r/variable_version.result.in b/storage/mroonga/mysql-test/mroonga/storage/r/variable_version.result similarity index 66% rename from storage/mroonga/mysql-test/mroonga/storage/r/variable_version.result.in rename to storage/mroonga/mysql-test/mroonga/storage/r/variable_version.result index 26ff300a759..146f70e1df0 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/r/variable_version.result.in +++ b/storage/mroonga/mysql-test/mroonga/storage/r/variable_version.result @@ -1,3 +1,3 @@ show variables like 'mroonga_version'; Variable_name Value -mroonga_version @MRN_VERSION@ +mroonga_version # diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/information_schema_plugins.test b/storage/mroonga/mysql-test/mroonga/storage/t/information_schema_plugins.test index 2d65b763aac..2fc986a27ee 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/information_schema_plugins.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/information_schema_plugins.test @@ -16,7 +16,7 @@ --source ../../include/mroonga/have_mroonga.inc -select PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_TYPE +select PLUGIN_NAME, PLUGIN_TYPE from information_schema.plugins where plugin_name = "Mroonga"; --source ../../include/mroonga/have_mroonga_deinit.inc diff --git a/storage/mroonga/mysql-test/mroonga/storage/t/variable_version.test b/storage/mroonga/mysql-test/mroonga/storage/t/variable_version.test index d9795eabdb6..848d800b5ea 100644 --- a/storage/mroonga/mysql-test/mroonga/storage/t/variable_version.test +++ b/storage/mroonga/mysql-test/mroonga/storage/t/variable_version.test @@ -17,6 +17,7 @@ --source ../../include/mroonga/have_mroonga.inc # show variables like 'groonga%'; +--replace_column 2 # show variables like 'mroonga_version'; --source ../../include/mroonga/have_mroonga_deinit.inc From 1f7898f6869fc0db486b453d644908b42e92d50b Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 25 Sep 2024 11:09:09 +1000 Subject: [PATCH 59/62] mroonga: remove -Wunused-but-set-variable warnings There where unused variable. They were not conditional on defines, so removed them. Added an error handing in proc_object if there was no db as subsequent operations would have failed. --- storage/mroonga/vendor/groonga/lib/proc/proc_object.c | 6 ++++-- .../mroonga/vendor/groonga/plugins/functions/index_column.c | 3 +-- .../mroonga/vendor/groonga/plugins/query_expanders/tsv.c | 3 +-- storage/mroonga/vendor/groonga/plugins/suggest/suggest.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/storage/mroonga/vendor/groonga/lib/proc/proc_object.c b/storage/mroonga/vendor/groonga/lib/proc/proc_object.c index 380e65531a1..40eb2b51bb5 100644 --- a/storage/mroonga/vendor/groonga/lib/proc/proc_object.c +++ b/storage/mroonga/vendor/groonga/lib/proc/proc_object.c @@ -69,13 +69,15 @@ command_object_remove(grn_ctx *ctx, grn_obj **args, grn_user_data *user_data) { - grn_obj *db; grn_obj *name; grn_bool force; grn_obj *target; grn_bool failed_to_open; - db = grn_ctx_db(ctx); + if (!grn_ctx_db(ctx)) { + GRN_PLUGIN_ERROR(ctx, GRN_INVALID_ARGUMENT, "invalid db assigned"); + return NULL; + } name = grn_plugin_proc_get_var(ctx, user_data, "name", -1); force = grn_plugin_proc_get_var_bool(ctx, user_data, "force", -1, GRN_FALSE); diff --git a/storage/mroonga/vendor/groonga/plugins/functions/index_column.c b/storage/mroonga/vendor/groonga/plugins/functions/index_column.c index 0501007471f..58764944d4f 100644 --- a/storage/mroonga/vendor/groonga/plugins/functions/index_column.c +++ b/storage/mroonga/vendor/groonga/plugins/functions/index_column.c @@ -91,8 +91,7 @@ selector_index_column_df_ratio_between(grn_ctx *ctx, df_ratio = (double)n_match_documents / (double)n_documents; { void *key; - int key_size; - key_size = grn_table_cursor_get_key(ctx, cursor, &key); + grn_table_cursor_get_key(ctx, cursor, &key); } if (min <= df_ratio && df_ratio <= max) { posting.rid = term_id; diff --git a/storage/mroonga/vendor/groonga/plugins/query_expanders/tsv.c b/storage/mroonga/vendor/groonga/plugins/query_expanders/tsv.c index 5d5deec69c1..09d3803eddb 100644 --- a/storage/mroonga/vendor/groonga/plugins/query_expanders/tsv.c +++ b/storage/mroonga/vendor/groonga/plugins/query_expanders/tsv.c @@ -196,7 +196,6 @@ load_synonyms(grn_ctx *ctx) const char *path; grn_file_reader *file_reader; int number_of_lines; - grn_encoding encoding; grn_obj line, key, value; grn_getenv("GRN_QUERY_EXPANDER_TSV_SYNONYMS_FILE", @@ -234,7 +233,7 @@ load_synonyms(grn_ctx *ctx) } number_of_lines++; if (number_of_lines == 1) { - encoding = guess_encoding(ctx, &line_value, &line_length); + guess_encoding(ctx, &line_value, &line_length); } GRN_BULK_REWIND(&key); GRN_BULK_REWIND(&value); diff --git a/storage/mroonga/vendor/groonga/plugins/suggest/suggest.c b/storage/mroonga/vendor/groonga/plugins/suggest/suggest.c index 7f64f3c17d9..411000f7dbf 100644 --- a/storage/mroonga/vendor/groonga/plugins/suggest/suggest.c +++ b/storage/mroonga/vendor/groonga/plugins/suggest/suggest.c @@ -653,7 +653,7 @@ learner_init(grn_ctx *ctx, grn_suggest_learner *learner, static void learner_init_columns(grn_ctx *ctx, grn_suggest_learner *learner) { - grn_id events_id, event_types_id; + grn_id events_id; grn_obj *seqs, *events, *post_item, *items, *pairs; learner->seqs = seqs = grn_ctx_at(ctx, GRN_OBJ_GET_DOMAIN(learner->seq)); @@ -665,7 +665,7 @@ learner_init_columns(grn_ctx *ctx, grn_suggest_learner *learner) learner->events_type = grn_obj_column(ctx, events, CONST_STR_LEN("type")); learner->events_time = grn_obj_column(ctx, events, CONST_STR_LEN("time")); - event_types_id = grn_obj_get_range(ctx, learner->events_type); + grn_obj_get_range(ctx, learner->events_type); learner->event_types = grn_obj_column(ctx, events, CONST_STR_LEN("time")); post_item = learner->post_item; From 23debf214fff3b3f03cf98f6298d06f552d93b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 3 Oct 2024 08:15:17 +0300 Subject: [PATCH 60/62] MDEV-28091 fixup: Fix another pfs_malloc() stub In commit 0f56e21efa68ba3b37d1171d001c21845c3d2b7d only one pfs_malloc() stub was fixed to return aligned memory. Also, the MSVC _aligned_malloc() pairs with _aligned_free(). --- storage/perfschema/unittest/stub_pfs_global.h | 7 +++++-- .../perfschema/unittest/stub_print_error.h | 20 +++++++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/storage/perfschema/unittest/stub_pfs_global.h b/storage/perfschema/unittest/stub_pfs_global.h index 48a01ce5be2..22a87430e33 100644 --- a/storage/perfschema/unittest/stub_pfs_global.h +++ b/storage/perfschema/unittest/stub_pfs_global.h @@ -67,8 +67,11 @@ void *pfs_malloc(PFS_builtin_memory_class *klass, size_t size, myf) void pfs_free(PFS_builtin_memory_class *, size_t, void *ptr) { - if (ptr != NULL) - free(ptr); +#ifdef HAVE_ALIGNED_MALLOC + _aligned_free(ptr); +#else + free(ptr); +#endif } void *pfs_malloc_array(PFS_builtin_memory_class *klass, size_t n, size_t size, myf flags) diff --git a/storage/perfschema/unittest/stub_print_error.h b/storage/perfschema/unittest/stub_print_error.h index a02e2478d27..026ac905569 100644 --- a/storage/perfschema/unittest/stub_print_error.h +++ b/storage/perfschema/unittest/stub_print_error.h @@ -23,12 +23,25 @@ #include #include #include +#ifdef HAVE_MEMALIGN +# include +#endif bool pfs_initialized= false; void *pfs_malloc(PFS_builtin_memory_class *klass, size_t size, myf flags) { +#ifndef PFS_ALIGNEMENT void *ptr= malloc(size); +#elif defined HAVE_MEMALIGN + void *ptr= memalign(PFS_ALIGNEMENT, size); +#elif defined HAVE_ALIGNED_MALLOC + void *ptr= _aligned_malloc(size, PFS_ALIGNEMENT); +#else + void *ptr; + if (posix_memalign(&ptr, PFS_ALIGNEMENT, size)) + ptr= NULL; +#endif if (ptr && (flags & MY_ZEROFILL)) memset(ptr, 0, size); return ptr; @@ -36,8 +49,11 @@ void *pfs_malloc(PFS_builtin_memory_class *klass, size_t size, myf flags) void pfs_free(PFS_builtin_memory_class *, size_t, void *ptr) { - if (ptr != NULL) - free(ptr); +#ifdef HAVE_ALIGNED_MALLOC + _aligned_free(ptr); +#else + free(ptr); +#endif } void *pfs_malloc_array(PFS_builtin_memory_class *klass, size_t n, size_t size, myf flags) From 170e4555e21dd04aefe9585d3cd0b8a40b77d2f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 3 Oct 2024 08:15:48 +0300 Subject: [PATCH 61/62] MDEV-35040: Fix std::unique deleter for clang++-20 -stdlib=libc++ Thanks to Khem Raj for reporting this. --- extra/mariabackup/backup_copy.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index f4c1b5bc83a..120555c0f1a 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -60,6 +60,7 @@ Street, Fifth Floor, Boston, MA 02110-1335 USA #ifdef _WIN32 #include /* rmdir */ #endif +#include #define ROCKSDB_BACKUP_DIR "#rocksdb" @@ -1851,7 +1852,7 @@ is_aria_log_dir_file(const datadir_node_t &node) bool copy_back_aria_logs(const char *dstdir) { - std::unique_ptr + std::unique_ptr> ds_ctxt_aria_log_dir_path(ds_create(dstdir, DS_TYPE_LOCAL), ds_destroy); datadir_node_t node; From 6878c9d591607be6e6f330a0ca11e8ab06dff59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Thu, 3 Oct 2024 10:40:58 +0300 Subject: [PATCH 62/62] MDEV-35050 fixup: ./mtr --embedded --- mysql-test/suite/plugins/t/fulltext_plugin.test | 1 + 1 file changed, 1 insertion(+) diff --git a/mysql-test/suite/plugins/t/fulltext_plugin.test b/mysql-test/suite/plugins/t/fulltext_plugin.test index 8a3a9d62e9c..f6f6e169945 100644 --- a/mysql-test/suite/plugins/t/fulltext_plugin.test +++ b/mysql-test/suite/plugins/t/fulltext_plugin.test @@ -1,3 +1,4 @@ +--source include/not_embedded.inc --source include/have_simple_parser.inc --echo #