diff options
author | Monty <monty@mariadb.org> | 2019-09-02 14:06:56 +0300 |
---|---|---|
committer | Monty <monty@mariadb.org> | 2019-09-03 13:17:32 +0300 |
commit | a071e0e029cd7c155cff1054d9f7f8a6aa898620 (patch) | |
tree | b592c10cb8ca3036688ea19039208eadd485fe7c /mysql-test/main | |
parent | b0ff5a6a7393c057cd201aff63279e45d3e0cc49 (diff) | |
parent | 9cba6c5aa3b15fffc0ca10e92bcb55a126a20701 (diff) | |
download | mariadb-git-a071e0e029cd7c155cff1054d9f7f8a6aa898620.tar.gz |
Merge branch '10.2' into 10.3
Diffstat (limited to 'mysql-test/main')
296 files changed, 2724 insertions, 2404 deletions
diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result index c5d974f4469..e0996379ed9 100644 --- a/mysql-test/main/alter_table.result +++ b/mysql-test/main/alter_table.result @@ -1,5 +1,6 @@ drop table if exists t1,t2; drop database if exists mysqltest; +set @save_max_allowed_packet=@@global.max_allowed_packet; create table t1 ( col1 int not null auto_increment primary key, col2 varchar(30) not null, @@ -1463,7 +1464,7 @@ disconnect con1; connection default; DROP TABLE t1, t2, t3; SET SQL_MODE=default; -SET GLOBAL max_allowed_packet=default; +SET GLOBAL max_allowed_packet=@save_max_allowed_packet; CREATE TABLE t1 ( id INT(11) NOT NULL, x_param INT(11) DEFAULT NULL, diff --git a/mysql-test/main/alter_table.test b/mysql-test/main/alter_table.test index 5c29dfae6b3..dc6983da38b 100644 --- a/mysql-test/main/alter_table.test +++ b/mysql-test/main/alter_table.test @@ -6,6 +6,7 @@ drop table if exists t1,t2; drop database if exists mysqltest; --enable_warnings +set @save_max_allowed_packet=@@global.max_allowed_packet; create table t1 ( col1 int not null auto_increment primary key, @@ -1340,7 +1341,7 @@ SELECT LENGTH(my_t3_fld1) FROM t3; DROP TABLE t1, t2, t3; SET SQL_MODE=default; -SET GLOBAL max_allowed_packet=default; +SET GLOBAL max_allowed_packet=@save_max_allowed_packet; # # Test of ALTER TABLE IF [NOT] EXISTS diff --git a/mysql-test/main/analyze.test b/mysql-test/main/analyze.test index 0903db1eca4..85a88158162 100644 --- a/mysql-test/main/analyze.test +++ b/mysql-test/main/analyze.test @@ -13,6 +13,8 @@ # before calling mi_state_info_write # +--source include/default_optimizer_switch.inc + create table t1 (a bigint); lock tables t1 write; insert into t1 values(0); diff --git a/mysql-test/main/analyze_format_json.test b/mysql-test/main/analyze_format_json.test index 915e0c2bf3c..3f3324e9eec 100644 --- a/mysql-test/main/analyze_format_json.test +++ b/mysql-test/main/analyze_format_json.test @@ -5,6 +5,8 @@ drop table if exists t0,t1,t2,t3; --enable_warnings +--source include/default_optimizer_switch.inc + create table t0 (a int); INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); diff --git a/mysql-test/main/analyze_stmt.result b/mysql-test/main/analyze_stmt.result index 3ae49c5eeb6..c5d35759c9c 100644 --- a/mysql-test/main/analyze_stmt.result +++ b/mysql-test/main/analyze_stmt.result @@ -1,3 +1,4 @@ +set join_cache_level=2; drop table if exists t0,t1,t2,t3; create table t0 (a int) engine=myisam; INSERT INTO t0 VALUES (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); diff --git a/mysql-test/main/analyze_stmt.test b/mysql-test/main/analyze_stmt.test index 15fc00a321d..b40edc1cd0f 100644 --- a/mysql-test/main/analyze_stmt.test +++ b/mysql-test/main/analyze_stmt.test @@ -1,6 +1,10 @@ # # Tests for "ANALYZE $statement" feature # + +# Fix that analyze delete with join doesn't add extra WHERE clause. +set join_cache_level=2; + --disable_warnings drop table if exists t0,t1,t2,t3; --enable_warnings diff --git a/mysql-test/main/analyze_stmt_orderby.test b/mysql-test/main/analyze_stmt_orderby.test index a1cfb58f31a..ecee8040ed5 100644 --- a/mysql-test/main/analyze_stmt_orderby.test +++ b/mysql-test/main/analyze_stmt_orderby.test @@ -1,5 +1,6 @@ --source include/have_innodb.inc +--source include/default_optimizer_switch.inc create table t0(a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); diff --git a/mysql-test/main/analyze_stmt_privileges2.test b/mysql-test/main/analyze_stmt_privileges2.test index e3274882ba6..a0f1f4908b6 100644 --- a/mysql-test/main/analyze_stmt_privileges2.test +++ b/mysql-test/main/analyze_stmt_privileges2.test @@ -1,4 +1,4 @@ -################################################################################ +############################################################################### # The test ensures that permission checks are applied correctly to # ANALYZE INSERT/REPLACE/UPDATE/DELETE/SELECT (I/R/U/D/S further in the test) # when it's executed on a table or on a view. @@ -18,7 +18,8 @@ # Search for 'MDEV' to find all of them. ################################################################################ --- source include/not_embedded.inc +--source include/not_embedded.inc +--source include/default_optimizer_switch.inc # Save the initial number of concurrent sessions --source include/count_sessions.inc @@ -44,6 +45,7 @@ INSERT INTO privtest_db.t2 VALUES (1,'foo'), (2,'bar'), (3,'qux'); GRANT SELECT ON privtest_db.t2 TO 'privtest'@'localhost'; connect(con1,localhost,privtest,,privtest_db); +--source include/default_optimizer_switch.inc --echo --echo ######################################################################### diff --git a/mysql-test/main/bootstrap.result b/mysql-test/main/bootstrap.result index 5cefc281996..a7365d4f462 100644 --- a/mysql-test/main/bootstrap.result +++ b/mysql-test/main/bootstrap.result @@ -3,7 +3,8 @@ drop table t1; drop table t1; ERROR 42S02: Unknown table 'test.t1' set @my_max_allowed_packet= @@max_allowed_packet; -set global max_allowed_packet=64*@@max_allowed_packet; +set @@global.max_allowed_packet= greatest(1073741824, @@max_allowed_packet); +set @max_allowed_packed=@@global.max_allowed_packet; set global max_allowed_packet=@my_max_allowed_packet; drop table t1; End of 5.1 tests diff --git a/mysql-test/main/bootstrap.test b/mysql-test/main/bootstrap.test index 97f5da86096..cd13a2748d1 100644 --- a/mysql-test/main/bootstrap.test +++ b/mysql-test/main/bootstrap.test @@ -33,10 +33,11 @@ drop table t1; remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_error.sql; # -# Bootstrap with a query larger than 2*thd->net.max_packet +# Bootstrap with a large thd->net.max_packet # set @my_max_allowed_packet= @@max_allowed_packet; -set global max_allowed_packet=64*@@max_allowed_packet; +set @@global.max_allowed_packet= greatest(1073741824, @@max_allowed_packet); +set @max_allowed_packed=@@global.max_allowed_packet; --disable_query_log create table t1 select 2 as a, concat(repeat('MySQL', @@max_allowed_packet/10), ';') as b; eval select * into outfile '$MYSQLTEST_VARDIR/tmp/long_query.sql' from t1; diff --git a/mysql-test/main/bug13633383.test b/mysql-test/main/bug13633383.test index 29106d379fe..273cef44d4a 100644 --- a/mysql-test/main/bug13633383.test +++ b/mysql-test/main/bug13633383.test @@ -2,6 +2,9 @@ --echo # Bug#13633383 63183: SMALL SORT_BUFFER_SIZE CRASH IN MERGE_BUFFERS --echo # +# Avoid warnings from join_buffer +--source include/default_optimizer_switch.inc + CREATE TABLE t1 ( `a` int(11) DEFAULT NULL, `col432` bit(8) DEFAULT NULL, diff --git a/mysql-test/main/cast.result b/mysql-test/main/cast.result index d500ef4fa1d..6021add2762 100644 --- a/mysql-test/main/cast.result +++ b/mysql-test/main/cast.result @@ -727,6 +727,7 @@ DROP TABLE t1; # # Bug #11765023: 57934: DOS POSSIBLE SINCE BINARY CASTING # DOESN'T ADHERE TO MAX_ALLOWED_PACKET +set @save_max_allowed_packet=@@global.max_allowed_packet; SET @@GLOBAL.max_allowed_packet=2048; Warnings: Warning 1708 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length' @@ -748,7 +749,7 @@ Warnings: Warning 1301 Result of cast_as_char() was larger than max_allowed_packet (2048) - truncated connection default; disconnect newconn; -SET @@GLOBAL.max_allowed_packet=default; +SET @@GLOBAL.max_allowed_packet=@save_max_allowed_packet; # # Bug#13519724 63793: CRASH IN DTCOLLATION::SET(DTCOLLATION &SET) # diff --git a/mysql-test/main/cast.test b/mysql-test/main/cast.test index f48d6d9f95f..165980aebed 100644 --- a/mysql-test/main/cast.test +++ b/mysql-test/main/cast.test @@ -393,6 +393,7 @@ DROP TABLE t1; --echo # Bug #11765023: 57934: DOS POSSIBLE SINCE BINARY CASTING --echo # DOESN'T ADHERE TO MAX_ALLOWED_PACKET +set @save_max_allowed_packet=@@global.max_allowed_packet; SET @@GLOBAL.max_allowed_packet=2048; # reconnect to make the new max packet size take effect --connect (newconn, localhost, root,,) @@ -403,7 +404,7 @@ SELECT length(CONVERT(repeat('a',2048), CHAR(2049))); connection default; disconnect newconn; -SET @@GLOBAL.max_allowed_packet=default; +SET @@GLOBAL.max_allowed_packet=@save_max_allowed_packet; --echo # --echo # Bug#13519724 63793: CRASH IN DTCOLLATION::SET(DTCOLLATION &SET) diff --git a/mysql-test/main/compound.result b/mysql-test/main/compound.result index a54faff4562..18df4fd34e2 100644 --- a/mysql-test/main/compound.result +++ b/mysql-test/main/compound.result @@ -154,6 +154,7 @@ master-bin.000001 # Query # # use `test`; insert t1 values( NAME_CONST('a',4)+3) master-bin.000001 # Query # # COMMIT drop function fn| drop table t1| +set @@sql_mode="STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"; begin not atomic select @@sql_mode; end| @@sql_mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION diff --git a/mysql-test/main/compound.test b/mysql-test/main/compound.test index 94a6c18b2f5..1f901e2a2b3 100644 --- a/mysql-test/main/compound.test +++ b/mysql-test/main/compound.test @@ -145,6 +145,8 @@ drop table t1| # MDEV-6606 Server crashes in String::append on selecting sql_mode inside anonymous block # MDEV-6609 SQL inside an anonymous block is executed with wrong SQL_MODE # + +set @@sql_mode="STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"; begin not atomic select @@sql_mode; end| create table t1 (a int)| select a from t1 having a > 1| diff --git a/mysql-test/main/compress.result b/mysql-test/main/compress.result index 762ab6630d8..8fbbb324b16 100644 --- a/mysql-test/main/compress.result +++ b/mysql-test/main/compress.result @@ -1354,8 +1354,10 @@ fld1 fld1 250503 250505 250504 250505 250505 250505 -SET @save_optimizer_switch=@@optimizer_switch; -SET optimizer_switch='outer_join_with_cache=off'; +SET @local_optimizer_switch=@@optimizer_switch; +set @local_join_cache_level=@@join_cache_level; +set @@join_cache_level=2; +set optimizer_switch='outer_join_with_cache=off,join_cache_hashed=off'; insert into t2 (fld1, companynr) values (999999,99); select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; companynr companyname @@ -1431,7 +1433,7 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -SET optimizer_switch=@save_optimizer_switch; +SET @@optimizer_switch=@local_optimizer_switch; select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; companynr companynr 37 36 @@ -1440,6 +1442,7 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr= id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join) +SET @@join_cache_level=@local_join_cache_level; select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; fld1 companynr fld3 period 038008 37 reporters 1008 diff --git a/mysql-test/main/connect.result b/mysql-test/main/connect.result index 92584d5d11d..057105d192f 100644 --- a/mysql-test/main/connect.result +++ b/mysql-test/main/connect.result @@ -257,7 +257,7 @@ mysqltest_u1 root # -- Resetting variables... -SET GLOBAL max_connections = 151; +SET GLOBAL max_connections = #max_connections#; # -- Stopping Event Scheduler... SET GLOBAL event_scheduler = OFF; diff --git a/mysql-test/main/connect.test b/mysql-test/main/connect.test index 560f29e840d..e7d7128b233 100644 --- a/mysql-test/main/connect.test +++ b/mysql-test/main/connect.test @@ -224,6 +224,7 @@ SELECT user FROM information_schema.processlist ORDER BY id; --echo --echo # -- Resetting variables... +--replace_result $saved_max_connections #max_connections# --eval SET GLOBAL max_connections = $saved_max_connections --echo diff --git a/mysql-test/main/create.result b/mysql-test/main/create.result index 03f36c801e1..d490457dd62 100644 --- a/mysql-test/main/create.result +++ b/mysql-test/main/create.result @@ -1053,6 +1053,8 @@ USE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' SHOW CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' +set @save_character_set_client=@@character_set_client; +set @save_collation_connection=@@collation_connection; set names utf8; create database имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45; use имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45; @@ -1141,7 +1143,9 @@ return 0; ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длинна' is too long drop view имÑ_вью_кодировке_утф8_длиной_больше_чем_42; drop table имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48; -set names default; +set @@character_set_client=@save_character_set_client; +set @@character_set_results=@save_character_set_client; +set @@session.collation_connection=@save_collation_connection; drop table if exists t1,t2,t3; drop function if exists f1; create function f1() returns int diff --git a/mysql-test/main/create.test b/mysql-test/main/create.test index 9cd3d9909f0..6b91a84197f 100644 --- a/mysql-test/main/create.test +++ b/mysql-test/main/create.test @@ -1,3 +1,5 @@ +--source include/default_charset.inc + call mtr.add_suppression("table or database name 't-1'"); # # Check some special create statements. @@ -993,6 +995,8 @@ SHOW CREATE DATABASE aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa # # Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte # +set @save_character_set_client=@@character_set_client; +set @save_collation_connection=@@collation_connection; set names utf8; create database имÑ_базы_в_кодировке_утф8_длиной_больше_чем_45; @@ -1069,7 +1073,9 @@ return 0; drop view имÑ_вью_кодировке_утф8_длиной_больше_чем_42; drop table имÑ_таблицы_в_кодировке_утф8_длиной_больше_чем_48; -set names default; +set @@character_set_client=@save_character_set_client; +set @@character_set_results=@save_character_set_client; +set @@session.collation_connection=@save_collation_connection; # # Bug#21136 CREATE TABLE SELECT within CREATE TABLE SELECT causes server crash diff --git a/mysql-test/main/cte_nonrecursive.test b/mysql-test/main/cte_nonrecursive.test index c0c5c22bed0..bd8af55071a 100644 --- a/mysql-test/main/cte_nonrecursive.test +++ b/mysql-test/main/cte_nonrecursive.test @@ -1,3 +1,5 @@ +--source include/default_optimizer_switch.inc + create table t1 (a int, b varchar(32)); insert into t1 values (4,'aaaa' ), (7,'bb'), (1,'ccc'), (4,'dd'); diff --git a/mysql-test/main/cte_recursive.test b/mysql-test/main/cte_recursive.test index 483e1ea8c7a..6a4f55cd408 100644 --- a/mysql-test/main/cte_recursive.test +++ b/mysql-test/main/cte_recursive.test @@ -1,3 +1,5 @@ +--source include/default_optimizer_switch.inc + create table t1 (a int, b varchar(32)); insert into t1 values (4,'aaaa' ), (7,'bb'), (1,'ccc'), (4,'dd'); diff --git a/mysql-test/main/ctype_ujis.result b/mysql-test/main/ctype_ujis.result index 8d01212c9b1..66175344615 100644 --- a/mysql-test/main/ctype_ujis.result +++ b/mysql-test/main/ctype_ujis.result @@ -2504,6 +2504,8 @@ Warning 1977 Cannot convert 'ujis' character 0x8FABF8 to 'ucs2' DROP TABLE IF EXISTS t1, t2; DROP PROCEDURE IF EXISTS sp1; set names ujis; +SET @save_character_set_server= @@character_set_server; +SET @save_character_set_database= @@character_set_database; set character_set_database = ujis; set character_set_server = ujis; CREATE TABLE t1(c1 char(2)) default charset = ujis; @@ -2539,8 +2541,8 @@ Warnings: Warning 1292 Truncated incorrect INTEGER value: 'a' Warning 1292 Truncated incorrect INTEGER value: 'a' set names default; -set character_set_database=default; -set character_set_server=default; +set character_set_database=@save_character_set_server; +set character_set_server=@save_character_set_database; End of 5.1 tests # # Start of 5.5 tests diff --git a/mysql-test/main/ctype_ujis.test b/mysql-test/main/ctype_ujis.test index cf247763b46..72a609edf39 100644 --- a/mysql-test/main/ctype_ujis.test +++ b/mysql-test/main/ctype_ujis.test @@ -1178,6 +1178,8 @@ DROP PROCEDURE IF EXISTS sp1; --enable_warnings set names ujis; +SET @save_character_set_server= @@character_set_server; +SET @save_character_set_database= @@character_set_database; set character_set_database = ujis; set character_set_server = ujis; @@ -1219,8 +1221,8 @@ SELECT CONVERT(REPLACE(EXPORT_SET('a','a','a','','a'),'00','') USING ujis); set names default; -set character_set_database=default; -set character_set_server=default; +set character_set_database=@save_character_set_server; +set character_set_server=@save_character_set_database; --echo End of 5.1 tests diff --git a/mysql-test/main/ctype_utf16.result b/mysql-test/main/ctype_utf16.result index 3ad7baadae3..371ccc01a22 100644 --- a/mysql-test/main/ctype_utf16.result +++ b/mysql-test/main/ctype_utf16.result @@ -1567,7 +1567,7 @@ SELECT space(date_add(101, INTERVAL CHAR('1' USING utf16) hour_second)); space(date_add(101, INTERVAL CHAR('1' USING utf16) hour_second)) NULL Warnings: -Warning 1301 Result of space() was larger than max_allowed_packet (16777216) - truncated +Warning 1301 Result of space() was larger than max_allowed_packet (XXX) - truncated # # Bug#11750518 41090: ORDER BY TRUNCATES GROUP_CONCAT RESULT # diff --git a/mysql-test/main/ctype_utf16.test b/mysql-test/main/ctype_utf16.test index 504e62e3e89..0e497b7b7bd 100644 --- a/mysql-test/main/ctype_utf16.test +++ b/mysql-test/main/ctype_utf16.test @@ -765,9 +765,10 @@ DROP TABLE t1; --echo # DATE_ADD/DATE_SUB WITH INTERVAL CRASHES IN GET_INTERVAL_VALUE() --echo # +let $max_packet=`select @@max_allowed_packet`; +--replace_result $max_packet XXX SELECT space(date_add(101, INTERVAL CHAR('1' USING utf16) hour_second)); - --echo # --echo # Bug#11750518 41090: ORDER BY TRUNCATES GROUP_CONCAT RESULT --echo # diff --git a/mysql-test/main/ctype_utf16_def-master.opt b/mysql-test/main/ctype_utf16_def-master.opt index 55bb5d14bbd..909a004bacc 100644 --- a/mysql-test/main/ctype_utf16_def-master.opt +++ b/mysql-test/main/ctype_utf16_def-master.opt @@ -1 +1 @@ ---character-set-server=utf16,latin1 +--character-set-server=utf16,latin1 --collation-server=utf16_general_ci diff --git a/mysql-test/main/ctype_utf8.test b/mysql-test/main/ctype_utf8.test index ab26b69d765..26fc491c568 100644 --- a/mysql-test/main/ctype_utf8.test +++ b/mysql-test/main/ctype_utf8.test @@ -7,6 +7,8 @@ let collation=utf8_unicode_ci; SET TIME_ZONE='+03:00'; --source include/have_innodb.inc +--source include/default_optimizer_switch.inc +--source include/default_charset.inc --disable_warnings drop table if exists t1,t2,t3,t4; diff --git a/mysql-test/main/ctype_utf8mb4.result b/mysql-test/main/ctype_utf8mb4.result index 911108bf74a..b0777a0b9f0 100644 --- a/mysql-test/main/ctype_utf8mb4.result +++ b/mysql-test/main/ctype_utf8mb4.result @@ -1850,6 +1850,7 @@ character_set_filesystem binary character_set_results utf8mb4 character_set_server latin1 character_set_system utf8 +SET @@character_set_server=@save_character_set_server; CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; USE crashtest; CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4; diff --git a/mysql-test/main/ctype_utf8mb4.test b/mysql-test/main/ctype_utf8mb4.test index 9cf87d12340..88fb3d23b62 100644 --- a/mysql-test/main/ctype_utf8mb4.test +++ b/mysql-test/main/ctype_utf8mb4.test @@ -5,6 +5,7 @@ # --source include/have_innodb.inc +--source include/default_optimizer_switch.inc --disable_warnings drop table if exists t1,t2; @@ -1187,7 +1188,9 @@ drop table t1; # SET CHARACTER SET utf8mb4; +--source include/default_charset.inc SHOW VARIABLES LIKE 'character\_set\_%'; +SET @@character_set_server=@save_character_set_server; CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; USE crashtest; CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4; diff --git a/mysql-test/main/ctype_utf8mb4_heap.result b/mysql-test/main/ctype_utf8mb4_heap.result index 18213e65166..127b72674ac 100644 --- a/mysql-test/main/ctype_utf8mb4_heap.result +++ b/mysql-test/main/ctype_utf8mb4_heap.result @@ -1682,6 +1682,7 @@ character_set_filesystem binary character_set_results utf8mb4 character_set_server latin1 character_set_system utf8 +SET @@character_set_server=@save_character_set_server; CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; USE crashtest; CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4 ENGINE heap; diff --git a/mysql-test/main/ctype_utf8mb4_innodb.result b/mysql-test/main/ctype_utf8mb4_innodb.result index baa22f0ffc4..c5fa569bd77 100644 --- a/mysql-test/main/ctype_utf8mb4_innodb.result +++ b/mysql-test/main/ctype_utf8mb4_innodb.result @@ -1808,6 +1808,7 @@ character_set_filesystem binary character_set_results utf8mb4 character_set_server latin1 character_set_system utf8 +SET @@character_set_server=@save_character_set_server; CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; USE crashtest; CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4 ENGINE InnoDB; diff --git a/mysql-test/main/ctype_utf8mb4_myisam.result b/mysql-test/main/ctype_utf8mb4_myisam.result index 67eef5856ec..260f3b639bf 100644 --- a/mysql-test/main/ctype_utf8mb4_myisam.result +++ b/mysql-test/main/ctype_utf8mb4_myisam.result @@ -1815,6 +1815,7 @@ character_set_filesystem binary character_set_results utf8mb4 character_set_server latin1 character_set_system utf8 +SET @@character_set_server=@save_character_set_server; CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; USE crashtest; CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4 ENGINE MyISAM; diff --git a/mysql-test/main/custom_aggregates_i_s.test b/mysql-test/main/custom_aggregates_i_s.test index 6aa6318b7c4..11ed26c59b0 100644 --- a/mysql-test/main/custom_aggregates_i_s.test +++ b/mysql-test/main/custom_aggregates_i_s.test @@ -1,3 +1,5 @@ +--source include/default_optimizer_switch.inc + flush status; show status like "%custom_aggregate%"; create table t2 (sal int(10)); diff --git a/mysql-test/main/derived.result b/mysql-test/main/derived.result index 23a8f75260f..e00e544720b 100644 --- a/mysql-test/main/derived.result +++ b/mysql-test/main/derived.result @@ -1,3 +1,4 @@ +drop table if exists t1,t2,t3; set @save_derived_optimizer_switch=@@optimizer_switch; set optimizer_switch='derived_merge=off,derived_with_keys=off'; select * from (select 2 from DUAL) b; diff --git a/mysql-test/main/derived.test b/mysql-test/main/derived.test index beb361fd5b7..f4477ce8550 100644 --- a/mysql-test/main/derived.test +++ b/mysql-test/main/derived.test @@ -1,4 +1,9 @@ # Initialize +--source include/default_optimizer_switch.inc + +--disable_warnings +drop table if exists t1,t2,t3; +--enable_warnings set @save_derived_optimizer_switch=@@optimizer_switch; set optimizer_switch='derived_merge=off,derived_with_keys=off'; @@ -106,6 +111,7 @@ create user mysqltest_1; create table t1 select 1 as a; connect (con1,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK); connection con1; +--source include/default_optimizer_switch.inc set optimizer_switch='derived_merge=off,derived_with_keys=off'; --error 1046 select 2 as a from (select * from t1) b; diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index 4474cb8c2d9..ea8400f8302 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -1,3 +1,4 @@ +set @@join_buffer_size=256*1024; create table t1 (a int, b int, c int); create table t2 (a int, b int, c int, d decimal); insert into t1 values diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test index 2d683f06023..6ee85df7ea5 100644 --- a/mysql-test/main/derived_cond_pushdown.test +++ b/mysql-test/main/derived_cond_pushdown.test @@ -1,4 +1,6 @@ +--source include/default_optimizer_switch.inc let $no_pushdown= set statement optimizer_switch='condition_pushdown_for_derived=off' for; +set @@join_buffer_size=256*1024; create table t1 (a int, b int, c int); create table t2 (a int, b int, c int, d decimal); diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test index 1bf70cd8114..4f9d2e970f7 100644 --- a/mysql-test/main/derived_split_innodb.test +++ b/mysql-test/main/derived_split_innodb.test @@ -1,4 +1,5 @@ --source include/have_innodb.inc +--source include/default_optimizer_switch.inc --echo # --echo # MDEV-16917: do not use splitting for derived with join cache diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index d83e343b125..dd0cac74d28 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -2,6 +2,7 @@ drop table if exists t1,t2; drop view if exists v1,v2,v3,v4; set @exit_optimizer_switch=@@optimizer_switch; set @exit_join_cache_level=@@join_cache_level; +set @exit_join_buffer_size=@@join_buffer_size; set optimizer_switch='derived_merge=on,derived_with_keys=on'; set @save_optimizer_switch=@@optimizer_switch; set join_cache_level=1; @@ -1995,8 +1996,8 @@ e e e e -SET SESSION join_cache_level = DEFAULT; -SET SESSION join_buffer_size = DEFAULT; +SET SESSION join_cache_level = @exit_join_cache_level; +SET SESSION join_buffer_size = @exit_join_buffer_size; DROP VIEW v3; DROP TABLE t1,t2,t3,t4,t5; # @@ -2111,7 +2112,7 @@ a b 8 x 5 r 9 y -SET SESSION join_cache_level = default; +SET SESSION join_cache_level = @exit_join_cache_level; SET optimizer_switch=@save_optimizer_switch; DROP VIEW v2; DROP TABLE t1,t2,t3; diff --git a/mysql-test/main/derived_view.test b/mysql-test/main/derived_view.test index 8adbcc8dfd4..76b15fa8787 100644 --- a/mysql-test/main/derived_view.test +++ b/mysql-test/main/derived_view.test @@ -1,3 +1,5 @@ +--source include/default_optimizer_switch.inc + --disable_warnings drop table if exists t1,t2; drop view if exists v1,v2,v3,v4; @@ -5,6 +7,7 @@ drop view if exists v1,v2,v3,v4; set @exit_optimizer_switch=@@optimizer_switch; set @exit_join_cache_level=@@join_cache_level; +set @exit_join_buffer_size=@@join_buffer_size; set optimizer_switch='derived_merge=on,derived_with_keys=on'; # The 'default' value within the scope of this test: set @save_optimizer_switch=@@optimizer_switch; @@ -1077,8 +1080,8 @@ EXPLAIN SELECT t2.d FROM t1,t2,v3 WHERE v3.e = t2.d AND v3.i < 3; SELECT t2.d FROM t1,t2,v3 WHERE v3.e = t2.d AND v3.i < 3; -SET SESSION join_cache_level = DEFAULT; -SET SESSION join_buffer_size = DEFAULT; +SET SESSION join_cache_level = @exit_join_cache_level; +SET SESSION join_buffer_size = @exit_join_buffer_size; DROP VIEW v3; DROP TABLE t1,t2,t3,t4,t5; @@ -1167,7 +1170,7 @@ SELECT * FROM t3 SELECT * FROM t3 WHERE t3.b <> ANY (SELECT t1.b FROM t1 LEFT JOIN v2 ON v2.a = t1.a); -SET SESSION join_cache_level = default; +SET SESSION join_cache_level = @exit_join_cache_level; SET optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/main/distinct.test b/mysql-test/main/distinct.test index d41340c29fd..da12c7273b2 100644 --- a/mysql-test/main/distinct.test +++ b/mysql-test/main/distinct.test @@ -3,6 +3,7 @@ # Bug with group by and not used fields # +--source include/default_optimizer_switch.inc --disable_warnings drop table if exists t1,t2,t3; --enable_warnings diff --git a/mysql-test/main/dyncol.result b/mysql-test/main/dyncol.result index d233d0d3be2..811d86141e5 100644 --- a/mysql-test/main/dyncol.result +++ b/mysql-test/main/dyncol.result @@ -1483,7 +1483,7 @@ hex(column_create("1212", 2, 3, 3)) select hex(column_create("1212", 2, "адын", 1, 3, 3)); hex(column_create("1212", 2, "адын", 1, 3, 3)) 0403000D000000000001001000050020003331323132D0B0D0B4D18BD0BD060402 -set names default; +set names latin1; # fetching column test (names) set names utf8; select column_get(column_create("адын", 1212), "адын" as int); @@ -1507,7 +1507,7 @@ NULL select column_get(column_create("1212", 2, "адын", 1, 3, 3), "4" as int); column_get(column_create("1212", 2, "адын", 1, 3, 3), "4" as int) NULL -set names default; +set names latin1; # column existance test (names) set names utf8; select column_exists(column_create("адын", 1212), "адын"); @@ -1534,7 +1534,7 @@ column_exists(column_create("1212", 2, "адын", 1, 3, 3), 4) select column_exists(column_create("1212", 2, "адын", 1, 3, 3), "4"); column_exists(column_create("1212", 2, "адын", 1, 3, 3), "4") 0 -set names default; +set names latin1; # column changing test (names) select hex(column_add(column_create(1, "AAA"), "b", "BBB")); hex(column_add(column_create(1, "AAA"), "b", "BBB")) diff --git a/mysql-test/main/dyncol.test b/mysql-test/main/dyncol.test index f2c0a31c898..c0835de8c44 100644 --- a/mysql-test/main/dyncol.test +++ b/mysql-test/main/dyncol.test @@ -2,6 +2,8 @@ # Dynamic column function test # +--source include/default_charset.inc + --echo # --echo # column create --echo # @@ -674,7 +676,7 @@ select hex(column_create(1212, 2, "www", 3)); select hex(column_create("1212", 2, "www", 3)); select hex(column_create("1212", 2, 3, 3)); select hex(column_create("1212", 2, "адын", 1, 3, 3)); -set names default; +set names latin1; --echo # fetching column test (names) set names utf8; @@ -685,7 +687,7 @@ select column_get(column_create("1212", 2, "адын", 1, 3, 3), "3" as int); select column_get(column_create("1212", 2, "адын", 1, 3, 3), 3 as int); select column_get(column_create("1212", 2, "адын", 1, 3, 3), 4 as int); select column_get(column_create("1212", 2, "адын", 1, 3, 3), "4" as int); -set names default; +set names latin1; --echo # column existance test (names) set names utf8; @@ -697,7 +699,7 @@ select column_exists(column_create("1212", 2, "адын", 1, 3, 3), "3"); select column_exists(column_create("1212", 2, "адын", 1, 3, 3), 3); select column_exists(column_create("1212", 2, "адын", 1, 3, 3), 4); select column_exists(column_create("1212", 2, "адын", 1, 3, 3), "4"); -set names default; +set names latin1; --echo # column changing test (names) select hex(column_add(column_create(1, "AAA"), "b", "BBB")); diff --git a/mysql-test/main/events_1.test b/mysql-test/main/events_1.test index 58c151bc86e..33b82730783 100644 --- a/mysql-test/main/events_1.test +++ b/mysql-test/main/events_1.test @@ -5,6 +5,7 @@ -- source include/not_embedded.inc set sql_mode=""; +--source include/default_charset.inc call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted"); diff --git a/mysql-test/main/events_2.test b/mysql-test/main/events_2.test index 12ce9210b0a..2012f94e9f2 100644 --- a/mysql-test/main/events_2.test +++ b/mysql-test/main/events_2.test @@ -4,6 +4,7 @@ -- source include/not_embedded.inc set sql_mode=""; +--source include/default_charset.inc --disable_warnings drop database if exists events_test; diff --git a/mysql-test/main/events_bugs.result b/mysql-test/main/events_bugs.result index 008d4db7dae..cb8850112a5 100644 --- a/mysql-test/main/events_bugs.result +++ b/mysql-test/main/events_bugs.result @@ -2,6 +2,7 @@ SET SQL_MODE=""; drop database if exists events_test; drop database if exists mysqltest_db1; drop database if exists mysqltest_db2; +set collation_server=latin1_swedish_ci; create database events_test; use events_test; set @concurrent_insert= @@global.concurrent_insert; diff --git a/mysql-test/main/events_bugs.test b/mysql-test/main/events_bugs.test index 76288c8fbae..a0f3c5991ef 100644 --- a/mysql-test/main/events_bugs.test +++ b/mysql-test/main/events_bugs.test @@ -139,6 +139,7 @@ drop database if exists events_test; drop database if exists mysqltest_db1; drop database if exists mysqltest_db2; --enable_warnings +set collation_server=latin1_swedish_ci; create database events_test; use events_test; # We use MyISAM tables and must avoid effects (visibility of changes might be diff --git a/mysql-test/main/events_grant.test b/mysql-test/main/events_grant.test index 8db4333cc03..0c89e9d1f6c 100644 --- a/mysql-test/main/events_grant.test +++ b/mysql-test/main/events_grant.test @@ -1,5 +1,7 @@ # Can't test with embedded server that doesn't support grants -- source include/not_embedded.inc +--source include/default_charset.inc + CREATE DATABASE IF NOT EXISTS events_test; use events_test; diff --git a/mysql-test/main/events_logs_tests.result b/mysql-test/main/events_logs_tests.result index 9cc6e44511c..ac4a43118da 100644 --- a/mysql-test/main/events_logs_tests.result +++ b/mysql-test/main/events_logs_tests.result @@ -1,3 +1,4 @@ +set @save_long_query_time=@@long_query_time; drop database if exists events_test; create database if not exists events_test; use events_test; @@ -68,5 +69,5 @@ user_host db sql_text USER_HOST events_test select 'events_logs_test' as inside_event, sleep(1.5) drop database events_test; set global event_scheduler=off; -set @@global.long_query_time=default; -set @@session.long_query_time=default; +set @@global.long_query_time=@save_long_query_time; +set @@session.long_query_time=@save_long_query_time; diff --git a/mysql-test/main/events_logs_tests.test b/mysql-test/main/events_logs_tests.test index c3bbff90723..c4ef133f46b 100644 --- a/mysql-test/main/events_logs_tests.test +++ b/mysql-test/main/events_logs_tests.test @@ -1,6 +1,7 @@ # Can't test with embedded server that doesn't support grants -- source include/not_embedded.inc +set @save_long_query_time=@@long_query_time; --disable_warnings drop database if exists events_test; --enable_warnings @@ -78,8 +79,8 @@ select user_host, db, sql_text from mysql.slow_log drop database events_test; set global event_scheduler=off; -set @@global.long_query_time=default; -set @@session.long_query_time=default; +set @@global.long_query_time=@save_long_query_time; +set @@session.long_query_time=@save_long_query_time; # # Safety diff --git a/mysql-test/main/events_restart.test b/mysql-test/main/events_restart.test index 7f01859e059..ca674170e96 100644 --- a/mysql-test/main/events_restart.test +++ b/mysql-test/main/events_restart.test @@ -3,6 +3,7 @@ call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted"); +let $collation_server=`select @@collation_server`; # # Test that when the server is restarted, it checks mysql.event table, # and disables the scheduler if it's not up to date. @@ -92,6 +93,7 @@ set global event_scheduler=on; select @@global.event_scheduler; --sorted_result --replace_column 6 # 9 # 10 # +--replace_result $collation_server latin1_swedish_ci show events; --echo Now let's restart the server again diff --git a/mysql-test/main/except.result b/mysql-test/main/except.result index 594bb7118eb..de20200b8ba 100644 --- a/mysql-test/main/except.result +++ b/mysql-test/main/except.result @@ -1,3 +1,4 @@ +set @@join_buffer_size=256*1024; create table t1 (a int, b int) engine=MyISAM; create table t2 (c int, d int) engine=MyISAM; insert into t1 values (1,1),(2,2); diff --git a/mysql-test/main/except.test b/mysql-test/main/except.test index f88d9b29e35..557599fd541 100644 --- a/mysql-test/main/except.test +++ b/mysql-test/main/except.test @@ -1,3 +1,7 @@ +# For explain +--source include/default_optimizer_switch.inc +set @@join_buffer_size=256*1024; + create table t1 (a int, b int) engine=MyISAM; create table t2 (c int, d int) engine=MyISAM; insert into t1 values (1,1),(2,2); diff --git a/mysql-test/main/explain_json.test b/mysql-test/main/explain_json.test index c3665b1818b..cfbc0cfa10c 100644 --- a/mysql-test/main/explain_json.test +++ b/mysql-test/main/explain_json.test @@ -1,6 +1,8 @@ # # EXPLAIN FORMAT=JSON tests. These are tests developed for MariaDB. # +--source include/default_optimizer_switch.inc + --disable_warnings drop table if exists t0,t1,t2; --enable_warnings diff --git a/mysql-test/main/flush2.result b/mysql-test/main/flush2.result index a66b0d5c688..513715b1aee 100644 --- a/mysql-test/main/flush2.result +++ b/mysql-test/main/flush2.result @@ -1,3 +1,4 @@ +set @save_expire_logs_days=@@global.expire_logs_days; flush logs; set global expire_logs_days = 3; show variables like 'log_bin%'; @@ -10,9 +11,9 @@ log_bin_index log_bin_trust_function_creators ON show variables like 'relay_log%'; Variable_name Value -relay_log mysqld-relay-bin -relay_log_basename MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin -relay_log_index MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin.index +relay_log XXX-relay-bin +relay_log_basename MYSQLTEST_VARDIR/mysqld.1/data/XXX-relay-bin +relay_log_index MYSQLTEST_VARDIR/mysqld.1/data/XXX-relay-bin.index relay_log_info_file relay-log.info relay_log_purge ON relay_log_recovery OFF @@ -28,11 +29,11 @@ log_bin_index log_bin_trust_function_creators ON show variables like 'relay_log%'; Variable_name Value -relay_log mysqld-relay-bin -relay_log_basename MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin -relay_log_index MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin.index +relay_log XXX-relay-bin +relay_log_basename MYSQLTEST_VARDIR/mysqld.1/data/XXX-relay-bin +relay_log_index MYSQLTEST_VARDIR/mysqld.1/data/XXX-relay-bin.index relay_log_info_file relay-log.info relay_log_purge ON relay_log_recovery OFF relay_log_space_limit 0 -set global expire_logs_days = 0; +set global expire_logs_days=@save_expire_logs_days; diff --git a/mysql-test/main/flush2.test b/mysql-test/main/flush2.test index 496b57ccea4..6c06eea0f98 100644 --- a/mysql-test/main/flush2.test +++ b/mysql-test/main/flush2.test @@ -4,13 +4,16 @@ --source include/not_embedded.inc +set @save_expire_logs_days=@@global.expire_logs_days; + flush logs; set global expire_logs_days = 3; +let $relay_prefix=`select concat(substring_index(@@relay_log,"-",1),"-")`; show variables like 'log_bin%'; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $relay_prefix XXX- show variables like 'relay_log%'; flush logs; show variables like 'log_bin%'; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $relay_prefix XXX- show variables like 'relay_log%'; -set global expire_logs_days = 0; +set global expire_logs_days=@save_expire_logs_days; diff --git a/mysql-test/main/func_compress.result b/mysql-test/main/func_compress.result index 60ddd866507..065b68b4979 100644 --- a/mysql-test/main/func_compress.result +++ b/mysql-test/main/func_compress.result @@ -1,3 +1,4 @@ +set @save_max_allowed_packet=@@max_allowed_packet; set global max_allowed_packet=1048576; connect conn1,localhost,root,,; connection conn1; @@ -81,7 +82,7 @@ Warning 1292 Truncated incorrect DOUBLE value: XXX Warning 1292 Truncated incorrect DOUBLE value: XXX disconnect newconn; connection default; -set @@global.max_allowed_packet=default; +set @@global.max_allowed_packet=@save_max_allowed_packet; create table t1(a blob); insert into t1 values(NULL), (compress('a')); select uncompress(a), uncompressed_length(a) from t1; @@ -163,7 +164,7 @@ Warnings: Warning 1259 ZLIB: Input data corrupted disconnect conn1; connection default; -set global max_allowed_packet=default; +set global max_allowed_packet=@save_max_allowed_packet; # # End of 5.5 tests # diff --git a/mysql-test/main/func_compress.test b/mysql-test/main/func_compress.test index 3fd9cad467b..983b792f4c4 100644 --- a/mysql-test/main/func_compress.test +++ b/mysql-test/main/func_compress.test @@ -5,6 +5,7 @@ # Note that this test gives error in the gzip library when running under # valgrind, but these warnings can be ignored +set @save_max_allowed_packet=@@max_allowed_packet; set global max_allowed_packet=1048576; connect (conn1,localhost,root,,); connection conn1; @@ -56,7 +57,7 @@ eval select compress(repeat('aaaaaaaaaa', IF('$LOW_MEMORY', 10, 10000000))) is n disconnect newconn; --source include/wait_until_disconnected.inc connection default; -set @@global.max_allowed_packet=default; +set @@global.max_allowed_packet=@save_max_allowed_packet; # # Bug #18643: problem with null values @@ -116,7 +117,7 @@ DROP TABLE t1; --echo End of 5.0 tests --disable_result_log --disable_query_log -set @@global.max_allowed_packet=default; +set @@global.max_allowed_packet=@save_max_allowed_packet; --enable_result_log --enable_query_log @@ -148,7 +149,7 @@ SELECT UNCOMPRESS(CAST(0 AS BINARY(5))); disconnect conn1; connection default; -set global max_allowed_packet=default; +set global max_allowed_packet=@save_max_allowed_packet; --echo # --echo # End of 5.5 tests --echo # diff --git a/mysql-test/main/func_isnull.test b/mysql-test/main/func_isnull.test index 7d1a7e83a1a..f4cf5a5b88b 100644 --- a/mysql-test/main/func_isnull.test +++ b/mysql-test/main/func_isnull.test @@ -1,6 +1,7 @@ # # test of ISNULL() # +--source include/default_optimizer_switch.inc --disable_warnings drop table if exists t1; diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index 427be24d5ea..4faa6f44f9f 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -619,6 +619,8 @@ JSON_search( '{"x": "\\""}', "one", '"') SELECT JSON_search( '{"x": "\\""}', "one", '\\"'); JSON_search( '{"x": "\\""}', "one", '\\"') "$.x" +set @save_max_allowed_packet=@@max_allowed_packet; +set @save_net_buffer_length=@@net_buffer_length; set @@global.net_buffer_length=1024; set @@global.max_allowed_packet=2048; connect newconn, localhost, root,,; @@ -639,8 +641,8 @@ NULL Warnings: Warning 1301 Result of json_object() was larger than max_allowed_packet (2048) - truncated connection default; -set @@global.max_allowed_packet = default; -set @@global.net_buffer_length = default; +set @@global.max_allowed_packet = @save_max_allowed_packet; +set @@global.net_buffer_length = @save_net_buffer_length; disconnect newconn; create table t1(j longtext, p longtext); insert into t1 values diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index e557be85308..33f8a598670 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -265,6 +265,9 @@ SELECT JSON_search( '{"x": "\\""}', "one", '\\"'); # # MDEV-11833 JSON functions don't seem to respect max_allowed_packet. # +set @save_max_allowed_packet=@@max_allowed_packet; +set @save_net_buffer_length=@@net_buffer_length; + set @@global.net_buffer_length=1024; set @@global.max_allowed_packet=2048; --connect (newconn, localhost, root,,) @@ -275,8 +278,8 @@ select json_array(repeat('a',1024),repeat('a',1024)); select json_object("a", repeat('a',1024),"b", repeat('a',1024)); --connection default -set @@global.max_allowed_packet = default; -set @@global.net_buffer_length = default; +set @@global.max_allowed_packet = @save_max_allowed_packet; +set @@global.net_buffer_length = @save_net_buffer_length; --disconnect newconn diff --git a/mysql-test/main/func_math.result b/mysql-test/main/func_math.result index db9b16f5507..44c8622b522 100644 --- a/mysql-test/main/func_math.result +++ b/mysql-test/main/func_math.result @@ -296,7 +296,7 @@ format(t2.f2-t2.f1+1,0) 10,000 10,000 drop table t1, t2; -set names default; +set names latin1; select cast(-2 as unsigned), 18446744073709551614, -2; cast(-2 as unsigned) 18446744073709551614 -2 18446744073709551614 18446744073709551614 -2 diff --git a/mysql-test/main/func_math.test b/mysql-test/main/func_math.test index 1e8e6cfbb70..6d28d99006a 100644 --- a/mysql-test/main/func_math.test +++ b/mysql-test/main/func_math.test @@ -2,6 +2,8 @@ # Test of math functions # +--source include/default_charset.inc + --disable_warnings drop table if exists t1; --enable_warnings @@ -193,7 +195,7 @@ insert into t2 values (16777216,16787215,1),(33554432,33564431,2); select format(t2.f2-t2.f1+1,0) from t1,t2 where t1.f2 = t2.f3 order by t1.f1; drop table t1, t2; -set names default; +set names latin1; # Bug 24912 -- misc functions have trouble with unsigned diff --git a/mysql-test/main/func_misc.test b/mysql-test/main/func_misc.test index e4a2cd22f69..580245ef5c7 100644 --- a/mysql-test/main/func_misc.test +++ b/mysql-test/main/func_misc.test @@ -2,6 +2,7 @@ # Testing of misc functions # +--source include/default_optimizer_switch.inc --disable_warnings DROP TABLE IF EXISTS t1, t2; --enable_warnings diff --git a/mysql-test/main/func_str.result b/mysql-test/main/func_str.result index 2d86d384288..9e63f6e4580 100644 --- a/mysql-test/main/func_str.result +++ b/mysql-test/main/func_str.result @@ -1,4 +1,5 @@ drop table if exists t1,t2; +set @save_max_allowed_packet=@@global.max_allowed_packet; set global max_allowed_packet=1048576; connect conn1,localhost,root,,; connection conn1; @@ -4800,7 +4801,7 @@ COLLATION(space(2)) latin2_general_ci disconnect conn1; connection default; -set global max_allowed_packet=default; +set global max_allowed_packet=@save_max_allowed_packet; # # End of 5.6 tests # diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test index 60a142cda20..780783e316f 100644 --- a/mysql-test/main/func_str.test +++ b/mysql-test/main/func_str.test @@ -6,6 +6,7 @@ drop table if exists t1,t2; --enable_warnings +set @save_max_allowed_packet=@@global.max_allowed_packet; set global max_allowed_packet=1048576; connect (conn1,localhost,root,,); connection conn1; @@ -1848,7 +1849,7 @@ EXECUTE stmt; disconnect conn1; connection default; -set global max_allowed_packet=default; +set global max_allowed_packet=@save_max_allowed_packet; --echo # --echo # End of 5.6 tests diff --git a/mysql-test/main/func_weight_string.result b/mysql-test/main/func_weight_string.result index 5fa78c861a9..3b72cdafa32 100644 --- a/mysql-test/main/func_weight_string.result +++ b/mysql-test/main/func_weight_string.result @@ -1,4 +1,5 @@ drop table if exists t1; +set @save_max_allowed_packet=@@max_allowed_packet; set global max_allowed_packet=1048576; connect conn1,localhost,root,,; connection conn1; @@ -95,7 +96,7 @@ Warning 1301 Result of cast_as_binary() was larger than max_allowed_packet (1048 Warning 1301 Result of weight_string() was larger than max_allowed_packet (1048576) - truncated disconnect conn1; connection default; -set global max_allowed_packet=default; +set global max_allowed_packet=@save_max_allowed_packet; # # Start of 10.1 tests # diff --git a/mysql-test/main/func_weight_string.test b/mysql-test/main/func_weight_string.test index b376b996556..528aa5d4f0f 100644 --- a/mysql-test/main/func_weight_string.test +++ b/mysql-test/main/func_weight_string.test @@ -2,7 +2,7 @@ drop table if exists t1; --enable_warnings - +set @save_max_allowed_packet=@@max_allowed_packet; set global max_allowed_packet=1048576; connect (conn1,localhost,root,,); connection conn1; @@ -118,7 +118,7 @@ SELECT HEX(WEIGHT_STRING('ab' AS BINARY(1000000000000000000))); disconnect conn1; connection default; -set global max_allowed_packet=default; +set global max_allowed_packet=@save_max_allowed_packet; --echo # --echo # Start of 10.1 tests diff --git a/mysql-test/main/grant.opt b/mysql-test/main/grant.opt new file mode 100644 index 00000000000..afe4f848260 --- /dev/null +++ b/mysql-test/main/grant.opt @@ -0,0 +1 @@ +--disable-skip-name-resolve --character_set_server=latin1 --collation_server=latin1_swedish_ci diff --git a/mysql-test/main/grant2.opt b/mysql-test/main/grant2.opt new file mode 100644 index 00000000000..afe4f848260 --- /dev/null +++ b/mysql-test/main/grant2.opt @@ -0,0 +1 @@ +--disable-skip-name-resolve --character_set_server=latin1 --collation_server=latin1_swedish_ci diff --git a/mysql-test/main/grant4.opt b/mysql-test/main/grant4.opt new file mode 100644 index 00000000000..afe4f848260 --- /dev/null +++ b/mysql-test/main/grant4.opt @@ -0,0 +1 @@ +--disable-skip-name-resolve --character_set_server=latin1 --collation_server=latin1_swedish_ci diff --git a/mysql-test/main/grant_cache_no_prot.result b/mysql-test/main/grant_cache_no_prot.result index f1adb3ae839..04eb2469732 100644 --- a/mysql-test/main/grant_cache_no_prot.result +++ b/mysql-test/main/grant_cache_no_prot.result @@ -1,3 +1,6 @@ +set @save_query_cache_size=@@global.query_cache_size; +set @save_sql_mode=@@global.sql_mode; +set @save_query_cache_type=@@global.query_cache_type; set GLOBAL sql_mode=""; set LOCAL sql_mode=""; drop table if exists test.t1,mysqltest.t1,mysqltest.t2; @@ -242,8 +245,8 @@ delete from mysql.columns_priv where user in ("mysqltest_1","mysqltest_2","mysql flush privileges; drop table test.t1,mysqltest.t1,mysqltest.t2; drop database mysqltest; -set GLOBAL query_cache_size=default; set GLOBAL query_cache_type=ON; set LOCAL query_cache_type=ON; -set GLOBAL sql_mode=default; -set GLOBAL query_cache_type=default; +set GLOBAL query_cache_size=@save_query_cache_size; +set GLOBAL sql_mode=@save_sql_mode; +set GLOBAL query_cache_type=@save_query_cache_type; diff --git a/mysql-test/main/grant_cache_ps_prot.result b/mysql-test/main/grant_cache_ps_prot.result index 56a98cc076d..3bc51430fd0 100644 --- a/mysql-test/main/grant_cache_ps_prot.result +++ b/mysql-test/main/grant_cache_ps_prot.result @@ -1,3 +1,6 @@ +set @save_query_cache_size=@@global.query_cache_size; +set @save_sql_mode=@@global.sql_mode; +set @save_query_cache_type=@@global.query_cache_type; set GLOBAL sql_mode=""; set LOCAL sql_mode=""; drop table if exists test.t1,mysqltest.t1,mysqltest.t2; @@ -242,8 +245,8 @@ delete from mysql.columns_priv where user in ("mysqltest_1","mysqltest_2","mysql flush privileges; drop table test.t1,mysqltest.t1,mysqltest.t2; drop database mysqltest; -set GLOBAL query_cache_size=default; set GLOBAL query_cache_type=ON; set LOCAL query_cache_type=ON; -set GLOBAL sql_mode=default; -set GLOBAL query_cache_type=default; +set GLOBAL query_cache_size=@save_query_cache_size; +set GLOBAL sql_mode=@save_sql_mode; +set GLOBAL query_cache_type=@save_query_cache_type; diff --git a/mysql-test/main/grant_explain_non_select.test b/mysql-test/main/grant_explain_non_select.test index 701586be325..2bde3bed17c 100644 --- a/mysql-test/main/grant_explain_non_select.test +++ b/mysql-test/main/grant_explain_non_select.test @@ -7,6 +7,7 @@ # Save the initial number of concurrent sessions --source include/count_sessions.inc +--source include/default_optimizer_switch.inc set GLOBAL sql_mode=""; set LOCAL sql_mode=""; @@ -22,6 +23,7 @@ GRANT SELECT ON privtest_db.t2 TO 'privtest'@'localhost'; connect(con1,localhost,privtest,,); connection con1; +--source include/default_optimizer_switch.inc USE privtest_db; diff --git a/mysql-test/main/greedy_optimizer.result b/mysql-test/main/greedy_optimizer.result index de9db45cb15..d7c7e603c68 100644 --- a/mysql-test/main/greedy_optimizer.result +++ b/mysql-test/main/greedy_optimizer.result @@ -110,13 +110,7 @@ insert into t7 values (18,2,3,4,5,6); insert into t7 values (19,2,3,4,5,6); insert into t7 values (20,2,3,4,5,6); insert into t7 values (21,2,3,4,5,6); -select @@optimizer_search_depth; -@@optimizer_search_depth -62 -select @@optimizer_prune_level; -@@optimizer_prune_level -1 -set optimizer_search_depth=63; +set optimizer_search_depth=63, optimizer_prune_level=1; Warnings: Warning 1292 Truncated incorrect optimizer_search_depth value: '63' select @@optimizer_search_depth; diff --git a/mysql-test/main/greedy_optimizer.test b/mysql-test/main/greedy_optimizer.test index dcd0587d76e..cac262bca64 100644 --- a/mysql-test/main/greedy_optimizer.test +++ b/mysql-test/main/greedy_optimizer.test @@ -138,11 +138,6 @@ insert into t7 values (21,2,3,4,5,6); # The actual test begins here # -# Check the default values for the optimizer parameters - -select @@optimizer_search_depth; -select @@optimizer_prune_level; - # This value swithes back to the old implementation of 'find_best()' # set optimizer_search_depth=63; - old (independent of the optimizer_prune_level) # @@ -170,7 +165,7 @@ select @@optimizer_prune_level; # procedure 'find_best'. Notice that 'find_best' does not depend on the # choice of heuristic. -set optimizer_search_depth=63; +set optimizer_search_depth=63, optimizer_prune_level=1; select @@optimizer_search_depth; # 6-table join, chain diff --git a/mysql-test/main/group_by.result b/mysql-test/main/group_by.result index 807645fb2c2..38ae5bc0b00 100644 --- a/mysql-test/main/group_by.result +++ b/mysql-test/main/group_by.result @@ -523,6 +523,8 @@ NULL 9 b 1 drop table t1; set big_tables=0; +SET @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity,@save_optimizer_switch=@@optimizer_switch; +SET optimizer_switch='outer_join_with_cache=off',@@optimizer_use_condition_selectivity=1; create table t1 (a int not null, b int not null); insert into t1 values (1,1),(1,2),(3,1),(3,2),(2,2),(2,1); create table t2 (a int not null, b int not null, key(a)); @@ -535,10 +537,10 @@ a b 3 1 select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL; a b +1 1 1 3 -3 1 2 2 -1 1 +3 1 explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort @@ -548,6 +550,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 6 Using temporary 1 SIMPLE t2 ALL a NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join) drop table t1,t2; +SET @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity,@@optimizer_switch=@save_optimizer_switch; create table t1 (a int, b int); insert into t1 values (1, 4),(10, 40),(1, 4),(10, 43),(1, 4),(10, 41),(1, 4),(10, 43),(1, 4); select a, MAX(b), INTERVAL (MAX(b), 1,3,10,30,39,40,50,60,100,1000) from t1 group by a; diff --git a/mysql-test/main/group_by.test b/mysql-test/main/group_by.test index c8b28828369..72f2c3b29d4 100644 --- a/mysql-test/main/group_by.test +++ b/mysql-test/main/group_by.test @@ -400,15 +400,20 @@ set big_tables=0; # Test of GROUP BY ... ORDER BY NULL optimization # +SET @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity,@save_optimizer_switch=@@optimizer_switch; +SET optimizer_switch='outer_join_with_cache=off',@@optimizer_use_condition_selectivity=1; create table t1 (a int not null, b int not null); insert into t1 values (1,1),(1,2),(3,1),(3,2),(2,2),(2,1); create table t2 (a int not null, b int not null, key(a)); insert into t2 values (1,3),(3,1),(2,2),(1,1); select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b; +--sorted_result select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL; explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b; explain select t1.a,t2.b from t1,t2 where t1.a=t2.a group by t1.a,t2.b ORDER BY NULL; drop table t1,t2; +SET @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity,@@optimizer_switch=@save_optimizer_switch; + # # group function arguments in some functions diff --git a/mysql-test/main/group_min_max.test b/mysql-test/main/group_min_max.test index e8245dd2898..7cea21df56b 100644 --- a/mysql-test/main/group_min_max.test +++ b/mysql-test/main/group_min_max.test @@ -3,6 +3,8 @@ # The queries in this file test query execution via QUICK_GROUP_MIN_MAX_SELECT. # +--source include/default_optimizer_switch.inc + # # TODO: # Add queries with: diff --git a/mysql-test/main/handlersocket.opt b/mysql-test/main/handlersocket.opt new file mode 100644 index 00000000000..8374626febe --- /dev/null +++ b/mysql-test/main/handlersocket.opt @@ -0,0 +1 @@ +--plugin-maturity=unknown diff --git a/mysql-test/main/host_cache_size_functionality.result b/mysql-test/main/host_cache_size_functionality.result index 069cf61bcad..f5d7e7ee109 100644 --- a/mysql-test/main/host_cache_size_functionality.result +++ b/mysql-test/main/host_cache_size_functionality.result @@ -4,12 +4,7 @@ echo '##' #################################################################### # Checking default value # #################################################################### -SELECT COUNT(@@GLOBAL.Host_Cache_Size) -1 Expected -set @Default_host_cache_size=279; -select @@global.Host_Cache_Size=@Default_host_cache_size; -@@global.Host_Cache_Size=@Default_host_cache_size -1 +select @@global.Host_Cache_Size > 0 1 Expected '#---------------------WL6372_VAR_6_02----------------------#' # Restart server with Host_Cache_Size 1 diff --git a/mysql-test/main/host_cache_size_functionality.test b/mysql-test/main/host_cache_size_functionality.test index 5a7376cc5eb..db4f64fd493 100644 --- a/mysql-test/main/host_cache_size_functionality.test +++ b/mysql-test/main/host_cache_size_functionality.test @@ -31,13 +31,8 @@ echo '##' #################################################################### # Checking default value # #################################################################### -SELECT COUNT(@@GLOBAL.Host_Cache_Size); ---echo 1 Expected -#set @Default_host_cache_size=(select if(if(@@global.max_connections<500,128+@@global.max_connections,128+@@global.max_connections+floor((@@global.max_connections-500)/20))>2000,2000,if(@@global.max_connections<500,128+@@global.max_connections,128+@@global.max_connections+floor((@@global.max_connections-500)/20)))); -set @Default_host_cache_size=279; - -select @@global.Host_Cache_Size=@Default_host_cache_size; +select @@global.Host_Cache_Size > 0; --echo 1 Expected diff --git a/mysql-test/main/huge_frm-6224.result b/mysql-test/main/huge_frm-6224.result index bbb650bc5b4..4c97bf3837c 100644 --- a/mysql-test/main/huge_frm-6224.result +++ b/mysql-test/main/huge_frm-6224.result @@ -1,6 +1,7 @@ +set @save_max_allowed_packet=@@max_allowed_packet; set global max_allowed_packet=1024*1024*10; connect con1,localhost,root; ERROR HY000: The definition for table `t1` is too big connection default; disconnect con1; -set global max_allowed_packet=default; +set global max_allowed_packet=@save_max_allowed_packet; diff --git a/mysql-test/main/huge_frm-6224.test b/mysql-test/main/huge_frm-6224.test index 322abd01738..e53c0a4c6e3 100644 --- a/mysql-test/main/huge_frm-6224.test +++ b/mysql-test/main/huge_frm-6224.test @@ -4,6 +4,7 @@ # verify that huge frms are rejected during creation, not on opening # --source include/have_partition.inc +set @save_max_allowed_packet=@@max_allowed_packet; set global max_allowed_packet=1024*1024*10; connect con1,localhost,root; @@ -23,5 +24,4 @@ eval $a partition foo); connection default; disconnect con1; -set global max_allowed_packet=default; - +set global max_allowed_packet=@save_max_allowed_packet; diff --git a/mysql-test/main/index_intersect.test b/mysql-test/main/index_intersect.test index 1be963cb9e5..76d37b16c3e 100644 --- a/mysql-test/main/index_intersect.test +++ b/mysql-test/main/index_intersect.test @@ -1,3 +1,6 @@ +--source include/default_optimizer_switch.inc +--source include/default_charset.inc + --disable_warnings DROP TABLE IF EXISTS t1,t2,t3,t4; DROP DATABASE IF EXISTS world; diff --git a/mysql-test/main/index_merge_innodb.result b/mysql-test/main/index_merge_innodb.result index f27bb263c6f..549c920e857 100644 --- a/mysql-test/main/index_merge_innodb.result +++ b/mysql-test/main/index_merge_innodb.result @@ -704,8 +704,8 @@ SELECT COUNT(*) FROM (SELECT * FROM t1 FORCE INDEX(primary,idx) WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6145 -2 DERIVED t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL 6145 Using sort_union(idx,PRIMARY); Using where +1 PRIMARY <derived2> ALL NULL NULL NULL NULL # +2 DERIVED t1 index_merge PRIMARY,idx idx,PRIMARY 5,4 NULL # Using sort_union(idx,PRIMARY); Using where SELECT COUNT(*) FROM (SELECT * FROM t1 FORCE INDEX(primary,idx) WHERE a BETWEEN 2 AND 7 OR pk=1000000) AS t; diff --git a/mysql-test/main/index_merge_innodb.test b/mysql-test/main/index_merge_innodb.test index f959db3039a..11988d4529c 100644 --- a/mysql-test/main/index_merge_innodb.test +++ b/mysql-test/main/index_merge_innodb.test @@ -74,6 +74,7 @@ set optimizer_switch='derived_merge=off,derived_with_keys=off'; # We have to use FORCE INDEX here as Innodb gives inconsistent estimates # which causes different query plans. +--replace_column 9 # EXPLAIN SELECT COUNT(*) FROM (SELECT * FROM t1 FORCE INDEX(primary,idx) diff --git a/mysql-test/main/information_schema-big.result b/mysql-test/main/information_schema-big.result index d4aa6deb2e2..0ed74d113ea 100644 --- a/mysql-test/main/information_schema-big.result +++ b/mysql-test/main/information_schema-big.result @@ -15,7 +15,7 @@ WHERE c2.table_schema = t.table_schema AND c2.table_name = t.table_name AND c2.column_name LIKE '%SCHEMA%' ) -AND t.table_name NOT LIKE 'innodb%'; +AND t.table_name NOT LIKE 'innodb%' and t.table_name NOT LIKE "OPTIMIZER_TRACE%"; table_name column_name ALL_PLUGINS PLUGIN_NAME APPLICABLE_ROLES GRANTEE @@ -73,7 +73,7 @@ WHERE c2.table_schema = 'information_schema' AND c2.table_name = t.table_name AND c2.column_name LIKE '%SCHEMA%' ) -AND t.table_name NOT LIKE 'innodb%'; +AND t.table_name NOT LIKE 'innodb%' and t.table_name NOT LIKE "OPTIMIZER_TRACE%"; table_name column_name ALL_PLUGINS PLUGIN_NAME APPLICABLE_ROLES GRANTEE diff --git a/mysql-test/main/information_schema-big.test b/mysql-test/main/information_schema-big.test index 9212348649e..3a82bbf6dcb 100644 --- a/mysql-test/main/information_schema-big.test +++ b/mysql-test/main/information_schema-big.test @@ -26,7 +26,7 @@ SELECT t.table_name, c1.column_name c2.table_name = t.table_name AND c2.column_name LIKE '%SCHEMA%' ) - AND t.table_name NOT LIKE 'innodb%'; + AND t.table_name NOT LIKE 'innodb%' and t.table_name NOT LIKE "OPTIMIZER_TRACE%"; --sorted_result SELECT t.table_name, c1.column_name FROM information_schema.tables t @@ -42,4 +42,4 @@ SELECT t.table_name, c1.column_name c2.table_name = t.table_name AND c2.column_name LIKE '%SCHEMA%' ) - AND t.table_name NOT LIKE 'innodb%'; + AND t.table_name NOT LIKE 'innodb%' and t.table_name NOT LIKE "OPTIMIZER_TRACE%"; diff --git a/mysql-test/main/information_schema.test b/mysql-test/main/information_schema.test index 2b318f5f1aa..64d7341882f 100644 --- a/mysql-test/main/information_schema.test +++ b/mysql-test/main/information_schema.test @@ -17,6 +17,9 @@ # Save the initial number of concurrent sessions --source include/count_sessions.inc +--source include/default_optimizer_switch.inc +--source include/default_charset.inc + set global sql_mode=""; set local sql_mode=""; diff --git a/mysql-test/main/information_schema_parameters.test b/mysql-test/main/information_schema_parameters.test index 8ce6af478b6..81aef66bfcd 100644 --- a/mysql-test/main/information_schema_parameters.test +++ b/mysql-test/main/information_schema_parameters.test @@ -7,6 +7,8 @@ # Last modified: 2007-12-03 #------------------------------------------------------------------------------ +--source include/default_charset.inc + ############################################################################### # Testcase parameters.1: Verify INFORMATION_SCHEMA.PARAMETERS view has the # following structure: diff --git a/mysql-test/main/information_schema_routines.test b/mysql-test/main/information_schema_routines.test index 190410c2b82..a07e54cd70b 100644 --- a/mysql-test/main/information_schema_routines.test +++ b/mysql-test/main/information_schema_routines.test @@ -56,6 +56,8 @@ ################################################################################ set sql_mode=""; set sql_mode=""; +--source include/default_charset.inc + -- echo # ========== routines.1 ========== USE INFORMATION_SCHEMA; --replace_result ENGINE=MyISAM "" ENGINE=MARIA "" ENGINE=Aria "" " PAGE_CHECKSUM=1" "" " PAGE_CHECKSUM=0" "" diff --git a/mysql-test/main/information_schema_stats.result b/mysql-test/main/information_schema_stats.result index bc2ce9f0294..8e044bc9f96 100644 --- a/mysql-test/main/information_schema_stats.result +++ b/mysql-test/main/information_schema_stats.result @@ -1,3 +1,4 @@ +set @save_userstat=@@global.userstat; set global userstat=1; create table just_a_test(id int,first_name varchar(10),last_name varchar(10),address varchar(100),phone bigint,email varchar(30), state varchar(30)); insert into just_a_test values(1,'fa','la','china_a',11111111,'fa_la@163.com','California'), @@ -67,4 +68,4 @@ select * from information_schema.index_statistics where table_schema='test' and TABLE_SCHEMA TABLE_NAME INDEX_NAME ROWS_READ select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; TABLE_SCHEMA TABLE_NAME ROWS_READ ROWS_CHANGED ROWS_CHANGED_X_INDEXES -set global userstat=0; +set global userstat=@save_userstat; diff --git a/mysql-test/main/information_schema_stats.test b/mysql-test/main/information_schema_stats.test index c7f39894ce7..49d46ee437d 100644 --- a/mysql-test/main/information_schema_stats.test +++ b/mysql-test/main/information_schema_stats.test @@ -1,6 +1,7 @@ # # MDEV-8633: information_schema.index_statistics doesn't delete item when drop table indexes or drop table; # +set @save_userstat=@@global.userstat; set global userstat=1; create table just_a_test(id int,first_name varchar(10),last_name varchar(10),address varchar(100),phone bigint,email varchar(30), state varchar(30)); insert into just_a_test values(1,'fa','la','china_a',11111111,'fa_la@163.com','California'), @@ -43,4 +44,4 @@ select * from information_schema.table_statistics where table_schema='test' and drop table just_a_test; select * from information_schema.index_statistics where table_schema='test' and table_name='just_a_test'; select * from information_schema.table_statistics where table_schema='test' and table_name='just_a_test'; -set global userstat=0; +set global userstat=@save_userstat; diff --git a/mysql-test/main/init_connection_query_cache.result b/mysql-test/main/init_connection_query_cache.result index eacc06c05f6..df27327e93b 100644 --- a/mysql-test/main/init_connection_query_cache.result +++ b/mysql-test/main/init_connection_query_cache.result @@ -2,6 +2,7 @@ # MDEV-4520: Assertion `0' fails in Query_cache::end_of_result on # concurrent drop event and event execution # +set @save_query_cache_size=@@query_cache_size; set GLOBAL query_cache_size=1355776; create user mysqltest1@localhost; grant SELECT on test.* to mysqltest1@localhost; @@ -20,4 +21,4 @@ disconnect con1; revoke all privileges, grant option from mysqltest1@localhost; drop user mysqltest1@localhost; drop table t1; -set GLOBAL query_cache_size=default; +set GLOBAL query_cache_size=@save_query_cache_size; diff --git a/mysql-test/main/init_connection_query_cache.test b/mysql-test/main/init_connection_query_cache.test index 4d83304163e..5a5c7dcef4b 100644 --- a/mysql-test/main/init_connection_query_cache.test +++ b/mysql-test/main/init_connection_query_cache.test @@ -4,6 +4,7 @@ --echo # MDEV-4520: Assertion `0' fails in Query_cache::end_of_result on --echo # concurrent drop event and event execution --echo # +set @save_query_cache_size=@@query_cache_size; set GLOBAL query_cache_size=1355776; create user mysqltest1@localhost; @@ -23,4 +24,4 @@ drop user mysqltest1@localhost; drop table t1; -set GLOBAL query_cache_size=default; +set GLOBAL query_cache_size=@save_query_cache_size; diff --git a/mysql-test/main/innodb_ext_key.result b/mysql-test/main/innodb_ext_key.result index c4b527a5107..dc8098d9bff 100644 --- a/mysql-test/main/innodb_ext_key.result +++ b/mysql-test/main/innodb_ext_key.result @@ -1137,6 +1137,7 @@ drop table t0,t1,t2; # # MDEV-11196: Error:Run-Time Check Failure #2 - Stack around the variable 'key_buff' # was corrupted, server crashes in opt_sum_query +SET @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity,@@optimizer_use_condition_selectivity=1; CREATE TABLE t1 ( pk INT, f1 VARCHAR(3), @@ -1209,3 +1210,4 @@ EXPLAIN } } drop table t1; +SET optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; diff --git a/mysql-test/main/innodb_ext_key.test b/mysql-test/main/innodb_ext_key.test index 4104ac5f787..8def57ad377 100644 --- a/mysql-test/main/innodb_ext_key.test +++ b/mysql-test/main/innodb_ext_key.test @@ -784,6 +784,8 @@ drop table t0,t1,t2; --echo # MDEV-11196: Error:Run-Time Check Failure #2 - Stack around the variable 'key_buff' --echo # was corrupted, server crashes in opt_sum_query +SET @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity,@@optimizer_use_condition_selectivity=1; + CREATE TABLE t1 ( pk INT, f1 VARCHAR(3), @@ -822,3 +824,4 @@ INSERT INTO t1 VALUES (1,2,'2','abc'),(2,3,'3','def'); explain format= json select * from t1 force index(k1) where f2 <= 5 and pk2 <=5 and pk1 = 'abc' and f1 <= '3'; drop table t1; +SET optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; diff --git a/mysql-test/main/innodb_icp.test b/mysql-test/main/innodb_icp.test index acb8238e01f..83b0f619349 100644 --- a/mysql-test/main/innodb_icp.test +++ b/mysql-test/main/innodb_icp.test @@ -3,6 +3,7 @@ # --source include/have_innodb.inc +--source include/default_optimizer_switch.inc set @save_storage_engine= @@storage_engine; set storage_engine=InnoDB; diff --git a/mysql-test/main/intersect.result b/mysql-test/main/intersect.result index 66c7addfd36..62ab0b7e5de 100644 --- a/mysql-test/main/intersect.result +++ b/mysql-test/main/intersect.result @@ -1,3 +1,5 @@ +set @@join_buffer_size=256*1024; +set @save_optimizer_switch=@@optimizer_switch; create table t1 (a int, b int); create table t2 (c int, d int); insert into t1 values (1,1),(2,2); @@ -279,6 +281,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra NULL INTERSECT RESULT <intersect2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1003 /* select#1 */ select `a`.`a` AS `a`,`a`.`b` AS `b` from ((/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1`) intersect (/* select#3 */ select `test`.`t2`.`c` AS `c`,`test`.`t3`.`e` AS `e` from `test`.`t2` join `test`.`t3`)) `a` +set @@optimizer_switch='optimize_join_buffer_size=off'; EXPLAIN format=json (select a,b from t1) intersect (select c,e from t2,t3); EXPLAIN { @@ -472,6 +475,7 @@ ANALYZE } } } +set @@optimizer_switch=@save_optimizer_switch; select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a; a b 2 2 diff --git a/mysql-test/main/intersect.test b/mysql-test/main/intersect.test index fb5e991a24c..901f471121f 100644 --- a/mysql-test/main/intersect.test +++ b/mysql-test/main/intersect.test @@ -1,3 +1,7 @@ +# For explain +set @@join_buffer_size=256*1024; +set @save_optimizer_switch=@@optimizer_switch; + create table t1 (a int, b int); create table t2 (c int, d int); insert into t1 values (1,1),(2,2); @@ -38,11 +42,13 @@ execute stmt; EXPLAIN (select a,b from t1) intersect (select c,e from t2,t3); EXPLAIN extended (select a,b from t1) intersect (select c,e from t2,t3); EXPLAIN extended select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a; +set @@optimizer_switch='optimize_join_buffer_size=off'; EXPLAIN format=json (select a,b from t1) intersect (select c,e from t2,t3); --replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/ ANALYZE format=json (select a,b from t1) intersect (select c,e from t2,t3); --replace_regex /"r_total_time_ms": [0-9e\.\-+]*,/"r_total_time_ms": "REPLACED",/ ANALYZE format=json select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a; +set @@optimizer_switch=@save_optimizer_switch; select * from ((select a,b from t1) intersect (select c,e from t2,t3)) a; prepare stmt from "(select a,b from t1) intersect (select c,e from t2,t3);"; diff --git a/mysql-test/main/join.test b/mysql-test/main/join.test index a2ad01639ec..c5d62e213d8 100644 --- a/mysql-test/main/join.test +++ b/mysql-test/main/join.test @@ -1,5 +1,6 @@ # # Initialization +--source include/default_optimizer_switch.inc --disable_warnings drop table if exists t1,t2,t3; drop view if exists v1,v2; diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result index 9bb64c0b32c..bab32395413 100644 --- a/mysql-test/main/join_cache.result +++ b/mysql-test/main/join_cache.result @@ -1,12 +1,16 @@ DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; DROP DATABASE IF EXISTS world; -set @save_optimizer_switch=@@optimizer_switch; +set @org_optimizer_switch=@@optimizer_switch; +set @save_join_cache_level=@@join_cache_level; +set @save_join_buffer_space_limit=@@join_buffer_space_limit; +set @save_join_buffer_size=@@join_buffer_size; +set @save_expensive_subquery_limit=@@expensive_subquery_limit; set @@optimizer_switch='optimize_join_buffer_size=on'; -set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on'; +set @@optimizer_switch='semijoin=on,firstmatch=on,loosescan=on'; set @@optimizer_switch='semijoin_with_cache=on'; set @@optimizer_switch='outer_join_with_cache=on'; -set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; -set @local_join_cache_test_optimizer_switch_default=@@optimizer_switch; +set @@optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +set @local_optimizer_switch=@@optimizer_switch; set names utf8; CREATE DATABASE world; use world; @@ -770,14 +774,8 @@ Long Beach United States English Lexington-Fayette United States English Louisville United States English Little Rock United States English -set join_cache_level=default; -set join_buffer_size=default; -show variables like 'join_buffer_size'; -Variable_name Value -join_buffer_size 262144 -show variables like 'join_cache_level'; -Variable_name Value -join_cache_level 2 +set join_cache_level=@save_join_cache_level; +set join_buffer_size=@save_join_buffer_size; DROP DATABASE world; CREATE DATABASE world; use world; @@ -2684,14 +2682,8 @@ Kaunas Klaipeda ?iauliai Panevezys -set join_cache_level=default; -set join_buffer_size=default; -show variables like 'join_buffer_size'; -Variable_name Value -join_buffer_size 262144 -show variables like 'join_cache_level'; -Variable_name Value -join_cache_level 2 +set join_cache_level=@save_join_cache_level; +set join_buffer_size=@save_join_buffer_size; set join_cache_level=1; SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND City.Population > 3000000; @@ -2799,7 +2791,7 @@ Teheran Iran Tianjin China Tokyo Japan Wuhan China -set join_buffer_size=default; +set join_buffer_size=@save_join_buffer_size; set join_cache_level=6; ALTER TABLE Country MODIFY Name varchar(52) NOT NULL default ''; SELECT City.Name, Country.Name FROM City,Country @@ -2883,8 +2875,8 @@ Kaunas Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Klaipeda Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ?iauliai Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Panevezys Lithuania xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -set join_cache_level=default; -set join_buffer_size=default; +set join_cache_level=@save_join_cache_level; +set join_buffer_size=@save_join_buffer_size; # # MDEV-17752: Plan changes from hash_index_merge to index_merge with new optimizer defaults # @@ -2915,7 +2907,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE City hash_index_merge Population,Country,City_Name #hash#Country:Population,City_Name 3:4,35 world.Country.Code 96 Using sort_union(Population,City_Name); Using where; Using join buffer (flat, BNLH join) set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set @@use_stat_tables=@save_use_stat_tables; -set join_cache_level=default; +set @@join_cache_level=@save_join_cache_level; DROP DATABASE world; use test; CREATE TABLE t1( @@ -3206,8 +3198,8 @@ DROP TABLE t1,t2; # # Bug #40134: outer join with not exists optimization and join buffer # -set join_cache_level=default; -set join_buffer_size=default; +set join_cache_level=@save_join_cache_level; +set join_buffer_size=@save_join_buffer_size; CREATE TABLE t1 (a int NOT NULL); INSERT INTO t1 VALUES (2), (4), (3), (5), (1); CREATE TABLE t2 (a int NOT NULL, b int NOT NULL, INDEX i_a(a)); @@ -3235,8 +3227,8 @@ a a b 5 NULL NULL 1 NULL NULL DROP TABLE t1, t2; -set join_cache_level=default; -set join_buffer_size=default; +set join_cache_level=@save_join_cache_level; +set join_buffer_size=@save_join_buffer_size; # # BUG#40136: Group by is ignored when join buffer is used for an outer join # @@ -3288,7 +3280,7 @@ a b a b a b 4 2 1 2 4 2 3 3 NULL NULL NULL NULL 5 3 NULL NULL NULL NULL -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; DROP TABLE t2, t3, t4; # # Bug #40192: outer join with where clause when using BNL @@ -3312,7 +3304,7 @@ select * from t1 left join t2 on t1.a=t2.a where t2.c=102 or t2.c is null; a b a c 3 30 3 102 2 20 NULL NULL -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; drop table t1, t2; # # Bug #40317: outer join with with constant on expression equal to FALSE @@ -3339,7 +3331,7 @@ explain select * from t1 left join t2 on (1=0); id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; drop table t1, t2; # # Bug #41204: small buffer with big rec_per_key for ref access @@ -3378,8 +3370,8 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; AVG(c) 5.0000 -set join_buffer_size=default; -set join_cache_level=default; +set join_buffer_size=@save_join_buffer_size; +set join_cache_level=@save_join_cache_level; DROP TABLE t1, t2; # # Bug #41894: big join buffer of level 7 used to join records @@ -3421,8 +3413,8 @@ WHERE t1.a=t2.a AND t2.a=t3.a AND t1.b IS NULL AND t2.b IS NULL AND t3.b IS NULL; COUNT(*) 16384 -set join_buffer_size=default; -set join_cache_level=default; +set join_buffer_size=@save_join_buffer_size; +set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3; # # Bug #42020: join buffer is used for outer join with fields of @@ -3521,8 +3513,8 @@ a a a b b val 2 2 2 60 60 0 2 2 2 70 70 0 2 2 2 80 80 0 -set join_buffer_size=default; -set join_cache_level=default; +set join_buffer_size=@save_join_buffer_size; +set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3; create table t1(f1 int, f2 int); insert into t1 values (1,1),(2,2),(3,3); @@ -3609,7 +3601,7 @@ Variable_name Value Handler_icp_attempts 80 Handler_icp_match 16 drop table t1,t2; -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; # # Bug #42955: join with GROUP BY/ORDER BY and when BKA is enabled # @@ -3653,7 +3645,7 @@ id1 20 30 30 -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; drop table t1,t2; # # Bug #44019: star-like multi-join query executed join_cache_level=6 @@ -3717,7 +3709,7 @@ select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4 where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c; a b c d e f g 3 30 300 3000 bbb ddd ccc -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; drop table t1,t2,t3,t4; # # Bug #44250: Corruption of linked join buffers when using BKA @@ -3801,8 +3793,8 @@ id1 num3 text1 id4 id3 dummy 228808822 3 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 228808822 28 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 228808822 62 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 2381969632 2482416112 0 -set join_buffer_size=default; -set join_cache_level=default; +set join_buffer_size=@save_join_buffer_size; +set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4,t5; # # Bug#45267: Incomplete check caused wrong result. @@ -3864,7 +3856,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 index NULL int_key 4 NULL 2 Using index; Using join buffer (flat, BNL join) DROP TABLE t1,t2; -SET join_cache_level=default; +SET join_cache_level=@save_join_cache_level; # # Regression test for # Bug#46733 - NULL value not returned for aggregate on empty result @@ -3917,7 +3909,7 @@ SELECT t1.*, t2.*, LENGTH(t2.c1), LENGTH(t2.c2) FROM t1,t2 WHERE t1.c2=LENGTH(t2.c2) and t1.c1=LENGTH(t2.c1); c1 c2 c1 c2 LENGTH(t2.c1) LENGTH(t2.c2) 2 2 tt uu 2 2 -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; # # Bug #51092: linked join buffer is used for a 3-way cross join query @@ -3961,7 +3953,7 @@ a b 2 2 1 1 2 2 -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; drop table t1,t2,t3; # # Bug #52394: using join buffer for 3 table join with ref access @@ -3990,7 +3982,7 @@ a 27 27 DROP TABLE t1,t2,t3; -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; # # Bug #51084: Batched key access crashes for SELECT with # derived table and LEFT JOIN @@ -4030,7 +4022,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 Using join buffer (flat, BNL join) 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t1.carrier 1 Using where 1 SIMPLE t4 ref carrier_id carrier_id 5 test.t3.id 2 Using index -SET join_cache_level=default; +SET join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4; # # Bug #52636: allowing JOINs on NULL values w/ join_cache_level = 5-8 @@ -4094,7 +4086,7 @@ SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; a NULL NULL -set join_cache_level = default; +set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; # # Bug #54359: Extra rows with join_cache_level=7,8 and two joins @@ -4121,7 +4113,7 @@ WHERE s.pk AND s.a >= t.pk AND s.b = t.c; a 9 9 -set join_cache_level = default; +set join_cache_level=@save_join_cache_level; DROP TABLE t1; # # Bug #54235: Extra rows with join_cache_level=6,8 and two LEFT JOINs @@ -4161,7 +4153,7 @@ WHERE t1.a OR t4.a; a 2 1 -set join_cache_level = default; +set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4; # # Bug #663840: Memory overwrite causing crash with hash join @@ -4296,8 +4288,8 @@ i d v i d t v 8 2009-01-13 z 5 1900-01-01 22:45:53 a 8 2009-01-13 z 5 1900-01-01 22:45:53 a DROP TABLE t1,t2,t3; -SET SESSION join_cache_level=DEFAULT; -SET SESSION join_buffer_size=DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; +SET SESSION join_buffer_size=@save_join_buffer_size; # # Bug #664508: 'Simple' GROUP BY + ORDER BY # when join buffers are used @@ -4442,7 +4434,7 @@ n v p DROP TABLE t1,t2,t3; -SET SESSION join_cache_level=DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; # # Bug #668290: hash join with non-binary collations # @@ -4488,7 +4480,7 @@ SELECT t2.i FROM t1,t2 WHERE t1.cu = t2.cl ; i 6 6 -SET SESSION join_cache_level = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; # # Bug #669382: hash join using a ref with constant key parts @@ -4513,8 +4505,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t2.a 36 Using where; Using join buffer (flat, BNLH join) SELECT t1.a, t2.c FROM t1,t2 WHERE t1.a=t2.a AND t2.b=99; a c -SET SESSION join_cache_level = DEFAULT; -SET SESSION join_buffer_size = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; +SET SESSION join_buffer_size=@save_join_buffer_size; DROP TABLE t1,t2; # # Bug #671901: hash join using a ref to a varchar field @@ -4582,7 +4574,7 @@ SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = concat(t1.v, t1.v); v i f 5 f 5 -SET SESSION join_cache_level = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; # Bug #672497: 3 way join with tiny incremental join buffer with # and a ref access from the first table @@ -4651,8 +4643,8 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT t3.i FROM t1,t2,t3 WHERE t1.v = t2.v AND t3.v = t1.v AND t2.i <> 0; i -SET SESSION join_cache_level = DEFAULT; -SET SESSION join_buffer_size = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; +SET SESSION join_buffer_size=@save_join_buffer_size; DROP TABLE t1,t2,t3; # # Bug #672551: hash join over a long varchar field @@ -4706,7 +4698,7 @@ pk a pk a 2 aa 131 aa 3 bb 132 bb 2 aa 142 aa -SET SESSION join_cache_level = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; # # Bug #674431: nested outer join when join_cache_level is set to 7 @@ -4727,8 +4719,8 @@ a Warnings: Warning 1292 Truncated incorrect INTEGER value: 'h' Warning 1292 Truncated incorrect INTEGER value: 'j' -SET SESSION optimizer_switch = 'outer_join_with_cache=off'; -SET SESSION join_cache_level = DEFAULT; +SET SESSION optimizer_switch=@local_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3; # # Bug #52540: nested outer join when join_cache_level is set to 3 @@ -4748,8 +4740,8 @@ FROM t2 LEFT JOIN a a pk a f 2 2 NULL x 2 2 NULL -SET SESSION optimizer_switch = 'outer_join_with_cache=off'; -SET SESSION join_cache_level = DEFAULT; +SET SESSION optimizer_switch=@local_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4; # # Bug #674423: outer join with ON expression over only outer tables @@ -4777,8 +4769,8 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT * FROM t2 LEFT JOIN t1 ON t2.a <> 0 WHERE t1.a <> 0 OR t2.pk < 9; pk a a 1 NULL NULL -SET SESSION optimizer_switch = 'outer_join_with_cache=off'; -SET SESSION join_cache_level = DEFAULT; +SET SESSION optimizer_switch=@local_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; # # Bug #675095: nested outer join using join buffer @@ -4863,8 +4855,8 @@ pk a1 pk a2 c2 d2 pk a3 c3 d3 pk a4 pk a5 2 NULL 9 0 0 2 9 0 0 2 NULL NULL 8 0 2 NULL 9 0 0 2 1 0 0 7 NULL NULL 8 0 8 0 NULL NULL NULL NULL NULL NULL NULL NULL 8 0 NULL NULL -SET SESSION optimizer_switch = 'outer_join_with_cache=off'; -SET SESSION join_cache_level = DEFAULT; +SET SESSION optimizer_switch=@local_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4,t5; # # Bug #675516: nested outer join with 3 tables in the nest @@ -4911,8 +4903,8 @@ t1 LEFT JOIN ((t2 JOIN t3 ON t2.a2 = t3.b3) JOIN t4 ON t4.b4 <> 0) ON t1.c1 = t3.c3 WHERE t3.a3 IS NULL; a1 b1 c1 a2 a3 b3 c3 a4 b4 c4 -SET SESSION optimizer_switch = 'outer_join_with_cache=off'; -SET SESSION join_cache_level = DEFAULT; +SET SESSION optimizer_switch=@local_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4; # # Bug #660963: nested outer join with join_cache_level set to 5 @@ -4946,8 +4938,8 @@ SELECT * FROM t1 LEFT JOIN t2 JOIN t3 ON t3.a3 = t2.a2 ON t3.b3 <> 0; a1 a2 b2 a3 b3 0 2 1 2 1 0 2 1 2 1 -SET SESSION optimizer_switch = 'outer_join_with_cache=off'; -SET SESSION join_cache_level = DEFAULT; +SET SESSION optimizer_switch=@local_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3; # # Bug #675922: incremental buffer for BKA with access from previous @@ -4998,8 +4990,8 @@ LEFT JOIN t4 ON t4.a4 <> 0) LEFT JOIN t5 ON t5.a5 = t2.a2; a4 b5 9 0 9 NULL -SET SESSION optimizer_switch = 'outer_join_with_cache=off'; -SET SESSION join_cache_level = DEFAULT; +SET SESSION optimizer_switch=@local_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4,t5; # # Bug #670380: hash join for non-binary collation @@ -5043,7 +5035,7 @@ pk a pk a 40 DD 112 dd 50 ee 113 EE 50 ee 114 ee -SET SESSION join_cache_level = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; # # Bug #694092: incorrect detection of index only pushdown conditions @@ -5077,8 +5069,8 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT * FROM t1,t2 WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6); f1 f3 f3 f2 f4 -SET SESSION join_cache_level = DEFAULT; -SET SESSION optimizer_switch = @local_join_cache_test_optimizer_switch_default; +SET SESSION join_cache_level=@save_join_cache_level; +SET SESSION optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2; CREATE TABLE t1 (f1 int, f2 varchar(10), KEY (f1), KEY (f2)) ; INSERT INTO t1 VALUES @@ -5100,7 +5092,7 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT * FROM t1,t2 WHERE t2.f3 = t1.f2 AND t1.f1 IN (9, 0 ,100) ORDER BY t1.f2 LIMIT 1; f1 f2 f3 -SET SESSION optimizer_switch = @local_join_cache_test_optimizer_switch_default; +SET SESSION optimizer_switch=@local_optimizer_switch; SET SESSION optimizer_switch = 'index_condition_pushdown=on'; EXPLAIN SELECT * FROM t1,t2 WHERE t2.f3 = t1.f2 AND t1.f1 IN (9, 0 ,100) ORDER BY t1.f2 LIMIT 1; @@ -5110,7 +5102,7 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT * FROM t1,t2 WHERE t2.f3 = t1.f2 AND t1.f1 IN (9, 0 ,100) ORDER BY t1.f2 LIMIT 1; f1 f2 f3 -SET SESSION optimizer_switch = @local_join_cache_test_optimizer_switch_default; +SET SESSION optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2; # # Bug #694443: hash join using IS NULL the an equi-join condition @@ -5156,7 +5148,7 @@ a a b 2 NULL 41 1 NULL 42 2 NULL 42 -SET SESSION join_cache_level = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; # # Bug #697557: hash join on a varchar field @@ -5178,7 +5170,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 hash_ALL f1 #hash#f1 13 test.t1.f1 20 Using join buffer (flat, BNLH join) SELECT * FROM t1,t2 WHERE t2.f1 = t1.f1; f1 f2 f1 f2 -SET SESSION join_cache_level = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; # # Bug #707827: hash join on varchar column with NULLs @@ -5212,8 +5204,8 @@ SELECT a FROM t1,t2 WHERE t2.v = t1.v ; a 11 18 -SET SESSION join_cache_level = DEFAULT; -SET SESSION join_buffer_size = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; +SET SESSION join_buffer_size=@save_join_buffer_size; DROP TABLE t1,t2; # # Bug #802860: crash on join cache + derived + duplicate_weedout @@ -5248,8 +5240,8 @@ SELECT * FROM (SELECT DISTINCT * FROM t1) t WHERE t.a IN (SELECT t2.a FROM t2); a 0 -SET SESSION join_cache_level = DEFAULT; DROP TABLE t1, t2; +SET SESSION join_cache_level=@save_join_cache_level; # # Bug #887479: join_cache_level=3 + semijoin=on # @@ -5257,7 +5249,7 @@ CREATE TABLE t1 (a int, b int); INSERT INTO t1 VALUES (3914,17), (3710,5), (3888,20); CREATE TABLE t2 (c int, KEY (c)); INSERT INTO t2 VALUES (27), (17), (33), (20), (3), (7), (18), (2); -SET @tmp887479_optimizer_switch=@@optimizer_switch; +SET @tmp_optimizer_switch=@@optimizer_switch; SET SESSION optimizer_switch='semijoin=on'; SET SESSION optimizer_switch='semijoin_with_cache=on'; SET SESSION join_cache_level=1; @@ -5280,8 +5272,8 @@ SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); a b 3914 17 3888 20 -SET SESSION join_cache_level = DEFAULT; -SET optimizer_switch=@tmp887479_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@tmp_optimizer_switch; DROP TABLE t1,t2; # # Bug #899777: join_cache_level=4 + semijoin=on @@ -5327,8 +5319,8 @@ WHERE (t1.b,t2.b) IN (SELECT t3.b,t4.b FROM t3,t4 WHERE t4.c=t3.b) AND t1.a = 1; a b c 1 8 6 -SET SESSION join_cache_level = DEFAULT; -SET optimizer_switch=@tmp_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2,t3,t4; # # Bug #899509: an attempt to use hash join with join_cache_level=0 @@ -5339,11 +5331,9 @@ CREATE TABLE t2 (a int); INSERT INTO t2 VALUES (8), (7); CREATE TABLE t3 (a int); INSERT INTO t3 VALUES (8), (7); -SET @tmp_optimizer_switch=@@optimizer_switch; -set optimizer_switch=default; set @@optimizer_switch='semijoin_with_cache=off'; set @@optimizer_switch='outer_join_with_cache=off'; -SET optimizer_switch='derived_merge=off,derived_with_keys=off'; +set @@optimizer_switch='derived_merge=off,derived_with_keys=off'; SET join_cache_level=0; EXPLAIN SELECT * FROM (SELECT t1.* FROM t1, t2) t WHERE t.a IN (SELECT * FROM t3); @@ -5365,8 +5355,8 @@ a 8 7 7 -SET SESSION join_cache_level = DEFAULT; -SET optimizer_switch=@tmp_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2,t3; # # Bug #900469: semijoin + BNLH + ORDER BY @@ -5379,8 +5369,8 @@ INSERT INTO t2 VALUES (9,11); CREATE TABLE t3 (c int, d int); INSERT INTO t3 VALUES (8,10); INSERT INTO t3 VALUES (9,11); -SET @tmp_optimizer_switch=@@optimizer_switch; set @@optimizer_switch='semijoin_with_cache=on'; +set @@optimizer_switch='firstmatch=off'; SET join_cache_level=1; EXPLAIN SELECT * FROM t1,t2 WHERE b IN (SELECT d FROM t3 WHERE c <= t2.c) ORDER BY a,d; @@ -5414,8 +5404,8 @@ SELECT * FROM t1,t2 WHERE b IN (SELECT d FROM t3 WHERE c <= t2.c) ORDER BY a,d; a b c d 8 10 8 10 8 10 9 11 -SET SESSION join_cache_level = DEFAULT; -SET optimizer_switch=@tmp_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2,t3; # # Bug #901478: semijoin + ORDER BY + join_cache_level=4|6 @@ -5433,7 +5423,6 @@ INSERT INTO t4 VALUES INSERT INTO t4 VALUES (19,11,10), (17,12,18), (12,13,15), (14,12,19), (18,13,18), (13,14,11), (15,15,14); -SET @tmp_optimizer_switch=@@optimizer_switch; SET @@optimizer_switch='semijoin=on'; SET @@optimizer_switch='firstmatch=off'; SET @@optimizer_switch='mrr=off'; @@ -5493,8 +5482,8 @@ ORDER BY t2.b; a a b c x 4 2 9 x 5 5 4 -SET join_cache_level = DEFAULT; -SET optimizer_switch=@tmp_optimizer_switch; +set join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2,t3,t4; # # Bug#53305 Duplicate weedout + join buffer (join cache --level=7,8) @@ -5513,11 +5502,10 @@ insert into t3 values (1,1), (1,2), (1,3),(1,4), (2,5), (2,6), (2,7), (2,8), (3,1), (3,2), (3,9); -set @tmp_optimizer_switch=@@optimizer_switch; -set @@optimizer_switch='semijoin=on'; -set optimizer_switch='materialization=off'; -set optimizer_switch='loosescan=off,firstmatch=off'; -set optimizer_switch='mrr_sort_keys=off'; +set @@optimizer_switch='semijoin=on'; +set @@optimizer_switch='materialization=off'; +set @@optimizer_switch='loosescan=off,firstmatch=off'; +set @@optimizer_switch='mrr_sort_keys=off'; set join_cache_level=7; create table t4 (uid int primary key, name varchar(128), index(name)); insert into t4 values @@ -5546,8 +5534,8 @@ F G H I -set join_cache_level = default; -set optimizer_switch=@tmp_optimizer_switch; +set join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; drop table t1,t2,t3,t4; # # Bug#50358 - semijoin execution of subquery with outerjoin @@ -5559,9 +5547,8 @@ CREATE TABLE t3 (i int); INSERT INTO t1 VALUES (1), (2); INSERT INTO t2 VALUES (6); INSERT INTO t3 VALUES (1), (2); -set @tmp_optimizer_switch=@@optimizer_switch; -set @@optimizer_switch='semijoin=on'; -set optimizer_switch='materialization=on'; +set @@optimizer_switch='semijoin=on'; +set @@optimizer_switch='materialization=on'; set join_cache_level=0; EXPLAIN SELECT * FROM t1 WHERE t1.i IN @@ -5590,8 +5577,8 @@ SELECT * FROM t1 WHERE t1.i IN i 1 2 -set join_cache_level = default; -set optimizer_switch=@tmp_optimizer_switch; +set join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2,t3; # # Bug #12546542: missing row with semijoin=off + join cache @@ -5605,9 +5592,8 @@ a varchar(1024) CHARACTER SET utf8 DEFAULT NULL, b int, c int INSERT INTO t2 VALUES ('we',4,NULL), ('v',1305673728,6); CREATE TABLE t3 (b int, c int); INSERT INTO t3 VALUES (4,4); -set @tmp_optimizer_switch=@@optimizer_switch; -set optimizer_switch='semijoin=off'; -set optimizer_switch='materialization=off'; +set @@optimizer_switch='semijoin=off'; +set @@optimizer_switch='materialization=off'; set join_cache_level=0; EXPLAIN SELECT * FROM t1 @@ -5638,8 +5624,8 @@ WHERE t2.c < 10 OR t3.c > 1); a v we -set join_cache_level = default; -set optimizer_switch=@tmp_optimizer_switch; +set join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2,t3; # # lp:925985 LEFT JOIN with optimize_join_buffer_size=off + @@ -5654,12 +5640,11 @@ INSERT INTO t2 VALUES (3,32), (1,12), (7,72), (2,22); CREATE TABLE t3 (b int, c int); INSERT INTO t3 VALUES (32, 302), (42,400), (30,300); -set @tmp_optimizer_switch=@@optimizer_switch; -set optimizer_switch='optimize_join_buffer_size=off'; +set @@optimizer_switch='optimize_join_buffer_size=off'; +set @@optimizer_switch='outer_join_with_cache=on'; set join_buffer_space_limit=4096; set join_buffer_size=4096*2; set join_cache_level=2; -set optimizer_switch='outer_join_with_cache=on'; EXPLAIN SELECT * FROM t1, t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra @@ -5671,10 +5656,10 @@ a a b b c 3 3 30 30 300 3 3 31 NULL NULL 3 3 32 32 302 -set join_buffer_space_limit=default; -set join_buffer_size=default; -set join_cache_level=default; -set optimizer_switch=@tmp_optimizer_switch; +set join_buffer_space_limit=@save_join_buffer_space_limit; +set join_buffer_size=@save_join_buffer_size; +set join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2,t3; # # Bug #1058071: LEFT JOIN using blobs @@ -5707,8 +5692,7 @@ CREATE TABLE t2 (b int) ENGINE=Aria; INSERT INTO t2 VALUES (NULL); CREATE TABLE t3 (c int) ENGINE=Aria; INSERT INTO t3 VALUES (NULL); -set @tmp_optimizer_switch=@@optimizer_switch; -set optimizer_switch = 'outer_join_with_cache=on,join_cache_incremental=on'; +set @@optimizer_switch = 'outer_join_with_cache=on,join_cache_incremental=on'; set join_buffer_size=128; EXPLAIN SELECT 1 AS c FROM t1 NATURAL LEFT JOIN t2 LEFT OUTER JOIN t3 ON 1 @@ -5721,11 +5705,9 @@ SELECT 1 AS c FROM t1 NATURAL LEFT JOIN t2 LEFT OUTER JOIN t3 ON 1 GROUP BY elt(t1.col282,1,t1.col280); c 1 -set join_buffer_size=default; -set optimizer_switch=@tmp_optimizer_switch; DROP table t1,t2,t3; -set join_buffer_size= default; -set @@optimizer_switch=@save_optimizer_switch; +set join_buffer_size=@save_join_buffer_size; +set @@optimizer_switch=@org_optimizer_switch,@local_optimizer_switch= @org_optimizer_switch; # # MDEV-5293: outer join, join buffering, and order by - invalid query plan # @@ -5896,8 +5878,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE c25 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE c26 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE c27 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (incremental, BNL join) -set join_buffer_size=default; -set join_cache_level = default; +set join_buffer_size=@save_join_buffer_size; +set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; # # MDEV-14960: BNLH used for materialized semi-join @@ -5915,11 +5897,10 @@ INSERT INTO t1 SELECT i1+64 FROM t1; INSERT INTO t2 SELECT * FROM t1; INSERT INTO t4 SELECT * FROM t1; INSERT INTO t5 SELECT * FROM t1; -set @save_optimizer_switch= @@optimizer_switch; SET join_cache_level = 6; SET join_buffer_size=4096; SET join_buffer_space_limit=4096; -SET optimizer_switch = 'join_cache_hashed=on,optimize_join_buffer_size=on'; +set @@optimizer_switch = 'join_cache_hashed=on,optimize_join_buffer_size=on'; EXPLAIN SELECT * FROM t1 WHERE i1 < 10 AND @@ -5952,10 +5933,10 @@ i1 7 8 9 -SET join_cache_level = default; -SET join_buffer_size = default; -SET join_buffer_space_limit= default; -set optimizer_switch=@save_optimizer_switch; +set join_cache_level=@save_join_cache_level; +SET join_buffer_size=@save_join_buffer_size; +SET join_buffer_space_limit=@save_join_buffer_space_limit; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t4,t5,t2; # # MDEV-16603: BNLH for query with materialized semi-join @@ -5989,11 +5970,10 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select `test`.`temp`.`f1` AS `f1`,`test`.`temp`.`f2` AS `f2` from `test`.`temp` semi join (`test`.`t2` join `test`.`t1`) where `test`.`temp`.`f1` = `test`.`t1`.`i1` and `test`.`t2`.`v1` = `test`.`t1`.`v1` and `test`.`temp`.`f2` = `test`.`t1`.`v1` DROP TABLE t1,t2,temp; -SET join_cache_level = default; +set join_cache_level=@save_join_cache_level; # # MDEV-5123 Remove duplicated conditions pushed both to join_tab->select_cond and join_tab->cache_select->cond for blocked joins. # -set join_cache_level=default; set expensive_subquery_limit=0; create table t1 (c1 int); create table t2 (c2 int); @@ -6036,7 +6016,7 @@ select @counter; @counter 2 drop table t1,t2,t3; -set expensive_subquery_limit=default; +set expensive_subquery_limit=@save_expensive_subquery_limit; # # MDEV-6071: EXPLAIN chooses to use join buffer while execution turns it down # @@ -6048,17 +6028,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 11 1 SIMPLE t2 ALL NULL NULL NULL NULL 11 Using where; Using join buffer (flat, BNL join) set join_buffer_space_limit=1024*8; -select @@join_buffer_space_limit; -@@join_buffer_space_limit -8192 -select @@join_buffer_size; -@@join_buffer_size -262144 explain select count(*) from t1, t1 t2 where t1.a=t2.a; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 11 1 SIMPLE t2 ALL NULL NULL NULL NULL 11 Using where -set join_buffer_space_limit=default; +set join_buffer_space_limit=@save_join_buffer_space_limit; drop table t1; # # MDEV-6687: Assertion `0' failed in Protocol::end_statement on query @@ -6072,7 +6046,7 @@ SELECT * FROM INFORMATION_SCHEMA.PROFILING, mysql.user WHERE password_expired = id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE PROFILING ALL NULL NULL NULL NULL NULL Using where 1 SIMPLE user hash_ALL NULL #hash#$hj 1 information_schema.PROFILING.PAGE_FAULTS_MINOR 4 Using where; Using join buffer (flat, BNLH join) -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; create table t1 (c1 date not null, key (c1)) engine=innodb; insert t1 values ('2017-12-27'); create table t2 (pk int, f1 int, f2 int); @@ -6081,5 +6055,5 @@ set join_buffer_size = 222222208; select f2 from t2,t1 where f2 = 0; f2 drop table t1, t2; -set join_buffer_size = default; +set join_buffer_size=@save_join_buffer_size; set @@optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/main/join_cache.test b/mysql-test/main/join_cache.test index ba5afafcf8b..9576d598125 100644 --- a/mysql-test/main/join_cache.test +++ b/mysql-test/main/join_cache.test @@ -2,15 +2,22 @@ DROP TABLE IF EXISTS t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11; DROP DATABASE IF EXISTS world; --enable_warnings +--source include/default_optimizer_switch.inc +--source include/default_charset.inc + +set @org_optimizer_switch=@@optimizer_switch; +set @save_join_cache_level=@@join_cache_level; +set @save_join_buffer_space_limit=@@join_buffer_space_limit; +set @save_join_buffer_size=@@join_buffer_size; +set @save_expensive_subquery_limit=@@expensive_subquery_limit; -set @save_optimizer_switch=@@optimizer_switch; set @@optimizer_switch='optimize_join_buffer_size=on'; -set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on'; +set @@optimizer_switch='semijoin=on,firstmatch=on,loosescan=on'; set @@optimizer_switch='semijoin_with_cache=on'; set @@optimizer_switch='outer_join_with_cache=on'; -set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +set @@optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +set @local_optimizer_switch=@@optimizer_switch; -set @local_join_cache_test_optimizer_switch_default=@@optimizer_switch; set names utf8; CREATE DATABASE world; @@ -318,11 +325,8 @@ SELECT City.Name, Country.Name, CountryLanguage.Language CountryLanguage.Percentage > 50 AND LENGTH(Language) < LENGTH(City.Name) - 2; -set join_cache_level=default; -set join_buffer_size=default; - -show variables like 'join_buffer_size'; -show variables like 'join_cache_level'; +set join_cache_level=@save_join_cache_level; +set join_buffer_size=@save_join_buffer_size; DROP DATABASE world; @@ -911,11 +915,8 @@ SELECT Name FROM City WHERE City.Country IN (SELECT Code FROM Country WHERE Country.Name LIKE 'L%') AND City.Population > 100000; -set join_cache_level=default; -set join_buffer_size=default; - -show variables like 'join_buffer_size'; -show variables like 'join_cache_level'; +set join_cache_level=@save_join_cache_level; +set join_buffer_size=@save_join_buffer_size; set join_cache_level=1; @@ -934,7 +935,7 @@ SELECT City.Name, Country.Name FROM City,Country SELECT City.Name, Country.Name FROM City,Country WHERE City.Country=Country.Code AND City.Population > 3000000; -set join_buffer_size=default; +set join_buffer_size=@save_join_buffer_size; set join_cache_level=6; @@ -964,8 +965,8 @@ SELECT City.Name, Country.Name, Country.PopulationBar FROM City,Country WHERE City.Country=Country.Code AND Country.Name LIKE 'L%' AND City.Population > 100000; -set join_cache_level=default; -set join_buffer_size=default; +set join_cache_level=@save_join_cache_level; +set join_buffer_size=@save_join_buffer_size; --echo # @@ -999,7 +1000,7 @@ SELECT Country.Name, Country.Population, City.Name, City.Population WHERE Country.Name LIKE 'C%' AND Country.Population > 10000000; set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; set @@use_stat_tables=@save_use_stat_tables; -set join_cache_level=default; +set @@join_cache_level=@save_join_cache_level; DROP DATABASE world; @@ -1272,8 +1273,8 @@ DROP TABLE t1,t2; --echo # Bug #40134: outer join with not exists optimization and join buffer --echo # -set join_cache_level=default; -set join_buffer_size=default; +set join_cache_level=@save_join_cache_level; +set join_buffer_size=@save_join_buffer_size; CREATE TABLE t1 (a int NOT NULL); INSERT INTO t1 VALUES (2), (4), (3), (5), (1); @@ -1292,8 +1293,8 @@ SELECT * FROM t1 LEFT JOIN t2 ON t1.a=t2.a WHERE t2.b IS NULL; DROP TABLE t1, t2; -set join_cache_level=default; -set join_buffer_size=default; +set join_cache_level=@save_join_cache_level; +set join_buffer_size=@save_join_buffer_size; --echo # --echo # BUG#40136: Group by is ignored when join buffer is used for an outer join @@ -1335,7 +1336,7 @@ SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b FROM t2 LEFT JOIN (t3, t4) ON t2.b=t4.b WHERE t3.a+2<t2.a OR t3.c IS NULL; -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; DROP TABLE t2, t3, t4; --echo # @@ -1353,7 +1354,7 @@ select * from t1 left join t2 on t1.a=t2.a; explain select * from t1 left join t2 on t1.a=t2.a where t2.c=102 or t2.c is null; select * from t1 left join t2 on t1.a=t2.a where t2.c=102 or t2.c is null; -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; drop table t1, t2; --echo # @@ -1374,7 +1375,7 @@ select * from t1 left join t2 on (1=0) where a=40; set join_cache_level=0; explain select * from t1 left join t2 on (1=0); -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; drop table t1, t2; --echo # @@ -1418,8 +1419,8 @@ set join_buffer_size=1024; EXPLAIN SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; SELECT AVG(c) FROM t1,t2 WHERE t1.a=t2.b; -set join_buffer_size=default; -set join_cache_level=default; +set join_buffer_size=@save_join_buffer_size; +set join_cache_level=@save_join_cache_level; DROP TABLE t1, t2; @@ -1465,8 +1466,8 @@ SELECT COUNT(*) FROM t1,t2,t3 WHERE t1.a=t2.a AND t2.a=t3.a AND t1.b IS NULL AND t2.b IS NULL AND t3.b IS NULL; -set join_buffer_size=default; -set join_cache_level=default; +set join_buffer_size=@save_join_buffer_size; +set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3; @@ -1536,8 +1537,8 @@ SELECT t1.a, t2.a, t3.a, t2.b, t3.b, t3.val FROM (t1,t2) LEFT JOIN t3 ON (t1.a=t3.a AND t2.b=t3.b) WHERE t1.a=t2.a; -set join_buffer_size=default; -set join_cache_level=default; +set join_buffer_size=@save_join_buffer_size; +set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3; @@ -1594,7 +1595,7 @@ where t1.f1=t2.f1 and t2.f2 between t1.f1 and t2.f2; show status like "Handler_icp%"; drop table t1,t2; -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; --echo # --echo # Bug #42955: join with GROUP BY/ORDER BY and when BKA is enabled @@ -1628,7 +1629,7 @@ select t1.id1 from t1 join t2 on t1.id1=t2.id1 select t1.id1 from t1 join t2 on t1.id1=t2.id1 where t1.d=3 and t2.id2 > 200 order by t1.id1; -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; drop table t1,t2; @@ -1692,7 +1693,7 @@ select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4 select t1.a, t1.b, t1.c, t1.d, t2.e, t3.f, t4.g from t1,t2,t3,t4 where t2.b=t1.b and t3.d=t1.d and t4.c=t1.c; -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; drop table t1,t2,t3,t4; @@ -2081,8 +2082,8 @@ SELECT STRAIGHT_JOIN t1.id1, t1.num3, t3.text1, t3.id4, t2.id3, t4.dummy WHERE t1.id1=t5.id1 AND t1.id2=t5.id2 and t4.id2=t1.id2 AND t5.enum2='Active' AND t3.id4=t2.id4 AND t2.id3=t1.id3 AND t3.text1<'D'; -set join_buffer_size=default; -set join_cache_level=default; +set join_buffer_size=@save_join_buffer_size; +set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4,t5; @@ -2153,7 +2154,7 @@ ORDER BY t1.int_key; DROP TABLE t1,t2; -SET join_cache_level=default; +SET join_cache_level=@save_join_cache_level; --echo # --echo # Regression test for @@ -2216,7 +2217,7 @@ set join_cache_level=6; SELECT t1.*, t2.*, LENGTH(t2.c1), LENGTH(t2.c2) FROM t1,t2 WHERE t1.c2=LENGTH(t2.c2) and t1.c1=LENGTH(t2.c1); -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; @@ -2242,7 +2243,7 @@ set join_cache_level=2; explain select t1.* from t1,t2,t3; select t1.* from t1,t2,t3; -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; drop table t1,t2,t3; @@ -2271,7 +2272,7 @@ SELECT t3.a FROM t1,t2,t3 WHERE t1.a = t3.a AND t1.b = t3.b; DROP TABLE t1,t2,t3; -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; --echo # --echo # Bug #51084: Batched key access crashes for SELECT with @@ -2313,7 +2314,7 @@ SELECT COUNT(*) FROM (t2 JOIN t1) LEFT JOIN (t3 JOIN t4 ON t3.id = t4.carrier_id) ON t3.carrier = t1.carrier; -SET join_cache_level=default; +SET join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4; @@ -2367,7 +2368,7 @@ explain SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; --sorted_result SELECT t2.a FROM t1 LEFT JOIN t2 ON t2.b = t1.b; -set join_cache_level = default; +set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; --echo # @@ -2395,7 +2396,7 @@ SELECT t.a FROM t1 t, t1 s FORCE INDEX(idx) SELECT t.a FROM t1 t, t1 s FORCE INDEX(idx) WHERE s.pk AND s.a >= t.pk AND s.b = t.c; -set join_cache_level = default; +set join_cache_level=@save_join_cache_level; DROP TABLE t1; --echo # @@ -2426,7 +2427,7 @@ SELECT t1.a FROM t1 LEFT JOIN (t2 LEFT JOIN (t3 LEFT JOIN t4 ON 1) ON t2.a) ON 0 WHERE t1.a OR t4.a; -set join_cache_level = default; +set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4; --echo # @@ -2484,8 +2485,8 @@ SELECT t1.i, t1.d, t1.v, t2.i, t2.d, t2.t, t2.v FROM t1,t2,t3 DROP TABLE t1,t2,t3; -SET SESSION join_cache_level=DEFAULT; -SET SESSION join_buffer_size=DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; +SET SESSION join_buffer_size=@save_join_buffer_size; --echo # @@ -2593,7 +2594,7 @@ WHERE t2.v <> t3.v AND t3.pk = t2.i AND t1.v = t3.v AND t1.pk*2<100 DROP TABLE t1,t2,t3; -SET SESSION join_cache_level=DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; --echo # --echo # Bug #668290: hash join with non-binary collations @@ -2634,7 +2635,7 @@ EXPLAIN SELECT t2.i FROM t1,t2 WHERE t1.cu = t2.cl ; SELECT t2.i FROM t1,t2 WHERE t1.cu = t2.cl ; -SET SESSION join_cache_level = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; @@ -2662,8 +2663,8 @@ EXPLAIN SELECT t1.a, t2.c FROM t1,t2 WHERE t1.a=t2.a AND t2.b=99; SELECT t1.a, t2.c FROM t1,t2 WHERE t1.a=t2.a AND t2.b=99; -SET SESSION join_cache_level = DEFAULT; -SET SESSION join_buffer_size = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; +SET SESSION join_buffer_size=@save_join_buffer_size; DROP TABLE t1,t2; @@ -2712,7 +2713,7 @@ EXPLAIN SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = concat(t1.v, t1.v); SELECT t1.v,t2.i FROM t1,t2 WHERE t2.v = concat(t1.v, t1.v); -SET SESSION join_cache_level = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; @@ -2785,8 +2786,8 @@ SELECT t3.i FROM t1,t2,t3 SELECT t3.i FROM t1,t2,t3 WHERE t1.v = t2.v AND t3.v = t1.v AND t2.i <> 0; -SET SESSION join_cache_level = DEFAULT; -SET SESSION join_buffer_size = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; +SET SESSION join_buffer_size=@save_join_buffer_size; DROP TABLE t1,t2,t3; @@ -2822,7 +2823,7 @@ EXPLAIN SELECT * FROM t1,t2 WHERE t2.a=t1.a; SELECT * FROM t1,t2 WHERE t2.a=t1.a; -SET SESSION join_cache_level = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; @@ -2844,8 +2845,8 @@ SELECT t3.a (t2 LEFT OUTER JOIN t3 ON t2.b = t3.b) ON t2.a = t1.b WHERE t3.a BETWEEN 3 AND 11 OR t1.a <= t2.c; -SET SESSION optimizer_switch = 'outer_join_with_cache=off'; -SET SESSION join_cache_level = DEFAULT; +SET SESSION optimizer_switch=@local_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3; @@ -2868,8 +2869,8 @@ SELECT * FROM t2 LEFT JOIN ((t1 JOIN t3 ON t1.a = t3.pk) LEFT JOIN t4 ON 1) ON 1; -SET SESSION optimizer_switch = 'outer_join_with_cache=off'; -SET SESSION join_cache_level = DEFAULT; +SET SESSION optimizer_switch=@local_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4; @@ -2895,8 +2896,8 @@ EXPLAIN SELECT * FROM t2 LEFT JOIN t1 ON t2.a <> 0 WHERE t1.a <> 0 OR t2.pk < 9; SELECT * FROM t2 LEFT JOIN t1 ON t2.a <> 0 WHERE t1.a <> 0 OR t2.pk < 9; -SET SESSION optimizer_switch = 'outer_join_with_cache=off'; -SET SESSION join_cache_level = DEFAULT; +SET SESSION optimizer_switch=@local_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; @@ -2955,8 +2956,8 @@ SELECT * FROM ((t1 LEFT JOIN (t2 JOIN t3 ON t2.c2 = t3.a3) ON t1.pk = t2.d2) LEFT JOIN t4 ON t1.a1 = t4.a4) LEFT JOIN t5 ON t3.a3 = t5.a5; -SET SESSION optimizer_switch = 'outer_join_with_cache=off'; -SET SESSION join_cache_level = DEFAULT; +SET SESSION optimizer_switch=@local_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4,t5; @@ -3001,8 +3002,8 @@ SELECT * FROM ((t2 JOIN t3 ON t2.a2 = t3.b3) JOIN t4 ON t4.b4 <> 0) ON t1.c1 = t3.c3 WHERE t3.a3 IS NULL; -SET SESSION optimizer_switch = 'outer_join_with_cache=off'; -SET SESSION join_cache_level = DEFAULT; +SET SESSION optimizer_switch=@local_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4; @@ -3031,8 +3032,8 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 JOIN t3 ON t3.a3 = t2.a2 ON t3.b3 <> 0; SELECT * FROM t1 LEFT JOIN t2 JOIN t3 ON t3.a3 = t2.a2 ON t3.b3 <> 0; -SET SESSION optimizer_switch = 'outer_join_with_cache=off'; -SET SESSION join_cache_level = DEFAULT; +SET SESSION optimizer_switch=@local_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3; @@ -3076,8 +3077,8 @@ SELECT t4.a4, t5.b5 FROM ((t1 LEFT JOIN (t2 JOIN t3 ON t2.a2 = t3.a3) ON t2.b2 = t1.a1) LEFT JOIN t4 ON t4.a4 <> 0) LEFT JOIN t5 ON t5.a5 = t2.a2; -SET SESSION optimizer_switch = 'outer_join_with_cache=off'; -SET SESSION join_cache_level = DEFAULT; +SET SESSION optimizer_switch=@local_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2,t3,t4,t5; @@ -3104,7 +3105,7 @@ EXPLAIN SELECT * FROM t1,t2 WHERE t1.a=t2.a; SELECT * FROM t1,t2 WHERE t1.a=t2.a; -SET SESSION join_cache_level = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; @@ -3138,8 +3139,8 @@ SELECT * FROM t1,t2 SELECT * FROM t1,t2 WHERE t1.f1 = t2.f4 AND (t1.f3 = 1 AND t2.f3 = 4 OR t1.f3 = 2 AND t2.f3 = 6); -SET SESSION join_cache_level = DEFAULT; -SET SESSION optimizer_switch = @local_join_cache_test_optimizer_switch_default; +SET SESSION join_cache_level=@save_join_cache_level; +SET SESSION optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2; @@ -3165,7 +3166,7 @@ EXPLAIN SELECT * FROM t1,t2 WHERE t2.f3 = t1.f2 AND t1.f1 IN (9, 0, 100) ORDER BY t1.f2 LIMIT 1; SELECT * FROM t1,t2 WHERE t2.f3 = t1.f2 AND t1.f1 IN (9, 0 ,100) ORDER BY t1.f2 LIMIT 1; -SET SESSION optimizer_switch = @local_join_cache_test_optimizer_switch_default; +SET SESSION optimizer_switch=@local_optimizer_switch; SET SESSION optimizer_switch = 'index_condition_pushdown=on'; EXPLAIN SELECT * FROM t1,t2 @@ -3173,7 +3174,7 @@ EXPLAIN SELECT * FROM t1,t2 SELECT * FROM t1,t2 WHERE t2.f3 = t1.f2 AND t1.f1 IN (9, 0 ,100) ORDER BY t1.f2 LIMIT 1; -SET SESSION optimizer_switch = @local_join_cache_test_optimizer_switch_default; +SET SESSION optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2; @@ -3202,8 +3203,7 @@ EXPLAIN SELECT * FROM t1,t2 WHERE t1.a < 3 and t2.a IS NULL; SELECT * FROM t1,t2 WHERE t1.a < 3 and t2.a IS NULL; - -SET SESSION join_cache_level = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; @@ -3229,7 +3229,7 @@ EXPLAIN SELECT * FROM t1,t2 WHERE t2.f1 = t1.f1; SELECT * FROM t1,t2 WHERE t2.f1 = t1.f1; -SET SESSION join_cache_level = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; @@ -3259,8 +3259,8 @@ EXPLAIN SELECT a FROM t1,t2 WHERE t2.v = t1.v ; SELECT a FROM t1,t2 WHERE t2.v = t1.v ; -SET SESSION join_cache_level = DEFAULT; -SET SESSION join_buffer_size = DEFAULT; +SET SESSION join_cache_level=@save_join_cache_level; +SET SESSION join_buffer_size=@save_join_buffer_size; DROP TABLE t1,t2; @@ -3293,10 +3293,12 @@ SELECT * FROM (SELECT DISTINCT * FROM t1) t SELECT * FROM (SELECT DISTINCT * FROM t1) t WHERE t.a IN (SELECT t2.a FROM t2); -SET SESSION join_cache_level = DEFAULT; - DROP TABLE t1, t2; +SET SESSION join_cache_level=@save_join_cache_level; + +# Note that next tests are run with same optimizer_switch as previous one! + --echo # --echo # Bug #887479: join_cache_level=3 + semijoin=on --echo # @@ -3307,7 +3309,7 @@ INSERT INTO t1 VALUES (3914,17), (3710,5), (3888,20); CREATE TABLE t2 (c int, KEY (c)); INSERT INTO t2 VALUES (27), (17), (33), (20), (3), (7), (18), (2); -SET @tmp887479_optimizer_switch=@@optimizer_switch; +SET @tmp_optimizer_switch=@@optimizer_switch; SET SESSION optimizer_switch='semijoin=on'; SET SESSION optimizer_switch='semijoin_with_cache=on'; @@ -3321,8 +3323,8 @@ EXPLAIN SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); SELECT * FROM t1 WHERE (t1.b) IN (SELECT c FROM t2); -SET SESSION join_cache_level = DEFAULT; -SET optimizer_switch=@tmp887479_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@tmp_optimizer_switch; DROP TABLE t1,t2; @@ -3361,8 +3363,8 @@ SELECT t1.* FROM t1,t2 WHERE (t1.b,t2.b) IN (SELECT t3.b,t4.b FROM t3,t4 WHERE t4.c=t3.b) AND t1.a = 1; -SET SESSION join_cache_level = DEFAULT; -SET optimizer_switch=@tmp_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2,t3,t4; @@ -3377,11 +3379,9 @@ INSERT INTO t2 VALUES (8), (7); CREATE TABLE t3 (a int); INSERT INTO t3 VALUES (8), (7); -SET @tmp_optimizer_switch=@@optimizer_switch; -set optimizer_switch=default; set @@optimizer_switch='semijoin_with_cache=off'; set @@optimizer_switch='outer_join_with_cache=off'; -SET optimizer_switch='derived_merge=off,derived_with_keys=off'; +set @@optimizer_switch='derived_merge=off,derived_with_keys=off'; SET join_cache_level=0; EXPLAIN @@ -3390,8 +3390,8 @@ SELECT * FROM (SELECT t1.* FROM t1, t2) t WHERE t.a IN (SELECT * FROM t3); SELECT * FROM ( SELECT ta.* FROM t1 AS ta, t1 ) tb WHERE a IN ( SELECT * FROM t1 ); -SET SESSION join_cache_level = DEFAULT; -SET optimizer_switch=@tmp_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2,t3; @@ -3410,8 +3410,8 @@ CREATE TABLE t3 (c int, d int); INSERT INTO t3 VALUES (8,10); INSERT INTO t3 VALUES (9,11); -SET @tmp_optimizer_switch=@@optimizer_switch; set @@optimizer_switch='semijoin_with_cache=on'; +set @@optimizer_switch='firstmatch=off'; SET join_cache_level=1; EXPLAIN @@ -3428,8 +3428,8 @@ EXPLAIN SELECT * FROM t1,t2 WHERE b IN (SELECT d FROM t3 WHERE c <= t2.c) ORDER BY a,d; SELECT * FROM t1,t2 WHERE b IN (SELECT d FROM t3 WHERE c <= t2.c) ORDER BY a,d; -SET SESSION join_cache_level = DEFAULT; -SET optimizer_switch=@tmp_optimizer_switch; +SET SESSION join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2,t3; @@ -3451,7 +3451,6 @@ INSERT INTO t4 VALUES (19,11,10), (17,12,18), (12,13,15), (14,12,19), (18,13,18), (13,14,11), (15,15,14); -SET @tmp_optimizer_switch=@@optimizer_switch; SET @@optimizer_switch='semijoin=on'; SET @@optimizer_switch='firstmatch=off'; SET @@optimizer_switch='mrr=off'; @@ -3491,8 +3490,8 @@ SELECT * FROM t1,t2 t2.a BETWEEN 4 and 5 ORDER BY t2.b; -SET join_cache_level = DEFAULT; -SET optimizer_switch=@tmp_optimizer_switch; +set join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2,t3,t4; @@ -3517,11 +3516,10 @@ insert into t3 values (2,5), (2,6), (2,7), (2,8), (3,1), (3,2), (3,9); -set @tmp_optimizer_switch=@@optimizer_switch; -set @@optimizer_switch='semijoin=on'; -set optimizer_switch='materialization=off'; -set optimizer_switch='loosescan=off,firstmatch=off'; -set optimizer_switch='mrr_sort_keys=off'; +set @@optimizer_switch='semijoin=on'; +set @@optimizer_switch='materialization=off'; +set @@optimizer_switch='loosescan=off,firstmatch=off'; +set @@optimizer_switch='mrr_sort_keys=off'; set join_cache_level=7; create table t4 (uid int primary key, name varchar(128), index(name)); @@ -3538,8 +3536,8 @@ select name from t2, t1 where t1.uid in (select t4.uid from t4, t3 where t3.uid=1 and t4.uid=t3.fid) and t2.uid=t1.fid; -set join_cache_level = default; -set optimizer_switch=@tmp_optimizer_switch; +set join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; drop table t1,t2,t3,t4; @@ -3555,9 +3553,8 @@ INSERT INTO t1 VALUES (1), (2); INSERT INTO t2 VALUES (6); INSERT INTO t3 VALUES (1), (2); -set @tmp_optimizer_switch=@@optimizer_switch; -set @@optimizer_switch='semijoin=on'; -set optimizer_switch='materialization=on'; +set @@optimizer_switch='semijoin=on'; +set @@optimizer_switch='materialization=on'; set join_cache_level=0; EXPLAIN @@ -3573,8 +3570,8 @@ SELECT * FROM t1 WHERE t1.i IN SELECT * FROM t1 WHERE t1.i IN (SELECT t3.i FROM t3 LEFT JOIN t2 ON t2.i=t3.i); -set join_cache_level = default; -set optimizer_switch=@tmp_optimizer_switch; +set join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2,t3; @@ -3592,9 +3589,8 @@ INSERT INTO t2 VALUES ('we',4,NULL), ('v',1305673728,6); CREATE TABLE t3 (b int, c int); INSERT INTO t3 VALUES (4,4); -set @tmp_optimizer_switch=@@optimizer_switch; -set optimizer_switch='semijoin=off'; -set optimizer_switch='materialization=off'; +set @@optimizer_switch='semijoin=off'; +set @@optimizer_switch='materialization=off'; set join_cache_level=0; EXPLAIN @@ -3615,8 +3611,8 @@ SELECT * FROM t1 WHERE a IN (SELECT t2.a FROM t2 LEFT JOIN t3 ON t2.b = t3.b WHERE t2.c < 10 OR t3.c > 1); -set join_cache_level = default; -set optimizer_switch=@tmp_optimizer_switch; +set join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2,t3; @@ -3637,21 +3633,20 @@ INSERT INTO t2 VALUES CREATE TABLE t3 (b int, c int); INSERT INTO t3 VALUES (32, 302), (42,400), (30,300); -set @tmp_optimizer_switch=@@optimizer_switch; -set optimizer_switch='optimize_join_buffer_size=off'; +set @@optimizer_switch='optimize_join_buffer_size=off'; +set @@optimizer_switch='outer_join_with_cache=on'; set join_buffer_space_limit=4096; set join_buffer_size=4096*2; set join_cache_level=2; -set optimizer_switch='outer_join_with_cache=on'; EXPLAIN SELECT * FROM t1, t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t1.a=t2.a; SELECT * FROM t1, t2 LEFT JOIN t3 ON t2.b=t3.b WHERE t1.a=t2.a; -set join_buffer_space_limit=default; -set join_buffer_size=default; -set join_cache_level=default; -set optimizer_switch=@tmp_optimizer_switch; +set join_buffer_space_limit=@save_join_buffer_space_limit; +set join_buffer_size=@save_join_buffer_size; +set join_cache_level=@save_join_cache_level; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2,t3; @@ -3688,8 +3683,7 @@ INSERT INTO t2 VALUES (NULL); CREATE TABLE t3 (c int) ENGINE=Aria; INSERT INTO t3 VALUES (NULL); -set @tmp_optimizer_switch=@@optimizer_switch; -set optimizer_switch = 'outer_join_with_cache=on,join_cache_incremental=on'; +set @@optimizer_switch = 'outer_join_with_cache=on,join_cache_incremental=on'; set join_buffer_size=128; EXPLAIN @@ -3699,12 +3693,14 @@ SELECT 1 AS c FROM t1 NATURAL LEFT JOIN t2 LEFT OUTER JOIN t3 ON 1 SELECT 1 AS c FROM t1 NATURAL LEFT JOIN t2 LEFT OUTER JOIN t3 ON 1 GROUP BY elt(t1.col282,1,t1.col280); -set join_buffer_size=default; -set optimizer_switch=@tmp_optimizer_switch; - DROP table t1,t2,t3; -set join_buffer_size= default; -set @@optimizer_switch=@save_optimizer_switch; +set join_buffer_size=@save_join_buffer_size; + +# +# --echo switch to use orginal test suite optimizer switch +# + +set @@optimizer_switch=@org_optimizer_switch,@local_optimizer_switch= @org_optimizer_switch; --echo # @@ -3853,8 +3849,8 @@ FROM ORDER BY col1; -set join_buffer_size=default; -set join_cache_level = default; +set join_buffer_size=@save_join_buffer_size; +set join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; @@ -3877,11 +3873,10 @@ INSERT INTO t2 SELECT * FROM t1; INSERT INTO t4 SELECT * FROM t1; INSERT INTO t5 SELECT * FROM t1; -set @save_optimizer_switch= @@optimizer_switch; SET join_cache_level = 6; SET join_buffer_size=4096; SET join_buffer_space_limit=4096; -SET optimizer_switch = 'join_cache_hashed=on,optimize_join_buffer_size=on'; +set @@optimizer_switch = 'join_cache_hashed=on,optimize_join_buffer_size=on'; let $q= SELECT * FROM t1 @@ -3896,10 +3891,10 @@ WHERE eval EXPLAIN $q; eval $q; -SET join_cache_level = default; -SET join_buffer_size = default; -SET join_buffer_space_limit= default; -set optimizer_switch=@save_optimizer_switch; +set join_cache_level=@save_join_cache_level; +SET join_buffer_size=@save_join_buffer_size; +SET join_buffer_space_limit=@save_join_buffer_space_limit; +set @@optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t4,t5,t2; @@ -3932,13 +3927,12 @@ eval EXPLAIN EXTENDED $q; DROP TABLE t1,t2,temp; -SET join_cache_level = default; +set join_cache_level=@save_join_cache_level; --echo # --echo # MDEV-5123 Remove duplicated conditions pushed both to join_tab->select_cond and join_tab->cache_select->cond for blocked joins. --echo # -set join_cache_level=default; set expensive_subquery_limit=0; create table t1 (c1 int); @@ -3976,7 +3970,7 @@ where c1 = c2-0 and select @counter; drop table t1,t2,t3; -set expensive_subquery_limit=default; +set expensive_subquery_limit=@save_expensive_subquery_limit; --echo # --echo # MDEV-6071: EXPLAIN chooses to use join buffer while execution turns it down @@ -3989,12 +3983,10 @@ insert into t1 values explain select count(*) from t1, t1 t2 where t1.a=t2.a; set join_buffer_space_limit=1024*8; -select @@join_buffer_space_limit; -select @@join_buffer_size; explain select count(*) from t1, t1 t2 where t1.a=t2.a; -set join_buffer_space_limit=default; +set join_buffer_space_limit=@save_join_buffer_space_limit; drop table t1; @@ -4008,7 +4000,7 @@ SET join_cache_level = 3; explain SELECT * FROM INFORMATION_SCHEMA.PROFILING, mysql.user WHERE password_expired = PAGE_FAULTS_MINOR; -set join_cache_level=default; +set join_cache_level=@save_join_cache_level; # # MDEV-12580 Wrong query result in join when using an index (Version > "10.2.3") @@ -4020,7 +4012,7 @@ insert t2 values (4,1,1), (6,1,1); set join_buffer_size = 222222208; select f2 from t2,t1 where f2 = 0; drop table t1, t2; -set join_buffer_size = default; +set join_buffer_size=@save_join_buffer_size; -# The following command must be the last one the file +# The following command must be the last one in the file set @@optimizer_switch=@save_optimizer_switch; diff --git a/mysql-test/main/join_nested_jcl6.result b/mysql-test/main/join_nested_jcl6.result index 516107aeacb..541cd47bf04 100644 --- a/mysql-test/main/join_nested_jcl6.result +++ b/mysql-test/main/join_nested_jcl6.result @@ -4,9 +4,7 @@ set @@optimizer_switch='semijoin_with_cache=on'; set @@optimizer_switch='outer_join_with_cache=on'; set @@optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; set join_cache_level=6; -show variables like 'join_cache_level'; -Variable_name Value -join_cache_level 6 +set optimizer_search_depth=62; set @optimizer_switch_for_join_nested_test=@@optimizer_switch; set @join_cache_level_for_join_nested_test=@@join_cache_level; DROP TABLE IF EXISTS t0,t1,t2,t3,t4,t5,t6,t7,t8,t9; @@ -2116,9 +2114,6 @@ a b a b a b a b 3 2 NULL NULL NULL NULL NULL NULL DROP TABLE t5,t6,t7,t8; set join_cache_level=default; -show variables like 'join_cache_level'; -Variable_name Value -join_cache_level 2 set @@optimizer_switch=@save_optimizer_switch_jcl6; set @optimizer_switch_for_join_nested_test=NULL; set @join_cache_level_for_join_nested_test=NULL; diff --git a/mysql-test/main/join_nested_jcl6.test b/mysql-test/main/join_nested_jcl6.test index 838427e85e6..504510ff055 100644 --- a/mysql-test/main/join_nested_jcl6.test +++ b/mysql-test/main/join_nested_jcl6.test @@ -9,7 +9,7 @@ set @@optimizer_switch='outer_join_with_cache=on'; set @@optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; set join_cache_level=6; -show variables like 'join_cache_level'; +set optimizer_search_depth=62; set @optimizer_switch_for_join_nested_test=@@optimizer_switch; set @join_cache_level_for_join_nested_test=@@join_cache_level; @@ -104,7 +104,6 @@ SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b DROP TABLE t5,t6,t7,t8; set join_cache_level=default; -show variables like 'join_cache_level'; set @@optimizer_switch=@save_optimizer_switch_jcl6; set @optimizer_switch_for_join_nested_test=NULL; diff --git a/mysql-test/main/join_outer.result b/mysql-test/main/join_outer.result index b02dcb963db..7a230ccd15a 100644 --- a/mysql-test/main/join_outer.result +++ b/mysql-test/main/join_outer.result @@ -1,5 +1,5 @@ drop table if exists t0,t1,t2,t3,t4,t5; -SET @save_optimizer_switch=@@optimizer_switch; +SET @org_optimizer_switch=@@optimizer_switch; SET optimizer_switch=ifnull(@optimizer_switch_for_join_outer_test,'outer_join_with_cache=off'); set join_cache_level=1; CREATE TABLE t1 ( @@ -2751,4 +2751,4 @@ WHERE t3.pk IN (2); 1 drop view v4; drop table t1,t2,t3,t4; -SET optimizer_switch=@save_optimizer_switch; +SET optimizer_switch=@org_optimizer_switch; diff --git a/mysql-test/main/join_outer.test b/mysql-test/main/join_outer.test index c02b2e32580..2e5fc65ebb6 100644 --- a/mysql-test/main/join_outer.test +++ b/mysql-test/main/join_outer.test @@ -8,7 +8,7 @@ drop table if exists t0,t1,t2,t3,t4,t5; --enable_warnings -SET @save_optimizer_switch=@@optimizer_switch; +SET @org_optimizer_switch=@@optimizer_switch; SET optimizer_switch=ifnull(@optimizer_switch_for_join_outer_test,'outer_join_with_cache=off'); if (`select @join_cache_level_for_join_outer_test is null`) { @@ -2251,4 +2251,4 @@ WHERE t3.pk IN (2); drop view v4; drop table t1,t2,t3,t4; -SET optimizer_switch=@save_optimizer_switch; +SET optimizer_switch=@org_optimizer_switch; diff --git a/mysql-test/main/join_outer_innodb.test b/mysql-test/main/join_outer_innodb.test index 67e9965a475..c26cd62fbc7 100644 --- a/mysql-test/main/join_outer_innodb.test +++ b/mysql-test/main/join_outer_innodb.test @@ -3,6 +3,7 @@ # --source include/have_innodb.inc +--source include/default_optimizer_switch.inc # # Test for bug #17164: ORed FALSE blocked conversion of outer join into join diff --git a/mysql-test/main/join_outer_jcl6.result b/mysql-test/main/join_outer_jcl6.result index 30981b2ff98..d3276de88ea 100644 --- a/mysql-test/main/join_outer_jcl6.result +++ b/mysql-test/main/join_outer_jcl6.result @@ -1,16 +1,12 @@ -set @save_optimizer_switch_jcl6=@@optimizer_switch; set @@optimizer_switch='optimize_join_buffer_size=on'; set @@optimizer_switch='semijoin_with_cache=on'; set @@optimizer_switch='outer_join_with_cache=on'; -set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; -set join_cache_level=6; -show variables like 'join_cache_level'; -Variable_name Value -join_cache_level 6 +set @@optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +set @@join_cache_level=6; set @optimizer_switch_for_join_outer_test=@@optimizer_switch; set @join_cache_level_for_join_outer_test=@@join_cache_level; drop table if exists t0,t1,t2,t3,t4,t5; -SET @save_optimizer_switch=@@optimizer_switch; +SET @org_optimizer_switch=@@optimizer_switch; SET optimizer_switch=ifnull(@optimizer_switch_for_join_outer_test,'outer_join_with_cache=off'); set join_cache_level=@join_cache_level_for_join_outer_test; CREATE TABLE t1 ( @@ -2762,11 +2758,4 @@ WHERE t3.pk IN (2); 1 drop view v4; drop table t1,t2,t3,t4; -SET optimizer_switch=@save_optimizer_switch; -set join_cache_level=default; -show variables like 'join_cache_level'; -Variable_name Value -join_cache_level 2 -set @@optimizer_switch=@save_optimizer_switch_jcl6; -set @optimizer_switch_for_join_outer_test=NULL; -set @join_cache_level_for_join_outer_test=NULL; +SET optimizer_switch=@org_optimizer_switch; diff --git a/mysql-test/main/join_outer_jcl6.test b/mysql-test/main/join_outer_jcl6.test index 9db06c783bd..46839cb1065 100644 --- a/mysql-test/main/join_outer_jcl6.test +++ b/mysql-test/main/join_outer_jcl6.test @@ -2,23 +2,15 @@ # Run join_outer.test with BKA enabled # -set @save_optimizer_switch_jcl6=@@optimizer_switch; +--source include/default_optimizer_switch.inc + set @@optimizer_switch='optimize_join_buffer_size=on'; set @@optimizer_switch='semijoin_with_cache=on'; set @@optimizer_switch='outer_join_with_cache=on'; -set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; - -set join_cache_level=6; -show variables like 'join_cache_level'; +set @@optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +set @@join_cache_level=6; set @optimizer_switch_for_join_outer_test=@@optimizer_switch; set @join_cache_level_for_join_outer_test=@@join_cache_level; --source join_outer.test - -set join_cache_level=default; -show variables like 'join_cache_level'; - -set @@optimizer_switch=@save_optimizer_switch_jcl6; -set @optimizer_switch_for_join_outer_test=NULL; -set @join_cache_level_for_join_outer_test=NULL; diff --git a/mysql-test/main/limit_rows_examined.test b/mysql-test/main/limit_rows_examined.test index 815394aec5c..28b39a4caa1 100644 --- a/mysql-test/main/limit_rows_examined.test +++ b/mysql-test/main/limit_rows_examined.test @@ -2,6 +2,7 @@ # Tests for LIMIT ROWS EXAMINED, MDEV-28 # +--source include/default_optimizer_switch.inc call mtr.add_suppression("Sort aborted.*"); set @save_join_cache_level = @@join_cache_level; diff --git a/mysql-test/main/log_slow.result b/mysql-test/main/log_slow.result index a7172af59d5..31d52ff0323 100644 --- a/mysql-test/main/log_slow.result +++ b/mysql-test/main/log_slow.result @@ -1,3 +1,4 @@ +set @@log_slow_verbosity=""; select @@log_slow_filter; @@log_slow_filter admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk diff --git a/mysql-test/main/log_slow.test b/mysql-test/main/log_slow.test index edb1865b5ae..64fd8202985 100644 --- a/mysql-test/main/log_slow.test +++ b/mysql-test/main/log_slow.test @@ -2,6 +2,8 @@ # Testing of slow log query options # +set @@log_slow_verbosity=""; + select @@log_slow_filter; select @@log_slow_rate_limit; select @@log_slow_verbosity; diff --git a/mysql-test/main/log_state.result b/mysql-test/main/log_state.result index d4f98a6bde9..5e7aac81b0c 100644 --- a/mysql-test/main/log_state.result +++ b/mysql-test/main/log_state.result @@ -3,6 +3,7 @@ SET @old_general_log= @@global.general_log; SET @old_general_log_file= @@global.general_log_file; SET @old_slow_query_log= @@global.slow_query_log; SET @old_slow_query_log_file= @@global.slow_query_log_file; +set @save_long_query_time=@@long_query_time; set global general_log= OFF; truncate table mysql.general_log; truncate table mysql.slow_log; @@ -276,7 +277,7 @@ SELECT @@general_log_file = @my_glf; SET GLOBAL general_log_file = @old_general_log_file; disconnect con1; connection default; -SET GLOBAL long_query_time = DEFAULT; +SET GLOBAL long_query_time = @save_long_query_time; SET GLOBAL log_output = @old_log_output; SET global general_log = @old_general_log; SET global general_log_file = @old_general_log_file; diff --git a/mysql-test/main/log_state.test b/mysql-test/main/log_state.test index 5a08b8015f0..44a844a67b0 100644 --- a/mysql-test/main/log_state.test +++ b/mysql-test/main/log_state.test @@ -12,7 +12,7 @@ SET @old_general_log= @@global.general_log; SET @old_general_log_file= @@global.general_log_file; SET @old_slow_query_log= @@global.slow_query_log; SET @old_slow_query_log_file= @@global.slow_query_log_file; - +set @save_long_query_time=@@long_query_time; --disable_ps_protocol @@ -330,7 +330,7 @@ disconnect con1; connection default; # Reset global system variables to initial values if forgotten somewhere above. -SET GLOBAL long_query_time = DEFAULT; +SET GLOBAL long_query_time = @save_long_query_time; SET GLOBAL log_output = @old_log_output; SET global general_log = @old_general_log; SET global general_log_file = @old_general_log_file; diff --git a/mysql-test/main/log_tables.result b/mysql-test/main/log_tables.result index 126230a8765..aed5dbfba3d 100644 --- a/mysql-test/main/log_tables.result +++ b/mysql-test/main/log_tables.result @@ -9,9 +9,6 @@ SET @saved_long_query_time = @@long_query_time; SET @saved_log_output = @@log_output; SET @saved_general_log = @@GLOBAL.general_log; SET @saved_slow_query_log = @@GLOBAL.slow_query_log; -SELECT @saved_long_query_time, @saved_log_output, @saved_general_log, @saved_slow_query_log; -@saved_long_query_time @saved_log_output @saved_general_log @saved_slow_query_log -10 FILE,TABLE 1 1 truncate table general_log; select * from general_log; event_time user_host thread_id server_id command_type argument @@ -436,9 +433,9 @@ My own slow query sleep(2) My own slow query 0 SELECT * FROM mysql.slow_log WHERE seq >= 2 LIMIT 3; start_time user_host query_time lock_time rows_sent rows_examined db last_insert_id insert_id server_id sql_text thread_id rows_affected seq -START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 4 0 2 -START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 4 0 3 -START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) 4 0 4 +START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) THREAD_ID 0 2 +START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) THREAD_ID 0 3 +START_TIME USER_HOST QUERY_TIME 00:00:00.000000 1 0 test 0 0 1 SELECT "My own slow query", sleep(2) THREAD_ID 0 4 SET GLOBAL slow_query_log = 0; SET SESSION long_query_time =@saved_long_query_time; FLUSH LOGS; diff --git a/mysql-test/main/log_tables.test b/mysql-test/main/log_tables.test index f822ec8d758..4ea8a7639ef 100644 --- a/mysql-test/main/log_tables.test +++ b/mysql-test/main/log_tables.test @@ -27,10 +27,6 @@ SET @saved_log_output = @@log_output; SET @saved_general_log = @@GLOBAL.general_log; SET @saved_slow_query_log = @@GLOBAL.slow_query_log; -SELECT @saved_long_query_time, @saved_log_output, @saved_general_log, @saved_slow_query_log; - - - # # Check that log tables work and we can do basic selects. This also # tests truncate, which works in a special mode with the log tables @@ -528,7 +524,7 @@ SELECT "My own slow query", sleep(2); SELECT "My own slow query", sleep(2); ## So we look for seq 2-4 ---replace_column 1 START_TIME 2 USER_HOST 3 QUERY_TIME +--replace_column 1 START_TIME 2 USER_HOST 3 QUERY_TIME 12 THREAD_ID SELECT * FROM mysql.slow_log WHERE seq >= 2 LIMIT 3; SET GLOBAL slow_query_log = 0; diff --git a/mysql-test/main/lowercase_table_qcache.result b/mysql-test/main/lowercase_table_qcache.result index 9d7e1007e4c..9f8c89a41e8 100644 --- a/mysql-test/main/lowercase_table_qcache.result +++ b/mysql-test/main/lowercase_table_qcache.result @@ -1,3 +1,4 @@ +set @save_query_cache_size=@@query_cache_size; set GLOBAL query_cache_size=1355776; set GLOBAL query_cache_type=ON; set LOCAL query_cache_type=ON; @@ -23,5 +24,5 @@ select * from MySQL.db; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 -set GLOBAL query_cache_size=default; +set GLOBAL query_cache_size=@save_query_cache_size; set GLOBAL query_cache_type=default; diff --git a/mysql-test/main/lowercase_table_qcache.test b/mysql-test/main/lowercase_table_qcache.test index ab05755bec1..bf24c8e9a1c 100644 --- a/mysql-test/main/lowercase_table_qcache.test +++ b/mysql-test/main/lowercase_table_qcache.test @@ -2,6 +2,7 @@ # # Test of query cache with --lower-case-table-names # +set @save_query_cache_size=@@query_cache_size; set GLOBAL query_cache_size=1355776; set GLOBAL query_cache_type=ON; set LOCAL query_cache_type=ON; @@ -28,7 +29,7 @@ select * from MySQL.db; enable_result_log; show status like "Qcache_queries_in_cache"; -set GLOBAL query_cache_size=default; +set GLOBAL query_cache_size=@save_query_cache_size; set GLOBAL query_cache_type=default; # End of 4.1 tests diff --git a/mysql-test/main/mdev13607.test b/mysql-test/main/mdev13607.test index 45fdb0a74d4..2d11312cd94 100644 --- a/mysql-test/main/mdev13607.test +++ b/mysql-test/main/mdev13607.test @@ -3,6 +3,7 @@ --echo # --source include/have_innodb.inc +--source include/default_optimizer_switch.inc CREATE TABLE t1 (id INT) ENGINE=InnoDB; INSERT INTO t1 VALUES diff --git a/mysql-test/main/mdev375.result b/mysql-test/main/mdev375.result index 0ae8375ff24..3fdf97f5c24 100644 --- a/mysql-test/main/mdev375.result +++ b/mysql-test/main/mdev375.result @@ -1,3 +1,4 @@ +set @save_log_warnings=@@log_warnings, @save_max_connections=@@max_connections; SET GLOBAL log_warnings=4; SET GLOBAL max_connections=10; connect tmp_con1,localhost,root,,; @@ -24,5 +25,5 @@ SELECT 0; show status like "Threads_connected"; Variable_name Value Threads_connected 11 -SET GLOBAL log_warnings=default; -SET GLOBAL max_connections=default; +SET GLOBAL log_warnings=@save_log_warnings; +SET GLOBAL max_connections=@save_max_connections; diff --git a/mysql-test/main/mdev375.test b/mysql-test/main/mdev375.test index 759f7bd31f0..9e35190b927 100644 --- a/mysql-test/main/mdev375.test +++ b/mysql-test/main/mdev375.test @@ -3,6 +3,7 @@ # --source include/not_embedded.inc +set @save_log_warnings=@@log_warnings, @save_max_connections=@@max_connections; SET GLOBAL log_warnings=4; SET GLOBAL max_connections=10; @@ -28,5 +29,5 @@ SELECT 2; SELECT 0; show status like "Threads_connected"; -SET GLOBAL log_warnings=default; -SET GLOBAL max_connections=default; +SET GLOBAL log_warnings=@save_log_warnings; +SET GLOBAL max_connections=@save_max_connections; diff --git a/mysql-test/main/merge.result b/mysql-test/main/merge.result index ff6bdf4a07e..a102d62ad4d 100644 --- a/mysql-test/main/merge.result +++ b/mysql-test/main/merge.result @@ -1,5 +1,6 @@ -set global storage_engine=myisam; -set session storage_engine=myisam; +set @save_default_storage_engine=@@global.storage_engine; +set global default_storage_engine=myisam; +set session default_storage_engine=myisam; drop table if exists t1,t2,t3,t4,t5,t6; drop database if exists mysqltest; create table t1 (a int not null primary key auto_increment, message char(20)); @@ -2582,11 +2583,8 @@ prepare stmt from @a; execute stmt; prepare stmt from "select * from t_parent"; execute stmt; -ERROR HY000: Prepared statement needs to be re-prepared execute stmt; -ERROR HY000: Prepared statement needs to be re-prepared execute stmt; -ERROR HY000: Prepared statement needs to be re-prepared deallocate prepare stmt; # # Create merge parent diff --git a/mysql-test/main/merge.test b/mysql-test/main/merge.test index edc4a364ad9..c22cf3950c1 100644 --- a/mysql-test/main/merge.test +++ b/mysql-test/main/merge.test @@ -6,9 +6,12 @@ --source include/count_sessions.inc # MERGE tables require MyISAM tables -let $default=`select @@global.storage_engine`; -set global storage_engine=myisam; -set session storage_engine=myisam; +set @save_default_storage_engine=@@global.storage_engine; +set global default_storage_engine=myisam; +set session default_storage_engine=myisam; + +# This test assumes a stable character set +--source include/default_charset.inc # Clean up resources used in this test case. --disable_warnings @@ -17,7 +20,6 @@ drop database if exists mysqltest; --enable_warnings let $MYSQLD_DATADIR= `select @@datadir`; - create table t1 (a int not null primary key auto_increment, message char(20)); create table t2 (a int not null primary key auto_increment, message char(20)); INSERT INTO t1 (message) VALUES ("Testing"),("table"),("t1"); @@ -1921,13 +1923,16 @@ set @a=concat("create table t_parent (a int) union(", @a, prepare stmt from @a; execute stmt; prepare stmt from "select * from t_parent"; ---error ER_NEED_REPREPARE +--disable_result_log +--error 0,ER_NEED_REPREPARE execute stmt; ---error ER_NEED_REPREPARE +--error 0,ER_NEED_REPREPARE execute stmt; ---error ER_NEED_REPREPARE +--error 0,ER_NEED_REPREPARE execute stmt; deallocate prepare stmt; +--enable_result_log + --echo # --echo # Create merge parent --echo # @@ -2907,7 +2912,7 @@ DROP TABLE m1; --disable_result_log --disable_query_log -eval set global storage_engine=$default; +set global default_storage_engine=@save_default_storage_engine; --enable_result_log --enable_query_log diff --git a/mysql-test/main/mrr_icp_extra.test b/mysql-test/main/mrr_icp_extra.test index 75ddc85b984..e2d25686c81 100644 --- a/mysql-test/main/mrr_icp_extra.test +++ b/mysql-test/main/mrr_icp_extra.test @@ -1,5 +1,8 @@ - # Generated by an ALTER TABLE in include/varchar.inc + +--source include/default_optimizer_switch.inc +--source include/default_charset.inc + call mtr.add_suppression("Can't find record in .*"); set @mrr_icp_extra_tmp=@@optimizer_switch; diff --git a/mysql-test/main/multi_update.test b/mysql-test/main/multi_update.test index 49799a45255..b09d02cb5aa 100644 --- a/mysql-test/main/multi_update.test +++ b/mysql-test/main/multi_update.test @@ -976,6 +976,8 @@ drop table t1, t2; # MDEV-14551 Can't find record in table on multi-table update with ORDER BY # +--source include/default_optimizer_switch.inc + # simple test with multi-update and Using temporary: create table t1 (i int) engine=memory; insert t1 values (1),(2); diff --git a/mysql-test/main/myisam.test b/mysql-test/main/myisam.test index 63f5f6672f2..c9519075a8f 100644 --- a/mysql-test/main/myisam.test +++ b/mysql-test/main/myisam.test @@ -2,6 +2,8 @@ # Test bugs in the MyISAM code # +--source include/default_optimizer_switch.inc + call mtr.add_suppression("Can't find record in '.*'"); call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired"); diff --git a/mysql-test/main/myisam_explain_non_select_all.test b/mysql-test/main/myisam_explain_non_select_all.test index ccd4ebd6297..8b79a6bd3ca 100644 --- a/mysql-test/main/myisam_explain_non_select_all.test +++ b/mysql-test/main/myisam_explain_non_select_all.test @@ -2,6 +2,8 @@ # Run explain_non_select.inc on MyISAM with all of the so-called 6.0 features. # +--source include/default_optimizer_switch.inc + #--source include/have_semijoin.inc #--source include/have_materialization.inc #--source include/have_firstmatch.inc diff --git a/mysql-test/main/myisam_icp.test b/mysql-test/main/myisam_icp.test index 508c282b1dc..d1dc35ebba4 100644 --- a/mysql-test/main/myisam_icp.test +++ b/mysql-test/main/myisam_icp.test @@ -2,6 +2,7 @@ # ICP/MyISAM tests (Index Condition Pushdown) # +--source include/default_optimizer_switch.inc set @myisam_icp_tmp=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; diff --git a/mysql-test/main/myisam_mrr.result b/mysql-test/main/myisam_mrr.result index 511e6a8d01f..0869faf3000 100644 --- a/mysql-test/main/myisam_mrr.result +++ b/mysql-test/main/myisam_mrr.result @@ -1,6 +1,7 @@ drop table if exists t0, t1, t2, t3; set @myisam_mrr_tmp=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +set optimizer_switch='optimize_join_buffer_size=off'; set @mrr_buffer_size_save= @@mrr_buffer_size; set mrr_buffer_size=79; Warnings: diff --git a/mysql-test/main/myisam_mrr.test b/mysql-test/main/myisam_mrr.test index b15fdf60ce7..e3c758d3c10 100644 --- a/mysql-test/main/myisam_mrr.test +++ b/mysql-test/main/myisam_mrr.test @@ -8,6 +8,7 @@ drop table if exists t0, t1, t2, t3; set @myisam_mrr_tmp=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +set optimizer_switch='optimize_join_buffer_size=off'; set @mrr_buffer_size_save= @@mrr_buffer_size; set mrr_buffer_size=79; diff --git a/mysql-test/main/myisam_recover.result b/mysql-test/main/myisam_recover.result index 92df67b42d1..4c655e39ae9 100644 --- a/mysql-test/main/myisam_recover.result +++ b/mysql-test/main/myisam_recover.result @@ -1,4 +1,5 @@ call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired"); +set @save_table_definition_cache=@@table_definition_cache; # # Tests for corrupted MyISAM tables and MyISAMMRG tables with corrupted # children.. @@ -97,10 +98,10 @@ unlock tables; prepare stmt from @drop_table_stmt; execute stmt; deallocate prepare stmt; -set @@global.table_definition_cache=default; set @@global.table_open_cache=@save_table_open_cache; disconnect con1; connection default; +set @@global.table_definition_cache=@save_table_definition_cache; # # 18075170 - sql node restart required to avoid deadlock after # restore diff --git a/mysql-test/main/myisam_recover.test b/mysql-test/main/myisam_recover.test index 316be56609b..9056b219148 100644 --- a/mysql-test/main/myisam_recover.test +++ b/mysql-test/main/myisam_recover.test @@ -2,6 +2,8 @@ call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired"); +set @save_table_definition_cache=@@table_definition_cache; + --echo # --echo # Tests for corrupted MyISAM tables and MyISAMMRG tables with corrupted --echo # children.. @@ -104,11 +106,11 @@ unlock tables; prepare stmt from @drop_table_stmt; execute stmt; deallocate prepare stmt; -set @@global.table_definition_cache=default; set @@global.table_open_cache=@save_table_open_cache; disconnect con1; connection default; --enable_ps_protocol +set @@global.table_definition_cache=@save_table_definition_cache; --echo # --echo # 18075170 - sql node restart required to avoid deadlock after diff --git a/mysql-test/main/mysql.test b/mysql-test/main/mysql.test index fbc5bd20842..1cb4977a32d 100644 --- a/mysql-test/main/mysql.test +++ b/mysql-test/main/mysql.test @@ -694,7 +694,7 @@ select count(*) from t1; truncate table t1; --exec $MYSQL --disable-local-infile -e "$ldli" select count(*) from t1; truncate table t1; --error 1 ---exec $MYSQL -e "/*q*/$ldli" +--exec $MYSQL --local-infile=0 -e "/*q*/$ldli" select count(*) from t1; truncate table t1; --exec $MYSQL --enable-local-infile -e "/*q*/$ldli" select count(*) from t1; truncate table t1; diff --git a/mysql-test/main/mysql_client_test.result b/mysql-test/main/mysql_client_test.result index 6ecf03946ab..8a2921f28b5 100644 --- a/mysql-test/main/mysql_client_test.result +++ b/mysql-test/main/mysql_client_test.result @@ -1,3 +1,9 @@ +SET @save_character_set_client= @@global.character_set_client; +SET @save_collation_connection= @@global.collation_connection; +SET @@global.character_set_server= @@character_set_server; +SET @@global.collation_server= @@collation_server; +SET @@global.character_set_client= @@character_set_server; +SET @@global.collation_connection= @@collation_server; SET @old_general_log= @@global.general_log; SET @old_slow_query_log= @@global.slow_query_log; call mtr.add_suppression(" Error reading file './client_test_db/test_frm_bug.frm'"); @@ -246,3 +252,7 @@ ANALYZE JSON DELETE number of fields: 1 SET @@global.general_log= @old_general_log; SET @@global.slow_query_log= @old_slow_query_log; +SET @@global.character_set_server= @save_character_set_server; +SET @@global.collation_server= @save_collation_server; +SET @@global.character_set_client= @save_character_set_client; +SET @@global.collation_connection= @save_collation_connection; diff --git a/mysql-test/main/mysql_client_test.test b/mysql-test/main/mysql_client_test.test index f8aa097b415..de4c33694ab 100644 --- a/mysql-test/main/mysql_client_test.test +++ b/mysql-test/main/mysql_client_test.test @@ -5,6 +5,15 @@ # This test is slow on buildbot. --source include/big_test.inc +# Run test with default character set +--source include/default_charset.inc +SET @save_character_set_client= @@global.character_set_client; +SET @save_collation_connection= @@global.collation_connection; +SET @@global.character_set_server= @@character_set_server; +SET @@global.collation_server= @@collation_server; +SET @@global.character_set_client= @@character_set_server; +SET @@global.collation_connection= @@collation_server; + SET @old_general_log= @@global.general_log; SET @old_slow_query_log= @@global.slow_query_log; @@ -40,3 +49,7 @@ echo ok; SET @@global.general_log= @old_general_log; SET @@global.slow_query_log= @old_slow_query_log; +SET @@global.character_set_server= @save_character_set_server; +SET @@global.collation_server= @save_collation_server; +SET @@global.character_set_client= @save_character_set_client; +SET @@global.collation_connection= @save_collation_connection; diff --git a/mysql-test/main/mysql_client_test_nonblock.test b/mysql-test/main/mysql_client_test_nonblock.test index 768a0590c30..19489bf9e0e 100644 --- a/mysql-test/main/mysql_client_test_nonblock.test +++ b/mysql-test/main/mysql_client_test_nonblock.test @@ -1,3 +1,4 @@ + # This runs the mysql_client_test using the non-blocking API. # The non-blocking API is not supported in the embedded server. diff --git a/mysql-test/main/mysql_comments.test b/mysql-test/main/mysql_comments.test index 338fe8dc6b9..1ee88553a8f 100644 --- a/mysql-test/main/mysql_comments.test +++ b/mysql-test/main/mysql_comments.test @@ -1,5 +1,6 @@ # This test should work in embedded server after we fix mysqltest -- source include/not_embedded.inc + ###################### mysql_comments.test ############################# # # # Testing of comments handling by the command line client (mysql) # @@ -31,13 +32,12 @@ drop trigger if exists t1_bi; # Test without comments --echo "Pass 1 : --disable-comments" --replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.[0-9]{2})*/--TIME--/ ---exec $MYSQL --disable-comments test 2>&1 < "./main/mysql_comments.sql" +--exec $MYSQL --default-character-set=latin1 --disable-comments test 2>&1 < "./main/mysql_comments.sql" # Test with comments --echo "Pass 2 : --enable-comments" --replace_regex /[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}(.[0-9]{2})*/--TIME--/ ---exec $MYSQL --enable-comments test 2>&1 < "./main/mysql_comments.sql" - +--exec $MYSQL --default-character-set=latin1 --enable-comments test 2>&1 < "./main/mysql_comments.sql" set global sql_mode=default; --echo End of 5.0 tests diff --git a/mysql-test/main/mysqlbinlog-innodb.result b/mysql-test/main/mysqlbinlog-innodb.result index 2971a69fb4d..f9f48299f41 100644 --- a/mysql-test/main/mysqlbinlog-innodb.result +++ b/mysql-test/main/mysqlbinlog-innodb.result @@ -30,10 +30,10 @@ use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; INSERT INTO t1 VALUES (1) @@ -61,10 +61,10 @@ use `foo`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; INSERT INTO t1 VALUES (1) diff --git a/mysql-test/main/mysqlbinlog-innodb.test b/mysql-test/main/mysqlbinlog-innodb.test index c8bf8095705..559fe785c00 100644 --- a/mysql-test/main/mysqlbinlog-innodb.test +++ b/mysql-test/main/mysqlbinlog-innodb.test @@ -24,7 +24,9 @@ COMMIT; USE test; SELECT * FROM t1 ORDER BY a; FLUSH LOGS; +--replace_regex /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --short-form +--replace_regex /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 --short-form --rewrite-db="test->foo" --rewrite-db="test2->bar" DROP DATABASE test2; DROP TABLE t1; diff --git a/mysql-test/main/mysqlbinlog.result b/mysql-test/main/mysqlbinlog.result index 8d7f6337c05..c4d95dc6ff7 100644 --- a/mysql-test/main/mysqlbinlog.result +++ b/mysql-test/main/mysqlbinlog.result @@ -23,10 +23,10 @@ use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; DROP TABLE IF EXISTS `t1`,`t2`,`t3`,`t4`,`t5`,`t03`,`t04` /* generated by server */ @@ -103,10 +103,10 @@ use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`) @@ -139,10 +139,10 @@ BEGIN SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; COMMIT @@ -190,10 +190,10 @@ use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; insert into t1 values ("Alas") @@ -217,10 +217,10 @@ use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; DROP TABLE IF EXISTS `t1`,`t2`,`t3`,`t4`,`t5`,`t03`,`t04` /* generated by server */ @@ -297,10 +297,10 @@ use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; LOAD DATA LOCAL INFILE 'MYSQLTEST_VARDIR/tmp/SQL_LOAD_MB-#-#' INTO TABLE `t1` FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`word`) @@ -333,10 +333,10 @@ BEGIN SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; COMMIT @@ -384,10 +384,10 @@ use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; insert into t1 values ("Alas") @@ -493,10 +493,10 @@ use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`() @@ -545,10 +545,10 @@ use `test`/*!*/; SET TIMESTAMP=1000000000/*!*/; SET @@session.pseudo_thread_id=999999999/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; create table t1 (a varchar(64) character set utf8) diff --git a/mysql-test/main/mysqlbinlog.test b/mysql-test/main/mysqlbinlog.test index 6988b2a8e9b..e0503402bd6 100644 --- a/mysql-test/main/mysqlbinlog.test +++ b/mysql-test/main/mysqlbinlog.test @@ -54,7 +54,7 @@ select "--- Local --" as ""; # let $MYSQLD_DATADIR= `select @@datadir`; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ +--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000001 # this should not fail but shouldn't produce any working statements @@ -62,7 +62,7 @@ let $MYSQLD_DATADIR= `select @@datadir`; select "--- Broken LOAD DATA --" as ""; --enable_query_log --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ +--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000002 2> /dev/null # this should show almost nothing @@ -70,7 +70,7 @@ select "--- Broken LOAD DATA --" as ""; select "--- --database --" as ""; --enable_query_log --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ +--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --database=nottest $MYSQLD_DATADIR/master-bin.000001 2> /dev/null # this test for start-position option @@ -78,7 +78,7 @@ select "--- --database --" as ""; select "--- --start-position --" as ""; --enable_query_log --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ +--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --start-position=$binlog_start_pos $MYSQLD_DATADIR/master-bin.000002 # These are tests for remote binlog. @@ -90,7 +90,7 @@ select "--- Remote --" as ""; # This is broken now --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ +--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000001 # This is broken too @@ -98,7 +98,7 @@ select "--- Remote --" as ""; select "--- Broken LOAD DATA --" as ""; --enable_query_log --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ +--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 2> /dev/null # And this too ! (altough it is documented) @@ -106,7 +106,7 @@ select "--- Broken LOAD DATA --" as ""; select "--- --database --" as ""; --enable_query_log --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ +--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --database=nottest master-bin.000001 2> /dev/null # Strangely but this works @@ -114,7 +114,7 @@ select "--- --database --" as ""; select "--- --start-position --" as ""; --enable_query_log --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ +--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --start-position=$binlog_start_pos --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 # Bug#7853 mysqlbinlog does not accept input from stdin @@ -122,11 +122,11 @@ select "--- --start-position --" as ""; select "--- reading stdin --" as ""; --enable_query_log --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ +--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --short-form - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001 --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR ---replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ +--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ # postion is constant to correspond to an event in pre-recorded binlog --let $binlog_start_pos=79 --exec $MYSQL_BINLOG --short-form --start-position=$binlog_start_pos - < $MYSQL_TEST_DIR/std_data/trunc_binlog.000001 @@ -214,7 +214,7 @@ call p1(); drop procedure p1; --error ER_SP_DOES_NOT_EXIST call p1(); ---replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ +--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000008 --exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000008 | $MYSQL call p1(); @@ -255,7 +255,7 @@ drop table t1; flush logs; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ +--replace_regex /SQL_LOAD_MB-[0-9a-f]+-[0-9a-f]+/SQL_LOAD_MB-#-#/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ $MYSQLD_DATADIR/master-bin.000010 # diff --git a/mysql-test/main/mysqlbinlog_row_big.result b/mysql-test/main/mysqlbinlog_row_big.result index a90ba9d79b6..ecbb9df2be1 100644 --- a/mysql-test/main/mysqlbinlog_row_big.result +++ b/mysql-test/main/mysqlbinlog_row_big.result @@ -96,6 +96,5 @@ FLUSH LOGS; # Cleanup. # # reset variable value to pass testcase checks -SET @@global.max_allowed_packet = 16777216; DROP TABLE t1; remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_big_1.out diff --git a/mysql-test/main/mysqlbinlog_row_big.test b/mysql-test/main/mysqlbinlog_row_big.test index 229cc8a31fc..fd6517a7a9a 100644 --- a/mysql-test/main/mysqlbinlog_row_big.test +++ b/mysql-test/main/mysqlbinlog_row_big.test @@ -138,7 +138,9 @@ let $MYSQLD_DATADIR= `select @@datadir`; --echo # Cleanup. --echo # --echo # reset variable value to pass testcase checks +--disable_query_log eval SET @@global.max_allowed_packet = $orig_max_allowed_packet; +--enable_query_log DROP TABLE t1; --echo remove_file \$MYSQLTEST_VARDIR/$mysqlbinlog_output diff --git a/mysql-test/main/mysqlbinlog_row_compressed.result b/mysql-test/main/mysqlbinlog_row_compressed.result index 8cf52f5b826..94125352654 100644 --- a/mysql-test/main/mysqlbinlog_row_compressed.result +++ b/mysql-test/main/mysqlbinlog_row_compressed.result @@ -34,10 +34,10 @@ use `test`/*!*/; SET TIMESTAMP=X/*!*/; SET @@session.pseudo_thread_id=5/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1)) diff --git a/mysql-test/main/mysqlbinlog_row_compressed.test b/mysql-test/main/mysqlbinlog_row_compressed.test index 1a7ce093986..6b62a42c449 100644 --- a/mysql-test/main/mysqlbinlog_row_compressed.test +++ b/mysql-test/main/mysqlbinlog_row_compressed.test @@ -29,7 +29,7 @@ DELETE FROM t2; FLUSH BINARY LOGS; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /\d{6} *\d*:\d\d:\d\d/<date>/ /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ +--replace_regex /\d{6} *\d*:\d\d:\d\d/<date>/ /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --verbose --verbose --base64-output=DECODE-ROWS $datadir/$binlog --echo diff --git a/mysql-test/main/mysqlbinlog_row_minimal.result b/mysql-test/main/mysqlbinlog_row_minimal.result index b3cee345428..6f3dbab55a8 100644 --- a/mysql-test/main/mysqlbinlog_row_minimal.result +++ b/mysql-test/main/mysqlbinlog_row_minimal.result @@ -32,10 +32,10 @@ use `test`/*!*/; SET TIMESTAMP=X/*!*/; SET @@session.pseudo_thread_id=5/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1)) @@ -380,10 +380,10 @@ BEGIN SET TIMESTAMP=X/*!*/; SET @@session.pseudo_thread_id=5/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; COMMIT diff --git a/mysql-test/main/mysqlbinlog_row_minimal.test b/mysql-test/main/mysqlbinlog_row_minimal.test index 85b816e1be5..b69aa6da14b 100644 --- a/mysql-test/main/mysqlbinlog_row_minimal.test +++ b/mysql-test/main/mysqlbinlog_row_minimal.test @@ -28,7 +28,7 @@ DELETE FROM t2; FLUSH BINARY LOGS; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /\d{6} *\d*:\d\d:\d\d/<date>/ /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ +--replace_regex /\d{6} *\d*:\d\d:\d\d/<date>/ /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --verbose --verbose --base64-output=DECODE-ROWS $datadir/$binlog DROP TABLE t1,t2; @@ -67,7 +67,7 @@ UPDATE t1 t1 INNER JOIN t2 t2 ON t1.ref_id = t2.id FLUSH BINARY LOGS; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /\d{6} *\d*:\d\d:\d\d/<date>/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /@3=\d*/@3=X/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ +--replace_regex /\d{6} *\d*:\d\d:\d\d/<date>/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /@3=\d*/@3=X/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --verbose --verbose --base64-output=DECODE-ROWS $datadir/$binlog --start-position=$binlog_pos DROP TABLE t1,t2; diff --git a/mysql-test/main/mysqlbinlog_stmt_compressed.result b/mysql-test/main/mysqlbinlog_stmt_compressed.result index cd8e98c1ee3..42717bccd01 100644 --- a/mysql-test/main/mysqlbinlog_stmt_compressed.result +++ b/mysql-test/main/mysqlbinlog_stmt_compressed.result @@ -34,10 +34,10 @@ use `test`/*!*/; SET TIMESTAMP=X/*!*/; SET @@session.pseudo_thread_id=5/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1/*!*/; -SET @@session.sql_mode=1411383296/*!*/; +SET @@session.sql_mode=#/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1)) diff --git a/mysql-test/main/mysqlbinlog_stmt_compressed.test b/mysql-test/main/mysqlbinlog_stmt_compressed.test index c4331ddf229..613a820d3ea 100644 --- a/mysql-test/main/mysqlbinlog_stmt_compressed.test +++ b/mysql-test/main/mysqlbinlog_stmt_compressed.test @@ -29,7 +29,7 @@ DELETE FROM t2; FLUSH BINARY LOGS; --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR ---replace_regex /\d{6} *\d*:\d\d:\d\d/<date>/ /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ +--replace_regex /\d{6} *\d*:\d\d:\d\d/<date>/ /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --verbose --verbose --base64-output=DECODE-ROWS $datadir/$binlog --echo diff --git a/mysql-test/main/mysqlcheck.opt b/mysql-test/main/mysqlcheck.opt new file mode 100644 index 00000000000..35db081c15b --- /dev/null +++ b/mysql-test/main/mysqlcheck.opt @@ -0,0 +1 @@ +--character-set-server=latin1 --collation_server=latin1_swedish_ci diff --git a/mysql-test/main/mysqlcheck.result b/mysql-test/main/mysqlcheck.result index 7259b68be50..bdcb6df44ba 100644 --- a/mysql-test/main/mysqlcheck.result +++ b/mysql-test/main/mysqlcheck.result @@ -1,4 +1,6 @@ call mtr.add_suppression("Invalid .old.. table or database name"); +set @save_character_set_client=@@character_set_client; +set @save_collation_connection=@@collation_connection; DROP TABLE IF EXISTS t1, `t``1`, `t 1`, test.`t.1`, v1; drop view if exists t1, `t``1`, `t 1`, test.`t.1`, v1; drop database if exists client_test_db; @@ -222,7 +224,9 @@ CREATE TABLE `#mysql50#@` (a INT) engine=myisam; SHOW TABLES; Tables_in_test #mysql50#@ -SET NAMES DEFAULT; +set @@character_set_client=@save_character_set_client; +set @@character_set_results=@save_character_set_client; +set @@collation_connection=@save_collation_connection; mysqlcheck --fix-table-names --databases test SET NAMES utf8; SHOW TABLES; @@ -230,7 +234,9 @@ Tables_in_test @ DROP TABLE `@`; CREATE TABLE `Ñ` (a INT) engine=myisam; -SET NAMES DEFAULT; +set @@character_set_client=@save_character_set_client; +set @@character_set_results=@save_character_set_client; +set @@collation_connection=@save_collation_connection; call mtr.add_suppression("@003f.frm' \\(errno: 22\\)"); mysqlcheck --default-character-set="latin1" --databases test call mtr.add_suppression("Can't find file: '..test.@003f.frm'"); @@ -241,7 +247,9 @@ mysqlcheck --default-character-set="utf8" --databases test test.Ñ OK SET NAMES utf8; DROP TABLE `Ñ`; -SET NAMES DEFAULT; +set @@character_set_client=@save_character_set_client; +set @@character_set_results=@save_character_set_client; +set @@collation_connection=@save_collation_connection; CREATE DATABASE `#mysql50#a@b`; USE `#mysql50#a@b`; CREATE TABLE `#mysql50#c@d` (a INT) engine=myisam; @@ -479,5 +487,5 @@ test.t1 Engine-independent statistics status : OK select * from mysql.column_stats where db_name = 'test' and table_name = 't1'; db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram -test t1 a 1 3 0.0000 4.0000 1.0000 0 NULL NULL +test t1 a 1 3 0.0000 4.0000 1.0000 # # # drop table t1; diff --git a/mysql-test/main/mysqlcheck.test b/mysql-test/main/mysqlcheck.test index 779ea8d13d4..8f3c241ebb7 100644 --- a/mysql-test/main/mysqlcheck.test +++ b/mysql-test/main/mysqlcheck.test @@ -2,8 +2,11 @@ call mtr.add_suppression("Invalid .old.. table or database name"); # Embedded server doesn't support external clients --source include/not_embedded.inc - --source include/have_innodb.inc +--source include/default_charset.inc + +set @save_character_set_client=@@character_set_client; +set @save_collation_connection=@@collation_connection; # check that CSV engine was compiled in, as the result of the test # depends on the presence of the log tables (which are CSV-based). @@ -136,7 +139,10 @@ drop table t1; SET NAMES utf8; CREATE TABLE `#mysql50#@` (a INT) engine=myisam; SHOW TABLES; -SET NAMES DEFAULT; +# Safer version of SET NAMES DEFAULT: +set @@character_set_client=@save_character_set_client; +set @@character_set_results=@save_character_set_client; +set @@collation_connection=@save_collation_connection; --echo mysqlcheck --fix-table-names --databases test --exec $MYSQL_CHECK --fix-table-names --databases test SET NAMES utf8; @@ -144,7 +150,10 @@ SHOW TABLES; DROP TABLE `@`; CREATE TABLE `Ñ` (a INT) engine=myisam; -SET NAMES DEFAULT; +set @@character_set_client=@save_character_set_client; +set @@character_set_results=@save_character_set_client; +set @@collation_connection=@save_collation_connection; + call mtr.add_suppression("@003f.frm' \\(errno: 22\\)"); --echo mysqlcheck --default-character-set="latin1" --databases test # Error returned depends on platform, replace it with "Table doesn't exist" @@ -155,7 +164,9 @@ call mtr.add_suppression("Can't find file: '..test.@003f.frm'"); --exec $MYSQL_CHECK --default-character-set="utf8" --databases test SET NAMES utf8; DROP TABLE `Ñ`; -SET NAMES DEFAULT; +set @@character_set_client=@save_character_set_client; +set @@character_set_results=@save_character_set_client; +set @@collation_connection=@save_collation_connection; CREATE DATABASE `#mysql50#a@b`; USE `#mysql50#a@b`; @@ -405,5 +416,6 @@ create table t1(a int); insert into t1 (a) values (1), (2), (3); select * from mysql.column_stats; --exec $MYSQL_CHECK --analyze test t1 --persistent +--replace_column 9 # 10 # 11 # select * from mysql.column_stats where db_name = 'test' and table_name = 't1'; drop table t1; diff --git a/mysql-test/main/mysqldump-compat-102.test b/mysql-test/main/mysqldump-compat-102.test index 582635dadc1..f10ba2ef5ed 100644 --- a/mysql-test/main/mysqldump-compat-102.test +++ b/mysql-test/main/mysqldump-compat-102.test @@ -77,7 +77,7 @@ DELIMITER ;$$ # mysqldump output is expected to have standalone PROCEDURE/FUNCTION, but not PACKAGE/PACKAGE BODY. --replace_regex /-- MySQL dump.*[^\n]/-- MySQL dump DUMPVERSION Distrib DISTVERSION, for OS/ / on [0-9 :-]+/ on TIMESTAMP/ ---exec $MYSQL_DUMP --quick --routines --triggers --no-create-info --skip-lock-tables --no-data --compress -uroot db1_mdev17429 +--exec $MYSQL_DUMP --quick --routines --triggers --no-create-info --skip-lock-tables --no-data --compress --default-character-set=utf8mb4 -uroot db1_mdev17429 DROP DATABASE db1_mdev17429; SET sql_mode=DEFAULT; diff --git a/mysql-test/main/mysqldump-max.test b/mysql-test/main/mysqldump-max.test index 4aadb09de53..a989fd28135 100644 --- a/mysql-test/main/mysqldump-max.test +++ b/mysql-test/main/mysqldump-max.test @@ -60,7 +60,9 @@ select * from t4; select * from t5; select * from t6; +--replace_result "NAMES utf8mb4" "NAMES utf8mb4" "NAMES utf8" "NAMES utf8mb4" --exec $MYSQL_DUMP --skip-comments --delayed-insert --insert-ignore --databases test +--replace_result "NAMES utf8mb4" "NAMES utf8mb4" "NAMES utf8" "NAMES utf8mb4" --exec $MYSQL_DUMP --skip-comments --delayed-insert --databases test drop table t1; diff --git a/mysql-test/main/mysqldump-nl.test b/mysql-test/main/mysqldump-nl.test index 4513fb2c637..863c846b9a6 100644 --- a/mysql-test/main/mysqldump-nl.test +++ b/mysql-test/main/mysqldump-nl.test @@ -6,6 +6,7 @@ --source include/not_embedded.inc # cmd.exe doesn't like new lines on the command line --source include/not_windows.inc +--source include/default_charset.inc create database `mysqltest1 1tsetlqsym`; diff --git a/mysql-test/main/mysqldump-utf8mb4.test b/mysql-test/main/mysqldump-utf8mb4.test index f8512c9bd7b..38b7527c5d6 100644 --- a/mysql-test/main/mysqldump-utf8mb4.test +++ b/mysql-test/main/mysqldump-utf8mb4.test @@ -1,5 +1,6 @@ --source include/have_utf8mb4.inc --source include/not_embedded.inc +--source include/default_charset.inc SET NAMES utf8mb4; @@ -18,14 +19,14 @@ INSERT INTO t1 VALUES ('01f300', UNHEX('f09f8c80'), 'U+1F300 CYCLONE'); --echo Testing XML format output --echo ---- ---exec $MYSQL_DUMP --skip-create-options --skip-comments -X test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-create-options --skip-comments -X test t1 --echo ---- --echo Testing text format output --echo ---- ---exec $MYSQL_DUMP --skip-create-options --skip-comments test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-create-options --skip-comments test t1 DROP TABLE t1; @@ -42,7 +43,7 @@ CREATE TABLE t1 ( ) CHARACTER SET utf8mb4; INSERT INTO t1 VALUES ('01f300', UNHEX('f09f8c80'), 'U+1F300 CYCLONE'); ---exec $MYSQL_DUMP test t1 > $file +--exec $MYSQL_DUMP --default-character-set=utf8mb4 test t1 > $file DROP TABLE t1; --exec $MYSQL test < $file SELECT * FROM t1; diff --git a/mysql-test/main/mysqldump.opt b/mysql-test/main/mysqldump.opt new file mode 100644 index 00000000000..0833e0abd4c --- /dev/null +++ b/mysql-test/main/mysqldump.opt @@ -0,0 +1 @@ +--character_set_server=latin1 --collation_server=latin1_swedish_ci --sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION diff --git a/mysql-test/main/mysqldump.test b/mysql-test/main/mysqldump.test index 2f1f5e38883..82cfe02958a 100644 --- a/mysql-test/main/mysqldump.test +++ b/mysql-test/main/mysqldump.test @@ -87,10 +87,10 @@ INSERT INTO t1 VALUES ("1.2345", 2.3456); SET SQL_MODE=@OLD_SQL_MODE; # check how mysqldump make quoting ---exec $MYSQL_DUMP --compact test t1 ---exec $MYSQL_DUMP --compact --skip-create-options test t1 ---exec $MYSQL_DUMP --skip-create-options --skip-comments test t1 ---exec $MYSQL_DUMP --skip-opt --extended-insert --skip-comments test t1 +--exec $MYSQL_DUMP --compact --default-character-set=utf8mb4 test t1 +--exec $MYSQL_DUMP --compact --skip-create-options --default-character-set=utf8mb4 test t1 +--exec $MYSQL_DUMP --skip-create-options --skip-comments --default-character-set=utf8mb4 test t1 +--exec $MYSQL_DUMP --skip-opt --extended-insert --skip-comments --default-character-set=utf8mb4 test t1 DROP TABLE t1; CREATE TABLE t1(a int, b text, c varchar(3)); @@ -114,7 +114,7 @@ DROP TABLE t1; CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r; INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL); ---exec $MYSQL_DUMP --skip-comments --skip-extended-insert test t1 +--exec $MYSQL_DUMP --skip-comments --skip-extended-insert --default-character-set=utf8mb4 test t1 DROP TABLE t1; --echo # @@ -123,8 +123,8 @@ DROP TABLE t1; CREATE TABLE t1 (a int) ENGINE=MYISAM; INSERT INTO t1 VALUES (1), (2); ---exec $MYSQL_DUMP --skip-comments --compatible=mysql40 test t1 ---exec $MYSQL_DUMP --skip-comments --compatible=mysql323 test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --compatible=mysql40 test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --compatible=mysql323 test t1 DROP TABLE t1; --echo # @@ -140,11 +140,11 @@ drop table ```a`; --echo # create table t1(a int); ---exec $MYSQL_DUMP --comments=0 test ---exec $MYSQL_DUMP --comments=0 --compatible=ansi test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --comments=0 test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --comments=0 --compatible=ansi test set global sql_mode='ANSI_QUOTES'; ---exec $MYSQL_DUMP --comments=0 test ---exec $MYSQL_DUMP --comments=0 --compatible=ansi test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --comments=0 test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --comments=0 --compatible=ansi test set global sql_mode=default; drop table t1; @@ -154,12 +154,12 @@ drop table t1; create table t1(a int); insert into t1 values (1),(2),(3); ---exec $MYSQL_DUMP --skip-comments --tab=$MYSQLTEST_VARDIR/tmp/ test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --tab=$MYSQLTEST_VARDIR/tmp/ test --cat_file $MYSQLTEST_VARDIR/tmp/t1.sql --cat_file $MYSQLTEST_VARDIR/tmp/t1.txt --remove_file $MYSQLTEST_VARDIR/tmp/t1.sql --remove_file $MYSQLTEST_VARDIR/tmp/t1.txt ---exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --tab=$MYSQLTEST_VARDIR/tmp/ test --remove_file $MYSQLTEST_VARDIR/tmp/t1.sql --remove_file $MYSQLTEST_VARDIR/tmp/t1.txt drop table t1; @@ -168,10 +168,10 @@ drop table t1; --echo # Bug#6101 create database problem --echo # ---exec $MYSQL_DUMP --skip-comments --databases test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --databases test create database mysqldump_test_db character set latin2 collate latin2_bin; ---exec $MYSQL_DUMP --skip-comments --databases mysqldump_test_db +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --databases mysqldump_test_db drop database mysqldump_test_db; --echo # @@ -183,7 +183,7 @@ drop database mysqldump_test_db; CREATE TABLE t1 (a CHAR(10)); INSERT INTO t1 VALUES (_latin1 'ÄÖÜß'); ---exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments test t1 --echo # --echo # Bug#8063 make test mysqldump [ fail ] @@ -193,7 +193,7 @@ INSERT INTO t1 VALUES (_latin1 'ÄÖÜß'); --echo # checking that "mysqldump" is compiled with "latin1" --echo # -#--exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --compatible=mysql323 test t1 +#--exec $MYSQL_DUMP --default-character-set=utf8mb4 --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --compatible=mysql323 test t1 --exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --compatible=mysql323 --default-character-set=cp850 test t1 --exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --default-character-set=cp850 --compatible=mysql323 test t1 --exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --skip-comments --default-character-set=utf8 --compatible=mysql323 test t1 @@ -207,7 +207,7 @@ CREATE TABLE t1 (a int); CREATE TABLE t2 (a int); INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t2 VALUES (4),(5),(6); ---exec $MYSQL_DUMP --skip-comments --ignore-table=test.t1 test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --ignore-table=test.t1 test DROP TABLE t1; DROP TABLE t2; @@ -217,7 +217,7 @@ DROP TABLE t2; CREATE TABLE t1 (`b` blob); INSERT INTO `t1` VALUES (0x602010000280100005E71A); ---exec $MYSQL_DUMP --skip-extended-insert --hex-blob test --skip-comments t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-extended-insert --hex-blob test --skip-comments t1 DROP TABLE t1; --echo # @@ -227,8 +227,8 @@ DROP TABLE t1; CREATE TABLE t1 (a INT) ENGINE=MyISAM; INSERT INTO t1 VALUES (1),(2),(3); INSERT INTO t1 VALUES (4),(5),(6); ---exec $MYSQL_DUMP --skip-comments --insert-ignore test t1 ---exec $MYSQL_DUMP --skip-comments --insert-ignore --delayed-insert test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --insert-ignore test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --insert-ignore --delayed-insert test t1 DROP TABLE t1; --echo # @@ -567,7 +567,7 @@ create table t1 ( F_6faa8040da20ef399b63a72d0e4ab575 int, F_fe73f687e5bc5280214e0486b273a5f9 int); insert into t1 (F_8d3bba7425e7c98c50f52ca1b52d3735) values (1); ---exec $MYSQL_DUMP --skip-comments -c test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments -c test drop table t1; --echo # @@ -576,7 +576,7 @@ drop table t1; CREATE TABLE t1 (a int); INSERT INTO t1 VALUES (1),(2),(3); ---exec $MYSQL_DUMP --add-drop-database --skip-comments --databases test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --add-drop-database --skip-comments --databases test DROP TABLE t1; --echo # @@ -589,10 +589,10 @@ CREATE TABLE t1 ( a INT ); CREATE TABLE t2 ( a INT ); INSERT INTO t1 VALUES (1), (2); INSERT INTO t2 VALUES (1), (2); ---exec $MYSQL_DUMP --skip-comments --no-data mysqldump_test_db ---exec $MYSQL_DUMP --skip-comments --no-data mysqldump_test_db t1 t2 ---exec $MYSQL_DUMP --skip-comments --skip-create-options --xml --no-data mysqldump_test_db ---exec $MYSQL_DUMP --skip-comments --skip-create-options --xml --no-data mysqldump_test_db t1 t2 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --no-data mysqldump_test_db +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --no-data mysqldump_test_db t1 t2 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --skip-create-options --xml --no-data mysqldump_test_db +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --skip-create-options --xml --no-data mysqldump_test_db t1 t2 DROP TABLE t1, t2; DROP DATABASE mysqldump_test_db; @@ -683,11 +683,11 @@ create table t2 (pk int primary key auto_increment, a int(10), b varchar(30), c datetime, d blob, e text); insert into t1 values (NULL), (10), (20); insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thirty"); ---exec $MYSQL_DUMP --skip-comments --xml --no-create-info test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --xml --no-create-info test # Test if UNIQUE_CHECK is done correctly ---exec $MYSQL_DUMP --skip-comments --no-create-info test ---exec $MYSQL_DUMP --skip-comments test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --no-create-info test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments test drop table t1, t2; @@ -698,7 +698,7 @@ drop table t1, t2; create table t1 (a text character set utf8, b text character set latin1); insert t1 values (0x4F736E616272C3BC636B, 0x4BF66C6E); select * from t1; ---exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ test +--exec $MYSQL_DUMP --disable-default-character-set --tab=$MYSQLTEST_VARDIR/tmp/ test --exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t1.sql --exec $MYSQL_IMPORT test $MYSQLTEST_VARDIR/tmp/t1.txt select * from t1; @@ -731,7 +731,7 @@ select * from t1; show create table `t1`; ---exec $MYSQL_DUMP --skip-comments test t1 > $MYSQLTEST_VARDIR/tmp/bug19025.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments test t1 > $MYSQLTEST_VARDIR/tmp/bug19025.sql DROP TABLE `t1`; --exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug19025.sql @@ -753,7 +753,7 @@ create table t2(a int); create table t3(a int); --replace_result mysqldump.exe mysqldump --error 6 ---exec $MYSQL_DUMP --skip-comments --force --no-data test t3 t1 non_existing t2 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --force --no-data test t3 t1 non_existing t2 drop table t1, t2, t3; @@ -764,7 +764,7 @@ drop table t1, t2, t3; create table t1 (a int); --replace_result mysqldump.exe mysqldump --error 2 ---exec $MYSQL_DUMP --skip-comments --force test t1 --where="xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 2>&1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --force test t1 --where="xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 2>&1 drop table t1; @@ -782,8 +782,8 @@ CREATE TABLE `t1` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1; insert into t1 values (0815, 4711, 2006); ---exec $MYSQL_DUMP --skip-comments --compatible=ansi --order-by-primary test t1 ---exec $MYSQL_DUMP --skip-comments --order-by-primary test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --compatible=ansi --order-by-primary test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --order-by-primary test t1 DROP TABLE `t1`; --enable_warnings @@ -808,7 +808,7 @@ INSERT INTO t2 VALUES ('bingo'); INSERT INTO t2 VALUES ('waffle'); INSERT INTO t2 VALUES ('lemon'); create view v2 as select * from t2 where a like 'a%' with check option; ---exec $MYSQL_DUMP --skip-comments db1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments db1 drop table t2; drop view v2; drop database db1; @@ -858,7 +858,7 @@ use test; create table t1(a int); create view v1 as select * from t1; ---exec $MYSQL_DUMP --skip-comments test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments test drop view v1; drop table t1; @@ -881,7 +881,7 @@ INSERT INTO t2 VALUES ('bingo'); INSERT INTO t2 VALUES ('waffle'); INSERT INTO t2 VALUES ('lemon'); create view v2 as select * from t2 where a like 'a%' with check option; ---exec $MYSQL_DUMP --skip-comments mysqldump_test_db +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments mysqldump_test_db drop table t2; drop view v2; drop database mysqldump_test_db; @@ -893,7 +893,7 @@ use test; CREATE TABLE t1 (a char(10)); INSERT INTO t1 VALUES ('\''); ---exec $MYSQL_DUMP --skip-comments test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments test t1 DROP TABLE t1; --echo # @@ -913,7 +913,7 @@ select * from v3 where b in (1, 2, 3, 4, 5, 6, 7); create view v2 as select v3.a from v3, v1 where v1.a=v3.a and v3.b=3 limit 1; ---exec $MYSQL_DUMP --skip-comments test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments test drop view v1, v2, v3; drop table t1; @@ -955,11 +955,11 @@ show triggers like "t1"; INSERT INTO t1 (a) VALUES (1),(2),(3),(22); update t1 set a = 4 where a=3; # Triggers should be dumped by default ---exec $MYSQL_DUMP --skip-comments --databases test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --databases test # Skip dumping triggers ---exec $MYSQL_DUMP --skip-comments --databases --skip-triggers test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --databases --skip-triggers test # Dump and reload... ---exec $MYSQL_DUMP --skip-comments --databases test > $MYSQLTEST_VARDIR/tmp/mysqldump.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --databases test > $MYSQLTEST_VARDIR/tmp/mysqldump.sql drop table t1; --exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqldump.sql # Check that tables have been reloaded @@ -1005,7 +1005,7 @@ INSERT INTO `test1` VALUES (1); SELECT * FROM `test2`; # dump ---exec $MYSQL_DUMP --skip-comments --databases test > $MYSQLTEST_VARDIR/tmp/mysqldump.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --databases test > $MYSQLTEST_VARDIR/tmp/mysqldump.sql #DROP TRIGGER testref; #DROP TABLE test1; @@ -1062,7 +1062,7 @@ create procedure `a'b` () select 1; # to fix syntax highlighting :') set sql_mode=''; # Dump the DB and ROUTINES ---exec $MYSQL_DUMP --skip-comments --routines --databases test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --routines --databases test # ok, now blow it all away DROP FUNCTION bug9056_func1; @@ -1090,8 +1090,8 @@ set time_zone='Europe/Moscow'; # results should show two same time values, despite unique select * from t1; set global time_zone='Europe/Moscow'; ---exec $MYSQL_DUMP --skip-comments --databases test ---exec $MYSQL_DUMP --skip-tz-utc --skip-comments --databases test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --databases test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-tz-utc --skip-comments --databases test drop table t1; set global time_zone=default; set time_zone=default; @@ -1124,7 +1124,7 @@ INSERT INTO `t1 test` VALUES (3); SELECT * FROM `t2 test`; # dump with compatible=ansi. Everything except triggers should be double # quoted ---exec $MYSQL_DUMP --skip-comments --compatible=ansi --triggers test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --compatible=ansi --triggers test DROP TRIGGER `test trig`; DROP TABLE `t1 test`; @@ -1147,7 +1147,7 @@ create view v0 as select * from v1; create view v2 as select * from v0; select * from v2; ---exec $MYSQL_DUMP -x --skip-comments --databases test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 -x --skip-comments --databases test drop view v2; drop view v0; @@ -1173,7 +1173,7 @@ DELIMITER ;| SET SQL_MODE = @old_sql_mode; ---exec $MYSQL_DUMP --skip-comments --databases test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --databases test DROP TRIGGER tr1; DROP TABLE t1; @@ -1184,8 +1184,8 @@ DROP TABLE t1; create table t1 (a binary(1), b blob); insert into t1 values ('',''); ---exec $MYSQL_DUMP --skip-comments --skip-extended-insert --hex-blob test t1 ---exec $MYSQL_DUMP --skip-comments --hex-blob test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --skip-extended-insert --hex-blob test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --hex-blob test t1 drop table t1; --echo # @@ -1201,7 +1201,7 @@ create algorithm=merge view v4 as select * from t1 with cascaded check option; create algorithm =temptable view v5 as select * from t1; # dump tables and views ---exec $MYSQL_DUMP test > $MYSQLTEST_VARDIR/tmp/bug14871.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 test > $MYSQLTEST_VARDIR/tmp/bug14871.sql # drop the db, tables and views drop table t1; @@ -1236,7 +1236,7 @@ end| delimiter ;| # dump table and trigger ---exec $MYSQL_DUMP test > $MYSQLTEST_VARDIR/tmp/bug16878.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 test > $MYSQLTEST_VARDIR/tmp/bug16878.sql drop trigger tr1; drop trigger tr2; drop table t1, t2; @@ -1261,7 +1261,7 @@ insert into t values(5, 51); create view v1 as select qty, price, qty*price as value from t; create view v2 as select qty from v1; --echo mysqldump { ---exec $MYSQL_DUMP --compact -F --tab $MYSQLTEST_VARDIR/tmp test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --compact -F --tab $MYSQLTEST_VARDIR/tmp test --cat_file $MYSQLTEST_VARDIR/tmp/v1.sql --echo } mysqldump { --cat_file $MYSQLTEST_VARDIR/tmp/v2.sql @@ -1302,7 +1302,7 @@ drop table t1; --echo mysqldump { --replace_result mysqldump.exe mysqldump --error 2 ---exec $MYSQL_DUMP --force -N --compact --skip-comments test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --force -N --compact --skip-comments test --echo } mysqldump drop view v1; @@ -1319,7 +1319,7 @@ insert into t1 values (1232131); insert into t1 values (4711); insert into t1 values (3231); insert into t1 values (0815); ---exec $MYSQL_DUMP --skip-comments --add-drop-database --databases mysqldump_test_db +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --add-drop-database --databases mysqldump_test_db drop view v1; drop table t1; drop database mysqldump_test_db; @@ -1337,7 +1337,7 @@ create database mysqldump_views; use mysqldump_views; create view nasishnasifu as select mysqldump_tables.basetable.id from mysqldump_tables.basetable; ---exec $MYSQL_DUMP --skip-comments --compact --databases mysqldump_tables mysqldump_views +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --compact --databases mysqldump_tables mysqldump_views drop view nasishnasifu; drop database mysqldump_views; @@ -1360,7 +1360,7 @@ create table t1 (f1 int, f2 int); insert into t1 values (2,2); create view v1 as select f1, f2 from t1; ---exec $MYSQL_DUMP --skip-comments --add-drop-database --databases mysqldump_dba mysqldump_dbb > $MYSQLTEST_VARDIR/tmp/bug20221_backup +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --add-drop-database --databases mysqldump_dba mysqldump_dbb > $MYSQLTEST_VARDIR/tmp/bug20221_backup drop view v1; drop table t1; @@ -1400,13 +1400,13 @@ reset master; # Execute mysqldump, will fail on FLUSH TABLES --replace_result mysqldump.exe mysqldump --error 2 ---exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --compact --master-data -u mysqltest_1 test 2>&1 # Execute mysqldump, will fail on FLUSH TABLES # use --force, should no affect behaviour --replace_result mysqldump.exe mysqldump --error 2 ---exec $MYSQL_DUMP --compact --force --master-data -u mysqltest_1 test 2>&1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --compact --force --master-data -u mysqltest_1 test 2>&1 # Add RELOAD grants grant RELOAD on *.* to mysqltest_1@localhost; @@ -1414,20 +1414,20 @@ grant RELOAD on *.* to mysqltest_1@localhost; # Execute mysqldump, will fail on SHOW MASTER STATUS --replace_result mysqldump.exe mysqldump --error 2 ---exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --compact --master-data -u mysqltest_1 test 2>&1 # Execute mysqldump, will fail on SHOW MASTER STATUS. # use --force, should not alter behaviour --replace_result mysqldump.exe mysqldump --error 2 ---exec $MYSQL_DUMP --compact --force --master-data -u mysqltest_1 test 2>&1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --compact --force --master-data -u mysqltest_1 test 2>&1 # Add REPLICATION CLIENT grants grant REPLICATION CLIENT on *.* to mysqltest_1@localhost; # Execute mysqldump, should now succeed --disable_result_log ---exec $MYSQL_DUMP --compact --master-data -u mysqltest_1 test 2>&1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --compact --master-data -u mysqltest_1 test 2>&1 --enable_result_log # Clean up @@ -1458,7 +1458,7 @@ insert into u1 values (4); create view v1 (c1) as select * from t1; # Backup should not fail for Bug#21527. Flush priviliges test begins. ---exec $MYSQL_DUMP --skip-comments --add-drop-table --flush-privileges --ignore-table=mysql.general_log --ignore-table=mysql.slow_log --ignore-table=mysql.transaction_registry --databases mysqldump_myDB mysql > $MYSQLTEST_VARDIR/tmp/bug21527.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --add-drop-table --flush-privileges --ignore-table=mysql.general_log --ignore-table=mysql.slow_log --ignore-table=mysql.transaction_registry --databases mysqldump_myDB mysql > $MYSQLTEST_VARDIR/tmp/bug21527.sql # Clean up connection root; @@ -1507,7 +1507,7 @@ use test; --echo # --echo # Bug #33762: mysqldump can not dump INFORMATION_SCHEMA --echo # ---exec $MYSQL_DUMP --compact --opt -d information_schema TABLES +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --compact --opt -d information_schema TABLES --echo # --echo # Bug#19745 mysqldump --xml produces invalid xml @@ -1520,7 +1520,7 @@ DROP TABLE IF EXISTS t1; CREATE TABLE t1 (f1 int(10), data MEDIUMBLOB); INSERT INTO t1 VALUES(1,0xff00fef0); ---exec $MYSQL_DUMP --xml --hex-blob --skip-create-options test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --xml --hex-blob --skip-create-options test t1 DROP TABLE t1; @@ -1535,19 +1535,19 @@ INSERT INTO t1 VALUES (1), (2); # too long a file path causes an error --replace_result mysqldump.exe mysqldump --error 1 ---exec $MYSQL_DUMP --tab=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test 2>&1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --tab=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test 2>&1 ---exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-terminated-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --tab=$MYSQLTEST_VARDIR/tmp/ --fields-terminated-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test --replace_result mysqldump.exe mysqldump --error 2 ---exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-enclosed-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --tab=$MYSQLTEST_VARDIR/tmp/ --fields-enclosed-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test --replace_result mysqldump.exe mysqldump --error 2 ---exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-optionally-enclosed-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --tab=$MYSQLTEST_VARDIR/tmp/ --fields-optionally-enclosed-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test --replace_result mysqldump.exe mysqldump --error 2 ---exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-escaped-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test ---exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --lines-terminated-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --tab=$MYSQLTEST_VARDIR/tmp/ --fields-escaped-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --tab=$MYSQLTEST_VARDIR/tmp/ --lines-terminated-by=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa test --remove_file $MYSQLTEST_VARDIR/tmp/t1.sql --remove_file $MYSQLTEST_VARDIR/tmp/t1.txt @@ -1561,7 +1561,7 @@ DROP TABLE t1; CREATE TABLE t2 (a INT) ENGINE=MyISAM; CREATE TABLE t3 (a INT) ENGINE=MyISAM; CREATE TABLE t1 (a INT) ENGINE=merge UNION=(t2, t3); ---exec $MYSQL_DUMP --skip-comments -c test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments -c test DROP TABLE t1, t2, t3; @@ -1582,7 +1582,7 @@ create function f2() returns int return f1(); create view v3 as select bug23491_original.f1(); # Backup. ---exec $MYSQL_DUMP --skip-comments -uroot --opt --routines bug23491_original > $MYSQLTEST_VARDIR/tmp/bug23491_backup.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments -uroot --opt --routines bug23491_original > $MYSQLTEST_VARDIR/tmp/bug23491_backup.sql # Restore. --exec $MYSQL bug23491_restore < $MYSQLTEST_VARDIR/tmp/bug23491_backup.sql @@ -1648,7 +1648,7 @@ DROP TABLE t1; --echo # CREATE VIEW v1 AS SELECT 1; ---exec $MYSQL_DUMP --skip-add-drop-table test > $MYSQLTEST_VARDIR/tmp/bug28524.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-add-drop-table test > $MYSQLTEST_VARDIR/tmp/bug28524.sql DROP VIEW v1; --exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug28524.sql @@ -1673,7 +1673,7 @@ INSERT INTO t2 VALUES (0), (1), (2); SET SQL_MODE = @TMP_SQL_MODE; SELECT * FROM t2; ---exec $MYSQL_DUMP --routines test >$MYSQLTEST_VARDIR/tmp/bug29788.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --routines test >$MYSQLTEST_VARDIR/tmp/bug29788.sql --exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/bug29788.sql SELECT * FROM t2; @@ -1688,15 +1688,15 @@ DROP TABLE t1,t2; --echo # --skip-dump-date: --replace_regex /-- [^D][^u][^m][^p].*// /\/\*!.*// ---exec $MYSQL_DUMP --skip-dump-date test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-dump-date test --echo # --dump-date: --replace_regex /-- [^D][^u][^m][^p].*// /\/\*!.*// / on [0-9 :-]+/ on DATE/ ---exec $MYSQL_DUMP --dump-date test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --dump-date test --echo # --dump-date (default): --replace_regex /-- [^D][^u][^m][^p].*// /\/\*!.*// / on [0-9 :-]+/ on DATE/ ---exec $MYSQL_DUMP test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 test --echo # --echo # Bug #42635: mysqldump includes views that were excluded using @@ -1708,7 +1708,7 @@ use db42635; create table t1 (id int); create view db42635.v1 (c) as select * from db42635.t1; create view db42635.v2 (c) as select * from db42635.t1; ---exec $MYSQL_DUMP --skip-comments --ignore-table=db42635.v1 db42635 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --ignore-table=db42635.v1 db42635 use test; drop database db42635; @@ -1744,7 +1744,7 @@ CREATE TABLE t1(a int, b int); INSERT INTO t1 VALUES (1,1); INSERT INTO t1 VALUES (2,3); INSERT INTO t1 VALUES (3,4), (4,5); ---exec $MYSQL_DUMP --replace --skip-comments test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --replace --skip-comments test t1 DROP TABLE t1; # @@ -1759,7 +1759,7 @@ insert t2 values ("We the people", "in order to perform"); insert t2 values ("a more perfect", "union"); select * from t1; select * from t2; ---exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --tab=$MYSQLTEST_VARDIR/tmp/ test --exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t1.sql --exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/t2.sql # The first load tests the pausing code @@ -1801,7 +1801,7 @@ set time_zone = 'UTC'; create event ee1 on schedule at '2035-12-31 20:01:23' do set @a=5; show events; show create event ee1; ---exec $MYSQL_DUMP --events first > $MYSQLTEST_VARDIR/tmp/bug16853-1.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --events first > $MYSQLTEST_VARDIR/tmp/bug16853-1.sql drop database first; create database second; @@ -1816,7 +1816,7 @@ show create event ee1; create event ee2 on schedule at '2030-12-31 21:01:22' do set @a=5; create event ee3 on schedule at '2030-12-31 22:01:23' do set @a=5; show events; ---exec $MYSQL_DUMP --events second > $MYSQLTEST_VARDIR/tmp/bug16853-2.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --events second > $MYSQLTEST_VARDIR/tmp/bug16853-2.sql drop database second; create database third; @@ -1844,7 +1844,7 @@ insert into t1 values (1232131); insert into t1 values (4711); insert into t1 values (3231); insert into t1 values (0815); ---exec $MYSQL_DUMP --skip-comments --add-drop-database --databases mysqldump_test_db +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --add-drop-database --databases mysqldump_test_db drop view v1; drop table t1; drop database mysqldump_test_db; @@ -1852,7 +1852,7 @@ drop database mysqldump_test_db; # # Bug#26121 mysqldump includes LOCK TABLES general_log WRITE # ---exec $MYSQL_DUMP --all-databases > $MYSQLTEST_VARDIR/tmp/bug26121.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --all-databases > $MYSQLTEST_VARDIR/tmp/bug26121.sql --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug26121.sql --remove_file $MYSQLTEST_VARDIR/tmp/bug26121.sql @@ -1924,7 +1924,7 @@ TRUNCATE mysql.event; USE test; CREATE event e29938 ON SCHEDULE AT '2035-12-31 20:01:23' DO SET @bug29938=29938; SHOW EVENTS; ---exec $MYSQL_DUMP --skip-events --all-databases > $MYSQLTEST_VARDIR/tmp/bug29938.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-events --all-databases > $MYSQLTEST_VARDIR/tmp/bug29938.sql TRUNCATE mysql.event; --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/bug29938.sql @@ -1935,7 +1935,7 @@ SHOW EVENTS; --echo # MDEV-13336: add ignore-database option --echo # with --all-databases --echo # ---exec $MYSQL_DUMP --ignore-database test --all-databases > $MYSQLTEST_VARDIR/tmp/mysqldump-MDEV-13336.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --ignore-database test --all-databases > $MYSQLTEST_VARDIR/tmp/mysqldump-MDEV-13336.sql DROP DATABASE test; --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/mysqldump-MDEV-13336.sql SHOW DATABASES LIKE 'test'; @@ -1979,7 +1979,7 @@ WHERE table_schema = 'mysqldump_test_db' AND table_name = 'v1'; --echo --echo ---> Dumping mysqldump_test_db to bug30217.sql ---exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --databases mysqldump_test_db > $MYSQLTEST_VARDIR/tmp/bug30217.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --character-sets-dir=$MYSQL_SHAREDIR/charsets --databases mysqldump_test_db > $MYSQLTEST_VARDIR/tmp/bug30217.sql --echo @@ -2013,7 +2013,7 @@ DROP DATABASE mysqldump_test_db; create table t1 (a int); create view v1 as select a from t1; ---exec $MYSQL_DUMP --skip-comments --tab=$MYSQLTEST_VARDIR/tmp/ test t1 v1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments --tab=$MYSQLTEST_VARDIR/tmp/ test t1 v1 drop view v1; drop table t1; @@ -2133,17 +2133,17 @@ INSERT INTO t1 VALUES (1, 'ABC-ÐБВ', 'DEF-ÂÃÄ'), (2, NULL, NULL); --replace_result mysqldump.exe mysqldump --error 2 ---exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-enclosed-by='12345' test t1 +--exec $MYSQL_DUMP --disable-default-character-set --tab=$MYSQLTEST_VARDIR/tmp/ --fields-enclosed-by='12345' test t1 --remove_file $file --replace_result mysqldump.exe mysqldump --error 2 ---exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ --fields-escaped-by='12345' test t1 +--exec $MYSQL_DUMP --disable-default-character-set --tab=$MYSQLTEST_VARDIR/tmp/ --fields-escaped-by='12345' test t1 --remove_file $file --echo # default '--default-charset' (binary): ---exec $MYSQL_DUMP --character-sets-dir=$MYSQL_SHAREDIR/charsets --tab=$MYSQLTEST_VARDIR/tmp/ test t1 +--exec $MYSQL_DUMP --disable-default-character-set --character-sets-dir=$MYSQL_SHAREDIR/charsets --tab=$MYSQLTEST_VARDIR/tmp/ test t1 --echo ################################################## --cat_file $file --echo ################################################## @@ -2367,7 +2367,7 @@ CREATE FUNCTION `straße` ( c1 CHAR(20)) RETURNS CHAR(50) DETERMINISTIC RETURN CONCAT(']]>, ', s, '!'); ---exec $MYSQL_DUMP --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=utf8 --compatible=mysql323 -R -X BUG52792 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --character-sets-dir=$CHARSETSDIR --skip-comments --default-character-set=utf8 --compatible=mysql323 -R -X BUG52792 DROP DATABASE BUG52792; @@ -2384,7 +2384,7 @@ USE test; --echo # CREATE TABLE t1 (a INT); # no_t = no_table_options; no_f = no_field_options ---exec $MYSQL_DUMP --compatible=no_t,no_f --skip-comments test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --compatible=no_t,no_f --skip-comments test DROP TABLE t1; --echo # @@ -2415,7 +2415,7 @@ INSERT INTO b12809202_db.t2 VALUES (1), (2), (3); # mixing of normal (stdout) and --verbose (stderr) output will happen in random # order depending on stdio internal buffer size. --replace_regex /-- Server version.*// /-- MySQL dump .*// /-- Dump completed on .*/-- Dump completed/ ---exec $MYSQL_DUMP --verbose --single-transaction --flush-logs b12809202_db 2>&1 > $MYSQLTEST_VARDIR/tmp/bug61854.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --verbose --single-transaction --flush-logs b12809202_db 2>&1 > $MYSQLTEST_VARDIR/tmp/bug61854.sql --echo --echo #### Dump ends here #### @@ -2440,7 +2440,7 @@ SET @old_general_log_state= @@global.general_log; SET @old_slow_query_log_state= @@global.slow_query_log; call mtr.add_suppression("Failed to write to mysql.general_log"); ---exec $MYSQL_DUMP -uroot --all-databases > $MYSQLTEST_VARDIR/tmp/bug45740.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 -uroot --all-databases > $MYSQLTEST_VARDIR/tmp/bug45740.sql # Make log_output as table and disabling general_log and slow_log SET @@global.log_output="TABLE"; SET @@global.general_log='OFF'; @@ -2460,7 +2460,7 @@ SET @@global.general_log= @old_general_log_state; create table t1 (g GEOMETRY) CHARSET koi8r; create table t2 (g GEOMETRY) CHARSET koi8r; insert into t1 values (point(1,1)), (point(2,2)); ---exec $MYSQL_DUMP --hex-blob --character-sets-dir=$MYSQL_SHAREDIR/charsets --tab=$MYSQLTEST_VARDIR/tmp/ test t1 +--exec $MYSQL_DUMP --disable-default-character-set --hex-blob --character-sets-dir=$MYSQL_SHAREDIR/charsets --tab=$MYSQLTEST_VARDIR/tmp/ test t1 --echo ################################################## --cat_file $file --echo ################################################## @@ -2488,7 +2488,7 @@ INSERT INTO t2 VALUES (3), (4); SELECT * FROM t1; SELECT * FROM t2; ---exec $MYSQL_DUMP --tab=$MYSQLTEST_VARDIR/tmp/ db_20772273 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --tab=$MYSQLTEST_VARDIR/tmp/ db_20772273 --exec $MYSQL db_20772273 < $MYSQLTEST_VARDIR/tmp/t1.sql --exec $MYSQL db_20772273 < $MYSQLTEST_VARDIR/tmp/t2.sql @@ -2543,7 +2543,7 @@ SELECT ROUTINE_NAME FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_SCHEMA='bug25717383' AND ROUTINE_TYPE= 'PROCEDURE' ORDER BY ROUTINE_NAME; ---exec $MYSQL_DUMP --triggers --events --routines --add-drop-database --databases bug25717383 > $MYSQLTEST_VARDIR/tmp/bug25717383.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --triggers --events --routines --add-drop-database --databases bug25717383 > $MYSQLTEST_VARDIR/tmp/bug25717383.sql SHOW TABLES FROM bug25717383; --replace_column 6 # @@ -2561,14 +2561,14 @@ DROP DATABASE bug25717383; # MDEV-6091 mysqldump goes in a loop and segfaults if --dump-slave is specified and it cannot connect to the server # --error 2 ---exec $MYSQL_DUMP -hunknownhost --dump-slave nulldb +--exec $MYSQL_DUMP --default-character-set=utf8mb4 -hunknownhost --dump-slave nulldb # # MDEV-6056 [PATCH] mysqldump writes usage to stdout even when not explicitly requested # --replace_result mysqldump.exe mysqldump --error 1 ---exec $MYSQL_DUMP --user=foo 2>&1 > $MYSQLTEST_VARDIR/tmp/bug6056.out +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --user=foo 2>&1 > $MYSQLTEST_VARDIR/tmp/bug6056.out --exec $MYSQL_DUMP --help > $MYSQLTEST_VARDIR/tmp/bug6056.out --echo # @@ -2596,8 +2596,8 @@ use test; create table t1 (a int); insert into t1 values (1); ---exec $MYSQL_DUMP --hex-blob --character-sets-dir=$MYSQL_SHAREDIR/charsets --tab=$MYSQLTEST_VARDIR/tmp/ test t1 ---exec $MYSQL_DUMP --disable-log-queries --skip-comments test t1 >$MYSQLTEST_VARDIR/tmp/mysqldump-test.out +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --hex-blob --character-sets-dir=$MYSQL_SHAREDIR/charsets --tab=$MYSQLTEST_VARDIR/tmp/ test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --disable-log-queries --skip-comments test t1 >$MYSQLTEST_VARDIR/tmp/mysqldump-test.out drop table t1; --exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mysqldump-test.out @@ -2658,7 +2658,7 @@ CREATE FUNCTION f() RETURNS INT RETURN 1; CREATE VIEW v1 AS SELECT f(); --echo # Running mysqldump -uroot test --routines --tables v1 > **vardir**/test.dmp ---exec $MYSQL_DUMP -uroot test --routines --tables v1 > $MYSQLTEST_VARDIR/test.dmp +--exec $MYSQL_DUMP --default-character-set=utf8mb4 -uroot test --routines --tables v1 > $MYSQLTEST_VARDIR/test.dmp DROP VIEW v1; DROP FUNCTION f; @@ -2709,7 +2709,7 @@ CREATE TRIGGER tt1_t1 BEFORE INSERT ON t1 FOR EACH ROW SET NEW.b=NEW.a + 10; INSERT INTO t1 (a) VALUES (1),(2),(3); ---exec $MYSQL_DUMP --triggers --no-data --no-create-info --add-drop-trigger --skip-comments --databases test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --triggers --no-data --no-create-info --add-drop-trigger --skip-comments --databases test DROP TABLE t1; --echo # --echo # Test for Invisible columns @@ -2740,10 +2740,10 @@ insert into t4 values(1); --echo #Check side effect on --complete insert --exec $MYSQL_DUMP --compact --complete-insert d --echo #Check xml ---exec $MYSQL_DUMP --skip-create-options --skip-comments -X d +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-create-options --skip-comments -X d #import data ---exec $MYSQL_DUMP --skip-comments d > $MYSQLTEST_VARDIR/tmp/invisible_dump.sql +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-comments d > $MYSQLTEST_VARDIR/tmp/invisible_dump.sql DROP table t1,t2,t3; --exec $MYSQL d < $MYSQLTEST_VARDIR/tmp/invisible_dump.sql diff --git a/mysql-test/main/named_pipe.result b/mysql-test/main/named_pipe.result index 66da9a874b4..f8c2acf98a0 100644 --- a/mysql-test/main/named_pipe.result +++ b/mysql-test/main/named_pipe.result @@ -1348,8 +1348,10 @@ fld1 fld1 250503 250505 250504 250505 250505 250505 -SET @save_optimizer_switch=@@optimizer_switch; -SET optimizer_switch='outer_join_with_cache=off'; +SET @local_optimizer_switch=@@optimizer_switch; +set @local_join_cache_level=@@join_cache_level; +set @@join_cache_level=2; +set optimizer_switch='outer_join_with_cache=off,join_cache_hashed=off'; insert into t2 (fld1, companynr) values (999999,99); select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; companynr companyname @@ -1425,7 +1427,7 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -SET optimizer_switch=@save_optimizer_switch; +SET @@optimizer_switch=@local_optimizer_switch; select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; companynr companynr 37 36 @@ -1434,6 +1436,7 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr= id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join) +SET @@join_cache_level=@local_join_cache_level; select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; fld1 companynr fld3 period 038008 37 reporters 1008 diff --git a/mysql-test/main/openssl_1.test b/mysql-test/main/openssl_1.test index 27eeb0198b1..b70d2018c9e 100644 --- a/mysql-test/main/openssl_1.test +++ b/mysql-test/main/openssl_1.test @@ -166,17 +166,17 @@ CREATE TABLE t1(a int); INSERT INTO t1 VALUES (1), (2); # Run mysqldump ---exec $MYSQL_DUMP --skip-create-options --skip-comments --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test t1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-create-options --skip-comments --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test t1 ---exec $MYSQL_DUMP --skip-create-options --skip-comments --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-create-options --skip-comments --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test ---exec $MYSQL_DUMP --skip-create-options --skip-comments --ssl --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-create-options --skip-comments --ssl --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test # With wrong parameters --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR mysqldump.exe mysqldump --replace_regex /SSL connection error.*/SSL connection error: xxxx/ --error 2 ---exec $MYSQL_DUMP --skip-create-options --skip-comments --ssl --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test 2>&1 +--exec $MYSQL_DUMP --default-character-set=utf8mb4 --skip-create-options --skip-comments --ssl --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test 2>&1 --echo DROP TABLE t1; --remove_file $MYSQLTEST_VARDIR/tmp/test.sql diff --git a/mysql-test/main/opt_tvc.test b/mysql-test/main/opt_tvc.test index 733ee0792fe..911dc997892 100644 --- a/mysql-test/main/opt_tvc.test +++ b/mysql-test/main/opt_tvc.test @@ -2,6 +2,7 @@ # MDEV-12176 Transform [NOT] IN predicate with long list of values INTO [NOT] IN subquery # source include/have_debug.inc; +--source include/default_optimizer_switch.inc create table t1 (a int, b int); diff --git a/mysql-test/main/partition_example.opt b/mysql-test/main/partition_example.opt new file mode 100644 index 00000000000..8374626febe --- /dev/null +++ b/mysql-test/main/partition_example.opt @@ -0,0 +1 @@ +--plugin-maturity=unknown diff --git a/mysql-test/main/partition_innodb.test b/mysql-test/main/partition_innodb.test index f1a25b91c5b..629bc29e758 100644 --- a/mysql-test/main/partition_innodb.test +++ b/mysql-test/main/partition_innodb.test @@ -1,6 +1,7 @@ --source include/not_embedded.inc --source include/have_partition.inc --source include/have_innodb.inc +--source include/default_optimizer_switch.inc call mtr.add_suppression("Deadlock found when trying to get lock; try restarting transaction"); diff --git a/mysql-test/main/partition_key_cache.result b/mysql-test/main/partition_key_cache.result index f1b174ca249..fae7639d9bb 100644 --- a/mysql-test/main/partition_key_cache.result +++ b/mysql-test/main/partition_key_cache.result @@ -1,9 +1,7 @@ DROP TABLE IF EXISTS t1, t2, v, x; # Actual test of key caches # Verifing that reads/writes use the key cache correctly -SELECT @org_key_cache_buffer_size:= @@global.default.key_buffer_size; -@org_key_cache_buffer_size:= @@global.default.key_buffer_size -1048576 +SET @org_key_cache_buffer_size= @@global.default.key_buffer_size; # Minimize default key cache (almost disabled). SET @@global.default.key_buffer_size = 4096; CREATE TABLE t1 ( diff --git a/mysql-test/main/partition_key_cache.test b/mysql-test/main/partition_key_cache.test index 067eb7fae59..365a571ae92 100644 --- a/mysql-test/main/partition_key_cache.test +++ b/mysql-test/main/partition_key_cache.test @@ -7,7 +7,7 @@ DROP TABLE IF EXISTS t1, t2, v, x; --echo # Actual test of key caches --echo # Verifing that reads/writes use the key cache correctly -SELECT @org_key_cache_buffer_size:= @@global.default.key_buffer_size; +SET @org_key_cache_buffer_size= @@global.default.key_buffer_size; --echo # Minimize default key cache (almost disabled). SET @@global.default.key_buffer_size = 4096; CREATE TABLE t1 ( diff --git a/mysql-test/main/partition_pruning.test b/mysql-test/main/partition_pruning.test index 2879b0eae6c..1770f028f31 100644 --- a/mysql-test/main/partition_pruning.test +++ b/mysql-test/main/partition_pruning.test @@ -3,6 +3,7 @@ # prune, so the test is EXPLAINs. # -- source include/have_partition.inc +--source include/default_optimizer_switch.inc --disable_warnings drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; diff --git a/mysql-test/main/plugin.opt b/mysql-test/main/plugin.opt new file mode 100644 index 00000000000..8374626febe --- /dev/null +++ b/mysql-test/main/plugin.opt @@ -0,0 +1 @@ +--plugin-maturity=unknown diff --git a/mysql-test/main/plugin_innodb.opt b/mysql-test/main/plugin_innodb.opt new file mode 100644 index 00000000000..8374626febe --- /dev/null +++ b/mysql-test/main/plugin_innodb.opt @@ -0,0 +1 @@ +--plugin-maturity=unknown diff --git a/mysql-test/main/plugin_load.opt b/mysql-test/main/plugin_load.opt index aeeb2e4eb7d..4e8881b1b32 100644 --- a/mysql-test/main/plugin_load.opt +++ b/mysql-test/main/plugin_load.opt @@ -1,3 +1,4 @@ +--plugin-maturity=unknown --plugin-load-add=$DIALOG_EXAMPLES_SO --plugin-load=$LIBDAEMON_EXAMPLE_SO --plugin-load-add=EXAMPLE=$HA_EXAMPLE_SO diff --git a/mysql-test/main/plugin_load_option.opt b/mysql-test/main/plugin_load_option.opt index be9bc9d5487..bd9843c7d11 100644 --- a/mysql-test/main/plugin_load_option.opt +++ b/mysql-test/main/plugin_load_option.opt @@ -1,2 +1,3 @@ +--plugin-maturity=unknown --plugin-load-add=EXAMPLE=$HA_EXAMPLE_SO --loose-plugin-example=FORCE_PLUS_PERMANENT diff --git a/mysql-test/main/plugin_not_embedded.opt b/mysql-test/main/plugin_not_embedded.opt new file mode 100644 index 00000000000..8374626febe --- /dev/null +++ b/mysql-test/main/plugin_not_embedded.opt @@ -0,0 +1 @@ +--plugin-maturity=unknown diff --git a/mysql-test/main/pool_of_threads.result b/mysql-test/main/pool_of_threads.result index b25d8d1e50e..9c02dfac9cd 100644 --- a/mysql-test/main/pool_of_threads.result +++ b/mysql-test/main/pool_of_threads.result @@ -1,4 +1,3 @@ -SET @save_optimizer_switch=@@optimizer_switch; SET optimizer_switch='outer_join_with_cache=off'; drop table if exists t1,t2,t3,t4; CREATE TABLE t1 ( @@ -1349,8 +1348,10 @@ fld1 fld1 250503 250505 250504 250505 250505 250505 -SET @save_optimizer_switch=@@optimizer_switch; -SET optimizer_switch='outer_join_with_cache=off'; +SET @local_optimizer_switch=@@optimizer_switch; +set @local_join_cache_level=@@join_cache_level; +set @@join_cache_level=2; +set optimizer_switch='outer_join_with_cache=off,join_cache_hashed=off'; insert into t2 (fld1, companynr) values (999999,99); select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; companynr companyname @@ -1426,7 +1427,7 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -SET optimizer_switch=@save_optimizer_switch; +SET @@optimizer_switch=@local_optimizer_switch; select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; companynr companynr 37 36 @@ -1435,6 +1436,7 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr= id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join) +SET @@join_cache_level=@local_join_cache_level; select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; fld1 companynr fld3 period 038008 37 reporters 1008 @@ -2156,7 +2158,7 @@ Privat (Private Nutzung) Mobilfunk Warnings: Warning 1052 Column 'kundentyp' in group statement is ambiguous drop table t1; -SET optimizer_switch=@save_optimizer_switch; +SET optimizer_switch=default; connection default; SELECT sleep(50); connect con2,localhost,root,,; diff --git a/mysql-test/main/pool_of_threads.test b/mysql-test/main/pool_of_threads.test index f13a096985c..cb62a27faeb 100644 --- a/mysql-test/main/pool_of_threads.test +++ b/mysql-test/main/pool_of_threads.test @@ -2,13 +2,14 @@ # and run a number of tests -- source include/have_pool_of_threads.inc -SET @save_optimizer_switch=@@optimizer_switch; +-- source include/default_optimizer_switch.inc + SET optimizer_switch='outer_join_with_cache=off'; # Slow test, don't run during staging part -- source include/not_staging.inc -- source include/long_test.inc -- source include/common-tests.inc -SET optimizer_switch=@save_optimizer_switch; +SET optimizer_switch=default; # Test that we cannot have more simultaneous connections than # --thread-pool-size on the standard port, but _can_ have additional diff --git a/mysql-test/main/ps-master.opt b/mysql-test/main/ps-master.opt index 2ae67eedad8..0fa6f43b7ef 100644 --- a/mysql-test/main/ps-master.opt +++ b/mysql-test/main/ps-master.opt @@ -1 +1 @@ ---log-output=table,file --slow-query-log --log-queries-not-using-indexes --general-log +--log-output=table,file --slow-query-log --log-queries-not-using-indexes --general-log --character-set-server=latin1 --collation_server=latin1_swedish_ci --sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test index 6677c3d8b2a..85ff887f40b 100644 --- a/mysql-test/main/ps.test +++ b/mysql-test/main/ps.test @@ -1814,7 +1814,6 @@ drop database mysqltest_1; deallocate prepare stmt; set @@character_set_server= @old_character_set_server; - # # BUG#24491 "using alias from source table in insert ... on duplicate key" # diff --git a/mysql-test/main/query_cache.result b/mysql-test/main/query_cache.result index 9c010cbffc7..8c6d281f7ba 100644 --- a/mysql-test/main/query_cache.result +++ b/mysql-test/main/query_cache.result @@ -1,3 +1,4 @@ +set @save_query_cache_size=@@query_cache_size; SET GLOBAL query_cache_type= Off; SET LOCAL query_cache_type= Off; SET LOCAL query_cache_type= 0; @@ -1634,7 +1635,7 @@ show status like 'Qcache_queries_in_cache'; Variable_name Value Qcache_queries_in_cache 0 drop database db2; -set global query_cache_size=default; +set global query_cache_size=@save_query_cache_size; drop database if exists db1; drop database if exists db3; set GLOBAL query_cache_size=15*1024*1024; @@ -1669,7 +1670,7 @@ drop database db3; set GLOBAL query_cache_type=default; set GLOBAL query_cache_limit=default; set GLOBAL query_cache_min_res_unit=default; -set GLOBAL query_cache_size=default; +set GLOBAL query_cache_size=@save_query_cache_size; set local query_cache_type=default; set GLOBAL query_cache_type=on; set local query_cache_type=on; @@ -1949,6 +1950,7 @@ select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type; # MDEV-4981: Account for queries handled by query-cache in # USER_STATISTICS (and in HOST_STATISTICS) # +set @save_userstat=@@global.userstat; SET GLOBAL userstat=1; set GLOBAL query_cache_size=1355776; FLUSH USER_STATISTICS; @@ -2089,7 +2091,7 @@ Qcache_hits 0 drop procedure p1; drop table t1; set GLOBAL query_cache_size=1355776; -SET GLOBAL userstat=default; +SET GLOBAL userstat=@save_userstat; End of 5.5 tests # # Bug#12977203: SERVER CRASH ON A DERIVED TABLE WITH QUERY CACHE ENABLED @@ -2189,5 +2191,4 @@ DROP FUNCTION foo; drop table t1; restore defaults SET GLOBAL query_cache_type= default; -SET GLOBAL query_cache_size= default; -SET LOCAL query_cache_type= default; +SET GLOBAL query_cache_size=@save_query_cache_size; diff --git a/mysql-test/main/query_cache.test b/mysql-test/main/query_cache.test index 1b1e24bc6f4..4091b8406fa 100644 --- a/mysql-test/main/query_cache.test +++ b/mysql-test/main/query_cache.test @@ -1,6 +1,7 @@ -- source include/have_query_cache.inc -- source include/long_test.inc +set @save_query_cache_size=@@query_cache_size; # # Tests with query cache # @@ -1236,7 +1237,7 @@ set session query_cache_type=on; drop database db1; show status like 'Qcache_queries_in_cache'; drop database db2; - set global query_cache_size=default; + set global query_cache_size=@save_query_cache_size; --disable_warnings drop database if exists db1; @@ -1266,7 +1267,7 @@ set session query_cache_type=on; set GLOBAL query_cache_type=default; set GLOBAL query_cache_limit=default; set GLOBAL query_cache_min_res_unit=default; -set GLOBAL query_cache_size=default; +set GLOBAL query_cache_size=@save_query_cache_size; set local query_cache_type=default; set GLOBAL query_cache_type=on; set local query_cache_type=on; @@ -1632,6 +1633,7 @@ select @@query_cache_size, @@global.query_cache_type, @@local.query_cache_type; --echo # USER_STATISTICS (and in HOST_STATISTICS) --echo # +set @save_userstat=@@global.userstat; SET GLOBAL userstat=1; set GLOBAL query_cache_size=1355776; FLUSH USER_STATISTICS; @@ -1716,7 +1718,7 @@ show status like "Qcache_hits"; drop procedure p1; drop table t1; set GLOBAL query_cache_size=1355776; -SET GLOBAL userstat=default; +SET GLOBAL userstat=@save_userstat; --echo End of 5.5 tests @@ -1784,5 +1786,4 @@ drop table t1; --echo restore defaults SET GLOBAL query_cache_type= default; -SET GLOBAL query_cache_size= default; -SET LOCAL query_cache_type= default; +SET GLOBAL query_cache_size=@save_query_cache_size; diff --git a/mysql-test/main/query_cache_debug.result b/mysql-test/main/query_cache_debug.result index 2a54f073974..e365984986a 100644 --- a/mysql-test/main/query_cache_debug.result +++ b/mysql-test/main/query_cache_debug.result @@ -1,4 +1,6 @@ set global query_cache_type= ON; +set @save_query_cache_size=@@global.query_cache_size; +SET @save_concurrent_insert= @@GLOBAL.concurrent_insert; flush status; set query_cache_type=DEMAND; set global query_cache_size= 1024*768; @@ -37,8 +39,6 @@ set debug_sync= 'RESET'; set global query_cache_size= 0; use test; drop table t1; -SET @old_concurrent_insert= @@GLOBAL.concurrent_insert; -SET @old_query_cache_size= @@GLOBAL.query_cache_size; DROP TABLE IF EXISTS t1, t2; CREATE TABLE t1 (a INT); CREATE TABLE t2 (a INT); @@ -214,7 +214,6 @@ SET GLOBAL query_cache_type= DEFAULT; # # Bug#56822: Add a thread state for sessions waiting on the query cache lock # -SET @old_query_cache_size= @@GLOBAL.query_cache_size; DROP TABLE IF EXISTS t1; CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2),(3); @@ -246,7 +245,7 @@ connection default; SET DEBUG_SYNC= 'RESET'; RESET QUERY CACHE; DROP TABLE t1; -SET GLOBAL query_cache_size= DEFAULT; +SET GLOBAL query_cache_size= @save_query_cache_size; SET GLOBAL query_cache_type= DEFAULT; # # MDEV-14526: MariaDB keeps crashing under load when @@ -270,7 +269,7 @@ SELECT DISTINCT id FROM t1 WHERE id BETWEEN 5603 AND 16218 ORDER BY k; connection default; set debug_sync="now WAIT_FOR parked"; connection con2; -SET GLOBAL query_cache_type= 0; +SET GLOBAL query_cache_type= 0;; connection default; set debug_sync="now SIGNAL go"; connection con1; @@ -281,6 +280,7 @@ disconnect con2; connection default; set debug_sync= 'RESET'; DROP TABLE t1; -SEt GLOBAL query_cache_size= DEFAULT; -SEt GLOBAL query_cache_type= DEFAULT; +SET GLOBAL query_cache_size=@save_query_cache_size; +SET GLOBAL query_cache_type= DEFAULT; +SET @@GLOBAL.concurrent_insert=@save_concurrent_insert; # End of 5.5 tests diff --git a/mysql-test/main/query_cache_debug.test b/mysql-test/main/query_cache_debug.test index 22ff1d45e63..90b76077cac 100644 --- a/mysql-test/main/query_cache_debug.test +++ b/mysql-test/main/query_cache_debug.test @@ -4,6 +4,9 @@ --source include/long_test.inc set global query_cache_type= ON; +set @save_query_cache_size=@@global.query_cache_size; +SET @save_concurrent_insert= @@GLOBAL.concurrent_insert; + # # Bug #30887 Server crashes on SET GLOBAL query_cache_size=0 # @@ -53,9 +56,6 @@ drop table t1; # Bug#41098: Query Cache returns wrong result with concurrent insert # -SET @old_concurrent_insert= @@GLOBAL.concurrent_insert; -SET @old_query_cache_size= @@GLOBAL.query_cache_size; - --disable_warnings DROP TABLE IF EXISTS t1, t2; --enable_warnings @@ -247,8 +247,6 @@ SET GLOBAL query_cache_type= DEFAULT; --echo # Bug#56822: Add a thread state for sessions waiting on the query cache lock --echo # -SET @old_query_cache_size= @@GLOBAL.query_cache_size; - --disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings @@ -297,7 +295,7 @@ connection default; SET DEBUG_SYNC= 'RESET'; RESET QUERY CACHE; DROP TABLE t1; -SET GLOBAL query_cache_size= DEFAULT; +SET GLOBAL query_cache_size= @save_query_cache_size; SET GLOBAL query_cache_type= DEFAULT; --echo # @@ -322,16 +320,13 @@ SET GLOBAL query_cache_type= 1; --connect (con2,localhost,root,,test) --connect (con1,localhost,root,,test) set debug_sync="wait_in_query_cache_store_query SIGNAL parked WAIT_FOR go"; ---send - - SELECT DISTINCT id FROM t1 WHERE id BETWEEN 5603 AND 16218 ORDER BY k; +--send SELECT DISTINCT id FROM t1 WHERE id BETWEEN 5603 AND 16218 ORDER BY k --connection default set debug_sync="now WAIT_FOR parked"; --connection con2 ---send - SET GLOBAL query_cache_type= 0; +--send SET GLOBAL query_cache_type= 0; --connection default set debug_sync="now SIGNAL go"; @@ -347,7 +342,8 @@ set debug_sync="now SIGNAL go"; --connection default set debug_sync= 'RESET'; DROP TABLE t1; -SEt GLOBAL query_cache_size= DEFAULT; -SEt GLOBAL query_cache_type= DEFAULT; +SET GLOBAL query_cache_size=@save_query_cache_size; +SET GLOBAL query_cache_type= DEFAULT; +SET @@GLOBAL.concurrent_insert=@save_concurrent_insert; --echo # End of 5.5 tests diff --git a/mysql-test/main/query_cache_innodb.result b/mysql-test/main/query_cache_innodb.result index 146a6fbc289..62424ac362b 100644 --- a/mysql-test/main/query_cache_innodb.result +++ b/mysql-test/main/query_cache_innodb.result @@ -1,3 +1,4 @@ +set @save_query_cache_size=@@query_cache_size; # # MDEV-12485: foreign key on delete cascade stale entries with # query cache enabled @@ -86,5 +87,5 @@ drop database `#mysql50#-`; SET NAMES default; FOUND 8 /\[ERROR\] Invalid \(old\?\) table or database name/ in mysqld.1.err set global query_cache_type=DEFAULT; -set global query_cache_size=DEFAULT; +set global query_cache_size=@save_query_cache_size; End of 10.2 tests diff --git a/mysql-test/main/query_cache_innodb.test b/mysql-test/main/query_cache_innodb.test index ba62ec36c16..72ae891e331 100644 --- a/mysql-test/main/query_cache_innodb.test +++ b/mysql-test/main/query_cache_innodb.test @@ -2,6 +2,8 @@ --source include/have_query_cache.inc --source include/not_embedded.inc +set @save_query_cache_size=@@query_cache_size; + --echo # --echo # MDEV-12485: foreign key on delete cascade stale entries with --echo # query cache enabled @@ -81,5 +83,5 @@ call mtr.add_suppression("\\[ERROR\\] Invalid \\(old\\?\\) table or database nam --source include/search_pattern_in_file.inc set global query_cache_type=DEFAULT; -set global query_cache_size=DEFAULT; +set global query_cache_size=@save_query_cache_size; --echo End of 10.2 tests diff --git a/mysql-test/main/query_cache_merge.result b/mysql-test/main/query_cache_merge.result index e31ab05b396..39e70abb51f 100644 --- a/mysql-test/main/query_cache_merge.result +++ b/mysql-test/main/query_cache_merge.result @@ -1,3 +1,5 @@ +set @save_query_cache_size=@@global.query_cache_size; +set @save_query_cache_type=@@global.query_cache_type; SET GLOBAL query_cache_type=ON; SET LOCAL query_cache_type=ON; SET @@global.query_cache_size=1355776; @@ -1692,7 +1694,7 @@ DROP TABLE t4; DROP TABLE t3; DROP TABLE t2; DROP TABLE t1; -SET @@global.query_cache_size = default; +SET @@global.query_cache_size = @save_query_cache_size; SET @@global.table_definition_cache = @save_table_definition_cache; -SET GLOBAL query_cache_type=default; +SET @@global.query_cache_type = @save_query_cache_type; End of 5.1 tests diff --git a/mysql-test/main/query_cache_merge.test b/mysql-test/main/query_cache_merge.test index 3046c4ecbfe..6212ff624e0 100644 --- a/mysql-test/main/query_cache_merge.test +++ b/mysql-test/main/query_cache_merge.test @@ -1,5 +1,8 @@ # Test query cache with many tables +set @save_query_cache_size=@@global.query_cache_size; +set @save_query_cache_type=@@global.query_cache_type; + SET GLOBAL query_cache_type=ON; SET LOCAL query_cache_type=ON; @@ -105,8 +108,7 @@ while ($c) dec $c; } -SET @@global.query_cache_size = default; +SET @@global.query_cache_size = @save_query_cache_size; SET @@global.table_definition_cache = @save_table_definition_cache; - -SET GLOBAL query_cache_type=default; +SET @@global.query_cache_type = @save_query_cache_type; --echo End of 5.1 tests diff --git a/mysql-test/main/query_cache_notembedded.result b/mysql-test/main/query_cache_notembedded.result index bfb8f4d1ff7..29a091b68c1 100644 --- a/mysql-test/main/query_cache_notembedded.result +++ b/mysql-test/main/query_cache_notembedded.result @@ -409,9 +409,7 @@ disconnect bug30269; DROP USER 'bug30269'@'localhost'; set GLOBAL query_cache_type=ON; set LOCAL query_cache_type=ON; -set GLOBAL query_cache_limit=default; -set GLOBAL query_cache_min_res_unit=default; -set GLOBAL query_cache_size=default; +set GLOBAL query_cache_size=@query_cache_size_save; drop table if exists t1| create table t1 ( id char(16) not null default '', diff --git a/mysql-test/main/query_cache_notembedded.test b/mysql-test/main/query_cache_notembedded.test index dff6c2a139b..03c9d9e4cd4 100644 --- a/mysql-test/main/query_cache_notembedded.test +++ b/mysql-test/main/query_cache_notembedded.test @@ -4,7 +4,6 @@ # Save the initial number of concurrent sessions --source include/count_sessions.inc - # # Tests with query cache # @@ -277,9 +276,7 @@ DROP USER 'bug30269'@'localhost'; set GLOBAL query_cache_type=ON; set LOCAL query_cache_type=ON; -set GLOBAL query_cache_limit=default; -set GLOBAL query_cache_min_res_unit=default; -set GLOBAL query_cache_size=default; +set GLOBAL query_cache_size=@query_cache_size_save; # # Bug#3583 query cache doesn't work for stored procedures @@ -333,4 +330,3 @@ delimiter ;| SET GLOBAL query_cache_size=@query_cache_size_save; SET GLOBAL query_cache_type=@query_cache_type_save; set GLOBAL sql_mode=@sql_mode_save; - diff --git a/mysql-test/main/query_cache_ps_no_prot.test b/mysql-test/main/query_cache_ps_no_prot.test index 4b2bb842e34..61388b0f97a 100644 --- a/mysql-test/main/query_cache_ps_no_prot.test +++ b/mysql-test/main/query_cache_ps_no_prot.test @@ -12,6 +12,8 @@ # We cannot run on embedded server because we use multiple sessions. --source include/not_embedded.inc --source include/have_query_cache.inc +--source include/default_charset.inc + let collation=utf8_unicode_ci; --source include/have_collation.inc diff --git a/mysql-test/main/query_cache_with_views.result b/mysql-test/main/query_cache_with_views.result index 763113dbac3..8cb3d8cb297 100644 --- a/mysql-test/main/query_cache_with_views.result +++ b/mysql-test/main/query_cache_with_views.result @@ -1,5 +1,7 @@ drop table if exists t1,t2,v1,v2,v3; drop view if exists t1,t2,v1,v2,v3; +set @save_query_cache_size=@@global.query_cache_size; +set @save_query_cache_type=@@global.query_cache_type; set GLOBAL query_cache_type=ON; set LOCAL query_cache_type=ON; set GLOBAL query_cache_size=1355776; @@ -208,5 +210,5 @@ DROP TABLE t1; DROP TABLE t2; DROP VIEW t1_view; SET AUTOCOMMIT=DEFAULT; -set GLOBAL query_cache_size=default; -set GLOBAL query_cache_type=default; +set GLOBAL query_cache_size=@save_query_cache_size; +set GLOBAL query_cache_type=@save_query_cache_type; diff --git a/mysql-test/main/query_cache_with_views.test b/mysql-test/main/query_cache_with_views.test index 9b03d0e99d0..c55327e3d0a 100644 --- a/mysql-test/main/query_cache_with_views.test +++ b/mysql-test/main/query_cache_with_views.test @@ -6,6 +6,9 @@ drop table if exists t1,t2,v1,v2,v3; drop view if exists t1,t2,v1,v2,v3; --enable_warnings + +set @save_query_cache_size=@@global.query_cache_size; +set @save_query_cache_type=@@global.query_cache_type; set GLOBAL query_cache_type=ON; set LOCAL query_cache_type=ON; set GLOBAL query_cache_size=1355776; @@ -145,5 +148,5 @@ DROP VIEW t1_view; SET AUTOCOMMIT=DEFAULT; # Reset default environment. -set GLOBAL query_cache_size=default; -set GLOBAL query_cache_type=default; +set GLOBAL query_cache_size=@save_query_cache_size; +set GLOBAL query_cache_type=@save_query_cache_type; diff --git a/mysql-test/main/range.result b/mysql-test/main/range.result index 32e0cf2868c..3ad577c79e9 100644 --- a/mysql-test/main/range.result +++ b/mysql-test/main/range.result @@ -1,3 +1,4 @@ +SET optimizer_use_condition_selectivity=1; CREATE TABLE t1 ( event_date date DEFAULT '0000-00-00' NOT NULL, type int(11) DEFAULT '0' NOT NULL, diff --git a/mysql-test/main/range.test b/mysql-test/main/range.test index bd2299bac5f..1cc7a2b6928 100644 --- a/mysql-test/main/range.test +++ b/mysql-test/main/range.test @@ -2,6 +2,7 @@ # Problem with range optimizer # --source include/have_innodb.inc +SET optimizer_use_condition_selectivity=1; CREATE TABLE t1 ( event_date date DEFAULT '0000-00-00' NOT NULL, diff --git a/mysql-test/main/range_interrupted-13751.test b/mysql-test/main/range_interrupted-13751.test index 000a46383e8..8b2c1834ee5 100644 --- a/mysql-test/main/range_interrupted-13751.test +++ b/mysql-test/main/range_interrupted-13751.test @@ -1,4 +1,6 @@ -source include/have_debug.inc; +-- source include/have_debug.inc +--source include/default_optimizer_switch.inc + # # MDEV-13751 Interrupted SELECT fails with 1030: 'Got error 1 "Operation not permitted" from storage engine MyISAM' # diff --git a/mysql-test/main/range_mrr_icp.result b/mysql-test/main/range_mrr_icp.result index 6b5bf33239f..05b2b700d47 100644 --- a/mysql-test/main/range_mrr_icp.result +++ b/mysql-test/main/range_mrr_icp.result @@ -1,5 +1,6 @@ set @mrr_icp_extra_tmp=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_use_condition_selectivity=1; CREATE TABLE t1 ( event_date date DEFAULT '0000-00-00' NOT NULL, type int(11) DEFAULT '0' NOT NULL, diff --git a/mysql-test/main/range_mrr_icp.test b/mysql-test/main/range_mrr_icp.test index 29e7af321db..c0f41e1fa6c 100644 --- a/mysql-test/main/range_mrr_icp.test +++ b/mysql-test/main/range_mrr_icp.test @@ -1,3 +1,5 @@ +--source include/default_optimizer_switch.inc + set @mrr_icp_extra_tmp=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; diff --git a/mysql-test/main/range_vs_index_merge.test b/mysql-test/main/range_vs_index_merge.test index 84b87579e85..60c912e9c3e 100644 --- a/mysql-test/main/range_vs_index_merge.test +++ b/mysql-test/main/range_vs_index_merge.test @@ -1,3 +1,6 @@ +--source include/default_optimizer_switch.inc +--source include/default_charset.inc + --disable_warnings DROP TABLE IF EXISTS t1,t2,t3,t4; DROP DATABASE IF EXISTS world; diff --git a/mysql-test/main/repair.result b/mysql-test/main/repair.result index 75d7525ee71..0be2251e922 100644 --- a/mysql-test/main/repair.result +++ b/mysql-test/main/repair.result @@ -1,3 +1,4 @@ +call mtr.add_suppression("character set is multi-byte"); drop table if exists t1; create table t1 SELECT 1,"table 1"; repair table t1 use_frm; @@ -188,6 +189,8 @@ drop tables t1, t2; # .frm file from MySQL 3.23 # # Test with a saved table from 3.23 +SET @save_global_character_set_server= @@global.character_set_server; +set @@global.character_set_server=@@character_set_server; select count(*) from t1; ERROR HY000: Got error 190 "Incompatible key or row definition between the MariaDB .frm file and the information in the storage engine. You have to dump an" from storage engine MyISAM check table t1; @@ -208,6 +211,7 @@ check table t1; Table Op Msg_type Msg_text test.t1 check status OK drop table t1; +set @@global.character_set_server=@save_global_character_set_server; create table t1 (a blob); create view v1 as select * from t1; repair view v1; diff --git a/mysql-test/main/repair.test b/mysql-test/main/repair.test index 5494e370133..75978ac482b 100644 --- a/mysql-test/main/repair.test +++ b/mysql-test/main/repair.test @@ -1,6 +1,9 @@ # # Test of repair table # +--source include/default_charset.inc + +call mtr.add_suppression("character set is multi-byte"); --disable_warnings drop table if exists t1; @@ -199,6 +202,9 @@ drop tables t1, t2; --echo # Test with a saved table from 3.23 let $MYSQLD_DATADIR= `select @@datadir`; + +SET @save_global_character_set_server= @@global.character_set_server; +set @@global.character_set_server=@@character_set_server; --copy_file std_data/host_old.frm $MYSQLD_DATADIR/test/t1.frm --copy_file std_data/host_old.MYD $MYSQLD_DATADIR/test/t1.MYD --copy_file std_data/host_old.MYI $MYSQLD_DATADIR/test/t1.MYI @@ -212,6 +218,8 @@ select count(*) from t1; check table t1; drop table t1; +set @@global.character_set_server=@save_global_character_set_server; + # # MDEV-8115 mysql_upgrade crashes the server with REPAIR VIEW # diff --git a/mysql-test/main/schema.test b/mysql-test/main/schema.test index 8f9047e2e3f..e8ab4e406c0 100644 --- a/mysql-test/main/schema.test +++ b/mysql-test/main/schema.test @@ -6,6 +6,7 @@ # Save the initial number of concurrent sessions. --source include/count_sessions.inc +--source include/default_charset.inc --disable_warnings drop database if exists mysqltest1; diff --git a/mysql-test/main/select.result b/mysql-test/main/select.result index 352ab4ddef4..1970a984b44 100644 --- a/mysql-test/main/select.result +++ b/mysql-test/main/select.result @@ -1,7 +1,6 @@ drop table if exists t1,t2,t3,t4,t11; drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; drop view if exists v1; -SET @save_optimizer_switch=@@optimizer_switch; SET optimizer_switch=ifnull(@optimizer_switch_for_select_test,'outer_join_with_cache=off'); set join_cache_level=1; CREATE TABLE t1 ( @@ -4894,7 +4893,7 @@ CREATE TABLE t5 (f1 int) ; INSERT INTO t5 VALUES (20),(5); CREATE TABLE t6(f1 int); INSERT INTO t6 VALUES (9),(7); -SET SESSION join_buffer_size = 2176; +SET @save_join_buffer_size=@@join_buffer_size,@@join_buffer_size = 2176; EXPLAIN SELECT STRAIGHT_JOIN * FROM t2, (t1 LEFT JOIN (t3,t4) ON t1.f1 = t4.f1), t5, t6; id select_type table type possible_keys key key_len ref rows Extra @@ -4954,7 +4953,7 @@ f1 f1 f1 f1 f2 f1 f1 3 9 NULL NULL NULL 5 7 7 9 NULL NULL NULL 5 7 18 9 NULL NULL NULL 5 7 -SET SESSION join_buffer_size = DEFAULT; +SET SESSION join_buffer_size = @save_join_buffer_size; DROP TABLE t1,t2,t3,t4,t5,t6; # # Bug #698882: best equality substitution not applied to ref @@ -5334,7 +5333,7 @@ SELECT a, COUNT(*) FROM t1 WHERE 0; a COUNT(*) NULL 0 DROP TABLE t1; -SET optimizer_switch=@save_optimizer_switch; +SET @@optimizer_switch=@save_optimizer_switch; # # LP bug#994275 Assertion `real->type() == Item::FIELD_ITEM' failed # in add_not_null_conds(JOIN*) with JOIN, ZEROFILL column, PK diff --git a/mysql-test/main/select.test b/mysql-test/main/select.test index 52ef4aa2111..7ac76286a3e 100644 --- a/mysql-test/main/select.test +++ b/mysql-test/main/select.test @@ -13,7 +13,8 @@ drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; drop view if exists v1; --enable_warnings -SET @save_optimizer_switch=@@optimizer_switch; +--source include/default_optimizer_switch.inc + SET optimizer_switch=ifnull(@optimizer_switch_for_select_test,'outer_join_with_cache=off'); if (`select @join_cache_level_for_select_test is null`) { @@ -4174,13 +4175,13 @@ INSERT INTO t5 VALUES (20),(5); CREATE TABLE t6(f1 int); INSERT INTO t6 VALUES (9),(7); -SET SESSION join_buffer_size = 2176; +SET @save_join_buffer_size=@@join_buffer_size,@@join_buffer_size = 2176; EXPLAIN SELECT STRAIGHT_JOIN * FROM t2, (t1 LEFT JOIN (t3,t4) ON t1.f1 = t4.f1), t5, t6; SELECT STRAIGHT_JOIN * FROM t2, (t1 LEFT JOIN (t3,t4) ON t1.f1 = t4.f1), t5, t6; -SET SESSION join_buffer_size = DEFAULT; +SET SESSION join_buffer_size = @save_join_buffer_size; DROP TABLE t1,t2,t3,t4,t5,t6; @@ -4479,7 +4480,7 @@ CREATE TABLE t1 (a TINYBLOB NOT NULL); SELECT a, COUNT(*) FROM t1 WHERE 0; DROP TABLE t1; -SET optimizer_switch=@save_optimizer_switch; +SET @@optimizer_switch=@save_optimizer_switch; --echo # --echo # LP bug#994275 Assertion `real->type() == Item::FIELD_ITEM' failed diff --git a/mysql-test/main/select_jcl6.result b/mysql-test/main/select_jcl6.result index 1c7192b75b6..12c01fb43a5 100644 --- a/mysql-test/main/select_jcl6.result +++ b/mysql-test/main/select_jcl6.result @@ -12,7 +12,6 @@ set @join_cache_level_for_select_test=@@join_cache_level; drop table if exists t1,t2,t3,t4,t11; drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; drop view if exists v1; -SET @save_optimizer_switch=@@optimizer_switch; SET optimizer_switch=ifnull(@optimizer_switch_for_select_test,'outer_join_with_cache=off'); set join_cache_level=@join_cache_level_for_select_test; CREATE TABLE t1 ( @@ -4905,7 +4904,7 @@ CREATE TABLE t5 (f1 int) ; INSERT INTO t5 VALUES (20),(5); CREATE TABLE t6(f1 int); INSERT INTO t6 VALUES (9),(7); -SET SESSION join_buffer_size = 2176; +SET @save_join_buffer_size=@@join_buffer_size,@@join_buffer_size = 2176; EXPLAIN SELECT STRAIGHT_JOIN * FROM t2, (t1 LEFT JOIN (t3,t4) ON t1.f1 = t4.f1), t5, t6; id select_type table type possible_keys key key_len ref rows Extra @@ -4965,7 +4964,7 @@ f1 f1 f1 f1 f2 f1 f1 3 9 NULL NULL NULL 5 7 7 9 NULL NULL NULL 5 7 18 9 NULL NULL NULL 5 7 -SET SESSION join_buffer_size = DEFAULT; +SET SESSION join_buffer_size = @save_join_buffer_size; DROP TABLE t1,t2,t3,t4,t5,t6; # # Bug #698882: best equality substitution not applied to ref @@ -5345,7 +5344,7 @@ SELECT a, COUNT(*) FROM t1 WHERE 0; a COUNT(*) NULL 0 DROP TABLE t1; -SET optimizer_switch=@save_optimizer_switch; +SET @@optimizer_switch=@save_optimizer_switch; # # LP bug#994275 Assertion `real->type() == Item::FIELD_ITEM' failed # in add_not_null_conds(JOIN*) with JOIN, ZEROFILL column, PK @@ -5560,9 +5559,6 @@ NULL drop table t1; End of 10.0 tests set join_cache_level=default; -show variables like 'join_cache_level'; -Variable_name Value -join_cache_level 2 set @@optimizer_switch=@save_optimizer_switch_jcl6; set @optimizer_switch_for_select_test=NULL; set @join_cache_level_for_select_test=NULL; diff --git a/mysql-test/main/select_jcl6.test b/mysql-test/main/select_jcl6.test index 120752fe12c..c1c82a8f46e 100644 --- a/mysql-test/main/select_jcl6.test +++ b/mysql-test/main/select_jcl6.test @@ -17,7 +17,6 @@ set @join_cache_level_for_select_test=@@join_cache_level; --source select.test set join_cache_level=default; -show variables like 'join_cache_level'; set @@optimizer_switch=@save_optimizer_switch_jcl6; set @optimizer_switch_for_select_test=NULL; diff --git a/mysql-test/main/select_pkeycache.result b/mysql-test/main/select_pkeycache.result index 352ab4ddef4..1970a984b44 100644 --- a/mysql-test/main/select_pkeycache.result +++ b/mysql-test/main/select_pkeycache.result @@ -1,7 +1,6 @@ drop table if exists t1,t2,t3,t4,t11; drop table if exists t1_1,t1_2,t9_1,t9_2,t1aa,t2aa; drop view if exists v1; -SET @save_optimizer_switch=@@optimizer_switch; SET optimizer_switch=ifnull(@optimizer_switch_for_select_test,'outer_join_with_cache=off'); set join_cache_level=1; CREATE TABLE t1 ( @@ -4894,7 +4893,7 @@ CREATE TABLE t5 (f1 int) ; INSERT INTO t5 VALUES (20),(5); CREATE TABLE t6(f1 int); INSERT INTO t6 VALUES (9),(7); -SET SESSION join_buffer_size = 2176; +SET @save_join_buffer_size=@@join_buffer_size,@@join_buffer_size = 2176; EXPLAIN SELECT STRAIGHT_JOIN * FROM t2, (t1 LEFT JOIN (t3,t4) ON t1.f1 = t4.f1), t5, t6; id select_type table type possible_keys key key_len ref rows Extra @@ -4954,7 +4953,7 @@ f1 f1 f1 f1 f2 f1 f1 3 9 NULL NULL NULL 5 7 7 9 NULL NULL NULL 5 7 18 9 NULL NULL NULL 5 7 -SET SESSION join_buffer_size = DEFAULT; +SET SESSION join_buffer_size = @save_join_buffer_size; DROP TABLE t1,t2,t3,t4,t5,t6; # # Bug #698882: best equality substitution not applied to ref @@ -5334,7 +5333,7 @@ SELECT a, COUNT(*) FROM t1 WHERE 0; a COUNT(*) NULL 0 DROP TABLE t1; -SET optimizer_switch=@save_optimizer_switch; +SET @@optimizer_switch=@save_optimizer_switch; # # LP bug#994275 Assertion `real->type() == Item::FIELD_ITEM' failed # in add_not_null_conds(JOIN*) with JOIN, ZEROFILL column, PK diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result index cf340b04660..c4434c4c87a 100644 --- a/mysql-test/main/selectivity.result +++ b/mysql-test/main/selectivity.result @@ -10,6 +10,8 @@ set use_stat_tables='preferably'; set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity; set @save_histogram_size=@@histogram_size; set @save_histogram_type=@@histogram_type; +set join_cache_level=2; +set @@global.histogram_size=0,@@local.histogram_size=0; set optimizer_use_condition_selectivity=3; create table t1 (a int); insert into t1 values @@ -1640,6 +1642,8 @@ drop function f1; # set @@optimizer_use_condition_selectivity=4; set @@use_stat_tables='preferably'; +set @save_histogram_size=@@histogram_size; +set @@histogram_size=0; create table t1 (a int, b int, key (b), key (a)); insert into t1 select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000; @@ -1667,5 +1671,7 @@ Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (17,51,5) drop table t1; set use_stat_tables= @save_use_stat_tables; +set @@histogram_size=@save_histogram_size; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; # End of 10.1 tests +set @@global.histogram_size=@save_histogram_size; diff --git a/mysql-test/main/selectivity.test b/mysql-test/main/selectivity.test index f1c9d6b31b8..b517b26bc1b 100644 --- a/mysql-test/main/selectivity.test +++ b/mysql-test/main/selectivity.test @@ -1,5 +1,6 @@ --source include/have_stat_tables.inc --source include/have_sequence.inc +--source include/default_charset.inc --disable_warnings drop table if exists t0,t1,t2,t3; @@ -9,12 +10,14 @@ select @@global.use_stat_tables; select @@session.use_stat_tables; set @save_use_stat_tables=@@use_stat_tables; - set use_stat_tables='preferably'; +--source include/default_optimizer_switch.inc set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity; set @save_histogram_size=@@histogram_size; set @save_histogram_type=@@histogram_type; +set join_cache_level=2; +set @@global.histogram_size=0,@@local.histogram_size=0; # check that statistics on nulls is used @@ -1108,6 +1111,8 @@ drop function f1; --echo # set @@optimizer_use_condition_selectivity=4; set @@use_stat_tables='preferably'; +set @save_histogram_size=@@histogram_size; +set @@histogram_size=0; create table t1 (a int, b int, key (b), key (a)); insert into t1 select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000; @@ -1123,6 +1128,12 @@ explain extended select * from t1 where a in (17,51,5) and b=2; drop table t1; set use_stat_tables= @save_use_stat_tables; +set @@histogram_size=@save_histogram_size; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; --echo # End of 10.1 tests +# +# Clean up +# +--source include/restore_charset.inc +set @@global.histogram_size=@save_histogram_size; diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result index f2fdd3f8381..3cea6a3848b 100644 --- a/mysql-test/main/selectivity_innodb.result +++ b/mysql-test/main/selectivity_innodb.result @@ -13,6 +13,8 @@ set use_stat_tables='preferably'; set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity; set @save_histogram_size=@@histogram_size; set @save_histogram_type=@@histogram_type; +set join_cache_level=2; +set @@global.histogram_size=0,@@local.histogram_size=0; set optimizer_use_condition_selectivity=3; create table t1 (a int); insert into t1 values @@ -1650,6 +1652,8 @@ drop function f1; # set @@optimizer_use_condition_selectivity=4; set @@use_stat_tables='preferably'; +set @save_histogram_size=@@histogram_size; +set @@histogram_size=0; create table t1 (a int, b int, key (b), key (a)); insert into t1 select (rand(1)*1000)/10, (rand(1001)*1000)/50 from seq_1_to_1000; @@ -1677,8 +1681,10 @@ Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` = 2 and `test`.`t1`.`a` in (17,51,5) drop table t1; set use_stat_tables= @save_use_stat_tables; +set @@histogram_size=@save_histogram_size; set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; # End of 10.1 tests +set @@global.histogram_size=@save_histogram_size; set optimizer_switch=@save_optimizer_switch_for_selectivity_test; set @tmp_ust= @@use_stat_tables; set @tmp_oucs= @@optimizer_use_condition_selectivity; @@ -1828,4 +1834,5 @@ drop view v1; # set use_stat_tables= @tmp_ust; set optimizer_use_condition_selectivity= @tmp_oucs; +set @@global.histogram_size=@save_histogram_size; SET SESSION STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/main/selectivity_innodb.test b/mysql-test/main/selectivity_innodb.test index f407eb052fe..6c457e2848b 100644 --- a/mysql-test/main/selectivity_innodb.test +++ b/mysql-test/main/selectivity_innodb.test @@ -1,6 +1,7 @@ --source include/have_innodb.inc # This test is slow on buildbot. --source include/big_test.inc +--source include/default_optimizer_switch.inc SET SESSION STORAGE_ENGINE='InnoDB'; @@ -175,4 +176,5 @@ drop view v1; set use_stat_tables= @tmp_ust; set optimizer_use_condition_selectivity= @tmp_oucs; +set @@global.histogram_size=@save_histogram_size; SET SESSION STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/main/selectivity_no_engine.test b/mysql-test/main/selectivity_no_engine.test index 2a31c01ed97..345b7bd1e8a 100644 --- a/mysql-test/main/selectivity_no_engine.test +++ b/mysql-test/main/selectivity_no_engine.test @@ -1,4 +1,5 @@ --source include/have_stat_tables.inc +--source include/default_optimizer_switch.inc --echo # --echo # Engine-agnostic tests for statistics-based selectivity calculations. diff --git a/mysql-test/main/set_statement.result b/mysql-test/main/set_statement.result index c34e1171899..48675145fd2 100644 --- a/mysql-test/main/set_statement.result +++ b/mysql-test/main/set_statement.result @@ -1044,19 +1044,11 @@ set @save_slow_query_log= @@slow_query_log; set @save_log_output= @@log_output; set statement long_query_time=default for select @@long_query_time; @@long_query_time -10.000000 +DEFAULT set statement log_slow_filter=default for select @@log_slow_filter; -@@log_slow_filter -admin,filesort,filesort_on_disk,filesort_priority_queue,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk set statement log_slow_verbosity=default for select @@log_slow_verbosity; -@@log_slow_verbosity - set statement log_slow_rate_limit=default for select @@log_slow_rate_limit; -@@log_slow_rate_limit -1 set statement slow_query_log=default for select @@slow_query_log; -@@slow_query_log -1 truncate table mysql.slow_log; set slow_query_log= 1; set global log_output='TABLE'; diff --git a/mysql-test/main/set_statement.test b/mysql-test/main/set_statement.test index cc361553cfd..6791c7e0b79 100644 --- a/mysql-test/main/set_statement.test +++ b/mysql-test/main/set_statement.test @@ -991,11 +991,17 @@ set @save_long_query_time= @@long_query_time; set @save_slow_query_log= @@slow_query_log; set @save_log_output= @@log_output; +let $long_query_time=`select @@long_query_time`; +--replace_result $long_query_time DEFAULT set statement long_query_time=default for select @@long_query_time; + +# Disable result log as the results depends on the values of the variables +--disable_result_log set statement log_slow_filter=default for select @@log_slow_filter; set statement log_slow_verbosity=default for select @@log_slow_verbosity; set statement log_slow_rate_limit=default for select @@log_slow_rate_limit; set statement slow_query_log=default for select @@slow_query_log; +--enable_result_log truncate table mysql.slow_log; set slow_query_log= 1; diff --git a/mysql-test/main/shm.result b/mysql-test/main/shm.result index 65187b6b19b..beaa2ecd3a7 100644 --- a/mysql-test/main/shm.result +++ b/mysql-test/main/shm.result @@ -1348,8 +1348,10 @@ fld1 fld1 250503 250505 250504 250505 250505 250505 -SET @save_optimizer_switch=@@optimizer_switch; -SET optimizer_switch='outer_join_with_cache=off'; +SET @local_optimizer_switch=@@optimizer_switch; +set @local_join_cache_level=@@join_cache_level; +set @@join_cache_level=2; +set optimizer_switch='outer_join_with_cache=off,join_cache_hashed=off'; insert into t2 (fld1, companynr) values (999999,99); select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; companynr companyname @@ -1425,7 +1427,7 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -SET optimizer_switch=@save_optimizer_switch; +SET @@optimizer_switch=@local_optimizer_switch; select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; companynr companynr 37 36 @@ -1434,6 +1436,7 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr= id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join) +SET @@join_cache_level=@local_join_cache_level; select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; fld1 companynr fld3 period 038008 37 reporters 1008 diff --git a/mysql-test/main/show_bad_definer-5553.test b/mysql-test/main/show_bad_definer-5553.test index 7c7f253ae7d..38b6134826d 100644 --- a/mysql-test/main/show_bad_definer-5553.test +++ b/mysql-test/main/show_bad_definer-5553.test @@ -1,4 +1,6 @@ --source include/not_embedded.inc +--source include/default_charset.inc + # # MDEV-5553 A view or procedure with a non existing definer can block "SHOW TABLE STATUS" with an unclear error message # diff --git a/mysql-test/main/show_check.result b/mysql-test/main/show_check.result index 1b9c1950668..2978feb53ff 100644 --- a/mysql-test/main/show_check.result +++ b/mysql-test/main/show_check.result @@ -1,3 +1,5 @@ +SET @@global.character_set_server= @@session.character_set_server; +set @@sql_mode="STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"; drop table if exists t1,t2; drop table if exists t1aa,t2aa; drop database if exists mysqltest; @@ -440,9 +442,7 @@ table CREATE TABLE `table` ( DROP TABLE `table`; SET sql_quote_show_create= @old_sql_quote_show_create; SET sql_mode= @old_sql_mode; -select @@max_heap_table_size; -@@max_heap_table_size -1048576 +set @@max_heap_table_size=1048576; CREATE TABLE t1 ( a int(11) default NULL, KEY a USING BTREE (a) @@ -1579,3 +1579,4 @@ Level Code Message SHOW CONTRIBUTORS; SHOW WARNINGS; Level Code Message +SET @@global.character_set_server=@save_character_set_server; diff --git a/mysql-test/main/show_check.test b/mysql-test/main/show_check.test index d9025bc8d10..d56202d0773 100644 --- a/mysql-test/main/show_check.test +++ b/mysql-test/main/show_check.test @@ -17,6 +17,11 @@ # depends on the presence of the log tables (which are CSV-based). --source include/have_csv.inc +# Test results assumes we are using latin1 +--source include/default_charset.inc +SET @@global.character_set_server= @@session.character_set_server; +set @@sql_mode="STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"; + # # Test of some show commands # @@ -261,7 +266,7 @@ SET sql_mode= @old_sql_mode; # Test for Bug#2719 Heap tables status shows wrong or missing data. # -select @@max_heap_table_size; +set @@max_heap_table_size=1048576; CREATE TABLE t1 ( a int(11) default NULL, @@ -1406,3 +1411,5 @@ SHOW WARNINGS; SHOW CONTRIBUTORS; --enable_result_log SHOW WARNINGS; + +SET @@global.character_set_server=@save_character_set_server; diff --git a/mysql-test/main/sp-anchor-type.test b/mysql-test/main/sp-anchor-type.test index 7f952d626e0..b340cf776c5 100644 --- a/mysql-test/main/sp-anchor-type.test +++ b/mysql-test/main/sp-anchor-type.test @@ -1,3 +1,4 @@ +--source include/default_charset.inc --echo # --echo # Start of 10.3 tests diff --git a/mysql-test/main/sp-error.test b/mysql-test/main/sp-error.test index 0e16948f438..61a3974a1df 100644 --- a/mysql-test/main/sp-error.test +++ b/mysql-test/main/sp-error.test @@ -2,6 +2,8 @@ # Stored PROCEDURE error tests # +--source include/default_charset.inc + --disable_warnings drop table if exists t1, t2; --enable_warnings diff --git a/mysql-test/main/sp-security.result b/mysql-test/main/sp-security.result index 4487528210f..de33c11a28f 100644 --- a/mysql-test/main/sp-security.result +++ b/mysql-test/main/sp-security.result @@ -1,3 +1,4 @@ +set @@global.character_set_server=@@session.character_set_server; connect con1root,localhost,root,,; connection con1root; use test; @@ -800,3 +801,4 @@ disconnect u1; connection default; DROP DATABASE u1; DROP USER u1@localhost; +set @@global.character_set_server=@save_character_set_server; diff --git a/mysql-test/main/sp-security.test b/mysql-test/main/sp-security.test index 4f645ce2cd3..30d7e4cf895 100644 --- a/mysql-test/main/sp-security.test +++ b/mysql-test/main/sp-security.test @@ -3,7 +3,9 @@ # # Can't test with embedded server that doesn't support grants --- source include/not_embedded.inc +--source include/not_embedded.inc +--source include/default_charset.inc +set @@global.character_set_server=@@session.character_set_server; # Save the initial number of concurrent sessions --source include/count_sessions.inc @@ -1080,3 +1082,5 @@ disconnect u1; connection default; DROP DATABASE u1; DROP USER u1@localhost; + +set @@global.character_set_server=@save_character_set_server; diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result index 7c9e85b0ccc..283eab6fccc 100644 --- a/mysql-test/main/sp.result +++ b/mysql-test/main/sp.result @@ -1,3 +1,5 @@ +set @save_character_set_client=@@character_set_client; +set @save_userstat=@@global.userstat, @@global.userstat= 0; use test; drop table if exists t1,t2,t3,t4; drop view if exists v1; @@ -3342,7 +3344,8 @@ läbel1: begin end| call bug6063()| call bug7088_1()| call bug7088_2()| -set character set default| +set @@character_set_client=@save_character_set_client| +set @@character_set_results=@save_character_set_client| show create procedure bug6063| Procedure sql_mode Create Procedure character_set_client collation_connection Database Collation bug6063 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug6063`() @@ -6250,7 +6253,8 @@ END| CALL p1(); áâä NULL -SET NAMES default; +set @@character_set_client=@save_character_set_client; +set @@character_set_results=@save_character_set_client; DROP PROCEDURE p1; drop procedure if exists proc_25411_a; drop procedure if exists proc_25411_b; @@ -7643,6 +7647,7 @@ c1 c2 count(c3) 2012-03-01 02:00:00 3 1 DROP PROCEDURE p1; # End of 5.5 test +FLUSH USER_STATISTICS; CREATE PROCEDURE sp() ALTER TABLE non_existing_table OPTIMIZE PARTITION p0; CALL sp; Table Op Msg_type Msg_text @@ -8828,6 +8833,7 @@ Note 1050 Table 't1' already exists drop procedure p4; drop table t1; set @@sql_mode=@save_sql_mode; +set @@global.userstat= @save_userstat; # # MDEV-17363 Compressed columns cannot be restored from dump # COMPRESSED conflicted between data type and SP label, diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test index 7ff780a1fb8..2fa17b603d2 100644 --- a/mysql-test/main/sp.test +++ b/mysql-test/main/sp.test @@ -14,6 +14,11 @@ # Tests that require --with-geometry go into sp_gis.test # Tests that require multibyte character sets, which are not always available, # go into separate files (e.g. sp-ucs2.test) + +--source include/default_charset.inc +set @save_character_set_client=@@character_set_client; +set @save_userstat=@@global.userstat, @@global.userstat= 0; + use test; # Test tables @@ -4087,7 +4092,8 @@ call bug6063()| call bug7088_1()| call bug7088_2()| -set character set default| +set @@character_set_client=@save_character_set_client| +set @@character_set_results=@save_character_set_client| show create procedure bug6063| show create procedure bug7088_1| @@ -7364,7 +7370,8 @@ DELIMITER ;| CALL p1(); -SET NAMES default; +set @@character_set_client=@save_character_set_client; +set @@character_set_results=@save_character_set_client; DROP PROCEDURE p1; # @@ -8240,6 +8247,7 @@ drop procedure p; # # Bug#43962 "Packets out of order" calling a SHOW TABLE STATUS # + DELIMITER //; CREATE DEFINER = 'root'@'localhost' PROCEDURE p1() NOT DETERMINISTIC @@ -9069,6 +9077,7 @@ DROP PROCEDURE p1; --echo # End of 5.5 test #MDEV-17610 +FLUSH USER_STATISTICS; CREATE PROCEDURE sp() ALTER TABLE non_existing_table OPTIMIZE PARTITION p0; CALL sp; SELECT 1; @@ -10354,6 +10363,7 @@ call p4(); drop procedure p4; drop table t1; set @@sql_mode=@save_sql_mode; +set @@global.userstat= @save_userstat; --echo # --echo # MDEV-17363 Compressed columns cannot be restored from dump diff --git a/mysql-test/main/ssl.result b/mysql-test/main/ssl.result index 8de36f55ecf..00faea58fd2 100644 --- a/mysql-test/main/ssl.result +++ b/mysql-test/main/ssl.result @@ -1357,8 +1357,10 @@ fld1 fld1 250503 250505 250504 250505 250505 250505 -SET @save_optimizer_switch=@@optimizer_switch; -SET optimizer_switch='outer_join_with_cache=off'; +SET @local_optimizer_switch=@@optimizer_switch; +set @local_join_cache_level=@@join_cache_level; +set @@join_cache_level=2; +set optimizer_switch='outer_join_with_cache=off,join_cache_hashed=off'; insert into t2 (fld1, companynr) values (999999,99); select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; companynr companyname @@ -1434,7 +1436,7 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -SET optimizer_switch=@save_optimizer_switch; +SET @@optimizer_switch=@local_optimizer_switch; select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; companynr companynr 37 36 @@ -1443,6 +1445,7 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr= id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join) +SET @@join_cache_level=@local_join_cache_level; select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; fld1 companynr fld3 period 038008 37 reporters 1008 diff --git a/mysql-test/main/ssl.test b/mysql-test/main/ssl.test index 67db668a1c2..45c903d43d2 100644 --- a/mysql-test/main/ssl.test +++ b/mysql-test/main/ssl.test @@ -8,6 +8,8 @@ # Save the initial number of concurrent sessions --source include/count_sessions.inc +--source include/default_charset.inc + connect (ssl_con,localhost,root,,,,,SSL); # Check ssl turned on diff --git a/mysql-test/main/ssl_compress.result b/mysql-test/main/ssl_compress.result index 4e37cc68a24..d298f8ec6e4 100644 --- a/mysql-test/main/ssl_compress.result +++ b/mysql-test/main/ssl_compress.result @@ -1354,8 +1354,10 @@ fld1 fld1 250503 250505 250504 250505 250505 250505 -SET @save_optimizer_switch=@@optimizer_switch; -SET optimizer_switch='outer_join_with_cache=off'; +SET @local_optimizer_switch=@@optimizer_switch; +set @local_join_cache_level=@@join_cache_level; +set @@join_cache_level=2; +set optimizer_switch='outer_join_with_cache=off,join_cache_hashed=off'; insert into t2 (fld1, companynr) values (999999,99); select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; companynr companyname @@ -1431,7 +1433,7 @@ explain select companynr,companyname from t4 left join t2 using (companynr) wher id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where -SET optimizer_switch=@save_optimizer_switch; +SET @@optimizer_switch=@local_optimizer_switch; select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1; companynr companynr 37 36 @@ -1440,6 +1442,7 @@ explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr= id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary 1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join) +SET @@join_cache_level=@local_join_cache_level; select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008; fld1 companynr fld3 period 038008 37 reporters 1008 diff --git a/mysql-test/main/ssl_compress.test b/mysql-test/main/ssl_compress.test index 588d4555db8..4e17beb0fba 100644 --- a/mysql-test/main/ssl_compress.test +++ b/mysql-test/main/ssl_compress.test @@ -4,6 +4,7 @@ -- source include/have_ssl_communication.inc -- source include/have_compress.inc -- source include/not_staging.inc +--source include/default_optimizer_switch.inc # Save the initial number of concurrent sessions --source include/count_sessions.inc diff --git a/mysql-test/main/stat_tables-enospc.result b/mysql-test/main/stat_tables-enospc.result index f0d76f04eee..943cbca6bc5 100644 --- a/mysql-test/main/stat_tables-enospc.result +++ b/mysql-test/main/stat_tables-enospc.result @@ -2,6 +2,7 @@ call mtr.add_suppression("No space left on device"); create table t1 (a varchar(255), b varchar(255), c varchar(255)); set use_stat_tables=PREFERABLY, optimizer_use_condition_selectivity=3; set debug_dbug='+d,simulate_file_write_error'; +set @@max_heap_table_size=128*1024; analyze table t1; Table Op Msg_type Msg_text test.t1 analyze Error Error writing file 'tmp-file' (Errcode: 28 "No space left on device") diff --git a/mysql-test/main/stat_tables-enospc.test b/mysql-test/main/stat_tables-enospc.test index 12e42f6adc0..932b2bde302 100644 --- a/mysql-test/main/stat_tables-enospc.test +++ b/mysql-test/main/stat_tables-enospc.test @@ -3,6 +3,7 @@ # # test that ANALYZE TABLE is immediately aborted when going out of disk space --source include/have_debug.inc + call mtr.add_suppression("No space left on device"); create table t1 (a varchar(255), b varchar(255), c varchar(255)); --disable_query_log @@ -16,8 +17,8 @@ while ($i) { --enable_query_log set use_stat_tables=PREFERABLY, optimizer_use_condition_selectivity=3; set debug_dbug='+d,simulate_file_write_error'; +set @@max_heap_table_size=128*1024; --replace_regex /'.*'/'tmp-file'/ analyze table t1; set debug_dbug=''; drop table t1; - diff --git a/mysql-test/main/stat_tables.result b/mysql-test/main/stat_tables.result index a631aab8714..795af788310 100644 --- a/mysql-test/main/stat_tables.result +++ b/mysql-test/main/stat_tables.result @@ -5,6 +5,9 @@ select @@session.use_stat_tables; @@session.use_stat_tables COMPLEMENTARY set @save_use_stat_tables=@@use_stat_tables; +set @save_histogram_size=@@global.histogram_size; +set @@global.histogram_size=0,@@local.histogram_size=0; +set optimizer_use_condition_selectivity=1; set use_stat_tables='preferably'; DROP DATABASE IF EXISTS dbt3_s001; CREATE DATABASE dbt3_s001; @@ -749,7 +752,6 @@ set names utf8; set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity; set optimizer_use_condition_selectivity=4; set use_stat_tables=preferably; -set @save_histogram_size= @@histogram_size; set histogram_size=255; create table t1 ( a varchar(255) character set utf8); insert into t1 values (REPEAT('Ó¥',255)), (REPEAT('ç',255)); @@ -800,3 +802,4 @@ set @@sql_mode= @save_sql_mode; set use_stat_tables=@save_use_stat_tables; set @@histogram_size= @save_histogram_size; set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; +set @@global.histogram_size=@save_histogram_size; diff --git a/mysql-test/main/stat_tables.test b/mysql-test/main/stat_tables.test index 79a7a17550b..4c49df82ca6 100644 --- a/mysql-test/main/stat_tables.test +++ b/mysql-test/main/stat_tables.test @@ -4,6 +4,9 @@ select @@global.use_stat_tables; select @@session.use_stat_tables; set @save_use_stat_tables=@@use_stat_tables; +set @save_histogram_size=@@global.histogram_size; +set @@global.histogram_size=0,@@local.histogram_size=0; +set optimizer_use_condition_selectivity=1; set use_stat_tables='preferably'; @@ -511,7 +514,6 @@ set names utf8; set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity; set optimizer_use_condition_selectivity=4; set use_stat_tables=preferably; -set @save_histogram_size= @@histogram_size; set histogram_size=255; create table t1 ( a varchar(255) character set utf8); @@ -544,3 +546,4 @@ set @@sql_mode= @save_sql_mode; set use_stat_tables=@save_use_stat_tables; set @@histogram_size= @save_histogram_size; set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; +set @@global.histogram_size=@save_histogram_size; diff --git a/mysql-test/main/stat_tables_innodb.result b/mysql-test/main/stat_tables_innodb.result index 53a1441158a..0363fec9adf 100644 --- a/mysql-test/main/stat_tables_innodb.result +++ b/mysql-test/main/stat_tables_innodb.result @@ -8,6 +8,9 @@ select @@session.use_stat_tables; @@session.use_stat_tables COMPLEMENTARY set @save_use_stat_tables=@@use_stat_tables; +set @save_histogram_size=@@global.histogram_size; +set @@global.histogram_size=0,@@local.histogram_size=0; +set optimizer_use_condition_selectivity=1; set use_stat_tables='preferably'; DROP DATABASE IF EXISTS dbt3_s001; CREATE DATABASE dbt3_s001; @@ -776,7 +779,6 @@ set names utf8; set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity; set optimizer_use_condition_selectivity=4; set use_stat_tables=preferably; -set @save_histogram_size= @@histogram_size; set histogram_size=255; create table t1 ( a varchar(255) character set utf8); insert into t1 values (REPEAT('Ó¥',255)), (REPEAT('ç',255)); @@ -827,5 +829,6 @@ set @@sql_mode= @save_sql_mode; set use_stat_tables=@save_use_stat_tables; set @@histogram_size= @save_histogram_size; set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity; +set @@global.histogram_size=@save_histogram_size; set optimizer_switch=@save_optimizer_switch_for_stat_tables_test; SET SESSION STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/main/statistics.result b/mysql-test/main/statistics.result index 267d9da965e..e800c327db6 100644 --- a/mysql-test/main/statistics.result +++ b/mysql-test/main/statistics.result @@ -1,5 +1,7 @@ drop table if exists t1,t2; set @save_use_stat_tables=@@use_stat_tables; +set @save_histogram_size=@@global.histogram_size; +set @@global.histogram_size=0,@@local.histogram_size=0; DELETE FROM mysql.table_stats; DELETE FROM mysql.column_stats; DELETE FROM mysql.index_stats; @@ -1771,3 +1773,4 @@ DROP TABLE t1; # # End of 10.2 tests # +set @@global.histogram_size=@save_histogram_size; diff --git a/mysql-test/main/statistics.test b/mysql-test/main/statistics.test index 4c45b4f38b8..0ed63ac8bf2 100644 --- a/mysql-test/main/statistics.test +++ b/mysql-test/main/statistics.test @@ -5,6 +5,8 @@ drop table if exists t1,t2; --enable_warnings set @save_use_stat_tables=@@use_stat_tables; +set @save_histogram_size=@@global.histogram_size; +set @@global.histogram_size=0,@@local.histogram_size=0; DELETE FROM mysql.table_stats; --sorted_result @@ -913,3 +915,5 @@ DROP TABLE t1; --echo # --echo # End of 10.2 tests --echo # + +set @@global.histogram_size=@save_histogram_size; diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result index b3ad55a050d..0dc8692cfae 100644 --- a/mysql-test/main/subselect.result +++ b/mysql-test/main/subselect.result @@ -5,7 +5,8 @@ set @subselect_tmp=@@optimizer_switch; set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_test, "semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); set join_cache_level=1; -set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_use_condition_selectivity=1; select (select 2); (select 2) 2 diff --git a/mysql-test/main/subselect.test b/mysql-test/main/subselect.test index 211ed5162a6..c425a98324e 100644 --- a/mysql-test/main/subselect.test +++ b/mysql-test/main/subselect.test @@ -26,7 +26,8 @@ if (`select @join_cache_level_for_subselect_test is not null`) { set join_cache_level=@join_cache_level_for_subselect_test; } - set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_use_condition_selectivity=1; select (select 2); explain extended select (select 2); diff --git a/mysql-test/main/subselect2.result b/mysql-test/main/subselect2.result index cae0f2286c1..72f6a8b5612 100644 --- a/mysql-test/main/subselect2.result +++ b/mysql-test/main/subselect2.result @@ -383,7 +383,7 @@ key_code value_string DEALLOCATE PREPARE stmt; DROP VIEW v1; DROP TABLE t1,t2,t3; -set optimizer_switch=@subselect2_test_tmp; +set optimizer_switch=@save_optimizer_switch; create table t1 (a int); create table t2 (a int); create table t3(a int); diff --git a/mysql-test/main/subselect2.test b/mysql-test/main/subselect2.test index 5f7e5f80626..3b982b8b7d0 100644 --- a/mysql-test/main/subselect2.test +++ b/mysql-test/main/subselect2.test @@ -7,6 +7,7 @@ --disable_warnings drop table if exists t1, t2, t3, t4; --enable_warnings +--source include/default_optimizer_switch.inc set @subselect2_test_tmp=@@optimizer_switch; set optimizer_switch='semijoin=on,firstmatch=on,mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; @@ -396,7 +397,7 @@ DEALLOCATE PREPARE stmt; DROP VIEW v1; DROP TABLE t1,t2,t3; -set optimizer_switch=@subselect2_test_tmp; +set optimizer_switch=@save_optimizer_switch; # # Bug #23303485 : HANDLE_FATAL_SIGNAL (SIG=11) IN SUBSELECT_UNION_ENGINE::NO_ROWS diff --git a/mysql-test/main/subselect3.inc b/mysql-test/main/subselect3.inc new file mode 100644 index 00000000000..8ed1c9ee210 --- /dev/null +++ b/mysql-test/main/subselect3.inc @@ -0,0 +1,1306 @@ +--disable_warnings +drop table if exists t0, t1, t2, t3, t4, t5, t11, t12, t21, t22; +--enable_warnings + +set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'; + +# +# 1. Subquery with GROUP/HAVING +# +create table t1 (oref int, grp int, ie int) ; +insert into t1 (oref, grp, ie) values + (1, 1, 1), + (1, 1, 1), + (1, 2, NULL), + + (2, 1, 3), + + (3, 1, 4), + (3, 2, NULL); + +# Ok, for +# select max(ie) from t1 where oref=PARAM group by grp +# we'll have: +# PARAM subquery result +# 1 -> {(1), (NULL)} matching + NULL +# 2 -> {(3)} non-matching +# 3 -> {(3), (NULL)} non-matching + NULL +# 4 -> {} empty set + +create table t2 (oref int, a int); +insert into t2 values + (1, 1), + (2, 2), + (3, 3), + (4, NULL), + (2, NULL); + +# true, false, null, false, null +select a, oref, a in (select max(ie) + from t1 where oref=t2.oref group by grp) Z from t2; + +# This must have a trigcond +explain extended +select a, oref, a in (select max(ie) + from t1 where oref=t2.oref group by grp) Z from t2; + +# This must not have a trigcond: +explain extended +select a, oref from t2 +where a in (select max(ie) from t1 where oref=t2.oref group by grp); +select a, oref, a in ( + select max(ie) from t1 where oref=t2.oref group by grp union + select max(ie) from t1 where oref=t2.oref group by grp + ) Z from t2; + +# Non-correlated subquery, 2 NULL evaluations +create table t3 (a int); +insert into t3 values (NULL), (NULL); +flush status; +select a in (select max(ie) from t1 where oref=4 group by grp) from t3; +show status like 'Handler_read_rnd_next'; +select ' ^ This must show 11' Z; + +set @save_optimizer_switch=@@optimizer_switch; +set @@optimizer_switch="partial_match_rowid_merge=off,partial_match_table_scan=off"; + +# This must show trigcond: +explain extended select a in (select max(ie) from t1 where oref=4 group by grp) from t3; + +set @@optimizer_switch=@save_optimizer_switch; +drop table t1, t2, t3; + +# +# 2. Subquery handled with 'index_subquery': +# +create table t1 (a int, oref int, key(a)); +insert into t1 values + (1, 1), + (1, NULL), + (2, 3), + (2, NULL), + (3, NULL); +insert into t1 values (5, 7), (8, 9), (4, 1); + +create table t2 (a int, oref int); +insert into t2 values (1, 1), (2,2), (NULL, 3), (NULL, 4); + +select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2; + +# The next explain shows "using index" but that is just incorrect display +# (there is a bug filed about this). +explain extended +select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2; + +flush status; +select oref, a from t2 where a in (select a from t1 where oref=t2.oref); +# This will only show access to t2: +show status like '%Handler_read_rnd_next'; + +# Check that repeated NULL-scans are not cached (subq. is not correlated): +delete from t2; +insert into t2 values (NULL, 0),(NULL, 0), (NULL, 0), (NULL, 0); + +set optimizer_switch='subquery_cache=off'; +flush status; +select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2; +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; + +drop table t1, t2; + +# +# 3. Subquery handled with 'unique_index_subquery': +# +create table t1 (a int, b int, primary key (a)); +insert into t1 values (1,1), (3,1),(100,1); + +create table t2 (a int, b int); +insert into t2 values (1,1),(2,1),(NULL,1),(NULL,0); + +select a,b, a in (select a from t1 where t1.b = t2.b) Z from t2 ; + +drop table t1, t2; + +# +# 4. Subquery that is a join, with ref access +# +create table t1 (a int, b int, key(a)); +insert into t1 values + (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); + +create table t2 like t1; +insert into t2 select * from t1; +update t2 set b=1; + +create table t3 (a int, oref int); +insert into t3 values (1, 1), (NULL,1), (NULL,0); +select a, oref, + t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z +from t3; + +# This must have trigcond in WHERE and HAVING: +explain extended +select a, oref, + t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z +from t3; + +drop table t1, t2, t3; + + +# +# BUG#24085: Wrong query result for "NULL IN (SELECT ... UNION SELECT ...)" +# + +# case 1: NULL IN (SELECT not_null_val FROM ...) w/o HAVING/GROUP-BY/etc +create table t1 (a int NOT NULL, b int NOT NULL, key(a)); +insert into t1 values + (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); + +create table t2 like t1; +insert into t2 select * from t1; +update t2 set b=1; + +create table t3 (a int, oref int); +insert into t3 values (1, 1), (NULL,1), (NULL,0); +select a, oref, + t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z +from t3; + +--echo This must show a trig_cond: +explain extended +select a, oref, + t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z +from t3; +drop table t1,t2,t3; + + +# case 2: NULL IN (SELECT not_null_val FROM) where SELECT has GROUP BY +create table t1 (oref int, grp int); +insert into t1 (oref, grp) values + (1, 1), + (1, 1); + +# Ok, for +# select count(*) from t1 group by grp having grp=PARAM +# we'll have: +# PARAM subuqery result +# 1 -> {(2)} +# 2 -> {} - empty set +create table t2 (oref int, a int); +insert into t2 values + (1, NULL), + (2, NULL); + +select a, oref, + a in (select count(*) from t1 group by grp having grp=t2.oref) Z from t2; + +--echo This must show a trig_cond: +explain extended +select a, oref, + a in (select count(*) from t1 group by grp having grp=t2.oref) Z from t2; + +drop table t1, t2; + +create table t1 (a int, b int, primary key (a)); +insert into t1 values (1,1), (3,1),(100,1); +create table t2 (a int, b int); +insert into t2 values (1,1),(2,1),(NULL,1),(NULL,0); + +select a,b, a in (select a from t1 where t1.b = t2.b union select a from +t1 where t1.b = t2.b) Z from t2 ; +select a,b, a in (select a from t1 where t1.b = t2.b) Z from t2 ; +drop table t1, t2; + + +# +# BUG#24127: Incorrect results of row-based subqueries with NULLs on the left side. +# +create table t3 (a int); +insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 (a int, b int, oref int); +insert into t2 values (NULL,1, 100), (NULL,2, 100); + +create table t1 (a int, b int, c int, key(a,b)); +insert into t1 select 2*A, 2*A, 100 from t3; + +# First test index subquery engine +explain extended select a,b, oref, (a,b) in (select a,b from t1 where c=t2.oref) Z from t2; +select a,b, oref, (a,b) in (select a,b from t1 where c=t2.oref) Z from t2; + +# Then check that we do turn off 'ref' scans in the subquery +create table t4 (x int); +insert into t4 select A.a + 10*B.a from t1 A, t1 B; +explain extended + select a,b, oref, + (a,b) in (select a,b from t1,t4 where c=t2.oref) Z + from t2; +select a,b, oref, + (a,b) in (select a,b from t1,t4 where c=t2.oref) Z +from t2; + +drop table t1,t2,t3,t4; + +# More tests for tricky multi-column cases, where some of pushed-down +# equalities are used for index lookups and some arent. +create table t1 (oref char(4), grp int, ie1 int, ie2 int); +insert into t1 (oref, grp, ie1, ie2) values + ('aa', 10, 2, 1), + ('aa', 10, 1, 1), + ('aa', 20, 2, 1), + ('bb', 10, 3, 1), + ('cc', 10, 4, 2), + ('cc', 20, 3, 2), + + ('ee', 10, 2, 1), + ('ee', 10, 1, 2), + + ('ff', 20, 2, 2), + ('ff', 20, 1, 2); +create table t2 (oref char(4), a int, b int); +insert into t2 values + ('ee', NULL, 1), + ('bb', 2, 1), + ('ff', 2, 2), + ('cc', 3, NULL), + ('bb', NULL, NULL), + ('aa', 1, 1), + ('dd', 1, NULL); +alter table t1 add index idx(ie1,ie2); + +# cc 3 NULL NULL +select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2 where a=3 and b is null ; +insert into t2 values ('new1', 10,10); +insert into t1 values ('new1', 1234, 10, NULL); +# new1, 10, 10, NULL, +select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2 where a=10 and b=10; +explain extended +select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2 where a=10 and b=10; +drop table t1, t2; + +# Now test different column types: +create table t1 (oref char(4), grp int, ie int); +insert into t1 (oref, grp, ie) values + ('aa', 10, 2), + ('aa', 10, 1), + ('aa', 20, NULL), + + ('bb', 10, 3), + + ('cc', 10, 4), + ('cc', 20, NULL), + + ('ee', 10, NULL), + ('ee', 10, NULL), + + ('ff', 20, 2), + ('ff', 20, 1); + +create table t2 (oref char(4), a int); +insert into t2 values + ('ee', NULL), + ('bb', 2), + ('ff', 2), + ('cc', 3), + ('aa', 1), + ('dd', NULL), + ('bb', NULL); + +select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; + +select oref, a from t2 where a in (select ie from t1 where oref=t2.oref); + +select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref); + + +select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z from t2; + +select oref, a from t2 where + a in (select min(ie) from t1 where oref=t2.oref group by grp); + +select oref, a from t2 where + a not in (select min(ie) from t1 where oref=t2.oref group by grp); + +# +update t1 set ie=3 where oref='ff' and ie=1; + +select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by +grp) Z from t2; + + +select oref, a from t2 where a in (select min(ie) from t1 where +oref=t2.oref group by grp); + +select oref, a from t2 where a not in (select min(ie) from t1 where +oref=t2.oref group by grp); + +select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by +grp having min(ie) > 1) Z from t2; + +select oref, a from t2 where a in (select min(ie) from t1 where +oref=t2.oref group by grp having min(ie) > 1); + +select oref, a from t2 where a not in (select min(ie) from t1 where +oref=t2.oref group by grp having min(ie) > 1); + +# +alter table t1 add index idx(ie); + +explain select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; + +select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; + +select oref, a from t2 where a in (select ie from t1 where oref=t2.oref); + +select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref); + + +alter table t1 drop index idx; +alter table t1 add index idx(oref,ie); + +explain select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; + +select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; + +select oref, a from t2 where a in (select ie from t1 where oref=t2.oref); + +select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref); + +explain +select oref, a, + a in (select min(ie) from t1 where oref=t2.oref + group by grp having min(ie) > 1) Z +from t2; + +select oref, a, + a in (select min(ie) from t1 where oref=t2.oref + group by grp having min(ie) > 1) Z +from t2; + +select oref, a from t2 where a in (select min(ie) from t1 where oref=t2.oref + group by grp having min(ie) > 1); + +select oref, a from t2 where a not in (select min(ie) from t1 where oref=t2.oref + group by grp having min(ie) > 1); + +drop table t1,t2; + +create table t1 (oref char(4), grp int, ie1 int, ie2 int); +insert into t1 (oref, grp, ie1, ie2) values + ('aa', 10, 2, 1), + ('aa', 10, 1, 1), + ('aa', 20, 2, 1), + + ('bb', 10, 3, 1), + + ('cc', 10, 4, 2), + ('cc', 20, 3, 2), + + ('ee', 10, 2, 1), + ('ee', 10, 1, 2), + + ('ff', 20, 2, 2), + ('ff', 20, 1, 2); + +create table t2 (oref char(4), a int, b int); +insert into t2 values + ('ee', NULL, 1), + ('bb', 2, 1), + ('ff', 2, 2), + ('cc', 3, NULL), + ('bb', NULL, NULL), + ('aa', 1, 1), + ('dd', 1, NULL); + +select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2; + +select oref, a, b from t2 where (a,b) in (select ie1,ie2 from t1 where oref=t2.oref); + +select oref, a, b from t2 where (a,b) not in (select ie1,ie2 from t1 where oref=t2.oref); + +select oref, a, b, + (a,b) in (select min(ie1),max(ie2) from t1 + where oref=t2.oref group by grp) Z +from t2; + +select oref, a, b from t2 where + (a,b) in (select min(ie1), max(ie2) from t1 where oref=t2.oref group by grp); + +select oref, a, b from t2 where + (a,b) not in (select min(ie1), max(ie2) from t1 where oref=t2.oref group by grp); + +alter table t1 add index idx(ie1,ie2); + +explain select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2; + +select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2; + +select oref, a, b from t2 where (a,b) in (select ie1,ie2 from t1 where oref=t2.oref); + +select oref, a, b from t2 where (a,b) not in (select ie1,ie2 from t1 where oref=t2.oref); + +explain extended +select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2; + +drop table t1,t2; + +create table t1 (oref char(4), grp int, ie int primary key); +insert into t1 (oref, grp, ie) values + ('aa', 10, 2), + ('aa', 10, 1), + + ('bb', 10, 3), + + ('cc', 10, 4), + ('cc', 20, 5), + ('cc', 10, 6); + +create table t2 (oref char(4), a int); +insert into t2 values + ('ee', NULL), + ('bb', 2), + ('cc', 5), + ('cc', 2), + ('cc', NULL), + ('aa', 1), + ('bb', NULL); + +explain select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; + +select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; + +select oref, a from t2 where a in (select ie from t1 where oref=t2.oref); + +select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref); + +explain +select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z from t2; + +select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z from t2; + +drop table t1,t2; + +# +# BUG#24420: row-based IN suqueries with aggregation when the left operand +# of the subquery predicate may contain NULL values +# + +create table t1 (a int, b int); +insert into t1 values (0,0), (2,2), (3,3); +create table t2 (a int, b int); +insert into t2 values (1,1), (3,3); + +select a, b, (a,b) in (select a, min(b) from t2 group by a) Z from t1; + +insert into t2 values (NULL,4); +select a, b, (a,b) in (select a, min(b) from t2 group by a) Z from t1; + +drop table t1,t2; + +# +# Bug #24484: Aggregate function used in column list subquery gives erroneous +# error +# +CREATE TABLE t1 (a int, b INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b)); +INSERT INTO t1 VALUES (1,1,'a'), (1,2,'b'), (1,3,'c'), (1,4,'d'), (1,5,'e'), + (2,1,'f'), (2,2,'g'), (2,3,'h'), (3,4,'i'),(3,3,'j'), (3,2,'k'), (3,1,'l'), + (1,9,'m'); +CREATE TABLE t2 (a int, b INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b)); +INSERT INTO t2 SELECT * FROM t1; + +# Gives error, but should work since it is (a, b) is the PK so only one +# given match possible +SELECT a, MAX(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b)) + as test FROM t1 GROUP BY a; +SELECT * FROM t1 GROUP by t1.a + HAVING (MAX(t1.b) > (SELECT MAX(t2.b) FROM t2 WHERE t2.c < t1.c + HAVING MAX(t2.b+t1.a) < 10)); + +SELECT a,b,c FROM t1 WHERE b in (9,3,4) ORDER BY b,c; + +SELECT a, MAX(b), + (SELECT COUNT(DISTINCT t.c) FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) + LIMIT 1) + as cnt, + (SELECT t.b FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) + as t_b, + (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) + as t_b, + (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) ORDER BY t.c LIMIT 1) + as t_b + FROM t1 GROUP BY a; + +SELECT a, MAX(b), + (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) as test + FROM t1 GROUP BY a; + + +DROP TABLE t1, t2; + +# The next three test cases must be executed with the IN=>EXISTS strategy +set @@optimizer_switch="partial_match_rowid_merge=off,partial_match_table_scan=off"; + +# +# Bug #27870: crash of an equijoin query with WHERE condition containing +# a subquery predicate of the form <join attr> NOT IN (SELECT ...) +# + +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int, PRIMARY KEY(b)); +INSERT INTO t1 VALUES (1), (NULL), (4); +INSERT INTO t2 VALUES (3), (1),(2), (5), (4), (7), (6); + +EXPLAIN EXTENDED +SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1)); +SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1)); +SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4)); + +DROP TABLE t1,t2; + +# +# Bug #28375: crash for NOT IN subquery predicate when left operand becomes NULL +# + +CREATE TABLE t1 (id int); +CREATE TABLE t2 (id int PRIMARY KEY); +CREATE TABLE t3 (id int PRIMARY KEY, name varchar(10)); +INSERT INTO t1 VALUES (2), (NULL), (3), (1); +INSERT INTO t2 VALUES (234), (345), (457); +INSERT INTO t3 VALUES (222,'bbb'), (333,'ccc'), (111,'aaa'); + +EXPLAIN +SELECT * FROM t1 + WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3 + WHERE t3.name='xxx' AND t2.id=t3.id); +SELECT * FROM t1 + WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3 + WHERE t3.name='xxx' AND t2.id=t3.id); + +SELECT (t1.id IN (SELECT t2.id FROM t2,t3 + WHERE t3.name='xxx' AND t2.id=t3.id)) AS x + FROM t1; + +DROP TABLE t1,t2,t3; + +# +# Bug #22855: Optimizer doesn't rewrite NOT IN subselects to a correlated +# subquery +# +CREATE TABLE t1 (a INT NOT NULL); +INSERT INTO t1 VALUES (1),(-1), (65),(66); + +CREATE TABLE t2 (a INT UNSIGNED NOT NULL PRIMARY KEY); +INSERT INTO t2 VALUES (65),(66); + +SELECT a FROM t1 WHERE a NOT IN (65,66); +SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2); +EXPLAIN SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2); + +DROP TABLE t1, t2; + +set @@optimizer_switch=@save_optimizer_switch; + +# +# Bug #34763: item_subselect.cc:1235:Item_in_subselect::row_value_transformer: +# Assertion failed, unexpected error message: +# ERROR 1247 (42S22): Reference '<list ref>' not supported (forward +# reference in item list) +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES(1); + +CREATE TABLE t2 (placeholder CHAR(11)); +INSERT INTO t2 VALUES("placeholder"); + +SELECT ROW(1, 2) IN (SELECT t1.a, 2) FROM t1 GROUP BY t1.a; +SELECT ROW(1, 2) IN (SELECT t1.a, 2 FROM t2) FROM t1 GROUP BY t1.a; + +DROP TABLE t1, t2; + +# +# Bug #36005: crash in subselect with single row +# (subselect_single_select_engine::exec) +# + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 SELECT * FROM t1; + +SELECT 1 FROM t1 WHERE t1.a NOT IN (SELECT 1 FROM t1, t2 WHERE 0); + +DROP TABLE t1, t2; + +# +# Bug 2198 +# + +create table t1 (a int, b decimal(13, 3)); +insert into t1 values (1, 0.123); +select a, (select max(b) from t1) into outfile "subselect.out.file.1" from t1; +delete from t1; +load data infile "subselect.out.file.1" into table t1; +select * from t1; +drop table t1; +let $datadir=`select @@datadir`; +--remove_file $datadir/test/subselect.out.file.1 + +# +# Bug #37894: Assertion in init_read_record_seq in handler.h line 1444 +# + +CREATE TABLE t1 ( + pk INT PRIMARY KEY, + int_key INT, + varchar_key VARCHAR(5) UNIQUE, + varchar_nokey VARCHAR(5) +); +INSERT INTO t1 VALUES (9, 7,NULL,NULL), (10,8,'p' ,'p'); + +SELECT varchar_nokey +FROM t1 +WHERE NULL NOT IN ( + SELECT INNR.pk FROM t1 AS INNR2 + LEFT JOIN t1 AS INNR ON ( INNR2.int_key = INNR.int_key ) + WHERE INNR.varchar_key > 'n{' +); + +DROP TABLE t1; + +# +# Bug #39069: <row constructor> IN <table-subquery> seriously messed up +# + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (11); + +--echo # 2nd and 3rd columns should be same +SELECT a, ROW(11, 12) = (SELECT a, 22), ROW(11, 12) IN (SELECT a, 22) FROM t1 GROUP BY t1.a; +SELECT a, ROW(11, 12) = (SELECT a, 12), ROW(11, 12) IN (SELECT a, 12) FROM t1 GROUP BY t1.a; +SELECT a, ROW(11, 12) = (SELECT a, 22), ROW(11, 12) IN (SELECT a, 22) FROM t1; +SELECT a, ROW(11, 12) = (SELECT a, 12), ROW(11, 12) IN (SELECT a, 12) FROM t1; + +# The x alias is used below to workaround bug #40674. +# Regression tests for sum function on outer column in subselect from dual: +SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 22), ROW(11, 12) IN (SELECT MAX(x), 22) FROM t1; +--echo # 2nd and 3rd columns should be same +EXPLAIN SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1; +SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1; + +DROP TABLE t1; + +--echo # both columns should be same +SELECT ROW(1,2) = (SELECT NULL, NULL), ROW(1,2) IN (SELECT NULL, NULL); +SELECT ROW(1,2) = (SELECT 1, NULL), ROW(1,2) IN (SELECT 1, NULL); +SELECT ROW(1,2) = (SELECT NULL, 2), ROW(1,2) IN (SELECT NULL, 2); +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); + +# +# Bug #37362 Crash in do_field_eq +# +# Note that currently this test produces wrong output, see MBug#430669. +# +CREATE TABLE t1 (a INT, b INT, c INT); +INSERT INTO t1 VALUES (1,1,1), (1,1,1); + +--error 1054 +EXPLAIN EXTENDED + SELECT c FROM + ( SELECT + (SELECT COUNT(a) FROM + (SELECT COUNT(b) FROM t1) AS x GROUP BY c + ) FROM t1 GROUP BY b + ) AS y; +SHOW WARNINGS; + +DROP TABLE t1; + + +--echo End of 5.0 tests + +--echo # +--echo # BUG#36896: Server crash on SELECT FROM DUAL +--echo # +create table t1 (a int); +select 1 as res from dual where (1) in (select * from t1); +drop table t1; + +# +# BUG#36135 "void Diagnostics_area::set_eof_status(THD*): Assertion `!is_set()' failed." +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1 ( + a int(11) default null, + b int(11) default null, + key (a) +); +# produce numbers 0..999 +insert into t1 select A.a+10*(B.a+10*C.a),A.a+10*(B.a+10*C.a) from t0 A, t0 B, t0 C; + +create table t2 (a int(11) default null); +insert into t2 values (0),(1); + +create table t3 (a int(11) default null); +insert into t3 values (0),(1); + +create table t4 (a int(11) default null); +insert into t4 values (0),(1); + +create table t5 (a int(11) default null); +insert into t5 values (0),(1),(0),(1); + +# this must not fail assertion +--error 1242 +select * from t2, t3 +where + t2.a < 10 and + t3.a+1 = 2 and + t3.a in (select t1.b from t1 + where t1.a+1=t1.a+1 and + t1.a < (select t4.a+10 + from t4, t5 limit 2)); + +drop table t0, t1, t2, t3, t4, t5; + +--echo # +--echo # BUG#48177 - SELECTs with NOT IN subqueries containing NULL +--echo # values return too many records +--echo # + +CREATE TABLE t1 ( + i1 int DEFAULT NULL, + i2 int DEFAULT NULL +) ; + +INSERT INTO t1 VALUES (1, NULL); +INSERT INTO t1 VALUES (2, 3); +INSERT INTO t1 VALUES (4, NULL); +INSERT INTO t1 VALUES (4, 0); +INSERT INTO t1 VALUES (NULL, NULL); + +CREATE TABLE t2 ( + i1 int DEFAULT NULL, + i2 int DEFAULT NULL +) ; + +INSERT INTO t2 VALUES (4, NULL); +INSERT INTO t2 VALUES (5, 0); + +--echo +--echo Data in t1 +SELECT i1, i2 FROM t1; + +--echo +--echo Data in subquery (should be filtered out) +SELECT i1, i2 FROM t2 ORDER BY i1; + +FLUSH STATUS; +set @save_optimizer_switch2=@@optimizer_switch; +set optimizer_switch='subquery_cache=off'; + +--echo +SELECT i1, i2 +FROM t1 +WHERE (i1, i2) + NOT IN (SELECT i1, i2 FROM t2); + +--echo +--echo # Check that the subquery only has to be evaluated once +--echo # for all-NULL values even though there are two (NULL,NULL) records +--echo # Baseline: +SHOW STATUS LIKE '%Handler_read_rnd_next'; + +--echo +INSERT INTO t1 VALUES (NULL, NULL); +FLUSH STATUS; + +--echo +SELECT i1, i2 +FROM t1 +WHERE (i1, i2) + NOT IN (SELECT i1, i2 FROM t2); + +--echo +--echo # Handler_read_rnd_next should be one more than baseline +--echo # (read record from t1, but do not read from t2) +SHOW STATUS LIKE '%Handler_read_rnd_next'; + +set @@optimizer_switch=@save_optimizer_switch2; +DROP TABLE t1,t2; + +--echo End of 5.1 tests + +# +# Test for the problem with using sj-materialization when subquery's select +# list element SCOL is covered by equality propagation and has preceding equal +# column PCOL which belongs to a table within the the semi-join nest: SJM-Scan +# process should unpack column value not to SCOL but rather to PCOL, as +# substitute_best_equal has made all conditions to refer to PCOL. +# +CREATE TABLE t1 ( + a int(11) NOT NULL, + b int(11) NOT NULL, + c datetime default NULL, + PRIMARY KEY (a), + KEY idx_bc (b,c) +); + +INSERT INTO t1 VALUES +(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), +(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), +(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), +(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), +(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), +(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), +(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), +(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), +(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), +(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), +(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), +(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), +(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), +(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), +(154503,67,'2005-10-28 11:52:38'); + +create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; +create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; +create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; +create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; + +set @@optimizer_switch=@save_optimizer_switch; +set @@optimizer_switch='materialization=off'; + +update t22 set c = '2005-12-08 15:58:27' where a = 255; +explain select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; +select t21.* from t21,t22 where t21.a = t22.a and +t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; + +set @@optimizer_switch=@save_optimizer_switch; + +drop table t1, t11, t12, t21, t22; + +# +# Test sj-materialization re-execution. The test isn't meaningful (materialized +# table stays the same across all executions) because it's hard to create a +# dataset that would verify correct re-execution without hitting BUG#31480 +# +create table t1(a int); +insert into t1 values (0),(1); + +set @@optimizer_switch='firstmatch=off,materialization=off'; +explain +select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X; +select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X; +set @@optimizer_switch=@save_optimizer_switch; + +drop table t1; + +# +# Test confluent duplicate weedout +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select * from t0; +insert into t1 select a+10 from t0; +set @@optimizer_switch='firstmatch=off,materialization=off'; +insert into t0 values(2); +explain select * from t1 where 2 in (select a from t0); +select * from t1 where 2 in (select a from t0); +set @@optimizer_switch=@save_optimizer_switch; +set @@optimizer_switch='materialization=off'; +explain select * from t1 where 2 in (select a from t0); +select * from t1 where 2 in (select a from t0); +set @@optimizer_switch=@save_optimizer_switch; + + +set @@optimizer_switch=@save_optimizer_switch; +set @@optimizer_switch='materialization=off'; + +# +# FirstMatch referring to a derived table +# +set @tmp_optimizer_switch=@@optimizer_switch; +set optimizer_switch='derived_merge=off,derived_with_keys=off'; +explain select * from (select a from t0) X where a in (select a from t1); +drop table t0, t1; +set optimizer_switch=@tmp_optimizer_switch; + +# +# LooseScan: Check if we can pick it together with range access +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); + +create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); +insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; +insert into t1 select * from t1 where kp1 < 20; + +create table t3 (a int); +insert into t3 select A.a + 10*B.a from t0 A, t0 B; + +explain select * from t3 where a in (select kp1 from t1 where kp1<20); + +create table t4 (pk int primary key); +insert into t4 select a from t3; + +explain select * from t3 where a in (select t1.kp1 from t1,t4 where kp1<20 +and t4.pk=t1.c); + +drop table t1, t3, t4; + +set @@optimizer_switch=@save_optimizer_switch; + +# +# Test if we handle duplicate elimination temptable overflowing to disk +# +create table t1 (a int) as select * from t0 where a < 5; + +set @save_max_heap_table_size=@@max_heap_table_size; +set @@optimizer_switch='firstmatch=off,materialization=off'; +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; +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); +show status like 'Created_tmp_disk_tables'; +set @save_max_heap_table_size=@@max_heap_table_size; +set @@optimizer_switch=@save_optimizer_switch; +drop table t0, t1; + +# +# Materialize + Scan + ref access to the subsequent table based on scanned +# value +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2(a int); +insert into t2 values (1),(2); +create table t3 ( a int , filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; +explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); +select * from t3 where a in (select a from t2); + +drop table t0, t2, t3; + +# +# DATETIME type checks +# +set @@optimizer_switch='firstmatch=off,materialization=off'; +create table t1 (a date); +insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); +create table t2 (a int); +insert into t2 values (1),(2); +create table t3 (a char(10)); +insert into t3 select * from t1; +insert into t3 values (1),(2); +explain select * from t2 where a in (select a from t1); +explain select * from t2 where a in (select a from t2); +explain select * from t2 where a in (select a from t3); +explain select * from t1 where a in (select a from t3); +drop table t1, t2, t3; +create table t1 (a decimal); +insert into t1 values (1),(2); +explain select * from t1 where a in (select a from t1); +drop table t1; +set @@optimizer_switch=@save_optimizer_switch; + +set @@optimizer_switch=@save_optimizer_switch; +set @@optimizer_switch='materialization=off'; + +# +# SJ-Materialization-scan for non-first table +# +create table t1 (a int); +insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t2 as select * from t1; +create table t3 (a int, b int, filler char(100), key(a)); +insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; +explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; + +# +# Verify that straight_join modifier in parent or child prevents flattening +# +explain select straight_join * from t1 A, t1 B where A.a in (select a from t2); +explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B); +explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B); +explain select straight_join * from t2 X, t2 Y +where X.a in (select straight_join A.a from t1 A, t1 B); + +# +# SJ-Materialization scan + first table being system const table +# +create table t0 (a int, b int); +insert into t0 values(1,1); +explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); +create table t4 as select a as x, a as y from t1; +explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); +drop table t0,t1,t2,t3,t4; + +# +# LooseScan with ref access +# +create table t0 (a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, b int, filler char(100), key(a,b)); +insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; +create table t2 as select * from t1; + +explain select * from t2 where a in (select b from t1 where a=3); +explain select * from t2 where (b,a) in (select a,b from t1 where a=3); + +drop table t1,t2; + +set @@optimizer_switch=@save_optimizer_switch; + +# +# Multi-column sj-materialization with lookups +# +create table t1 (a int, b int); +insert into t1 select a,a from t0; +create table t2 (a int, b int); +insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; + +set @@optimizer_switch='firstmatch=off,materialization=off'; +explain select * from t1 where (a,b) in (select a,b from t2); + +# A smallish test if find_best() still works for semi-join optimization: +set @save_optimizer_search_depth=@@optimizer_search_depth; +set @@optimizer_search_depth=63; +explain select * from t1 where (a,b) in (select a,b from t2); +set @@optimizer_search_depth=@save_optimizer_search_depth; +set @@optimizer_switch=@save_optimizer_switch; + +drop table t0, t1, t2; + +set @@optimizer_switch='materialization=off'; + +# +# Primitive SJ-Materialization tests for DECIMAL and DATE +# +create table t0 (a decimal(4,2)); +insert into t0 values (10.24), (22.11); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +select * from t0 where a in (select a from t1); +drop table t0, t1; + +create table t0(a date); +insert into t0 values ('2008-01-01'),('2008-02-02'); +create table t1 as select * from t0; +insert into t1 select * from t0; +explain select * from t0 where a in (select a from t1); +select * from t0 where a in (select a from t1); +drop table t0, t1; + +# +# Fix a trivial crash with SJ-Materialization lookup, multiple tables in the +# subquery, and a condition on some of inner tables but not others +# +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 as select a as a, a as b, a as c from t0 where a < 3; +create table t2 as select a as a, a as b from t0 where a < 3; +insert into t2 select * from t2; + +explain select * from t1 where (a,b,c) in (select X.a, Y.a, Z.a from t2 X, t2 Y, t2 Z where X.b=33); + +drop table t0,t1,t2; + +set @@optimizer_switch=@save_optimizer_switch; + +--echo +--echo BUG#37842: Assertion in DsMrr_impl::dsmrr_init, at handler.cc:4307 +--echo +CREATE TABLE t1 ( + `pk` int(11) NOT NULL AUTO_INCREMENT, + `int_key` int(11) DEFAULT NULL, + PRIMARY KEY (`pk`), + KEY `int_key` (`int_key`) +) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,9),(2,3),(3,8),(4,6),(5,9),(6,5),(7,5),(8,9),(9,1),(10,10); +SELECT `pk` FROM t1 AS OUTR WHERE `int_key` = ALL ( + SELECT `int_key` FROM t1 AS INNR WHERE INNR . `pk` >= 9 +); +DROP TABLE t1; + +--echo +--echo BUG#40118 Crash when running Batched Key Access and requiring one match for each key +--echo +create table t0(a int); +insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); +create table t1 (a int, key(a)); +insert into t1 select * from t0; +alter table t1 add b int not null, add filler char(200); +insert into t1 select * from t1; +insert into t1 select * from t1; + +set @save_join_cache_level=@@join_cache_level; +set join_cache_level=6; +select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); +set join_cache_level=@save_join_cache_level; +drop table t0, t1; + +--echo # +--echo # BUG#32665 Query with dependent subquery is too slow +--echo # +create table t1 ( + idIndividual int primary key +); +insert into t1 values (1),(2); + +create table t2 ( + idContact int primary key, + contactType int, + idObj int +); +insert into t2 values (1,1,1),(2,2,2),(3,3,3); + +create table t3 ( + idAddress int primary key, + idContact int, + postalStripped varchar(100) +); + +insert into t3 values (1,1, 'foo'), (2,2,'bar'); + +--echo The following must be converted to a semi-join: +set @save_optimizer_switch=@@optimizer_switch; +set @@optimizer_switch='materialization=off'; +explain extended SELECT a.idIndividual FROM t1 a +WHERE a.idIndividual IN + ( SELECT c.idObj FROM t3 cona + INNER JOIN t2 c ON c.idContact=cona.idContact + WHERE cona.postalStripped='T2H3B2' + ); +set @@optimizer_switch=@save_optimizer_switch; +drop table t1,t2,t3; + +--echo # +--echo # BUG#47367 Crash in Name_resolution_context::process_error +--echo # + +SET SESSION optimizer_switch = 'semijoin=off'; +CREATE TABLE t1 (f1 INTEGER); +CREATE TABLE t2 LIKE t1; +delimiter |; +CREATE PROCEDURE p1 () BEGIN SELECT f1 FROM t1 WHERE f1 IN (SELECT f1 FROM t2); END| +delimiter ;| +CALL p1; +ALTER TABLE t2 CHANGE COLUMN f1 my_column INT; +CALL p1; +DROP PROCEDURE p1; +--echo # Restore the original column list of table t2: +ALTER TABLE t2 CHANGE COLUMN my_column f1 INT; + +SET SESSION optimizer_switch = 'semijoin=on'; +delimiter |; +--echo # Recreate procedure so that we eliminate any caching effects +CREATE PROCEDURE p1 () BEGIN SELECT f1 FROM t1 WHERE f1 IN (SELECT f1 FROM t2); END| +delimiter ;| +CALL p1; +ALTER TABLE t2 CHANGE COLUMN f1 my_column INT; +--error ER_BAD_FIELD_ERROR +CALL p1; +DROP PROCEDURE p1; +DROP TABLE t1, t2; + +--echo # +--echo # fix of lp:824425 (prohibiting subqueries in row in +--echo # left part of IN/ALL/ANY) +--echo # + +CREATE TABLE t1 ( a int) ; +INSERT INTO t1 VALUES (20),(30); + +CREATE TABLE t2 (a int) ; +INSERT INTO t2 VALUES (3),(9); + +CREATE TABLE t3 ( a int, b int) ; +INSERT INTO t3 VALUES (20,5),(30,6); + +set @optimizer_switch_save=@@optimizer_switch; +SET SESSION optimizer_switch='semijoin=OFF,in_to_exists=OFF,materialization=ON,partial_match_rowid_merge=ON,partial_match_table_scan=OFF'; + +SELECT * FROM t1 +WHERE ( + ( SELECT a FROM t2 WHERE a = 9 ) +) NOT IN ( + SELECT b + FROM t3 +); +explain extended +SELECT * FROM t1 +WHERE ( + ( SELECT a FROM t2 WHERE a = 9 ) +) NOT IN ( + SELECT b + FROM t3 +); + +--error ER_NOT_SUPPORTED_YET +SELECT * FROM t1 +WHERE ( + ( SELECT a FROM t2 WHERE a = 9 ), + ( SELECT a FROM t2 WHERE a = 3 ) +) NOT IN ( + SELECT b , a + FROM t3 +); +set optimizer_switch=@optimizer_switch_save; + +drop table t1,t2,t3; + +--echo End of 5.3 tests + +--echo # +--echo # BUG#48920: COUNT DISTINCT returns 1 for NULL values when in a subquery +--echo # in the select list +--echo # + +--echo +CREATE TABLE t1 ( + i int(11) DEFAULT NULL, + v varchar(1) DEFAULT NULL +); + +--echo +INSERT INTO t1 VALUES (8,'v'); +INSERT INTO t1 VALUES (9,'r'); +INSERT INTO t1 VALUES (NULL,'y'); + +--echo +CREATE TABLE t2 ( + i int(11) DEFAULT NULL, + v varchar(1) DEFAULT NULL, + KEY i_key (i) +); + +--echo +INSERT INTO t2 VALUES (NULL,'r'); +INSERT INTO t2 VALUES (0,'c'); +INSERT INTO t2 VALUES (0,'o'); +INSERT INTO t2 VALUES (2,'v'); +INSERT INTO t2 VALUES (7,'c'); + +--echo +SELECT i, v, (SELECT COUNT(DISTINCT i) + FROM t1 + WHERE v = t2.v) as subsel +FROM t2; + +--echo +EXPLAIN EXTENDED +SELECT i, v, (SELECT COUNT(DISTINCT i) + FROM t1 + WHERE v = t2.v) as subsel +FROM t2; + +DROP TABLE t1,t2; + +--echo End of 5.6 tests diff --git a/mysql-test/main/subselect3.result b/mysql-test/main/subselect3.result index 3c33182b3ef..5c4544a1b05 100644 --- a/mysql-test/main/subselect3.result +++ b/mysql-test/main/subselect3.result @@ -1,7 +1,7 @@ drop table if exists t0, t1, t2, t3, t4, t5, t11, t12, t21, t22; -set @subselect3_tmp= @@optimizer_switch; -set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'; set join_cache_level=1; +drop table if exists t0, t1, t2, t3, t4, t5, t11, t12, t21, t22; +set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'; create table t1 (oref int, grp int, ie int) ; insert into t1 (oref, grp, ie) values (1, 1, 1), @@ -1544,4 +1544,4 @@ Note 1276 Field or reference 'test.t2.v' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`v` AS `v`,<expr_cache><`test`.`t2`.`v`>((/* select#2 */ select count(distinct `test`.`t1`.`i`) from `test`.`t1` where `test`.`t1`.`v` = `test`.`t2`.`v`)) AS `subsel` from `test`.`t2` DROP TABLE t1,t2; End of 5.6 tests -set @@optimizer_switch=@subselect3_tmp; +# end of 10.2 test diff --git a/mysql-test/main/subselect3.test b/mysql-test/main/subselect3.test index 0221315eb35..79034f976a8 100644 --- a/mysql-test/main/subselect3.test +++ b/mysql-test/main/subselect3.test @@ -1,1318 +1,10 @@ --disable_warnings drop table if exists t0, t1, t2, t3, t4, t5, t11, t12, t21, t22; --enable_warnings +--source include/default_optimizer_switch.inc -set @subselect3_tmp= @@optimizer_switch; -set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'; -if (`select @join_cache_level_for_subselect3_test is null`) -{ - set join_cache_level=1; -} -if (`select @join_cache_level_for_subselect3_test is not null`) -{ - set join_cache_level=@join_cache_level_for_subselect3_test; -} +set join_cache_level=1; -# -# 1. Subquery with GROUP/HAVING -# -create table t1 (oref int, grp int, ie int) ; -insert into t1 (oref, grp, ie) values - (1, 1, 1), - (1, 1, 1), - (1, 2, NULL), +--source subselect3.inc - (2, 1, 3), - - (3, 1, 4), - (3, 2, NULL); - -# Ok, for -# select max(ie) from t1 where oref=PARAM group by grp -# we'll have: -# PARAM subquery result -# 1 -> {(1), (NULL)} matching + NULL -# 2 -> {(3)} non-matching -# 3 -> {(3), (NULL)} non-matching + NULL -# 4 -> {} empty set - -create table t2 (oref int, a int); -insert into t2 values - (1, 1), - (2, 2), - (3, 3), - (4, NULL), - (2, NULL); - -# true, false, null, false, null -select a, oref, a in (select max(ie) - from t1 where oref=t2.oref group by grp) Z from t2; - -# This must have a trigcond -explain extended -select a, oref, a in (select max(ie) - from t1 where oref=t2.oref group by grp) Z from t2; - -# This must not have a trigcond: -explain extended -select a, oref from t2 -where a in (select max(ie) from t1 where oref=t2.oref group by grp); -select a, oref, a in ( - select max(ie) from t1 where oref=t2.oref group by grp union - select max(ie) from t1 where oref=t2.oref group by grp - ) Z from t2; - -# Non-correlated subquery, 2 NULL evaluations -create table t3 (a int); -insert into t3 values (NULL), (NULL); -flush status; -select a in (select max(ie) from t1 where oref=4 group by grp) from t3; -show status like 'Handler_read_rnd_next'; -select ' ^ This must show 11' Z; - -set @save_optimizer_switch=@@optimizer_switch; -set @@optimizer_switch="partial_match_rowid_merge=off,partial_match_table_scan=off"; - -# This must show trigcond: -explain extended select a in (select max(ie) from t1 where oref=4 group by grp) from t3; - -set @@optimizer_switch=@save_optimizer_switch; -drop table t1, t2, t3; - -# -# 2. Subquery handled with 'index_subquery': -# -create table t1 (a int, oref int, key(a)); -insert into t1 values - (1, 1), - (1, NULL), - (2, 3), - (2, NULL), - (3, NULL); -insert into t1 values (5, 7), (8, 9), (4, 1); - -create table t2 (a int, oref int); -insert into t2 values (1, 1), (2,2), (NULL, 3), (NULL, 4); - -select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2; - -# The next explain shows "using index" but that is just incorrect display -# (there is a bug filed about this). -explain extended -select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2; - -flush status; -select oref, a from t2 where a in (select a from t1 where oref=t2.oref); -# This will only show access to t2: -show status like '%Handler_read_rnd_next'; - -# Check that repeated NULL-scans are not cached (subq. is not correlated): -delete from t2; -insert into t2 values (NULL, 0),(NULL, 0), (NULL, 0), (NULL, 0); - -set optimizer_switch='subquery_cache=off'; -flush status; -select oref, a, a in (select a from t1 where oref=t2.oref) Z from t2; -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; - -drop table t1, t2; - -# -# 3. Subquery handled with 'unique_index_subquery': -# -create table t1 (a int, b int, primary key (a)); -insert into t1 values (1,1), (3,1),(100,1); - -create table t2 (a int, b int); -insert into t2 values (1,1),(2,1),(NULL,1),(NULL,0); - -select a,b, a in (select a from t1 where t1.b = t2.b) Z from t2 ; - -drop table t1, t2; - -# -# 4. Subquery that is a join, with ref access -# -create table t1 (a int, b int, key(a)); -insert into t1 values - (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); - -create table t2 like t1; -insert into t2 select * from t1; -update t2 set b=1; - -create table t3 (a int, oref int); -insert into t3 values (1, 1), (NULL,1), (NULL,0); -select a, oref, - t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z -from t3; - -# This must have trigcond in WHERE and HAVING: -explain extended -select a, oref, - t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z -from t3; - -drop table t1, t2, t3; - - -# -# BUG#24085: Wrong query result for "NULL IN (SELECT ... UNION SELECT ...)" -# - -# case 1: NULL IN (SELECT not_null_val FROM ...) w/o HAVING/GROUP-BY/etc -create table t1 (a int NOT NULL, b int NOT NULL, key(a)); -insert into t1 values - (0,0),(1,1),(2,2),(3,3),(4,4),(5,5),(6,6),(7,7),(8,8),(9,9); - -create table t2 like t1; -insert into t2 select * from t1; -update t2 set b=1; - -create table t3 (a int, oref int); -insert into t3 values (1, 1), (NULL,1), (NULL,0); -select a, oref, - t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z -from t3; - ---echo This must show a trig_cond: -explain extended -select a, oref, - t3.a in (select t1.a from t1, t2 where t1.b=t2.a and t2.b=t3.oref) Z -from t3; -drop table t1,t2,t3; - - -# case 2: NULL IN (SELECT not_null_val FROM) where SELECT has GROUP BY -create table t1 (oref int, grp int); -insert into t1 (oref, grp) values - (1, 1), - (1, 1); - -# Ok, for -# select count(*) from t1 group by grp having grp=PARAM -# we'll have: -# PARAM subuqery result -# 1 -> {(2)} -# 2 -> {} - empty set -create table t2 (oref int, a int); -insert into t2 values - (1, NULL), - (2, NULL); - -select a, oref, - a in (select count(*) from t1 group by grp having grp=t2.oref) Z from t2; - ---echo This must show a trig_cond: -explain extended -select a, oref, - a in (select count(*) from t1 group by grp having grp=t2.oref) Z from t2; - -drop table t1, t2; - -create table t1 (a int, b int, primary key (a)); -insert into t1 values (1,1), (3,1),(100,1); -create table t2 (a int, b int); -insert into t2 values (1,1),(2,1),(NULL,1),(NULL,0); - -select a,b, a in (select a from t1 where t1.b = t2.b union select a from -t1 where t1.b = t2.b) Z from t2 ; -select a,b, a in (select a from t1 where t1.b = t2.b) Z from t2 ; -drop table t1, t2; - - -# -# BUG#24127: Incorrect results of row-based subqueries with NULLs on the left side. -# -create table t3 (a int); -insert into t3 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table t2 (a int, b int, oref int); -insert into t2 values (NULL,1, 100), (NULL,2, 100); - -create table t1 (a int, b int, c int, key(a,b)); -insert into t1 select 2*A, 2*A, 100 from t3; - -# First test index subquery engine -explain extended select a,b, oref, (a,b) in (select a,b from t1 where c=t2.oref) Z from t2; -select a,b, oref, (a,b) in (select a,b from t1 where c=t2.oref) Z from t2; - -# Then check that we do turn off 'ref' scans in the subquery -create table t4 (x int); -insert into t4 select A.a + 10*B.a from t1 A, t1 B; -explain extended - select a,b, oref, - (a,b) in (select a,b from t1,t4 where c=t2.oref) Z - from t2; -select a,b, oref, - (a,b) in (select a,b from t1,t4 where c=t2.oref) Z -from t2; - -drop table t1,t2,t3,t4; - -# More tests for tricky multi-column cases, where some of pushed-down -# equalities are used for index lookups and some arent. -create table t1 (oref char(4), grp int, ie1 int, ie2 int); -insert into t1 (oref, grp, ie1, ie2) values - ('aa', 10, 2, 1), - ('aa', 10, 1, 1), - ('aa', 20, 2, 1), - ('bb', 10, 3, 1), - ('cc', 10, 4, 2), - ('cc', 20, 3, 2), - - ('ee', 10, 2, 1), - ('ee', 10, 1, 2), - - ('ff', 20, 2, 2), - ('ff', 20, 1, 2); -create table t2 (oref char(4), a int, b int); -insert into t2 values - ('ee', NULL, 1), - ('bb', 2, 1), - ('ff', 2, 2), - ('cc', 3, NULL), - ('bb', NULL, NULL), - ('aa', 1, 1), - ('dd', 1, NULL); -alter table t1 add index idx(ie1,ie2); - -# cc 3 NULL NULL -select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2 where a=3 and b is null ; -insert into t2 values ('new1', 10,10); -insert into t1 values ('new1', 1234, 10, NULL); -# new1, 10, 10, NULL, -select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2 where a=10 and b=10; -explain extended -select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2 where a=10 and b=10; -drop table t1, t2; - -# Now test different column types: -create table t1 (oref char(4), grp int, ie int); -insert into t1 (oref, grp, ie) values - ('aa', 10, 2), - ('aa', 10, 1), - ('aa', 20, NULL), - - ('bb', 10, 3), - - ('cc', 10, 4), - ('cc', 20, NULL), - - ('ee', 10, NULL), - ('ee', 10, NULL), - - ('ff', 20, 2), - ('ff', 20, 1); - -create table t2 (oref char(4), a int); -insert into t2 values - ('ee', NULL), - ('bb', 2), - ('ff', 2), - ('cc', 3), - ('aa', 1), - ('dd', NULL), - ('bb', NULL); - -select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; - -select oref, a from t2 where a in (select ie from t1 where oref=t2.oref); - -select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref); - - -select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z from t2; - -select oref, a from t2 where - a in (select min(ie) from t1 where oref=t2.oref group by grp); - -select oref, a from t2 where - a not in (select min(ie) from t1 where oref=t2.oref group by grp); - -# -update t1 set ie=3 where oref='ff' and ie=1; - -select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by -grp) Z from t2; - - -select oref, a from t2 where a in (select min(ie) from t1 where -oref=t2.oref group by grp); - -select oref, a from t2 where a not in (select min(ie) from t1 where -oref=t2.oref group by grp); - -select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by -grp having min(ie) > 1) Z from t2; - -select oref, a from t2 where a in (select min(ie) from t1 where -oref=t2.oref group by grp having min(ie) > 1); - -select oref, a from t2 where a not in (select min(ie) from t1 where -oref=t2.oref group by grp having min(ie) > 1); - -# -alter table t1 add index idx(ie); - -explain select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; - -select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; - -select oref, a from t2 where a in (select ie from t1 where oref=t2.oref); - -select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref); - - -alter table t1 drop index idx; -alter table t1 add index idx(oref,ie); - -explain select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; - -select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; - -select oref, a from t2 where a in (select ie from t1 where oref=t2.oref); - -select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref); - -explain -select oref, a, - a in (select min(ie) from t1 where oref=t2.oref - group by grp having min(ie) > 1) Z -from t2; - -select oref, a, - a in (select min(ie) from t1 where oref=t2.oref - group by grp having min(ie) > 1) Z -from t2; - -select oref, a from t2 where a in (select min(ie) from t1 where oref=t2.oref - group by grp having min(ie) > 1); - -select oref, a from t2 where a not in (select min(ie) from t1 where oref=t2.oref - group by grp having min(ie) > 1); - -drop table t1,t2; - -create table t1 (oref char(4), grp int, ie1 int, ie2 int); -insert into t1 (oref, grp, ie1, ie2) values - ('aa', 10, 2, 1), - ('aa', 10, 1, 1), - ('aa', 20, 2, 1), - - ('bb', 10, 3, 1), - - ('cc', 10, 4, 2), - ('cc', 20, 3, 2), - - ('ee', 10, 2, 1), - ('ee', 10, 1, 2), - - ('ff', 20, 2, 2), - ('ff', 20, 1, 2); - -create table t2 (oref char(4), a int, b int); -insert into t2 values - ('ee', NULL, 1), - ('bb', 2, 1), - ('ff', 2, 2), - ('cc', 3, NULL), - ('bb', NULL, NULL), - ('aa', 1, 1), - ('dd', 1, NULL); - -select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2; - -select oref, a, b from t2 where (a,b) in (select ie1,ie2 from t1 where oref=t2.oref); - -select oref, a, b from t2 where (a,b) not in (select ie1,ie2 from t1 where oref=t2.oref); - -select oref, a, b, - (a,b) in (select min(ie1),max(ie2) from t1 - where oref=t2.oref group by grp) Z -from t2; - -select oref, a, b from t2 where - (a,b) in (select min(ie1), max(ie2) from t1 where oref=t2.oref group by grp); - -select oref, a, b from t2 where - (a,b) not in (select min(ie1), max(ie2) from t1 where oref=t2.oref group by grp); - -alter table t1 add index idx(ie1,ie2); - -explain select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2; - -select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2; - -select oref, a, b from t2 where (a,b) in (select ie1,ie2 from t1 where oref=t2.oref); - -select oref, a, b from t2 where (a,b) not in (select ie1,ie2 from t1 where oref=t2.oref); - -explain extended -select oref, a, b, (a,b) in (select ie1,ie2 from t1 where oref=t2.oref) Z from t2; - -drop table t1,t2; - -create table t1 (oref char(4), grp int, ie int primary key); -insert into t1 (oref, grp, ie) values - ('aa', 10, 2), - ('aa', 10, 1), - - ('bb', 10, 3), - - ('cc', 10, 4), - ('cc', 20, 5), - ('cc', 10, 6); - -create table t2 (oref char(4), a int); -insert into t2 values - ('ee', NULL), - ('bb', 2), - ('cc', 5), - ('cc', 2), - ('cc', NULL), - ('aa', 1), - ('bb', NULL); - -explain select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; - -select oref, a, a in (select ie from t1 where oref=t2.oref) Z from t2; - -select oref, a from t2 where a in (select ie from t1 where oref=t2.oref); - -select oref, a from t2 where a not in (select ie from t1 where oref=t2.oref); - -explain -select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z from t2; - -select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z from t2; - -drop table t1,t2; - -# -# BUG#24420: row-based IN suqueries with aggregation when the left operand -# of the subquery predicate may contain NULL values -# - -create table t1 (a int, b int); -insert into t1 values (0,0), (2,2), (3,3); -create table t2 (a int, b int); -insert into t2 values (1,1), (3,3); - -select a, b, (a,b) in (select a, min(b) from t2 group by a) Z from t1; - -insert into t2 values (NULL,4); -select a, b, (a,b) in (select a, min(b) from t2 group by a) Z from t1; - -drop table t1,t2; - -# -# Bug #24484: Aggregate function used in column list subquery gives erroneous -# error -# -CREATE TABLE t1 (a int, b INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b)); -INSERT INTO t1 VALUES (1,1,'a'), (1,2,'b'), (1,3,'c'), (1,4,'d'), (1,5,'e'), - (2,1,'f'), (2,2,'g'), (2,3,'h'), (3,4,'i'),(3,3,'j'), (3,2,'k'), (3,1,'l'), - (1,9,'m'); -CREATE TABLE t2 (a int, b INT, c CHAR(10) NOT NULL, PRIMARY KEY (a, b)); -INSERT INTO t2 SELECT * FROM t1; - -# Gives error, but should work since it is (a, b) is the PK so only one -# given match possible -SELECT a, MAX(b), (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b)) - as test FROM t1 GROUP BY a; -SELECT * FROM t1 GROUP by t1.a - HAVING (MAX(t1.b) > (SELECT MAX(t2.b) FROM t2 WHERE t2.c < t1.c - HAVING MAX(t2.b+t1.a) < 10)); - -SELECT a,b,c FROM t1 WHERE b in (9,3,4) ORDER BY b,c; - -SELECT a, MAX(b), - (SELECT COUNT(DISTINCT t.c) FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) - LIMIT 1) - as cnt, - (SELECT t.b FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) - as t_b, - (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) - as t_b, - (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) ORDER BY t.c LIMIT 1) - as t_b - FROM t1 GROUP BY a; - -SELECT a, MAX(b), - (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.b=MAX(t1.b) LIMIT 1) as test - FROM t1 GROUP BY a; - - -DROP TABLE t1, t2; - -# The next three test cases must be executed with the IN=>EXISTS strategy -set @@optimizer_switch="partial_match_rowid_merge=off,partial_match_table_scan=off"; - -# -# Bug #27870: crash of an equijoin query with WHERE condition containing -# a subquery predicate of the form <join attr> NOT IN (SELECT ...) -# - -CREATE TABLE t1 (a int); -CREATE TABLE t2 (b int, PRIMARY KEY(b)); -INSERT INTO t1 VALUES (1), (NULL), (4); -INSERT INTO t2 VALUES (3), (1),(2), (5), (4), (7), (6); - -EXPLAIN EXTENDED -SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1)); -SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1)); -SELECT a FROM t1, t2 WHERE a=b AND (b NOT IN (SELECT a FROM t1 WHERE a > 4)); - -DROP TABLE t1,t2; - -# -# Bug #28375: crash for NOT IN subquery predicate when left operand becomes NULL -# - -CREATE TABLE t1 (id int); -CREATE TABLE t2 (id int PRIMARY KEY); -CREATE TABLE t3 (id int PRIMARY KEY, name varchar(10)); -INSERT INTO t1 VALUES (2), (NULL), (3), (1); -INSERT INTO t2 VALUES (234), (345), (457); -INSERT INTO t3 VALUES (222,'bbb'), (333,'ccc'), (111,'aaa'); - -EXPLAIN -SELECT * FROM t1 - WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3 - WHERE t3.name='xxx' AND t2.id=t3.id); -SELECT * FROM t1 - WHERE t1.id NOT IN (SELECT t2.id FROM t2,t3 - WHERE t3.name='xxx' AND t2.id=t3.id); - -SELECT (t1.id IN (SELECT t2.id FROM t2,t3 - WHERE t3.name='xxx' AND t2.id=t3.id)) AS x - FROM t1; - -DROP TABLE t1,t2,t3; - -# -# Bug #22855: Optimizer doesn't rewrite NOT IN subselects to a correlated -# subquery -# -CREATE TABLE t1 (a INT NOT NULL); -INSERT INTO t1 VALUES (1),(-1), (65),(66); - -CREATE TABLE t2 (a INT UNSIGNED NOT NULL PRIMARY KEY); -INSERT INTO t2 VALUES (65),(66); - -SELECT a FROM t1 WHERE a NOT IN (65,66); -SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2); -EXPLAIN SELECT a FROM t1 WHERE a NOT IN (SELECT a FROM t2); - -DROP TABLE t1, t2; - -set @@optimizer_switch=@save_optimizer_switch; - -# -# Bug #34763: item_subselect.cc:1235:Item_in_subselect::row_value_transformer: -# Assertion failed, unexpected error message: -# ERROR 1247 (42S22): Reference '<list ref>' not supported (forward -# reference in item list) -# -CREATE TABLE t1 (a INT); -INSERT INTO t1 VALUES(1); - -CREATE TABLE t2 (placeholder CHAR(11)); -INSERT INTO t2 VALUES("placeholder"); - -SELECT ROW(1, 2) IN (SELECT t1.a, 2) FROM t1 GROUP BY t1.a; -SELECT ROW(1, 2) IN (SELECT t1.a, 2 FROM t2) FROM t1 GROUP BY t1.a; - -DROP TABLE t1, t2; - -# -# Bug #36005: crash in subselect with single row -# (subselect_single_select_engine::exec) -# - -CREATE TABLE t1 (a INT); -INSERT INTO t1 VALUES (1),(2),(3); -CREATE TABLE t2 SELECT * FROM t1; - -SELECT 1 FROM t1 WHERE t1.a NOT IN (SELECT 1 FROM t1, t2 WHERE 0); - -DROP TABLE t1, t2; - -# -# Bug 2198 -# - -create table t1 (a int, b decimal(13, 3)); -insert into t1 values (1, 0.123); -select a, (select max(b) from t1) into outfile "subselect.out.file.1" from t1; -delete from t1; -load data infile "subselect.out.file.1" into table t1; -select * from t1; -drop table t1; -let $datadir=`select @@datadir`; ---remove_file $datadir/test/subselect.out.file.1 - -# -# Bug #37894: Assertion in init_read_record_seq in handler.h line 1444 -# - -CREATE TABLE t1 ( - pk INT PRIMARY KEY, - int_key INT, - varchar_key VARCHAR(5) UNIQUE, - varchar_nokey VARCHAR(5) -); -INSERT INTO t1 VALUES (9, 7,NULL,NULL), (10,8,'p' ,'p'); - -SELECT varchar_nokey -FROM t1 -WHERE NULL NOT IN ( - SELECT INNR.pk FROM t1 AS INNR2 - LEFT JOIN t1 AS INNR ON ( INNR2.int_key = INNR.int_key ) - WHERE INNR.varchar_key > 'n{' -); - -DROP TABLE t1; - -# -# Bug #39069: <row constructor> IN <table-subquery> seriously messed up -# - -CREATE TABLE t1 (a INT); -INSERT INTO t1 VALUES (1), (2), (11); - ---echo # 2nd and 3rd columns should be same -SELECT a, ROW(11, 12) = (SELECT a, 22), ROW(11, 12) IN (SELECT a, 22) FROM t1 GROUP BY t1.a; -SELECT a, ROW(11, 12) = (SELECT a, 12), ROW(11, 12) IN (SELECT a, 12) FROM t1 GROUP BY t1.a; -SELECT a, ROW(11, 12) = (SELECT a, 22), ROW(11, 12) IN (SELECT a, 22) FROM t1; -SELECT a, ROW(11, 12) = (SELECT a, 12), ROW(11, 12) IN (SELECT a, 12) FROM t1; - -# The x alias is used below to workaround bug #40674. -# Regression tests for sum function on outer column in subselect from dual: -SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 22), ROW(11, 12) IN (SELECT MAX(x), 22) FROM t1; ---echo # 2nd and 3rd columns should be same -EXPLAIN SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1; -SELECT a AS x, ROW(11, 12) = (SELECT MAX(x), 12), ROW(11, 12) IN (SELECT MAX(x), 12) FROM t1; - -DROP TABLE t1; - ---echo # both columns should be same -SELECT ROW(1,2) = (SELECT NULL, NULL), ROW(1,2) IN (SELECT NULL, NULL); -SELECT ROW(1,2) = (SELECT 1, NULL), ROW(1,2) IN (SELECT 1, NULL); -SELECT ROW(1,2) = (SELECT NULL, 2), ROW(1,2) IN (SELECT NULL, 2); -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); - -# -# Bug #37362 Crash in do_field_eq -# -# Note that currently this test produces wrong output, see MBug#430669. -# -CREATE TABLE t1 (a INT, b INT, c INT); -INSERT INTO t1 VALUES (1,1,1), (1,1,1); - ---error 1054 -EXPLAIN EXTENDED - SELECT c FROM - ( SELECT - (SELECT COUNT(a) FROM - (SELECT COUNT(b) FROM t1) AS x GROUP BY c - ) FROM t1 GROUP BY b - ) AS y; -SHOW WARNINGS; - -DROP TABLE t1; - - ---echo End of 5.0 tests - ---echo # ---echo # BUG#36896: Server crash on SELECT FROM DUAL ---echo # -create table t1 (a int); -select 1 as res from dual where (1) in (select * from t1); -drop table t1; - -# -# BUG#36135 "void Diagnostics_area::set_eof_status(THD*): Assertion `!is_set()' failed." -# -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); - -create table t1 ( - a int(11) default null, - b int(11) default null, - key (a) -); -# produce numbers 0..999 -insert into t1 select A.a+10*(B.a+10*C.a),A.a+10*(B.a+10*C.a) from t0 A, t0 B, t0 C; - -create table t2 (a int(11) default null); -insert into t2 values (0),(1); - -create table t3 (a int(11) default null); -insert into t3 values (0),(1); - -create table t4 (a int(11) default null); -insert into t4 values (0),(1); - -create table t5 (a int(11) default null); -insert into t5 values (0),(1),(0),(1); - -# this must not fail assertion ---error 1242 -select * from t2, t3 -where - t2.a < 10 and - t3.a+1 = 2 and - t3.a in (select t1.b from t1 - where t1.a+1=t1.a+1 and - t1.a < (select t4.a+10 - from t4, t5 limit 2)); - -drop table t0, t1, t2, t3, t4, t5; - ---echo # ---echo # BUG#48177 - SELECTs with NOT IN subqueries containing NULL ---echo # values return too many records ---echo # - -CREATE TABLE t1 ( - i1 int DEFAULT NULL, - i2 int DEFAULT NULL -) ; - -INSERT INTO t1 VALUES (1, NULL); -INSERT INTO t1 VALUES (2, 3); -INSERT INTO t1 VALUES (4, NULL); -INSERT INTO t1 VALUES (4, 0); -INSERT INTO t1 VALUES (NULL, NULL); - -CREATE TABLE t2 ( - i1 int DEFAULT NULL, - i2 int DEFAULT NULL -) ; - -INSERT INTO t2 VALUES (4, NULL); -INSERT INTO t2 VALUES (5, 0); - ---echo ---echo Data in t1 -SELECT i1, i2 FROM t1; - ---echo ---echo Data in subquery (should be filtered out) -SELECT i1, i2 FROM t2 ORDER BY i1; - -FLUSH STATUS; -set @save_optimizer_switch2=@@optimizer_switch; -set optimizer_switch='subquery_cache=off'; - ---echo -SELECT i1, i2 -FROM t1 -WHERE (i1, i2) - NOT IN (SELECT i1, i2 FROM t2); - ---echo ---echo # Check that the subquery only has to be evaluated once ---echo # for all-NULL values even though there are two (NULL,NULL) records ---echo # Baseline: -SHOW STATUS LIKE '%Handler_read_rnd_next'; - ---echo -INSERT INTO t1 VALUES (NULL, NULL); -FLUSH STATUS; - ---echo -SELECT i1, i2 -FROM t1 -WHERE (i1, i2) - NOT IN (SELECT i1, i2 FROM t2); - ---echo ---echo # Handler_read_rnd_next should be one more than baseline ---echo # (read record from t1, but do not read from t2) -SHOW STATUS LIKE '%Handler_read_rnd_next'; - -set @@optimizer_switch=@save_optimizer_switch2; -DROP TABLE t1,t2; - ---echo End of 5.1 tests - -# -# Test for the problem with using sj-materialization when subquery's select -# list element SCOL is covered by equality propagation and has preceding equal -# column PCOL which belongs to a table within the the semi-join nest: SJM-Scan -# process should unpack column value not to SCOL but rather to PCOL, as -# substitute_best_equal has made all conditions to refer to PCOL. -# -CREATE TABLE t1 ( - a int(11) NOT NULL, - b int(11) NOT NULL, - c datetime default NULL, - PRIMARY KEY (a), - KEY idx_bc (b,c) -); - -INSERT INTO t1 VALUES -(406989,67,'2006-02-23 17:08:46'), (150078,67,'2005-10-26 11:17:45'), -(406993,67,'2006-02-27 11:20:57'), (245655,67,'2005-12-08 15:59:08'), -(406994,67,'2006-02-27 11:26:46'), (256,67,NULL), -(398341,67,'2006-02-20 04:48:44'), (254,67,NULL),(1120,67,NULL), -(406988,67,'2006-02-23 17:07:22'), (255,67,NULL), -(398340,67,'2006-02-20 04:38:53'),(406631,67,'2006-02-23 10:49:42'), -(245653,67,'2005-12-08 15:59:07'),(406992,67,'2006-02-24 16:47:18'), -(245654,67,'2005-12-08 15:59:08'),(406995,67,'2006-02-28 11:55:00'), -(127261,67,'2005-10-13 12:17:58'),(406991,67,'2006-02-24 16:42:32'), -(245652,67,'2005-12-08 15:58:27'),(398545,67,'2006-02-20 04:53:13'), -(154504,67,'2005-10-28 11:53:01'),(9199,67,NULL),(1,67,'2006-02-23 15:01:35'), -(223456,67,NULL),(4101,67,NULL),(1133,67,NULL), -(406990,67,'2006-02-23 18:01:45'),(148815,67,'2005-10-25 15:34:17'), -(148812,67,'2005-10-25 15:30:01'),(245651,67,'2005-12-08 15:58:27'), -(154503,67,'2005-10-28 11:52:38'); - -create table t11 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 asc; -create table t12 select * from t1 where b = 67 AND (c IS NULL OR c > NOW()) order by 3 desc; -create table t21 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 asc; -create table t22 select * from t1 where b = 67 AND (c IS NULL OR c > '2005-12-08') order by 3 desc; - -set @@optimizer_switch=@save_optimizer_switch; -set @@optimizer_switch='materialization=off'; - -update t22 set c = '2005-12-08 15:58:27' where a = 255; -explain select t21.* from t21,t22 where t21.a = t22.a and -t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; -select t21.* from t21,t22 where t21.a = t22.a and -t22.a in (select t12.a from t11, t12 where t11.a in(255,256) and t11.a = t12.a and t11.c is null) and t22.c is null order by t21.a; - -set @@optimizer_switch=@save_optimizer_switch; - -drop table t1, t11, t12, t21, t22; - -# -# Test sj-materialization re-execution. The test isn't meaningful (materialized -# table stays the same across all executions) because it's hard to create a -# dataset that would verify correct re-execution without hitting BUG#31480 -# -create table t1(a int); -insert into t1 values (0),(1); - -set @@optimizer_switch='firstmatch=off,materialization=off'; -explain -select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X; -select (select max(Y.a) from t1 Y where a in (select a from t1 Z) and a < X.a) as subq from t1 X; -set @@optimizer_switch=@save_optimizer_switch; - -drop table t1; - -# -# Test confluent duplicate weedout -# -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table t1 as select * from t0; -insert into t1 select a+10 from t0; -set @@optimizer_switch='firstmatch=off,materialization=off'; -insert into t0 values(2); -explain select * from t1 where 2 in (select a from t0); -select * from t1 where 2 in (select a from t0); -set @@optimizer_switch=@save_optimizer_switch; -set @@optimizer_switch='materialization=off'; -explain select * from t1 where 2 in (select a from t0); -select * from t1 where 2 in (select a from t0); -set @@optimizer_switch=@save_optimizer_switch; - - -set @@optimizer_switch=@save_optimizer_switch; -set @@optimizer_switch='materialization=off'; - -# -# FirstMatch referring to a derived table -# -set @tmp_optimizer_switch=@@optimizer_switch; -set optimizer_switch='derived_merge=off,derived_with_keys=off'; -explain select * from (select a from t0) X where a in (select a from t1); -drop table t0, t1; -set optimizer_switch=@tmp_optimizer_switch; - -# -# LooseScan: Check if we can pick it together with range access -# -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); - -create table t1 (kp1 int, kp2 int, c int, filler char(100), key(kp1, kp2)); -insert into t1 select A.a+10*(B.a+10*C.a), 0, 0, 'filler' from t0 A, t0 B, t0 C; -insert into t1 select * from t1 where kp1 < 20; - -create table t3 (a int); -insert into t3 select A.a + 10*B.a from t0 A, t0 B; - -explain select * from t3 where a in (select kp1 from t1 where kp1<20); - -create table t4 (pk int primary key); -insert into t4 select a from t3; - -explain select * from t3 where a in (select t1.kp1 from t1,t4 where kp1<20 -and t4.pk=t1.c); - -drop table t1, t3, t4; - -set @@optimizer_switch=@save_optimizer_switch; - -# -# Test if we handle duplicate elimination temptable overflowing to disk -# -create table t1 (a int) as select * from t0 where a < 5; - -set @save_max_heap_table_size=@@max_heap_table_size; -set @@optimizer_switch='firstmatch=off,materialization=off'; -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; -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); -show status like 'Created_tmp_disk_tables'; -set @save_max_heap_table_size=@@max_heap_table_size; -set @@optimizer_switch=@save_optimizer_switch; -drop table t0, t1; - -# -# Materialize + Scan + ref access to the subsequent table based on scanned -# value -# -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table t2(a int); -insert into t2 values (1),(2); -create table t3 ( a int , filler char(100), key(a)); -insert into t3 select A.a + 10*B.a, 'filler' from t0 A, t0 B; -explain select * from t3 where a in (select a from t2) and (a > 5 or a < 10); -select * from t3 where a in (select a from t2); - -drop table t0, t2, t3; - -# -# DATETIME type checks -# -set @@optimizer_switch='firstmatch=off,materialization=off'; -create table t1 (a date); -insert into t1 values ('2008-01-01'),('2008-01-01'),('2008-02-01'),('2008-02-01'); -create table t2 (a int); -insert into t2 values (1),(2); -create table t3 (a char(10)); -insert into t3 select * from t1; -insert into t3 values (1),(2); -explain select * from t2 where a in (select a from t1); -explain select * from t2 where a in (select a from t2); -explain select * from t2 where a in (select a from t3); -explain select * from t1 where a in (select a from t3); -drop table t1, t2, t3; -create table t1 (a decimal); -insert into t1 values (1),(2); -explain select * from t1 where a in (select a from t1); -drop table t1; -set @@optimizer_switch=@save_optimizer_switch; - -set @@optimizer_switch=@save_optimizer_switch; -set @@optimizer_switch='materialization=off'; - -# -# SJ-Materialization-scan for non-first table -# -create table t1 (a int); -insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table t2 as select * from t1; -create table t3 (a int, b int, filler char(100), key(a)); -insert into t3 select A.a + 10*B.a, A.a + 10*B.a, 'filler' from t1 A, t1 B, t1 C; -explain select * from t1, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30) and t1.a =3; - -# -# Verify that straight_join modifier in parent or child prevents flattening -# -explain select straight_join * from t1 A, t1 B where A.a in (select a from t2); -explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B); -explain select * from t2 where a in (select straight_join A.a from t1 A, t1 B); -explain select straight_join * from t2 X, t2 Y -where X.a in (select straight_join A.a from t1 A, t1 B); - -# -# SJ-Materialization scan + first table being system const table -# -create table t0 (a int, b int); -insert into t0 values(1,1); -explain select * from t0, t3 where t3.a in (select a from t2) and (t3.a < 10 or t3.a >30); -create table t4 as select a as x, a as y from t1; -explain select * from t0, t3 where (t3.a, t3.b) in (select x,y from t4) and (t3.a < 10 or t3.a >30); -drop table t0,t1,t2,t3,t4; - -# -# LooseScan with ref access -# -create table t0 (a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table t1 (a int, b int, filler char(100), key(a,b)); -insert into t1 select A.a, B.a, 'filler' from t0 A, t0 B; -create table t2 as select * from t1; - -explain select * from t2 where a in (select b from t1 where a=3); -explain select * from t2 where (b,a) in (select a,b from t1 where a=3); - -drop table t1,t2; - -set @@optimizer_switch=@save_optimizer_switch; - -# -# Multi-column sj-materialization with lookups -# -create table t1 (a int, b int); -insert into t1 select a,a from t0; -create table t2 (a int, b int); -insert into t2 select A.a + 10*B.a, A.a + 10*B.a from t0 A, t0 B; - -set @@optimizer_switch='firstmatch=off,materialization=off'; -explain select * from t1 where (a,b) in (select a,b from t2); - -# A smallish test if find_best() still works for semi-join optimization: -set @save_optimizer_search_depth=@@optimizer_search_depth; -set @@optimizer_search_depth=63; -explain select * from t1 where (a,b) in (select a,b from t2); -set @@optimizer_search_depth=@save_optimizer_search_depth; -set @@optimizer_switch=@save_optimizer_switch; - -drop table t0, t1, t2; - -set @@optimizer_switch='materialization=off'; - -# -# Primitive SJ-Materialization tests for DECIMAL and DATE -# -create table t0 (a decimal(4,2)); -insert into t0 values (10.24), (22.11); -create table t1 as select * from t0; -insert into t1 select * from t0; -explain select * from t0 where a in (select a from t1); -select * from t0 where a in (select a from t1); -drop table t0, t1; - -create table t0(a date); -insert into t0 values ('2008-01-01'),('2008-02-02'); -create table t1 as select * from t0; -insert into t1 select * from t0; -explain select * from t0 where a in (select a from t1); -select * from t0 where a in (select a from t1); -drop table t0, t1; - -# -# Fix a trivial crash with SJ-Materialization lookup, multiple tables in the -# subquery, and a condition on some of inner tables but not others -# -create table t0(a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table t1 as select a as a, a as b, a as c from t0 where a < 3; -create table t2 as select a as a, a as b from t0 where a < 3; -insert into t2 select * from t2; - -explain select * from t1 where (a,b,c) in (select X.a, Y.a, Z.a from t2 X, t2 Y, t2 Z where X.b=33); - -drop table t0,t1,t2; - -set @@optimizer_switch=@save_optimizer_switch; - ---echo ---echo BUG#37842: Assertion in DsMrr_impl::dsmrr_init, at handler.cc:4307 ---echo -CREATE TABLE t1 ( - `pk` int(11) NOT NULL AUTO_INCREMENT, - `int_key` int(11) DEFAULT NULL, - PRIMARY KEY (`pk`), - KEY `int_key` (`int_key`) -) ENGINE=MyISAM; -INSERT INTO t1 VALUES (1,9),(2,3),(3,8),(4,6),(5,9),(6,5),(7,5),(8,9),(9,1),(10,10); -SELECT `pk` FROM t1 AS OUTR WHERE `int_key` = ALL ( - SELECT `int_key` FROM t1 AS INNR WHERE INNR . `pk` >= 9 -); -DROP TABLE t1; - ---echo ---echo BUG#40118 Crash when running Batched Key Access and requiring one match for each key ---echo -create table t0(a int); -insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table t1 (a int, key(a)); -insert into t1 select * from t0; -alter table t1 add b int not null, add filler char(200); -insert into t1 select * from t1; -insert into t1 select * from t1; - -set @save_join_cache_level=@@join_cache_level; -set join_cache_level=6; -select * from t0 where t0.a in (select t1.a from t1 where t1.b=0); -set join_cache_level=@save_join_cache_level; -drop table t0, t1; - ---echo # ---echo # BUG#32665 Query with dependent subquery is too slow ---echo # -create table t1 ( - idIndividual int primary key -); -insert into t1 values (1),(2); - -create table t2 ( - idContact int primary key, - contactType int, - idObj int -); -insert into t2 values (1,1,1),(2,2,2),(3,3,3); - -create table t3 ( - idAddress int primary key, - idContact int, - postalStripped varchar(100) -); - -insert into t3 values (1,1, 'foo'), (2,2,'bar'); - ---echo The following must be converted to a semi-join: -set @save_optimizer_switch=@@optimizer_switch; -set @@optimizer_switch='materialization=off'; -explain extended SELECT a.idIndividual FROM t1 a -WHERE a.idIndividual IN - ( SELECT c.idObj FROM t3 cona - INNER JOIN t2 c ON c.idContact=cona.idContact - WHERE cona.postalStripped='T2H3B2' - ); -set @@optimizer_switch=@save_optimizer_switch; -drop table t1,t2,t3; - ---echo # ---echo # BUG#47367 Crash in Name_resolution_context::process_error ---echo # - -SET SESSION optimizer_switch = 'semijoin=off'; -CREATE TABLE t1 (f1 INTEGER); -CREATE TABLE t2 LIKE t1; -delimiter |; -CREATE PROCEDURE p1 () BEGIN SELECT f1 FROM t1 WHERE f1 IN (SELECT f1 FROM t2); END| -delimiter ;| -CALL p1; -ALTER TABLE t2 CHANGE COLUMN f1 my_column INT; -CALL p1; -DROP PROCEDURE p1; ---echo # Restore the original column list of table t2: -ALTER TABLE t2 CHANGE COLUMN my_column f1 INT; - -SET SESSION optimizer_switch = 'semijoin=on'; -delimiter |; ---echo # Recreate procedure so that we eliminate any caching effects -CREATE PROCEDURE p1 () BEGIN SELECT f1 FROM t1 WHERE f1 IN (SELECT f1 FROM t2); END| -delimiter ;| -CALL p1; -ALTER TABLE t2 CHANGE COLUMN f1 my_column INT; ---error ER_BAD_FIELD_ERROR -CALL p1; -DROP PROCEDURE p1; -DROP TABLE t1, t2; - ---echo # ---echo # fix of lp:824425 (prohibiting subqueries in row in ---echo # left part of IN/ALL/ANY) ---echo # - -CREATE TABLE t1 ( a int) ; -INSERT INTO t1 VALUES (20),(30); - -CREATE TABLE t2 (a int) ; -INSERT INTO t2 VALUES (3),(9); - -CREATE TABLE t3 ( a int, b int) ; -INSERT INTO t3 VALUES (20,5),(30,6); - -set @optimizer_switch_save=@@optimizer_switch; -SET SESSION optimizer_switch='semijoin=OFF,in_to_exists=OFF,materialization=ON,partial_match_rowid_merge=ON,partial_match_table_scan=OFF'; - -SELECT * FROM t1 -WHERE ( - ( SELECT a FROM t2 WHERE a = 9 ) -) NOT IN ( - SELECT b - FROM t3 -); -explain extended -SELECT * FROM t1 -WHERE ( - ( SELECT a FROM t2 WHERE a = 9 ) -) NOT IN ( - SELECT b - FROM t3 -); - ---error ER_NOT_SUPPORTED_YET -SELECT * FROM t1 -WHERE ( - ( SELECT a FROM t2 WHERE a = 9 ), - ( SELECT a FROM t2 WHERE a = 3 ) -) NOT IN ( - SELECT b , a - FROM t3 -); -set optimizer_switch=@optimizer_switch_save; - -drop table t1,t2,t3; - ---echo End of 5.3 tests - ---echo # ---echo # BUG#48920: COUNT DISTINCT returns 1 for NULL values when in a subquery ---echo # in the select list ---echo # - ---echo -CREATE TABLE t1 ( - i int(11) DEFAULT NULL, - v varchar(1) DEFAULT NULL -); - ---echo -INSERT INTO t1 VALUES (8,'v'); -INSERT INTO t1 VALUES (9,'r'); -INSERT INTO t1 VALUES (NULL,'y'); - ---echo -CREATE TABLE t2 ( - i int(11) DEFAULT NULL, - v varchar(1) DEFAULT NULL, - KEY i_key (i) -); - ---echo -INSERT INTO t2 VALUES (NULL,'r'); -INSERT INTO t2 VALUES (0,'c'); -INSERT INTO t2 VALUES (0,'o'); -INSERT INTO t2 VALUES (2,'v'); -INSERT INTO t2 VALUES (7,'c'); - ---echo -SELECT i, v, (SELECT COUNT(DISTINCT i) - FROM t1 - WHERE v = t2.v) as subsel -FROM t2; - ---echo -EXPLAIN EXTENDED -SELECT i, v, (SELECT COUNT(DISTINCT i) - FROM t1 - WHERE v = t2.v) as subsel -FROM t2; - -DROP TABLE t1,t2; - ---echo End of 5.6 tests - -# The following command must be the last one in the file -set @@optimizer_switch=@subselect3_tmp; +--echo # end of 10.2 test diff --git a/mysql-test/main/subselect3_jcl6.result b/mysql-test/main/subselect3_jcl6.result index 69f720a95b7..4260676cc37 100644 --- a/mysql-test/main/subselect3_jcl6.result +++ b/mysql-test/main/subselect3_jcl6.result @@ -1,17 +1,10 @@ -set @save_optimizer_switch=@@optimizer_switch; set @@optimizer_switch='optimize_join_buffer_size=on'; set @@optimizer_switch='semijoin_with_cache=on'; set @@optimizer_switch='outer_join_with_cache=on'; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; set join_cache_level=6; -show variables like 'join_cache_level'; -Variable_name Value -join_cache_level 6 -set @join_cache_level_for_subselect3_test=@@join_cache_level; drop table if exists t0, t1, t2, t3, t4, t5, t11, t12, t21, t22; -set @subselect3_tmp= @@optimizer_switch; set optimizer_switch='semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'; -set join_cache_level=@join_cache_level_for_subselect3_test; create table t1 (oref int, grp int, ie int) ; insert into t1 (oref, grp, ie) values (1, 1, 1), @@ -1554,10 +1547,4 @@ Note 1276 Field or reference 'test.t2.v' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select `test`.`t2`.`i` AS `i`,`test`.`t2`.`v` AS `v`,<expr_cache><`test`.`t2`.`v`>((/* select#2 */ select count(distinct `test`.`t1`.`i`) from `test`.`t1` where `test`.`t1`.`v` = `test`.`t2`.`v`)) AS `subsel` from `test`.`t2` DROP TABLE t1,t2; End of 5.6 tests -set @@optimizer_switch=@subselect3_tmp; -set join_cache_level=default; -show variables like 'join_cache_level'; -Variable_name Value -join_cache_level 2 -set @@optimizer_switch=@save_optimizer_switch; -set @join_cache_level_for_subselect3_test=NULL; +# end of 10.2 test diff --git a/mysql-test/main/subselect3_jcl6.test b/mysql-test/main/subselect3_jcl6.test index 6cbbf10cc2f..e367866733d 100644 --- a/mysql-test/main/subselect3_jcl6.test +++ b/mysql-test/main/subselect3_jcl6.test @@ -2,21 +2,14 @@ # Run subselect3.test with BKA enabled # -set @save_optimizer_switch=@@optimizer_switch; +--source include/default_optimizer_switch.inc + set @@optimizer_switch='optimize_join_buffer_size=on'; set @@optimizer_switch='semijoin_with_cache=on'; set @@optimizer_switch='outer_join_with_cache=on'; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; - set join_cache_level=6; -show variables like 'join_cache_level'; - -set @join_cache_level_for_subselect3_test=@@join_cache_level; - ---source subselect3.test -set join_cache_level=default; -show variables like 'join_cache_level'; +--source subselect3.inc -set @@optimizer_switch=@save_optimizer_switch; -set @join_cache_level_for_subselect3_test=NULL; +--echo # end of 10.2 test diff --git a/mysql-test/main/subselect4.test b/mysql-test/main/subselect4.test index d5a40419185..5012e9eb4d8 100644 --- a/mysql-test/main/subselect4.test +++ b/mysql-test/main/subselect4.test @@ -1,5 +1,7 @@ # General purpose bug fix tests go here : subselect.test too large +--source include/default_optimizer_switch.inc + --disable_warnings drop table if exists t0,t1,t2,t3,t4,t5,t6; drop view if exists v1, v2; diff --git a/mysql-test/main/subselect_exists2in.test b/mysql-test/main/subselect_exists2in.test index 5a8ddb3612f..1354953e972 100644 --- a/mysql-test/main/subselect_exists2in.test +++ b/mysql-test/main/subselect_exists2in.test @@ -1,3 +1,4 @@ +--source include/default_optimizer_switch.inc --disable_warnings drop table if exists t1,t2,t3; diff --git a/mysql-test/main/subselect_extra.test b/mysql-test/main/subselect_extra.test index b76f3f70516..3651aed9aab 100644 --- a/mysql-test/main/subselect_extra.test +++ b/mysql-test/main/subselect_extra.test @@ -6,6 +6,7 @@ # # and get as much subquery testing as possible. # +--source include/default_optimizer_switch.inc --disable_warnings drop table if exists t1,t2,t3,t4; diff --git a/mysql-test/main/subselect_mat.result b/mysql-test/main/subselect_mat.result index d38b40586b0..898b1b69117 100644 --- a/mysql-test/main/subselect_mat.result +++ b/mysql-test/main/subselect_mat.result @@ -1,5 +1,4 @@ set @subselect_mat_test_optimizer_switch_value='materialization=on,in_to_exists=off,semijoin=off'; -set @subselect_sj_mat_tmp= @@optimizer_switch; set optimizer_switch=ifnull(@subselect_mat_test_optimizer_switch_value, 'semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'); set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; set @optimizer_switch_local_default= @@optimizer_switch; @@ -185,7 +184,7 @@ a1 a2 1 - 02 2 - 02 select * from t1 where (a1, a2) in (select b1, min(b2) from t2i limit 1,1); ERROR 42000: This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; set @@optimizer_switch='semijoin=off'; prepare st1 from @@ -218,7 +217,7 @@ execute st1; a1 a2 1 - 01 2 - 01 1 - 02 2 - 02 -set @@optimizer_switch=@save_optimizer_switch; +set @@optimizer_switch=@local_optimizer_switch; explain extended select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2); id select_type table type possible_keys key key_len ref rows filtered Extra @@ -1186,7 +1185,7 @@ id select_type table type possible_keys key key_len ref rows Extra select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1); min(a1) NULL -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; set @@optimizer_switch='materialization=off,in_to_exists=on'; explain select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1); @@ -1223,7 +1222,7 @@ id select_type table type possible_keys key key_len ref rows Extra select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4; min(a1) NULL -set @@optimizer_switch= @save_optimizer_switch; +set @@optimizer_switch= @local_optimizer_switch; drop table t1,t2; create table t1 (a char(2), b varchar(10)); insert into t1 values ('a', 'aaa'); @@ -1472,7 +1471,7 @@ INSERT INTO t1 (f1, f2) VALUES (10, 1.668); CREATE TABLE t2 LIKE t1; INSERT INTO t2 VALUES (1, 1.789); INSERT INTO t2 VALUES (13, 1.454); -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; SET @@optimizer_switch='semijoin=on,materialization=on'; EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); @@ -1483,7 +1482,7 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); COUNT(*) 2 -set @@optimizer_switch= @save_optimizer_switch; +set @@optimizer_switch= @local_optimizer_switch; DROP TABLE t1, t2; CREATE TABLE t1 ( pk int, @@ -1496,7 +1495,7 @@ PRIMARY KEY (pk) INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); CREATE TABLE t2 LIKE t1; INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; SET @@optimizer_switch='semijoin=on,materialization=on'; EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); @@ -1511,7 +1510,7 @@ SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); pk 2 DROP TABLE t1, t2; -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@local_optimizer_switch; # # BUG#50019: Wrong result for IN-subquery with materialization # @@ -1527,7 +1526,7 @@ i 2 3 4 -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set session optimizer_switch='materialization=off,in_to_exists=on'; select * from t1 where t1.i in (select t2.i from t2 join t3 where t2.i + t3.i = 5); i @@ -1535,7 +1534,7 @@ i 2 3 4 -set session optimizer_switch=@save_optimizer_switch; +set session optimizer_switch=@local_optimizer_switch; drop table t1, t2, t3; create table t0 (a int); insert into t0 values (0),(1),(2); @@ -1911,7 +1910,7 @@ DROP TABLE t1,t2,t3; # # BUG#939009: Crash with aggregate function in IN subquery # -SET @save_optimizer_switch=@@optimizer_switch; +SET @local_optimizer_switch=@@optimizer_switch; SET optimizer_switch='materialization=on,semijoin=on'; CREATE TABLE t1 (a int, b int); INSERT INTO t1 VALUES (7,1), (4,2), (7,7); @@ -1940,7 +1939,7 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT * FROM t1 WHERE a IN (SELECT MAX(c) FROM t2 WHERE c < 4) AND b=7 AND (a IS NULL OR a=b); a b -SET optimizer_switch=@save_optimizer_switch; +SET optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2; # # BUG#946055: Crash with semijoin IN subquery when hash join is used @@ -1951,8 +1950,7 @@ CREATE TABLE t2 (b int, c int, d varchar(1), e varchar(1), KEY (c), KEY (d, c)); INSERT INTO t2 VALUES (4,2,'v','v'), (6,1,'v','v'), (0,5,'x','x'), (7,1,'x','x'), (7,3,'i','i'), (7,1,'e','e'), (1,4,'p','p'), (1,2,'j','j'); -SET @save_optimizer_switch=@@optimizer_switch; -SET @save_join_cache_level=@@join_cache_level; +SET @local_optimizer_switch=@@optimizer_switch; SET join_cache_level=2; EXPLAIN SELECT a, c FROM t1, t2 @@ -1990,7 +1988,7 @@ a c 7 1 7 1 7 1 -SET optimizer_switch=@save_optimizer_switch; +SET optimizer_switch=@local_optimizer_switch; SET join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; # @@ -2043,21 +2041,21 @@ insert into t2 values (1, 1), (2, 1), (3, 1), (4, 2), (5, 3), (6, 3), (7, 3); delete t2 from t2 where a_id in (select * from (select t1.id from t1 limit 2) as x); drop table t1,t2; # This must be at the end: -set optimizer_switch=@subselect_sj_mat_tmp; +set optimizer_switch=@save_optimizer_switch; set join_cache_level=@save_join_cache_level; # # MDEV-4908: Assertion `((Item_cond *) cond)->functype() == # ((Item_cond *) new_item)->functype()' fails on a query with # IN and equal conditions, AND/OR, materialization+semijoin # -SET @save_optimizer_switch=@@optimizer_switch; +SET @local_optimizer_switch=@@optimizer_switch; SET optimizer_switch = 'materialization=on,semijoin=on'; CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM; INSERT INTO t1 VALUES (1,3,5),(2,4,6); SELECT * FROM t1 WHERE 8 IN ( SELECT MIN(pk) FROM t1 ) AND ( pk = a OR pk = b ); pk a b drop table t1; -SET optimizer_switch=@save_optimizer_switch; +SET optimizer_switch=@local_optimizer_switch; # # MDEV-5011: ERROR Plugin 'MEMORY' has ref_count=1 after shutdown for SJM queries # @@ -2203,7 +2201,7 @@ WHERE EXISTS ( SELECT * FROM t1 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); f2 foo -set @save_optimizer_switch= @@optimizer_switch; +set @local_optimizer_switch= @@optimizer_switch; set optimizer_switch='exists_to_in=off'; EXPLAIN SELECT sq1.f2 FROM t1 AS sq1 @@ -2221,7 +2219,7 @@ WHERE EXISTS ( SELECT * FROM t1 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); f2 foo -set optimizer_switch= @save_optimizer_switch; +set optimizer_switch= @local_optimizer_switch; DROP TABLE t1; # # MDEV-12145: IN subquery used in WHERE of EXISTS subquery @@ -2232,7 +2230,7 @@ CREATE TABLE t2 (i2 INT, KEY(i2)) ENGINE=MyISAM; INSERT INTO t2 VALUES (8),(7),(1); CREATE TABLE t3 (f3 INT, i3 INT, KEY(i3)) ENGINE=MyISAM; INSERT INTO t3 VALUES (8,0),(6,3),(2,8),(3,8),(1,6),(0,0),(1,0),(1,5); -set @save_optimizer_switch= @@optimizer_switch; +set @local_optimizer_switch= @@optimizer_switch; set optimizer_switch='exists_to_in=off'; SELECT * FROM t1 WHERE EXISTS ( SELECT * FROM t2, t3 @@ -2259,7 +2257,7 @@ WHERE EXISTS ( SELECT * FROM t2, t3 WHERE i3 = i2 AND f1 IN ( SELECT f3 FROM t3 ) ); f1 6 -set optimizer_switch= @save_optimizer_switch; +set optimizer_switch= @local_optimizer_switch; DROP TABLE t1,t2,t3; # # MDEV-9686: IN subquery used in WHERE of a subquery from select list @@ -2291,7 +2289,7 @@ Warnings: Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`f1` AS `f1`,<expr_cache><`test`.`t1`.`pk`>((/* select#2 */ select count(0) from `test`.`t2` semi join (`test`.`t2`) where `test`.`t1`.`pk` = `test`.`t2`.`f2`)) AS `sq` from `test`.`t1` # this checks the result set above -set @save_optimizer_switch= @@optimizer_switch; +set @local_optimizer_switch= @@optimizer_switch; set optimizer_switch= 'materialization=off,semijoin=off'; SELECT pk, f1, ( SELECT COUNT(*) FROM t2 WHERE t1.pk IN ( SELECT f2 FROM t2 ) ) AS sq FROM t1; @@ -2301,12 +2299,12 @@ pk f1 sq 3 3 5 4 6 5 5 3 5 -set optimizer_switch= @save_optimizer_switch; +set optimizer_switch= @local_optimizer_switch; DROP TABLE t1,t2; # # mdev-12838: scan of materialized of semi-join subquery in join # -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; CREATE TABLE t1 ( dispatch_group varchar(32), assignment_group varchar(32), @@ -2390,7 +2388,7 @@ ec70316637232000158bbfc8bcbe5d60 7b10fd2637232000158bbfc8bcbe5d30 ebb4620037332000158bbfc8bcbe5d89 DROP TABLE t1,t2,t3; -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@local_optimizer_switch; # # MDEV-16751: Server crashes in st_join_table::cleanup or # TABLE_LIST::is_with_table_recursive_reference with join_cache_level>2 @@ -2453,7 +2451,7 @@ a 4189 8732 5 -set @save_optimizer_switch= @@optimizer_switch; +set @local_optimizer_switch= @@optimizer_switch; SET optimizer_switch='materialization=off'; SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5; @@ -2465,7 +2463,7 @@ WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c a 5 drop procedure prepare_data; -set @@optimizer_switch= @save_optimizer_switch; +set @@optimizer_switch= @local_optimizer_switch; drop table t1,t2,t3; CREATE TABLE t1 ( id int NOT NULL, key(id)); INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19); diff --git a/mysql-test/main/subselect_mat_cost.result b/mysql-test/main/subselect_mat_cost.result index a9f980fff5d..d7b2efd3580 100644 --- a/mysql-test/main/subselect_mat_cost.result +++ b/mysql-test/main/subselect_mat_cost.result @@ -1,4 +1,3 @@ -set @subselect_mat_cost=@@optimizer_switch; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; set long_query_time=0.1; TEST GROUP 1: @@ -562,4 +561,4 @@ TEST GROUP 2: Tests of various combinations of optimizer switches, types of queries, available indexes, column nullability, constness of tables/predicates. ===================================================================== -set optimizer_switch=@subselect_mat_cost; +set optimizer_switch=default; diff --git a/mysql-test/main/subselect_mat_cost.test b/mysql-test/main/subselect_mat_cost.test index 5a1fb550ca4..b183e2496c6 100644 --- a/mysql-test/main/subselect_mat_cost.test +++ b/mysql-test/main/subselect_mat_cost.test @@ -13,7 +13,9 @@ # switches, data distribution, available indexes, and typical queries. # -set @subselect_mat_cost=@@optimizer_switch; +--source include/default_optimizer_switch.inc +--source include/default_charset.inc + set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; # # Test logging to slow log (there was some errors in the log files about @@ -426,4 +428,4 @@ drop database world; # inner subqyery is materialized while the outer subquery is not ( #IN_EXIST transformation is applied to it) -set optimizer_switch=@subselect_mat_cost; +set optimizer_switch=default; diff --git a/mysql-test/main/subselect_mat_cost_bugs.test b/mysql-test/main/subselect_mat_cost_bugs.test index 67af6e3a54a..028cdced560 100644 --- a/mysql-test/main/subselect_mat_cost_bugs.test +++ b/mysql-test/main/subselect_mat_cost_bugs.test @@ -2,6 +2,7 @@ # Test cases for bugs related to the implementation of # MWL#89 cost-based choice between the materialization and in-to-exists # +--source include/default_optimizer_switch.inc --echo # --echo # LP BUG#643424 valgrind warning in choose_subquery_plan() diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result index e5f357efaaa..b9c302abc76 100644 --- a/mysql-test/main/subselect_no_exists_to_in.result +++ b/mysql-test/main/subselect_no_exists_to_in.result @@ -9,7 +9,8 @@ set @subselect_tmp=@@optimizer_switch; set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_test, "semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); set join_cache_level=1; -set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_use_condition_selectivity=1; select (select 2); (select 2) 2 diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result index 9e8ab611993..a97b3555c98 100644 --- a/mysql-test/main/subselect_no_mat.result +++ b/mysql-test/main/subselect_no_mat.result @@ -12,7 +12,8 @@ set @subselect_tmp=@@optimizer_switch; set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_test, "semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); set join_cache_level=@join_cache_level_for_subselect_test; -set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_use_condition_selectivity=1; select (select 2); (select 2) 2 diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result index 3b9df8ab5c4..a80f086555f 100644 --- a/mysql-test/main/subselect_no_opts.result +++ b/mysql-test/main/subselect_no_opts.result @@ -8,7 +8,8 @@ set @subselect_tmp=@@optimizer_switch; set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_test, "semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); set join_cache_level=@join_cache_level_for_subselect_test; -set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_use_condition_selectivity=1; select (select 2); (select 2) 2 diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result index e346332e377..d2a8f8e1713 100644 --- a/mysql-test/main/subselect_no_scache.result +++ b/mysql-test/main/subselect_no_scache.result @@ -11,7 +11,8 @@ set @subselect_tmp=@@optimizer_switch; set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_test, "semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); set join_cache_level=@join_cache_level_for_subselect_test; -set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_use_condition_selectivity=1; select (select 2); (select 2) 2 diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result index edf3afe0a4b..f8e44b4faa8 100644 --- a/mysql-test/main/subselect_no_semijoin.result +++ b/mysql-test/main/subselect_no_semijoin.result @@ -8,7 +8,8 @@ set @subselect_tmp=@@optimizer_switch; set @@optimizer_switch=ifnull(@optimizer_switch_for_subselect_test, "semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on,partial_match_rowid_merge=off,partial_match_table_scan=off"); set join_cache_level=@join_cache_level_for_subselect_test; -set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +SET optimizer_use_condition_selectivity=1; select (select 2); (select 2) 2 diff --git a/mysql-test/main/subselect_sj.result b/mysql-test/main/subselect_sj.result index 246330db7d5..ea0f139ed0c 100644 --- a/mysql-test/main/subselect_sj.result +++ b/mysql-test/main/subselect_sj.result @@ -7,7 +7,7 @@ set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; SET optimizer_switch=ifnull(@optimizer_switch_for_subselect_sj_test,'outer_join_with_cache=off'); SET optimizer_switch=ifnull(@optimizer_switch_for_subselect_sj_test,'semijoin_with_cache=off'); set join_cache_level=1; -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; create table t0 (a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1(a int, b int); @@ -94,6 +94,7 @@ id select_type tABle type possiBle_keys key key_len ref rows filtered ExtrA 2 MATERIALIZED t10 index PRIMARY PRIMARY 4 NULL 10 100.00 Using index Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`A` = `test`.`t1`.`A` And <in_optimizer>(`test`.`t1`.`A`,`test`.`t1`.`A` in ( <mAteriAlize> (/* select#2 */ select `test`.`t10`.`pk` from `test`.`t10` ), <primAry_index_lookup>(`test`.`t1`.`A` in <temporAry tABle> on distinct_key where `test`.`t1`.`A` = `<suBquery2>`.`pk`)))) where 1 +set @save_join_buffer_size=@@join_buffer_size; set join_buffer_size=8*1024; we shouldn't flatten if we're going to get a join of > MAX_TABLES. explain select * from @@ -186,7 +187,7 @@ a b a b 0 0 0 0 1 1 1 1 2 2 2 2 -set join_buffer_size=default; +set join_buffer_size=@save_join_buffer_size; prepare s1 from ' select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) @@ -333,7 +334,7 @@ INSERT INTO WORKS VALUES ('E3','P2',20); INSERT INTO WORKS VALUES ('E4','P2',20); INSERT INTO WORKS VALUES ('E4','P4',40); INSERT INTO WORKS VALUES ('E4','P5',80); -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@local_optimizer_switch; set optimizer_switch='materialization=off'; explain SELECT EMPNUM, EMPNAME FROM STAFF @@ -356,7 +357,7 @@ E1 Alice E2 Betty E3 Carmen E4 Don -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@local_optimizer_switch; drop table STAFF,WORKS,PROJ; # End of bug#45191 # @@ -444,7 +445,7 @@ COUNT(*) drop table t1, t2; drop view v1; drop procedure p1; -set SESSION optimizer_switch=@save_optimizer_switch; +set SESSION optimizer_switch=@local_optimizer_switch; # End of bug#46744 Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order @@ -595,7 +596,7 @@ v1field DROP TABLE t1,t2; DROP VIEW v1,v2; DROP PROCEDURE p1; -set SESSION optimizer_switch=@save_optimizer_switch; +set SESSION optimizer_switch=@local_optimizer_switch; # End of BUG#48834 Bug#49097 subquery with view generates wrong result with @@ -1076,7 +1077,7 @@ DROP TABLE t3; # LPBUG#602574: RQG: sql_select.cc:5385: bool greedy_search(JOIN*, table_map, uint, # uint): Assertion `join->best_read < # -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimizer_switch=@@optimizer_switch; set optimizer_switch='materialization=off'; CREATE TABLE t1 ( varchar_key varchar(1) DEFAULT NULL, @@ -1110,7 +1111,7 @@ FROM t1 RIGHT JOIN t2 ON t1.varchar_key ) ); varchar_key -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimizer_switch; DROP TABLE t1, t2, t3; # # Bug#46692 "Crash occurring on queries with nested FROM subqueries @@ -1236,9 +1237,11 @@ DROP TABLE t1, t2, t3; # # BUG#53060: LooseScan semijoin strategy does not return all rows # -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimizer_switch=@@optimizer_switch; set optimizer_switch='semijoin=on,materialization=off'; set optimizer_switch='firstmatch=off,loosescan=on'; +set @tmp_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity; +set optimizer_use_condition_selectivity=1; CREATE TABLE t1 (i INTEGER); INSERT INTO t1 VALUES (1), (2), (3), (4), (5); CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); @@ -1253,7 +1256,8 @@ i 1 2 DROP TABLE t1, t2; -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimizer_switch; +set @@optimizer_use_condition_selectivity=@tmp_optimizer_use_condition_selectivity; # # BUG#49453: re-execution of prepared statement with view # and semijoin crashes @@ -1296,7 +1300,7 @@ create table t3 (a int); insert into t1 values(1),(1); insert into t2 values(1),(1),(1),(1); insert into t3 values(2),(2); -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimizer_switch=@@optimizer_switch; set optimizer_switch='materialization=off'; set optimizer_switch='semijoin=off'; explain @@ -1320,7 +1324,7 @@ select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); a 1 1 -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimizer_switch; drop table t1,t2,t3; # # Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) @@ -1331,7 +1335,7 @@ CREATE TABLE t3 (a INT); INSERT INTO t1 VALUES(1),(1); INSERT INTO t2 VALUES(1),(1); INSERT INTO t3 VALUES(2),(2); -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimzer_switch=@@optimizer_switch; set optimizer_switch='semijoin=off,materialization=off'; EXPLAIN SELECT * FROM t1 @@ -1380,7 +1384,7 @@ FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); a 1 1 -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimzer_switch; DROP TABLE t1,t2,t3; # # BUG#52329 - Wrong result: subquery materialization, IN, @@ -1398,7 +1402,7 @@ INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), ('1 - 13', '2 - 23'); INSERT INTO t2b SELECT * FROM t2a; INSERT INTO t2c SELECT * FROM t2a; -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimzer_switch=@@optimizer_switch; set optimizer_switch='semijoin=off,materialization=on'; SELECT * FROM t1 WHERE (a1, a2) IN ( @@ -1420,7 +1424,7 @@ WHERE (a1, a2) IN ( SELECT b1, b2 FROM t2c WHERE b1 > '0'); a1 a2 1 - 12 2 - 22 -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimzer_switch; DROP TABLE t1,t2a,t2b,t2c; # # Bug#57623: subquery within before insert trigger causes crash (sj=on) @@ -1433,7 +1437,7 @@ INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); INSERT INTO ot2 VALUES(0),(2),(4),(6); INSERT INTO ot3 VALUES(0),(3),(6); INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimzer_switch=@@optimizer_switch; set optimizer_switch='semijoin=on'; set optimizer_switch='materialization=off'; explain SELECT * @@ -1537,7 +1541,7 @@ a a a 6 6 6 7 NULL NULL deallocate prepare s; -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimzer_switch; DROP TABLE ot1, ot2, ot3, it1; # # Bug#59919/11766739: Crash in tmp_table_param::init() with semijoin=on @@ -1550,7 +1554,7 @@ INSERT INTO t2 VALUES (1,1), (2,1); INSERT INTO t3 VALUES (1,1), (2,1), (5,4), (7,3), (8,2), (8,1), (7,3), (9,5), (4,3), (7,2), (7,7), (3,1), (5,8), (9,7); -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimzer_switch=@@optimizer_switch; set optimizer_switch='semijoin=off,materialization=on'; EXPLAIN SELECT * FROM t3 @@ -1588,7 +1592,7 @@ f1 f2 2 1 8 1 3 1 -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimzer_switch; DROP TABLE t1, t2, t3 ; # # @@ -3038,7 +3042,7 @@ DROP TABLE t1,t2,t3; SET @tmp_mdev5059=@@join_cache_level; SET join_cache_level = 3; set @tmp_os_mdev5059= @@optimizer_switch; -set optimizer_switch=default; +set optimizer_switch=@local_optimizer_switch; CREATE TABLE t1 (pk1 INT PRIMARY KEY, i1 INT) ENGINE=MyISAM; INSERT INTO t1 VALUES (1,4),(2,5); CREATE TABLE t2 (i2 INT, c2 CHAR(1)) ENGINE=MyISAM; diff --git a/mysql-test/main/subselect_sj.test b/mysql-test/main/subselect_sj.test index cade91c6f44..37cb54af786 100644 --- a/mysql-test/main/subselect_sj.test +++ b/mysql-test/main/subselect_sj.test @@ -22,7 +22,7 @@ if (`select @join_cache_level_for_subselect_sj_test is not null`) } # The 'default' value within the scope of this test: -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; # # 1. Subqueries that are converted into semi-joins @@ -79,6 +79,7 @@ select * from t1 left join (t2 A, t2 B) on ( A.a= t1.a and B.a in (select pk fro explain extended select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)); +set @save_join_buffer_size=@@join_buffer_size; set join_buffer_size=8*1024; --echo we shouldn't flatten if we're going to get a join of > MAX_TABLES. @@ -99,7 +100,7 @@ select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) where t1.a < 5; -set join_buffer_size=default; +set join_buffer_size=@save_join_buffer_size; # # Prepared statements @@ -247,7 +248,7 @@ INSERT INTO WORKS VALUES ('E4','P2',20); INSERT INTO WORKS VALUES ('E4','P4',40); INSERT INTO WORKS VALUES ('E4','P5',80); -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@local_optimizer_switch; set optimizer_switch='materialization=off'; explain SELECT EMPNUM, EMPNAME @@ -264,7 +265,7 @@ WHERE EMPNUM IN WHERE PNUM IN (SELECT PNUM FROM PROJ)); -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@local_optimizer_switch; drop table STAFF,WORKS,PROJ; @@ -383,7 +384,7 @@ drop table t1, t2; drop view v1; drop procedure p1; -set SESSION optimizer_switch=@save_optimizer_switch; +set SESSION optimizer_switch=@local_optimizer_switch; --echo # End of bug#46744 @@ -550,7 +551,7 @@ DROP TABLE t1,t2; DROP VIEW v1,v2; DROP PROCEDURE p1; -set SESSION optimizer_switch=@save_optimizer_switch; +set SESSION optimizer_switch=@local_optimizer_switch; --echo # End of BUG#48834 @@ -966,7 +967,7 @@ DROP TABLE t3; --echo # LPBUG#602574: RQG: sql_select.cc:5385: bool greedy_search(JOIN*, table_map, uint, --echo # uint): Assertion `join->best_read < --echo # -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimizer_switch=@@optimizer_switch; set optimizer_switch='materialization=off'; CREATE TABLE t1 ( varchar_key varchar(1) DEFAULT NULL, @@ -1002,7 +1003,7 @@ WHERE (SELECT varchar_key FROM t3 FROM t1 RIGHT JOIN t2 ON t1.varchar_key ) ); -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimizer_switch; DROP TABLE t1, t2, t3; --echo # @@ -1144,9 +1145,11 @@ DROP TABLE t1, t2, t3; --echo # BUG#53060: LooseScan semijoin strategy does not return all rows --echo # -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimizer_switch=@@optimizer_switch; set optimizer_switch='semijoin=on,materialization=off'; set optimizer_switch='firstmatch=off,loosescan=on'; +set @tmp_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity; +set optimizer_use_condition_selectivity=1; CREATE TABLE t1 (i INTEGER); INSERT INTO t1 VALUES (1), (2), (3), (4), (5); @@ -1159,7 +1162,8 @@ SELECT * FROM t1 WHERE (i) IN (SELECT i FROM t2 where j > 0); DROP TABLE t1, t2; -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimizer_switch; +set @@optimizer_use_condition_selectivity=@tmp_optimizer_use_condition_selectivity; --echo # --echo # BUG#49453: re-execution of prepared statement with view @@ -1202,7 +1206,7 @@ insert into t1 values(1),(1); insert into t2 values(1),(1),(1),(1); insert into t3 values(2),(2); -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimizer_switch=@@optimizer_switch; set optimizer_switch='materialization=off'; @@ -1216,7 +1220,7 @@ explain select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimizer_switch; drop table t1,t2,t3; @@ -1231,7 +1235,7 @@ INSERT INTO t1 VALUES(1),(1); INSERT INTO t2 VALUES(1),(1); INSERT INTO t3 VALUES(2),(2); -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimzer_switch=@@optimizer_switch; set optimizer_switch='semijoin=off,materialization=off'; EXPLAIN @@ -1260,7 +1264,7 @@ SELECT * FROM t1 WHERE t1.a IN (SELECT t2.a FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimzer_switch; DROP TABLE t1,t2,t3; @@ -1286,7 +1290,7 @@ INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), INSERT INTO t2b SELECT * FROM t2a; INSERT INTO t2c SELECT * FROM t2a; -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimzer_switch=@@optimizer_switch; set optimizer_switch='semijoin=off,materialization=on'; @@ -1308,7 +1312,7 @@ SELECT * FROM t1 WHERE (a1, a2) IN ( SELECT b1, b2 FROM t2c WHERE b1 > '0'); -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimzer_switch; DROP TABLE t1,t2a,t2b,t2c; @@ -1333,7 +1337,7 @@ FROM ot1 (ot2 JOIN ot3 on ot2.a=ot3.a) ON ot1.a=ot2.a AND ot1.a IN (SELECT a from it1); -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimzer_switch=@@optimizer_switch; set optimizer_switch='semijoin=on'; @@ -1353,7 +1357,7 @@ execute s; execute s; deallocate prepare s; -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimzer_switch; DROP TABLE ot1, ot2, ot3, it1; @@ -1371,7 +1375,7 @@ INSERT INTO t3 VALUES (1,1), (2,1), (5,4), (7,3), (8,2), (8,1), (7,3), (9,5), (4,3), (7,2), (7,7), (3,1), (5,8), (9,7); -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimzer_switch=@@optimizer_switch; set optimizer_switch='semijoin=off,materialization=on'; EXPLAIN @@ -1391,7 +1395,7 @@ SELECT * FROM t3 WHERE f2 IN (SELECT t1.f1 FROM t1 LEFT OUTER JOIN (t2 AS b1 JOIN t2 AS b2 ON TRUE) ON TRUE); -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimzer_switch; DROP TABLE t1, t2, t3 ; @@ -2724,7 +2728,7 @@ SET @tmp_mdev5059=@@join_cache_level; # Any value > 2 will do SET join_cache_level = 3; set @tmp_os_mdev5059= @@optimizer_switch; -set optimizer_switch=default; +set optimizer_switch=@local_optimizer_switch; CREATE TABLE t1 (pk1 INT PRIMARY KEY, i1 INT) ENGINE=MyISAM; INSERT INTO t1 VALUES (1,4),(2,5); diff --git a/mysql-test/main/subselect_sj2.result b/mysql-test/main/subselect_sj2.result index b5070d55b69..ea74a8c0b8d 100644 --- a/mysql-test/main/subselect_sj2.result +++ b/mysql-test/main/subselect_sj2.result @@ -619,7 +619,7 @@ set @save_join_buffer_size=@@join_buffer_size; set join_buffer_size=1; select * from t2 where filler1 in ( select a from t1); a b c filler1 -set join_buffer_size=default; +set join_buffer_size=@save_join_buffer_size; drop table t1, t2; create table t1 (a int not null); drop procedure if exists p1; diff --git a/mysql-test/main/subselect_sj2.test b/mysql-test/main/subselect_sj2.test index a948b086a85..f63de3cd35a 100644 --- a/mysql-test/main/subselect_sj2.test +++ b/mysql-test/main/subselect_sj2.test @@ -794,9 +794,9 @@ set join_buffer_size=1; --enable_warnings select * from t2 where filler1 in ( select a from t1); -set join_buffer_size=default; +set join_buffer_size=@save_join_buffer_size; -drop table t1, t2; +drop table t1, t2; # # BUG#33509: Server crashes with number of recursive subqueries=61 # (the query may or may not fail with an error so we're using it with SP diff --git a/mysql-test/main/subselect_sj2_jcl6.result b/mysql-test/main/subselect_sj2_jcl6.result index 23c54ab7734..5974553210c 100644 --- a/mysql-test/main/subselect_sj2_jcl6.result +++ b/mysql-test/main/subselect_sj2_jcl6.result @@ -632,7 +632,7 @@ set @save_join_buffer_size=@@join_buffer_size; set join_buffer_size=1; select * from t2 where filler1 in ( select a from t1); a b c filler1 -set join_buffer_size=default; +set join_buffer_size=@save_join_buffer_size; drop table t1, t2; create table t1 (a int not null); drop procedure if exists p1; @@ -1438,10 +1438,6 @@ v v set optimizer_switch=@tmp_optimizer_switch; set join_cache_level=default; DROP TABLE t1,t2; -set join_cache_level=default; -show variables like 'join_cache_level'; -Variable_name Value -join_cache_level 2 set @@optimizer_switch=@save_optimizer_switch_jcl6; set @optimizer_switch_for_subselect_sj2_test=NULL; set @join_cache_level_subselect_sj2_test=NULL; diff --git a/mysql-test/main/subselect_sj2_jcl6.test b/mysql-test/main/subselect_sj2_jcl6.test index 7ff08716230..49994988ea2 100644 --- a/mysql-test/main/subselect_sj2_jcl6.test +++ b/mysql-test/main/subselect_sj2_jcl6.test @@ -103,10 +103,6 @@ set join_cache_level=default; DROP TABLE t1,t2; - -set join_cache_level=default; -show variables like 'join_cache_level'; - set @@optimizer_switch=@save_optimizer_switch_jcl6; set @optimizer_switch_for_subselect_sj2_test=NULL; set @join_cache_level_subselect_sj2_test=NULL; diff --git a/mysql-test/main/subselect_sj2_mat.result b/mysql-test/main/subselect_sj2_mat.result index a0a2cc1cf07..dd9f560aeed 100644 --- a/mysql-test/main/subselect_sj2_mat.result +++ b/mysql-test/main/subselect_sj2_mat.result @@ -621,7 +621,7 @@ set @save_join_buffer_size=@@join_buffer_size; set join_buffer_size=1; select * from t2 where filler1 in ( select a from t1); a b c filler1 -set join_buffer_size=default; +set join_buffer_size=@save_join_buffer_size; drop table t1, t2; create table t1 (a int not null); drop procedure if exists p1; diff --git a/mysql-test/main/subselect_sj2_mat.test b/mysql-test/main/subselect_sj2_mat.test index 6ae687aa99a..d8e515aa993 100644 --- a/mysql-test/main/subselect_sj2_mat.test +++ b/mysql-test/main/subselect_sj2_mat.test @@ -1,6 +1,8 @@ # # Run subselect_sj2.test with subquery materialization. # +--source include/default_optimizer_switch.inc + set optimizer_switch='materialization=on'; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; diff --git a/mysql-test/main/subselect_sj_jcl6.result b/mysql-test/main/subselect_sj_jcl6.result index 91079aacb3d..207fd80ac6d 100644 --- a/mysql-test/main/subselect_sj_jcl6.result +++ b/mysql-test/main/subselect_sj_jcl6.result @@ -5,10 +5,8 @@ set @@optimizer_switch='semijoin_with_cache=on'; set @@optimizer_switch='outer_join_with_cache=on'; set @@optimizer_switch='join_cache_hashed=off'; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; +set @save_join_cache_level=@@join_cache_level; set join_cache_level=6; -show variables like 'join_cache_level'; -Variable_name Value -join_cache_level 6 set @optimizer_switch_for_subselect_sj_test=@@optimizer_switch; set @join_cache_level_for_subselect_sj_test=@@join_cache_level; drop table if exists t0, t1, t2, t3, t4, t5, t10, t11, t12; @@ -20,7 +18,7 @@ set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; SET optimizer_switch=ifnull(@optimizer_switch_for_subselect_sj_test,'outer_join_with_cache=off'); SET optimizer_switch=ifnull(@optimizer_switch_for_subselect_sj_test,'semijoin_with_cache=off'); set join_cache_level=@join_cache_level_for_subselect_sj_test; -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; create table t0 (a int); insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); create table t1(a int, b int); @@ -107,6 +105,7 @@ id select_type tABle type possiBle_keys key key_len ref rows filtered ExtrA 2 MATERIALIZED t10 index PRIMARY PRIMARY 4 NULL 10 100.00 Using index Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`A` AS `A`,`test`.`t1`.`B` AS `B`,`test`.`t2`.`A` AS `A`,`test`.`t2`.`B` AS `B` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`A` = `test`.`t1`.`A` And <in_optimizer>(`test`.`t1`.`A`,`test`.`t1`.`A` in ( <mAteriAlize> (/* select#2 */ select `test`.`t10`.`pk` from `test`.`t10` ), <primAry_index_lookup>(`test`.`t1`.`A` in <temporAry tABle> on distinct_key where `test`.`t1`.`A` = `<suBquery2>`.`pk`)))) where 1 +set @save_join_buffer_size=@@join_buffer_size; set join_buffer_size=8*1024; we shouldn't flatten if we're going to get a join of > MAX_TABLES. explain select * from @@ -199,7 +198,7 @@ a b a b 0 0 0 0 1 1 1 1 2 2 2 2 -set join_buffer_size=default; +set join_buffer_size=@save_join_buffer_size; prepare s1 from ' select * from t1 left join t2 on (t2.a= t1.a and t2.a in (select pk from t10)) @@ -346,7 +345,7 @@ INSERT INTO WORKS VALUES ('E3','P2',20); INSERT INTO WORKS VALUES ('E4','P2',20); INSERT INTO WORKS VALUES ('E4','P4',40); INSERT INTO WORKS VALUES ('E4','P5',80); -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@local_optimizer_switch; set optimizer_switch='materialization=off'; explain SELECT EMPNUM, EMPNAME FROM STAFF @@ -369,7 +368,7 @@ E1 Alice E2 Betty E3 Carmen E4 Don -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@local_optimizer_switch; drop table STAFF,WORKS,PROJ; # End of bug#45191 # @@ -457,7 +456,7 @@ COUNT(*) drop table t1, t2; drop view v1; drop procedure p1; -set SESSION optimizer_switch=@save_optimizer_switch; +set SESSION optimizer_switch=@local_optimizer_switch; # End of bug#46744 Bug#46797 "Crash in fix_semijoin_strategies_for_picked_join_order @@ -608,7 +607,7 @@ v1field DROP TABLE t1,t2; DROP VIEW v1,v2; DROP PROCEDURE p1; -set SESSION optimizer_switch=@save_optimizer_switch; +set SESSION optimizer_switch=@local_optimizer_switch; # End of BUG#48834 Bug#49097 subquery with view generates wrong result with @@ -1089,7 +1088,7 @@ DROP TABLE t3; # LPBUG#602574: RQG: sql_select.cc:5385: bool greedy_search(JOIN*, table_map, uint, # uint): Assertion `join->best_read < # -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimizer_switch=@@optimizer_switch; set optimizer_switch='materialization=off'; CREATE TABLE t1 ( varchar_key varchar(1) DEFAULT NULL, @@ -1123,7 +1122,7 @@ FROM t1 RIGHT JOIN t2 ON t1.varchar_key ) ); varchar_key -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimizer_switch; DROP TABLE t1, t2, t3; # # Bug#46692 "Crash occurring on queries with nested FROM subqueries @@ -1249,9 +1248,11 @@ DROP TABLE t1, t2, t3; # # BUG#53060: LooseScan semijoin strategy does not return all rows # -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimizer_switch=@@optimizer_switch; set optimizer_switch='semijoin=on,materialization=off'; set optimizer_switch='firstmatch=off,loosescan=on'; +set @tmp_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity; +set optimizer_use_condition_selectivity=1; CREATE TABLE t1 (i INTEGER); INSERT INTO t1 VALUES (1), (2), (3), (4), (5); CREATE TABLE t2 (i INTEGER, j INTEGER, KEY k(i, j)); @@ -1266,7 +1267,8 @@ i 1 2 DROP TABLE t1, t2; -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimizer_switch; +set @@optimizer_use_condition_selectivity=@tmp_optimizer_use_condition_selectivity; # # BUG#49453: re-execution of prepared statement with view # and semijoin crashes @@ -1309,7 +1311,7 @@ create table t3 (a int); insert into t1 values(1),(1); insert into t2 values(1),(1),(1),(1); insert into t3 values(2),(2); -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimizer_switch=@@optimizer_switch; set optimizer_switch='materialization=off'; set optimizer_switch='semijoin=off'; explain @@ -1333,7 +1335,7 @@ select * from t1 where t1.a in (select t2.a from t2 left join t3 on t2.a=t3.a); a 1 1 -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimizer_switch; drop table t1,t2,t3; # # Bug#55955: crash in MEMORY engine with IN(LEFT JOIN (JOIN)) @@ -1344,7 +1346,7 @@ CREATE TABLE t3 (a INT); INSERT INTO t1 VALUES(1),(1); INSERT INTO t2 VALUES(1),(1); INSERT INTO t3 VALUES(2),(2); -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimzer_switch=@@optimizer_switch; set optimizer_switch='semijoin=off,materialization=off'; EXPLAIN SELECT * FROM t1 @@ -1393,7 +1395,7 @@ FROM t2 LEFT JOIN (t2 AS t2inner, t3) ON t2.a=t3.a); a 1 1 -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimzer_switch; DROP TABLE t1,t2,t3; # # BUG#52329 - Wrong result: subquery materialization, IN, @@ -1411,7 +1413,7 @@ INSERT INTO t2a VALUES ('1 - 11', '2 - 21'), ('1 - 13', '2 - 23'); INSERT INTO t2b SELECT * FROM t2a; INSERT INTO t2c SELECT * FROM t2a; -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimzer_switch=@@optimizer_switch; set optimizer_switch='semijoin=off,materialization=on'; SELECT * FROM t1 WHERE (a1, a2) IN ( @@ -1433,7 +1435,7 @@ WHERE (a1, a2) IN ( SELECT b1, b2 FROM t2c WHERE b1 > '0'); a1 a2 1 - 12 2 - 22 -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimzer_switch; DROP TABLE t1,t2a,t2b,t2c; # # Bug#57623: subquery within before insert trigger causes crash (sj=on) @@ -1446,7 +1448,7 @@ INSERT INTO ot1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); INSERT INTO ot2 VALUES(0),(2),(4),(6); INSERT INTO ot3 VALUES(0),(3),(6); INSERT INTO it1 VALUES(0),(1),(2),(3),(4),(5),(6),(7); -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimzer_switch=@@optimizer_switch; set optimizer_switch='semijoin=on'; set optimizer_switch='materialization=off'; explain SELECT * @@ -1550,7 +1552,7 @@ a a a 5 NULL NULL 7 NULL NULL deallocate prepare s; -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimzer_switch; DROP TABLE ot1, ot2, ot3, it1; # # Bug#59919/11766739: Crash in tmp_table_param::init() with semijoin=on @@ -1563,7 +1565,7 @@ INSERT INTO t2 VALUES (1,1), (2,1); INSERT INTO t3 VALUES (1,1), (2,1), (5,4), (7,3), (8,2), (8,1), (7,3), (9,5), (4,3), (7,2), (7,7), (3,1), (5,8), (9,7); -set @save_optimizer_switch=@@optimizer_switch; +set @tmp_optimzer_switch=@@optimizer_switch; set optimizer_switch='semijoin=off,materialization=on'; EXPLAIN SELECT * FROM t3 @@ -1601,7 +1603,7 @@ f1 f2 2 1 8 1 3 1 -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@tmp_optimzer_switch; DROP TABLE t1, t2, t3 ; # # @@ -3051,7 +3053,7 @@ DROP TABLE t1,t2,t3; SET @tmp_mdev5059=@@join_cache_level; SET join_cache_level = 3; set @tmp_os_mdev5059= @@optimizer_switch; -set optimizer_switch=default; +set optimizer_switch=@local_optimizer_switch; CREATE TABLE t1 (pk1 INT PRIMARY KEY, i1 INT) ENGINE=MyISAM; INSERT INTO t1 VALUES (1,4),(2,5); CREATE TABLE t2 (i2 INT, c2 CHAR(1)) ENGINE=MyISAM; @@ -3526,10 +3528,7 @@ set optimizer_switch=@tmp_optimizer_switch; set join_cache_level=@tmp_join_cache_level; DROP TABLE t1,t2; # End -set join_cache_level=default; -show variables like 'join_cache_level'; -Variable_name Value -join_cache_level 2 +set join_cache_level=@save_join_cache_level; set @@optimizer_switch=@save_optimizer_switch_jcl6; set @optimizer_switch_for_subselect_sj_test=NULL; set @join_cache_level_subselect_sj_test=NULL; diff --git a/mysql-test/main/subselect_sj_jcl6.test b/mysql-test/main/subselect_sj_jcl6.test index ad4a78bdaa5..179c1aa029b 100644 --- a/mysql-test/main/subselect_sj_jcl6.test +++ b/mysql-test/main/subselect_sj_jcl6.test @@ -1,6 +1,7 @@ # # Run subselect_sj.test with BKA enabled # +--source include/default_optimizer_switch.inc set @save_optimizer_switch_jcl6=@@optimizer_switch; set @@optimizer_switch='optimize_join_buffer_size=on'; @@ -9,9 +10,8 @@ set @@optimizer_switch='semijoin_with_cache=on'; set @@optimizer_switch='outer_join_with_cache=on'; set @@optimizer_switch='join_cache_hashed=off'; set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; - +set @save_join_cache_level=@@join_cache_level; set join_cache_level=6; -show variables like 'join_cache_level'; set @optimizer_switch_for_subselect_sj_test=@@optimizer_switch; set @join_cache_level_for_subselect_sj_test=@@join_cache_level; @@ -208,9 +208,7 @@ DROP TABLE t1,t2; --echo # End -set join_cache_level=default; -show variables like 'join_cache_level'; - +set join_cache_level=@save_join_cache_level; set @@optimizer_switch=@save_optimizer_switch_jcl6; set @optimizer_switch_for_subselect_sj_test=NULL; set @join_cache_level_subselect_sj_test=NULL; diff --git a/mysql-test/main/subselect_sj_mat.result b/mysql-test/main/subselect_sj_mat.result index b65dbb68437..8486d36c2ae 100644 --- a/mysql-test/main/subselect_sj_mat.result +++ b/mysql-test/main/subselect_sj_mat.result @@ -1,4 +1,3 @@ -set @subselect_sj_mat_tmp= @@optimizer_switch; set optimizer_switch=ifnull(@subselect_mat_test_optimizer_switch_value, 'semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'); set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; set @optimizer_switch_local_default= @@optimizer_switch; @@ -195,7 +194,7 @@ a1 a2 1 - 02 2 - 02 select * from t1 where (a1, a2) in (select b1, min(b2) from t2i limit 1,1); ERROR 42000: This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; set @@optimizer_switch='semijoin=off'; prepare st1 from @@ -228,7 +227,7 @@ execute st1; a1 a2 1 - 01 2 - 01 1 - 02 2 - 02 -set @@optimizer_switch=@save_optimizer_switch; +set @@optimizer_switch=@local_optimizer_switch; explain extended select * from t1 where (a1, a2) in (select b1, b2 from t2 order by b1, b2); id select_type table type possible_keys key key_len ref rows filtered Extra @@ -1221,7 +1220,7 @@ id select_type table type possible_keys key key_len ref rows Extra select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1); min(a1) NULL -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; set @@optimizer_switch='materialization=off,in_to_exists=on'; explain select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1); @@ -1257,7 +1256,7 @@ id select_type table type possible_keys key key_len ref rows Extra select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4; min(a1) NULL -set @@optimizer_switch= @save_optimizer_switch; +set @@optimizer_switch= @local_optimizer_switch; drop table t1,t2; create table t1 (a char(2), b varchar(10)); insert into t1 values ('a', 'aaa'); @@ -1509,7 +1508,7 @@ INSERT INTO t1 (f1, f2) VALUES (10, 1.668); CREATE TABLE t2 LIKE t1; INSERT INTO t2 VALUES (1, 1.789); INSERT INTO t2 VALUES (13, 1.454); -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; SET @@optimizer_switch='semijoin=on,materialization=on'; EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); @@ -1520,7 +1519,7 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); COUNT(*) 2 -set @@optimizer_switch= @save_optimizer_switch; +set @@optimizer_switch= @local_optimizer_switch; DROP TABLE t1, t2; CREATE TABLE t1 ( pk int, @@ -1533,7 +1532,7 @@ PRIMARY KEY (pk) INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); CREATE TABLE t2 LIKE t1; INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; SET @@optimizer_switch='semijoin=on,materialization=on'; EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); @@ -1548,7 +1547,7 @@ SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); pk 2 DROP TABLE t1, t2; -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@local_optimizer_switch; # # BUG#50019: Wrong result for IN-subquery with materialization # @@ -1564,7 +1563,7 @@ i 2 3 4 -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set session optimizer_switch='materialization=off,in_to_exists=on'; select * from t1 where t1.i in (select t2.i from t2 join t3 where t2.i + t3.i = 5); i @@ -1572,7 +1571,7 @@ i 3 2 1 -set session optimizer_switch=@save_optimizer_switch; +set session optimizer_switch=@local_optimizer_switch; drop table t1, t2, t3; create table t0 (a int); insert into t0 values (0),(1),(2); @@ -1949,7 +1948,7 @@ DROP TABLE t1,t2,t3; # # BUG#939009: Crash with aggregate function in IN subquery # -SET @save_optimizer_switch=@@optimizer_switch; +SET @local_optimizer_switch=@@optimizer_switch; SET optimizer_switch='materialization=on,semijoin=on'; CREATE TABLE t1 (a int, b int); INSERT INTO t1 VALUES (7,1), (4,2), (7,7); @@ -1978,7 +1977,7 @@ id select_type table type possible_keys key key_len ref rows Extra SELECT * FROM t1 WHERE a IN (SELECT MAX(c) FROM t2 WHERE c < 4) AND b=7 AND (a IS NULL OR a=b); a b -SET optimizer_switch=@save_optimizer_switch; +SET optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2; # # BUG#946055: Crash with semijoin IN subquery when hash join is used @@ -1989,8 +1988,7 @@ CREATE TABLE t2 (b int, c int, d varchar(1), e varchar(1), KEY (c), KEY (d, c)); INSERT INTO t2 VALUES (4,2,'v','v'), (6,1,'v','v'), (0,5,'x','x'), (7,1,'x','x'), (7,3,'i','i'), (7,1,'e','e'), (1,4,'p','p'), (1,2,'j','j'); -SET @save_optimizer_switch=@@optimizer_switch; -SET @save_join_cache_level=@@join_cache_level; +SET @local_optimizer_switch=@@optimizer_switch; SET join_cache_level=2; EXPLAIN SELECT a, c FROM t1, t2 @@ -2030,7 +2028,7 @@ a c 7 1 7 1 7 1 -SET optimizer_switch=@save_optimizer_switch; +SET optimizer_switch=@local_optimizer_switch; SET join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; # @@ -2083,21 +2081,21 @@ insert into t2 values (1, 1), (2, 1), (3, 1), (4, 2), (5, 3), (6, 3), (7, 3); delete t2 from t2 where a_id in (select * from (select t1.id from t1 limit 2) as x); drop table t1,t2; # This must be at the end: -set optimizer_switch=@subselect_sj_mat_tmp; +set optimizer_switch=@save_optimizer_switch; set join_cache_level=@save_join_cache_level; # # MDEV-4908: Assertion `((Item_cond *) cond)->functype() == # ((Item_cond *) new_item)->functype()' fails on a query with # IN and equal conditions, AND/OR, materialization+semijoin # -SET @save_optimizer_switch=@@optimizer_switch; +SET @local_optimizer_switch=@@optimizer_switch; SET optimizer_switch = 'materialization=on,semijoin=on'; CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM; INSERT INTO t1 VALUES (1,3,5),(2,4,6); SELECT * FROM t1 WHERE 8 IN ( SELECT MIN(pk) FROM t1 ) AND ( pk = a OR pk = b ); pk a b drop table t1; -SET optimizer_switch=@save_optimizer_switch; +SET optimizer_switch=@local_optimizer_switch; # # MDEV-5011: ERROR Plugin 'MEMORY' has ref_count=1 after shutdown for SJM queries # @@ -2243,7 +2241,7 @@ WHERE EXISTS ( SELECT * FROM t1 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); f2 foo -set @save_optimizer_switch= @@optimizer_switch; +set @local_optimizer_switch= @@optimizer_switch; set optimizer_switch='exists_to_in=off'; EXPLAIN SELECT sq1.f2 FROM t1 AS sq1 @@ -2261,7 +2259,7 @@ WHERE EXISTS ( SELECT * FROM t1 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); f2 foo -set optimizer_switch= @save_optimizer_switch; +set optimizer_switch= @local_optimizer_switch; DROP TABLE t1; # # MDEV-12145: IN subquery used in WHERE of EXISTS subquery @@ -2272,7 +2270,7 @@ CREATE TABLE t2 (i2 INT, KEY(i2)) ENGINE=MyISAM; INSERT INTO t2 VALUES (8),(7),(1); CREATE TABLE t3 (f3 INT, i3 INT, KEY(i3)) ENGINE=MyISAM; INSERT INTO t3 VALUES (8,0),(6,3),(2,8),(3,8),(1,6),(0,0),(1,0),(1,5); -set @save_optimizer_switch= @@optimizer_switch; +set @local_optimizer_switch= @@optimizer_switch; set optimizer_switch='exists_to_in=off'; SELECT * FROM t1 WHERE EXISTS ( SELECT * FROM t2, t3 @@ -2299,7 +2297,7 @@ WHERE EXISTS ( SELECT * FROM t2, t3 WHERE i3 = i2 AND f1 IN ( SELECT f3 FROM t3 ) ); f1 6 -set optimizer_switch= @save_optimizer_switch; +set optimizer_switch= @local_optimizer_switch; DROP TABLE t1,t2,t3; # # MDEV-9686: IN subquery used in WHERE of a subquery from select list @@ -2331,7 +2329,7 @@ Warnings: Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1 Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`f1` AS `f1`,<expr_cache><`test`.`t1`.`pk`>((/* select#2 */ select count(0) from `test`.`t2` semi join (`test`.`t2`) where `test`.`t1`.`pk` = `test`.`t2`.`f2`)) AS `sq` from `test`.`t1` # this checks the result set above -set @save_optimizer_switch= @@optimizer_switch; +set @local_optimizer_switch= @@optimizer_switch; set optimizer_switch= 'materialization=off,semijoin=off'; SELECT pk, f1, ( SELECT COUNT(*) FROM t2 WHERE t1.pk IN ( SELECT f2 FROM t2 ) ) AS sq FROM t1; @@ -2341,12 +2339,12 @@ pk f1 sq 3 3 5 4 6 5 5 3 5 -set optimizer_switch= @save_optimizer_switch; +set optimizer_switch= @local_optimizer_switch; DROP TABLE t1,t2; # # mdev-12838: scan of materialized of semi-join subquery in join # -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; CREATE TABLE t1 ( dispatch_group varchar(32), assignment_group varchar(32), @@ -2430,7 +2428,7 @@ ec70316637232000158bbfc8bcbe5d60 7b10fd2637232000158bbfc8bcbe5d30 ebb4620037332000158bbfc8bcbe5d89 DROP TABLE t1,t2,t3; -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@local_optimizer_switch; # # MDEV-16751: Server crashes in st_join_table::cleanup or # TABLE_LIST::is_with_table_recursive_reference with join_cache_level>2 @@ -2493,7 +2491,7 @@ a 4189 8732 5 -set @save_optimizer_switch= @@optimizer_switch; +set @local_optimizer_switch= @@optimizer_switch; SET optimizer_switch='materialization=off'; SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5; @@ -2505,7 +2503,7 @@ WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c a 5 drop procedure prepare_data; -set @@optimizer_switch= @save_optimizer_switch; +set @@optimizer_switch= @local_optimizer_switch; drop table t1,t2,t3; CREATE TABLE t1 ( id int NOT NULL, key(id)); INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19); diff --git a/mysql-test/main/subselect_sj_mat.test b/mysql-test/main/subselect_sj_mat.test index 12c32b53aa6..8583a6951b9 100644 --- a/mysql-test/main/subselect_sj_mat.test +++ b/mysql-test/main/subselect_sj_mat.test @@ -3,7 +3,8 @@ # (WL#1110: Subquery optimization: materialization) # -set @subselect_sj_mat_tmp= @@optimizer_switch; +--source include/default_optimizer_switch.inc + set optimizer_switch=ifnull(@subselect_mat_test_optimizer_switch_value, 'semijoin=on,firstmatch=on,loosescan=on,semijoin_with_cache=on'); set optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; set @optimizer_switch_local_default= @@optimizer_switch; @@ -127,7 +128,7 @@ select * from t1 where (a1, a2) in (select b1, min(b2) from t2i limit 1,1); # test re-optimization/re-execution with different execution methods # prepare once, exec with different modes -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; set @@optimizer_switch='semijoin=off'; prepare st1 from @@ -149,7 +150,7 @@ execute st1; set @@optimizer_switch=@optimizer_switch_local_default; set @@optimizer_switch='materialization=off,in_to_exists=on'; execute st1; -set @@optimizer_switch=@save_optimizer_switch; +set @@optimizer_switch=@local_optimizer_switch; # materialize the result of ORDER BY # non-indexed fields @@ -838,7 +839,7 @@ insert into t1 values (5); explain select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1); select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1); # Query with group by, executed via IN=>EXISTS -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; set @@optimizer_switch='materialization=off,in_to_exists=on'; explain select min(a1) from t1 where 7 in (select max(b1) from t2 group by b1); @@ -860,7 +861,7 @@ select min(a1) from t1 where 7 in (select b1 from t2); -- echo # but when we go around MWL#90 code, the problem still shows up: explain select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4; select min(a1) from t1 where 7 in (select b1 from t2) or 2> 4; -set @@optimizer_switch= @save_optimizer_switch; +set @@optimizer_switch= @local_optimizer_switch; drop table t1,t2; # @@ -1146,12 +1147,12 @@ CREATE TABLE t2 LIKE t1; INSERT INTO t2 VALUES (1, 1.789); INSERT INTO t2 VALUES (13, 1.454); -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; SET @@optimizer_switch='semijoin=on,materialization=on'; EXPLAIN SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); SELECT COUNT(*) FROM t1 WHERE (f1,f2) IN (SELECT f1,f2 FROM t2); -set @@optimizer_switch= @save_optimizer_switch; +set @@optimizer_switch= @local_optimizer_switch; DROP TABLE t1, t2; @@ -1171,14 +1172,14 @@ INSERT INTO t1 VALUES (1,'o','ffff','ffff','ffoo'),(2,'f','ffff','ffff','ffff'); CREATE TABLE t2 LIKE t1; INSERT INTO t2 VALUES (1,'i','iiii','iiii','iiii'),(2,'f','ffff','ffff','ffff'); -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set @@optimizer_switch=@optimizer_switch_local_default; SET @@optimizer_switch='semijoin=on,materialization=on'; EXPLAIN SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); SELECT pk FROM t1 WHERE (a) IN (SELECT a FROM t2 WHERE pk > 0); SELECT pk FROM t1 WHERE (b,c,d) IN (SELECT b,c,d FROM t2 WHERE pk > 0); DROP TABLE t1, t2; -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@local_optimizer_switch; --echo # --echo # BUG#50019: Wrong result for IN-subquery with materialization @@ -1190,10 +1191,10 @@ insert into t2 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); create table t3(i int); insert into t3 values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); select * from t1 where t1.i in (select t2.i from t2 join t3 where t2.i + t3.i = 5); -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; set session optimizer_switch='materialization=off,in_to_exists=on'; select * from t1 where t1.i in (select t2.i from t2 join t3 where t2.i + t3.i = 5); -set session optimizer_switch=@save_optimizer_switch; +set session optimizer_switch=@local_optimizer_switch; drop table t1, t2, t3; # @@ -1579,7 +1580,7 @@ DROP TABLE t1,t2,t3; --echo # BUG#939009: Crash with aggregate function in IN subquery --echo # -SET @save_optimizer_switch=@@optimizer_switch; +SET @local_optimizer_switch=@@optimizer_switch; SET optimizer_switch='materialization=on,semijoin=on'; CREATE TABLE t1 (a int, b int); @@ -1600,7 +1601,7 @@ SELECT * FROM t1 SELECT * FROM t1 WHERE a IN (SELECT MAX(c) FROM t2 WHERE c < 4) AND b=7 AND (a IS NULL OR a=b); -SET optimizer_switch=@save_optimizer_switch; +SET optimizer_switch=@local_optimizer_switch; DROP TABLE t1,t2; @@ -1617,8 +1618,7 @@ INSERT INTO t2 VALUES (4,2,'v','v'), (6,1,'v','v'), (0,5,'x','x'), (7,1,'x','x'), (7,3,'i','i'), (7,1,'e','e'), (1,4,'p','p'), (1,2,'j','j'); -SET @save_optimizer_switch=@@optimizer_switch; -SET @save_join_cache_level=@@join_cache_level; +SET @local_optimizer_switch=@@optimizer_switch; SET join_cache_level=2; EXPLAIN @@ -1639,7 +1639,7 @@ SELECT a, c FROM t1, t2 WHERE (a, c) IN (SELECT s1.b, s1.c FROM t2 AS s1, t2 AS s2 WHERE s2.d = s1.e AND s1.e = (SELECT MAX(e) FROM t2)); -SET optimizer_switch=@save_optimizer_switch; +SET optimizer_switch=@local_optimizer_switch; SET join_cache_level=@save_join_cache_level; DROP TABLE t1,t2; @@ -1699,7 +1699,7 @@ delete t2 from t2 where a_id in (select * from (select t1.id from t1 limit 2) as drop table t1,t2; --echo # This must be at the end: -set optimizer_switch=@subselect_sj_mat_tmp; +set optimizer_switch=@save_optimizer_switch; set join_cache_level=@save_join_cache_level; --echo # @@ -1709,7 +1709,7 @@ set join_cache_level=@save_join_cache_level; --echo # -SET @save_optimizer_switch=@@optimizer_switch; +SET @local_optimizer_switch=@@optimizer_switch; SET optimizer_switch = 'materialization=on,semijoin=on'; CREATE TABLE t1 (pk INT, a INT, b INT, PRIMARY KEY(pk)) ENGINE=MyISAM; @@ -1717,7 +1717,7 @@ INSERT INTO t1 VALUES (1,3,5),(2,4,6); SELECT * FROM t1 WHERE 8 IN ( SELECT MIN(pk) FROM t1 ) AND ( pk = a OR pk = b ); drop table t1; -SET optimizer_switch=@save_optimizer_switch; +SET optimizer_switch=@local_optimizer_switch; --echo # --echo # MDEV-5011: ERROR Plugin 'MEMORY' has ref_count=1 after shutdown for SJM queries @@ -1871,7 +1871,7 @@ SELECT sq1.f2 FROM t1 AS sq1 WHERE EXISTS ( SELECT * FROM t1 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); -set @save_optimizer_switch= @@optimizer_switch; +set @local_optimizer_switch= @@optimizer_switch; set optimizer_switch='exists_to_in=off'; EXPLAIN @@ -1885,7 +1885,7 @@ SELECT sq1.f2 FROM t1 AS sq1 WHERE EXISTS ( SELECT * FROM t1 AS sq2 WHERE sq1.`pk` IN ( SELECT f1 FROM t1 ) AND sq2.f1 = sq1.f1 ); -set optimizer_switch= @save_optimizer_switch; +set optimizer_switch= @local_optimizer_switch; DROP TABLE t1; @@ -1902,7 +1902,7 @@ INSERT INTO t2 VALUES (8),(7),(1); CREATE TABLE t3 (f3 INT, i3 INT, KEY(i3)) ENGINE=MyISAM; INSERT INTO t3 VALUES (8,0),(6,3),(2,8),(3,8),(1,6),(0,0),(1,0),(1,5); -set @save_optimizer_switch= @@optimizer_switch; +set @local_optimizer_switch= @@optimizer_switch; set optimizer_switch='exists_to_in=off'; SELECT * FROM t1 @@ -1919,7 +1919,7 @@ SELECT * FROM t1 WHERE EXISTS ( SELECT * FROM t2, t3 WHERE i3 = i2 AND f1 IN ( SELECT f3 FROM t3 ) ); -set optimizer_switch= @save_optimizer_switch; +set optimizer_switch= @local_optimizer_switch; DROP TABLE t1,t2,t3; @@ -1944,11 +1944,11 @@ SELECT pk, f1, ( SELECT COUNT(*) FROM t2 WHERE t1.pk IN ( SELECT f2 FROM t2 ) ) AS sq FROM t1; --echo # this checks the result set above -set @save_optimizer_switch= @@optimizer_switch; +set @local_optimizer_switch= @@optimizer_switch; set optimizer_switch= 'materialization=off,semijoin=off'; SELECT pk, f1, ( SELECT COUNT(*) FROM t2 WHERE t1.pk IN ( SELECT f2 FROM t2 ) ) AS sq FROM t1; -set optimizer_switch= @save_optimizer_switch; +set optimizer_switch= @local_optimizer_switch; DROP TABLE t1,t2; @@ -1956,7 +1956,7 @@ DROP TABLE t1,t2; --echo # mdev-12838: scan of materialized of semi-join subquery in join --echo # -set @save_optimizer_switch=@@optimizer_switch; +set @local_optimizer_switch=@@optimizer_switch; CREATE TABLE t1 ( dispatch_group varchar(32), @@ -2157,7 +2157,7 @@ eval explain $q; eval $q; DROP TABLE t1,t2,t3; -set optimizer_switch=@save_optimizer_switch; +set optimizer_switch=@local_optimizer_switch; --echo # --echo # MDEV-16751: Server crashes in st_join_table::cleanup or @@ -2214,7 +2214,7 @@ CALL prepare_data(); SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27); -set @save_optimizer_switch= @@optimizer_switch; +set @local_optimizer_switch= @@optimizer_switch; SET optimizer_switch='materialization=off'; SELECT t1.a FROM t1 @@ -2226,7 +2226,7 @@ SELECT t1.a FROM t1 WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5; drop procedure prepare_data; -set @@optimizer_switch= @save_optimizer_switch; +set @@optimizer_switch= @local_optimizer_switch; drop table t1,t2,t3; CREATE TABLE t1 ( id int NOT NULL, key(id)); diff --git a/mysql-test/main/subselect_sj_nonmerged.test b/mysql-test/main/subselect_sj_nonmerged.test index e47e72ffe97..689e922ad24 100644 --- a/mysql-test/main/subselect_sj_nonmerged.test +++ b/mysql-test/main/subselect_sj_nonmerged.test @@ -1,6 +1,8 @@ # # Tests for non-merged semi-joins # +--source include/default_optimizer_switch.inc + --disable_warnings drop table if exists t0, t1, t2, t3, t4; --enable_warnings diff --git a/mysql-test/main/table_options-5867.opt b/mysql-test/main/table_options-5867.opt new file mode 100644 index 00000000000..8374626febe --- /dev/null +++ b/mysql-test/main/table_options-5867.opt @@ -0,0 +1 @@ +--plugin-maturity=unknown diff --git a/mysql-test/main/trigger-compat.test b/mysql-test/main/trigger-compat.test index 437df89b4b1..baf3cad11d6 100644 --- a/mysql-test/main/trigger-compat.test +++ b/mysql-test/main/trigger-compat.test @@ -2,7 +2,8 @@ # supported in embedded server. So, this test should not be run on embedded # server. --- source include/not_embedded.inc +--source include/not_embedded.inc +--source include/default_charset.inc ########################################################################### # diff --git a/mysql-test/main/trigger.test b/mysql-test/main/trigger.test index 2eeab16ec5a..581015a45e6 100644 --- a/mysql-test/main/trigger.test +++ b/mysql-test/main/trigger.test @@ -1,6 +1,6 @@ # This test uses chmod, can't be run with root permissions -- source include/not_as_root.inc - +--source include/default_charset.inc # # Basic triggers test diff --git a/mysql-test/main/trigger_notembedded.test b/mysql-test/main/trigger_notembedded.test index a31594826e7..1e9e31c0692 100644 --- a/mysql-test/main/trigger_notembedded.test +++ b/mysql-test/main/trigger_notembedded.test @@ -2,7 +2,8 @@ # supported in embedded server. So, this test should not be run on embedded # server. --- source include/not_embedded.inc +--source include/not_embedded.inc +--source include/default_charset.inc ########################################################################### # diff --git a/mysql-test/main/truncate-stale-6500.result b/mysql-test/main/truncate-stale-6500.result index b6222716953..be8d0aa7143 100644 --- a/mysql-test/main/truncate-stale-6500.result +++ b/mysql-test/main/truncate-stale-6500.result @@ -1,3 +1,4 @@ +set @save_query_cache_size=@@query_cache_size; SET GLOBAL query_cache_size=1024*1024*8; CREATE TABLE `test` ( `uniqueId` INT NOT NULL, @@ -30,4 +31,4 @@ uniqueId partitionId SELECT SQL_NO_CACHE * FROM `test`; uniqueId partitionId DROP TABLE test; -SET GLOBAL query_cache_size=DEFAULT; +SET GLOBAL query_cache_size=@save_query_cache_size; diff --git a/mysql-test/main/truncate-stale-6500.test b/mysql-test/main/truncate-stale-6500.test index 47dffb1966d..95dc293bff9 100644 --- a/mysql-test/main/truncate-stale-6500.test +++ b/mysql-test/main/truncate-stale-6500.test @@ -1,6 +1,7 @@ --source include/have_innodb.inc --source include/have_partition.inc +set @save_query_cache_size=@@query_cache_size; SET GLOBAL query_cache_size=1024*1024*8; CREATE TABLE `test` ( `uniqueId` INT NOT NULL, @@ -29,4 +30,4 @@ SELECT SQL_CACHE * FROM `test`; SELECT SQL_NO_CACHE * FROM `test`; DROP TABLE test; -SET GLOBAL query_cache_size=DEFAULT; +SET GLOBAL query_cache_size=@save_query_cache_size; diff --git a/mysql-test/main/truncate_badse.opt b/mysql-test/main/truncate_badse.opt new file mode 100644 index 00000000000..8374626febe --- /dev/null +++ b/mysql-test/main/truncate_badse.opt @@ -0,0 +1 @@ +--plugin-maturity=unknown diff --git a/mysql-test/main/type_time_6065.test b/mysql-test/main/type_time_6065.test index fc91c530760..274d5db50b9 100644 --- a/mysql-test/main/type_time_6065.test +++ b/mysql-test/main/type_time_6065.test @@ -1,3 +1,5 @@ +--source include/default_optimizer_switch.inc + # # MDEV-6065 MySQL Bug#13623473 "MISSING ROWS ON SELECT AND JOIN WITH TIME/DATETIME COMPARE" # diff --git a/mysql-test/main/type_varchar.opt b/mysql-test/main/type_varchar.opt new file mode 100644 index 00000000000..35db081c15b --- /dev/null +++ b/mysql-test/main/type_varchar.opt @@ -0,0 +1 @@ +--character-set-server=latin1 --collation_server=latin1_swedish_ci diff --git a/mysql-test/main/udf_query_cache.result b/mysql-test/main/udf_query_cache.result index 8c25c127012..38bb78a8007 100644 --- a/mysql-test/main/udf_query_cache.result +++ b/mysql-test/main/udf_query_cache.result @@ -1,6 +1,7 @@ drop table if exists t1; CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB"; create table t1 (a char); +set @save_query_cache_size=@@query_cache_size; set GLOBAL query_cache_size=1355776; reset query cache; flush status; @@ -22,4 +23,4 @@ Variable_name Value Qcache_queries_in_cache 0 drop table t1; drop function metaphon; -set GLOBAL query_cache_size=default; +set GLOBAL query_cache_size=@save_query_cache_size; diff --git a/mysql-test/main/udf_query_cache.test b/mysql-test/main/udf_query_cache.test index b0037973631..99cbffb1aae 100644 --- a/mysql-test/main/udf_query_cache.test +++ b/mysql-test/main/udf_query_cache.test @@ -18,6 +18,7 @@ drop table if exists t1; eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_SO"; create table t1 (a char); +set @save_query_cache_size=@@query_cache_size; set GLOBAL query_cache_size=1355776; reset query cache; flush status; @@ -32,5 +33,6 @@ show status like "Qcache_queries_in_cache"; drop table t1; drop function metaphon; -set GLOBAL query_cache_size=default; +set GLOBAL query_cache_size=@save_query_cache_size; + diff --git a/mysql-test/main/union.result b/mysql-test/main/union.result index ef767b1d5af..3c8ef81537e 100644 --- a/mysql-test/main/union.result +++ b/mysql-test/main/union.result @@ -560,12 +560,15 @@ a b 2 2 3 3 4 4 +set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity,@save_optimizer_switch=@@optimizer_switch; +SET optimizer_switch='outer_join_with_cache=off',@@optimizer_use_condition_selectivity=1; explain (select * from t1 where a=1 and b=10) union (select straight_join t1.a,t2.a from t1,t2 where t1.a=t2.a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables 2 UNION t1 index PRIMARY PRIMARY 4 NULL 4 Using index 2 UNION t2 index PRIMARY PRIMARY 4 NULL 4 Using where; Using index; Using join buffer (flat, BNL join) NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL +set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity,@@optimizer_switch=@save_optimizer_switch; explain (select * from t1 where a=1) union (select * from t1 where b=1); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 const PRIMARY PRIMARY 4 const 1 @@ -1368,9 +1371,7 @@ t3 CREATE TABLE `t3` ( `left(a,100000000)` longtext DEFAULT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop tables t1,t2,t3; -SELECT @tmp_max:= @@global.max_allowed_packet; -@tmp_max:= @@global.max_allowed_packet -16777216 +SET @tmp_max= @@global.max_allowed_packet; SET @@global.max_allowed_packet=25000000; Warnings: Warning 1292 Truncated incorrect max_allowed_packet value: '25000000' diff --git a/mysql-test/main/union.test b/mysql-test/main/union.test index 9d9194ebab6..8c0540375f2 100644 --- a/mysql-test/main/union.test +++ b/mysql-test/main/union.test @@ -339,7 +339,12 @@ explain extended (select * from t1 where a=1) union (select * from t2 where a=1) (select * from t1 where a=5 and a=6) union (select * from t2 where a=1); (select t1.a,t1.b from t1,t2 where t1.a=5) union (select * from t2 where a=1); (select * from t1 where a=1) union (select t1.a,t2.a from t1,t2 where t1.a=t2.a); + +set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity,@save_optimizer_switch=@@optimizer_switch; +SET optimizer_switch='outer_join_with_cache=off',@@optimizer_use_condition_selectivity=1; explain (select * from t1 where a=1 and b=10) union (select straight_join t1.a,t2.a from t1,t2 where t1.a=t2.a); +set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity,@@optimizer_switch=@save_optimizer_switch; + explain (select * from t1 where a=1) union (select * from t1 where b=1); drop table t1,t2; create table t1 ( id int not null auto_increment, primary key (id) ,user_name text ); @@ -840,7 +845,7 @@ drop tables t1,t2,t3; # exceeds mediumtext maximum length # -SELECT @tmp_max:= @@global.max_allowed_packet; +SET @tmp_max= @@global.max_allowed_packet; SET @@global.max_allowed_packet=25000000; # switching connection to allow the new max_allowed_packet take effect --connect (newconn, localhost, root,,) diff --git a/mysql-test/main/upgrade.opt b/mysql-test/main/upgrade.opt new file mode 100644 index 00000000000..35db081c15b --- /dev/null +++ b/mysql-test/main/upgrade.opt @@ -0,0 +1 @@ +--character-set-server=latin1 --collation_server=latin1_swedish_ci diff --git a/mysql-test/main/upgrade.test b/mysql-test/main/upgrade.test index ab9330176f8..e7a3e4d8abf 100644 --- a/mysql-test/main/upgrade.test +++ b/mysql-test/main/upgrade.test @@ -1,5 +1,5 @@ call mtr.add_suppression("Invalid .old.. table or database name"); --- source include/not_embedded.inc +--source include/not_embedded.inc --disable_warnings drop database if exists `mysqltest1`; diff --git a/mysql-test/main/user_var-binlog.result b/mysql-test/main/user_var-binlog.result index 6066da2481a..0d8732399c7 100644 --- a/mysql-test/main/user_var-binlog.result +++ b/mysql-test/main/user_var-binlog.result @@ -33,7 +33,7 @@ SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.uniq SET @@session.sql_mode=1411383296/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C latin1 *//*!*/; -SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=8/*!*/; +SET @@session.character_set_client=8,@@session.collation_connection=8,@@session.collation_server=#/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; INSERT INTO t1 VALUES(@`a b`) diff --git a/mysql-test/main/user_var-binlog.test b/mysql-test/main/user_var-binlog.test index 0098f237de9..3f48ebbf570 100644 --- a/mysql-test/main/user_var-binlog.test +++ b/mysql-test/main/user_var-binlog.test @@ -18,6 +18,7 @@ source include/show_binlog_events.inc; # escaped). let $MYSQLD_DATADIR= `select @@datadir`; flush logs; +--replace_regex /collation_server=\d+/collation_server=#/ --exec $MYSQL_BINLOG --short-form $MYSQLD_DATADIR/master-bin.000001 drop table t1; diff --git a/mysql-test/main/userstat-badlogin-4824.result b/mysql-test/main/userstat-badlogin-4824.result index 6a38c2bd601..757b20e0ce0 100644 --- a/mysql-test/main/userstat-badlogin-4824.result +++ b/mysql-test/main/userstat-badlogin-4824.result @@ -1,3 +1,4 @@ +set @save_userstat=@@global.userstat; create user foo@localhost identified by 'foo'; flush user_statistics; set global userstat=1; @@ -18,4 +19,4 @@ select user, bytes_received from information_schema.user_statistics where user = user bytes_received foo 18 drop user foo@localhost; -set global userstat=0; +set global userstat=@save_userstat; diff --git a/mysql-test/main/userstat-badlogin-4824.test b/mysql-test/main/userstat-badlogin-4824.test index 97370c1d081..78f2150e446 100644 --- a/mysql-test/main/userstat-badlogin-4824.test +++ b/mysql-test/main/userstat-badlogin-4824.test @@ -2,6 +2,7 @@ # MDEV-4824 userstats - wrong user statistics # --source include/not_embedded.inc +set @save_userstat=@@global.userstat; create user foo@localhost identified by 'foo'; flush user_statistics; @@ -30,4 +31,4 @@ connection default; select user, bytes_received from information_schema.user_statistics where user = 'foo'; drop user foo@localhost; -set global userstat=0; +set global userstat=@save_userstat; diff --git a/mysql-test/main/userstat.opt b/mysql-test/main/userstat.opt new file mode 100644 index 00000000000..45c618ea22e --- /dev/null +++ b/mysql-test/main/userstat.opt @@ -0,0 +1 @@ +--disable-userstat diff --git a/mysql-test/main/variables-master.opt b/mysql-test/main/variables-master.opt index e4b213a0323..1049117752d 100644 --- a/mysql-test/main/variables-master.opt +++ b/mysql-test/main/variables-master.opt @@ -1 +1 @@ ---max-user-connections=1 +--max-user-connections=1 --myisam_recover_options=BACKUP,QUICK diff --git a/mysql-test/main/variables-notembedded.result b/mysql-test/main/variables-notembedded.result index a8bf7ecc429..70a068cd802 100644 --- a/mysql-test/main/variables-notembedded.result +++ b/mysql-test/main/variables-notembedded.result @@ -33,12 +33,12 @@ ERROR HY000: Variable 'log_slave_updates' is a read only variable # SHOW VARIABLES like 'relay_log'; Variable_name Value -relay_log mysqld-relay-bin +relay_log XXX-relay-bin SELECT @@session.relay_log; ERROR HY000: Variable 'relay_log' is a GLOBAL variable SELECT @@global.relay_log; @@global.relay_log -mysqld-relay-bin +XXX-relay-bin SET @@session.relay_log= 'x'; ERROR HY000: Variable 'relay_log' is a read only variable SET @@global.relay_log= 'x'; @@ -46,12 +46,12 @@ ERROR HY000: Variable 'relay_log' is a read only variable # SHOW VARIABLES like 'relay_log_basename'; Variable_name Value -relay_log_basename MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin +relay_log_basename MYSQLTEST_VARDIR/mysqld.1/data/XXX-relay-bin SELECT @@session.relay_log_basename; ERROR HY000: Variable 'relay_log_basename' is a GLOBAL variable SELECT @@global.relay_log_basename; @@global.relay_log_basename -MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin +MYSQLTEST_VARDIR/mysqld.1/data/XXX-relay-bin SET @@session.relay_log_basename= 'x'; ERROR HY000: Variable 'relay_log_basename' is a read only variable SET @@global.relay_log_basename= 'x'; @@ -72,12 +72,12 @@ ERROR HY000: Variable 'log_bin_basename' is a read only variable # SHOW VARIABLES like 'relay_log_index'; Variable_name Value -relay_log_index MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin.index +relay_log_index MYSQLTEST_VARDIR/mysqld.1/data/XXX-relay-bin.index SELECT @@session.relay_log_index; ERROR HY000: Variable 'relay_log_index' is a GLOBAL variable SELECT @@global.relay_log_index; @@global.relay_log_index -MYSQLTEST_VARDIR/mysqld.1/data/mysqld-relay-bin.index +MYSQLTEST_VARDIR/mysqld.1/data/XXX-relay-bin.index SET @@session.relay_log_index= 'x'; ERROR HY000: Variable 'relay_log_index' is a read only variable SET @@global.relay_log_index= 'x'; @@ -152,6 +152,7 @@ ERROR HY000: Variable 'slave_skip_errors' is a read only variable # ARE NOT BEING HONORED # CREATE TABLE t1 (a MEDIUMTEXT); +set @save_max_allowed_packet=@@global.max_allowed_packet, @save_net_buffer_length=@@net_buffer_length; SET GLOBAL max_allowed_packet=2048; Warnings: Warning 1708 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length' @@ -170,7 +171,7 @@ connection default; disconnect con1; SELECT LENGTH(a) FROM t1; LENGTH(a) -SET GLOBAL max_allowed_packet=default; -SET GLOBAL net_buffer_length=default; +SET GLOBAL max_allowed_packet=@save_max_allowed_packet; +SET GLOBAL net_buffer_length=@save_net_buffer_length; DROP TABLE t1; End of 5.1 tests diff --git a/mysql-test/main/variables-notembedded.test b/mysql-test/main/variables-notembedded.test index 2aa77e1e254..7a1489cf392 100644 --- a/mysql-test/main/variables-notembedded.test +++ b/mysql-test/main/variables-notembedded.test @@ -48,9 +48,12 @@ SET @@session.log_slave_updates= true; SET @@global.log_slave_updates= true; # --echo # +let $relay_prefix=`select concat(substring_index(@@relay_log,"-",1),"-")`; +--replace_result $relay_prefix XXX- SHOW VARIABLES like 'relay_log'; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@session.relay_log; +--replace_result $relay_prefix XXX- SELECT @@global.relay_log; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SET @@session.relay_log= 'x'; @@ -58,11 +61,11 @@ SET @@session.relay_log= 'x'; SET @@global.relay_log= 'x'; # --echo # ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $relay_prefix XXX- SHOW VARIABLES like 'relay_log_basename'; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@session.relay_log_basename; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $relay_prefix XXX- SELECT @@global.relay_log_basename; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SET @@session.relay_log_basename= 'x'; @@ -70,9 +73,11 @@ SET @@session.relay_log_basename= 'x'; SET @@global.relay_log_basename= 'x'; # --echo # +--replace_result $relay_prefix XXX- SHOW VARIABLES like 'log_bin_basename'; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@session.log_bin_basename; +--replace_result $relay_prefix XXX- SELECT @@global.log_bin_basename; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SET @@session.log_bin_basename= 'x'; @@ -80,11 +85,11 @@ SET @@session.log_bin_basename= 'x'; SET @@global.log_bin_basename= 'x'; # --echo # ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $relay_prefix XXX- SHOW VARIABLES like 'relay_log_index'; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@session.relay_log_index; ---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR +--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $relay_prefix XXX- SELECT @@global.relay_log_index; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SET @@session.relay_log_index= 'x'; @@ -92,9 +97,11 @@ SET @@session.relay_log_index= 'x'; SET @@global.relay_log_index= 'x'; # --echo # +--replace_result $relay_prefix XXX- SHOW VARIABLES like 'log_bin_index'; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@session.log_bin_index; +--replace_result $relay_prefix XXX- SELECT @@global.log_bin_index; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SET @@session.log_bin_index= 'x'; @@ -151,6 +158,7 @@ SET @@global.slave_skip_errors= 7; CREATE TABLE t1 (a MEDIUMTEXT); +set @save_max_allowed_packet=@@global.max_allowed_packet, @save_net_buffer_length=@@net_buffer_length; SET GLOBAL max_allowed_packet=2048; SET GLOBAL net_buffer_length=4096; CONNECT (con1,localhost,root,,test); @@ -170,8 +178,8 @@ CONNECTION default; DISCONNECT con1; SELECT LENGTH(a) FROM t1; -SET GLOBAL max_allowed_packet=default; -SET GLOBAL net_buffer_length=default; +SET GLOBAL max_allowed_packet=@save_max_allowed_packet; +SET GLOBAL net_buffer_length=@save_net_buffer_length; DROP TABLE t1; --echo End of 5.1 tests diff --git a/mysql-test/main/variables.result b/mysql-test/main/variables.result index 9224aa82e8a..9cf751a1ee5 100644 --- a/mysql-test/main/variables.result +++ b/mysql-test/main/variables.result @@ -27,7 +27,8 @@ set @my_thread_cache_size =@@global.thread_cache_size; set @my_max_allowed_packet =@@global.max_allowed_packet; set @my_delay_key_write =@@global.delay_key_write; set @my_join_buffer_size =@@global.join_buffer_size; -set @my_log_warnings =@@global.log_warnings; +set @my_log_warnings =@@global.log_warnings; +set @my_local_infile =@@global.local_infile; set @`test`=1; select @test, @`test`, @TEST, @`TEST`, @"teSt"; @test @`test` @TEST @`TEST` @"teSt" @@ -522,9 +523,6 @@ Warning 1292 Truncated incorrect max_heap_table_size value: '100' set max_join_size=100; set max_sort_length=100; set global max_user_connections=100; -select @@max_user_connections; -@@max_user_connections -100 set global max_write_lock_count=100; set myisam_sort_buffer_size=100; Warnings: @@ -648,13 +646,14 @@ select * from information_schema.global_variables where variable_name like 'myis VARIABLE_NAME VARIABLE_VALUE MYISAM_MAX_SORT_FILE_SIZE MAX_FILE_SIZE set global myisam_max_sort_file_size=default; +set @@global.max_user_connections=10, @@local.max_join_size=1000; select @@global.max_user_connections,@@local.max_join_size; @@global.max_user_connections @@local.max_join_size -100 100 +10 1000 set @svc=@@global.max_user_connections, @svj=@@local.max_join_size; select @@global.max_user_connections,@@local.max_join_size; @@global.max_user_connections @@local.max_join_size -100 100 +10 1000 set @@global.max_user_connections=111,@@local.max_join_size=222; select @@global.max_user_connections,@@local.max_join_size; @@global.max_user_connections @@local.max_join_size @@ -666,12 +665,13 @@ select @@global.max_user_connections,@@local.max_join_size; set @@global.max_user_connections=@svc, @@local.max_join_size=@svj; select @@global.max_user_connections,@@local.max_join_size; @@global.max_user_connections @@local.max_join_size -100 100 +10 1000 set @a=1, @b=2; set @a=@b, @b=@a; select @a, @b; @a @b 2 1 +set @@global.max_user_connections=@my_max_user_connections; set @@global.global.key_buffer_size= 1; ERROR HY000: Unknown structured system variable or ROW routine variable 'global' set GLOBAL global.key_buffer_size= 1; @@ -1061,12 +1061,13 @@ set global net_write_timeout =@my_net_write_timeout; set global net_read_timeout =@my_net_read_timeout; set global server_id =@my_server_id; set global slow_launch_time =@my_slow_launch_time; -set global default_storage_engine =@my_storage_engine; +set global default_storage_engine =@my_storage_engine; set global thread_cache_size =@my_thread_cache_size; -set global max_allowed_packet = default; +set global max_allowed_packet =@my_max_allowed_packet; set global delay_key_write =@my_delay_key_write; set global join_buffer_size =@my_join_buffer_size; set global log_warnings =@my_log_warnings; +set global local_infile =@my_local_infile; show global variables where Variable_name='table_definition_cache'; Variable_name Value table_definition_cache # @@ -1136,12 +1137,12 @@ ERROR HY000: Variable 'ft_stopword_file' is a read only variable # SHOW VARIABLES like 'back_log'; Variable_name Value -back_log 80 +back_log # SELECT @@session.back_log; ERROR HY000: Variable 'back_log' is a GLOBAL variable -SELECT @@global.back_log; -@@global.back_log -80 +SELECT @@global.back_log > 0; +@@global.back_log > 0 +1 SET @@session.back_log= 7; ERROR HY000: Variable 'back_log' is a read only variable SET @@global.back_log= 7; @@ -1492,12 +1493,12 @@ SET GLOBAL max_binlog_cache_size = @old_max_binlog_cache_size; # # Bug #37168 : Missing variable - skip_name_resolve # -SELECT @@skip_name_resolve; -@@skip_name_resolve -0 +SELECT @@skip_name_resolve >= 0; +@@skip_name_resolve >= 0 +1 SHOW VARIABLES LIKE 'skip_name_resolve'; Variable_name Value -skip_name_resolve OFF +skip_name_resolve # # # Bug #43233 : Some server variables are clipped during "update," # not "check" stage @@ -1531,9 +1532,9 @@ SET @@global.max_binlog_cache_size=DEFAULT; SET @@global.max_join_size=DEFAULT; SET @@global.key_buffer_size=@kbs; SET @@global.key_cache_block_size=@kcbs; -select @@max_long_data_size; -@@max_long_data_size -16777216 +select @@max_long_data_size > 0; +@@max_long_data_size > 0 +1 # # Bug#11766424 59527: # Assert in DECIMAL_BIN_SIZE: diff --git a/mysql-test/main/variables.test b/mysql-test/main/variables.test index fa0bdc251b5..846d2665013 100644 --- a/mysql-test/main/variables.test +++ b/mysql-test/main/variables.test @@ -36,7 +36,9 @@ set @my_thread_cache_size =@@global.thread_cache_size; set @my_max_allowed_packet =@@global.max_allowed_packet; set @my_delay_key_write =@@global.delay_key_write; set @my_join_buffer_size =@@global.join_buffer_size; -set @my_log_warnings =@@global.log_warnings; +set @my_log_warnings =@@global.log_warnings; +set @my_local_infile =@@global.local_infile; + # case insensitivity tests (new in 5.0) set @`test`=1; select @test, @`test`, @TEST, @`TEST`, @"teSt"; @@ -314,7 +316,6 @@ set max_heap_table_size=100; set max_join_size=100; set max_sort_length=100; set global max_user_connections=100; -select @@max_user_connections; set global max_write_lock_count=100; set myisam_sort_buffer_size=100; set global net_buffer_length=100; @@ -423,6 +424,10 @@ set global myisam_max_sort_file_size=default; # # swap # + +# set some variables to play with +set @@global.max_user_connections=10, @@local.max_join_size=1000; + select @@global.max_user_connections,@@local.max_join_size; set @svc=@@global.max_user_connections, @svj=@@local.max_join_size; select @@global.max_user_connections,@@local.max_join_size; @@ -435,6 +440,7 @@ select @@global.max_user_connections,@@local.max_join_size; set @a=1, @b=2; set @a=@b, @b=@a; select @a, @b; +set @@global.max_user_connections=@my_max_user_connections; # # Bug#2586:Disallow global/session/local as structured var. instance names @@ -814,12 +820,13 @@ set global net_write_timeout =@my_net_write_timeout; set global net_read_timeout =@my_net_read_timeout; set global server_id =@my_server_id; set global slow_launch_time =@my_slow_launch_time; -set global default_storage_engine =@my_storage_engine; +set global default_storage_engine =@my_storage_engine; set global thread_cache_size =@my_thread_cache_size; -set global max_allowed_packet = default; +set global max_allowed_packet =@my_max_allowed_packet; set global delay_key_write =@my_delay_key_write; set global join_buffer_size =@my_join_buffer_size; set global log_warnings =@my_log_warnings; +set global local_infile =@my_local_infile; # # Bug#28580 Repeatation of status variables @@ -891,10 +898,11 @@ SET @@global.ft_stopword_file= 'x'; # Additional variables fixed. # --echo # +--replace_column 2 # SHOW VARIABLES like 'back_log'; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SELECT @@session.back_log; -SELECT @@global.back_log; +SELECT @@global.back_log > 0; --error ER_INCORRECT_GLOBAL_LOCAL_VAR SET @@session.back_log= 7; --error ER_INCORRECT_GLOBAL_LOCAL_VAR @@ -1208,7 +1216,8 @@ SET GLOBAL max_binlog_cache_size = @old_max_binlog_cache_size; --echo # Bug #37168 : Missing variable - skip_name_resolve --echo # -SELECT @@skip_name_resolve; +SELECT @@skip_name_resolve >= 0; +--replace_column 2 # SHOW VARIABLES LIKE 'skip_name_resolve'; --echo # @@ -1258,7 +1267,7 @@ SET @@global.key_cache_block_size=@kcbs; # # Bug#56976: added new start-up parameter # -select @@max_long_data_size; +select @@max_long_data_size > 0; --echo # --echo # Bug#11766424 59527: diff --git a/mysql-test/main/view.result b/mysql-test/main/view.result index 5c078d77c1d..01d7dd3b6ea 100644 --- a/mysql-test/main/view.result +++ b/mysql-test/main/view.result @@ -1,4 +1,3 @@ -SET @save_optimizer_switch=@@optimizer_switch; SET optimizer_switch='outer_join_with_cache=off'; create view v1 (c,d) as select a,b from t1; ERROR 42S02: Table 'test.t1' doesn't exist @@ -3717,76 +3716,76 @@ a 2 CREATE VIEW v2 AS SELECT t1.a FROM t1, v1 AS a; REPLACE INTO v2(a) SELECT 1 FROM t1,t1 AS c; -SELECT * FROM v2; +SELECT * FROM v2 order by 1; a 1 -2 1 -2 1 -2 1 2 +2 +2 +2 REPLACE INTO v2(a) SELECT 3 FROM t1,t1 AS c; -SELECT * FROM v2; +SELECT * FROM v2 order by 1; a 1 -2 -3 1 -2 -3 1 -2 -3 1 -2 -3 1 -2 -3 1 -2 -3 1 -2 -3 1 -2 -3 1 2 +2 +2 +2 +2 +2 +2 +2 +2 +3 +3 +3 +3 +3 +3 +3 +3 3 INSERT INTO v2(a) SELECT 1 FROM t1,t1 AS c ON DUPLICATE KEY UPDATE `v2`.`a`= 1; -SELECT * FROM v2; +SELECT * FROM v2 order by 1; a 1 -2 -3 1 -2 -3 1 -2 -3 1 -2 -3 1 -2 -3 1 -2 -3 1 -2 -3 1 -2 -3 1 2 +2 +2 +2 +2 +2 +2 +2 +2 +3 +3 +3 +3 +3 +3 +3 +3 3 DROP VIEW v1; DROP VIEW v2; diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test index 66020687547..ef42cf08df7 100644 --- a/mysql-test/main/view.test +++ b/mysql-test/main/view.test @@ -1,8 +1,8 @@ --source include/have_partition.inc # Save the initial number of concurrent sessions. --source include/count_sessions.inc +--source include/default_optimizer_switch.inc -SET @save_optimizer_switch=@@optimizer_switch; SET optimizer_switch='outer_join_with_cache=off'; # @@ -3664,12 +3664,12 @@ SELECT * FROM v1; CREATE VIEW v2 AS SELECT t1.a FROM t1, v1 AS a; REPLACE INTO v2(a) SELECT 1 FROM t1,t1 AS c; -SELECT * FROM v2; +SELECT * FROM v2 order by 1; REPLACE INTO v2(a) SELECT 3 FROM t1,t1 AS c; -SELECT * FROM v2; +SELECT * FROM v2 order by 1; INSERT INTO v2(a) SELECT 1 FROM t1,t1 AS c ON DUPLICATE KEY UPDATE `v2`.`a`= 1; -SELECT * FROM v2; +SELECT * FROM v2 order by 1; DROP VIEW v1; DROP VIEW v2; diff --git a/mysql-test/main/xtradb_mrr.result b/mysql-test/main/xtradb_mrr.result index f49207c0e41..f4d54a78a5c 100644 --- a/mysql-test/main/xtradb_mrr.result +++ b/mysql-test/main/xtradb_mrr.result @@ -742,6 +742,7 @@ count(*) sum(table1.col_int_key*table2.pk) drop table t1,t2; set join_cache_level=@my_save_join_cache_level; set join_buffer_size=@my_save_join_buffer_size; +set optimizer_switch=@save_optimizer_switch; # # BUG#665669: Result differences on query re-execution # diff --git a/mysql-test/main/xtradb_mrr.test b/mysql-test/main/xtradb_mrr.test index 3e84668955a..8dccd20796f 100644 --- a/mysql-test/main/xtradb_mrr.test +++ b/mysql-test/main/xtradb_mrr.test @@ -284,6 +284,7 @@ drop table t1; --echo # --echo # BUG#671340: Diverging results in with mrr_sort_keys=ON|OFF and join_cache_level=5 --echo # + CREATE TABLE t1 ( pk int(11) NOT NULL AUTO_INCREMENT, col_int_key int(11) NOT NULL, @@ -346,6 +347,7 @@ INSERT INTO t2 VALUES (19,5,'h','h'), (20,7,'w','w'); +--source include/default_optimizer_switch.inc SELECT count(*), sum(table1.col_int_key*table2.pk) FROM t2 AS table1, t1 AS table2, t2 AS table3 @@ -366,6 +368,7 @@ WHERE drop table t1,t2; set join_cache_level=@my_save_join_cache_level; set join_buffer_size=@my_save_join_buffer_size; +set optimizer_switch=@save_optimizer_switch; --echo # |