diff options
Diffstat (limited to 'mysql-test/main')
183 files changed, 10777 insertions, 15093 deletions
diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result index 879bc0edfec..1508bb9d34a 100644 --- a/mysql-test/main/alter_table.result +++ b/mysql-test/main/alter_table.result @@ -268,28 +268,6 @@ ERROR 42000: Incorrect table name '' rename table t1 to ``; ERROR 42000: Incorrect table name '' drop table t1; -drop table if exists t1, t2; -Warnings: -Note 1051 Unknown table 'test.t1,test.t2' -create table t1 ( a varchar(10) not null primary key ) engine=myisam; -create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1); -flush tables; -alter table t1 modify a varchar(10); -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `a` varchar(10) NOT NULL, - PRIMARY KEY (`a`) -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci UNION=(`t1`) -flush tables; -alter table t1 modify a varchar(10) not null; -show create table t2; -Table Create Table -t2 CREATE TABLE `t2` ( - `a` varchar(10) NOT NULL, - PRIMARY KEY (`a`) -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci UNION=(`t1`) -drop table if exists t1, t2; create table t1 (a int, b int, c int, d int, e int, f int, g int, h int,i int, primary key (a,b,c,d,e,f,g,i,h)) engine=MyISAM; insert ignore into t1 (a) values(1); Warnings: diff --git a/mysql-test/main/alter_table.test b/mysql-test/main/alter_table.test index 8ddf60f26d8..ebf10008f48 100644 --- a/mysql-test/main/alter_table.test +++ b/mysql-test/main/alter_table.test @@ -244,20 +244,6 @@ alter table t1 rename to ``; rename table t1 to ``; drop table t1; -# -# BUG#6236 - ALTER TABLE MODIFY should set implicit NOT NULL on PK columns -# -drop table if exists t1, t2; -create table t1 ( a varchar(10) not null primary key ) engine=myisam; -create table t2 ( a varchar(10) not null primary key ) engine=merge union=(t1); -flush tables; -alter table t1 modify a varchar(10); -show create table t2; -flush tables; -alter table t1 modify a varchar(10) not null; -show create table t2; -drop table if exists t1, t2; - # The following is also part of bug #6236 (CREATE TABLE didn't properly count # not null columns for primary keys) diff --git a/mysql-test/main/analyze_format_json.result b/mysql-test/main/analyze_format_json.result index 02635a8f3dd..0e1ea88404b 100644 --- a/mysql-test/main/analyze_format_json.result +++ b/mysql-test/main/analyze_format_json.result @@ -201,8 +201,11 @@ ANALYZE "buffer_type": "flat", "buffer_size": "1Kb", "join_type": "BNL", + "r_loops": 20, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 60 } } ] @@ -257,8 +260,11 @@ ANALYZE "buffer_size": "1Kb", "join_type": "BNL", "attached_condition": "tbl1.c > tbl2.c", + "r_loops": 20, "r_filtered": 15.83333333, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 60 } } ] @@ -836,8 +842,11 @@ ANALYZE "buffer_size": "65", "join_type": "BNL", "attached_condition": "<in_optimizer>(t2.b,t2.b in (subquery#2))", + "r_loops": 2, "r_filtered": null, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 0 } } ], @@ -950,8 +959,11 @@ ANALYZE "buffer_type": "flat", "buffer_size": "1", "join_type": "BNL", + "r_loops": 2, "r_filtered": null, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 0 } } ], @@ -994,8 +1006,11 @@ ANALYZE "buffer_size": "65", "join_type": "BNL", "attached_condition": "t2.f2 = t3.f3", + "r_loops": 0, "r_filtered": null, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": null } } ] @@ -1089,3 +1104,155 @@ ANALYZE } } drop table t0,t1,t2; +# +# MDEV-30806: ANALYZE FORMAT=JSON: better support for BNL and BNL-H joins +# +create table t10 ( +a int, +b int +); +insert into t10 select seq, seq/3 from seq_0_to_999; +create table t11 ( +a int, +b int +); +insert into t11 select seq, seq/5 from seq_0_to_999; +analyze table t10,t11 persistent for all; +Table Op Msg_type Msg_text +test.t10 analyze status Engine-independent statistics collected +test.t10 analyze status OK +test.t11 analyze status Engine-independent statistics collected +test.t11 analyze status OK +analyze format=json +select * from t10, t11 +where +t10.a < 700 and +t11.a < 100 +and t10.b=t11.b; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "cost": "REPLACED", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "loops": 1, + "r_loops": 1, + "rows": 1000, + "r_rows": 1000, + "cost": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 10, + "r_filtered": 10, + "attached_condition": "t11.a < 100" + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t10", + "access_type": "ALL", + "loops": 100, + "r_loops": 1, + "rows": 1000, + "r_rows": 1000, + "cost": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 70, + "r_filtered": 70, + "attached_condition": "t10.a < 700" + }, + "buffer_type": "flat", + "buffer_size": "1Kb", + "join_type": "BNL", + "attached_condition": "t10.b = t11.b", + "r_loops": 100, + "r_filtered": 0.424285714, + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 700 + } + } + ] + } +} +set @tmp=@@join_cache_level, join_cache_level=6; +analyze format=json +select * from t10, t11 +where +t10.a < 700 and +t11.a < 100 +and t10.b=t11.b; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "cost": "REPLACED", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t11", + "access_type": "ALL", + "loops": 1, + "r_loops": 1, + "rows": 1000, + "r_rows": 1000, + "cost": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 10, + "r_filtered": 10, + "attached_condition": "t11.a < 100 and t11.b is not null" + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t10", + "access_type": "hash_ALL", + "key": "#hash#$hj", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t11.b"], + "loops": 100, + "r_loops": 1, + "rows": 1000, + "r_rows": 1000, + "cost": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 0.209580004, + "r_filtered": 70, + "attached_condition": "t10.a < 700" + }, + "buffer_type": "flat", + "buffer_size": "3Kb", + "join_type": "BNLH", + "attached_condition": "t10.b = t11.b", + "r_loops": 100, + "r_filtered": 100, + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 2.97 + } + } + ] + } +} +set join_cache_level=@tmp; +drop table t10, t11; diff --git a/mysql-test/main/analyze_format_json.test b/mysql-test/main/analyze_format_json.test index 84625f125fb..001616304cf 100644 --- a/mysql-test/main/analyze_format_json.test +++ b/mysql-test/main/analyze_format_json.test @@ -228,3 +228,45 @@ create table t2 as select * from t1; --source include/analyze-format.inc analyze format=json select a, (select t2.b from t2 where t2.a<t1.a order by t2.c limit 1) from t1 where t1.a<0; drop table t0,t1,t2; + + +--echo # +--echo # MDEV-30806: ANALYZE FORMAT=JSON: better support for BNL and BNL-H joins +--echo # +--source include/have_sequence.inc +create table t10 ( + a int, + b int +); +insert into t10 select seq, seq/3 from seq_0_to_999; + +create table t11 ( + a int, + b int +); +insert into t11 select seq, seq/5 from seq_0_to_999; + +analyze table t10,t11 persistent for all; + +--source include/analyze-format.inc +analyze format=json +select * from t10, t11 +where + t10.a < 700 and + t11.a < 100 + and t10.b=t11.b; + +set @tmp=@@join_cache_level, join_cache_level=6; + +--source include/analyze-format.inc +analyze format=json +select * from t10, t11 +where + t10.a < 700 and + t11.a < 100 + and t10.b=t11.b; + +set join_cache_level=@tmp; +drop table t10, t11; + + diff --git a/mysql-test/main/analyze_format_json_emb.result b/mysql-test/main/analyze_format_json_emb.result new file mode 100644 index 00000000000..d61e205f031 --- /dev/null +++ b/mysql-test/main/analyze_format_json_emb.result @@ -0,0 +1,11 @@ +# +# MDEV-31121: ANALYZE statement produces 0 for all timings in embedded serve +# +create table t1 (a int); +insert into t1 values (0),(0); +set @js='$out'; +set @out=(select json_extract(@js,'$**.query_block.r_total_time_ms')); +select cast(json_extract(@out,'$[0]') as DOUBLE) > 0; +cast(json_extract(@out,'$[0]') as DOUBLE) > 0 +1 +drop table t1; diff --git a/mysql-test/main/analyze_format_json_emb.test b/mysql-test/main/analyze_format_json_emb.test new file mode 100644 index 00000000000..dcf6f24dd8e --- /dev/null +++ b/mysql-test/main/analyze_format_json_emb.test @@ -0,0 +1,18 @@ +--source include/is_embedded.inc +--source include/big_test.inc + +--echo # +--echo # MDEV-31121: ANALYZE statement produces 0 for all timings in embedded serve +--echo # +create table t1 (a int); +insert into t1 values (0),(0); +let $out=` +analyze format=json select sleep(1+a) from t1 +`; + +evalp set @js='$out'; +set @out=(select json_extract(@js,'$**.query_block.r_total_time_ms')); +select cast(json_extract(@out,'$[0]') as DOUBLE) > 0; + +drop table t1; + diff --git a/mysql-test/main/analyze_format_json_timings.result b/mysql-test/main/analyze_format_json_timings.result new file mode 100644 index 00000000000..4686359186e --- /dev/null +++ b/mysql-test/main/analyze_format_json_timings.result @@ -0,0 +1,199 @@ +# +# MDEV-30830: ANALYZE FORMAT=JSON: r_unpack_time_ms is empty for the hashed joins +# +# +# First, check a regular BNL-join +# +create table t1 ( +a int, +b int +); +insert into t1 select seq, seq/3 from seq_0_to_99; +create table t2 ( +a int, +b int +); +insert into t2 select seq, seq/5 from seq_0_to_99; +set @js='$out'; +set @out=(select json_extract(@js,'$**.block-nl-join.r_unpack_time_ms')); +select cast(json_extract(@out,'$[0]') as DOUBLE) > 0; +cast(json_extract(@out,'$[0]') as DOUBLE) > 0 +1 +drop table t1,t2; +# +# Now, check the hashed, BNL-H join +# +create table t1 ( +a int, +b int +); +insert into t1 select seq, seq/3 from seq_0_to_499; +create table t2 ( +a int, +b int +); +insert into t2 select seq, seq/5 from seq_0_to_499; +set @tmp=@@join_cache_level, join_cache_level=6; +select '$out' as X; +X +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "cost": "REPLACED", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "loops": 1, + "r_loops": 1, + "rows": 500, + "r_rows": 500, + "cost": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "t1.a < 700 and t1.b is not null" + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "hash_ALL", + "key": "#hash#$hj", + "key_length": "5", + "used_key_parts": ["b"], + "ref": ["test.t1.b"], + "loops": 500, + "r_loops": 1, + "rows": 500, + "r_rows": 500, + "cost": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 10, + "r_filtered": 20, + "attached_condition": "t2.a < 100" + }, + "buffer_type": "flat", + "buffer_size": "18Kb", + "join_type": "BNLH", + "attached_condition": "t2.b = t1.b", + "r_loops": 500, + "r_filtered": 100, + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 0.594 + } + } + ] + } +} +set @out=(select json_extract(@js,'$**.block-nl-join.r_unpack_time_ms')); +select cast(json_extract(@out,'$[0]') as DOUBLE) > 0; +cast(json_extract(@out,'$[0]') as DOUBLE) > 0 +1 +set join_cache_level=@tmp; +drop table t1, t2; +# +# MDEV-30972: ANALYZE FORMAT=JSON: some time is unaccounted-for in BNL-H join +# +create table t1 ( +a int, +col1 varchar(100), +col2 varchar(100), +col3 varchar(100) +); +insert into t1 select +seq/100, +concat('col1-', seq), +concat('col1-', seq), +concat('col1-', seq) +from seq_1_to_1000; +create table t2 ( +a int, +col1 varchar(100), +col2 varchar(100), +col3 varchar(100) +); +insert into t2 select +seq/100, +concat('col1-', seq), +concat('col1-', seq), +concat('col1-', seq) +from seq_1_to_2000; +set @tmp=@@join_cache_level, join_cache_level=6; +select '$out' as X; +X +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "cost": "REPLACED", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "loops": 1, + "r_loops": 1, + "rows": 1000, + "r_rows": 1000, + "cost": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "t1.a is not null" + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t2", + "access_type": "hash_ALL", + "key": "#hash#$hj", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t1.a"], + "loops": 1000, + "r_loops": 1, + "rows": 2000, + "r_rows": 2000, + "cost": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 10, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "256Kb", + "join_type": "BNLH", + "attached_condition": "t2.a = t1.a and concat(t1.col1,t1.col2,t1.col3) = concat(t2.col1,t2.col2,t2.col3)", + "r_loops": 1000, + "r_filtered": 1.025630506, + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 97.501 + } + } + ] + } +} +set @out=(select json_extract(@js,'$**.block-nl-join.r_other_time_ms')); +select cast(json_extract(@out,'$[0]') as DOUBLE) > 0; +cast(json_extract(@out,'$[0]') as DOUBLE) > 0 +1 +set join_cache_level=@tmp; +drop table t1, t2; diff --git a/mysql-test/main/analyze_format_json_timings.test b/mysql-test/main/analyze_format_json_timings.test new file mode 100644 index 00000000000..fe02c318388 --- /dev/null +++ b/mysql-test/main/analyze_format_json_timings.test @@ -0,0 +1,127 @@ +# +# Tests to check that r_something_time_ms is non-zero in +# ANALYZE FORMAT=JSON <statement> +# +--source include/default_optimizer_switch.inc +--source include/have_sequence.inc + +# The tests here are large so that we get non-zero timings +--source include/big_test.inc + +--echo # +--echo # MDEV-30830: ANALYZE FORMAT=JSON: r_unpack_time_ms is empty for the hashed joins +--echo # + +--echo # +--echo # First, check a regular BNL-join +--echo # +create table t1 ( + a int, + b int +); +insert into t1 select seq, seq/3 from seq_0_to_99; + +create table t2 ( + a int, + b int +); +insert into t2 select seq, seq/5 from seq_0_to_99; + +let $out=` +analyze format=json +select * from t1, t2 +where + t1.a < 700 and + t2.a < 100 + and t1.b=t2.b +`; + +evalp set @js='$out'; +set @out=(select json_extract(@js,'$**.block-nl-join.r_unpack_time_ms')); +select cast(json_extract(@out,'$[0]') as DOUBLE) > 0; +drop table t1,t2; + +--echo # +--echo # Now, check the hashed, BNL-H join +--echo # +create table t1 ( + a int, + b int +); +insert into t1 select seq, seq/3 from seq_0_to_499; + +create table t2 ( + a int, + b int +); +insert into t2 select seq, seq/5 from seq_0_to_499; +set @tmp=@@join_cache_level, join_cache_level=6; + +let $out=` +analyze format=json +select * from t1, t2 +where + t1.a < 700 and + t2.a < 100 + and t1.b=t2.b +`; + +--source include/analyze-format.inc +evalp select '$out' as X; + +set @out=(select json_extract(@js,'$**.block-nl-join.r_unpack_time_ms')); +select cast(json_extract(@out,'$[0]') as DOUBLE) > 0; + +set join_cache_level=@tmp; +drop table t1, t2; + +--echo # +--echo # MDEV-30972: ANALYZE FORMAT=JSON: some time is unaccounted-for in BNL-H join +--echo # + +create table t1 ( + a int, + col1 varchar(100), + col2 varchar(100), + col3 varchar(100) +); + +insert into t1 select + seq/100, + concat('col1-', seq), + concat('col1-', seq), + concat('col1-', seq) +from seq_1_to_1000; + +create table t2 ( + a int, + col1 varchar(100), + col2 varchar(100), + col3 varchar(100) +); + +insert into t2 select + seq/100, + concat('col1-', seq), + concat('col1-', seq), + concat('col1-', seq) +from seq_1_to_2000; + +set @tmp=@@join_cache_level, join_cache_level=6; + +let $out=` +analyze format=json +select * from t1, t2 +where + t1.a=t2.a + and concat(t1.col1, t1.col2, t1.col3)= concat(t2.col1, t2.col2, t2.col3) +`; +--source include/analyze-format.inc +evalp select '$out' as X; + +set @out=(select json_extract(@js,'$**.block-nl-join.r_other_time_ms')); +select cast(json_extract(@out,'$[0]') as DOUBLE) > 0; + +set join_cache_level=@tmp; +drop table t1, t2; + diff --git a/mysql-test/main/analyze_stmt_orderby.result b/mysql-test/main/analyze_stmt_orderby.result index c3a3f2c562e..7008ad8dea3 100644 --- a/mysql-test/main/analyze_stmt_orderby.result +++ b/mysql-test/main/analyze_stmt_orderby.result @@ -522,8 +522,11 @@ ANALYZE "buffer_size": "65", "join_type": "BNL", "attached_condition": "t3.a = t0.a", + "r_loops": 10, "r_filtered": 10, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 10 } } ] @@ -612,8 +615,11 @@ ANALYZE "buffer_size": "119", "join_type": "BNL", "attached_condition": "t5.a = t6.a", + "r_loops": 4, "r_filtered": 21.42857143, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 7 } } ] diff --git a/mysql-test/main/bootstrap.result b/mysql-test/main/bootstrap.result index fd9b4726cb6..cfff13136d6 100644 --- a/mysql-test/main/bootstrap.result +++ b/mysql-test/main/bootstrap.result @@ -1,15 +1,28 @@ -drop table if exists t1; +# +# test mysqld in bootstrap mode +# +# +# Check that --bootstrap reads from stdin +# # Kill the server # restart drop table t1; +# +# Check that --bootstrap of file with SQL error returns error +# # Kill the server # restart drop table t1; ERROR 42S02: Unknown table 'test.t1' +# +# Bootstrap with a large thd->net.max_packet +# # Kill the server # restart drop table t1; -End of 5.1 tests +# +# End of 5.1 tests +# # # Bug #11766306: 59393: HAVE_INNODB=YES WHEN MYSQLD # STARTED WITH --SKIP-INNODB @@ -18,9 +31,23 @@ SELECT 'bug' as '' FROM INFORMATION_SCHEMA.ENGINES WHERE engine='innodb' and SUPPORT='YES'; # Kill the server +# +# MDEV-13063 Server crashes in intern_plugin_lock or assertion `plugin_ptr->ref_count == 1' fails in plugin_init +# +# +# MDEV-19349 mysql_install_db: segfault at tmp_file_prefix check +# # restart -End of 5.5 tests +# +# End of 5.5 tests +# +# +# Check that --bootstrap can install and uninstall plugins +# # Kill the server +# +# Check that installed plugins are *not* automatically loaded in --bootstrap +# # restart flush tables; show create table t1; @@ -35,6 +62,18 @@ EXAMPLE ha_example.so truncate table mysql.plugin; # Kill the server # +# MDEV-9969 mysql_install_db error processing ignore_db_dirs. +# +# +# MDEV-13397 MariaDB upgrade fail when using default_time_zone +# +# +# MDEV-30818 invalid ssl prevents bootstrap +# +# +# End of 10.3 tests +# +# # MDEV-28782 mariadb-tzinfo-to-sql to work in bootstrap mode # # diff --git a/mysql-test/main/bootstrap.test b/mysql-test/main/bootstrap.test index f7bddf23408..d7cc8e36d56 100644 --- a/mysql-test/main/bootstrap.test +++ b/mysql-test/main/bootstrap.test @@ -1,17 +1,20 @@ +--echo # +--echo # test mysqld in bootstrap mode +--echo # --source include/not_embedded.inc -# -# test mysqld in bootstrap mode -# ---disable_warnings -drop table if exists t1; ---enable_warnings +--source include/have_example_plugin.inc + +--let test_bootstrap=$MYSQLTEST_VARDIR/tmp/test_bootstrap.sql +--write_file $test_bootstrap +use test; +EOF # Add the datadir to the bootstrap command let $MYSQLD_DATADIR= `select @@datadir`; let $MYSQLD_BOOTSTRAP_CMD= $MYSQLD_BOOTSTRAP_CMD --datadir=$MYSQLD_DATADIR --tmpdir=$MYSQL_TMP_DIR --default-storage-engine=MyISAM --loose-skip-innodb --plugin-maturity=unknown; -# -# Check that --bootstrap reads from stdin -# +--echo # +--echo # Check that --bootstrap reads from stdin +--echo # --write_file $MYSQLTEST_VARDIR/tmp/bootstrap_test.sql use test; CREATE TABLE t1(a int); @@ -21,9 +24,9 @@ EOF --source include/start_mysqld.inc drop table t1; remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_test.sql; -# -# Check that --bootstrap of file with SQL error returns error -# +--echo # +--echo # Check that --bootstrap of file with SQL error returns error +--echo # --write_file $MYSQLTEST_VARDIR/tmp/bootstrap_error.sql use test; CREATE TABLE t1; @@ -37,9 +40,9 @@ EOF drop table t1; remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_error.sql; -# -# Bootstrap with a large thd->net.max_packet -# +--echo # +--echo # Bootstrap with a large thd->net.max_packet +--echo # --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; @@ -51,7 +54,9 @@ remove_file $MYSQLTEST_VARDIR/tmp/long_query.sql; --source include/start_mysqld.inc drop table t1; ---echo End of 5.1 tests +--echo # +--echo # End of 5.1 tests +--echo # --echo # --echo # Bug #11766306: 59393: HAVE_INNODB=YES WHEN MYSQLD @@ -63,29 +68,25 @@ SELECT 'bug' as '' FROM INFORMATION_SCHEMA.ENGINES WHERE engine='innodb' and SUPPORT='YES'; --source include/kill_mysqld.inc -# -# MDEV-13063 Server crashes in intern_plugin_lock or assertion `plugin_ptr->ref_count == 1' fails in plugin_init -# +--echo # +--echo # MDEV-13063 Server crashes in intern_plugin_lock or assertion `plugin_ptr->ref_count == 1' fails in plugin_init +--echo # --error 1 --exec $MYSQLD_BOOTSTRAP_CMD --myisam_recover_options=NONE -# -# MDEV-19349 mysql_install_db: segfault at tmp_file_prefix check -# ---write_file $MYSQLTEST_VARDIR/tmp/1 -use test; -EOF ---exec $MYSQLD_BOOTSTRAP_CMD < $MYSQLTEST_VARDIR/tmp/1 >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1 ---remove_file $MYSQLTEST_VARDIR/tmp/1 +--echo # +--echo # MDEV-19349 mysql_install_db: segfault at tmp_file_prefix check +--echo # +--exec $MYSQLD_BOOTSTRAP_CMD < $test_bootstrap >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1 --source include/start_mysqld.inc ---echo End of 5.5 tests +--echo # +--echo # End of 5.5 tests +--echo # ---source include/not_windows_embedded.inc ---source include/have_example_plugin.inc -# -# Check that --bootstrap can install and uninstall plugins -# +--echo # +--echo # Check that --bootstrap can install and uninstall plugins +--echo # let $PLUGIN_DIR=`select @@plugin_dir`; --source include/kill_mysqld.inc --write_file $MYSQLTEST_VARDIR/tmp/install_plugin.sql @@ -95,9 +96,9 @@ EOF --exec $MYSQLD_BOOTSTRAP_CMD --plugin-dir=$PLUGIN_DIR < $MYSQLTEST_VARDIR/tmp/install_plugin.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1 --remove_file $MYSQLTEST_VARDIR/tmp/install_plugin.sql -# -# Check that installed plugins are *not* automatically loaded in --bootstrap -# +--echo # +--echo # Check that installed plugins are *not* automatically loaded in --bootstrap +--echo # --write_file $MYSQLTEST_VARDIR/tmp/bootstrap_plugins.sql SET SQL_MODE=""; use test; @@ -113,25 +114,25 @@ drop table t1; select * from mysql.plugin; truncate table mysql.plugin; - -# -# MDEV-9969 mysql_install_db error processing ignore_db_dirs. -# ---write_file $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql -use test; -EOF --source include/kill_mysqld.inc ---exec $MYSQLD_BOOTSTRAP_CMD --ignore-db-dirs='some_dir' --ignore-db-dirs='some_dir' < $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1 ---remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql +--echo # +--echo # MDEV-9969 mysql_install_db error processing ignore_db_dirs. +--echo # +--exec $MYSQLD_BOOTSTRAP_CMD --ignore-db-dirs='some_dir' --ignore-db-dirs='some_dir' < $test_bootstrap >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1 -# -# MDEV-13397 MariaDB upgrade fail when using default_time_zone -# ---write_file $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql -use test; -EOF ---exec $MYSQLD_BOOTSTRAP_CMD --default-time-zone=Europe/Moscow < $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1 ---remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_9969.sql +--echo # +--echo # MDEV-13397 MariaDB upgrade fail when using default_time_zone +--echo # +--exec $MYSQLD_BOOTSTRAP_CMD --default-time-zone=Europe/Moscow < $test_bootstrap >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1 + +--echo # +--echo # MDEV-30818 invalid ssl prevents bootstrap +--echo # +--exec $MYSQLD_BOOTSTRAP_CMD --ssl-ca=/dev/nonexistent < $test_bootstrap >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1 + +--echo # +--echo # End of 10.3 tests +--echo # --echo # --echo # MDEV-28782 mariadb-tzinfo-to-sql to work in bootstrap mode @@ -160,3 +161,4 @@ EOF # restore --source include/start_mysqld.inc +--remove_file $test_bootstrap diff --git a/mysql-test/main/cli_options_force_protocol_not_win.result b/mysql-test/main/cli_options_force_protocol_not_win.result index 20b12eb2cc0..46ee29dc509 100644 --- a/mysql-test/main/cli_options_force_protocol_not_win.result +++ b/mysql-test/main/cli_options_force_protocol_not_win.result @@ -4,21 +4,19 @@ # # The following group of tests should produce no warnings # -# exec MYSQL --host=localhost -e "status" 2>&1 | grep "Connection:\|WARNING:" +# exec MYSQL --host=localhost -e "status" 2>&1 | grep "Connection:" Connection: Localhost via UNIX socket -# exec MYSQL --port=MASTER_MYPORT --protocol=tcp -e "status" 2>&1 | grep "Connection:\|WARNING:" +# exec MYSQL --port=MASTER_MYPORT --protocol=tcp -e "status" 2>&1 | grep "Connection:" Connection: localhost via TCP/IP -# exec MYSQL --host=localhost --port=MASTER_MYPORT --protocol=socket -e "status" 2>&1 | grep "Connection:\|WARNING:" +# exec MYSQL --host=localhost --port=MASTER_MYPORT --protocol=socket -e "status" 2>&1 | grep "Connection:" Connection: Localhost via UNIX socket -# exec MYSQL --host=127.0.0.1 --port=MASTER_MYPORT -e "status" 2>&1 | grep "Connection:\|WARNING:" +# exec MYSQL --host=127.0.0.1 --port=MASTER_MYPORT -e "status" 2>&1 | grep "Connection:" Connection: 127.0.0.1 via TCP/IP -# exec MYSQL --host=localhost --socket=MASTER_MYSOCK --port=MASTER_MYPORT -e "status" 2>&1 | grep "Connection:\|WARNING:" +# exec MYSQL --host=localhost --socket=MASTER_MYSOCK --port=MASTER_MYPORT -e "status" 2>&1 | grep "Connection:" +Connection: localhost via TCP/IP +# exec MYSQL --host=localhost --port=MASTER_MYPORT --socket=MASTER_MYSOCK -e "status" 2>&1 | grep "Connection:" Connection: Localhost via UNIX socket -# exec MYSQL --host=localhost --socket=MASTER_MYSOCK -e "status" 2>&1 | grep "Connection:\|WARNING:" +# exec MYSQL --host=localhost --socket=MASTER_MYSOCK -e "status" 2>&1 | grep "Connection:" Connection: Localhost via UNIX socket -# -# The remaining tests should produce warnings -# -# exec MYSQL --host=localhost --port=MASTER_MYPORT -e "status" 2>&1 | grep "Connection:\|WARNING:" -WARNING: Forcing protocol to TCP due to option specification. Please explicitly state intended protocol. +# exec MYSQL --host=localhost --port=MASTER_MYPORT -e "status" 2>&1 | grep "Connection:" Connection: localhost via TCP/IP diff --git a/mysql-test/main/cli_options_force_protocol_not_win.test b/mysql-test/main/cli_options_force_protocol_not_win.test index a3c495f26ee..a92f6b93c4d 100644 --- a/mysql-test/main/cli_options_force_protocol_not_win.test +++ b/mysql-test/main/cli_options_force_protocol_not_win.test @@ -10,28 +10,26 @@ --echo # The following group of tests should produce no warnings --echo # ---echo # exec MYSQL --host=localhost -e "status" 2>&1 | grep "Connection:\|WARNING:" ---exec $MYSQL --host=localhost -e "status" 2>&1 | grep "Connection:\|WARNING:" +--echo # exec MYSQL --host=localhost -e "status" 2>&1 | grep "Connection:" +--exec $MYSQL --host=localhost -e "status" 2>&1 | grep "Connection:" ---echo # exec MYSQL --port=MASTER_MYPORT --protocol=tcp -e "status" 2>&1 | grep "Connection:\|WARNING:" ---exec $MYSQL --port=$MASTER_MYPORT --protocol=tcp -e "status" 2>&1 | grep "Connection:\|WARNING:" +--echo # exec MYSQL --port=MASTER_MYPORT --protocol=tcp -e "status" 2>&1 | grep "Connection:" +--exec $MYSQL --port=$MASTER_MYPORT --protocol=tcp -e "status" 2>&1 | grep "Connection:" ---echo # exec MYSQL --host=localhost --port=MASTER_MYPORT --protocol=socket -e "status" 2>&1 | grep "Connection:\|WARNING:" ---exec $MYSQL --host=localhost --port=$MASTER_MYPORT --protocol=socket -e "status" 2>&1 | grep "Connection:\|WARNING:" +--echo # exec MYSQL --host=localhost --port=MASTER_MYPORT --protocol=socket -e "status" 2>&1 | grep "Connection:" +--exec $MYSQL --host=localhost --port=$MASTER_MYPORT --protocol=socket -e "status" 2>&1 | grep "Connection:" ---echo # exec MYSQL --host=127.0.0.1 --port=MASTER_MYPORT -e "status" 2>&1 | grep "Connection:\|WARNING:" ---exec $MYSQL --host=127.0.0.1 --port=$MASTER_MYPORT -e "status" 2>&1 | grep "Connection:\|WARNING:" +--echo # exec MYSQL --host=127.0.0.1 --port=MASTER_MYPORT -e "status" 2>&1 | grep "Connection:" +--exec $MYSQL --host=127.0.0.1 --port=$MASTER_MYPORT -e "status" 2>&1 | grep "Connection:" ---echo # exec MYSQL --host=localhost --socket=MASTER_MYSOCK --port=MASTER_MYPORT -e "status" 2>&1 | grep "Connection:\|WARNING:" ---exec $MYSQL --host=localhost --socket=$MASTER_MYSOCK --port=$MASTER_MYPORT -e "status" 2>&1 | grep "Connection:\|WARNING:" +--echo # exec MYSQL --host=localhost --socket=MASTER_MYSOCK --port=MASTER_MYPORT -e "status" 2>&1 | grep "Connection:" +--exec $MYSQL --host=localhost --socket=$MASTER_MYSOCK --port=$MASTER_MYPORT -e "status" 2>&1 | grep "Connection:" ---echo # exec MYSQL --host=localhost --socket=MASTER_MYSOCK -e "status" 2>&1 | grep "Connection:\|WARNING:" ---exec $MYSQL --host=localhost --socket=$MASTER_MYSOCK -e "status" 2>&1 | grep "Connection:\|WARNING:" +--echo # exec MYSQL --host=localhost --port=MASTER_MYPORT --socket=MASTER_MYSOCK -e "status" 2>&1 | grep "Connection:" +--exec $MYSQL --host=localhost --port=MASTER_MYPORT --socket=$MASTER_MYSOCK -e "status" 2>&1 | grep "Connection:" +--echo # exec MYSQL --host=localhost --socket=MASTER_MYSOCK -e "status" 2>&1 | grep "Connection:" +--exec $MYSQL --host=localhost --socket=$MASTER_MYSOCK -e "status" 2>&1 | grep "Connection:" ---echo # ---echo # The remaining tests should produce warnings ---echo # - ---echo # exec MYSQL --host=localhost --port=MASTER_MYPORT -e "status" 2>&1 | grep "Connection:\|WARNING:" ---exec $MYSQL --host=localhost --port=$MASTER_MYPORT -e "status" 2>&1 | grep "Connection:\|WARNING:" +--echo # exec MYSQL --host=localhost --port=MASTER_MYPORT -e "status" 2>&1 | grep "Connection:" +--exec $MYSQL --host=localhost --port=$MASTER_MYPORT -e "status" 2>&1 | grep "Connection:" diff --git a/mysql-test/main/cli_options_force_protocol_win.result b/mysql-test/main/cli_options_force_protocol_win.result index 4fffc2a4837..eedfde4f1de 100644 --- a/mysql-test/main/cli_options_force_protocol_win.result +++ b/mysql-test/main/cli_options_force_protocol_win.result @@ -1,24 +1,17 @@ # # MDEV-14974: --port ignored for --host=localhost # -# -# The following group of tests should produce no warnings -# -# exec MYSQL --host=localhost -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" +# exec MYSQL --host=localhost -e "status" 2>&1 | findstr /c:"Connection:" Connection: localhost via TCP/IP -# exec MYSQL --host=localhost --port=MASTER_MYPORT -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" +# exec MYSQL --host=localhost --port=MASTER_MYPORT -e "status" 2>&1 | findstr /c:"Connection:" Connection: localhost via TCP/IP -# exec MYSQL --host=localhost --port=MASTER_MYPORT --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" +# exec MYSQL --host=localhost --port=MASTER_MYPORT --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" Connection: localhost via TCP/IP -# exec MYSQL --host=localhost --protocol=pipe -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" -Connection: localhost via named pipe -# exec MYSQL --host=localhost -W -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" -Connection: localhost via named pipe -# exec MYSQL --host=localhost -W --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" +# exec MYSQL --host=localhost --protocol=pipe -e "status" 2>&1 | findstr /c:"Connection:" Connection: localhost via named pipe -# -# The remaining tests should produce warnings -# -# exec MYSQL --host=localhost --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" -WARNING: Forcing protocol to PIPE due to option specification. Please explicitly state intended protocol. +# exec MYSQL --host=localhost -W -e "status" 2>&1 | findstr /c:"Connection:" Connection: localhost via named pipe +# exec MYSQL --host=localhost -W --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" +Connection: localhost via TCP/IP +# exec MYSQL --host=localhost --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" +Connection: localhost via TCP/IP diff --git a/mysql-test/main/cli_options_force_protocol_win.test b/mysql-test/main/cli_options_force_protocol_win.test index 54fbb78e5dc..63024f3b620 100644 --- a/mysql-test/main/cli_options_force_protocol_win.test +++ b/mysql-test/main/cli_options_force_protocol_win.test @@ -5,33 +5,23 @@ --source include/not_embedded.inc --source include/windows.inc +--echo # exec MYSQL --host=localhost -e "status" 2>&1 | findstr /c:"Connection:" +--exec $MYSQL --host=localhost -e "status" 2>&1 | findstr /c:"Connection:" ---echo # ---echo # The following group of tests should produce no warnings ---echo # - ---echo # exec MYSQL --host=localhost -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" ---exec $MYSQL --host=localhost -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" - ---echo # exec MYSQL --host=localhost --port=MASTER_MYPORT -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" ---exec $MYSQL --host=localhost --port=$MASTER_MYPORT -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" +--echo # exec MYSQL --host=localhost --port=MASTER_MYPORT -e "status" 2>&1 | findstr /c:"Connection:" +--exec $MYSQL --host=localhost --port=$MASTER_MYPORT -e "status" 2>&1 | findstr /c:"Connection:" ---echo # exec MYSQL --host=localhost --port=MASTER_MYPORT --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" ---exec $MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" +--echo # exec MYSQL --host=localhost --port=MASTER_MYPORT --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" +--exec $MYSQL --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" ---echo # exec MYSQL --host=localhost --protocol=pipe -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" ---exec $MYSQL --host=localhost --protocol=pipe -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" +--echo # exec MYSQL --host=localhost --protocol=pipe -e "status" 2>&1 | findstr /c:"Connection:" +--exec $MYSQL --host=localhost --protocol=pipe -e "status" 2>&1 | findstr /c:"Connection:" ---echo # exec MYSQL --host=localhost -W -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" ---exec $MYSQL --host=localhost -W -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" +--echo # exec MYSQL --host=localhost -W -e "status" 2>&1 | findstr /c:"Connection:" +--exec $MYSQL --host=localhost -W -e "status" 2>&1 | findstr /c:"Connection:" ---echo # exec MYSQL --host=localhost -W --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" ---exec $MYSQL --host=localhost -W --socket=$MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" - - ---echo # ---echo # The remaining tests should produce warnings ---echo # +--echo # exec MYSQL --host=localhost -W --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" +--exec $MYSQL --host=localhost -W --socket=$MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" ---echo # exec MYSQL --host=localhost --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" ---exec $MYSQL --host=localhost --socket=$MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" /c:"WARNING:" +--echo # exec MYSQL --host=localhost --socket=MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" +--exec $MYSQL --host=localhost --socket=$MASTER_MYSOCK -e "status" 2>&1 | findstr /c:"Connection:" diff --git a/mysql-test/main/ctype_ldml.result b/mysql-test/main/ctype_ldml.result index a23e835d1fa..31508fcd1b1 100644 --- a/mysql-test/main/ctype_ldml.result +++ b/mysql-test/main/ctype_ldml.result @@ -3074,6 +3074,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -3091,6 +3096,10 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 49 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B0AF E2B0AF â°¯ +2C5F E2B19F E2B19F ⱟ +A7C0 EA9F80 EA9F80 Ꟁ +A7C1 EA9F81 EA9F81 êŸ DROP TABLE case_folding; # # End of 10.3 tests @@ -3267,6 +3276,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -3284,6 +3298,39 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 49 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B19F E2B0AF â°¯ +2C5F E2B19F E2B0AF ⱟ +A7C0 EA9F81 EA9F80 Ꟁ +A7C1 EA9F81 EA9F80 êŸ +DROP TABLE case_folding; +# +# MDEV-30577 Case folding for uca1400 collations is not up to date +# +SET NAMES utf8mb4 COLLATE utf8mb4_uca1400_test01_as_ci; +CREATE OR REPLACE TABLE case_folding AS SELECT 0 AS code, SPACE(32) AS c, SPACE(64) AS comment LIMIT 0; +SHOW CREATE TABLE case_folding; +Table Create Table +case_folding CREATE TABLE `case_folding` ( + `code` int(1) NOT NULL, + `c` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_test01_as_ci DEFAULT NULL, + `comment` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_test01_as_ci DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO case_folding (code, comment) VALUES (0x10595, 'VITHKUQI CAPITAL LETTER ZE (Unicode-14.0)'); +INSERT INTO case_folding (code, comment) VALUES (0x105BC, 'VITHKUQI SMALL LETTER ZE (Unicode-14.0)'); +INSERT INTO case_folding (code, comment) VALUES (0x1E921, 'ADLAM CAPITAL LETTER SHA (Unicode-9.0)'); +INSERT INTO case_folding (code, comment) VALUES (0x1E943, 'ADLAM SMALL LETTER SHA (Unicode-9.0)'); +UPDATE case_folding SET c=CHAR(code USING utf32); +SELECT +HEX(CONVERT(c USING utf32)) AS ch, +HEX(CONVERT(LOWER(c) USING utf32)) AS cl, +HEX(CONVERT(UPPER(c) USING utf32)) AS cu, +comment +FROM case_folding ORDER BY BINARY(c); +ch cl cu comment +00010595 000105BC 00010595 VITHKUQI CAPITAL LETTER ZE (Unicode-14.0) +000105BC 000105BC 00010595 VITHKUQI SMALL LETTER ZE (Unicode-14.0) +0001E921 0001E943 0001E921 ADLAM CAPITAL LETTER SHA (Unicode-9.0) +0001E943 0001E943 0001E921 ADLAM SMALL LETTER SHA (Unicode-9.0) DROP TABLE case_folding; # # End of 10.10 tests diff --git a/mysql-test/main/ctype_ldml.test b/mysql-test/main/ctype_ldml.test index 6336a1d0f5f..9189630e5a3 100644 --- a/mysql-test/main/ctype_ldml.test +++ b/mysql-test/main/ctype_ldml.test @@ -705,5 +705,12 @@ SET NAMES utf8mb4 COLLATE utf8mb4_uca1400_test01_as_ci; --source include/ctype_casefolding.inc --echo # +--echo # MDEV-30577 Case folding for uca1400 collations is not up to date +--echo # + +SET NAMES utf8mb4 COLLATE utf8mb4_uca1400_test01_as_ci; +--source include/ctype_casefolding_supplementary.inc + +--echo # --echo # End of 10.10 tests --echo # diff --git a/mysql-test/main/ctype_uca_partitions.result b/mysql-test/main/ctype_uca_partitions.result index 677b68e2387..486e848e191 100644 --- a/mysql-test/main/ctype_uca_partitions.result +++ b/mysql-test/main/ctype_uca_partitions.result @@ -84,3 +84,43 @@ O P Y DROP TABLE t1; +# +# Start of 10.4 tests +# +# +# MDEV-30072 Wrong ORDER BY for a partitioned prefix key + NOPAD +# +SET NAMES utf8mb4; +CREATE TABLE t1 +( +id INT, +data VARCHAR(20), +KEY data_id (data,id) +) COLLATE utf8mb3_unicode_nopad_ci ENGINE=MyISAM +PARTITION BY RANGE COLUMNS (id) +( +PARTITION p10 VALUES LESS THAN (20), +PARTITION p20 VALUES LESS THAN MAXVALUE +); +INSERT INTO t1 VALUES (30, 'ss '), (10, 'ß '); +SELECT id FROM t1 WHERE data='ss ' ORDER BY id; +id +10 +30 +SELECT id FROM t1 WHERE data='ss ' ORDER BY id DESC; +id +30 +10 +ALTER TABLE t1 DROP KEY data_id, ADD KEY data_id2(data(10),id); +SELECT id FROM t1 WHERE data='ss ' ORDER BY id; +id +10 +30 +SELECT id FROM t1 WHERE data='ss ' ORDER BY id DESC; +id +30 +10 +DROP TABLE t1; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/ctype_uca_partitions.test b/mysql-test/main/ctype_uca_partitions.test index 5734bb52008..81f1a091574 100644 --- a/mysql-test/main/ctype_uca_partitions.test +++ b/mysql-test/main/ctype_uca_partitions.test @@ -36,3 +36,35 @@ SELECT * FROM t1 PARTITION (p0) ORDER BY c1; SELECT * FROM t1 PARTITION (p1) ORDER BY c1; SELECT * FROM t1 PARTITION (p2) ORDER BY c1; DROP TABLE t1; + +--echo # +--echo # Start of 10.4 tests +--echo # + +--echo # +--echo # MDEV-30072 Wrong ORDER BY for a partitioned prefix key + NOPAD +--echo # + +SET NAMES utf8mb4; +CREATE TABLE t1 +( + id INT, + data VARCHAR(20), + KEY data_id (data,id) +) COLLATE utf8mb3_unicode_nopad_ci ENGINE=MyISAM +PARTITION BY RANGE COLUMNS (id) +( + PARTITION p10 VALUES LESS THAN (20), + PARTITION p20 VALUES LESS THAN MAXVALUE +); +INSERT INTO t1 VALUES (30, 'ss '), (10, 'ß '); +SELECT id FROM t1 WHERE data='ss ' ORDER BY id; +SELECT id FROM t1 WHERE data='ss ' ORDER BY id DESC; +ALTER TABLE t1 DROP KEY data_id, ADD KEY data_id2(data(10),id); +SELECT id FROM t1 WHERE data='ss ' ORDER BY id; +SELECT id FROM t1 WHERE data='ss ' ORDER BY id DESC; +DROP TABLE t1; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/main/ctype_ucs.result b/mysql-test/main/ctype_ucs.result index 987f1b704fd..f4ca4089e55 100644 --- a/mysql-test/main/ctype_ucs.result +++ b/mysql-test/main/ctype_ucs.result @@ -6439,6 +6439,23 @@ IS_IPV4('10.0.0.1') 1 SET NAMES utf8; # +# MDEV-30746 Regression in ucs2_general_mysql500_ci +# +SET NAMES utf8mb3; +CREATE TABLE t1 (a VARCHAR(32) CHARACTER SET ucs2 COLLATE ucs2_general_mysql500_ci); +INSERT INTO t1 VALUES ('s'),('z'),(_latin1 0xDF); +SELECT GROUP_CONCAT(a) FROM t1 GROUP BY a ORDER BY a; +GROUP_CONCAT(a) +s +z +ß +SELECT a, HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a; +a HEX(a) HEX(WEIGHT_STRING(a)) +s 0073 0053 +z 007A 005A +ß 00DF 00DF +DROP TABLE t1; +# # End of 10.4 tests # # diff --git a/mysql-test/main/ctype_ucs.test b/mysql-test/main/ctype_ucs.test index 20e2ea3908d..b77636507dd 100644 --- a/mysql-test/main/ctype_ucs.test +++ b/mysql-test/main/ctype_ucs.test @@ -1141,6 +1141,18 @@ SELECT IS_IPV4('10.0.0.1'); SET NAMES utf8; --echo # +--echo # MDEV-30746 Regression in ucs2_general_mysql500_ci +--echo # + +SET NAMES utf8mb3; +CREATE TABLE t1 (a VARCHAR(32) CHARACTER SET ucs2 COLLATE ucs2_general_mysql500_ci); +INSERT INTO t1 VALUES ('s'),('z'),(_latin1 0xDF); +SELECT GROUP_CONCAT(a) FROM t1 GROUP BY a ORDER BY a; +SELECT a, HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a; +DROP TABLE t1; + + +--echo # --echo # End of 10.4 tests --echo # diff --git a/mysql-test/main/ctype_ucs2_general_mysql500_ci_ws.result b/mysql-test/main/ctype_ucs2_general_mysql500_ci_ws.result index 3679169122e..40ba714560f 100644 --- a/mysql-test/main/ctype_ucs2_general_mysql500_ci_ws.result +++ b/mysql-test/main/ctype_ucs2_general_mysql500_ci_ws.result @@ -24,7 +24,7 @@ SUM(codepoint_hex4=HEX(WEIGHT_STRING(c))) AS count_bmp_weight_is_codepoint, SUM(codepoint_hex4<>HEX(WEIGHT_STRING(c))) AS count_bmp_weight_is_not_codepoint FROM v_bmp; count_bmp_weight_is_codepoint count_bmp_weight_is_not_codepoint -64428 1108 +64429 1107 SELECT codepoint_hex4,HEX(WEIGHT_STRING(c)) FROM v_bmp WHERE codepoint_hex4<>HEX(WEIGHT_STRING(c)); @@ -82,7 +82,6 @@ codepoint_hex4 HEX(WEIGHT_STRING(c)) 00DB 0055 00DC 0055 00DD 0059 -00DF 0053 00E0 0041 00E1 0041 00E2 0041 diff --git a/mysql-test/main/ctype_upgrade.result b/mysql-test/main/ctype_upgrade.result index 30684df4023..500b013a5a1 100644 --- a/mysql-test/main/ctype_upgrade.result +++ b/mysql-test/main/ctype_upgrade.result @@ -603,3 +603,56 @@ DROP TABLE maria050313_utf8_croatian_ci; DROP TABLE maria050533_xxx_croatian_ci; DROP TABLE maria100004_xxx_croatian_ci; DROP TABLE mysql050614_xxx_croatian_ci; +# +# Start of 10.4 tests +# +# +# MDEV-30746 Regression in ucs2_general_mysql500_ci +# +SET NAMES utf8mb3; +SHOW CREATE TABLE t1; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.t1` FORCE" or dump/reload to fix it! +SELECT * FROM t1; +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.t1` FORCE" or dump/reload to fix it! +SELECT * FROM t1 IGNORE KEY(a); +ERROR HY000: Table rebuild required. Please do "ALTER TABLE `test.t1` FORCE" or dump/reload to fix it! +CHECK TABLE t1; +Table Op Msg_type Msg_text +test.t1 check error Upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it! +REPAIR TABLE t1; +Table Op Msg_type Msg_text +test.t1 repair status OK +SELECT a, HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a; +a HEX(a) HEX(WEIGHT_STRING(a)) +s 0073 0053 +z 007A 005A +ß 00DF 00DF +SELECT a, HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 FORCE KEY(a) ORDER BY a; +a HEX(a) HEX(WEIGHT_STRING(a)) +s 0073 0053 +z 007A 005A +ß 00DF 00DF +SELECT a, HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 IGNORE KEY(a) ORDER BY a; +a HEX(a) HEX(WEIGHT_STRING(a)) +s 0073 0053 +z 007A 005A +ß 00DF 00DF +SELECT GROUP_CONCAT(a) FROM t1 GROUP BY a ORDER BY a; +GROUP_CONCAT(a) +s +z +ß +SELECT GROUP_CONCAT(a) FROM t1 IGNORE KEY(a) GROUP BY a ORDER BY a; +GROUP_CONCAT(a) +s +z +ß +SELECT GROUP_CONCAT(a) FROM t1 FORCE KEY(a) GROUP BY a ORDER BY a; +GROUP_CONCAT(a) +s +z +ß +DROP TABLE t1; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/ctype_upgrade.test b/mysql-test/main/ctype_upgrade.test index f2fdc36554e..f28d23eeae9 100644 --- a/mysql-test/main/ctype_upgrade.test +++ b/mysql-test/main/ctype_upgrade.test @@ -203,3 +203,38 @@ DROP TABLE maria050313_utf8_croatian_ci; DROP TABLE maria050533_xxx_croatian_ci; DROP TABLE maria100004_xxx_croatian_ci; DROP TABLE mysql050614_xxx_croatian_ci; + + +--echo # +--echo # Start of 10.4 tests +--echo # + +--echo # +--echo # MDEV-30746 Regression in ucs2_general_mysql500_ci +--echo # + +SET NAMES utf8mb3; + +copy_file std_data/ctype_upgrade/mariadb100428_ucs2_general_ci.frm $MYSQLD_DATADIR/test/t1.frm; +copy_file std_data/ctype_upgrade/mariadb100428_ucs2_general_ci.MYD $MYSQLD_DATADIR/test/t1.MYD; +copy_file std_data/ctype_upgrade/mariadb100428_ucs2_general_ci.MYI $MYSQLD_DATADIR/test/t1.MYI; + +--error ER_TABLE_NEEDS_REBUILD +SHOW CREATE TABLE t1; +--error ER_TABLE_NEEDS_REBUILD +SELECT * FROM t1; +--error ER_TABLE_NEEDS_REBUILD +SELECT * FROM t1 IGNORE KEY(a); +CHECK TABLE t1; +REPAIR TABLE t1; +SELECT a, HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 ORDER BY a; +SELECT a, HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 FORCE KEY(a) ORDER BY a; +SELECT a, HEX(a), HEX(WEIGHT_STRING(a)) FROM t1 IGNORE KEY(a) ORDER BY a; +SELECT GROUP_CONCAT(a) FROM t1 GROUP BY a ORDER BY a; +SELECT GROUP_CONCAT(a) FROM t1 IGNORE KEY(a) GROUP BY a ORDER BY a; +SELECT GROUP_CONCAT(a) FROM t1 FORCE KEY(a) GROUP BY a ORDER BY a; +DROP TABLE t1; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/main/ctype_utf8_uca.result b/mysql-test/main/ctype_utf8_uca.result index ecd2daa5272..97bdadbb97b 100644 --- a/mysql-test/main/ctype_utf8_uca.result +++ b/mysql-test/main/ctype_utf8_uca.result @@ -618,6 +618,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -635,6 +640,10 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 49 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B0AF E2B0AF â°¯ +2C5F E2B19F E2B19F ⱟ +A7C0 EA9F80 EA9F80 Ꟁ +A7C1 EA9F81 EA9F81 êŸ DROP TABLE case_folding; SET NAMES utf8mb3 COLLATE utf8mb3_turkish_ci /*Unicode-4.0 folding, with Turkish mapping for I */; CREATE OR REPLACE TABLE case_folding AS SELECT 0 AS code, SPACE(32) AS c LIMIT 0; @@ -661,6 +670,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -678,6 +692,10 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 C4B0 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B0AF E2B0AF â°¯ +2C5F E2B19F E2B19F ⱟ +A7C0 EA9F80 EA9F80 Ꟁ +A7C1 EA9F81 EA9F81 êŸ DROP TABLE case_folding; SET NAMES utf8mb3 COLLATE utf8mb3_unicode_520_ci; CREATE OR REPLACE TABLE case_folding AS SELECT 0 AS code, SPACE(32) AS c LIMIT 0; @@ -704,6 +722,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -721,6 +744,10 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 49 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B0AF E2B0AF â°¯ +2C5F E2B19F E2B19F ⱟ +A7C0 EA9F80 EA9F80 Ꟁ +A7C1 EA9F81 EA9F81 êŸ DROP TABLE case_folding; SET NAMES utf8mb3 COLLATE utf8mb3_unicode_520_nopad_ci; CREATE OR REPLACE TABLE case_folding AS SELECT 0 AS code, SPACE(32) AS c LIMIT 0; @@ -747,6 +774,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -764,6 +796,10 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 49 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B0AF E2B0AF â°¯ +2C5F E2B19F E2B19F ⱟ +A7C0 EA9F80 EA9F80 Ꟁ +A7C1 EA9F81 EA9F81 êŸ DROP TABLE case_folding; SET NAMES utf8mb3 COLLATE utf8mb3_myanmar_ci; CREATE OR REPLACE TABLE case_folding AS SELECT 0 AS code, SPACE(32) AS c LIMIT 0; @@ -790,6 +826,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -807,6 +848,10 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 49 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B0AF E2B0AF â°¯ +2C5F E2B19F E2B19F ⱟ +A7C0 EA9F80 EA9F80 Ꟁ +A7C1 EA9F81 EA9F81 êŸ DROP TABLE case_folding; SET NAMES utf8mb3 COLLATE utf8mb3_thai_520_w2; CREATE OR REPLACE TABLE case_folding AS SELECT 0 AS code, SPACE(32) AS c LIMIT 0; @@ -833,6 +878,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -850,11 +900,163 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 49 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B0AF E2B0AF â°¯ +2C5F E2B19F E2B19F ⱟ +A7C0 EA9F80 EA9F80 Ꟁ +A7C1 EA9F81 EA9F81 êŸ DROP TABLE case_folding; # # End of 10.3 tests # # +# Start of 10.4 tests +# +SET DEFAULT_STORAGE_ENGINE=MyISAM; +SET NAMES utf8mb3 COLLATE utf8mb3_unicode_nopad_ci; +# +# MDEV-30034 UNIQUE USING HASH accepts duplicate entries for tricky collations +# +EXECUTE IMMEDIATE REPLACE( +'CREATE TABLE t1 ( ' + ' a TEXT COLLATE <COLLATION>,' + 'UNIQUE(a(3)))', +'<COLLATION>', @@collation_connection); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_nopad_ci DEFAULT NULL, + UNIQUE KEY `a` (`a`(3)) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO t1 VALUES ('ss '); +INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/; +ERROR 23000: Duplicate entry 'ß ' for key 'a' +DROP TABLE t1; +EXECUTE IMMEDIATE REPLACE( +'CREATE TABLE t1 ( ' + ' a TEXT COLLATE <COLLATION>,' + 'UNIQUE(a(3)) USING HASH)', +'<COLLATION>', @@collation_connection); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` text CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_nopad_ci DEFAULT NULL, + UNIQUE KEY `a` (`a`(3)) USING HASH +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO t1 VALUES ('ss '); +INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/; +ERROR 23000: Duplicate entry 'ß ' for key 'a' +DROP TABLE t1; +EXECUTE IMMEDIATE REPLACE( +'CREATE TABLE t1 ( ' + ' a VARCHAR(2000) COLLATE <COLLATION>,' + 'UNIQUE(a(3)))', +'<COLLATION>', @@collation_connection); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(2000) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_nopad_ci DEFAULT NULL, + UNIQUE KEY `a` (`a`(3)) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO t1 VALUES ('ss '); +INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/; +ERROR 23000: Duplicate entry 'ß ' for key 'a' +DROP TABLE t1; +EXECUTE IMMEDIATE REPLACE( +'CREATE TABLE t1 ( ' + ' a VARCHAR(2000) COLLATE <COLLATION>,' + 'UNIQUE(a(3)) USING HASH)', +'<COLLATION>', @@collation_connection); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(2000) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_nopad_ci DEFAULT NULL, + UNIQUE KEY `a` (`a`(3)) USING HASH +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO t1 VALUES ('ss '); +INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/; +ERROR 23000: Duplicate entry 'ß ' for key 'a' +DROP TABLE t1; +EXECUTE IMMEDIATE REPLACE( +'CREATE TABLE t1 ( ' + ' a CHAR(20) COLLATE <COLLATION>,' + 'UNIQUE(a(3)) USING HASH)', +'<COLLATION>', @@collation_connection); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_nopad_ci DEFAULT NULL, + UNIQUE KEY `a` (`a`(3)) USING HASH +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO t1 VALUES ('ss '); +INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/; +DROP TABLE t1; +SET DEFAULT_STORAGE_ENGINE=HEAP; +# +# MDEV-30034 UNIQUE USING HASH accepts duplicate entries for tricky collations +# +EXECUTE IMMEDIATE REPLACE( +'CREATE TABLE t1 ( ' + ' a VARCHAR(2000) COLLATE <COLLATION>,' + 'UNIQUE(a(3)))', +'<COLLATION>', @@collation_connection); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(2000) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_nopad_ci DEFAULT NULL, + UNIQUE KEY `a` (`a`(3)) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO t1 VALUES ('ss '); +INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/; +ERROR 23000: Duplicate entry 'ß ' for key 'a' +DROP TABLE t1; +EXECUTE IMMEDIATE REPLACE( +'CREATE TABLE t1 ( ' + ' a VARCHAR(2000) COLLATE <COLLATION>,' + 'UNIQUE(a(3)) USING HASH)', +'<COLLATION>', @@collation_connection); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` varchar(2000) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_nopad_ci DEFAULT NULL, + UNIQUE KEY `a` (`a`(3)) USING HASH +) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO t1 VALUES ('ss '); +INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/; +ERROR 23000: Duplicate entry 'ß ' for key 'a' +DROP TABLE t1; +EXECUTE IMMEDIATE REPLACE( +'CREATE TABLE t1 ( ' + ' a CHAR(20) COLLATE <COLLATION>,' + 'UNIQUE(a(3)))', +'<COLLATION>', @@collation_connection); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_nopad_ci DEFAULT NULL, + UNIQUE KEY `a` (`a`(3)) +) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO t1 VALUES ('ss '); +INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/; +DROP TABLE t1; +EXECUTE IMMEDIATE REPLACE( +'CREATE TABLE t1 ( ' + ' a CHAR(20) COLLATE <COLLATION>,' + 'UNIQUE(a(3)) USING HASH)', +'<COLLATION>', @@collation_connection); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(20) CHARACTER SET utf8mb3 COLLATE utf8mb3_unicode_nopad_ci DEFAULT NULL, + UNIQUE KEY `a` (`a`(3)) USING HASH +) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO t1 VALUES ('ss '); +INSERT INTO t1 VALUES (_utf8mb3 0xC39F20)/*SZ+SPACE*/; +DROP TABLE t1; +SET DEFAULT_STORAGE_ENGINE=DEFAULT; +# +# End of 10.4 tests +# +# # Start of 10.10 tests # # @@ -1657,6 +1859,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -1674,6 +1881,10 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 49 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B19F E2B0AF â°¯ +2C5F E2B19F E2B0AF ⱟ +A7C0 EA9F81 EA9F80 Ꟁ +A7C1 EA9F81 EA9F80 êŸ DROP TABLE case_folding; # # End of 10.10 tests diff --git a/mysql-test/main/ctype_utf8_uca.test b/mysql-test/main/ctype_utf8_uca.test index 5abf9192511..6f89d646260 100644 --- a/mysql-test/main/ctype_utf8_uca.test +++ b/mysql-test/main/ctype_utf8_uca.test @@ -54,6 +54,24 @@ SET NAMES utf8mb3 COLLATE utf8mb3_thai_520_w2; --echo # End of 10.3 tests --echo # + +--echo # +--echo # Start of 10.4 tests +--echo # + +SET DEFAULT_STORAGE_ENGINE=MyISAM; +SET NAMES utf8mb3 COLLATE utf8mb3_unicode_nopad_ci; +--source include/ctype_nopad_prefix_unique.inc + +SET DEFAULT_STORAGE_ENGINE=HEAP; +--source include/ctype_nopad_prefix_unique.inc + +SET DEFAULT_STORAGE_ENGINE=DEFAULT; + +--echo # +--echo # End of 10.4 tests +--echo # + --echo # --echo # Start of 10.10 tests --echo # diff --git a/mysql-test/main/ctype_utf8mb4_uca.result b/mysql-test/main/ctype_utf8mb4_uca.result index 42de45c98a3..3cd25891119 100644 --- a/mysql-test/main/ctype_utf8mb4_uca.result +++ b/mysql-test/main/ctype_utf8mb4_uca.result @@ -6636,6 +6636,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -6653,6 +6658,10 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 49 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B0AF E2B0AF â°¯ +2C5F E2B19F E2B19F ⱟ +A7C0 EA9F80 EA9F80 Ꟁ +A7C1 EA9F81 EA9F81 êŸ DROP TABLE case_folding; SET NAMES utf8mb4 COLLATE utf8mb4_turkish_ci /*Unicode-4.0 folding with Turkish mapping for I */; CREATE OR REPLACE TABLE case_folding AS SELECT 0 AS code, SPACE(32) AS c LIMIT 0; @@ -6679,6 +6688,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -6696,6 +6710,10 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 C4B0 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B0AF E2B0AF â°¯ +2C5F E2B19F E2B19F ⱟ +A7C0 EA9F80 EA9F80 Ꟁ +A7C1 EA9F81 EA9F81 êŸ DROP TABLE case_folding; SET NAMES utf8mb4 COLLATE utf8mb4_unicode_520_ci; CREATE OR REPLACE TABLE case_folding AS SELECT 0 AS code, SPACE(32) AS c LIMIT 0; @@ -6722,6 +6740,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -6739,6 +6762,10 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 49 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B0AF E2B0AF â°¯ +2C5F E2B19F E2B19F ⱟ +A7C0 EA9F80 EA9F80 Ꟁ +A7C1 EA9F81 EA9F81 êŸ DROP TABLE case_folding; SET NAMES utf8mb4 COLLATE utf8mb4_unicode_520_nopad_ci; CREATE OR REPLACE TABLE case_folding AS SELECT 0 AS code, SPACE(32) AS c LIMIT 0; @@ -6765,6 +6792,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -6782,6 +6814,10 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 49 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B0AF E2B0AF â°¯ +2C5F E2B19F E2B19F ⱟ +A7C0 EA9F80 EA9F80 Ꟁ +A7C1 EA9F81 EA9F81 êŸ DROP TABLE case_folding; SET NAMES utf8mb4 COLLATE utf8mb4_myanmar_ci; CREATE OR REPLACE TABLE case_folding AS SELECT 0 AS code, SPACE(32) AS c LIMIT 0; @@ -6808,6 +6844,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -6825,6 +6866,10 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 49 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B0AF E2B0AF â°¯ +2C5F E2B19F E2B19F ⱟ +A7C0 EA9F80 EA9F80 Ꟁ +A7C1 EA9F81 EA9F81 êŸ DROP TABLE case_folding; SET NAMES utf8mb4 COLLATE utf8mb4_thai_520_w2; CREATE OR REPLACE TABLE case_folding AS SELECT 0 AS code, SPACE(32) AS c LIMIT 0; @@ -6851,6 +6896,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -6868,6 +6918,10 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 49 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B0AF E2B0AF â°¯ +2C5F E2B19F E2B19F ⱟ +A7C0 EA9F80 EA9F80 Ꟁ +A7C1 EA9F81 EA9F81 êŸ DROP TABLE case_folding; # # End of 10.3 tests @@ -11499,6 +11553,11 @@ INSERT INTO case_folding (code) VALUES (0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, (0x0131) /* LATIN SMALL LETTER DOTLESS I */ ; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; UPDATE case_folding SET c=CHAR(code USING ucs2); SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c @@ -11516,6 +11575,112 @@ HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c 69 69 49 i 130 69 C4B0 İ 131 C4B1 49 ı +2C2F E2B19F E2B0AF â°¯ +2C5F E2B19F E2B0AF ⱟ +A7C0 EA9F81 EA9F80 Ꟁ +A7C1 EA9F81 EA9F80 êŸ +DROP TABLE case_folding; +CREATE OR REPLACE TABLE case_folding AS SELECT 0 AS code, SPACE(32) AS c, SPACE(64) AS comment LIMIT 0; +SHOW CREATE TABLE case_folding; +Table Create Table +case_folding CREATE TABLE `case_folding` ( + `code` int(1) NOT NULL, + `c` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci DEFAULT NULL, + `comment` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO case_folding (code, comment) VALUES (0x10595, 'VITHKUQI CAPITAL LETTER ZE (Unicode-14.0)'); +INSERT INTO case_folding (code, comment) VALUES (0x105BC, 'VITHKUQI SMALL LETTER ZE (Unicode-14.0)'); +INSERT INTO case_folding (code, comment) VALUES (0x1E921, 'ADLAM CAPITAL LETTER SHA (Unicode-9.0)'); +INSERT INTO case_folding (code, comment) VALUES (0x1E943, 'ADLAM SMALL LETTER SHA (Unicode-9.0)'); +UPDATE case_folding SET c=CHAR(code USING utf32); +SELECT +HEX(CONVERT(c USING utf32)) AS ch, +HEX(CONVERT(LOWER(c) USING utf32)) AS cl, +HEX(CONVERT(UPPER(c) USING utf32)) AS cu, +comment +FROM case_folding ORDER BY BINARY(c); +ch cl cu comment +00010595 000105BC 00010595 VITHKUQI CAPITAL LETTER ZE (Unicode-14.0) +000105BC 000105BC 00010595 VITHKUQI SMALL LETTER ZE (Unicode-14.0) +0001E921 0001E943 0001E921 ADLAM CAPITAL LETTER SHA (Unicode-9.0) +0001E943 0001E943 0001E921 ADLAM SMALL LETTER SHA (Unicode-9.0) +DROP TABLE case_folding; +SET NAMES utf8mb4 COLLATE utf8mb4_uca1400_turkish_ai_ci; +CREATE OR REPLACE TABLE case_folding AS SELECT 0 AS code, SPACE(32) AS c LIMIT 0; +SHOW CREATE TABLE case_folding; +Table Create Table +case_folding CREATE TABLE `case_folding` ( + `code` int(1) NOT NULL, + `c` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_turkish_ai_ci DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO case_folding (code) VALUES +(0x23A), +(0x23E), +(0x23F), +(0x240), +(0x250), +(0x251), +(0x252), +(0x26B), +(0x271), +(0x27D); +INSERT INTO case_folding (code) VALUES +(0x0049) /* LATIN CAPITAL LETTER I */, +(0x0069) /* LATIN SMALL LETTER I */, +(0x0130) /* LATIN CAPITAL LETTER I WITH DOT ABOVE */, +(0x0131) /* LATIN SMALL LETTER DOTLESS I */ +; +INSERT INTO case_folding (code) VALUES +(0x2C2F) /* GLAGOLITIC CAPITAL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0x2C5F) /* GLAGOLITIC SMALL LETTER CAUDATE CHRIVI (Unicode-14.0) */, +(0xA7C0) /* LATIN CAPITAL LETTER OLD POLISH O (Unicode-14.0) */, +(0xA7C1) /* LATIN SMALL LETTER OLD POLISH O (Unicode-14.0) */; +UPDATE case_folding SET c=CHAR(code USING ucs2); +SELECT HEX(code), HEX(LOWER(c)), HEX(UPPER(c)), c FROM case_folding; +HEX(code) HEX(LOWER(c)) HEX(UPPER(c)) c +23A E2B1A5 C8BA Ⱥ +23E E2B1A6 C8BE Ⱦ +23F C8BF E2B1BE È¿ +240 C980 E2B1BF É€ +250 C990 E2B1AF É +251 C991 E2B1AD É‘ +252 C992 E2B1B0 É’ +26B C9AB E2B1A2 É« +271 C9B1 E2B1AE ɱ +27D C9BD E2B1A4 ɽ +49 C4B1 49 I +69 69 C4B0 i +130 69 C4B0 İ +131 C4B1 49 ı +2C2F E2B19F E2B0AF â°¯ +2C5F E2B19F E2B0AF ⱟ +A7C0 EA9F81 EA9F80 Ꟁ +A7C1 EA9F81 EA9F80 êŸ +DROP TABLE case_folding; +CREATE OR REPLACE TABLE case_folding AS SELECT 0 AS code, SPACE(32) AS c, SPACE(64) AS comment LIMIT 0; +SHOW CREATE TABLE case_folding; +Table Create Table +case_folding CREATE TABLE `case_folding` ( + `code` int(1) NOT NULL, + `c` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_turkish_ai_ci DEFAULT NULL, + `comment` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_turkish_ai_ci DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +INSERT INTO case_folding (code, comment) VALUES (0x10595, 'VITHKUQI CAPITAL LETTER ZE (Unicode-14.0)'); +INSERT INTO case_folding (code, comment) VALUES (0x105BC, 'VITHKUQI SMALL LETTER ZE (Unicode-14.0)'); +INSERT INTO case_folding (code, comment) VALUES (0x1E921, 'ADLAM CAPITAL LETTER SHA (Unicode-9.0)'); +INSERT INTO case_folding (code, comment) VALUES (0x1E943, 'ADLAM SMALL LETTER SHA (Unicode-9.0)'); +UPDATE case_folding SET c=CHAR(code USING utf32); +SELECT +HEX(CONVERT(c USING utf32)) AS ch, +HEX(CONVERT(LOWER(c) USING utf32)) AS cl, +HEX(CONVERT(UPPER(c) USING utf32)) AS cu, +comment +FROM case_folding ORDER BY BINARY(c); +ch cl cu comment +00010595 000105BC 00010595 VITHKUQI CAPITAL LETTER ZE (Unicode-14.0) +000105BC 000105BC 00010595 VITHKUQI SMALL LETTER ZE (Unicode-14.0) +0001E921 0001E943 0001E921 ADLAM CAPITAL LETTER SHA (Unicode-9.0) +0001E943 0001E943 0001E921 ADLAM SMALL LETTER SHA (Unicode-9.0) DROP TABLE case_folding; # # End of 10.10 tests diff --git a/mysql-test/main/ctype_utf8mb4_uca.test b/mysql-test/main/ctype_utf8mb4_uca.test index 3f428447cc9..1b709ebba69 100644 --- a/mysql-test/main/ctype_utf8mb4_uca.test +++ b/mysql-test/main/ctype_utf8mb4_uca.test @@ -435,6 +435,11 @@ DROP PROCEDURE test_styles; SET NAMES utf8mb4 COLLATE utf8mb4_uca1400_ai_ci; --source include/ctype_casefolding.inc +--source include/ctype_casefolding_supplementary.inc + +SET NAMES utf8mb4 COLLATE utf8mb4_uca1400_turkish_ai_ci; +--source include/ctype_casefolding.inc +--source include/ctype_casefolding_supplementary.inc --echo # --echo # End of 10.10 tests diff --git a/mysql-test/main/ctype_utf8mb4_uca1400_ai_ci_casefold.result b/mysql-test/main/ctype_utf8mb4_uca1400_ai_ci_casefold.result new file mode 100644 index 00000000000..85e87f217cc --- /dev/null +++ b/mysql-test/main/ctype_utf8mb4_uca1400_ai_ci_casefold.result @@ -0,0 +1,2927 @@ +# +# Start of 10.10 tests +# +# +# MDEV-30577 Case folding for uca1400 collations is not up to date +# +SET NAMES utf8mb4 COLLATE utf8mb4_uca1400_ai_ci; +EXECUTE IMMEDIATE SFORMAT(' +CREATE VIEW v_bmp AS +SELECT + seq AS codepoint, + LPAD(HEX(seq),4,''0'') AS codepoint_hex4, + CONVERT(CHAR(seq USING utf32) USING {}) COLLATE {} AS c +FROM + seq_0_to_65535', @@character_set_connection, @@collation_connection); +SELECT COLLATION(c) FROM v_bmp LIMIT 1; +COLLATION(c) +utf8mb4_uca1400_ai_ci +SELECT +codepoint_hex4, +HEX(CAST(LOWER(c) AS CHAR CHARACTER SET ucs2)), +HEX(CAST(UPPER(c) AS CHAR CHARACTER SET ucs2)) +FROM v_bmp +WHERE BINARY(c)<>BINARY(LOWER(c)) OR BINARY(c)<>BINARY(UPPER(c)); +codepoint_hex4 HEX(CAST(LOWER(c) AS CHAR CHARACTER SET ucs2)) HEX(CAST(UPPER(c) AS CHAR CHARACTER SET ucs2)) +0041 0061 0041 +0042 0062 0042 +0043 0063 0043 +0044 0064 0044 +0045 0065 0045 +0046 0066 0046 +0047 0067 0047 +0048 0068 0048 +0049 0069 0049 +004A 006A 004A +004B 006B 004B +004C 006C 004C +004D 006D 004D +004E 006E 004E +004F 006F 004F +0050 0070 0050 +0051 0071 0051 +0052 0072 0052 +0053 0073 0053 +0054 0074 0054 +0055 0075 0055 +0056 0076 0056 +0057 0077 0057 +0058 0078 0058 +0059 0079 0059 +005A 007A 005A +0061 0061 0041 +0062 0062 0042 +0063 0063 0043 +0064 0064 0044 +0065 0065 0045 +0066 0066 0046 +0067 0067 0047 +0068 0068 0048 +0069 0069 0049 +006A 006A 004A +006B 006B 004B +006C 006C 004C +006D 006D 004D +006E 006E 004E +006F 006F 004F +0070 0070 0050 +0071 0071 0051 +0072 0072 0052 +0073 0073 0053 +0074 0074 0054 +0075 0075 0055 +0076 0076 0056 +0077 0077 0057 +0078 0078 0058 +0079 0079 0059 +007A 007A 005A +00B5 00B5 039C +00C0 00E0 00C0 +00C1 00E1 00C1 +00C2 00E2 00C2 +00C3 00E3 00C3 +00C4 00E4 00C4 +00C5 00E5 00C5 +00C6 00E6 00C6 +00C7 00E7 00C7 +00C8 00E8 00C8 +00C9 00E9 00C9 +00CA 00EA 00CA +00CB 00EB 00CB +00CC 00EC 00CC +00CD 00ED 00CD +00CE 00EE 00CE +00CF 00EF 00CF +00D0 00F0 00D0 +00D1 00F1 00D1 +00D2 00F2 00D2 +00D3 00F3 00D3 +00D4 00F4 00D4 +00D5 00F5 00D5 +00D6 00F6 00D6 +00D8 00F8 00D8 +00D9 00F9 00D9 +00DA 00FA 00DA +00DB 00FB 00DB +00DC 00FC 00DC +00DD 00FD 00DD +00DE 00FE 00DE +00E0 00E0 00C0 +00E1 00E1 00C1 +00E2 00E2 00C2 +00E3 00E3 00C3 +00E4 00E4 00C4 +00E5 00E5 00C5 +00E6 00E6 00C6 +00E7 00E7 00C7 +00E8 00E8 00C8 +00E9 00E9 00C9 +00EA 00EA 00CA +00EB 00EB 00CB +00EC 00EC 00CC +00ED 00ED 00CD +00EE 00EE 00CE +00EF 00EF 00CF +00F0 00F0 00D0 +00F1 00F1 00D1 +00F2 00F2 00D2 +00F3 00F3 00D3 +00F4 00F4 00D4 +00F5 00F5 00D5 +00F6 00F6 00D6 +00F8 00F8 00D8 +00F9 00F9 00D9 +00FA 00FA 00DA +00FB 00FB 00DB +00FC 00FC 00DC +00FD 00FD 00DD +00FE 00FE 00DE +00FF 00FF 0178 +0100 0101 0100 +0101 0101 0100 +0102 0103 0102 +0103 0103 0102 +0104 0105 0104 +0105 0105 0104 +0106 0107 0106 +0107 0107 0106 +0108 0109 0108 +0109 0109 0108 +010A 010B 010A +010B 010B 010A +010C 010D 010C +010D 010D 010C +010E 010F 010E +010F 010F 010E +0110 0111 0110 +0111 0111 0110 +0112 0113 0112 +0113 0113 0112 +0114 0115 0114 +0115 0115 0114 +0116 0117 0116 +0117 0117 0116 +0118 0119 0118 +0119 0119 0118 +011A 011B 011A +011B 011B 011A +011C 011D 011C +011D 011D 011C +011E 011F 011E +011F 011F 011E +0120 0121 0120 +0121 0121 0120 +0122 0123 0122 +0123 0123 0122 +0124 0125 0124 +0125 0125 0124 +0126 0127 0126 +0127 0127 0126 +0128 0129 0128 +0129 0129 0128 +012A 012B 012A +012B 012B 012A +012C 012D 012C +012D 012D 012C +012E 012F 012E +012F 012F 012E +0130 0069 0130 +0131 0131 0049 +0132 0133 0132 +0133 0133 0132 +0134 0135 0134 +0135 0135 0134 +0136 0137 0136 +0137 0137 0136 +0139 013A 0139 +013A 013A 0139 +013B 013C 013B +013C 013C 013B +013D 013E 013D +013E 013E 013D +013F 0140 013F +0140 0140 013F +0141 0142 0141 +0142 0142 0141 +0143 0144 0143 +0144 0144 0143 +0145 0146 0145 +0146 0146 0145 +0147 0148 0147 +0148 0148 0147 +014A 014B 014A +014B 014B 014A +014C 014D 014C +014D 014D 014C +014E 014F 014E +014F 014F 014E +0150 0151 0150 +0151 0151 0150 +0152 0153 0152 +0153 0153 0152 +0154 0155 0154 +0155 0155 0154 +0156 0157 0156 +0157 0157 0156 +0158 0159 0158 +0159 0159 0158 +015A 015B 015A +015B 015B 015A +015C 015D 015C +015D 015D 015C +015E 015F 015E +015F 015F 015E +0160 0161 0160 +0161 0161 0160 +0162 0163 0162 +0163 0163 0162 +0164 0165 0164 +0165 0165 0164 +0166 0167 0166 +0167 0167 0166 +0168 0169 0168 +0169 0169 0168 +016A 016B 016A +016B 016B 016A +016C 016D 016C +016D 016D 016C +016E 016F 016E +016F 016F 016E +0170 0171 0170 +0171 0171 0170 +0172 0173 0172 +0173 0173 0172 +0174 0175 0174 +0175 0175 0174 +0176 0177 0176 +0177 0177 0176 +0178 00FF 0178 +0179 017A 0179 +017A 017A 0179 +017B 017C 017B +017C 017C 017B +017D 017E 017D +017E 017E 017D +017F 017F 0053 +0180 0180 0243 +0181 0253 0181 +0182 0183 0182 +0183 0183 0182 +0184 0185 0184 +0185 0185 0184 +0186 0254 0186 +0187 0188 0187 +0188 0188 0187 +0189 0256 0189 +018A 0257 018A +018B 018C 018B +018C 018C 018B +018E 01DD 018E +018F 0259 018F +0190 025B 0190 +0191 0192 0191 +0192 0192 0191 +0193 0260 0193 +0194 0263 0194 +0195 0195 01F6 +0196 0269 0196 +0197 0268 0197 +0198 0199 0198 +0199 0199 0198 +019A 019A 023D +019C 026F 019C +019D 0272 019D +019E 019E 0220 +019F 0275 019F +01A0 01A1 01A0 +01A1 01A1 01A0 +01A2 01A3 01A2 +01A3 01A3 01A2 +01A4 01A5 01A4 +01A5 01A5 01A4 +01A6 0280 01A6 +01A7 01A8 01A7 +01A8 01A8 01A7 +01A9 0283 01A9 +01AC 01AD 01AC +01AD 01AD 01AC +01AE 0288 01AE +01AF 01B0 01AF +01B0 01B0 01AF +01B1 028A 01B1 +01B2 028B 01B2 +01B3 01B4 01B3 +01B4 01B4 01B3 +01B5 01B6 01B5 +01B6 01B6 01B5 +01B7 0292 01B7 +01B8 01B9 01B8 +01B9 01B9 01B8 +01BC 01BD 01BC +01BD 01BD 01BC +01BF 01BF 01F7 +01C4 01C6 01C4 +01C5 01C6 01C4 +01C6 01C6 01C4 +01C7 01C9 01C7 +01C8 01C9 01C7 +01C9 01C9 01C7 +01CA 01CC 01CA +01CB 01CC 01CA +01CC 01CC 01CA +01CD 01CE 01CD +01CE 01CE 01CD +01CF 01D0 01CF +01D0 01D0 01CF +01D1 01D2 01D1 +01D2 01D2 01D1 +01D3 01D4 01D3 +01D4 01D4 01D3 +01D5 01D6 01D5 +01D6 01D6 01D5 +01D7 01D8 01D7 +01D8 01D8 01D7 +01D9 01DA 01D9 +01DA 01DA 01D9 +01DB 01DC 01DB +01DC 01DC 01DB +01DD 01DD 018E +01DE 01DF 01DE +01DF 01DF 01DE +01E0 01E1 01E0 +01E1 01E1 01E0 +01E2 01E3 01E2 +01E3 01E3 01E2 +01E4 01E5 01E4 +01E5 01E5 01E4 +01E6 01E7 01E6 +01E7 01E7 01E6 +01E8 01E9 01E8 +01E9 01E9 01E8 +01EA 01EB 01EA +01EB 01EB 01EA +01EC 01ED 01EC +01ED 01ED 01EC +01EE 01EF 01EE +01EF 01EF 01EE +01F1 01F3 01F1 +01F2 01F3 01F1 +01F3 01F3 01F1 +01F4 01F5 01F4 +01F5 01F5 01F4 +01F6 0195 01F6 +01F7 01BF 01F7 +01F8 01F9 01F8 +01F9 01F9 01F8 +01FA 01FB 01FA +01FB 01FB 01FA +01FC 01FD 01FC +01FD 01FD 01FC +01FE 01FF 01FE +01FF 01FF 01FE +0200 0201 0200 +0201 0201 0200 +0202 0203 0202 +0203 0203 0202 +0204 0205 0204 +0205 0205 0204 +0206 0207 0206 +0207 0207 0206 +0208 0209 0208 +0209 0209 0208 +020A 020B 020A +020B 020B 020A +020C 020D 020C +020D 020D 020C +020E 020F 020E +020F 020F 020E +0210 0211 0210 +0211 0211 0210 +0212 0213 0212 +0213 0213 0212 +0214 0215 0214 +0215 0215 0214 +0216 0217 0216 +0217 0217 0216 +0218 0219 0218 +0219 0219 0218 +021A 021B 021A +021B 021B 021A +021C 021D 021C +021D 021D 021C +021E 021F 021E +021F 021F 021E +0220 019E 0220 +0222 0223 0222 +0223 0223 0222 +0224 0225 0224 +0225 0225 0224 +0226 0227 0226 +0227 0227 0226 +0228 0229 0228 +0229 0229 0228 +022A 022B 022A +022B 022B 022A +022C 022D 022C +022D 022D 022C +022E 022F 022E +022F 022F 022E +0230 0231 0230 +0231 0231 0230 +0232 0233 0232 +0233 0233 0232 +023A 2C65 023A +023B 023C 023B +023C 023C 023B +023D 019A 023D +023E 2C66 023E +023F 023F 2C7E +0240 0240 2C7F +0241 0242 0241 +0242 0242 0241 +0243 0180 0243 +0244 0289 0244 +0245 028C 0245 +0246 0247 0246 +0247 0247 0246 +0248 0249 0248 +0249 0249 0248 +024A 024B 024A +024B 024B 024A +024C 024D 024C +024D 024D 024C +024E 024F 024E +024F 024F 024E +0250 0250 2C6F +0251 0251 2C6D +0252 0252 2C70 +0253 0253 0181 +0254 0254 0186 +0256 0256 0189 +0257 0257 018A +0259 0259 018F +025B 025B 0190 +025C 025C A7AB +0260 0260 0193 +0261 0261 A7AC +0263 0263 0194 +0265 0265 A78D +0266 0266 A7AA +0268 0268 0197 +0269 0269 0196 +026A 026A A7AE +026B 026B 2C62 +026C 026C A7AD +026F 026F 019C +0271 0271 2C6E +0272 0272 019D +0275 0275 019F +027D 027D 2C64 +0280 0280 01A6 +0282 0282 A7C5 +0283 0283 01A9 +0287 0287 A7B1 +0288 0288 01AE +0289 0289 0244 +028A 028A 01B1 +028B 028B 01B2 +028C 028C 0245 +0292 0292 01B7 +029D 029D A7B2 +029E 029E A7B0 +0345 0345 0399 +0370 0371 0370 +0371 0371 0370 +0372 0373 0372 +0373 0373 0372 +0376 0377 0376 +0377 0377 0376 +037B 037B 03FD +037C 037C 03FE +037D 037D 03FF +037F 03F3 037F +0386 03AC 0386 +0388 03AD 0388 +0389 03AE 0389 +038A 03AF 038A +038C 03CC 038C +038E 03CD 038E +038F 03CE 038F +0391 03B1 0391 +0392 03B2 0392 +0393 03B3 0393 +0394 03B4 0394 +0395 03B5 0395 +0396 03B6 0396 +0397 03B7 0397 +0398 03B8 0398 +0399 03B9 0399 +039A 03BA 039A +039B 03BB 039B +039C 03BC 039C +039D 03BD 039D +039E 03BE 039E +039F 03BF 039F +03A0 03C0 03A0 +03A1 03C1 03A1 +03A3 03C3 03A3 +03A4 03C4 03A4 +03A5 03C5 03A5 +03A6 03C6 03A6 +03A7 03C7 03A7 +03A8 03C8 03A8 +03A9 03C9 03A9 +03AA 03CA 03AA +03AB 03CB 03AB +03AC 03AC 0386 +03AD 03AD 0388 +03AE 03AE 0389 +03AF 03AF 038A +03B1 03B1 0391 +03B2 03B2 0392 +03B3 03B3 0393 +03B4 03B4 0394 +03B5 03B5 0395 +03B6 03B6 0396 +03B7 03B7 0397 +03B8 03B8 0398 +03B9 03B9 0399 +03BA 03BA 039A +03BB 03BB 039B +03BC 03BC 039C +03BD 03BD 039D +03BE 03BE 039E +03BF 03BF 039F +03C0 03C0 03A0 +03C1 03C1 03A1 +03C2 03C2 03A3 +03C3 03C3 03A3 +03C4 03C4 03A4 +03C5 03C5 03A5 +03C6 03C6 03A6 +03C7 03C7 03A7 +03C8 03C8 03A8 +03C9 03C9 03A9 +03CA 03CA 03AA +03CB 03CB 03AB +03CC 03CC 038C +03CD 03CD 038E +03CE 03CE 038F +03CF 03D7 03CF +03D0 03D0 0392 +03D1 03D1 0398 +03D5 03D5 03A6 +03D6 03D6 03A0 +03D7 03D7 03CF +03D8 03D9 03D8 +03D9 03D9 03D8 +03DA 03DB 03DA +03DB 03DB 03DA +03DC 03DD 03DC +03DD 03DD 03DC +03DE 03DF 03DE +03DF 03DF 03DE +03E0 03E1 03E0 +03E1 03E1 03E0 +03E2 03E3 03E2 +03E3 03E3 03E2 +03E4 03E5 03E4 +03E5 03E5 03E4 +03E6 03E7 03E6 +03E7 03E7 03E6 +03E8 03E9 03E8 +03E9 03E9 03E8 +03EA 03EB 03EA +03EB 03EB 03EA +03EC 03ED 03EC +03ED 03ED 03EC +03EE 03EF 03EE +03EF 03EF 03EE +03F0 03F0 039A +03F1 03F1 03A1 +03F2 03F2 03F9 +03F3 03F3 037F +03F4 03B8 03F4 +03F5 03F5 0395 +03F7 03F8 03F7 +03F8 03F8 03F7 +03F9 03F2 03F9 +03FA 03FB 03FA +03FB 03FB 03FA +03FD 037B 03FD +03FE 037C 03FE +03FF 037D 03FF +0400 0450 0400 +0401 0451 0401 +0402 0452 0402 +0403 0453 0403 +0404 0454 0404 +0405 0455 0405 +0406 0456 0406 +0407 0457 0407 +0408 0458 0408 +0409 0459 0409 +040A 045A 040A +040B 045B 040B +040C 045C 040C +040D 045D 040D +040E 045E 040E +040F 045F 040F +0410 0430 0410 +0411 0431 0411 +0412 0432 0412 +0413 0433 0413 +0414 0434 0414 +0415 0435 0415 +0416 0436 0416 +0417 0437 0417 +0418 0438 0418 +0419 0439 0419 +041A 043A 041A +041B 043B 041B +041C 043C 041C +041D 043D 041D +041E 043E 041E +041F 043F 041F +0420 0440 0420 +0421 0441 0421 +0422 0442 0422 +0423 0443 0423 +0424 0444 0424 +0425 0445 0425 +0426 0446 0426 +0427 0447 0427 +0428 0448 0428 +0429 0449 0429 +042A 044A 042A +042B 044B 042B +042C 044C 042C +042D 044D 042D +042E 044E 042E +042F 044F 042F +0430 0430 0410 +0431 0431 0411 +0432 0432 0412 +0433 0433 0413 +0434 0434 0414 +0435 0435 0415 +0436 0436 0416 +0437 0437 0417 +0438 0438 0418 +0439 0439 0419 +043A 043A 041A +043B 043B 041B +043C 043C 041C +043D 043D 041D +043E 043E 041E +043F 043F 041F +0440 0440 0420 +0441 0441 0421 +0442 0442 0422 +0443 0443 0423 +0444 0444 0424 +0445 0445 0425 +0446 0446 0426 +0447 0447 0427 +0448 0448 0428 +0449 0449 0429 +044A 044A 042A +044B 044B 042B +044C 044C 042C +044D 044D 042D +044E 044E 042E +044F 044F 042F +0450 0450 0400 +0451 0451 0401 +0452 0452 0402 +0453 0453 0403 +0454 0454 0404 +0455 0455 0405 +0456 0456 0406 +0457 0457 0407 +0458 0458 0408 +0459 0459 0409 +045A 045A 040A +045B 045B 040B +045C 045C 040C +045D 045D 040D +045E 045E 040E +045F 045F 040F +0460 0461 0460 +0461 0461 0460 +0462 0463 0462 +0463 0463 0462 +0464 0465 0464 +0465 0465 0464 +0466 0467 0466 +0467 0467 0466 +0468 0469 0468 +0469 0469 0468 +046A 046B 046A +046B 046B 046A +046C 046D 046C +046D 046D 046C +046E 046F 046E +046F 046F 046E +0470 0471 0470 +0471 0471 0470 +0472 0473 0472 +0473 0473 0472 +0474 0475 0474 +0475 0475 0474 +0476 0477 0476 +0477 0477 0476 +0478 0479 0478 +0479 0479 0478 +047A 047B 047A +047B 047B 047A +047C 047D 047C +047D 047D 047C +047E 047F 047E +047F 047F 047E +0480 0481 0480 +0481 0481 0480 +048A 048B 048A +048B 048B 048A +048C 048D 048C +048D 048D 048C +048E 048F 048E +048F 048F 048E +0490 0491 0490 +0491 0491 0490 +0492 0493 0492 +0493 0493 0492 +0494 0495 0494 +0495 0495 0494 +0496 0497 0496 +0497 0497 0496 +0498 0499 0498 +0499 0499 0498 +049A 049B 049A +049B 049B 049A +049C 049D 049C +049D 049D 049C +049E 049F 049E +049F 049F 049E +04A0 04A1 04A0 +04A1 04A1 04A0 +04A2 04A3 04A2 +04A3 04A3 04A2 +04A4 04A5 04A4 +04A5 04A5 04A4 +04A6 04A7 04A6 +04A7 04A7 04A6 +04A8 04A9 04A8 +04A9 04A9 04A8 +04AA 04AB 04AA +04AB 04AB 04AA +04AC 04AD 04AC +04AD 04AD 04AC +04AE 04AF 04AE +04AF 04AF 04AE +04B0 04B1 04B0 +04B1 04B1 04B0 +04B2 04B3 04B2 +04B3 04B3 04B2 +04B4 04B5 04B4 +04B5 04B5 04B4 +04B6 04B7 04B6 +04B7 04B7 04B6 +04B8 04B9 04B8 +04B9 04B9 04B8 +04BA 04BB 04BA +04BB 04BB 04BA +04BC 04BD 04BC +04BD 04BD 04BC +04BE 04BF 04BE +04BF 04BF 04BE +04C0 04CF 04C0 +04C1 04C2 04C1 +04C2 04C2 04C1 +04C3 04C4 04C3 +04C4 04C4 04C3 +04C5 04C6 04C5 +04C6 04C6 04C5 +04C7 04C8 04C7 +04C8 04C8 04C7 +04C9 04CA 04C9 +04CA 04CA 04C9 +04CB 04CC 04CB +04CC 04CC 04CB +04CD 04CE 04CD +04CE 04CE 04CD +04CF 04CF 04C0 +04D0 04D1 04D0 +04D1 04D1 04D0 +04D2 04D3 04D2 +04D3 04D3 04D2 +04D4 04D5 04D4 +04D5 04D5 04D4 +04D6 04D7 04D6 +04D7 04D7 04D6 +04D8 04D9 04D8 +04D9 04D9 04D8 +04DA 04DB 04DA +04DB 04DB 04DA +04DC 04DD 04DC +04DD 04DD 04DC +04DE 04DF 04DE +04DF 04DF 04DE +04E0 04E1 04E0 +04E1 04E1 04E0 +04E2 04E3 04E2 +04E3 04E3 04E2 +04E4 04E5 04E4 +04E5 04E5 04E4 +04E6 04E7 04E6 +04E7 04E7 04E6 +04E8 04E9 04E8 +04E9 04E9 04E8 +04EA 04EB 04EA +04EB 04EB 04EA +04EC 04ED 04EC +04ED 04ED 04EC +04EE 04EF 04EE +04EF 04EF 04EE +04F0 04F1 04F0 +04F1 04F1 04F0 +04F2 04F3 04F2 +04F3 04F3 04F2 +04F4 04F5 04F4 +04F5 04F5 04F4 +04F6 04F7 04F6 +04F7 04F7 04F6 +04F8 04F9 04F8 +04F9 04F9 04F8 +04FA 04FB 04FA +04FB 04FB 04FA +04FC 04FD 04FC +04FD 04FD 04FC +04FE 04FF 04FE +04FF 04FF 04FE +0500 0501 0500 +0501 0501 0500 +0502 0503 0502 +0503 0503 0502 +0504 0505 0504 +0505 0505 0504 +0506 0507 0506 +0507 0507 0506 +0508 0509 0508 +0509 0509 0508 +050A 050B 050A +050B 050B 050A +050C 050D 050C +050D 050D 050C +050E 050F 050E +050F 050F 050E +0510 0511 0510 +0511 0511 0510 +0512 0513 0512 +0513 0513 0512 +0514 0515 0514 +0515 0515 0514 +0516 0517 0516 +0517 0517 0516 +0518 0519 0518 +0519 0519 0518 +051A 051B 051A +051B 051B 051A +051C 051D 051C +051D 051D 051C +051E 051F 051E +051F 051F 051E +0520 0521 0520 +0521 0521 0520 +0522 0523 0522 +0523 0523 0522 +0524 0525 0524 +0525 0525 0524 +0526 0527 0526 +0527 0527 0526 +0528 0529 0528 +0529 0529 0528 +052A 052B 052A +052B 052B 052A +052C 052D 052C +052D 052D 052C +052E 052F 052E +052F 052F 052E +0531 0561 0531 +0532 0562 0532 +0533 0563 0533 +0534 0564 0534 +0535 0565 0535 +0536 0566 0536 +0537 0567 0537 +0538 0568 0538 +0539 0569 0539 +053A 056A 053A +053B 056B 053B +053C 056C 053C +053D 056D 053D +053E 056E 053E +053F 056F 053F +0540 0570 0540 +0541 0571 0541 +0542 0572 0542 +0543 0573 0543 +0544 0574 0544 +0545 0575 0545 +0546 0576 0546 +0547 0577 0547 +0548 0578 0548 +0549 0579 0549 +054A 057A 054A +054B 057B 054B +054C 057C 054C +054D 057D 054D +054E 057E 054E +054F 057F 054F +0550 0580 0550 +0551 0581 0551 +0552 0582 0552 +0553 0583 0553 +0554 0584 0554 +0555 0585 0555 +0556 0586 0556 +0561 0561 0531 +0562 0562 0532 +0563 0563 0533 +0564 0564 0534 +0565 0565 0535 +0566 0566 0536 +0567 0567 0537 +0568 0568 0538 +0569 0569 0539 +056A 056A 053A +056B 056B 053B +056C 056C 053C +056D 056D 053D +056E 056E 053E +056F 056F 053F +0570 0570 0540 +0571 0571 0541 +0572 0572 0542 +0573 0573 0543 +0574 0574 0544 +0575 0575 0545 +0576 0576 0546 +0577 0577 0547 +0578 0578 0548 +0579 0579 0549 +057A 057A 054A +057B 057B 054B +057C 057C 054C +057D 057D 054D +057E 057E 054E +057F 057F 054F +0580 0580 0550 +0581 0581 0551 +0582 0582 0552 +0583 0583 0553 +0584 0584 0554 +0585 0585 0555 +0586 0586 0556 +10A0 2D00 10A0 +10A1 2D01 10A1 +10A2 2D02 10A2 +10A3 2D03 10A3 +10A4 2D04 10A4 +10A5 2D05 10A5 +10A6 2D06 10A6 +10A7 2D07 10A7 +10A8 2D08 10A8 +10A9 2D09 10A9 +10AA 2D0A 10AA +10AB 2D0B 10AB +10AC 2D0C 10AC +10AD 2D0D 10AD +10AE 2D0E 10AE +10AF 2D0F 10AF +10B0 2D10 10B0 +10B1 2D11 10B1 +10B2 2D12 10B2 +10B3 2D13 10B3 +10B4 2D14 10B4 +10B5 2D15 10B5 +10B6 2D16 10B6 +10B7 2D17 10B7 +10B8 2D18 10B8 +10B9 2D19 10B9 +10BA 2D1A 10BA +10BB 2D1B 10BB +10BC 2D1C 10BC +10BD 2D1D 10BD +10BE 2D1E 10BE +10BF 2D1F 10BF +10C0 2D20 10C0 +10C1 2D21 10C1 +10C2 2D22 10C2 +10C3 2D23 10C3 +10C4 2D24 10C4 +10C5 2D25 10C5 +10C7 2D27 10C7 +10CD 2D2D 10CD +10D0 10D0 1C90 +10D1 10D1 1C91 +10D2 10D2 1C92 +10D3 10D3 1C93 +10D4 10D4 1C94 +10D5 10D5 1C95 +10D6 10D6 1C96 +10D7 10D7 1C97 +10D8 10D8 1C98 +10D9 10D9 1C99 +10DA 10DA 1C9A +10DB 10DB 1C9B +10DC 10DC 1C9C +10DD 10DD 1C9D +10DE 10DE 1C9E +10DF 10DF 1C9F +10E0 10E0 1CA0 +10E1 10E1 1CA1 +10E2 10E2 1CA2 +10E3 10E3 1CA3 +10E4 10E4 1CA4 +10E5 10E5 1CA5 +10E6 10E6 1CA6 +10E7 10E7 1CA7 +10E8 10E8 1CA8 +10E9 10E9 1CA9 +10EA 10EA 1CAA +10EB 10EB 1CAB +10EC 10EC 1CAC +10ED 10ED 1CAD +10EE 10EE 1CAE +10EF 10EF 1CAF +10F0 10F0 1CB0 +10F1 10F1 1CB1 +10F2 10F2 1CB2 +10F3 10F3 1CB3 +10F4 10F4 1CB4 +10F5 10F5 1CB5 +10F6 10F6 1CB6 +10F7 10F7 1CB7 +10F8 10F8 1CB8 +10F9 10F9 1CB9 +10FA 10FA 1CBA +10FD 10FD 1CBD +10FE 10FE 1CBE +10FF 10FF 1CBF +13A0 AB70 13A0 +13A1 AB71 13A1 +13A2 AB72 13A2 +13A3 AB73 13A3 +13A4 AB74 13A4 +13A5 AB75 13A5 +13A6 AB76 13A6 +13A7 AB77 13A7 +13A8 AB78 13A8 +13A9 AB79 13A9 +13AA AB7A 13AA +13AB AB7B 13AB +13AC AB7C 13AC +13AD AB7D 13AD +13AE AB7E 13AE +13AF AB7F 13AF +13B0 AB80 13B0 +13B1 AB81 13B1 +13B2 AB82 13B2 +13B3 AB83 13B3 +13B4 AB84 13B4 +13B5 AB85 13B5 +13B6 AB86 13B6 +13B7 AB87 13B7 +13B8 AB88 13B8 +13B9 AB89 13B9 +13BA AB8A 13BA +13BB AB8B 13BB +13BC AB8C 13BC +13BD AB8D 13BD +13BE AB8E 13BE +13BF AB8F 13BF +13C0 AB90 13C0 +13C1 AB91 13C1 +13C2 AB92 13C2 +13C3 AB93 13C3 +13C4 AB94 13C4 +13C5 AB95 13C5 +13C6 AB96 13C6 +13C7 AB97 13C7 +13C8 AB98 13C8 +13C9 AB99 13C9 +13CA AB9A 13CA +13CB AB9B 13CB +13CC AB9C 13CC +13CD AB9D 13CD +13CE AB9E 13CE +13CF AB9F 13CF +13D0 ABA0 13D0 +13D1 ABA1 13D1 +13D2 ABA2 13D2 +13D3 ABA3 13D3 +13D4 ABA4 13D4 +13D5 ABA5 13D5 +13D6 ABA6 13D6 +13D7 ABA7 13D7 +13D8 ABA8 13D8 +13D9 ABA9 13D9 +13DA ABAA 13DA +13DB ABAB 13DB +13DC ABAC 13DC +13DD ABAD 13DD +13DE ABAE 13DE +13DF ABAF 13DF +13E0 ABB0 13E0 +13E1 ABB1 13E1 +13E2 ABB2 13E2 +13E3 ABB3 13E3 +13E4 ABB4 13E4 +13E5 ABB5 13E5 +13E6 ABB6 13E6 +13E7 ABB7 13E7 +13E8 ABB8 13E8 +13E9 ABB9 13E9 +13EA ABBA 13EA +13EB ABBB 13EB +13EC ABBC 13EC +13ED ABBD 13ED +13EE ABBE 13EE +13EF ABBF 13EF +13F0 13F8 13F0 +13F1 13F9 13F1 +13F2 13FA 13F2 +13F3 13FB 13F3 +13F4 13FC 13F4 +13F5 13FD 13F5 +13F8 13F8 13F0 +13F9 13F9 13F1 +13FA 13FA 13F2 +13FB 13FB 13F3 +13FC 13FC 13F4 +13FD 13FD 13F5 +1C80 1C80 0412 +1C81 1C81 0414 +1C82 1C82 041E +1C83 1C83 0421 +1C84 1C84 0422 +1C85 1C85 0422 +1C86 1C86 042A +1C87 1C87 0462 +1C88 1C88 A64A +1C90 10D0 1C90 +1C91 10D1 1C91 +1C92 10D2 1C92 +1C93 10D3 1C93 +1C94 10D4 1C94 +1C95 10D5 1C95 +1C96 10D6 1C96 +1C97 10D7 1C97 +1C98 10D8 1C98 +1C99 10D9 1C99 +1C9A 10DA 1C9A +1C9B 10DB 1C9B +1C9C 10DC 1C9C +1C9D 10DD 1C9D +1C9E 10DE 1C9E +1C9F 10DF 1C9F +1CA0 10E0 1CA0 +1CA1 10E1 1CA1 +1CA2 10E2 1CA2 +1CA3 10E3 1CA3 +1CA4 10E4 1CA4 +1CA5 10E5 1CA5 +1CA6 10E6 1CA6 +1CA7 10E7 1CA7 +1CA8 10E8 1CA8 +1CA9 10E9 1CA9 +1CAA 10EA 1CAA +1CAB 10EB 1CAB +1CAC 10EC 1CAC +1CAD 10ED 1CAD +1CAE 10EE 1CAE +1CAF 10EF 1CAF +1CB0 10F0 1CB0 +1CB1 10F1 1CB1 +1CB2 10F2 1CB2 +1CB3 10F3 1CB3 +1CB4 10F4 1CB4 +1CB5 10F5 1CB5 +1CB6 10F6 1CB6 +1CB7 10F7 1CB7 +1CB8 10F8 1CB8 +1CB9 10F9 1CB9 +1CBA 10FA 1CBA +1CBD 10FD 1CBD +1CBE 10FE 1CBE +1CBF 10FF 1CBF +1D79 1D79 A77D +1D7D 1D7D 2C63 +1D8E 1D8E A7C6 +1E00 1E01 1E00 +1E01 1E01 1E00 +1E02 1E03 1E02 +1E03 1E03 1E02 +1E04 1E05 1E04 +1E05 1E05 1E04 +1E06 1E07 1E06 +1E07 1E07 1E06 +1E08 1E09 1E08 +1E09 1E09 1E08 +1E0A 1E0B 1E0A +1E0B 1E0B 1E0A +1E0C 1E0D 1E0C +1E0D 1E0D 1E0C +1E0E 1E0F 1E0E +1E0F 1E0F 1E0E +1E10 1E11 1E10 +1E11 1E11 1E10 +1E12 1E13 1E12 +1E13 1E13 1E12 +1E14 1E15 1E14 +1E15 1E15 1E14 +1E16 1E17 1E16 +1E17 1E17 1E16 +1E18 1E19 1E18 +1E19 1E19 1E18 +1E1A 1E1B 1E1A +1E1B 1E1B 1E1A +1E1C 1E1D 1E1C +1E1D 1E1D 1E1C +1E1E 1E1F 1E1E +1E1F 1E1F 1E1E +1E20 1E21 1E20 +1E21 1E21 1E20 +1E22 1E23 1E22 +1E23 1E23 1E22 +1E24 1E25 1E24 +1E25 1E25 1E24 +1E26 1E27 1E26 +1E27 1E27 1E26 +1E28 1E29 1E28 +1E29 1E29 1E28 +1E2A 1E2B 1E2A +1E2B 1E2B 1E2A +1E2C 1E2D 1E2C +1E2D 1E2D 1E2C +1E2E 1E2F 1E2E +1E2F 1E2F 1E2E +1E30 1E31 1E30 +1E31 1E31 1E30 +1E32 1E33 1E32 +1E33 1E33 1E32 +1E34 1E35 1E34 +1E35 1E35 1E34 +1E36 1E37 1E36 +1E37 1E37 1E36 +1E38 1E39 1E38 +1E39 1E39 1E38 +1E3A 1E3B 1E3A +1E3B 1E3B 1E3A +1E3C 1E3D 1E3C +1E3D 1E3D 1E3C +1E3E 1E3F 1E3E +1E3F 1E3F 1E3E +1E40 1E41 1E40 +1E41 1E41 1E40 +1E42 1E43 1E42 +1E43 1E43 1E42 +1E44 1E45 1E44 +1E45 1E45 1E44 +1E46 1E47 1E46 +1E47 1E47 1E46 +1E48 1E49 1E48 +1E49 1E49 1E48 +1E4A 1E4B 1E4A +1E4B 1E4B 1E4A +1E4C 1E4D 1E4C +1E4D 1E4D 1E4C +1E4E 1E4F 1E4E +1E4F 1E4F 1E4E +1E50 1E51 1E50 +1E51 1E51 1E50 +1E52 1E53 1E52 +1E53 1E53 1E52 +1E54 1E55 1E54 +1E55 1E55 1E54 +1E56 1E57 1E56 +1E57 1E57 1E56 +1E58 1E59 1E58 +1E59 1E59 1E58 +1E5A 1E5B 1E5A +1E5B 1E5B 1E5A +1E5C 1E5D 1E5C +1E5D 1E5D 1E5C +1E5E 1E5F 1E5E +1E5F 1E5F 1E5E +1E60 1E61 1E60 +1E61 1E61 1E60 +1E62 1E63 1E62 +1E63 1E63 1E62 +1E64 1E65 1E64 +1E65 1E65 1E64 +1E66 1E67 1E66 +1E67 1E67 1E66 +1E68 1E69 1E68 +1E69 1E69 1E68 +1E6A 1E6B 1E6A +1E6B 1E6B 1E6A +1E6C 1E6D 1E6C +1E6D 1E6D 1E6C +1E6E 1E6F 1E6E +1E6F 1E6F 1E6E +1E70 1E71 1E70 +1E71 1E71 1E70 +1E72 1E73 1E72 +1E73 1E73 1E72 +1E74 1E75 1E74 +1E75 1E75 1E74 +1E76 1E77 1E76 +1E77 1E77 1E76 +1E78 1E79 1E78 +1E79 1E79 1E78 +1E7A 1E7B 1E7A +1E7B 1E7B 1E7A +1E7C 1E7D 1E7C +1E7D 1E7D 1E7C +1E7E 1E7F 1E7E +1E7F 1E7F 1E7E +1E80 1E81 1E80 +1E81 1E81 1E80 +1E82 1E83 1E82 +1E83 1E83 1E82 +1E84 1E85 1E84 +1E85 1E85 1E84 +1E86 1E87 1E86 +1E87 1E87 1E86 +1E88 1E89 1E88 +1E89 1E89 1E88 +1E8A 1E8B 1E8A +1E8B 1E8B 1E8A +1E8C 1E8D 1E8C +1E8D 1E8D 1E8C +1E8E 1E8F 1E8E +1E8F 1E8F 1E8E +1E90 1E91 1E90 +1E91 1E91 1E90 +1E92 1E93 1E92 +1E93 1E93 1E92 +1E94 1E95 1E94 +1E95 1E95 1E94 +1E9B 1E9B 1E60 +1E9E 00DF 1E9E +1EA0 1EA1 1EA0 +1EA1 1EA1 1EA0 +1EA2 1EA3 1EA2 +1EA3 1EA3 1EA2 +1EA4 1EA5 1EA4 +1EA5 1EA5 1EA4 +1EA6 1EA7 1EA6 +1EA7 1EA7 1EA6 +1EA8 1EA9 1EA8 +1EA9 1EA9 1EA8 +1EAA 1EAB 1EAA +1EAB 1EAB 1EAA +1EAC 1EAD 1EAC +1EAD 1EAD 1EAC +1EAE 1EAF 1EAE +1EAF 1EAF 1EAE +1EB0 1EB1 1EB0 +1EB1 1EB1 1EB0 +1EB2 1EB3 1EB2 +1EB3 1EB3 1EB2 +1EB4 1EB5 1EB4 +1EB5 1EB5 1EB4 +1EB6 1EB7 1EB6 +1EB7 1EB7 1EB6 +1EB8 1EB9 1EB8 +1EB9 1EB9 1EB8 +1EBA 1EBB 1EBA +1EBB 1EBB 1EBA +1EBC 1EBD 1EBC +1EBD 1EBD 1EBC +1EBE 1EBF 1EBE +1EBF 1EBF 1EBE +1EC0 1EC1 1EC0 +1EC1 1EC1 1EC0 +1EC2 1EC3 1EC2 +1EC3 1EC3 1EC2 +1EC4 1EC5 1EC4 +1EC5 1EC5 1EC4 +1EC6 1EC7 1EC6 +1EC7 1EC7 1EC6 +1EC8 1EC9 1EC8 +1EC9 1EC9 1EC8 +1ECA 1ECB 1ECA +1ECB 1ECB 1ECA +1ECC 1ECD 1ECC +1ECD 1ECD 1ECC +1ECE 1ECF 1ECE +1ECF 1ECF 1ECE +1ED0 1ED1 1ED0 +1ED1 1ED1 1ED0 +1ED2 1ED3 1ED2 +1ED3 1ED3 1ED2 +1ED4 1ED5 1ED4 +1ED5 1ED5 1ED4 +1ED6 1ED7 1ED6 +1ED7 1ED7 1ED6 +1ED8 1ED9 1ED8 +1ED9 1ED9 1ED8 +1EDA 1EDB 1EDA +1EDB 1EDB 1EDA +1EDC 1EDD 1EDC +1EDD 1EDD 1EDC +1EDE 1EDF 1EDE +1EDF 1EDF 1EDE +1EE0 1EE1 1EE0 +1EE1 1EE1 1EE0 +1EE2 1EE3 1EE2 +1EE3 1EE3 1EE2 +1EE4 1EE5 1EE4 +1EE5 1EE5 1EE4 +1EE6 1EE7 1EE6 +1EE7 1EE7 1EE6 +1EE8 1EE9 1EE8 +1EE9 1EE9 1EE8 +1EEA 1EEB 1EEA +1EEB 1EEB 1EEA +1EEC 1EED 1EEC +1EED 1EED 1EEC +1EEE 1EEF 1EEE +1EEF 1EEF 1EEE +1EF0 1EF1 1EF0 +1EF1 1EF1 1EF0 +1EF2 1EF3 1EF2 +1EF3 1EF3 1EF2 +1EF4 1EF5 1EF4 +1EF5 1EF5 1EF4 +1EF6 1EF7 1EF6 +1EF7 1EF7 1EF6 +1EF8 1EF9 1EF8 +1EF9 1EF9 1EF8 +1EFA 1EFB 1EFA +1EFB 1EFB 1EFA +1EFC 1EFD 1EFC +1EFD 1EFD 1EFC +1EFE 1EFF 1EFE +1EFF 1EFF 1EFE +1F00 1F00 1F08 +1F01 1F01 1F09 +1F02 1F02 1F0A +1F03 1F03 1F0B +1F04 1F04 1F0C +1F05 1F05 1F0D +1F06 1F06 1F0E +1F07 1F07 1F0F +1F08 1F00 1F08 +1F09 1F01 1F09 +1F0A 1F02 1F0A +1F0B 1F03 1F0B +1F0C 1F04 1F0C +1F0D 1F05 1F0D +1F0E 1F06 1F0E +1F0F 1F07 1F0F +1F10 1F10 1F18 +1F11 1F11 1F19 +1F12 1F12 1F1A +1F13 1F13 1F1B +1F14 1F14 1F1C +1F15 1F15 1F1D +1F18 1F10 1F18 +1F19 1F11 1F19 +1F1A 1F12 1F1A +1F1B 1F13 1F1B +1F1C 1F14 1F1C +1F1D 1F15 1F1D +1F20 1F20 1F28 +1F21 1F21 1F29 +1F22 1F22 1F2A +1F23 1F23 1F2B +1F24 1F24 1F2C +1F25 1F25 1F2D +1F26 1F26 1F2E +1F27 1F27 1F2F +1F28 1F20 1F28 +1F29 1F21 1F29 +1F2A 1F22 1F2A +1F2B 1F23 1F2B +1F2C 1F24 1F2C +1F2D 1F25 1F2D +1F2E 1F26 1F2E +1F2F 1F27 1F2F +1F30 1F30 1F38 +1F31 1F31 1F39 +1F32 1F32 1F3A +1F33 1F33 1F3B +1F34 1F34 1F3C +1F35 1F35 1F3D +1F36 1F36 1F3E +1F37 1F37 1F3F +1F38 1F30 1F38 +1F39 1F31 1F39 +1F3A 1F32 1F3A +1F3B 1F33 1F3B +1F3C 1F34 1F3C +1F3D 1F35 1F3D +1F3E 1F36 1F3E +1F3F 1F37 1F3F +1F40 1F40 1F48 +1F41 1F41 1F49 +1F42 1F42 1F4A +1F43 1F43 1F4B +1F44 1F44 1F4C +1F45 1F45 1F4D +1F48 1F40 1F48 +1F49 1F41 1F49 +1F4A 1F42 1F4A +1F4B 1F43 1F4B +1F4C 1F44 1F4C +1F4D 1F45 1F4D +1F51 1F51 1F59 +1F53 1F53 1F5B +1F55 1F55 1F5D +1F57 1F57 1F5F +1F59 1F51 1F59 +1F5B 1F53 1F5B +1F5D 1F55 1F5D +1F5F 1F57 1F5F +1F60 1F60 1F68 +1F61 1F61 1F69 +1F62 1F62 1F6A +1F63 1F63 1F6B +1F64 1F64 1F6C +1F65 1F65 1F6D +1F66 1F66 1F6E +1F67 1F67 1F6F +1F68 1F60 1F68 +1F69 1F61 1F69 +1F6A 1F62 1F6A +1F6B 1F63 1F6B +1F6C 1F64 1F6C +1F6D 1F65 1F6D +1F6E 1F66 1F6E +1F6F 1F67 1F6F +1F70 1F70 1FBA +1F71 1F71 1FBB +1F72 1F72 1FC8 +1F73 1F73 1FC9 +1F74 1F74 1FCA +1F75 1F75 1FCB +1F76 1F76 1FDA +1F77 1F77 1FDB +1F78 1F78 1FF8 +1F79 1F79 1FF9 +1F7A 1F7A 1FEA +1F7B 1F7B 1FEB +1F7C 1F7C 1FFA +1F7D 1F7D 1FFB +1F80 1F80 1F88 +1F81 1F81 1F89 +1F82 1F82 1F8A +1F83 1F83 1F8B +1F84 1F84 1F8C +1F85 1F85 1F8D +1F86 1F86 1F8E +1F87 1F87 1F8F +1F88 1F80 1F88 +1F89 1F81 1F89 +1F8A 1F82 1F8A +1F8B 1F83 1F8B +1F8C 1F84 1F8C +1F8D 1F85 1F8D +1F8E 1F86 1F8E +1F8F 1F87 1F8F +1F90 1F90 1F98 +1F91 1F91 1F99 +1F92 1F92 1F9A +1F93 1F93 1F9B +1F94 1F94 1F9C +1F95 1F95 1F9D +1F96 1F96 1F9E +1F97 1F97 1F9F +1F98 1F90 1F98 +1F99 1F91 1F99 +1F9A 1F92 1F9A +1F9B 1F93 1F9B +1F9C 1F94 1F9C +1F9D 1F95 1F9D +1F9E 1F96 1F9E +1F9F 1F97 1F9F +1FA0 1FA0 1FA8 +1FA1 1FA1 1FA9 +1FA2 1FA2 1FAA +1FA3 1FA3 1FAB +1FA4 1FA4 1FAC +1FA5 1FA5 1FAD +1FA6 1FA6 1FAE +1FA7 1FA7 1FAF +1FA8 1FA0 1FA8 +1FA9 1FA1 1FA9 +1FAA 1FA2 1FAA +1FAB 1FA3 1FAB +1FAC 1FA4 1FAC +1FAD 1FA5 1FAD +1FAE 1FA6 1FAE +1FAF 1FA7 1FAF +1FB0 1FB0 1FB8 +1FB1 1FB1 1FB9 +1FB3 1FB3 1FBC +1FB8 1FB0 1FB8 +1FB9 1FB1 1FB9 +1FBA 1F70 1FBA +1FBB 1F71 1FBB +1FBC 1FB3 1FBC +1FBE 1FBE 0399 +1FC3 1FC3 1FCC +1FC8 1F72 1FC8 +1FC9 1F73 1FC9 +1FCA 1F74 1FCA +1FCB 1F75 1FCB +1FCC 1FC3 1FCC +1FD0 1FD0 1FD8 +1FD1 1FD1 1FD9 +1FD8 1FD0 1FD8 +1FD9 1FD1 1FD9 +1FDA 1F76 1FDA +1FDB 1F77 1FDB +1FE0 1FE0 1FE8 +1FE1 1FE1 1FE9 +1FE5 1FE5 1FEC +1FE8 1FE0 1FE8 +1FE9 1FE1 1FE9 +1FEA 1F7A 1FEA +1FEB 1F7B 1FEB +1FEC 1FE5 1FEC +1FF3 1FF3 1FFC +1FF8 1F78 1FF8 +1FF9 1F79 1FF9 +1FFA 1F7C 1FFA +1FFB 1F7D 1FFB +1FFC 1FF3 1FFC +2126 03C9 2126 +212A 006B 212A +212B 00E5 212B +2132 214E 2132 +214E 214E 2132 +2160 2170 2160 +2161 2171 2161 +2162 2172 2162 +2163 2173 2163 +2164 2174 2164 +2165 2175 2165 +2166 2176 2166 +2167 2177 2167 +2168 2178 2168 +2169 2179 2169 +216A 217A 216A +216B 217B 216B +216C 217C 216C +216D 217D 216D +216E 217E 216E +216F 217F 216F +2170 2170 2160 +2171 2171 2161 +2172 2172 2162 +2173 2173 2163 +2174 2174 2164 +2175 2175 2165 +2176 2176 2166 +2177 2177 2167 +2178 2178 2168 +2179 2179 2169 +217A 217A 216A +217B 217B 216B +217C 217C 216C +217D 217D 216D +217E 217E 216E +217F 217F 216F +2183 2184 2183 +2184 2184 2183 +24B6 24D0 24B6 +24B7 24D1 24B7 +24B8 24D2 24B8 +24B9 24D3 24B9 +24BA 24D4 24BA +24BB 24D5 24BB +24BC 24D6 24BC +24BD 24D7 24BD +24BE 24D8 24BE +24BF 24D9 24BF +24C0 24DA 24C0 +24C1 24DB 24C1 +24C2 24DC 24C2 +24C3 24DD 24C3 +24C4 24DE 24C4 +24C5 24DF 24C5 +24C6 24E0 24C6 +24C7 24E1 24C7 +24C8 24E2 24C8 +24C9 24E3 24C9 +24CA 24E4 24CA +24CB 24E5 24CB +24CC 24E6 24CC +24CD 24E7 24CD +24CE 24E8 24CE +24CF 24E9 24CF +24D0 24D0 24B6 +24D1 24D1 24B7 +24D2 24D2 24B8 +24D3 24D3 24B9 +24D4 24D4 24BA +24D5 24D5 24BB +24D6 24D6 24BC +24D7 24D7 24BD +24D8 24D8 24BE +24D9 24D9 24BF +24DA 24DA 24C0 +24DB 24DB 24C1 +24DC 24DC 24C2 +24DD 24DD 24C3 +24DE 24DE 24C4 +24DF 24DF 24C5 +24E0 24E0 24C6 +24E1 24E1 24C7 +24E2 24E2 24C8 +24E3 24E3 24C9 +24E4 24E4 24CA +24E5 24E5 24CB +24E6 24E6 24CC +24E7 24E7 24CD +24E8 24E8 24CE +24E9 24E9 24CF +2C00 2C30 2C00 +2C01 2C31 2C01 +2C02 2C32 2C02 +2C03 2C33 2C03 +2C04 2C34 2C04 +2C05 2C35 2C05 +2C06 2C36 2C06 +2C07 2C37 2C07 +2C08 2C38 2C08 +2C09 2C39 2C09 +2C0A 2C3A 2C0A +2C0B 2C3B 2C0B +2C0C 2C3C 2C0C +2C0D 2C3D 2C0D +2C0E 2C3E 2C0E +2C0F 2C3F 2C0F +2C10 2C40 2C10 +2C11 2C41 2C11 +2C12 2C42 2C12 +2C13 2C43 2C13 +2C14 2C44 2C14 +2C15 2C45 2C15 +2C16 2C46 2C16 +2C17 2C47 2C17 +2C18 2C48 2C18 +2C19 2C49 2C19 +2C1A 2C4A 2C1A +2C1B 2C4B 2C1B +2C1C 2C4C 2C1C +2C1D 2C4D 2C1D +2C1E 2C4E 2C1E +2C1F 2C4F 2C1F +2C20 2C50 2C20 +2C21 2C51 2C21 +2C22 2C52 2C22 +2C23 2C53 2C23 +2C24 2C54 2C24 +2C25 2C55 2C25 +2C26 2C56 2C26 +2C27 2C57 2C27 +2C28 2C58 2C28 +2C29 2C59 2C29 +2C2A 2C5A 2C2A +2C2B 2C5B 2C2B +2C2C 2C5C 2C2C +2C2D 2C5D 2C2D +2C2E 2C5E 2C2E +2C2F 2C5F 2C2F +2C30 2C30 2C00 +2C31 2C31 2C01 +2C32 2C32 2C02 +2C33 2C33 2C03 +2C34 2C34 2C04 +2C35 2C35 2C05 +2C36 2C36 2C06 +2C37 2C37 2C07 +2C38 2C38 2C08 +2C39 2C39 2C09 +2C3A 2C3A 2C0A +2C3B 2C3B 2C0B +2C3C 2C3C 2C0C +2C3D 2C3D 2C0D +2C3E 2C3E 2C0E +2C3F 2C3F 2C0F +2C40 2C40 2C10 +2C41 2C41 2C11 +2C42 2C42 2C12 +2C43 2C43 2C13 +2C44 2C44 2C14 +2C45 2C45 2C15 +2C46 2C46 2C16 +2C47 2C47 2C17 +2C48 2C48 2C18 +2C49 2C49 2C19 +2C4A 2C4A 2C1A +2C4B 2C4B 2C1B +2C4C 2C4C 2C1C +2C4D 2C4D 2C1D +2C4E 2C4E 2C1E +2C4F 2C4F 2C1F +2C50 2C50 2C20 +2C51 2C51 2C21 +2C52 2C52 2C22 +2C53 2C53 2C23 +2C54 2C54 2C24 +2C55 2C55 2C25 +2C56 2C56 2C26 +2C57 2C57 2C27 +2C58 2C58 2C28 +2C59 2C59 2C29 +2C5A 2C5A 2C2A +2C5B 2C5B 2C2B +2C5C 2C5C 2C2C +2C5D 2C5D 2C2D +2C5E 2C5E 2C2E +2C5F 2C5F 2C2F +2C60 2C61 2C60 +2C61 2C61 2C60 +2C62 026B 2C62 +2C63 1D7D 2C63 +2C64 027D 2C64 +2C65 2C65 023A +2C66 2C66 023E +2C67 2C68 2C67 +2C68 2C68 2C67 +2C69 2C6A 2C69 +2C6A 2C6A 2C69 +2C6B 2C6C 2C6B +2C6C 2C6C 2C6B +2C6D 0251 2C6D +2C6E 0271 2C6E +2C6F 0250 2C6F +2C70 0252 2C70 +2C72 2C73 2C72 +2C73 2C73 2C72 +2C75 2C76 2C75 +2C76 2C76 2C75 +2C7E 023F 2C7E +2C7F 0240 2C7F +2C80 2C81 2C80 +2C81 2C81 2C80 +2C82 2C83 2C82 +2C83 2C83 2C82 +2C84 2C85 2C84 +2C85 2C85 2C84 +2C86 2C87 2C86 +2C87 2C87 2C86 +2C88 2C89 2C88 +2C89 2C89 2C88 +2C8A 2C8B 2C8A +2C8B 2C8B 2C8A +2C8C 2C8D 2C8C +2C8D 2C8D 2C8C +2C8E 2C8F 2C8E +2C8F 2C8F 2C8E +2C90 2C91 2C90 +2C91 2C91 2C90 +2C92 2C93 2C92 +2C93 2C93 2C92 +2C94 2C95 2C94 +2C95 2C95 2C94 +2C96 2C97 2C96 +2C97 2C97 2C96 +2C98 2C99 2C98 +2C99 2C99 2C98 +2C9A 2C9B 2C9A +2C9B 2C9B 2C9A +2C9C 2C9D 2C9C +2C9D 2C9D 2C9C +2C9E 2C9F 2C9E +2C9F 2C9F 2C9E +2CA0 2CA1 2CA0 +2CA1 2CA1 2CA0 +2CA2 2CA3 2CA2 +2CA3 2CA3 2CA2 +2CA4 2CA5 2CA4 +2CA5 2CA5 2CA4 +2CA6 2CA7 2CA6 +2CA7 2CA7 2CA6 +2CA8 2CA9 2CA8 +2CA9 2CA9 2CA8 +2CAA 2CAB 2CAA +2CAB 2CAB 2CAA +2CAC 2CAD 2CAC +2CAD 2CAD 2CAC +2CAE 2CAF 2CAE +2CAF 2CAF 2CAE +2CB0 2CB1 2CB0 +2CB1 2CB1 2CB0 +2CB2 2CB3 2CB2 +2CB3 2CB3 2CB2 +2CB4 2CB5 2CB4 +2CB5 2CB5 2CB4 +2CB6 2CB7 2CB6 +2CB7 2CB7 2CB6 +2CB8 2CB9 2CB8 +2CB9 2CB9 2CB8 +2CBA 2CBB 2CBA +2CBB 2CBB 2CBA +2CBC 2CBD 2CBC +2CBD 2CBD 2CBC +2CBE 2CBF 2CBE +2CBF 2CBF 2CBE +2CC0 2CC1 2CC0 +2CC1 2CC1 2CC0 +2CC2 2CC3 2CC2 +2CC3 2CC3 2CC2 +2CC4 2CC5 2CC4 +2CC5 2CC5 2CC4 +2CC6 2CC7 2CC6 +2CC7 2CC7 2CC6 +2CC8 2CC9 2CC8 +2CC9 2CC9 2CC8 +2CCA 2CCB 2CCA +2CCB 2CCB 2CCA +2CCC 2CCD 2CCC +2CCD 2CCD 2CCC +2CCE 2CCF 2CCE +2CCF 2CCF 2CCE +2CD0 2CD1 2CD0 +2CD1 2CD1 2CD0 +2CD2 2CD3 2CD2 +2CD3 2CD3 2CD2 +2CD4 2CD5 2CD4 +2CD5 2CD5 2CD4 +2CD6 2CD7 2CD6 +2CD7 2CD7 2CD6 +2CD8 2CD9 2CD8 +2CD9 2CD9 2CD8 +2CDA 2CDB 2CDA +2CDB 2CDB 2CDA +2CDC 2CDD 2CDC +2CDD 2CDD 2CDC +2CDE 2CDF 2CDE +2CDF 2CDF 2CDE +2CE0 2CE1 2CE0 +2CE1 2CE1 2CE0 +2CE2 2CE3 2CE2 +2CE3 2CE3 2CE2 +2CEB 2CEC 2CEB +2CEC 2CEC 2CEB +2CED 2CEE 2CED +2CEE 2CEE 2CED +2CF2 2CF3 2CF2 +2CF3 2CF3 2CF2 +2D00 2D00 10A0 +2D01 2D01 10A1 +2D02 2D02 10A2 +2D03 2D03 10A3 +2D04 2D04 10A4 +2D05 2D05 10A5 +2D06 2D06 10A6 +2D07 2D07 10A7 +2D08 2D08 10A8 +2D09 2D09 10A9 +2D0A 2D0A 10AA +2D0B 2D0B 10AB +2D0C 2D0C 10AC +2D0D 2D0D 10AD +2D0E 2D0E 10AE +2D0F 2D0F 10AF +2D10 2D10 10B0 +2D11 2D11 10B1 +2D12 2D12 10B2 +2D13 2D13 10B3 +2D14 2D14 10B4 +2D15 2D15 10B5 +2D16 2D16 10B6 +2D17 2D17 10B7 +2D18 2D18 10B8 +2D19 2D19 10B9 +2D1A 2D1A 10BA +2D1B 2D1B 10BB +2D1C 2D1C 10BC +2D1D 2D1D 10BD +2D1E 2D1E 10BE +2D1F 2D1F 10BF +2D20 2D20 10C0 +2D21 2D21 10C1 +2D22 2D22 10C2 +2D23 2D23 10C3 +2D24 2D24 10C4 +2D25 2D25 10C5 +2D27 2D27 10C7 +2D2D 2D2D 10CD +A640 A641 A640 +A641 A641 A640 +A642 A643 A642 +A643 A643 A642 +A644 A645 A644 +A645 A645 A644 +A646 A647 A646 +A647 A647 A646 +A648 A649 A648 +A649 A649 A648 +A64A A64B A64A +A64B A64B A64A +A64C A64D A64C +A64D A64D A64C +A64E A64F A64E +A64F A64F A64E +A650 A651 A650 +A651 A651 A650 +A652 A653 A652 +A653 A653 A652 +A654 A655 A654 +A655 A655 A654 +A656 A657 A656 +A657 A657 A656 +A658 A659 A658 +A659 A659 A658 +A65A A65B A65A +A65B A65B A65A +A65C A65D A65C +A65D A65D A65C +A65E A65F A65E +A65F A65F A65E +A660 A661 A660 +A661 A661 A660 +A662 A663 A662 +A663 A663 A662 +A664 A665 A664 +A665 A665 A664 +A666 A667 A666 +A667 A667 A666 +A668 A669 A668 +A669 A669 A668 +A66A A66B A66A +A66B A66B A66A +A66C A66D A66C +A66D A66D A66C +A680 A681 A680 +A681 A681 A680 +A682 A683 A682 +A683 A683 A682 +A684 A685 A684 +A685 A685 A684 +A686 A687 A686 +A687 A687 A686 +A688 A689 A688 +A689 A689 A688 +A68A A68B A68A +A68B A68B A68A +A68C A68D A68C +A68D A68D A68C +A68E A68F A68E +A68F A68F A68E +A690 A691 A690 +A691 A691 A690 +A692 A693 A692 +A693 A693 A692 +A694 A695 A694 +A695 A695 A694 +A696 A697 A696 +A697 A697 A696 +A698 A699 A698 +A699 A699 A698 +A69A A69B A69A +A69B A69B A69A +A722 A723 A722 +A723 A723 A722 +A724 A725 A724 +A725 A725 A724 +A726 A727 A726 +A727 A727 A726 +A728 A729 A728 +A729 A729 A728 +A72A A72B A72A +A72B A72B A72A +A72C A72D A72C +A72D A72D A72C +A72E A72F A72E +A72F A72F A72E +A732 A733 A732 +A733 A733 A732 +A734 A735 A734 +A735 A735 A734 +A736 A737 A736 +A737 A737 A736 +A738 A739 A738 +A739 A739 A738 +A73A A73B A73A +A73B A73B A73A +A73C A73D A73C +A73D A73D A73C +A73E A73F A73E +A73F A73F A73E +A740 A741 A740 +A741 A741 A740 +A742 A743 A742 +A743 A743 A742 +A744 A745 A744 +A745 A745 A744 +A746 A747 A746 +A747 A747 A746 +A748 A749 A748 +A749 A749 A748 +A74A A74B A74A +A74B A74B A74A +A74C A74D A74C +A74D A74D A74C +A74E A74F A74E +A74F A74F A74E +A750 A751 A750 +A751 A751 A750 +A752 A753 A752 +A753 A753 A752 +A754 A755 A754 +A755 A755 A754 +A756 A757 A756 +A757 A757 A756 +A758 A759 A758 +A759 A759 A758 +A75A A75B A75A +A75B A75B A75A +A75C A75D A75C +A75D A75D A75C +A75E A75F A75E +A75F A75F A75E +A760 A761 A760 +A761 A761 A760 +A762 A763 A762 +A763 A763 A762 +A764 A765 A764 +A765 A765 A764 +A766 A767 A766 +A767 A767 A766 +A768 A769 A768 +A769 A769 A768 +A76A A76B A76A +A76B A76B A76A +A76C A76D A76C +A76D A76D A76C +A76E A76F A76E +A76F A76F A76E +A779 A77A A779 +A77A A77A A779 +A77B A77C A77B +A77C A77C A77B +A77D 1D79 A77D +A77E A77F A77E +A77F A77F A77E +A780 A781 A780 +A781 A781 A780 +A782 A783 A782 +A783 A783 A782 +A784 A785 A784 +A785 A785 A784 +A786 A787 A786 +A787 A787 A786 +A78B A78C A78B +A78C A78C A78B +A78D 0265 A78D +A790 A791 A790 +A791 A791 A790 +A792 A793 A792 +A793 A793 A792 +A794 A794 A7C4 +A796 A797 A796 +A797 A797 A796 +A798 A799 A798 +A799 A799 A798 +A79A A79B A79A +A79B A79B A79A +A79C A79D A79C +A79D A79D A79C +A79E A79F A79E +A79F A79F A79E +A7A0 A7A1 A7A0 +A7A1 A7A1 A7A0 +A7A2 A7A3 A7A2 +A7A3 A7A3 A7A2 +A7A4 A7A5 A7A4 +A7A5 A7A5 A7A4 +A7A6 A7A7 A7A6 +A7A7 A7A7 A7A6 +A7A8 A7A9 A7A8 +A7A9 A7A9 A7A8 +A7AA 0266 A7AA +A7AB 025C A7AB +A7AC 0261 A7AC +A7AD 026C A7AD +A7AE 026A A7AE +A7B0 029E A7B0 +A7B1 0287 A7B1 +A7B2 029D A7B2 +A7B3 AB53 A7B3 +A7B4 A7B5 A7B4 +A7B5 A7B5 A7B4 +A7B6 A7B7 A7B6 +A7B7 A7B7 A7B6 +A7B8 A7B9 A7B8 +A7B9 A7B9 A7B8 +A7BA A7BB A7BA +A7BB A7BB A7BA +A7BC A7BD A7BC +A7BD A7BD A7BC +A7BE A7BF A7BE +A7BF A7BF A7BE +A7C0 A7C1 A7C0 +A7C1 A7C1 A7C0 +A7C2 A7C3 A7C2 +A7C3 A7C3 A7C2 +A7C4 A794 A7C4 +A7C5 0282 A7C5 +A7C6 1D8E A7C6 +A7C7 A7C8 A7C7 +A7C8 A7C8 A7C7 +A7C9 A7CA A7C9 +A7CA A7CA A7C9 +A7D0 A7D1 A7D0 +A7D1 A7D1 A7D0 +A7D6 A7D7 A7D6 +A7D7 A7D7 A7D6 +A7D8 A7D9 A7D8 +A7D9 A7D9 A7D8 +A7F5 A7F6 A7F5 +A7F6 A7F6 A7F5 +AB53 AB53 A7B3 +AB70 AB70 13A0 +AB71 AB71 13A1 +AB72 AB72 13A2 +AB73 AB73 13A3 +AB74 AB74 13A4 +AB75 AB75 13A5 +AB76 AB76 13A6 +AB77 AB77 13A7 +AB78 AB78 13A8 +AB79 AB79 13A9 +AB7A AB7A 13AA +AB7B AB7B 13AB +AB7C AB7C 13AC +AB7D AB7D 13AD +AB7E AB7E 13AE +AB7F AB7F 13AF +AB80 AB80 13B0 +AB81 AB81 13B1 +AB82 AB82 13B2 +AB83 AB83 13B3 +AB84 AB84 13B4 +AB85 AB85 13B5 +AB86 AB86 13B6 +AB87 AB87 13B7 +AB88 AB88 13B8 +AB89 AB89 13B9 +AB8A AB8A 13BA +AB8B AB8B 13BB +AB8C AB8C 13BC +AB8D AB8D 13BD +AB8E AB8E 13BE +AB8F AB8F 13BF +AB90 AB90 13C0 +AB91 AB91 13C1 +AB92 AB92 13C2 +AB93 AB93 13C3 +AB94 AB94 13C4 +AB95 AB95 13C5 +AB96 AB96 13C6 +AB97 AB97 13C7 +AB98 AB98 13C8 +AB99 AB99 13C9 +AB9A AB9A 13CA +AB9B AB9B 13CB +AB9C AB9C 13CC +AB9D AB9D 13CD +AB9E AB9E 13CE +AB9F AB9F 13CF +ABA0 ABA0 13D0 +ABA1 ABA1 13D1 +ABA2 ABA2 13D2 +ABA3 ABA3 13D3 +ABA4 ABA4 13D4 +ABA5 ABA5 13D5 +ABA6 ABA6 13D6 +ABA7 ABA7 13D7 +ABA8 ABA8 13D8 +ABA9 ABA9 13D9 +ABAA ABAA 13DA +ABAB ABAB 13DB +ABAC ABAC 13DC +ABAD ABAD 13DD +ABAE ABAE 13DE +ABAF ABAF 13DF +ABB0 ABB0 13E0 +ABB1 ABB1 13E1 +ABB2 ABB2 13E2 +ABB3 ABB3 13E3 +ABB4 ABB4 13E4 +ABB5 ABB5 13E5 +ABB6 ABB6 13E6 +ABB7 ABB7 13E7 +ABB8 ABB8 13E8 +ABB9 ABB9 13E9 +ABBA ABBA 13EA +ABBB ABBB 13EB +ABBC ABBC 13EC +ABBD ABBD 13ED +ABBE ABBE 13EE +ABBF ABBF 13EF +FF21 FF41 FF21 +FF22 FF42 FF22 +FF23 FF43 FF23 +FF24 FF44 FF24 +FF25 FF45 FF25 +FF26 FF46 FF26 +FF27 FF47 FF27 +FF28 FF48 FF28 +FF29 FF49 FF29 +FF2A FF4A FF2A +FF2B FF4B FF2B +FF2C FF4C FF2C +FF2D FF4D FF2D +FF2E FF4E FF2E +FF2F FF4F FF2F +FF30 FF50 FF30 +FF31 FF51 FF31 +FF32 FF52 FF32 +FF33 FF53 FF33 +FF34 FF54 FF34 +FF35 FF55 FF35 +FF36 FF56 FF36 +FF37 FF57 FF37 +FF38 FF58 FF38 +FF39 FF59 FF39 +FF3A FF5A FF3A +FF41 FF41 FF21 +FF42 FF42 FF22 +FF43 FF43 FF23 +FF44 FF44 FF24 +FF45 FF45 FF25 +FF46 FF46 FF26 +FF47 FF47 FF27 +FF48 FF48 FF28 +FF49 FF49 FF29 +FF4A FF4A FF2A +FF4B FF4B FF2B +FF4C FF4C FF2C +FF4D FF4D FF2D +FF4E FF4E FF2E +FF4F FF4F FF2F +FF50 FF50 FF30 +FF51 FF51 FF31 +FF52 FF52 FF32 +FF53 FF53 FF33 +FF54 FF54 FF34 +FF55 FF55 FF35 +FF56 FF56 FF36 +FF57 FF57 FF37 +FF58 FF58 FF38 +FF59 FF59 FF39 +FF5A FF5A FF3A +DROP VIEW v_bmp; +EXECUTE IMMEDIATE SFORMAT(' +CREATE VIEW v_supplementary AS +SELECT + seq AS codepoint, + LPAD(HEX(seq),8,''0'') AS codepoint_hex8, + CONVERT(CHAR(seq USING utf32) USING {}) COLLATE {} AS c +FROM + seq_65536_to_1114111', @@character_set_connection, @@collation_connection); +SELECT COLLATION(c) FROM v_supplementary LIMIT 1; +COLLATION(c) +utf8mb4_uca1400_ai_ci +SELECT +codepoint_hex8, +HEX(CAST(LOWER(c) AS CHAR CHARACTER SET utf32)), +HEX(CAST(UPPER(c) AS CHAR CHARACTER SET utf32)) +FROM v_supplementary +WHERE BINARY(c)<>BINARY(LOWER(c)) OR BINARY(c)<>BINARY(UPPER(c)); +codepoint_hex8 HEX(CAST(LOWER(c) AS CHAR CHARACTER SET utf32)) HEX(CAST(UPPER(c) AS CHAR CHARACTER SET utf32)) +00010400 00010428 00010400 +00010401 00010429 00010401 +00010402 0001042A 00010402 +00010403 0001042B 00010403 +00010404 0001042C 00010404 +00010405 0001042D 00010405 +00010406 0001042E 00010406 +00010407 0001042F 00010407 +00010408 00010430 00010408 +00010409 00010431 00010409 +0001040A 00010432 0001040A +0001040B 00010433 0001040B +0001040C 00010434 0001040C +0001040D 00010435 0001040D +0001040E 00010436 0001040E +0001040F 00010437 0001040F +00010410 00010438 00010410 +00010411 00010439 00010411 +00010412 0001043A 00010412 +00010413 0001043B 00010413 +00010414 0001043C 00010414 +00010415 0001043D 00010415 +00010416 0001043E 00010416 +00010417 0001043F 00010417 +00010418 00010440 00010418 +00010419 00010441 00010419 +0001041A 00010442 0001041A +0001041B 00010443 0001041B +0001041C 00010444 0001041C +0001041D 00010445 0001041D +0001041E 00010446 0001041E +0001041F 00010447 0001041F +00010420 00010448 00010420 +00010421 00010449 00010421 +00010422 0001044A 00010422 +00010423 0001044B 00010423 +00010424 0001044C 00010424 +00010425 0001044D 00010425 +00010426 0001044E 00010426 +00010427 0001044F 00010427 +00010428 00010428 00010400 +00010429 00010429 00010401 +0001042A 0001042A 00010402 +0001042B 0001042B 00010403 +0001042C 0001042C 00010404 +0001042D 0001042D 00010405 +0001042E 0001042E 00010406 +0001042F 0001042F 00010407 +00010430 00010430 00010408 +00010431 00010431 00010409 +00010432 00010432 0001040A +00010433 00010433 0001040B +00010434 00010434 0001040C +00010435 00010435 0001040D +00010436 00010436 0001040E +00010437 00010437 0001040F +00010438 00010438 00010410 +00010439 00010439 00010411 +0001043A 0001043A 00010412 +0001043B 0001043B 00010413 +0001043C 0001043C 00010414 +0001043D 0001043D 00010415 +0001043E 0001043E 00010416 +0001043F 0001043F 00010417 +00010440 00010440 00010418 +00010441 00010441 00010419 +00010442 00010442 0001041A +00010443 00010443 0001041B +00010444 00010444 0001041C +00010445 00010445 0001041D +00010446 00010446 0001041E +00010447 00010447 0001041F +00010448 00010448 00010420 +00010449 00010449 00010421 +0001044A 0001044A 00010422 +0001044B 0001044B 00010423 +0001044C 0001044C 00010424 +0001044D 0001044D 00010425 +0001044E 0001044E 00010426 +0001044F 0001044F 00010427 +000104B0 000104D8 000104B0 +000104B1 000104D9 000104B1 +000104B2 000104DA 000104B2 +000104B3 000104DB 000104B3 +000104B4 000104DC 000104B4 +000104B5 000104DD 000104B5 +000104B6 000104DE 000104B6 +000104B7 000104DF 000104B7 +000104B8 000104E0 000104B8 +000104B9 000104E1 000104B9 +000104BA 000104E2 000104BA +000104BB 000104E3 000104BB +000104BC 000104E4 000104BC +000104BD 000104E5 000104BD +000104BE 000104E6 000104BE +000104BF 000104E7 000104BF +000104C0 000104E8 000104C0 +000104C1 000104E9 000104C1 +000104C2 000104EA 000104C2 +000104C3 000104EB 000104C3 +000104C4 000104EC 000104C4 +000104C5 000104ED 000104C5 +000104C6 000104EE 000104C6 +000104C7 000104EF 000104C7 +000104C8 000104F0 000104C8 +000104C9 000104F1 000104C9 +000104CA 000104F2 000104CA +000104CB 000104F3 000104CB +000104CC 000104F4 000104CC +000104CD 000104F5 000104CD +000104CE 000104F6 000104CE +000104CF 000104F7 000104CF +000104D0 000104F8 000104D0 +000104D1 000104F9 000104D1 +000104D2 000104FA 000104D2 +000104D3 000104FB 000104D3 +000104D8 000104D8 000104B0 +000104D9 000104D9 000104B1 +000104DA 000104DA 000104B2 +000104DB 000104DB 000104B3 +000104DC 000104DC 000104B4 +000104DD 000104DD 000104B5 +000104DE 000104DE 000104B6 +000104DF 000104DF 000104B7 +000104E0 000104E0 000104B8 +000104E1 000104E1 000104B9 +000104E2 000104E2 000104BA +000104E3 000104E3 000104BB +000104E4 000104E4 000104BC +000104E5 000104E5 000104BD +000104E6 000104E6 000104BE +000104E7 000104E7 000104BF +000104E8 000104E8 000104C0 +000104E9 000104E9 000104C1 +000104EA 000104EA 000104C2 +000104EB 000104EB 000104C3 +000104EC 000104EC 000104C4 +000104ED 000104ED 000104C5 +000104EE 000104EE 000104C6 +000104EF 000104EF 000104C7 +000104F0 000104F0 000104C8 +000104F1 000104F1 000104C9 +000104F2 000104F2 000104CA +000104F3 000104F3 000104CB +000104F4 000104F4 000104CC +000104F5 000104F5 000104CD +000104F6 000104F6 000104CE +000104F7 000104F7 000104CF +000104F8 000104F8 000104D0 +000104F9 000104F9 000104D1 +000104FA 000104FA 000104D2 +000104FB 000104FB 000104D3 +00010570 00010597 00010570 +00010571 00010598 00010571 +00010572 00010599 00010572 +00010573 0001059A 00010573 +00010574 0001059B 00010574 +00010575 0001059C 00010575 +00010576 0001059D 00010576 +00010577 0001059E 00010577 +00010578 0001059F 00010578 +00010579 000105A0 00010579 +0001057A 000105A1 0001057A +0001057C 000105A3 0001057C +0001057D 000105A4 0001057D +0001057E 000105A5 0001057E +0001057F 000105A6 0001057F +00010580 000105A7 00010580 +00010581 000105A8 00010581 +00010582 000105A9 00010582 +00010583 000105AA 00010583 +00010584 000105AB 00010584 +00010585 000105AC 00010585 +00010586 000105AD 00010586 +00010587 000105AE 00010587 +00010588 000105AF 00010588 +00010589 000105B0 00010589 +0001058A 000105B1 0001058A +0001058C 000105B3 0001058C +0001058D 000105B4 0001058D +0001058E 000105B5 0001058E +0001058F 000105B6 0001058F +00010590 000105B7 00010590 +00010591 000105B8 00010591 +00010592 000105B9 00010592 +00010594 000105BB 00010594 +00010595 000105BC 00010595 +00010597 00010597 00010570 +00010598 00010598 00010571 +00010599 00010599 00010572 +0001059A 0001059A 00010573 +0001059B 0001059B 00010574 +0001059C 0001059C 00010575 +0001059D 0001059D 00010576 +0001059E 0001059E 00010577 +0001059F 0001059F 00010578 +000105A0 000105A0 00010579 +000105A1 000105A1 0001057A +000105A3 000105A3 0001057C +000105A4 000105A4 0001057D +000105A5 000105A5 0001057E +000105A6 000105A6 0001057F +000105A7 000105A7 00010580 +000105A8 000105A8 00010581 +000105A9 000105A9 00010582 +000105AA 000105AA 00010583 +000105AB 000105AB 00010584 +000105AC 000105AC 00010585 +000105AD 000105AD 00010586 +000105AE 000105AE 00010587 +000105AF 000105AF 00010588 +000105B0 000105B0 00010589 +000105B1 000105B1 0001058A +000105B3 000105B3 0001058C +000105B4 000105B4 0001058D +000105B5 000105B5 0001058E +000105B6 000105B6 0001058F +000105B7 000105B7 00010590 +000105B8 000105B8 00010591 +000105B9 000105B9 00010592 +000105BB 000105BB 00010594 +000105BC 000105BC 00010595 +00010C80 00010CC0 00010C80 +00010C81 00010CC1 00010C81 +00010C82 00010CC2 00010C82 +00010C83 00010CC3 00010C83 +00010C84 00010CC4 00010C84 +00010C85 00010CC5 00010C85 +00010C86 00010CC6 00010C86 +00010C87 00010CC7 00010C87 +00010C88 00010CC8 00010C88 +00010C89 00010CC9 00010C89 +00010C8A 00010CCA 00010C8A +00010C8B 00010CCB 00010C8B +00010C8C 00010CCC 00010C8C +00010C8D 00010CCD 00010C8D +00010C8E 00010CCE 00010C8E +00010C8F 00010CCF 00010C8F +00010C90 00010CD0 00010C90 +00010C91 00010CD1 00010C91 +00010C92 00010CD2 00010C92 +00010C93 00010CD3 00010C93 +00010C94 00010CD4 00010C94 +00010C95 00010CD5 00010C95 +00010C96 00010CD6 00010C96 +00010C97 00010CD7 00010C97 +00010C98 00010CD8 00010C98 +00010C99 00010CD9 00010C99 +00010C9A 00010CDA 00010C9A +00010C9B 00010CDB 00010C9B +00010C9C 00010CDC 00010C9C +00010C9D 00010CDD 00010C9D +00010C9E 00010CDE 00010C9E +00010C9F 00010CDF 00010C9F +00010CA0 00010CE0 00010CA0 +00010CA1 00010CE1 00010CA1 +00010CA2 00010CE2 00010CA2 +00010CA3 00010CE3 00010CA3 +00010CA4 00010CE4 00010CA4 +00010CA5 00010CE5 00010CA5 +00010CA6 00010CE6 00010CA6 +00010CA7 00010CE7 00010CA7 +00010CA8 00010CE8 00010CA8 +00010CA9 00010CE9 00010CA9 +00010CAA 00010CEA 00010CAA +00010CAB 00010CEB 00010CAB +00010CAC 00010CEC 00010CAC +00010CAD 00010CED 00010CAD +00010CAE 00010CEE 00010CAE +00010CAF 00010CEF 00010CAF +00010CB0 00010CF0 00010CB0 +00010CB1 00010CF1 00010CB1 +00010CB2 00010CF2 00010CB2 +00010CC0 00010CC0 00010C80 +00010CC1 00010CC1 00010C81 +00010CC2 00010CC2 00010C82 +00010CC3 00010CC3 00010C83 +00010CC4 00010CC4 00010C84 +00010CC5 00010CC5 00010C85 +00010CC6 00010CC6 00010C86 +00010CC7 00010CC7 00010C87 +00010CC8 00010CC8 00010C88 +00010CC9 00010CC9 00010C89 +00010CCA 00010CCA 00010C8A +00010CCB 00010CCB 00010C8B +00010CCC 00010CCC 00010C8C +00010CCD 00010CCD 00010C8D +00010CCE 00010CCE 00010C8E +00010CCF 00010CCF 00010C8F +00010CD0 00010CD0 00010C90 +00010CD1 00010CD1 00010C91 +00010CD2 00010CD2 00010C92 +00010CD3 00010CD3 00010C93 +00010CD4 00010CD4 00010C94 +00010CD5 00010CD5 00010C95 +00010CD6 00010CD6 00010C96 +00010CD7 00010CD7 00010C97 +00010CD8 00010CD8 00010C98 +00010CD9 00010CD9 00010C99 +00010CDA 00010CDA 00010C9A +00010CDB 00010CDB 00010C9B +00010CDC 00010CDC 00010C9C +00010CDD 00010CDD 00010C9D +00010CDE 00010CDE 00010C9E +00010CDF 00010CDF 00010C9F +00010CE0 00010CE0 00010CA0 +00010CE1 00010CE1 00010CA1 +00010CE2 00010CE2 00010CA2 +00010CE3 00010CE3 00010CA3 +00010CE4 00010CE4 00010CA4 +00010CE5 00010CE5 00010CA5 +00010CE6 00010CE6 00010CA6 +00010CE7 00010CE7 00010CA7 +00010CE8 00010CE8 00010CA8 +00010CE9 00010CE9 00010CA9 +00010CEA 00010CEA 00010CAA +00010CEB 00010CEB 00010CAB +00010CEC 00010CEC 00010CAC +00010CED 00010CED 00010CAD +00010CEE 00010CEE 00010CAE +00010CEF 00010CEF 00010CAF +00010CF0 00010CF0 00010CB0 +00010CF1 00010CF1 00010CB1 +00010CF2 00010CF2 00010CB2 +000118A0 000118C0 000118A0 +000118A1 000118C1 000118A1 +000118A2 000118C2 000118A2 +000118A3 000118C3 000118A3 +000118A4 000118C4 000118A4 +000118A5 000118C5 000118A5 +000118A6 000118C6 000118A6 +000118A7 000118C7 000118A7 +000118A8 000118C8 000118A8 +000118A9 000118C9 000118A9 +000118AA 000118CA 000118AA +000118AB 000118CB 000118AB +000118AC 000118CC 000118AC +000118AD 000118CD 000118AD +000118AE 000118CE 000118AE +000118AF 000118CF 000118AF +000118B0 000118D0 000118B0 +000118B1 000118D1 000118B1 +000118B2 000118D2 000118B2 +000118B3 000118D3 000118B3 +000118B4 000118D4 000118B4 +000118B5 000118D5 000118B5 +000118B6 000118D6 000118B6 +000118B7 000118D7 000118B7 +000118B8 000118D8 000118B8 +000118B9 000118D9 000118B9 +000118BA 000118DA 000118BA +000118BB 000118DB 000118BB +000118BC 000118DC 000118BC +000118BD 000118DD 000118BD +000118BE 000118DE 000118BE +000118BF 000118DF 000118BF +000118C0 000118C0 000118A0 +000118C1 000118C1 000118A1 +000118C2 000118C2 000118A2 +000118C3 000118C3 000118A3 +000118C4 000118C4 000118A4 +000118C5 000118C5 000118A5 +000118C6 000118C6 000118A6 +000118C7 000118C7 000118A7 +000118C8 000118C8 000118A8 +000118C9 000118C9 000118A9 +000118CA 000118CA 000118AA +000118CB 000118CB 000118AB +000118CC 000118CC 000118AC +000118CD 000118CD 000118AD +000118CE 000118CE 000118AE +000118CF 000118CF 000118AF +000118D0 000118D0 000118B0 +000118D1 000118D1 000118B1 +000118D2 000118D2 000118B2 +000118D3 000118D3 000118B3 +000118D4 000118D4 000118B4 +000118D5 000118D5 000118B5 +000118D6 000118D6 000118B6 +000118D7 000118D7 000118B7 +000118D8 000118D8 000118B8 +000118D9 000118D9 000118B9 +000118DA 000118DA 000118BA +000118DB 000118DB 000118BB +000118DC 000118DC 000118BC +000118DD 000118DD 000118BD +000118DE 000118DE 000118BE +000118DF 000118DF 000118BF +00016E40 00016E60 00016E40 +00016E41 00016E61 00016E41 +00016E42 00016E62 00016E42 +00016E43 00016E63 00016E43 +00016E44 00016E64 00016E44 +00016E45 00016E65 00016E45 +00016E46 00016E66 00016E46 +00016E47 00016E67 00016E47 +00016E48 00016E68 00016E48 +00016E49 00016E69 00016E49 +00016E4A 00016E6A 00016E4A +00016E4B 00016E6B 00016E4B +00016E4C 00016E6C 00016E4C +00016E4D 00016E6D 00016E4D +00016E4E 00016E6E 00016E4E +00016E4F 00016E6F 00016E4F +00016E50 00016E70 00016E50 +00016E51 00016E71 00016E51 +00016E52 00016E72 00016E52 +00016E53 00016E73 00016E53 +00016E54 00016E74 00016E54 +00016E55 00016E75 00016E55 +00016E56 00016E76 00016E56 +00016E57 00016E77 00016E57 +00016E58 00016E78 00016E58 +00016E59 00016E79 00016E59 +00016E5A 00016E7A 00016E5A +00016E5B 00016E7B 00016E5B +00016E5C 00016E7C 00016E5C +00016E5D 00016E7D 00016E5D +00016E5E 00016E7E 00016E5E +00016E5F 00016E7F 00016E5F +00016E60 00016E60 00016E40 +00016E61 00016E61 00016E41 +00016E62 00016E62 00016E42 +00016E63 00016E63 00016E43 +00016E64 00016E64 00016E44 +00016E65 00016E65 00016E45 +00016E66 00016E66 00016E46 +00016E67 00016E67 00016E47 +00016E68 00016E68 00016E48 +00016E69 00016E69 00016E49 +00016E6A 00016E6A 00016E4A +00016E6B 00016E6B 00016E4B +00016E6C 00016E6C 00016E4C +00016E6D 00016E6D 00016E4D +00016E6E 00016E6E 00016E4E +00016E6F 00016E6F 00016E4F +00016E70 00016E70 00016E50 +00016E71 00016E71 00016E51 +00016E72 00016E72 00016E52 +00016E73 00016E73 00016E53 +00016E74 00016E74 00016E54 +00016E75 00016E75 00016E55 +00016E76 00016E76 00016E56 +00016E77 00016E77 00016E57 +00016E78 00016E78 00016E58 +00016E79 00016E79 00016E59 +00016E7A 00016E7A 00016E5A +00016E7B 00016E7B 00016E5B +00016E7C 00016E7C 00016E5C +00016E7D 00016E7D 00016E5D +00016E7E 00016E7E 00016E5E +00016E7F 00016E7F 00016E5F +0001E900 0001E922 0001E900 +0001E901 0001E923 0001E901 +0001E902 0001E924 0001E902 +0001E903 0001E925 0001E903 +0001E904 0001E926 0001E904 +0001E905 0001E927 0001E905 +0001E906 0001E928 0001E906 +0001E907 0001E929 0001E907 +0001E908 0001E92A 0001E908 +0001E909 0001E92B 0001E909 +0001E90A 0001E92C 0001E90A +0001E90B 0001E92D 0001E90B +0001E90C 0001E92E 0001E90C +0001E90D 0001E92F 0001E90D +0001E90E 0001E930 0001E90E +0001E90F 0001E931 0001E90F +0001E910 0001E932 0001E910 +0001E911 0001E933 0001E911 +0001E912 0001E934 0001E912 +0001E913 0001E935 0001E913 +0001E914 0001E936 0001E914 +0001E915 0001E937 0001E915 +0001E916 0001E938 0001E916 +0001E917 0001E939 0001E917 +0001E918 0001E93A 0001E918 +0001E919 0001E93B 0001E919 +0001E91A 0001E93C 0001E91A +0001E91B 0001E93D 0001E91B +0001E91C 0001E93E 0001E91C +0001E91D 0001E93F 0001E91D +0001E91E 0001E940 0001E91E +0001E91F 0001E941 0001E91F +0001E920 0001E942 0001E920 +0001E921 0001E943 0001E921 +0001E922 0001E922 0001E900 +0001E923 0001E923 0001E901 +0001E924 0001E924 0001E902 +0001E925 0001E925 0001E903 +0001E926 0001E926 0001E904 +0001E927 0001E927 0001E905 +0001E928 0001E928 0001E906 +0001E929 0001E929 0001E907 +0001E92A 0001E92A 0001E908 +0001E92B 0001E92B 0001E909 +0001E92C 0001E92C 0001E90A +0001E92D 0001E92D 0001E90B +0001E92E 0001E92E 0001E90C +0001E92F 0001E92F 0001E90D +0001E930 0001E930 0001E90E +0001E931 0001E931 0001E90F +0001E932 0001E932 0001E910 +0001E933 0001E933 0001E911 +0001E934 0001E934 0001E912 +0001E935 0001E935 0001E913 +0001E936 0001E936 0001E914 +0001E937 0001E937 0001E915 +0001E938 0001E938 0001E916 +0001E939 0001E939 0001E917 +0001E93A 0001E93A 0001E918 +0001E93B 0001E93B 0001E919 +0001E93C 0001E93C 0001E91A +0001E93D 0001E93D 0001E91B +0001E93E 0001E93E 0001E91C +0001E93F 0001E93F 0001E91D +0001E940 0001E940 0001E91E +0001E941 0001E941 0001E91F +0001E942 0001E942 0001E920 +0001E943 0001E943 0001E921 +DROP VIEW v_supplementary; +# +# End of 10.10 tests +# diff --git a/mysql-test/main/ctype_utf8mb4_uca1400_ai_ci_casefold.test b/mysql-test/main/ctype_utf8mb4_uca1400_ai_ci_casefold.test new file mode 100644 index 00000000000..288f86155e2 --- /dev/null +++ b/mysql-test/main/ctype_utf8mb4_uca1400_ai_ci_casefold.test @@ -0,0 +1,15 @@ +--echo # +--echo # Start of 10.10 tests +--echo # + +--echo # +--echo # MDEV-30577 Case folding for uca1400 collations is not up to date +--echo # + +SET NAMES utf8mb4 COLLATE utf8mb4_uca1400_ai_ci; +--source include/ctype_unicode_casefold_bmp.inc +--source include/ctype_unicode_casefold_supplementary.inc + +--echo # +--echo # End of 10.10 tests +--echo # diff --git a/mysql-test/main/derived.result b/mysql-test/main/derived.result index 7203c9bf67a..0c23f558757 100644 --- a/mysql-test/main/derived.result +++ b/mysql-test/main/derived.result @@ -1357,6 +1357,29 @@ a b DROP VIEW v1; DROP TABLE t1; # +# MDEV-28616: derived table over union with order by clause that +# contains subquery with unresolvable column reference +# +SELECT 1 FROM ( +SELECT 1 UNION SELECT 2 ORDER BY (SELECT 1 FROM DUAL WHERE xxx = 0) +) dt; +ERROR 42S22: Unknown column 'xxx' in 'where clause' +create table t1 (a int, b int); +insert into t1 values (3,8), (7,2), (1,4), (5,9); +create table t2 (a int, b int); +insert into t2 values (9,1), (7,3), (2,6); +create table t3 (c int, d int); +insert into t3 values (7,8), (1,2), (3,8); +select * from +( +select a,b from t1 where t1.a > 3 +union +select a,b from t2 where t2.b < 6 +order by (a - b / (select a + max(c) from t3 where d = x)) +) dt; +ERROR 42S22: Unknown column 'x' in 'where clause' +drop table t1,t2,t3; +# # End of 10.3 tests # # @@ -1476,6 +1499,34 @@ a 2 drop table t1; # +# MDEV-31022: SIGSEGV in maria_create from create_internal_tmp_table +# keydef incorrectly allocated on the stack in create_internal_tmp_table() +# +CREATE TABLE t1 (c CHAR(1) NULL) ENGINE=MyISAM; +INSERT INTO t1 (c) VALUES (1); +SET statement +optimizer_where_cost=1, +big_tables=1, +in_predicate_conversion_threshold=2 +FOR +SELECT * FROM t1 WHERE c IN ('',''); +c +Warnings: +Warning 1287 '@@big_tables' is deprecated and will be removed in a future release +Warning 1287 '@@big_tables' is deprecated and will be removed in a future release +SET statement +optimizer_where_cost=1, +big_tables=1, +in_predicate_conversion_threshold=2, +sql_mode='' +FOR +SELECT * FROM t1 WHERE c IN ('',''); +c +Warnings: +Warning 1287 '@@big_tables' is deprecated and will be removed in a future release +Warning 1287 '@@big_tables' is deprecated and will be removed in a future release +DROP TABLE t1; +# # End of 11.0 tests # # @@ -1668,7 +1719,8 @@ t1.a = ( select * from (select a from t1) dt where dt.a > 7); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where -2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 Using where +2 SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 Using where +3 DERIVED t1 ALL NULL NULL NULL NULL 2 Using where update t1,t3 set t1.a = 1 where t1.a=t3.a and t1.a = ( select * from (select a from t1) dt where dt.a > 7); @@ -1705,7 +1757,8 @@ t1.a = ( select * from (select a from t2) dt where dt.a > 7); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 2 Using where 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where -2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using where +2 SUBQUERY <derived3> ALL NULL NULL NULL NULL 4 Using where +3 DERIVED t2 ALL NULL NULL NULL NULL 4 Using where update t1,t3 set t1.a = 1 where t1.a=t3.a and t1.a = ( select * from (select a from t2) dt where dt.a > 7); @@ -1745,7 +1798,8 @@ t1.a = ( select * from (select a from t1) dt where dt.a > 7); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where 1 PRIMARY t3 ALL NULL NULL NULL NULL 5 Using where -2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 Using where +2 SUBQUERY <derived3> ALL NULL NULL NULL NULL 4 Using where +3 DERIVED t1 ALL NULL NULL NULL NULL 4 Using where delete from t1 using t1,t3 where t1.a=t3.a and t1.a = ( select * from (select a from t1) dt where dt.a > 7); @@ -1781,7 +1835,8 @@ t1.a = ( select * from (select a from t2) dt where dt.a > 7); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 Using where 1 PRIMARY t3 ALL NULL NULL NULL NULL 5 Using where -2 SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using where +2 SUBQUERY <derived3> ALL NULL NULL NULL NULL 4 Using where +3 DERIVED t2 ALL NULL NULL NULL NULL 4 Using where delete from t1 using t1,t3 where t1.a=t3.a and t1.a = ( select * from (select a from t2) dt where dt.a > 7); diff --git a/mysql-test/main/derived.test b/mysql-test/main/derived.test index dceae7a8c8f..772d7be2ace 100644 --- a/mysql-test/main/derived.test +++ b/mysql-test/main/derived.test @@ -1153,6 +1153,36 @@ DROP VIEW v1; DROP TABLE t1; --echo # +--echo # MDEV-28616: derived table over union with order by clause that +--echo # contains subquery with unresolvable column reference +--echo # + +--error ER_BAD_FIELD_ERROR +SELECT 1 FROM ( + SELECT 1 UNION SELECT 2 ORDER BY (SELECT 1 FROM DUAL WHERE xxx = 0) +) dt; + +create table t1 (a int, b int); +insert into t1 values (3,8), (7,2), (1,4), (5,9); + +create table t2 (a int, b int); +insert into t2 values (9,1), (7,3), (2,6); + +create table t3 (c int, d int); +insert into t3 values (7,8), (1,2), (3,8); + +--error ER_BAD_FIELD_ERROR +select * from +( + select a,b from t1 where t1.a > 3 + union + select a,b from t2 where t2.b < 6 + order by (a - b / (select a + max(c) from t3 where d = x)) +) dt; + +drop table t1,t2,t3; + +--echo # --echo # End of 10.3 tests --echo # @@ -1244,6 +1274,30 @@ SELECT a FROM t1 WHERE a IN ( 1, 1, 2, 194 ); drop table t1; --echo # +--echo # MDEV-31022: SIGSEGV in maria_create from create_internal_tmp_table +--echo # keydef incorrectly allocated on the stack in create_internal_tmp_table() +--echo # + +CREATE TABLE t1 (c CHAR(1) NULL) ENGINE=MyISAM; +INSERT INTO t1 (c) VALUES (1); +SET statement + optimizer_where_cost=1, + big_tables=1, + in_predicate_conversion_threshold=2 +FOR +SELECT * FROM t1 WHERE c IN ('',''); + +SET statement + optimizer_where_cost=1, + big_tables=1, + in_predicate_conversion_threshold=2, + sql_mode='' +FOR +SELECT * FROM t1 WHERE c IN ('',''); + +DROP TABLE t1; + +--echo # --echo # End of 11.0 tests --echo # diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result index 544c8ace7b7..76f899edc96 100644 --- a/mysql-test/main/derived_cond_pushdown.result +++ b/mysql-test/main/derived_cond_pushdown.result @@ -22609,6 +22609,103 @@ id select_type table type possible_keys key key_len ref rows Extra 3 DERIVED t1 ALL NULL NULL NULL NULL 3 Using temporary drop view v1; drop table t1; +# +# MDEV-31102: execution of PS for query where pushdown of condition +# into view defined as union is applied +# +create table t1 ( +n int, +lv varchar(31) charset latin1, +mv varchar(31) charset utf8mb3 +) engine=myisam; +insert into t1 values (1,'aa','xxx'), ('2','bb','yyy'), (3,'cc','zzz'); +create view v1 as +select case when n=1 then lv when n=2 then mv else NULL end as r from t1 +union +select 'a'; +select * from v1 where r < 'x'; +r +aa +a +explain extended select * from v1 where r < 'x'; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 100.00 Using where +2 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00 Using where +3 UNION NULL NULL NULL NULL NULL NULL NULL NULL No tables used +NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL +Warnings: +Note 1003 /* select#1 */ select `v1`.`r` AS `r` from `test`.`v1` where `v1`.`r` < 'x' +explain format=json select * from v1 where r < 'x'; +EXPLAIN +{ + "query_block": { + "select_id": 1, + "cost": 0.012461052, + "nested_loop": [ + { + "table": { + "table_name": "<derived2>", + "access_type": "ALL", + "loops": 1, + "rows": 3, + "cost": 0.012461052, + "filtered": 100, + "attached_condition": "v1.r < 'x'", + "materialized": { + "query_block": { + "union_result": { + "table_name": "<union2,3>", + "access_type": "ALL", + "query_specifications": [ + { + "query_block": { + "select_id": 2, + "cost": 0.010504815, + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "loops": 1, + "rows": 3, + "cost": 0.010504815, + "filtered": 100, + "attached_condition": "case when t1.n = 1 then convert(t1.lv using utf8mb3) when t1.n = 2 then t1.mv else NULL end < 'x'" + } + } + ] + } + }, + { + "query_block": { + "select_id": 3, + "operation": "UNION", + "table": { + "message": "No tables used" + } + } + } + ] + } + } + } + } + } + ] + } +} +prepare stmt from "select * from v1 where r < 'x'"; +execute stmt; +r +aa +a +execute stmt; +r +aa +a +deallocate prepare stmt; +drop view v1; +drop table t1; # End of 10.4 tests # # MDEV-28958: condition pushable into view after simplification diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test index d77e0210eae..5bd1489db78 100644 --- a/mysql-test/main/derived_cond_pushdown.test +++ b/mysql-test/main/derived_cond_pushdown.test @@ -4143,6 +4143,36 @@ explain select * from v1; drop view v1; drop table t1; +--echo # +--echo # MDEV-31102: execution of PS for query where pushdown of condition +--echo # into view defined as union is applied +--echo # + +create table t1 ( + n int, + lv varchar(31) charset latin1, + mv varchar(31) charset utf8mb3 +) engine=myisam; +insert into t1 values (1,'aa','xxx'), ('2','bb','yyy'), (3,'cc','zzz'); +create view v1 as +select case when n=1 then lv when n=2 then mv else NULL end as r from t1 +union +select 'a'; + +let $q= +select * from v1 where r < 'x'; + +eval $q; +eval explain extended $q; +eval explain format=json $q; +eval prepare stmt from "$q"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +drop view v1; +drop table t1; + --echo # End of 10.4 tests --echo # diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result index 9ea3d0f1396..f6d7cb02246 100644 --- a/mysql-test/main/derived_split_innodb.result +++ b/mysql-test/main/derived_split_innodb.result @@ -287,4 +287,589 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DERIVED t4 ALL NULL NULL NULL NULL 40 Using filesort drop table t3, t4; # End of 10.3 tests +# +# MDEV-26301: Split optimization refills temporary table too many times +# +create table t1(a int, b int); +insert into t1 select seq,seq from seq_1_to_5; +create table t2(a int, b int, key(a)); +insert into t2 +select A.seq,B.seq from seq_1_to_25 A, seq_1_to_2 B; +create table t3(a int, b int, key(a)); +insert into t3 +select A.seq,B.seq from seq_1_to_5 A, seq_1_to_3 B; +analyze table t1,t2,t3 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status Table is already up to date +test.t3 analyze status Engine-independent statistics collected +test.t3 analyze status Table is already up to date +explain +select * from +(t1 left join t2 on t2.a=t1.b) left join t3 on t3.a=t1.b; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 5 +1 SIMPLE t2 ref a a 5 test.t1.b 2 Using where +1 SIMPLE t3 ref a a 5 test.t1.b 3 Using where +create table t10 ( +grp_id int, +col1 int, +key(grp_id) +); +insert into t10 +select +A.seq, +B.seq +from +seq_1_to_100 A, +seq_1_to_100 B; +create table t11 ( +col1 int, +col2 int +); +insert into t11 +select A.seq, A.seq from seq_1_to_10 A; +analyze table t10,t11 persistent for all; +Table Op Msg_type Msg_text +test.t10 analyze status Engine-independent statistics collected +test.t10 analyze status Table is already up to date +test.t11 analyze status Engine-independent statistics collected +test.t11 analyze status OK +explain select * from +( +(t1 left join t2 on t2.a=t1.b) +left join t3 on t3.a=t1.b +) left join (select grp_id, count(*) +from t10 left join t11 on t11.col1=t10.col1 +group by grp_id) T on T.grp_id=t1.b; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 +1 PRIMARY t2 ref a a 5 test.t1.b 2 Using where +1 PRIMARY t3 ref a a 5 test.t1.b 3 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t1.b 10 Using where +2 LATERAL DERIVED t10 ref grp_id grp_id 5 test.t1.b 100 +2 LATERAL DERIVED t11 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) +# The important part in the below output is: +# "lateral": 1, +# "query_block": { +# "select_id": 2, +# "r_loops": 5, <-- must be 5, not 30. +analyze format=json select * from +( +(t1 left join t2 on t2.a=t1.b) +left join t3 on t3.a=t1.b +) left join (select grp_id, count(*) +from t10 left join t11 on t11.col1=t10.col1 +group by grp_id) T on T.grp_id=t1.b; +ANALYZE +{ + "query_optimization": { + "r_total_time_ms": "REPLACED" + }, + "query_block": { + "select_id": 1, + "cost": "REPLACED", + "r_loops": 1, + "r_total_time_ms": "REPLACED", + "const_condition": "1", + "nested_loop": [ + { + "table": { + "table_name": "t1", + "access_type": "ALL", + "loops": 1, + "r_loops": 1, + "rows": 5, + "r_rows": 5, + "cost": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + }, + { + "table": { + "table_name": "t2", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t1.b"], + "loops": 5, + "r_loops": 5, + "rows": 2, + "r_rows": 2, + "cost": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "trigcond(trigcond(t1.b is not null))" + } + }, + { + "table": { + "table_name": "t3", + "access_type": "ref", + "possible_keys": ["a"], + "key": "a", + "key_length": "5", + "used_key_parts": ["a"], + "ref": ["test.t1.b"], + "loops": 10, + "r_loops": 10, + "rows": 3, + "r_rows": 3, + "cost": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "trigcond(trigcond(t1.b is not null))" + } + }, + { + "table": { + "table_name": "<derived2>", + "access_type": "ref", + "possible_keys": ["key0"], + "key": "key0", + "key_length": "5", + "used_key_parts": ["grp_id"], + "ref": ["test.t1.b"], + "loops": 30, + "r_loops": 30, + "rows": 10, + "r_rows": 1, + "cost": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100, + "attached_condition": "trigcond(trigcond(t1.b is not null))", + "materialized": { + "lateral": 1, + "query_block": { + "select_id": 2, + "cost": "REPLACED", + "r_loops": 5, + "r_total_time_ms": "REPLACED", + "outer_ref_condition": "t1.b is not null", + "nested_loop": [ + { + "table": { + "table_name": "t10", + "access_type": "ref", + "possible_keys": ["grp_id"], + "key": "grp_id", + "key_length": "5", + "used_key_parts": ["grp_id"], + "ref": ["test.t1.b"], + "loops": 1, + "r_loops": 5, + "rows": 100, + "r_rows": 100, + "cost": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + } + }, + { + "block-nl-join": { + "table": { + "table_name": "t11", + "access_type": "ALL", + "loops": 100, + "r_loops": 5, + "rows": 10, + "r_rows": 10, + "cost": "REPLACED", + "r_table_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "filtered": 100, + "r_filtered": 100 + }, + "buffer_type": "flat", + "buffer_size": "1Kb", + "join_type": "BNL", + "attached_condition": "trigcond(t11.col1 = t10.col1)", + "r_loops": 500, + "r_filtered": 10, + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 10 + } + } + ] + } + } + } + } + ] + } +} +create table t21 (pk int primary key); +insert into t21 values (1),(2),(3); +create table t22 (pk int primary key); +insert into t22 values (1),(2),(3); +explain +select * from +t21, t22, +( +(t1 left join t2 on t2.a=t1.b) +left join t3 on t3.a=t1.b +) left join (select grp_id, count(*) +from t10 left join t11 on t11.col1=t10.col1 +group by grp_id) T on T.grp_id=t1.b +where +t21.pk=1 and t22.pk=2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t21 const PRIMARY PRIMARY 4 const 1 Using index +1 PRIMARY t22 const PRIMARY PRIMARY 4 const 1 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 +1 PRIMARY t2 ref a a 5 test.t1.b 2 Using where +1 PRIMARY t3 ref a a 5 test.t1.b 3 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t1.b 10 Using where +2 LATERAL DERIVED t10 ref grp_id grp_id 5 test.t1.b 100 +2 LATERAL DERIVED t11 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) +explain +select * from +t21, +( +(t1 left join t2 on t2.a=t1.b) +left join t3 on t3.a=t1.b +) left join (select grp_id, count(*) +from +t22 join t10 left join t11 on t11.col1=t10.col1 +where +t22.pk=1 +group by grp_id) T on T.grp_id=t1.b +where +t21.pk=1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t21 const PRIMARY PRIMARY 4 const 1 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 +1 PRIMARY t2 ref a a 5 test.t1.b 2 Using where +1 PRIMARY t3 ref a a 5 test.t1.b 3 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t1.b 10 Using where +2 LATERAL DERIVED t22 const PRIMARY PRIMARY 4 const 1 Using index +2 LATERAL DERIVED t10 ref grp_id grp_id 5 test.t1.b 100 +2 LATERAL DERIVED t11 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) +create table t5 ( +pk int primary key +); +insert into t5 select seq from seq_1_to_1000; +explain +select * from +t21, +( +(((t1 join t5 on t5.pk=t1.b)) left join t2 on t2.a=t1.b) +left join t3 on t3.a=t1.b +) left join (select grp_id, count(*) +from +t22 join t10 left join t11 on t11.col1=t10.col1 +where +t22.pk=1 +group by grp_id) T on T.grp_id=t1.b +where +t21.pk=1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t21 const PRIMARY PRIMARY 4 const 1 Using index +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where +1 PRIMARY t5 eq_ref PRIMARY PRIMARY 4 test.t1.b 1 Using index +1 PRIMARY t2 ref a a 5 test.t1.b 2 +1 PRIMARY t3 ref a a 5 test.t1.b 3 +1 PRIMARY <derived2> ref key0 key0 5 test.t1.b 10 Using where +2 LATERAL DERIVED t22 const PRIMARY PRIMARY 4 const 1 Using index +2 LATERAL DERIVED t10 ref grp_id grp_id 5 test.t5.pk 100 Using index condition +2 LATERAL DERIVED t11 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) +drop table t1,t2,t3,t5, t10, t11, t21, t22; +create table t1(a int, b int); +insert into t1 select seq,seq from seq_1_to_5; +create table t2(a int, b int, key(a)); +insert into t2 +select A.seq,B.seq from seq_1_to_25 A, seq_1_to_2 B; +create table t3(a int, b int, key(a)); +insert into t3 +select A.seq,B.seq from seq_1_to_5 A, seq_1_to_3 B; +analyze table t1,t2,t3 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status Table is already up to date +test.t3 analyze status Engine-independent statistics collected +test.t3 analyze status Table is already up to date +create table t10 ( +grp_id int, +col1 int, +key(grp_id) +); +insert into t10 +select +A.seq, +B.seq +from +seq_1_to_100 A, +seq_1_to_100 B; +create table t11 ( +col1 int, +col2 int +); +insert into t11 +select A.seq, A.seq from seq_1_to_10 A; +analyze table t10,t11 persistent for all; +Table Op Msg_type Msg_text +test.t10 analyze status Engine-independent statistics collected +test.t10 analyze status Table is already up to date +test.t11 analyze status Engine-independent statistics collected +test.t11 analyze status OK +explain select * +from +( +(t1 left join t2 on t2.a=t1.b) +left join +t3 +on t3.a=t1.b +) +left join +( +select grp_id, count(*) +from t10 left join t11 on t11.col1=t10.col1 +group by grp_id +)dt +on dt.grp_id=t1.b; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 +1 PRIMARY t2 ref a a 5 test.t1.b 2 Using where +1 PRIMARY t3 ref a a 5 test.t1.b 3 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t1.b 10 Using where +2 LATERAL DERIVED t10 ref grp_id grp_id 5 test.t1.b 100 +2 LATERAL DERIVED t11 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) +select * +from +( +(t1 left join t2 on t2.a=t1.b) +left join +t3 +on t3.a=t1.b +) +left join +( +select grp_id, count(*) +from t10 left join t11 on t11.col1=t10.col1 +group by grp_id +)dt +on dt.grp_id=t1.b; +a b a b a b grp_id count(*) +1 1 1 1 1 1 1 100 +1 1 1 1 1 2 1 100 +1 1 1 1 1 3 1 100 +1 1 1 2 1 1 1 100 +1 1 1 2 1 2 1 100 +1 1 1 2 1 3 1 100 +2 2 2 1 2 1 2 100 +2 2 2 1 2 2 2 100 +2 2 2 1 2 3 2 100 +2 2 2 2 2 1 2 100 +2 2 2 2 2 2 2 100 +2 2 2 2 2 3 2 100 +3 3 3 1 3 1 3 100 +3 3 3 1 3 2 3 100 +3 3 3 1 3 3 3 100 +3 3 3 2 3 1 3 100 +3 3 3 2 3 2 3 100 +3 3 3 2 3 3 3 100 +4 4 4 1 4 1 4 100 +4 4 4 1 4 2 4 100 +4 4 4 1 4 3 4 100 +4 4 4 2 4 1 4 100 +4 4 4 2 4 2 4 100 +4 4 4 2 4 3 4 100 +5 5 5 1 5 1 5 100 +5 5 5 1 5 2 5 100 +5 5 5 1 5 3 5 100 +5 5 5 2 5 1 5 100 +5 5 5 2 5 2 5 100 +5 5 5 2 5 3 5 100 +set join_cache_level=4; +set optimizer_trace=1; +set @tmp=@@optimizer_switch, optimizer_switch='hash_join_cardinality=off'; +insert into t11 +select A.seq, A.seq from seq_11_to_100 A; +analyze table t11 persistent for all; +Table Op Msg_type Msg_text +test.t11 analyze status Engine-independent statistics collected +test.t11 analyze status OK +explain select * +from +( +(t1 left join t2 on t2.a=t1.b) +left join +t3 +on t3.a=t1.b +) +left join +( +select grp_id, count(*) +from t10 left join t11 on t11.col1=t10.col1 +group by grp_id +)dt +on dt.grp_id=t1.b; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 +1 PRIMARY t2 ref a a 5 test.t1.b 2 Using where +1 PRIMARY t3 ref a a 5 test.t1.b 3 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t1.b 10 Using where +2 LATERAL DERIVED t10 ref grp_id grp_id 5 test.t1.b 100 +2 LATERAL DERIVED t11 hash_ALL NULL #hash#$hj 5 test.t10.col1 100 Using where; Using join buffer (flat, BNLH join) +select * +from +( +(t1 left join t2 on t2.a=t1.b) +left join +t3 +on t3.a=t1.b +) +left join +( +select grp_id, count(*) +from t10 left join t11 on t11.col1=t10.col1 +group by grp_id +)dt +on dt.grp_id=t1.b; +a b a b a b grp_id count(*) +1 1 1 1 1 1 1 100 +1 1 1 1 1 2 1 100 +1 1 1 1 1 3 1 100 +1 1 1 2 1 1 1 100 +1 1 1 2 1 2 1 100 +1 1 1 2 1 3 1 100 +2 2 2 1 2 1 2 100 +2 2 2 1 2 2 2 100 +2 2 2 1 2 3 2 100 +2 2 2 2 2 1 2 100 +2 2 2 2 2 2 2 100 +2 2 2 2 2 3 2 100 +3 3 3 1 3 1 3 100 +3 3 3 1 3 2 3 100 +3 3 3 1 3 3 3 100 +3 3 3 2 3 1 3 100 +3 3 3 2 3 2 3 100 +3 3 3 2 3 3 3 100 +4 4 4 1 4 1 4 100 +4 4 4 1 4 2 4 100 +4 4 4 1 4 3 4 100 +4 4 4 2 4 1 4 100 +4 4 4 2 4 2 4 100 +4 4 4 2 4 3 4 100 +5 5 5 1 5 1 5 100 +5 5 5 1 5 2 5 100 +5 5 5 1 5 3 5 100 +5 5 5 2 5 1 5 100 +5 5 5 2 5 2 5 100 +5 5 5 2 5 3 5 100 +set optimizer_switch=@tmp; +set join_cache_level=default; +delete from t11; +insert into t11 select A.seq, A.seq from seq_1_to_10 A; +analyze table t11 persistent for all; +Table Op Msg_type Msg_text +test.t11 analyze status Engine-independent statistics collected +test.t11 analyze status OK +drop index a on t2; +drop index a on t3; +explain select * +from +( +(t1 left join t2 on t2.a=t1.b) +left join +t3 +on t3.a=t1.b +) +left join +( +select grp_id, count(*) +from t10 left join t11 on t11.col1=t10.col1 +group by grp_id +)dt +on dt.grp_id=t1.b; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 +1 PRIMARY t2 ALL NULL NULL NULL NULL 50 Using where; Using join buffer (flat, BNL join) +1 PRIMARY t3 ALL NULL NULL NULL NULL 15 Using where; Using join buffer (incremental, BNL join) +1 PRIMARY <derived2> ref key0 key0 5 test.t1.b 1000 Using where +2 DERIVED t10 ALL grp_id NULL NULL NULL 10000 Using temporary; Using filesort +2 DERIVED t11 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) +select * +from +( +(t1 left join t2 on t2.a=t1.b) +left join +t3 +on t3.a=t1.b +) +left join +( +select grp_id, count(*) +from t10 left join t11 on t11.col1=t10.col1 +group by grp_id +)dt +on dt.grp_id=t1.b; +a b a b a b grp_id count(*) +1 1 1 1 1 1 1 100 +1 1 1 2 1 1 1 100 +1 1 1 1 1 2 1 100 +1 1 1 2 1 2 1 100 +1 1 1 1 1 3 1 100 +1 1 1 2 1 3 1 100 +2 2 2 1 2 1 2 100 +2 2 2 2 2 1 2 100 +2 2 2 1 2 2 2 100 +2 2 2 2 2 2 2 100 +2 2 2 1 2 3 2 100 +2 2 2 2 2 3 2 100 +3 3 3 1 3 1 3 100 +3 3 3 2 3 1 3 100 +3 3 3 1 3 2 3 100 +3 3 3 2 3 2 3 100 +3 3 3 1 3 3 3 100 +3 3 3 2 3 3 3 100 +4 4 4 1 4 1 4 100 +4 4 4 2 4 1 4 100 +4 4 4 1 4 2 4 100 +4 4 4 2 4 2 4 100 +4 4 4 1 4 3 4 100 +4 4 4 2 4 3 4 100 +5 5 5 1 5 1 5 100 +5 5 5 2 5 1 5 100 +5 5 5 1 5 2 5 100 +5 5 5 2 5 2 5 100 +5 5 5 1 5 3 5 100 +5 5 5 2 5 3 5 100 +drop table t1,t2,t3; +drop table t10, t11; +# +# MDEV-31194: Server crash or assertion failure with join_cache_level=4 +# (a followup to the above bug, MDEV-26301) +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (3),(4); +CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=Aria; +INSERT INTO t2 VALUES (1),(2); +set @tmp1= @@optimizer_switch, @tmp2= @@join_cache_level; +set +optimizer_switch= 'derived_with_keys=off', +join_cache_level= 4; +SELECT t1.* FROM t1 JOIN (SELECT id, COUNT(*) FROM t2 GROUP BY id) sq ON sq.id= t1.a; +a +set optimizer_switch= @tmp1, join_cache_level= @tmp2; +DROP TABLE t1, t2; +# End of 10.4 tests SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent; diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test index 86a2b6d73b0..e7c5cc8f274 100644 --- a/mysql-test/main/derived_split_innodb.test +++ b/mysql-test/main/derived_split_innodb.test @@ -233,4 +233,251 @@ drop table t3, t4; --echo # End of 10.3 tests + +--echo # +--echo # MDEV-26301: Split optimization refills temporary table too many times +--echo # + +# 5 values +create table t1(a int, b int); +insert into t1 select seq,seq from seq_1_to_5; + +# 5 value groups of size 2 each +create table t2(a int, b int, key(a)); +insert into t2 +select A.seq,B.seq from seq_1_to_25 A, seq_1_to_2 B; + +# 5 value groups of size 3 each +create table t3(a int, b int, key(a)); +insert into t3 +select A.seq,B.seq from seq_1_to_5 A, seq_1_to_3 B; + +analyze table t1,t2,t3 persistent for all; + +explain +select * from + (t1 left join t2 on t2.a=t1.b) left join t3 on t3.a=t1.b; + +# Now, create tables for Groups. + +create table t10 ( + grp_id int, + col1 int, + key(grp_id) +); + +# 100 groups of 100 values each +insert into t10 +select + A.seq, + B.seq +from + seq_1_to_100 A, + seq_1_to_100 B; + +# and X10 multiplier + +create table t11 ( + col1 int, + col2 int +); +insert into t11 +select A.seq, A.seq from seq_1_to_10 A; + +analyze table t10,t11 persistent for all; + +let $q1= +select * from + ( + (t1 left join t2 on t2.a=t1.b) + left join t3 on t3.a=t1.b + ) left join (select grp_id, count(*) + from t10 left join t11 on t11.col1=t10.col1 + group by grp_id) T on T.grp_id=t1.b; + +eval +explain $q1; + +--echo # The important part in the below output is: +--echo # "lateral": 1, +--echo # "query_block": { +--echo # "select_id": 2, +--echo # "r_loops": 5, <-- must be 5, not 30. +--source include/analyze-format.inc + +eval +analyze format=json $q1; + +create table t21 (pk int primary key); +insert into t21 values (1),(2),(3); + +create table t22 (pk int primary key); +insert into t22 values (1),(2),(3); + +# Same as above but throw in a couple of const tables. +explain +select * from + t21, t22, + ( + (t1 left join t2 on t2.a=t1.b) + left join t3 on t3.a=t1.b + ) left join (select grp_id, count(*) + from t10 left join t11 on t11.col1=t10.col1 + group by grp_id) T on T.grp_id=t1.b +where + t21.pk=1 and t22.pk=2; + +explain +select * from + t21, + ( + (t1 left join t2 on t2.a=t1.b) + left join t3 on t3.a=t1.b + ) left join (select grp_id, count(*) + from + t22 join t10 left join t11 on t11.col1=t10.col1 + where + t22.pk=1 + group by grp_id) T on T.grp_id=t1.b +where + t21.pk=1; + +# And also add a non-const table + +create table t5 ( + pk int primary key + ); +insert into t5 select seq from seq_1_to_1000; + +explain +select * from + t21, + ( + (((t1 join t5 on t5.pk=t1.b)) left join t2 on t2.a=t1.b) + left join t3 on t3.a=t1.b + ) left join (select grp_id, count(*) + from + t22 join t10 left join t11 on t11.col1=t10.col1 + where + t22.pk=1 + group by grp_id) T on T.grp_id=t1.b +where + t21.pk=1; + +drop table t1,t2,t3,t5, t10, t11, t21, t22; + +# 5 values +create table t1(a int, b int); +insert into t1 select seq,seq from seq_1_to_5; + +# 5 value groups of size 2 each +create table t2(a int, b int, key(a)); +insert into t2 +select A.seq,B.seq from seq_1_to_25 A, seq_1_to_2 B; + +# 5 value groups of size 3 each +create table t3(a int, b int, key(a)); +insert into t3 +select A.seq,B.seq from seq_1_to_5 A, seq_1_to_3 B; + +analyze table t1,t2,t3 persistent for all; + +create table t10 ( + grp_id int, + col1 int, + key(grp_id) +); + +# 100 groups of 100 values each +insert into t10 +select + A.seq, + B.seq +from + seq_1_to_100 A, + seq_1_to_100 B; + +# and X10 multiplier + +create table t11 ( + col1 int, + col2 int +); +insert into t11 +select A.seq, A.seq from seq_1_to_10 A; + +analyze table t10,t11 persistent for all; + +let $q= +select * +from + ( + (t1 left join t2 on t2.a=t1.b) + left join + t3 + on t3.a=t1.b + ) + left join + ( + select grp_id, count(*) + from t10 left join t11 on t11.col1=t10.col1 + group by grp_id + )dt + on dt.grp_id=t1.b; + +eval explain $q; +eval $q; + +set join_cache_level=4; +set optimizer_trace=1; +set @tmp=@@optimizer_switch, optimizer_switch='hash_join_cardinality=off'; +# Need table t11 to be larger in 11.0: +insert into t11 +select A.seq, A.seq from seq_11_to_100 A; +analyze table t11 persistent for all; + +eval explain $q; +eval $q; + +set optimizer_switch=@tmp; +set join_cache_level=default; + +delete from t11; +insert into t11 select A.seq, A.seq from seq_1_to_10 A; +analyze table t11 persistent for all; + +drop index a on t2; +drop index a on t3; + +eval explain $q; +eval $q; + +drop table t1,t2,t3; +drop table t10, t11; + + +--echo # +--echo # MDEV-31194: Server crash or assertion failure with join_cache_level=4 +--echo # (a followup to the above bug, MDEV-26301) +--echo # +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (3),(4); + +CREATE TABLE t2 (id INT PRIMARY KEY) ENGINE=Aria; +INSERT INTO t2 VALUES (1),(2); + +set @tmp1= @@optimizer_switch, @tmp2= @@join_cache_level; +set + optimizer_switch= 'derived_with_keys=off', + join_cache_level= 4; + +SELECT t1.* FROM t1 JOIN (SELECT id, COUNT(*) FROM t2 GROUP BY id) sq ON sq.id= t1.a; + +set optimizer_switch= @tmp1, join_cache_level= @tmp2; + +# Cleanup +DROP TABLE t1, t2; + +--echo # End of 10.4 tests + SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent; diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result index aa7519ae750..75c92b23089 100644 --- a/mysql-test/main/derived_view.result +++ b/mysql-test/main/derived_view.result @@ -3828,3 +3828,553 @@ drop procedure sp2; drop view v, v2; drop table t1,t2; # End of 10.2 tests +# +# MDEV-30706: view defined as select with implicit grouping and +# a set function used in a subquery +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2); +CREATE TABLE t2 (a INT PRIMARY KEY, b INT); +INSERT INTO t2 VALUES (1,1), (3,3); +CREATE TABLE t3 (a INT PRIMARY KEY, b INT); +INSERT INTO t3 VALUES (2,2), (4,4), (7,7); +CREATE TABLE t4 (a INT PRIMARY KEY, b INT); +INSERT INTO t4 VALUES (2,2), (5,5), (7,7); +CREATE VIEW v AS SELECT +(SELECT SUM(t4.b) FROM t1, t2 WHERE t1.a = t2.b GROUP BY t1.a) AS m +FROM t3, t4 +WHERE t3.a = t4.b; +SELECT +(SELECT SUM(t4.b) FROM t1, t2 WHERE t1.a = t2.b GROUP BY t1.a) AS m +FROM t3, t4 +WHERE t3.a = t4.b; +m +9 +SELECT * FROM v; +m +9 +WITH cte AS ( SELECT +(SELECT SUM(t4.b) FROM t1, t2 WHERE t1.a = t2.b GROUP BY t1.a) AS m +FROM t3, t4 +WHERE t3.a = t4.b ) SELECT * FROM cte; +m +9 +EXPLAIN SELECT +(SELECT SUM(t4.b) FROM t1, t2 WHERE t1.a = t2.b GROUP BY t1.a) AS m +FROM t3, t4 +WHERE t3.a = t4.b; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t4 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY t3 eq_ref PRIMARY PRIMARY 4 test.t4.b 1 Using index +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort +2 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.t2.b 1 Using index +EXPLAIN SELECT * FROM v; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 +2 SUBQUERY t4 ALL NULL NULL NULL NULL 3 Using where +2 SUBQUERY t3 eq_ref PRIMARY PRIMARY 4 test.t4.b 1 Using index +3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort +3 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.t2.b 1 Using index +EXPLAIN WITH cte AS ( SELECT +(SELECT SUM(t4.b) FROM t1, t2 WHERE t1.a = t2.b GROUP BY t1.a) AS m +FROM t3, t4 +WHERE t3.a = t4.b ) SELECT * FROM cte; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 +2 DERIVED t4 ALL NULL NULL NULL NULL 3 Using where +2 DERIVED t3 eq_ref PRIMARY PRIMARY 4 test.t4.b 1 Using index +3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using temporary; Using filesort +3 DEPENDENT SUBQUERY t1 eq_ref PRIMARY PRIMARY 4 test.t2.b 1 Using index +PREPARE stmt FROM "SELECT +(SELECT SUM(t4.b) FROM t1, t2 WHERE t1.a = t2.b GROUP BY t1.a) AS m +FROM t3, t4 +WHERE t3.a = t4.b"; +execute stmt; +m +9 +execute stmt; +m +9 +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM "SELECT * FROM v"; +execute stmt; +m +9 +execute stmt; +m +9 +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM "WITH cte AS ( SELECT +(SELECT SUM(t4.b) FROM t1, t2 WHERE t1.a = t2.b GROUP BY t1.a) AS m +FROM t3, t4 +WHERE t3.a = t4.b ) SELECT * FROM cte"; +execute stmt; +m +9 +execute stmt; +m +9 +DEALLOCATE PREPARE stmt; +DROP VIEW v; +DROP TABLE t1,t2,t3,t4; +# +# MDEV-29224: view defined as select with implicit grouping and +# a set function used in a subquery +# +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (f2 int); +INSERT INTO t2 VALUES (3); +CREATE VIEW v AS SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1; +SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1; +( SELECT MAX(f1) FROM t2 ) +2 +SELECT * FROM v; +( SELECT MAX(f1) FROM t2 ) +2 +WITH cte AS ( SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1 ) SELECT * FROM cte; +( SELECT MAX(f1) FROM t2 ) +2 +EXPLAIN SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 +2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 +EXPLAIN SELECT * FROM v; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 +2 SUBQUERY t1 ALL NULL NULL NULL NULL 2 +3 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 +EXPLAIN WITH cte AS ( SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1 ) SELECT * FROM cte; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 +2 DERIVED t1 ALL NULL NULL NULL NULL 2 +3 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1 +PREPARE stmt FROM "SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1"; +execute stmt; +( SELECT MAX(f1) FROM t2 ) +2 +execute stmt; +( SELECT MAX(f1) FROM t2 ) +2 +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM "SELECT * FROM v"; +execute stmt; +( SELECT MAX(f1) FROM t2 ) +2 +execute stmt; +( SELECT MAX(f1) FROM t2 ) +2 +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM "WITH cte AS ( SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1 ) SELECT * FROM cte"; +execute stmt; +( SELECT MAX(f1) FROM t2 ) +2 +execute stmt; +( SELECT MAX(f1) FROM t2 ) +2 +DEALLOCATE PREPARE stmt; +DROP VIEW v; +DROP TABLE t1,t2; +# +# MDEV-28573: view defined as select with implicit grouping and +# a set function used in a subquery +# +CREATE TABLE t1 (a INTEGER, b INTEGER); +CREATE TABLE t2 (c INTEGER); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +INSERT INTO t2 VALUES (1), (2); +CREATE VIEW v1 AS SELECT (SELECT COUNT(b) FROM t2) FROM t1; +CREATE VIEW v2 AS SELECT (SELECT COUNT(b) FROM t2 WHERE c > 1) FROM t1; +SELECT (SELECT COUNT(b) FROM t2) FROM t1; +ERROR 21000: Subquery returns more than 1 row +SELECT * FROM v1; +ERROR 21000: Subquery returns more than 1 row +WITH cte AS ( SELECT (SELECT COUNT(b) FROM t2) FROM t1 ) SELECT * FROM cte; +ERROR 21000: Subquery returns more than 1 row +SELECT (SELECT COUNT(b) FROM t2 WHERE c > 1) FROM t1; +(SELECT COUNT(b) FROM t2 WHERE c > 1) +3 +SELECT * FROM v2; +(SELECT COUNT(b) FROM t2 WHERE c > 1) +3 +WITH cte AS ( SELECT (SELECT COUNT(b) FROM t2 WHERE c > 1) FROM t1 ) SELECT * FROM cte; +(SELECT COUNT(b) FROM t2 WHERE c > 1) +3 +EXPLAIN SELECT (SELECT COUNT(b) FROM t2) FROM t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 +EXPLAIN SELECT * FROM v1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 +2 SUBQUERY t1 ALL NULL NULL NULL NULL 3 +3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 +EXPLAIN WITH cte AS ( SELECT (SELECT COUNT(b) FROM t2) FROM t1 ) SELECT * FROM cte; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 +2 DERIVED t1 ALL NULL NULL NULL NULL 3 +3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 +PREPARE stmt FROM "SELECT (SELECT COUNT(b) FROM t2) FROM t1"; +execute stmt; +ERROR 21000: Subquery returns more than 1 row +execute stmt; +ERROR 21000: Subquery returns more than 1 row +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM "SELECT * FROM v1"; +execute stmt; +ERROR 21000: Subquery returns more than 1 row +execute stmt; +ERROR 21000: Subquery returns more than 1 row +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM "WITH cte AS ( SELECT (SELECT COUNT(b) FROM t2) FROM t1 ) SELECT * FROM cte"; +execute stmt; +ERROR 21000: Subquery returns more than 1 row +execute stmt; +ERROR 21000: Subquery returns more than 1 row +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM "SELECT (SELECT COUNT(b) FROM t2 WHERE c > 1) FROM t1"; +execute stmt; +(SELECT COUNT(b) FROM t2 WHERE c > 1) +3 +execute stmt; +(SELECT COUNT(b) FROM t2 WHERE c > 1) +3 +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM "SELECT * FROM v2"; +execute stmt; +(SELECT COUNT(b) FROM t2 WHERE c > 1) +3 +execute stmt; +(SELECT COUNT(b) FROM t2 WHERE c > 1) +3 +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM "WITH cte AS ( SELECT (SELECT COUNT(b) FROM t2 WHERE c > 1) FROM t1 ) SELECT * FROM cte"; +execute stmt; +(SELECT COUNT(b) FROM t2 WHERE c > 1) +3 +execute stmt; +(SELECT COUNT(b) FROM t2 WHERE c > 1) +3 +DEALLOCATE PREPARE stmt; +DROP VIEW v1,v2; +DROP TABLE t1,t2; +# +# MDEV-28570: VIEW with WHERE containing subquery +# with set function aggregated in query +# +CREATE TABLE t1 (a int, b int); +CREATE TABLE t2 (c int, d int); +INSERT INTO t1 VALUES +(1,10), (2,10), (1,20), (2,20), (3,20), (2,30), (4,40); +INSERT INTO t2 VALUES +(2,10), (2,20), (4,10), (5,10), (3,20), (2,40); +CREATE VIEW v AS SELECT a FROM t1 GROUP BY a +HAVING a IN (SELECT c FROM t2 WHERE MAX(b)>20); +SELECT a FROM t1 GROUP BY a +HAVING a IN (SELECT c FROM t2 WHERE MAX(b)>20); +a +2 +4 +SELECT * FROM v; +a +2 +4 +WITH cte AS ( SELECT a FROM t1 GROUP BY a +HAVING a IN (SELECT c FROM t2 WHERE MAX(b)>20) ) SELECT * FROM cte; +a +2 +4 +EXPLAIN SELECT a FROM t1 GROUP BY a +HAVING a IN (SELECT c FROM t2 WHERE MAX(b)>20); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 7 Using temporary; Using filesort +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 6 +EXPLAIN SELECT * FROM v; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 7 +2 DERIVED t1 ALL NULL NULL NULL NULL 7 Using temporary; Using filesort +3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 6 +EXPLAIN WITH cte AS ( SELECT a FROM t1 GROUP BY a +HAVING a IN (SELECT c FROM t2 WHERE MAX(b)>20) ) SELECT * FROM cte; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 7 +2 DERIVED t1 ALL NULL NULL NULL NULL 7 Using temporary; Using filesort +3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 6 +PREPARE stmt FROM "SELECT a FROM t1 GROUP BY a +HAVING a IN (SELECT c FROM t2 WHERE MAX(b)>20)"; +execute stmt; +a +2 +4 +execute stmt; +a +2 +4 +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM "SELECT * FROM v"; +execute stmt; +a +2 +4 +execute stmt; +a +2 +4 +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM "WITH cte AS ( SELECT a FROM t1 GROUP BY a +HAVING a IN (SELECT c FROM t2 WHERE MAX(b)>20) ) SELECT * FROM cte"; +execute stmt; +a +2 +4 +execute stmt; +a +2 +4 +DEALLOCATE PREPARE stmt; +DROP VIEW v; +DROP TABLE t1,t2; +# +# MDEV-28571: VIEW with select list containing subquery +# with set function aggregated in query +# +CREATE TABLE t1 (a int, b int); +CREATE TABLE t2 (m int, n int); +INSERT INTO t1 VALUES (2,2), (2,2), (3,3), (3,3), (3,3), (4,4); +INSERT INTO t2 VALUES (1,11), (2,22), (3,32), (4,44), (4,44); +CREATE VIEW v AS SELECT (SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a) AS c +FROM t1 +GROUP BY a; +SELECT (SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a) AS c +FROM t1 +GROUP BY a; +c +2 +3 +1,1 +SELECT * FROM v; +c +2 +3 +1,1 +WITH cte AS ( SELECT (SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a) AS c +FROM t1 +GROUP BY a ) SELECT * FROM cte; +c +2 +3 +1,1 +EXPLAIN SELECT (SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a) AS c +FROM t1 +GROUP BY a; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where +EXPLAIN SELECT * FROM v; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 +2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort +3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where +EXPLAIN WITH cte AS ( SELECT (SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a) AS c +FROM t1 +GROUP BY a ) SELECT * FROM cte; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY <derived2> ALL NULL NULL NULL NULL 6 +2 DERIVED t1 ALL NULL NULL NULL NULL 6 Using temporary; Using filesort +3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 Using where +PREPARE stmt FROM "SELECT (SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a) AS c +FROM t1 +GROUP BY a"; +execute stmt; +c +2 +3 +1,1 +execute stmt; +c +2 +3 +1,1 +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM "SELECT * FROM v"; +execute stmt; +c +2 +3 +1,1 +execute stmt; +c +2 +3 +1,1 +DEALLOCATE PREPARE stmt; +PREPARE stmt FROM "WITH cte AS ( SELECT (SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a) AS c +FROM t1 +GROUP BY a ) SELECT * FROM cte"; +execute stmt; +c +2 +3 +1,1 +execute stmt; +c +2 +3 +1,1 +DEALLOCATE PREPARE stmt; +DROP VIEW v; +DROP TABLE t1,t2; +# +# MDEV-30668: VIEW with WHERE containing nested subquery +# with set function aggregated in outer subquery +# +create table t1 (a int); +insert into t1 values (3), (7), (1); +create table t2 (b int); +insert into t2 values (2), (1), (4), (7); +create table t3 (a int, b int); +insert into t3 values (2,10), (7,30), (2,30), (1,10), (7,40); +create view v as select * from t1 +where t1.a in (select t3.a from t3 group by t3.a +having t3.a > any (select t2.b from t2 +where t2.b*10 < sum(t3.b))); +select * from t1 +where t1.a in (select t3.a from t3 group by t3.a +having t3.a > any (select t2.b from t2 +where t2.b*10 < sum(t3.b))); +a +7 +select * from v; +a +7 +with cte as ( select * from t1 +where t1.a in (select t3.a from t3 group by t3.a +having t3.a > any (select t2.b from t2 +where t2.b*10 < sum(t3.b))) ) select * from cte; +a +7 +explain select * from t1 +where t1.a in (select t3.a from t3 group by t3.a +having t3.a > any (select t2.b from t2 +where t2.b*10 < sum(t3.b))); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 test.t1.a 1 +2 MATERIALIZED t3 ALL NULL NULL NULL NULL 5 Using temporary +3 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using where +explain select * from v; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 test.t1.a 1 +3 MATERIALIZED t3 ALL NULL NULL NULL NULL 5 Using temporary +4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using where +explain with cte as ( select * from t1 +where t1.a in (select t3.a from t3 group by t3.a +having t3.a > any (select t2.b from t2 +where t2.b*10 < sum(t3.b))) ) select * from cte; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +1 PRIMARY <subquery3> eq_ref distinct_key distinct_key 4 test.t1.a 1 +3 MATERIALIZED t3 ALL NULL NULL NULL NULL 5 Using temporary +4 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 4 Using where +prepare stmt from "select * from t1 +where t1.a in (select t3.a from t3 group by t3.a +having t3.a > any (select t2.b from t2 +where t2.b*10 < sum(t3.b)))"; +execute stmt; +a +7 +execute stmt; +a +7 +deallocate prepare stmt; +prepare stmt from "select * from v"; +execute stmt; +a +7 +execute stmt; +a +7 +deallocate prepare stmt; +prepare stmt from "with cte as ( select * from t1 +where t1.a in (select t3.a from t3 group by t3.a +having t3.a > any (select t2.b from t2 +where t2.b*10 < sum(t3.b))) ) select * from cte"; +execute stmt; +a +7 +execute stmt; +a +7 +deallocate prepare stmt; +drop view v; +drop table t1,t2,t3; +# End of 10.4 tests +# +# MDEV-31143: view with ORDER BY used in query with rownum() in WHERE +# +create table t1 (id int primary key); +insert into t1 values (3), (7), (1); +create table t2 (a int); +insert into t2 values (2), (4); +create view v as select a from t2 order by a; +set big_tables= 1; +Warnings: +Warning 1287 '@@big_tables' is deprecated and will be removed in a future release +select t1.id from v, t1 where rownum() = 1 group by t1.id; +id +1 +set big_tables=default; +Warnings: +Warning 1287 '@@big_tables' is deprecated and will be removed in a future release +drop view v; +drop table t1, t2; +# +# MDEV-31162: multi-table mergeable view with ORDER BY used +# in query with rownum() in WHERE +# +create table t1 (a INT) engine=MyISAM; +insert into t1 values (1),(2); +create table t2 (b INT) engine=MyISAM; +insert into t2 values (3),(4); +create view v1 AS select * from t1 join t2 order by b; +explain select * from v1 where rownum() <= 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +select * from v1 where rownum() <= 2; +a b +1 3 +2 3 +prepare stmt from "select * from v1 where rownum() <= 2"; +execute stmt; +a b +1 3 +2 3 +execute stmt; +a b +1 3 +2 3 +deallocate prepare stmt; +create view v2 AS select * from t1 join t2 order by b/a; +explain select * from v2 where rownum() <= 2; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +select * from v2 where rownum() <= 2; +a b +2 3 +1 3 +prepare stmt from "select * from v2 where rownum() <= 2"; +execute stmt; +a b +2 3 +1 3 +execute stmt; +a b +2 3 +1 3 +deallocate prepare stmt; +drop view v1,v2; +drop table t1,t2; +# End of 10.6 tests diff --git a/mysql-test/main/derived_view.test b/mysql-test/main/derived_view.test index 13444676659..379c58cc73c 100644 --- a/mysql-test/main/derived_view.test +++ b/mysql-test/main/derived_view.test @@ -2463,3 +2463,362 @@ drop view v, v2; drop table t1,t2; --echo # End of 10.2 tests + +--echo # +--echo # MDEV-30706: view defined as select with implicit grouping and +--echo # a set function used in a subquery +--echo # + +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (1,1), (2,2); +CREATE TABLE t2 (a INT PRIMARY KEY, b INT); +INSERT INTO t2 VALUES (1,1), (3,3); +CREATE TABLE t3 (a INT PRIMARY KEY, b INT); +INSERT INTO t3 VALUES (2,2), (4,4), (7,7); +CREATE TABLE t4 (a INT PRIMARY KEY, b INT); +INSERT INTO t4 VALUES (2,2), (5,5), (7,7); + +let $q= +SELECT + (SELECT SUM(t4.b) FROM t1, t2 WHERE t1.a = t2.b GROUP BY t1.a) AS m +FROM t3, t4 + WHERE t3.a = t4.b; + +eval CREATE VIEW v AS $q; + +eval $q; +SELECT * FROM v; +eval WITH cte AS ( $q ) SELECT * FROM cte; + +eval EXPLAIN $q; +EXPLAIN SELECT * FROM v; +eval EXPLAIN WITH cte AS ( $q ) SELECT * FROM cte; + +eval PREPARE stmt FROM "$q"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +eval PREPARE stmt FROM "SELECT * FROM v"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +eval PREPARE stmt FROM "WITH cte AS ( $q ) SELECT * FROM cte"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +DROP VIEW v; +DROP TABLE t1,t2,t3,t4; + +--echo # +--echo # MDEV-29224: view defined as select with implicit grouping and +--echo # a set function used in a subquery +--echo # + +CREATE TABLE t1 (f1 INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (f2 int); +INSERT INTO t2 VALUES (3); + +let $q= +SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1; + +eval CREATE VIEW v AS $q; + +eval $q; +SELECT * FROM v; +eval WITH cte AS ( $q ) SELECT * FROM cte; + +eval EXPLAIN $q; +EXPLAIN SELECT * FROM v; +eval EXPLAIN WITH cte AS ( $q ) SELECT * FROM cte; + +eval PREPARE stmt FROM "$q"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +eval PREPARE stmt FROM "SELECT * FROM v"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +eval PREPARE stmt FROM "WITH cte AS ( $q ) SELECT * FROM cte"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +DROP VIEW v; +DROP TABLE t1,t2; + +--echo # +--echo # MDEV-28573: view defined as select with implicit grouping and +--echo # a set function used in a subquery +--echo # + +CREATE TABLE t1 (a INTEGER, b INTEGER); +CREATE TABLE t2 (c INTEGER); +INSERT INTO t1 VALUES (1,11), (2,22), (2,22); +INSERT INTO t2 VALUES (1), (2); + +let $q1= +SELECT (SELECT COUNT(b) FROM t2) FROM t1; +let $q2= +SELECT (SELECT COUNT(b) FROM t2 WHERE c > 1) FROM t1; + +eval CREATE VIEW v1 AS $q1; +eval CREATE VIEW v2 AS $q2; + +--error ER_SUBQUERY_NO_1_ROW +eval $q1; +--error ER_SUBQUERY_NO_1_ROW +SELECT * FROM v1; +--error ER_SUBQUERY_NO_1_ROW +eval WITH cte AS ( $q1 ) SELECT * FROM cte; +eval $q2; +SELECT * FROM v2; +eval WITH cte AS ( $q2 ) SELECT * FROM cte; + +eval EXPLAIN $q1; +EXPLAIN SELECT * FROM v1; +eval EXPLAIN WITH cte AS ( $q1 ) SELECT * FROM cte; + +eval PREPARE stmt FROM "$q1"; +--error ER_SUBQUERY_NO_1_ROW +execute stmt; +--error ER_SUBQUERY_NO_1_ROW +execute stmt; +DEALLOCATE PREPARE stmt; + +eval PREPARE stmt FROM "SELECT * FROM v1"; +--error ER_SUBQUERY_NO_1_ROW +execute stmt; +--error ER_SUBQUERY_NO_1_ROW +execute stmt; +DEALLOCATE PREPARE stmt; + +eval PREPARE stmt FROM "WITH cte AS ( $q1 ) SELECT * FROM cte"; +--error ER_SUBQUERY_NO_1_ROW +execute stmt; +--error ER_SUBQUERY_NO_1_ROW +execute stmt; +DEALLOCATE PREPARE stmt; + +eval PREPARE stmt FROM "$q2"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +eval PREPARE stmt FROM "SELECT * FROM v2"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +eval PREPARE stmt FROM "WITH cte AS ( $q2 ) SELECT * FROM cte"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +DROP VIEW v1,v2; +DROP TABLE t1,t2; + +--echo # +--echo # MDEV-28570: VIEW with WHERE containing subquery +--echo # with set function aggregated in query +--echo # + +CREATE TABLE t1 (a int, b int); +CREATE TABLE t2 (c int, d int); + +INSERT INTO t1 VALUES + (1,10), (2,10), (1,20), (2,20), (3,20), (2,30), (4,40); +INSERT INTO t2 VALUES + (2,10), (2,20), (4,10), (5,10), (3,20), (2,40); + +let $q= +SELECT a FROM t1 GROUP BY a + HAVING a IN (SELECT c FROM t2 WHERE MAX(b)>20); + +eval CREATE VIEW v AS $q; + +eval $q; +SELECT * FROM v; +eval WITH cte AS ( $q ) SELECT * FROM cte; + +eval EXPLAIN $q; +EXPLAIN SELECT * FROM v; +eval EXPLAIN WITH cte AS ( $q ) SELECT * FROM cte; + +eval PREPARE stmt FROM "$q"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +eval PREPARE stmt FROM "SELECT * FROM v"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +eval PREPARE stmt FROM "WITH cte AS ( $q ) SELECT * FROM cte"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +DROP VIEW v; +DROP TABLE t1,t2; + +--echo # +--echo # MDEV-28571: VIEW with select list containing subquery +--echo # with set function aggregated in query +--echo # + +CREATE TABLE t1 (a int, b int); +CREATE TABLE t2 (m int, n int); +INSERT INTO t1 VALUES (2,2), (2,2), (3,3), (3,3), (3,3), (4,4); +INSERT INTO t2 VALUES (1,11), (2,22), (3,32), (4,44), (4,44); + +let $q= +SELECT (SELECT GROUP_CONCAT(COUNT(a)) FROM t2 WHERE m = a) AS c +FROM t1 +GROUP BY a; + +eval CREATE VIEW v AS $q; + +eval $q; +SELECT * FROM v; +eval WITH cte AS ( $q ) SELECT * FROM cte; + +eval EXPLAIN $q; +EXPLAIN SELECT * FROM v; +eval EXPLAIN WITH cte AS ( $q ) SELECT * FROM cte; + +eval PREPARE stmt FROM "$q"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +eval PREPARE stmt FROM "SELECT * FROM v"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +eval PREPARE stmt FROM "WITH cte AS ( $q ) SELECT * FROM cte"; +execute stmt; +execute stmt; +DEALLOCATE PREPARE stmt; + +DROP VIEW v; +DROP TABLE t1,t2; + +--echo # +--echo # MDEV-30668: VIEW with WHERE containing nested subquery +--echo # with set function aggregated in outer subquery +--echo # + +create table t1 (a int); +insert into t1 values (3), (7), (1); + +create table t2 (b int); +insert into t2 values (2), (1), (4), (7); + +create table t3 (a int, b int); +insert into t3 values (2,10), (7,30), (2,30), (1,10), (7,40); + +let $q= +select * from t1 + where t1.a in (select t3.a from t3 group by t3.a + having t3.a > any (select t2.b from t2 + where t2.b*10 < sum(t3.b))); +eval create view v as $q; + +eval $q; +eval select * from v; +eval with cte as ( $q ) select * from cte; + +eval explain $q; +eval explain select * from v; +eval explain with cte as ( $q ) select * from cte; + +eval prepare stmt from "$q"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +eval prepare stmt from "select * from v"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +eval prepare stmt from "with cte as ( $q ) select * from cte"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +drop view v; +drop table t1,t2,t3; + +--echo # End of 10.4 tests + +--echo # +--echo # MDEV-31143: view with ORDER BY used in query with rownum() in WHERE +--echo # + +create table t1 (id int primary key); +insert into t1 values (3), (7), (1); + +create table t2 (a int); +insert into t2 values (2), (4); + +create view v as select a from t2 order by a; + +set big_tables= 1; +select t1.id from v, t1 where rownum() = 1 group by t1.id; + +set big_tables=default; + +drop view v; +drop table t1, t2; + +--echo # +--echo # MDEV-31162: multi-table mergeable view with ORDER BY used +--echo # in query with rownum() in WHERE +--echo # + +create table t1 (a INT) engine=MyISAM; +insert into t1 values (1),(2); + +create table t2 (b INT) engine=MyISAM; +insert into t2 values (3),(4); + +create view v1 AS select * from t1 join t2 order by b; +let $q1= +select * from v1 where rownum() <= 2; + +eval explain $q1; +--sorted_result +eval $q1; + +eval prepare stmt from "$q1"; +--sorted_result +execute stmt; +--sorted_result +execute stmt; +deallocate prepare stmt; + +create view v2 AS select * from t1 join t2 order by b/a; +let $q2= +select * from v2 where rownum() <= 2; + +eval explain $q2; +eval $q2; +eval prepare stmt from "$q2"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +drop view v1,v2; +drop table t1,t2; + +--echo # End of 10.6 tests diff --git a/mysql-test/main/disabled.def b/mysql-test/main/disabled.def index 02104f6a680..7d0c59e1c84 100644 --- a/mysql-test/main/disabled.def +++ b/mysql-test/main/disabled.def @@ -10,7 +10,6 @@ # ############################################################################## tablespace : disabled in MariaDB (no TABLESPACE table attribute) -events_time_zone : Test is not predictable as it depends on precise timing. read_many_rows_innodb : Bug#11748886 2010-11-15 mattiasj report already exists mysql_embedded : Bug#12561297 2011-05-14 Anitha Dependent on PB2 changes - eventum#41836 #show_explain : Psergey: random timeout in range-checked-for-each record query. diff --git a/mysql-test/main/distinct.result b/mysql-test/main/distinct.result index 02a76cf3e09..c779459ebb5 100644 --- a/mysql-test/main/distinct.result +++ b/mysql-test/main/distinct.result @@ -1075,6 +1075,57 @@ UNION drop table t1; End of 5.5 tests # +# MDEV-20057 Distinct SUM on CROSS JOIN and grouped returns wrong result +# +create table t1 (c int, d int); +insert into t1 values (5, 1), (0, 3); +select distinct sum(distinct 1), sum(t1.d) > 2 from (t1 e join t1) group by t1.c; +sum(distinct 1) sum(t1.d) > 2 +1 1 +1 0 +select distinct sum(distinct 1), sum(t1.d) > 2, t1.c from (t1 e join t1) group by t1.c; +sum(distinct 1) sum(t1.d) > 2 c +1 1 0 +1 0 5 +insert into t1 values (6,6); +select distinct sum(distinct 1), sum(t1.d) > 5 from (t1 e join t1) group by t1.c; +sum(distinct 1) sum(t1.d) > 5 +1 1 +1 0 +select distinct sum(distinct 1), sum(t1.d) > 5, t1.c from (t1 e join t1) group by t1.c; +sum(distinct 1) sum(t1.d) > 5 c +1 1 0 +1 0 5 +1 1 6 +SET @sort_buffer_size_save= @@sort_buffer_size; +set @@sort_buffer_size=1024; +insert into t1 select -seq,-seq from seq_1_to_100; +select distinct sum(distinct 1), sum(t1.d) > 2, length(group_concat(t1.d)) > 1000 from (t1 e join t1) group by t1.c having t1.c > -2 ; +sum(distinct 1) sum(t1.d) > 2 length(group_concat(t1.d)) > 1000 +1 0 0 +1 1 0 +select distinct sum(distinct 1), sum(t1.d) > 2, length(group_concat(t1.d)) > 1000,t1.c from (t1 e join t1) group by t1.c having t1.c > -2; +sum(distinct 1) sum(t1.d) > 2 length(group_concat(t1.d)) > 1000 c +1 0 0 -1 +1 1 0 0 +1 1 0 5 +1 1 0 6 +drop table t1; +set @@sort_buffer_size=@sort_buffer_size_save; +# +# MDEV-31113 Server crashes in store_length / Type_handler_string_result::make_sort_key +# with DISTINCT and group function +# +CREATE TABLE t (f INT); +INSERT INTO t VALUES (1),(2); +SELECT DISTINCT CONVERT(STDDEV(f), CHAR(16)) AS f1, UUID() AS f2 FROM t GROUP BY f2 WITH ROLLUP; +f1 f2 +0.0000 # +0.0000 # +0.5000 # +DROP TABLE t; +# End of 10.4 tests +# # MDEV-27382: OFFSET is ignored when it is combined with the DISTINCT, IN() and JOIN # CREATE TABLE t1 ( diff --git a/mysql-test/main/distinct.test b/mysql-test/main/distinct.test index 2f10d866560..06d04afca56 100644 --- a/mysql-test/main/distinct.test +++ b/mysql-test/main/distinct.test @@ -822,6 +822,41 @@ drop table t1; --echo End of 5.5 tests --echo # +--echo # MDEV-20057 Distinct SUM on CROSS JOIN and grouped returns wrong result +--echo # + +create table t1 (c int, d int); +insert into t1 values (5, 1), (0, 3); +select distinct sum(distinct 1), sum(t1.d) > 2 from (t1 e join t1) group by t1.c; +select distinct sum(distinct 1), sum(t1.d) > 2, t1.c from (t1 e join t1) group by t1.c; + +insert into t1 values (6,6); +select distinct sum(distinct 1), sum(t1.d) > 5 from (t1 e join t1) group by t1.c; +select distinct sum(distinct 1), sum(t1.d) > 5, t1.c from (t1 e join t1) group by t1.c; + +# Force usage of remove_dup_with_compare() algorithm +SET @sort_buffer_size_save= @@sort_buffer_size; +set @@sort_buffer_size=1024; +insert into t1 select -seq,-seq from seq_1_to_100; +select distinct sum(distinct 1), sum(t1.d) > 2, length(group_concat(t1.d)) > 1000 from (t1 e join t1) group by t1.c having t1.c > -2 ; +select distinct sum(distinct 1), sum(t1.d) > 2, length(group_concat(t1.d)) > 1000,t1.c from (t1 e join t1) group by t1.c having t1.c > -2; +drop table t1; +set @@sort_buffer_size=@sort_buffer_size_save; + +--echo # +--echo # MDEV-31113 Server crashes in store_length / Type_handler_string_result::make_sort_key +--echo # with DISTINCT and group function +--echo # + +CREATE TABLE t (f INT); +INSERT INTO t VALUES (1),(2); +--replace_column 2 # +SELECT DISTINCT CONVERT(STDDEV(f), CHAR(16)) AS f1, UUID() AS f2 FROM t GROUP BY f2 WITH ROLLUP; +DROP TABLE t; + +--echo # End of 10.4 tests + +--echo # --echo # MDEV-27382: OFFSET is ignored when it is combined with the DISTINCT, IN() and JOIN --echo # CREATE TABLE t1 ( diff --git a/mysql-test/main/events_1.result b/mysql-test/main/events_1.result deleted file mode 100644 index 2f2a951158c..00000000000 --- a/mysql-test/main/events_1.result +++ /dev/null @@ -1,571 +0,0 @@ -set sql_mode=""; -call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted"); -call mtr.add_suppression("Incorrect definition of table mysql.event:.*"); -drop database if exists events_test; -drop database if exists db_x; -drop database if exists mysqltest_db2; -drop database if exists mysqltest_no_such_database; -create database events_test; -use events_test; -CREATE USER pauline@localhost; -CREATE DATABASE db_x; -GRANT EVENT ON db_x.* TO pauline@localhost; -USE db_x; -CREATE TABLE x_table(a int); -connect priv_conn,localhost,pauline,,db_x; -CREATE EVENT e_x1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE db_x; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -CREATE EVENT e_x2 ON SCHEDULE EVERY 1 SECOND DO DROP TABLE x_table; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -connection default; -SHOW DATABASES LIKE 'db_x'; -Database (db_x) -db_x -SET GLOBAL event_scheduler=1; -SHOW DATABASES LIKE 'db_x'; -Database (db_x) -db_x -SHOW TABLES FROM db_x; -Tables_in_db_x -x_table -SET GLOBAL event_scheduler=off; -connection priv_conn; -DROP EVENT e_x1; -DROP EVENT e_x2; -disconnect priv_conn; -connection default; -DROP DATABASE db_x; -DROP USER pauline@localhost; -USE events_test; -SET GLOBAL event_scheduler=off; -drop event if exists event1; -Warnings: -Note 1305 Event event1 does not exist -create event event1 on schedule every 15 minute starts now() ends date_add(now(), interval 5 hour) DO begin end; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -alter event event1 rename to event2 enable; -alter event event2 disable; -alter event event2 enable; -alter event event2 on completion not preserve; -alter event event2 on schedule every 1 year on completion preserve rename to event3 comment "new comment" do begin select 1; end__ -alter event event3 rename to event2; -drop event event2; -create event event2 on schedule every 2 second starts now() ends date_add(now(), interval 5 hour) comment "some" DO begin end; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -drop event event2; -CREATE EVENT event_starts_test ON SCHEDULE EVERY 10 SECOND COMMENT "" DO SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SELECT interval_field, interval_value, body FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -interval_field interval_value body -SECOND 10 SELECT 1 -SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -execute_at IS NULL starts IS NULL ends IS NULL comment -1 0 1 -ALTER EVENT event_starts_test ON SCHEDULE AT '1970-01-02 00:00:00' ON COMPLETION PRESERVE DISABLE; -SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -execute_at IS NULL starts IS NULL ends IS NULL comment -0 1 1 -ALTER EVENT event_starts_test COMMENT "non-empty comment"; -SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -execute_at IS NULL starts IS NULL ends IS NULL comment -0 1 1 non-empty comment -ALTER EVENT event_starts_test COMMENT ""; -SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -execute_at IS NULL starts IS NULL ends IS NULL comment -0 1 1 -DROP EVENT event_starts_test; -CREATE EVENT event_starts_test ON SCHEDULE EVERY 20 SECOND STARTS '1970-01-02 00:00:00' ENDS '1970-01-03 00:00:00' ON COMPLETION PRESERVE DISABLE DO SELECT 2; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -execute_at IS NULL starts IS NULL ends IS NULL comment -1 0 0 -ALTER EVENT event_starts_test COMMENT "non-empty comment"; -SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -execute_at IS NULL starts IS NULL ends IS NULL comment -1 0 0 non-empty comment -ALTER EVENT event_starts_test COMMENT ""; -SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -execute_at IS NULL starts IS NULL ends IS NULL comment -1 0 0 -DROP EVENT event_starts_test; -create table test_nested(a int); -create event e_43 on schedule every 1 second do set @a = 5; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -alter event e_43 do alter event e_43 do set @a = 4; -ERROR HY000: Recursion of EVENT DDL statements is forbidden when body is present -alter event e_43 do -begin -alter event e_43 on schedule every 5 minute; -insert into test_nested values(1); -end| -set global event_scheduler = on; -select db, name, body, status, interval_field, interval_value from mysql.event; -db name body status interval_field interval_value -events_test e_43 begin -alter event e_43 on schedule every 5 minute; -insert into test_nested values(1); -end ENABLED MINUTE 5 -drop event e_43; -drop table test_nested; -"Let's check whether we can use non-qualified names" -create table non_qualif(a int); -create event non_qualif_ev on schedule every 10 minute do insert into non_qualif values (800219); -select * from non_qualif; -a -800219 -drop event non_qualif_ev; -drop table non_qualif; -alter event non_existant rename to non_existant_too; -ERROR HY000: Unknown event 'non_existant' -set global event_scheduler = off; -create event existant on schedule at now() + interval 1 year do select 12; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -alter event non_existant rename to existant; -ERROR HY000: Event 'existant' already exists -alter event existant rename to events_test.existant; -ERROR HY000: Same old and new event name -drop event existant; -create table t_event3 (a int, b float); -drop event if exists event3; -Warnings: -Note 1305 Event event3 does not exist -create event event3 on schedule every 50 + 10 minute starts date_add(curdate(), interval 5 minute) ends date_add(curdate(), interval 5 day) comment "portokala_comment" DO insert into t_event3 values (unix_timestamp(), rand()); -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -select count(*) from t_event3; -count(*) -0 -drop event event3; -drop table t_event3; -set names utf8; -CREATE EVENT root6 ON SCHEDULE EVERY '10:20' MINUTE_SECOND ON COMPLETION PRESERVE ENABLE COMMENT 'some comment' DO select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root6; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root6 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root6` ON SCHEDULE EVERY '10:20' MINUTE_SECOND STARTS '#' ON COMPLETION PRESERVE ENABLE COMMENT 'some comment' DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root7 on schedule every 2 year do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root7; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root7 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root7` ON SCHEDULE EVERY 2 YEAR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root8 on schedule every '2:5' year_month do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root8; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root8 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root8` ON SCHEDULE EVERY '2-5' YEAR_MONTH STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root8_1 on schedule every '2:15' year_month do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root8_1; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root8_1 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root8_1` ON SCHEDULE EVERY '3-3' YEAR_MONTH STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root9 on schedule every 2 week ON COMPLETION PRESERVE DISABLE COMMENT 'коментар на кирилица' do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root9; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root9 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root9` ON SCHEDULE EVERY 2 WEEK STARTS '#' ON COMPLETION PRESERVE DISABLE COMMENT 'коментар на кирилица' DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root10 on schedule every '20:5' day_hour do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root10; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root10 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root10` ON SCHEDULE EVERY '20 5' DAY_HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root11 on schedule every '20:25' day_hour do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root11; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root11 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root11` ON SCHEDULE EVERY '21 1' DAY_HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root12 on schedule every '20:25' hour_minute do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root12; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root12 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root12` ON SCHEDULE EVERY '20:25' HOUR_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root13 on schedule every '25:25' hour_minute do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root13; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root13 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root13` ON SCHEDULE EVERY '25:25' HOUR_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root13_1 on schedule every '11:65' hour_minute do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root13_1; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root13_1 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root13_1` ON SCHEDULE EVERY '12:5' HOUR_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root14 on schedule every '35:35' minute_second do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root14; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root14 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root14` ON SCHEDULE EVERY '35:35' MINUTE_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root15 on schedule every '35:66' minute_second do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root15; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root15 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root15` ON SCHEDULE EVERY '36:6' MINUTE_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root16 on schedule every '35:56' day_minute do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root16; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root16 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root16` ON SCHEDULE EVERY '1 11:56' DAY_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root17 on schedule every '35:12:45' day_minute do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root17; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root17 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root17` ON SCHEDULE EVERY '35 12:45' DAY_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root17_1 on schedule every '35:25:65' day_minute do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root17_1; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root17_1 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root17_1` ON SCHEDULE EVERY '36 2:5' DAY_MINUTE STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root18 on schedule every '35:12:45' hour_second do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root18; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root18 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root18` ON SCHEDULE EVERY '35:12:45' HOUR_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root19 on schedule every '15:59:85' hour_second do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root19; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root19 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root19` ON SCHEDULE EVERY '16:0:25' HOUR_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -create event root20 on schedule every '50:20:12:45' day_second do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT root20; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -root20 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `root20` ON SCHEDULE EVERY '50 20:12:45' DAY_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -set names cp1251; -create event ðóóò21 on schedule every '50:23:59:95' day_second COMMENT 'òîâà å 1251 êîìåíòàð' do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW CREATE EVENT ðóóò21; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -ðóóò21 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `руут21` ON SCHEDULE EVERY '51 0:0:35' DAY_SECOND STARTS '#' ON COMPLETION NOT PRESERVE ENABLE COMMENT 'това е 1251 коментар' DO select 1 cp1251 cp1251_general_ci latin1_swedish_ci -insert into mysql.event ( -db, -name, -body, -definer, -interval_value, -interval_field, -originator, -character_set_client, -collation_connection, -db_collation, -body_utf8) -values ( -database(), -"root22", -"select 1", -user(), -100, -"SECOND_MICROSECOND", -1, -'utf8', -'utf8_general_ci', -'utf8_general_ci', -'select 1'); -show create event root22; -ERROR 42000: This version of MariaDB doesn't yet support 'MICROSECOND' -SHOW EVENTS; -ERROR 42000: This version of MariaDB doesn't yet support 'MICROSECOND' -drop event root22; -create event root23 on schedule every -100 year do select 1; -ERROR HY000: INTERVAL is either not positive or too big -create event root23 on schedule every 222222222222222222222 year do select 1; -ERROR HY000: INTERVAL is either not positive or too big -drop event root6; -drop event root7; -drop event root8; -drop event root8_1; -drop event root9; -drop event root10; -drop event root11; -drop event root12; -drop event root13; -drop event root13_1; -drop event root14; -drop event root15; -drop event root16; -drop event root17; -drop event root17_1; -drop event root18; -drop event root19; -drop event root20; -drop event ðóóò21; -set names latin1; -Create a test event. Only event metadata is relevant, -the actual schedule and body are not. -CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing"; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test intact_check root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -Try to alter mysql.event: the server should fail to load -event information after mysql.event was tampered with. - -First, let's add a column to the end and check the error is emitted. - -ALTER TABLE mysql.event ADD dummy INT; -SHOW EVENTS; -ERROR HY000: Failed to open mysql.event -SELECT event_name FROM INFORMATION_SCHEMA.events; -ERROR HY000: Failed to open mysql.event -SHOW CREATE EVENT intact_check; -ERROR HY000: Failed to open mysql.event -DROP EVENT no_such_event; -ERROR HY000: Failed to open mysql.event -CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; -ERROR HY000: Failed to open mysql.event -ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; -ERROR HY000: Failed to open mysql.event -ALTER EVENT intact_check_1 RENAME TO intact_check_2; -ERROR HY000: Failed to open mysql.event -DROP EVENT intact_check_1; -ERROR HY000: Failed to open mysql.event -DROP EVENT intact_check_2; -ERROR HY000: Failed to open mysql.event -DROP EVENT intact_check; -ERROR HY000: Failed to open mysql.event -DROP DATABASE IF EXISTS mysqltest_no_such_database; -Warnings: -Note 1008 Can't drop database 'mysqltest_no_such_database'; database doesn't exist -CREATE DATABASE mysqltest_db2; -DROP DATABASE mysqltest_db2; -Warnings: -Error 1545 Failed to open mysql.event -SELECT @@event_scheduler; -@@event_scheduler -OFF -SHOW VARIABLES LIKE 'event_scheduler'; -Variable_name Value -event_scheduler OFF -SET GLOBAL event_scheduler=OFF; -ALTER TABLE mysql.event DROP dummy; -DROP EVENT intact_check; -CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing"; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. - -Now let's add a column to the first position: the server -expects to see event schema name there - -ALTER TABLE mysql.event ADD dummy INT FIRST; -SHOW EVENTS; -ERROR HY000: Failed to open mysql.event -SELECT event_name FROM INFORMATION_SCHEMA.events; -ERROR HY000: Failed to open mysql.event -SHOW CREATE EVENT intact_check; -ERROR HY000: Failed to open mysql.event -DROP EVENT no_such_event; -ERROR HY000: Failed to open mysql.event -CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; -ERROR HY000: Failed to open mysql.event -ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; -ERROR HY000: Failed to open mysql.event -ALTER EVENT intact_check_1 RENAME TO intact_check_2; -ERROR HY000: Failed to open mysql.event -DROP EVENT intact_check_1; -ERROR HY000: Failed to open mysql.event -DROP EVENT intact_check_2; -ERROR HY000: Failed to open mysql.event -DROP EVENT intact_check; -ERROR HY000: Failed to open mysql.event -DROP DATABASE IF EXISTS mysqltest_no_such_database; -Warnings: -Note 1008 Can't drop database 'mysqltest_no_such_database'; database doesn't exist -CREATE DATABASE mysqltest_db2; -DROP DATABASE mysqltest_db2; -Warnings: -Error 1545 Failed to open mysql.event -SELECT @@event_scheduler; -@@event_scheduler -OFF -SHOW VARIABLES LIKE 'event_scheduler'; -Variable_name Value -event_scheduler OFF -SET GLOBAL event_scheduler=OFF; -Clean up -ALTER TABLE mysql.event DROP dummy; -DELETE FROM mysql.event; -CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing"; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -Back up the table, further changes are not reversible -CREATE TABLE event_like LIKE mysql.event; -INSERT INTO event_like SELECT * FROM mysql.event; - -Drop some columns and try more checks. - - -ALTER TABLE mysql.event DROP comment, DROP starts; -SHOW EVENTS; -ERROR HY000: Failed to open mysql.event -SELECT event_name FROM INFORMATION_SCHEMA.EVENTS; -ERROR HY000: Failed to open mysql.event -SHOW CREATE EVENT intact_check; -ERROR HY000: Failed to open mysql.event -DROP EVENT no_such_event; -ERROR HY000: Failed to open mysql.event -CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; -ERROR HY000: Failed to open mysql.event -ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; -ERROR HY000: Failed to open mysql.event -ALTER EVENT intact_check_1 RENAME TO intact_check_2; -ERROR HY000: Failed to open mysql.event -DROP EVENT intact_check_1; -ERROR HY000: Failed to open mysql.event -DROP EVENT intact_check_2; -ERROR HY000: Failed to open mysql.event -DROP EVENT intact_check; -ERROR HY000: Failed to open mysql.event -DROP DATABASE IF EXISTS mysqltest_no_such_database; -Warnings: -Note 1008 Can't drop database 'mysqltest_no_such_database'; database doesn't exist -CREATE DATABASE mysqltest_db2; -DROP DATABASE mysqltest_db2; -Warnings: -Error 1545 Failed to open mysql.event -SELECT @@event_scheduler; -@@event_scheduler -OFF -SHOW VARIABLES LIKE 'event_scheduler'; -Variable_name Value -event_scheduler OFF -SET GLOBAL event_scheduler=OFF; - -Now drop the table, and test again - - -DROP TABLE mysql.event; -SHOW EVENTS; -ERROR 42S02: Table 'mysql.event' doesn't exist -SELECT event_name FROM INFORMATION_SCHEMA.events; -ERROR 42S02: Table 'mysql.event' doesn't exist -SHOW CREATE EVENT intact_check; -ERROR 42S02: Table 'mysql.event' doesn't exist -DROP EVENT no_such_event; -ERROR 42S02: Table 'mysql.event' doesn't exist -CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; -ERROR 42S02: Table 'mysql.event' doesn't exist -ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; -ERROR 42S02: Table 'mysql.event' doesn't exist -ALTER EVENT intact_check_1 RENAME TO intact_check_2; -ERROR 42S02: Table 'mysql.event' doesn't exist -DROP EVENT intact_check_1; -ERROR 42S02: Table 'mysql.event' doesn't exist -DROP EVENT intact_check_2; -ERROR 42S02: Table 'mysql.event' doesn't exist -DROP EVENT intact_check; -ERROR 42S02: Table 'mysql.event' doesn't exist -DROP DATABASE IF EXISTS mysqltest_no_such_database; -Warnings: -Note 1008 Can't drop database 'mysqltest_no_such_database'; database doesn't exist -CREATE DATABASE mysqltest_db2; -DROP DATABASE mysqltest_db2; -Warnings: -Error 1146 Table 'mysql.event' doesn't exist -OK, there is an unnecessary warning about the non-existent table -but it's not easy to fix and no one complained about it. -A similar warning is printed if mysql.proc is missing. -SHOW WARNINGS; -Level Code Message -Error 1146 Table 'mysql.event' doesn't exist -SELECT @@event_scheduler; -@@event_scheduler -OFF -SHOW VARIABLES LIKE 'event_scheduler'; -Variable_name Value -event_scheduler OFF -SET GLOBAL event_scheduler=OFF; -Restore the original table. -CREATE TABLE mysql.event like event_like; -DROP TABLE event_like; -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation - -# -# Bug#12394306: the sever may crash if mysql.event is corrupted -# - -CREATE EVENT ev1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -ALTER EVENT ev1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; - -CREATE TABLE event_original LIKE mysql.event; -INSERT INTO event_original SELECT * FROM mysql.event; - -ALTER TABLE mysql.event MODIFY modified CHAR(1); -Warnings: -Warning 1265 Data truncated for column 'modified' at row 1 - -SHOW EVENTS; -ERROR HY000: Failed to open mysql.event - -SELECT event_name, created, last_altered FROM information_schema.events; -ERROR HY000: Failed to open mysql.event - -CREATE EVENT ev2 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; -ERROR HY000: Failed to open mysql.event - -ALTER EVENT ev1 ON SCHEDULE EVERY 9 HOUR DO SELECT 9; -ERROR HY000: Failed to open mysql.event - -DROP TABLE mysql.event; -RENAME TABLE event_original TO mysql.event; - -DROP EVENT ev1; - -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -# -# MDEV-9524 Cannot load from mysql.event when sql_mode is set to PAD_CHAR_TO_FULL_LENGTH -# -CREATE TABLE t1 (a INT); -CREATE EVENT ev1 ON SCHEDULE EVERY 5 SECOND DO DELETE FROM t1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test ev1 root@localhost SYSTEM RECURRING NULL 5 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -SET sql_mode=PAD_CHAR_TO_FULL_LENGTH; -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test ev1 root@localhost SYSTEM RECURRING NULL 5 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -DROP EVENT ev1; -CREATE EVENT ev1 ON SCHEDULE EVERY 5 SECOND DO DELETE FROM t1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test ev1 root@localhost SYSTEM RECURRING NULL 5 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -DROP EVENT ev1; -DROP TABLE t1; -SET sql_mode=DEFAULT; - -# -# End of tests -# -drop database events_test; diff --git a/mysql-test/main/events_1.test b/mysql-test/main/events_1.test deleted file mode 100644 index ba8a2059e2d..00000000000 --- a/mysql-test/main/events_1.test +++ /dev/null @@ -1,495 +0,0 @@ -# changes 2008-02-20 hhunger splitted events.test into events_1 and events_2 -# changes 2008-02-22 hhunger replaced all sleep by wait_condition -# -# Can't test with embedded server that doesn't support grants --- 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"); -call mtr.add_suppression("Incorrect definition of table mysql.event:.*"); - ---disable_warnings -drop database if exists events_test; -drop database if exists db_x; -drop database if exists mysqltest_db2; -drop database if exists mysqltest_no_such_database; ---enable_warnings -create database events_test; -use events_test; - -# -# START: BUG #17289 Events: missing privilege check for drop database -# -CREATE USER pauline@localhost; -CREATE DATABASE db_x; -GRANT EVENT ON db_x.* TO pauline@localhost; -USE db_x; -CREATE TABLE x_table(a int); -connect (priv_conn,localhost,pauline,,db_x); -CREATE EVENT e_x1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE db_x; -CREATE EVENT e_x2 ON SCHEDULE EVERY 1 SECOND DO DROP TABLE x_table; -connection default; -SHOW DATABASES LIKE 'db_x'; -SET GLOBAL event_scheduler=1; -let $wait_condition= SELECT count(*)= 1 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME LIKE 'db_x'; ---source include/wait_condition.inc -SHOW DATABASES LIKE 'db_x'; -SHOW TABLES FROM db_x; -SET GLOBAL event_scheduler=off; -connection priv_conn; -DROP EVENT e_x1; -DROP EVENT e_x2; -disconnect priv_conn; -connection default; -DROP DATABASE db_x; -DROP USER pauline@localhost; -USE events_test; -# -# END: BUG #17289 Events: missing privilege check for drop database -# -SET GLOBAL event_scheduler=off; -drop event if exists event1; -create event event1 on schedule every 15 minute starts now() ends date_add(now(), interval 5 hour) DO begin end; -alter event event1 rename to event2 enable; -alter event event2 disable; -alter event event2 enable; -alter event event2 on completion not preserve; -delimiter __; -alter event event2 on schedule every 1 year on completion preserve rename to event3 comment "new comment" do begin select 1; end__ -delimiter ;__ -alter event event3 rename to event2; - -drop event event2; -create event event2 on schedule every 2 second starts now() ends date_add(now(), interval 5 hour) comment "some" DO begin end; -drop event event2; - -# -# BUG #16537 (Events: mysql.event.starts is null) -# -CREATE EVENT event_starts_test ON SCHEDULE EVERY 10 SECOND COMMENT "" DO SELECT 1; -SELECT interval_field, interval_value, body FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -ALTER EVENT event_starts_test ON SCHEDULE AT '1970-01-02 00:00:00' ON COMPLETION PRESERVE DISABLE; -SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -ALTER EVENT event_starts_test COMMENT "non-empty comment"; -SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -ALTER EVENT event_starts_test COMMENT ""; -SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -DROP EVENT event_starts_test; - -CREATE EVENT event_starts_test ON SCHEDULE EVERY 20 SECOND STARTS '1970-01-02 00:00:00' ENDS '1970-01-03 00:00:00' ON COMPLETION PRESERVE DISABLE DO SELECT 2; -SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -ALTER EVENT event_starts_test COMMENT "non-empty comment"; -SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -ALTER EVENT event_starts_test COMMENT ""; -SELECT execute_at IS NULL, starts IS NULL, ends IS NULL, comment FROM mysql.event WHERE db='events_test' AND name='event_starts_test'; -DROP EVENT event_starts_test; -# -# -create table test_nested(a int); -create event e_43 on schedule every 1 second do set @a = 5; ---error ER_EVENT_RECURSION_FORBIDDEN -alter event e_43 do alter event e_43 do set @a = 4; -delimiter |; -alter event e_43 do -begin - alter event e_43 on schedule every 5 minute; - insert into test_nested values(1); -end| -delimiter ;| -set global event_scheduler = on; -let $wait_condition= SELECT count(*)>0 from mysql.event where name='e_43' and interval_value= 5; ---source include/wait_condition.inc -select db, name, body, status, interval_field, interval_value from mysql.event; -drop event e_43; -drop table test_nested; - ---echo "Let's check whether we can use non-qualified names" -create table non_qualif(a int); -create event non_qualif_ev on schedule every 10 minute do insert into non_qualif values (800219); -let $wait_condition=SELECT count(*)= 1 from non_qualif where a=800219; ---source include/wait_condition.inc -select * from non_qualif; -drop event non_qualif_ev; -drop table non_qualif; - ---error ER_EVENT_DOES_NOT_EXIST -alter event non_existant rename to non_existant_too; - -set global event_scheduler = off; -create event existant on schedule at now() + interval 1 year do select 12; ---error ER_EVENT_ALREADY_EXISTS -alter event non_existant rename to existant; ---error ER_EVENT_SAME_NAME -alter event existant rename to events_test.existant; -drop event existant; - - -create table t_event3 (a int, b float); -drop event if exists event3; -create event event3 on schedule every 50 + 10 minute starts date_add(curdate(), interval 5 minute) ends date_add(curdate(), interval 5 day) comment "portokala_comment" DO insert into t_event3 values (unix_timestamp(), rand()); -let $wait_condition=SELECT count(*)=0 from t_event3; ---source include/wait_condition.inc -select count(*) from t_event3; -drop event event3; -drop table t_event3; - - -set names utf8; -# -# SHOW CREATE EVENT test begin -# -CREATE EVENT root6 ON SCHEDULE EVERY '10:20' MINUTE_SECOND ON COMPLETION PRESERVE ENABLE COMMENT 'some comment' DO select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root6; -create event root7 on schedule every 2 year do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root7; -create event root8 on schedule every '2:5' year_month do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root8; -create event root8_1 on schedule every '2:15' year_month do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root8_1; -create event root9 on schedule every 2 week ON COMPLETION PRESERVE DISABLE COMMENT 'коментар на кирилица' do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root9; -create event root10 on schedule every '20:5' day_hour do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root10; -create event root11 on schedule every '20:25' day_hour do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root11; -create event root12 on schedule every '20:25' hour_minute do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root12; -create event root13 on schedule every '25:25' hour_minute do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root13; -create event root13_1 on schedule every '11:65' hour_minute do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root13_1; -create event root14 on schedule every '35:35' minute_second do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root14; -create event root15 on schedule every '35:66' minute_second do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root15; -create event root16 on schedule every '35:56' day_minute do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root16; -create event root17 on schedule every '35:12:45' day_minute do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root17; -create event root17_1 on schedule every '35:25:65' day_minute do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root17_1; -create event root18 on schedule every '35:12:45' hour_second do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root18; -create event root19 on schedule every '15:59:85' hour_second do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root19; -create event root20 on schedule every '50:20:12:45' day_second do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT root20; -set names cp1251; -create event ðóóò21 on schedule every '50:23:59:95' day_second COMMENT 'òîâà å 1251 êîìåíòàð' do select 1; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT ðóóò21; -insert into mysql.event ( - db, - name, - body, - definer, - interval_value, - interval_field, - originator, - character_set_client, - collation_connection, - db_collation, - body_utf8) -values ( - database(), - "root22", - "select 1", - user(), - 100, - "SECOND_MICROSECOND", - 1, - 'utf8', - 'utf8_general_ci', - 'utf8_general_ci', - 'select 1'); ---error ER_NOT_SUPPORTED_YET -show create event root22; ---error ER_NOT_SUPPORTED_YET -SHOW EVENTS; -drop event root22; ---error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG -create event root23 on schedule every -100 year do select 1; ---error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG -create event root23 on schedule every 222222222222222222222 year do select 1; -drop event root6; -drop event root7; -drop event root8; -drop event root8_1; -drop event root9; -drop event root10; -drop event root11; -drop event root12; -drop event root13; -drop event root13_1; -drop event root14; -drop event root15; -drop event root16; -drop event root17; -drop event root17_1; -drop event root18; -drop event root19; -drop event root20; -drop event ðóóò21; - -set names latin1; -# -# SHOW CREATE EVENT test end -# - -# -# mysql.event intact checking -# Check that the server does not crash if -# one has destroyed or tampered with the event table. -# Please see see for events_restart_phase* tests to -# see the server behavior at start up with bad mysql.event -# table. -# -# ---echo Create a test event. Only event metadata is relevant, ---echo the actual schedule and body are not. -# -CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing"; ---replace_column 8 # 9 # -SHOW EVENTS; -# ---echo Try to alter mysql.event: the server should fail to load ---echo event information after mysql.event was tampered with. ---echo ---echo First, let's add a column to the end and check the error is emitted. ---echo -ALTER TABLE mysql.event ADD dummy INT; ---error ER_EVENT_OPEN_TABLE_FAILED -SHOW EVENTS; ---error ER_EVENT_OPEN_TABLE_FAILED -SELECT event_name FROM INFORMATION_SCHEMA.events; ---error ER_EVENT_OPEN_TABLE_FAILED -SHOW CREATE EVENT intact_check; ---error ER_EVENT_OPEN_TABLE_FAILED -DROP EVENT no_such_event; ---error ER_EVENT_OPEN_TABLE_FAILED -CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; ---error ER_EVENT_OPEN_TABLE_FAILED -ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; ---error ER_EVENT_OPEN_TABLE_FAILED -ALTER EVENT intact_check_1 RENAME TO intact_check_2; ---error ER_EVENT_OPEN_TABLE_FAILED -DROP EVENT intact_check_1; ---error ER_EVENT_OPEN_TABLE_FAILED -DROP EVENT intact_check_2; ---error ER_EVENT_OPEN_TABLE_FAILED -DROP EVENT intact_check; -DROP DATABASE IF EXISTS mysqltest_no_such_database; -CREATE DATABASE mysqltest_db2; -DROP DATABASE mysqltest_db2; -SELECT @@event_scheduler; -SHOW VARIABLES LIKE 'event_scheduler'; -SET GLOBAL event_scheduler=OFF; -# Clean up -ALTER TABLE mysql.event DROP dummy; -DROP EVENT intact_check; -CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing"; ---echo ---echo Now let's add a column to the first position: the server ---echo expects to see event schema name there ---echo -ALTER TABLE mysql.event ADD dummy INT FIRST; ---error ER_EVENT_OPEN_TABLE_FAILED -SHOW EVENTS; ---error ER_EVENT_OPEN_TABLE_FAILED -SELECT event_name FROM INFORMATION_SCHEMA.events; ---error ER_EVENT_OPEN_TABLE_FAILED -SHOW CREATE EVENT intact_check; ---error ER_EVENT_OPEN_TABLE_FAILED -DROP EVENT no_such_event; ---error ER_EVENT_OPEN_TABLE_FAILED -CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; ---error ER_EVENT_OPEN_TABLE_FAILED -ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; ---error ER_EVENT_OPEN_TABLE_FAILED -ALTER EVENT intact_check_1 RENAME TO intact_check_2; ---error ER_EVENT_OPEN_TABLE_FAILED -DROP EVENT intact_check_1; ---error ER_EVENT_OPEN_TABLE_FAILED -DROP EVENT intact_check_2; ---error ER_EVENT_OPEN_TABLE_FAILED -DROP EVENT intact_check; -# Should work OK -DROP DATABASE IF EXISTS mysqltest_no_such_database; -CREATE DATABASE mysqltest_db2; -DROP DATABASE mysqltest_db2; -SELECT @@event_scheduler; -SHOW VARIABLES LIKE 'event_scheduler'; -SET GLOBAL event_scheduler=OFF; ---echo Clean up -ALTER TABLE mysql.event DROP dummy; -DELETE FROM mysql.event; -CREATE EVENT intact_check ON SCHEDULE EVERY 10 HOUR DO SELECT "nothing"; ---echo Back up the table, further changes are not reversible -CREATE TABLE event_like LIKE mysql.event; -INSERT INTO event_like SELECT * FROM mysql.event; ---echo ---echo Drop some columns and try more checks. ---echo ---echo -ALTER TABLE mysql.event DROP comment, DROP starts; ---error ER_EVENT_OPEN_TABLE_FAILED -SHOW EVENTS; ---error ER_EVENT_OPEN_TABLE_FAILED -SELECT event_name FROM INFORMATION_SCHEMA.EVENTS; ---error ER_EVENT_OPEN_TABLE_FAILED -SHOW CREATE EVENT intact_check; ---error ER_EVENT_OPEN_TABLE_FAILED -DROP EVENT no_such_event; ---error ER_EVENT_OPEN_TABLE_FAILED -CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; ---error ER_EVENT_OPEN_TABLE_FAILED -ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; ---error ER_EVENT_OPEN_TABLE_FAILED -ALTER EVENT intact_check_1 RENAME TO intact_check_2; ---error ER_EVENT_OPEN_TABLE_FAILED -DROP EVENT intact_check_1; ---error ER_EVENT_OPEN_TABLE_FAILED -DROP EVENT intact_check_2; ---error ER_EVENT_OPEN_TABLE_FAILED -DROP EVENT intact_check; -DROP DATABASE IF EXISTS mysqltest_no_such_database; -CREATE DATABASE mysqltest_db2; -DROP DATABASE mysqltest_db2; -SELECT @@event_scheduler; -SHOW VARIABLES LIKE 'event_scheduler'; -SET GLOBAL event_scheduler=OFF; ---echo ---echo Now drop the table, and test again ---echo ---echo -DROP TABLE mysql.event; ---error ER_NO_SUCH_TABLE -SHOW EVENTS; ---error ER_NO_SUCH_TABLE -SELECT event_name FROM INFORMATION_SCHEMA.events; ---error ER_NO_SUCH_TABLE -SHOW CREATE EVENT intact_check; ---error ER_NO_SUCH_TABLE -DROP EVENT no_such_event; ---error ER_NO_SUCH_TABLE -CREATE EVENT intact_check_1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; ---error ER_NO_SUCH_TABLE -ALTER EVENT intact_check_1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; ---error ER_NO_SUCH_TABLE -ALTER EVENT intact_check_1 RENAME TO intact_check_2; ---error ER_NO_SUCH_TABLE -DROP EVENT intact_check_1; ---error ER_NO_SUCH_TABLE -DROP EVENT intact_check_2; ---error ER_NO_SUCH_TABLE -DROP EVENT intact_check; -DROP DATABASE IF EXISTS mysqltest_no_such_database; -CREATE DATABASE mysqltest_db2; -DROP DATABASE mysqltest_db2; ---echo OK, there is an unnecessary warning about the non-existent table ---echo but it's not easy to fix and no one complained about it. ---echo A similar warning is printed if mysql.proc is missing. -SHOW WARNINGS; -SELECT @@event_scheduler; -SHOW VARIABLES LIKE 'event_scheduler'; -SET GLOBAL event_scheduler=OFF; ---echo Restore the original table. -CREATE TABLE mysql.event like event_like; -DROP TABLE event_like; ---replace_column 8 # 9 # -SHOW EVENTS; - ---echo ---echo # ---echo # Bug#12394306: the sever may crash if mysql.event is corrupted ---echo # - ---echo -CREATE EVENT ev1 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; -ALTER EVENT ev1 ON SCHEDULE EVERY 8 HOUR DO SELECT 8; - ---echo -CREATE TABLE event_original LIKE mysql.event; -INSERT INTO event_original SELECT * FROM mysql.event; - ---echo -ALTER TABLE mysql.event MODIFY modified CHAR(1); - ---echo ---error ER_EVENT_OPEN_TABLE_FAILED -SHOW EVENTS; - ---echo ---error ER_EVENT_OPEN_TABLE_FAILED -SELECT event_name, created, last_altered FROM information_schema.events; - ---echo ---error ER_EVENT_OPEN_TABLE_FAILED -CREATE EVENT ev2 ON SCHEDULE EVERY 5 HOUR DO SELECT 5; - ---echo ---error ER_EVENT_OPEN_TABLE_FAILED -ALTER EVENT ev1 ON SCHEDULE EVERY 9 HOUR DO SELECT 9; - ---echo -DROP TABLE mysql.event; -RENAME TABLE event_original TO mysql.event; - ---echo -DROP EVENT ev1; - ---echo -SHOW EVENTS; - - ---echo # ---echo # MDEV-9524 Cannot load from mysql.event when sql_mode is set to PAD_CHAR_TO_FULL_LENGTH ---echo # -CREATE TABLE t1 (a INT); -CREATE EVENT ev1 ON SCHEDULE EVERY 5 SECOND DO DELETE FROM t1; ---replace_column 8 # 9 # -SHOW EVENTS; -SET sql_mode=PAD_CHAR_TO_FULL_LENGTH; ---replace_column 8 # 9 # -SHOW EVENTS; -DROP EVENT ev1; -CREATE EVENT ev1 ON SCHEDULE EVERY 5 SECOND DO DELETE FROM t1; ---replace_column 8 # 9 # -SHOW EVENTS; -DROP EVENT ev1; -DROP TABLE t1; -SET sql_mode=DEFAULT; - - ---echo ---echo # ---echo # End of tests ---echo # - -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where db='events_test' and command = 'Connect' and user=current_user(); ---source include/wait_condition.inc - -drop database events_test; diff --git a/mysql-test/main/events_2.result b/mysql-test/main/events_2.result deleted file mode 100644 index 1753fa41ad0..00000000000 --- a/mysql-test/main/events_2.result +++ /dev/null @@ -1,439 +0,0 @@ -set sql_mode=""; -drop database if exists events_test; -create database events_test; -use events_test; -create event e_26 on schedule at '2037-01-01 00:00:00' disable do set @a = 5; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event; -db name body definer convert_tz(execute_at, 'UTC', 'SYSTEM') on_completion -events_test e_26 set @a = 5 root@localhost 2037-01-01 00:00:00 DROP -drop event e_26; -create event e_26 on schedule at NULL disable do set @a = 5; -ERROR HY000: Incorrect AT value: 'NULL' -create event e_26 on schedule at 'definitely not a datetime' disable do set @a = 5; -ERROR HY000: Incorrect AT value: 'definitely not a datetime' -set names utf8; -create event задачка on schedule every 123 minute starts now() ends now() + interval 1 month do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -drop event задачка; -"DISABLE the scheduler. Testing that it does not work when the variable is 0" -set global event_scheduler=off; -select definer, name, db from mysql.event; -definer name db -select get_lock("test_lock1", 20); -get_lock("test_lock1", 20) -1 -create event закачка on schedule every 10 hour do select get_lock("test_lock1", 20); -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -"Should return 1 row" -select definer, name, db from mysql.event; -definer name db -root@localhost закачка events_test -"Should be only 0 process" -select /*1*/ user, host, db, command, state, info -from information_schema.processlist -where (user='event_scheduler') -order by info; -user host db command state info -select release_lock("test_lock1"); -release_lock("test_lock1") -1 -drop event закачка; -"Should have 0 events" -select count(*) from mysql.event; -count(*) -0 -"ENABLE the scheduler and get a lock" -set global event_scheduler=on; -select get_lock("test_lock2", 20); -get_lock("test_lock2", 20) -1 -"Create an event which tries to acquire a mutex. The event locks on the mutex" -create event закачка on schedule every 10 hour do select get_lock("test_lock2", 20); -"Should have only 2 processes: the scheduler and the locked event" -select /*2*/ user, host, db, command, state, info -from information_schema.processlist -where (info like "select get_lock%" OR user='event_scheduler') -order by info; -user host db command state info -event_scheduler localhost NULL Daemon Waiting for next activation NULL -root localhost events_test Connect User lock select get_lock("test_lock2", 20) -"Release the mutex, the event worker should finish." -select release_lock("test_lock2"); -release_lock("test_lock2") -1 -drop event закачка; -set global event_scheduler=1; -select get_lock("test_lock2_1", 20); -get_lock("test_lock2_1", 20) -1 -create event закачка21 on schedule every 10 hour do select get_lock("test_lock2_1", 20); -"Should have only 2 processes: the scheduler and the locked event" -select /*3*/ user, host, db, command, state, info -from information_schema.processlist -where (info like "select get_lock%" OR user='event_scheduler') -order by info; -user host db command state info -event_scheduler localhost NULL Daemon Waiting for next activation NULL -root localhost events_test Connect User lock select get_lock("test_lock2_1", 20) -set global event_scheduler=off; -"Should have only our process now:" -select /*4*/ user, host, db, command, state, info -from information_schema.processlist -where (info like "select get_lock%" OR user='event_scheduler') -order by info; -user host db command state info -root localhost events_test Connect User lock select get_lock("test_lock2_1", 20) -select release_lock("test_lock2_1"); -release_lock("test_lock2_1") -1 -drop event закачка21; -create table t_16 (s1 int); -create trigger t_16_bi before insert on t_16 for each row create event e_16 on schedule every 1 second do set @a=5; -ERROR HY000: Recursion of EVENT DDL statements is forbidden when body is present -drop table t_16; -create event white_space -on schedule every 10 hour -disable -do -select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space'; -event_schema event_name definer event_definition -events_test white_space root@localhost select 1 -drop event white_space; -create event white_space on schedule every 10 hour disable do -select 2; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space'; -event_schema event_name definer event_definition -events_test white_space root@localhost select 2 -drop event white_space; -create event white_space on schedule every 10 hour disable do select 3; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space'; -event_schema event_name definer event_definition -events_test white_space root@localhost select 3 -drop event white_space; -create event e1 on schedule every 1 year do set @a = 5; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -create table t1 (s1 int); -create trigger t1_ai after insert on t1 for each row show create event e1; -ERROR 0A000: Not allowed to return a result set from a trigger -drop table t1; -drop event e1; -SHOW EVENTS FROM aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; -ERROR 42000: Incorrect database name 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' -SHOW EVENTS FROM ``; -ERROR 42000: Incorrect database name '' -SHOW EVENTS FROM `events\\test`; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation - -LOCK TABLES mode. - -create table t1 (a int); -create event e1 on schedule every 10 hour do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -lock table t1 read; -show create event e1; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -e1 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -select event_name from information_schema.events; -event_name -e1 -create event e2 on schedule every 10 hour do select 1; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -alter event e2 disable; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -alter event e2 rename to e3; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -drop event e2; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -drop event e1; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -unlock tables; -lock table t1 write; -show create event e1; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -e1 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -select event_name from information_schema.events; -event_name -e1 -create event e2 on schedule every 10 hour do select 1; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -alter event e2 disable; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -alter event e2 rename to e3; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -drop event e2; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -drop event e1; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -unlock tables; -lock table t1 read, mysql.event read; -show create event e1; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -e1 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -select event_name from information_schema.events; -event_name -e1 -create event e2 on schedule every 10 hour do select 1; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -alter event e2 disable; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -alter event e2 rename to e3; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -drop event e2; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -drop event e1; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -unlock tables; -lock table t1 write, mysql.event read; -show create event e1; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -e1 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -select event_name from information_schema.events; -event_name -e1 -create event e2 on schedule every 10 hour do select 1; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -alter event e2 disable; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -alter event e2 rename to e3; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -drop event e2; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -drop event e1; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -unlock tables; -lock table t1 read, mysql.event write; -ERROR HY000: You can't combine write-locking of system tables with other tables or lock types -lock table t1 write, mysql.event write; -ERROR HY000: You can't combine write-locking of system tables with other tables or lock types -lock table mysql.event write; -show create event e1; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -e1 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `e1` ON SCHEDULE EVERY 10 HOUR STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO select 1 utf8mb3 utf8mb3_general_ci latin1_swedish_ci -select event_name from information_schema.events; -event_name -e1 -create event e2 on schedule every 10 hour do select 1; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -alter event e2 disable; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -alter event e2 rename to e3; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -drop event e3; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -drop event e1; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -unlock tables; -drop event e1; -Make sure we have left no events -select event_name from information_schema.events; -event_name - -Events in sub-statements, events and prelocking - - -create event e1 on schedule every 10 hour do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -create function f1() returns int -begin -show create event e1; -return 1; -end| -ERROR 0A000: Not allowed to return a result set from a function -create trigger trg before insert on t1 for each row -begin -show create event e1; -end| -ERROR 0A000: Not allowed to return a result set from a trigger -create function f1() returns int -begin -select event_name from information_schema.events; -return 1; -end| -ERROR 0A000: Not allowed to return a result set from a function -create trigger trg before insert on t1 for each row -begin -select event_name from information_schema.events; -end| -ERROR 0A000: Not allowed to return a result set from a trigger -create function f1() returns int -begin -create event e2 on schedule every 10 hour do select 1; -return 1; -end| -ERROR HY000: Recursion of EVENT DDL statements is forbidden when body is present -create function f1() returns int -begin -alter event e1 rename to e2; -return 1; -end| -ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger -create function f1() returns int -begin -drop event e2; -return 1; -end| -ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger ----------------------------------------------------------------------- -create trigger trg before insert on t1 for each row -begin -set new.a= f1(); -end| -create function f1() returns int -begin -call p1(); -return 0; -end| -create procedure p1() -begin -select event_name from information_schema.events; -end| -insert into t1 (a) values (1)| -ERROR 0A000: Not allowed to return a result set from a trigger -drop procedure p1| -create procedure p1() -begin -show create event e1; -end| -insert into t1 (a) values (1)| -ERROR 0A000: Not allowed to return a result set from a trigger -drop procedure p1| -create procedure p1() -begin -create temporary table tmp select event_name from information_schema.events; -end| -expected to work, since we redirect the output into a tmp table -insert into t1 (a) values (1)| -select * from tmp| -event_name -e1 -drop temporary table tmp| -drop procedure p1| -create procedure p1() -begin -alter event e1 rename to e2; -end| -insert into t1 (a) values (1)| -ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger -drop procedure p1| -create procedure p1() -begin -drop event e1; -end| -insert into t1 (a) values (1)| -ERROR HY000: Explicit or implicit commit is not allowed in stored function or trigger -drop table t1| -drop event e1| -set names utf8; -create event имÑ_ÑобытиÑ_в_кодировке_утф8_длиной_больше_чем_48 on schedule every 2 year do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -select EVENT_NAME from information_schema.events -where event_schema='test'; -EVENT_NAME -drop event имÑ_ÑобытиÑ_в_кодировке_утф8_длиной_больше_чем_48; -create event -очень_очень_очень_очень_очень_очень_очень_очень_длиннаÑ_Ñтрока_66 -on schedule every 2 year do select 1; -ERROR 42000: Identifier name 'очень_очень_очень_очень_очень_очень_очень_очень_длин...' is too long -create event event_35981 on schedule every 6 month on completion preserve -disable -do -select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -The following SELECTs should all give 1 -select count(*) from information_schema.events -where event_schema = database() and event_name = 'event_35981' and -on_completion = 'PRESERVE'; -count(*) -1 -alter event event_35981 enable; -select count(*) from information_schema.events -where event_schema = database() and event_name = 'event_35981' and -on_completion = 'PRESERVE'; -count(*) -1 -alter event event_35981 on completion not preserve; -select count(*) from information_schema.events -where event_schema = database() and event_name = 'event_35981' and -on_completion = 'NOT PRESERVE'; -count(*) -1 -alter event event_35981 disable; -select count(*) from information_schema.events -where event_schema = database() and event_name = 'event_35981' and -on_completion = 'NOT PRESERVE'; -count(*) -1 -alter event event_35981 on completion preserve; -select count(*) from information_schema.events -where event_schema = database() and event_name = 'event_35981' and -on_completion = 'PRESERVE'; -count(*) -1 -drop event event_35981; -create event event_35981 on schedule every 6 month disable -do -select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -select count(*) from information_schema.events -where event_schema = database() and event_name = 'event_35981' and -on_completion = 'NOT PRESERVE'; -count(*) -1 -drop event event_35981; -create event event_35981 on schedule every 1 hour starts current_timestamp -on completion not preserve -do -select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' - ends '1999-01-02 00:00:00'; -ERROR HY000: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was not changed. Specify a time in the future -drop event event_35981; -create event event_35981 on schedule every 1 hour starts current_timestamp -on completion not preserve -do -select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' - ends '1999-01-02 00:00:00' on completion preserve; -Warnings: -Note 1544 Event execution time is in the past. Event has been disabled -drop event event_35981; -create event event_35981 on schedule every 1 hour starts current_timestamp -on completion preserve -do -select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' - ends '1999-01-02 00:00:00'; -Warnings: -Note 1544 Event execution time is in the past. Event has been disabled -alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' - ends '1999-01-02 00:00:00' on completion not preserve; -ERROR HY000: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was not changed. Specify a time in the future -alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' - ends '1999-01-02 00:00:00' on completion preserve; -Warnings: -Note 1544 Event execution time is in the past. Event has been disabled -drop event event_35981; -drop database events_test; diff --git a/mysql-test/main/events_2.test b/mysql-test/main/events_2.test deleted file mode 100644 index cd0d908b870..00000000000 --- a/mysql-test/main/events_2.test +++ /dev/null @@ -1,528 +0,0 @@ -# changes 2008-02-20 hhunger splitted events.test into events_1 and events_2 -# -# Can't test with embedded server that doesn't support grants --- source include/not_embedded.inc - ---disable_service_connection - -set sql_mode=""; ---source include/default_charset.inc - ---disable_warnings -drop database if exists events_test; ---enable_warnings -create database events_test; -use events_test; - -# -# mysql.event intact checking end -# - -create event e_26 on schedule at '2037-01-01 00:00:00' disable do set @a = 5; -select db, name, body, definer, convert_tz(execute_at, 'UTC', 'SYSTEM'), on_completion from mysql.event; -drop event e_26; ---error ER_WRONG_VALUE -create event e_26 on schedule at NULL disable do set @a = 5; ---error ER_WRONG_VALUE -create event e_26 on schedule at 'definitely not a datetime' disable do set @a = 5; - -set names utf8; -create event задачка on schedule every 123 minute starts now() ends now() + interval 1 month do select 1; -drop event задачка; - ---echo "DISABLE the scheduler. Testing that it does not work when the variable is 0" -set global event_scheduler=off; -select definer, name, db from mysql.event; -select get_lock("test_lock1", 20); -create event закачка on schedule every 10 hour do select get_lock("test_lock1", 20); ---echo "Should return 1 row" -select definer, name, db from mysql.event; - ---echo "Should be only 0 process" -select /*1*/ user, host, db, command, state, info - from information_schema.processlist - where (user='event_scheduler') - order by info; -select release_lock("test_lock1"); -drop event закачка; ---echo "Should have 0 events" -select count(*) from mysql.event; - -# -# -# ---echo "ENABLE the scheduler and get a lock" -set global event_scheduler=on; -select get_lock("test_lock2", 20); ---echo "Create an event which tries to acquire a mutex. The event locks on the mutex" -create event закачка on schedule every 10 hour do select get_lock("test_lock2", 20); - ---echo "Should have only 2 processes: the scheduler and the locked event" -let $wait_condition= select count(*) = 2 from information_schema.processlist - where ( (state like 'User lock%' AND info like 'select get_lock%') - OR (command='Daemon' AND user='event_scheduler' AND - state = 'Waiting for next activation')); ---source include/wait_condition.inc - -select /*2*/ user, host, db, command, state, info - from information_schema.processlist - where (info like "select get_lock%" OR user='event_scheduler') - order by info; ---echo "Release the mutex, the event worker should finish." -select release_lock("test_lock2"); -drop event закачка; - -# Wait for get_lock("test_lock2") to complete, -# to avoid polluting the next test information_schema.processlist -let $wait_condition= select count(*) = 0 from information_schema.processlist - where info='select get_lock("test_lock2", 20)'; ---source include/wait_condition.inc - - -## -## 1. get a lock -## 2. create an event -## 3. sleep so it has time to start -## 4. should appear in processlist -## 5. kill the scheduler, it will wait for the child to stop -## 6. both processes should be there on show processlist -## 7. release the lock and sleep, both scheduler and child should end -set global event_scheduler=1; -select get_lock("test_lock2_1", 20); -create event закачка21 on schedule every 10 hour do select get_lock("test_lock2_1", 20); - ---echo "Should have only 2 processes: the scheduler and the locked event" -let $wait_condition= select count(*) = 2 from information_schema.processlist - where ( (state like 'User lock%' AND info like 'select get_lock%') - OR (command='Daemon' AND user='event_scheduler' AND - state = 'Waiting for next activation')); ---source include/wait_condition.inc - -select /*3*/ user, host, db, command, state, info - from information_schema.processlist - where (info like "select get_lock%" OR user='event_scheduler') - order by info; - -set global event_scheduler=off; - -let $wait_condition= select count(*) =1 from information_schema.processlist - where (info like "select get_lock%" OR user='event_scheduler'); ---source include/wait_condition.inc - ---echo "Should have only our process now:" -select /*4*/ user, host, db, command, state, info - from information_schema.processlist - where (info like "select get_lock%" OR user='event_scheduler') - order by info; -select release_lock("test_lock2_1"); -drop event закачка21; -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where db='events_test' and command = 'Connect' and user=current_user(); ---source include/wait_condition.inc - -#### -# Bug #16410 Events: CREATE EVENT is legal in a CREATE TRIGGER statement -# -create table t_16 (s1 int); ---error ER_EVENT_RECURSION_FORBIDDEN -create trigger t_16_bi before insert on t_16 for each row create event e_16 on schedule every 1 second do set @a=5; -drop table t_16; -# -# end of test case -#### - -# -# START: BUG #17453: Creating Event crash the server -# -create event white_space -on schedule every 10 hour -disable -do -select 1; -select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space'; -drop event white_space; -create event white_space on schedule every 10 hour disable do - -select 2; -select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space'; -drop event white_space; -create event white_space on schedule every 10 hour disable do select 3; -select event_schema, event_name, definer, event_definition from information_schema.events where event_name='white_space'; -drop event white_space; -# -# END: BUG #17453: Creating Event crash the server -# - -# -# Bug#17403 "Events: packets out of order with show create event" -# -create event e1 on schedule every 1 year do set @a = 5; -create table t1 (s1 int); ---error ER_SP_NO_RETSET -create trigger t1_ai after insert on t1 for each row show create event e1; -drop table t1; -drop event e1; - -##set global event_scheduler=1; -##select get_lock("test_lock3", 20); -##create event закачка on schedule every 10 hour do select get_lock("test_lock3", 20); -##select sleep(2); -##select /*5*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info; -##drop event закачка; -##select release_lock("test_lock3"); - -# -# test with very often occuring event -# (disabled for now, locks) -##select get_lock("test_lock4", 20); -##create event закачка4 on schedule every 1 second do select get_lock("test_lock4", 20); -##select sleep(3); -##select /*6*/ user, host, db, command, state, info from information_schema.processlist where info is null or info not like '%processlist%' order by info; -##drop event закачка4; -##select release_lock("test_lock4"); - -##set global event_scheduler=off; -##select sleep(2); -##--replace_column 1 # 6 # -##show processlist; -##select count(*) from mysql.event; - -# -# Test wrong syntax -# - ---error ER_WRONG_DB_NAME -SHOW EVENTS FROM aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; ---error ER_WRONG_DB_NAME -SHOW EVENTS FROM ``; - -SHOW EVENTS FROM `events\\test`; -# -# A check for events SQL under LOCK TABLES and in pre-locked mode. -# ---echo ---echo LOCK TABLES mode. ---echo -# -# SHOW CREATE EVENT and INFORMATION_SCHEMA.events are available and -# cause an implicit lock/unlock of mysql.event table, regardless of the -# currently locked tables. -# -create table t1 (a int); -create event e1 on schedule every 10 hour do select 1; -# -lock table t1 read; -# ---replace_regex /STARTS '[^']+'/STARTS '#'/ -show create event e1; -select event_name from information_schema.events; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -create event e2 on schedule every 10 hour do select 1; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -alter event e2 disable; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -alter event e2 rename to e3; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -drop event e2; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -drop event e1; -unlock tables; -# -lock table t1 write; -# ---replace_regex /STARTS '[^']+'/STARTS '#'/ -show create event e1; -select event_name from information_schema.events; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -create event e2 on schedule every 10 hour do select 1; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -alter event e2 disable; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -alter event e2 rename to e3; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -drop event e2; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -drop event e1; -unlock tables; -# -lock table t1 read, mysql.event read; -# ---replace_regex /STARTS '[^']+'/STARTS '#'/ -show create event e1; -select event_name from information_schema.events; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -create event e2 on schedule every 10 hour do select 1; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -alter event e2 disable; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -alter event e2 rename to e3; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -drop event e2; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -drop event e1; -unlock tables; -# -lock table t1 write, mysql.event read; -# ---replace_regex /STARTS '[^']+'/STARTS '#'/ -show create event e1; -select event_name from information_schema.events; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -create event e2 on schedule every 10 hour do select 1; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -alter event e2 disable; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -alter event e2 rename to e3; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -drop event e2; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -drop event e1; -unlock tables; -# ---error ER_WRONG_LOCK_OF_SYSTEM_TABLE -lock table t1 read, mysql.event write; -# ---error ER_WRONG_LOCK_OF_SYSTEM_TABLE -lock table t1 write, mysql.event write; -# -lock table mysql.event write; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -show create event e1; -select event_name from information_schema.events; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -create event e2 on schedule every 10 hour do select 1; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -alter event e2 disable; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -alter event e2 rename to e3; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -drop event e3; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -drop event e1; -unlock tables; -drop event e1; ---echo Make sure we have left no events -select event_name from information_schema.events; ---echo ---echo Events in sub-statements, events and prelocking ---echo ---echo -create event e1 on schedule every 10 hour do select 1; -delimiter |; ---error ER_SP_NO_RETSET -create function f1() returns int -begin - show create event e1; - return 1; -end| ---error ER_SP_NO_RETSET -create trigger trg before insert on t1 for each row -begin - show create event e1; -end| ---error ER_SP_NO_RETSET -create function f1() returns int -begin - select event_name from information_schema.events; - return 1; -end| ---error ER_SP_NO_RETSET -create trigger trg before insert on t1 for each row -begin - select event_name from information_schema.events; -end| ---error ER_EVENT_RECURSION_FORBIDDEN -create function f1() returns int -begin - create event e2 on schedule every 10 hour do select 1; - return 1; -end| ---error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG -create function f1() returns int -begin - alter event e1 rename to e2; - return 1; -end| ---error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG -create function f1() returns int -begin - drop event e2; - return 1; -end| ---echo ---------------------------------------------------------------------- -create trigger trg before insert on t1 for each row -begin - set new.a= f1(); -end| -create function f1() returns int -begin - call p1(); - return 0; -end| -create procedure p1() -begin - select event_name from information_schema.events; -end| ---error ER_SP_NO_RETSET -insert into t1 (a) values (1)| -drop procedure p1| -create procedure p1() -begin - show create event e1; -end| ---error ER_SP_NO_RETSET -insert into t1 (a) values (1)| -drop procedure p1| -create procedure p1() -begin - create temporary table tmp select event_name from information_schema.events; -end| ---echo expected to work, since we redirect the output into a tmp table -insert into t1 (a) values (1)| -select * from tmp| -drop temporary table tmp| -drop procedure p1| -create procedure p1() -begin - alter event e1 rename to e2; -end| ---error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG -insert into t1 (a) values (1)| -drop procedure p1| -create procedure p1() -begin - drop event e1; -end| ---error ER_COMMIT_NOT_ALLOWED_IN_SF_OR_TRG -insert into t1 (a) values (1)| -drop table t1| -drop event e1| -delimiter ;| - -# -# Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte -# -set names utf8; -create event имÑ_ÑобытиÑ_в_кодировке_утф8_длиной_больше_чем_48 on schedule every 2 year do select 1; -select EVENT_NAME from information_schema.events -where event_schema='test'; -drop event имÑ_ÑобытиÑ_в_кодировке_утф8_длиной_больше_чем_48; ---error 1059 -create event -очень_очень_очень_очень_очень_очень_очень_очень_длиннаÑ_Ñтрока_66 -on schedule every 2 year do select 1; - -# -# Bug#35981: ALTER EVENT causes the server to change the PRESERVE option. -# - -create event event_35981 on schedule every 6 month on completion preserve -disable -do - select 1; - -echo The following SELECTs should all give 1; - -# show current ON_COMPLETION -select count(*) from information_schema.events -where event_schema = database() and event_name = 'event_35981' and - on_completion = 'PRESERVE'; - -# show ON_COMPLETION remains "PRESERVE" when not given in ALTER EVENT -alter event event_35981 enable; -select count(*) from information_schema.events -where event_schema = database() and event_name = 'event_35981' and - on_completion = 'PRESERVE'; - -# show we can change ON_COMPLETION -alter event event_35981 on completion not preserve; -select count(*) from information_schema.events -where event_schema = database() and event_name = 'event_35981' and - on_completion = 'NOT PRESERVE'; - -# show ON_COMPLETION remains "NOT PRESERVE" when not given in ALTER EVENT -alter event event_35981 disable; -select count(*) from information_schema.events -where event_schema = database() and event_name = 'event_35981' and - on_completion = 'NOT PRESERVE'; - -# show we can change ON_COMPLETION -alter event event_35981 on completion preserve; -select count(*) from information_schema.events -where event_schema = database() and event_name = 'event_35981' and - on_completion = 'PRESERVE'; - - -drop event event_35981; - -create event event_35981 on schedule every 6 month disable -do - select 1; - -# show that the defaults for CREATE EVENT are still correct (NOT PRESERVE) -select count(*) from information_schema.events -where event_schema = database() and event_name = 'event_35981' and - on_completion = 'NOT PRESERVE'; - -drop event event_35981; - - -# show that backdating doesn't break - -create event event_35981 on schedule every 1 hour starts current_timestamp - on completion not preserve -do - select 1; - -# should fail thanks to above's NOT PRESERVE ---error ER_EVENT_CANNOT_ALTER_IN_THE_PAST -alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' - ends '1999-01-02 00:00:00'; - -drop event event_35981; - -create event event_35981 on schedule every 1 hour starts current_timestamp - on completion not preserve -do - select 1; - -# succeed with warning -alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' - ends '1999-01-02 00:00:00' on completion preserve; - -drop event event_35981; - - - -create event event_35981 on schedule every 1 hour starts current_timestamp - on completion preserve -do - select 1; - -# this should succeed thanks to above PRESERVE! give a warning though. -alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' - ends '1999-01-02 00:00:00'; - -# this should fail, as the event would have passed already ---error ER_EVENT_CANNOT_ALTER_IN_THE_PAST -alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' - ends '1999-01-02 00:00:00' on completion not preserve; - -# should succeed giving a warning -alter event event_35981 on schedule every 1 hour starts '1999-01-01 00:00:00' - ends '1999-01-02 00:00:00' on completion preserve; - -drop event event_35981; - -# -# End of tests -# - -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where db='events_test' and command = 'Connect' and user=current_user(); ---source include/wait_condition.inc - -drop database events_test; ---enable_service_connection diff --git a/mysql-test/main/events_bugs-master.opt b/mysql-test/main/events_bugs-master.opt deleted file mode 100644 index f93413a61e5..00000000000 --- a/mysql-test/main/events_bugs-master.opt +++ /dev/null @@ -1 +0,0 @@ ---event-scheduler diff --git a/mysql-test/main/events_bugs.result b/mysql-test/main/events_bugs.result deleted file mode 100644 index 0615dac53b1..00000000000 --- a/mysql-test/main/events_bugs.result +++ /dev/null @@ -1,871 +0,0 @@ -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; -set @@global.concurrent_insert = 0; -select * from information_schema.global_variables where variable_name like 'event_scheduler'; -VARIABLE_NAME VARIABLE_VALUE -EVENT_SCHEDULER ON -SET GLOBAL event_scheduler = 'OFF'; -CREATE EVENT lower_case ON SCHEDULE EVERY 1 MINUTE DO SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -CREATE EVENT Lower_case ON SCHEDULE EVERY 2 MINUTE DO SELECT 2; -ERROR HY000: Event 'Lower_case' already exists -DROP EVENT Lower_case; -SET NAMES cp1251; -CREATE EVENT äîëåí_ðåãèñòúð_1251 ON SCHEDULE EVERY 1 YEAR DO SELECT 100; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -CREATE EVENT ÄîËåÍ_ðåãèñòúð_1251 ON SCHEDULE EVERY 2 YEAR DO SELECT 200; -ERROR HY000: Event 'ÄîËåÍ_ðåãèñòúð_1251' already exists -DROP EVENT ÄîËåÍ_ðåãèñòúð_1251; -SET NAMES utf8; -CREATE EVENT долен_региÑтър_утф8 ON SCHEDULE EVERY 3 YEAR DO SELECT 300; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -CREATE EVENT ДОЛЕÐ_региÑтър_утф8 ON SCHEDULE EVERY 4 YEAR DO SELECT 400; -ERROR HY000: Event 'ДОЛЕÐ_региÑтър_утф8' already exists -DROP EVENT ДОЛЕÐ_региÑтър_утф8; -SET NAMES latin1; -set @a=3; -CREATE PROCEDURE p_16 () CREATE EVENT e_16 ON SCHEDULE EVERY @a SECOND DO SET @a=5; -ERROR HY000: Recursion of EVENT DDL statements is forbidden when body is present -create event e_55 on schedule at 99990101000000 do drop table t; -ERROR HY000: Incorrect AT value: '99990101000000' -create event e_55 on schedule every 10 hour starts 99990101000000 do drop table t; -ERROR HY000: Incorrect STARTS value: '99990101000000' -create event e_55 on schedule every 10 minute ends 99990101000000 do drop table t; -ERROR HY000: ENDS is either invalid or before STARTS -create event e_55 on schedule at 10000101000000 do drop table t; -ERROR HY000: Incorrect AT value: '10000101000000' -create event e_55 on schedule at 20000101000000 do drop table t; -Warnings: -Note 1588 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation -show events; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -create event e_55 on schedule at 20200101000000 starts 10000101000000 do drop table t; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'starts 10000101000000 do drop table t' at line 1 -create event e_55 on schedule at 20200101000000 ends 10000101000000 do drop table t; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ends 10000101000000 do drop table t' at line 1 -create event e_55 on schedule at 20200101000000 starts 10000101000000 ends 10000101000000 do drop table t; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'starts 10000101000000 ends 10000101000000 do drop table t' at line 1 -create event e_55 on schedule every 10 hour starts 10000101000000 do drop table t; -ERROR HY000: Incorrect STARTS value: '10000101000000' -set global event_scheduler=off; -delete from mysql.event; -set global event_scheduler= on; -set @old_sql_mode:=@@sql_mode; -set sql_mode=ansi; -select get_lock('test_bug16407', 60); -get_lock('test_bug16407', 60) -1 -create event e_16407 on schedule every 60 second do -begin -select get_lock('test_bug16407', 60); -end| -"Now if everything is fine the event has compiled and is locked" -select /*1*/ user, host, db, info from information_schema.processlist -where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)'; -user host db info -root localhost events_test select get_lock('test_bug16407', 60) -select release_lock('test_bug16407'); -release_lock('test_bug16407') -1 -set global event_scheduler= off; -select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; -event_schema event_name sql_mode -events_test e_16407 REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI -"Let's check whether we change the sql_mode on ALTER EVENT" -set sql_mode='traditional'; -alter event e_16407 do select 1; -select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; -event_schema event_name sql_mode -events_test e_16407 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION -drop event e_16407; -set sql_mode="ansi"; -select get_lock('ee_16407_2', 60); -get_lock('ee_16407_2', 60) -1 -set global event_scheduler= 1; -"Another sql_mode test" -set sql_mode="traditional"; -create table events_smode_test(ev_name char(10), a date); -"This should never insert something" -create event ee_16407_2 on schedule every 60 second do -begin -select get_lock('ee_16407_2', 60); /*ee_16407_2*/ -select release_lock('ee_16407_2'); -insert into events_test.events_smode_test values('ee_16407_2','1980-19-02'); -end| -insert into events_test.events_smode_test values ('test','1980-19-02')| -ERROR 22007: Incorrect date value: '1980-19-02' for column `events_test`.`events_smode_test`.`a` at row 1 -"This is ok" -create event ee_16407_3 on schedule every 60 second do -begin -select get_lock('ee_16407_2', 60); /*ee_16407_3*/ -select release_lock('ee_16407_2'); -insert into events_test.events_smode_test values ('ee_16407_3','1980-02-19'); -insert into events_test.events_smode_test values ('ee_16407_3','1980-02-29'); -end| -set sql_mode=""| -"This will insert rows but they will be truncated" -create event ee_16407_4 on schedule every 60 second do -begin -select get_lock('ee_16407_2', 60); /*ee_16407_4*/ -select release_lock('ee_16407_2'); -insert into events_test.events_smode_test values ('ee_16407_4','10-11-1956'); -end| -select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; -event_schema event_name sql_mode -events_test ee_16407_2 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION -events_test ee_16407_3 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION -events_test ee_16407_4 -select /*2*/ user, host, db, info from information_schema.processlist -where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; -user host db info -root localhost events_test select get_lock('ee_16407_2', 60) -root localhost events_test select get_lock('ee_16407_2', 60) -root localhost events_test select get_lock('ee_16407_2', 60) -select release_lock('ee_16407_2'); -release_lock('ee_16407_2') -1 -select /*3*/ user, host, db, info from information_schema.processlist -where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; -user host db info -set global event_scheduler= off; -select * from events_test.events_smode_test order by ev_name, a; -ev_name a -ee_16407_3 1980-02-19 -ee_16407_3 1980-02-29 -ee_16407_4 0000-00-00 -"OK, last check before we drop them" -select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; -event_schema event_name sql_mode -events_test ee_16407_2 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION -events_test ee_16407_3 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION -events_test ee_16407_4 -drop event ee_16407_2; -drop event ee_16407_3; -drop event ee_16407_4; -"And now one last test regarding sql_mode and call of SP from an event" -delete from events_test.events_smode_test; -set sql_mode='ansi'; -select get_lock('ee_16407_5', 60); -get_lock('ee_16407_5', 60) -1 -set global event_scheduler= on; -set sql_mode='traditional'; -create procedure ee_16407_5_pendant() begin insert into events_test.events_smode_test values('ee_16407_5','2001-02-29'); end| -create procedure ee_16407_6_pendant() begin insert into events_test.events_smode_test values('ee_16407_6','2004-02-29'); end| -create event ee_16407_5 on schedule every 60 second do -begin -select get_lock('ee_16407_5', 60); /*ee_16407_5*/ -select release_lock('ee_16407_5'); -call events_test.ee_16407_5_pendant(); -end| -create event ee_16407_6 on schedule every 60 second do -begin -select get_lock('ee_16407_5', 60); /*ee_16407_6*/ -select release_lock('ee_16407_5'); -call events_test.ee_16407_6_pendant(); -end| -"Should have 2 locked processes" -select /*4*/ user, host, db, info from information_schema.processlist -where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; -user host db info -root localhost events_test select get_lock('ee_16407_5', 60) -root localhost events_test select get_lock('ee_16407_5', 60) -select release_lock('ee_16407_5'); -release_lock('ee_16407_5') -1 -"Should have 0 processes locked" -select /*5*/ user, host, db, info from information_schema.processlist -where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; -user host db info -select * from events_test.events_smode_test order by ev_name, a; -ev_name a -ee_16407_6 2004-02-29 -"And here we check one more time before we drop the events" -select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; -event_schema event_name sql_mode -events_test ee_16407_5 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION -events_test ee_16407_6 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION -drop event ee_16407_5; -drop event ee_16407_6; -drop procedure ee_16407_5_pendant; -drop procedure ee_16407_6_pendant; -set global event_scheduler= off; -drop table events_smode_test; -set sql_mode=@old_sql_mode; -set global event_scheduler=off; -delete from mysql.user where User like 'mysqltest_%'; -delete from mysql.db where User like 'mysqltest_%'; -flush privileges; -drop database if exists mysqltest_db1; -create user mysqltest_user1@localhost; -create database mysqltest_db1; -grant event on events_test.* to mysqltest_user1@localhost; -connect conn2,localhost,mysqltest_user1,,events_test; -create event mysqltest_user1 on schedule every 10 second do select 42; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -alter event mysqltest_user1 rename to mysqltest_db1.mysqltest_user1; -ERROR 42000: Access denied for user 'mysqltest_user1'@'localhost' to database 'mysqltest_db1' -"Let's test now rename when there is no select DB" -disconnect conn2; -connect conn2,localhost,mysqltest_user1,,*NO-ONE*; -select database(); -database() -NULL -alter event events_test.mysqltest_user1 rename to mysqltest_user1; -ERROR 3D000: No database selected -select event_schema, event_name, definer, event_type, status from information_schema.events; -event_schema event_name definer event_type status -events_test mysqltest_user1 mysqltest_user1@localhost RECURRING ENABLED -drop event events_test.mysqltest_user1; -disconnect conn2; -connection default; -drop user mysqltest_user1@localhost; -drop database mysqltest_db1; -create event e_53 on schedule at (select s1 from ttx) do drop table t; -ERROR 42000: CREATE/ALTER EVENT does not support subqueries or stored functions -create event e_53 on schedule every (select s1 from ttx) second do drop table t; -ERROR 42000: CREATE/ALTER EVENT does not support subqueries or stored functions -create event e_53 on schedule every 5 second starts (select s1 from ttx) do drop table t; -ERROR 42000: CREATE/ALTER EVENT does not support subqueries or stored functions -create event e_53 on schedule every 5 second ends (select s1 from ttx) do drop table t; -ERROR 42000: CREATE/ALTER EVENT does not support subqueries or stored functions -drop event if exists e_16; -drop procedure if exists p_16; -create event e_16 on schedule every 1 second do set @a=5; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -create procedure p_16 () alter event e_16 on schedule every @a second; -set @a = null; -call p_16(); -ERROR HY000: Incorrect INTERVAL value: 'NULL' -call p_16(); -ERROR HY000: Incorrect INTERVAL value: 'NULL' -set @a= 6; -call p_16(); -drop procedure p_16; -drop event e_16; -drop function if exists f22830; -drop event if exists e22830; -drop event if exists e22830_1; -drop event if exists e22830_2; -drop event if exists e22830_3; -drop event if exists e22830_4; -drop table if exists t1; -drop table if exists t2; -create table t1 (a int); -insert into t1 values (2); -create table t2 (a char(20)); -insert into t2 values ("e22830_1"); -create function f22830 () returns int return 5; -select get_lock('ee_22830', 60); -get_lock('ee_22830', 60) -1 -set global event_scheduler=on; -create procedure p22830_wait() -begin -select get_lock('ee_22830', 60); -select release_lock('ee_22830'); -end| -create event e22830 on schedule every f22830() second do -begin -call p22830_wait(); -select 123; -end| -ERROR 42000: CREATE/ALTER EVENT does not support subqueries or stored functions -create event e22830_1 on schedule every 1 hour do -begin -call p22830_wait(); -alter event e22830_1 on schedule every (select 8 from dual) hour; -end| -create event e22830_2 on schedule every 1 hour do -begin -call p22830_wait(); -alter event e22830_2 on schedule every (select 8 from t1) hour; -end| -create event e22830_3 on schedule every 1 hour do -begin -call p22830_wait(); -alter event e22830_3 on schedule every f22830() hour; -end| -create event e22830_4 on schedule every 1 hour do -begin -call p22830_wait(); -alter event e22830_4 on schedule every (select f22830() from dual) hour; -end| -"All events should be blocked in get_lock()" -select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name; -event_name event_definition interval_value interval_field -e22830_1 begin -call p22830_wait(); -alter event e22830_1 on schedule every (select 8 from dual) hour; -end 1 HOUR -e22830_2 begin -call p22830_wait(); -alter event e22830_2 on schedule every (select 8 from t1) hour; -end 1 HOUR -e22830_3 begin -call p22830_wait(); -alter event e22830_3 on schedule every f22830() hour; -end 1 HOUR -e22830_4 begin -call p22830_wait(); -alter event e22830_4 on schedule every (select f22830() from dual) hour; -end 1 HOUR -select release_lock('ee_22830'); -release_lock('ee_22830') -1 -set global event_scheduler=off; -select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name; -event_name event_definition interval_value interval_field -e22830_1 begin -call p22830_wait(); -alter event e22830_1 on schedule every (select 8 from dual) hour; -end 8 HOUR -e22830_2 begin -call p22830_wait(); -alter event e22830_2 on schedule every (select 8 from t1) hour; -end 1 HOUR -e22830_3 begin -call p22830_wait(); -alter event e22830_3 on schedule every f22830() hour; -end 1 HOUR -e22830_4 begin -call p22830_wait(); -alter event e22830_4 on schedule every (select f22830() from dual) hour; -end 1 HOUR -drop procedure p22830_wait; -drop function f22830; -drop event (select a from t2); -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(select a from t2)' at line 1 -drop event e22830_1; -drop event e22830_2; -drop event e22830_3; -drop event e22830_4; -drop table t1; -drop table t2; -DROP USER mysqltest_u1@localhost; -CREATE USER mysqltest_u1@localhost; -GRANT EVENT ON events_test.* TO mysqltest_u1@localhost; -CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -event_name definer -e1 root@localhost -DROP EVENT e1; -CREATE DEFINER=CURRENT_USER EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -event_name definer -e1 root@localhost -ALTER DEFINER=mysqltest_u1@localhost EVENT e1 ON SCHEDULE EVERY 1 HOUR; -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -event_name definer -e1 mysqltest_u1@localhost -DROP EVENT e1; -CREATE DEFINER=CURRENT_USER() EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -event_name definer -e1 root@localhost -DROP EVENT e1; -CREATE DEFINER=mysqltest_u1@localhost EVENT e1 ON SCHEDULE EVERY 1 DAY DO -SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -event_name definer -e1 mysqltest_u1@localhost -DROP EVENT e1; -connect conn1, localhost, mysqltest_u1, , events_test; -CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -event_name definer -e1 mysqltest_u1@localhost -DROP EVENT e1; -CREATE DEFINER=CURRENT_USER EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -event_name definer -e1 mysqltest_u1@localhost -ALTER DEFINER=root@localhost EVENT e1 ON SCHEDULE EVERY 1 HOUR; -ERROR 42000: Access denied; you need (at least one of) the SET USER privilege(s) for this operation -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -event_name definer -e1 mysqltest_u1@localhost -DROP EVENT e1; -CREATE DEFINER=CURRENT_USER() EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -event_name definer -e1 mysqltest_u1@localhost -DROP EVENT e1; -CREATE DEFINER=root@localhost EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -ERROR 42000: Access denied; you need (at least one of) the SET USER privilege(s) for this operation -DROP EVENT e1; -ERROR HY000: Unknown event 'e1' -disconnect conn1; -connection default; -DROP USER mysqltest_u1@localhost; -SET GLOBAL EVENT_SCHEDULER= OFF; -SET @save_time_zone= @@TIME_ZONE; -SET TIME_ZONE= '+00:00'; -SET TIMESTAMP= UNIX_TIMESTAMP('2005-12-31 23:58:59'); -CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test e1 root@localhost +00:00 RECURRING NULL 1 DAY 2005-12-31 23:58:59 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -SET TIME_ZONE= '-01:00'; -ALTER EVENT e1 ON SCHEDULE EVERY 1 DAY STARTS '2000-01-01 00:00:00'; -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test e1 root@localhost -01:00 RECURRING NULL 1 DAY 2000-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -SET TIME_ZONE= '+02:00'; -ALTER EVENT e1 ON SCHEDULE AT '2000-01-02 00:00:00' - ON COMPLETION PRESERVE DISABLE; -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test e1 root@localhost +02:00 ONE TIME 2000-01-02 00:00:00 NULL NULL NULL NULL DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -SET TIME_ZONE= '-03:00'; -ALTER EVENT e1 ON SCHEDULE EVERY 1 DAY ENDS '2030-01-03 00:00:00' - ON COMPLETION PRESERVE DISABLE; -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test e1 root@localhost -03:00 RECURRING NULL 1 DAY 2005-12-31 20:58:59 2030-01-03 00:00:00 DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -SET TIME_ZONE= '+04:00'; -ALTER EVENT e1 DO SELECT 2; -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test e1 root@localhost -03:00 RECURRING NULL 1 DAY 2005-12-31 20:58:59 2030-01-03 00:00:00 DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -DROP EVENT e1; -SET TIME_ZONE='+05:00'; -CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO -SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SET TIMESTAMP= @@TIMESTAMP + 1; -SET TIME_ZONE='-05:00'; -CREATE EVENT e2 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO -SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SET TIMESTAMP= @@TIMESTAMP + 1; -SET TIME_ZONE='+00:00'; -CREATE EVENT e3 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO -SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SELECT * FROM INFORMATION_SCHEMA.EVENTS ORDER BY event_name; -EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER TIME_ZONE EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD SQL_MODE STARTS ENDS STATUS ON_COMPLETION CREATED LAST_ALTERED LAST_EXECUTED EVENT_COMMENT ORIGINATOR CHARACTER_SET_CLIENT COLLATION_CONNECTION DATABASE_COLLATION -def events_test e1 root@localhost +05:00 SQL SELECT 1 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED NOT PRESERVE 2005-12-31 23:58:59 2005-12-31 23:58:59 NULL 1 latin1 latin1_swedish_ci latin1_swedish_ci -def events_test e2 root@localhost -05:00 SQL SELECT 1 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED NOT PRESERVE 2005-12-31 23:59:00 2005-12-31 23:59:00 NULL 1 latin1 latin1_swedish_ci latin1_swedish_ci -def events_test e3 root@localhost +00:00 SQL SELECT 1 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED NOT PRESERVE 2005-12-31 23:59:01 2005-12-31 23:59:01 NULL 1 latin1 latin1_swedish_ci latin1_swedish_ci -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test e1 root@localhost +05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test e2 root@localhost -05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test e3 root@localhost +00:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -SHOW CREATE EVENT e1; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -e1 +05:00 CREATE DEFINER=`root`@`localhost` EVENT `e1` ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci -SHOW CREATE EVENT e2; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -e2 -05:00 CREATE DEFINER=`root`@`localhost` EVENT `e2` ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci -SHOW CREATE EVENT e3; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -e3 +00:00 CREATE DEFINER=`root`@`localhost` EVENT `e3` ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' ON COMPLETION NOT PRESERVE ENABLE DO SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci -The following should fail, and nothing should be altered. -ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00'; -ERROR HY000: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was not changed. Specify a time in the future -ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00' DISABLE; -ERROR HY000: Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was not changed. Specify a time in the future -The following should give warnings, and nothing should be created. -CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00' -DO -SELECT 1; -Warnings: -Note 1588 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation -CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00' DISABLE -DO -SELECT 1; -Warnings: -Note 1588 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation -CREATE EVENT e4 ON SCHEDULE AT '1999-01-01 00:00:00' DO -SELECT 1; -Warnings: -Note 1588 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation -CREATE EVENT e4 ON SCHEDULE AT '1999-01-01 00:00:00' DISABLE -DO -SELECT 1; -Warnings: -Note 1588 Event execution time is in the past and ON COMPLETION NOT PRESERVE is set. The event was dropped immediately after creation -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test e1 root@localhost +05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test e2 root@localhost -05:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test e3 root@localhost +00:00 RECURRING NULL 1 DAY 2006-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -The following should succeed giving a warning. -ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE; -Warnings: -Note 1544 Event execution time is in the past. Event has been disabled -CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE -DO -SELECT 1; -Warnings: -Note 1544 Event execution time is in the past. Event has been disabled -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -CREATE EVENT e5 ON SCHEDULE AT '1999-01-01 00:00:00' - ON COMPLETION PRESERVE -DO -SELECT 1; -Warnings: -Note 1544 Event execution time is in the past. Event has been disabled -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -The following should succeed without warnings. -ALTER EVENT e2 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'; -ALTER EVENT e3 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE DISABLE; -CREATE EVENT e6 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' DO -SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -CREATE EVENT e7 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE DISABLE -DO -SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -CREATE EVENT e8 ON SCHEDULE AT '1999-01-01 00:00:00' - ON COMPLETION PRESERVE DISABLE -DO -SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test e1 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 1999-01-02 00:00:00 DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test e2 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test e3 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 1999-01-02 00:00:00 DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test e4 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 1999-01-02 00:00:00 DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test e5 root@localhost +00:00 ONE TIME 1999-01-01 00:00:00 NULL NULL NULL NULL DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test e6 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test e7 root@localhost +00:00 RECURRING NULL 1 HOUR 1999-01-01 00:00:00 1999-01-02 00:00:00 DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test e8 root@localhost +00:00 ONE TIME 1999-01-01 00:00:00 NULL NULL NULL NULL DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -DROP EVENT e8; -DROP EVENT e7; -DROP EVENT e6; -DROP EVENT e5; -DROP EVENT e4; -DROP EVENT e3; -DROP EVENT e2; -DROP EVENT e1; -SET TIME_ZONE=@save_time_zone; -SET TIMESTAMP=DEFAULT; -drop event if exists new_event; -CREATE EVENT new_event ON SCHEDULE EVERY 0 SECOND DO SELECT 1; -ERROR HY000: INTERVAL is either not positive or too big -CREATE EVENT new_event ON SCHEDULE EVERY (SELECT 0) SECOND DO SELECT 1; -ERROR HY000: INTERVAL is either not positive or too big -CREATE EVENT new_event ON SCHEDULE EVERY "abcdef" SECOND DO SELECT 1; -ERROR HY000: INTERVAL is either not positive or too big -CREATE EVENT new_event ON SCHEDULE EVERY "0abcdef" SECOND DO SELECT 1; -ERROR HY000: INTERVAL is either not positive or too big -CREATE EVENT new_event ON SCHEDULE EVERY "a1bcdef" SECOND DO SELECT 1; -ERROR HY000: INTERVAL is either not positive or too big -CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "abcdef" UNION SELECT "abcdef") SECOND DO SELECT 1; -ERROR HY000: INTERVAL is either not positive or too big -CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "0abcdef") SECOND DO SELECT 1; -ERROR HY000: INTERVAL is either not positive or too big -CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "a1bcdef") SECOND DO SELECT 1; -ERROR HY000: INTERVAL is either not positive or too big -CREATE EVENT new_event ON SCHEDULE AT "every day" DO SELECT 1; -ERROR HY000: Incorrect AT value: 'every day' -CREATE EVENT new_event ON SCHEDULE AT "0every day" DO SELECT 1; -ERROR HY000: Incorrect AT value: '0every day' -CREATE EVENT new_event ON SCHEDULE AT (SELECT "every day") DO SELECT 1; -ERROR HY000: Incorrect AT value: 'every day' -CREATE EVENT new_event ON SCHEDULE AT NOW() STARTS NOW() DO SELECT 1; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'STARTS NOW() DO SELECT 1' at line 1 -CREATE EVENT new_event ON SCHEDULE AT NOW() ENDS NOW() DO SELECT 1; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ENDS NOW() DO SELECT 1' at line 1 -CREATE EVENT new_event ON SCHEDULE AT NOW() STARTS NOW() ENDS NOW() DO SELECT 1; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'STARTS NOW() ENDS NOW() DO SELECT 1' at line 1 -USE test; -SHOW GRANTS FOR CURRENT_USER; -Grants for root@localhost -GRANT ALL PRIVILEGES ON *.* TO `root`@`localhost` WITH GRANT OPTION -GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION -SET GLOBAL event_scheduler = ON; -CREATE TABLE events_test.event_log -(id int KEY AUTO_INCREMENT, ev_nm char(40), ev_cnt int, ev_tm timestamp) -ENGINE=MyISAM; -SET autocommit=0; -CREATE USER evtest1@localhost; -SET PASSWORD FOR evtest1@localhost = password('ev1'); -REVOKE ALL PRIVILEGES, GRANT OPTION FROM evtest1@localhost; -GRANT create, insert, select, event ON events_test.* TO evtest1@localhost; -GRANT select,insert ON test.* TO evtest1@localhost; -SHOW GRANTS FOR evtest1@localhost; -Grants for evtest1@localhost -GRANT USAGE ON *.* TO `evtest1`@`localhost` IDENTIFIED BY PASSWORD '*3170F3644E31580C25DE4A08F4C07CC9A2D40C32' -GRANT SELECT, INSERT ON `test`.* TO `evtest1`@`localhost` -GRANT SELECT, INSERT, CREATE, EVENT ON `events_test`.* TO `evtest1`@`localhost` -connect e1,localhost,evtest1,ev1,events_test,$MASTER_MYPORT,$MASTER_MYSOCK; -CREATE EVENT ev_sched_1823 ON SCHEDULE EVERY 2 SECOND -DO BEGIN -SET AUTOCOMMIT = 0; -SET @evname = 'ev_sched_1823'; -SET @cnt = 0; -SELECT COUNT(*) INTO @cnt FROM events_test.event_log WHERE ev_nm = @evname; -IF @cnt < 6 THEN -INSERT INTO events_test.event_log VALUES (NULL,@evname,@cnt+1,current_timestamp()); -COMMIT; -END IF; -SELECT COUNT(*) INTO @cnt FROM events_test.event_log WHERE ev_nm = @evname; -IF @cnt < 6 THEN -INSERT INTO events_test.event_log VALUES (NULL,@evname,@cnt+1,current_timestamp()); -ROLLBACK; -END IF; -END;| -Sleep till the first INSERT into events_test.event_log occurred -SELECT COUNT(*) > 0 AS "Expect 1" FROM events_test.event_log; -Expect 1 -1 -connection default; -DROP USER evtest1@localhost; -Sleep 4 seconds -SELECT COUNT(*) INTO @row_cnt FROM events_test.event_log; -Sleep 4 seconds -SELECT COUNT(*) > @row_cnt AS "Expect 0" FROM events_test.event_log; -Expect 0 -0 -disconnect e1; -DROP EVENT events_test.ev_sched_1823; -DROP TABLE events_test.event_log; -SET GLOBAL event_scheduler = OFF; -SET GLOBAL event_scheduler= ON; -CREATE EVENT bug28641 ON SCHEDULE AT '2038.01.18 03:00:00' -DO BEGIN -SELECT 1; -END;| -SET GLOBAL event_scheduler= OFF; -DROP EVENT bug28641; - -##################################################################### -# -# BUG#31111: --read-only crashes MySQL (events fail to load). -# -##################################################################### - -DROP USER mysqltest_u1@localhost; -DROP EVENT IF EXISTS e1; -DROP EVENT IF EXISTS e2; - -GRANT EVENT ON *.* TO mysqltest_u1@localhost; - -SET GLOBAL READ_ONLY = 1; - -connect u1_con,localhost,mysqltest_u1,,events_test; - -CREATE EVENT e1 ON SCHEDULE AT '2038-01-01 00:00:00' DO SET @a = 1; -ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement - -ALTER EVENT e1 COMMENT 'comment'; -ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement - -DROP EVENT e1; -ERROR HY000: The MariaDB server is running with the --read-only option so it cannot execute this statement - -connect root_con,localhost,root,,events_test; - -CREATE EVENT e1 ON SCHEDULE AT '2038-01-01 00:00:00' DO SET @a = 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. - -ALTER EVENT e1 COMMENT 'comment'; - -DROP EVENT e1; - -SET GLOBAL READ_ONLY = 0; - -connection u1_con; - -CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND DO SET @a = 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -CREATE EVENT e2 ON SCHEDULE EVERY 1 SECOND DO SET @a = 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. - -SELECT -event_name, -last_executed IS NULL, -definer -FROM INFORMATION_SCHEMA.EVENTS -WHERE event_schema = 'events_test'; -event_name last_executed IS NULL definer -e1 1 mysqltest_u1@localhost -e2 1 mysqltest_u1@localhost - -connection root_con; - -SET GLOBAL READ_ONLY = 1; - -SET GLOBAL EVENT_SCHEDULER = ON; - -# Waiting for the event scheduler to execute and drop event e1... - -# Waiting for the event scheduler to execute and update event e2... - -SET GLOBAL EVENT_SCHEDULER = OFF; - -SELECT -event_name, -last_executed IS NULL, -definer -FROM INFORMATION_SCHEMA.EVENTS -WHERE event_schema = 'events_test'; -event_name last_executed IS NULL definer -e2 0 mysqltest_u1@localhost - -DROP EVENT e1; -ERROR HY000: Unknown event 'e1' - -# Cleanup. - -DROP EVENT e2; - -SET GLOBAL READ_ONLY = 0; - -disconnect u1_con; -disconnect root_con; -connection default; - -DROP USER mysqltest_u1@localhost; - -##################################################################### -# -# End of BUG#31111. -# -##################################################################### - -drop procedure if exists p; -set @old_mode= @@sql_mode; -set @@sql_mode= cast(pow(2,32)-1 as unsigned integer); -create event e1 on schedule every 1 day do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -select @@sql_mode into @full_mode; -set @@sql_mode= @old_mode; -select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mode; -select name from mysql.event where name = 'e1' and sql_mode = @full_mode; -name -e1 -drop event e1; -SET @old_server_id = @@GLOBAL.server_id; -SET GLOBAL server_id = (1 << 32) - 1; -SELECT @@GLOBAL.server_id; -@@GLOBAL.server_id -4294967295 -CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SELECT event_name, originator FROM INFORMATION_SCHEMA.EVENTS; -event_name originator -ev1 4294967295 -DROP EVENT ev1; -SET GLOBAL server_id = @old_server_id; -CREATE DATABASE event_test12; -USE event_test12; -CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -CREATE DATABASE event_test1; -USE event_test1; -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -DROP DATABASE event_test1; -DROP DATABASE event_test12; -# -# Bug#12546938 (formerly known as bug#61005): -# CREATE IF NOT EXIST EVENT WILL CREATE MULTIPLE RUNNING EVENTS -# -USE events_test; -SET GLOBAL event_scheduler = ON; -DROP TABLE IF EXISTS table_bug12546938; -DROP EVENT IF EXISTS event_Bug12546938; -CREATE TABLE table_bug12546938 (i INT); -# Create an event which will be executed with a small delay -# and won't be automatically dropped after that. -CREATE EVENT event_Bug12546938 -ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND ON COMPLETION PRESERVE -ENABLE DO -BEGIN -INSERT INTO table_bug12546938 VALUES(1); -END -| -# Now try to create the same event using CREATE EVENT IF NOT EXISTS. -# A warning should be emitted. A new event should not be created nor -# the old event should be re-executed. -CREATE EVENT IF NOT EXISTS event_bug12546938 -ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND ON COMPLETION PRESERVE -ENABLE DO -BEGIN -INSERT INTO table_bug12546938 VALUES (1); -END -| -Warnings: -Note 1537 Event 'event_bug12546938' already exists -# Wait until at least one instance of event is executed. -# Check that only one instance of our event was executed. -SELECT COUNT(*) FROM table_bug12546938; -COUNT(*) -1 -# Clean-up. -DROP EVENT IF EXISTS event_Bug12546938; -DROP TABLE table_bug12546938; -SET GLOBAL EVENT_SCHEDULER = OFF; -DROP DATABASE IF EXISTS event_test11764334; -CREATE DATABASE event_test11764334; -USE event_test11764334; -CREATE EVENT ev1 ON SCHEDULE EVERY 3 SECOND DISABLE DO SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW EVENTS IN event_test11764334 WHERE NAME='ev1'; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -event_test11764334 ev1 root@localhost SYSTEM RECURRING NULL 3 SECOND # # DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -ALTER EVENT ev1 ON SCHEDULE EVERY 4 SECOND; -SHOW EVENTS IN event_test11764334 WHERE NAME='ev1'; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -event_test11764334 ev1 root@localhost SYSTEM RECURRING NULL 4 SECOND # # DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -DROP EVENT ev1; -DROP DATABASE event_test11764334; -USE test; -DROP DATABASE events_test; -SET GLOBAL event_scheduler= 'ON'; -SET @@global.concurrent_insert= @concurrent_insert; diff --git a/mysql-test/main/events_bugs.test b/mysql-test/main/events_bugs.test deleted file mode 100644 index fe744de86c9..00000000000 --- a/mysql-test/main/events_bugs.test +++ /dev/null @@ -1,1306 +0,0 @@ -# Tests will be skipped for the view protocol because the view protocol creates -# an additional util connection and other statistics data --- source include/no_view_protocol.inc - -#### t/events_bugs.test -# -# Last change: -# 2009-01-08 mleich -# - Fix for -# Bug#41111 events_bugs fails sporadically on pushbuild -# - Avoid effects of -# Bug#41925 Warning 1366 Incorrect string value: ... for column processlist.info -# -# Please set $ -SET SQL_MODE=""; -let $fixed_bug41925= 0; -# -# Dear maintainer of this test. Please do NOT remove the next big comment. -# The tests for events were quite unstable over a significant time because the -# effects of events in general and their representation within the processlist -# were partially not known. Therefore I had to make excessive experiments. -# The comment with the outcome of these experiments will be moved into a README -# file as soon as the tests for events get their own testsuite. -# -# Outcome of some experiments (mleich, mysql-5.1 2008-12): -# -------------------------------------------------------- -# 0. Most time used setup: -# High parallel I/O load -# set global event_scheduler= off; -# sleep 3; -# use events_test; -# create event e_16407 on schedule every 2 second do -# begin -# select 'FIRST COMMAND', sleep(0.5); -# select 'SECOND COMMAND'; -# end| -# set global event_scheduler= on; -# Start observation of the processlist -# -# -# 1. SET GLOBAL event_scheduler = 'ON' and immediate observation of the processlist. -# 1.1 Effects around event scheduler: -# 1.1.1 First phase (very short) -# No user 'event_scheduler' within information_schema.processlist. -# 1.1.2 Second phase observed (independend of probably existing events and very short) was -# USER HOST DB COMMAND TIME STATE INFO -# event_scheduler localhost NULL Daemon 0 Initialized NULL -# 1.1.3 Third phase observed: -# 1.1.3.1 Case we do not have existing events (rather long) -# USER HOST DB COMMAND TIME STATE INFO -# event_scheduler localhost NULL Daemon 0 Waiting on empty queue NULL -# 1.1.3.2 Case there exists already an event -# 1.1.3.2.1 Event executor is not visible in processlist but comes up soon -# USER HOST DB COMMAND TIME STATE INFO -# event_scheduler localhost NULL Daemon 0 NULL -# or -# event_scheduler localhost NULL Daemon 0 NULL NULL -# 1.1.3.2.2 A bit later, at least one event executor is or was visible in processlist -# The states mentioned in 3.2.1 or a bit later -# USER HOST DB COMMAND TIME STATE INFO -# event_scheduler localhost NULL Daemon 0 Waiting for next activation NULL -# 1.2 Effects around event executor: -# Typical processlist content: -# USER evtest1 -- Definer of event -# DB events_test -- DB during time of event creation (use DB is not allowed in events) -# COMMAND Connect -# STATE NULL -# INFO SET @evname = 'ev_sched_1823' -- Part of the event code -# -# State before "User sleep select 'FIRST COMMAND', sleep(0.5);" -# ID USER HOST DB COMMAND TIME STATE INFO -# 7 event_scheduler localhost NULL Connect 0 NULL NULL -# !! The user is not the event creator and the DB is different. !! -# !! This means that we must get later a change of the identity. !! -# or -# USER HOST DB COMMAND TIME STATE INFO -# root localhost events_test Connect 0 checking permissions -# or -# USER HOST DB COMMAND TIME STATE INFO -# root localhost events_test Connect 0 checking permissions CREATE PROCEDURE .... -# or -# USER HOST DB COMMAND TIME STATE INFO -# root localhost events_test Connect 0 NULL select 'FIRST COMMAND', sleep(0.5) -# or -# USER HOST DB COMMAND TIME STATE INFO -# root localhost events_test Connect 0 checking permissions select 'FIRST COMMAND'... -# or -# USER HOST DB COMMAND TIME STATE INFO -# root localhost events_test Connect 0 Opening table select 'FIRST COMMAND', sleep(0.5) -# or -# USER HOST DB COMMAND TIME STATE INFO -# root localhost events_test Connect 0 Locked select 'FIRST COMMAND', sleep(0.5) -# or -# USER HOST DB COMMAND TIME STATE INFO -# root localhost events_test Connect 0 executing select 'FIRST COMMAND', sleep(0.5) -# -# State "User sleep select 'FIRST COMMAND', sleep(0.5);" reached -# USER HOST DB COMMAND TIME STATE INFO -# root localhost events_test Connect 0 User sleep select 'FIRST COMMAND', sleep(0.5) -# -# State at end (! It looks like a slow CREATE PROC !) of event code execution was sometimes -# USER HOST DB COMMAND TIME STATE INFO -# root localhost events_test Connect 0 logging slow query CREATE PROCEDURE `e_16407`... -# -# State after running some event code was sometimes -# USER HOST DB COMMAND TIME STATE INFO -# root localhost events_test Connect 0 logging slow query select 'SECOND COMMAND' -# -# State somewhere (I guess just before the event executor disappears) -# USER HOST DB COMMAND TIME STATE INFO -# Event thread fin <empty> events_test Connect 0 Clearing NULL -# -# -# 2. SET GLOBAL event_scheduler = 'OFF'; -# Immediate observation of the processlist. -# Effects: -# 1. I never found the user 'event_scheduler' within the processlist. -# 2. Events just during execution could be found within the processlist -# = It does not look like "SET GLOBAL event_scheduler = 'OFF'" stops them. -# ==> Everything mentioned in 1.2 above could be observed. -# -# Several subtests were weak because they showed random result set differences after issuing -# "SET GLOBAL EVENT_SCHEDULER= off;". -# 1. Reason one: There were already event executors -# Fix: Wait till there is no event executor active ==> no session WHERE -# - command IN ('Connect') -# There must be no parallel session being just in "Connect" phase! -# or -# - user = <who created the maybe current running events> -# There must be no parallel session of this person. -# or user = 'event_scheduler' with command = 'Connect' -# The session which will soon change its identity to event creator. -# -# 2. Reason two: If an event modifies a MyISAM table than a delayed visibilty of changes -# might occur (concurrent_inserts=on or delayed inserts ...). -# - -# Can't test with embedded server that doesn't support grants --- source include/not_embedded.inc - ---disable_warnings -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 -# delayed) caused by concurrent_insert on (default). -set @concurrent_insert= @@global.concurrent_insert; -set @@global.concurrent_insert = 0; - -# -# START: Bug #31332 --event-scheduler option misbehaving -# - -# NOTE!! this test must come first! It's testing that the --event-scheduler -# option with no argument in events_bugs-master.opt turns the scheduler on. - -select * from information_schema.global_variables where variable_name like 'event_scheduler'; -# Check that the event_scheduler is really running ---source include/running_event_scheduler.inc - -SET GLOBAL event_scheduler = 'OFF'; ---source include/check_events_off.inc - -# -# END: Bug #31332 -# - -# -# START - 16415: Events: event names are case sensitive -# -CREATE EVENT lower_case ON SCHEDULE EVERY 1 MINUTE DO SELECT 1; ---error ER_EVENT_ALREADY_EXISTS -CREATE EVENT Lower_case ON SCHEDULE EVERY 2 MINUTE DO SELECT 2; -DROP EVENT Lower_case; -SET NAMES cp1251; -CREATE EVENT äîëåí_ðåãèñòúð_1251 ON SCHEDULE EVERY 1 YEAR DO SELECT 100; ---error ER_EVENT_ALREADY_EXISTS -CREATE EVENT ÄîËåÍ_ðåãèñòúð_1251 ON SCHEDULE EVERY 2 YEAR DO SELECT 200; -DROP EVENT ÄîËåÍ_ðåãèñòúð_1251; -SET NAMES utf8; -CREATE EVENT долен_региÑтър_утф8 ON SCHEDULE EVERY 3 YEAR DO SELECT 300; ---error ER_EVENT_ALREADY_EXISTS -CREATE EVENT ДОЛЕÐ_региÑтър_утф8 ON SCHEDULE EVERY 4 YEAR DO SELECT 400; -DROP EVENT ДОЛЕÐ_региÑтър_утф8; -SET NAMES latin1; -# -# END - 16415: Events: event names are case sensitive -# - -# -# START - BUG#16408: Events: crash for an event in a procedure -# -set @a=3; ---error ER_EVENT_RECURSION_FORBIDDEN -CREATE PROCEDURE p_16 () CREATE EVENT e_16 ON SCHEDULE EVERY @a SECOND DO SET @a=5; -# -# END - BUG#16408: Events: crash for an event in a procedure -# - -# -# Start - 16396: Events: Distant-future dates become past dates -# ---error ER_WRONG_VALUE -create event e_55 on schedule at 99990101000000 do drop table t; ---error ER_WRONG_VALUE -create event e_55 on schedule every 10 hour starts 99990101000000 do drop table t; ---error ER_EVENT_ENDS_BEFORE_STARTS -create event e_55 on schedule every 10 minute ends 99990101000000 do drop table t; ---error ER_WRONG_VALUE -create event e_55 on schedule at 10000101000000 do drop table t; - -# For the purpose of backup we allow times in the past. Here, no -# error will be given, but the event won't be created. One may think -# of that as if the event was created, then it turned out it's in the -# past, so it was dropped because of implicit ON COMPLETION NOT -# PRESERVE. -create event e_55 on schedule at 20000101000000 do drop table t; -show events; - ---error ER_PARSE_ERROR -create event e_55 on schedule at 20200101000000 starts 10000101000000 do drop table t; ---error ER_PARSE_ERROR -create event e_55 on schedule at 20200101000000 ends 10000101000000 do drop table t; ---error ER_PARSE_ERROR -create event e_55 on schedule at 20200101000000 starts 10000101000000 ends 10000101000000 do drop table t; ---error ER_WRONG_VALUE -create event e_55 on schedule every 10 hour starts 10000101000000 do drop table t; - -# -# End - 16396: Events: Distant-future dates become past dates -# - -# -# Start - 16407: Events: Changes in sql_mode won't be taken into account -# -set global event_scheduler=off; ---source include/check_events_off.inc -delete from mysql.event; -set global event_scheduler= on; ---source include/running_event_scheduler.inc -set @old_sql_mode:=@@sql_mode; -set sql_mode=ansi; -select get_lock('test_bug16407', 60); -delimiter |; -create event e_16407 on schedule every 60 second do -begin - select get_lock('test_bug16407', 60); -end| -delimiter ;| - -# The default session has the user lock. -# We wait till one event runs and hangs when trying to get the user lock. -let $wait_condition= - select count(*) > 0 from information_schema.processlist - where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)'; ---source include/wait_condition.inc - ---echo "Now if everything is fine the event has compiled and is locked" -# Expect to see one session in events_test waiting for the user lock. -select /*1*/ user, host, db, info from information_schema.processlist -where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)'; -select release_lock('test_bug16407'); -# Try to avoid -# Bug#39863 events_bugs fails sporadically on pushbuild (extra processes in I_S.PROCESSLIST) -# which is most probably caused by -# Bug#32782 User lock hash fails to find lock -# "various issues related to missing or incorrect return results -# from release_lock()." -# Therefore we check here if the event executor is no more locked or -# we waited >= 5 seconds for this to happen. -let $wait_timeout= 5; -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where state = 'User lock' and info = 'select get_lock(\'test_bug16407\', 60)'; ---source include/wait_condition.inc -if (!`$wait_condition`) -{ - --echo ERROR: There must be no session with - --echo state = 'User lock' and info = 'select get_lock('test_bug16407', 60) - --echo within the processlist. - --echo We probably hit Bug#32782 User lock hash fails to find lock - SELECT * FROM information_schema.processlist; - --echo Abort - exit; -} - -set global event_scheduler= off; -# Wait till the event scheduler and all event executors have finished their work. ---source include/check_events_off.inc - -select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; ---echo "Let's check whether we change the sql_mode on ALTER EVENT" -set sql_mode='traditional'; -alter event e_16407 do select 1; -select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; -drop event e_16407; - -set sql_mode="ansi"; -select get_lock('ee_16407_2', 60); - -set global event_scheduler= 1; ---source include/running_event_scheduler.inc ---echo "Another sql_mode test" -set sql_mode="traditional"; -create table events_smode_test(ev_name char(10), a date); ---echo "This should never insert something" -delimiter |; -create event ee_16407_2 on schedule every 60 second do -begin - select get_lock('ee_16407_2', 60); /*ee_16407_2*/ - select release_lock('ee_16407_2'); - insert into events_test.events_smode_test values('ee_16407_2','1980-19-02'); -end| ---error ER_TRUNCATED_WRONG_VALUE -insert into events_test.events_smode_test values ('test','1980-19-02')| ---echo "This is ok" -create event ee_16407_3 on schedule every 60 second do -begin - select get_lock('ee_16407_2', 60); /*ee_16407_3*/ - select release_lock('ee_16407_2'); - insert into events_test.events_smode_test values ('ee_16407_3','1980-02-19'); - insert into events_test.events_smode_test values ('ee_16407_3','1980-02-29'); -end| -set sql_mode=""| ---echo "This will insert rows but they will be truncated" -create event ee_16407_4 on schedule every 60 second do -begin - select get_lock('ee_16407_2', 60); /*ee_16407_4*/ - select release_lock('ee_16407_2'); - insert into events_test.events_smode_test values ('ee_16407_4','10-11-1956'); -end| -delimiter ;| -select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; - -# We wait till we have three event executors waiting for the removal of the lock. -let $wait_condition= - select count(*) = 3 from information_schema.processlist - where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; ---source include/wait_condition.inc - -# There is an extreme low risk that an additional event execution is just coming -# up because -# - the events have to be started every 60 seconds. -# - we are just after event creation + waiting for seeing 3 locked -# We expect to see three event executors in state 'User lock'. -select /*2*/ user, host, db, info from information_schema.processlist -where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; - -select release_lock('ee_16407_2'); - -# Try to avoid -# Bug#39863 events_bugs fails sporadically on pushbuild (extra processes in I_S.PROCESSLIST) -# which is most probably caused by -# Bug#32782 User lock hash fails to find lock -# "various issues related to missing or incorrect return results -# from release_lock()." -# Therefore we check here if the event executing sessions disappeared or -# we waited >= 5 seconds for this to happen. -let $wait_timeout= 5; -let $wait_condition= - select count(*) = 0 - from information_schema.processlist - where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; ---source include/wait_condition.inc -if (!`$wait_condition`) -{ - --echo ERROR: There must be no session with - --echo state = 'User lock' and info = 'select get_lock('test_bug16407_2', 60) - --echo within the processlist. - --echo We probably hit Bug#32782 User lock hash fails to find lock - SELECT * FROM information_schema.processlist; - --echo Abort - exit; -} - -# We expect to see no event executors in state 'User lock'. -if(!$fixed_bug41925) -{ - --disable_warnings -} -select /*3*/ user, host, db, info from information_schema.processlist -where state = 'User lock' and info = 'select get_lock(\'ee_16407_2\', 60)'; -if(!$fixed_bug41925) -{ - --enable_warnings -} - -set global event_scheduler= off; -# Wait till the event scheduler and all event executors have finished their work. -# Without this the next queries will give unstable results. ---source include/check_events_off.inc - -select * from events_test.events_smode_test order by ev_name, a; ---echo "OK, last check before we drop them" -select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; -drop event ee_16407_2; -drop event ee_16407_3; -drop event ee_16407_4; - - ---echo "And now one last test regarding sql_mode and call of SP from an event" -delete from events_test.events_smode_test; -set sql_mode='ansi'; -select get_lock('ee_16407_5', 60); - -set global event_scheduler= on; ---source include/running_event_scheduler.inc - -set sql_mode='traditional'; -delimiter |; -# ee_16407_5_pendant() should not insert anything because of invalid date. -create procedure ee_16407_5_pendant() begin insert into events_test.events_smode_test values('ee_16407_5','2001-02-29'); end| -create procedure ee_16407_6_pendant() begin insert into events_test.events_smode_test values('ee_16407_6','2004-02-29'); end| -create event ee_16407_5 on schedule every 60 second do -begin - select get_lock('ee_16407_5', 60); /*ee_16407_5*/ - select release_lock('ee_16407_5'); - call events_test.ee_16407_5_pendant(); -end| -create event ee_16407_6 on schedule every 60 second do -begin - select get_lock('ee_16407_5', 60); /*ee_16407_6*/ - select release_lock('ee_16407_5'); - call events_test.ee_16407_6_pendant(); -end| -delimiter ;| - -let $wait_condition= - select count(*) = 2 from information_schema.processlist - where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; ---source include/wait_condition.inc - ---echo "Should have 2 locked processes" -select /*4*/ user, host, db, info from information_schema.processlist -where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; - -select release_lock('ee_16407_5'); - -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; ---source include/wait_condition.inc - ---echo "Should have 0 processes locked" -if(!$fixed_bug41925) -{ - --disable_warnings -} -select /*5*/ user, host, db, info from information_schema.processlist -where state = 'User lock' and info = 'select get_lock(\'ee_16407_5\', 60)'; -if(!$fixed_bug41925) -{ - --enable_warnings -} - -# Wait till all event executors have finished their work, so that we can be sure -# that their changes to events_smode_test are done. ---source include/no_running_events.inc - -select * from events_test.events_smode_test order by ev_name, a; ---echo "And here we check one more time before we drop the events" -select event_schema, event_name, sql_mode from information_schema.events order by event_schema, event_name; - -drop event ee_16407_5; -drop event ee_16407_6; -drop procedure ee_16407_5_pendant; -drop procedure ee_16407_6_pendant; -set global event_scheduler= off; ---source include/check_events_off.inc -drop table events_smode_test; -set sql_mode=@old_sql_mode; -# -# End - 16407: Events: Changes in sql_mode won't be taken into account -# - -# -# START - 18897: Events: unauthorized action possible with alter event rename -# -set global event_scheduler=off; ---source include/check_events_off.inc ---disable_warnings -delete from mysql.user where User like 'mysqltest_%'; -delete from mysql.db where User like 'mysqltest_%'; -flush privileges; -drop database if exists mysqltest_db1; ---enable_warnings -create user mysqltest_user1@localhost; -create database mysqltest_db1; -grant event on events_test.* to mysqltest_user1@localhost; -connect (conn2,localhost,mysqltest_user1,,events_test); -create event mysqltest_user1 on schedule every 10 second do select 42; ---error ER_DBACCESS_DENIED_ERROR -alter event mysqltest_user1 rename to mysqltest_db1.mysqltest_user1; ---echo "Let's test now rename when there is no select DB" -disconnect conn2; -connect (conn2,localhost,mysqltest_user1,,*NO-ONE*); -select database(); ---error ER_NO_DB_ERROR -alter event events_test.mysqltest_user1 rename to mysqltest_user1; -select event_schema, event_name, definer, event_type, status from information_schema.events; -drop event events_test.mysqltest_user1; -disconnect conn2; -connection default; -drop user mysqltest_user1@localhost; -drop database mysqltest_db1; -# -# END - 18897: Events: unauthorized action possible with alter event rename -# - -# -# START - BUG#16394: Events: Crash if schedule contains SELECT -# ---error ER_SUBQUERIES_NOT_SUPPORTED -create event e_53 on schedule at (select s1 from ttx) do drop table t; ---error ER_SUBQUERIES_NOT_SUPPORTED -create event e_53 on schedule every (select s1 from ttx) second do drop table t; ---error ER_SUBQUERIES_NOT_SUPPORTED -create event e_53 on schedule every 5 second starts (select s1 from ttx) do drop table t; ---error ER_SUBQUERIES_NOT_SUPPORTED -create event e_53 on schedule every 5 second ends (select s1 from ttx) do drop table t; -# -# END - BUG#16394: Events: Crash if schedule contains SELECT -# - -# -# START - BUG#22397: Events: crash with procedure which alters events -# ---disable_warnings -drop event if exists e_16; -drop procedure if exists p_16; ---enable_warnings -create event e_16 on schedule every 1 second do set @a=5; -create procedure p_16 () alter event e_16 on schedule every @a second; -set @a = null; ---error ER_WRONG_VALUE -call p_16(); ---error ER_WRONG_VALUE -call p_16(); -set @a= 6; -call p_16(); - -drop procedure p_16; -drop event e_16; - -# -# START - BUG#22830 Events: crash with procedure which alters events with function -# ---disable_warnings -drop function if exists f22830; -drop event if exists e22830; -drop event if exists e22830_1; -drop event if exists e22830_2; -drop event if exists e22830_3; -drop event if exists e22830_4; -drop table if exists t1; -drop table if exists t2; ---enable_warnings -create table t1 (a int); -insert into t1 values (2); -create table t2 (a char(20)); -insert into t2 values ("e22830_1"); -create function f22830 () returns int return 5; - -select get_lock('ee_22830', 60); -set global event_scheduler=on; ---source include/running_event_scheduler.inc - -delimiter |; -create procedure p22830_wait() -begin - select get_lock('ee_22830', 60); - select release_lock('ee_22830'); -end| - ---error ER_SUBQUERIES_NOT_SUPPORTED -create event e22830 on schedule every f22830() second do -begin - call p22830_wait(); - select 123; -end| -create event e22830_1 on schedule every 1 hour do -begin - call p22830_wait(); - alter event e22830_1 on schedule every (select 8 from dual) hour; -end| -create event e22830_2 on schedule every 1 hour do -begin - call p22830_wait(); - alter event e22830_2 on schedule every (select 8 from t1) hour; -end| -create event e22830_3 on schedule every 1 hour do -begin - call p22830_wait(); - alter event e22830_3 on schedule every f22830() hour; -end| -create event e22830_4 on schedule every 1 hour do -begin - call p22830_wait(); - alter event e22830_4 on schedule every (select f22830() from dual) hour; -end| -delimiter ;| - ---echo "All events should be blocked in get_lock()" -select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name; - -select release_lock('ee_22830'); - -let $wait_condition= - select group_concat(interval_value order by interval_value) = '1,1,1,8' - from information_schema.events; ---source include/wait_condition.inc - -set global event_scheduler=off; ---source include/check_events_off.inc -select event_name, event_definition, interval_value, interval_field from information_schema.events order by event_name; -drop procedure p22830_wait; -drop function f22830; ---error ER_PARSE_ERROR -drop event (select a from t2); -drop event e22830_1; -drop event e22830_2; -drop event e22830_3; -drop event e22830_4; -drop table t1; -drop table t2; - - -# -# BUG#16425: Events: no DEFINER clause -# ---error 0,ER_CANNOT_USER -DROP USER mysqltest_u1@localhost; - -CREATE USER mysqltest_u1@localhost; -GRANT EVENT ON events_test.* TO mysqltest_u1@localhost; - -CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -DROP EVENT e1; - -CREATE DEFINER=CURRENT_USER EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -ALTER DEFINER=mysqltest_u1@localhost EVENT e1 ON SCHEDULE EVERY 1 HOUR; -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -DROP EVENT e1; - -CREATE DEFINER=CURRENT_USER() EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -DROP EVENT e1; - -CREATE DEFINER=mysqltest_u1@localhost EVENT e1 ON SCHEDULE EVERY 1 DAY DO - SELECT 1; -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -DROP EVENT e1; - -connect (conn1, localhost, mysqltest_u1, , events_test); - -CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -DROP EVENT e1; - -CREATE DEFINER=CURRENT_USER EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; ---error ER_SPECIFIC_ACCESS_DENIED_ERROR -ALTER DEFINER=root@localhost EVENT e1 ON SCHEDULE EVERY 1 HOUR; -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -DROP EVENT e1; - -CREATE DEFINER=CURRENT_USER() EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -SELECT event_name, definer FROM INFORMATION_SCHEMA.EVENTS; -DROP EVENT e1; - ---error ER_SPECIFIC_ACCESS_DENIED_ERROR -CREATE DEFINER=root@localhost EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; ---error ER_EVENT_DOES_NOT_EXIST -DROP EVENT e1; - -disconnect conn1; -connection default; - -DROP USER mysqltest_u1@localhost; - - -# -# BUG#16420: Events: timestamps become UTC -# BUG#26429: SHOW CREATE EVENT is incorrect for an event that -# STARTS NOW() -# BUG#26431: Impossible to re-create an event from backup if its -# STARTS clause is in the past -# WL#3698: Events: execution in local time zone -# -# Here we only check non-concurrent aspects of the patch. -# For the actual tests of time zones please see events_time_zone.test -# -SET GLOBAL EVENT_SCHEDULER= OFF; ---source include/check_events_off.inc -SET @save_time_zone= @@TIME_ZONE; - -#---------------------------------------------------------------------- - -# We will use a separate connection because SET TIMESTAMP will stop -# the clock in that connection. - -SET TIME_ZONE= '+00:00'; -SET TIMESTAMP= UNIX_TIMESTAMP('2005-12-31 23:58:59'); - - -# Test when event time zone is updated on ALTER EVENT. -# - -CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -SHOW EVENTS; - -# Test storing and updating of the event time zone. -# -SET TIME_ZONE= '-01:00'; -ALTER EVENT e1 ON SCHEDULE EVERY 1 DAY STARTS '2000-01-01 00:00:00'; -SHOW EVENTS; - -# This will update event time zone. -SET TIME_ZONE= '+02:00'; -ALTER EVENT e1 ON SCHEDULE AT '2000-01-02 00:00:00' - ON COMPLETION PRESERVE DISABLE; -SHOW EVENTS; - -# This will update event time zone. -SET TIME_ZONE= '-03:00'; -ALTER EVENT e1 ON SCHEDULE EVERY 1 DAY ENDS '2030-01-03 00:00:00' - ON COMPLETION PRESERVE DISABLE; -SHOW EVENTS; - -# This will not update event time zone, as no time is being adjusted. -SET TIME_ZONE= '+04:00'; -ALTER EVENT e1 DO SELECT 2; -SHOW EVENTS; - -DROP EVENT e1; - -#---------------------------------------------------------------------- - -# Create some events. -SET TIME_ZONE='+05:00'; -CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO - SELECT 1; - -SET TIMESTAMP= @@TIMESTAMP + 1; - -SET TIME_ZONE='-05:00'; -CREATE EVENT e2 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO - SELECT 1; - -SET TIMESTAMP= @@TIMESTAMP + 1; - -SET TIME_ZONE='+00:00'; -CREATE EVENT e3 ON SCHEDULE EVERY 1 DAY STARTS '2006-01-01 00:00:00' DO - SELECT 1; - - -# Test INFORMATION_SCHEMA.EVENTS. -# - -SELECT * FROM INFORMATION_SCHEMA.EVENTS ORDER BY event_name; - - -# Test SHOW EVENTS. -# - -SHOW EVENTS; - - -# Test SHOW CREATE EVENT. -# - -SHOW CREATE EVENT e1; -SHOW CREATE EVENT e2; -SHOW CREATE EVENT e3; - -#---------------------------------------------------------------------- - -# Test times in the past. -# - ---echo The following should fail, and nothing should be altered. - ---error ER_EVENT_CANNOT_ALTER_IN_THE_PAST -ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00'; - ---error ER_EVENT_CANNOT_ALTER_IN_THE_PAST -ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00' DISABLE; - ---echo The following should give warnings, and nothing should be created. - -CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00' -DO - SELECT 1; - -CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00' DISABLE -DO - SELECT 1; - -CREATE EVENT e4 ON SCHEDULE AT '1999-01-01 00:00:00' DO - SELECT 1; - -CREATE EVENT e4 ON SCHEDULE AT '1999-01-01 00:00:00' DISABLE -DO - SELECT 1; - -SHOW EVENTS; - ---echo The following should succeed giving a warning. - -ALTER EVENT e1 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE; - -CREATE EVENT e4 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE -DO - SELECT 1; - -CREATE EVENT e5 ON SCHEDULE AT '1999-01-01 00:00:00' - ON COMPLETION PRESERVE -DO - SELECT 1; - ---echo The following should succeed without warnings. - -ALTER EVENT e2 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00'; - -ALTER EVENT e3 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE DISABLE; - -CREATE EVENT e6 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' DO - SELECT 1; - -CREATE EVENT e7 ON SCHEDULE EVERY 1 HOUR STARTS '1999-01-01 00:00:00' - ENDS '1999-01-02 00:00:00' ON COMPLETION PRESERVE DISABLE -DO - SELECT 1; - -CREATE EVENT e8 ON SCHEDULE AT '1999-01-01 00:00:00' - ON COMPLETION PRESERVE DISABLE -DO - SELECT 1; - -SHOW EVENTS; - - -DROP EVENT e8; -DROP EVENT e7; -DROP EVENT e6; -DROP EVENT e5; -DROP EVENT e4; -DROP EVENT e3; -DROP EVENT e2; -DROP EVENT e1; - -SET TIME_ZONE=@save_time_zone; -SET TIMESTAMP=DEFAULT; - -# -# START - BUG#28666 CREATE EVENT ... EVERY 0 SECOND let server crash -# ---disable_warnings -drop event if exists new_event; ---enable_warnings ---error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG -CREATE EVENT new_event ON SCHEDULE EVERY 0 SECOND DO SELECT 1; ---error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG -CREATE EVENT new_event ON SCHEDULE EVERY (SELECT 0) SECOND DO SELECT 1; ---error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG -CREATE EVENT new_event ON SCHEDULE EVERY "abcdef" SECOND DO SELECT 1; ---error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG -CREATE EVENT new_event ON SCHEDULE EVERY "0abcdef" SECOND DO SELECT 1; ---error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG -CREATE EVENT new_event ON SCHEDULE EVERY "a1bcdef" SECOND DO SELECT 1; - ---error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG -CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "abcdef" UNION SELECT "abcdef") SECOND DO SELECT 1; ---error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG -CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "0abcdef") SECOND DO SELECT 1; ---error ER_EVENT_INTERVAL_NOT_POSITIVE_OR_TOO_BIG -CREATE EVENT new_event ON SCHEDULE EVERY (SELECT "a1bcdef") SECOND DO SELECT 1; - ---error ER_WRONG_VALUE -CREATE EVENT new_event ON SCHEDULE AT "every day" DO SELECT 1; ---error ER_WRONG_VALUE -CREATE EVENT new_event ON SCHEDULE AT "0every day" DO SELECT 1; ---error ER_WRONG_VALUE -CREATE EVENT new_event ON SCHEDULE AT (SELECT "every day") DO SELECT 1; - ---error ER_PARSE_ERROR -CREATE EVENT new_event ON SCHEDULE AT NOW() STARTS NOW() DO SELECT 1; ---error ER_PARSE_ERROR -CREATE EVENT new_event ON SCHEDULE AT NOW() ENDS NOW() DO SELECT 1; ---error ER_PARSE_ERROR -CREATE EVENT new_event ON SCHEDULE AT NOW() STARTS NOW() ENDS NOW() DO SELECT 1; - -# -# START - BUG#28924 If I drop the user who is the definer of an active event -# then server cores -# -let $engine=MyISAM; -USE test; -SHOW GRANTS FOR CURRENT_USER; -SET GLOBAL event_scheduler = ON; ---source include/running_event_scheduler.inc -eval -CREATE TABLE events_test.event_log -(id int KEY AUTO_INCREMENT, ev_nm char(40), ev_cnt int, ev_tm timestamp) -ENGINE=$engine; -SET autocommit=0; -CREATE USER evtest1@localhost; -SET PASSWORD FOR evtest1@localhost = password('ev1'); -REVOKE ALL PRIVILEGES, GRANT OPTION FROM evtest1@localhost; -GRANT create, insert, select, event ON events_test.* TO evtest1@localhost; -GRANT select,insert ON test.* TO evtest1@localhost; -SHOW GRANTS FOR evtest1@localhost; - ---replace_result $MASTER_MYPORT MASTER_MYPORT $MASTER_MYSOCK MASTER_MYSOCK -connect (e1,localhost,evtest1,ev1,events_test,$MASTER_MYPORT,$MASTER_MYSOCK); -DELIMITER |; -CREATE EVENT ev_sched_1823 ON SCHEDULE EVERY 2 SECOND -DO BEGIN - SET AUTOCOMMIT = 0; - SET @evname = 'ev_sched_1823'; - SET @cnt = 0; - SELECT COUNT(*) INTO @cnt FROM events_test.event_log WHERE ev_nm = @evname; - IF @cnt < 6 THEN - INSERT INTO events_test.event_log VALUES (NULL,@evname,@cnt+1,current_timestamp()); - COMMIT; - END IF; - SELECT COUNT(*) INTO @cnt FROM events_test.event_log WHERE ev_nm = @evname; - IF @cnt < 6 THEN - INSERT INTO events_test.event_log VALUES (NULL,@evname,@cnt+1,current_timestamp()); - ROLLBACK; - END IF; -END;| -DELIMITER ;| -# 1. Show that the new created event is runnable and gets executed within a -# reasonable time like 4 seconds. Till ~ 2 seconds could pass on a heavy -# loaded testing box before something gets executed). -# Detection of execution is via the records inserted by the event. ---echo Sleep till the first INSERT into events_test.event_log occurred -let $wait_timeout= 4; -let $wait_condition= -SELECT COUNT(*) > 0 FROM events_test.event_log; ---source include/wait_condition.inc -SELECT COUNT(*) > 0 AS "Expect 1" FROM events_test.event_log; -# -connection default; -DROP USER evtest1@localhost; -# 2. If we meet BUG#28924 again than a server crash happens within the next -# few seconds -# 3. Check that the event is never executed again -# It could be that an event execution was running before the DROP USER -# and all implicite actions belonging to this are completed. -# Lets assume that ~ 4 seconds waiting are enough for the event -# scheduler to detect that ---echo Sleep 4 seconds -sleep 4; -SELECT COUNT(*) INTO @row_cnt FROM events_test.event_log; -# Give the event mechanism ~ 4 seconds to do something wrong -# (execute the event of the dropped user -> inser rows). ---echo Sleep 4 seconds -sleep 4; -SELECT COUNT(*) > @row_cnt AS "Expect 0" FROM events_test.event_log; -# -# Cleanup -disconnect e1; -DROP EVENT events_test.ev_sched_1823; -DROP TABLE events_test.event_log; -SET GLOBAL event_scheduler = OFF; ---source include/check_events_off.inc - - -# -# Bug#28641 CREATE EVENT with '2038.01.18 03:00:00' let server crash. -# -SET GLOBAL event_scheduler= ON; ---source include/running_event_scheduler.inc -DELIMITER |; -CREATE EVENT bug28641 ON SCHEDULE AT '2038.01.18 03:00:00' -DO BEGIN - SELECT 1; -END;| - -DELIMITER ;| -SET GLOBAL event_scheduler= OFF; ---source include/check_events_off.inc -DROP EVENT bug28641; - -########################################################################### - ---echo ---echo ##################################################################### ---echo # ---echo # BUG#31111: --read-only crashes MySQL (events fail to load). ---echo # ---echo ##################################################################### ---echo - ---error 0,ER_CANNOT_USER -DROP USER mysqltest_u1@localhost; - ---disable_warnings -DROP EVENT IF EXISTS e1; -DROP EVENT IF EXISTS e2; ---enable_warnings - ---echo - -# Check that an ordinary user can not create/update/drop events in the -# read-only mode. - -GRANT EVENT ON *.* TO mysqltest_u1@localhost; - ---echo - -SET GLOBAL READ_ONLY = 1; - ---echo - ---connect(u1_con,localhost,mysqltest_u1,,events_test) - ---echo - ---error ER_OPTION_PREVENTS_STATEMENT -CREATE EVENT e1 ON SCHEDULE AT '2038-01-01 00:00:00' DO SET @a = 1; - ---echo - ---error ER_OPTION_PREVENTS_STATEMENT -ALTER EVENT e1 COMMENT 'comment'; - ---echo - ---error ER_OPTION_PREVENTS_STATEMENT -DROP EVENT e1; - ---echo - -# Check that the super user still can create/update/drop events. - ---connect(root_con,localhost,root,,events_test) - ---echo - -CREATE EVENT e1 ON SCHEDULE AT '2038-01-01 00:00:00' DO SET @a = 1; - ---echo - -ALTER EVENT e1 COMMENT 'comment'; - ---echo - -DROP EVENT e1; - ---echo - -# -# Switch to read-write mode; create test events under the user mysqltest_u1; -# switch back to read-only mode. -# - -SET GLOBAL READ_ONLY = 0; - ---echo - ---connection u1_con - ---echo - -CREATE EVENT e1 ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND DO SET @a = 1; -CREATE EVENT e2 ON SCHEDULE EVERY 1 SECOND DO SET @a = 1; - ---echo - -SELECT - event_name, - last_executed IS NULL, - definer -FROM INFORMATION_SCHEMA.EVENTS -WHERE event_schema = 'events_test'; - ---echo - ---connection root_con - ---echo - -SET GLOBAL READ_ONLY = 1; - -# Check that the event scheduler is able to update event. - ---echo - -SET GLOBAL EVENT_SCHEDULER = ON; ---source include/running_event_scheduler.inc - ---echo - ---echo # Waiting for the event scheduler to execute and drop event e1... - -let $wait_timeout = 4; -let $wait_condition = - SELECT COUNT(*) = 0 - FROM INFORMATION_SCHEMA.EVENTS - WHERE event_schema = 'events_test' AND event_name = 'e1'; ---source include/wait_condition.inc - ---echo - ---echo # Waiting for the event scheduler to execute and update event e2... - -let $wait_condition = - SELECT last_executed IS NOT NULL - FROM INFORMATION_SCHEMA.EVENTS - WHERE event_schema = 'events_test' AND event_name = 'e2'; ---source include/wait_condition.inc - ---echo - -SET GLOBAL EVENT_SCHEDULER = OFF; ---source include/check_events_off.inc - ---echo - -SELECT - event_name, - last_executed IS NULL, - definer -FROM INFORMATION_SCHEMA.EVENTS -WHERE event_schema = 'events_test'; - ---echo - ---error ER_EVENT_DOES_NOT_EXIST -DROP EVENT e1; - ---echo ---echo # Cleanup. ---echo - -DROP EVENT e2; - ---echo - -SET GLOBAL READ_ONLY = 0; - ---echo - ---disconnect u1_con ---disconnect root_con ---connection default - ---echo - -DROP USER mysqltest_u1@localhost; - ---echo ---echo ##################################################################### ---echo # ---echo # End of BUG#31111. ---echo # ---echo ##################################################################### ---echo - -# -# Bug#32633 Can not create any routine if SQL_MODE=no_engine_substitution -# -# Ensure that when new SQL modes are introduced, they are also added to -# the mysql.event table. -# - ---disable_warnings -drop procedure if exists p; ---enable_warnings -set @old_mode= @@sql_mode; -set @@sql_mode= cast(pow(2,32)-1 as unsigned integer); -create event e1 on schedule every 1 day do select 1; -select @@sql_mode into @full_mode; -set @@sql_mode= @old_mode; -select replace(@full_mode, 'ALLOW_INVALID_DATES', 'INVALID_DATES') into @full_mode; -select name from mysql.event where name = 'e1' and sql_mode = @full_mode; -drop event e1; - -# -# Bug#36540: CREATE EVENT and ALTER EVENT statements fail with large server_id -# - -SET @old_server_id = @@GLOBAL.server_id; -SET GLOBAL server_id = (1 << 32) - 1; -SELECT @@GLOBAL.server_id; -CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -SELECT event_name, originator FROM INFORMATION_SCHEMA.EVENTS; -DROP EVENT ev1; -SET GLOBAL server_id = @old_server_id; - -# -# Bug#11751148: show events shows events in other schema -# - -CREATE DATABASE event_test12; -USE event_test12; -CREATE EVENT ev1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -CREATE DATABASE event_test1; -USE event_test1; -# Following show events should not show ev1 -SHOW EVENTS; -DROP DATABASE event_test1; -DROP DATABASE event_test12; - ---echo # ---echo # Bug#12546938 (formerly known as bug#61005): ---echo # CREATE IF NOT EXIST EVENT WILL CREATE MULTIPLE RUNNING EVENTS ---echo # -USE events_test; -SET GLOBAL event_scheduler = ON; - ---disable_warnings -DROP TABLE IF EXISTS table_bug12546938; -DROP EVENT IF EXISTS event_Bug12546938; ---enable_warnings -CREATE TABLE table_bug12546938 (i INT); - -delimiter |; - ---echo # Create an event which will be executed with a small delay ---echo # and won't be automatically dropped after that. -CREATE EVENT event_Bug12546938 -ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND ON COMPLETION PRESERVE -ENABLE DO -BEGIN - INSERT INTO table_bug12546938 VALUES(1); -END -| - ---echo # Now try to create the same event using CREATE EVENT IF NOT EXISTS. ---echo # A warning should be emitted. A new event should not be created nor ---echo # the old event should be re-executed. -CREATE EVENT IF NOT EXISTS event_bug12546938 -ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 1 SECOND ON COMPLETION PRESERVE -ENABLE DO -BEGIN - INSERT INTO table_bug12546938 VALUES (1); -END -| - -delimiter ;| - ---echo # Wait until at least one instance of event is executed. -let $wait_condition= SELECT COUNT(*) FROM table_bug12546938; ---source include/wait_condition.inc - ---echo # Check that only one instance of our event was executed. -SELECT COUNT(*) FROM table_bug12546938; - ---echo # Clean-up. -DROP EVENT IF EXISTS event_Bug12546938; -DROP TABLE table_bug12546938; -SET GLOBAL EVENT_SCHEDULER = OFF; - -# -# Bug#11764334 - 57156: ALTER EVENT CHANGES THE EVENT STATUS -# ---disable_warnings -DROP DATABASE IF EXISTS event_test11764334; ---enable_warnings -CREATE DATABASE event_test11764334; -USE event_test11764334; -CREATE EVENT ev1 ON SCHEDULE EVERY 3 SECOND DISABLE DO SELECT 1; ---replace_column 9 # 10 # -SHOW EVENTS IN event_test11764334 WHERE NAME='ev1'; -ALTER EVENT ev1 ON SCHEDULE EVERY 4 SECOND; ---replace_column 9 # 10 # -SHOW EVENTS IN event_test11764334 WHERE NAME='ev1'; -DROP EVENT ev1; -DROP DATABASE event_test11764334; -USE test; -########################################################################### -# -# End of tests -# -# !!! KEEP this section AT THE END of this file !!! -# -########################################################################### - -# Ensure that all event executors have finished their work and cannot harm -# the next test. ---source include/no_running_events.inc - -DROP DATABASE events_test; -# Restore the original state i.e to how it was when test started -# (option with no argument in events_bugs-master.opt turns the scheduler on). -SET GLOBAL event_scheduler= 'ON'; ---source include/running_event_scheduler.inc -SET @@global.concurrent_insert= @concurrent_insert; -# THIS MUST BE THE LAST LINE in this file. diff --git a/mysql-test/main/events_embedded.result b/mysql-test/main/events_embedded.result deleted file mode 100644 index 1a02188f2df..00000000000 --- a/mysql-test/main/events_embedded.result +++ /dev/null @@ -1,2 +0,0 @@ -set global event_scheduler=ON; -ERROR HY000: Unknown system variable 'event_scheduler' diff --git a/mysql-test/main/events_embedded.test b/mysql-test/main/events_embedded.test deleted file mode 100644 index c607573b2dc..00000000000 --- a/mysql-test/main/events_embedded.test +++ /dev/null @@ -1,4 +0,0 @@ ---source include/is_embedded.inc - ---error ER_UNKNOWN_SYSTEM_VARIABLE -set global event_scheduler=ON; diff --git a/mysql-test/main/events_grant.result b/mysql-test/main/events_grant.result deleted file mode 100644 index 5952097a8d2..00000000000 --- a/mysql-test/main/events_grant.result +++ /dev/null @@ -1,149 +0,0 @@ -CREATE DATABASE IF NOT EXISTS events_test; -use events_test; -CREATE EVENT one_event ON SCHEDULE EVERY 10 SECOND DO SELECT 123; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test one_event root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; -EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT -def events_test one_event root@localhost SQL SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE -CREATE DATABASE events_test2; -CREATE USER ev_test@localhost; -GRANT ALL ON events_test.* to ev_test@localhost; -GRANT ALL ON events_test2.* to ev_test@localhost; -GRANT ALL ON test.* TO ev_test@localhost; -REVOKE EVENT ON events_test2.* FROM ev_test@localhost; -connect ev_con1,localhost,ev_test,,events_test2; -select "NEW CONNECTION"; -NEW CONNECTION -NEW CONNECTION -SELECT USER(), DATABASE(); -USER() DATABASE() -ev_test@localhost events_test2 -SHOW GRANTS; -Grants for ev_test@localhost -GRANT USAGE ON *.* TO `ev_test`@`localhost` -GRANT ALL PRIVILEGES ON `test`.* TO `ev_test`@`localhost` -GRANT ALL PRIVILEGES ON `events_test`.* TO `ev_test`@`localhost` -GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE, TRIGGER, DELETE HISTORY ON `events_test2`.* TO `ev_test`@`localhost` -"Here comes an error:"; -SHOW EVENTS; -ERROR 42000: Access denied for user 'ev_test'@'localhost' to database 'events_test2' -USE events_test; -"We should see one event"; -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test one_event root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -SELECT CONCAT("Let's create some new events from the name of ", USER()); -CONCAT("Let's create some new events from the name of ", USER()) -Let's create some new events from the name of ev_test@localhost -CREATE EVENT one_event ON SCHEDULE EVERY 20 SECOND DO SELECT 123; -ERROR HY000: Event 'one_event' already exists -CREATE EVENT two_event ON SCHEDULE EVERY 20 SECOND ON COMPLETION NOT PRESERVE COMMENT "two event" DO SELECT 123; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -CREATE EVENT three_event ON SCHEDULE EVERY 20 SECOND ON COMPLETION PRESERVE COMMENT "three event" DO SELECT 123; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -"Now we should see 3 events:"; -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test one_event root@localhost SYSTEM RECURRING NULL 10 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test three_event ev_test@localhost SYSTEM RECURRING NULL 20 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test two_event ev_test@localhost SYSTEM RECURRING NULL 20 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -"This should show us only 2 events:"; -SHOW EVENTS LIKE 't%event'; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test three_event ev_test@localhost SYSTEM RECURRING NULL 20 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test two_event ev_test@localhost SYSTEM RECURRING NULL 20 # # NULL ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -"This should show us no events:"; -SHOW EVENTS FROM test LIKE '%'; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -connection default; -GRANT EVENT ON events_test2.* TO ev_test@localhost; -connection ev_con1; -USE events_test2; -CREATE EVENT four_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -connection default; -USE events_test; -"We should see 4 events : one_event, two_event, three_event & four_event" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; -EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT -def events_test one_event root@localhost SQL SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE -def events_test three_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED PRESERVE three event -def events_test two_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE two event -def events_test2 four_event ev_test@localhost SQL SELECT 42 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE -DROP DATABASE events_test2; -"We should see 3 events : one_event, two_event, three_event" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; -EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT -def events_test one_event root@localhost SQL SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE -def events_test three_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED PRESERVE three event -def events_test two_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE two event -connection default; -CREATE DATABASE events_test2; -USE events_test2; -CREATE EVENT five_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -connection ev_con1; -"Should see 4 events - one, two, three & five" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; -EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT -def events_test one_event root@localhost SQL SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE -def events_test three_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED PRESERVE three event -def events_test two_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE two event -def events_test2 five_event root@localhost SQL SELECT 42 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE -connection default; -REVOKE EVENT ON events_test2.* FROM ev_test@localhost; -connection ev_con1; -USE test; -"Should see 3 events - one, two & three" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; -EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT -def events_test one_event root@localhost SQL SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE -def events_test three_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED PRESERVE three event -def events_test two_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE two event -"Let's test ALTER EVENT which changes the definer" -USE events_test; -ALTER EVENT one_event ON SCHEDULE EVERY 10 SECOND; -"The definer should be ev_test@localhost" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event'; -EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT -def events_test one_event ev_test@localhost SQL SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE -connection default; -USE events_test; -ALTER EVENT one_event COMMENT "comment"; -connection ev_con1; -"The definer should be root@localhost" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event'; -EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT -def events_test one_event root@localhost SQL SELECT 123 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE comment -ALTER EVENT one_event DO SELECT 12; -"The definer should be ev_test@localhost" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event'; -EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT -def events_test one_event ev_test@localhost SQL SELECT 12 RECURRING NULL 10 SECOND ENABLED NOT PRESERVE comment -connection default; -"make the definer again root@localhost" -ALTER EVENT one_event COMMENT "new comment"; -connection ev_con1; -"test DROP by another user" -DROP EVENT one_event; -connection default; -"One event should not be there" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; -EVENT_CATALOG EVENT_SCHEMA EVENT_NAME DEFINER EVENT_BODY EVENT_DEFINITION EVENT_TYPE EXECUTE_AT INTERVAL_VALUE INTERVAL_FIELD STATUS ON_COMPLETION EVENT_COMMENT -def events_test three_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED PRESERVE three event -def events_test two_event ev_test@localhost SQL SELECT 123 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE two event -def events_test2 five_event root@localhost SQL SELECT 42 RECURRING NULL 20 SECOND ENABLED NOT PRESERVE -connection ev_con1; -disconnect ev_con1; -connection default; -DROP USER ev_test@localhost; -DROP DATABASE events_test2; -DROP DATABASE events_test; diff --git a/mysql-test/main/events_grant.test b/mysql-test/main/events_grant.test deleted file mode 100644 index 2fe39a6cf2d..00000000000 --- a/mysql-test/main/events_grant.test +++ /dev/null @@ -1,117 +0,0 @@ -# Can't test with embedded server that doesn't support grants --- source include/not_embedded.inc ---source include/default_charset.inc - ---disable_service_connection -CREATE DATABASE IF NOT EXISTS events_test; -use events_test; -# -# Events grants test begin -# -CREATE EVENT one_event ON SCHEDULE EVERY 10 SECOND DO SELECT 123; ---replace_column 8 # 9 # -SHOW EVENTS; -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; -CREATE DATABASE events_test2; -CREATE USER ev_test@localhost; -GRANT ALL ON events_test.* to ev_test@localhost; -GRANT ALL ON events_test2.* to ev_test@localhost; -GRANT ALL ON test.* TO ev_test@localhost; -REVOKE EVENT ON events_test2.* FROM ev_test@localhost; -#now we are on con1 -connect (ev_con1,localhost,ev_test,,events_test2); -select "NEW CONNECTION"; -SELECT USER(), DATABASE(); -SHOW GRANTS; ---echo "Here comes an error:"; -#NO EVENT_ACL on events_test2 ---error 1044 -SHOW EVENTS; -USE events_test; ---echo "We should see one event"; ---replace_column 8 # 9 # -SHOW EVENTS; -#now create an event with the same name but we are different user -SELECT CONCAT("Let's create some new events from the name of ", USER()); ---error ER_EVENT_ALREADY_EXISTS -CREATE EVENT one_event ON SCHEDULE EVERY 20 SECOND DO SELECT 123; -CREATE EVENT two_event ON SCHEDULE EVERY 20 SECOND ON COMPLETION NOT PRESERVE COMMENT "two event" DO SELECT 123; -CREATE EVENT three_event ON SCHEDULE EVERY 20 SECOND ON COMPLETION PRESERVE COMMENT "three event" DO SELECT 123; - ---echo "Now we should see 3 events:"; ---replace_column 8 # 9 # -SHOW EVENTS; - ---echo "This should show us only 2 events:"; ---replace_column 8 # 9 # -SHOW EVENTS LIKE 't%event'; - ---echo "This should show us no events:"; ---replace_column 8 # 9 # -SHOW EVENTS FROM test LIKE '%'; -#ok, we are back -connection default; -GRANT EVENT ON events_test2.* TO ev_test@localhost; -connection ev_con1; -USE events_test2; -CREATE EVENT four_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42; -connection default; -USE events_test; ---echo "We should see 4 events : one_event, two_event, three_event & four_event" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; -DROP DATABASE events_test2; ---echo "We should see 3 events : one_event, two_event, three_event" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; - -connection default; -CREATE DATABASE events_test2; -USE events_test2; -CREATE EVENT five_event ON SCHEDULE EVERY 20 SECOND DO SELECT 42; - -connection ev_con1; ---echo "Should see 4 events - one, two, three & five" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; -connection default; -REVOKE EVENT ON events_test2.* FROM ev_test@localhost; -connection ev_con1; -USE test; ---echo "Should see 3 events - one, two & three" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; ---echo "Let's test ALTER EVENT which changes the definer" -USE events_test; -ALTER EVENT one_event ON SCHEDULE EVERY 10 SECOND; ---echo "The definer should be ev_test@localhost" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event'; -connection default; -USE events_test; -ALTER EVENT one_event COMMENT "comment"; -connection ev_con1; ---echo "The definer should be root@localhost" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event'; -ALTER EVENT one_event DO SELECT 12; ---echo "The definer should be ev_test@localhost" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_NAME='one_event'; -connection default; ---echo "make the definer again root@localhost" -ALTER EVENT one_event COMMENT "new comment"; -connection ev_con1; ---echo "test DROP by another user" -DROP EVENT one_event; -connection default; ---echo "One event should not be there" -SELECT EVENT_CATALOG, EVENT_SCHEMA, EVENT_NAME, DEFINER, EVENT_BODY, EVENT_DEFINITION, EVENT_TYPE, EXECUTE_AT, INTERVAL_VALUE, INTERVAL_FIELD, STATUS,ON_COMPLETION, EVENT_COMMENT FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_SCHEMA, EVENT_NAME; -connection ev_con1; -disconnect ev_con1; ---source include/wait_until_disconnected.inc -connection default; -DROP USER ev_test@localhost; -DROP DATABASE events_test2; - -# -# End of tests -# - ---source include/check_events_off.inc - -DROP DATABASE events_test; ---enable_service_connection diff --git a/mysql-test/main/events_logs_tests-master.opt b/mysql-test/main/events_logs_tests-master.opt deleted file mode 100644 index 73d26b7260d..00000000000 --- a/mysql-test/main/events_logs_tests-master.opt +++ /dev/null @@ -1 +0,0 @@ ---slow-query-log --log-output=table --general-log --general-log-file="" --slow-query-log-file="" diff --git a/mysql-test/main/events_logs_tests.result b/mysql-test/main/events_logs_tests.result deleted file mode 100644 index d332767a9f1..00000000000 --- a/mysql-test/main/events_logs_tests.result +++ /dev/null @@ -1,74 +0,0 @@ -set @save_long_query_time=@@long_query_time; -drop database if exists events_test; -create database if not exists events_test; -use events_test; - -We use procedure here because its statements won't be -logged into the general log. If we had used normal select -that are logged in different ways depending on whether the -test suite is run in normal mode or with --ps-protocol - -create procedure select_general_log() -begin -select user_host, argument from mysql.general_log -where argument like '%events_logs_test%' AND -(command_type = 'Query' OR command_type = 'Execute'); -end| - -Check that general query log works, but sub-statements -of the stored procedure do not leave traces in it. - -truncate mysql.general_log; -select 'events_logs_tests' as outside_event; -outside_event -events_logs_tests -call select_general_log(); -user_host argument -USER_HOST select 'events_logs_tests' as outside_event - -Check that unlike sub-statements of stored procedures, -sub-statements of events are present in the general log. - -set global event_scheduler=on; -truncate mysql.general_log; -create event ev_log_general on schedule at now() on completion not preserve do select 'events_logs_test' as inside_event; -call select_general_log(); -user_host argument -USER_HOST create event ev_log_general on schedule at now() on completion not preserve do select 'events_logs_test' as inside_event -USER_HOST select 'events_logs_test' as inside_event - -Check slow query log - -Ensure that slow logging is on -show variables like 'slow_query_log'; -Variable_name Value -slow_query_log ON - -Demonstrate that session value has no effect - -set @@session.long_query_time=1; -set @@global.long_query_time=300; -truncate mysql.slow_log; -create event ev_log_general on schedule at now() on completion not preserve -do select 'events_logs_test' as inside_event, sleep(1.5); - -Nothing should be logged - -select user_host, db, sql_text from mysql.slow_log -where sql_text like 'select \'events_logs_test\'%'; -user_host db sql_text -set @@global.long_query_time=1; -truncate mysql.slow_log; -create event ev_log_general on schedule at now() on completion not preserve -do select 'events_logs_test' as inside_event, sleep(1.5); - -Event sub-statement should be logged. - -select user_host, db, sql_text from mysql.slow_log -where sql_text like 'select \'events_logs_test\'%'; -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=@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 deleted file mode 100644 index f7445352079..00000000000 --- a/mysql-test/main/events_logs_tests.test +++ /dev/null @@ -1,93 +0,0 @@ -# Can't test with embedded server that doesn't support grants --- source include/not_embedded.inc --- source include/no_view_protocol.inc - -set @save_long_query_time=@@long_query_time; ---disable_warnings -drop database if exists events_test; ---enable_warnings -create database if not exists events_test; -use events_test; ---echo ---echo We use procedure here because its statements won't be ---echo logged into the general log. If we had used normal select ---echo that are logged in different ways depending on whether the ---echo test suite is run in normal mode or with --ps-protocol ---echo -delimiter |; -create procedure select_general_log() -begin - select user_host, argument from mysql.general_log - where argument like '%events_logs_test%' AND - (command_type = 'Query' OR command_type = 'Execute'); -end| -delimiter ;| ---echo ---echo Check that general query log works, but sub-statements ---echo of the stored procedure do not leave traces in it. ---echo -truncate mysql.general_log; -# Logging format in ps protocol is slightly different ---disable_ps_protocol -select 'events_logs_tests' as outside_event; ---enable_ps_protocol ---replace_column 1 USER_HOST -call select_general_log(); ---echo ---echo Check that unlike sub-statements of stored procedures, ---echo sub-statements of events are present in the general log. ---echo -set global event_scheduler=on; -truncate mysql.general_log; -create event ev_log_general on schedule at now() on completion not preserve do select 'events_logs_test' as inside_event; ---let $wait_condition=select count(*)=0 from information_schema.events where event_name='ev_log_general' ---source include/wait_condition.inc ---replace_column 1 USER_HOST -call select_general_log(); - ---echo ---echo Check slow query log ---echo ---echo Ensure that slow logging is on -show variables like 'slow_query_log'; ---echo ---echo Demonstrate that session value has no effect ---echo -set @@session.long_query_time=1; -set @@global.long_query_time=300; -truncate mysql.slow_log; -create event ev_log_general on schedule at now() on completion not preserve - do select 'events_logs_test' as inside_event, sleep(1.5); ---let $wait_condition=select count(*)=0 from information_schema.events where event_name='ev_log_general' ---source include/wait_condition.inc ---echo ---echo Nothing should be logged ---echo ---replace_column 1 USER_HOST -select user_host, db, sql_text from mysql.slow_log - where sql_text like 'select \'events_logs_test\'%'; -set @@global.long_query_time=1; -truncate mysql.slow_log; -create event ev_log_general on schedule at now() on completion not preserve - do select 'events_logs_test' as inside_event, sleep(1.5); ---let $wait_condition=select count(*)=0 from information_schema.events where event_name='ev_log_general' ---source include/wait_condition.inc ---echo ---echo Event sub-statement should be logged. ---echo ---replace_column 1 USER_HOST -select user_host, db, sql_text from mysql.slow_log - where sql_text like 'select \'events_logs_test\'%'; - -drop database events_test; -set global event_scheduler=off; -set @@global.long_query_time=@save_long_query_time; -set @@session.long_query_time=@save_long_query_time; - -# -# Safety -# -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where db='events_test' and command = 'Connect' and user=current_user(); ---source include/wait_condition.inc diff --git a/mysql-test/main/events_microsec.result b/mysql-test/main/events_microsec.result deleted file mode 100644 index 2a9f3587706..00000000000 --- a/mysql-test/main/events_microsec.result +++ /dev/null @@ -1,13 +0,0 @@ -create database if not exists events_test; -use events_test; -CREATE EVENT micro_test ON SCHEDULE EVERY 100 MICROSECOND DO SELECT 1; -ERROR 42000: This version of MariaDB doesn't yet support 'MICROSECOND' -CREATE EVENT micro_test ON SCHEDULE EVERY 100 DAY_MICROSECOND DO SELECT 1; -ERROR 42000: This version of MariaDB doesn't yet support 'MICROSECOND' -CREATE EVENT micro_test ON SCHEDULE EVERY 100 HOUR_MICROSECOND DO SELECT 1; -ERROR 42000: This version of MariaDB doesn't yet support 'MICROSECOND' -CREATE EVENT micro_test ON SCHEDULE EVERY 100 MINUTE_MICROSECOND DO SELECT 1; -ERROR 42000: This version of MariaDB doesn't yet support 'MICROSECOND' -CREATE EVENT micro_test ON SCHEDULE EVERY 100 SECOND_MICROSECOND DO SELECT 1; -ERROR 42000: This version of MariaDB doesn't yet support 'MICROSECOND' -drop database events_test; diff --git a/mysql-test/main/events_microsec.test b/mysql-test/main/events_microsec.test deleted file mode 100644 index 3e9abf6ec56..00000000000 --- a/mysql-test/main/events_microsec.test +++ /dev/null @@ -1,21 +0,0 @@ -# Can't test with embedded server that doesn't support grants --- source include/not_embedded.inc - ---disable_warnings -create database if not exists events_test; ---enable_warnings - -use events_test; - ---error ER_NOT_SUPPORTED_YET -CREATE EVENT micro_test ON SCHEDULE EVERY 100 MICROSECOND DO SELECT 1; ---error ER_NOT_SUPPORTED_YET -CREATE EVENT micro_test ON SCHEDULE EVERY 100 DAY_MICROSECOND DO SELECT 1; ---error ER_NOT_SUPPORTED_YET -CREATE EVENT micro_test ON SCHEDULE EVERY 100 HOUR_MICROSECOND DO SELECT 1; ---error ER_NOT_SUPPORTED_YET -CREATE EVENT micro_test ON SCHEDULE EVERY 100 MINUTE_MICROSECOND DO SELECT 1; ---error ER_NOT_SUPPORTED_YET -CREATE EVENT micro_test ON SCHEDULE EVERY 100 SECOND_MICROSECOND DO SELECT 1; - -drop database events_test; diff --git a/mysql-test/main/events_restart-master.opt b/mysql-test/main/events_restart-master.opt deleted file mode 100644 index f93413a61e5..00000000000 --- a/mysql-test/main/events_restart-master.opt +++ /dev/null @@ -1 +0,0 @@ ---event-scheduler diff --git a/mysql-test/main/events_restart.result b/mysql-test/main/events_restart.result deleted file mode 100644 index 58401c7be80..00000000000 --- a/mysql-test/main/events_restart.result +++ /dev/null @@ -1,145 +0,0 @@ -call mtr.add_suppression("Column count of mysql.event is wrong. Expected .*, found .*\. The table is probably corrupted"); -set global event_scheduler=off; -drop database if exists events_test; -create database events_test; -use events_test; -create table execution_log(name char(10)); -create event abc1 on schedule every 1 second do -insert into execution_log value('abc1'); -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -create event abc2 on schedule every 1 second do -insert into execution_log value('abc2'); -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -create event abc3 on schedule every 1 second do -insert into execution_log value('abc3'); -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -create table event_like like mysql.event; -insert into event_like select * from mysql.event; -alter table mysql.event -change column body body longtext character set utf8 collate utf8_bin; -"Now we restart the server" -call mtr.add_suppression("Incorrect definition of table mysql.event:.*"); -# restart -use events_test; -select @@event_scheduler; -@@event_scheduler -OFF -show events; -ERROR HY000: Cannot proceed, because event scheduler is disabled -select event_name from information_schema.events; -ERROR HY000: Cannot proceed, because event scheduler is disabled -show create event intact_check; -ERROR HY000: Cannot proceed, because event scheduler is disabled -drop event no_such_event; -ERROR HY000: Cannot proceed, because event scheduler is disabled -create event intact_check_1 on schedule every 5 hour do select 5; -ERROR HY000: Cannot proceed, because event scheduler is disabled -alter event intact_check_1 on schedule every 8 hour do select 8; -ERROR HY000: Cannot proceed, because event scheduler is disabled -alter event intact_check_1 rename to intact_check_2; -ERROR HY000: Cannot proceed, because event scheduler is disabled -drop event intact_check_1; -ERROR HY000: Cannot proceed, because event scheduler is disabled -drop event intact_check_2; -ERROR HY000: Cannot proceed, because event scheduler is disabled -drop event intact_check; -ERROR HY000: Cannot proceed, because event scheduler is disabled -set global event_scheduler=on; -ERROR HY000: Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler. -set global event_scheduler=off; -ERROR HY000: Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler. -show variables like 'event_scheduler'; -Variable_name Value -event_scheduler OFF -Make sure that we still can create and drop databases, -and no warnings are produced. -drop database if exists mysqltest_database_not_exists; -Warnings: -Note 1008 Can't drop database 'mysqltest_database_not_exists'; database doesn't exist -create database mysqltest_db1; -drop database mysqltest_db1; -Warnings: -Error 1545 Failed to open mysql.event -Restore the original mysql.event table -drop table mysql.event; -rename table event_like to mysql.event; -check that we can now enable events without restart -set global event_scheduler=original; -Warnings: -Note 1408 Event Scheduler: Loaded 3 events -select @@global.event_scheduler; -@@global.event_scheduler -ON -set global event_scheduler=on; -select @@global.event_scheduler; -@@global.event_scheduler -ON -show events; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -events_test abc1 root@localhost SYSTEM RECURRING # 1 SECOND # # ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test abc2 root@localhost SYSTEM RECURRING # 1 SECOND # # ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -events_test abc3 root@localhost SYSTEM RECURRING # 1 SECOND # # ENABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -Now let's restart the server again -# restart -use events_test; -select @@event_scheduler; -@@event_scheduler -ON -drop table execution_log; -drop database events_test; -# -# Test for bug#11748899 -- EVENT SET TO DISABLED AND ON COMPLETION -# NOT PRESERVE IS DELETED AT SERVER -# -SELECT @@event_scheduler; -@@event_scheduler -ON -USE test; -DROP EVENT IF EXISTS e1; -CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND DISABLE DO SELECT 1; -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -test e1 root@localhost SYSTEM RECURRING # 1 SECOND # # DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -"Now we restart the server" -# restart -USE test; -SELECT @@event_scheduler; -@@event_scheduler -ON -SHOW EVENTS; -Db Name Definer Time zone Type Execute at Interval value Interval field Starts Ends Status Originator character_set_client collation_connection Database Collation -test e1 root@localhost SYSTEM RECURRING # 1 SECOND # # DISABLED 1 latin1 latin1_swedish_ci latin1_swedish_ci -DROP EVENT e1; -# end test for bug#11748899 -# -# Test for MDEV-21758 Events switched randomly to SLAVESIDE_DISABLED -# -create event ev on schedule every 1 minute do set @a= 1; -select name, originator, status from mysql.event; -name originator status -ev 1 ENABLED -# -# Restarting server with server_id=100 -# -# restart: --server-id=100 -select @@global.server_id; -@@global.server_id -100 -select name, originator, status from mysql.event; -name originator status -ev 1 ENABLED -set global server_id= 1; -# -# Restarting server with the original server_id=1 -# -# restart -select @@global.server_id; -@@global.server_id -1 -select name, originator, status from mysql.event; -name originator status -ev 1 ENABLED -drop event ev; diff --git a/mysql-test/main/events_restart.test b/mysql-test/main/events_restart.test deleted file mode 100644 index 6f7c01d81c2..00000000000 --- a/mysql-test/main/events_restart.test +++ /dev/null @@ -1,174 +0,0 @@ -# Can't test with embedded server that doesn't support grants --- source include/not_embedded.inc -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. -# - -# Switch off the scheduler for now. -set global event_scheduler=off; - ---disable_warnings -drop database if exists events_test; ---enable_warnings -create database events_test; -use events_test; -create table execution_log(name char(10)); - -create event abc1 on schedule every 1 second do - insert into execution_log value('abc1'); -create event abc2 on schedule every 1 second do - insert into execution_log value('abc2'); -create event abc3 on schedule every 1 second do - insert into execution_log value('abc3'); -# -# There are various conditions when a server would regard mysql.event -# table as damaged: -# - the table has more column than specified in the compiled in value, but -# the version of the server which created the table is the same -# - the column count in the table is less than the compiled in value -# - some column has an incompatible type specification (for what is an -# incompatible type specification please refer to the comments in the source -# -# Unfortunately, in order to test a condition, we need to restart the -# server. Therefore, here we test only one simple case: changing the data -# type of the 'body' field to blob. -# -# First, let's do a backup to not depend on actual definition of mysql.event -create table event_like like mysql.event; -insert into event_like select * from mysql.event; -# Now let's alter the table and restart the server -alter table mysql.event - change column body body longtext character set utf8 collate utf8_bin; ---echo "Now we restart the server" - -call mtr.add_suppression("Incorrect definition of table mysql.event:.*"); ---source include/restart_mysqld.inc - -use events_test; -# Event scheduler should be disabled: the system tables are damaged -select @@event_scheduler; -# Try various Event Scheduler operation and check the output. ---error ER_EVENTS_DB_ERROR -show events; ---error ER_EVENTS_DB_ERROR -select event_name from information_schema.events; ---error ER_EVENTS_DB_ERROR -show create event intact_check; ---error ER_EVENTS_DB_ERROR -drop event no_such_event; ---error ER_EVENTS_DB_ERROR -create event intact_check_1 on schedule every 5 hour do select 5; ---error ER_EVENTS_DB_ERROR -alter event intact_check_1 on schedule every 8 hour do select 8; ---error ER_EVENTS_DB_ERROR -alter event intact_check_1 rename to intact_check_2; ---error ER_EVENTS_DB_ERROR -drop event intact_check_1; ---error ER_EVENTS_DB_ERROR -drop event intact_check_2; ---error ER_EVENTS_DB_ERROR -drop event intact_check; ---error ER_STARTUP -set global event_scheduler=on; ---error ER_STARTUP -set global event_scheduler=off; -show variables like 'event_scheduler'; ---echo Make sure that we still can create and drop databases, ---echo and no warnings are produced. -drop database if exists mysqltest_database_not_exists; -create database mysqltest_db1; -drop database mysqltest_db1; ---echo Restore the original mysql.event table -drop table mysql.event; -rename table event_like to mysql.event; - ---echo check that we can now enable events without restart -set global event_scheduler=original; -select @@global.event_scheduler; -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 - ---source include/restart_mysqld.inc - -# We need this file primarily to make sure that the scheduler is restarted -# and enabled after we have restored mysql.event table. -# This is the final step of the "cleanup". -# -# Make sure also that events are executed OK after restart, just in case. -use events_test; -# Make sure the scheduler was started successfully -select @@event_scheduler; -let $wait_condition=select count(distinct name)=3 from execution_log; ---source include/wait_condition.inc -drop table execution_log; -# Will drop all events -drop database events_test; - -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where db='events_test' and command = 'Connect' and user=current_user(); ---source include/wait_condition.inc - ---echo # ---echo # Test for bug#11748899 -- EVENT SET TO DISABLED AND ON COMPLETION ---echo # NOT PRESERVE IS DELETED AT SERVER ---echo # -SELECT @@event_scheduler; -USE test; ---disable_warnings -DROP EVENT IF EXISTS e1; ---enable_warnings -CREATE EVENT e1 ON SCHEDULE EVERY 1 SECOND DISABLE DO SELECT 1; ---replace_column 6 # 9 # 10 # -SHOW EVENTS; - ---echo "Now we restart the server" ---source include/restart_mysqld.inc -USE test; -SELECT @@event_scheduler; ---replace_column 6 # 9 # 10 # -SHOW EVENTS; -DROP EVENT e1; - ---echo # end test for bug#11748899 - ---echo # ---echo # Test for MDEV-21758 Events switched randomly to SLAVESIDE_DISABLED ---echo # - -create event ev on schedule every 1 minute do set @a= 1; -select name, originator, status from mysql.event; - ---let $server_id= `SELECT @@global.server_id` - ---echo # ---echo # Restarting server with server_id=100 ---echo # ---let $restart_parameters= --server-id=100 ---source include/restart_mysqld.inc - -select @@global.server_id; -select name, originator, status from mysql.event; ---eval set global server_id= $server_id - ---echo # ---echo # Restarting server with the original server_id=$server_id ---echo # ---let $restart_parameters= ---source include/restart_mysqld.inc - -select @@global.server_id; -select name, originator, status from mysql.event; - -# Cleanup -drop event ev; diff --git a/mysql-test/main/events_scheduling.result b/mysql-test/main/events_scheduling.result deleted file mode 100644 index 262caea3d7f..00000000000 --- a/mysql-test/main/events_scheduling.result +++ /dev/null @@ -1,105 +0,0 @@ -CREATE DATABASE IF NOT EXISTS events_test; -USE events_test; -SET @event_scheduler=@@global.event_scheduler; -SET GLOBAL event_scheduler=OFF; -Try again to make sure it's allowed -SET GLOBAL event_scheduler=OFF; -SHOW VARIABLES LIKE 'event_scheduler'; -Variable_name Value -event_scheduler OFF -SET GLOBAL event_scheduler=1; -SHOW VARIABLES LIKE 'event_scheduler'; -Variable_name Value -event_scheduler ON -SET GLOBAL event_scheduler=0; -SHOW VARIABLES LIKE 'event_scheduler'; -Variable_name Value -event_scheduler OFF -SET GLOBAL event_scheduler=ON; -Try again to make sure it's allowed -SET GLOBAL event_scheduler=ON; -SHOW VARIABLES LIKE 'event_scheduler'; -Variable_name Value -event_scheduler ON -SET GLOBAL event_scheduler=DISABLED; -ERROR 42000: Variable 'event_scheduler' can't be set to the value of 'DISABLED' -SHOW VARIABLES LIKE 'event_scheduler'; -Variable_name Value -event_scheduler ON -SET GLOBAL event_scheduler=-1; -ERROR 42000: Variable 'event_scheduler' can't be set to the value of '-1' -SHOW VARIABLES LIKE 'event_scheduler'; -Variable_name Value -event_scheduler ON -SET GLOBAL event_scheduler=2; -ERROR 42000: Variable 'event_scheduler' can't be set to the value of '2' -SHOW VARIABLES LIKE 'event_scheduler'; -Variable_name Value -event_scheduler ON -SET GLOBAL event_scheduler=5; -ERROR 42000: Variable 'event_scheduler' can't be set to the value of '5' -SHOW VARIABLES LIKE 'event_scheduler'; -Variable_name Value -event_scheduler ON -CREATE TABLE table_1(a int); -CREATE TABLE table_2(a int); -CREATE TABLE table_3(a int); -CREATE TABLE table_4(a int); -SET GLOBAL event_scheduler=ON; -CREATE EVENT event_1 ON SCHEDULE EVERY 2 SECOND -DO -INSERT INTO table_1 VALUES (1); -CREATE EVENT event_2 ON SCHEDULE EVERY 1 SECOND -ENDS NOW() + INTERVAL 6 SECOND -ON COMPLETION PRESERVE -DO -INSERT INTO table_2 VALUES (1); -CREATE EVENT event_3 ON SCHEDULE EVERY 2 SECOND ENDS NOW() + INTERVAL 1 SECOND -ON COMPLETION NOT PRESERVE -DO -INSERT INTO table_3 VALUES (1); -CREATE EVENT event_4 ON SCHEDULE EVERY 1 SECOND ENDS NOW() + INTERVAL 1 SECOND -ON COMPLETION PRESERVE -DO -INSERT INTO table_4 VALUES (1); -SELECT IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR') -FROM INFORMATION_SCHEMA.EVENTS -WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='event_2'; -IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR') -OK -"Already dropped because ended. Therefore an error." -DROP EVENT event_3; -ERROR HY000: Unknown event 'event_3' -DROP EVENT event_1; -"Should be preserved" -SELECT EVENT_NAME, STATUS FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_NAME; -EVENT_NAME STATUS -event_2 DISABLED -event_4 DISABLED -DROP EVENT event_2; -DROP EVENT event_4; -DROP TABLE table_1; -DROP TABLE table_2; -DROP TABLE table_3; -DROP TABLE table_4; - -Bug #50087 Interval arithmetic for Event_queue_element is not portable. - -CREATE TABLE t1(a int); -CREATE EVENT e1 ON SCHEDULE EVERY 1 MONTH -STARTS NOW() - INTERVAL 1 MONTH -ENDS NOW() + INTERVAL 2 MONTH -ON COMPLETION PRESERVE -DO -INSERT INTO t1 VALUES (1); -CREATE EVENT e2 ON SCHEDULE EVERY 1 MONTH -STARTS NOW() -ENDS NOW() + INTERVAL 11 MONTH -ON COMPLETION PRESERVE -DO -INSERT INTO t1 VALUES (1); -DROP TABLE t1; -DROP EVENT e1; -DROP EVENT e2; -DROP DATABASE events_test; -SET GLOBAL event_scheduler=@event_scheduler; diff --git a/mysql-test/main/events_scheduling.test b/mysql-test/main/events_scheduling.test deleted file mode 100644 index 5f16f8bea6a..00000000000 --- a/mysql-test/main/events_scheduling.test +++ /dev/null @@ -1,148 +0,0 @@ -# Can't test with embedded server that doesn't support events --- source include/not_embedded.inc - -CREATE DATABASE IF NOT EXISTS events_test; -USE events_test; - -SET @event_scheduler=@@global.event_scheduler; -SET GLOBAL event_scheduler=OFF; ---echo Try again to make sure it's allowed -SET GLOBAL event_scheduler=OFF; -SHOW VARIABLES LIKE 'event_scheduler'; -SET GLOBAL event_scheduler=1; -SHOW VARIABLES LIKE 'event_scheduler'; -SET GLOBAL event_scheduler=0; -SHOW VARIABLES LIKE 'event_scheduler'; -SET GLOBAL event_scheduler=ON; ---echo Try again to make sure it's allowed -SET GLOBAL event_scheduler=ON; -SHOW VARIABLES LIKE 'event_scheduler'; ---error ER_WRONG_VALUE_FOR_VAR -SET GLOBAL event_scheduler=DISABLED; -SHOW VARIABLES LIKE 'event_scheduler'; ---error ER_WRONG_VALUE_FOR_VAR -SET GLOBAL event_scheduler=-1; -SHOW VARIABLES LIKE 'event_scheduler'; ---error ER_WRONG_VALUE_FOR_VAR -SET GLOBAL event_scheduler=2; -SHOW VARIABLES LIKE 'event_scheduler'; ---error ER_WRONG_VALUE_FOR_VAR -SET GLOBAL event_scheduler=5; -SHOW VARIABLES LIKE 'event_scheduler'; - -CREATE TABLE table_1(a int); -CREATE TABLE table_2(a int); -CREATE TABLE table_3(a int); -CREATE TABLE table_4(a int); - -SET GLOBAL event_scheduler=ON; -# We need to have 2 to make it safe with valgrind. This is probably because -# of when we calculate the timestamp value -CREATE EVENT event_1 ON SCHEDULE EVERY 2 SECOND -DO - INSERT INTO table_1 VALUES (1); - -CREATE EVENT event_2 ON SCHEDULE EVERY 1 SECOND -ENDS NOW() + INTERVAL 6 SECOND -ON COMPLETION PRESERVE -DO - INSERT INTO table_2 VALUES (1); - -CREATE EVENT event_3 ON SCHEDULE EVERY 2 SECOND ENDS NOW() + INTERVAL 1 SECOND -ON COMPLETION NOT PRESERVE -DO - INSERT INTO table_3 VALUES (1); - -CREATE EVENT event_4 ON SCHEDULE EVERY 1 SECOND ENDS NOW() + INTERVAL 1 SECOND -ON COMPLETION PRESERVE -DO - INSERT INTO table_4 VALUES (1); - -# Let event_1 insert at least 4 records into the table -let $wait_condition=select count(*) >= 4 from table_1; ---source include/wait_condition.inc -# Minimum of passed time is 6 seconds assuming -# - event executions starts immediate after creation -# - 4 times event_1 means an insert at ect, ect+2, ect+4, ect+6 -# ect = event creation time - -# Let event_2 reach the end of its execution interval -let $wait_condition=select count(*) = 0 from information_schema.events -where event_name='event_2' and status='enabled'; ---source include/wait_condition.inc -# Minimum of passed time is 6 seconds. -# See wait_condition for event_1 above and ENDS condition for event_2. - -# Let event_3, which is ON COMPLETION NOT PRESERVE execute and drop itself -let $wait_condition=select count(*) = 0 from information_schema.events -where event_name='event_3'; ---source include/wait_condition.inc - -# Let event_4 reach the end of its execution interval -let $wait_condition=select count(*) = 0 from information_schema.events -where event_name='event_4' and status='enabled'; ---source include/wait_condition.inc - -# -# On a busy system the scheduler may skip execution of events, -# we can't reliably expect that the data in a table to be modified -# by an event will be exact. Thus we do not SELECT from the tables -# in this test. See also -# Bug#39854 events_scheduling fails sporadically on pushbuild -# - -SELECT IF(TIME_TO_SEC(TIMEDIFF(ENDS,STARTS))=6, 'OK', 'ERROR') -FROM INFORMATION_SCHEMA.EVENTS -WHERE EVENT_SCHEMA=DATABASE() AND EVENT_NAME='event_2'; - ---echo "Already dropped because ended. Therefore an error." ---error ER_EVENT_DOES_NOT_EXIST -DROP EVENT event_3; - -DROP EVENT event_1; ---echo "Should be preserved" -SELECT EVENT_NAME, STATUS FROM INFORMATION_SCHEMA.EVENTS ORDER BY EVENT_NAME; -DROP EVENT event_2; -DROP EVENT event_4; -DROP TABLE table_1; -DROP TABLE table_2; -DROP TABLE table_3; -DROP TABLE table_4; - --- echo --- echo Bug #50087 Interval arithmetic for Event_queue_element is not portable. --- echo - -CREATE TABLE t1(a int); - -CREATE EVENT e1 ON SCHEDULE EVERY 1 MONTH -STARTS NOW() - INTERVAL 1 MONTH -ENDS NOW() + INTERVAL 2 MONTH -ON COMPLETION PRESERVE -DO - INSERT INTO t1 VALUES (1); - -CREATE EVENT e2 ON SCHEDULE EVERY 1 MONTH -STARTS NOW() -ENDS NOW() + INTERVAL 11 MONTH -ON COMPLETION PRESERVE -DO - INSERT INTO t1 VALUES (1); - -DROP TABLE t1; -DROP EVENT e1; -DROP EVENT e2; - - -DROP DATABASE events_test; -SET GLOBAL event_scheduler=@event_scheduler; - -# -# End of tests -# - -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where db='events_test' and command = 'Connect' and user=current_user(); ---source include/wait_condition.inc - diff --git a/mysql-test/main/events_slowlog.result b/mysql-test/main/events_slowlog.result deleted file mode 100644 index be0a1e78d2a..00000000000 --- a/mysql-test/main/events_slowlog.result +++ /dev/null @@ -1,13 +0,0 @@ -set @event_scheduler_save= @@global.event_scheduler; -set @slow_query_log_save= @@global.slow_query_log; -set global event_scheduler= on; -set global slow_query_log= on; -set global long_query_time=0.2; -create table t1 (i int); -insert into t1 values (0); -create event ev on schedule at CURRENT_TIMESTAMP + INTERVAL 1 second do update t1 set i=1+sleep(0.5); -FOUND 1 /update t1 set i=1/ in mysqld-slow.log -drop table t1; -set global event_scheduler= @event_scheduler_save; -set global slow_query_log= @slow_query_log_save; -set global long_query_time= @@session.long_query_time; diff --git a/mysql-test/main/events_slowlog.test b/mysql-test/main/events_slowlog.test deleted file mode 100644 index 9679714dba3..00000000000 --- a/mysql-test/main/events_slowlog.test +++ /dev/null @@ -1,28 +0,0 @@ ---source include/not_embedded.inc -# -# MDEV-11552 Queries executed by event scheduler are written to slow log incorrectly or not written at all -# -set @event_scheduler_save= @@global.event_scheduler; -set @slow_query_log_save= @@global.slow_query_log; - -set global event_scheduler= on; -set global slow_query_log= on; -set global long_query_time=0.2; - -create table t1 (i int); -insert into t1 values (0); -create event ev on schedule at CURRENT_TIMESTAMP + INTERVAL 1 second do update t1 set i=1+sleep(0.5); - ---let wait_condition= select i from t1 where i > 0 ---source include/wait_condition.inc - ---let SEARCH_FILE = `SELECT @@slow_query_log_file` ---let SEARCH_PATTERN= update t1 set i=1 ---let SEARCH_RANGE= -1000 ---source include/search_pattern_in_file.inc - -drop table t1; - -set global event_scheduler= @event_scheduler_save; -set global slow_query_log= @slow_query_log_save; -set global long_query_time= @@session.long_query_time; diff --git a/mysql-test/main/events_stress.result b/mysql-test/main/events_stress.result deleted file mode 100644 index 1a91ff0f528..00000000000 --- a/mysql-test/main/events_stress.result +++ /dev/null @@ -1,78 +0,0 @@ -CREATE DATABASE IF NOT EXISTS events_test; -CREATE DATABASE events_conn1_test2; -CREATE TABLE events_test.fill_it1(test_name varchar(20), occur datetime); -CREATE TABLE events_test.fill_it2(test_name varchar(20), occur datetime); -CREATE TABLE events_test.fill_it3(test_name varchar(20), occur datetime); -CREATE USER event_user2@localhost; -CREATE DATABASE events_conn2_db; -GRANT ALL ON *.* TO event_user2@localhost; -CREATE USER event_user3@localhost; -CREATE DATABASE events_conn3_db; -GRANT ALL ON *.* TO event_user3@localhost; -connect conn2,localhost,event_user2,,events_conn2_db; -"In the second connection we create some events which won't be dropped till the end" -connect conn3,localhost,event_user3,,events_conn3_db; -"In the second connection we create some events which won't be dropped till the end" -connection default; -USE events_conn1_test2; -CREATE EVENT ev_drop1 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1; -CREATE EVENT ev_drop2 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1; -CREATE EVENT ev_drop3 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1; -USE events_test; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS; -COUNT(*) -103 -SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; -COUNT(*) -3 -DROP DATABASE events_conn1_test2; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; -COUNT(*) -0 -"Now testing stability - dropping db -> events while they are running" -CREATE DATABASE events_conn1_test2; -USE events_conn1_test2; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; -COUNT(*) -50 -SET @old_event_scheduler=@@event_scheduler; -SET GLOBAL event_scheduler=on; -DROP DATABASE events_conn1_test2; -SET GLOBAL event_scheduler=off; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; -COUNT(*) -0 -CREATE DATABASE events_conn1_test3; -USE events_conn1_test3; -SET GLOBAL event_scheduler=on; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test3'; -COUNT(*) -50 -CREATE DATABASE events_conn1_test4; -USE events_conn1_test4; -CREATE DATABASE events_conn1_test2; -USE events_conn1_test2; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; -COUNT(*) -50 -connection conn2; -DROP DATABASE events_conn2_db; -connection conn3; -DROP DATABASE events_conn3_db; -connection default; -DROP DATABASE events_conn1_test2; -DROP DATABASE events_conn1_test3; -SET GLOBAL event_scheduler=off; -DROP DATABASE events_conn1_test4; -SET GLOBAL event_scheduler=on; -connection conn2; -disconnect conn2; -connection conn3; -disconnect conn3; -connection default; -USE events_test; -DROP TABLE fill_it1; -DROP TABLE fill_it2; -DROP TABLE fill_it3; -DROP DATABASE events_test; -SET GLOBAL event_scheduler=@old_event_scheduler; diff --git a/mysql-test/main/events_stress.test b/mysql-test/main/events_stress.test deleted file mode 100644 index 080707f029f..00000000000 --- a/mysql-test/main/events_stress.test +++ /dev/null @@ -1,143 +0,0 @@ -# Can't test with embedded server that doesn't support grants ---source include/not_embedded.inc ---source include/big_test.inc - -CREATE DATABASE IF NOT EXISTS events_test; -# -# DROP DATABASE test start (bug #16406) -# -CREATE DATABASE events_conn1_test2; -# BUG#20676: MySQL in debug mode has a limit of 100 waiters -# (in mysys/thr_lock.c), so use three different tables to insert into. -CREATE TABLE events_test.fill_it1(test_name varchar(20), occur datetime); -CREATE TABLE events_test.fill_it2(test_name varchar(20), occur datetime); -CREATE TABLE events_test.fill_it3(test_name varchar(20), occur datetime); -CREATE USER event_user2@localhost; -CREATE DATABASE events_conn2_db; -GRANT ALL ON *.* TO event_user2@localhost; -CREATE USER event_user3@localhost; -CREATE DATABASE events_conn3_db; -GRANT ALL ON *.* TO event_user3@localhost; -connect (conn2,localhost,event_user2,,events_conn2_db); ---echo "In the second connection we create some events which won't be dropped till the end" ---disable_query_log ---disable_warnings -let $1= 50; -while ($1) -{ - eval CREATE EVENT conn2_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it1 VALUES("conn2_ev$1", NOW()); - dec $1; -} ---enable_query_log -connect (conn3,localhost,event_user3,,events_conn3_db); ---echo "In the second connection we create some events which won't be dropped till the end" ---disable_query_log -let $1= 50; -while ($1) -{ - eval CREATE EVENT conn3_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it1 VALUES("conn3_ev$1", NOW()); - dec $1; -} ---enable_query_log -connection default; -USE events_conn1_test2; -CREATE EVENT ev_drop1 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1; -CREATE EVENT ev_drop2 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1; -CREATE EVENT ev_drop3 ON SCHEDULE EVERY 10 MINUTE DISABLE DO SELECT 1; -USE events_test; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; -DROP DATABASE events_conn1_test2; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; - ---echo "Now testing stability - dropping db -> events while they are running" -CREATE DATABASE events_conn1_test2; -USE events_conn1_test2; ---disable_query_log -let $1= 50; -while ($1) -{ - eval CREATE EVENT conn1_round1_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it2 VALUES("conn1_round1_ev$1", NOW()); - dec $1; -} ---enable_query_log -SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; -SET @old_event_scheduler=@@event_scheduler; -SET GLOBAL event_scheduler=on; ---sleep 2.5 -DROP DATABASE events_conn1_test2; - -SET GLOBAL event_scheduler=off; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; -CREATE DATABASE events_conn1_test3; -USE events_conn1_test3; ---disable_query_log -let $1= 50; -while ($1) -{ - eval CREATE EVENT conn1_round2_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it2 VALUES("conn1_round2_ev$1", NOW()); - dec $1; -} ---enable_query_log -SET GLOBAL event_scheduler=on; -SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test3'; -CREATE DATABASE events_conn1_test4; -USE events_conn1_test4; ---disable_query_log -let $1= 50; -while ($1) -{ - eval CREATE EVENT conn1_round3_ev$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it3 VALUES("conn1_round3_ev$1", NOW()); - dec $1; -} ---enable_query_log - -CREATE DATABASE events_conn1_test2; -USE events_conn1_test2; ---disable_query_log -let $1= 50; -while ($1) -{ - eval CREATE EVENT ev_round4_drop$1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO events_test.fill_it3 VALUES("conn1_round4_ev$1", NOW()); - dec $1; -} ---enable_query_log -SELECT COUNT(*) FROM INFORMATION_SCHEMA.EVENTS WHERE EVENT_SCHEMA='events_conn1_test2'; ---sleep 2.5 -connection conn2; ---send -DROP DATABASE events_conn2_db; -connection conn3; ---send -DROP DATABASE events_conn3_db; -connection default; -# --send -DROP DATABASE events_conn1_test2; -DROP DATABASE events_conn1_test3; -SET GLOBAL event_scheduler=off; -DROP DATABASE events_conn1_test4; -SET GLOBAL event_scheduler=on; -connection conn2; -reap; -disconnect conn2; -connection conn3; -reap; -disconnect conn3; -connection default; -USE events_test; -DROP TABLE fill_it1; -DROP TABLE fill_it2; -DROP TABLE fill_it3; ---disable_query_log -DROP USER event_user2@localhost; -DROP USER event_user3@localhost; ---enable_query_log -# -# DROP DATABASE test end (bug #16406) -# - -DROP DATABASE events_test; - -# Cleanup -SET GLOBAL event_scheduler=@old_event_scheduler; ---source include/check_events_off.inc diff --git a/mysql-test/main/events_time_zone.result b/mysql-test/main/events_time_zone.result deleted file mode 100644 index 155a9d155af..00000000000 --- a/mysql-test/main/events_time_zone.result +++ /dev/null @@ -1,152 +0,0 @@ -DROP DATABASE IF EXISTS mysqltest_db1; -CREATE DATABASE mysqltest_db1; -USE mysqltest_db1; -SET GLOBAL EVENT_SCHEDULER= OFF; -SET @save_time_zone= @@TIME_ZONE; -CREATE TABLE t_step (step INT); -INSERT INTO t_step VALUES (@step); -CREATE FUNCTION round_to_step(i INT, n INT) RETURNS INT -BEGIN -DECLARE step INT; -SELECT * INTO step FROM t_step; -# We add 0.1 as a protection from inexact division. -RETURN FLOOR((i % (step * n) + 0.1) / step); -END// -SET @step3= @step * 3; -SET @step6= @step * 6; -SET @unix_time= UNIX_TIMESTAMP() - 1; -SET @unix_time= @unix_time - @unix_time % @step6; -INSERT INTO mysql.time_zone VALUES (NULL, 'N'); -SET @tzid= LAST_INSERT_ID(); -INSERT INTO mysql.time_zone_transition_type -VALUES (@tzid, 0, 0, 0, 'b16420_0'); -INSERT INTO mysql.time_zone_transition_type -VALUES (@tzid, 1, @step3 - @step, 1, 'b16420_1'); -INSERT INTO mysql.time_zone_name VALUES ('<TZ_NAME_1>', @tzid); -CREATE TABLE t1 (count INT, unix_time INT, local_time INT, comment CHAR(80)); -CREATE TABLE t2 (count INT); -INSERT INTO t2 VALUES (1); -CREATE FUNCTION f1(comment CHAR(80)) RETURNS INT -BEGIN -DECLARE orig_tz CHAR(64); -DECLARE unix_time INT; -DECLARE local_now DATETIME; -DECLARE utc_now DATETIME; -DECLARE local_time INT; -SET unix_time= UNIX_TIMESTAMP(); -SET local_now= FROM_UNIXTIME(unix_time); -SET orig_tz= @@TIME_ZONE; -SET TIME_ZONE = '+00:00'; -SET utc_now= FROM_UNIXTIME(unix_time); -SET TIME_ZONE= orig_tz; -SET local_time = unix_time + TIMESTAMPDIFF(SECOND, utc_now, local_now); -SET unix_time= round_to_step(unix_time, 6); -SET local_time= round_to_step(local_time, 6); -INSERT INTO t1 VALUES ((SELECT count FROM t2), -unix_time, local_time, comment); -RETURN 0; -END// -SET TIME_ZONE= '+00:00'; -CREATE EVENT e1 ON SCHEDULE EVERY @step SECOND -STARTS FROM_UNIXTIME(@unix_time) DO SELECT f1("<e1>"); -SET TIME_ZONE= '<TZ_NAME_1>'; -CREATE EVENT e2 ON SCHEDULE EVERY @step SECOND -STARTS FROM_UNIXTIME(@unix_time) DO SELECT f1("<e2>"); -SET GLOBAL EVENT_SCHEDULER= ON; -SELECT SLEEP(@step / 2); -SLEEP(@step / 2) -0 -SET GLOBAL EVENT_SCHEDULER= OFF; -SELECT * FROM t1 ORDER BY count, comment; -count unix_time local_time comment -1 1 1 <e1> -1 1 3 <e2> -1 1 3 e2 should be executed -2 2 2 <e1> -2 2 4 <e2> -2 2 4 e2 should be executed -3 3 3 <e1> -3 3 3 Second pass after backward -2 step shift, e2 should not be executed -4 4 4 <e1> -4 4 4 Second pass after backward -2 step shift, e2 should not be executed -5 5 5 <e1> -5 5 5 <e2> -5 5 5 e2 should be executed -6 0 0 <e1> -6 0 2 <e2> -6 0 2 Forward +2 step shift, local 0, 1 are skipped, e2 should be executed -7 1 1 <e1> -7 1 3 <e2> -7 1 3 e2 should be executed -SET TIME_ZONE= @save_time_zone; -DROP EVENT e2; -DROP EVENT e1; -DROP FUNCTION f1; -DROP TABLE t1, t2; -DELETE FROM mysql.time_zone_name WHERE time_zone_id = @tzid; -DELETE FROM mysql.time_zone_transition_type WHERE time_zone_id = @tzid; -DELETE FROM mysql.time_zone_transition WHERE time_zone_id = @tzid; -DELETE FROM mysql.time_zone WHERE time_zone_id = @tzid; -ALTER TABLE mysql.time_zone AUTO_INCREMENT = 6; -SET TIME_ZONE= '+00:00'; -CREATE TABLE t1 (event CHAR(2), dt DATE, offset INT); -INSERT INTO mysql.time_zone VALUES (NULL, 'N'); -SET @tzid= LAST_INSERT_ID(); -SET @now= UNIX_TIMESTAMP(); -SET @offset_month_01= UNIX_TIMESTAMP('2030-01-31 12:00:00') - @now; -SET @offset_month_02= UNIX_TIMESTAMP('2030-02-28 12:00:00') - @now - 5*@step; -SET @offset_month_03= UNIX_TIMESTAMP('2030-03-31 12:00:00') - @now - 5*@step; -SET @offset_month_04= UNIX_TIMESTAMP('2030-04-30 12:00:00') - @now - 13*@step; -INSERT INTO mysql.time_zone_transition_type -VALUES (@tzid, 0, @offset_month_01, 0, 'b16420_0'); -INSERT INTO mysql.time_zone_transition_type -VALUES (@tzid, 1, @offset_month_02, 1, 'b16420_1'); -INSERT INTO mysql.time_zone_transition_type -VALUES (@tzid, 2, @offset_month_03, 1, 'b16420_2'); -INSERT INTO mysql.time_zone_transition_type -VALUES (@tzid, 3, @offset_month_04, 1, 'b16420_3'); -INSERT INTO mysql.time_zone_transition -VALUES (@tzid, @now, 0); -INSERT INTO mysql.time_zone_transition -VALUES (@tzid, @now + 3 * @step, 1); -INSERT INTO mysql.time_zone_transition -VALUES (@tzid, @now + 7 * @step, 2); -INSERT INTO mysql.time_zone_transition -VALUES (@tzid, @now + 12 * @step, 3); -INSERT INTO mysql.time_zone_name VALUES ('<TZ_NAME_2>', @tzid); -SET TIME_ZONE= '<TZ_NAME_2>'; -SET GLOBAL EVENT_SCHEDULER= ON; -SET GLOBAL EVENT_SCHEDULER= OFF; -Below we should see the following: -- On Jan 31 only e2 is executed, because we started later than -e1 should have been executed. Offset of e2 is 0 because of -the late start, not 1. -- The next execution is on Feb 28 (last day of Feb). Both events -are executed in their times, offsets are -1 and 1. -- The next time is Mar 31. Because the time of event -execution was skipped over, events are executed right away, -offsets are 2 and 2. -- The next time is Apr 30. Events are again executed in their -appointed times, offsets are -1 and 1. -SELECT * FROM t1 ORDER BY dt, event; -event dt offset -e2 2030-01-31 0 -e1 2030-02-28 -1 -e2 2030-02-28 1 -e1 2030-03-31 2 -e2 2030-03-31 2 -e1 2030-04-30 -1 -e2 2030-04-30 1 -DROP EVENT e2; -DROP EVENT e1; -DROP TABLE t1; -SET TIME_ZONE= @save_time_zone; -DELETE FROM mysql.time_zone_name WHERE time_zone_id = @tzid; -DELETE FROM mysql.time_zone_transition_type WHERE time_zone_id = @tzid; -DELETE FROM mysql.time_zone_transition WHERE time_zone_id = @tzid; -DELETE FROM mysql.time_zone WHERE time_zone_id = @tzid; -ALTER TABLE mysql.time_zone AUTO_INCREMENT = 6; -DROP FUNCTION round_to_step; -DROP TABLE t_step; -DROP DATABASE mysqltest_db1; -End of 5.1 tests. diff --git a/mysql-test/main/events_time_zone.test b/mysql-test/main/events_time_zone.test deleted file mode 100644 index 5291eb96e6b..00000000000 --- a/mysql-test/main/events_time_zone.test +++ /dev/null @@ -1,336 +0,0 @@ -# 1. This test case is sensitive to execution timing. You may control -# this sensitivity by the parameter below. Small values will result -# in fast but more unstable execution, large values will improve -# stability at the cost of speed. Basically, N is a number of seconds -# to wait for operation to complete. Should be positive. Test runs -# about 25*N seconds (it sleeps most of the time, so CPU speed is not -# relevant). -let $N = 6; -# -# 2. Some subtests -# - create a new time zone -# - run some statements -# - delete the new time zone. -# But the time zone name used gets somewhere cached and it cannot be -# "reused" later in the same or another session for a new time zone. -# Experiments (2008-11 MySQL 5.1) showed that none of the available -# RESET/FLUSH commands removes these entries. -# 2008-11 MySQL 5.1 Bug#39979 main.events_time_zone does not clean up -# second bad effect -# Therefore we compute unique and unusual timezone names to minimize -# the likelihood that a later test uses the same name. -# -# 3. The subtests mentioned in 2. cause that the AUTO_INCREMENT value -# within "SHOW CREATE TABLE mysql.timezone" differ from the initial one. -# (Bug#39979 main.events_time_zone does not clean up) -# Therefore we reset this value after each of these subtests. -# -# Note(mleich): -# There is a significant likelihood that future improvements of the server -# cause that the solutions for the issues mentioned in 2. and 3. will no -# more work. -# A mysql-test-run.pl feature which allows to enforce -# 1. Server shutdown (-> Problem mentioned in 2. disappears) -# 2. Reset all data to initial state (-> Problem mentioned in 3. disappears) -# 3. Server start -# after a tests would be a perfect replacement. -# - -# Can't test with embedded server that doesn't support grants --- source include/not_embedded.inc - ---source include/big_test.inc - - ---disable_warnings -DROP DATABASE IF EXISTS mysqltest_db1; ---enable_warnings - -CREATE DATABASE mysqltest_db1; - -let $old_db= `SELECT DATABASE()`; -USE mysqltest_db1; - -SET GLOBAL EVENT_SCHEDULER= OFF; -SET @save_time_zone= @@TIME_ZONE; - - -# -# BUG#16420: Events: timestamps become UTC -# BUG#26429: SHOW CREATE EVENT is incorrect for an event that -# STARTS NOW() -# BUG#26431: Impossible to re-create an event from backup if its -# STARTS clause is in the past -# WL#3698: Events: execution in local time zone -# - -#---------------------------------------------------------------------- - -# Create rounding function. - -# Disable query log to hide actual value of $N. ---disable_query_log -eval SET @step= $N; ---enable_query_log - -# Since we are working in a separate database, we may use any names we -# like. -CREATE TABLE t_step (step INT); -INSERT INTO t_step VALUES (@step); - -# We can't use @variables in function, because it will be called from -# the event thread, and 'eval' doesn't work for multi-statements, so -# we can't interpolate $variables either, hence we fetch the step -# value from the table. -delimiter //; -CREATE FUNCTION round_to_step(i INT, n INT) RETURNS INT -BEGIN - DECLARE step INT; - - SELECT * INTO step FROM t_step; - - # We add 0.1 as a protection from inexact division. - RETURN FLOOR((i % (step * n) + 0.1) / step); -END// -delimiter ;// - - -# Test time computations wrt Daylight Saving Time shifts. We also -# test here that the event operates in its time zone (see what NOW() -# returns). -# - -# Create a fake time zone with time transitions every 3*$N second. - -SET @step3= @step * 3; -SET @step6= @step * 6; - -SET @unix_time= UNIX_TIMESTAMP() - 1; -SET @unix_time= @unix_time - @unix_time % @step6; - -INSERT INTO mysql.time_zone VALUES (NULL, 'N'); -SET @tzid= LAST_INSERT_ID(); -INSERT INTO mysql.time_zone_transition_type - VALUES (@tzid, 0, 0, 0, 'b16420_0'); -INSERT INTO mysql.time_zone_transition_type - VALUES (@tzid, 1, @step3 - @step, 1, 'b16420_1'); - -let $transition_unix_time= `SELECT @unix_time`; -let $count= 30; ---disable_query_log -begin; -while ($count) -{ - eval INSERT INTO mysql.time_zone_transition - VALUES (@tzid, $transition_unix_time, - $transition_unix_time % @step6 = 0); - let $transition_unix_time= `SELECT $transition_unix_time + @step3`; - dec $count; -} -commit; ---enable_query_log -let $tz_name = `SELECT CONCAT('b16420_a',UNIX_TIMESTAMP())`; ---replace_result $tz_name <TZ_NAME_1> -eval INSERT INTO mysql.time_zone_name VALUES ('$tz_name', @tzid); - -CREATE TABLE t1 (count INT, unix_time INT, local_time INT, comment CHAR(80)); -CREATE TABLE t2 (count INT); -INSERT INTO t2 VALUES (1); - -delimiter //; -CREATE FUNCTION f1(comment CHAR(80)) RETURNS INT -BEGIN - DECLARE orig_tz CHAR(64); - DECLARE unix_time INT; - DECLARE local_now DATETIME; - DECLARE utc_now DATETIME; - DECLARE local_time INT; - - SET unix_time= UNIX_TIMESTAMP(); - SET local_now= FROM_UNIXTIME(unix_time); - SET orig_tz= @@TIME_ZONE; - SET TIME_ZONE = '+00:00'; - SET utc_now= FROM_UNIXTIME(unix_time); - SET TIME_ZONE= orig_tz; - SET local_time = unix_time + TIMESTAMPDIFF(SECOND, utc_now, local_now); - - SET unix_time= round_to_step(unix_time, 6); - SET local_time= round_to_step(local_time, 6); - - INSERT INTO t1 VALUES ((SELECT count FROM t2), - unix_time, local_time, comment); - RETURN 0; -END// -delimiter ;// - -SET TIME_ZONE= '+00:00'; -CREATE EVENT e1 ON SCHEDULE EVERY @step SECOND - STARTS FROM_UNIXTIME(@unix_time) DO SELECT f1("<e1>"); - ---replace_result $tz_name <TZ_NAME_1> -eval SET TIME_ZONE= '$tz_name'; -CREATE EVENT e2 ON SCHEDULE EVERY @step SECOND - STARTS FROM_UNIXTIME(@unix_time) DO SELECT f1("<e2>"); - -# We want to start at the beginning of the DST cycle, so we wait -# untill current time divides by @step6. -let $wait_timeout= `SELECT @step6*2 + 1`; -let $wait_condition= SELECT UNIX_TIMESTAMP() % @step6 = @step6 - 1; ---source include/wait_condition.inc -# The second wait is needed because after the first wait we may end up -# on the ending edge of a second. Second wait will bring us to the -# beginning edge. -let $wait_timeout= `SELECT @step*2 + 1`; -let $wait_condition= SELECT UNIX_TIMESTAMP() % @step6 = 0; ---source include/wait_condition.inc - -# Note that after the scheduler is enabled, the event will be -# scheduled only for the next second. -SET GLOBAL EVENT_SCHEDULER= ON; - -# We want to run after the events are executed. -SELECT SLEEP(@step / 2); - -let $count= 7; ---disable_query_log ---disable_result_log -while ($count) -{ - SELECT SLEEP(@step); - - eval SELECT CASE $count - WHEN 5 THEN f1(CONCAT("Second pass after backward -2 step shift,", - " e2 should not be executed")) - WHEN 4 THEN f1(CONCAT("Second pass after backward -2 step shift,", - " e2 should not be executed")) - WHEN 2 THEN f1(CONCAT("Forward +2 step shift, local 0, 1 are skipped,", - " e2 should be executed")) - ELSE f1("e2 should be executed") - END; - UPDATE t2 SET count= count + 1; - - dec $count; -} ---enable_result_log ---enable_query_log - -SET GLOBAL EVENT_SCHEDULER= OFF; - -SELECT * FROM t1 ORDER BY count, comment; - -SET TIME_ZONE= @save_time_zone; - -DROP EVENT e2; -DROP EVENT e1; -DROP FUNCTION f1; -DROP TABLE t1, t2; - -DELETE FROM mysql.time_zone_name WHERE time_zone_id = @tzid; -DELETE FROM mysql.time_zone_transition_type WHERE time_zone_id = @tzid; -DELETE FROM mysql.time_zone_transition WHERE time_zone_id = @tzid; -DELETE FROM mysql.time_zone WHERE time_zone_id = @tzid; -let $time_zone_auto_inc = `SELECT MAX(Time_zone_id) + 1 FROM mysql.time_zone`; -eval ALTER TABLE mysql.time_zone AUTO_INCREMENT = $time_zone_auto_inc; - -#---------------------------------------------------------------------- - -# Test MONTH interval. -# - -SET TIME_ZONE= '+00:00'; - -CREATE TABLE t1 (event CHAR(2), dt DATE, offset INT); - -INSERT INTO mysql.time_zone VALUES (NULL, 'N'); -SET @tzid= LAST_INSERT_ID(); - -SET @now= UNIX_TIMESTAMP(); -SET @offset_month_01= UNIX_TIMESTAMP('2030-01-31 12:00:00') - @now; -SET @offset_month_02= UNIX_TIMESTAMP('2030-02-28 12:00:00') - @now - 5*@step; -SET @offset_month_03= UNIX_TIMESTAMP('2030-03-31 12:00:00') - @now - 5*@step; -SET @offset_month_04= UNIX_TIMESTAMP('2030-04-30 12:00:00') - @now - 13*@step; - -INSERT INTO mysql.time_zone_transition_type - VALUES (@tzid, 0, @offset_month_01, 0, 'b16420_0'); -INSERT INTO mysql.time_zone_transition_type - VALUES (@tzid, 1, @offset_month_02, 1, 'b16420_1'); -INSERT INTO mysql.time_zone_transition_type - VALUES (@tzid, 2, @offset_month_03, 1, 'b16420_2'); -INSERT INTO mysql.time_zone_transition_type - VALUES (@tzid, 3, @offset_month_04, 1, 'b16420_3'); -INSERT INTO mysql.time_zone_transition - VALUES (@tzid, @now, 0); -INSERT INTO mysql.time_zone_transition - VALUES (@tzid, @now + 3 * @step, 1); -INSERT INTO mysql.time_zone_transition - VALUES (@tzid, @now + 7 * @step, 2); -INSERT INTO mysql.time_zone_transition - VALUES (@tzid, @now + 12 * @step, 3); -let $tz_name = `SELECT CONCAT('b16420_b',UNIX_TIMESTAMP())`; ---replace_result $tz_name <TZ_NAME_2> -eval INSERT INTO mysql.time_zone_name VALUES ('$tz_name', @tzid); - ---replace_result $tz_name <TZ_NAME_2> -eval SET TIME_ZONE= '$tz_name'; - -SET GLOBAL EVENT_SCHEDULER= ON; - -let $now= `SELECT @now`; ---disable_query_log -eval CREATE EVENT e1 ON SCHEDULE EVERY 1 MONTH - STARTS FROM_UNIXTIME($now - @step) DO - INSERT INTO t1 VALUES - ("e1", NOW(), round_to_step(UNIX_TIMESTAMP() - $now, 4) - 1); -eval CREATE EVENT e2 ON SCHEDULE EVERY 1 MONTH - STARTS FROM_UNIXTIME($now + @step) DO - INSERT INTO t1 VALUES - ("e2", NOW(), round_to_step(UNIX_TIMESTAMP() - $now, 4) - 1); ---enable_query_log - -let $wait_timeout= `SELECT 16 * @step`; -let $wait_condition= SELECT COUNT(*) = 7 FROM t1; ---source include/wait_condition.inc - -SET GLOBAL EVENT_SCHEDULER= OFF; - ---echo Below we should see the following: ---echo - On Jan 31 only e2 is executed, because we started later than ---echo e1 should have been executed. Offset of e2 is 0 because of ---echo the late start, not 1. ---echo - The next execution is on Feb 28 (last day of Feb). Both events ---echo are executed in their times, offsets are -1 and 1. ---echo - The next time is Mar 31. Because the time of event ---echo execution was skipped over, events are executed right away, ---echo offsets are 2 and 2. ---echo - The next time is Apr 30. Events are again executed in their ---echo appointed times, offsets are -1 and 1. -SELECT * FROM t1 ORDER BY dt, event; - -DROP EVENT e2; -DROP EVENT e1; -DROP TABLE t1; - -SET TIME_ZONE= @save_time_zone; - -DELETE FROM mysql.time_zone_name WHERE time_zone_id = @tzid; -DELETE FROM mysql.time_zone_transition_type WHERE time_zone_id = @tzid; -DELETE FROM mysql.time_zone_transition WHERE time_zone_id = @tzid; -DELETE FROM mysql.time_zone WHERE time_zone_id = @tzid; -let $time_zone_auto_inc = `SELECT MAX(Time_zone_id) + 1 FROM mysql.time_zone`; -eval ALTER TABLE mysql.time_zone AUTO_INCREMENT = $time_zone_auto_inc; - -DROP FUNCTION round_to_step; -DROP TABLE t_step; - - -DROP DATABASE mysqltest_db1; ---disable_query_log -eval USE $old_db; - ---enable_query_log -let $wait_condition= - SELECT COUNT(*) = 0 FROM information_schema.processlist - WHERE db='mysqltest_db1' AND command = 'Connect' AND user=current_user(); ---source include/wait_condition.inc - ---echo End of 5.1 tests. diff --git a/mysql-test/main/events_trans.result b/mysql-test/main/events_trans.result deleted file mode 100644 index a7b268fe2a7..00000000000 --- a/mysql-test/main/events_trans.result +++ /dev/null @@ -1,148 +0,0 @@ -set sql_mode=""; -drop database if exists events_test; -drop database if exists mysqltest_no_such_database; -create database events_test; -use events_test; - -Test that Events DDL issue an implicit COMMIT - - -set autocommit=off; -select @@autocommit; -@@autocommit -0 -create table t1 (a varchar(255)) engine=innodb; -begin work; -insert into t1 (a) values ("OK: create event"); -create event e1 on schedule every 1 day do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -rollback work; -select * from t1; -a -OK: create event -delete from t1; -commit work; -begin work; -insert into t1 (a) values ("OK: alter event"); -alter event e1 on schedule every 2 day do select 2; -rollback work; -select * from t1; -a -OK: alter event -delete from t1; -commit work; -begin work; -insert into t1 (a) values ("OK: alter event rename"); -alter event e1 rename to e2; -rollback work; -select * from t1; -a -OK: alter event rename -delete from t1; -commit work; -begin work; -insert into t1 (a) values ("OK: drop event"); -drop event e2; -rollback work; -select * from t1; -a -OK: drop event -delete from t1; -commit work; -begin work; -insert into t1 (a) values ("OK: drop event if exists"); -drop event if exists e2; -Warnings: -Note 1305 Event e2 does not exist -rollback work; -select * from t1; -a -OK: drop event if exists -delete from t1; -commit work; -create event e1 on schedule every 1 day do select 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -begin work; -insert into t1 (a) values ("OK: create event if not exists"); -create event if not exists e1 on schedule every 2 day do select 2; -Warnings: -Note 1537 Event 'e1' already exists -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -rollback work; -select * from t1; -a -OK: create event if not exists -delete from t1; -commit work; - -Now check various error conditions: make sure we issue an -implicit commit anyway - -begin work; -insert into t1 (a) values ("OK: create event: event already exists"); -create event e1 on schedule every 2 day do select 2; -ERROR HY000: Event 'e1' already exists -rollback work; -select * from t1; -a -OK: create event: event already exists -delete from t1; -commit work; -begin work; -insert into t1 (a) values ("OK: alter event rename: rename to same name"); -alter event e1 rename to e1; -ERROR HY000: Same old and new event name -rollback work; -select * from t1; -a -OK: alter event rename: rename to same name -delete from t1; -commit work; -create event e2 on schedule every 3 day do select 3; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -begin work; -insert into t1 (a) values ("OK: alter event rename: destination exists"); -alter event e2 rename to e1; -ERROR HY000: Event 'e1' already exists -rollback work; -select * from t1; -a -OK: alter event rename: destination exists -delete from t1; -commit work; -begin work; -insert into t1 (a) values ("OK: create event: database does not exist"); -create event mysqltest_no_such_database.e1 on schedule every 1 day do select 1; -ERROR 42000: Unknown database 'mysqltest_no_such_database' -rollback work; -select * from t1; -a -OK: create event: database does not exist -delete from t1; -commit work; -drop database events_test; -# -# Bug#54105 assert in MDL_context::release_locks_stored_before -# -USE test; -DROP TABLE IF EXISTS t1, t2; -DROP EVENT IF EXISTS e1; -CREATE TABLE t1 (a INT) ENGINE=InnoDB; -CREATE TABLE t2 (a INT); -CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; -Warnings: -Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. -START TRANSACTION; -INSERT INTO t1 VALUES (1); -SAVEPOINT A; -SHOW CREATE EVENT e1; -Event sql_mode time_zone Create Event character_set_client collation_connection Database Collation -e1 SYSTEM CREATE DEFINER=`root`@`localhost` EVENT `e1` ON SCHEDULE EVERY 1 DAY STARTS '#' ON COMPLETION NOT PRESERVE ENABLE DO SELECT 1 latin1 latin1_swedish_ci latin1_swedish_ci -SELECT * FROM t2; -a -ROLLBACK WORK TO SAVEPOINT A; -DROP TABLE t1, t2; -DROP EVENT e1; diff --git a/mysql-test/main/events_trans.test b/mysql-test/main/events_trans.test deleted file mode 100644 index cc83fa6e578..00000000000 --- a/mysql-test/main/events_trans.test +++ /dev/null @@ -1,152 +0,0 @@ -# -# Tests that require transactions -# --- source include/have_innodb.inc --- source include/not_embedded.inc --- source include/no_view_protocol.inc - -set sql_mode=""; - ---disable_warnings -drop database if exists events_test; -drop database if exists mysqltest_no_such_database; ---enable_warnings -create database events_test; -use events_test; - ---echo ---echo Test that Events DDL issue an implicit COMMIT ---echo ---echo -set autocommit=off; -# Sanity check -select @@autocommit; -create table t1 (a varchar(255)) engine=innodb; -# Basic: check that successful Events DDL commits pending transaction -begin work; -insert into t1 (a) values ("OK: create event"); -create event e1 on schedule every 1 day do select 1; -rollback work; -select * from t1; -delete from t1; -commit work; -# -begin work; -insert into t1 (a) values ("OK: alter event"); -alter event e1 on schedule every 2 day do select 2; -rollback work; -select * from t1; -delete from t1; -commit work; -# -begin work; -insert into t1 (a) values ("OK: alter event rename"); -alter event e1 rename to e2; -rollback work; -select * from t1; -delete from t1; -commit work; -# -begin work; -insert into t1 (a) values ("OK: drop event"); -drop event e2; -rollback work; -select * from t1; -delete from t1; -commit work; -# -begin work; -insert into t1 (a) values ("OK: drop event if exists"); -drop event if exists e2; -rollback work; -select * from t1; -delete from t1; -commit work; -# -create event e1 on schedule every 1 day do select 1; -begin work; -insert into t1 (a) values ("OK: create event if not exists"); -create event if not exists e1 on schedule every 2 day do select 2; -rollback work; -select * from t1; -delete from t1; -commit work; ---echo ---echo Now check various error conditions: make sure we issue an ---echo implicit commit anyway ---echo -# -begin work; -insert into t1 (a) values ("OK: create event: event already exists"); ---error ER_EVENT_ALREADY_EXISTS -create event e1 on schedule every 2 day do select 2; -rollback work; -select * from t1; -delete from t1; -commit work; -# -begin work; -insert into t1 (a) values ("OK: alter event rename: rename to same name"); ---error ER_EVENT_SAME_NAME -alter event e1 rename to e1; -rollback work; -select * from t1; -delete from t1; -commit work; -# -create event e2 on schedule every 3 day do select 3; -begin work; -insert into t1 (a) values ("OK: alter event rename: destination exists"); ---error ER_EVENT_ALREADY_EXISTS -alter event e2 rename to e1; -rollback work; -select * from t1; -delete from t1; -commit work; -# -begin work; -insert into t1 (a) values ("OK: create event: database does not exist"); ---error ER_BAD_DB_ERROR -create event mysqltest_no_such_database.e1 on schedule every 1 day do select 1; -rollback work; -select * from t1; -delete from t1; -commit work; - -# -# Cleanup -# - -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where db='events_test' and command = 'Connect' and user=current_user(); ---source include/wait_condition.inc - -drop database events_test; - - ---echo # ---echo # Bug#54105 assert in MDL_context::release_locks_stored_before ---echo # - -USE test; - ---disable_warnings -DROP TABLE IF EXISTS t1, t2; -DROP EVENT IF EXISTS e1; ---enable_warnings - -CREATE TABLE t1 (a INT) ENGINE=InnoDB; -CREATE TABLE t2 (a INT); -CREATE EVENT e1 ON SCHEDULE EVERY 1 DAY DO SELECT 1; - -START TRANSACTION; -INSERT INTO t1 VALUES (1); -SAVEPOINT A; ---replace_regex /STARTS '[^']+'/STARTS '#'/ -SHOW CREATE EVENT e1; -SELECT * FROM t2; -ROLLBACK WORK TO SAVEPOINT A; - -DROP TABLE t1, t2; -DROP EVENT e1; diff --git a/mysql-test/main/events_trans_notembedded.result b/mysql-test/main/events_trans_notembedded.result deleted file mode 100644 index 324e28ddb62..00000000000 --- a/mysql-test/main/events_trans_notembedded.result +++ /dev/null @@ -1,49 +0,0 @@ -drop database if exists events_test; -drop database if exists mysqltest_db2; -create database events_test; -use events_test; -create user mysqltest_user1@localhost; -grant create, insert, select, delete on mysqltest_db2.* -to mysqltest_user1@localhost; -create database mysqltest_db2; -connect conn1,localhost,mysqltest_user1,,mysqltest_db2; -set autocommit=off; -select @@autocommit; -@@autocommit -0 -create table t1 (a varchar(255)) engine=innodb; -begin work; -insert into t1 (a) values ("OK: create event: insufficient privileges"); -create event e1 on schedule every 1 day do select 1; -ERROR 42000: Access denied for user 'mysqltest_user1'@'localhost' to database 'mysqltest_db2' -rollback work; -select * from t1; -a -OK: create event: insufficient privileges -delete from t1; -commit work; -begin work; -insert into t1 (a) values ("OK: alter event: insufficient privileges"); -alter event e1 on schedule every 1 day do select 1; -ERROR 42000: Access denied for user 'mysqltest_user1'@'localhost' to database 'mysqltest_db2' -rollback work; -select * from t1; -a -OK: alter event: insufficient privileges -delete from t1; -commit work; -begin work; -insert into t1 (a) values ("OK: drop event: insufficient privileges"); -drop event e1; -ERROR 42000: Access denied for user 'mysqltest_user1'@'localhost' to database 'mysqltest_db2' -rollback work; -select * from t1; -a -OK: drop event: insufficient privileges -delete from t1; -commit work; -disconnect conn1; -connection default; -drop user mysqltest_user1@localhost; -drop database mysqltest_db2; -drop database events_test; diff --git a/mysql-test/main/events_trans_notembedded.test b/mysql-test/main/events_trans_notembedded.test deleted file mode 100644 index 3cf823bf713..00000000000 --- a/mysql-test/main/events_trans_notembedded.test +++ /dev/null @@ -1,68 +0,0 @@ -# -# Tests that require transactions -# --- source include/not_embedded.inc --- source include/have_innodb.inc ---disable_warnings -drop database if exists events_test; -drop database if exists mysqltest_db2; ---enable_warnings -create database events_test; -use events_test; - -# -# Privilege checks -# -create user mysqltest_user1@localhost; -grant create, insert, select, delete on mysqltest_db2.* - to mysqltest_user1@localhost; -create database mysqltest_db2; -connect (conn1,localhost,mysqltest_user1,,mysqltest_db2); -set autocommit=off; -# Sanity check -select @@autocommit; -create table t1 (a varchar(255)) engine=innodb; -# Not enough privileges to CREATE EVENT -begin work; -insert into t1 (a) values ("OK: create event: insufficient privileges"); ---error ER_DBACCESS_DENIED_ERROR -create event e1 on schedule every 1 day do select 1; -rollback work; -select * from t1; -delete from t1; -commit work; -# Not enough privileges to ALTER EVENT -begin work; -insert into t1 (a) values ("OK: alter event: insufficient privileges"); ---error ER_DBACCESS_DENIED_ERROR -alter event e1 on schedule every 1 day do select 1; -rollback work; -select * from t1; -delete from t1; -commit work; -# Not enough privileges to DROP EVENT -begin work; -insert into t1 (a) values ("OK: drop event: insufficient privileges"); ---error ER_DBACCESS_DENIED_ERROR -drop event e1; -rollback work; -select * from t1; -delete from t1; -commit work; -# Cleanup -disconnect conn1; ---source include/wait_until_disconnected.inc -connection default; -drop user mysqltest_user1@localhost; -drop database mysqltest_db2; - -# -# Cleanup -# -let $wait_condition= - select count(*) = 0 from information_schema.processlist - where db='events_test' and command = 'Connect' and user=current_user(); ---source include/wait_condition.inc - -drop database events_test; - diff --git a/mysql-test/main/except.result b/mysql-test/main/except.result index ec7d085c70f..e08427d9c65 100644 --- a/mysql-test/main/except.result +++ b/mysql-test/main/except.result @@ -423,8 +423,11 @@ ANALYZE "buffer_type": "flat", "buffer_size": "119", "join_type": "BNL", + "r_loops": 2, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 2 } } ] @@ -471,8 +474,11 @@ ANALYZE "buffer_type": "flat", "buffer_size": "119", "join_type": "BNL", + "r_loops": 2, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 2 } } ] @@ -556,8 +562,11 @@ ANALYZE "buffer_type": "flat", "buffer_size": "119", "join_type": "BNL", + "r_loops": 2, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 2 } } ] @@ -604,8 +613,11 @@ ANALYZE "buffer_type": "flat", "buffer_size": "119", "join_type": "BNL", + "r_loops": 2, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 2 } } ] diff --git a/mysql-test/main/except_all.result b/mysql-test/main/except_all.result index f79f35ee932..ffc9ddb7601 100644 --- a/mysql-test/main/except_all.result +++ b/mysql-test/main/except_all.result @@ -556,8 +556,11 @@ ANALYZE "buffer_type": "flat", "buffer_size": "119", "join_type": "BNL", + "r_loops": 3, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 3 } } ] @@ -604,8 +607,11 @@ ANALYZE "buffer_type": "flat", "buffer_size": "119", "join_type": "BNL", + "r_loops": 2, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 3 } } ] @@ -688,8 +694,11 @@ ANALYZE "buffer_type": "flat", "buffer_size": "119", "join_type": "BNL", + "r_loops": 3, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 3 } } ] @@ -736,8 +745,11 @@ ANALYZE "buffer_type": "flat", "buffer_size": "119", "join_type": "BNL", + "r_loops": 2, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 3 } } ] diff --git a/mysql-test/main/explain_innodb.result b/mysql-test/main/explain_innodb.result index 0bdd5a44985..03052eb3006 100644 --- a/mysql-test/main/explain_innodb.result +++ b/mysql-test/main/explain_innodb.result @@ -18,3 +18,21 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DERIVED t1 range NULL id 53 NULL 1 Using index for group-by SET GLOBAL slow_query_log = @sql_tmp; drop table t1; +# +# MDEV-31181: Server crash in subselect_uniquesubquery_engine::print +# upon EXPLAIN EXTENDED DELETE +# +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (pk INT PRIMARY KEY); +INSERT INTO t2 VALUES (1),(2); +EXPLAIN EXTENDED DELETE FROM t1 WHERE a IN (SELECT pk FROM t2); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where +1 PRIMARY t2 eq_ref PRIMARY PRIMARY 4 test.t1.a 1 100.00 Using index +Warnings: +Note 1003 delete from `test`.`t1` using `test`.`t2` where `test`.`t2`.`pk` = `test`.`t1`.`a` +drop table t1, t2; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/explain_innodb.test b/mysql-test/main/explain_innodb.test index 2c29a6e26da..3dcad4c2d49 100644 --- a/mysql-test/main/explain_innodb.test +++ b/mysql-test/main/explain_innodb.test @@ -18,3 +18,22 @@ SELECT * FROM (SELECT id FROM t1 GROUP BY id) dt WHERE 1=0; SET GLOBAL slow_query_log = @sql_tmp; drop table t1; + + +--echo # +--echo # MDEV-31181: Server crash in subselect_uniquesubquery_engine::print +--echo # upon EXPLAIN EXTENDED DELETE +--echo # + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (pk INT PRIMARY KEY); +INSERT INTO t2 VALUES (1),(2); + +EXPLAIN EXTENDED DELETE FROM t1 WHERE a IN (SELECT pk FROM t2); + +drop table t1, t2; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/main/explain_json.result b/mysql-test/main/explain_json.result index df443003a86..969e069da83 100644 --- a/mysql-test/main/explain_json.result +++ b/mysql-test/main/explain_json.result @@ -2060,8 +2060,11 @@ ANALYZE "buffer_size": "400", "join_type": "BKA", "mrr_type": "Rowid-ordered scan", + "r_loops": 10, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 1 } } ] diff --git a/mysql-test/main/explain_non_select.result b/mysql-test/main/explain_non_select.result index 7dea232f260..e998d8745c1 100644 --- a/mysql-test/main/explain_non_select.result +++ b/mysql-test/main/explain_non_select.result @@ -157,9 +157,13 @@ id select_type table partitions type possible_keys key key_len ref rows Extra explain extended update t2 set b=3 where a in (3,4); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`b` = 3 where `test`.`t2`.`a` in (3,4) explain extended delete from t2 where a in (3,4); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` using dual where `test`.`t2`.`a` in (3,4) drop table t1,t2; # # Check the special case where partition pruning removed all partitions diff --git a/mysql-test/main/merge-big.result b/mysql-test/main/flush_corruption.result index bd188d7a856..bd188d7a856 100644 --- a/mysql-test/main/merge-big.result +++ b/mysql-test/main/flush_corruption.result diff --git a/mysql-test/main/merge-big.test b/mysql-test/main/flush_corruption.test index 5873d2eb233..97ef416307f 100644 --- a/mysql-test/main/merge-big.test +++ b/mysql-test/main/flush_corruption.test @@ -1,5 +1,5 @@ # -# Test of MERGE tables with multisession and many waits. +# Test of MyISAM tables with multisession and many waits. # # This test takes rather long time so let us run it only in --big-test mode --source include/big_test.inc diff --git a/mysql-test/main/func_group.result b/mysql-test/main/func_group.result index de64d01ed4c..37420df6f00 100644 --- a/mysql-test/main/func_group.result +++ b/mysql-test/main/func_group.result @@ -1443,16 +1443,11 @@ FROM derived1 AS X WHERE X.int_nokey < 61 GROUP BY pk -LIMIT 1) +LIMIT 1) AS m FROM D AS X WHERE X.int_key < 13 GROUP BY int_nokey LIMIT 1; -(SELECT COUNT( int_nokey ) -FROM derived1 AS X -WHERE -X.int_nokey < 61 -GROUP BY pk -LIMIT 1) +m 1 DROP TABLE derived1; DROP TABLE D; diff --git a/mysql-test/main/func_group.test b/mysql-test/main/func_group.test index 842ca4388ef..05946908fcf 100644 --- a/mysql-test/main/func_group.test +++ b/mysql-test/main/func_group.test @@ -583,8 +583,6 @@ DROP TABLE t1; # # Bug #16792 query with subselect, join, and group not returning proper values # -#enable after fix MDEV-28573 ---disable_view_protocol CREATE TABLE t1 (a INT, b INT); INSERT INTO t1 VALUES (1,1),(1,2),(2,3); @@ -595,7 +593,6 @@ SELECT AVG(2), BIT_AND(2), BIT_OR(2), BIT_XOR(2), COUNT(*), COUNT(12), COUNT(DISTINCT 12), MIN(2),MAX(2),STD(2), VARIANCE(2),SUM(2), GROUP_CONCAT(2),GROUP_CONCAT(DISTINCT 2); DROP TABLE t1; ---enable_view_protocol # End of 4.1 tests @@ -627,13 +624,10 @@ drop table t1, t2, t3; # # BUG#3190, WL#1639: Standard Deviation STDDEV - 2 different calculations # -#enable after fix MDEV-28573 ---disable_view_protocol CREATE TABLE t1 (id int(11),value1 float(10,2)); INSERT INTO t1 VALUES (1,0.00),(1,1.00), (1,2.00), (2,10.00), (2,11.00), (2,12.00), (2,13.00); select id, stddev_pop(value1), var_pop(value1), stddev_samp(value1), var_samp(value1) from t1 group by id; DROP TABLE t1; ---enable_view_protocol # # BUG#8464 decimal AVG returns incorrect result @@ -970,22 +964,19 @@ INSERT INTO D VALUES (83,45,4,repeat(' X', 42)), (105,53,12,NULL); -#enable after fix MDEV-27871 ---disable_view_protocol SELECT (SELECT COUNT( int_nokey ) FROM derived1 AS X WHERE X.int_nokey < 61 GROUP BY pk - LIMIT 1) + LIMIT 1) AS m FROM D AS X WHERE X.int_key < 13 GROUP BY int_nokey LIMIT 1; DROP TABLE derived1; DROP TABLE D; ---enable_view_protocol # # Bug #39656: Behaviour different for agg functions with & without where - diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result index bdda00e256d..f202de76359 100644 --- a/mysql-test/main/func_json.result +++ b/mysql-test/main/func_json.result @@ -1449,6 +1449,13 @@ JSON_LOOSE(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) [{"range_scan_alternatives": [{"index": "a_b", "ranges": ["2 <= a <= 2 AND 4 <= b <= 4", "123"], "rowid_ordered": true, "using_mrr": false, "index_only": true, "rows": 1, "cost": 1.1752, "chosen": true}], "analyzing_roworder_intersect": {"cause": "too few roworder scans"}, "analyzing_index_merge_union": [], "test_one_line_array": ["123"]}] drop table t200; # +# MDEV-24538: JSON_LENGTH does not return error upon wrong number of parameters +# +SELECT JSON_LENGTH('{"a":"b"}','$','$', 'foo'); +ERROR 42000: Incorrect parameter count in the call to native function 'json_length' +SELECT JSON_LENGTH(); +ERROR 42000: Incorrect parameter count in the call to native function 'JSON_LENGTH' +# # End of 10.4 tests # # @@ -1667,7 +1674,18 @@ DROP TABLE t; # End of 10.6 tests # # -# Beginning of 10.9 tests +# MDEV-31147 json_normalize does not work correctly with MSAN build +# +CREATE TABLE t1 (val JSON); +ALTER TABLE t1 ADD COLUMN normalized_json JSON AS (JSON_NORMALIZE(val)); +INSERT INTO t1 (val) VALUES ('15'); +SELECT * FROM t1; +val normalized_json +15 1.5E1 +DROP TABLE t1; +# +# End of 10.8 tests +# # # MDEV-27677: Implement JSON_OVERLAPS() # diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test index 7fc2f05a57a..120e5085ddb 100644 --- a/mysql-test/main/func_json.test +++ b/mysql-test/main/func_json.test @@ -665,6 +665,7 @@ SELECT 1 + JSON_VALUE('{"nulltest": null}', '$.nulltest'); SELECT NULL; SELECT JSON_EXTRACT('{"a":null, "b":10, "c":"null"}', '$.a'); + --echo # --echo # End of 10.3 tests --echo # @@ -918,6 +919,14 @@ select JSON_LOOSE(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t200 drop table t200; --echo # +--echo # MDEV-24538: JSON_LENGTH does not return error upon wrong number of parameters +--echo # +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +SELECT JSON_LENGTH('{"a":"b"}','$','$', 'foo'); +--error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT +SELECT JSON_LENGTH(); + +--echo # --echo # End of 10.4 tests --echo # @@ -1105,7 +1114,18 @@ DROP TABLE t; --echo # --echo # ---echo # Beginning of 10.9 tests +--echo # MDEV-31147 json_normalize does not work correctly with MSAN build +--echo # +CREATE TABLE t1 (val JSON); +ALTER TABLE t1 ADD COLUMN normalized_json JSON AS (JSON_NORMALIZE(val)); +INSERT INTO t1 (val) VALUES ('15'); +SELECT * FROM t1; +DROP TABLE t1; + +--echo # +--echo # End of 10.8 tests +--echo # + --echo # --echo # MDEV-27677: Implement JSON_OVERLAPS() --echo # diff --git a/mysql-test/main/func_str.result b/mysql-test/main/func_str.result index a477c3c2ec4..149eeebe0bb 100644 --- a/mysql-test/main/func_str.result +++ b/mysql-test/main/func_str.result @@ -5241,6 +5241,15 @@ DROP TABLE t1; # Start of 10.4 tests # # +# MDEV-30351 crash in Item_func_left::val_str +# +SELECT WEIGHT_STRING('aa') IN (LEFT(WEIGHT_STRING('aaa'),4),'bbb') as expect_1; +expect_1 +1 +SELECT UNHEX('0032') in (LEFT(UNHEX('003200'), 2),'dog') as expect_1; +expect_1 +1 +# # MDEV-21841 CONV() function truncates the result type to 21 symbol. # CREATE TABLE t1(i BIGINT); diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test index 1c8839f24a2..377470ca60e 100644 --- a/mysql-test/main/func_str.test +++ b/mysql-test/main/func_str.test @@ -2280,17 +2280,23 @@ CREATE TABLE crash_test_2 ( --echo # Cleanup DROP TABLE t1; - --echo # --echo # End of 10.3 tests --echo # - --echo # --echo # Start of 10.4 tests --echo # --echo # +--echo # MDEV-30351 crash in Item_func_left::val_str +--echo # + +SELECT WEIGHT_STRING('aa') IN (LEFT(WEIGHT_STRING('aaa'),4),'bbb') as expect_1; + +SELECT UNHEX('0032') in (LEFT(UNHEX('003200'), 2),'dog') as expect_1; + +--echo # --echo # MDEV-21841 CONV() function truncates the result type to 21 symbol. --echo # diff --git a/mysql-test/main/grant5.result b/mysql-test/main/grant5.result index 6f50f530a3e..76a5f5375e9 100644 --- a/mysql-test/main/grant5.result +++ b/mysql-test/main/grant5.result @@ -453,4 +453,13 @@ insert mysql.host values (1); flush privileges; ERROR HY000: Fatal error: mysql.host table is damaged or in unsupported 3.20 format drop table mysql.host; +# +# MDEV-30826 Invalid data on mysql.host segfaults the server after an upgrade to 10.4 +# +create table mysql.host (host char(60) binary default '' not null, db char(64) binary default '' not null, select_priv enum('n','y') collate utf8_general_ci default 'n' not null, insert_priv enum('n','y') collate utf8_general_ci default 'n' not null, update_priv enum('n','y') collate utf8_general_ci default 'n' not null, delete_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_priv enum('n','y') collate utf8_general_ci default 'n' not null, drop_priv enum('n','y') collate utf8_general_ci default 'n' not null, grant_priv enum('n','y') collate utf8_general_ci default 'n' not null, references_priv enum('n','y') collate utf8_general_ci default 'n' not null, index_priv enum('n','y') collate utf8_general_ci default 'n' not null, alter_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_tmp_table_priv enum('n','y') collate utf8_general_ci default 'n' not null, lock_tables_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_view_priv enum('n','y') collate utf8_general_ci default 'n' not null, show_view_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_routine_priv enum('n','y') collate utf8_general_ci default 'n' not null, alter_routine_priv enum('n','y') collate utf8_general_ci default 'n' not null, execute_priv enum('n','y') collate utf8_general_ci default 'n' not null, trigger_priv enum('n','y') collate utf8_general_ci default 'n' not null, primary key /*host*/ (host,db)) engine=myisam character set utf8 collate utf8_bin comment='host privileges; merged with database privileges'; +insert mysql.host values('10.5.0.0/255.255.0.0','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N'); +flush privileges; +drop table mysql.host; +# # End of 10.4 tests +# diff --git a/mysql-test/main/grant5.test b/mysql-test/main/grant5.test index c4a302fca86..49e0ab1abf1 100644 --- a/mysql-test/main/grant5.test +++ b/mysql-test/main/grant5.test @@ -408,4 +408,16 @@ insert mysql.host values (1); flush privileges; drop table mysql.host; +--echo # +--echo # MDEV-30826 Invalid data on mysql.host segfaults the server after an upgrade to 10.4 +--echo # + +# from mysql_system_tables.sql in 10.3: +create table mysql.host (host char(60) binary default '' not null, db char(64) binary default '' not null, select_priv enum('n','y') collate utf8_general_ci default 'n' not null, insert_priv enum('n','y') collate utf8_general_ci default 'n' not null, update_priv enum('n','y') collate utf8_general_ci default 'n' not null, delete_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_priv enum('n','y') collate utf8_general_ci default 'n' not null, drop_priv enum('n','y') collate utf8_general_ci default 'n' not null, grant_priv enum('n','y') collate utf8_general_ci default 'n' not null, references_priv enum('n','y') collate utf8_general_ci default 'n' not null, index_priv enum('n','y') collate utf8_general_ci default 'n' not null, alter_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_tmp_table_priv enum('n','y') collate utf8_general_ci default 'n' not null, lock_tables_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_view_priv enum('n','y') collate utf8_general_ci default 'n' not null, show_view_priv enum('n','y') collate utf8_general_ci default 'n' not null, create_routine_priv enum('n','y') collate utf8_general_ci default 'n' not null, alter_routine_priv enum('n','y') collate utf8_general_ci default 'n' not null, execute_priv enum('n','y') collate utf8_general_ci default 'n' not null, trigger_priv enum('n','y') collate utf8_general_ci default 'n' not null, primary key /*host*/ (host,db)) engine=myisam character set utf8 collate utf8_bin comment='host privileges; merged with database privileges'; +insert mysql.host values('10.5.0.0/255.255.0.0','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','N'); +flush privileges; +drop table mysql.host; + +--echo # --echo # End of 10.4 tests +--echo # diff --git a/mysql-test/main/group_by.result b/mysql-test/main/group_by.result index ef5e500c314..79102ffaf61 100644 --- a/mysql-test/main/group_by.result +++ b/mysql-test/main/group_by.result @@ -1037,8 +1037,9 @@ FROM t1 AS t1_outer GROUP BY t1_outer.b; 21 21 SELECT (SELECT SUM(t1_inner.a) FROM t1 AS t1_inner GROUP BY t1_inner.b LIMIT 1) +AS m FROM t1 AS t1_outer; -(SELECT SUM(t1_inner.a) FROM t1 AS t1_inner GROUP BY t1_inner.b LIMIT 1) +m 3 3 3 @@ -1278,12 +1279,9 @@ a select avg ( (select (select sum(outr.a + innr.a) from t1 as innr limit 1) as tt -from t1 as outr order by outr.a limit 1)) +from t1 as outr order by outr.a limit 1)) as m from t1 as most_outer; -avg ( -(select -(select sum(outr.a + innr.a) from t1 as innr limit 1) as tt -from t1 as outr order by outr.a limit 1)) +m 29.0000 select avg ( (select ( diff --git a/mysql-test/main/group_by.test b/mysql-test/main/group_by.test index 3aa7f1cd0d3..6ca80f55ebf 100644 --- a/mysql-test/main/group_by.test +++ b/mysql-test/main/group_by.test @@ -786,11 +786,9 @@ SELECT 1 FROM t1 as t1_outer GROUP BY a SELECT (SELECT SUM(t1_inner.a) FROM t1 AS t1_inner LIMIT 1) FROM t1 AS t1_outer GROUP BY t1_outer.b; -#enable after fix MDEV-27871 ---disable_view_protocol SELECT (SELECT SUM(t1_inner.a) FROM t1 AS t1_inner GROUP BY t1_inner.b LIMIT 1) +AS m FROM t1 AS t1_outer; ---enable_view_protocol --error ER_WRONG_FIELD_WITH_GROUP SELECT (SELECT SUM(t1_outer.a) FROM t1 AS t1_inner LIMIT 1) @@ -866,6 +864,7 @@ DROP TABLE t1; --echo # --echo # Bug#27219: Aggregate functions in ORDER BY. --echo # + SET @save_sql_mode=@@sql_mode; SET @@sql_mode='ONLY_FULL_GROUP_BY'; @@ -887,6 +886,8 @@ SELECT 1 FROM t1 ORDER BY SUM(a) + 1; --error 1140 SELECT 1 FROM t1 ORDER BY SUM(a), b; +--disable_service_connection + --error 1140 SELECT a FROM t1 ORDER BY COUNT(b); @@ -899,9 +900,6 @@ SELECT t1.a FROM t1 ORDER BY (SELECT SUM(t2.a) FROM t2 ORDER BY t2.a); --error 1140 SELECT t1.a FROM t1 ORDER BY (SELECT t2.a FROM t2 ORDER BY SUM(t2.b) LIMIT 1); -#enable after fix MDEV-28570 ---disable_view_protocol - --error 1140 SELECT t1.a FROM t1 WHERE t1.a = (SELECT t2.a FROM t2 ORDER BY SUM(t2.b) LIMIT 1); @@ -939,7 +937,7 @@ SELECT 1 FROM t1 GROUP BY t1.a SELECT 1 FROM t1 GROUP BY t1.a HAVING (SELECT AVG(t1.b + t2.b) FROM t2 ORDER BY t2.a LIMIT 1); ---enable_view_protocol +--enable_service_connection # Both SUMs are aggregated in the subquery, no mixture: SELECT t1.a FROM t1 @@ -964,18 +962,17 @@ SELECT t1.a, SUM(t1.b) FROM t1 ORDER BY SUM(t2.b + t1.a) LIMIT 1) GROUP BY t1.a; -#enable after fix MDEV-28570, MDEV-28571 ---disable_view_protocol - SELECT t1.a FROM t1 GROUP BY t1.a HAVING (1, 1) = (SELECT SUM(t1.a), t1.a FROM t2 LIMIT 1); select avg ( (select (select sum(outr.a + innr.a) from t1 as innr limit 1) as tt - from t1 as outr order by outr.a limit 1)) + from t1 as outr order by outr.a limit 1)) as m from t1 as most_outer; +--disable_service_connection + --error 1140 select avg ( (select ( @@ -983,7 +980,7 @@ select avg ( from t1 as outr order by count(outr.a) limit 1)) as tt from t1 as most_outer; ---enable_view_protocol +--enable_service_connection select (select sum(outr.a + t1.a) from t1 limit 1) as tt from t1 as outr order by outr.a; @@ -1388,7 +1385,7 @@ DROP TABLE t1; --echo # Bug#11765254 (58200): Assertion failed: param.sort_length when grouping --echo # by functions --echo # -#createing view adds one new warning +#creating view adds one new warning --disable_view_protocol set tmp_memory_table_size=0; diff --git a/mysql-test/main/group_min_max.result b/mysql-test/main/group_min_max.result index a227246e7ec..cf4bfd62424 100644 --- a/mysql-test/main/group_min_max.result +++ b/mysql-test/main/group_min_max.result @@ -4117,6 +4117,18 @@ MIN(pk) 1 DROP TABLE t1, t2; # +# MDEV-30605 Wrong result while using index for group-by +# +CREATE TABLE t1 (pk INT primary key, a int, key(a)) engine=innodb; +INSERT INTO t1 VALUES (1,-1),(2,8),(3,5),(4,-1),(5,10), (6,-1); +SELECT MIN(pk), a FROM t1 WHERE pk <> 1 GROUP BY a; +MIN(pk) a +4 -1 +3 5 +2 8 +5 10 +DROP TABLE t1; +# # End of 10.5 tests # # diff --git a/mysql-test/main/group_min_max.test b/mysql-test/main/group_min_max.test index d230cd15749..a1d2988ad4c 100644 --- a/mysql-test/main/group_min_max.test +++ b/mysql-test/main/group_min_max.test @@ -1746,6 +1746,17 @@ SELECT MIN(pk) FROM t1, t2; DROP TABLE t1, t2; --echo # +--echo # MDEV-30605 Wrong result while using index for group-by +--echo # + +CREATE TABLE t1 (pk INT primary key, a int, key(a)) engine=innodb; +INSERT INTO t1 VALUES (1,-1),(2,8),(3,5),(4,-1),(5,10), (6,-1); + +SELECT MIN(pk), a FROM t1 WHERE pk <> 1 GROUP BY a; + +DROP TABLE t1; + +--echo # --echo # End of 10.5 tests --echo # diff --git a/mysql-test/main/insert_innodb.result b/mysql-test/main/insert_innodb.result index 314412bcfdd..b8f3979d2ba 100644 --- a/mysql-test/main/insert_innodb.result +++ b/mysql-test/main/insert_innodb.result @@ -51,7 +51,7 @@ CREATE TEMPORARY TABLE v0 ( v1 TEXT ( 15 ) CHAR SET BINARY NOT NULL NOT NULL UNI ERROR HY000: Field 'v1' doesn't have a default value CREATE TEMPORARY TABLE t1 (i TEXT(15) NOT NULL DEFAULT '' UNIQUE CHECK (i)) engine=innodb REPLACE SELECT NULL AS a; -ERROR HY000: Field 'DB_ROW_HASH_1' doesn't have a default value +ERROR 23000: CONSTRAINT `t1.i` failed for `test`.`t1` # # End of 10.5 tests # diff --git a/mysql-test/main/insert_innodb.test b/mysql-test/main/insert_innodb.test index b5a9fc72c07..56ddb2eafbf 100644 --- a/mysql-test/main/insert_innodb.test +++ b/mysql-test/main/insert_innodb.test @@ -71,7 +71,7 @@ DROP TABLE t2, t1; --error ER_NO_DEFAULT_FOR_FIELD CREATE TEMPORARY TABLE v0 ( v1 TEXT ( 15 ) CHAR SET BINARY NOT NULL NOT NULL UNIQUE CHECK ( v1 ) ) REPLACE SELECT NULL AS v3 , 74 AS v2 ; ---error ER_NO_DEFAULT_FOR_FIELD +--error ER_CONSTRAINT_FAILED CREATE TEMPORARY TABLE t1 (i TEXT(15) NOT NULL DEFAULT '' UNIQUE CHECK (i)) engine=innodb REPLACE SELECT NULL AS a; diff --git a/mysql-test/main/insert_returning.result b/mysql-test/main/insert_returning.result index 1976c1ca02e..b2ed9c90e51 100644 --- a/mysql-test/main/insert_returning.result +++ b/mysql-test/main/insert_returning.result @@ -63,6 +63,8 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN EXTENDED INSERT INTO t1(id1,val1) VALUES(9,'j') RETURNING id1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 INSERT t1 ALL NULL NULL NULL NULL NULL 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t1`(id1,val1) values (9,'j') EXPLAIN FORMAT="json" INSERT INTO t1(id1,val1) VALUES (10,'k') RETURNING id1; EXPLAIN { @@ -151,6 +153,8 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN EXTENDED INSERT INTO t1 VALUES (17,'s'),(18,'t') RETURNING *; id select_type table type possible_keys key key_len ref rows filtered Extra 1 INSERT t1 ALL NULL NULL NULL NULL NULL 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t1` values (17,'s'),(18,'t') EXPLAIN FORMAT="json" INSERT INTO t1 VALUES(19,'u'),(20,'v') RETURNING id1; EXPLAIN { @@ -236,6 +240,8 @@ EXPLAIN EXTENDED INSERT INTO ins_duplicate(id,val) VALUES (2,'b') ON DUPLICATE KEY UPDATE val='i' RETURNING val; id select_type table type possible_keys key key_len ref rows filtered Extra 1 INSERT ins_duplicate ALL NULL NULL NULL NULL NULL 100.00 NULL +Warnings: +Note 1003 insert into `test`.`ins_duplicate`(id,val) values (2,'b') on duplicate key update `test`.`ins_duplicate`.`val` = 'i' EXPLAIN FORMAT="json" INSERT INTO ins_duplicate(id,val) VALUES (2,'b') ON DUPLICATE KEY UPDATE val='j' RETURNING val; EXPLAIN @@ -320,6 +326,8 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN EXTENDED INSERT INTO t1 SET id1=10, val1='j' RETURNING val1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 INSERT t1 ALL NULL NULL NULL NULL NULL 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t1`(id1,val1) values (10,'j') EXPLAIN FORMAT="json" INSERT INTO t1 SET id1=11, val1='k' RETURNING val1; EXPLAIN { @@ -404,6 +412,8 @@ id select_type table type possible_keys key key_len ref rows Extra EXPLAIN EXTENDED INSERT INTO t1 SELECT * FROM t1 WHERE id1=9 RETURNING val1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables +Warnings: +Note 1003 insert into `test`.`t1` select sql_buffer_result NULL AS `id1`,NULL AS `val1` from `test`.`t1` where 0 EXPLAIN FORMAT="json" INSERT INTO t1 SELECT * FROM t1 WHERE id1=10 RETURNING val1; EXPLAIN { diff --git a/mysql-test/main/insert_update.result b/mysql-test/main/insert_update.result index 68a1003ad85..3cbc1944b5e 100644 --- a/mysql-test/main/insert_update.result +++ b/mysql-test/main/insert_update.result @@ -412,3 +412,45 @@ select if( @stamp1 = @stamp2, "correct", "wrong"); if( @stamp1 = @stamp2, "correct", "wrong") correct drop table t1; +# +# MDEV-31164 default current_timestamp() not working when used INSERT ON DUPLICATE KEY in some cases +# +set timestamp=unix_timestamp('2000-10-20 0:0:0'); +create table t1 (pk integer primary key, val varchar(20) not null, ts timestamp +default current_timestamp on update current_timestamp); +insert t1 (pk, val) values(1, 'val1'); +select * from t1; +pk val ts +1 val1 2000-10-20 00:00:00 +set timestamp=unix_timestamp('2000-10-20 1:0:0'); +insert t1 (pk, val) select 2, 'val3' union select 3, 'val4' + on duplicate key update ts=now(); +select * from t1; +pk val ts +1 val1 2000-10-20 00:00:00 +2 val3 2000-10-20 01:00:00 +3 val4 2000-10-20 01:00:00 +set timestamp=unix_timestamp('2000-10-20 2:0:0'); +insert t1 (pk, val) select 1, 'val1' union select 4, 'val2' + on duplicate key update ts=now(); +select * from t1; +pk val ts +1 val1 2000-10-20 02:00:00 +2 val3 2000-10-20 01:00:00 +3 val4 2000-10-20 01:00:00 +4 val2 2000-10-20 02:00:00 +set timestamp=unix_timestamp('2000-10-20 3:0:0'); +insert t1 (pk, val) select 5, 'val1' union select 1, 'val2' + on duplicate key update ts=now(); +select * from t1; +pk val ts +1 val1 2000-10-20 03:00:00 +2 val3 2000-10-20 01:00:00 +3 val4 2000-10-20 01:00:00 +4 val2 2000-10-20 02:00:00 +5 val1 2000-10-20 03:00:00 +drop table t1; +set timestamp=default; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/insert_update.test b/mysql-test/main/insert_update.test index 06e16be84d7..bb56f04c532 100644 --- a/mysql-test/main/insert_update.test +++ b/mysql-test/main/insert_update.test @@ -311,3 +311,30 @@ insert into t1(f1) values(1) on duplicate key update f1=1; select @stamp2:=f2 from t1; select if( @stamp1 = @stamp2, "correct", "wrong"); drop table t1; + +--echo # +--echo # MDEV-31164 default current_timestamp() not working when used INSERT ON DUPLICATE KEY in some cases +--echo # +set timestamp=unix_timestamp('2000-10-20 0:0:0'); +create table t1 (pk integer primary key, val varchar(20) not null, ts timestamp + default current_timestamp on update current_timestamp); +insert t1 (pk, val) values(1, 'val1'); +select * from t1; +set timestamp=unix_timestamp('2000-10-20 1:0:0'); +insert t1 (pk, val) select 2, 'val3' union select 3, 'val4' + on duplicate key update ts=now(); +select * from t1; +set timestamp=unix_timestamp('2000-10-20 2:0:0'); +insert t1 (pk, val) select 1, 'val1' union select 4, 'val2' + on duplicate key update ts=now(); +select * from t1; +set timestamp=unix_timestamp('2000-10-20 3:0:0'); +insert t1 (pk, val) select 5, 'val1' union select 1, 'val2' + on duplicate key update ts=now(); +select * from t1; +drop table t1; +set timestamp=default; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/main/intersect.result b/mysql-test/main/intersect.result index 83a607f4e45..9e1b60ca381 100644 --- a/mysql-test/main/intersect.result +++ b/mysql-test/main/intersect.result @@ -508,8 +508,11 @@ ANALYZE "buffer_type": "flat", "buffer_size": "256Kb", "join_type": "BNL", + "r_loops": 3, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 3 } } ] @@ -618,8 +621,11 @@ ANALYZE "buffer_type": "flat", "buffer_size": "256Kb", "join_type": "BNL", + "r_loops": 3, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 3 } } ] diff --git a/mysql-test/main/intersect_all.result b/mysql-test/main/intersect_all.result index 8f826a193aa..3b1f3f2ac47 100644 --- a/mysql-test/main/intersect_all.result +++ b/mysql-test/main/intersect_all.result @@ -539,8 +539,11 @@ ANALYZE "buffer_type": "flat", "buffer_size": "65", "join_type": "BNL", + "r_loops": 5, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 7 } } ] @@ -649,8 +652,11 @@ ANALYZE "buffer_type": "flat", "buffer_size": "65", "join_type": "BNL", + "r_loops": 5, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 7 } } ] diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result index c02ac192dde..d6a530a9f77 100644 --- a/mysql-test/main/join_cache.result +++ b/mysql-test/main/join_cache.result @@ -5977,10 +5977,9 @@ LEFT JOIN t5 ON t4.e1 = t5.e1 LEFT JOIN (SELECT e1 FROM t2 ) AS d ON t4.e1 = d.e1) a); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 128 Using where -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t4 ALL NULL NULL NULL NULL 128 -2 MATERIALIZED t5 hash_ALL NULL #hash#$hj 5 test.t4.e1 128 Using where; Using join buffer (flat, BNLH join) -2 MATERIALIZED t2 hash_ALL NULL #hash#$hj 5 test.t4.e1 128 Using where; Using join buffer (incremental, BNLH join) +1 PRIMARY t4 hash_ALL NULL #hash#$hj 5 test.t1.i1 128 Using where; Start temporary; Using join buffer (flat, BNLH join) +1 PRIMARY t5 hash_ALL NULL #hash#$hj 5 test.t4.e1 128 Using where; Using join buffer (incremental, BNLH join) +1 PRIMARY t2 hash_ALL NULL #hash#$hj 5 test.t4.e1 128 Using where; End temporary; Using join buffer (incremental, BNLH join) SELECT * FROM t1 WHERE i1 < 10 AND @@ -6035,12 +6034,11 @@ f1 f2 EXPLAIN EXTENDED SELECT * FROM temp WHERE (f1,f2) IN (SELECT t1.i1, t1.v1 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1))); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY temp ALL NULL NULL NULL NULL 7 100.00 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1 100.00 -2 MATERIALIZED t1 ALL NULL NULL NULL NULL 1 100.00 Using where -2 MATERIALIZED t2 hash_index v1 #hash#v1:v1 4:9 test.t1.v1 10 33.33 Using index; Using join buffer (flat, BNLH join) +1 PRIMARY t1 ALL NULL NULL NULL NULL 1 100.00 Using where; Start temporary +1 PRIMARY temp hash_ALL NULL #hash#$hj 9 test.t1.i1,test.t1.v1 7 10.00 Using where; Using join buffer (flat, BNLH join) +1 PRIMARY t2 hash_index v1 #hash#v1:v1 4:9 test.t1.v1 10 10.00 Using index; End temporary; Using join buffer (incremental, BNLH join) 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`.`t2`.`v1` = `test`.`t1`.`v1` +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`.`temp`.`f2` = `test`.`t1`.`v1` and `test`.`t2`.`v1` = `test`.`t1`.`v1` DROP TABLE t1,t2,temp; set join_cache_level=@save_join_cache_level; # @@ -6163,9 +6161,9 @@ b c d e EXPLAIN SELECT * FROM t1 LEFT JOIN ( ( t2 LEFT JOIN t3 ON c = d ) JOIN t4 ) ON b = e; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 -1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t4 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index; Using join buffer (flat, BNL join) +1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t4.e 2 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t3 hash_index d #hash#d:d 5:5 test.t2.c 2 Using where; Using index; Using join buffer (incremental, BNLH join) -1 SIMPLE t4 hash_index PRIMARY #hash#PRIMARY:PRIMARY 4:4 test.t2.b 2 Using index; Using join buffer (incremental, BNLH join) SELECT * FROM t1 LEFT JOIN ( ( t2 LEFT JOIN t3 ON c = d ) JOIN t4 ) ON b = e; a b c d e 1 1 2 2 1 @@ -6176,9 +6174,9 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN ( ( t2 LEFT JOIN t3 ON c = d ) JOIN t4 ) ON b WHERE e IS NULL; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 -1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) +1 SIMPLE t4 index PRIMARY PRIMARY 4 NULL 2 Using where; Using index; Not exists; Using join buffer (flat, BNL join) +1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t4.e 2 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t3 hash_index d #hash#d:d 5:5 test.t2.c 2 Using where; Using index; Using join buffer (incremental, BNLH join) -1 SIMPLE t4 hash_index PRIMARY #hash#PRIMARY:PRIMARY 4:4 test.t2.b 2 Using where; Using index; Not exists; Using join buffer (incremental, BNLH join) SELECT * FROM t1 LEFT JOIN ( ( t2 LEFT JOIN t3 ON c = d ) JOIN t4 ) ON b = e WHERE e IS NULL; a b c d e diff --git a/mysql-test/main/join_cache_cardinality.result b/mysql-test/main/join_cache_cardinality.result new file mode 100644 index 00000000000..de6b99f4b3a --- /dev/null +++ b/mysql-test/main/join_cache_cardinality.result @@ -0,0 +1,105 @@ +create table t1 (a int, b int, c int); +insert into t1 select seq,seq/2, seq/4 from seq_1_to_100; +create table t2 (a int, b int, c int); +insert into t2 select seq, seq/2, seq/4 from seq_1_to_200; +analyze table t1,t2 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +set optimizer_trace=1; +set join_cache_level=6; +set optimizer_switch='hash_join_cardinality=on'; +explain select * +from t1, t2 +where t1.a=t2.a and t1.a=t2.b and t1.c=t2.c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 Using where +1 SIMPLE t2 hash_ALL NULL #hash#$hj 15 test.t1.a,test.t1.a,test.t1.c 200 Using where; Using join buffer (flat, BNLH join) +set @json= (select trace from information_schema.optimizer_trace); +select json_detailed(json_extract(@json, '$**.hash_join_cardinality')) as JS; +JS +[ + { + "hash_join_columns": + [ + { + "field": "a", + "avg_frequency": 1 + }, + { + "field": "b", + "avg_frequency": 2 + }, + { + "field": "c", + "avg_frequency": 3.9216 + } + ], + "rows": 1 + } +] +select json_detailed(json_extract(@json, '$**.rest_of_plan[*].rows_for_plan')) +as ROWS_FOR_PLAN; +ROWS_FOR_PLAN +[100] +explain select * +from t1, t2 where t1.c=t2.c; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 Using where +1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.c 200 Using where; Using join buffer (flat, BNLH join) +set @json= (select trace from information_schema.optimizer_trace); +select json_detailed(json_extract(@json, '$**.hash_join_cardinality')) as JS; +JS +[ + { + "hash_join_columns": + [ + { + "field": "c", + "avg_frequency": 3.9216 + } + ], + "rows": 3.9216 + } +] +select json_detailed(json_extract(@json, '$**.rest_of_plan[*].rows_for_plan')) +as ROWS_FOR_PLAN; +ROWS_FOR_PLAN +[392.16] +explain select * +from t1 straight_join t2 where t1.c=t2.c and t2.a<30; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 100 Using where +1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.c 200 Using where; Using join buffer (flat, BNLH join) +set @json= (select trace from information_schema.optimizer_trace); +# Note that rows is the same: +select json_detailed(json_extract(@json, '$**.hash_join_cardinality')) as JS; +JS +[ + { + "hash_join_columns": + [ + { + "field": "c", + "avg_frequency": 3.9216 + } + ], + "rows": 0.568632 + } +] +# Despite available selectivity: +select json_detailed(json_extract(@json, '$**.selectivity_for_columns')) as JS; +JS +[ + [ + { + "column_name": "a", + "ranges": + ["NULL < a < 30"], + "selectivity_from_histogram": 0.145 + } + ] +] +drop table t1,t2; diff --git a/mysql-test/main/join_cache_cardinality.test b/mysql-test/main/join_cache_cardinality.test new file mode 100644 index 00000000000..b178810b807 --- /dev/null +++ b/mysql-test/main/join_cache_cardinality.test @@ -0,0 +1,41 @@ +--source include/have_sequence.inc + +# Embedded doesn't have optimizer trace: +--source include/not_embedded.inc + +create table t1 (a int, b int, c int); +insert into t1 select seq,seq/2, seq/4 from seq_1_to_100; + +create table t2 (a int, b int, c int); +insert into t2 select seq, seq/2, seq/4 from seq_1_to_200; + +analyze table t1,t2 persistent for all; + +set optimizer_trace=1; +set join_cache_level=6; +set optimizer_switch='hash_join_cardinality=on'; +explain select * +from t1, t2 +where t1.a=t2.a and t1.a=t2.b and t1.c=t2.c; + +set @json= (select trace from information_schema.optimizer_trace); +select json_detailed(json_extract(@json, '$**.hash_join_cardinality')) as JS; +select json_detailed(json_extract(@json, '$**.rest_of_plan[*].rows_for_plan')) +as ROWS_FOR_PLAN; + +explain select * +from t1, t2 where t1.c=t2.c; +set @json= (select trace from information_schema.optimizer_trace); +select json_detailed(json_extract(@json, '$**.hash_join_cardinality')) as JS; +select json_detailed(json_extract(@json, '$**.rest_of_plan[*].rows_for_plan')) +as ROWS_FOR_PLAN; + +explain select * +from t1 straight_join t2 where t1.c=t2.c and t2.a<30; +set @json= (select trace from information_schema.optimizer_trace); +--echo # Note that rows is the same: +select json_detailed(json_extract(@json, '$**.hash_join_cardinality')) as JS; + +--echo # Despite available selectivity: +select json_detailed(json_extract(@json, '$**.selectivity_for_columns')) as JS; +drop table t1,t2; diff --git a/mysql-test/main/join_nested_jcl6.result b/mysql-test/main/join_nested_jcl6.result index d5c46d48e68..3c292484c9e 100644 --- a/mysql-test/main/join_nested_jcl6.result +++ b/mysql-test/main/join_nested_jcl6.result @@ -61,8 +61,8 @@ LEFT JOIN ON t2.b=t4.b; a b a b a b 4 2 1 2 3 2 -4 2 2 2 3 2 4 2 1 2 4 2 +4 2 2 2 3 2 4 2 2 2 4 2 3 3 NULL NULL NULL NULL 5 3 NULL NULL NULL NULL @@ -85,8 +85,8 @@ ON t2.b=t4.b WHERE t3.a=1 OR t3.c IS NULL; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 -1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 10.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`b` is not null) where `test`.`t3`.`a` = 1 or `test`.`t3`.`c` is null SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b @@ -139,16 +139,16 @@ LEFT JOIN ON t2.b=t4.b; a b a b a b a b 4 2 1 2 3 2 3 1 -4 2 2 2 3 2 3 1 4 2 1 2 4 2 3 1 +4 2 2 2 3 2 3 1 4 2 2 2 4 2 3 1 4 2 1 2 3 2 2 2 -4 2 2 2 3 2 2 2 4 2 1 2 4 2 2 2 +4 2 2 2 3 2 2 2 4 2 2 2 4 2 2 2 4 2 1 2 3 2 3 3 -4 2 2 2 3 2 3 3 4 2 1 2 4 2 3 3 +4 2 2 2 3 2 3 3 4 2 2 2 4 2 3 3 3 3 NULL NULL NULL NULL NULL NULL 5 3 NULL NULL NULL NULL NULL NULL @@ -161,8 +161,8 @@ ON t2.b=t4.b WHERE t3.a>1 OR t3.c IS NULL; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 -1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 10.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join) Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on(`test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`b` is not null) where `test`.`t3`.`a` > 1 or `test`.`t3`.`c` is null @@ -191,8 +191,8 @@ WHERE (t3.a>1 OR t3.c IS NULL) AND (t5.a<3 OR t5.c IS NULL); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 -1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 10.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) Warnings: Note 1003 select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b` from `test`.`t2` left join (`test`.`t3` join `test`.`t4` join `test`.`t5`) on(`test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`b` is not null) where (`test`.`t3`.`a` > 1 or `test`.`t3`.`c` is null) and (`test`.`t5`.`a` < 3 or `test`.`t5`.`c` is null) @@ -242,7 +242,7 @@ ON t7.b=t8.b AND t6.b < 10; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t7 ALL NULL NULL NULL NULL 2 100.00 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join) -1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t7.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t7.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) Warnings: Note 1003 select `test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t7`.`b` and `test`.`t6`.`b` < 10 and `test`.`t7`.`b` is not null) where 1 SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b @@ -556,14 +556,14 @@ t0.b=t1.b AND (t2.a >= 4 OR t2.c IS NULL); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where -1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 10.00 Using where; Using join buffer (flat, BNLH join) 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (incremental, BNL join) -1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) Warnings: Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, @@ -651,17 +651,17 @@ t0.b=t1.b AND (t9.a=1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where -1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 10.00 Using where; Using join buffer (flat, BNLH join) 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t4`.`b` = `test`.`t3`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t9`.`b` = `test`.`t8`.`b` or `test`.`t8`.`c` is null) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t3`.`b` = `test`.`t4`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t9`.`b` = `test`.`t8`.`b` or `test`.`t8`.`c` is null) SELECT t9.a,t9.b FROM t9; a b @@ -849,8 +849,8 @@ WHERE t1.a <= 2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 Using join buffer (flat, BNL join) +1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b` from `test`.`t1` join `test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`b` is not null) where `test`.`t1`.`a` <= 2 INSERT INTO t2 VALUES (-1,9,0), (-3,10,0), (-2,8,0), (-4,11,0), (-5,15,0); @@ -919,17 +919,17 @@ t0.b=t1.b AND (t9.a=1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where -1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 10.00 Using where; Using join buffer (flat, BNLH join) 1 SIMPLE t5 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join) +1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t2.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) Warnings: -Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`a` > 0 and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t4`.`b` = `test`.`t3`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t9`.`b` = `test`.`t8`.`b` or `test`.`t8`.`c` is null) +Note 1003 select `test`.`t0`.`a` AS `a`,`test`.`t0`.`b` AS `b`,`test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b`,`test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`a` AS `a`,`test`.`t4`.`b` AS `b`,`test`.`t5`.`a` AS `a`,`test`.`t5`.`b` AS `b`,`test`.`t6`.`a` AS `a`,`test`.`t6`.`b` AS `b`,`test`.`t7`.`a` AS `a`,`test`.`t7`.`b` AS `b`,`test`.`t8`.`a` AS `a`,`test`.`t8`.`b` AS `b`,`test`.`t9`.`a` AS `a`,`test`.`t9`.`b` AS `b` from `test`.`t0` join `test`.`t1` left join (`test`.`t2` left join (`test`.`t3` join `test`.`t4`) on(`test`.`t3`.`a` = 1 and `test`.`t4`.`b` = `test`.`t2`.`b` and `test`.`t2`.`a` > 0 and `test`.`t2`.`b` is not null) join `test`.`t5` left join (`test`.`t6` join `test`.`t7` left join `test`.`t8` on(`test`.`t8`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` < 10 and `test`.`t5`.`b` is not null)) on(`test`.`t7`.`b` = `test`.`t5`.`b` and `test`.`t6`.`b` >= 2 and `test`.`t5`.`b` is not null)) on((`test`.`t3`.`b` = 2 or `test`.`t3`.`c` is null) and (`test`.`t6`.`b` = 2 or `test`.`t6`.`c` is null) and (`test`.`t5`.`b` = `test`.`t0`.`b` or `test`.`t3`.`c` is null or `test`.`t6`.`c` is null or `test`.`t8`.`c` is null) and `test`.`t1`.`a` <> 2) join `test`.`t9` where `test`.`t0`.`a` = 1 and `test`.`t1`.`b` = `test`.`t0`.`b` and `test`.`t9`.`a` = 1 and (`test`.`t2`.`a` >= 4 or `test`.`t2`.`c` is null) and (`test`.`t3`.`a` < 5 or `test`.`t3`.`c` is null) and (`test`.`t3`.`b` = `test`.`t4`.`b` or `test`.`t3`.`c` is null or `test`.`t4`.`c` is null) and (`test`.`t5`.`a` >= 2 or `test`.`t5`.`c` is null) and (`test`.`t6`.`a` >= 4 or `test`.`t6`.`c` is null) and (`test`.`t7`.`a` <= 2 or `test`.`t7`.`c` is null) and (`test`.`t8`.`a` < 1 or `test`.`t8`.`c` is null) and (`test`.`t9`.`b` = `test`.`t8`.`b` or `test`.`t8`.`c` is null) INSERT INTO t4 VALUES (-3,12,0), (-4,13,0), (-1,11,0), (-3,11,0), (-5,15,0); INSERT INTO t5 VALUES (-3,11,0), (-2,12,0), (-3,13,0), (-4,12,0); CREATE INDEX idx_b ON t4(b); @@ -971,12 +971,12 @@ t0.b=t1.b AND (t9.a=1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where -1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 10.00 Using where; Using join buffer (flat, BNLH join) 1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t8 hash_ALL NULL #hash#$hj 5 test.t5.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t4 ref idx_b idx_b 5 test.t2.b 1 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t3 ALL NULL NULL NULL NULL 2 100.00 Using where; Using join buffer (incremental, BNL join) @@ -1021,10 +1021,10 @@ t0.b=t1.b AND (t9.a=1); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t0 ALL NULL NULL NULL NULL 3 100.00 Using where -1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 100.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t1 hash_ALL NULL #hash#$hj 5 test.t0.b 3 10.00 Using where; Using join buffer (flat, BNLH join) 1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 1 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join) @@ -1075,7 +1075,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ref idx_b idx_b 5 test.t0.b 1 100.00 Using join buffer (flat, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t9 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t5 ALL idx_b NULL NULL NULL 7 100.00 Using where; Using join buffer (incremental, BNL join) -1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t7 hash_ALL NULL #hash#$hj 5 test.t5.b 2 10.00 Using where; Using join buffer (incremental, BNLH join) 1 SIMPLE t6 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (incremental, BNL join) 1 SIMPLE t8 ref idx_b idx_b 5 test.t5.b 1 100.00 Using where; Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan 1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where; Using join buffer (incremental, BNL join) @@ -1848,8 +1848,8 @@ ON t1.a=t2.a WHERE t3.a IS NULL; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 -1 SIMPLE t2 hash_ALL NULL #hash#$hj 4 test.t1.a 1 100.00 Using where; Using join buffer (flat, BNLH join) -1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1 100.00 Using where; Not exists; Using join buffer (incremental, BNLH join) +1 SIMPLE t2 hash_ALL NULL #hash#$hj 4 test.t1.a 1 10.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1 10.00 Using where; Not exists; Using join buffer (incremental, BNLH join) 1 SIMPLE t4 hash_ALL NULL #hash#$hj 5 test.t3.a 0 0.00 Using where; Using join buffer (incremental, BNLH join) Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t4`.`b` AS `b` from `test`.`t1` left join (`test`.`t2` left join `test`.`t3` on(`test`.`t3`.`b` = `test`.`t1`.`a`) left join `test`.`t4` on(`test`.`t4`.`b` = `test`.`t3`.`a` and `test`.`t3`.`a` is not null)) on(`test`.`t2`.`a` = `test`.`t1`.`a`) where `test`.`t3`.`a` is null diff --git a/mysql-test/main/join_outer_jcl6.result b/mysql-test/main/join_outer_jcl6.result index ff5e76b78ad..a34bf96a0ef 100644 --- a/mysql-test/main/join_outer_jcl6.result +++ b/mysql-test/main/join_outer_jcl6.result @@ -2230,8 +2230,8 @@ SELECT * FROM t1 LEFT JOIN t2 LEFT JOIN t3 ON i2 = i3 ON i1 = i3 WHERE d3 IS NULL; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 -1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.i1 2 100.00 Using where; Using join buffer (flat, BNLH join) -1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.i1 2 100.00 Using where; Using join buffer (incremental, BNLH join) +1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.i1 2 10.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.i1 2 10.00 Using where; Using join buffer (incremental, BNLH join) Warnings: Note 1003 select `test`.`t1`.`i1` AS `i1`,`test`.`t2`.`i2` AS `i2`,`test`.`t3`.`i3` AS `i3`,`test`.`t3`.`d3` AS `d3` from `test`.`t1` left join (`test`.`t2` join `test`.`t3`) on(`test`.`t2`.`i2` = `test`.`t1`.`i1` and `test`.`t3`.`i3` = `test`.`t1`.`i1` and `test`.`t1`.`i1` is not null and `test`.`t1`.`i1` is not null) where `test`.`t3`.`d3` = 0 or `test`.`t3`.`d3` is null DROP TABLE t1,t2,t3; @@ -2251,7 +2251,7 @@ WHERE b IN (1,2,3) OR b = d; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where -1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 const 2 100.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 const 2 10.00 Using where; Using join buffer (flat, BNLH join) Warnings: Note 1003 select 10 AS `a`,8 AS `b`,`test`.`t2`.`c` AS `c`,`test`.`t3`.`d` AS `d` from `test`.`t2` left join `test`.`t3` on(`test`.`t3`.`d` = 10 and 10 is not null) where `test`.`t2`.`c` = 8 and `test`.`t3`.`d` = 8 SELECT * FROM t1 INNER JOIN t2 ON c = b LEFT JOIN t3 ON d = a @@ -2368,7 +2368,7 @@ ON t1.x = t2.x WHERE IFNULL(t2.x,0)=0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 -1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.x 2 100.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.x 2 10.00 Using where; Using join buffer (flat, BNLH join) Warnings: Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t2`.`x` AS `x`,ifnull(`test`.`t2`.`x`,0) AS `IFNULL(t2.x,0)`,`f`(`test`.`t2`.`x`,0) AS `f(t2.x,0)` from `test`.`t` `t1` left join `test`.`t` `t2` on(`test`.`t2`.`x` = `test`.`t1`.`x` and `test`.`t1`.`x` is not null) where ifnull(`test`.`t2`.`x`,0) = 0 SELECT t1.x, t2.x, IFNULL(t2.x,0), f(t2.x,0) @@ -2384,7 +2384,7 @@ ON t1.x = t2.x WHERE f(t2.x,0)=0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 -1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.x 2 100.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.x 2 10.00 Using where; Using join buffer (flat, BNLH join) Warnings: Note 1003 select `test`.`t1`.`x` AS `x`,`test`.`t2`.`x` AS `x`,ifnull(`test`.`t2`.`x`,0) AS `IFNULL(t2.x,0)`,`f`(`test`.`t2`.`x`,0) AS `f(t2.x,0)` from `test`.`t` `t1` left join `test`.`t` `t2` on(`test`.`t2`.`x` = `test`.`t1`.`x` and `test`.`t1`.`x` is not null) where `f`(`test`.`t2`.`x`,0) = 0 drop function f; @@ -2424,7 +2424,7 @@ FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2 WHERE IFNULL(t2.col3,0) = 0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 -1 SIMPLE t2 hash_ALL NULL #hash#$hj 17 test.t1.col1 2 100.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL NULL #hash#$hj 17 test.t1.col1 2 10.00 Using where; Using join buffer (flat, BNLH join) Warnings: Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`col2` = `test`.`t1`.`col1` and `test`.`t1`.`col1` is not null) where ifnull(`test`.`t2`.`col3`,0) = 0 SELECT t1.col1, t2.col1, t2.col3 @@ -2438,7 +2438,7 @@ FROM t1 LEFT OUTER JOIN t2 ON t1.col1 = t2.col2 WHERE f1(t2.col3,0) = 0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 -1 SIMPLE t2 hash_ALL NULL #hash#$hj 17 test.t1.col1 2 100.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL NULL #hash#$hj 17 test.t1.col1 2 10.00 Using where; Using join buffer (flat, BNLH join) Warnings: Note 1003 select `test`.`t1`.`col1` AS `col1`,`test`.`t2`.`col1` AS `col1`,`test`.`t2`.`col3` AS `col3` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`col2` = `test`.`t1`.`col1` and `test`.`t1`.`col1` is not null) where `f1`(`test`.`t2`.`col3`,0) = 0 DROP FUNCTION f1; @@ -2542,7 +2542,7 @@ a b explain extended select * from t1 left join t2 on a=b where (b > 3) is not true; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 -1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.a 3 100.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.a 3 10.00 Using where; Using join buffer (flat, BNLH join) Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`b` = `test`.`t1`.`a` and `test`.`t1`.`a` is not null) where `test`.`t2`.`b` > 3 is not true select * from t1 left join t2 on a=b where (b > 3) is not false; @@ -2552,7 +2552,7 @@ a b explain extended select * from t1 left join t2 on a=b where (b > 3) is not false; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 -1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.a 3 100.00 Using where; Using join buffer (flat, BNLH join) +1 SIMPLE t2 hash_ALL NULL #hash#$hj 5 test.t1.a 3 10.00 Using where; Using join buffer (flat, BNLH join) Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t1` left join `test`.`t2` on(`test`.`t2`.`b` = `test`.`t1`.`a` and `test`.`t1`.`a` is not null) where `test`.`t2`.`b` > 3 is not false drop table t1,t2; @@ -2783,8 +2783,8 @@ id select_type table type possible_keys key key_len ref rows Extra explain select * from t1 left join (t3 join t2) on t1.a=t3.b and t3.a<5; id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 -1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) -1 SIMPLE t3 hash_range a #hash#$hj:a 5:5 test.t1.a 5 Using where; Rowid-ordered scan; Using join buffer (incremental, BNLH join) +1 SIMPLE t3 hash_range a #hash#$hj:a 5:5 test.t1.a 5 Using where; Rowid-ordered scan; Using join buffer (flat, BNLH join) +1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join) # # .. part 2: make sure condition selectivity can use the condition too. # diff --git a/mysql-test/main/kill-2.result b/mysql-test/main/kill-2.result index daaba2c092a..0f9d069aacc 100644 --- a/mysql-test/main/kill-2.result +++ b/mysql-test/main/kill-2.result @@ -10,3 +10,34 @@ foo root kill user foo@'127.0.0.1'; drop user foo@'127.0.0.1'; +# +# KILL USER and missing privileges +# +create user a@'127.0.0.1'; +create user b@'127.0.0.1'; +grant process on *.* to a@'127.0.0.1'; +grant select on *.* to b@'127.0.0.1'; +connect a,127.0.0.1,a; +show grants; +Grants for a@127.0.0.1 +GRANT PROCESS ON *.* TO `a`@`127.0.0.1` +connect b,127.0.0.1,b; +show processlist; +Id User Host db Command Time State Info Progress +# b # test # # starting show processlist # +kill user a; +kill user x; +connection a; +show processlist; +Id User Host db Command Time State Info Progress +# root # test # # # # # +# a # NULL # # # # # +# b # test # # # # # +kill user b; +ERROR HY000: Operation KILL USER failed for b@% +connection default; +drop user a@'127.0.0.1'; +drop user b@'127.0.0.1'; +# +# End of 10.3 tests +# diff --git a/mysql-test/main/kill-2.test b/mysql-test/main/kill-2.test index 6d40e14a700..9bc4fe03346 100644 --- a/mysql-test/main/kill-2.test +++ b/mysql-test/main/kill-2.test @@ -27,3 +27,30 @@ let $wait_condition= --source include/wait_condition.inc drop user foo@'127.0.0.1'; --enable_service_connection + +--echo # +--echo # KILL USER and missing privileges +--echo # +create user a@'127.0.0.1'; +create user b@'127.0.0.1'; +grant process on *.* to a@'127.0.0.1'; +grant select on *.* to b@'127.0.0.1'; +--connect a,127.0.0.1,a +show grants; +--connect b,127.0.0.1,b +--replace_column 1 # 3 # 5 # 6 # 9 # +show processlist; +kill user a; # existing connection, but not visible to current_user +kill user x; # not existing connection +--connection a +--replace_column 1 # 3 # 5 # 6 # 7 # 8 # 9 # +show processlist; +--error ER_KILL_DENIED_ERROR +kill user b; +--connection default +drop user a@'127.0.0.1'; +drop user b@'127.0.0.1'; + +--echo # +--echo # End of 10.3 tests +--echo # diff --git a/mysql-test/main/locale.result b/mysql-test/main/locale.result index 39f11053df6..b1d41709a9d 100644 --- a/mysql-test/main/locale.result +++ b/mysql-test/main/locale.result @@ -307,6 +307,16 @@ select date_format('2001-09-01', '%c %b %M', 'de_CH'); date_format('2001-09-01', '%c %b %M', 'de_CH') 9 Sep September # +# MDEV-30630 locale: Chinese error message for ZH_CN +# +SET lc_messages=ZH_CN; +SELECT x; +ERROR 42S22: 未知列'x'在'field list' +SET lc_messages=DEFAULT; +# +# End of 10.4 tests +# +# # MDEV-30789 Add Georgian error messages and locale # SET lc_messages=ka_GE; @@ -314,5 +324,47 @@ SELECT x; ERROR 42S22: უცნáƒáƒ‘ი სვეტი 'x' 'field list'-ში SET lc_messages=DEFAULT; # +# MDEV-30997 SIGSEGV in __strlen_avx2 | make_date_time | Item_func_date_format::val_str +# +SET lc_messages=en_US; +SET lc_time_names=111; +SELECT DATE_FORMAT('1-12-01','%c %b %M'); +DATE_FORMAT('1-12-01','%c %b %M') +12 დეკ დეკემბერი +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12); +SELECT d, DATE_FORMAT(d, '%b') AS MONTH_ABBR, MONTHNAME(d) FROM +( +SELECT CAST(CONCAT('2001-', i, '-01') AS DATE) AS d FROM t1 +) d1 ORDER BY d; +d MONTH_ABBR MONTHNAME(d) +2001-01-01 იáƒáƒœ იáƒáƒœáƒ•áƒáƒ ი +2001-02-01 თებ თებერვáƒáƒšáƒ˜ +2001-03-01 მáƒáƒ მáƒáƒ ტი +2001-04-01 áƒáƒžáƒ áƒáƒžáƒ ილი +2001-05-01 მáƒáƒ˜ მáƒáƒ˜áƒ¡áƒ˜ +2001-06-01 ივნ ივნისი +2001-07-01 ივლ ივლისი +2001-08-01 áƒáƒ’ვ áƒáƒ’ვისტრ+2001-09-01 სექტ სექტემბერი +2001-10-01 áƒáƒ¥áƒ¢ áƒáƒ¥áƒ¢áƒáƒ›áƒ‘ერი +2001-11-01 ნáƒáƒ” ნáƒáƒ”მბერი +2001-12-01 დეკ დეკემბერი +SELECT d, WEEKDAY(d), DATE_FORMAT(d, '%a') AS DAY_ABBR, DAYNAME(d) FROM +( +SELECT CAST(CONCAT('2001-01-', i) AS DATE) AS d FROM t1 WHERE i BETWEEN 1 AND 7 +) d1 ORDER BY d; +d WEEKDAY(d) DAY_ABBR DAYNAME(d) +2001-01-01 0 áƒáƒ შ áƒáƒ შáƒáƒ‘áƒáƒ—ი +2001-01-02 1 სáƒáƒ›áƒ¨ სáƒáƒ›áƒ¨áƒáƒ‘áƒáƒ—ი +2001-01-03 2 áƒáƒ—ხშ áƒáƒ—ხშáƒáƒ‘áƒáƒ—ი +2001-01-04 3 ხუთშ ხუთშáƒáƒ‘áƒáƒ—ი +2001-01-05 4 პáƒáƒ პáƒáƒ áƒáƒ¡áƒ™áƒ”ვი +2001-01-06 5 შáƒáƒ‘ შáƒáƒ‘áƒáƒ—ი +2001-01-07 6 კვ კვირრ+DROP TABLE t1; +SET lc_time_names=DEFAULT; +SET lc_messages=DEFAULT; +# # End of 10.11 tests # diff --git a/mysql-test/main/locale.test b/mysql-test/main/locale.test index 9f4ceb270d9..c99f2cb3865 100644 --- a/mysql-test/main/locale.test +++ b/mysql-test/main/locale.test @@ -182,6 +182,20 @@ select date_format('2001-12-01', '%c %b %M', 'rm_CH'); select date_format('2001-01-06', '%w %a %W', 'de_CH'); select date_format('2001-09-01', '%c %b %M', 'de_CH'); +--echo # +--echo # MDEV-30630 locale: Chinese error message for ZH_CN +--echo # + +SET lc_messages=ZH_CN; +--error ER_BAD_FIELD_ERROR +SELECT x; + +SET lc_messages=DEFAULT; + +--echo # +--echo # End of 10.4 tests +--echo # + --echo # --echo # MDEV-30789 Add Georgian error messages and locale @@ -193,6 +207,32 @@ SELECT x; SET lc_messages=DEFAULT; + +--echo # +--echo # MDEV-30997 SIGSEGV in __strlen_avx2 | make_date_time | Item_func_date_format::val_str +--echo # + +SET lc_messages=en_US; +SET lc_time_names=111; +SELECT DATE_FORMAT('1-12-01','%c %b %M'); +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11),(12); +SELECT d, DATE_FORMAT(d, '%b') AS MONTH_ABBR, MONTHNAME(d) FROM +( + SELECT CAST(CONCAT('2001-', i, '-01') AS DATE) AS d FROM t1 +) d1 ORDER BY d; + +SELECT d, WEEKDAY(d), DATE_FORMAT(d, '%a') AS DAY_ABBR, DAYNAME(d) FROM +( + SELECT CAST(CONCAT('2001-01-', i) AS DATE) AS d FROM t1 WHERE i BETWEEN 1 AND 7 +) d1 ORDER BY d; + + +DROP TABLE t1; +SET lc_time_names=DEFAULT; +SET lc_messages=DEFAULT; + + --echo # --echo # End of 10.11 tests --echo # diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result index 283ea870a5f..ed13c668ec3 100644 --- a/mysql-test/main/long_unique_bugs.result +++ b/mysql-test/main/long_unique_bugs.result @@ -451,6 +451,12 @@ a b 1 xxx drop table t1; # +# MDEV-22756 SQL Error (1364): Field 'DB_ROW_HASH_1' doesn't have a default value +# +create table t1 (f text not null, unique (f)); +insert into t1 (f) select 'f'; +drop table t1; +# # End of 10.4 tests # # diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test index 27bb402bd8b..6fc29e1d2dd 100644 --- a/mysql-test/main/long_unique_bugs.test +++ b/mysql-test/main/long_unique_bugs.test @@ -444,6 +444,13 @@ select * from t1; drop table t1; --echo # +--echo # MDEV-22756 SQL Error (1364): Field 'DB_ROW_HASH_1' doesn't have a default value +--echo # +create table t1 (f text not null, unique (f)); +insert into t1 (f) select 'f'; +drop table t1; + +--echo # --echo # End of 10.4 tests --echo # diff --git a/mysql-test/main/merge.result b/mysql-test/main/merge.result deleted file mode 100644 index 7144fd1d349..00000000000 --- a/mysql-test/main/merge.result +++ /dev/null @@ -1,3975 +0,0 @@ -set @save_default_storage_engine=@@global.default_storage_engine; -set global default_storage_engine=myisam; -set session default_storage_engine=myisam; -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"); -INSERT INTO t2 (message) VALUES ("Testing"),("table"),("t2"); -create table t3 (a int not null, b char(20), key(a)) engine=MERGE UNION=(t1,t2); -select * from t3; -a b -1 Testing -2 table -3 t1 -1 Testing -2 table -3 t2 -select * from t3 order by a desc; -a b -3 t1 -3 t2 -2 table -2 table -1 Testing -1 Testing -drop table t3; -insert into t1 select NULL,message from t2; -insert into t2 select NULL,message from t1; -insert into t1 select NULL,message from t2; -insert into t2 select NULL,message from t1; -insert into t1 select NULL,message from t2; -insert into t2 select NULL,message from t1; -insert into t1 select NULL,message from t2; -insert into t2 select NULL,message from t1; -insert into t1 select NULL,message from t2; -insert into t2 select NULL,message from t1; -insert into t1 select NULL,message from t2; -create table t3 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,test.t2); -explain select * from t3 where a < 10; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range a a 4 NULL 17 Using where -explain select * from t3 where a > 10 and a < 20; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 range a a 4 NULL 17 Using where -select * from t3 where a = 10; -a b -10 Testing -10 Testing -select * from t3 where a < 10; -a b -1 Testing -1 Testing -2 table -2 table -3 t1 -3 t2 -4 Testing -4 Testing -5 table -5 table -6 t2 -6 t1 -7 Testing -7 Testing -8 table -8 table -9 t2 -9 t2 -select * from t3 where a > 10 and a < 20; -a b -11 table -11 table -12 t1 -12 t1 -13 Testing -13 Testing -14 table -14 table -15 t2 -15 t2 -16 Testing -16 Testing -17 table -17 table -18 t2 -18 t2 -19 Testing -19 Testing -explain select a from t3 order by a desc limit 10; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 index NULL a 4 NULL 10 Using index -select a from t3 order by a desc limit 10; -a -699 -698 -697 -696 -695 -694 -693 -692 -691 -690 -select a from t3 order by a desc limit 300,10; -a -416 -415 -415 -414 -414 -413 -413 -412 -412 -411 -delete from t3 where a=3; -select * from t3 where a < 10; -a b -1 Testing -1 Testing -2 table -2 table -4 Testing -4 Testing -5 table -5 table -6 t2 -6 t1 -7 Testing -7 Testing -8 table -8 table -9 t2 -9 t2 -delete from t3 where a >= 6 and a <= 8; -select * from t3 where a < 10; -a b -1 Testing -1 Testing -2 table -2 table -4 Testing -4 Testing -5 table -5 table -9 t2 -9 t2 -update t3 set a=3 where a=9; -select * from t3 where a < 10; -a b -1 Testing -1 Testing -2 table -2 table -3 t2 -3 t2 -4 Testing -4 Testing -5 table -5 table -update t3 set a=6 where a=7; -select * from t3 where a < 10; -a b -1 Testing -1 Testing -2 table -2 table -3 t2 -3 t2 -4 Testing -4 Testing -5 table -5 table -show create table t3; -Table Create Table -t3 CREATE TABLE `t3` ( - `a` int(11) NOT NULL, - `b` char(20) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci UNION=(`t1`,`t2`) -create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2); -select * from t4; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -alter table t4 add column c int; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -flush tables; -select * from t4; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -create database mysqltest; -create table mysqltest.t6 (a int not null primary key auto_increment, message char(20)); -create table t5 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,mysqltest.t6); -show create table t5; -Table Create Table -t5 CREATE TABLE `t5` ( - `a` int(11) NOT NULL, - `b` char(20) DEFAULT NULL, - KEY `a` (`a`) -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci UNION=(`t1`,`mysqltest`.`t6`) -alter table t5 engine=myisam; -drop table t5, mysqltest.t6; -drop database mysqltest; -drop table t4,t3,t1,t2; -create table t1 (c char(10)) engine=myisam; -create table t2 (c char(10)) engine=myisam; -create table t3 (c char(10)) union=(t1,t2) engine=merge; -insert into t1 (c) values ('test1'); -insert into t1 (c) values ('test1'); -insert into t1 (c) values ('test1'); -insert into t2 (c) values ('test2'); -insert into t2 (c) values ('test2'); -insert into t2 (c) values ('test2'); -select * from t3; -c -test1 -test1 -test1 -test2 -test2 -test2 -select * from t3; -c -test1 -test1 -test1 -test2 -test2 -test2 -delete from t3 where 1=1; -select * from t3; -c -select * from t1; -c -drop table t3,t2,t1; -CREATE TABLE t1 (incr int not null, othr int not null, primary key(incr)); -CREATE TABLE t2 (incr int not null, othr int not null, primary key(incr)); -CREATE TABLE t3 (incr int not null, othr int not null, primary key(incr)) -ENGINE=MERGE UNION=(t1,t2); -SELECT * from t3; -incr othr -INSERT INTO t1 VALUES ( 1,10),( 3,53),( 5,21),( 7,12),( 9,17); -INSERT INTO t2 VALUES ( 2,24),( 4,33),( 6,41),( 8,26),( 0,32); -INSERT INTO t1 VALUES (11,20),(13,43),(15,11),(17,22),(19,37); -INSERT INTO t2 VALUES (12,25),(14,31),(16,42),(18,27),(10,30); -SELECT * from t3 where incr in (1,2,3,4) order by othr; -incr othr -1 10 -2 24 -4 33 -3 53 -alter table t3 UNION=(t1); -select count(*) from t3; -count(*) -10 -alter table t3 UNION=(t1,t2); -select count(*) from t3; -count(*) -20 -alter table t3 ENGINE=MYISAM; -select count(*) from t3; -count(*) -20 -drop table t3; -CREATE TABLE t3 (incr int not null, othr int not null, primary key(incr)) -ENGINE=MERGE UNION=(t1,t2); -show create table t3; -Table Create Table -t3 CREATE TABLE `t3` ( - `incr` int(11) NOT NULL, - `othr` int(11) NOT NULL, - PRIMARY KEY (`incr`) -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci UNION=(`t1`,`t2`) -alter table t3 drop primary key; -show create table t3; -Table Create Table -t3 CREATE TABLE `t3` ( - `incr` int(11) NOT NULL, - `othr` int(11) NOT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci UNION=(`t1`,`t2`) -drop table t3,t2,t1; -create table t1 (a int not null, key(a)) engine=merge; -select * from t1; -a -drop table t1; -create table t1 (a int not null, b int not null, key(a,b)); -create table t2 (a int not null, b int not null, key(a,b)); -create table t3 (a int not null, b int not null, key(a,b)) ENGINE=MERGE UNION=(t1,t2); -insert into t1 values (1,2),(2,1),(0,0),(4,4),(5,5),(6,6); -insert into t2 values (1,1),(2,2),(0,0),(4,4),(5,5),(6,6); -flush tables; -select * from t3 where a=1 order by b limit 2; -a b -1 1 -1 2 -drop table t3,t1,t2; -create table t1 (a int not null, b int not null auto_increment, primary key(a,b)); -create table t2 (a int not null, b int not null auto_increment, primary key(a,b)); -create table t3 (a int not null, b int not null, key(a,b)) UNION=(t1,t2) INSERT_METHOD=NO; -create table t4 (a int not null, b int not null, key(a,b)) ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=NO; -create table t5 (a int not null, b int not null auto_increment, primary key(a,b)) ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=FIRST; -create table t6 (a int not null, b int not null auto_increment, primary key(a,b)) ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST; -show create table t3; -Table Create Table -t3 CREATE TABLE `t3` ( - `a` int(11) NOT NULL, - `b` int(11) NOT NULL, - KEY `a` (`a`,`b`) -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -show create table t4; -Table Create Table -t4 CREATE TABLE `t4` ( - `a` int(11) NOT NULL, - `b` int(11) NOT NULL, - KEY `a` (`a`,`b`) -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci UNION=(`t1`,`t2`) -show create table t5; -Table Create Table -t5 CREATE TABLE `t5` ( - `a` int(11) NOT NULL, - `b` int(11) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`a`,`b`) -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=FIRST UNION=(`t1`,`t2`) -show create table t6; -Table Create Table -t6 CREATE TABLE `t6` ( - `a` int(11) NOT NULL, - `b` int(11) NOT NULL AUTO_INCREMENT, - PRIMARY KEY (`a`,`b`) -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -insert into t1 values (1,NULL),(1,NULL),(1,NULL),(1,NULL); -insert into t2 values (2,NULL),(2,NULL),(2,NULL),(2,NULL); -select * from t3 order by b,a limit 3; -a b -select * from t4 order by b,a limit 3; -a b -1 1 -2 1 -1 2 -select * from t5 order by b,a limit 3,3; -a b -2 2 -1 3 -2 3 -select * from t6 order by b,a limit 6,3; -a b -1 4 -2 4 -insert into t5 values (5,1),(5,2); -insert into t6 values (6,1),(6,2); -select * from t1 order by a,b; -a b -1 1 -1 2 -1 3 -1 4 -5 1 -5 2 -select * from t2 order by a,b; -a b -2 1 -2 2 -2 3 -2 4 -6 1 -6 2 -select * from t4 order by a,b; -a b -1 1 -1 2 -1 3 -1 4 -2 1 -2 2 -2 3 -2 4 -5 1 -5 2 -6 1 -6 2 -insert into t3 values (3,1),(3,2),(3,3),(3,4); -select * from t3 order by a,b; -a b -3 1 -3 2 -3 3 -3 4 -alter table t4 UNION=(t1,t2,t3); -show create table t4; -Table Create Table -t4 CREATE TABLE `t4` ( - `a` int(11) NOT NULL, - `b` int(11) NOT NULL, - KEY `a` (`a`,`b`) -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci UNION=(`t1`,`t2`,`t3`) -select * from t4 order by a,b; -a b -1 1 -1 2 -1 3 -1 4 -2 1 -2 2 -2 3 -2 4 -3 1 -3 2 -3 3 -3 4 -5 1 -5 2 -6 1 -6 2 -alter table t4 INSERT_METHOD=FIRST; -show create table t4; -Table Create Table -t4 CREATE TABLE `t4` ( - `a` int(11) NOT NULL, - `b` int(11) NOT NULL, - KEY `a` (`a`,`b`) -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=FIRST UNION=(`t1`,`t2`,`t3`) -insert into t4 values (4,1),(4,2); -select * from t1 order by a,b; -a b -1 1 -1 2 -1 3 -1 4 -4 1 -4 2 -5 1 -5 2 -select * from t2 order by a,b; -a b -2 1 -2 2 -2 3 -2 4 -6 1 -6 2 -select * from t3 order by a,b; -a b -3 1 -3 2 -3 3 -3 4 -select * from t4 order by a,b; -a b -1 1 -1 2 -1 3 -1 4 -2 1 -2 2 -2 3 -2 4 -3 1 -3 2 -3 3 -3 4 -4 1 -4 2 -5 1 -5 2 -6 1 -6 2 -select * from t5 order by a,b; -a b -1 1 -1 2 -1 3 -1 4 -2 1 -2 2 -2 3 -2 4 -4 1 -4 2 -5 1 -5 2 -6 1 -6 2 -select 1; -1 -1 -insert into t5 values (1,NULL),(5,NULL); -insert into t6 values (2,NULL),(6,NULL); -select * from t1 order by a,b; -a b -1 1 -1 2 -1 3 -1 4 -1 5 -4 1 -4 2 -5 1 -5 2 -5 3 -select * from t2 order by a,b; -a b -2 1 -2 2 -2 3 -2 4 -2 5 -6 1 -6 2 -6 3 -select * from t5 order by a,b; -a b -1 1 -1 2 -1 3 -1 4 -1 5 -2 1 -2 2 -2 3 -2 4 -2 5 -4 1 -4 2 -5 1 -5 2 -5 3 -6 1 -6 2 -6 3 -select * from t6 order by a,b; -a b -1 1 -1 2 -1 3 -1 4 -1 5 -2 1 -2 2 -2 3 -2 4 -2 5 -4 1 -4 2 -5 1 -5 2 -5 3 -6 1 -6 2 -6 3 -insert into t1 values (99,NULL); -select * from t4 where a+0 > 90; -a b -99 1 -insert t5 values (1,1); -ERROR 23000: Duplicate entry '1-1' for key 'PRIMARY' -insert t6 values (2,1); -ERROR 23000: Duplicate entry '2-1' for key 'PRIMARY' -insert t5 values (1,1) on duplicate key update b=b+10; -insert t6 values (2,1) on duplicate key update b=b+20; -select * from t5 where a < 3; -a b -1 2 -1 3 -1 4 -1 5 -1 11 -2 2 -2 3 -2 4 -2 5 -2 21 -drop table t6, t5, t4, t3, t2, t1; -CREATE TABLE t1 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) ENGINE=MyISAM; -INSERT INTO t1 VALUES (1,1), (2,1); -CREATE TABLE t2 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) ENGINE=MyISAM; -INSERT INTO t2 VALUES (1,2), (2,2); -CREATE TABLE t3 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) ENGINE=MRG_MyISAM UNION=(t1,t2); -select max(b) from t3 where a = 2; -max(b) -2 -select max(b) from t1 where a = 2; -max(b) -1 -drop table t3,t1,t2; -create table t1 (a int not null); -create table t2 (a int not null); -insert into t1 values (1); -insert into t2 values (2); -create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2); -select * from t3; -a -1 -2 -create temporary table t4 (a int not null); -create temporary table t5 (a int not null); -insert into t4 values (1); -insert into t5 values (2); -create temporary table t6 (a int not null) ENGINE=MERGE UNION=(t4,t5); -select * from t6; -a -1 -2 -drop table t6, t3, t1, t2, t4, t5; -create temporary table t1 (a int not null); -create temporary table t2 (a int not null); -insert into t1 values (1); -insert into t2 values (2); -create table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2); -select * from t3; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -drop table t3, t2, t1; -create table t1 (a int not null); -create temporary table t2 (a int not null); -insert into t1 values (1); -insert into t2 values (2); -create table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2); -select * from t3; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -drop table t3; -create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2); -select * from t3; -a -1 -2 -drop table t3, t2, t1; -# CREATE...SELECT is not implemented for MERGE tables. -CREATE TEMPORARY TABLE t1 (c1 INT NOT NULL); -CREATE TEMPORARY TABLE t2 (c1 INT NOT NULL); -CREATE TABLE t3 (c1 INT NOT NULL); -INSERT INTO t3 VALUES (3), (33); -LOCK TABLES t3 READ; -CREATE TEMPORARY TABLE t4 (c1 INT NOT NULL) ENGINE=MERGE UNION=(t1,t2) -INSERT_METHOD=LAST SELECT * FROM t3; -ERROR HY000: 'test.t4' is not of type 'BASE TABLE' -SELECT * FROM t4; -ERROR HY000: Table 't4' was not locked with LOCK TABLES -UNLOCK TABLES; -CREATE TEMPORARY TABLE t4 (c1 INT NOT NULL) ENGINE=MERGE UNION=(t1,t2) -INSERT_METHOD=LAST; -INSERT INTO t4 SELECT * FROM t3; -# Alter temporary MERGE table. -ALTER TABLE t4 UNION=(t1); -LOCK TABLES t4 WRITE; -# Alter temporary MERGE table under LOCk tables. -ALTER TABLE t4 UNION=(t1,t2); -UNLOCK TABLES; -# MERGE table and function. -CREATE FUNCTION f1 () RETURNS INT RETURN (SELECT max(c1) FROM t3); -SELECT * FROM t4 WHERE c1 < f1(); -c1 -3 -DROP FUNCTION f1; -DROP TABLE t4, t3, t2, t1; -CREATE TABLE t1 ( -fileset_id tinyint(3) unsigned NOT NULL default '0', -file_code varchar(32) NOT NULL default '', -fileset_root_id tinyint(3) unsigned NOT NULL default '0', -PRIMARY KEY (fileset_id,file_code), -KEY files (fileset_id,fileset_root_id) -) ENGINE=MyISAM; -INSERT INTO t1 VALUES (2, '0000000111', 1), (2, '0000000112', 1), (2, '0000000113', 1), -(2, '0000000114', 1), (2, '0000000115', 1), (2, '0000000116', 1), (2, '0000000117', 1), -(2, '0000000118', 1), (2, '0000000119', 1), (2, '0000000120', 1); -CREATE TABLE t2 ( -fileset_id tinyint(3) unsigned NOT NULL default '0', -file_code varchar(32) NOT NULL default '', -fileset_root_id tinyint(3) unsigned NOT NULL default '0', -PRIMARY KEY (fileset_id,file_code), -KEY files (fileset_id,fileset_root_id) -) ENGINE=MRG_MyISAM UNION=(t1); -EXPLAIN SELECT * FROM t2 IGNORE INDEX (files) WHERE fileset_id = 2 -AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range PRIMARY PRIMARY 35 NULL 6 Using where -EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2 -AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 range PRIMARY,files PRIMARY 35 NULL 6 Using where -EXPLAIN SELECT * FROM t1 WHERE fileset_id = 2 -AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t1 range PRIMARY,files PRIMARY 35 NULL 6 Using index condition -EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2 -AND file_code = '0000000115' LIMIT 1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 const PRIMARY,files PRIMARY 35 const,const 1 -DROP TABLE t2, t1; -create table t1 (x int, y int, index xy(x, y)); -create table t2 (x int, y int, index xy(x, y)); -create table t3 (x int, y int, index xy(x, y)) engine=merge union=(t1,t2); -insert into t1 values(1, 2); -insert into t2 values(1, 3); -select * from t3 where x = 1 and y < 5 order by y; -x y -1 2 -1 3 -select * from t3 where x = 1 and y < 5 order by y desc; -x y -1 3 -1 2 -drop table t1,t2,t3; -create table t1 (a int); -create table t2 (a int); -insert into t1 values (0); -insert into t2 values (1); -create table t3 engine=merge union=(t1, t2) select * from t1; -ERROR HY000: 'test.t3' is not of type 'BASE TABLE' -create table t3 engine=merge union=(t1, t2) select * from t2; -ERROR HY000: 'test.t3' is not of type 'BASE TABLE' -create table t3 engine=merge union=(t1, t2) select (select max(a) from t2); -ERROR HY000: 'test.t3' is not of type 'BASE TABLE' -drop table t1, t2; -create table t1 ( -a double(14,4), -b varchar(10), -index (a,b) -) engine=merge union=(t2,t3); -create table t2 ( -a double(14,4), -b varchar(10), -index (a,b) -) engine=myisam; -create table t3 ( -a double(14,4), -b varchar(10), -index (a,b) -) engine=myisam; -insert into t2 values ( null, ''); -insert into t2 values ( 9999999999.999, ''); -insert into t3 select * from t2; -select min(a), max(a) from t1; -min(a) max(a) -9999999999.9990 9999999999.9990 -flush tables; -select min(a), max(a) from t1; -min(a) max(a) -9999999999.9990 9999999999.9990 -drop table t1, t2, t3; -create table t1 (a int,b int,c int, index (a,b,c)); -create table t2 (a int,b int,c int, index (a,b,c)); -create table t3 (a int,b int,c int, index (a,b,c)) -engine=merge union=(t1 ,t2); -insert into t1 (a,b,c) values (1,1,0),(1,2,0); -insert into t2 (a,b,c) values (1,1,1),(1,2,1); -explain select a,b,c from t3 force index (a) where a=1 order by a,b,c; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 ref a a 5 const 4 Using where; Using index -select a,b,c from t3 force index (a) where a=1 order by a,b,c; -a b c -1 1 0 -1 1 1 -1 2 0 -1 2 1 -explain select a,b,c from t3 force index (a) where a=1 order by a desc, b desc, c desc; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t3 ref a a 5 const 4 Using where; Using index -select a,b,c from t3 force index (a) where a=1 order by a desc, b desc, c desc; -a b c -1 2 1 -1 2 0 -1 1 1 -1 1 0 -show index from t3; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Ignored -t3 1 a 1 a A NULL NULL NULL YES BTREE NO -t3 1 a 2 b A NULL NULL NULL YES BTREE NO -t3 1 a 3 c A NULL NULL NULL YES BTREE NO -drop table t1, t2, t3; -CREATE TABLE t1 ( a INT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(10), UNIQUE (b) ) -ENGINE=MyISAM; -CREATE TABLE t2 ( a INT AUTO_INCREMENT, b VARCHAR(10), INDEX (a), INDEX (b) ) -ENGINE=MERGE UNION (t1) INSERT_METHOD=FIRST; -INSERT INTO t2 (b) VALUES (1) ON DUPLICATE KEY UPDATE b=2; -INSERT INTO t2 (b) VALUES (1) ON DUPLICATE KEY UPDATE b=3; -SELECT b FROM t2; -b -3 -DROP TABLE t1, t2; -create table t1(a int); -create table t2(a int); -insert into t1 values (1); -insert into t2 values (2); -create table t3 (a int) engine=merge union=(t1, t2) insert_method=first; -select * from t3; -a -1 -2 -insert t2 select * from t2; -select * from t2; -a -2 -2 -insert t3 select * from t1; -select * from t3; -a -1 -1 -2 -2 -insert t1 select * from t3; -select * from t1; -a -1 -1 -1 -1 -2 -2 -select * from t2; -a -2 -2 -select * from t3; -a -1 -1 -1 -1 -2 -2 -2 -2 -check table t1, t2; -Table Op Msg_type Msg_text -test.t1 check status OK -test.t2 check status OK -drop table t1, t2, t3; -CREATE TABLE t1(a INT); -INSERT INTO t1 VALUES(2),(1); -CREATE TABLE t2(a INT, KEY(a)) ENGINE=MERGE UNION=(t1); -SELECT * FROM t2 WHERE a=2; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DROP TABLE t1, t2; -CREATE TABLE t1(a INT) ENGINE=MEMORY; -CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1); -SELECT * FROM t2; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DROP TABLE t1, t2; -CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3); -SELECT * FROM t2; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DROP TABLE t2; -CREATE TABLE t1(a INT, b TEXT); -CREATE TABLE tm1(a TEXT, b INT) ENGINE=MERGE UNION=(t1); -SELECT * FROM tm1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DROP TABLE t1, tm1; -CREATE TABLE t1(a SMALLINT, b SMALLINT); -CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1); -SELECT * FROM tm1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DROP TABLE t1, tm1; -CREATE TABLE t1(a SMALLINT, b SMALLINT, KEY(a, b)); -CREATE TABLE tm1(a SMALLINT, b SMALLINT, KEY(a)) ENGINE=MERGE UNION=(t1); -SELECT * FROM tm1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DROP TABLE t1, tm1; -CREATE TABLE t1(a SMALLINT, b SMALLINT, KEY(b)); -CREATE TABLE tm1(a SMALLINT, b SMALLINT, KEY(a)) ENGINE=MERGE UNION=(t1); -SELECT * FROM tm1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DROP TABLE t1, tm1; -CREATE TABLE t1(c1 VARCHAR(1)); -CREATE TABLE m1 LIKE t1; -ALTER TABLE m1 ENGINE=MERGE UNION=(t1); -SELECT * FROM m1; -c1 -DROP TABLE t1, m1; -CREATE TABLE t1(c1 VARCHAR(4), c2 TINYINT, c3 TINYINT, c4 TINYINT, -c5 TINYINT, c6 TINYINT, c7 TINYINT, c8 TINYINT, c9 TINYINT); -CREATE TABLE m1 LIKE t1; -ALTER TABLE m1 ENGINE=MERGE UNION=(t1); -SELECT * FROM m1; -c1 c2 c3 c4 c5 c6 c7 c8 c9 -DROP TABLE t1, m1; -CREATE TABLE t1 (a VARCHAR(255) CHARACTER SET latin1 COLLATE latin1_german2_ci, -b INT, INDEX(a,b)); -CREATE TABLE t2 LIKE t1; -CREATE TABLE t3 LIKE t1; -ALTER TABLE t3 ENGINE=MERGE UNION=(t1,t2); -INSERT INTO t1 VALUES ('ss',1); -INSERT INTO t2 VALUES ('ss',2),(0xDF,2); -SELECT COUNT(*) FROM t3 WHERE a=0xDF AND b=2; -COUNT(*) -2 -DROP TABLE t1,t2,t3; -create table t1 (b bit(1)); -create table t2 (b bit(1)); -create table tm (b bit(1)) engine = merge union = (t1,t2); -select * from tm; -b -drop table tm, t1, t2; -create table t1 (a int) insert_method = last engine = merge; -insert into t1 values (1); -ERROR HY000: Table 't1' is read only -create table t2 (a int) engine = myisam; -alter table t1 union (t2); -insert into t1 values (1); -alter table t1 insert_method = no; -insert into t1 values (1); -ERROR HY000: Table 't1' is read only -drop table t2; -drop table t1; -CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1, t2); -SELECT * FROM tm1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -CHECK TABLE tm1; -Table Op Msg_type Msg_text -test.tm1 check Error Table 'test.t1' is differently defined or of non-MyISAM type or doesn't exist -test.tm1 check Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist -test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -test.tm1 check error Corrupt -CREATE TABLE t1(a INT); -SELECT * FROM tm1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -CHECK TABLE tm1; -Table Op Msg_type Msg_text -test.tm1 check Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist -test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -test.tm1 check error Corrupt -CREATE TABLE t2(a BLOB); -SELECT * FROM tm1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -CHECK TABLE tm1; -Table Op Msg_type Msg_text -test.tm1 check Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist -test.tm1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -test.tm1 check error Corrupt -ALTER TABLE t2 MODIFY a INT; -SELECT * FROM tm1; -a -CHECK TABLE tm1; -Table Op Msg_type Msg_text -test.tm1 check status OK -DROP TABLE tm1, t1, t2; -CREATE TABLE t1(c1 INT); -CREATE TABLE t2 (c1 INT) ENGINE=MERGE UNION=(t1) INSERT_METHOD=FIRST; -CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2; -Warnings: -Note 1050 Table 't1' already exists -DROP TABLE t1, t2; -CREATE TABLE t1 (id INT NOT NULL, ref INT NOT NULL, INDEX (id)) ENGINE=MyISAM; -CREATE TABLE t2 LIKE t1; -INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4); -INSERT INTO t1 SELECT * FROM t2; -INSERT INTO t1 SELECT * FROM t2; -CREATE TABLE t3 (id INT NOT NULL, ref INT NOT NULL, INDEX (id)) ENGINE=MERGE -UNION(t1); -SELECT * FROM t3 AS a INNER JOIN t3 AS b USING (id) WHERE a.ref < b.ref; -id ref ref -4 4 5 -4 4 5 -4 4 5 -4 4 5 -SELECT * FROM t3; -id ref -1 3 -2 1 -3 2 -4 5 -4 4 -1 3 -2 1 -3 2 -4 5 -4 4 -DELETE FROM a USING t3 AS a INNER JOIN t3 AS b USING (id) WHERE a.ref < b.ref; -SELECT * FROM t3; -id ref -1 3 -2 1 -3 2 -4 5 -1 3 -2 1 -3 2 -4 5 -DROP TABLE t1, t2, t3; -CREATE TABLE t1(a INT); -CREATE TABLE m1(a INT) ENGINE=MERGE; -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TABLE `m1` ( - `a` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -DROP TABLE m1; -CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(); -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TABLE `m1` ( - `a` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -ALTER TABLE m1 UNION=(t1); -ALTER TABLE m1 UNION=(); -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TABLE `m1` ( - `a` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -DROP TABLE t1, m1; -CREATE TABLE t1(a INT); -CREATE TABLE t2(a VARCHAR(10)); -CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(t1, t2); -CREATE TABLE m2(a INT) ENGINE=MERGE UNION=(t1); -SELECT * FROM t1; -a -SELECT * FROM m1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -SELECT * FROM m2; -a -DROP TABLE t1, t2, m1, m2; -End of 5.0 tests -create table t1 (c1 int, index(c1)); -create table t2 (c1 int, index(c1)) engine=merge union=(t1); -insert into t1 values (1); -flush tables; -select * from t2; -c1 -1 -flush tables; -truncate table t1; -insert into t1 values (1); -flush tables; -select * from t2; -c1 -1 -truncate table t1; -insert into t1 values (1); -drop table t1,t2; -# -# Extra tests for TRUNCATE. -# -# Truncate MERGE table. -CREATE TABLE t1 (c1 INT, INDEX(c1)); -CREATE TABLE t2 (c1 INT, INDEX(c1)); -CREATE TABLE t3 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1,t2); -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -SELECT * FROM t3; -c1 -1 -2 -TRUNCATE TABLE t3; -SELECT * FROM t3; -c1 -# -# Truncate child table. -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -TRUNCATE TABLE t1; -SELECT * FROM t3; -c1 -2 -# -# Truncate MERGE table under locked tables. -LOCK TABLE t1 WRITE, t2 WRITE, t3 WRITE; -INSERT INTO t1 VALUES (1); -TRUNCATE TABLE t3; -SELECT * FROM t3; -c1 -UNLOCK TABLES; -SELECT * FROM t1; -c1 -SELECT * FROM t2; -c1 -# -# Truncate child table under locked tables. -LOCK TABLE t1 WRITE, t2 WRITE, t3 WRITE; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -TRUNCATE TABLE t1; -SELECT * FROM t3; -c1 -2 -UNLOCK TABLES; -DROP TABLE t1, t2, t3; -# -# Truncate temporary MERGE table. -CREATE TEMPORARY TABLE t1 (c1 INT, INDEX(c1)); -CREATE TEMPORARY TABLE t2 (c1 INT, INDEX(c1)); -CREATE TEMPORARY TABLE t3 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1,t2); -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -SELECT * FROM t3; -c1 -1 -2 -TRUNCATE TABLE t3; -SELECT * FROM t3; -c1 -# -# Truncate temporary child table. -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -TRUNCATE TABLE t1; -SELECT * FROM t3; -c1 -2 -# -# Truncate temporary MERGE table under locked tables. -INSERT INTO t1 VALUES (1); -CREATE TABLE t4 (c1 INT, INDEX(c1)); -LOCK TABLE t4 WRITE; -TRUNCATE TABLE t3; -SELECT * FROM t3; -c1 -SELECT * FROM t1; -c1 -SELECT * FROM t2; -c1 -# -# Truncate temporary child table under locked tables. -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -TRUNCATE TABLE t1; -SELECT * FROM t3; -c1 -2 -SELECT * FROM t1; -c1 -SELECT * FROM t2; -c1 -2 -UNLOCK TABLES; -DROP TABLE t1, t2, t3, t4; -connect con1,localhost,root,,; -connect con2,localhost,root,,; -connection default; -CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; -CREATE TABLE t2 (c1 INT) ENGINE= MRG_MYISAM UNION= (t1) INSERT_METHOD= LAST; -REPAIR TABLE t1; -connection con1; -INSERT INTO t2 VALUES (1); -connection default; -Table Op Msg_type Msg_text -test.t1 repair status OK -DROP TABLE t1, t2; -CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; -CREATE TABLE t2 (c1 INT) ENGINE= MRG_MYISAM UNION= (t1) INSERT_METHOD= LAST; -LOCK TABLE t1 WRITE; -connection con1; -INSERT INTO t2 VALUES (1); -connection default; -REPAIR TABLE t1; -Table Op Msg_type Msg_text -test.t1 repair status OK -UNLOCK TABLES; -connection con1; -connection default; -DROP TABLE t1, t2; -CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; -LOCK TABLE t1 WRITE; -connection con1; -INSERT INTO t1 VALUES (1); -connection default; -FLUSH TABLES; -FLUSH TABLES; -SELECT * FROM t1; -c1 -UNLOCK TABLES; -connection con1; -connection default; -DROP TABLE t1; -disconnect con1; -disconnect con2; -# -# Extra tests for Bug#26379 - Combination of FLUSH TABLE and -# REPAIR TABLE corrupts a MERGE table -# -# CREATE ... SELECT is disabled for MERGE tables. -# -CREATE TABLE t1(c1 INT); -INSERT INTO t1 VALUES (1); -CREATE TABLE t2 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; -CREATE TABLE t3 ENGINE=MRG_MYISAM INSERT_METHOD=LAST SELECT * FROM t2; -ERROR HY000: Table 't3' is read only -SHOW CREATE TABLE t3; -ERROR 42S02: Table 'test.t3' doesn't exist -CREATE TABLE t3 ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST -SELECT * FROM t2; -ERROR HY000: 'test.t3' is not of type 'BASE TABLE' -SHOW CREATE TABLE t3; -ERROR 42S02: Table 'test.t3' doesn't exist -DROP TABLE t1, t2; -# -# Bug#37371 "CREATE TABLE LIKE merge loses UNION parameter" -# Demonstrate that this is no longer the case. -# -# 1. Create like. -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TABLE t3 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -INSERT INTO t3 VALUES (3); -CREATE TABLE t4 LIKE t3; -SHOW CREATE TABLE t4; -Table Create Table -t4 CREATE TABLE `t4` ( - `c1` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -INSERT INTO t4 VALUES (4); -DROP TABLE t4; -# -# 1. Create like with locked tables. -LOCK TABLES t3 WRITE, t2 WRITE, t1 WRITE; -CREATE TABLE t4 LIKE t3; -ERROR HY000: Table 't4' was not locked with LOCK TABLES -SHOW CREATE TABLE t4; -ERROR HY000: Table 't4' was not locked with LOCK TABLES -INSERT INTO t4 VALUES (4); -ERROR HY000: Table 't4' was not locked with LOCK TABLES -# Temporary tables can be created in spite of LOCK TABLES. -# If the temporary MERGE table uses the locked children only, -# it can even be used. -CREATE TEMPORARY TABLE t4 LIKE t3; -SHOW CREATE TABLE t4; -Table Create Table -t4 CREATE TEMPORARY TABLE `t4` ( - `c1` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -INSERT INTO t4 VALUES (4); -UNLOCK TABLES; -INSERT INTO t4 VALUES (4); -DROP TABLE t4; -# -# Rename child. -# -# 1. Normal rename of non-MERGE table. -CREATE TABLE t4 (c1 INT); -INSERT INTO t4 VALUES (4); -SELECT * FROM t4 ORDER BY c1; -c1 -4 -RENAME TABLE t4 TO t5; -SELECT * FROM t5 ORDER BY c1; -c1 -4 -RENAME TABLE t5 TO t4; -SELECT * FROM t4 ORDER BY c1; -c1 -4 -DROP TABLE t4; -# -# 2. Normal rename. -SELECT * FROM t3 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -4 -RENAME TABLE t2 TO t5; -SELECT * FROM t3 ORDER BY c1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -RENAME TABLE t5 TO t2; -SELECT * FROM t3 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -4 -# -# 3. Normal rename with locked tables. -LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE; -SELECT * FROM t3 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -4 -RENAME TABLE t2 TO t5; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -SELECT * FROM t3 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -4 -RENAME TABLE t5 TO t2; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -SELECT * FROM t3 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -4 -UNLOCK TABLES; -# -# 4. Alter table rename. -ALTER TABLE t2 RENAME TO t5; -SELECT * FROM t3 ORDER BY c1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -ALTER TABLE t5 RENAME TO t2; -SELECT * FROM t3 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -4 -# -# 5. Alter table rename with locked tables. -LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE; -ALTER TABLE t2 RENAME TO t5; -SELECT * FROM t3 ORDER BY c1; -ERROR HY000: Table 't2' was not locked with LOCK TABLES -ALTER TABLE t5 RENAME TO t2; -ERROR HY000: Table 't5' was not locked with LOCK TABLES -UNLOCK TABLES; -ALTER TABLE t5 RENAME TO t2; -SELECT * FROM t3 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -4 -# -# Rename parent. -# -# 1. Normal rename with locked tables. -LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE; -SELECT * FROM t3 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -4 -RENAME TABLE t3 TO t5; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -SELECT * FROM t3 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -4 -RENAME TABLE t5 TO t3; -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -SELECT * FROM t3 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -4 -# -# 5. Alter table rename with locked tables. -ALTER TABLE t3 RENAME TO t5; -SELECT * FROM t5 ORDER BY c1; -ERROR HY000: Table 't5' was not locked with LOCK TABLES -ALTER TABLE t5 RENAME TO t3; -ERROR HY000: Table 't5' was not locked with LOCK TABLES -UNLOCK TABLES; -ALTER TABLE t5 RENAME TO t3; -SELECT * FROM t3 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -4 -DROP TABLE t1, t2, t3; -# -# Drop locked tables. -# -# 1. Drop parent. -CREATE TABLE t1 (c1 INT, INDEX(c1)); -CREATE TABLE t2 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1) -INSERT_METHOD=LAST; -LOCK TABLES t1 WRITE, t2 WRITE; -INSERT INTO t1 VALUES (1); -DROP TABLE t2; -SELECT * FROM t2; -ERROR HY000: Table 't2' was not locked with LOCK TABLES -SELECT * FROM t1; -c1 -1 -UNLOCK TABLES; -# 2. Drop child. -CREATE TABLE t2 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1) -INSERT_METHOD=LAST; -LOCK TABLES t1 WRITE, t2 WRITE; -INSERT INTO t1 VALUES (1); -DROP TABLE t1; -SELECT * FROM t2; -ERROR HY000: Table 't1' was not locked with LOCK TABLES -SELECT * FROM t1; -ERROR HY000: Table 't1' was not locked with LOCK TABLES -UNLOCK TABLES; -DROP TABLE t2; -# -# ALTER TABLE. Change child list. -# -CREATE TABLE t1 (c1 INT, INDEX(c1)); -CREATE TABLE t2 (c1 INT, INDEX(c1)); -CREATE TABLE t3 (c1 INT, INDEX(c1)); -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -INSERT INTO t3 VALUES (3); -CREATE TABLE t4 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t3,t2) -INSERT_METHOD=LAST; -# Shrink child list. -ALTER TABLE t4 UNION=(t3); -SHOW CREATE TABLE t4; -Table Create Table -t4 CREATE TABLE `t4` ( - `c1` int(11) DEFAULT NULL, - KEY `c1` (`c1`) -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t3`) -SELECT * FROM t4 ORDER BY c1; -c1 -3 -# Extend child list. -ALTER TABLE t4 UNION=(t3,t2); -SHOW CREATE TABLE t4; -Table Create Table -t4 CREATE TABLE `t4` ( - `c1` int(11) DEFAULT NULL, - KEY `c1` (`c1`) -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t3`,`t2`) -SELECT * FROM t4 ORDER BY c1; -c1 -2 -3 -# -# ALTER TABLE under LOCK TABLES. Change child list. -# -LOCK TABLES t4 WRITE, t3 WRITE, t2 WRITE; -# Shrink child list. -ALTER TABLE t4 UNION=(t3); -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -# Extend child list within locked tables. -ALTER TABLE t4 UNION=(t3,t2); -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -# Extend child list beyond locked tables. -ALTER TABLE t4 UNION=(t3,t2,t1); -ERROR HY000: Can't execute the given command because you have active locked tables or an active transaction -SHOW CREATE TABLE t4; -Table Create Table -t4 CREATE TABLE `t4` ( - `c1` int(11) DEFAULT NULL, - KEY `c1` (`c1`) -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t3`,`t2`) -SELECT * FROM t4 ORDER BY c1; -c1 -2 -3 -UNLOCK TABLES; -DROP TABLE t4; -# -# ALTER TABLE under LOCK TABLES. Grave change, table re-creation. -# -CREATE TABLE t4 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1,t2,t3) -INSERT_METHOD=LAST; -# Lock parent first and then children. -LOCK TABLES t4 WRITE, t3 WRITE, t2 WRITE, t1 WRITE; -ALTER TABLE t4 DROP INDEX c1, ADD UNIQUE INDEX (c1); -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -ALTER TABLE t2 DROP INDEX c1, ADD UNIQUE INDEX (c1); -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -UNLOCK TABLES; -# Lock children first and then parent. -LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t4 WRITE; -ALTER TABLE t4 DROP INDEX c1, ADD UNIQUE INDEX (c1); -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -ALTER TABLE t2 DROP INDEX c1, ADD UNIQUE INDEX (c1); -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -UNLOCK TABLES; -# Lock parent between children. -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -ALTER TABLE t4 DROP INDEX c1, ADD UNIQUE INDEX (c1); -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -ALTER TABLE t2 DROP INDEX c1, ADD UNIQUE INDEX (c1); -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -UNLOCK TABLES; -DROP TABLE t1, t2, t3, t4; -# -# ALTER TABLE under LOCK TABLES. Simple change, no re-creation. -# -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TABLE t3 (c1 INT); -CREATE TABLE t4 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2,t3) -INSERT_METHOD=LAST; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -INSERT INTO t3 VALUES (3); -# Lock parent first and then children. -LOCK TABLES t4 WRITE, t3 WRITE, t2 WRITE, t1 WRITE; -ALTER TABLE t4 ALTER COLUMN c1 SET DEFAULT 44; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -ALTER TABLE t2 ALTER COLUMN c1 SET DEFAULT 22; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -UNLOCK TABLES; -# Lock children first and then parent. -LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t4 WRITE; -ALTER TABLE t4 ALTER COLUMN c1 SET DEFAULT 44; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -ALTER TABLE t2 ALTER COLUMN c1 SET DEFAULT 22; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -UNLOCK TABLES; -# Lock parent between children. -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -ALTER TABLE t4 ALTER COLUMN c1 SET DEFAULT 44; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -ALTER TABLE t2 ALTER COLUMN c1 SET DEFAULT 22; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -UNLOCK TABLES; -# -# FLUSH TABLE under LOCK TABLES. -# -# Lock parent first and then children. -LOCK TABLES t4 WRITE, t3 WRITE, t2 WRITE, t1 WRITE; -FLUSH TABLE t4; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -FLUSH TABLE t2; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -FLUSH TABLES; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -UNLOCK TABLES; -# Lock children first and then parent. -LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t4 WRITE; -FLUSH TABLE t4; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -FLUSH TABLE t2; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -FLUSH TABLES; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -UNLOCK TABLES; -# Lock parent between children. -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -FLUSH TABLE t4; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -FLUSH TABLE t2; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -FLUSH TABLES; -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -UNLOCK TABLES; -# -# Triggers -# -# Trigger on parent -DELETE FROM t4 WHERE c1 = 4; -CREATE TRIGGER t4_ai1 AFTER INSERT ON t4 FOR EACH ROW SET @a=1; -SET @a=0; -INSERT INTO t4 VALUES (4); -SELECT @a; -@a -1 -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -DROP TRIGGER t4_ai1; -CHECK TABLE t3; -Table Op Msg_type Msg_text -test.t3 check status OK -# Trigger on parent under LOCK TABLES -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -CREATE TRIGGER t4_ai2 AFTER INSERT ON t4 FOR EACH ROW SET @a=1; -SET @a=0; -INSERT INTO t4 VALUES (4); -SELECT @a; -@a -1 -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -DROP TRIGGER t4_ai2; -UNLOCK TABLES; -CHECK TABLE t3; -Table Op Msg_type Msg_text -test.t3 check status OK -# -# Trigger on child -DELETE FROM t4 WHERE c1 = 4; -CREATE TRIGGER t3_ai3 AFTER INSERT ON t3 FOR EACH ROW SET @a=1; -SET @a=0; -INSERT INTO t4 VALUES (4); -SELECT @a; -@a -0 -INSERT INTO t3 VALUES (33); -SELECT @a; -@a -1 -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -33 -DROP TRIGGER t3_ai3; -CHECK TABLE t3; -Table Op Msg_type Msg_text -test.t3 check status OK -# Trigger on child under LOCK TABLES -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -CREATE TRIGGER t3_ai4 AFTER INSERT ON t3 FOR EACH ROW SET @a=1; -SET @a=0; -INSERT INTO t4 VALUES (4); -SELECT @a; -@a -0 -INSERT INTO t3 VALUES (33); -SELECT @a; -@a -1 -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -33 -33 -DELETE FROM t4 WHERE c1 = 33; -DROP TRIGGER t3_ai4; -UNLOCK TABLES; -CHECK TABLE t3; -Table Op Msg_type Msg_text -test.t3 check status OK -# -# Trigger with table use on child -DELETE FROM t4 WHERE c1 = 4; -CREATE TRIGGER t3_ai5 AFTER INSERT ON t3 FOR EACH ROW INSERT INTO t2 VALUES(22); -SELECT COUNT(*) FROM t2; -COUNT(*) -1 -INSERT INTO t4 VALUES (4); -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -INSERT INTO t3 VALUES (33); -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -22 -33 -DELETE FROM t4 WHERE c1 = 22; -DELETE FROM t4 WHERE c1 = 33; -DROP TRIGGER t3_ai5; -UNLOCK TABLES; -CHECK TABLE t2,t3; -Table Op Msg_type Msg_text -test.t2 check status OK -test.t3 check status OK -# Trigger with table use on child under LOCK TABLES -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -CREATE TRIGGER t3_ai6 AFTER INSERT ON t3 FOR EACH ROW INSERT INTO t2 VALUES(22); -INSERT INTO t4 VALUES (4); -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -INSERT INTO t3 VALUES (33); -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -4 -22 -33 -DROP TRIGGER t3_ai6; -UNLOCK TABLES; -check table t2,t3,t4; -Table Op Msg_type Msg_text -test.t2 check status OK -test.t3 check status OK -test.t4 check status OK -DELETE FROM t4 WHERE c1 = 22; -DELETE FROM t4 WHERE c1 = 33; -# Trigger with table use on child under different LOCK TABLES -DELETE FROM t4 WHERE c1 = 4; -LOCK TABLES t4 WRITE,t3 WRITE, t2 WRITE, t1 WRITE; -CREATE TRIGGER t3_ai7 AFTER INSERT ON t3 FOR EACH ROW INSERT INTO t2 VALUES(22); -INSERT INTO t4 VALUES (4); -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -INSERT INTO t3 VALUES (33); -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -22 -33 -DROP TRIGGER t3_ai7; -UNLOCK TABLES; -check table t2,t3,t4; -Table Op Msg_type Msg_text -test.t2 check status OK -test.t3 check status OK -test.t4 check status OK -DELETE FROM t4 WHERE c1 = 22; -DELETE FROM t4 WHERE c1 = 33; -# -# Repair -# -REPAIR TABLE t4; -Table Op Msg_type Msg_text -test.t4 repair note The storage engine for the table doesn't support repair -REPAIR TABLE t2; -Table Op Msg_type Msg_text -test.t2 repair status OK -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -REPAIR TABLE t4; -Table Op Msg_type Msg_text -test.t4 repair note The storage engine for the table doesn't support repair -REPAIR TABLE t2; -Table Op Msg_type Msg_text -test.t2 repair status OK -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -UNLOCK TABLES; -# -# Optimize -# -OPTIMIZE TABLE t4; -Table Op Msg_type Msg_text -test.t4 optimize note The storage engine for the table doesn't support optimize -OPTIMIZE TABLE t2; -Table Op Msg_type Msg_text -test.t2 optimize status OK -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -OPTIMIZE TABLE t4; -Table Op Msg_type Msg_text -test.t4 optimize note The storage engine for the table doesn't support optimize -OPTIMIZE TABLE t2; -Table Op Msg_type Msg_text -test.t2 optimize status Table is already up to date -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -UNLOCK TABLES; -# -# Checksum -# -CHECKSUM TABLE t4; -Table Checksum -test.t4 149057747 -CHECKSUM TABLE t2; -Table Checksum -test.t2 3700403066 -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -CHECKSUM TABLE t4; -Table Checksum -test.t4 149057747 -CHECKSUM TABLE t2; -Table Checksum -test.t2 3700403066 -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -UNLOCK TABLES; -# -# Insert delayed -# -INSERT DELAYED INTO t4 VALUES(44); -DELETE FROM t4 WHERE c1 = 44; -INSERT DELAYED INTO t3 VALUES(33); -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -33 -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -INSERT DELAYED INTO t4 VALUES(444); -Got one of the listed errors -INSERT DELAYED INTO t3 VALUES(333); -Got one of the listed errors -SELECT * FROM t4 ORDER BY c1; -c1 -1 -2 -3 -4 -33 -UNLOCK TABLES; -DROP TABLE t1, t2, t3, t4; -# -# Recursive inclusion of merge tables in their union clauses. -# -CREATE TABLE t1 (c1 INT, INDEX(c1)); -CREATE TABLE t2 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1) -INSERT_METHOD=LAST; -CREATE TABLE t3 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t2,t1) -INSERT_METHOD=LAST; -ALTER TABLE t2 UNION=(t3,t1); -SELECT * FROM t2; -ERROR HY000: Table 't3' is differently defined or of non-MyISAM type or doesn't exist -DROP TABLE t1, t2, t3; -CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; -CREATE TABLE t2 (c1 INT) ENGINE= MyISAM; -CREATE TABLE t3 (c1 INT) ENGINE= MRG_MYISAM UNION= (t1, t2); -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -SELECT * FROM t3; -c1 -1 -2 -TRUNCATE TABLE t1; -SELECT * FROM t3; -c1 -2 -DROP TABLE t1, t2, t3; -CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER); -SET @rnd_max= 2147483647; -set @@read_buffer_size=2*1024*1024; -CREATE TABLE t2 SELECT * FROM t1; -INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; -INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; -INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; -INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; -INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; -CREATE TABLE t3 (id INTEGER, grp TINYINT, id_rev INTEGER) -ENGINE= MRG_MYISAM UNION= (t1, t2); -SELECT COUNT(*) FROM t1; -COUNT(*) -130 -SELECT COUNT(*) FROM t2; -COUNT(*) -80 -SELECT COUNT(*) FROM t3; -COUNT(*) -210 -connect con1,localhost,root,,; -SELECT COUNT(DISTINCT a1.id) FROM t3 AS a1, t3 AS a2 -WHERE a1.id = a2.id GROUP BY a2.grp; -connection default; -TRUNCATE TABLE t1; -connection con1; -disconnect con1; -connection default; -SELECT COUNT(*) FROM t1; -COUNT(*) -0 -SELECT COUNT(*) FROM t2; -COUNT(*) -80 -SELECT COUNT(*) FROM t3; -COUNT(*) -80 -DROP TABLE t1, t2, t3; -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE t2 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; -INSERT INTO t2 VALUES (1); -SELECT * FROM t2; -c1 -1 -LOCK TABLES t2 WRITE, t1 WRITE; -FLUSH TABLES; -REPAIR TABLE t1; -Table Op Msg_type Msg_text -test.t1 repair status OK -CHECK TABLE t1; -Table Op Msg_type Msg_text -test.t1 check status OK -REPAIR TABLE t1; -Table Op Msg_type Msg_text -test.t1 repair status OK -UNLOCK TABLES; -CHECK TABLE t1 EXTENDED; -Table Op Msg_type Msg_text -test.t1 check status OK -LOCK TABLES t2 WRITE, t1 WRITE; -REPAIR TABLE t1; -Table Op Msg_type Msg_text -test.t1 repair status OK -CHECK TABLE t1; -Table Op Msg_type Msg_text -test.t1 check status OK -REPAIR TABLE t1; -Table Op Msg_type Msg_text -test.t1 repair status OK -UNLOCK TABLES; -CHECK TABLE t1 EXTENDED; -Table Op Msg_type Msg_text -test.t1 check status OK -DROP TABLE t1, t2; -CREATE TABLE t1 ( a INT ) ENGINE=MyISAM; -CREATE TABLE m1 ( a INT ) ENGINE=MRG_MYISAM UNION=(t1); -LOCK TABLES t1 WRITE, m1 WRITE; -FLUSH TABLE t1; -UNLOCK TABLES; -DROP TABLE m1, t1; -CREATE TABLE t1 ( a INT ) ENGINE=MyISAM; -CREATE TABLE m1 ( a INT ) ENGINE=MRG_MYISAM UNION=(t1); -LOCK TABLES m1 WRITE, t1 WRITE; -FLUSH TABLE t1; -UNLOCK TABLES; -DROP TABLE m1, t1; -CREATE TABLE t1 (c1 INT, c2 INT) ENGINE= MyISAM; -CREATE TABLE t2 (c1 INT, c2 INT) ENGINE= MyISAM; -CREATE TABLE t3 (c1 INT, c2 INT) ENGINE= MRG_MYISAM UNION(t1, t2); -INSERT INTO t1 VALUES (1, 1); -INSERT INTO t2 VALUES (2, 2); -SELECT * FROM t3; -c1 c2 -1 1 -2 2 -ALTER TABLE t1 ENGINE= MEMORY; -INSERT INTO t1 VALUES (0, 0); -SELECT * FROM t3; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DROP TABLE t1, t2, t3; -CREATE TABLE t1 (c1 INT, KEY(c1)); -CREATE TABLE t2 (c1 INT, KEY(c1)) ENGINE=MRG_MYISAM UNION=(t1) -INSERT_METHOD=FIRST; -LOCK TABLE t1 WRITE, t2 WRITE; -FLUSH TABLES t2, t1; -OPTIMIZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 optimize status Table is already up to date -FLUSH TABLES t1; -UNLOCK TABLES; -FLUSH TABLES; -INSERT INTO t1 VALUES (1); -LOCK TABLE t1 WRITE, t2 WRITE; -FLUSH TABLES t2, t1; -OPTIMIZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 optimize status OK -FLUSH TABLES t1; -UNLOCK TABLES; -DROP TABLE t1, t2; -CREATE TABLE t1 (ID INT) ENGINE=MYISAM; -CREATE TABLE m1 (ID INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=FIRST; -INSERT INTO t1 VALUES (); -INSERT INTO m1 VALUES (); -LOCK TABLE t1 WRITE, m1 WRITE; -FLUSH TABLES m1, t1; -OPTIMIZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 optimize status OK -FLUSH TABLES m1, t1; -UNLOCK TABLES; -DROP TABLE t1, m1; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=FIRST; -SELECT table_schema, table_name, table_type, engine, version, row_format, table_comment FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' and TABLE_NAME='tm1'; -table_schema table_name table_type engine version row_format table_comment -test tm1 BASE TABLE NULL NULL NULL Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -Warnings: -Warning 1168 Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DROP TABLE tm1; -CREATE TABLE t1(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM; -CREATE TABLE t2(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM; -CREATE TABLE t3(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM; -CREATE TABLE t4(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) -ENGINE=MRG_MYISAM UNION=(t1, t2, t3); -INSERT INTO t1 VALUES (1,1), (1,2),(1,3), (1,4); -INSERT INTO t2 VALUES (2,1), (2,2),(2,3), (2,4); -INSERT INTO t3 VALUES (3,1), (3,2),(3,3), (3,4); -EXPLAIN SELECT COUNT(*) FROM t1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away -EXPLAIN SELECT COUNT(*) FROM t4; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away -DROP TABLE t1, t2, t3, t4; -CREATE TABLE t1(a INT, KEY(a)); -INSERT INTO t1 VALUES(0),(1),(2),(3),(4); -ANALYZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status OK -CREATE TABLE m1(a INT, KEY(a)) ENGINE=MERGE UNION=(t1); -SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; -CARDINALITY -5 -SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; -CARDINALITY -5 -SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; -CARDINALITY -5 -SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; -CARDINALITY -5 -DROP TABLE t1, m1; -# -# Bug #40675 MySQL 5.1 crash with index merge algorithm and Merge tables -# -# create MYISAM table t1 and insert values into it -CREATE TABLE t1(a INT); -INSERT INTO t1 VALUES(1); -# create MYISAM table t2 and insert values into it -CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b)); -INSERT INTO t2(a,b) VALUES -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(1,2); -# Create the merge table t3 -CREATE TABLE t3(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b)) -ENGINE=MERGE UNION=(t2) INSERT_METHOD=FIRST; -# Lock tables t1 and t3 for write -LOCK TABLES t1 WRITE, t3 WRITE; -# Insert values into the merge table t3 -INSERT INTO t3(a,b) VALUES(1,2); -# select from the join of t2 and t3 (The merge table) -SELECT t3.a FROM t1,t3 WHERE t3.b=2 AND t3.a=1; -a -1 -1 -# Unlock the tables -UNLOCK TABLES; -# drop the created tables -DROP TABLE t1, t2, t3; -# insert duplicate value in child table while merge table doesn't have key -create table t1 ( -col1 int(10), -primary key (col1) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -CREATE TABLE m1 ( -col1 int(10) NOT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(t1); -insert into m1 (col1) values (1); -insert into m1 (col1) values (1); -ERROR 23000: Can't write; duplicate key in table 'm1' -drop table m1, t1; -# -# Bug#45800 crash when replacing into a merge table and there is a duplicate -# -# Replace duplicate value in child table when merge table doesn't have key -CREATE TABLE t1 (c1 INT PRIMARY KEY) ENGINE=MyISAM; -CREATE TABLE m1 (c1 INT NOT NULL) ENGINE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1); -INSERT INTO m1 VALUES (666); -SELECT * FROM m1; -c1 -666 -# insert the duplicate value into the merge table -REPLACE INTO m1 VALUES (666); -SELECT * FROM m1; -c1 -666 -DROP TABLE m1, t1; -# Insert... on duplicate key update (with duplicate values in the table) -CREATE TABLE t1 (c1 INT PRIMARY KEY) ENGINE=MyISAM; -CREATE TABLE m1 (c1 INT NOT NULL) ENGINE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1); -INSERT INTO m1 VALUES (666); -SELECT * FROM m1; -c1 -666 -# insert the duplicate value into the merge table -INSERT INTO m1 VALUES (666) ON DUPLICATE KEY UPDATE c1=c1+1; -SELECT * FROM m1; -c1 -667 -DROP TABLE m1, t1; -# Insert duplicate value on MERGE table, where, MERGE has a key but MyISAM has more keys -CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE (c1), UNIQUE (c2)); -CREATE TABLE m1 (c1 INT, c2 INT, UNIQUE (c1)) ENGINE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1); -INSERT INTO m1 VALUES (1,2); -# insert the duplicate value into the merge table -INSERT INTO m1 VALUES (3,2); -ERROR 23000: Can't write; duplicate key in table 'm1' -DROP TABLE m1,t1; -# Try to define MERGE and MyISAM with keys on different columns -CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE (c1)); -CREATE TABLE m1 (c1 INT, c2 INT, UNIQUE (c2)) ENGINE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1); -# Try accessing the merge table for inserts (error occurs) -INSERT INTO m1 VALUES (1,2); -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -INSERT INTO m1 VALUES (1,4); -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DROP TABLE m1,t1; -CREATE TABLE t1 ( -col1 INT(10) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; -CREATE VIEW v1 as SELECT * FROM t1; -CREATE TABLE m1 ( -col1 INT(10) -)ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(v1); -#Select should detect that the child table is a view and fail. -SELECT * FROM m1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DROP VIEW v1; -DROP TABLE m1, t1; -# -# Bug #45796: invalid memory reads and writes when altering merge and -# base tables -# -CREATE TABLE t1(c1 INT) ENGINE=MyISAM; -CREATE TABLE m1(c1 INT) ENGINE=MERGE UNION=(t1); -ALTER TABLE m1 ADD INDEX idx_c1(c1); -SELECT * FROM m1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -ALTER TABLE t1 ADD INDEX idx_c1(c1); -SELECT * FROM m1; -c1 -DROP TABLE m1; -DROP TABLE t1; -# -# Bug45781 infinite hang/crash in "opening tables" after handler tries to -# open merge table -# -CREATE TABLE t1(a int)engine=myisam; -CREATE TABLE t2(a int)engine=myisam; -CREATE TABLE t3(a int)engine=myisam; -CREATE TABLE t4(a int)engine=myisam; -CREATE TABLE t5(a int)engine=myisam; -CREATE TABLE t6(a int)engine=myisam; -CREATE TABLE t7(a int)engine=myisam; -CREATE TABLE m1(a int)engine=merge union=(t1,t2,t3,t4,t5,t6,t7); -SELECT 1 FROM m1; -1 -HANDLER m1 OPEN; -ERROR HY000: Storage engine MRG_MyISAM of the table `test`.`m1` doesn't have this option -DROP TABLE m1,t1,t2,t3,t4,t5,t6,t7; -SELECT 1 FROM m1; -ERROR 42S02: Table 'test.m1' doesn't exist -# -# Bug #46614: Assertion in show_create_trigger() -# -CREATE TABLE t1(a int); -CREATE TABLE t2(a int); -CREATE TABLE t3(a int) ENGINE = MERGE UNION(t1, t2); -CREATE TRIGGER tr1 AFTER INSERT ON t3 FOR EACH ROW CALL foo(); -SHOW CREATE TRIGGER tr1; -Trigger sql_mode SQL Original Statement character_set_client collation_connection Database Collation Created -tr1 STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION CREATE DEFINER=`root`@`localhost` TRIGGER tr1 AFTER INSERT ON t3 FOR EACH ROW CALL foo() latin1 latin1_swedish_ci latin1_swedish_ci # -DROP TRIGGER tr1; -DROP TABLE t1, t2, t3; -# -# BUG#48265 - MRG_MYISAM problem (works in 5.0.85, does't work in 5.1.40) -# -CREATE DATABASE `test/1`; -CREATE TABLE `test/1`.`t/1`(a INT); -CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(`test/1`.`t/1`); -SELECT * FROM m1; -a -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TABLE `m1` ( - `a` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci UNION=(`test/1`.`t/1`) -DROP TABLE m1; -CREATE TABLE `test/1`.m1(a INT) ENGINE=MERGE UNION=(`test/1`.`t/1`); -SELECT * FROM `test/1`.m1; -a -SHOW CREATE TABLE `test/1`.m1; -Table Create Table -m1 CREATE TABLE `m1` ( - `a` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci UNION=(`t/1`) -DROP TABLE `test/1`.m1; -DROP TABLE `test/1`.`t/1`; -CREATE TEMPORARY TABLE `test/1`.`t/1`(a INT); -CREATE TEMPORARY TABLE m1(a INT) ENGINE=MERGE UNION=(`test/1`.`t/1`); -SELECT * FROM m1; -a -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TEMPORARY TABLE `m1` ( - `a` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci UNION=(`test/1`.`t/1`) -DROP TABLE m1; -CREATE TEMPORARY TABLE `test/1`.m1(a INT) ENGINE=MERGE UNION=(`test/1`.`t/1`); -SELECT * FROM `test/1`.m1; -a -SHOW CREATE TABLE `test/1`.m1; -Table Create Table -m1 CREATE TEMPORARY TABLE `m1` ( - `a` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci UNION=(`t/1`) -DROP TABLE `test/1`.m1; -DROP TABLE `test/1`.`t/1`; -DROP DATABASE `test/1`; -CREATE TABLE `t@1`(a INT); -SELECT * FROM m1; -a -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TABLE `m1` ( - `a` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci UNION=(`t@1`) -DROP TABLE `t@1`; -CREATE DATABASE `test@1`; -CREATE TABLE `test@1`.`t@1`(a INT); -FLUSH TABLE m1; -SELECT * FROM m1; -a -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TABLE `m1` ( - `a` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci UNION=(`test@1`.`t@1`) -DROP TABLE m1; -DROP TABLE `test@1`.`t@1`; -DROP DATABASE `test@1`; -# -# Bug#51494c rash with join, explain and 'sounds like' operator -# -CREATE TABLE t1 (a INT) ENGINE=MYISAM; -INSERT INTO t1 VALUES(1); -CREATE TABLE t2 (b INT NOT NULL,c INT,d INT,e BLOB NOT NULL, -KEY idx0 (d, c)) ENGINE=MERGE; -EXPLAIN SELECT * FROM t1 NATURAL RIGHT JOIN -t2 WHERE b SOUNDS LIKE e AND d = 1; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -DROP TABLE t2, t1; -# -# Bug#46339 - crash on REPAIR TABLE merge table USE_FRM -# -CREATE TABLE t1 (c1 INT) ENGINE=MYISAM; -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1) INSERT_METHOD=LAST; -LOCK TABLE m1 READ; -REPAIR TABLE m1 USE_FRM; -Table Op Msg_type Msg_text -test.m1 repair Error Table 'm1' was locked with a READ lock and can't be updated -test.m1 repair status Operation failed -UNLOCK TABLES; -REPAIR TABLE m1 USE_FRM; -Table Op Msg_type Msg_text -test.m1 repair note The storage engine for the table doesn't support repair -DROP TABLE m1,t1; -CREATE TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1); -REPAIR TABLE m1 USE_FRM; -Table Op Msg_type Msg_text -test.m1 repair Warning Can't open table -test.m1 repair error Corrupt -CREATE TABLE t1 (f1 BIGINT) ENGINE = MyISAM; -REPAIR TABLE m1 USE_FRM; -Table Op Msg_type Msg_text -test.m1 repair note The storage engine for the table doesn't support repair -REPAIR TABLE m1; -Table Op Msg_type Msg_text -test.m1 repair note The storage engine for the table doesn't support repair -DROP TABLE m1, t1; -CREATE TEMPORARY TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1); -REPAIR TABLE m1 USE_FRM; -Table Op Msg_type Msg_text -test.m1 repair Error Table 'test.m1' doesn't exist -test.m1 repair error Corrupt -CREATE TEMPORARY TABLE t1 (f1 BIGINT) ENGINE=MyISAM; -REPAIR TABLE m1 USE_FRM; -Table Op Msg_type Msg_text -m1 repair error Cannot repair temporary table from .frm file -REPAIR TABLE m1; -Table Op Msg_type Msg_text -test.m1 repair note The storage engine for the table doesn't support repair -DROP TABLE m1, t1; -create temporary table t1_temp(i int); -create temporary table tm_temp_temp (i int) engine=merge union=(t1_temp) insert_method=last; -alter table tm_temp_temp insert_method=first; -check table tm_temp_temp; -Table Op Msg_type Msg_text -test.tm_temp_temp check status OK -drop temporary table t1_temp, tm_temp_temp; -End of 5.1 tests -# -# MDEV-4277: Crash inside mi_killed_in_mariadb() with myisammrg -# -create table t1 (a int); -insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); -create table t2 ( i int ) engine=myisam; -insert into t2 values (1),(2); -create table t3 (a int, b int, filler char(100), key(a), key(b)) engine=myisam; -create table t4 like t3; -insert into t3 -select A.a+10*B.a+100*C.a, -A.a+10*B.a+100*C.a, -'filler-data-FILLER-DATA-qqq' -from t1 A, t1 B, t1 C where C.a < 5; -insert into t4 -select A.a+10*B.a+100*C.a, -A.a+10*B.a+100*C.a, -'filler-data-FILLER-DATA-qqq' -from t1 A, t1 B, t1 C where C.a >= 5; -create table t5 like t3; -alter table t5 engine=merge; -alter table t5 union(t3, t4); -update t5 set b=999, a=999 where b>950; -explain -select * from t2, t5 where t5.a=999 and t5.b=999; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 2 -1 SIMPLE t5 index_merge a,b a,b 5,5 NULL 6 Using intersect(a,b); Using where; Using join buffer (flat, BNL join) -select * from t2, t5 where t5.a=999 and t5.b=999; -i a b filler -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -1 999 999 filler-data-FILLER-DATA-qqq -2 999 999 filler-data-FILLER-DATA-qqq -drop table t5; -drop table t1,t2,t3,t4; -End of 5.3 tests -CREATE TABLE t1(a INT, KEY(a)) ENGINE=merge; -SELECT MAX(a) FROM t1; -MAX(a) -NULL -DROP TABLE t1; -# -# An additional test case for Bug#27430 Crash in subquery code -# when in PS and table DDL changed after PREPARE -# -# Test merge table with too many merge children. -# -set @save_table_open_cache=@@global.table_open_cache; -# -# Set @@global.table_open_cache to minimum -# -set @@global.table_open_cache=400; -select @@table_open_cache; -@@table_open_cache -400 -set @a=null; -# -# Create 400 merge children -# -set @a=concat("create table t_parent (a int) union(", @a, -") insert_method=first engine=mrg_myisam"); -prepare stmt from @a; -execute stmt; -prepare stmt from "select * from t_parent"; -execute stmt; -execute stmt; -execute stmt; -deallocate prepare stmt; -# -# Create merge parent -# -# -# Cleanup -# -drop table t_parent; -set @@global.table_open_cache=@save_table_open_cache; -CREATE DATABASE mysql_test1; -CREATE TABLE t1 ... DATA DIRECTORY=... INDEX DIRECTORY=... -CREATE TABLE mysql_test1.t2 ... DATA DIRECTORY=... INDEX DIRECTORY=... -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,mysql_test1.t2) -INSERT_METHOD=LAST; -INSERT INTO t1 VALUES (1); -INSERT INTO mysql_test1.t2 VALUES (2); -SELECT * FROM m1; -c1 -1 -2 -DROP TABLE t1, mysql_test1.t2, m1; -DROP DATABASE mysql_test1; -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -INSERT INTO t1 (c1) VALUES (1); -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2) INSERT_METHOD=FIRST; -CREATE TABLE t3 (c1 INT); -INSERT INTO t3 (c1) VALUES (1); -CREATE FUNCTION f1() RETURNS INT RETURN (SELECT MAX(c1) FROM t3); -CREATE VIEW v1 AS SELECT foo.c1 c1, f1() c2, bar.c1 c3, f1() c4 -FROM tm1 foo, tm1 bar, t3; -SELECT * FROM v1; -c1 c2 c3 c4 -1 1 1 1 -DROP FUNCTION f1; -DROP VIEW v1; -DROP TABLE tm1, t1, t2, t3; -CREATE TEMPORARY TABLE t1 (c1 INT); -CREATE TEMPORARY TABLE t2 (c1 INT); -CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2) -INSERT_METHOD=FIRST; -CREATE FUNCTION f1() RETURNS INT RETURN (SELECT MAX(c1) FROM tm1); -INSERT INTO tm1 (c1) VALUES (1); -SELECT f1() FROM (SELECT 1) AS c1; -f1() -1 -DROP FUNCTION f1; -DROP TABLE tm1, t1, t2; -CREATE FUNCTION f1() RETURNS INT -BEGIN -CREATE TEMPORARY TABLE t1 (c1 INT); -CREATE TEMPORARY TABLE t2 (c1 INT); -CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2); -INSERT INTO t1 (c1) VALUES (1); -RETURN (SELECT MAX(c1) FROM tm1); -END| -SELECT f1() FROM (SELECT 1 UNION SELECT 1) c1; -f1() -1 -DROP FUNCTION f1; -DROP TABLE tm1, t1, t2; -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; -INSERT INTO tm1 VALUES (1); -SELECT * FROM tm1; -c1 -1 -DROP TABLE tm1, t1; -CREATE FUNCTION f1() RETURNS INT -BEGIN -INSERT INTO tm1 VALUES (1); -RETURN (SELECT MAX(c1) FROM tm1); -END| -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; -SELECT f1(); -f1() -1 -DROP FUNCTION f1; -DROP TABLE tm1, t1; -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; -LOCK TABLE tm1 WRITE; -INSERT INTO tm1 VALUES (1); -SELECT * FROM tm1; -c1 -1 -UNLOCK TABLES; -DROP TABLE tm1, t1; -CREATE FUNCTION f1() RETURNS INT -BEGIN -INSERT INTO tm1 VALUES (1); -RETURN (SELECT MAX(c1) FROM tm1); -END| -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; -LOCK TABLE tm1 WRITE; -SELECT f1(); -f1() -1 -UNLOCK TABLES; -DROP FUNCTION f1; -DROP TABLE tm1, t1; -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE t2 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; -CREATE TRIGGER t2_ai AFTER INSERT ON t2 -FOR EACH ROW INSERT INTO tm1 VALUES(11); -LOCK TABLE t2 WRITE; -INSERT INTO t2 VALUES (2); -SELECT * FROM tm1; -c1 -11 -SELECT * FROM t2; -c1 -2 -UNLOCK TABLES; -DROP TRIGGER t2_ai; -DROP TABLE tm1, t1, t2; -CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) -INSERT_METHOD=LAST; -INSERT INTO tm1 VALUES (1); -SELECT * FROM tm1; -c1 -1 -DROP TABLE tm1, t1; -CREATE FUNCTION f1() RETURNS INT -BEGIN -INSERT INTO tm1 VALUES (1); -RETURN (SELECT MAX(c1) FROM tm1); -END| -CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) -INSERT_METHOD=LAST; -SELECT f1(); -f1() -1 -DROP FUNCTION f1; -DROP TABLE tm1, t1; -CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) -INSERT_METHOD=LAST; -CREATE TABLE t9 (c1 INT) ENGINE=MyISAM; -LOCK TABLE t9 WRITE; -INSERT INTO tm1 VALUES (1); -SELECT * FROM tm1; -c1 -1 -UNLOCK TABLES; -DROP TABLE tm1, t1, t9; -CREATE FUNCTION f1() RETURNS INT -BEGIN -INSERT INTO tm1 VALUES (1); -RETURN (SELECT MAX(c1) FROM tm1); -END| -CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) -INSERT_METHOD=LAST; -CREATE TABLE t9 (c1 INT) ENGINE=MyISAM; -LOCK TABLE t9 WRITE; -SELECT f1(); -f1() -1 -UNLOCK TABLES; -DROP FUNCTION f1; -DROP TABLE tm1, t1, t9; -CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) -INSERT_METHOD=LAST; -CREATE TABLE t2 (c1 INT) ENGINE=MyISAM; -CREATE TRIGGER t2_ai AFTER INSERT ON t2 -FOR EACH ROW INSERT INTO tm1 VALUES(11); -LOCK TABLE t2 WRITE; -INSERT INTO t2 VALUES (2); -SELECT * FROM tm1; -c1 -11 -SELECT * FROM t2; -c1 -2 -UNLOCK TABLES; -DROP TRIGGER t2_ai; -DROP TABLE tm1, t1, t2; -# -# Don't allow an update of a MERGE child in a trigger -# if the table's already being modified by the main -# statement. -# -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) -INSERT_METHOD=LAST; -CREATE TRIGGER tm1_ai AFTER INSERT ON tm1 -FOR EACH ROW INSERT INTO t1 VALUES(11); -LOCK TABLE tm1 WRITE, t1 WRITE; -INSERT INTO tm1 VALUES (1); -ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger -SELECT * FROM tm1; -c1 -1 -UNLOCK TABLES; -LOCK TABLE t1 WRITE, tm1 WRITE; -INSERT INTO tm1 VALUES (1); -ERROR HY000: Can't update table 't1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger -SELECT * FROM tm1; -c1 -1 -1 -UNLOCK TABLES; -DROP TRIGGER tm1_ai; -DROP TABLE tm1, t1; -# -# Don't select MERGE child when trying to get a prelocked table. -# -# Due to a limitation demonstrated by the previous test -# we can no longer use a write-locked prelocked table. -# The test is kept for historical purposes. -# -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) -INSERT_METHOD=LAST; -CREATE TRIGGER tm1_ai AFTER INSERT ON tm1 -FOR EACH ROW SELECT max(c1) FROM t1 INTO @var; -LOCK TABLE tm1 WRITE, t1 WRITE; -INSERT INTO tm1 VALUES (1); -SELECT * FROM tm1; -c1 -1 -UNLOCK TABLES; -LOCK TABLE t1 WRITE, tm1 WRITE; -INSERT INTO tm1 VALUES (1); -SELECT * FROM tm1; -c1 -1 -1 -UNLOCK TABLES; -DROP TRIGGER tm1_ai; -DROP TABLE tm1, t1; -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE t2 (c1 INT) ENGINE=MyISAM; -CREATE TABLE t3 (c1 INT) ENGINE=MyISAM; -CREATE TABLE t4 (c1 INT) ENGINE=MyISAM; -CREATE TABLE t5 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2,t3,t4,t5) -INSERT_METHOD=LAST; -CREATE TRIGGER t2_au AFTER UPDATE ON t2 -FOR EACH ROW SELECT MAX(c1) FROM t1 INTO @var; -CREATE FUNCTION f1() RETURNS INT -RETURN (SELECT MAX(c1) FROM t4); -LOCK TABLE tm1 WRITE, t1 WRITE, t2 WRITE, t3 WRITE, t4 WRITE, t5 WRITE; -INSERT INTO t1 VALUES(1); -INSERT INTO t2 VALUES(2); -INSERT INTO t3 VALUES(3); -INSERT INTO t4 VALUES(4); -INSERT INTO t5 VALUES(5); -connect con1,localhost,root,,; -UPDATE t2, tm1 SET t2.c1=f1(); -connection default; -FLUSH TABLES; -FLUSH TABLES; -UNLOCK TABLES; -connection con1; -disconnect con1; -connection default; -SELECT * FROM tm1; -c1 -1 -4 -3 -4 -5 -DROP TRIGGER t2_au; -DROP FUNCTION f1; -DROP TABLE tm1, t1, t2, t3, t4, t5; -# -# Bug#47633 - assert in ha_myisammrg::info during OPTIMIZE -# -CREATE TEMPORARY TABLE t1 (c1 INT); -ALTER TABLE t1 ENGINE=MERGE UNION(t_not_exists,t1); -OPTIMIZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 optimize Error Table 'test.t_not_exists' doesn't exist -test.t1 optimize Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -test.t1 optimize error Corrupt -DROP TABLE t1; -# -# Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine -# More tests with TEMPORARY MERGE table and permanent children. -# First without locked tables. -# -# -CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM; -CREATE TABLE t2 (c1 INT, c2 INT) ENGINE=MyISAM; -CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TEMPORARY TABLE `m1` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -SELECT * FROM m1; -c1 c2 -INSERT INTO t1 VALUES (111, 121); -INSERT INTO m1 VALUES (211, 221); -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -SELECT * FROM t1; -c1 c2 -111 121 -SELECT * FROM t2; -c1 c2 -211 221 -# -ALTER TABLE m1 RENAME m2; -SHOW CREATE TABLE m2; -Table Create Table -m2 CREATE TEMPORARY TABLE `m2` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -SELECT * FROM m2; -c1 c2 -111 121 -211 221 -# -CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -ALTER TABLE m2 RENAME m1; -ERROR 42S01: Table 'm1' already exists -DROP TABLE m1; -ALTER TABLE m2 RENAME m1; -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TEMPORARY TABLE `m1` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -# -ALTER TABLE m1 ADD COLUMN c3 INT; -INSERT INTO m1 VALUES (212, 222, 232); -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -SELECT * FROM m1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -ALTER TABLE t1 ADD COLUMN c3 INT; -ALTER TABLE t2 ADD COLUMN c3 INT; -INSERT INTO m1 VALUES (212, 222, 232); -SELECT * FROM m1; -c1 c2 c3 -111 121 NULL -211 221 NULL -212 222 232 -# -ALTER TABLE m1 DROP COLUMN c3; -INSERT INTO m1 VALUES (213, 223); -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -SELECT * FROM m1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -ALTER TABLE t1 DROP COLUMN c3; -ALTER TABLE t2 DROP COLUMN c3; -INSERT INTO m1 VALUES (213, 223); -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -212 222 -213 223 -# -CREATE TABLE t3 (c1 INT, c2 INT) ENGINE=MyISAM; -ALTER TABLE m1 UNION=(t1,t2,t3); -INSERT INTO m1 VALUES (311, 321); -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -212 222 -213 223 -311 321 -SELECT * FROM t1; -c1 c2 -111 121 -SELECT * FROM t2; -c1 c2 -211 221 -212 222 -213 223 -SELECT * FROM t3; -c1 c2 -311 321 -# -CREATE TEMPORARY TABLE t4 (c1 INT, c2 INT) ENGINE=MyISAM; -ALTER TABLE m1 UNION=(t1,t2,t3,t4); -INSERT INTO m1 VALUES (411, 421); -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -212 222 -213 223 -311 321 -411 421 -SELECT * FROM t1; -c1 c2 -111 121 -SELECT * FROM t2; -c1 c2 -211 221 -212 222 -213 223 -SELECT * FROM t3; -c1 c2 -311 321 -SELECT * FROM t4; -c1 c2 -411 421 -# -ALTER TABLE m1 ENGINE=MyISAM; -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TEMPORARY TABLE `m1` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -INSERT INTO m1 VALUES (511, 521); -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -212 222 -213 223 -311 321 -411 421 -511 521 -# -ALTER TABLE m1 ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -212 222 -213 223 -SELECT * FROM t1; -c1 c2 -111 121 -SELECT * FROM t2; -c1 c2 -211 221 -212 222 -213 223 -# -CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM; -INSERT INTO t1 VALUES (611, 621); -SELECT * FROM m1; -c1 c2 -611 621 -211 221 -212 222 -213 223 -DROP TABLE t1; -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -212 222 -213 223 -# -# -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TEMPORARY TABLE `m1` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -# -CREATE TABLE m2 SELECT * FROM m1; -SHOW CREATE TABLE m2; -Table Create Table -m2 CREATE TABLE `m2` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -SELECT * FROM m2; -c1 c2 -111 121 -211 221 -212 222 -213 223 -DROP TABLE m2; -# -CREATE TEMPORARY TABLE m2 SELECT * FROM m1; -SHOW CREATE TABLE m2; -Table Create Table -m2 CREATE TEMPORARY TABLE `m2` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -SELECT * FROM m2; -c1 c2 -111 121 -211 221 -212 222 -213 223 -DROP TABLE m2; -# -CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) -INSERT_METHOD=LAST; -SELECT * FROM m2; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DROP TABLE m2; -# -CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) -INSERT_METHOD=LAST SELECT * FROM m1; -ERROR HY000: 'test.m2' is not of type 'BASE TABLE' -# -CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) -INSERT_METHOD=LAST SELECT * FROM m1; -ERROR HY000: 'test.m2' is not of type 'BASE TABLE' -# -CREATE TABLE m2 LIKE m1; -SHOW CREATE TABLE m2; -Table Create Table -m2 CREATE TABLE `m2` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -SELECT * FROM m2; -c1 c2 -111 121 -211 221 -212 222 -213 223 -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -c1 c2 -111 121 -211 221 -212 222 -213 223 -111 121 -211 221 -212 222 -213 223 -DROP TABLE m2; -# -CREATE TEMPORARY TABLE m2 LIKE m1; -SHOW CREATE TABLE m2; -Table Create Table -m2 CREATE TEMPORARY TABLE `m2` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -SELECT * FROM m2; -c1 c2 -111 121 -211 221 -212 222 -213 223 -111 121 -211 221 -212 222 -213 223 -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -c1 c2 -111 121 -211 221 -212 222 -213 223 -111 121 -211 221 -212 222 -213 223 -111 121 -211 221 -212 222 -213 223 -111 121 -211 221 -212 222 -213 223 -DROP TABLE m2; -# -CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) -INSERT_METHOD=LAST; -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -c1 c2 -311 321 -411 421 -111 121 -211 221 -212 222 -213 223 -111 121 -211 221 -212 222 -213 223 -111 121 -211 221 -212 222 -213 223 -111 121 -211 221 -212 222 -213 223 -# -# -LOCK TABLE m1 WRITE, m2 WRITE; -SELECT * FROM m1,m2 WHERE m1.c1=m2.c1; -c1 c2 c1 c2 -111 121 111 121 -111 121 111 121 -111 121 111 121 -111 121 111 121 -211 221 211 221 -211 221 211 221 -211 221 211 221 -211 221 211 221 -212 222 212 222 -212 222 212 222 -212 222 212 222 -212 222 212 222 -213 223 213 223 -213 223 213 223 -213 223 213 223 -213 223 213 223 -111 121 111 121 -111 121 111 121 -111 121 111 121 -111 121 111 121 -211 221 211 221 -211 221 211 221 -211 221 211 221 -211 221 211 221 -212 222 212 222 -212 222 212 222 -212 222 212 222 -212 222 212 222 -213 223 213 223 -213 223 213 223 -213 223 213 223 -213 223 213 223 -111 121 111 121 -111 121 111 121 -111 121 111 121 -111 121 111 121 -211 221 211 221 -211 221 211 221 -211 221 211 221 -211 221 211 221 -212 222 212 222 -212 222 212 222 -212 222 212 222 -212 222 212 222 -213 223 213 223 -213 223 213 223 -213 223 213 223 -213 223 213 223 -111 121 111 121 -111 121 111 121 -111 121 111 121 -111 121 111 121 -211 221 211 221 -211 221 211 221 -211 221 211 221 -211 221 211 221 -212 222 212 222 -212 222 212 222 -212 222 212 222 -212 222 212 222 -213 223 213 223 -213 223 213 223 -213 223 213 223 -213 223 213 223 -UNLOCK TABLES; -DROP TABLE t1, t2, t3, t4, m1, m2; -# -# Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine -# More tests with TEMPORARY MERGE table and permanent children. -# (continued) Now the same with locked table. -# -CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM; -CREATE TABLE t2 (c1 INT, c2 INT) ENGINE=MyISAM; -CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -SHOW CREATE TABLE t1; -Table Create Table -t1 CREATE TABLE `t1` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TEMPORARY TABLE `m1` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -SELECT * FROM m1; -c1 c2 -INSERT INTO t1 VALUES (111, 121); -INSERT INTO m1 VALUES (211, 221); -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -SELECT * FROM t1; -c1 c2 -111 121 -SELECT * FROM t2; -c1 c2 -211 221 -# -LOCK TABLE m1 WRITE, t1 WRITE, t2 WRITE; -# -ALTER TABLE m1 RENAME m2; -SHOW CREATE TABLE m2; -Table Create Table -m2 CREATE TEMPORARY TABLE `m2` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -SELECT * FROM m2; -c1 c2 -111 121 -211 221 -# -CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -ALTER TABLE m2 RENAME m1; -ERROR 42S01: Table 'm1' already exists -DROP TABLE m1; -ALTER TABLE m2 RENAME m1; -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TEMPORARY TABLE `m1` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -# -ALTER TABLE m1 ADD COLUMN c3 INT; -INSERT INTO m1 VALUES (212, 222, 232); -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -SELECT * FROM m1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -ALTER TABLE t1 ADD COLUMN c3 INT; -ALTER TABLE t2 ADD COLUMN c3 INT; -INSERT INTO m1 VALUES (212, 222, 232); -SELECT * FROM m1; -c1 c2 c3 -111 121 NULL -211 221 NULL -212 222 232 -# -ALTER TABLE m1 DROP COLUMN c3; -INSERT INTO m1 VALUES (213, 223); -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -SELECT * FROM m1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -ALTER TABLE t1 DROP COLUMN c3; -ALTER TABLE t2 DROP COLUMN c3; -INSERT INTO m1 VALUES (213, 223); -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -212 222 -213 223 -# -UNLOCK TABLES; -CREATE TABLE t3 (c1 INT, c2 INT) ENGINE=MyISAM; -ALTER TABLE m1 UNION=(t1,t2,t3); -LOCK TABLE m1 WRITE; -INSERT INTO m1 VALUES (311, 321); -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -212 222 -213 223 -311 321 -SELECT * FROM t1; -c1 c2 -111 121 -SELECT * FROM t2; -c1 c2 -211 221 -212 222 -213 223 -SELECT * FROM t3; -c1 c2 -311 321 -# -CREATE TEMPORARY TABLE t4 (c1 INT, c2 INT) ENGINE=MyISAM; -ALTER TABLE m1 UNION=(t1,t2,t3,t4); -INSERT INTO m1 VALUES (411, 421); -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -212 222 -213 223 -311 321 -411 421 -SELECT * FROM t1; -c1 c2 -111 121 -SELECT * FROM t2; -c1 c2 -211 221 -212 222 -213 223 -SELECT * FROM t3; -c1 c2 -311 321 -SELECT * FROM t4; -c1 c2 -411 421 -# -ALTER TABLE m1 ENGINE=MyISAM; -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TEMPORARY TABLE `m1` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -INSERT INTO m1 VALUES (511, 521); -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -212 222 -213 223 -311 321 -411 421 -511 521 -# -ALTER TABLE m1 ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -212 222 -213 223 -SELECT * FROM t1; -c1 c2 -111 121 -SELECT * FROM t2; -c1 c2 -211 221 -212 222 -213 223 -# -CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM; -INSERT INTO t1 VALUES (611, 621); -SELECT * FROM m1; -c1 c2 -611 621 -211 221 -212 222 -213 223 -DROP TABLE t1; -SELECT * FROM m1; -c1 c2 -111 121 -211 221 -212 222 -213 223 -# -# -SHOW CREATE TABLE m1; -Table Create Table -m1 CREATE TEMPORARY TABLE `m1` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -CREATE TABLE m2 SELECT * FROM m1; -ERROR HY000: Table 'm2' was not locked with LOCK TABLES -# -CREATE TEMPORARY TABLE m2 SELECT * FROM m1; -SHOW CREATE TABLE m2; -Table Create Table -m2 CREATE TEMPORARY TABLE `m2` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci -SELECT * FROM m2; -c1 c2 -111 121 -211 221 -212 222 -213 223 -DROP TABLE m2; -# -CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) -INSERT_METHOD=LAST; -SELECT * FROM m2; -c1 c2 -311 321 -411 421 -LOCK TABLE m1 WRITE, m2 WRITE; -UNLOCK TABLES; -DROP TABLE m2; -LOCK TABLE m1 WRITE; -# -# ER_TABLE_NOT_LOCKED is returned in ps-protocol -CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) -INSERT_METHOD=LAST SELECT * FROM m1; -Got one of the listed errors -# -CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) -INSERT_METHOD=LAST SELECT * FROM m1; -ERROR HY000: 'test.m2' is not of type 'BASE TABLE' -# -CREATE TEMPORARY TABLE m2 LIKE m1; -SHOW CREATE TABLE m2; -Table Create Table -m2 CREATE TEMPORARY TABLE `m2` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -LOCK TABLE m1 WRITE, m2 WRITE; -SHOW CREATE TABLE m2; -Table Create Table -m2 CREATE TEMPORARY TABLE `m2` ( - `c1` int(11) DEFAULT NULL, - `c2` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=LAST UNION=(`t1`,`t2`) -SELECT * FROM m2; -c1 c2 -111 121 -211 221 -212 222 -213 223 -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -c1 c2 -111 121 -211 221 -212 222 -213 223 -111 121 -211 221 -212 222 -213 223 -DROP TABLE m2; -# -CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) -INSERT_METHOD=LAST; -LOCK TABLE m1 WRITE, m2 WRITE; -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -c1 c2 -311 321 -411 421 -111 121 -211 221 -212 222 -213 223 -111 121 -211 221 -212 222 -213 223 -# -UNLOCK TABLES; -DROP TABLE t1, t2, t3, t4, m1, m2; -# -# Bug47098 assert in MDL_context::destroy on HANDLER -# <damaged merge table> OPEN -# -# Test that merge tables are closed correctly when opened using -# HANDLER ... OPEN. -# The general case. -connect con1,localhost,root,,; -CREATE TABLE t1 (c1 int); -CREATE TABLE t2 (c1 int); -CREATE TABLE t3 (c1 int) ENGINE = MERGE UNION (t1,t2); -START TRANSACTION; -HANDLER t3 OPEN; -ERROR HY000: Storage engine MRG_MyISAM of the table `test`.`t3` doesn't have this option -DROP TABLE t1, t2, t3; -connection default; -# all mdl_tickets must have been released. -disconnect con1; -# The bug-specific case. -connect con1,localhost,root,,; -CREATE TABLE t1 (c1 int); -CREATE TABLE t2 (c1 int); -CREATE TABLE t3 (c1 int) ENGINE = MERGE UNION (t1,t2); -DROP TABLE t2; -START TRANSACTION; -HANDLER t3 OPEN; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DROP TABLE t1, t3; -connection default; -# all mdl_tickets must have been released. -disconnect con1; -# -# A test case for Bug#47648 main.merge fails sporadically -# -# Make sure we correctly maintain lex->query_tables_last_own. -# -create table t1 (c1 int not null); -create table t2 (c1 int not null); -create table t3 (c1 int not null); -create function f1 () returns int return (select max(c1) from t3); -create table t4 (c1 int not null) engine=merge union=(t1,t2) insert_method=last ; -select * from t4 where c1 < f1(); -c1 -prepare stmt from "select * from t4 where c1 < f1()"; -execute stmt; -c1 -execute stmt; -c1 -execute stmt; -c1 -drop function f1; -execute stmt; -ERROR 42000: FUNCTION test.f1 does not exist -execute stmt; -ERROR 42000: FUNCTION test.f1 does not exist -drop table t4, t3, t2, t1; -# -# Bug#51240 ALTER TABLE of a locked MERGE table fails -# -CREATE TABLE t1 (c1 INT); -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1); -LOCK TABLE m1 WRITE; -ALTER TABLE m1 ADD INDEX (c1); -UNLOCK TABLES; -DROP TABLE m1, t1; -# -# Locking the merge table won't implicitly lock children. -# -CREATE TABLE t1 (c1 INT); -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1); -LOCK TABLE m1 WRITE; -ALTER TABLE t1 ADD INDEX (c1); -ERROR HY000: Table 't1' was locked with a READ lock and can't be updated -LOCK TABLE m1 WRITE, t1 WRITE; -ALTER TABLE t1 ADD INDEX (c1); -UNLOCK TABLES; -DROP TABLE m1, t1; -# -# Test for bug #37371 "CREATE TABLE LIKE merge loses UNION parameter" -# -create table t1 (i int) engine=myisam; -create table m1 (i int) engine=mrg_myisam union=(t1) insert_method=first; -create table m2 like m1; -# Table definitions should match -show create table m1; -Table Create Table -m1 CREATE TABLE `m1` ( - `i` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=FIRST UNION=(`t1`) -show create table m2; -Table Create Table -m2 CREATE TABLE `m2` ( - `i` int(11) DEFAULT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci INSERT_METHOD=FIRST UNION=(`t1`) -drop tables m1, m2, t1; -# -# Test case for Bug#54811 "Assert in mysql_lock_have_duplicate()" -# Check that unique_table() works correctly for merge tables. -# -create table t1 (a int); -create table t2 (a int); -create table t3 (b int); -create view v1 as select * from t3,t1; -create table m1 (a int) engine=merge union (t1, t2) insert_method=last; -create table m2 (a int) engine=merge union (t1, t2) insert_method=first; -create temporary table tmp (b int); -insert into tmp (b) values (1); -insert into t1 (a) values (1); -insert into t3 (b) values (1); -insert into m1 (a) values ((select max(a) from m1)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data -insert into m1 (a) values ((select max(a) from m2)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data -insert into m1 (a) values ((select max(a) from t1)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data -insert into m1 (a) values ((select max(a) from t2)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data -insert into m1 (a) values ((select max(a) from t3, m1)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data -insert into m1 (a) values ((select max(a) from t3, m2)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data -insert into m1 (a) values ((select max(a) from t3, t1)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data -insert into m1 (a) values ((select max(a) from t3, t2)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data -insert into m1 (a) values ((select max(a) from tmp, m1)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data -insert into m1 (a) values ((select max(a) from tmp, m2)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data -insert into m1 (a) values ((select max(a) from tmp, t1)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data -insert into m1 (a) values ((select max(a) from tmp, t2)); -ERROR HY000: Table 'm1' is specified twice, both as a target for 'INSERT' and as a separate source for data -insert into m1 (a) values ((select max(a) from v1)); -ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'm1' -insert into m1 (a) values ((select max(a) from tmp, v1)); -ERROR HY000: The definition of table 'v1' prevents operation INSERT on table 'm1' -drop view v1; -drop temporary table tmp; -drop table t1, t2, t3, m1, m2; -# -# Bug#56494 Segfault in upgrade_shared_lock_to_exclusive() for -# REPAIR of merge table -# -CREATE TABLE t1(a INT); -ALTER TABLE t1 engine= MERGE UNION (t_not_exists); -ANALYZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 analyze Error Table 'test.t_not_exists' doesn't exist -test.t1 analyze Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -test.t1 analyze error Corrupt -CHECK TABLE t1; -Table Op Msg_type Msg_text -test.t1 check Error Table 'test.t_not_exists' is differently defined or of non-MyISAM type or doesn't exist -test.t1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -test.t1 check error Corrupt -CHECKSUM TABLE t1; -Table Checksum -test.t1 NULL -Warnings: -Error 1146 Table 'test.t_not_exists' doesn't exist -Error 1168 Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -OPTIMIZE TABLE t1; -Table Op Msg_type Msg_text -test.t1 optimize Error Table 'test.t_not_exists' doesn't exist -test.t1 optimize Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -test.t1 optimize error Corrupt -REPAIR TABLE t1; -Table Op Msg_type Msg_text -test.t1 repair Error Table 'test.t_not_exists' is differently defined or of non-MyISAM type or doesn't exist -test.t1 repair Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -test.t1 repair error Corrupt -REPAIR TABLE t1 USE_FRM; -Table Op Msg_type Msg_text -test.t1 repair Warning Can't open table -test.t1 repair error Corrupt -DROP TABLE t1; -CREATE TABLE t1(a INT); -CREATE TABLE t2(a INT) engine= MERGE UNION (t1); -REPAIR TABLE t2 USE_FRM; -Table Op Msg_type Msg_text -test.t2 repair note The storage engine for the table doesn't support repair -DROP TABLE t1, t2; -# -# Bug#57002 Assert in upgrade_shared_lock_to_exclusive() -# for ALTER TABLE + MERGE tables -# -CREATE TABLE t1(a INT) engine=myisam; -CREATE TABLE m1(a INT) engine=merge UNION(t1); -LOCK TABLES t1 READ, m1 WRITE; -ALTER TABLE t1 engine=myisam; -ERROR HY000: Table 't1' was locked with a READ lock and can't be updated -UNLOCK TABLES; -DROP TABLE m1, t1; -# -# Test for bug #11754210 - "45777: CHECK TABLE DOESN'T SHOW ALL -# PROBLEMS FOR MERGE TABLE COMPLIANCE IN 5.1" -# -create table t1(id int) engine=myisam; -create view t3 as select 1 as id; -create table t4(id int) engine=memory; -create table m1(id int) engine=merge union=(t1,t2,t3,t4); -select * from m1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -# The below CHECK and REPAIR TABLE statements should -# report all problems with underlying tables: -# - absence of 't2', -# - missing base table for 't3', -# - wrong engine of 't4'. -check table m1; -Table Op Msg_type Msg_text -test.m1 check Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist -test.m1 check Error Table 'test.t3' is differently defined or of non-MyISAM type or doesn't exist -test.m1 check Error Table 'test.t4' is differently defined or of non-MyISAM type or doesn't exist -test.m1 check Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -test.m1 check error Corrupt -repair table m1; -Table Op Msg_type Msg_text -test.m1 repair Error Table 'test.t2' is differently defined or of non-MyISAM type or doesn't exist -test.m1 repair Error Table 'test.t3' is differently defined or of non-MyISAM type or doesn't exist -test.m1 repair Error Table 'test.t4' is differently defined or of non-MyISAM type or doesn't exist -test.m1 repair Error Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -test.m1 repair error Corrupt -# Clean-up. -drop tables m1, t1, t4; -drop view t3; -# -# MDEV-10424 Assertion `ticket == __null' failed in MDL_request::set_type -# -CREATE TABLE t1 (f1 INT) ENGINE=MyISAM; -CREATE TABLE tmerge (f1 INT) ENGINE=MERGE UNION=(t1); -PREPARE stmt FROM "ANALYZE TABLE tmerge, t1"; -EXECUTE stmt; -Table Op Msg_type Msg_text -test.tmerge analyze status Engine-independent statistics collected -test.tmerge analyze note The storage engine for the table doesn't support analyze -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status Table is already up to date -EXECUTE stmt; -Table Op Msg_type Msg_text -test.tmerge analyze status Engine-independent statistics collected -test.tmerge analyze note The storage engine for the table doesn't support analyze -test.t1 analyze status Engine-independent statistics collected -test.t1 analyze status Table is already up to date -DEALLOCATE PREPARE stmt; -DROP TABLE t1, tmerge; -# -# End of 5.5 tests -# -# -# Additional coverage for refactoring which is made as part -# of fix for bug #27480 "Extend CREATE TEMPORARY TABLES privilege -# to allow temp table operations". -# -# Check that prelocking works correctly for various variants of -# merge tables. -# -create table t1 (j int); -insert into t1 values (1); -create function f1() returns int return (select count(*) from m1); -create temporary table t2 (a int) engine=myisam; -insert into t2 values (1); -create temporary table m1 (a int) engine=merge union=(t2); -select f1() from t1; -f1() -1 -drop tables t2, m1; -create table t2 (a int) engine=myisam; -insert into t2 values (1); -create table m1 (a int) engine=merge union=(t2); -select f1() from t1; -f1() -1 -drop table m1; -create temporary table m1 (a int) engine=merge union=(t2); -select f1() from t1; -f1() -1 -drop tables t1, t2, m1; -drop function f1; -# -# Check that REPAIR/CHECK and CHECKSUM statements work correctly -# for various variants of merge tables. -create table t1 (a int) engine=myisam; -insert into t1 values (1); -create table m1 (a int) engine=merge union=(t1); -check table m1; -Table Op Msg_type Msg_text -test.m1 check status OK -repair table m1; -Table Op Msg_type Msg_text -test.m1 repair note The storage engine for the table doesn't support repair -checksum table m1; -Table Checksum -test.m1 3459908756 -drop tables t1, m1; -create temporary table t1 (a int) engine=myisam; -insert into t1 values (1); -create temporary table m1 (a int) engine=merge union=(t1); -check table m1; -Table Op Msg_type Msg_text -test.m1 check status OK -repair table m1; -Table Op Msg_type Msg_text -test.m1 repair note The storage engine for the table doesn't support repair -checksum table m1; -Table Checksum -test.m1 3459908756 -drop tables t1, m1; -create table t1 (a int) engine=myisam; -insert into t1 values (1); -create temporary table m1 (a int) engine=merge union=(t1); -check table m1; -Table Op Msg_type Msg_text -test.m1 check status OK -repair table m1; -Table Op Msg_type Msg_text -test.m1 repair note The storage engine for the table doesn't support repair -checksum table m1; -Table Checksum -test.m1 3459908756 -drop tables t1, m1; -CREATE TABLE t1(a INT); -CREATE TABLE m1(a INT) ENGINE = MERGE UNION (q1, q2); -CREATE TRIGGER trg1 BEFORE DELETE ON t1 -FOR EACH ROW -INSERT INTO m1 VALUES (1); -DELETE FROM t1; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DROP TRIGGER trg1; -DROP TABLE t1; -DROP TABLE m1; -set global default_storage_engine=@save_default_storage_engine; -# -# MDEV-27407 Different ASC/DESC index attributes on MERGE and underlying table can cause wrong results -# -create table t (a int, key(a desc)) engine=myisam; -create table tm (a int, key(a)) engine=merge union(t); -select * from tm; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -drop table tm, t; -# -# MDEV-27586 Auto-increment does not work with DESC on MERGE table -# -create table t (a int not null, primary key(a desc)) engine=myisam; -create table tm (a int not null auto_increment, primary key(a desc)) engine=merge union=(t) insert_method=first; -insert into tm () values (); -insert into tm () values (); -insert into tm () values (); -select * from tm; -a -3 -2 -1 -drop table tm, t; -# -# End of 10.8 tests -# -# -# MDEV-30088 Assertion `cond_selectivity <= 1.0' failed in get_range_limit_read_cost -# -CREATE TABLE t1 (a TIMESTAMP, KEY(a)) ENGINE=MRG_MyISAM; -explain SELECT a, COUNT(*) FROM t1 WHERE a >= '2000-01-01 00:00:00' GROUP BY a; -id select_type table type possible_keys key key_len ref rows Extra -1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables -SELECT a, COUNT(*) FROM t1 WHERE a >= '2000-01-01 00:00:00' GROUP BY a; -a COUNT(*) -DROP TABLE t1; -# -# MDEV-30525: Assertion `ranges > 0' fails in IO_AND_CPU_COST handler::keyread_time -# -CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM; -CREATE TABLE t2 (a INT, KEY(a)) ENGINE=MyISAM; -CREATE TABLE tm (a INT, KEY(a)) ENGINE=MRG_MyISAM UNION=(t1,t2); -SELECT DISTINCT a FROM tm WHERE a > 50; -a -DROP TABLE tm, t1, t2; -# Testcase 2: -CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM; -CREATE TABLE t2 (a INT, KEY(a)) ENGINE=MyISAM; -CREATE TABLE tm (a INT, KEY(a)) ENGINE=MERGE UNION = (t1, t2) INSERT_METHOD=FIRST; -ANALYZE TABLE tm PERSISTENT FOR ALL; -Table Op Msg_type Msg_text -test.tm analyze status Engine-independent statistics collected -test.tm analyze note The storage engine for the table doesn't support analyze -SELECT DISTINCT a FROM (SELECT * FROM tm WHERE a iS NOT NULL) AS sq; -a -DROP TABLE tm, t1, t2; -# -# MDEV-30568 Assertion `cond_selectivity <= 1.000000001' failed in get_range_limit_read_cost -# -CREATE TABLE t1 (f INT, KEY(f)) ENGINE=MyISAM; -CREATE TABLE t2 (f INT, KEY(f)) ENGINE=MyISAM; -CREATE TABLE tm (f INT, KEY(f)) ENGINE=MERGE UNION = (t1, t2); -SELECT DISTINCT f FROM tm WHERE f IN (47, 126, 97, 48, 73, 0); -f -DROP TABLE tm, t1, t2; -# -# End of 11.0 tests -# -# -# MDEV-29174: UPDATE of view that uses MERGE table -# -CREATE TABLE t1 (a int) ENGINE=MERGE; -CREATE VIEW v1 AS SELECT a FROM t1; -UPDATE v1 SET a=0; -DROP VIEW v1; -DROP TABLE t1; -# End of 11.1 tests diff --git a/mysql-test/main/merge.test b/mysql-test/main/merge.test deleted file mode 100644 index f8f421994e9..00000000000 --- a/mysql-test/main/merge.test +++ /dev/null @@ -1,2934 +0,0 @@ -# -# Test of MERGE TABLES -# - -# Save the initial number of concurrent sessions. ---source include/count_sessions.inc - -# MERGE tables require MyISAM tables -set @save_default_storage_engine=@@global.default_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 - -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"); -INSERT INTO t2 (message) VALUES ("Testing"),("table"),("t2"); -create table t3 (a int not null, b char(20), key(a)) engine=MERGE UNION=(t1,t2); -select * from t3; -select * from t3 order by a desc; -drop table t3; -insert into t1 select NULL,message from t2; -insert into t2 select NULL,message from t1; -insert into t1 select NULL,message from t2; -insert into t2 select NULL,message from t1; -insert into t1 select NULL,message from t2; -insert into t2 select NULL,message from t1; -insert into t1 select NULL,message from t2; -insert into t2 select NULL,message from t1; -insert into t1 select NULL,message from t2; -insert into t2 select NULL,message from t1; -insert into t1 select NULL,message from t2; -create table t3 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,test.t2); -explain select * from t3 where a < 10; -explain select * from t3 where a > 10 and a < 20; -select * from t3 where a = 10; -select * from t3 where a < 10; -select * from t3 where a > 10 and a < 20; -explain select a from t3 order by a desc limit 10; -select a from t3 order by a desc limit 10; -select a from t3 order by a desc limit 300,10; -delete from t3 where a=3; -select * from t3 where a < 10; -delete from t3 where a >= 6 and a <= 8; -select * from t3 where a < 10; -update t3 set a=3 where a=9; -select * from t3 where a < 10; -update t3 set a=6 where a=7; -select * from t3 where a < 10; -show create table t3; - -# The following should give errors -create table t4 (a int not null, b char(10), key(a)) engine=MERGE UNION=(t1,t2); ---error 1168 -select * from t4; ---error 1168 -alter table t4 add column c int; -flush tables; ---error 1168 -select * from t4; - -# -# Test tables in different databases -# -create database mysqltest; -create table mysqltest.t6 (a int not null primary key auto_increment, message char(20)); -create table t5 (a int not null, b char(20), key(a)) engine=MERGE UNION=(test.t1,mysqltest.t6); -show create table t5; -alter table t5 engine=myisam; -drop table t5, mysqltest.t6; -drop database mysqltest; - -# Because of windows, it's important that we drop the merge tables first! -drop table t4,t3,t1,t2; - -create table t1 (c char(10)) engine=myisam; -create table t2 (c char(10)) engine=myisam; -create table t3 (c char(10)) union=(t1,t2) engine=merge; -insert into t1 (c) values ('test1'); -insert into t1 (c) values ('test1'); -insert into t1 (c) values ('test1'); -insert into t2 (c) values ('test2'); -insert into t2 (c) values ('test2'); -insert into t2 (c) values ('test2'); -select * from t3; -select * from t3; -delete from t3 where 1=1; -select * from t3; -select * from t1; -drop table t3,t2,t1; - -# -# Test 2 -# - -CREATE TABLE t1 (incr int not null, othr int not null, primary key(incr)); -CREATE TABLE t2 (incr int not null, othr int not null, primary key(incr)); -CREATE TABLE t3 (incr int not null, othr int not null, primary key(incr)) -ENGINE=MERGE UNION=(t1,t2); - -SELECT * from t3; - -INSERT INTO t1 VALUES ( 1,10),( 3,53),( 5,21),( 7,12),( 9,17); -INSERT INTO t2 VALUES ( 2,24),( 4,33),( 6,41),( 8,26),( 0,32); -INSERT INTO t1 VALUES (11,20),(13,43),(15,11),(17,22),(19,37); -INSERT INTO t2 VALUES (12,25),(14,31),(16,42),(18,27),(10,30); - -SELECT * from t3 where incr in (1,2,3,4) order by othr; -alter table t3 UNION=(t1); -select count(*) from t3; -alter table t3 UNION=(t1,t2); -select count(*) from t3; -alter table t3 ENGINE=MYISAM; -select count(*) from t3; - -# Test that ALTER TABLE rembers the old UNION - -drop table t3; -CREATE TABLE t3 (incr int not null, othr int not null, primary key(incr)) -ENGINE=MERGE UNION=(t1,t2); -show create table t3; -alter table t3 drop primary key; -show create table t3; - -drop table t3,t2,t1; - -# -# Test table without unions -# -create table t1 (a int not null, key(a)) engine=merge; -select * from t1; -drop table t1; - -# -# Bug in flush tables combined with MERGE tables -# - -create table t1 (a int not null, b int not null, key(a,b)); -create table t2 (a int not null, b int not null, key(a,b)); -create table t3 (a int not null, b int not null, key(a,b)) ENGINE=MERGE UNION=(t1,t2); -insert into t1 values (1,2),(2,1),(0,0),(4,4),(5,5),(6,6); -insert into t2 values (1,1),(2,2),(0,0),(4,4),(5,5),(6,6); -flush tables; -select * from t3 where a=1 order by b limit 2; -drop table t3,t1,t2; - -# -# [phi] testing INSERT_METHOD stuff -# - -# first testing of common stuff with new parameters -create table t1 (a int not null, b int not null auto_increment, primary key(a,b)); -create table t2 (a int not null, b int not null auto_increment, primary key(a,b)); -create table t3 (a int not null, b int not null, key(a,b)) UNION=(t1,t2) INSERT_METHOD=NO; -create table t4 (a int not null, b int not null, key(a,b)) ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=NO; -create table t5 (a int not null, b int not null auto_increment, primary key(a,b)) ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=FIRST; -create table t6 (a int not null, b int not null auto_increment, primary key(a,b)) ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=LAST; -show create table t3; -show create table t4; -show create table t5; -show create table t6; -insert into t1 values (1,NULL),(1,NULL),(1,NULL),(1,NULL); -insert into t2 values (2,NULL),(2,NULL),(2,NULL),(2,NULL); -select * from t3 order by b,a limit 3; -select * from t4 order by b,a limit 3; -select * from t5 order by b,a limit 3,3; -select * from t6 order by b,a limit 6,3; -# now testing inserts and where the data gets written -insert into t5 values (5,1),(5,2); -insert into t6 values (6,1),(6,2); -select * from t1 order by a,b; -select * from t2 order by a,b; -select * from t4 order by a,b; -# preperation for next test -insert into t3 values (3,1),(3,2),(3,3),(3,4); -select * from t3 order by a,b; -# now testing whether options are kept by alter table -alter table t4 UNION=(t1,t2,t3); -show create table t4; -select * from t4 order by a,b; -# testing switching off insert method and inserts again -alter table t4 INSERT_METHOD=FIRST; -show create table t4; -insert into t4 values (4,1),(4,2); -select * from t1 order by a,b; -select * from t2 order by a,b; -select * from t3 order by a,b; -select * from t4 order by a,b; -select * from t5 order by a,b; -# auto_increment -select 1; -insert into t5 values (1,NULL),(5,NULL); -insert into t6 values (2,NULL),(6,NULL); -select * from t1 order by a,b; -select * from t2 order by a,b; -select * from t5 order by a,b; -select * from t6 order by a,b; -insert into t1 values (99,NULL); -select * from t4 where a+0 > 90; -# bug#4008 - cannot determine a unique key that caused "dupl. key error" ---error ER_DUP_ENTRY -insert t5 values (1,1); ---error ER_DUP_ENTRY -insert t6 values (2,1); -insert t5 values (1,1) on duplicate key update b=b+10; -insert t6 values (2,1) on duplicate key update b=b+20; -select * from t5 where a < 3; -drop table t6, t5, t4, t3, t2, t1; - -CREATE TABLE t1 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) ENGINE=MyISAM; -INSERT INTO t1 VALUES (1,1), (2,1); -CREATE TABLE t2 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', PRIMARY KEY (a,b)) ENGINE=MyISAM; -INSERT INTO t2 VALUES (1,2), (2,2); -CREATE TABLE t3 ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0', KEY a (a,b)) ENGINE=MRG_MyISAM UNION=(t1,t2); -select max(b) from t3 where a = 2; -select max(b) from t1 where a = 2; -drop table t3,t1,t2; - -# -# temporary merge tables -# -create table t1 (a int not null); -create table t2 (a int not null); -insert into t1 values (1); -insert into t2 values (2); -create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2); -select * from t3; -create temporary table t4 (a int not null); -create temporary table t5 (a int not null); -insert into t4 values (1); -insert into t5 values (2); -create temporary table t6 (a int not null) ENGINE=MERGE UNION=(t4,t5); -select * from t6; -drop table t6, t3, t1, t2, t4, t5; -# -# Bug#19627 - temporary merge table locking -# MERGE table and its children must match in temporary type. -# Forbid temporary merge on non-temporary children: shown above. -# Forbid non-temporary merge on temporary children: -create temporary table t1 (a int not null); -create temporary table t2 (a int not null); -insert into t1 values (1); -insert into t2 values (2); -create table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2); ---error ER_WRONG_MRG_TABLE -select * from t3; -drop table t3, t2, t1; -# Forbid children mismatch in temporary: -create table t1 (a int not null); -create temporary table t2 (a int not null); -insert into t1 values (1); -insert into t2 values (2); -create table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2); ---error ER_WRONG_MRG_TABLE -select * from t3; -drop table t3; -create temporary table t3 (a int not null) ENGINE=MERGE UNION=(t1,t2); -select * from t3; -drop table t3, t2, t1; ---echo # CREATE...SELECT is not implemented for MERGE tables. -CREATE TEMPORARY TABLE t1 (c1 INT NOT NULL); -CREATE TEMPORARY TABLE t2 (c1 INT NOT NULL); -CREATE TABLE t3 (c1 INT NOT NULL); -INSERT INTO t3 VALUES (3), (33); -LOCK TABLES t3 READ; ---error ER_WRONG_OBJECT -CREATE TEMPORARY TABLE t4 (c1 INT NOT NULL) ENGINE=MERGE UNION=(t1,t2) - INSERT_METHOD=LAST SELECT * FROM t3; ---error ER_TABLE_NOT_LOCKED -SELECT * FROM t4; -UNLOCK TABLES; -CREATE TEMPORARY TABLE t4 (c1 INT NOT NULL) ENGINE=MERGE UNION=(t1,t2) - INSERT_METHOD=LAST; -INSERT INTO t4 SELECT * FROM t3; ---echo # Alter temporary MERGE table. -ALTER TABLE t4 UNION=(t1); -LOCK TABLES t4 WRITE; ---echo # Alter temporary MERGE table under LOCk tables. -ALTER TABLE t4 UNION=(t1,t2); -UNLOCK TABLES; ---echo # MERGE table and function. -CREATE FUNCTION f1 () RETURNS INT RETURN (SELECT max(c1) FROM t3); -SELECT * FROM t4 WHERE c1 < f1(); -DROP FUNCTION f1; -DROP TABLE t4, t3, t2, t1; - -# -# testing merge::records_in_range and optimizer -# - -CREATE TABLE t1 ( - fileset_id tinyint(3) unsigned NOT NULL default '0', - file_code varchar(32) NOT NULL default '', - fileset_root_id tinyint(3) unsigned NOT NULL default '0', - PRIMARY KEY (fileset_id,file_code), - KEY files (fileset_id,fileset_root_id) -) ENGINE=MyISAM; -INSERT INTO t1 VALUES (2, '0000000111', 1), (2, '0000000112', 1), (2, '0000000113', 1), -(2, '0000000114', 1), (2, '0000000115', 1), (2, '0000000116', 1), (2, '0000000117', 1), -(2, '0000000118', 1), (2, '0000000119', 1), (2, '0000000120', 1); -CREATE TABLE t2 ( - fileset_id tinyint(3) unsigned NOT NULL default '0', - file_code varchar(32) NOT NULL default '', - fileset_root_id tinyint(3) unsigned NOT NULL default '0', - PRIMARY KEY (fileset_id,file_code), - KEY files (fileset_id,fileset_root_id) -) ENGINE=MRG_MyISAM UNION=(t1); - -EXPLAIN SELECT * FROM t2 IGNORE INDEX (files) WHERE fileset_id = 2 -AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1; -EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2 -AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1; -EXPLAIN SELECT * FROM t1 WHERE fileset_id = 2 -AND file_code BETWEEN '0000000115' AND '0000000120' LIMIT 1; -EXPLAIN SELECT * FROM t2 WHERE fileset_id = 2 -AND file_code = '0000000115' LIMIT 1; -DROP TABLE t2, t1; - -# -# Test of ORDER BY DESC on key (Bug #515) -# - -create table t1 (x int, y int, index xy(x, y)); -create table t2 (x int, y int, index xy(x, y)); -create table t3 (x int, y int, index xy(x, y)) engine=merge union=(t1,t2); -insert into t1 values(1, 2); -insert into t2 values(1, 3); -select * from t3 where x = 1 and y < 5 order by y; -# Bug is that followng query returns empty set while it must be same as above -select * from t3 where x = 1 and y < 5 order by y desc; -drop table t1,t2,t3; - -# -# Bug#5232: CREATE TABLE ... SELECT -# - -create table t1 (a int); -create table t2 (a int); -insert into t1 values (0); -insert into t2 values (1); ---error ER_WRONG_OBJECT -create table t3 engine=merge union=(t1, t2) select * from t1; ---error ER_WRONG_OBJECT -create table t3 engine=merge union=(t1, t2) select * from t2; ---error ER_WRONG_OBJECT -create table t3 engine=merge union=(t1, t2) select (select max(a) from t2); -drop table t1, t2; - -# -# Bug#9112 - Merge table with composite index producing invalid results with some queries -# This test case will fail only without the bugfix and some -# non-deterministic circumstances. It depends on properly initialized -# "un-initialized" memory. At the time it happens with a standard -# non-debug build. But there is no guarantee that this will be always so. -# -create table t1 ( - a double(14,4), - b varchar(10), - index (a,b) -) engine=merge union=(t2,t3); - -create table t2 ( - a double(14,4), - b varchar(10), - index (a,b) -) engine=myisam; - -create table t3 ( - a double(14,4), - b varchar(10), - index (a,b) -) engine=myisam; - -insert into t2 values ( null, ''); -insert into t2 values ( 9999999999.999, ''); -insert into t3 select * from t2; -select min(a), max(a) from t1; -flush tables; -select min(a), max(a) from t1; -drop table t1, t2, t3; -# BUG#6699 : no sorting on 'ref' retrieval -create table t1 (a int,b int,c int, index (a,b,c)); -create table t2 (a int,b int,c int, index (a,b,c)); -create table t3 (a int,b int,c int, index (a,b,c)) - engine=merge union=(t1 ,t2); -insert into t1 (a,b,c) values (1,1,0),(1,2,0); -insert into t2 (a,b,c) values (1,1,1),(1,2,1); - -explain select a,b,c from t3 force index (a) where a=1 order by a,b,c; -select a,b,c from t3 force index (a) where a=1 order by a,b,c; - -# this actually wasn't affected: -explain select a,b,c from t3 force index (a) where a=1 order by a desc, b desc, c desc; -select a,b,c from t3 force index (a) where a=1 order by a desc, b desc, c desc; - -# BUG#7377 SHOW index on MERGE table crashes debug server -show index from t3; - -drop table t1, t2, t3; - -# -# Bug#10400 - Improperly-defined MERGE table crashes with INSERT ... ON DUPLICATE KEY UPDATE -# -CREATE TABLE t1 ( a INT AUTO_INCREMENT PRIMARY KEY, b VARCHAR(10), UNIQUE (b) ) - ENGINE=MyISAM; -CREATE TABLE t2 ( a INT AUTO_INCREMENT, b VARCHAR(10), INDEX (a), INDEX (b) ) - ENGINE=MERGE UNION (t1) INSERT_METHOD=FIRST; -INSERT INTO t2 (b) VALUES (1) ON DUPLICATE KEY UPDATE b=2; -INSERT INTO t2 (b) VALUES (1) ON DUPLICATE KEY UPDATE b=3; -SELECT b FROM t2; -DROP TABLE t1, t2; - - -# -# BUG#5390 - problems with merge tables -# Problem #1: INSERT...SELECT -# -#drop table if exists t1, t2, t3; -create table t1(a int); -create table t2(a int); -insert into t1 values (1); -insert into t2 values (2); -create table t3 (a int) engine=merge union=(t1, t2) insert_method=first; -select * from t3; -# -insert t2 select * from t2; -select * from t2; -# -insert t3 select * from t1; -select * from t3; -# -insert t1 select * from t3; -select * from t1; -select * from t2; -select * from t3; -check table t1, t2; -drop table t1, t2, t3; - -# -# BUG#21617 - crash when selecting from merge table with inconsistent -# indexes -# -CREATE TABLE t1(a INT); -INSERT INTO t1 VALUES(2),(1); -CREATE TABLE t2(a INT, KEY(a)) ENGINE=MERGE UNION=(t1); ---error 1168 -SELECT * FROM t2 WHERE a=2; -DROP TABLE t1, t2; - -# -# BUG#10974 - No error message if merge table based on union of innodb, -# memory -# -CREATE TABLE t1(a INT) ENGINE=MEMORY; -CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t1); ---error 1168 -SELECT * FROM t2; -DROP TABLE t1, t2; -CREATE TABLE t2(a INT) ENGINE=MERGE UNION=(t3); ---error ER_WRONG_MRG_TABLE -SELECT * FROM t2; -DROP TABLE t2; - -# -# Underlying table definition conformance tests. -# -CREATE TABLE t1(a INT, b TEXT); -CREATE TABLE tm1(a TEXT, b INT) ENGINE=MERGE UNION=(t1); ---error 1168 -SELECT * FROM tm1; -DROP TABLE t1, tm1; - -CREATE TABLE t1(a SMALLINT, b SMALLINT); -CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1); ---error 1168 -SELECT * FROM tm1; -DROP TABLE t1, tm1; - -CREATE TABLE t1(a SMALLINT, b SMALLINT, KEY(a, b)); -CREATE TABLE tm1(a SMALLINT, b SMALLINT, KEY(a)) ENGINE=MERGE UNION=(t1); ---error 1168 -SELECT * FROM tm1; -DROP TABLE t1, tm1; - -CREATE TABLE t1(a SMALLINT, b SMALLINT, KEY(b)); -CREATE TABLE tm1(a SMALLINT, b SMALLINT, KEY(a)) ENGINE=MERGE UNION=(t1); ---error 1168 -SELECT * FROM tm1; -DROP TABLE t1, tm1; - - -# BUG#26881 - Large MERGE tables report incorrect specification when no -# differences in tables -# -CREATE TABLE t1(c1 VARCHAR(1)); -CREATE TABLE m1 LIKE t1; -ALTER TABLE m1 ENGINE=MERGE UNION=(t1); -SELECT * FROM m1; -DROP TABLE t1, m1; - -CREATE TABLE t1(c1 VARCHAR(4), c2 TINYINT, c3 TINYINT, c4 TINYINT, - c5 TINYINT, c6 TINYINT, c7 TINYINT, c8 TINYINT, c9 TINYINT); -CREATE TABLE m1 LIKE t1; -ALTER TABLE m1 ENGINE=MERGE UNION=(t1); -SELECT * FROM m1; -DROP TABLE t1, m1; - -# -# BUG#24342 - Incorrect results with query over MERGE table -# -CREATE TABLE t1 (a VARCHAR(255) CHARACTER SET latin1 COLLATE latin1_german2_ci, - b INT, INDEX(a,b)); -CREATE TABLE t2 LIKE t1; -CREATE TABLE t3 LIKE t1; -ALTER TABLE t3 ENGINE=MERGE UNION=(t1,t2); -INSERT INTO t1 VALUES ('ss',1); -INSERT INTO t2 VALUES ('ss',2),(0xDF,2); -SELECT COUNT(*) FROM t3 WHERE a=0xDF AND b=2; -DROP TABLE t1,t2,t3; - -# End of 4.1 tests - -# -# BUG#19648 - Merge table does not work with bit types -# -create table t1 (b bit(1)); -create table t2 (b bit(1)); -create table tm (b bit(1)) engine = merge union = (t1,t2); -select * from tm; -drop table tm, t1, t2; - -# -# Bug #17766: The server accepts to create MERGE tables which cannot work -# -create table t1 (a int) insert_method = last engine = merge; ---error ER_OPEN_AS_READONLY -insert into t1 values (1); -create table t2 (a int) engine = myisam; -alter table t1 union (t2); -insert into t1 values (1); -alter table t1 insert_method = no; ---error ER_OPEN_AS_READONLY -insert into t1 values (1); -drop table t2; -drop table t1; - -# -# BUG#26976 - Missing table in merge not noted in related error msg + SHOW -# CREATE TABLE fails -# -CREATE TABLE tm1(a INT) ENGINE=MERGE UNION=(t1, t2); ---error ER_WRONG_MRG_TABLE -SELECT * FROM tm1; -CHECK TABLE tm1; -CREATE TABLE t1(a INT); ---error ER_WRONG_MRG_TABLE -SELECT * FROM tm1; -CHECK TABLE tm1; -CREATE TABLE t2(a BLOB); ---error ER_WRONG_MRG_TABLE -SELECT * FROM tm1; -CHECK TABLE tm1; -ALTER TABLE t2 MODIFY a INT; -SELECT * FROM tm1; -CHECK TABLE tm1; -DROP TABLE tm1, t1, t2; - -# -# Bug#15522 - create ... select and with merge tables -# -# This was fixed together with Bug#20662 (Infinite loop in CREATE TABLE -# IF NOT EXISTS ... SELECT with locked tables). -# The new behavior for MERGE tables is consistent with the -# CREATE TABLE SELECT behavior for ordinary tables. -# -CREATE TABLE t1(c1 INT); -CREATE TABLE t2 (c1 INT) ENGINE=MERGE UNION=(t1) INSERT_METHOD=FIRST; -# After WL#5370, it just generates a warning that the table already exists -CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2; -DROP TABLE t1, t2; - -# -# Bug #28837: MyISAM storage engine error (134) doing delete with self-join -# - -CREATE TABLE t1 (id INT NOT NULL, ref INT NOT NULL, INDEX (id)) ENGINE=MyISAM; -CREATE TABLE t2 LIKE t1; - -INSERT INTO t2 (id, ref) VALUES (1,3), (2,1), (3,2), (4,5), (4,4); -INSERT INTO t1 SELECT * FROM t2; -INSERT INTO t1 SELECT * FROM t2; - -CREATE TABLE t3 (id INT NOT NULL, ref INT NOT NULL, INDEX (id)) ENGINE=MERGE - UNION(t1); - -SELECT * FROM t3 AS a INNER JOIN t3 AS b USING (id) WHERE a.ref < b.ref; -SELECT * FROM t3; -DELETE FROM a USING t3 AS a INNER JOIN t3 AS b USING (id) WHERE a.ref < b.ref; -SELECT * FROM t3; - -DROP TABLE t1, t2, t3; - -# -# BUG#28248 - mysqldump results with MERGE ... UNION=() cannot be executed -# -CREATE TABLE t1(a INT); -CREATE TABLE m1(a INT) ENGINE=MERGE; -SHOW CREATE TABLE m1; -DROP TABLE m1; -CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(); -SHOW CREATE TABLE m1; -ALTER TABLE m1 UNION=(t1); -ALTER TABLE m1 UNION=(); -SHOW CREATE TABLE m1; -DROP TABLE t1, m1; - -# -# BUG#32047 - 'Spurious' errors while opening MERGE tables -# -CREATE TABLE t1(a INT); -CREATE TABLE t2(a VARCHAR(10)); -CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(t1, t2); -CREATE TABLE m2(a INT) ENGINE=MERGE UNION=(t1); -SELECT * FROM t1; ---error ER_WRONG_MRG_TABLE -SELECT * FROM m1; -SELECT * FROM m2; -DROP TABLE t1, t2, m1, m2; - ---echo End of 5.0 tests - - -# -# Bug #8306: TRUNCATE leads to index corruption -# -create table t1 (c1 int, index(c1)); -create table t2 (c1 int, index(c1)) engine=merge union=(t1); -insert into t1 values (1); -# Close all tables. -flush tables; -# Open t2 and (implicitly) t1. -select * from t2; -# Truncate after flush works (unless another threads reopens t2 in between). -flush tables; -truncate table t1; -insert into t1 values (1); -# Close all tables. -flush tables; -# Open t2 and (implicitly) t1. -select * from t2; -# Truncate t1, which was not recognized as open without the bugfix. -# After fix for Bug#8306 and before fix for Bug#26379, -# it should fail with a table-in-use error message, otherwise succeed. -truncate table t1; -# The insert used to fail on the crashed table. -insert into t1 values (1); -drop table t1,t2; ---echo # ---echo # Extra tests for TRUNCATE. ---echo # ---echo # Truncate MERGE table. -CREATE TABLE t1 (c1 INT, INDEX(c1)); -CREATE TABLE t2 (c1 INT, INDEX(c1)); -CREATE TABLE t3 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1,t2); -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -SELECT * FROM t3; -TRUNCATE TABLE t3; -SELECT * FROM t3; ---echo # ---echo # Truncate child table. -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -TRUNCATE TABLE t1; -SELECT * FROM t3; ---echo # ---echo # Truncate MERGE table under locked tables. -LOCK TABLE t1 WRITE, t2 WRITE, t3 WRITE; -INSERT INTO t1 VALUES (1); -TRUNCATE TABLE t3; -SELECT * FROM t3; -UNLOCK TABLES; -SELECT * FROM t1; -SELECT * FROM t2; ---echo # ---echo # Truncate child table under locked tables. -LOCK TABLE t1 WRITE, t2 WRITE, t3 WRITE; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -TRUNCATE TABLE t1; -SELECT * FROM t3; -UNLOCK TABLES; -DROP TABLE t1, t2, t3; ---echo # ---echo # Truncate temporary MERGE table. -CREATE TEMPORARY TABLE t1 (c1 INT, INDEX(c1)); -CREATE TEMPORARY TABLE t2 (c1 INT, INDEX(c1)); -CREATE TEMPORARY TABLE t3 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1,t2); -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -SELECT * FROM t3; -TRUNCATE TABLE t3; -SELECT * FROM t3; ---echo # ---echo # Truncate temporary child table. -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -TRUNCATE TABLE t1; -SELECT * FROM t3; ---echo # ---echo # Truncate temporary MERGE table under locked tables. -INSERT INTO t1 VALUES (1); -CREATE TABLE t4 (c1 INT, INDEX(c1)); -LOCK TABLE t4 WRITE; -TRUNCATE TABLE t3; -SELECT * FROM t3; -SELECT * FROM t1; -SELECT * FROM t2; ---echo # ---echo # Truncate temporary child table under locked tables. -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -TRUNCATE TABLE t1; -SELECT * FROM t3; -SELECT * FROM t1; -SELECT * FROM t2; -UNLOCK TABLES; -DROP TABLE t1, t2, t3, t4; - -# -# Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table -# Preparation -connect (con1,localhost,root,,); -connect (con2,localhost,root,,); -connection default; -# -# Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table -# Problem #1 -# A thread trying to lock a MERGE table performed busy waiting while -# REPAIR TABLE or a similar table administration task was ongoing on one or -# more of its MyISAM tables. -# To allow for observability it was necessary to enter a multi-second sleep -# in mysql_admin_table() after remove_table_from_cache(), which comes after -# mysql_abort_lock(). The sleep faked a long running operation. One could -# watch a high CPU load during the sleep time. -# The problem was that mysql_abort_lock() upgrades the write lock to -# TL_WRITE_ONLY. This lock type persisted until the final unlock at the end -# of the administration task. The effect of TL_WRITE_ONLY is to reject any -# attempt to lock the table. The trying thread must close the table and wait -# until it is no longer used. Unfortunately there is no way to detect that -# one of the MyISAM tables of a MERGE table is in use. When trying to lock -# the MERGE table, all MyISAM tables are locked. If one fails on -# TL_WRITE_ONLY, all locks are aborted and wait_for_tables() is entered. -# But this doesn't see the MERGE table as used, so it seems appropriate to -# retry a lock... -# -CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; -CREATE TABLE t2 (c1 INT) ENGINE= MRG_MYISAM UNION= (t1) INSERT_METHOD= LAST; -send REPAIR TABLE t1; - connection con1; - sleep 1; # let repair run into its sleep - INSERT INTO t2 VALUES (1); -connection default; -reap; -DROP TABLE t1, t2; -# -# Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table -# Problem #2 -# A thread trying to lock a MERGE table performed busy waiting until all -# threads that did REPAIR TABLE or similar table administration tasks on -# one or more of its MyISAM tables in LOCK TABLES segments did -# UNLOCK TABLES. -# The difference against problem #1 is that the busy waiting took place -# *after* the administration task. It was terminated by UNLOCK TABLES only. -# -# This is the same test case as for -# Bug#26867 - LOCK TABLES REPAIR + merge table result in memory/cpu hogging -# -# -CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; -CREATE TABLE t2 (c1 INT) ENGINE= MRG_MYISAM UNION= (t1) INSERT_METHOD= LAST; -LOCK TABLE t1 WRITE; - connection con1; - send INSERT INTO t2 VALUES (1); -connection default; -sleep 1; # Let INSERT go into thr_multi_lock(). -REPAIR TABLE t1; -sleep 2; # con1 performs busy waiting during this sleep. -UNLOCK TABLES; - connection con1; - reap; -connection default; -DROP TABLE t1, t2; -# -# Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table -# Problem #3 -# Two FLUSH TABLES within a LOCK TABLES segment could invalidate the lock. -# This did *not* require a MERGE table. -# To increase reproducibility it was necessary to enter a sleep of 2 seconds -# at the end of wait_for_tables() after unlock of LOCK_open. In 5.0 and 5.1 -# the sleep must be inserted in open_and_lock_tables() after open_tables() -# instead. wait_for_tables() is not used in this case. -# The problem was that FLUSH TABLES releases LOCK_open while having unlocked -# and closed all tables. When this happened while a thread was in the loop in -# mysql_lock_tables() right after wait_for_tables() and before retrying to -# lock, the thread got the lock. (Translate to similar code places in 5.0 -# and 5.1). And it did not notice that the table needed a refresh. So it -# executed its statement on the table. -# The first FLUSH TABLES kicked the INSERT out of thr_multi_lock() and let -# it wait in wait_for_tables(). (open_table() in 5.0 and 5.1). The second -# FLUSH TABLES must happen while the INSERT was on its way from -# wait_for_tables() to the next call of thr_multi_lock(). This needed to be -# supported by a sleep to make it repeatable. -# -CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; -LOCK TABLE t1 WRITE; - connection con1; - send INSERT INTO t1 VALUES (1); -connection default; -sleep 1; # Let INSERT go into thr_multi_lock(). -FLUSH TABLES; -sleep 1; # Let INSERT go through wait_for_tables() where it sleeps. -FLUSH TABLES; -# This should give no result. But it will with sleep(2) at the right place. -SELECT * FROM t1; -UNLOCK TABLES; - connection con1; - reap; -connection default; -DROP TABLE t1; -# -# Bug#26379 - Combination of FLUSH TABLE and REPAIR TABLE corrupts a MERGE table -# Cleanup -disconnect con1; -disconnect con2; -# ---echo # ---echo # Extra tests for Bug#26379 - Combination of FLUSH TABLE and ---echo # REPAIR TABLE corrupts a MERGE table -# ---echo # ---echo # CREATE ... SELECT is disabled for MERGE tables. ---echo # -CREATE TABLE t1(c1 INT); -INSERT INTO t1 VALUES (1); -CREATE TABLE t2 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; ---error ER_OPEN_AS_READONLY -CREATE TABLE t3 ENGINE=MRG_MYISAM INSERT_METHOD=LAST SELECT * FROM t2; ---error ER_NO_SUCH_TABLE -SHOW CREATE TABLE t3; ---error ER_WRONG_OBJECT -CREATE TABLE t3 ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST - SELECT * FROM t2; ---error ER_NO_SUCH_TABLE -SHOW CREATE TABLE t3; -DROP TABLE t1, t2; -# ---echo # ---echo # Bug#37371 "CREATE TABLE LIKE merge loses UNION parameter" ---echo # Demonstrate that this is no longer the case. ---echo # ---echo # 1. Create like. -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TABLE t3 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -INSERT INTO t3 VALUES (3); -CREATE TABLE t4 LIKE t3; -SHOW CREATE TABLE t4; -INSERT INTO t4 VALUES (4); -DROP TABLE t4; ---echo # ---echo # 1. Create like with locked tables. -LOCK TABLES t3 WRITE, t2 WRITE, t1 WRITE; ---error ER_TABLE_NOT_LOCKED -CREATE TABLE t4 LIKE t3; ---error ER_TABLE_NOT_LOCKED -SHOW CREATE TABLE t4; ---error ER_TABLE_NOT_LOCKED -INSERT INTO t4 VALUES (4); ---echo # Temporary tables can be created in spite of LOCK TABLES. ---echo # If the temporary MERGE table uses the locked children only, ---echo # it can even be used. -CREATE TEMPORARY TABLE t4 LIKE t3; -SHOW CREATE TABLE t4; -INSERT INTO t4 VALUES (4); -UNLOCK TABLES; -INSERT INTO t4 VALUES (4); -DROP TABLE t4; -# ---echo # ---echo # Rename child. ---echo # ---echo # 1. Normal rename of non-MERGE table. -CREATE TABLE t4 (c1 INT); -INSERT INTO t4 VALUES (4); -SELECT * FROM t4 ORDER BY c1; -RENAME TABLE t4 TO t5; -SELECT * FROM t5 ORDER BY c1; -RENAME TABLE t5 TO t4; -SELECT * FROM t4 ORDER BY c1; -DROP TABLE t4; ---echo # ---echo # 2. Normal rename. -SELECT * FROM t3 ORDER BY c1; -RENAME TABLE t2 TO t5; ---error ER_WRONG_MRG_TABLE -SELECT * FROM t3 ORDER BY c1; -RENAME TABLE t5 TO t2; -SELECT * FROM t3 ORDER BY c1; ---echo # ---echo # 3. Normal rename with locked tables. -LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE; -SELECT * FROM t3 ORDER BY c1; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -RENAME TABLE t2 TO t5; -SELECT * FROM t3 ORDER BY c1; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -RENAME TABLE t5 TO t2; -SELECT * FROM t3 ORDER BY c1; -UNLOCK TABLES; ---echo # ---echo # 4. Alter table rename. -ALTER TABLE t2 RENAME TO t5; ---error ER_WRONG_MRG_TABLE -SELECT * FROM t3 ORDER BY c1; -ALTER TABLE t5 RENAME TO t2; -SELECT * FROM t3 ORDER BY c1; ---echo # ---echo # 5. Alter table rename with locked tables. -LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE; -ALTER TABLE t2 RENAME TO t5; ---error ER_TABLE_NOT_LOCKED -SELECT * FROM t3 ORDER BY c1; ---error ER_TABLE_NOT_LOCKED -ALTER TABLE t5 RENAME TO t2; -UNLOCK TABLES; -ALTER TABLE t5 RENAME TO t2; -SELECT * FROM t3 ORDER BY c1; -# ---echo # ---echo # Rename parent. ---echo # ---echo # 1. Normal rename with locked tables. -LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE; -SELECT * FROM t3 ORDER BY c1; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -RENAME TABLE t3 TO t5; -SELECT * FROM t3 ORDER BY c1; ---error ER_LOCK_OR_ACTIVE_TRANSACTION -RENAME TABLE t5 TO t3; -SELECT * FROM t3 ORDER BY c1; ---echo # ---echo # 5. Alter table rename with locked tables. -ALTER TABLE t3 RENAME TO t5; ---error ER_TABLE_NOT_LOCKED -SELECT * FROM t5 ORDER BY c1; ---error ER_TABLE_NOT_LOCKED -ALTER TABLE t5 RENAME TO t3; -UNLOCK TABLES; -ALTER TABLE t5 RENAME TO t3; -SELECT * FROM t3 ORDER BY c1; -DROP TABLE t1, t2, t3; -# ---echo # ---echo # Drop locked tables. ---echo # ---echo # 1. Drop parent. -CREATE TABLE t1 (c1 INT, INDEX(c1)); -CREATE TABLE t2 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1) - INSERT_METHOD=LAST; -LOCK TABLES t1 WRITE, t2 WRITE; -INSERT INTO t1 VALUES (1); -DROP TABLE t2; ---error ER_TABLE_NOT_LOCKED -SELECT * FROM t2; -SELECT * FROM t1; -UNLOCK TABLES; ---echo # 2. Drop child. -CREATE TABLE t2 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1) - INSERT_METHOD=LAST; -LOCK TABLES t1 WRITE, t2 WRITE; -INSERT INTO t1 VALUES (1); -DROP TABLE t1; ---error ER_TABLE_NOT_LOCKED -SELECT * FROM t2; ---error ER_TABLE_NOT_LOCKED -SELECT * FROM t1; -UNLOCK TABLES; -DROP TABLE t2; -# ---echo # ---echo # ALTER TABLE. Change child list. ---echo # -CREATE TABLE t1 (c1 INT, INDEX(c1)); -CREATE TABLE t2 (c1 INT, INDEX(c1)); -CREATE TABLE t3 (c1 INT, INDEX(c1)); -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -INSERT INTO t3 VALUES (3); -CREATE TABLE t4 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t3,t2) - INSERT_METHOD=LAST; ---echo # Shrink child list. -ALTER TABLE t4 UNION=(t3); -SHOW CREATE TABLE t4; -SELECT * FROM t4 ORDER BY c1; ---echo # Extend child list. -ALTER TABLE t4 UNION=(t3,t2); -SHOW CREATE TABLE t4; -SELECT * FROM t4 ORDER BY c1; -# ---echo # ---echo # ALTER TABLE under LOCK TABLES. Change child list. ---echo # -LOCK TABLES t4 WRITE, t3 WRITE, t2 WRITE; ---echo # Shrink child list. ---error ER_LOCK_OR_ACTIVE_TRANSACTION -ALTER TABLE t4 UNION=(t3); ---echo # Extend child list within locked tables. ---error ER_LOCK_OR_ACTIVE_TRANSACTION -ALTER TABLE t4 UNION=(t3,t2); ---echo # Extend child list beyond locked tables. ---error ER_LOCK_OR_ACTIVE_TRANSACTION -ALTER TABLE t4 UNION=(t3,t2,t1); -SHOW CREATE TABLE t4; -SELECT * FROM t4 ORDER BY c1; -UNLOCK TABLES; -DROP TABLE t4; -# ---echo # ---echo # ALTER TABLE under LOCK TABLES. Grave change, table re-creation. ---echo # -CREATE TABLE t4 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1,t2,t3) - INSERT_METHOD=LAST; ---echo # Lock parent first and then children. -LOCK TABLES t4 WRITE, t3 WRITE, t2 WRITE, t1 WRITE; -ALTER TABLE t4 DROP INDEX c1, ADD UNIQUE INDEX (c1); -SELECT * FROM t4 ORDER BY c1; -ALTER TABLE t2 DROP INDEX c1, ADD UNIQUE INDEX (c1); -SELECT * FROM t4 ORDER BY c1; -UNLOCK TABLES; ---echo # Lock children first and then parent. -LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t4 WRITE; -ALTER TABLE t4 DROP INDEX c1, ADD UNIQUE INDEX (c1); -SELECT * FROM t4 ORDER BY c1; -ALTER TABLE t2 DROP INDEX c1, ADD UNIQUE INDEX (c1); -SELECT * FROM t4 ORDER BY c1; -UNLOCK TABLES; ---echo # Lock parent between children. -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -ALTER TABLE t4 DROP INDEX c1, ADD UNIQUE INDEX (c1); -SELECT * FROM t4 ORDER BY c1; -ALTER TABLE t2 DROP INDEX c1, ADD UNIQUE INDEX (c1); -SELECT * FROM t4 ORDER BY c1; -UNLOCK TABLES; -DROP TABLE t1, t2, t3, t4; -# ---echo # ---echo # ALTER TABLE under LOCK TABLES. Simple change, no re-creation. ---echo # -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TABLE t3 (c1 INT); -CREATE TABLE t4 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2,t3) - INSERT_METHOD=LAST; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -INSERT INTO t3 VALUES (3); ---echo # Lock parent first and then children. -LOCK TABLES t4 WRITE, t3 WRITE, t2 WRITE, t1 WRITE; -ALTER TABLE t4 ALTER COLUMN c1 SET DEFAULT 44; -SELECT * FROM t4 ORDER BY c1; -ALTER TABLE t2 ALTER COLUMN c1 SET DEFAULT 22; -SELECT * FROM t4 ORDER BY c1; -UNLOCK TABLES; ---echo # Lock children first and then parent. -LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t4 WRITE; -ALTER TABLE t4 ALTER COLUMN c1 SET DEFAULT 44; -SELECT * FROM t4 ORDER BY c1; -ALTER TABLE t2 ALTER COLUMN c1 SET DEFAULT 22; -SELECT * FROM t4 ORDER BY c1; -UNLOCK TABLES; ---echo # Lock parent between children. -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -ALTER TABLE t4 ALTER COLUMN c1 SET DEFAULT 44; -SELECT * FROM t4 ORDER BY c1; -ALTER TABLE t2 ALTER COLUMN c1 SET DEFAULT 22; -SELECT * FROM t4 ORDER BY c1; -UNLOCK TABLES; -# ---echo # ---echo # FLUSH TABLE under LOCK TABLES. ---echo # ---echo # Lock parent first and then children. -LOCK TABLES t4 WRITE, t3 WRITE, t2 WRITE, t1 WRITE; -FLUSH TABLE t4; -SELECT * FROM t4 ORDER BY c1; -FLUSH TABLE t2; -SELECT * FROM t4 ORDER BY c1; -FLUSH TABLES; -SELECT * FROM t4 ORDER BY c1; -UNLOCK TABLES; ---echo # Lock children first and then parent. -LOCK TABLES t1 WRITE, t2 WRITE, t3 WRITE, t4 WRITE; -FLUSH TABLE t4; -SELECT * FROM t4 ORDER BY c1; -FLUSH TABLE t2; -SELECT * FROM t4 ORDER BY c1; -FLUSH TABLES; -SELECT * FROM t4 ORDER BY c1; -UNLOCK TABLES; ---echo # Lock parent between children. -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -FLUSH TABLE t4; -SELECT * FROM t4 ORDER BY c1; -FLUSH TABLE t2; -SELECT * FROM t4 ORDER BY c1; -FLUSH TABLES; -SELECT * FROM t4 ORDER BY c1; -UNLOCK TABLES; -# ---echo # ---echo # Triggers ---echo # ---echo # Trigger on parent -DELETE FROM t4 WHERE c1 = 4; -CREATE TRIGGER t4_ai1 AFTER INSERT ON t4 FOR EACH ROW SET @a=1; -SET @a=0; -INSERT INTO t4 VALUES (4); -SELECT @a; -SELECT * FROM t4 ORDER BY c1; -DROP TRIGGER t4_ai1; -CHECK TABLE t3; ---echo # Trigger on parent under LOCK TABLES -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -CREATE TRIGGER t4_ai2 AFTER INSERT ON t4 FOR EACH ROW SET @a=1; -SET @a=0; -INSERT INTO t4 VALUES (4); -SELECT @a; -SELECT * FROM t4 ORDER BY c1; -DROP TRIGGER t4_ai2; -UNLOCK TABLES; -CHECK TABLE t3; ---echo # ---echo # Trigger on child -DELETE FROM t4 WHERE c1 = 4; -CREATE TRIGGER t3_ai3 AFTER INSERT ON t3 FOR EACH ROW SET @a=1; -SET @a=0; -INSERT INTO t4 VALUES (4); -SELECT @a; -INSERT INTO t3 VALUES (33); -SELECT @a; -SELECT * FROM t4 ORDER BY c1; -DROP TRIGGER t3_ai3; -CHECK TABLE t3; ---echo # Trigger on child under LOCK TABLES -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -CREATE TRIGGER t3_ai4 AFTER INSERT ON t3 FOR EACH ROW SET @a=1; -SET @a=0; -INSERT INTO t4 VALUES (4); -SELECT @a; -INSERT INTO t3 VALUES (33); -SELECT @a; -SELECT * FROM t4 ORDER BY c1; -DELETE FROM t4 WHERE c1 = 33; -DROP TRIGGER t3_ai4; -UNLOCK TABLES; -CHECK TABLE t3; ---echo # ---echo # Trigger with table use on child -DELETE FROM t4 WHERE c1 = 4; -CREATE TRIGGER t3_ai5 AFTER INSERT ON t3 FOR EACH ROW INSERT INTO t2 VALUES(22); -SELECT COUNT(*) FROM t2; -INSERT INTO t4 VALUES (4); -SELECT * FROM t4 ORDER BY c1; -INSERT INTO t3 VALUES (33); -SELECT * FROM t4 ORDER BY c1; -DELETE FROM t4 WHERE c1 = 22; -DELETE FROM t4 WHERE c1 = 33; -DROP TRIGGER t3_ai5; -UNLOCK TABLES; -CHECK TABLE t2,t3; ---echo # Trigger with table use on child under LOCK TABLES -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -CREATE TRIGGER t3_ai6 AFTER INSERT ON t3 FOR EACH ROW INSERT INTO t2 VALUES(22); -INSERT INTO t4 VALUES (4); -SELECT * FROM t4 ORDER BY c1; -INSERT INTO t3 VALUES (33); -SELECT * FROM t4 ORDER BY c1; -DROP TRIGGER t3_ai6; -UNLOCK TABLES; -check table t2,t3,t4; -DELETE FROM t4 WHERE c1 = 22; -DELETE FROM t4 WHERE c1 = 33; ---echo # Trigger with table use on child under different LOCK TABLES -DELETE FROM t4 WHERE c1 = 4; -LOCK TABLES t4 WRITE,t3 WRITE, t2 WRITE, t1 WRITE; -CREATE TRIGGER t3_ai7 AFTER INSERT ON t3 FOR EACH ROW INSERT INTO t2 VALUES(22); -INSERT INTO t4 VALUES (4); -SELECT * FROM t4 ORDER BY c1; -INSERT INTO t3 VALUES (33); -SELECT * FROM t4 ORDER BY c1; -DROP TRIGGER t3_ai7; -UNLOCK TABLES; -check table t2,t3,t4; -DELETE FROM t4 WHERE c1 = 22; -DELETE FROM t4 WHERE c1 = 33; -# ---echo # ---echo # Repair ---echo # -REPAIR TABLE t4; -REPAIR TABLE t2; -SELECT * FROM t4 ORDER BY c1; -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -REPAIR TABLE t4; -REPAIR TABLE t2; -SELECT * FROM t4 ORDER BY c1; -UNLOCK TABLES; -# ---echo # ---echo # Optimize ---echo # -OPTIMIZE TABLE t4; -OPTIMIZE TABLE t2; -SELECT * FROM t4 ORDER BY c1; -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -OPTIMIZE TABLE t4; -OPTIMIZE TABLE t2; -SELECT * FROM t4 ORDER BY c1; -UNLOCK TABLES; -# ---echo # ---echo # Checksum ---echo # -CHECKSUM TABLE t4; -CHECKSUM TABLE t2; -SELECT * FROM t4 ORDER BY c1; -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; -CHECKSUM TABLE t4; -CHECKSUM TABLE t2; -SELECT * FROM t4 ORDER BY c1; -UNLOCK TABLES; -# ---echo # ---echo # Insert delayed ---echo # -# See also Bug#26464 - insert delayed + update + merge = corruption -# Succeeds in embedded server - is converted to normal insert -# Fails in normal server, ps-protocol - not supported by engine -# Fails in normal server, normal protocol - not a base table ---error 0, ER_DELAYED_NOT_SUPPORTED, ER_WRONG_OBJECT -INSERT DELAYED INTO t4 VALUES(44); -# Get rid of row in embedded server -DELETE FROM t4 WHERE c1 = 44; -INSERT DELAYED INTO t3 VALUES(33); - let $wait_cmd= SHOW STATUS LIKE 'Not_flushed_delayed_rows'; - let $run= query_get_value($wait_cmd, Value, 1); - while ($run) - { - let $run= query_get_value($wait_cmd, Value, 1); - } -SELECT * FROM t4 ORDER BY c1; -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, t1 WRITE; ---error ER_DELAYED_INSERT_TABLE_LOCKED, ER_DELAYED_NOT_SUPPORTED -INSERT DELAYED INTO t4 VALUES(444); ---error ER_DELAYED_INSERT_TABLE_LOCKED, ER_DELAYED_NOT_SUPPORTED -INSERT DELAYED INTO t3 VALUES(333); -SELECT * FROM t4 ORDER BY c1; -UNLOCK TABLES; -DROP TABLE t1, t2, t3, t4; -# ---echo # ---echo # Recursive inclusion of merge tables in their union clauses. ---echo # -CREATE TABLE t1 (c1 INT, INDEX(c1)); -CREATE TABLE t2 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t1) - INSERT_METHOD=LAST; -CREATE TABLE t3 (c1 INT, INDEX(c1)) ENGINE=MRG_MYISAM UNION=(t2,t1) - INSERT_METHOD=LAST; -ALTER TABLE t2 UNION=(t3,t1); ---error ER_ADMIN_WRONG_MRG_TABLE -SELECT * FROM t2; -DROP TABLE t1, t2, t3; - - -# -# Bug#25038 - Waiting TRUNCATE -# Truncate failed with error message when table was in use by MERGE. -# -# Show that truncate of child table after use of parent table works. -CREATE TABLE t1 (c1 INT) ENGINE= MyISAM; -CREATE TABLE t2 (c1 INT) ENGINE= MyISAM; -CREATE TABLE t3 (c1 INT) ENGINE= MRG_MYISAM UNION= (t1, t2); -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2); -SELECT * FROM t3; -TRUNCATE TABLE t1; -SELECT * FROM t3; -DROP TABLE t1, t2, t3; -# -# Show that truncate of child table waits while parent table is used. -# (test partly borrowed from count_distinct3.) -CREATE TABLE t1 (id INTEGER, grp TINYINT, id_rev INTEGER); -SET @rnd_max= 2147483647; -let $1 = 10; ---disable_query_log -begin; -while ($1) -{ - SET @rnd= RAND(); - SET @id = CAST(@rnd * @rnd_max AS UNSIGNED); - SET @id_rev= @rnd_max - @id; - SET @grp= CAST(127.0 * @rnd AS UNSIGNED); - INSERT INTO t1 (id, grp, id_rev) VALUES (@id, @grp, @id_rev); - dec $1; -} -commit; ---enable_query_log -set @@read_buffer_size=2*1024*1024; -CREATE TABLE t2 SELECT * FROM t1; -INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; -INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; -INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; -INSERT INTO t2 (id, grp, id_rev) SELECT id, grp, id_rev FROM t1; -INSERT INTO t1 (id, grp, id_rev) SELECT id, grp, id_rev FROM t2; -CREATE TABLE t3 (id INTEGER, grp TINYINT, id_rev INTEGER) - ENGINE= MRG_MYISAM UNION= (t1, t2); -SELECT COUNT(*) FROM t1; -SELECT COUNT(*) FROM t2; -SELECT COUNT(*) FROM t3; -connect (con1,localhost,root,,); - # As t3 contains random numbers, results are different from test to test. - # That's okay, because we test only that select doesn't yield an - # error. Note, that --disable_result_log doesn't suppress error output. - --disable_result_log - send SELECT COUNT(DISTINCT a1.id) FROM t3 AS a1, t3 AS a2 - WHERE a1.id = a2.id GROUP BY a2.grp; -connection default; -sleep 1; -TRUNCATE TABLE t1; - connection con1; - reap; - --enable_result_log - disconnect con1; -connection default; -SELECT COUNT(*) FROM t1; -SELECT COUNT(*) FROM t2; -SELECT COUNT(*) FROM t3; -DROP TABLE t1, t2, t3; - -# -# Bug#25700 - merge base tables get corrupted by optimize/analyze/repair table -# -# Using FLUSH TABLES before REPAIR. -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE t2 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; -INSERT INTO t2 VALUES (1); -SELECT * FROM t2; -LOCK TABLES t2 WRITE, t1 WRITE; -FLUSH TABLES; -REPAIR TABLE t1; -CHECK TABLE t1; -REPAIR TABLE t1; -UNLOCK TABLES; -CHECK TABLE t1 EXTENDED; -# -# Not using FLUSH TABLES before REPAIR. -LOCK TABLES t2 WRITE, t1 WRITE; -REPAIR TABLE t1; -CHECK TABLE t1; -REPAIR TABLE t1; -UNLOCK TABLES; -CHECK TABLE t1 EXTENDED; -DROP TABLE t1, t2; - -# -# Bug#26377 - Deadlock with MERGE and FLUSH TABLE -# -CREATE TABLE t1 ( a INT ) ENGINE=MyISAM; -CREATE TABLE m1 ( a INT ) ENGINE=MRG_MYISAM UNION=(t1); -# Lock t1 first. This did always work. -LOCK TABLES t1 WRITE, m1 WRITE; -FLUSH TABLE t1; -UNLOCK TABLES; -DROP TABLE m1, t1; -# -CREATE TABLE t1 ( a INT ) ENGINE=MyISAM; -CREATE TABLE m1 ( a INT ) ENGINE=MRG_MYISAM UNION=(t1); -# Lock m1 first. This did deadlock. -LOCK TABLES m1 WRITE, t1 WRITE; -FLUSH TABLE t1; -UNLOCK TABLES; -DROP TABLE m1, t1; - -# -# Bug#27660 - Falcon: merge table possible -# -# Normal MyISAM MERGE operation. -CREATE TABLE t1 (c1 INT, c2 INT) ENGINE= MyISAM; -CREATE TABLE t2 (c1 INT, c2 INT) ENGINE= MyISAM; -CREATE TABLE t3 (c1 INT, c2 INT) ENGINE= MRG_MYISAM UNION(t1, t2); -INSERT INTO t1 VALUES (1, 1); -INSERT INTO t2 VALUES (2, 2); -SELECT * FROM t3; -# Try an unsupported engine. -ALTER TABLE t1 ENGINE= MEMORY; -INSERT INTO t1 VALUES (0, 0); -# Before fixing, this succeeded, but (0, 0) was missing. ---error 1168 -SELECT * FROM t3; -DROP TABLE t1, t2, t3; - -# -# Bug#30275 - Merge tables: flush tables or unlock tables causes server to crash -# -CREATE TABLE t1 (c1 INT, KEY(c1)); -CREATE TABLE t2 (c1 INT, KEY(c1)) ENGINE=MRG_MYISAM UNION=(t1) - INSERT_METHOD=FIRST; -LOCK TABLE t1 WRITE, t2 WRITE; -FLUSH TABLES t2, t1; -OPTIMIZE TABLE t1; -FLUSH TABLES t1; -UNLOCK TABLES; -# -FLUSH TABLES; -INSERT INTO t1 VALUES (1); -LOCK TABLE t1 WRITE, t2 WRITE; -FLUSH TABLES t2, t1; -OPTIMIZE TABLE t1; -FLUSH TABLES t1; -UNLOCK TABLES; -DROP TABLE t1, t2; - -# -# Test derived from test program for -# Bug#30273 - merge tables: Can't lock file (errno: 155) -# -CREATE TABLE t1 (ID INT) ENGINE=MYISAM; -CREATE TABLE m1 (ID INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=FIRST; -INSERT INTO t1 VALUES (); -INSERT INTO m1 VALUES (); -LOCK TABLE t1 WRITE, m1 WRITE; -FLUSH TABLES m1, t1; -OPTIMIZE TABLE t1; -FLUSH TABLES m1, t1; -UNLOCK TABLES; -DROP TABLE t1, m1; - -# -# Bug#35068 - Assertion fails when reading from i_s.tables -# and there is incorrect merge table -# -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=FIRST; -SELECT table_schema, table_name, table_type, engine, version, row_format, table_comment FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'test' and TABLE_NAME='tm1'; - -DROP TABLE tm1; - -# -# Bug#36006 - Optimizer does table scan for select count(*) -# -CREATE TABLE t1(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM; -CREATE TABLE t2(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM; -CREATE TABLE t3(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) ENGINE=MYISAM; -CREATE TABLE t4(C1 INT, C2 INT, KEY C1(C1), KEY C2(C2)) - ENGINE=MRG_MYISAM UNION=(t1, t2, t3); -INSERT INTO t1 VALUES (1,1), (1,2),(1,3), (1,4); -INSERT INTO t2 VALUES (2,1), (2,2),(2,3), (2,4); -INSERT INTO t3 VALUES (3,1), (3,2),(3,3), (3,4); -EXPLAIN SELECT COUNT(*) FROM t1; -EXPLAIN SELECT COUNT(*) FROM t4; -DROP TABLE t1, t2, t3, t4; - -# -# BUG#39185 - Cardinality for merge tables calculated incorrectly. -# -CREATE TABLE t1(a INT, KEY(a)); -INSERT INTO t1 VALUES(0),(1),(2),(3),(4); -ANALYZE TABLE t1; -CREATE TABLE m1(a INT, KEY(a)) ENGINE=MERGE UNION=(t1); -SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; -SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; -SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; -SELECT CARDINALITY FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA='test' AND TABLE_NAME='m1'; -DROP TABLE t1, m1; - ---echo # ---echo # Bug #40675 MySQL 5.1 crash with index merge algorithm and Merge tables ---echo # - ---echo # create MYISAM table t1 and insert values into it -CREATE TABLE t1(a INT); -INSERT INTO t1 VALUES(1); - ---echo # create MYISAM table t2 and insert values into it -CREATE TABLE t2(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b)); -INSERT INTO t2(a,b) VALUES -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0),(0,0), -(1,2); - ---echo # Create the merge table t3 -CREATE TABLE t3(a INT, b INT, dummy CHAR(16) DEFAULT '', KEY(a), KEY(b)) -ENGINE=MERGE UNION=(t2) INSERT_METHOD=FIRST; - ---echo # Lock tables t1 and t3 for write -LOCK TABLES t1 WRITE, t3 WRITE; - ---echo # Insert values into the merge table t3 -INSERT INTO t3(a,b) VALUES(1,2); - ---echo # select from the join of t2 and t3 (The merge table) -SELECT t3.a FROM t1,t3 WHERE t3.b=2 AND t3.a=1; - ---echo # Unlock the tables -UNLOCK TABLES; - ---echo # drop the created tables -DROP TABLE t1, t2, t3; - -# -# Bug #41305 server crashes when inserting duplicate row into a merge table -# ---echo # insert duplicate value in child table while merge table doesn't have key -create table t1 ( - col1 int(10), - primary key (col1) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -CREATE TABLE m1 ( - col1 int(10) NOT NULL -) ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(t1); - -insert into m1 (col1) values (1); ---error ER_DUP_KEY -insert into m1 (col1) values (1); - -drop table m1, t1; - ---echo # ---echo # Bug#45800 crash when replacing into a merge table and there is a duplicate ---echo # - ---echo # Replace duplicate value in child table when merge table doesn't have key -CREATE TABLE t1 (c1 INT PRIMARY KEY) ENGINE=MyISAM; -CREATE TABLE m1 (c1 INT NOT NULL) ENGINE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1); -INSERT INTO m1 VALUES (666); -SELECT * FROM m1; ---echo # insert the duplicate value into the merge table -REPLACE INTO m1 VALUES (666); -SELECT * FROM m1; -DROP TABLE m1, t1; - ---echo # Insert... on duplicate key update (with duplicate values in the table) -CREATE TABLE t1 (c1 INT PRIMARY KEY) ENGINE=MyISAM; -CREATE TABLE m1 (c1 INT NOT NULL) ENGINE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1); -INSERT INTO m1 VALUES (666); -SELECT * FROM m1; ---echo # insert the duplicate value into the merge table -INSERT INTO m1 VALUES (666) ON DUPLICATE KEY UPDATE c1=c1+1; -SELECT * FROM m1; -DROP TABLE m1, t1; - ---echo # Insert duplicate value on MERGE table, where, MERGE has a key but MyISAM has more keys -CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE (c1), UNIQUE (c2)); -CREATE TABLE m1 (c1 INT, c2 INT, UNIQUE (c1)) ENGINE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1); -INSERT INTO m1 VALUES (1,2); ---echo # insert the duplicate value into the merge table ---error ER_DUP_KEY -INSERT INTO m1 VALUES (3,2); -DROP TABLE m1,t1; - ---echo # Try to define MERGE and MyISAM with keys on different columns -CREATE TABLE t1 (c1 INT, c2 INT, UNIQUE (c1)); -CREATE TABLE m1 (c1 INT, c2 INT, UNIQUE (c2)) ENGINE=MRG_MyISAM INSERT_METHOD=LAST UNION=(t1); ---echo # Try accessing the merge table for inserts (error occurs) ---error ER_WRONG_MRG_TABLE -INSERT INTO m1 VALUES (1,2); ---error ER_WRONG_MRG_TABLE -INSERT INTO m1 VALUES (1,4); -DROP TABLE m1,t1; - -# -#Bug #44040 MySQL allows creating a MERGE table upon VIEWs but crashes -#when using it -# - -CREATE TABLE t1 ( - col1 INT(10) -) ENGINE=MyISAM DEFAULT CHARSET=latin1; - -CREATE VIEW v1 as SELECT * FROM t1; -CREATE TABLE m1 ( - col1 INT(10) -)ENGINE=MRG_MyISAM DEFAULT CHARSET=latin1 INSERT_METHOD=LAST UNION=(v1); - ---echo #Select should detect that the child table is a view and fail. ---error ER_WRONG_MRG_TABLE -SELECT * FROM m1; - -DROP VIEW v1; -DROP TABLE m1, t1; - ---echo # ---echo # Bug #45796: invalid memory reads and writes when altering merge and ---echo # base tables ---echo # - -CREATE TABLE t1(c1 INT) ENGINE=MyISAM; -CREATE TABLE m1(c1 INT) ENGINE=MERGE UNION=(t1); -ALTER TABLE m1 ADD INDEX idx_c1(c1); -# Open the MERGE table and allocate buffers based on children's definition. ---error ER_WRONG_MRG_TABLE -SELECT * FROM m1; -# Change the child table definition. -ALTER TABLE t1 ADD INDEX idx_c1(c1); -# Check that old buffers are not reused -SELECT * FROM m1; - -DROP TABLE m1; -DROP TABLE t1; - ---echo # ---echo # Bug45781 infinite hang/crash in "opening tables" after handler tries to ---echo # open merge table ---echo # - -CREATE TABLE t1(a int)engine=myisam; -CREATE TABLE t2(a int)engine=myisam; -CREATE TABLE t3(a int)engine=myisam; -CREATE TABLE t4(a int)engine=myisam; -CREATE TABLE t5(a int)engine=myisam; -CREATE TABLE t6(a int)engine=myisam; -CREATE TABLE t7(a int)engine=myisam; -CREATE TABLE m1(a int)engine=merge union=(t1,t2,t3,t4,t5,t6,t7); -SELECT 1 FROM m1; ---error ER_ILLEGAL_HA -HANDLER m1 OPEN; -DROP TABLE m1,t1,t2,t3,t4,t5,t6,t7; ---error ER_NO_SUCH_TABLE -SELECT 1 FROM m1; # Should not hang! - ---echo # ---echo # Bug #46614: Assertion in show_create_trigger() ---echo # -CREATE TABLE t1(a int); -CREATE TABLE t2(a int); -CREATE TABLE t3(a int) ENGINE = MERGE UNION(t1, t2); -CREATE TRIGGER tr1 AFTER INSERT ON t3 FOR EACH ROW CALL foo(); ---replace_column 7 # -SHOW CREATE TRIGGER tr1; -DROP TRIGGER tr1; -DROP TABLE t1, t2, t3; - ---echo # ---echo # BUG#48265 - MRG_MYISAM problem (works in 5.0.85, does't work in 5.1.40) ---echo # -CREATE DATABASE `test/1`; - -CREATE TABLE `test/1`.`t/1`(a INT); -CREATE TABLE m1(a INT) ENGINE=MERGE UNION=(`test/1`.`t/1`); -SELECT * FROM m1; -SHOW CREATE TABLE m1; -DROP TABLE m1; - -CREATE TABLE `test/1`.m1(a INT) ENGINE=MERGE UNION=(`test/1`.`t/1`); -SELECT * FROM `test/1`.m1; -SHOW CREATE TABLE `test/1`.m1; -DROP TABLE `test/1`.m1; -DROP TABLE `test/1`.`t/1`; - -CREATE TEMPORARY TABLE `test/1`.`t/1`(a INT); -CREATE TEMPORARY TABLE m1(a INT) ENGINE=MERGE UNION=(`test/1`.`t/1`); -SELECT * FROM m1; -SHOW CREATE TABLE m1; -DROP TABLE m1; - -CREATE TEMPORARY TABLE `test/1`.m1(a INT) ENGINE=MERGE UNION=(`test/1`.`t/1`); -SELECT * FROM `test/1`.m1; -SHOW CREATE TABLE `test/1`.m1; -DROP TABLE `test/1`.m1; -DROP TABLE `test/1`.`t/1`; - -DROP DATABASE `test/1`; - -# Test compatibility. Use '@' instead of '/' (was not allowed in 5.0) - -CREATE TABLE `t@1`(a INT); -copy_file std_data/bug48265.frm $MYSQLD_DATADIR/test/m1.frm; -write_file $MYSQLD_DATADIR/test/m1.MRG; -t@1 -EOF -SELECT * FROM m1; -SHOW CREATE TABLE m1; -DROP TABLE `t@1`; - -CREATE DATABASE `test@1`; -CREATE TABLE `test@1`.`t@1`(a INT); -FLUSH TABLE m1; -remove_file $MYSQLD_DATADIR/test/m1.MRG; -write_file $MYSQLD_DATADIR/test/m1.MRG; -./test@1/t@1 -EOF -SELECT * FROM m1; -SHOW CREATE TABLE m1; -DROP TABLE m1; -DROP TABLE `test@1`.`t@1`; -DROP DATABASE `test@1`; - ---echo # ---echo # Bug#51494c rash with join, explain and 'sounds like' operator ---echo # - -CREATE TABLE t1 (a INT) ENGINE=MYISAM; -INSERT INTO t1 VALUES(1); - -CREATE TABLE t2 (b INT NOT NULL,c INT,d INT,e BLOB NOT NULL, -KEY idx0 (d, c)) ENGINE=MERGE; - -EXPLAIN SELECT * FROM t1 NATURAL RIGHT JOIN -t2 WHERE b SOUNDS LIKE e AND d = 1; - -DROP TABLE t2, t1; - ---echo # ---echo # Bug#46339 - crash on REPAIR TABLE merge table USE_FRM ---echo # -# -# Test derived from a proposal of Shane Bester. -# -CREATE TABLE t1 (c1 INT) ENGINE=MYISAM; -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1) INSERT_METHOD=LAST; -# -# REPAIR ... USE_FRM with LOCK TABLES. -# -LOCK TABLE m1 READ; -REPAIR TABLE m1 USE_FRM; -UNLOCK TABLES; -# -# REPAIR ... USE_FRM without LOCK TABLES. -# -# This statement crashed the server (Bug#46339). -# -REPAIR TABLE m1 USE_FRM; -# -DROP TABLE m1,t1; -# -# Test derived from a proposal of Matthias Leich. -# -# Base table is missing. -# -CREATE TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1); -# -# This statement crashed the server (Bug#46339). -# -REPAIR TABLE m1 USE_FRM; -# -# Create base table. -# -CREATE TABLE t1 (f1 BIGINT) ENGINE = MyISAM; -# -# This statement crashed the server (Bug#46339). -# -REPAIR TABLE m1 USE_FRM; -# -# Normal repair as reference. -# -REPAIR TABLE m1; -# -# Cleanup. -# -DROP TABLE m1, t1; -# -# Same with temporary tables. -# -# Base table is missing. -# -CREATE TEMPORARY TABLE m1 (f1 BIGINT) ENGINE=MRG_MyISAM UNION(t1); -# -# This statement crashed the server (Bug#46339). -# -REPAIR TABLE m1 USE_FRM; -# -# Create base table. -# -CREATE TEMPORARY TABLE t1 (f1 BIGINT) ENGINE=MyISAM; -# -# This statement crashed the server (Bug#46339). -# -REPAIR TABLE m1 USE_FRM; -# -# Normal repair as reference. -# -REPAIR TABLE m1; -# -# Cleanup. -# -DROP TABLE m1, t1; - -# -# MDEV-5266 MySQL:57657 - Temporary MERGE table with temporary underlying is broken by ALTER -# -create temporary table t1_temp(i int); -create temporary table tm_temp_temp (i int) engine=merge union=(t1_temp) insert_method=last; -alter table tm_temp_temp insert_method=first; -check table tm_temp_temp; -drop temporary table t1_temp, tm_temp_temp; - ---echo End of 5.1 tests - ---echo # ---echo # MDEV-4277: Crash inside mi_killed_in_mariadb() with myisammrg ---echo # -create table t1 (a int); -insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); - -create table t2 ( i int ) engine=myisam; -insert into t2 values (1),(2); - -create table t3 (a int, b int, filler char(100), key(a), key(b)) engine=myisam; -create table t4 like t3; -insert into t3 - select A.a+10*B.a+100*C.a, - A.a+10*B.a+100*C.a, - 'filler-data-FILLER-DATA-qqq' - from t1 A, t1 B, t1 C where C.a < 5; -insert into t4 - select A.a+10*B.a+100*C.a, - A.a+10*B.a+100*C.a, - 'filler-data-FILLER-DATA-qqq' - from t1 A, t1 B, t1 C where C.a >= 5; - -create table t5 like t3; -alter table t5 engine=merge; -alter table t5 union(t3, t4); - -update t5 set b=999, a=999 where b>950; - -explain -select * from t2, t5 where t5.a=999 and t5.b=999; -select * from t2, t5 where t5.a=999 and t5.b=999; - -drop table t5; -drop table t1,t2,t3,t4; - ---echo End of 5.3 tests - -# -# BUG#35274 - merge table doesn't need any base tables, gives error 124 when -# key accessed -# -CREATE TABLE t1(a INT, KEY(a)) ENGINE=merge; -SELECT MAX(a) FROM t1; -DROP TABLE t1; - ---echo # ---echo # An additional test case for Bug#27430 Crash in subquery code ---echo # when in PS and table DDL changed after PREPARE ---echo # ---echo # Test merge table with too many merge children. ---echo # -set @save_table_open_cache=@@global.table_open_cache; ---echo # ---echo # Set @@global.table_open_cache to minimum ---echo # -set @@global.table_open_cache=400; -select @@table_open_cache; -set @a=null; -let $1 = `select @@table_open_cache;`; ---echo # ---echo # Create 400 merge children ---echo # ---disable_query_log -while ($1) -{ - eval create table t$1 (a int) engine=myisam; - eval set @a=ifnull(concat(@a, ", ", "t$1"), "t$1"); - dec $1; -} ---enable_query_log -set @a=concat("create table t_parent (a int) union(", @a, - ") insert_method=first engine=mrg_myisam"); -prepare stmt from @a; -execute stmt; -prepare stmt from "select * from t_parent"; ---disable_result_log ---error 0,ER_NEED_REPREPARE -execute stmt; ---error 0,ER_NEED_REPREPARE -execute stmt; ---error 0,ER_NEED_REPREPARE -execute stmt; -deallocate prepare stmt; ---enable_result_log - ---echo # ---echo # Create merge parent ---echo # - ---echo # ---echo # Cleanup ---echo # -let $1 = `select @@table_open_cache;`; ---disable_query_log -while ($1) -{ - eval drop table t$1; - dec $1; -} ---enable_query_log -drop table t_parent; -set @@global.table_open_cache=@save_table_open_cache; - -# -# WL#4144 - Lock MERGE engine children -# -# Test DATA/INDEX DIRECTORY -# -CREATE DATABASE mysql_test1; ---disable_query_log -# data/index directory don't work in HAVE_purify builds. Disable -# build-dependent warnings. ---disable_warnings ---echo CREATE TABLE t1 ... DATA DIRECTORY=... INDEX DIRECTORY=... -eval CREATE TABLE t1 (c1 INT) - DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp' - INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp'; ---echo CREATE TABLE mysql_test1.t2 ... DATA DIRECTORY=... INDEX DIRECTORY=... -eval CREATE TABLE mysql_test1.t2 (c1 INT) - DATA DIRECTORY='$MYSQLTEST_VARDIR/tmp' - INDEX DIRECTORY='$MYSQLTEST_VARDIR/tmp'; ---enable_query_log ---enable_warnings -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,mysql_test1.t2) - INSERT_METHOD=LAST; -INSERT INTO t1 VALUES (1); -INSERT INTO mysql_test1.t2 VALUES (2); -SELECT * FROM m1; -#--copy_file $MYSQLTEST_DATADIR/test/m1.MRG /tmp/mysql-test-m1.MRG -DROP TABLE t1, mysql_test1.t2, m1; -DROP DATABASE mysql_test1; -# -# Review detected Crash #1. Detaching main tables while in sub statement. -# -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -INSERT INTO t1 (c1) VALUES (1); -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2) INSERT_METHOD=FIRST; -CREATE TABLE t3 (c1 INT); -INSERT INTO t3 (c1) VALUES (1); -CREATE FUNCTION f1() RETURNS INT RETURN (SELECT MAX(c1) FROM t3); -CREATE VIEW v1 AS SELECT foo.c1 c1, f1() c2, bar.c1 c3, f1() c4 - FROM tm1 foo, tm1 bar, t3; -SELECT * FROM v1; -DROP FUNCTION f1; -DROP VIEW v1; -DROP TABLE tm1, t1, t2, t3; -# -# Review detected Crash #2. Trying to attach temporary table twice. -# -CREATE TEMPORARY TABLE t1 (c1 INT); -CREATE TEMPORARY TABLE t2 (c1 INT); -CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2) - INSERT_METHOD=FIRST; -CREATE FUNCTION f1() RETURNS INT RETURN (SELECT MAX(c1) FROM tm1); -INSERT INTO tm1 (c1) VALUES (1); -SELECT f1() FROM (SELECT 1) AS c1; -DROP FUNCTION f1; -DROP TABLE tm1, t1, t2; -# -# Review suggested test. DDL in a stored function. -# -DELIMITER |; -CREATE FUNCTION f1() RETURNS INT -BEGIN - CREATE TEMPORARY TABLE t1 (c1 INT); - CREATE TEMPORARY TABLE t2 (c1 INT); - CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2); - INSERT INTO t1 (c1) VALUES (1); - RETURN (SELECT MAX(c1) FROM tm1); -END| -DELIMITER ;| -SELECT f1() FROM (SELECT 1 UNION SELECT 1) c1; -DROP FUNCTION f1; -DROP TABLE tm1, t1, t2; -# -# Base table. No LOCK TABLES, no functions/triggers. -# -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; -INSERT INTO tm1 VALUES (1); -SELECT * FROM tm1; -DROP TABLE tm1, t1; -# -# Base table. No LOCK TABLES, sub-statement that is run inside a function. -# -DELIMITER |; -CREATE FUNCTION f1() RETURNS INT -BEGIN - INSERT INTO tm1 VALUES (1); - RETURN (SELECT MAX(c1) FROM tm1); -END| -DELIMITER ;| -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; -SELECT f1(); -DROP FUNCTION f1; -DROP TABLE tm1, t1; -# -# Base table. LOCK TABLES, no functions/triggers. -# -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; -LOCK TABLE tm1 WRITE; -INSERT INTO tm1 VALUES (1); -SELECT * FROM tm1; -UNLOCK TABLES; -DROP TABLE tm1, t1; -# -# Base table. LOCK TABLES, sub-statement that is run inside a function. -# -DELIMITER |; -CREATE FUNCTION f1() RETURNS INT -BEGIN - INSERT INTO tm1 VALUES (1); - RETURN (SELECT MAX(c1) FROM tm1); -END| -DELIMITER ;| -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; -LOCK TABLE tm1 WRITE; -SELECT f1(); -UNLOCK TABLES; -DROP FUNCTION f1; -DROP TABLE tm1, t1; -# -# Base table. LOCK TABLES statement that locks a table that has a trigger -# that inserts into a merge table, so an attempt is made to lock tables -# of a sub-statement. -# -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE t2 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) INSERT_METHOD=LAST; -CREATE TRIGGER t2_ai AFTER INSERT ON t2 - FOR EACH ROW INSERT INTO tm1 VALUES(11); -LOCK TABLE t2 WRITE; -INSERT INTO t2 VALUES (2); -SELECT * FROM tm1; -SELECT * FROM t2; -UNLOCK TABLES; -DROP TRIGGER t2_ai; -DROP TABLE tm1, t1, t2; -# -# Temporary. No LOCK TABLES, no functions/triggers. -# -CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) - INSERT_METHOD=LAST; -INSERT INTO tm1 VALUES (1); -SELECT * FROM tm1; -DROP TABLE tm1, t1; -# -# Temporary. No LOCK TABLES, sub-statement that is run inside a function. -# -DELIMITER |; -CREATE FUNCTION f1() RETURNS INT -BEGIN - INSERT INTO tm1 VALUES (1); - RETURN (SELECT MAX(c1) FROM tm1); -END| -DELIMITER ;| -CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) - INSERT_METHOD=LAST; -SELECT f1(); -DROP FUNCTION f1; -DROP TABLE tm1, t1; -# -# Temporary. LOCK TABLES, no functions/triggers. -# -CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) - INSERT_METHOD=LAST; -CREATE TABLE t9 (c1 INT) ENGINE=MyISAM; -LOCK TABLE t9 WRITE; -INSERT INTO tm1 VALUES (1); -SELECT * FROM tm1; -UNLOCK TABLES; -DROP TABLE tm1, t1, t9; -# -# Temporary. LOCK TABLES, sub-statement that is run inside a function. -# -DELIMITER |; -CREATE FUNCTION f1() RETURNS INT -BEGIN - INSERT INTO tm1 VALUES (1); - RETURN (SELECT MAX(c1) FROM tm1); -END| -DELIMITER ;| -CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) - INSERT_METHOD=LAST; -CREATE TABLE t9 (c1 INT) ENGINE=MyISAM; -LOCK TABLE t9 WRITE; -SELECT f1(); -UNLOCK TABLES; -DROP FUNCTION f1; -DROP TABLE tm1, t1, t9; -# -# Temporary. LOCK TABLES statement that locks a table that has a trigger -# that inserts into a merge table, so an attempt is made to lock tables -# of a sub-statement. -# -CREATE TEMPORARY TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TEMPORARY TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) - INSERT_METHOD=LAST; -CREATE TABLE t2 (c1 INT) ENGINE=MyISAM; -CREATE TRIGGER t2_ai AFTER INSERT ON t2 - FOR EACH ROW INSERT INTO tm1 VALUES(11); -LOCK TABLE t2 WRITE; -INSERT INTO t2 VALUES (2); -SELECT * FROM tm1; -SELECT * FROM t2; -UNLOCK TABLES; -DROP TRIGGER t2_ai; -DROP TABLE tm1, t1, t2; ---echo # ---echo # Don't allow an update of a MERGE child in a trigger ---echo # if the table's already being modified by the main ---echo # statement. ---echo # -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) - INSERT_METHOD=LAST; -CREATE TRIGGER tm1_ai AFTER INSERT ON tm1 - FOR EACH ROW INSERT INTO t1 VALUES(11); -LOCK TABLE tm1 WRITE, t1 WRITE; ---error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG -INSERT INTO tm1 VALUES (1); -SELECT * FROM tm1; -UNLOCK TABLES; -LOCK TABLE t1 WRITE, tm1 WRITE; ---error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG -INSERT INTO tm1 VALUES (1); -SELECT * FROM tm1; -UNLOCK TABLES; -DROP TRIGGER tm1_ai; -DROP TABLE tm1, t1; - ---echo # ---echo # Don't select MERGE child when trying to get a prelocked table. ---echo # ---echo # Due to a limitation demonstrated by the previous test ---echo # we can no longer use a write-locked prelocked table. ---echo # The test is kept for historical purposes. ---echo # -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1) - INSERT_METHOD=LAST; ---enable_prepare_warnings -CREATE TRIGGER tm1_ai AFTER INSERT ON tm1 - FOR EACH ROW SELECT max(c1) FROM t1 INTO @var; ---disable_prepare_warnings -LOCK TABLE tm1 WRITE, t1 WRITE; -INSERT INTO tm1 VALUES (1); -SELECT * FROM tm1; -UNLOCK TABLES; -LOCK TABLE t1 WRITE, tm1 WRITE; -INSERT INTO tm1 VALUES (1); -SELECT * FROM tm1; -UNLOCK TABLES; -DROP TRIGGER tm1_ai; -DROP TABLE tm1, t1; - -# Don't resurrect chopped off prelocked tables. -# The problem is not visible by test results; only by debugging. -# -CREATE TABLE t1 (c1 INT) ENGINE=MyISAM; -CREATE TABLE t2 (c1 INT) ENGINE=MyISAM; -CREATE TABLE t3 (c1 INT) ENGINE=MyISAM; -CREATE TABLE t4 (c1 INT) ENGINE=MyISAM; -CREATE TABLE t5 (c1 INT) ENGINE=MyISAM; -CREATE TABLE tm1 (c1 INT) ENGINE=MRG_MYISAM UNION=(t1,t2,t3,t4,t5) - INSERT_METHOD=LAST; ---enable_prepare_warnings -CREATE TRIGGER t2_au AFTER UPDATE ON t2 - FOR EACH ROW SELECT MAX(c1) FROM t1 INTO @var; ---disable_prepare_warnings -CREATE FUNCTION f1() RETURNS INT - RETURN (SELECT MAX(c1) FROM t4); -LOCK TABLE tm1 WRITE, t1 WRITE, t2 WRITE, t3 WRITE, t4 WRITE, t5 WRITE; -INSERT INTO t1 VALUES(1); -INSERT INTO t2 VALUES(2); -INSERT INTO t3 VALUES(3); -INSERT INTO t4 VALUES(4); -INSERT INTO t5 VALUES(5); - connect (con1,localhost,root,,); - send UPDATE t2, tm1 SET t2.c1=f1(); -connection default; -# Force reopen in other thread. -#sleep 1; -FLUSH TABLES; -#sleep 1; -FLUSH TABLES; -#sleep 1; -UNLOCK TABLES; - connection con1; - reap; - disconnect con1; -connection default; -SELECT * FROM tm1; -DROP TRIGGER t2_au; -DROP FUNCTION f1; -DROP TABLE tm1, t1, t2, t3, t4, t5; - ---echo # ---echo # Bug#47633 - assert in ha_myisammrg::info during OPTIMIZE ---echo # -CREATE TEMPORARY TABLE t1 (c1 INT); -ALTER TABLE t1 ENGINE=MERGE UNION(t_not_exists,t1); -OPTIMIZE TABLE t1; -DROP TABLE t1; - ---echo # ---echo # Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine ---echo # More tests with TEMPORARY MERGE table and permanent children. ---echo # First without locked tables. ---echo # -# ---echo # -CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM; -CREATE TABLE t2 (c1 INT, c2 INT) ENGINE=MyISAM; -CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -SHOW CREATE TABLE t1; -SHOW CREATE TABLE m1; -SELECT * FROM m1; -INSERT INTO t1 VALUES (111, 121); -INSERT INTO m1 VALUES (211, 221); -SELECT * FROM m1; -SELECT * FROM t1; -SELECT * FROM t2; -# ---echo # -ALTER TABLE m1 RENAME m2; -SHOW CREATE TABLE m2; -SELECT * FROM m2; -# ---echo # -CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; ---error ER_TABLE_EXISTS_ERROR -ALTER TABLE m2 RENAME m1; -DROP TABLE m1; -ALTER TABLE m2 RENAME m1; -SHOW CREATE TABLE m1; -SELECT * FROM m1; -# ---echo # -ALTER TABLE m1 ADD COLUMN c3 INT; ---error ER_WRONG_MRG_TABLE -INSERT INTO m1 VALUES (212, 222, 232); ---error ER_WRONG_MRG_TABLE -SELECT * FROM m1; -ALTER TABLE t1 ADD COLUMN c3 INT; -ALTER TABLE t2 ADD COLUMN c3 INT; -INSERT INTO m1 VALUES (212, 222, 232); -SELECT * FROM m1; -# ---echo # -ALTER TABLE m1 DROP COLUMN c3; ---error ER_WRONG_MRG_TABLE -INSERT INTO m1 VALUES (213, 223); ---error ER_WRONG_MRG_TABLE -SELECT * FROM m1; -ALTER TABLE t1 DROP COLUMN c3; -ALTER TABLE t2 DROP COLUMN c3; -INSERT INTO m1 VALUES (213, 223); -SELECT * FROM m1; -# ---echo # -CREATE TABLE t3 (c1 INT, c2 INT) ENGINE=MyISAM; -ALTER TABLE m1 UNION=(t1,t2,t3); -INSERT INTO m1 VALUES (311, 321); -SELECT * FROM m1; -SELECT * FROM t1; -SELECT * FROM t2; -SELECT * FROM t3; -# ---echo # -CREATE TEMPORARY TABLE t4 (c1 INT, c2 INT) ENGINE=MyISAM; -ALTER TABLE m1 UNION=(t1,t2,t3,t4); -INSERT INTO m1 VALUES (411, 421); -SELECT * FROM m1; -SELECT * FROM t1; -SELECT * FROM t2; -SELECT * FROM t3; -SELECT * FROM t4; -# ---echo # -ALTER TABLE m1 ENGINE=MyISAM; -SHOW CREATE TABLE m1; -INSERT INTO m1 VALUES (511, 521); -SELECT * FROM m1; -# ---echo # -ALTER TABLE m1 ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -SELECT * FROM m1; -SELECT * FROM t1; -SELECT * FROM t2; -# ---echo # -CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM; -INSERT INTO t1 VALUES (611, 621); -SELECT * FROM m1; -DROP TABLE t1; -SELECT * FROM m1; -# -# ---echo # ---echo # -SHOW CREATE TABLE m1; -# ---echo # -CREATE TABLE m2 SELECT * FROM m1; -SHOW CREATE TABLE m2; -SELECT * FROM m2; -DROP TABLE m2; -# ---echo # -CREATE TEMPORARY TABLE m2 SELECT * FROM m1; -SHOW CREATE TABLE m2; -SELECT * FROM m2; -DROP TABLE m2; -# ---echo # -CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) - INSERT_METHOD=LAST; ---error ER_WRONG_MRG_TABLE -SELECT * FROM m2; -DROP TABLE m2; -# ---echo # ---error ER_WRONG_OBJECT -CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) - INSERT_METHOD=LAST SELECT * FROM m1; -# ---echo # ---error ER_WRONG_OBJECT -CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) - INSERT_METHOD=LAST SELECT * FROM m1; -# ---echo # -CREATE TABLE m2 LIKE m1; -SHOW CREATE TABLE m2; -SELECT * FROM m2; -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -DROP TABLE m2; -# ---echo # -CREATE TEMPORARY TABLE m2 LIKE m1; -SHOW CREATE TABLE m2; -SELECT * FROM m2; -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -DROP TABLE m2; -# ---echo # -CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) - INSERT_METHOD=LAST; -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -# -# ---echo # ---echo # -LOCK TABLE m1 WRITE, m2 WRITE; -SELECT * FROM m1,m2 WHERE m1.c1=m2.c1; -UNLOCK TABLES; -# -DROP TABLE t1, t2, t3, t4, m1, m2; -# -# -# ---echo # ---echo # Bug#36171 - CREATE TEMPORARY TABLE and MERGE engine ---echo # More tests with TEMPORARY MERGE table and permanent children. ---echo # (continued) Now the same with locked table. ---echo # -CREATE TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM; -CREATE TABLE t2 (c1 INT, c2 INT) ENGINE=MyISAM; -CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -SHOW CREATE TABLE t1; -SHOW CREATE TABLE m1; -SELECT * FROM m1; -INSERT INTO t1 VALUES (111, 121); -INSERT INTO m1 VALUES (211, 221); -SELECT * FROM m1; -SELECT * FROM t1; -SELECT * FROM t2; -# ---echo # -LOCK TABLE m1 WRITE, t1 WRITE, t2 WRITE; -# ---echo # -ALTER TABLE m1 RENAME m2; -SHOW CREATE TABLE m2; -SELECT * FROM m2; -# ---echo # -CREATE TEMPORARY TABLE m1 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; ---error ER_TABLE_EXISTS_ERROR -ALTER TABLE m2 RENAME m1; -DROP TABLE m1; -ALTER TABLE m2 RENAME m1; -SHOW CREATE TABLE m1; -SELECT * FROM m1; -# ---echo # -ALTER TABLE m1 ADD COLUMN c3 INT; ---error ER_WRONG_MRG_TABLE -INSERT INTO m1 VALUES (212, 222, 232); ---error ER_WRONG_MRG_TABLE -SELECT * FROM m1; -ALTER TABLE t1 ADD COLUMN c3 INT; -ALTER TABLE t2 ADD COLUMN c3 INT; -INSERT INTO m1 VALUES (212, 222, 232); -SELECT * FROM m1; -# ---echo # -ALTER TABLE m1 DROP COLUMN c3; ---error ER_WRONG_MRG_TABLE -INSERT INTO m1 VALUES (213, 223); ---error ER_WRONG_MRG_TABLE -SELECT * FROM m1; -ALTER TABLE t1 DROP COLUMN c3; -ALTER TABLE t2 DROP COLUMN c3; -INSERT INTO m1 VALUES (213, 223); -SELECT * FROM m1; -# ---echo # -UNLOCK TABLES; -CREATE TABLE t3 (c1 INT, c2 INT) ENGINE=MyISAM; -ALTER TABLE m1 UNION=(t1,t2,t3); -LOCK TABLE m1 WRITE; -INSERT INTO m1 VALUES (311, 321); -SELECT * FROM m1; -SELECT * FROM t1; -SELECT * FROM t2; -SELECT * FROM t3; -# ---echo # -CREATE TEMPORARY TABLE t4 (c1 INT, c2 INT) ENGINE=MyISAM; -ALTER TABLE m1 UNION=(t1,t2,t3,t4); -INSERT INTO m1 VALUES (411, 421); -SELECT * FROM m1; -SELECT * FROM t1; -SELECT * FROM t2; -SELECT * FROM t3; -SELECT * FROM t4; -# ---echo # -ALTER TABLE m1 ENGINE=MyISAM; -SHOW CREATE TABLE m1; -INSERT INTO m1 VALUES (511, 521); -SELECT * FROM m1; -# ---echo # -ALTER TABLE m1 ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -SELECT * FROM m1; -SELECT * FROM t1; -SELECT * FROM t2; -# ---echo # -CREATE TEMPORARY TABLE t1 (c1 INT, c2 INT) ENGINE=MyISAM; -INSERT INTO t1 VALUES (611, 621); -SELECT * FROM m1; -DROP TABLE t1; -SELECT * FROM m1; -# -# ---echo # ---echo # -SHOW CREATE TABLE m1; ---error ER_TABLE_NOT_LOCKED -CREATE TABLE m2 SELECT * FROM m1; -# ---echo # -CREATE TEMPORARY TABLE m2 SELECT * FROM m1; -SHOW CREATE TABLE m2; -SELECT * FROM m2; -DROP TABLE m2; -# ---echo # -CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) - INSERT_METHOD=LAST; -SELECT * FROM m2; -LOCK TABLE m1 WRITE, m2 WRITE; -UNLOCK TABLES; -DROP TABLE m2; -LOCK TABLE m1 WRITE; -# ---echo # ---echo # ER_TABLE_NOT_LOCKED is returned in ps-protocol ---error ER_WRONG_OBJECT, ER_TABLE_NOT_LOCKED -CREATE TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) - INSERT_METHOD=LAST SELECT * FROM m1; -# ---echo # ---error ER_WRONG_OBJECT -CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) - INSERT_METHOD=LAST SELECT * FROM m1; -# ---echo # -CREATE TEMPORARY TABLE m2 LIKE m1; -SHOW CREATE TABLE m2; -LOCK TABLE m1 WRITE, m2 WRITE; -SHOW CREATE TABLE m2; -SELECT * FROM m2; -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -DROP TABLE m2; -# ---echo # -CREATE TEMPORARY TABLE m2 (c1 INT, c2 INT) ENGINE=MRG_MyISAM UNION=(t3,t4) - INSERT_METHOD=LAST; -LOCK TABLE m1 WRITE, m2 WRITE; -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -# ---echo # -UNLOCK TABLES; -DROP TABLE t1, t2, t3, t4, m1, m2; - ---echo # ---echo # Bug47098 assert in MDL_context::destroy on HANDLER ---echo # <damaged merge table> OPEN ---echo # ---echo # Test that merge tables are closed correctly when opened using ---echo # HANDLER ... OPEN. ---echo # The general case. -connect (con1,localhost,root,,); -CREATE TABLE t1 (c1 int); -CREATE TABLE t2 (c1 int); -CREATE TABLE t3 (c1 int) ENGINE = MERGE UNION (t1,t2); -START TRANSACTION; ---error ER_ILLEGAL_HA -HANDLER t3 OPEN; -DROP TABLE t1, t2, t3; -connection default; ---echo # all mdl_tickets must have been released. -disconnect con1; ---echo # The bug-specific case. -connect (con1,localhost,root,,); -CREATE TABLE t1 (c1 int); -CREATE TABLE t2 (c1 int); -CREATE TABLE t3 (c1 int) ENGINE = MERGE UNION (t1,t2); -DROP TABLE t2; -START TRANSACTION; ---error ER_WRONG_MRG_TABLE -HANDLER t3 OPEN; -DROP TABLE t1, t3; -connection default; ---echo # all mdl_tickets must have been released. -disconnect con1; - ---echo # ---echo # A test case for Bug#47648 main.merge fails sporadically ---echo # ---echo # Make sure we correctly maintain lex->query_tables_last_own. ---echo # -create table t1 (c1 int not null); -create table t2 (c1 int not null); -create table t3 (c1 int not null); - -create function f1 () returns int return (select max(c1) from t3); - -create table t4 (c1 int not null) engine=merge union=(t1,t2) insert_method=last ; - -select * from t4 where c1 < f1(); -prepare stmt from "select * from t4 where c1 < f1()"; -execute stmt; -execute stmt; -execute stmt; -drop function f1; ---error ER_SP_DOES_NOT_EXIST -execute stmt; ---error ER_SP_DOES_NOT_EXIST -execute stmt; -drop table t4, t3, t2, t1; - - ---echo # ---echo # Bug#51240 ALTER TABLE of a locked MERGE table fails ---echo # - -CREATE TABLE t1 (c1 INT); -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1); -LOCK TABLE m1 WRITE; -# This used to cause an error. -ALTER TABLE m1 ADD INDEX (c1); - -UNLOCK TABLES; -DROP TABLE m1, t1; - ---echo # ---echo # Locking the merge table won't implicitly lock children. ---echo # -CREATE TABLE t1 (c1 INT); -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1); -LOCK TABLE m1 WRITE; ---error ER_TABLE_NOT_LOCKED_FOR_WRITE -ALTER TABLE t1 ADD INDEX (c1); -LOCK TABLE m1 WRITE, t1 WRITE; -ALTER TABLE t1 ADD INDEX (c1); -UNLOCK TABLES; -DROP TABLE m1, t1; - ---echo # ---echo # Test for bug #37371 "CREATE TABLE LIKE merge loses UNION parameter" ---echo # -create table t1 (i int) engine=myisam; -create table m1 (i int) engine=mrg_myisam union=(t1) insert_method=first; -create table m2 like m1; ---echo # Table definitions should match -show create table m1; -show create table m2; -drop tables m1, m2, t1; - ---echo # ---echo # Test case for Bug#54811 "Assert in mysql_lock_have_duplicate()" ---echo # Check that unique_table() works correctly for merge tables. ---echo # -create table t1 (a int); -create table t2 (a int); -create table t3 (b int); -create view v1 as select * from t3,t1; -create table m1 (a int) engine=merge union (t1, t2) insert_method=last; -create table m2 (a int) engine=merge union (t1, t2) insert_method=first; -create temporary table tmp (b int); -insert into tmp (b) values (1); - -insert into t1 (a) values (1); -insert into t3 (b) values (1); ---error ER_UPDATE_TABLE_USED -insert into m1 (a) values ((select max(a) from m1)); ---error ER_UPDATE_TABLE_USED -insert into m1 (a) values ((select max(a) from m2)); ---error ER_UPDATE_TABLE_USED -insert into m1 (a) values ((select max(a) from t1)); ---error ER_UPDATE_TABLE_USED -insert into m1 (a) values ((select max(a) from t2)); - ---error ER_UPDATE_TABLE_USED -insert into m1 (a) values ((select max(a) from t3, m1)); ---error ER_UPDATE_TABLE_USED -insert into m1 (a) values ((select max(a) from t3, m2)); ---error ER_UPDATE_TABLE_USED -insert into m1 (a) values ((select max(a) from t3, t1)); ---error ER_UPDATE_TABLE_USED -insert into m1 (a) values ((select max(a) from t3, t2)); - ---error ER_UPDATE_TABLE_USED -insert into m1 (a) values ((select max(a) from tmp, m1)); ---error ER_UPDATE_TABLE_USED -insert into m1 (a) values ((select max(a) from tmp, m2)); ---error ER_UPDATE_TABLE_USED -insert into m1 (a) values ((select max(a) from tmp, t1)); ---error ER_UPDATE_TABLE_USED -insert into m1 (a) values ((select max(a) from tmp, t2)); - ---error ER_VIEW_PREVENT_UPDATE -insert into m1 (a) values ((select max(a) from v1)); ---error ER_VIEW_PREVENT_UPDATE -insert into m1 (a) values ((select max(a) from tmp, v1)); - - -drop view v1; -drop temporary table tmp; -drop table t1, t2, t3, m1, m2; - - ---echo # ---echo # Bug#56494 Segfault in upgrade_shared_lock_to_exclusive() for ---echo # REPAIR of merge table ---echo # - -CREATE TABLE t1(a INT); -ALTER TABLE t1 engine= MERGE UNION (t_not_exists); -# This caused the segfault -ANALYZE TABLE t1; -CHECK TABLE t1; -CHECKSUM TABLE t1; -OPTIMIZE TABLE t1; -REPAIR TABLE t1; - -# This caused an assert -REPAIR TABLE t1 USE_FRM; - -DROP TABLE t1; -CREATE TABLE t1(a INT); -CREATE TABLE t2(a INT) engine= MERGE UNION (t1); -# This caused an assert -REPAIR TABLE t2 USE_FRM; - -DROP TABLE t1, t2; - - ---echo # ---echo # Bug#57002 Assert in upgrade_shared_lock_to_exclusive() ---echo # for ALTER TABLE + MERGE tables ---echo # - -CREATE TABLE t1(a INT) engine=myisam; -CREATE TABLE m1(a INT) engine=merge UNION(t1); -LOCK TABLES t1 READ, m1 WRITE; - -# This caused an assert ---error ER_TABLE_NOT_LOCKED_FOR_WRITE -ALTER TABLE t1 engine=myisam; - -UNLOCK TABLES; -DROP TABLE m1, t1; - - ---echo # ---echo # Test for bug #11754210 - "45777: CHECK TABLE DOESN'T SHOW ALL ---echo # PROBLEMS FOR MERGE TABLE COMPLIANCE IN 5.1" ---echo # -create table t1(id int) engine=myisam; -create view t3 as select 1 as id; -create table t4(id int) engine=memory; -create table m1(id int) engine=merge union=(t1,t2,t3,t4); ---error ER_WRONG_MRG_TABLE -select * from m1; ---echo # The below CHECK and REPAIR TABLE statements should ---echo # report all problems with underlying tables: ---echo # - absence of 't2', ---echo # - missing base table for 't3', ---echo # - wrong engine of 't4'. -check table m1; -repair table m1; ---echo # Clean-up. -drop tables m1, t1, t4; -drop view t3; - - ---echo # ---echo # MDEV-10424 Assertion `ticket == __null' failed in MDL_request::set_type ---echo # -CREATE TABLE t1 (f1 INT) ENGINE=MyISAM; -CREATE TABLE tmerge (f1 INT) ENGINE=MERGE UNION=(t1); -PREPARE stmt FROM "ANALYZE TABLE tmerge, t1"; -EXECUTE stmt; -EXECUTE stmt; -DEALLOCATE PREPARE stmt; -DROP TABLE t1, tmerge; - ---echo # ---echo # End of 5.5 tests ---echo # - ---echo # ---echo # Additional coverage for refactoring which is made as part ---echo # of fix for bug #27480 "Extend CREATE TEMPORARY TABLES privilege ---echo # to allow temp table operations". ---echo # ---echo # Check that prelocking works correctly for various variants of ---echo # merge tables. ---echo # -create table t1 (j int); -insert into t1 values (1); -create function f1() returns int return (select count(*) from m1); -create temporary table t2 (a int) engine=myisam; -insert into t2 values (1); -create temporary table m1 (a int) engine=merge union=(t2); -select f1() from t1; -drop tables t2, m1; -create table t2 (a int) engine=myisam; -insert into t2 values (1); -create table m1 (a int) engine=merge union=(t2); -select f1() from t1; -drop table m1; -create temporary table m1 (a int) engine=merge union=(t2); -select f1() from t1; -drop tables t1, t2, m1; -drop function f1; ---echo # ---echo # Check that REPAIR/CHECK and CHECKSUM statements work correctly ---echo # for various variants of merge tables. -create table t1 (a int) engine=myisam; -insert into t1 values (1); -create table m1 (a int) engine=merge union=(t1); -check table m1; -repair table m1; -checksum table m1; -drop tables t1, m1; -create temporary table t1 (a int) engine=myisam; -insert into t1 values (1); -create temporary table m1 (a int) engine=merge union=(t1); -check table m1; -repair table m1; -checksum table m1; -drop tables t1, m1; -create table t1 (a int) engine=myisam; -insert into t1 values (1); -create temporary table m1 (a int) engine=merge union=(t1); -check table m1; -repair table m1; -checksum table m1; -drop tables t1, m1; - -# Check effect of Bug#27480-preliminary patch: -# a merge-table with non-existing children, opened from a prelocked list. - -CREATE TABLE t1(a INT); -CREATE TABLE m1(a INT) ENGINE = MERGE UNION (q1, q2); - -CREATE TRIGGER trg1 BEFORE DELETE ON t1 -FOR EACH ROW - INSERT INTO m1 VALUES (1); - ---error ER_WRONG_MRG_TABLE -DELETE FROM t1; - -DROP TRIGGER trg1; -DROP TABLE t1; -DROP TABLE m1; - -set global default_storage_engine=@save_default_storage_engine; - -# Check that all connections opened by test cases in this file are really -# gone so execution of other tests won't be affected by their presence. ---source include/wait_until_count_sessions.inc - ---echo # ---echo # MDEV-27407 Different ASC/DESC index attributes on MERGE and underlying table can cause wrong results ---echo # -create table t (a int, key(a desc)) engine=myisam; -create table tm (a int, key(a)) engine=merge union(t); ---error ER_WRONG_MRG_TABLE -select * from tm; -drop table tm, t; - ---echo # ---echo # MDEV-27586 Auto-increment does not work with DESC on MERGE table ---echo # -create table t (a int not null, primary key(a desc)) engine=myisam; -create table tm (a int not null auto_increment, primary key(a desc)) engine=merge union=(t) insert_method=first; -insert into tm () values (); -insert into tm () values (); -insert into tm () values (); -select * from tm; -drop table tm, t; - ---echo # ---echo # End of 10.8 tests ---echo # - ---echo # ---echo # MDEV-30088 Assertion `cond_selectivity <= 1.0' failed in get_range_limit_read_cost ---echo # - -CREATE TABLE t1 (a TIMESTAMP, KEY(a)) ENGINE=MRG_MyISAM; -explain SELECT a, COUNT(*) FROM t1 WHERE a >= '2000-01-01 00:00:00' GROUP BY a; -SELECT a, COUNT(*) FROM t1 WHERE a >= '2000-01-01 00:00:00' GROUP BY a; -DROP TABLE t1; - ---echo # ---echo # MDEV-30525: Assertion `ranges > 0' fails in IO_AND_CPU_COST handler::keyread_time ---echo # -CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM; -CREATE TABLE t2 (a INT, KEY(a)) ENGINE=MyISAM; -CREATE TABLE tm (a INT, KEY(a)) ENGINE=MRG_MyISAM UNION=(t1,t2); -SELECT DISTINCT a FROM tm WHERE a > 50; -DROP TABLE tm, t1, t2; - ---echo # Testcase 2: -CREATE TABLE t1 (a INT, KEY(a)) ENGINE=MyISAM; -CREATE TABLE t2 (a INT, KEY(a)) ENGINE=MyISAM; -CREATE TABLE tm (a INT, KEY(a)) ENGINE=MERGE UNION = (t1, t2) INSERT_METHOD=FIRST; -ANALYZE TABLE tm PERSISTENT FOR ALL; -SELECT DISTINCT a FROM (SELECT * FROM tm WHERE a iS NOT NULL) AS sq; -DROP TABLE tm, t1, t2; - ---echo # ---echo # MDEV-30568 Assertion `cond_selectivity <= 1.000000001' failed in get_range_limit_read_cost ---echo # -CREATE TABLE t1 (f INT, KEY(f)) ENGINE=MyISAM; -CREATE TABLE t2 (f INT, KEY(f)) ENGINE=MyISAM; -CREATE TABLE tm (f INT, KEY(f)) ENGINE=MERGE UNION = (t1, t2); -SELECT DISTINCT f FROM tm WHERE f IN (47, 126, 97, 48, 73, 0); -DROP TABLE tm, t1, t2; - ---echo # ---echo # End of 11.0 tests ---echo # ---echo # ---echo # MDEV-29174: UPDATE of view that uses MERGE table ---echo # - -CREATE TABLE t1 (a int) ENGINE=MERGE; -CREATE VIEW v1 AS SELECT a FROM t1; -UPDATE v1 SET a=0; -DROP VIEW v1; -DROP TABLE t1; - ---echo # End of 11.1 tests diff --git a/mysql-test/main/merge_debug.result b/mysql-test/main/merge_debug.result deleted file mode 100644 index 36cf254f87e..00000000000 --- a/mysql-test/main/merge_debug.result +++ /dev/null @@ -1,27 +0,0 @@ -set @default_storage_engine= @@global.default_storage_engine; -set global default_storage_engine=myisam; -set session default_storage_engine=myisam; -call mtr.add_suppression("Index for table .*crashed' is corrupt; try to repair it"); -drop table if exists crashed,t2,t3,t4; -SET @orig_debug=@@global.debug_dbug; -CREATE TABLE crashed (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TABLE t3 (c1 INT); -CREATE TABLE t4 (c1 INT) ENGINE=MRG_MYISAM UNION=(crashed,t2,t3) INSERT_METHOD=LAST; -INSERT INTO crashed VALUES (10); -INSERT INTO t2 VALUES (20); -INSERT INTO t3 VALUES (30); -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, crashed WRITE; -SET GLOBAL debug_dbug="+d,myisam_pretend_crashed_table_on_open"; -CREATE TRIGGER t1_ai AFTER INSERT ON crashed FOR EACH ROW INSERT INTO t2 VALUES(29); -SET GLOBAL debug_dbug=@orig_debug; -INSERT INTO t4 VALUES (39); -ERROR HY000: Table 'crashed' was not locked with LOCK TABLES -INSERT INTO crashed VALUES (11); -ERROR HY000: Table 'crashed' was not locked with LOCK TABLES -INSERT INTO t2 VALUES (21); -INSERT INTO t3 VALUES (31); -UNLOCK TABLES; -DROP TRIGGER t1_ai; -DROP TABLE t4,crashed,t2,t3; -set global default_storage_engine=@default_storage_engine; diff --git a/mysql-test/main/merge_debug.test b/mysql-test/main/merge_debug.test deleted file mode 100644 index 4141042c261..00000000000 --- a/mysql-test/main/merge_debug.test +++ /dev/null @@ -1,46 +0,0 @@ -# -# Test failures with MERGE -# - ---source include/have_debug.inc - -set @default_storage_engine= @@global.default_storage_engine; -set global default_storage_engine=myisam; -set session default_storage_engine=myisam; - -call mtr.add_suppression("Index for table .*crashed' is corrupt; try to repair it"); - ---disable_warnings -drop table if exists crashed,t2,t3,t4; ---enable_warnings - -SET @orig_debug=@@global.debug_dbug; - -# -# Check that MariaDB handles reopen that fails without crashing -# -CREATE TABLE crashed (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TABLE t3 (c1 INT); -CREATE TABLE t4 (c1 INT) ENGINE=MRG_MYISAM UNION=(crashed,t2,t3) INSERT_METHOD=LAST; -INSERT INTO crashed VALUES (10); -INSERT INTO t2 VALUES (20); -INSERT INTO t3 VALUES (30); - -LOCK TABLES t3 WRITE, t2 WRITE, t4 WRITE, crashed WRITE; -SET GLOBAL debug_dbug="+d,myisam_pretend_crashed_table_on_open"; ---disable_warnings -CREATE TRIGGER t1_ai AFTER INSERT ON crashed FOR EACH ROW INSERT INTO t2 VALUES(29); ---enable_warnings -SET GLOBAL debug_dbug=@orig_debug; ---error ER_TABLE_NOT_LOCKED -INSERT INTO t4 VALUES (39); ---error ER_TABLE_NOT_LOCKED -INSERT INTO crashed VALUES (11); -INSERT INTO t2 VALUES (21); -INSERT INTO t3 VALUES (31); -UNLOCK TABLES; -DROP TRIGGER t1_ai; -DROP TABLE t4,crashed,t2,t3; - -set global default_storage_engine=@default_storage_engine; diff --git a/mysql-test/main/merge_innodb.result b/mysql-test/main/merge_innodb.result deleted file mode 100644 index 5aa344a9391..00000000000 --- a/mysql-test/main/merge_innodb.result +++ /dev/null @@ -1,70 +0,0 @@ -DROP TABLE IF EXISTS t1, t2, t3, t4, t5; -CREATE TABLE t1 (c1 varchar(100)) ENGINE=MyISAM; -CREATE TABLE t2 (c1 varchar(100)) ENGINE=MyISAM; -CREATE TABLE t3 (c1 varchar(100)) ENGINE=InnoDB; -INSERT INTO t1 VALUES ('Ann'), ('Alice'); -INSERT INTO t2 VALUES ('Bob'), ('Brian'); -INSERT INTO t3 VALUES ('Chris'), ('Charlie'); -CREATE TABLE t4 (c1 varchar(100)) ENGINE=MRG_MYISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -CREATE TABLE t5 (c1 varchar(100)) ENGINE=MRG_MYISAM UNION=(t1,t3) -INSERT_METHOD=LAST; -SELECT * FROM t5; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -SELECT * FROM t4; -c1 -Ann -Alice -Bob -Brian -ALTER TABLE t2 ENGINE=InnoDB; -SELECT * FROM t4; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -DELETE FROM t2 LIMIT 1; -SELECT * FROM t4; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -INSERT INTO t4 VALUES ('Beware'); -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -SELECT * FROM t4; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -SELECT * FROM t2; -c1 -Brian -SELECT * FROM t1; -c1 -Ann -Alice -DROP TABLE t1, t2, t3, t4, t5; -create table t1 (c1 varchar(100)); -create table t2 (c1 varchar(100)); -create view t3 as select * from t1; -insert into t1 values ('ann'), ('alice'); -insert into t2 values ('bob'), ('brian'); -create temporary table t4 (c1 varchar(100)) engine=MERGE union=(t2, t1); -create temporary table t5 (c1 varchar(100)) engine=MERGE union=(t3, t1); -select * from t5; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -lock tables t1 read, t2 read, t3 read, t4 read; -select * from t5; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -select * from t4; -c1 -bob -brian -ann -alice -unlock tables; -drop table t2; -create view t2 as select * from t1; -select * from t4; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -lock tables t1 read, t2 read, t3 read; -select * from t4; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -select * from t4; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -select * from t4; -ERROR HY000: Unable to open underlying table which is differently defined or of non-MyISAM type or doesn't exist -unlock tables; -drop view t2, t3; -drop table t1; diff --git a/mysql-test/main/merge_innodb.test b/mysql-test/main/merge_innodb.test deleted file mode 100644 index 9f87f241d00..00000000000 --- a/mysql-test/main/merge_innodb.test +++ /dev/null @@ -1,72 +0,0 @@ -# t/merge_innodb.test -# -# Tests with MERGE tables over InnoDB tables -# - ---source include/have_innodb.inc - ---disable_warnings -DROP TABLE IF EXISTS t1, t2, t3, t4, t5; ---enable_warnings - -# -# Bug#30491 - MERGE doesn't report error when one table is Innodb -# -CREATE TABLE t1 (c1 varchar(100)) ENGINE=MyISAM; -CREATE TABLE t2 (c1 varchar(100)) ENGINE=MyISAM; -CREATE TABLE t3 (c1 varchar(100)) ENGINE=InnoDB; -INSERT INTO t1 VALUES ('Ann'), ('Alice'); -INSERT INTO t2 VALUES ('Bob'), ('Brian'); -INSERT INTO t3 VALUES ('Chris'), ('Charlie'); -CREATE TABLE t4 (c1 varchar(100)) ENGINE=MRG_MYISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -CREATE TABLE t5 (c1 varchar(100)) ENGINE=MRG_MYISAM UNION=(t1,t3) - INSERT_METHOD=LAST; ---error ER_WRONG_MRG_TABLE -SELECT * FROM t5; -SELECT * FROM t4; -ALTER TABLE t2 ENGINE=InnoDB; ---error ER_WRONG_MRG_TABLE -SELECT * FROM t4; -DELETE FROM t2 LIMIT 1; ---error ER_WRONG_MRG_TABLE -SELECT * FROM t4; ---error ER_WRONG_MRG_TABLE -INSERT INTO t4 VALUES ('Beware'); ---error ER_WRONG_MRG_TABLE -SELECT * FROM t4; -SELECT * FROM t2; -SELECT * FROM t1; -DROP TABLE t1, t2, t3, t4, t5; - -# -# Bug#20691429 temporary merge over view under lock tables -# -create table t1 (c1 varchar(100)); -create table t2 (c1 varchar(100)); -create view t3 as select * from t1; -insert into t1 values ('ann'), ('alice'); -insert into t2 values ('bob'), ('brian'); -create temporary table t4 (c1 varchar(100)) engine=MERGE union=(t2, t1); -create temporary table t5 (c1 varchar(100)) engine=MERGE union=(t3, t1); ---error ER_WRONG_MRG_TABLE -select * from t5; -lock tables t1 read, t2 read, t3 read, t4 read; ---error ER_WRONG_MRG_TABLE -select * from t5; -select * from t4; -unlock tables; -drop table t2; -create view t2 as select * from t1; ---error ER_WRONG_MRG_TABLE -select * from t4; -lock tables t1 read, t2 read, t3 read; ---error ER_WRONG_MRG_TABLE -select * from t4; ---error ER_WRONG_MRG_TABLE -select * from t4; ---error ER_WRONG_MRG_TABLE -select * from t4; -unlock tables; -drop view t2, t3; -drop table t1; diff --git a/mysql-test/main/merge_mmap-master.opt b/mysql-test/main/merge_mmap-master.opt deleted file mode 100644 index 9606fb57187..00000000000 --- a/mysql-test/main/merge_mmap-master.opt +++ /dev/null @@ -1 +0,0 @@ ---myisam-use-mmap diff --git a/mysql-test/main/merge_mmap.result b/mysql-test/main/merge_mmap.result deleted file mode 100644 index 8e655a0491b..00000000000 --- a/mysql-test/main/merge_mmap.result +++ /dev/null @@ -1,190 +0,0 @@ -SET GLOBAL default_storage_engine = MyISAM; -SET SESSION default_storage_engine = MyISAM; -DROP TABLE IF EXISTS t1, t2, m1, m2; -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -c1 -1 -2 -3 -4 -1 -2 -3 -4 -SELECT * FROM t2; -c1 -2 -3 -4 -1 -2 -3 -4 -DROP TABLE m2, m1, t2, t1; -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -c1 -1 -2 -3 -4 -1 -2 -3 -4 -DROP TABLE m2, m1, t2, t1; -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -c1 -1 -2 -3 -4 -1 -2 -3 -4 -DROP TABLE m2, m1, t2, t1; -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -c1 -1 -2 -3 -4 -1 -2 -3 -4 -DROP TABLE m2, m1, t2, t1; -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -LOCK TABLE m1 WRITE, m2 WRITE; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -c1 -1 -2 -3 -4 -1 -2 -3 -4 -SELECT * FROM t2; -c1 -2 -3 -4 -1 -2 -3 -4 -UNLOCK TABLES; -DROP TABLE m2, m1, t2, t1; -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -LOCK TABLE m1 WRITE, m2 WRITE; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -c1 -1 -2 -3 -4 -1 -2 -3 -4 -UNLOCK TABLES; -DROP TABLE m2, m1, t2, t1; -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -LOCK TABLE m1 WRITE, m2 WRITE; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -c1 -1 -2 -3 -4 -1 -2 -3 -4 -UNLOCK TABLES; -DROP TABLE m2, m1, t2, t1; -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) -INSERT_METHOD=LAST; -LOCK TABLE m1 WRITE, m2 WRITE; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -c1 -1 -2 -3 -4 -1 -2 -3 -4 -UNLOCK TABLES; -DROP TABLE m2, m1, t2, t1; -End of 6.0 tests diff --git a/mysql-test/main/merge_mmap.test b/mysql-test/main/merge_mmap.test deleted file mode 100644 index 01c3896bd02..00000000000 --- a/mysql-test/main/merge_mmap.test +++ /dev/null @@ -1,153 +0,0 @@ -# -# Test of MERGE TABLES with MyISAM memory mapping enabled (--myisam-use-mmap) -# - -# MERGE tables require MyISAM tables ---let $default=`SELECT @@global.default_storage_engine` -SET GLOBAL default_storage_engine = MyISAM; -SET SESSION default_storage_engine = MyISAM; - -# Clean up resources used in this test case. ---disable_warnings -DROP TABLE IF EXISTS t1, t2, m1, m2; ---enable_warnings - -#################### -## No locked tables. -#################### -# -# INSERT-SELECT with no TEMPORARY table. -# -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -SELECT * FROM t2; -DROP TABLE m2, m1, t2, t1; -# -# INSERT-SELECT with TEMPORARY select table. -# -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -DROP TABLE m2, m1, t2, t1; -# -# INSERT-SELECT with TEMPORARY insert table. -# -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -DROP TABLE m2, m1, t2, t1; -# -# INSERT-SELECT with TEMPORARY both tables. -# -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -DROP TABLE m2, m1, t2, t1; - -#################### -## With LOCK TABLES. -#################### -# -# INSERT-SELECT with no TEMPORARY table. -# ---disable_service_connection -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -LOCK TABLE m1 WRITE, m2 WRITE; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -SELECT * FROM t2; -UNLOCK TABLES; -DROP TABLE m2, m1, t2, t1; -# -# INSERT-SELECT with TEMPORARY select table. -# -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -CREATE TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -LOCK TABLE m1 WRITE, m2 WRITE; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -UNLOCK TABLES; -DROP TABLE m2, m1, t2, t1; -# -# INSERT-SELECT with TEMPORARY insert table. -# -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -LOCK TABLE m1 WRITE, m2 WRITE; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -UNLOCK TABLES; -DROP TABLE m2, m1, t2, t1; -# -# INSERT-SELECT with TEMPORARY both tables. -# -CREATE TABLE t1 (c1 INT); -CREATE TABLE t2 (c1 INT); -CREATE TEMPORARY TABLE m1 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -CREATE TEMPORARY TABLE m2 (c1 INT) ENGINE=MRG_MyISAM UNION=(t1,t2) - INSERT_METHOD=LAST; -LOCK TABLE m1 WRITE, m2 WRITE; -INSERT INTO t1 VALUES (1); -INSERT INTO t2 VALUES (2), (3), (4); -INSERT INTO m2 SELECT * FROM m1; -SELECT * FROM m2; -UNLOCK TABLES; -DROP TABLE m2, m1, t2, t1; ---enable_service_connection - ---echo End of 6.0 tests - ---disable_result_log ---disable_query_log -eval SET GLOBAL default_storage_engine = $default; ---enable_result_log ---enable_query_log diff --git a/mysql-test/main/myisam_explain_non_select_all.result b/mysql-test/main/myisam_explain_non_select_all.result index 28107af3770..84b8d9ae4c5 100644 --- a/mysql-test/main/myisam_explain_non_select_all.result +++ b/mysql-test/main/myisam_explain_non_select_all.result @@ -15,6 +15,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE a < 10; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = 10 where `test`.`t1`.`a` < 10 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 2 @@ -54,6 +56,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1 WHERE a < 10; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` using dual where `test`.`t1`.`a` < 10 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 2 @@ -93,6 +97,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1 USING t1 WHERE a = 1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` using `test`.`t1` where `test`.`t1`.`a` = 1 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 2 @@ -136,6 +142,8 @@ EXPLAIN EXTENDED UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where 1 SIMPLE t2 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 update `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where `test`.`t1`.`a` = 1 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -182,6 +190,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t11 ALL NULL NULL NULL NULL 3 100.00 Using where 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 100.00 2 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 /* select#1 */ update `test`.`t1` `t11` join (/* select#2 */ select `test`.`t2`.`b` AS `b` from `test`.`t2`) `t12` set `test`.`t11`.`a` = 10 where `test`.`t11`.`a` = 1 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -226,6 +236,8 @@ EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 update `test`.`t1` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where `test`.`t2`.`b` < 3 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -273,6 +285,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 33.33 Using where; FirstMatch(t1) Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1003 update `test`.`t1` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where `test`.`t2`.`b` = `test`.`t1`.`a` and `test`.`t1`.`a` < 3 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -325,6 +338,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 100.00 2 MATERIALIZED t3 ALL NULL NULL NULL NULL 1004 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` semi join (`test`.`t3`) join `test`.`t2` set `test`.`t1`.`a` = 10 where `test`.`t3`.`b` < 3 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 6 @@ -373,6 +388,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t11 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 100.00 2 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 /* select#1 */ update `test`.`t1` `t11` join (/* select#2 */ select `test`.`t2`.`b` AS `b` from `test`.`t2`) `t12` set `test`.`t11`.`a` = `test`.`t11`.`a` + 10 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -421,6 +438,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY <derived2> system NULL NULL NULL NULL 1 100.00 1 PRIMARY t11 ALL NULL NULL NULL NULL 3 100.00 2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1003 /* select#1 */ update `test`.`t1` `t11` set `test`.`t11`.`a` = `test`.`t11`.`a` + 10 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 2 @@ -471,6 +490,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t11 ALL NULL NULL NULL NULL 3 100.00 Using where 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 100.00 2 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 /* select#1 */ update `test`.`t1` `t11` join (/* select#2 */ select `test`.`t2`.`b` AS `b` from `test`.`t2`) `t12` set `test`.`t11`.`a` = 10 where `test`.`t11`.`a` > 1 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -511,6 +532,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1 WHERE a > 1 LIMIT 1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` using dual where `test`.`t1`.`a` > 1 limit 1 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 2 @@ -550,6 +573,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1 WHERE 0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` using dual where 0 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 2 @@ -586,6 +611,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1 USING t1 WHERE 0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` using `test`.`t1` where 0 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 2 @@ -622,6 +649,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1 WHERE a = 3; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range a a 5 NULL 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` using dual where `test`.`t1`.`a` = 3 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 5 @@ -659,6 +688,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1 WHERE a < 3; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range a a 5 NULL 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` using dual where `test`.`t1`.`a` < 3 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 5 @@ -694,6 +725,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 delete from `test`.`t1` using dual where `test`.`t1`.`a` > 0 order by `test`.`t1`.`a` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 3 @@ -729,6 +762,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` using dual where `test`.`t1`.`a` > 0 order by `test`.`t1`.`a` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 3 @@ -768,6 +803,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 index NULL PRIMARY 4 NULL 1 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` using dual where @a:=`test`.`t1`.`a` order by `test`.`t1`.`a` limit 1 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 3 @@ -808,6 +845,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t1` using dual order by `test`.`t1`.`a`,`test`.`t1`.`b` limit 1 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 7 @@ -861,6 +900,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 1 SIMPLE t2 ref PRIMARY PRIMARY 4 test.t1.a1 1 100.00 1 SIMPLE t3 eq_ref PRIMARY PRIMARY 8 test.t2.b2,test.t1.b1 1 100.00 +Warnings: +Note 1003 delete from `test`.`t1`,`test`.`t2`,`test`.`t3` using `test`.`t1` join `test`.`t2` join `test`.`t3` where `test`.`t2`.`a2` = `test`.`t1`.`a1` and `test`.`t3`.`a3` = `test`.`t2`.`b2` and `test`.`t3`.`b3` = `test`.`t1`.`b1` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 13 @@ -909,6 +950,8 @@ EXPLAIN EXTENDED UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 4 25.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 update `test`.`t1` semi join (`test`.`t2`) set `test`.`t1`.`a` = 10 where `test`.`t2`.`a` = `test`.`t1`.`a` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -954,6 +997,8 @@ EXPLAIN EXTENDED DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 Using where 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 5 100.00 Using where +Warnings: +Note 1003 /* select#1 */ delete from `test`.`t1` using dual where <in_optimizer>(`test`.`t1`.`a1`,<exists>(/* select#2 */ select `test`.`t2`.`a2` from `test`.`t2` where `test`.`t2`.`a2` > 2 and <cache>(`test`.`t1`.`a1`) = `test`.`t2`.`a2`)) # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -995,6 +1040,8 @@ EXPLAIN EXTENDED DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 20.00 Using where; FirstMatch(t1) +Warnings: +Note 1003 delete from `test`.`t1` using (`test`.`t2`) where `test`.`t2`.`a2` > 2 and `test`.`t1`.`a1` = `test`.`t2`.`a2` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -1035,6 +1082,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t1 SET i = 10; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 100.00 +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`i` = 10 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 3 @@ -1074,6 +1123,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL 5 NULL Deleting all rows +Warnings: +Note 1003 delete from `test`.`t1` using dual # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 3 @@ -1116,6 +1167,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 index NULL a 15 NULL 5 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` using dual where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 8 @@ -1158,6 +1211,8 @@ FLUSH TABLES; EXPLAIN EXTENDED INSERT INTO t2 SELECT * FROM t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 insert into `test`.`t2` select `test`.`t1`.`i` AS `i` from `test`.`t1` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -1198,6 +1253,8 @@ FLUSH TABLES; EXPLAIN EXTENDED REPLACE INTO t2 SELECT * FROM t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 replace into `test`.`t2` select `test`.`t1`.`i` AS `i` from `test`.`t1` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -1236,6 +1293,8 @@ FLUSH TABLES; EXPLAIN EXTENDED INSERT INTO t1 SET i = 10; id select_type table type possible_keys key key_len ref rows filtered Extra 1 INSERT t1 ALL NULL NULL NULL NULL NULL 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t1`(i) values (10) # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 2 @@ -1259,6 +1318,8 @@ FLUSH TABLES; EXPLAIN EXTENDED REPLACE INTO t1 SET i = 10; id select_type table type possible_keys key key_len ref rows filtered Extra 1 INSERT t1 ALL NULL NULL NULL NULL NULL 100.00 NULL +Warnings: +Note 1003 replace into `test`.`t1`(i) values (10) # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 2 @@ -1285,6 +1346,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 5 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t1` using dual where `test`.`t1`.`i` > 10 and `test`.`t1`.`i` <= 18 order by `test`.`t1`.`i` limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -1326,6 +1389,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t1` using dual where `test`.`t1`.`i` > 10 and `test`.`t1`.`i` <= 18 order by `test`.`t1`.`i` limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -1375,6 +1440,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 index NULL a 15 NULL 5 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` using dual where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 8 @@ -1421,6 +1488,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 index NULL a 15 NULL 5 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` using dual where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 8 @@ -1466,6 +1535,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` using dual where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 8 @@ -1516,6 +1587,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` using dual where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 8 @@ -1567,6 +1640,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t2` using dual where `test`.`t2`.`key1` < 13 or `test`.`t2`.`key2` < 14 order by `test`.`t2`.`key1` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 6 @@ -1616,6 +1691,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 5 100.00 Using where +Warnings: +Note 1003 delete from `test`.`t2` using dual where `test`.`t2`.`i` > 10 and `test`.`t2`.`i` <= 18 order by `test`.`t2`.`i` desc limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -1659,6 +1736,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t2 ORDER BY a, b DESC LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 delete from `test`.`t2` using dual order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 6 @@ -1709,6 +1788,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 index NULL a 6 NULL 5 100.00 +Warnings: +Note 1003 delete from `test`.`t2` using dual order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 6 @@ -1754,6 +1835,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 5 100.00 Using where; Using buffer +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where `test`.`t2`.`i` > 10 and `test`.`t2`.`i` <= 18 order by `test`.`t2`.`i` limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -1798,6 +1881,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where `test`.`t2`.`i` > 10 and `test`.`t2`.`i` <= 18 order by `test`.`t2`.`i` limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -1848,6 +1933,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 index NULL a 15 NULL 5 100.00 Using where; Using buffer +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 8 @@ -1895,6 +1982,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 index NULL a 15 NULL 5 100.00 Using where; Using buffer +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 8 @@ -1941,6 +2030,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 8 @@ -1991,6 +2082,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`d` = 10 where `test`.`t2`.`b` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`c` limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 8 @@ -2042,6 +2135,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 index_merge key1,key2 key1,key2 5,5 NULL 7 100.00 Using sort_union(key1,key2); Using where; Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`i` = 123 where `test`.`t2`.`key1` < 13 or `test`.`t2`.`key2` < 14 order by `test`.`t2`.`key1` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 6 @@ -2091,6 +2186,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 range PRIMARY PRIMARY 4 NULL 5 100.00 Using where; Using buffer +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`a` = 10 where `test`.`t2`.`i` > 10 and `test`.`t2`.`i` <= 18 order by `test`.`t2`.`i` desc limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -2135,6 +2232,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 26 100.00 Using filesort +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a`,`test`.`t2`.`b` desc limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 6 @@ -2186,6 +2285,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 index NULL a 6 NULL 5 100.00 Using buffer +Warnings: +Note 1003 update `test`.`t2` set `test`.`t2`.`c` = 10 order by `test`.`t2`.`a` desc,`test`.`t2`.`b` desc limit 5 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 6 @@ -2234,6 +2335,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range c1_idx c1_idx 2 NULL 2 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`c2` = 0 where `test`.`t1`.`c1_idx` = 'y' order by `test`.`t1`.`pk` desc limit 2 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 6 @@ -2276,6 +2379,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range c1_idx c1_idx 2 NULL 2 100.00 Using where; Using filesort +Warnings: +Note 1003 delete from `test`.`t1` using dual where `test`.`t1`.`c1_idx` = 'y' order by `test`.`t1`.`pk` desc limit 2 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 6 @@ -2321,6 +2426,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t1 SET a=a+10 WHERE a > 34; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 100.00 Using where; Using buffer +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = `test`.`t1`.`a` + 10 where `test`.`t1`.`a` > 34 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 3 @@ -2364,6 +2471,8 @@ EXPLAIN EXTENDED UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 system NULL NULL NULL NULL 0 0.00 Const row not found 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 +Warnings: +Note 1003 update `test`.`t1` set NULL = 10 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 7 @@ -2403,6 +2512,8 @@ EXPLAIN EXTENDED UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 W id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 system NULL NULL NULL NULL 0 0.00 Const row not found 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 update `test`.`t1` set NULL = 10 where `test`.`t1`.`c3` = 10 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 7 @@ -2451,6 +2562,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 2 DEPENDENT SUBQUERY t2 ref IDX IDX 5 test.t1.f1 1 100.00 Warnings: Note 1276 Field or reference 'test.t1.f1' of SELECT #2 was resolved in SELECT #1 +Note 1003 /* select#1 */ update `test`.`t1` set `test`.`t1`.`f2` = (/* select#2 */ select max(`test`.`t2`.`f4`) from `test`.`t2` where `test`.`t2`.`f3` = `test`.`t1`.`f1`) # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 7 @@ -2520,6 +2632,8 @@ EXPLAIN EXTENDED UPDATE v1 SET a = 1 WHERE a > 0; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t11 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t12 ALL NULL NULL NULL NULL 2 100.00 +Warnings: +Note 1003 update `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where `test`.`t11`.`a` > 0 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 2 @@ -2561,6 +2675,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 1 SIMPLE t11 ALL NULL NULL NULL NULL 2 100.00 Using where 1 SIMPLE t12 ALL NULL NULL NULL NULL 2 100.00 +Warnings: +Note 1003 update `test`.`t1` join `test`.`t1` `t11` join `test`.`t1` `t12` set `test`.`t11`.`a` = 1 where `test`.`t11`.`a` = `test`.`t1`.`a` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 2 @@ -2606,6 +2722,8 @@ FLUSH TABLES; EXPLAIN EXTENDED DELETE FROM v1 WHERE a < 4; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 3 100.00 Using where +Warnings: +Note 1003 /* select#1 */ delete from `test`.`t1` using dual where `test`.`t1`.`a` < 4 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 3 @@ -2653,6 +2771,8 @@ EXPLAIN EXTENDED DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 4 100.00 Using where 1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 +Warnings: +Note 1003 delete from `test`.`t1` using `test`.`t2` join `test`.`t1` where `test`.`t1`.`a` = `test`.`t2`.`x` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 6 @@ -2700,6 +2820,8 @@ EXPLAIN EXTENDED DELETE v1 FROM t2, v1 WHERE t2.x = v1.a; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t2 ALL NULL NULL NULL NULL 4 100.00 Using where 1 SIMPLE t1 eq_ref PRIMARY PRIMARY 4 test.t2.x 1 100.00 +Warnings: +Note 1003 delete from `test`.`t1` using `test`.`t2` join `test`.`t1` where `test`.`t1`.`a` = `test`.`t2`.`x` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 6 @@ -2742,6 +2864,8 @@ FLUSH TABLES; EXPLAIN EXTENDED INSERT INTO v1 VALUES (10); id select_type table type possible_keys key key_len ref rows filtered Extra 1 INSERT t1 ALL NULL NULL NULL NULL NULL 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t1`(x) values (10) # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 2 @@ -2780,6 +2904,8 @@ FLUSH TABLES; EXPLAIN EXTENDED INSERT INTO v1 SELECT * FROM t1; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 system NULL NULL NULL NULL 0 0.00 Const row not found +Warnings: +Note 1003 insert into `test`.`t2`(x) /* select#1 */ select NULL AS `a` from `test`.`t1` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -2833,6 +2959,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 100.00 Using where 1 PRIMARY <derived3> eq_ref distinct_key distinct_key 5 test.t1.a 1 100.00 3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ update (/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` join `test`.`t1` set `test`.`t1`.`a` = 10 where `x`.`b` = `test`.`t1`.`a` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -2882,6 +3010,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY <derived3> eq_ref distinct_key distinct_key 5 test.t1.a 1 100.00 1 PRIMARY t2 ALL NULL NULL NULL NULL 3 100.00 3 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort +Warnings: +Note 1003 /* select#1 */ update (/* select#3 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` join `test`.`t1` join `test`.`t2` set `test`.`t1`.`a` = 10 where `x`.`b` = `test`.`t1`.`a` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -2933,6 +3063,8 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 100.00 4 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 Using filesort 2 DERIVED t2 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1003 /* select#1 */ update (/* select#4 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` order by `test`.`t2`.`b` limit 2,2) `x` join `test`.`t1` join (/* select#2 */ select `test`.`t2`.`b` AS `b` from `test`.`t2`) `y` set `test`.`t1`.`a` = 10 where `x`.`b` = `test`.`t1`.`a` # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 4 @@ -2979,6 +3111,8 @@ JOIN t1 AS a12 ON a12.c1 = a11.c1 ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(NULL) from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where 0) DROP TABLE t1, t2, t3; #73 CREATE TABLE t1 (id INT); @@ -3005,6 +3139,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t1 SET a=a+1 WHERE a>10; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 100.00 Using where; Using buffer +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = `test`.`t1`.`a` + 1 where `test`.`t1`.`a` > 10 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 3 @@ -3038,6 +3174,8 @@ FLUSH TABLES; EXPLAIN EXTENDED UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 1 100.00 Using where; Using filesort +Warnings: +Note 1003 update `test`.`t1` set `test`.`t1`.`a` = `test`.`t1`.`a` + 1 where `test`.`t1`.`a` > 10 order by `test`.`t1`.`a` + 20 # Status of EXPLAIN EXTENDED query Variable_name Value Handler_read_key 3 @@ -3061,6 +3199,61 @@ Handler_read_key 4 Sort_range 1 DROP TABLE t1; +#75 +CREATE TABLE t1 (id INT PRIMARY KEY, i INT); +# +# query: INSERT INTO t1 VALUES (3,10), (7,11), (3,11) ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +# select: +# +EXPLAIN INSERT INTO t1 VALUES (3,10), (7,11), (3,11) ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id);; +id select_type table type possible_keys key key_len ref rows Extra +1 INSERT t1 ALL NULL NULL NULL NULL NULL NULL +FLUSH STATUS; +FLUSH TABLES; +EXPLAIN EXTENDED INSERT INTO t1 VALUES (3,10), (7,11), (3,11) ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id);; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 INSERT t1 ALL NULL NULL NULL NULL NULL 100.00 NULL +Warnings: +Note 1003 insert into `test`.`t1` values (3,10),(7,11),(3,11) on duplicate key update `test`.`t1`.`id` = last_insert_id(`test`.`t1`.`id`) +# Status of EXPLAIN EXTENDED query +Variable_name Value +Handler_read_key 4 +# Status of testing query execution: +Variable_name Value +Handler_read_key 4 +Handler_read_rnd 1 +Handler_write 3 + +DROP TABLE t1; +#76 +CREATE TABLE t1 (id INT PRIMARY KEY, i INT); +CREATE TABLE t2 (a INT, b INT); +INSERT INTO t2 VALUES (1,10), (3,10), (7,11), (3,11); +# +# query: INSERT INTO t1 SELECT * FROM t2 ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id); +# select: +# +EXPLAIN INSERT INTO t1 SELECT * FROM t2 ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id);; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 4 +FLUSH STATUS; +FLUSH TABLES; +EXPLAIN EXTENDED INSERT INTO t1 SELECT * FROM t2 ON DUPLICATE KEY UPDATE id=LAST_INSERT_ID(id);; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t2 ALL NULL NULL NULL NULL 4 100.00 +Warnings: +Note 1003 insert into `test`.`t1` select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b` from `test`.`t2` on duplicate key update `test`.`t1`.`id` = last_insert_id(`test`.`t1`.`id`) +# Status of EXPLAIN EXTENDED query +Variable_name Value +Handler_read_key 7 +# Status of testing query execution: +Variable_name Value +Handler_read_key 7 +Handler_read_rnd 1 +Handler_read_rnd_next 5 +Handler_write 4 + +DROP TABLE t1,t2; # # Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH # EXPLAIN UPDATE/DEL/INS diff --git a/mysql-test/main/mysql_tzinfo_to_sql_symlink.result b/mysql-test/main/mysql_tzinfo_to_sql_symlink.result index b6b35e44988..97548768a2d 100644 --- a/mysql-test/main/mysql_tzinfo_to_sql_symlink.result +++ b/mysql-test/main/mysql_tzinfo_to_sql_symlink.result @@ -10,13 +10,13 @@ CREATE TABLE time_zone_leap_second LIKE mysql.time_zone_leap_second; set @wsrep_is_on=(select coalesce(sum(SESSION_VALUE='ON'), 0) from information_schema.SYSTEM_VARIABLES WHERE VARIABLE_NAME='wsrep_on'); SET STATEMENT SQL_MODE='' FOR SELECT concat('%', GROUP_CONCAT(OPTION), '%') INTO @replicate_opt FROM (SELECT DISTINCT concat('REPLICATE_', UPPER(ENGINE)) AS OPTION FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME IN ('time_zone', 'time_zone_name', 'time_zone_transition', 'time_zone_transition_type', 'time_zone_leap_second') AND ENGINE in ('MyISAM', 'Aria')) AS o ORDER BY OPTION DESC; set @wsrep_cannot_replicate_tz=@wsrep_is_on AND (select coalesce(sum(GLOBAL_VALUE NOT LIKE @replicate_opt), 0) from information_schema.SYSTEM_VARIABLES WHERE VARIABLE_NAME='wsrep_mode'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_name_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_name'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_name_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_name''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_name ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_transition_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_transition'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_transition_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_transition''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_transition_type'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_transition_type''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition_type ENGINE=InnoDB', 'do 0'); TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; @@ -59,13 +59,13 @@ execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_t set @wsrep_is_on=(select coalesce(sum(SESSION_VALUE='ON'), 0) from information_schema.SYSTEM_VARIABLES WHERE VARIABLE_NAME='wsrep_on'); SET STATEMENT SQL_MODE='' FOR SELECT concat('%', GROUP_CONCAT(OPTION), '%') INTO @replicate_opt FROM (SELECT DISTINCT concat('REPLICATE_', UPPER(ENGINE)) AS OPTION FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME IN ('time_zone', 'time_zone_name', 'time_zone_transition', 'time_zone_transition_type', 'time_zone_leap_second') AND ENGINE in ('MyISAM', 'Aria')) AS o ORDER BY OPTION DESC; set @wsrep_cannot_replicate_tz=@wsrep_is_on AND (select coalesce(sum(GLOBAL_VALUE NOT LIKE @replicate_opt), 0) from information_schema.SYSTEM_VARIABLES WHERE VARIABLE_NAME='wsrep_mode'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_name_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_name'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_name_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_name''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_name ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_transition_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_transition'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_transition_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_transition''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_transition_type'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_transition_type''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition_type ENGINE=InnoDB', 'do 0'); TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; @@ -191,13 +191,13 @@ TRUNCATE TABLE time_zone_leap_second; set @wsrep_is_on=(select coalesce(sum(SESSION_VALUE='ON'), 0) from information_schema.SYSTEM_VARIABLES WHERE VARIABLE_NAME='wsrep_on'); SET STATEMENT SQL_MODE='' FOR SELECT concat('%', GROUP_CONCAT(OPTION), '%') INTO @replicate_opt FROM (SELECT DISTINCT concat('REPLICATE_', UPPER(ENGINE)) AS OPTION FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME IN ('time_zone', 'time_zone_name', 'time_zone_transition', 'time_zone_transition_type', 'time_zone_leap_second') AND ENGINE in ('MyISAM', 'Aria')) AS o ORDER BY OPTION DESC; set @wsrep_cannot_replicate_tz=@wsrep_is_on AND (select coalesce(sum(GLOBAL_VALUE NOT LIKE @replicate_opt), 0) from information_schema.SYSTEM_VARIABLES WHERE VARIABLE_NAME='wsrep_mode'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_name_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_name'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_name_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_name''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_name ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_transition_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_transition'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_transition_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_transition''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_transition_type'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_transition_type''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition_type ENGINE=InnoDB', 'do 0'); /*M!100602 execute immediate if(@wsrep_cannot_replicate_tz, 'start transaction', 'LOCK TABLES time_zone WRITE, time_zone_leap_second WRITE, @@ -313,20 +313,20 @@ TRUNCATE TABLE time_zone_leap_second; set @wsrep_is_on=(select coalesce(sum(SESSION_VALUE='ON'), 0) from information_schema.SYSTEM_VARIABLES WHERE VARIABLE_NAME='wsrep_on'); SET STATEMENT SQL_MODE='' FOR SELECT concat('%', GROUP_CONCAT(OPTION), '%') INTO @replicate_opt FROM (SELECT DISTINCT concat('REPLICATE_', UPPER(ENGINE)) AS OPTION FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME IN ('time_zone', 'time_zone_name', 'time_zone_transition', 'time_zone_transition_type', 'time_zone_leap_second') AND ENGINE in ('MyISAM', 'Aria')) AS o ORDER BY OPTION DESC; set @wsrep_cannot_replicate_tz=@wsrep_is_on AND (select coalesce(sum(GLOBAL_VALUE NOT LIKE @replicate_opt), 0) from information_schema.SYSTEM_VARIABLES WHERE VARIABLE_NAME='wsrep_mode'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_name_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_name'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_name_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_name''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_name ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_transition_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_transition'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_transition_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_transition''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_transition_type'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_transition_type''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition_type ENGINE=InnoDB', 'do 0'); /*M!100602 execute immediate if(@wsrep_cannot_replicate_tz, 'start transaction', 'LOCK TABLES time_zone WRITE, time_zone_leap_second WRITE, time_zone_name WRITE, time_zone_transition WRITE, time_zone_transition_type WRITE')*/; -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_leap_second_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_leap_second'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_leap_second_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_leap_second''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_leap_second ENGINE=InnoDB', 'do 0'); TRUNCATE TABLE time_zone_leap_second; execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_leap_second ENGINE=', @time_zone_leap_second_engine), 'do 0'); @@ -497,13 +497,13 @@ set sql_mode=default; set @wsrep_is_on=(select coalesce(sum(SESSION_VALUE='ON'), 0) from information_schema.SYSTEM_VARIABLES WHERE VARIABLE_NAME='wsrep_on'); SET STATEMENT SQL_MODE='' FOR SELECT concat('%', GROUP_CONCAT(OPTION), '%') INTO @replicate_opt FROM (SELECT DISTINCT concat('REPLICATE_', UPPER(ENGINE)) AS OPTION FROM information_schema.TABLES WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME IN ('time_zone', 'time_zone_name', 'time_zone_transition', 'time_zone_transition_type', 'time_zone_leap_second') AND ENGINE in ('MyISAM', 'Aria')) AS o ORDER BY OPTION DESC; set @wsrep_cannot_replicate_tz=@wsrep_is_on AND (select coalesce(sum(GLOBAL_VALUE NOT LIKE @replicate_opt), 0) from information_schema.SYSTEM_VARIABLES WHERE VARIABLE_NAME='wsrep_mode'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_name_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_name'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_name_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_name''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_name ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_transition_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_transition'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_transition_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_transition''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition ENGINE=InnoDB', 'do 0'); -execute immediate if(@wsrep_cannot_replicate_tz, "select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME='time_zone_transition_type'", 'do 0'); +execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_transition_type''', 'do 0'); execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition_type ENGINE=InnoDB', 'do 0'); TRUNCATE TABLE time_zone; TRUNCATE TABLE time_zone_name; diff --git a/mysql-test/main/mysqlbinlog.test b/mysql-test/main/mysqlbinlog.test index 430cdb708cd..9394ca3fbd3 100644 --- a/mysql-test/main/mysqlbinlog.test +++ b/mysql-test/main/mysqlbinlog.test @@ -534,7 +534,7 @@ remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.warn; --echo # MYSQL_BINLOG std_data/master-bin.000001 --base64-output 2>&1 # The error produces the absolute path of the mysqlbinlog executable, remove it. --replace_regex /.*mariadb-binlog.*:/mariadb-binlog:/i ---error 1 +--error 5 --exec $MYSQL_BINLOG std_data/master-bin.000001 --base64-output 2>&1 --echo # diff --git a/mysql-test/main/mysqld--help,win.rdiff b/mysql-test/main/mysqld--help,win.rdiff index a43d7f0d86c..3e9541d7d2f 100644 --- a/mysql-test/main/mysqld--help,win.rdiff +++ b/mysql-test/main/mysqld--help,win.rdiff @@ -1,6 +1,12 @@ ---- a/mysql-test/r/mysqld--help.result -+++ b/mysql-test/r/mysqld--help.result -@@ -685,6 +685,7 @@ +@@ -180,6 +180,7 @@ + --console Write error output on screen; don't remove the console + window on windows. + --core-file Write core on crashes ++ (Defaults to on; use --skip-core-file to disable.) + -h, --datadir=name Path to the database root directory + --date-format=name The DATE format (ignored) + --datetime-format=name +@@ -650,6 +651,7 @@ Use MySQL-5.6 (instead of MariaDB-5.3) format for TIME, DATETIME, TIMESTAMP columns. (Defaults to on; use --skip-mysql56-temporal-format to disable.) diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index fb059b8b988..dbb4fbc262d 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -190,7 +190,7 @@ The following specify which files/extra groups are read (specified before remain ALWAYS --console Write error output on screen; don't remove the console window on windows. - --core-file Write core on errors. + --core-file Write core on crashes -h, --datadir=name Path to the database root directory --date-format=name The DATE format (ignored) --datetime-format=name @@ -799,7 +799,8 @@ The following specify which files/extra groups are read (specified before remain extended_keys, exists_to_in, orderby_uses_equalities, condition_pushdown_for_derived, split_materialized, condition_pushdown_for_subquery, rowid_filter, - condition_pushdown_from_having, not_null_range_scan + condition_pushdown_from_having, not_null_range_scan, + hash_join_cardinality --optimizer-trace=name Controls tracing of the Optimizer: optimizer_trace=option=val[,option=val...], where option @@ -1583,6 +1584,7 @@ column-compression-zlib-wrap FALSE completion-type NO_CHAIN concurrent-insert AUTO console TRUE +core-file TRUE date-format %Y-%m-%d datetime-format %Y-%m-%d %H:%i:%s deadlock-search-depth-long 15 @@ -1757,7 +1759,7 @@ optimizer-rowid-copy-cost 0.002653 optimizer-scan-setup-cost 10 optimizer-search-depth 62 optimizer-selectivity-sampling-limit 100 -optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on +optimizer-switch index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=on,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off,hash_join_cardinality=on optimizer-trace optimizer-trace-max-mem-size 1048576 optimizer-use-condition-selectivity 4 diff --git a/mysql-test/main/mysqltest_tracking_info.result b/mysql-test/main/mysqltest_tracking_info.result index 61bb3f2d1e2..c4fedd6b59c 100644 --- a/mysql-test/main/mysqltest_tracking_info.result +++ b/mysql-test/main/mysqltest_tracking_info.result @@ -38,7 +38,7 @@ SET @@session.session_track_system_variables='optimizer_switch'; set optimizer_switch='index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off'; -- Tracker : SESSION_TRACK_SYSTEM_VARIABLES -- optimizer_switch --- index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off +-- index_merge=off,index_merge_union=off,index_merge_sort_union=off,index_merge_intersection=off,index_merge_sort_intersection=on,engine_condition_pushdown=on,index_condition_pushdown=off,derived_merge=off,derived_with_keys=off,firstmatch=off,loosescan=off,materialization=on,in_to_exists=off,semijoin=off,partial_match_rowid_merge=off,partial_match_table_scan=off,subquery_cache=off,mrr=on,mrr_cost_based=on,mrr_sort_keys=on,outer_join_with_cache=off,semijoin_with_cache=off,join_cache_incremental=off,join_cache_hashed=off,join_cache_bka=off,optimize_join_buffer_size=on,table_elimination=off,extended_keys=off,exists_to_in=off,orderby_uses_equalities=off,condition_pushdown_for_derived=off,split_materialized=on,condition_pushdown_for_subquery=on,rowid_filter=on,condition_pushdown_from_having=on,not_null_range_scan=off,hash_join_cardinality=on Warnings: Warning 1681 'engine_condition_pushdown=on' is deprecated and will be removed in a future release diff --git a/mysql-test/main/name_resolution_cache_debug.result b/mysql-test/main/name_resolution_cache_debug.result new file mode 100644 index 00000000000..7030176c5fe --- /dev/null +++ b/mysql-test/main/name_resolution_cache_debug.result @@ -0,0 +1,25 @@ +connect con1,localhost,root; +create table t1 (a int, b int); +create table t2 (c int, d int); +create view v1 as select c+1 as e, d+1 as f from t2; +SET DEBUG_SYNC= 'table_field_cached SIGNAL in_sync WAIT_FOR go'; +prepare stmt1 from "select a from t1"; +execute stmt1; +connection default; +SET DEBUG_SYNC= 'now WAIT_FOR in_sync'; +SET DEBUG_SYNC= 'now SIGNAL go'; +connection con1; +a +SET DEBUG_SYNC= 'table_field_cached SIGNAL in_sync WAIT_FOR go'; +prepare stmt1 from "select e from v1"; +execute stmt1; +connection default; +SET DEBUG_SYNC= 'now WAIT_FOR in_sync'; +SET DEBUG_SYNC= 'now SIGNAL go'; +connection con1; +e +connection default; +disconnect con1; +SET DEBUG_SYNC = 'RESET'; +drop view v1; +drop table t1,t2; diff --git a/mysql-test/main/name_resolution_cache_debug.test b/mysql-test/main/name_resolution_cache_debug.test new file mode 100644 index 00000000000..362d883cbd1 --- /dev/null +++ b/mysql-test/main/name_resolution_cache_debug.test @@ -0,0 +1,36 @@ + +source include/have_debug_sync.inc; + +connect con1,localhost,root; +create table t1 (a int, b int); +create table t2 (c int, d int); +create view v1 as select c+1 as e, d+1 as f from t2; + +SET DEBUG_SYNC= 'table_field_cached SIGNAL in_sync WAIT_FOR go'; +prepare stmt1 from "select a from t1"; +--send execute stmt1 + +connection default; +SET DEBUG_SYNC= 'now WAIT_FOR in_sync'; +SET DEBUG_SYNC= 'now SIGNAL go'; + +connection con1; +--reap + +SET DEBUG_SYNC= 'table_field_cached SIGNAL in_sync WAIT_FOR go'; +prepare stmt1 from "select e from v1"; +--send execute stmt1 + +connection default; +SET DEBUG_SYNC= 'now WAIT_FOR in_sync'; +SET DEBUG_SYNC= 'now SIGNAL go'; + +connection con1; +--reap + +connection default; +disconnect con1; + +SET DEBUG_SYNC = 'RESET'; +drop view v1; +drop table t1,t2; diff --git a/mysql-test/main/old-mode.result b/mysql-test/main/old-mode.result index 44e8f5bfece..daa2a4dc915 100644 --- a/mysql-test/main/old-mode.result +++ b/mysql-test/main/old-mode.result @@ -221,3 +221,39 @@ a UNIX_TIMESTAMP(t1.a) a UNIX_TIMESTAMP(t2.a) DROP TABLE t1; SET time_zone=DEFAULT; SET global mysql56_temporal_format=true; +# +# MDEV-26765 UNIX_TIMESTAMP(CURRENT_TIME()) return null ?!? +# +SET old_mode=zero_date_time_cast; +SET @@time_zone='+00:00'; +SET timestamp=1234567; +SELECT CURRENT_TIMESTAMP; +CURRENT_TIMESTAMP +1970-01-15 06:56:07 +SELECT UNIX_TIMESTAMP(CURRENT_TIME()); +UNIX_TIMESTAMP(CURRENT_TIME()) +NULL +Warnings: +Warning 1292 Truncated incorrect datetime value: '06:56:07' +SELECT UNIX_TIMESTAMP(TIME'06:56:07'); +UNIX_TIMESTAMP(TIME'06:56:07') +NULL +Warnings: +Warning 1292 Truncated incorrect datetime value: '06:56:07' +SELECT UNIX_TIMESTAMP(TIME'10:20:30'); +UNIX_TIMESTAMP(TIME'10:20:30') +NULL +Warnings: +Warning 1292 Truncated incorrect datetime value: '10:20:30' +CREATE OR REPLACE TABLE t1 (a TIME); +INSERT INTO t1 VALUES (TIME'06:56:07'),('10:20:30'); +SELECT UNIX_TIMESTAMP(a) FROM t1 ORDER BY a; +UNIX_TIMESTAMP(a) +NULL +NULL +Warnings: +Warning 1264 Out of range value for column 'a' at row 1 +Warning 1264 Out of range value for column 'a' at row 2 +DROP TABLE t1; +SET @@time_zone=DEFAULT; +SET TIMESTAMP=DEFAULT; diff --git a/mysql-test/main/old-mode.test b/mysql-test/main/old-mode.test index 0419be4bf6a..e4928329b47 100644 --- a/mysql-test/main/old-mode.test +++ b/mysql-test/main/old-mode.test @@ -149,3 +149,23 @@ SELECT t1.a, UNIX_TIMESTAMP(t1.a), t2.a, UNIX_TIMESTAMP(t2.a) FROM t1 t1, t1 t2 DROP TABLE t1; SET time_zone=DEFAULT; SET global mysql56_temporal_format=true; + + +--echo # +--echo # MDEV-26765 UNIX_TIMESTAMP(CURRENT_TIME()) return null ?!? +--echo # + +SET old_mode=zero_date_time_cast; +SET @@time_zone='+00:00'; +SET timestamp=1234567; +SELECT CURRENT_TIMESTAMP; +SELECT UNIX_TIMESTAMP(CURRENT_TIME()); +SELECT UNIX_TIMESTAMP(TIME'06:56:07'); +SELECT UNIX_TIMESTAMP(TIME'10:20:30'); +CREATE OR REPLACE TABLE t1 (a TIME); +INSERT INTO t1 VALUES (TIME'06:56:07'),('10:20:30'); +SELECT UNIX_TIMESTAMP(a) FROM t1 ORDER BY a; +DROP TABLE t1; + +SET @@time_zone=DEFAULT; +SET TIMESTAMP=DEFAULT; diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result index 634ef3343a4..1342bc65f17 100644 --- a/mysql-test/main/opt_trace.result +++ b/mysql-test/main/opt_trace.result @@ -515,6 +515,11 @@ select * from v2 { ] }, { + "check_split_materialized": { + "not_applicable": "no candidate field can be accessed through ref" + } + }, + { "best_join_order": ["t1"], "rows": 1, "cost": 0.010978597 @@ -901,6 +906,11 @@ explain select * from v1 { ] }, { + "check_split_materialized": { + "not_applicable": "group list has no candidates" + } + }, + { "best_join_order": ["t1"], "rows": 10, "cost": 0.017968034 @@ -4266,7 +4276,7 @@ explain delete from t0 where t0.a<3 { "select_id": 1, "steps": [ { - "expanded_query": "select from dual where t0.a < 3" + "expanded_query": "delete from t0 using dual where t0.a < 3" } ] } @@ -4346,7 +4356,7 @@ explain delete t0,t1 from t0, t1 where t0.a=t1.a and t1.a<3 { "select_id": 1, "steps": [ { - "expanded_query": "select from t0 join t1 where t0.a = t1.a and t1.a < 3" + "expanded_query": "delete from t0,t1 using t0 join t1 where t0.a = t1.a and t1.a < 3" } ] } @@ -4792,7 +4802,7 @@ explain select * from (select rand() from t1)q { "derived": { "table": "q", "select_id": 2, - "algorithm": "merged" + "algorithm": "materialized" } }, { @@ -4806,7 +4816,7 @@ explain select * from (select rand() from t1)q { } }, { - "expanded_query": "/* select#1 */ select rand() AS `rand()` from (/* select#2 */ select rand() AS `rand()` from t1) q" + "expanded_query": "/* select#1 */ select q.`rand()` AS `rand()` from (/* select#2 */ select rand() AS `rand()` from t1) q" } ] } @@ -4816,14 +4826,6 @@ explain select * from (select rand() from t1)q { "select_id": 1, "steps": [ { - "derived": { - "table": "q", - "select_id": 2, - "algorithm": "materialized", - "cause": "Random function in the select" - } - }, - { "join_optimization": { "select_id": 2, "steps": [ @@ -11586,6 +11588,518 @@ SELECT a FROM t1 WHERE (a,b) in (SELECT @c,@d); a DROP TABLE t1; # +# MDEV-31085: multi-update using view with optimizer trace enabled +# +SET SESSION optimizer_trace = 'enabled=on'; +CREATE TABLE t (a int, b int); +CREATE VIEW v AS SELECT 1 AS c UNION SELECT 2 AS c; +INSERT INTO t VALUES (0,4),(5,6); +UPDATE t, v SET t.b = t.a, t.a = v.c WHERE v.c < t.a; +SELECT * FROM information_schema.optimizer_trace; +QUERY TRACE MISSING_BYTES_BEYOND_MAX_MEM_SIZE INSUFFICIENT_PRIVILEGES +UPDATE t, v SET t.b = t.a, t.a = v.c WHERE v.c < t.a { + "steps": [ + { + "view": { + "table": "v", + "select_id": 2, + "algorithm": "materialized" + } + }, + { + "join_preparation": { + "select_id": 2, + "steps": [ + { + "expanded_query": "/* select#2 */ select 1 AS c" + } + ] + } + }, + { + "join_preparation": { + "select_id": 3, + "steps": [ + { + "expanded_query": "/* select#3 */ select 2 AS c" + } + ] + } + }, + { + "join_preparation": { + "select_id": 1, + "steps": [ + { + "expanded_query": "/* select#1 */ update t join v set t.b = t.a,t.a = v.c where v.c < t.a" + } + ] + } + }, + { + "join_optimization": { + "select_id": 1, + "steps": [ + { + "condition_processing": { + "condition": "WHERE", + "original_condition": "v.c < t.a", + "steps": [ + { + "transformation": "equality_propagation", + "resulting_condition": "v.c < t.a" + }, + { + "transformation": "constant_propagation", + "resulting_condition": "v.c < t.a" + }, + { + "transformation": "trivial_condition_removal", + "resulting_condition": "v.c < t.a" + } + ] + } + }, + { + "join_optimization": { + "select_id": 2, + "steps": [] + } + }, + { + "join_optimization": { + "select_id": 3, + "steps": [] + } + }, + { + "table_dependencies": [ + { + "table": "t", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [] + }, + { + "table": "<derived2>", + "row_may_be_null": false, + "map_bit": 1, + "depends_on_map_bits": [] + } + ] + }, + { + "ref_optimizer_key_uses": [] + }, + { + "rows_estimation": [ + { + "table": "t", + "table_scan": { + "rows": 2, + "read_cost": 0.01028441, + "read_and_compare_cost": 0.01034841 + } + }, + { + "table": "<derived2>", + "table_scan": { + "rows": 2, + "read_cost": 0.012350033, + "read_and_compare_cost": 0.012418701 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": "", + "get_costs_for_tables": [ + { + "best_access_path": { + "table": "t", + "plan_details": { + "record_count": 1 + }, + "considered_access_paths": [ + { + "access_type": "scan", + "rows": 2, + "rows_after_filter": 2, + "rows_out": 2, + "cost": 0.01034841, + "index_only": false, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "rows_read": 2, + "rows_out": 2, + "cost": 0.01034841, + "uses_join_buffering": false + } + } + }, + { + "best_access_path": { + "table": "<derived2>", + "plan_details": { + "record_count": 1 + }, + "considered_access_paths": [ + { + "access_type": "scan", + "rows": 2, + "rows_after_filter": 2, + "rows_out": 2, + "cost": 0.012418701, + "index_only": false, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "rows_read": 2, + "rows_out": 2, + "cost": 0.012418701, + "uses_join_buffering": false + } + } + } + ] + }, + { + "plan_prefix": "", + "table": "t", + "rows_for_plan": 2, + "cost_for_plan": 0.01034841, + "rest_of_plan": [ + { + "plan_prefix": "t", + "get_costs_for_tables": [ + { + "best_access_path": { + "table": "<derived2>", + "plan_details": { + "record_count": 2 + }, + "considered_access_paths": [ + { + "access_type": "scan_with_join_cache", + "rows": 2, + "rows_after_filter": 2, + "rows_out": 2, + "cost": 0.012911897, + "index_only": false, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "rows_read": 2, + "rows_out": 2, + "cost": 0.012911897, + "uses_join_buffering": true + } + } + } + ] + }, + { + "plan_prefix": "t", + "table": "<derived2>", + "rows_for_plan": 4, + "cost_for_plan": 0.023260307 + } + ] + }, + { + "plan_prefix": "", + "table": "<derived2>", + "rows_for_plan": 2, + "cost_for_plan": 0.012418701, + "pruned_by_heuristic": true + } + ] + }, + { + "best_join_order": ["t", "<derived2>"], + "rows": 4, + "cost": 0.023260307 + }, + { + "substitute_best_equal": { + "condition": "WHERE", + "resulting_condition": "v.c < t.a" + } + }, + { + "attaching_conditions_to_tables": { + "attached_conditions_computation": [], + "attached_conditions_summary": [ + { + "table": "t", + "attached_condition": null + }, + { + "table": "<derived2>", + "attached_condition": "v.c < t.a" + } + ] + } + }, + { + "make_join_readinfo": [] + } + ] + } + }, + { + "join_execution": { + "select_id": 1, + "steps": [ + { + "join_execution": { + "select_id": 2, + "steps": [] + } + }, + { + "join_execution": { + "select_id": 3, + "steps": [] + } + }, + { + "join_preparation": { + "select_id": "fake", + "steps": [ + { + "expanded_query": "select c AS c from dual" + } + ] + } + }, + { + "join_optimization": { + "select_id": "fake", + "steps": [ + { + "table_dependencies": [ + { + "table": "union", + "row_may_be_null": false, + "map_bit": 0, + "depends_on_map_bits": [] + } + ] + }, + { + "rows_estimation": [ + { + "table": "union", + "table_scan": { + "rows": 2, + "read_cost": 0.010020701, + "read_and_compare_cost": 0.010084701 + } + } + ] + }, + { + "considered_execution_plans": [ + { + "plan_prefix": "", + "get_costs_for_tables": [ + { + "best_access_path": { + "table": "union", + "plan_details": { + "record_count": 1 + }, + "considered_access_paths": [ + { + "access_type": "scan", + "rows": 2, + "rows_after_filter": 2, + "rows_out": 2, + "cost": 0.010084701, + "index_only": false, + "chosen": true + } + ], + "chosen_access_method": { + "type": "scan", + "rows_read": 2, + "rows_out": 2, + "cost": 0.010084701, + "uses_join_buffering": false + } + } + } + ] + }, + { + "plan_prefix": "", + "table": "union", + "rows_for_plan": 2, + "cost_for_plan": 0.010084701 + } + ] + }, + { + "best_join_order": ["union"], + "rows": 2, + "cost": 0.010084701 + }, + { + "attaching_conditions_to_tables": { + "attached_conditions_computation": [], + "attached_conditions_summary": [ + { + "table": "union", + "attached_condition": null + } + ] + } + }, + { + "make_join_readinfo": [] + } + ] + } + }, + { + "join_execution": { + "select_id": "fake", + "steps": [] + } + } + ] + } + } + ] +} 0 0 +SELECT * FROM t; +a b +0 4 +1 5 +SET optimizer_trace=DEFAULT; +DROP VIEW v; +DROP TABLE t; +# +# MDEV-26301: Split optimization improvements: Optimizer Trace coverage +# +create table t1(a int, b int); +insert into t1 select seq,seq from seq_1_to_5; +create table t2(a int, b int, key(a)); +insert into t2 +select A.seq,B.seq from seq_1_to_25 A, seq_1_to_2 B; +create table t3(a int, b int, key(a)); +insert into t3 +select A.seq,B.seq from seq_1_to_5 A, seq_1_to_3 B; +analyze table t1,t2,t3 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status Table is already up to date +test.t3 analyze status Engine-independent statistics collected +test.t3 analyze status Table is already up to date +create table t10 ( +grp_id int, +col1 int, +key(grp_id) +); +insert into t10 +select +A.seq, +B.seq +from +seq_1_to_100 A, +seq_1_to_100 B; +create table t11 ( +col1 int, +col2 int +); +insert into t11 +select A.seq, A.seq from seq_1_to_10 A; +analyze table t10,t11 persistent for all; +Table Op Msg_type Msg_text +test.t10 analyze status Engine-independent statistics collected +test.t10 analyze status Table is already up to date +test.t11 analyze status Engine-independent statistics collected +test.t11 analyze status OK +set optimizer_trace=1; +explain +select * from +( +(t1 left join t2 on t2.a=t1.b) +left join t3 on t3.a=t1.b +) left join (select grp_id, count(*) +from t10 left join t11 on t11.col1=t10.col1 +group by grp_id) T on T.grp_id=t1.b; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 5 +1 PRIMARY t2 ref a a 5 test.t1.b 2 Using where +1 PRIMARY t3 ref a a 5 test.t1.b 3 Using where +1 PRIMARY <derived2> ref key0 key0 5 test.t1.b 10 Using where +2 LATERAL DERIVED t10 ref grp_id grp_id 5 test.t1.b 100 +2 LATERAL DERIVED t11 ALL NULL NULL NULL NULL 10 Using where; Using join buffer (flat, BNL join) +select json_detailed(json_extract(trace, '$**.check_split_materialized')) as JS +from information_schema.optimizer_trace; +JS +[ + { + "split_candidates": + ["t10.grp_id"] + } +] +select +json_detailed( +json_remove( +json_extract(trace, '$**.choose_best_splitting') +, '$[0].split_plan_search[0]' + ) +) as JS +from information_schema.optimizer_trace; +JS +[ + { + "considered_keys": + [ + { + "table_name": "t10", + "index": "grp_id", + "rec_per_key": 100, + "param_tables": 1 + } + ], + "refills": 5, + "spl_pd_boundary": 2, + "split_plan_search": + [], + "split_materialized": + { + "table": "t10", + "key": "grp_id", + "org_cost": 1.159965, + "postjoin_cost": 4.020888502, + "one_splitting_cost": 5.180853502, + "unsplit_postjoin_cost": 32.78652054, + "unsplit_cost": 148.7830205, + "rows": 100, + "refills": 5, + "total_splitting_cost": 25.90426751, + "chosen": true + } + } +] +drop table t1,t2,t3,t10,t11; +set optimizer_trace=DEFAULT; +# # End of 10.4 tests # set optimizer_trace='enabled=on'; @@ -12017,84 +12531,94 @@ from information_schema.optimizer_trace; json_detailed(json_extract(trace, '$**.choose_best_splitting')) [ - [ - { - "considered_execution_plans": - [ - { - "plan_prefix": "", - "get_costs_for_tables": - [ - { - "best_access_path": + { + "considered_keys": + [] + }, + { + "considered_keys": + [ + { + "table_name": "t2", + "index": "idx_a", + "rec_per_key": 1.8367, + "param_tables": 1 + } + ], + "refills": 4, + "spl_pd_boundary": 2, + "split_plan_search": + [ + { + "considered_execution_plans": + [ + { + "plan_prefix": "", + "get_costs_for_tables": + [ { - "table": "t2", - "plan_details": + "best_access_path": { - "record_count": 1 - }, - "considered_access_paths": - [ + "table": "t2", + "plan_details": { - "access_type": "ref", - "index": "idx_a", - "used_range_estimates": false, - "reason": "not available", - "rows": 1.8367, - "cost": 0.002051185, - "chosen": true + "record_count": 1 }, + "considered_access_paths": + [ + { + "access_type": "ref", + "index": "idx_a", + "used_range_estimates": false, + "reason": "not available", + "rows": 1.8367, + "cost": 0.002051185, + "chosen": true + }, + { + "type": "scan", + "chosen": false, + "cause": "cost" + } + ], + "chosen_access_method": { - "type": "scan", - "chosen": false, - "cause": "cost" + "type": "ref", + "rows_read": 1.8367, + "rows_out": 1.8367, + "cost": 0.002051185, + "uses_join_buffering": false } - ], - "chosen_access_method": - { - "type": "ref", - "rows_read": 1.8367, - "rows_out": 1.8367, - "cost": 0.002051185, - "uses_join_buffering": false } } - } - ] - }, - { - "plan_prefix": "", - "table": "t2", - "rows_for_plan": 1.8367, - "cost_for_plan": 0.002051185, - "cost_for_sorting": 0.001155201 - } - ] - }, - { - "split_materialized": - { - "table": "t2", - "key": "idx_a", - "org_cost": 0.002051185, - "postjoin_cost": 0.001135418, - "one_splitting_cost": 0.003186603, - "unsplit_postjoin_cost": 0.036032575, - "unsplit_cost": 0.060625425, - "rows": 1.8367, - "outer_rows": 4, - "total_splitting_cost": 0.012746412, - "chosen": true + ] + }, + { + "plan_prefix": "", + "table": "t2", + "rows_for_plan": 1.8367, + "cost_for_plan": 0.002051185, + "cost_for_sorting": 0.001155201 + } + ] } + ], + "split_materialized": + { + "table": "t2", + "key": "idx_a", + "org_cost": 0.002051185, + "postjoin_cost": 0.001135418, + "one_splitting_cost": 0.003186603, + "unsplit_postjoin_cost": 0.036032575, + "unsplit_cost": 0.060625425, + "rows": 1.8367, + "refills": 4, + "total_splitting_cost": 0.012746412, + "chosen": true } - ] + } ] -select -json_detailed(json_extract(trace, '$**.lateral_derived')) -from -information_schema.optimizer_trace; -json_detailed(json_extract(trace, '$**.lateral_derived')) -NULL drop table t1,t2; # # Test table functions. diff --git a/mysql-test/main/opt_trace.test b/mysql-test/main/opt_trace.test index 6f8040f1689..b60cb95fcd6 100644 --- a/mysql-test/main/opt_trace.test +++ b/mysql-test/main/opt_trace.test @@ -654,6 +654,101 @@ SELECT a FROM t1 WHERE (a,b) in (SELECT @c,@d); DROP TABLE t1; --echo # +--echo # MDEV-31085: multi-update using view with optimizer trace enabled +--echo # + +SET SESSION optimizer_trace = 'enabled=on'; + +CREATE TABLE t (a int, b int); +CREATE VIEW v AS SELECT 1 AS c UNION SELECT 2 AS c; +INSERT INTO t VALUES (0,4),(5,6); +UPDATE t, v SET t.b = t.a, t.a = v.c WHERE v.c < t.a; +SELECT * FROM information_schema.optimizer_trace; + +SELECT * FROM t; + +SET optimizer_trace=DEFAULT; + +DROP VIEW v; +DROP TABLE t; + +--echo # +--echo # MDEV-26301: Split optimization improvements: Optimizer Trace coverage +--echo # + +# 5 values +create table t1(a int, b int); +insert into t1 select seq,seq from seq_1_to_5; + +# 5 value groups of size 2 each +create table t2(a int, b int, key(a)); +insert into t2 +select A.seq,B.seq from seq_1_to_25 A, seq_1_to_2 B; + +# 5 value groups of size 3 each +create table t3(a int, b int, key(a)); +insert into t3 +select A.seq,B.seq from seq_1_to_5 A, seq_1_to_3 B; + +analyze table t1,t2,t3 persistent for all; + +create table t10 ( + grp_id int, + col1 int, + key(grp_id) +); + +# 100 groups of 100 values each +insert into t10 +select + A.seq, + B.seq +from + seq_1_to_100 A, + seq_1_to_100 B; + +# and X10 multiplier +create table t11 ( + col1 int, + col2 int +); +insert into t11 +select A.seq, A.seq from seq_1_to_10 A; + +analyze table t10,t11 persistent for all; + +set optimizer_trace=1; +explain +select * from + ( + (t1 left join t2 on t2.a=t1.b) + left join t3 on t3.a=t1.b + ) left join (select grp_id, count(*) + from t10 left join t11 on t11.col1=t10.col1 + group by grp_id) T on T.grp_id=t1.b; + +# Not sure how MDEV-27871 is related but this test uses this reason +# all over the place: +#enable after fix MDEV-27871 +--disable_view_protocol + +select json_detailed(json_extract(trace, '$**.check_split_materialized')) as JS +from information_schema.optimizer_trace; + +select + json_detailed( + json_remove( + json_extract(trace, '$**.choose_best_splitting') + , '$[0].split_plan_search[0]' + ) + ) as JS +from information_schema.optimizer_trace; + +--enable_view_protocol +drop table t1,t2,t3,t10,t11; +set optimizer_trace=DEFAULT; + +--echo # --echo # End of 10.4 tests --echo # @@ -861,13 +956,6 @@ from information_schema.optimizer_trace; --enable_view_protocol -# Same as above. just to show that splitting plan has some coverage in the -# trace. -select - json_detailed(json_extract(trace, '$**.lateral_derived')) -from - information_schema.optimizer_trace; - drop table t1,t2; --echo # diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index c0c459e57b4..2f343c7bca8 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -1905,12 +1905,32 @@ SET @@sql_mode=@save_sql_mode; # # MDEV-30151 parse error 1=2 not between/in # -select 1=2 not in (3,4); -1=2 not in (3,4) +SELECT 1=2 NOT IN (3,4); +1=2 NOT IN (3,4) 1 -select 1=2 not between 3 and 4; -1=2 not between 3 and 4 +SELECT 1=2 NOT BETWEEN 3 AND 4; +1=2 NOT BETWEEN 3 AND 4 1 +CREATE TABLE t1 ( f INT AS ( 1 IN ( 2 NOT BETWEEN 3 AND 4 ) ) ); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f` int(11) GENERATED ALWAYS AS (1 = 2 not between 3 and 4) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DROP TABLE t1; +CREATE TABLE t1 ( f INT, CHECK ( 1 IN ( 2 NOT BETWEEN 3 AND 4 ) ) ); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f` int(11) DEFAULT NULL, + CONSTRAINT `CONSTRAINT_1` CHECK (1 = 2 not between 3 and 4) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +DROP TABLE t1; +CREATE VIEW v1 AS SELECT 1 IN ( 2 NOT BETWEEN 3 AND 4 ); +SHOW CREATE VIEW v1; +View Create View character_set_client collation_connection +v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select 1 = 2 not between 3 and 4 AS `1 IN ( 2 NOT BETWEEN 3 AND 4 )` latin1 latin1_swedish_ci +DROP VIEW v1; # # End of 10.3 tests # diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index 48cda68b416..dcad30b36b8 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -1687,8 +1687,21 @@ SET @@sql_mode=@save_sql_mode; --echo # --echo # MDEV-30151 parse error 1=2 not between/in --echo # -select 1=2 not in (3,4); -select 1=2 not between 3 and 4; + +SELECT 1=2 NOT IN (3,4); +SELECT 1=2 NOT BETWEEN 3 AND 4; + +CREATE TABLE t1 ( f INT AS ( 1 IN ( 2 NOT BETWEEN 3 AND 4 ) ) ); +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE TABLE t1 ( f INT, CHECK ( 1 IN ( 2 NOT BETWEEN 3 AND 4 ) ) ); +SHOW CREATE TABLE t1; +DROP TABLE t1; + +CREATE VIEW v1 AS SELECT 1 IN ( 2 NOT BETWEEN 3 AND 4 ); +SHOW CREATE VIEW v1; +DROP VIEW v1; --echo # --echo # End of 10.3 tests diff --git a/mysql-test/main/partition.result b/mysql-test/main/partition.result index ad4c3cf1ad3..78d4aa3f87c 100644 --- a/mysql-test/main/partition.result +++ b/mysql-test/main/partition.result @@ -2820,3 +2820,41 @@ DROP TABLE t1,t2; # # End of 10.1 tests # +# +# MDEV-30596: Assertion 'pushed_rowid_filter != __null ...' failed +# +create table t1 (a int); +insert into t1 values (NULL),(1),(2); +create table t2 (a int); +insert into t2 select seq from seq_1_to_1000; +create table t3 ( +a1 int, +a2 int, +b int, +c int, +filler1 char(200), +filler2 char(200), +key(a1,a2), +key(b) +) partition by hash(a1) partitions 2; +insert into t3 select seq/100, seq/100, seq, seq, seq, seq from seq_1_to_10000; +analyze table t3 persistent for all; +Table Op Msg_type Msg_text +test.t3 analyze status Engine-independent statistics collected +test.t3 analyze status OK +set @tmp_os= @@optimizer_switch; +set optimizer_switch='materialization=off'; +# Must not show "Using rowid filter": +explain +select * +from t1 +where +t1.a not in (select straight_join t3.a1 +from t2, t3 +where t3.b < 3000 and t3.a2=t2.a); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Using where +2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 1000 Using where +2 DEPENDENT SUBQUERY t3 ref_or_null a1,b a1 10 func,test.t2.a 198 Using where; Full scan on NULL key +set optimizer_switch=@tmp_os; +drop table t1,t2,t3; diff --git a/mysql-test/main/partition.test b/mysql-test/main/partition.test index 5f4c5f659ca..d96031a6b2b 100644 --- a/mysql-test/main/partition.test +++ b/mysql-test/main/partition.test @@ -3021,7 +3021,44 @@ INSERT INTO t2 VALUES (1),(2); UPDATE t1 SET a = 7 WHERE a = ( SELECT b FROM t2 ) ORDER BY a LIMIT 6; DROP TABLE t1,t2; - --echo # --echo # End of 10.1 tests --echo # + +--echo # +--echo # MDEV-30596: Assertion 'pushed_rowid_filter != __null ...' failed +--echo # +--source include/have_sequence.inc +create table t1 (a int); +insert into t1 values (NULL),(1),(2); +create table t2 (a int); +insert into t2 select seq from seq_1_to_1000; + +create table t3 ( + a1 int, + a2 int, + b int, + c int, + filler1 char(200), + filler2 char(200), + key(a1,a2), + key(b) +) partition by hash(a1) partitions 2; +insert into t3 select seq/100, seq/100, seq, seq, seq, seq from seq_1_to_10000; +analyze table t3 persistent for all; + +set @tmp_os= @@optimizer_switch; +set optimizer_switch='materialization=off'; + +--echo # Must not show "Using rowid filter": +explain +select * +from t1 +where + t1.a not in (select straight_join t3.a1 + from t2, t3 + where t3.b < 3000 and t3.a2=t2.a); +set optimizer_switch=@tmp_os; + +drop table t1,t2,t3; + diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result index cb2e9651c3d..cb7b215a110 100644 --- a/mysql-test/main/ps.result +++ b/mysql-test/main/ps.result @@ -5553,10 +5553,14 @@ CREATE TABLE t3 (c3 INT) ENGINE=MyISAM; EXPLAIN EXTENDED UPDATE t3 SET c3 = ( SELECT COUNT(d1.c1) FROM ( SELECT a11.c1 FROM t1 AS a11 STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 JOIN t1 AS a12 ON a12.c1 = a11.c1 ) d1 ); id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(NULL) from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where 0) PREPARE stmt FROM "EXPLAIN EXTENDED UPDATE t3 SET c3 = ( SELECT COUNT(d1.c1) FROM ( SELECT a11.c1 FROM t1 AS a11 STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1 JOIN t1 AS a12 ON a12.c1 = a11.c1 ) d1 )"; EXECUTE stmt; id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL Impossible WHERE +Warnings: +Note 1003 /* select#1 */ update `test`.`t3` set `test`.`t3`.`c3` = (/* select#2 */ select count(NULL) from `test`.`t1` `a11` straight_join `test`.`t2` `a21` join `test`.`t1` `a12` where 0) DEALLOCATE PREPARE stmt; DROP TABLE t1, t2, t3; # diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result index da6c848e334..5b8c56c87d3 100644 --- a/mysql-test/main/rowid_filter_innodb.result +++ b/mysql-test/main/rowid_filter_innodb.result @@ -3342,8 +3342,11 @@ ANALYZE "join_type": "BKA", "mrr_type": "Rowid-ordered scan", "attached_condition": "a.atp = 1", + "r_loops": 3, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 1 } }, { @@ -3384,8 +3387,11 @@ ANALYZE "join_type": "BKA", "mrr_type": "Rowid-ordered scan", "attached_condition": "fi.fh in (6311439873746261694,-397087483897438286,8518228073041491534,-5420422472375069774)", + "r_loops": 3, "r_filtered": 100, - "r_unpack_time_ms": "REPLACED" + "r_unpack_time_ms": "REPLACED", + "r_other_time_ms": "REPLACED", + "r_effective_rows": 10.66666667 } } ] diff --git a/mysql-test/main/rownum.result b/mysql-test/main/rownum.result index 3ad51c93260..b61269b1b47 100644 --- a/mysql-test/main/rownum.result +++ b/mysql-test/main/rownum.result @@ -139,6 +139,13 @@ select * from t1,t2 where t1.a=t2.a and rownum()<=2 order by t1.a,t2.a; a b a b 2 20 2 21 3 30 3 31 +create view v1 as +select * from (select * from t1 order by a desc) as t where rownum() <= 2; +select * from v1; +a b +3 30 +2 20 +drop view v1; # # Having # @@ -984,3 +991,29 @@ next row is 3 3 next row is 5 5 +# +# MDEV-31073: Server crash, assertion `table != 0 && +# view->field_translation != 0' failure with ROWNUM and view +# +CREATE TABLE t (f INT); +INSERT INTO t VALUES (1),(2); +CREATE VIEW v AS SELECT * FROM t; +UPDATE v SET f = 10 WHERE ROWNUM() > 42 LIMIT 1; +DROP VIEW v; +DROP TABLE t; +CREATE TABLE t (f INT); +INSERT INTO t VALUES (1),(2); +CREATE VIEW v AS SELECT f, 3 as e FROM t; +UPDATE v SET f = 10 WHERE e > 42 LIMIT 1; +DROP VIEW v; +DROP TABLE t; +CREATE TABLE t (f INT); +INSERT INTO t VALUES (1),(2); +CREATE VIEW v AS SELECT f, ROWNUM() as e FROM t; +UPDATE v SET f = 10 WHERE e > 42 LIMIT 1; +ERROR HY000: The target table v of the UPDATE is not updatable +DROP VIEW v; +DROP TABLE t; +# +# End of 10.6 tests +# diff --git a/mysql-test/main/rownum.test b/mysql-test/main/rownum.test index bdd0bfa4f41..291bd9bd993 100644 --- a/mysql-test/main/rownum.test +++ b/mysql-test/main/rownum.test @@ -58,6 +58,11 @@ select *,rownum() from t1,t2 order by t2.a desc, t1.a desc; select * from (select * from t1 order by a desc) as t where rownum() <= 2; select * from t1,t2 where t1.a=t2.a and rownum()<=2 order by t1.a,t2.a; +create view v1 as +select * from (select * from t1 order by a desc) as t where rownum() <= 2; +select * from v1; +drop view v1; + --echo # --echo # Having --echo # @@ -568,3 +573,40 @@ drop table t1; --echo # Table value constructors --echo # values ("first row"),("next row is 3"),(rownum()),("next row is 5"),(rownum()); + +--echo # +--echo # MDEV-31073: Server crash, assertion `table != 0 && +--echo # view->field_translation != 0' failure with ROWNUM and view +--echo # + +CREATE TABLE t (f INT); +INSERT INTO t VALUES (1),(2); +CREATE VIEW v AS SELECT * FROM t; +UPDATE v SET f = 10 WHERE ROWNUM() > 42 LIMIT 1; + +# Cleanup +DROP VIEW v; +DROP TABLE t; + +CREATE TABLE t (f INT); +INSERT INTO t VALUES (1),(2); +CREATE VIEW v AS SELECT f, 3 as e FROM t; +UPDATE v SET f = 10 WHERE e > 42 LIMIT 1; + +# Cleanup +DROP VIEW v; +DROP TABLE t; + +CREATE TABLE t (f INT); +INSERT INTO t VALUES (1),(2); +CREATE VIEW v AS SELECT f, ROWNUM() as e FROM t; +--error ER_NON_UPDATABLE_TABLE +UPDATE v SET f = 10 WHERE e > 42 LIMIT 1; + +# Cleanup +DROP VIEW v; +DROP TABLE t; + +--echo # +--echo # End of 10.6 tests +--echo # diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result index 54c39d090d2..ad8d733a163 100644 --- a/mysql-test/main/selectivity.result +++ b/mysql-test/main/selectivity.result @@ -834,7 +834,7 @@ flush table t1; set optimizer_use_condition_selectivity=4; explain extended select * from t1 where a=0; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1025 0.39 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1025 0.78 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 0 drop table t1; @@ -1977,11 +1977,11 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 25.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 2 +DROP TABLE t1; +# End of 10.2 tests set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; set histogram_size=@save_histogram_size; set use_stat_tables= @save_use_stat_tables; -DROP TABLE t1; -# End of 10.2 tests set @@global.histogram_size=@save_histogram_size; # # MDEV-20595 diff --git a/mysql-test/main/selectivity.test b/mysql-test/main/selectivity.test index 6957773fc8e..c96fb864408 100644 --- a/mysql-test/main/selectivity.test +++ b/mysql-test/main/selectivity.test @@ -1331,17 +1331,18 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=2; FLUSH TABLES; EXPLAIN EXTENDED SELECT * FROM t1 WHERE a=2; -set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; -set histogram_size=@save_histogram_size; -set use_stat_tables= @save_use_stat_tables; DROP TABLE t1; --echo # End of 10.2 tests + # # Clean up # +set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +set histogram_size=@save_histogram_size; +set use_stat_tables= @save_use_stat_tables; --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 03e5079eff0..99723013eaa 100644 --- a/mysql-test/main/selectivity_innodb.result +++ b/mysql-test/main/selectivity_innodb.result @@ -840,7 +840,7 @@ flush table t1; set optimizer_use_condition_selectivity=4; explain extended select * from t1 where a=0; id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 1025 0.39 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 1025 0.78 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 0 drop table t1; @@ -1984,11 +1984,11 @@ id select_type table type possible_keys key key_len ref rows filtered Extra 1 SIMPLE t1 ALL NULL NULL NULL NULL 5 25.00 Using where Warnings: Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 2 +DROP TABLE t1; +# End of 10.2 tests set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; set histogram_size=@save_histogram_size; set use_stat_tables= @save_use_stat_tables; -DROP TABLE t1; -# End of 10.2 tests set @@global.histogram_size=@save_histogram_size; # # MDEV-20595 diff --git a/mysql-test/main/selectivity_innodb_notembedded.result b/mysql-test/main/selectivity_innodb_notembedded.result new file mode 100644 index 00000000000..8b06fe7556b --- /dev/null +++ b/mysql-test/main/selectivity_innodb_notembedded.result @@ -0,0 +1,104 @@ +SET SESSION STORAGE_ENGINE='InnoDB'; +Warnings: +Warning 1287 '@@storage_engine' is deprecated and will be removed in a future release. Please use '@@default_storage_engine' instead +set @save_optimizer_switch_for_selectivity_test=@@optimizer_switch; +set optimizer_switch='extended_keys=on'; +drop table if exists t0,t1,t2,t3; +select @@global.use_stat_tables; +@@global.use_stat_tables +COMPLEMENTARY +select @@session.use_stat_tables; +@@session.use_stat_tables +COMPLEMENTARY +set @save_use_stat_tables=@@use_stat_tables; +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 histogram_type='single_prec_hb'; +set optimizer_use_condition_selectivity=3; +# +# MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram +# +create table t0(a int); +insert into t0 select 1 from seq_1_to_78; +create table t1(a int); +insert into t1 select 1 from seq_1_to_26; +create table t10 (a int); +insert into t10 select 0 from t0, seq_1_to_4; +insert into t10 select 8693 from t1; +insert into t10 select 8694 from t1; +insert into t10 select 8695 from t1; +insert into t10 select 34783 from t1; +insert into t10 select 34784 from t1; +insert into t10 select 34785 from t1; +insert into t10 select 34785 from t0, seq_1_to_8; +insert into t10 select 65214 from t1; +insert into t10 select 65215 from t1; +insert into t10 select 65216 from t1; +insert into t10 select 65216 from t0, seq_1_to_52; +insert into t10 select 65217 from t1; +insert into t10 select 65218 from t1; +insert into t10 select 65219 from t1; +insert into t10 select 65219 from t0; +insert into t10 select 73913 from t1; +insert into t10 select 73914 from t1; +insert into t10 select 73915 from t1; +insert into t10 select 73915 from t0, seq_1_to_40; +insert into t10 select 78257 from t1; +insert into t10 select 78258 from t1; +insert into t10 select 78259 from t1; +insert into t10 select 91300 from t1; +insert into t10 select 91301 from t1; +insert into t10 select 91302 from t1; +insert into t10 select 91302 from t0, seq_1_to_6; +insert into t10 select 91303 from t1; +insert into t10 select 91304 from t1; +insert into t10 select 91305 from t1; +insert into t10 select 91305 from t0, seq_1_to_8; +insert into t10 select 99998 from t1; +insert into t10 select 99999 from t1; +insert into t10 select 100000 from t1; +set use_stat_tables=preferably; +analyze table t10 persistent for all; +Table Op Msg_type Msg_text +test.t10 analyze status Engine-independent statistics collected +test.t10 analyze status OK +flush tables; +set @tmp=@@optimizer_trace; +set optimizer_trace=1; +explain select * from t10 where a in (91303); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t10 ALL NULL NULL NULL NULL 9984 Using where +# Must have selectivity_from_histogram <= 1.0: +select json_detailed(json_extract(trace, '$**.selectivity_for_columns')) as sel +from information_schema.optimizer_trace; +sel +[ + [ + { + "column_name": "a", + "ranges": + ["91303 <= a <= 91303"], + "selectivity_from_histogram": 0.035714283 + } + ] +] +set optimizer_trace=@tmp; +drop table t0,t1,t10; +set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +set histogram_size=@save_histogram_size; +set use_stat_tables= @save_use_stat_tables; +# +# End of 10.4 tests +# +# +# Clean up +# +set @@global.histogram_size=@save_histogram_size; +set optimizer_switch=@save_optimizer_switch_for_selectivity_test; +SET SESSION STORAGE_ENGINE=DEFAULT; +Warnings: +Warning 1287 '@@storage_engine' is deprecated and will be removed in a future release. Please use '@@default_storage_engine' instead diff --git a/mysql-test/main/selectivity_innodb_notembedded.test b/mysql-test/main/selectivity_innodb_notembedded.test new file mode 100644 index 00000000000..387f7dcb7de --- /dev/null +++ b/mysql-test/main/selectivity_innodb_notembedded.test @@ -0,0 +1,16 @@ +--source include/have_innodb.inc +# This test is slow on buildbot. +--source include/big_test.inc +--source include/default_optimizer_switch.inc +--source include/not_embedded.inc + +SET SESSION STORAGE_ENGINE='InnoDB'; + +set @save_optimizer_switch_for_selectivity_test=@@optimizer_switch; +set optimizer_switch='extended_keys=on'; + +--source selectivity_notembedded.test + +set optimizer_switch=@save_optimizer_switch_for_selectivity_test; + +SET SESSION STORAGE_ENGINE=DEFAULT; diff --git a/mysql-test/main/selectivity_no_engine.result b/mysql-test/main/selectivity_no_engine.result index 5df1c61e758..3f23b579b23 100644 --- a/mysql-test/main/selectivity_no_engine.result +++ b/mysql-test/main/selectivity_no_engine.result @@ -36,12 +36,12 @@ test.t2 analyze status OK # The following two must have the same in 'Extra' column: explain extended select * from t2 where col1 IN (20, 180); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 1100 1.35 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1100 1.00 Using where Warnings: Note 1003 select `test`.`t2`.`col1` AS `col1` from `test`.`t2` where `test`.`t2`.`col1` in (20,180) explain extended select * from t2 where col1 IN (180, 20); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t2 ALL NULL NULL NULL NULL 1100 1.35 Using where +1 SIMPLE t2 ALL NULL NULL NULL NULL 1100 1.00 Using where Warnings: Note 1003 select `test`.`t2`.`col1` AS `col1` from `test`.`t2` where `test`.`t2`.`col1` in (180,20) drop table t1, t2; @@ -102,7 +102,7 @@ test.t1 analyze status Engine-independent statistics collected test.t1 analyze status OK explain extended select * from t1 where col1 in (1,2,3); id select_type table type possible_keys key key_len ref rows filtered Extra -1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 3.37 Using where +1 SIMPLE t1 ALL NULL NULL NULL NULL 10000 2.97 Using where Warnings: Note 1003 select `test`.`t1`.`col1` AS `col1` from `test`.`t1` where `test`.`t1`.`col1` in (1,2,3) # Must not cause fp division by zero, or produce nonsense numbers: @@ -333,6 +333,29 @@ SELECT * FROM t1 JOIN t2 ON t1.a = t2.c WHERE t2.b IN ('o') OR t2.e >= 'f' OR t2 a b c d e set join_cache_level=@tmp_jcl; drop table t1,t2; +# +# MDEV-31199: Assertion `field->table->stats_is_read' fails with hash_join_cardinality=on +# +CREATE TABLE t1 (a VARCHAR(255)); +INSERT INTO t1 VALUES ('u'),('uu'); +CREATE TABLE t2 (b VARCHAR(255)) CHARACTER SET utf8mb4; +INSERT INTO t2 VALUES ('x'),('xx'); +CREATE TABLE t3 (c VARCHAR(255)); +INSERT INTO t3 VALUES ('z'),('zz'); +ANALYZE TABLE t1, t2, t3 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +test.t2 analyze status Engine-independent statistics collected +test.t2 analyze status OK +test.t3 analyze status Engine-independent statistics collected +test.t3 analyze status OK +set @tmp1=@@optimizer_switch, @tmp2=@@join_cache_level; +set optimizer_switch='hash_join_cardinality=on', join_cache_level=3; +SELECT t1.* FROM t1 JOIN (SELECT DISTINCT b FROM t2 JOIN t3) sq ON sq.b = t1.a; +a +set optimizer_switch=@tmp1, join_cache_level=@tmp2; +DROP TABLE t1, t2, t3; # # End of the test file # diff --git a/mysql-test/main/selectivity_no_engine.test b/mysql-test/main/selectivity_no_engine.test index 8596fce9bf2..4d050513015 100644 --- a/mysql-test/main/selectivity_no_engine.test +++ b/mysql-test/main/selectivity_no_engine.test @@ -271,6 +271,27 @@ SELECT * FROM t1 JOIN t2 ON t1.a = t2.c WHERE t2.b IN ('o') OR t2.e >= 'f' OR t2 set join_cache_level=@tmp_jcl; drop table t1,t2; + +--echo # +--echo # MDEV-31199: Assertion `field->table->stats_is_read' fails with hash_join_cardinality=on +--echo # +CREATE TABLE t1 (a VARCHAR(255)); +INSERT INTO t1 VALUES ('u'),('uu'); + +CREATE TABLE t2 (b VARCHAR(255)) CHARACTER SET utf8mb4; +INSERT INTO t2 VALUES ('x'),('xx'); + +CREATE TABLE t3 (c VARCHAR(255)); +INSERT INTO t3 VALUES ('z'),('zz'); + +ANALYZE TABLE t1, t2, t3 PERSISTENT FOR ALL; # Optional, fails either way + +set @tmp1=@@optimizer_switch, @tmp2=@@join_cache_level; +set optimizer_switch='hash_join_cardinality=on', join_cache_level=3; +SELECT t1.* FROM t1 JOIN (SELECT DISTINCT b FROM t2 JOIN t3) sq ON sq.b = t1.a; +set optimizer_switch=@tmp1, join_cache_level=@tmp2; +DROP TABLE t1, t2, t3; + --echo # --echo # End of the test file --echo # diff --git a/mysql-test/main/selectivity_notembedded.result b/mysql-test/main/selectivity_notembedded.result new file mode 100644 index 00000000000..d2e90a19a68 --- /dev/null +++ b/mysql-test/main/selectivity_notembedded.result @@ -0,0 +1,95 @@ +drop table if exists t0,t1,t2,t3; +select @@global.use_stat_tables; +@@global.use_stat_tables +COMPLEMENTARY +select @@session.use_stat_tables; +@@session.use_stat_tables +COMPLEMENTARY +set @save_use_stat_tables=@@use_stat_tables; +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 histogram_type='single_prec_hb'; +set optimizer_use_condition_selectivity=3; +# +# MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram +# +create table t0(a int); +insert into t0 select 1 from seq_1_to_78; +create table t1(a int); +insert into t1 select 1 from seq_1_to_26; +create table t10 (a int); +insert into t10 select 0 from t0, seq_1_to_4; +insert into t10 select 8693 from t1; +insert into t10 select 8694 from t1; +insert into t10 select 8695 from t1; +insert into t10 select 34783 from t1; +insert into t10 select 34784 from t1; +insert into t10 select 34785 from t1; +insert into t10 select 34785 from t0, seq_1_to_8; +insert into t10 select 65214 from t1; +insert into t10 select 65215 from t1; +insert into t10 select 65216 from t1; +insert into t10 select 65216 from t0, seq_1_to_52; +insert into t10 select 65217 from t1; +insert into t10 select 65218 from t1; +insert into t10 select 65219 from t1; +insert into t10 select 65219 from t0; +insert into t10 select 73913 from t1; +insert into t10 select 73914 from t1; +insert into t10 select 73915 from t1; +insert into t10 select 73915 from t0, seq_1_to_40; +insert into t10 select 78257 from t1; +insert into t10 select 78258 from t1; +insert into t10 select 78259 from t1; +insert into t10 select 91300 from t1; +insert into t10 select 91301 from t1; +insert into t10 select 91302 from t1; +insert into t10 select 91302 from t0, seq_1_to_6; +insert into t10 select 91303 from t1; +insert into t10 select 91304 from t1; +insert into t10 select 91305 from t1; +insert into t10 select 91305 from t0, seq_1_to_8; +insert into t10 select 99998 from t1; +insert into t10 select 99999 from t1; +insert into t10 select 100000 from t1; +set use_stat_tables=preferably; +analyze table t10 persistent for all; +Table Op Msg_type Msg_text +test.t10 analyze status Engine-independent statistics collected +test.t10 analyze status OK +flush tables; +set @tmp=@@optimizer_trace; +set optimizer_trace=1; +explain select * from t10 where a in (91303); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t10 ALL NULL NULL NULL NULL 9984 Using where +# Must have selectivity_from_histogram <= 1.0: +select json_detailed(json_extract(trace, '$**.selectivity_for_columns')) as sel +from information_schema.optimizer_trace; +sel +[ + [ + { + "column_name": "a", + "ranges": + ["91303 <= a <= 91303"], + "selectivity_from_histogram": 0.035714283 + } + ] +] +set optimizer_trace=@tmp; +drop table t0,t1,t10; +set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +set histogram_size=@save_histogram_size; +set use_stat_tables= @save_use_stat_tables; +# +# End of 10.4 tests +# +# +# Clean up +# +set @@global.histogram_size=@save_histogram_size; diff --git a/mysql-test/main/selectivity_notembedded.test b/mysql-test/main/selectivity_notembedded.test new file mode 100644 index 00000000000..6752bd3c7e1 --- /dev/null +++ b/mysql-test/main/selectivity_notembedded.test @@ -0,0 +1,121 @@ +--source include/no_valgrind_without_big.inc +--source include/have_stat_tables.inc +--source include/have_sequence.inc +--source include/default_charset.inc +--source include/not_embedded.inc + +--disable_warnings +drop table if exists t0,t1,t2,t3; +--enable_warnings + +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; +set histogram_type='single_prec_hb'; + +# check that statistics on nulls is used + +set optimizer_use_condition_selectivity=3; + +--echo # +--echo # MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram +--echo # +create table t0(a int); # This holds how many rows we hold in a bucket. +insert into t0 select 1 from seq_1_to_78; + +create table t1(a int); # one-third of a bucket +insert into t1 select 1 from seq_1_to_26; + +create table t10 (a int); +insert into t10 select 0 from t0, seq_1_to_4; + +insert into t10 select 8693 from t1; +insert into t10 select 8694 from t1; +insert into t10 select 8695 from t1; + + +insert into t10 select 34783 from t1; +insert into t10 select 34784 from t1; +insert into t10 select 34785 from t1; + + +insert into t10 select 34785 from t0, seq_1_to_8; + +insert into t10 select 65214 from t1; +insert into t10 select 65215 from t1; +insert into t10 select 65216 from t1; + +insert into t10 select 65216 from t0, seq_1_to_52; + +insert into t10 select 65217 from t1; +insert into t10 select 65218 from t1; +insert into t10 select 65219 from t1; + +insert into t10 select 65219 from t0; + + +insert into t10 select 73913 from t1; +insert into t10 select 73914 from t1; +insert into t10 select 73915 from t1; + +insert into t10 select 73915 from t0, seq_1_to_40; + + +insert into t10 select 78257 from t1; +insert into t10 select 78258 from t1; +insert into t10 select 78259 from t1; + +insert into t10 select 91300 from t1; +insert into t10 select 91301 from t1; +insert into t10 select 91302 from t1; + +insert into t10 select 91302 from t0, seq_1_to_6; + +insert into t10 select 91303 from t1; # Only 1/3rd of bucket matches the search tuple +insert into t10 select 91304 from t1; +insert into t10 select 91305 from t1; + +insert into t10 select 91305 from t0, seq_1_to_8; + +insert into t10 select 99998 from t1; +insert into t10 select 99999 from t1; +insert into t10 select 100000 from t1; + +set use_stat_tables=preferably; +analyze table t10 persistent for all; +flush tables; + +set @tmp=@@optimizer_trace; +set optimizer_trace=1; +explain select * from t10 where a in (91303); + +--echo # Must have selectivity_from_histogram <= 1.0: +select json_detailed(json_extract(trace, '$**.selectivity_for_columns')) as sel +from information_schema.optimizer_trace; + +set optimizer_trace=@tmp; +drop table t0,t1,t10; + +set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +set histogram_size=@save_histogram_size; +set use_stat_tables= @save_use_stat_tables; + + +--echo # +--echo # End of 10.4 tests +--echo # + +--echo # +--echo # Clean up +--echo # +--source include/restore_charset.inc +set @@global.histogram_size=@save_histogram_size; diff --git a/mysql-test/main/shutdown.test b/mysql-test/main/shutdown.test index 13b7ac3f672..71f2156a17f 100644 --- a/mysql-test/main/shutdown.test +++ b/mysql-test/main/shutdown.test @@ -18,8 +18,8 @@ disconnect c1; create procedure try_shutdown() shutdown; drop procedure try_shutdown; ---let $_server_id= `SELECT @@server_id` ---let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect +--let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')` +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect --exec echo "wait" > $_expect_file_name --send shutdown diff --git a/mysql-test/main/skr.result b/mysql-test/main/skr.result deleted file mode 100644 index 291377573bc..00000000000 --- a/mysql-test/main/skr.result +++ /dev/null @@ -1,54 +0,0 @@ -# -# MDEV-23406: query with mutually recursive CTEs when big_tables=1 -# -set @save_big_tables=@@big_tables; -set big_tables=1; -Warnings: -Warning 1287 '@@big_tables' is deprecated and will be removed in a future release -create table folks(id int, name char(32), dob date, father int, mother int); -insert into folks values -(100, 'Me', '2000-01-01', 20, 30), -(20, 'Dad', '1970-02-02', 10, 9), -(30, 'Mom', '1975-03-03', 8, 7), -(10, 'Grandpa Bill', '1940-04-05', null, null), -(9, 'Grandma Ann', '1941-10-15', null, null), -(25, 'Uncle Jim', '1968-11-18', 8, 7), -(98, 'Sister Amy', '2001-06-20', 20, 30), -(7, 'Grandma Sally', '1943-08-23', null, 6), -(8, 'Grandpa Ben', '1940-10-21', null, null), -(6, 'Grandgrandma Martha', '1923-05-17', null, null), -(67, 'Cousin Eddie', '1992-02-28', 25, 27), -(27, 'Auntie Melinda', '1971-03-29', null, null); -with recursive -ancestor_couples(h_id, h_name, h_dob, h_father, h_mother, -w_id, w_name, w_dob, w_father, w_mother) -as -( -select h.*, w.* -from folks h, folks w, coupled_ancestors a -where a.father = h.id AND a.mother = w.id -union -select h.*, w.* -from folks v, folks h, folks w -where v.name = 'Me' and -(v.father = h.id AND v.mother= w.id) -), -coupled_ancestors (id, name, dob, father, mother) -as -( -select h_id, h_name, h_dob, h_father, h_mother -from ancestor_couples -union -select w_id, w_name, w_dob, w_father, w_mother -from ancestor_couples -) -select h_name, h_dob, w_name, w_dob -from ancestor_couples; -h_name h_dob w_name w_dob -Dad 1970-02-02 Mom 1975-03-03 -Grandpa Bill 1940-04-05 Grandma Ann 1941-10-15 -Grandpa Ben 1940-10-21 Grandma Sally 1943-08-23 -drop table folks; -set big_tables=@save_big_tables; -Warnings: -Warning 1287 '@@big_tables' is deprecated and will be removed in a future release diff --git a/mysql-test/main/skr.test b/mysql-test/main/skr.test deleted file mode 100644 index 3094faff696..00000000000 --- a/mysql-test/main/skr.test +++ /dev/null @@ -1,56 +0,0 @@ ---source include/default_optimizer_switch.inc - ---echo # ---echo # MDEV-23406: query with mutually recursive CTEs when big_tables=1 ---echo # - -set @save_big_tables=@@big_tables; -set big_tables=1; - -create table folks(id int, name char(32), dob date, father int, mother int); - -insert into folks values -(100, 'Me', '2000-01-01', 20, 30), -(20, 'Dad', '1970-02-02', 10, 9), -(30, 'Mom', '1975-03-03', 8, 7), -(10, 'Grandpa Bill', '1940-04-05', null, null), -(9, 'Grandma Ann', '1941-10-15', null, null), -(25, 'Uncle Jim', '1968-11-18', 8, 7), -(98, 'Sister Amy', '2001-06-20', 20, 30), -(7, 'Grandma Sally', '1943-08-23', null, 6), -(8, 'Grandpa Ben', '1940-10-21', null, null), -(6, 'Grandgrandma Martha', '1923-05-17', null, null), -(67, 'Cousin Eddie', '1992-02-28', 25, 27), -(27, 'Auntie Melinda', '1971-03-29', null, null); - -let q= -with recursive -ancestor_couples(h_id, h_name, h_dob, h_father, h_mother, - w_id, w_name, w_dob, w_father, w_mother) -as -( - select h.*, w.* - from folks h, folks w, coupled_ancestors a - where a.father = h.id AND a.mother = w.id - union - select h.*, w.* - from folks v, folks h, folks w - where v.name = 'Me' and - (v.father = h.id AND v.mother= w.id) -), -coupled_ancestors (id, name, dob, father, mother) -as -( - select h_id, h_name, h_dob, h_father, h_mother - from ancestor_couples - union - select w_id, w_name, w_dob, w_father, w_mother - from ancestor_couples -) -select h_name, h_dob, w_name, w_dob - from ancestor_couples; - -eval $q; -drop table folks; - -set big_tables=@save_big_tables; diff --git a/mysql-test/main/sql_mode_pad_char_to_full_length.result b/mysql-test/main/sql_mode_pad_char_to_full_length.result new file mode 100644 index 00000000000..6f68aade613 --- /dev/null +++ b/mysql-test/main/sql_mode_pad_char_to_full_length.result @@ -0,0 +1,94 @@ +# +# Start of 10.4 tests +# +# +# MDEV-28190 sql_mode makes MDEV-371 virtual column expressions nondeterministic +# +SET default_storage_engine=MyISAM; +# +# MDEV-28190 sql_mode makes MDEV-371 virtual column expressions nondeterministic +# +CREATE TABLE t1 (a INT,b CHAR(20)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` char(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +CREATE UNIQUE INDEX bi USING HASH ON t1 (b); +INSERT INTO t1 VALUES (0,0); +SET sql_mode='pad_char_to_full_length'; +DELETE FROM t1; +DROP TABLE t1; +SET sql_mode=''; +CREATE TABLE t1 (a INT,b CHAR(20)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` char(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +CREATE UNIQUE INDEX bi USING HASH ON t1 (b); +SET sql_mode='pad_char_to_full_length'; +INSERT INTO t1 VALUES (0,0); +DELETE FROM t1; +DROP TABLE t1; +SET sql_mode=''; +CREATE OR REPLACE TABLE t1 (a CHAR(20),b CHAR(20)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(20) DEFAULT NULL, + `b` char(20) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +CREATE UNIQUE INDEX bi USING HASH ON t1 (b); +INSERT INTO t1 VALUES (0,0); +SET sql_mode='pad_char_to_full_length'; +DELETE FROM t1; +DROP TABLE t1; +SET default_storage_engine=MEMORY; +# +# MDEV-28190 sql_mode makes MDEV-371 virtual column expressions nondeterministic +# +CREATE TABLE t1 (a INT,b CHAR(20)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` char(20) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +CREATE UNIQUE INDEX bi USING HASH ON t1 (b); +INSERT INTO t1 VALUES (0,0); +SET sql_mode='pad_char_to_full_length'; +DELETE FROM t1; +DROP TABLE t1; +SET sql_mode=''; +CREATE TABLE t1 (a INT,b CHAR(20)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `b` char(20) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +CREATE UNIQUE INDEX bi USING HASH ON t1 (b); +SET sql_mode='pad_char_to_full_length'; +INSERT INTO t1 VALUES (0,0); +DELETE FROM t1; +DROP TABLE t1; +SET sql_mode=''; +CREATE OR REPLACE TABLE t1 (a CHAR(20),b CHAR(20)); +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(20) DEFAULT NULL, + `b` char(20) DEFAULT NULL +) ENGINE=MEMORY DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +CREATE UNIQUE INDEX bi USING HASH ON t1 (b); +INSERT INTO t1 VALUES (0,0); +SET sql_mode='pad_char_to_full_length'; +DELETE FROM t1; +DROP TABLE t1; +SET default_storage_engine=DEFAULT; +# +# End of 10.4 tests +# diff --git a/mysql-test/main/sql_mode_pad_char_to_full_length.test b/mysql-test/main/sql_mode_pad_char_to_full_length.test new file mode 100644 index 00000000000..4d492bc1b70 --- /dev/null +++ b/mysql-test/main/sql_mode_pad_char_to_full_length.test @@ -0,0 +1,19 @@ +--echo # +--echo # Start of 10.4 tests +--echo # + +--echo # +--echo # MDEV-28190 sql_mode makes MDEV-371 virtual column expressions nondeterministic +--echo # + +SET default_storage_engine=MyISAM; +--source include/sql_mode_pad_char_to_full_length.inc + +SET default_storage_engine=MEMORY; +--source include/sql_mode_pad_char_to_full_length.inc + +SET default_storage_engine=DEFAULT; + +--echo # +--echo # End of 10.4 tests +--echo # diff --git a/mysql-test/main/status.result b/mysql-test/main/status.result index 0669bdf3b34..9a4dd7c9302 100644 --- a/mysql-test/main/status.result +++ b/mysql-test/main/status.result @@ -447,3 +447,22 @@ Feature_json 2 connection default; set @@global.concurrent_insert= @old_concurrent_insert; SET GLOBAL log_output = @old_log_output; +# +# MDEV-30543 New status variable: Max_used_connections_time +# +FLUSH STATUS; +connect con1,localhost,root,,; +connect con2,localhost,root,,; +connection con1; +disconnect con2; +SELECT 'DTVALUE' = 'DTVALUE' AS expect_1; +expect_1 +1 +connect con3,localhost,root,,; +connect con4,localhost,root,,; +SELECT 'DTVALUE' < 'DTVALUE' as expect_1; +expect_1 +1 +disconnect con4; +disconnect con3; +disconnect con1; diff --git a/mysql-test/main/status.test b/mysql-test/main/status.test index 78626615d45..acf29f35b9e 100644 --- a/mysql-test/main/status.test +++ b/mysql-test/main/status.test @@ -280,7 +280,6 @@ show status like 'Com%function'; # connect (root, localhost, root,,test); connection root; -let $root_connection_id= `select connection_id()`; --disable_warnings create database db37908; --enable_warnings @@ -296,7 +295,6 @@ delimiter ;| connect (user1,localhost,mysqltest_1,,test); connection user1; -let $user1_connection_id= `select connection_id()`; --error ER_TABLEACCESS_DENIED_ERROR select * from db37908.t1; @@ -315,11 +313,8 @@ drop procedure proc37908; drop function func37908; REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_1@localhost; DROP USER mysqltest_1@localhost; -# Wait till the sessions user1 and root are disconnected -let $wait_condition = - SELECT COUNT(*) = 0 - FROM information_schema.processlist - WHERE id in ('$root_connection_id','$user1_connection_id'); +# Wait until all non-default sessions are disconnected +let $wait_condition = SELECT COUNT(*) = 1 FROM information_schema.processlist; --source include/wait_condition.inc # @@ -447,3 +442,34 @@ SET GLOBAL log_output = @old_log_output; # Wait till we reached the initial number of concurrent sessions --source include/wait_until_count_sessions.inc +--echo # +--echo # MDEV-30543 New status variable: Max_used_connections_time +--echo # + +FLUSH STATUS; + +connect (con1,localhost,root,,); +--sleep 1 +connect (con2,localhost,root,,); +--sleep 1 +let $time_1=`SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections_time'`; +--sleep 1 +connection con1; +disconnect con2; +--sleep 1 +let $time_2=`SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections_time'`; +--replace_regex /[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*/DTVALUE/ +eval SELECT '$time_1' = '$time_2' AS expect_1; +--sleep 1 +connect (con3,localhost,root,,); +--sleep 1 +connect (con4,localhost,root,,); +--sleep 1 +let $time_3=`SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME LIKE 'max_used_connections_time'`; +--replace_regex /[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*/DTVALUE/ +eval SELECT '$time_1' < '$time_3' as expect_1; + +disconnect con4; +disconnect con3; +disconnect con1; + diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result index e0cf1e61d95..6e0c956b77e 100644 --- a/mysql-test/main/subselect.result +++ b/mysql-test/main/subselect.result @@ -118,27 +118,27 @@ ROW(1,2,3) > (SELECT 1,2,1) SELECT ROW(1,2,3) = (SELECT 1,2,NULL); ROW(1,2,3) = (SELECT 1,2,NULL) NULL -SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a'); -(SELECT 1.5,2,'a') = ROW(1.5,2,'a') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a') AS m; +m 1 -SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b'); -(SELECT 1.5,2,'a') = ROW(1.5,2,'b') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b') AS m; +m 0 -SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b'); -(SELECT 1.5,2,'a') = ROW('1.5b',2,'b') +SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DOUBLE value: '1.5b' -SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a'); -(SELECT 'b',2,'a') = ROW(1.5,2,'a') +SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DOUBLE value: 'b' -SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a'); -(SELECT 1.5,2,'a') = ROW(1.5,'2','a') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a') AS m; +m 1 -SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a'); -(SELECT 1.5,'c','a') = ROW(1.5,2,'a') +SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DECIMAL value: 'c' @@ -228,19 +228,26 @@ a 2 select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a < t1.a) order by 1 desc limit 1); a -select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; -b (select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) +select +b, +(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) as m +from t4; +b m 8 7.5000 8 4.5000 9 7.5000 -explain extended select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; +explain extended +select +b, +(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) as m +from t4; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t4 ALL NULL NULL NULL NULL 3 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1276 Field or reference 'test.t4.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`t4`.`b` AS `b`,<expr_cache><`test`.`t4`.`a`>((/* select#2 */ select avg(`test`.`t2`.`a` + (/* select#3 */ select min(`test`.`t3`.`a`) from `test`.`t3` where `test`.`t3`.`a` >= `test`.`t4`.`a`)) from `test`.`t2`)) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` +Note 1003 /* select#1 */ select `test`.`t4`.`b` AS `b`,<expr_cache><`test`.`t4`.`a`>((/* select#2 */ select avg(`test`.`t2`.`a` + (/* select#3 */ select min(`test`.`t3`.`a`) from `test`.`t3` where `test`.`t3`.`a` >= `test`.`t4`.`a`)) from `test`.`t2`)) AS `m` from `test`.`t4` select * from t3 where exists (select * from t2 where t2.b=t3.a); a 7 @@ -307,21 +314,34 @@ select b,max(a) as ma from t4 group by b having b >= (select max(t2.a) from t2 w b ma 7 12 create table t5 (a int); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 insert into t5 values (5); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 insert into t5 values (2); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 -explain extended select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +explain extended +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 100.00 @@ -330,7 +350,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select <expr_cache><`test`.`t2`.`a`>((/* select#2 */ select 2 from dual where 2 = `test`.`t2`.`a` union /* select#3 */ select `test`.`t5`.`a` from `test`.`t5` where `test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` +Note 1003 /* select#1 */ select <expr_cache><`test`.`t2`.`a`>((/* select#2 */ select 2 from dual where 2 = `test`.`t2`.`a` union /* select#3 */ select `test`.`t5`.`a` from `test`.`t5` where `test`.`t5`.`a` = `test`.`t2`.`a`)) AS `m`,`test`.`t2`.`a` AS `a` from `test`.`t2` select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subquery returns more than 1 row create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); @@ -486,8 +506,11 @@ SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING t mot topic date pseudo joce 40143 2002-10-22 joce joce 43506 2002-10-22 joce -SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) from t2; -mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) +SELECT +*, +topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) AS m +FROM t2; +mot topic date pseudo m joce 40143 2002-10-22 joce 1 joce 43506 2002-10-22 joce 1 SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2); @@ -505,8 +528,11 @@ joce 40143 2002-10-22 joce SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); mot topic date pseudo joce 40143 2002-10-22 joce -SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) from t2; -mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) +SELECT +*, +topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) AS m +FROM t2; +mot topic date pseudo m joce 40143 2002-10-22 joce 1 joce 43506 2002-10-22 joce 0 drop table t1,t2; @@ -890,6 +916,25 @@ NULL select 1.5 > ANY (SELECT * from t1); 1.5 > ANY (SELECT * from t1) NULL +update t1 set a=NULL where a=2.5; +select 1.5 IN (SELECT * from t1); +1.5 IN (SELECT * from t1) +1 +select 3.5 IN (SELECT * from t1); +3.5 IN (SELECT * from t1) +1 +select 10.5 IN (SELECT * from t1); +10.5 IN (SELECT * from t1) +NULL +select 1.5 > ALL (SELECT * from t1); +1.5 > ALL (SELECT * from t1) +0 +select 10.5 > ALL (SELECT * from t1); +10.5 > ALL (SELECT * from t1) +NULL +select 1.5 > ANY (SELECT * from t1); +1.5 > ANY (SELECT * from t1) +NULL select 10.5 > ANY (SELECT * from t1); 10.5 > ANY (SELECT * from t1) 1 @@ -900,6 +945,20 @@ Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1249 Select 2 was reduced during optimization Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` +explain extended select (select a+1) from t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` +explain extended select (select a+1) from t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` select (select a+1) from t1; (select a+1) 2.5 @@ -1547,8 +1606,8 @@ create table t3 (a int, b int); insert into t1 values (0,100),(1,2), (1,3), (2,2), (2,7), (2,-1), (3,10); insert into t2 values (0,0), (1,1), (2,1), (3,1), (4,1); insert into t3 values (3,3), (2,2), (1,1); -select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3; -a (select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) +select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) as m from t3; +a m 3 1 2 2 1 2 @@ -1746,8 +1805,8 @@ CREATE TABLE `t3` (`taskgenid` mediumint(9) NOT NULL auto_increment,`dbid` int(1 INSERT INTO `t3` (`taskgenid`, `dbid`, `taskid`, `mon`, `tues`,`wed`, `thur`, `fri`, `sat`, `sun`, `how_often`, `userid`, `active`) VALUES (1,-1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1); CREATE TABLE `t4` (`task_id` smallint(6) NOT NULL default '0',`description` varchar(200) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1; INSERT INTO `t4` (`task_id`, `description`) VALUES (1, 'Daily Check List'),(2, 'Weekly Status'); -select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid; -dbid name (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') +select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') as m FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') as m from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid; +dbid name m -1 Valid 1 -1 Valid 2 1 -1 Should Not Return 0 @@ -3809,9 +3868,10 @@ SELECT (SELECT COUNT(DISTINCT t1.b) from t2) FROM t1 GROUP BY t1.a; 2 1 1 -SELECT (SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) +SELECT +(SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) AS m FROM t1 GROUP BY t1.a; -(SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) +m 2 1 1 @@ -3821,9 +3881,9 @@ COUNT(DISTINCT t1.b) (SELECT COUNT(DISTINCT t1.b)) 1 1 1 1 SELECT COUNT(DISTINCT t1.b), -(SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) +(SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) AS m FROM t1 GROUP BY t1.a; -COUNT(DISTINCT t1.b) (SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) +COUNT(DISTINCT t1.b) m 2 2 1 1 1 1 @@ -3847,16 +3907,10 @@ SELECT ( SELECT COUNT(DISTINCT t1.b) ) ) -FROM t1 GROUP BY t1.a LIMIT 1) +FROM t1 GROUP BY t1.a LIMIT 1) AS m FROM t1 t2 GROUP BY t2.a; -( -SELECT ( -SELECT ( -SELECT COUNT(DISTINCT t1.b) -) -) -FROM t1 GROUP BY t1.a LIMIT 1) +m 2 2 2 @@ -6453,11 +6507,10 @@ CREATE TABLE t3 (a int, b int); INSERT INTO t3 VALUES (10,7), (0,7); SELECT SUM(DISTINCT b), (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 -WHERE t.a != 0 AND t2.a != 0) +WHERE t.a != 0 AND t2.a != 0) AS m FROM (SELECT * FROM t3) AS t GROUP BY 2; -SUM(DISTINCT b) (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 -WHERE t.a != 0 AND t2.a != 0) +SUM(DISTINCT b) m 7 NULL SELECT SUM(DISTINCT b), (SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) @@ -6590,66 +6643,93 @@ CREATE TABLE t3 (f3a int default 1, f3b int default 2); INSERT INTO t3 VALUES (1,1),(2,2); set @old_optimizer_switch = @@session.optimizer_switch; set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off,subquery_cache=off,semijoin=off'; -SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m; +m NULL -SELECT (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m; +m NULL set @@session.optimizer_switch=@old_optimizer_switch; -SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m; +m NULL -SELECT (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2; +SELECT +(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2 AS m; (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m; +m NULL select (null, null) = (null, null); (null, null) = (null, null) @@ -6695,8 +6775,10 @@ INSERT INTO t2 VALUES (1); CREATE TABLE t3 ( c INT ); INSERT INTO t3 VALUES (4),(5); SET optimizer_switch='subquery_cache=off'; -SELECT ( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1; -( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) +SELECT +( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) AS m +FROM t1; +m 1 NULL SELECT ( SELECT b FROM t2 WHERE b = a OR b * 0) FROM t1; @@ -6913,7 +6995,9 @@ CREATE TABLE t3 (c INT); INSERT INTO t3 VALUES (8),(3); set @@expensive_subquery_limit= 0; EXPLAIN -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 ALL NULL NULL NULL NULL 2 @@ -6923,9 +7007,11 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 flush status; -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; -(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +m NULL NULL NULL @@ -6951,7 +7037,9 @@ Handler_read_rnd_deleted 0 Handler_read_rnd_next 22 set @@expensive_subquery_limit= default; EXPLAIN -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 ALL NULL NULL NULL NULL 2 @@ -6961,9 +7049,11 @@ id select_type table type possible_keys key key_len ref rows Extra 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 flush status; -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; -(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +m NULL NULL NULL diff --git a/mysql-test/main/subselect.test b/mysql-test/main/subselect.test index 578dbe86406..089eb10b6f0 100644 --- a/mysql-test/main/subselect.test +++ b/mysql-test/main/subselect.test @@ -79,13 +79,13 @@ SELECT ROW(1,2,3) > (SELECT 1,2,1); #enable after fix MDEV-28585 --disable_view_protocol SELECT ROW(1,2,3) = (SELECT 1,2,NULL); -SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a'); -SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b'); -SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b'); -SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a'); -SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a'); -SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a'); --enable_view_protocol +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a') AS m; +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b') AS m; +SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b') AS m; +SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a') AS m; +SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a') AS m; +SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a') AS m; -- error ER_OPERAND_COLUMNS SELECT (SELECT * FROM (SELECT 'test' a,'test' b) a); @@ -123,11 +123,15 @@ set optimizer_switch=@tmp_optimizer_switch; select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3) order by 1 desc limit 1); select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a > t1.a) order by 1 desc limit 1); select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a < t1.a) order by 1 desc limit 1); -#enable afte fix MDEV-27871 ---disable_view_protocol -select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; -explain extended select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; ---enable_view_protocol +select + b, + (select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) as m +from t4; +explain extended +select + b, + (select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) as m +from t4; select * from t3 where exists (select * from t2 where t2.b=t3.a); select * from t3 where not exists (select * from t2 where t2.b=t3.a); select * from t3 where a in (select b from t2); @@ -160,16 +164,25 @@ delete from t2 where a=2 and b=10; select b,max(a) as ma from t4 group by b having b >= (select max(t2.a) from t2 where t2.b=t4.b); create table t5 (a int); -#enable afte fix MDEV-27871 ---disable_view_protocol - -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +select + (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, + a +from t2; insert into t5 values (5); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +select + (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, + a +from t2; insert into t5 values (2); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -explain extended select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; ---enable_view_protocol +select + (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, + a +from t2; +explain extended +select + (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, + a +from t2; -- error ER_SUBQUERY_NO_1_ROW select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; @@ -274,19 +287,19 @@ SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic HAVING t SELECT * from t2 where topic = any (SELECT SUM(topic) FROM t1); SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic); SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100); -#enable after fix MDEV-27871 ---disable_view_protocol -SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) from t2; ---enable_view_protocol +SELECT + *, + topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) AS m +FROM t2; SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2); SELECT * from t2 where topic <> any (SELECT SUM(topic) FROM t2); SELECT * from t2 where topic IN (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); SELECT * from t2 where topic = any (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); -#enable after fix MDEV-27871 ---disable_view_protocol -SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) from t2; ---enable_view_protocol +SELECT + *, + topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) AS m +FROM t2; drop table t1,t2; #forumconthardwarefr7 @@ -535,13 +548,22 @@ select 10.5 IN (SELECT * from t1); select 1.5 > ALL (SELECT * from t1); select 10.5 > ALL (SELECT * from t1); select 1.5 > ANY (SELECT * from t1); +update t1 set a=NULL where a=2.5; +select 1.5 IN (SELECT * from t1); +select 3.5 IN (SELECT * from t1); +select 10.5 IN (SELECT * from t1); +select 1.5 > ALL (SELECT * from t1); +select 10.5 > ALL (SELECT * from t1); +select 1.5 > ANY (SELECT * from t1); select 10.5 > ANY (SELECT * from t1); --enable_prepare_warnings +--enable_view_protocol +explain extended select (select a+1) from t1; +explain extended select (select a+1) from t1; explain extended select (select a+1) from t1; --disable_prepare_warnings select (select a+1) from t1; drop table t1; ---enable_view_protocol --echo # --echo # Null with keys @@ -961,10 +983,7 @@ create table t3 (a int, b int); insert into t1 values (0,100),(1,2), (1,3), (2,2), (2,7), (2,-1), (3,10); insert into t2 values (0,0), (1,1), (2,1), (3,1), (4,1); insert into t3 values (3,3), (2,2), (1,1); -#enable after fix MDEV-27871 ---disable_view_protocol -select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3; ---enable_view_protocol +select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) as m from t3; drop table t1,t2,t3; # @@ -1083,10 +1102,7 @@ CREATE TABLE `t3` (`taskgenid` mediumint(9) NOT NULL auto_increment,`dbid` int(1 INSERT INTO `t3` (`taskgenid`, `dbid`, `taskid`, `mon`, `tues`,`wed`, `thur`, `fri`, `sat`, `sun`, `how_often`, `userid`, `active`) VALUES (1,-1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1); CREATE TABLE `t4` (`task_id` smallint(6) NOT NULL default '0',`description` varchar(200) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1; INSERT INTO `t4` (`task_id`, `description`) VALUES (1, 'Daily Check List'),(2, 'Weekly Status'); -#enable after fix MDEV-27871 ---disable_view_protocol -select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid; ---enable_view_protocol +select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') as m FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') as m from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid; SELECT dbid, name FROM t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND ((date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01')) AND t4.task_id = taskid; drop table t1,t2,t3,t4; @@ -2406,9 +2422,6 @@ SELECT a, MAX(b), MIN(b) FROM t1 GROUP BY a; SELECT * FROM t2; SELECT * FROM t3; -#enable after fix MDEV-28570 ---disable_view_protocol - SELECT a FROM t1 GROUP BY a HAVING a IN (SELECT c FROM t2 WHERE MAX(b)>20); SELECT a FROM t1 GROUP BY a @@ -2473,8 +2486,6 @@ SELECT t1.a, SUM(b) AS sum FROM t1 GROUP BY t1.a HAVING t1.a IN (SELECT t2.c FROM t2 GROUP BY t2.c HAVING t2.c+sum > 20); ---enable_view_protocol - DROP TABLE t1,t2,t3; @@ -2705,19 +2716,17 @@ DROP TABLE t1; # Bug#21540 Subqueries with no from and aggregate functions return # wrong results -#enable after fix MDEV-27871, MDEV-28573 ---disable_view_protocol - CREATE TABLE t1 (a INT, b INT); CREATE TABLE t2 (a INT); INSERT INTO t2 values (1); INSERT INTO t1 VALUES (1,1),(1,2),(2,3),(3,4); SELECT (SELECT COUNT(DISTINCT t1.b) from t2) FROM t1 GROUP BY t1.a; -SELECT (SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) +SELECT + (SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) AS m FROM t1 GROUP BY t1.a; SELECT COUNT(DISTINCT t1.b), (SELECT COUNT(DISTINCT t1.b)) FROM t1 GROUP BY t1.a; SELECT COUNT(DISTINCT t1.b), - (SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) + (SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) AS m FROM t1 GROUP BY t1.a; SELECT ( SELECT ( @@ -2731,11 +2740,10 @@ SELECT ( SELECT COUNT(DISTINCT t1.b) ) ) - FROM t1 GROUP BY t1.a LIMIT 1) + FROM t1 GROUP BY t1.a LIMIT 1) AS m FROM t1 t2 GROUP BY t2.a; DROP TABLE t1,t2; ---enable_view_protocol # # Bug#21727 Correlated subquery that requires filesort: @@ -2970,8 +2978,6 @@ DROP TABLE t1,t2; # Bug#27229 GROUP_CONCAT in subselect with COUNT() as an argument # -#enable after fix MDEV-28571 ---disable_view_protocol CREATE TABLE t1 (a int, b int); CREATE TABLE t2 (m int, n int); INSERT INTO t1 VALUES (2,2), (2,2), (3,3), (3,3), (3,3), (4,4); @@ -2986,7 +2992,6 @@ SELECT COUNT(*) c, a, FROM t1 GROUP BY a; DROP table t1,t2; ---enable_view_protocol # # Bug#27321 Wrong subquery result in a grouping select @@ -3017,14 +3022,11 @@ SELECT tt.a, FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1) as test FROM t1 as tt GROUP BY tt.a; -#enable after fix MDEV-28571 ---disable_view_protocol SELECT tt.a, MAX( (SELECT (SELECT t.c FROM t1 AS t WHERE t1.a=t.a AND t.d=MAX(t1.b + tt.a) LIMIT 1) FROM t1 WHERE t1.a=tt.a GROUP BY a LIMIT 1)) as test FROM t1 as tt GROUP BY tt.a; ---enable_view_protocol DROP TABLE t1; @@ -3180,8 +3182,6 @@ CREATE TABLE t2 (x INTEGER); INSERT INTO t1 VALUES (1,11), (2,22), (2,22); INSERT INTO t2 VALUES (1), (2); -#enable after fix MDEV-28573 ---disable_view_protocol # wasn't failing, but should --error ER_SUBQUERY_NO_1_ROW SELECT a, COUNT(b), (SELECT COUNT(b) FROM t2) FROM t1 GROUP BY a; @@ -3191,7 +3191,6 @@ SELECT a, COUNT(b), (SELECT COUNT(b) FROM t2) FROM t1 GROUP BY a; SELECT a, COUNT(b), (SELECT COUNT(b)+0 FROM t2) FROM t1 GROUP BY a; SELECT (SELECT SUM(t1.a)/AVG(t2.x) FROM t2) FROM t1; ---enable_view_protocol DROP TABLE t1,t2; @@ -3206,8 +3205,6 @@ GROUP BY a1.a; DROP TABLE t1; #test cases from 29297 -#enable after fix MDEV-28573 ---disable_view_protocol CREATE TABLE t1 (a INT); CREATE TABLE t2 (a INT); INSERT INTO t1 VALUES (1),(2); @@ -3217,7 +3214,6 @@ SELECT (SELECT SUM(t1.a) FROM t2 WHERE a=0) FROM t1; SELECT (SELECT SUM(t1.a) FROM t2 WHERE a!=0) FROM t1; SELECT (SELECT SUM(t1.a) FROM t2 WHERE a=1) FROM t1; DROP TABLE t1,t2; ---enable_view_protocol # # Bug#31884 Assertion + crash in subquery in the SELECT clause. @@ -5420,14 +5416,11 @@ INSERT INTO t2 VALUES (10,7,0), (0,7,0); CREATE TABLE t3 (a int, b int); INSERT INTO t3 VALUES (10,7), (0,7); -#enable after fix MDEV-27871 ---disable_view_protocol SELECT SUM(DISTINCT b), (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 - WHERE t.a != 0 AND t2.a != 0) + WHERE t.a != 0 AND t2.a != 0) AS m FROM (SELECT * FROM t3) AS t GROUP BY 2; ---enable_view_protocol SELECT SUM(DISTINCT b), (SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) @@ -5585,29 +5578,53 @@ INSERT INTO t3 VALUES (1,1),(2,2); set @old_optimizer_switch = @@session.optimizer_switch; set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off,subquery_cache=off,semijoin=off'; -#enable after fix MDEV-27871 ---disable_view_protocol -SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2; -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) FROM t2; -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2; -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1); -SELECT (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2; -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) FROM t2; -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) FROM t2; -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1); +SELECT + (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) AS m +FROM t2; +SELECT + (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) AS m + FROM t2; +SELECT + (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +SELECT + (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m; +SELECT + (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) AS m +FROM t2; +SELECT + (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +SELECT + (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +SELECT + (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m; set @@session.optimizer_switch=@old_optimizer_switch; # check different IN with default switches -SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2; -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) FROM t2; -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2; -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1); -SELECT (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2; -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) FROM t2; -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) FROM t2; -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1); ---enable_view_protocol +SELECT + (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) AS m +FROM t2; +SELECT + (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +SELECT + (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +SELECT + (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m; +SELECT + (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2 AS m; +SELECT + (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +SELECT + (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +SELECT + (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m; # other row operation with NULL single row subquery also should work select (null, null) = (null, null); @@ -5647,10 +5664,9 @@ INSERT INTO t3 VALUES (4),(5); SET optimizer_switch='subquery_cache=off'; -#enable after fix MDEV-27871 ---disable_view_protocol -SELECT ( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1; ---enable_view_protocol +SELECT + ( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) AS m +FROM t1; # This query just for example, it should return the same as above (1 and NULL) SELECT ( SELECT b FROM t2 WHERE b = a OR b * 0) FROM t1; @@ -5839,15 +5855,17 @@ INSERT INTO t3 VALUES (8),(3); set @@expensive_subquery_limit= 0; -#enable after fix MDEV-27871 ---disable_view_protocol EXPLAIN -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT + (SELECT MIN(b) FROM t1, t2 + WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; flush status; -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT + (SELECT MIN(b) FROM t1, t2 + WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; show status like "subquery_cache%"; @@ -5856,17 +5874,20 @@ show status like '%Handler_read%'; set @@expensive_subquery_limit= default; EXPLAIN -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT + (SELECT MIN(b) FROM t1, t2 + WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; flush status; -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT + (SELECT MIN(b) FROM t1, t2 + WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; show status like "subquery_cache%"; show status like '%Handler_read%'; ---enable_view_protocol drop table t1, t2, t3; @@ -6120,22 +6141,16 @@ INSERT INTO t1 VALUES (1),(2); CREATE TABLE t2 (f2 int); INSERT INTO t2 VALUES (3); -#enable after fix MDEV-29224 ---disable_view_protocol SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1; SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1; ---enable_view_protocol INSERT INTO t2 VALUES (4); -#enable after fix MDEV-28573 ---disable_view_protocol --error ER_SUBQUERY_NO_1_ROW SELECT ( SELECT MAX(f1) FROM t2 ) FROM v1; --error ER_SUBQUERY_NO_1_ROW SELECT ( SELECT MAX(f1) FROM t2 ) FROM t1; ---enable_view_protocol drop view v1; drop table t1,t2; diff --git a/mysql-test/main/subselect3_jcl6.result b/mysql-test/main/subselect3_jcl6.result index acd1269d875..ca06d25db49 100644 --- a/mysql-test/main/subselect3_jcl6.result +++ b/mysql-test/main/subselect3_jcl6.result @@ -1170,11 +1170,11 @@ 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); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY E ALL NULL NULL NULL NULL 5 Using where; Start temporary -1 PRIMARY A ALL NULL NULL NULL NULL 10 Using join buffer (flat, BNL join) +1 PRIMARY A ALL NULL NULL NULL NULL 10 +1 PRIMARY E ALL NULL NULL NULL NULL 5 Using where; Start temporary; Using join buffer (flat, BNL join) +1 PRIMARY D hash_ALL NULL #hash#$hj 5 test.E.a 10 Using where; Using join buffer (incremental, BNLH join) 1 PRIMARY B ALL NULL NULL NULL NULL 10 Using join buffer (incremental, BNL join) -1 PRIMARY C ALL NULL NULL NULL NULL 10 Using where; Using join buffer (incremental, BNL join) -1 PRIMARY D hash_ALL NULL #hash#$hj 5 test.E.a 10 Using where; End temporary; Using join buffer (incremental, BNLH join) +1 PRIMARY C ALL NULL NULL NULL NULL 10 Using where; End temporary; Using join buffer (incremental, BNL join) 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); count(*) diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result index 29e7e11f0ba..cef56e27d91 100644 --- a/mysql-test/main/subselect4.result +++ b/mysql-test/main/subselect4.result @@ -20,8 +20,8 @@ WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE 1 = (SELECT MIN(t2.b) FROM t3)) ORDER BY count(*); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL a 5 NULL 2 Using index -2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where -3 DEPENDENT SUBQUERY t3 system NULL NULL NULL NULL 0 Const row not found +2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where +3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL no matching row in const table # should not crash the next statement SELECT 1 FROM t1 WHERE NOT EXISTS (SELECT 1 FROM t2 WHERE 1 = (SELECT MIN(t2.b) FROM t3)) diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result index 3be4f07b8ca..3750c96871b 100644 --- a/mysql-test/main/subselect_no_exists_to_in.result +++ b/mysql-test/main/subselect_no_exists_to_in.result @@ -122,27 +122,27 @@ ROW(1,2,3) > (SELECT 1,2,1) SELECT ROW(1,2,3) = (SELECT 1,2,NULL); ROW(1,2,3) = (SELECT 1,2,NULL) NULL -SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a'); -(SELECT 1.5,2,'a') = ROW(1.5,2,'a') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a') AS m; +m 1 -SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b'); -(SELECT 1.5,2,'a') = ROW(1.5,2,'b') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b') AS m; +m 0 -SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b'); -(SELECT 1.5,2,'a') = ROW('1.5b',2,'b') +SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DOUBLE value: '1.5b' -SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a'); -(SELECT 'b',2,'a') = ROW(1.5,2,'a') +SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DOUBLE value: 'b' -SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a'); -(SELECT 1.5,2,'a') = ROW(1.5,'2','a') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a') AS m; +m 1 -SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a'); -(SELECT 1.5,'c','a') = ROW(1.5,2,'a') +SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DECIMAL value: 'c' @@ -232,19 +232,26 @@ a 2 select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a < t1.a) order by 1 desc limit 1); a -select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; -b (select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) +select +b, +(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) as m +from t4; +b m 8 7.5000 8 4.5000 9 7.5000 -explain extended select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; +explain extended +select +b, +(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) as m +from t4; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t4 ALL NULL NULL NULL NULL 3 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1276 Field or reference 'test.t4.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`t4`.`b` AS `b`,<expr_cache><`test`.`t4`.`a`>((/* select#2 */ select avg(`test`.`t2`.`a` + (/* select#3 */ select min(`test`.`t3`.`a`) from `test`.`t3` where `test`.`t3`.`a` >= `test`.`t4`.`a`)) from `test`.`t2`)) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` +Note 1003 /* select#1 */ select `test`.`t4`.`b` AS `b`,<expr_cache><`test`.`t4`.`a`>((/* select#2 */ select avg(`test`.`t2`.`a` + (/* select#3 */ select min(`test`.`t3`.`a`) from `test`.`t3` where `test`.`t3`.`a` >= `test`.`t4`.`a`)) from `test`.`t2`)) AS `m` from `test`.`t4` select * from t3 where exists (select * from t2 where t2.b=t3.a); a 7 @@ -311,21 +318,34 @@ select b,max(a) as ma from t4 group by b having b >= (select max(t2.a) from t2 w b ma 7 12 create table t5 (a int); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 insert into t5 values (5); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 insert into t5 values (2); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 -explain extended select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +explain extended +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 100.00 @@ -334,7 +354,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select <expr_cache><`test`.`t2`.`a`>((/* select#2 */ select 2 from dual where 2 = `test`.`t2`.`a` union /* select#3 */ select `test`.`t5`.`a` from `test`.`t5` where `test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` +Note 1003 /* select#1 */ select <expr_cache><`test`.`t2`.`a`>((/* select#2 */ select 2 from dual where 2 = `test`.`t2`.`a` union /* select#3 */ select `test`.`t5`.`a` from `test`.`t5` where `test`.`t5`.`a` = `test`.`t2`.`a`)) AS `m`,`test`.`t2`.`a` AS `a` from `test`.`t2` select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subquery returns more than 1 row create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); @@ -490,8 +510,11 @@ SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING t mot topic date pseudo joce 40143 2002-10-22 joce joce 43506 2002-10-22 joce -SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) from t2; -mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) +SELECT +*, +topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) AS m +FROM t2; +mot topic date pseudo m joce 40143 2002-10-22 joce 1 joce 43506 2002-10-22 joce 1 SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2); @@ -509,8 +532,11 @@ joce 40143 2002-10-22 joce SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); mot topic date pseudo joce 40143 2002-10-22 joce -SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) from t2; -mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) +SELECT +*, +topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) AS m +FROM t2; +mot topic date pseudo m joce 40143 2002-10-22 joce 1 joce 43506 2002-10-22 joce 0 drop table t1,t2; @@ -894,6 +920,25 @@ NULL select 1.5 > ANY (SELECT * from t1); 1.5 > ANY (SELECT * from t1) NULL +update t1 set a=NULL where a=2.5; +select 1.5 IN (SELECT * from t1); +1.5 IN (SELECT * from t1) +1 +select 3.5 IN (SELECT * from t1); +3.5 IN (SELECT * from t1) +1 +select 10.5 IN (SELECT * from t1); +10.5 IN (SELECT * from t1) +NULL +select 1.5 > ALL (SELECT * from t1); +1.5 > ALL (SELECT * from t1) +0 +select 10.5 > ALL (SELECT * from t1); +10.5 > ALL (SELECT * from t1) +NULL +select 1.5 > ANY (SELECT * from t1); +1.5 > ANY (SELECT * from t1) +NULL select 10.5 > ANY (SELECT * from t1); 10.5 > ANY (SELECT * from t1) 1 @@ -904,6 +949,20 @@ Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1249 Select 2 was reduced during optimization Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` +explain extended select (select a+1) from t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` +explain extended select (select a+1) from t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` select (select a+1) from t1; (select a+1) 2.5 @@ -1551,8 +1610,8 @@ create table t3 (a int, b int); insert into t1 values (0,100),(1,2), (1,3), (2,2), (2,7), (2,-1), (3,10); insert into t2 values (0,0), (1,1), (2,1), (3,1), (4,1); insert into t3 values (3,3), (2,2), (1,1); -select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3; -a (select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) +select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) as m from t3; +a m 3 1 2 2 1 2 @@ -1750,8 +1809,8 @@ CREATE TABLE `t3` (`taskgenid` mediumint(9) NOT NULL auto_increment,`dbid` int(1 INSERT INTO `t3` (`taskgenid`, `dbid`, `taskid`, `mon`, `tues`,`wed`, `thur`, `fri`, `sat`, `sun`, `how_often`, `userid`, `active`) VALUES (1,-1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1); CREATE TABLE `t4` (`task_id` smallint(6) NOT NULL default '0',`description` varchar(200) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1; INSERT INTO `t4` (`task_id`, `description`) VALUES (1, 'Daily Check List'),(2, 'Weekly Status'); -select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid; -dbid name (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') +select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') as m FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') as m from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid; +dbid name m -1 Valid 1 -1 Valid 2 1 -1 Should Not Return 0 @@ -3812,9 +3871,10 @@ SELECT (SELECT COUNT(DISTINCT t1.b) from t2) FROM t1 GROUP BY t1.a; 2 1 1 -SELECT (SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) +SELECT +(SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) AS m FROM t1 GROUP BY t1.a; -(SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) +m 2 1 1 @@ -3824,9 +3884,9 @@ COUNT(DISTINCT t1.b) (SELECT COUNT(DISTINCT t1.b)) 1 1 1 1 SELECT COUNT(DISTINCT t1.b), -(SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) +(SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) AS m FROM t1 GROUP BY t1.a; -COUNT(DISTINCT t1.b) (SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) +COUNT(DISTINCT t1.b) m 2 2 1 1 1 1 @@ -3850,16 +3910,10 @@ SELECT ( SELECT COUNT(DISTINCT t1.b) ) ) -FROM t1 GROUP BY t1.a LIMIT 1) +FROM t1 GROUP BY t1.a LIMIT 1) AS m FROM t1 t2 GROUP BY t2.a; -( -SELECT ( -SELECT ( -SELECT COUNT(DISTINCT t1.b) -) -) -FROM t1 GROUP BY t1.a LIMIT 1) +m 2 2 2 @@ -6455,11 +6509,10 @@ CREATE TABLE t3 (a int, b int); INSERT INTO t3 VALUES (10,7), (0,7); SELECT SUM(DISTINCT b), (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 -WHERE t.a != 0 AND t2.a != 0) +WHERE t.a != 0 AND t2.a != 0) AS m FROM (SELECT * FROM t3) AS t GROUP BY 2; -SUM(DISTINCT b) (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 -WHERE t.a != 0 AND t2.a != 0) +SUM(DISTINCT b) m 7 NULL SELECT SUM(DISTINCT b), (SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) @@ -6592,66 +6645,93 @@ CREATE TABLE t3 (f3a int default 1, f3b int default 2); INSERT INTO t3 VALUES (1,1),(2,2); set @old_optimizer_switch = @@session.optimizer_switch; set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off,subquery_cache=off,semijoin=off'; -SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m; +m NULL -SELECT (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m; +m NULL set @@session.optimizer_switch=@old_optimizer_switch; -SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m; +m NULL -SELECT (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2; +SELECT +(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2 AS m; (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m; +m NULL select (null, null) = (null, null); (null, null) = (null, null) @@ -6697,8 +6777,10 @@ INSERT INTO t2 VALUES (1); CREATE TABLE t3 ( c INT ); INSERT INTO t3 VALUES (4),(5); SET optimizer_switch='subquery_cache=off'; -SELECT ( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1; -( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) +SELECT +( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) AS m +FROM t1; +m 1 NULL SELECT ( SELECT b FROM t2 WHERE b = a OR b * 0) FROM t1; @@ -6915,7 +6997,9 @@ CREATE TABLE t3 (c INT); INSERT INTO t3 VALUES (8),(3); set @@expensive_subquery_limit= 0; EXPLAIN -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 ALL NULL NULL NULL NULL 2 @@ -6925,9 +7009,11 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 flush status; -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; -(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +m NULL NULL NULL @@ -6953,7 +7039,9 @@ Handler_read_rnd_deleted 0 Handler_read_rnd_next 22 set @@expensive_subquery_limit= default; EXPLAIN -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 ALL NULL NULL NULL NULL 2 @@ -6963,9 +7051,11 @@ id select_type table type possible_keys key key_len ref rows Extra 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 flush status; -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; -(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +m NULL NULL NULL diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result index a47e2977774..f837e20be8b 100644 --- a/mysql-test/main/subselect_no_mat.result +++ b/mysql-test/main/subselect_no_mat.result @@ -125,27 +125,27 @@ ROW(1,2,3) > (SELECT 1,2,1) SELECT ROW(1,2,3) = (SELECT 1,2,NULL); ROW(1,2,3) = (SELECT 1,2,NULL) NULL -SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a'); -(SELECT 1.5,2,'a') = ROW(1.5,2,'a') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a') AS m; +m 1 -SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b'); -(SELECT 1.5,2,'a') = ROW(1.5,2,'b') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b') AS m; +m 0 -SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b'); -(SELECT 1.5,2,'a') = ROW('1.5b',2,'b') +SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DOUBLE value: '1.5b' -SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a'); -(SELECT 'b',2,'a') = ROW(1.5,2,'a') +SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DOUBLE value: 'b' -SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a'); -(SELECT 1.5,2,'a') = ROW(1.5,'2','a') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a') AS m; +m 1 -SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a'); -(SELECT 1.5,'c','a') = ROW(1.5,2,'a') +SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DECIMAL value: 'c' @@ -235,19 +235,26 @@ a 2 select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a < t1.a) order by 1 desc limit 1); a -select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; -b (select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) +select +b, +(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) as m +from t4; +b m 8 7.5000 8 4.5000 9 7.5000 -explain extended select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; +explain extended +select +b, +(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) as m +from t4; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t4 ALL NULL NULL NULL NULL 3 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1276 Field or reference 'test.t4.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`t4`.`b` AS `b`,<expr_cache><`test`.`t4`.`a`>((/* select#2 */ select avg(`test`.`t2`.`a` + (/* select#3 */ select min(`test`.`t3`.`a`) from `test`.`t3` where `test`.`t3`.`a` >= `test`.`t4`.`a`)) from `test`.`t2`)) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` +Note 1003 /* select#1 */ select `test`.`t4`.`b` AS `b`,<expr_cache><`test`.`t4`.`a`>((/* select#2 */ select avg(`test`.`t2`.`a` + (/* select#3 */ select min(`test`.`t3`.`a`) from `test`.`t3` where `test`.`t3`.`a` >= `test`.`t4`.`a`)) from `test`.`t2`)) AS `m` from `test`.`t4` select * from t3 where exists (select * from t2 where t2.b=t3.a); a 7 @@ -314,21 +321,34 @@ select b,max(a) as ma from t4 group by b having b >= (select max(t2.a) from t2 w b ma 7 12 create table t5 (a int); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 insert into t5 values (5); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 insert into t5 values (2); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 -explain extended select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +explain extended +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 100.00 @@ -337,7 +357,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select <expr_cache><`test`.`t2`.`a`>((/* select#2 */ select 2 from dual where 2 = `test`.`t2`.`a` union /* select#3 */ select `test`.`t5`.`a` from `test`.`t5` where `test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` +Note 1003 /* select#1 */ select <expr_cache><`test`.`t2`.`a`>((/* select#2 */ select 2 from dual where 2 = `test`.`t2`.`a` union /* select#3 */ select `test`.`t5`.`a` from `test`.`t5` where `test`.`t5`.`a` = `test`.`t2`.`a`)) AS `m`,`test`.`t2`.`a` AS `a` from `test`.`t2` select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subquery returns more than 1 row create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); @@ -493,8 +513,11 @@ SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING t mot topic date pseudo joce 40143 2002-10-22 joce joce 43506 2002-10-22 joce -SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) from t2; -mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) +SELECT +*, +topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) AS m +FROM t2; +mot topic date pseudo m joce 40143 2002-10-22 joce 1 joce 43506 2002-10-22 joce 1 SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2); @@ -512,8 +535,11 @@ joce 40143 2002-10-22 joce SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); mot topic date pseudo joce 40143 2002-10-22 joce -SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) from t2; -mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) +SELECT +*, +topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) AS m +FROM t2; +mot topic date pseudo m joce 40143 2002-10-22 joce 1 joce 43506 2002-10-22 joce 0 drop table t1,t2; @@ -897,6 +923,25 @@ NULL select 1.5 > ANY (SELECT * from t1); 1.5 > ANY (SELECT * from t1) NULL +update t1 set a=NULL where a=2.5; +select 1.5 IN (SELECT * from t1); +1.5 IN (SELECT * from t1) +1 +select 3.5 IN (SELECT * from t1); +3.5 IN (SELECT * from t1) +1 +select 10.5 IN (SELECT * from t1); +10.5 IN (SELECT * from t1) +NULL +select 1.5 > ALL (SELECT * from t1); +1.5 > ALL (SELECT * from t1) +0 +select 10.5 > ALL (SELECT * from t1); +10.5 > ALL (SELECT * from t1) +NULL +select 1.5 > ANY (SELECT * from t1); +1.5 > ANY (SELECT * from t1) +NULL select 10.5 > ANY (SELECT * from t1); 10.5 > ANY (SELECT * from t1) 1 @@ -907,6 +952,20 @@ Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1249 Select 2 was reduced during optimization Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` +explain extended select (select a+1) from t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` +explain extended select (select a+1) from t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` select (select a+1) from t1; (select a+1) 2.5 @@ -1554,8 +1613,8 @@ create table t3 (a int, b int); insert into t1 values (0,100),(1,2), (1,3), (2,2), (2,7), (2,-1), (3,10); insert into t2 values (0,0), (1,1), (2,1), (3,1), (4,1); insert into t3 values (3,3), (2,2), (1,1); -select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3; -a (select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) +select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) as m from t3; +a m 3 1 2 2 1 2 @@ -1753,8 +1812,8 @@ CREATE TABLE `t3` (`taskgenid` mediumint(9) NOT NULL auto_increment,`dbid` int(1 INSERT INTO `t3` (`taskgenid`, `dbid`, `taskid`, `mon`, `tues`,`wed`, `thur`, `fri`, `sat`, `sun`, `how_often`, `userid`, `active`) VALUES (1,-1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1); CREATE TABLE `t4` (`task_id` smallint(6) NOT NULL default '0',`description` varchar(200) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1; INSERT INTO `t4` (`task_id`, `description`) VALUES (1, 'Daily Check List'),(2, 'Weekly Status'); -select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid; -dbid name (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') +select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') as m FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') as m from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid; +dbid name m -1 Valid 1 -1 Valid 2 1 -1 Should Not Return 0 @@ -3812,9 +3871,10 @@ SELECT (SELECT COUNT(DISTINCT t1.b) from t2) FROM t1 GROUP BY t1.a; 2 1 1 -SELECT (SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) +SELECT +(SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) AS m FROM t1 GROUP BY t1.a; -(SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) +m 2 1 1 @@ -3824,9 +3884,9 @@ COUNT(DISTINCT t1.b) (SELECT COUNT(DISTINCT t1.b)) 1 1 1 1 SELECT COUNT(DISTINCT t1.b), -(SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) +(SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) AS m FROM t1 GROUP BY t1.a; -COUNT(DISTINCT t1.b) (SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) +COUNT(DISTINCT t1.b) m 2 2 1 1 1 1 @@ -3850,16 +3910,10 @@ SELECT ( SELECT COUNT(DISTINCT t1.b) ) ) -FROM t1 GROUP BY t1.a LIMIT 1) +FROM t1 GROUP BY t1.a LIMIT 1) AS m FROM t1 t2 GROUP BY t2.a; -( -SELECT ( -SELECT ( -SELECT COUNT(DISTINCT t1.b) -) -) -FROM t1 GROUP BY t1.a LIMIT 1) +m 2 2 2 @@ -6452,11 +6506,10 @@ CREATE TABLE t3 (a int, b int); INSERT INTO t3 VALUES (10,7), (0,7); SELECT SUM(DISTINCT b), (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 -WHERE t.a != 0 AND t2.a != 0) +WHERE t.a != 0 AND t2.a != 0) AS m FROM (SELECT * FROM t3) AS t GROUP BY 2; -SUM(DISTINCT b) (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 -WHERE t.a != 0 AND t2.a != 0) +SUM(DISTINCT b) m 7 NULL SELECT SUM(DISTINCT b), (SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) @@ -6589,66 +6642,93 @@ CREATE TABLE t3 (f3a int default 1, f3b int default 2); INSERT INTO t3 VALUES (1,1),(2,2); set @old_optimizer_switch = @@session.optimizer_switch; set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off,subquery_cache=off,semijoin=off'; -SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m; +m NULL -SELECT (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m; +m NULL set @@session.optimizer_switch=@old_optimizer_switch; -SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m; +m NULL -SELECT (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2; +SELECT +(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2 AS m; (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m; +m NULL select (null, null) = (null, null); (null, null) = (null, null) @@ -6694,8 +6774,10 @@ INSERT INTO t2 VALUES (1); CREATE TABLE t3 ( c INT ); INSERT INTO t3 VALUES (4),(5); SET optimizer_switch='subquery_cache=off'; -SELECT ( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1; -( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) +SELECT +( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) AS m +FROM t1; +m 1 NULL SELECT ( SELECT b FROM t2 WHERE b = a OR b * 0) FROM t1; @@ -6911,7 +6993,9 @@ CREATE TABLE t3 (c INT); INSERT INTO t3 VALUES (8),(3); set @@expensive_subquery_limit= 0; EXPLAIN -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 ALL NULL NULL NULL NULL 2 @@ -6921,9 +7005,11 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 flush status; -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; -(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +m NULL NULL NULL @@ -6949,7 +7035,9 @@ Handler_read_rnd_deleted 0 Handler_read_rnd_next 22 set @@expensive_subquery_limit= default; EXPLAIN -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 ALL NULL NULL NULL NULL 2 @@ -6959,9 +7047,11 @@ id select_type table type possible_keys key key_len ref rows Extra 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 flush status; -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; -(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +m NULL NULL NULL diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result index 10153b0f60c..e2352090797 100644 --- a/mysql-test/main/subselect_no_opts.result +++ b/mysql-test/main/subselect_no_opts.result @@ -121,27 +121,27 @@ ROW(1,2,3) > (SELECT 1,2,1) SELECT ROW(1,2,3) = (SELECT 1,2,NULL); ROW(1,2,3) = (SELECT 1,2,NULL) NULL -SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a'); -(SELECT 1.5,2,'a') = ROW(1.5,2,'a') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a') AS m; +m 1 -SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b'); -(SELECT 1.5,2,'a') = ROW(1.5,2,'b') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b') AS m; +m 0 -SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b'); -(SELECT 1.5,2,'a') = ROW('1.5b',2,'b') +SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DOUBLE value: '1.5b' -SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a'); -(SELECT 'b',2,'a') = ROW(1.5,2,'a') +SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DOUBLE value: 'b' -SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a'); -(SELECT 1.5,2,'a') = ROW(1.5,'2','a') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a') AS m; +m 1 -SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a'); -(SELECT 1.5,'c','a') = ROW(1.5,2,'a') +SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DECIMAL value: 'c' @@ -231,19 +231,26 @@ a 2 select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a < t1.a) order by 1 desc limit 1); a -select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; -b (select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) +select +b, +(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) as m +from t4; +b m 8 7.5000 8 4.5000 9 7.5000 -explain extended select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; +explain extended +select +b, +(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) as m +from t4; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t4 ALL NULL NULL NULL NULL 3 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1276 Field or reference 'test.t4.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`t4`.`b` AS `b`,(/* select#2 */ select avg(`test`.`t2`.`a` + (/* select#3 */ select min(`test`.`t3`.`a`) from `test`.`t3` where `test`.`t3`.`a` >= `test`.`t4`.`a`)) from `test`.`t2`) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` +Note 1003 /* select#1 */ select `test`.`t4`.`b` AS `b`,(/* select#2 */ select avg(`test`.`t2`.`a` + (/* select#3 */ select min(`test`.`t3`.`a`) from `test`.`t3` where `test`.`t3`.`a` >= `test`.`t4`.`a`)) from `test`.`t2`) AS `m` from `test`.`t4` select * from t3 where exists (select * from t2 where t2.b=t3.a); a 7 @@ -310,21 +317,34 @@ select b,max(a) as ma from t4 group by b having b >= (select max(t2.a) from t2 w b ma 7 12 create table t5 (a int); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 insert into t5 values (5); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 insert into t5 values (2); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 -explain extended select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +explain extended +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 100.00 @@ -333,7 +353,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select (/* select#2 */ select 2 from dual where 2 = `test`.`t2`.`a` union /* select#3 */ select `test`.`t5`.`a` from `test`.`t5` where `test`.`t5`.`a` = `test`.`t2`.`a`) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` +Note 1003 /* select#1 */ select (/* select#2 */ select 2 from dual where 2 = `test`.`t2`.`a` union /* select#3 */ select `test`.`t5`.`a` from `test`.`t5` where `test`.`t5`.`a` = `test`.`t2`.`a`) AS `m`,`test`.`t2`.`a` AS `a` from `test`.`t2` select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subquery returns more than 1 row create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); @@ -489,8 +509,11 @@ SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING t mot topic date pseudo joce 40143 2002-10-22 joce joce 43506 2002-10-22 joce -SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) from t2; -mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) +SELECT +*, +topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) AS m +FROM t2; +mot topic date pseudo m joce 40143 2002-10-22 joce 1 joce 43506 2002-10-22 joce 1 SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2); @@ -508,8 +531,11 @@ joce 40143 2002-10-22 joce SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); mot topic date pseudo joce 40143 2002-10-22 joce -SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) from t2; -mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) +SELECT +*, +topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) AS m +FROM t2; +mot topic date pseudo m joce 40143 2002-10-22 joce 1 joce 43506 2002-10-22 joce 0 drop table t1,t2; @@ -893,6 +919,25 @@ NULL select 1.5 > ANY (SELECT * from t1); 1.5 > ANY (SELECT * from t1) NULL +update t1 set a=NULL where a=2.5; +select 1.5 IN (SELECT * from t1); +1.5 IN (SELECT * from t1) +1 +select 3.5 IN (SELECT * from t1); +3.5 IN (SELECT * from t1) +1 +select 10.5 IN (SELECT * from t1); +10.5 IN (SELECT * from t1) +NULL +select 1.5 > ALL (SELECT * from t1); +1.5 > ALL (SELECT * from t1) +0 +select 10.5 > ALL (SELECT * from t1); +10.5 > ALL (SELECT * from t1) +NULL +select 1.5 > ANY (SELECT * from t1); +1.5 > ANY (SELECT * from t1) +NULL select 10.5 > ANY (SELECT * from t1); 10.5 > ANY (SELECT * from t1) 1 @@ -903,6 +948,20 @@ Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1249 Select 2 was reduced during optimization Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` +explain extended select (select a+1) from t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` +explain extended select (select a+1) from t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` select (select a+1) from t1; (select a+1) 2.5 @@ -1550,8 +1609,8 @@ create table t3 (a int, b int); insert into t1 values (0,100),(1,2), (1,3), (2,2), (2,7), (2,-1), (3,10); insert into t2 values (0,0), (1,1), (2,1), (3,1), (4,1); insert into t3 values (3,3), (2,2), (1,1); -select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3; -a (select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) +select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) as m from t3; +a m 3 1 2 2 1 2 @@ -1749,8 +1808,8 @@ CREATE TABLE `t3` (`taskgenid` mediumint(9) NOT NULL auto_increment,`dbid` int(1 INSERT INTO `t3` (`taskgenid`, `dbid`, `taskid`, `mon`, `tues`,`wed`, `thur`, `fri`, `sat`, `sun`, `how_often`, `userid`, `active`) VALUES (1,-1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1); CREATE TABLE `t4` (`task_id` smallint(6) NOT NULL default '0',`description` varchar(200) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1; INSERT INTO `t4` (`task_id`, `description`) VALUES (1, 'Daily Check List'),(2, 'Weekly Status'); -select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid; -dbid name (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') +select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') as m FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') as m from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid; +dbid name m -1 Valid 1 -1 Valid 2 1 -1 Should Not Return 0 @@ -3808,9 +3867,10 @@ SELECT (SELECT COUNT(DISTINCT t1.b) from t2) FROM t1 GROUP BY t1.a; 2 1 1 -SELECT (SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) +SELECT +(SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) AS m FROM t1 GROUP BY t1.a; -(SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) +m 2 1 1 @@ -3820,9 +3880,9 @@ COUNT(DISTINCT t1.b) (SELECT COUNT(DISTINCT t1.b)) 1 1 1 1 SELECT COUNT(DISTINCT t1.b), -(SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) +(SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) AS m FROM t1 GROUP BY t1.a; -COUNT(DISTINCT t1.b) (SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) +COUNT(DISTINCT t1.b) m 2 2 1 1 1 1 @@ -3846,16 +3906,10 @@ SELECT ( SELECT COUNT(DISTINCT t1.b) ) ) -FROM t1 GROUP BY t1.a LIMIT 1) +FROM t1 GROUP BY t1.a LIMIT 1) AS m FROM t1 t2 GROUP BY t2.a; -( -SELECT ( -SELECT ( -SELECT COUNT(DISTINCT t1.b) -) -) -FROM t1 GROUP BY t1.a LIMIT 1) +m 2 2 2 @@ -6448,11 +6502,10 @@ CREATE TABLE t3 (a int, b int); INSERT INTO t3 VALUES (10,7), (0,7); SELECT SUM(DISTINCT b), (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 -WHERE t.a != 0 AND t2.a != 0) +WHERE t.a != 0 AND t2.a != 0) AS m FROM (SELECT * FROM t3) AS t GROUP BY 2; -SUM(DISTINCT b) (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 -WHERE t.a != 0 AND t2.a != 0) +SUM(DISTINCT b) m 7 NULL SELECT SUM(DISTINCT b), (SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) @@ -6585,66 +6638,93 @@ CREATE TABLE t3 (f3a int default 1, f3b int default 2); INSERT INTO t3 VALUES (1,1),(2,2); set @old_optimizer_switch = @@session.optimizer_switch; set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off,subquery_cache=off,semijoin=off'; -SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m; +m NULL -SELECT (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m; +m NULL set @@session.optimizer_switch=@old_optimizer_switch; -SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m; +m NULL -SELECT (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2; +SELECT +(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2 AS m; (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m; +m NULL select (null, null) = (null, null); (null, null) = (null, null) @@ -6690,8 +6770,10 @@ INSERT INTO t2 VALUES (1); CREATE TABLE t3 ( c INT ); INSERT INTO t3 VALUES (4),(5); SET optimizer_switch='subquery_cache=off'; -SELECT ( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1; -( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) +SELECT +( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) AS m +FROM t1; +m 1 NULL SELECT ( SELECT b FROM t2 WHERE b = a OR b * 0) FROM t1; @@ -6908,7 +6990,9 @@ CREATE TABLE t3 (c INT); INSERT INTO t3 VALUES (8),(3); set @@expensive_subquery_limit= 0; EXPLAIN -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 ALL NULL NULL NULL NULL 2 @@ -6918,9 +7002,11 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 flush status; -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; -(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +m NULL NULL NULL @@ -6946,7 +7032,9 @@ Handler_read_rnd_deleted 0 Handler_read_rnd_next 22 set @@expensive_subquery_limit= default; EXPLAIN -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 ALL NULL NULL NULL NULL 2 @@ -6956,9 +7044,11 @@ id select_type table type possible_keys key key_len ref rows Extra 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 flush status; -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; -(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +m NULL NULL NULL diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result index 456d1dec846..0e5216eb120 100644 --- a/mysql-test/main/subselect_no_scache.result +++ b/mysql-test/main/subselect_no_scache.result @@ -124,27 +124,27 @@ ROW(1,2,3) > (SELECT 1,2,1) SELECT ROW(1,2,3) = (SELECT 1,2,NULL); ROW(1,2,3) = (SELECT 1,2,NULL) NULL -SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a'); -(SELECT 1.5,2,'a') = ROW(1.5,2,'a') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a') AS m; +m 1 -SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b'); -(SELECT 1.5,2,'a') = ROW(1.5,2,'b') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b') AS m; +m 0 -SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b'); -(SELECT 1.5,2,'a') = ROW('1.5b',2,'b') +SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DOUBLE value: '1.5b' -SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a'); -(SELECT 'b',2,'a') = ROW(1.5,2,'a') +SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DOUBLE value: 'b' -SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a'); -(SELECT 1.5,2,'a') = ROW(1.5,'2','a') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a') AS m; +m 1 -SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a'); -(SELECT 1.5,'c','a') = ROW(1.5,2,'a') +SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DECIMAL value: 'c' @@ -234,19 +234,26 @@ a 2 select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a < t1.a) order by 1 desc limit 1); a -select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; -b (select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) +select +b, +(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) as m +from t4; +b m 8 7.5000 8 4.5000 9 7.5000 -explain extended select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; +explain extended +select +b, +(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) as m +from t4; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t4 ALL NULL NULL NULL NULL 3 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1276 Field or reference 'test.t4.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`t4`.`b` AS `b`,(/* select#2 */ select avg(`test`.`t2`.`a` + (/* select#3 */ select min(`test`.`t3`.`a`) from `test`.`t3` where `test`.`t3`.`a` >= `test`.`t4`.`a`)) from `test`.`t2`) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` +Note 1003 /* select#1 */ select `test`.`t4`.`b` AS `b`,(/* select#2 */ select avg(`test`.`t2`.`a` + (/* select#3 */ select min(`test`.`t3`.`a`) from `test`.`t3` where `test`.`t3`.`a` >= `test`.`t4`.`a`)) from `test`.`t2`) AS `m` from `test`.`t4` select * from t3 where exists (select * from t2 where t2.b=t3.a); a 7 @@ -313,21 +320,34 @@ select b,max(a) as ma from t4 group by b having b >= (select max(t2.a) from t2 w b ma 7 12 create table t5 (a int); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 insert into t5 values (5); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 insert into t5 values (2); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 -explain extended select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +explain extended +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 100.00 @@ -336,7 +356,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select (/* select#2 */ select 2 from dual where 2 = `test`.`t2`.`a` union /* select#3 */ select `test`.`t5`.`a` from `test`.`t5` where `test`.`t5`.`a` = `test`.`t2`.`a`) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` +Note 1003 /* select#1 */ select (/* select#2 */ select 2 from dual where 2 = `test`.`t2`.`a` union /* select#3 */ select `test`.`t5`.`a` from `test`.`t5` where `test`.`t5`.`a` = `test`.`t2`.`a`) AS `m`,`test`.`t2`.`a` AS `a` from `test`.`t2` select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subquery returns more than 1 row create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); @@ -492,8 +512,11 @@ SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING t mot topic date pseudo joce 40143 2002-10-22 joce joce 43506 2002-10-22 joce -SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) from t2; -mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) +SELECT +*, +topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) AS m +FROM t2; +mot topic date pseudo m joce 40143 2002-10-22 joce 1 joce 43506 2002-10-22 joce 1 SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2); @@ -511,8 +534,11 @@ joce 40143 2002-10-22 joce SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); mot topic date pseudo joce 40143 2002-10-22 joce -SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) from t2; -mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) +SELECT +*, +topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) AS m +FROM t2; +mot topic date pseudo m joce 40143 2002-10-22 joce 1 joce 43506 2002-10-22 joce 0 drop table t1,t2; @@ -896,6 +922,25 @@ NULL select 1.5 > ANY (SELECT * from t1); 1.5 > ANY (SELECT * from t1) NULL +update t1 set a=NULL where a=2.5; +select 1.5 IN (SELECT * from t1); +1.5 IN (SELECT * from t1) +1 +select 3.5 IN (SELECT * from t1); +3.5 IN (SELECT * from t1) +1 +select 10.5 IN (SELECT * from t1); +10.5 IN (SELECT * from t1) +NULL +select 1.5 > ALL (SELECT * from t1); +1.5 > ALL (SELECT * from t1) +0 +select 10.5 > ALL (SELECT * from t1); +10.5 > ALL (SELECT * from t1) +NULL +select 1.5 > ANY (SELECT * from t1); +1.5 > ANY (SELECT * from t1) +NULL select 10.5 > ANY (SELECT * from t1); 10.5 > ANY (SELECT * from t1) 1 @@ -906,6 +951,20 @@ Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1249 Select 2 was reduced during optimization Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` +explain extended select (select a+1) from t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` +explain extended select (select a+1) from t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` select (select a+1) from t1; (select a+1) 2.5 @@ -1553,8 +1612,8 @@ create table t3 (a int, b int); insert into t1 values (0,100),(1,2), (1,3), (2,2), (2,7), (2,-1), (3,10); insert into t2 values (0,0), (1,1), (2,1), (3,1), (4,1); insert into t3 values (3,3), (2,2), (1,1); -select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3; -a (select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) +select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) as m from t3; +a m 3 1 2 2 1 2 @@ -1752,8 +1811,8 @@ CREATE TABLE `t3` (`taskgenid` mediumint(9) NOT NULL auto_increment,`dbid` int(1 INSERT INTO `t3` (`taskgenid`, `dbid`, `taskid`, `mon`, `tues`,`wed`, `thur`, `fri`, `sat`, `sun`, `how_often`, `userid`, `active`) VALUES (1,-1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1); CREATE TABLE `t4` (`task_id` smallint(6) NOT NULL default '0',`description` varchar(200) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1; INSERT INTO `t4` (`task_id`, `description`) VALUES (1, 'Daily Check List'),(2, 'Weekly Status'); -select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid; -dbid name (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') +select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') as m FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') as m from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid; +dbid name m -1 Valid 1 -1 Valid 2 1 -1 Should Not Return 0 @@ -3815,9 +3874,10 @@ SELECT (SELECT COUNT(DISTINCT t1.b) from t2) FROM t1 GROUP BY t1.a; 2 1 1 -SELECT (SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) +SELECT +(SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) AS m FROM t1 GROUP BY t1.a; -(SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) +m 2 1 1 @@ -3827,9 +3887,9 @@ COUNT(DISTINCT t1.b) (SELECT COUNT(DISTINCT t1.b)) 1 1 1 1 SELECT COUNT(DISTINCT t1.b), -(SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) +(SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) AS m FROM t1 GROUP BY t1.a; -COUNT(DISTINCT t1.b) (SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) +COUNT(DISTINCT t1.b) m 2 2 1 1 1 1 @@ -3853,16 +3913,10 @@ SELECT ( SELECT COUNT(DISTINCT t1.b) ) ) -FROM t1 GROUP BY t1.a LIMIT 1) +FROM t1 GROUP BY t1.a LIMIT 1) AS m FROM t1 t2 GROUP BY t2.a; -( -SELECT ( -SELECT ( -SELECT COUNT(DISTINCT t1.b) -) -) -FROM t1 GROUP BY t1.a LIMIT 1) +m 2 2 2 @@ -6459,11 +6513,10 @@ CREATE TABLE t3 (a int, b int); INSERT INTO t3 VALUES (10,7), (0,7); SELECT SUM(DISTINCT b), (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 -WHERE t.a != 0 AND t2.a != 0) +WHERE t.a != 0 AND t2.a != 0) AS m FROM (SELECT * FROM t3) AS t GROUP BY 2; -SUM(DISTINCT b) (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 -WHERE t.a != 0 AND t2.a != 0) +SUM(DISTINCT b) m 7 NULL SELECT SUM(DISTINCT b), (SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) @@ -6596,66 +6649,93 @@ CREATE TABLE t3 (f3a int default 1, f3b int default 2); INSERT INTO t3 VALUES (1,1),(2,2); set @old_optimizer_switch = @@session.optimizer_switch; set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off,subquery_cache=off,semijoin=off'; -SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m; +m NULL -SELECT (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m; +m NULL set @@session.optimizer_switch=@old_optimizer_switch; -SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m; +m NULL -SELECT (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2; +SELECT +(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2 AS m; (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m; +m NULL select (null, null) = (null, null); (null, null) = (null, null) @@ -6701,8 +6781,10 @@ INSERT INTO t2 VALUES (1); CREATE TABLE t3 ( c INT ); INSERT INTO t3 VALUES (4),(5); SET optimizer_switch='subquery_cache=off'; -SELECT ( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1; -( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) +SELECT +( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) AS m +FROM t1; +m 1 NULL SELECT ( SELECT b FROM t2 WHERE b = a OR b * 0) FROM t1; @@ -6919,7 +7001,9 @@ CREATE TABLE t3 (c INT); INSERT INTO t3 VALUES (8),(3); set @@expensive_subquery_limit= 0; EXPLAIN -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 ALL NULL NULL NULL NULL 2 @@ -6929,9 +7013,11 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 flush status; -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; -(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +m NULL NULL NULL @@ -6957,7 +7043,9 @@ Handler_read_rnd_deleted 0 Handler_read_rnd_next 58 set @@expensive_subquery_limit= default; EXPLAIN -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 ALL NULL NULL NULL NULL 2 @@ -6967,9 +7055,11 @@ id select_type table type possible_keys key key_len ref rows Extra 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 flush status; -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; -(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +m NULL NULL NULL diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result index eba0f55a072..c7acdc2990c 100644 --- a/mysql-test/main/subselect_no_semijoin.result +++ b/mysql-test/main/subselect_no_semijoin.result @@ -121,27 +121,27 @@ ROW(1,2,3) > (SELECT 1,2,1) SELECT ROW(1,2,3) = (SELECT 1,2,NULL); ROW(1,2,3) = (SELECT 1,2,NULL) NULL -SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a'); -(SELECT 1.5,2,'a') = ROW(1.5,2,'a') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'a') AS m; +m 1 -SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b'); -(SELECT 1.5,2,'a') = ROW(1.5,2,'b') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,2,'b') AS m; +m 0 -SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b'); -(SELECT 1.5,2,'a') = ROW('1.5b',2,'b') +SELECT (SELECT 1.5,2,'a') = ROW('1.5b',2,'b') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DOUBLE value: '1.5b' -SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a'); -(SELECT 'b',2,'a') = ROW(1.5,2,'a') +SELECT (SELECT 'b',2,'a') = ROW(1.5,2,'a') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DOUBLE value: 'b' -SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a'); -(SELECT 1.5,2,'a') = ROW(1.5,'2','a') +SELECT (SELECT 1.5,2,'a') = ROW(1.5,'2','a') AS m; +m 1 -SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a'); -(SELECT 1.5,'c','a') = ROW(1.5,2,'a') +SELECT (SELECT 1.5,'c','a') = ROW(1.5,2,'a') AS m; +m 0 Warnings: Warning 1292 Truncated incorrect DECIMAL value: 'c' @@ -231,19 +231,26 @@ a 2 select * from t1 where t1.a=(select t2.a from t2 where t2.b=(select max(a) from t3 where t3.a < t1.a) order by 1 desc limit 1); a -select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; -b (select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) +select +b, +(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) as m +from t4; +b m 8 7.5000 8 4.5000 9 7.5000 -explain extended select b,(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) from t4; +explain extended +select +b, +(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2) as m +from t4; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t4 ALL NULL NULL NULL NULL 3 100.00 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 100.00 Using where Warnings: Note 1276 Field or reference 'test.t4.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select `test`.`t4`.`b` AS `b`,<expr_cache><`test`.`t4`.`a`>((/* select#2 */ select avg(`test`.`t2`.`a` + (/* select#3 */ select min(`test`.`t3`.`a`) from `test`.`t3` where `test`.`t3`.`a` >= `test`.`t4`.`a`)) from `test`.`t2`)) AS `(select avg(t2.a+(select min(t3.a) from t3 where t3.a >= t4.a)) from t2)` from `test`.`t4` +Note 1003 /* select#1 */ select `test`.`t4`.`b` AS `b`,<expr_cache><`test`.`t4`.`a`>((/* select#2 */ select avg(`test`.`t2`.`a` + (/* select#3 */ select min(`test`.`t3`.`a`) from `test`.`t3` where `test`.`t3`.`a` >= `test`.`t4`.`a`)) from `test`.`t2`)) AS `m` from `test`.`t4` select * from t3 where exists (select * from t2 where t2.b=t3.a); a 7 @@ -310,21 +317,34 @@ select b,max(a) as ma from t4 group by b having b >= (select max(t2.a) from t2 w b ma 7 12 create table t5 (a int); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 insert into t5 values (5); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 insert into t5 values (2); -select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; -(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) a +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; +m a NULL 1 2 2 -explain extended select (select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a), a from t2; +explain extended +select +(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a) as m, +a +from t2; id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 100.00 @@ -333,7 +353,7 @@ NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL Warnings: Note 1276 Field or reference 'test.t2.a' of SELECT #2 was resolved in SELECT #1 Note 1276 Field or reference 'test.t2.a' of SELECT #3 was resolved in SELECT #1 -Note 1003 /* select#1 */ select <expr_cache><`test`.`t2`.`a`>((/* select#2 */ select 2 from dual where 2 = `test`.`t2`.`a` union /* select#3 */ select `test`.`t5`.`a` from `test`.`t5` where `test`.`t5`.`a` = `test`.`t2`.`a`)) AS `(select a from t1 where t1.a=t2.a union select a from t5 where t5.a=t2.a)`,`test`.`t2`.`a` AS `a` from `test`.`t2` +Note 1003 /* select#1 */ select <expr_cache><`test`.`t2`.`a`>((/* select#2 */ select 2 from dual where 2 = `test`.`t2`.`a` union /* select#3 */ select `test`.`t5`.`a` from `test`.`t5` where `test`.`t5`.`a` = `test`.`t2`.`a`)) AS `m`,`test`.`t2`.`a` AS `a` from `test`.`t2` select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subquery returns more than 1 row create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); @@ -489,8 +509,11 @@ SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING t mot topic date pseudo joce 40143 2002-10-22 joce joce 43506 2002-10-22 joce -SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) from t2; -mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) +SELECT +*, +topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 4100) AS m +FROM t2; +mot topic date pseudo m joce 40143 2002-10-22 joce 1 joce 43506 2002-10-22 joce 1 SELECT * from t2 where topic = all (SELECT SUM(topic) FROM t2); @@ -508,8 +531,11 @@ joce 40143 2002-10-22 joce SELECT * from t2 where topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000); mot topic date pseudo joce 40143 2002-10-22 joce -SELECT *, topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) from t2; -mot topic date pseudo topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) +SELECT +*, +topic = all (SELECT topic FROM t2 GROUP BY topic HAVING topic < 41000) AS m +FROM t2; +mot topic date pseudo m joce 40143 2002-10-22 joce 1 joce 43506 2002-10-22 joce 0 drop table t1,t2; @@ -893,6 +919,25 @@ NULL select 1.5 > ANY (SELECT * from t1); 1.5 > ANY (SELECT * from t1) NULL +update t1 set a=NULL where a=2.5; +select 1.5 IN (SELECT * from t1); +1.5 IN (SELECT * from t1) +1 +select 3.5 IN (SELECT * from t1); +3.5 IN (SELECT * from t1) +1 +select 10.5 IN (SELECT * from t1); +10.5 IN (SELECT * from t1) +NULL +select 1.5 > ALL (SELECT * from t1); +1.5 > ALL (SELECT * from t1) +0 +select 10.5 > ALL (SELECT * from t1); +10.5 > ALL (SELECT * from t1) +NULL +select 1.5 > ANY (SELECT * from t1); +1.5 > ANY (SELECT * from t1) +NULL select 10.5 > ANY (SELECT * from t1); 10.5 > ANY (SELECT * from t1) 1 @@ -903,6 +948,20 @@ Warnings: Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 Note 1249 Select 2 was reduced during optimization Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` +explain extended select (select a+1) from t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` +explain extended select (select a+1) from t1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 ALL NULL NULL NULL NULL 3 100.00 +Warnings: +Note 1276 Field or reference 'test.t1.a' of SELECT #2 was resolved in SELECT #1 +Note 1249 Select 2 was reduced during optimization +Note 1003 select `test`.`t1`.`a` + 1 AS `(select a+1)` from `test`.`t1` select (select a+1) from t1; (select a+1) 2.5 @@ -1550,8 +1609,8 @@ create table t3 (a int, b int); insert into t1 values (0,100),(1,2), (1,3), (2,2), (2,7), (2,-1), (3,10); insert into t2 values (0,0), (1,1), (2,1), (3,1), (4,1); insert into t3 values (3,3), (2,2), (1,1); -select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) from t3; -a (select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) +select a,(select count(distinct t1.b) as sum from t1,t2 where t1.a=t2.a and t2.b > 0 and t1.a <= t3.b group by t1.a order by sum limit 1) as m from t3; +a m 3 1 2 2 1 2 @@ -1749,8 +1808,8 @@ CREATE TABLE `t3` (`taskgenid` mediumint(9) NOT NULL auto_increment,`dbid` int(1 INSERT INTO `t3` (`taskgenid`, `dbid`, `taskid`, `mon`, `tues`,`wed`, `thur`, `fri`, `sat`, `sun`, `how_often`, `userid`, `active`) VALUES (1,-1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 1); CREATE TABLE `t4` (`task_id` smallint(6) NOT NULL default '0',`description` varchar(200) NOT NULL default '') ENGINE=MyISAM CHARSET=latin1; INSERT INTO `t4` (`task_id`, `description`) VALUES (1, 'Daily Check List'),(2, 'Weekly Status'); -select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid; -dbid name (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') +select dbid, name, (date_format(now() , '%Y-%m-%d') - INTERVAL how_often DAY) >= ifnull((SELECT date_format(max(create_date),'%Y-%m-%d') as m FROM t1 WHERE dbid = b.db_id AND taskid = a.taskgenid), '1950-01-01') as m from t3 a, t2 b, t4 WHERE dbid = - 1 AND primary_uid = '1' AND t4.task_id = taskid; +dbid name m -1 Valid 1 -1 Valid 2 1 -1 Should Not Return 0 @@ -3808,9 +3867,10 @@ SELECT (SELECT COUNT(DISTINCT t1.b) from t2) FROM t1 GROUP BY t1.a; 2 1 1 -SELECT (SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) +SELECT +(SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) AS m FROM t1 GROUP BY t1.a; -(SELECT COUNT(DISTINCT t1.b) from t2 union select 1 from t2 where 12 < 3) +m 2 1 1 @@ -3820,9 +3880,9 @@ COUNT(DISTINCT t1.b) (SELECT COUNT(DISTINCT t1.b)) 1 1 1 1 SELECT COUNT(DISTINCT t1.b), -(SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) +(SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) AS m FROM t1 GROUP BY t1.a; -COUNT(DISTINCT t1.b) (SELECT COUNT(DISTINCT t1.b) union select 1 from DUAL where 12 < 3) +COUNT(DISTINCT t1.b) m 2 2 1 1 1 1 @@ -3846,16 +3906,10 @@ SELECT ( SELECT COUNT(DISTINCT t1.b) ) ) -FROM t1 GROUP BY t1.a LIMIT 1) +FROM t1 GROUP BY t1.a LIMIT 1) AS m FROM t1 t2 GROUP BY t2.a; -( -SELECT ( -SELECT ( -SELECT COUNT(DISTINCT t1.b) -) -) -FROM t1 GROUP BY t1.a LIMIT 1) +m 2 2 2 @@ -6448,11 +6502,10 @@ CREATE TABLE t3 (a int, b int); INSERT INTO t3 VALUES (10,7), (0,7); SELECT SUM(DISTINCT b), (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 -WHERE t.a != 0 AND t2.a != 0) +WHERE t.a != 0 AND t2.a != 0) AS m FROM (SELECT * FROM t3) AS t GROUP BY 2; -SUM(DISTINCT b) (SELECT t2.a FROM t1 JOIN t2 ON t2.c != 0 -WHERE t.a != 0 AND t2.a != 0) +SUM(DISTINCT b) m 7 NULL SELECT SUM(DISTINCT b), (SELECT t2.a FROM t1,t2 WHERE t.a != 0 or 1=2 LIMIT 1) @@ -6585,66 +6638,93 @@ CREATE TABLE t3 (f3a int default 1, f3b int default 2); INSERT INTO t3 VALUES (1,1),(2,2); set @old_optimizer_switch = @@session.optimizer_switch; set @@optimizer_switch='materialization=on,partial_match_rowid_merge=on,partial_match_table_scan=off,subquery_cache=off,semijoin=off'; -SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m; +m NULL -SELECT (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m; +m NULL set @@session.optimizer_switch=@old_optimizer_switch; -SELECT (SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) FROM t2; -(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) +SELECT +(SELECT f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) NOT IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) NOT IN (SELECT f1a, f1b FROM t1) AS m; +m NULL -SELECT (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2; +SELECT +(SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) FROM t2 AS m; (SELECT f3a FROM t3 where f3a > 3) IN (SELECT f1a FROM t1) NULL NULL -SELECT (SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) FROM t2; -(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) +SELECT +(SELECT f3a,f3a FROM t3 where f3a > 3) IN (SELECT f1a,f1a FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) FROM t2; -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m +FROM t2; +m NULL NULL -SELECT (SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1); -(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) +SELECT +(SELECT f3a, f3b FROM t3 where f3a > 3) IN (SELECT f1a, f1b FROM t1) AS m; +m NULL select (null, null) = (null, null); (null, null) = (null, null) @@ -6690,8 +6770,10 @@ INSERT INTO t2 VALUES (1); CREATE TABLE t3 ( c INT ); INSERT INTO t3 VALUES (4),(5); SET optimizer_switch='subquery_cache=off'; -SELECT ( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) FROM t1; -( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) +SELECT +( SELECT b FROM t2 WHERE b = a OR EXISTS ( SELECT c FROM t3 WHERE c = b ) ) AS m +FROM t1; +m 1 NULL SELECT ( SELECT b FROM t2 WHERE b = a OR b * 0) FROM t1; @@ -6908,7 +6990,9 @@ CREATE TABLE t3 (c INT); INSERT INTO t3 VALUES (8),(3); set @@expensive_subquery_limit= 0; EXPLAIN -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 ALL NULL NULL NULL NULL 2 @@ -6918,9 +7002,11 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 flush status; -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; -(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +m NULL NULL NULL @@ -6946,7 +7032,9 @@ Handler_read_rnd_deleted 0 Handler_read_rnd_next 22 set @@expensive_subquery_limit= default; EXPLAIN -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY alias1 ALL NULL NULL NULL NULL 2 @@ -6956,9 +7044,11 @@ id select_type table type possible_keys key key_len ref rows Extra 2 SUBQUERY t2 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join) 3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 flush status; -SELECT (SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +SELECT +(SELECT MIN(b) FROM t1, t2 +WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) AS m FROM t2 alias1, t1 alias2, t1 alias3; -(SELECT MIN(b) FROM t1, t2 WHERE b = a AND (b = alias1.b OR EXISTS (SELECT * FROM t3))) +m NULL NULL NULL diff --git a/mysql-test/main/subselect_sj.test b/mysql-test/main/subselect_sj.test index 3c046c6321c..b4aff7561cf 100644 --- a/mysql-test/main/subselect_sj.test +++ b/mysql-test/main/subselect_sj.test @@ -780,7 +780,13 @@ eval $query; let $query= SELECT pk FROM t1 WHERE (b, i) IN (SELECT b, i FROM t2 WHERE pk > 0); +#set optimizer_trace=1; +#select @@optimizer_switch; +#select @@join_cache_level; +#select @@optimizer_use_condition_selectivity; eval EXPLAIN EXTENDED $query; +#select * from information_schema.optimizer_trace; + eval $query; let $query= diff --git a/mysql-test/main/subselect_sj2.result b/mysql-test/main/subselect_sj2.result index fa10a4aa066..e2e44fd8e80 100644 --- a/mysql-test/main/subselect_sj2.result +++ b/mysql-test/main/subselect_sj2.result @@ -152,7 +152,7 @@ insert into t1 values (2, 'duplicate ok', 'duplicate ok'); insert into t1 values (18, 'duplicate ok', 'duplicate ok'); insert into t2 values (3, 'duplicate ok', 'duplicate ok'); insert into t2 values (19, 'duplicate ok', 'duplicate ok'); -explain select +explain select a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z from t1 ot where a in (select a from t2 it); id select_type table type possible_keys key key_len ref rows Extra diff --git a/mysql-test/main/subselect_sj2.test b/mysql-test/main/subselect_sj2.test index 4ccdcc50a38..67c70d449d7 100644 --- a/mysql-test/main/subselect_sj2.test +++ b/mysql-test/main/subselect_sj2.test @@ -124,7 +124,7 @@ insert into t1 values (18, 'duplicate ok', 'duplicate ok'); insert into t2 values (3, 'duplicate ok', 'duplicate ok'); insert into t2 values (19, 'duplicate ok', 'duplicate ok'); -explain select +explain select a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z from t1 ot where a in (select a from t2 it); select @@ -1248,6 +1248,7 @@ INSERT INTO t2 VALUES analyze table t1 persistent for all; analyze table t2 persistent for all; --replace_column 9 # + EXPLAIN SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3 WHERE alias3.d IN ( diff --git a/mysql-test/main/subselect_sj2_jcl6.result b/mysql-test/main/subselect_sj2_jcl6.result index 6ccec99ba5e..a5bcfbfa147 100644 --- a/mysql-test/main/subselect_sj2_jcl6.result +++ b/mysql-test/main/subselect_sj2_jcl6.result @@ -161,7 +161,7 @@ insert into t1 values (2, 'duplicate ok', 'duplicate ok'); insert into t1 values (18, 'duplicate ok', 'duplicate ok'); insert into t2 values (3, 'duplicate ok', 'duplicate ok'); insert into t2 values (19, 'duplicate ok', 'duplicate ok'); -explain select +explain select a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z from t1 ot where a in (select a from t2 it); id select_type table type possible_keys key key_len ref rows Extra @@ -912,11 +912,10 @@ EXPLAIN SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a WHERE t3.b IN (SELECT b FROM t4); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY t3 ALL NULL NULL NULL NULL 1 +1 PRIMARY t3 ALL NULL NULL NULL NULL 1 Using where 1 PRIMARY t2 hash_ALL NULL #hash#$hj 4 test.t3.a 1 Using where; Using join buffer (flat, BNLH join) 1 PRIMARY <derived3> ALL NULL NULL NULL NULL 2 Using join buffer (incremental, BNL join) -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 -2 MATERIALIZED t4 ALL NULL NULL NULL NULL 2 +1 PRIMARY t4 hash_ALL NULL #hash#$hj 4 test.t3.b 2 Using where; Start temporary; End temporary; Using join buffer (incremental, BNLH join) 3 DERIVED t1 ALL NULL NULL NULL NULL 1 SELECT * FROM t3 LEFT JOIN (v1,t2) ON t3.a = t2.a WHERE t3.b IN (SELECT b FROM t4); @@ -1151,10 +1150,10 @@ WHERE alias5.b = alias4.b AND ( alias5.b >= alias3.b OR alias5.c != alias3.c ) ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL # Using where -1 PRIMARY alias4 ref PRIMARY,c c 4 test.alias3.d # Using index -1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using where; FirstMatch(alias3) -1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join) +1 PRIMARY alias4 index PRIMARY,c c 4 NULL # Using where; Using index; Start temporary +1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using join buffer (flat, BKA join); Key-ordered scan +1 PRIMARY alias3 hash_ALL PRIMARY #hash#$hj 4 test.alias4.c # Using where; End temporary; Using join buffer (incremental, BNLH join) +1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (incremental, BNL join) 1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (incremental, BNL join) SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3 WHERE alias3.d IN ( @@ -1172,10 +1171,10 @@ WHERE alias5.b = alias4.b AND ( alias5.b >= alias3.b OR alias3.c != alias5.c ) ); id select_type table type possible_keys key key_len ref rows Extra -1 PRIMARY alias3 ALL PRIMARY NULL NULL NULL # Using where -1 PRIMARY alias4 ref PRIMARY,c c 4 test.alias3.d # Using index -1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using where; FirstMatch(alias3) -1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (flat, BNL join) +1 PRIMARY alias4 index PRIMARY,c c 4 NULL # Using where; Using index; Start temporary +1 PRIMARY alias5 eq_ref PRIMARY PRIMARY 4 test.alias4.b # Using join buffer (flat, BKA join); Key-ordered scan +1 PRIMARY alias3 hash_ALL PRIMARY #hash#$hj 4 test.alias4.c # Using where; End temporary; Using join buffer (incremental, BNLH join) +1 PRIMARY alias1 ALL NULL NULL NULL NULL # Using join buffer (incremental, BNL join) 1 PRIMARY alias2 ALL NULL NULL NULL NULL # Using join buffer (incremental, BNL join) SELECT COUNT(*) FROM t1 AS alias1, t1 AS alias2, t2 AS alias3 WHERE alias3.d IN ( diff --git a/mysql-test/main/subselect_sj2_mat.result b/mysql-test/main/subselect_sj2_mat.result index 5bc7751eeaa..acd600a734f 100644 --- a/mysql-test/main/subselect_sj2_mat.result +++ b/mysql-test/main/subselect_sj2_mat.result @@ -154,7 +154,7 @@ insert into t1 values (2, 'duplicate ok', 'duplicate ok'); insert into t1 values (18, 'duplicate ok', 'duplicate ok'); insert into t2 values (3, 'duplicate ok', 'duplicate ok'); insert into t2 values (19, 'duplicate ok', 'duplicate ok'); -explain select +explain select a, mid(filler1, 1,10), length(filler1)=length(filler2) as Z from t1 ot where a in (select a from t2 it); id select_type table type possible_keys key key_len ref rows Extra @@ -1661,7 +1661,7 @@ SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 = i2 OR 1=2); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 Using where 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00 -2 DEPENDENT SUBQUERY t3 hash_ALL NULL #hash#$hj 5 func 3 100.00 Using where; Using join buffer (flat, BNLH join) +2 DEPENDENT SUBQUERY t3 hash_ALL NULL #hash#$hj 5 func 3 10.00 Using where; Using join buffer (flat, BNLH join) Warnings: Note 1003 /* select#1 */ select `test`.`t1`.`i1` AS `i1` from `test`.`t1` where <expr_cache><`test`.`t1`.`i1`>(<in_optimizer>(`test`.`t1`.`i1`,<exists>(/* select#2 */ select `test`.`t3`.`i3` from `test`.`t2` join `test`.`t3` where `test`.`t3`.`i3` = `test`.`t2`.`i2` and <cache>(`test`.`t1`.`i1`) = `test`.`t3`.`i3`))) SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 = i2 OR 1=2); @@ -1671,12 +1671,11 @@ set optimizer_switch='materialization=on,semijoin=on'; EXPLAIN EXTENDED SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 = i2 OR 1=2); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 Using where -2 MATERIALIZED t3 hash_ALL NULL #hash#$hj 5 test.t2.i2 3 100.00 Using where; Using join buffer (flat, BNLH join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 PRIMARY t3 hash_ALL NULL #hash#$hj 5 test.t2.i2 3 10.00 Using where; Using join buffer (flat, BNLH join) +1 PRIMARY t1 hash_ALL NULL #hash#$hj 5 test.t2.i2 5 10.00 Using where; End temporary; Using join buffer (flat, BNLH join) Warnings: -Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where `test`.`t3`.`i3` = `test`.`t2`.`i2` +Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t1`.`i1` = `test`.`t2`.`i2` SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 = i2 OR 1=2); i1 7 @@ -1684,12 +1683,11 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 > 0 AND i3 = i2 OR 1=2); id select_type table type possible_keys key key_len ref rows filtered Extra -1 PRIMARY t1 ALL NULL NULL NULL NULL 5 100.00 -1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00 -2 MATERIALIZED t2 ALL NULL NULL NULL NULL 2 100.00 Using where -2 MATERIALIZED t3 hash_ALL NULL #hash#$hj 5 test.t2.i2 3 100.00 Using where; Using join buffer (flat, BNLH join) +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where; Start temporary +1 PRIMARY t3 hash_ALL NULL #hash#$hj 5 test.t2.i2 3 10.00 Using where; Using join buffer (flat, BNLH join) +1 PRIMARY t1 hash_ALL NULL #hash#$hj 5 test.t2.i2 5 10.00 Using where; End temporary; Using join buffer (flat, BNLH join) Warnings: -Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t3`.`i3` > 0 +Note 1003 select `test`.`t1`.`i1` AS `i1` from `test`.`t1` semi join (`test`.`t2` join `test`.`t3`) where `test`.`t3`.`i3` = `test`.`t2`.`i2` and `test`.`t1`.`i1` = `test`.`t2`.`i2` and `test`.`t3`.`i3` > 0 SELECT * FROM t1 WHERE i1 IN (SELECT i3 FROM t2, t3 WHERE i3 > 0 AND i3 = i2 OR 1=2); i1 diff --git a/mysql-test/main/subselect_sj_jcl6.result b/mysql-test/main/subselect_sj_jcl6.result index 5971fa30e89..6e397ddd754 100644 --- a/mysql-test/main/subselect_sj_jcl6.result +++ b/mysql-test/main/subselect_sj_jcl6.result @@ -3575,8 +3575,8 @@ SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a) GROUP BY a HAVING a != 'z'; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t range idx_a idx_a 4 NULL 3 Using where; Using index -1 PRIMARY t1 ref idx_a idx_a 4 test.t.a 1 Using index -1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t) +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where +1 PRIMARY t1 ref idx_a idx_a 4 test.t.a 1 Using index; FirstMatch(t) SELECT a FROM t1 t WHERE a IN (SELECT b FROM t1, t2 WHERE b = a) GROUP BY a HAVING a != 'z'; a diff --git a/mysql-test/main/system_mysql_db_fix50030.result b/mysql-test/main/system_mysql_db_fix50030.result index b99b8678b1a..a257c16b865 100644 --- a/mysql-test/main/system_mysql_db_fix50030.result +++ b/mysql-test/main/system_mysql_db_fix50030.result @@ -166,14 +166,14 @@ show create table servers; Table Create Table servers CREATE TABLE `servers` ( `Server_name` char(64) NOT NULL DEFAULT '', - `Host` char(64) NOT NULL DEFAULT '', + `Host` varchar(2048) NOT NULL DEFAULT '', `Db` char(64) NOT NULL DEFAULT '', `Username` char(128) NOT NULL DEFAULT '', `Password` char(64) NOT NULL DEFAULT '', `Port` int(4) NOT NULL DEFAULT 0, `Socket` char(64) NOT NULL DEFAULT '', `Wrapper` char(64) NOT NULL DEFAULT '', - `Owner` char(64) NOT NULL DEFAULT '', + `Owner` varchar(512) NOT NULL DEFAULT '', PRIMARY KEY (`Server_name`) ) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='MySQL Foreign Servers table' show create table proc; diff --git a/mysql-test/main/system_mysql_db_fix50117.result b/mysql-test/main/system_mysql_db_fix50117.result index 8e48c2accb7..fde130839d4 100644 --- a/mysql-test/main/system_mysql_db_fix50117.result +++ b/mysql-test/main/system_mysql_db_fix50117.result @@ -146,14 +146,14 @@ show create table servers; Table Create Table servers CREATE TABLE `servers` ( `Server_name` char(64) NOT NULL DEFAULT '', - `Host` char(64) NOT NULL DEFAULT '', + `Host` varchar(2048) NOT NULL DEFAULT '', `Db` char(64) NOT NULL DEFAULT '', `Username` char(128) NOT NULL DEFAULT '', `Password` char(64) NOT NULL DEFAULT '', `Port` int(4) NOT NULL DEFAULT 0, `Socket` char(64) NOT NULL DEFAULT '', `Wrapper` char(64) NOT NULL DEFAULT '', - `Owner` char(64) NOT NULL DEFAULT '', + `Owner` varchar(512) NOT NULL DEFAULT '', PRIMARY KEY (`Server_name`) ) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='MySQL Foreign Servers table' show create table proc; diff --git a/mysql-test/main/system_mysql_db_fix50568.result b/mysql-test/main/system_mysql_db_fix50568.result new file mode 100644 index 00000000000..763fcb866d0 --- /dev/null +++ b/mysql-test/main/system_mysql_db_fix50568.result @@ -0,0 +1,297 @@ +use test; +CREATE TABLE IF NOT EXISTS db ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges'; +Warnings: +Warning 1280 Name 'Host' ignored for PRIMARY key. +CREATE TABLE IF NOT EXISTS host ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Host privileges; Merged with database privileges'; +Warnings: +Warning 1280 Name 'Host' ignored for PRIMARY key. +CREATE TABLE IF NOT EXISTS user ( Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tablespace_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL, ssl_cipher BLOB NOT NULL, x509_issuer BLOB NOT NULL, x509_subject BLOB NOT NULL, max_questions int(11) unsigned DEFAULT 0 NOT NULL, max_updates int(11) unsigned DEFAULT 0 NOT NULL, max_connections int(11) unsigned DEFAULT 0 NOT NULL, max_user_connections int(11) DEFAULT 0 NOT NULL, plugin char(64) CHARACTER SET latin1 DEFAULT '' NOT NULL, authentication_string TEXT NOT NULL, PRIMARY KEY Host (Host,User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Users and global privileges'; +Warnings: +Warning 1280 Name 'Host' ignored for PRIMARY key. +CREATE TABLE IF NOT EXISTS func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User defined functions'; +CREATE TABLE IF NOT EXISTS plugin ( name varchar(64) DEFAULT '' NOT NULL, dl varchar(128) DEFAULT '' NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci comment='MySQL plugins'; +CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table'; +CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges'; +CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges'; +CREATE TABLE IF NOT EXISTS help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url text not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics'; +CREATE TABLE IF NOT EXISTS help_category ( help_category_id smallint unsigned not null, name char(64) not null, parent_category_id smallint unsigned null, url text not null, primary key (help_category_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help categories'; +CREATE TABLE IF NOT EXISTS help_relation ( help_topic_id int unsigned not null references help_topic, help_keyword_id int unsigned not null references help_keyword, primary key (help_keyword_id, help_topic_id) ) engine=MyISAM CHARACTER SET utf8 comment='keyword-topic relation'; +CREATE TABLE IF NOT EXISTS help_keyword ( help_keyword_id int unsigned not null, name char(64) not null, primary key (help_keyword_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help keywords'; +CREATE TABLE IF NOT EXISTS time_zone_name ( Name char(64) NOT NULL, Time_zone_id int unsigned NOT NULL, PRIMARY KEY Name (Name) ) engine=MyISAM CHARACTER SET utf8 comment='Time zone names'; +Warnings: +Warning 1280 Name 'Name' ignored for PRIMARY key. +CREATE TABLE IF NOT EXISTS time_zone ( Time_zone_id int unsigned NOT NULL auto_increment, Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY TzId (Time_zone_id) ) engine=MyISAM CHARACTER SET utf8 comment='Time zones'; +Warnings: +Warning 1280 Name 'TzId' ignored for PRIMARY key. +CREATE TABLE IF NOT EXISTS time_zone_transition ( Time_zone_id int unsigned NOT NULL, Transition_time bigint signed NOT NULL, Transition_type_id int unsigned NOT NULL, PRIMARY KEY TzIdTranTime (Time_zone_id, Transition_time) ) engine=MyISAM CHARACTER SET utf8 comment='Time zone transitions'; +Warnings: +Warning 1280 Name 'TzIdTranTime' ignored for PRIMARY key. +CREATE TABLE IF NOT EXISTS time_zone_transition_type ( Time_zone_id int unsigned NOT NULL, Transition_type_id int unsigned NOT NULL, `Offset` int signed DEFAULT 0 NOT NULL, Is_DST tinyint unsigned DEFAULT 0 NOT NULL, Abbreviation char(8) DEFAULT '' NOT NULL, PRIMARY KEY TzIdTrTId (Time_zone_id, Transition_type_id) ) engine=MyISAM CHARACTER SET utf8 comment='Time zone transition types'; +Warnings: +Warning 1280 Name 'TzIdTrTId' ignored for PRIMARY key. +CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint signed NOT NULL, Correction int signed NOT NULL, PRIMARY KEY TranTime (Transition_time) ) engine=MyISAM CHARACTER SET utf8 comment='Leap seconds information for time zones'; +Warnings: +Warning 1280 Name 'TranTime' ignored for PRIMARY key. +CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum( 'CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA') DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns longblob DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'IGNORE_BAD_TABLE_OPTIONS', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE', 'NO_ENGINE_SUBSTITUTION', 'PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment text collate utf8_bin NOT NULL, character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db,name,type)) engine=MyISAM character set utf8 comment='Stored Procedures'; +CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) COLLATE utf8_general_ci DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges'; +CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', originator INTEGER UNSIGNED NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events'; +CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM; +CREATE TABLE IF NOT EXISTS proxies_priv (Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Proxied_host char(60) binary DEFAULT '' NOT NULL, Proxied_user char(16) binary DEFAULT '' NOT NULL, With_grant BOOL DEFAULT 0 NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY Host (Host,User,Proxied_host,Proxied_user), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User proxy privileges'; +Warnings: +Warning 1280 Name 'Host' ignored for PRIMARY key. +show tables; +Tables_in_db +column_stats +columns_priv +db +event +func +general_log +global_priv +gtid_slave_pos +help_category +help_keyword +help_relation +help_topic +host +index_stats +innodb_index_stats +innodb_table_stats +ndb_binlog_index +plugin +proc +procs_priv +proxies_priv +roles_mapping +servers +slow_log +table_stats +tables_priv +time_zone +time_zone_leap_second +time_zone_name +time_zone_transition +time_zone_transition_type +transaction_registry +user +show create table db; +Table Create Table +db CREATE TABLE `db` ( + `Host` char(255) NOT NULL DEFAULT '', + `Db` char(64) NOT NULL DEFAULT '', + `User` char(128) NOT NULL DEFAULT '', + `Select_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Insert_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Update_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Delete_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Create_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Drop_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Grant_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `References_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Index_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Alter_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Lock_tables_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Create_view_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Show_view_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Create_routine_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Alter_routine_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Execute_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Event_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Trigger_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + `Delete_history_priv` enum('N','Y') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'N', + PRIMARY KEY (`Host`,`Db`,`User`), + KEY `User` (`User`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Database privileges' +show create table user; +View Create View character_set_client collation_connection +user CREATE ALGORITHM=UNDEFINED DEFINER=`mariadb.sys`@`localhost` SQL SECURITY DEFINER VIEW `user` AS select `test`.`global_priv`.`Host` AS `Host`,`test`.`global_priv`.`User` AS `User`,if(json_value(`test`.`global_priv`.`Priv`,'$.plugin') in ('mysql_native_password','mysql_old_password'),ifnull(json_value(`test`.`global_priv`.`Priv`,'$.authentication_string'),''),'') AS `Password`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 1,'Y','N') AS `Select_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 2,'Y','N') AS `Insert_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 4,'Y','N') AS `Update_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 8,'Y','N') AS `Delete_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 16,'Y','N') AS `Create_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 32,'Y','N') AS `Drop_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 64,'Y','N') AS `Reload_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 128,'Y','N') AS `Shutdown_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 256,'Y','N') AS `Process_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 512,'Y','N') AS `File_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 1024,'Y','N') AS `Grant_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 2048,'Y','N') AS `References_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 4096,'Y','N') AS `Index_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 8192,'Y','N') AS `Alter_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 16384,'Y','N') AS `Show_db_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 32768,'Y','N') AS `Super_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 65536,'Y','N') AS `Create_tmp_table_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 131072,'Y','N') AS `Lock_tables_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 262144,'Y','N') AS `Execute_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 524288,'Y','N') AS `Repl_slave_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 1048576,'Y','N') AS `Repl_client_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 2097152,'Y','N') AS `Create_view_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 4194304,'Y','N') AS `Show_view_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 8388608,'Y','N') AS `Create_routine_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 16777216,'Y','N') AS `Alter_routine_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 33554432,'Y','N') AS `Create_user_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 67108864,'Y','N') AS `Event_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 134217728,'Y','N') AS `Trigger_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 268435456,'Y','N') AS `Create_tablespace_priv`,if(json_value(`test`.`global_priv`.`Priv`,'$.access') & 536870912,'Y','N') AS `Delete_history_priv`,elt(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.ssl_type'),0) + 1,'','ANY','X509','SPECIFIED') AS `ssl_type`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.ssl_cipher'),'') AS `ssl_cipher`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.x509_issuer'),'') AS `x509_issuer`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.x509_subject'),'') AS `x509_subject`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_questions'),0) as unsigned) AS `max_questions`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_updates'),0) as unsigned) AS `max_updates`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_connections'),0) as unsigned) AS `max_connections`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_user_connections'),0) as signed) AS `max_user_connections`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.plugin'),'') AS `plugin`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.authentication_string'),'') AS `authentication_string`,if(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.password_last_changed'),1) = 0,'Y','N') AS `password_expired`,elt(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.is_role'),0) + 1,'N','Y') AS `is_role`,ifnull(json_value(`test`.`global_priv`.`Priv`,'$.default_role'),'') AS `default_role`,cast(ifnull(json_value(`test`.`global_priv`.`Priv`,'$.max_statement_time'),0.0) as decimal(12,6)) AS `max_statement_time` from `global_priv` latin1 latin1_swedish_ci +show create table func; +Table Create Table +func CREATE TABLE `func` ( + `name` char(64) NOT NULL DEFAULT '', + `ret` tinyint(1) NOT NULL DEFAULT 0, + `dl` char(128) NOT NULL DEFAULT '', + `type` enum('function','aggregate') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL, + PRIMARY KEY (`name`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='User defined functions' +show create table global_priv; +Table Create Table +global_priv CREATE TABLE `global_priv` ( + `Host` char(255) NOT NULL DEFAULT '', + `User` char(128) NOT NULL DEFAULT '', + `Priv` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL DEFAULT '{}' CHECK (json_valid(`Priv`)), + PRIMARY KEY (`Host`,`User`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Users and global privileges' +show create table tables_priv; +Table Create Table +tables_priv CREATE TABLE `tables_priv` ( + `Host` char(255) NOT NULL DEFAULT '', + `Db` char(64) NOT NULL DEFAULT '', + `User` char(128) NOT NULL DEFAULT '', + `Table_name` char(64) NOT NULL DEFAULT '', + `Grantor` varchar(384) NOT NULL DEFAULT '', + `Timestamp` timestamp NULL DEFAULT NULL, + `Table_priv` set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger','Delete versioning rows') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '', + `Column_priv` set('Select','Insert','Update','References') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '', + PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`), + KEY `Grantor` (`Grantor`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Table privileges' +show create table columns_priv; +Table Create Table +columns_priv CREATE TABLE `columns_priv` ( + `Host` char(255) NOT NULL DEFAULT '', + `Db` char(64) NOT NULL DEFAULT '', + `User` char(128) NOT NULL DEFAULT '', + `Table_name` char(64) NOT NULL DEFAULT '', + `Column_name` char(64) NOT NULL DEFAULT '', + `Timestamp` timestamp NULL DEFAULT NULL, + `Column_priv` set('Select','Insert','Update','References') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '', + PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`,`Column_name`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Column privileges' +show create table procs_priv; +Table Create Table +procs_priv CREATE TABLE `procs_priv` ( + `Host` char(60) NOT NULL DEFAULT '', + `Db` char(64) NOT NULL DEFAULT '', + `User` char(128) NOT NULL DEFAULT '', + `Routine_name` char(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '', + `Routine_type` enum('FUNCTION','PROCEDURE','PACKAGE','PACKAGE BODY') NOT NULL, + `Grantor` varchar(384) NOT NULL DEFAULT '', + `Proc_priv` set('Execute','Alter Routine','Grant') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '', + `Timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), + PRIMARY KEY (`Host`,`Db`,`User`,`Routine_name`,`Routine_type`), + KEY `Grantor` (`Grantor`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Procedure privileges' +show create table servers; +Table Create Table +servers CREATE TABLE `servers` ( + `Server_name` char(64) NOT NULL DEFAULT '', + `Host` varchar(2048) NOT NULL DEFAULT '', + `Db` char(64) NOT NULL DEFAULT '', + `Username` char(128) NOT NULL DEFAULT '', + `Password` char(64) NOT NULL DEFAULT '', + `Port` int(4) NOT NULL DEFAULT 0, + `Socket` char(64) NOT NULL DEFAULT '', + `Wrapper` char(64) NOT NULL DEFAULT '', + `Owner` varchar(512) NOT NULL DEFAULT '', + PRIMARY KEY (`Server_name`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='MySQL Foreign Servers table' +show create table proc; +Table Create Table +proc CREATE TABLE `proc` ( + `db` char(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL DEFAULT '', + `name` char(64) NOT NULL DEFAULT '', + `type` enum('FUNCTION','PROCEDURE','PACKAGE','PACKAGE BODY') NOT NULL, + `specific_name` char(64) NOT NULL DEFAULT '', + `language` enum('SQL') NOT NULL DEFAULT 'SQL', + `sql_data_access` enum('CONTAINS_SQL','NO_SQL','READS_SQL_DATA','MODIFIES_SQL_DATA') NOT NULL DEFAULT 'CONTAINS_SQL', + `is_deterministic` enum('YES','NO') NOT NULL DEFAULT 'NO', + `security_type` enum('INVOKER','DEFINER') NOT NULL DEFAULT 'DEFINER', + `param_list` blob NOT NULL, + `returns` longblob NOT NULL, + `body` longblob NOT NULL, + `definer` varchar(384) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL DEFAULT '', + `created` timestamp NULL DEFAULT NULL, + `modified` timestamp NULL DEFAULT NULL, + `sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH','EMPTY_STRING_IS_NULL','SIMULTANEOUS_ASSIGNMENT','TIME_ROUND_FRACTIONAL') NOT NULL DEFAULT '', + `comment` text CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL, + `character_set_client` char(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL, + `collation_connection` char(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL, + `db_collation` char(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL, + `body_utf8` longblob DEFAULT NULL, + `aggregate` enum('NONE','GROUP') NOT NULL DEFAULT 'NONE', + PRIMARY KEY (`db`,`name`,`type`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Stored Procedures' +show create table event; +Table Create Table +event CREATE TABLE `event` ( + `db` char(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL DEFAULT '', + `name` char(64) NOT NULL DEFAULT '', + `body` longblob NOT NULL, + `definer` varchar(384) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL DEFAULT '', + `execute_at` datetime DEFAULT NULL, + `interval_value` int(11) DEFAULT NULL, + `interval_field` enum('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') DEFAULT NULL, + `created` timestamp NOT NULL, + `modified` timestamp NOT NULL, + `last_executed` datetime DEFAULT NULL, + `starts` datetime DEFAULT NULL, + `ends` datetime DEFAULT NULL, + `status` enum('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL DEFAULT 'ENABLED', + `on_completion` enum('DROP','PRESERVE') NOT NULL DEFAULT 'DROP', + `sql_mode` set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH','EMPTY_STRING_IS_NULL','SIMULTANEOUS_ASSIGNMENT','TIME_ROUND_FRACTIONAL') NOT NULL DEFAULT '', + `comment` char(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin NOT NULL DEFAULT '', + `originator` int(10) unsigned NOT NULL, + `time_zone` char(64) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT 'SYSTEM', + `character_set_client` char(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL, + `collation_connection` char(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL, + `db_collation` char(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL, + `body_utf8` longblob DEFAULT NULL, + PRIMARY KEY (`db`,`name`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Events' +show create table general_log; +Table Create Table +general_log CREATE TABLE `general_log` ( + `event_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6), + `user_host` mediumtext NOT NULL, + `thread_id` bigint(21) unsigned NOT NULL, + `server_id` int(10) unsigned NOT NULL, + `command_type` varchar(64) NOT NULL, + `argument` mediumtext NOT NULL +) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='General log' +show create table slow_log; +Table Create Table +slow_log CREATE TABLE `slow_log` ( + `start_time` timestamp(6) NOT NULL DEFAULT current_timestamp(6) ON UPDATE current_timestamp(6), + `user_host` mediumtext NOT NULL, + `query_time` time(6) NOT NULL, + `lock_time` time(6) NOT NULL, + `rows_sent` int(11) NOT NULL, + `rows_examined` int(11) NOT NULL, + `db` varchar(512) NOT NULL, + `last_insert_id` int(11) NOT NULL, + `insert_id` int(11) NOT NULL, + `server_id` int(10) unsigned NOT NULL, + `sql_text` mediumtext NOT NULL, + `thread_id` bigint(21) unsigned NOT NULL, + `rows_affected` int(11) NOT NULL +) ENGINE=CSV DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci COMMENT='Slow log' +show create table table_stats; +Table Create Table +table_stats CREATE TABLE `table_stats` ( + `db_name` varchar(64) NOT NULL, + `table_name` varchar(64) NOT NULL, + `cardinality` bigint(21) unsigned DEFAULT NULL, + PRIMARY KEY (`db_name`,`table_name`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Tables' +show create table column_stats; +Table Create Table +column_stats CREATE TABLE `column_stats` ( + `db_name` varchar(64) NOT NULL, + `table_name` varchar(64) NOT NULL, + `column_name` varchar(64) NOT NULL, + `min_value` varbinary(255) DEFAULT NULL, + `max_value` varbinary(255) DEFAULT NULL, + `nulls_ratio` decimal(12,4) DEFAULT NULL, + `avg_length` decimal(12,4) DEFAULT NULL, + `avg_frequency` decimal(12,4) DEFAULT NULL, + `hist_size` tinyint(3) unsigned DEFAULT NULL, + `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') DEFAULT NULL, + `histogram` longblob DEFAULT NULL, + PRIMARY KEY (`db_name`,`table_name`,`column_name`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns' +show create table index_stats; +Table Create Table +index_stats CREATE TABLE `index_stats` ( + `db_name` varchar(64) NOT NULL, + `table_name` varchar(64) NOT NULL, + `index_name` varchar(64) NOT NULL, + `prefix_arity` int(11) unsigned NOT NULL, + `avg_frequency` decimal(12,4) DEFAULT NULL, + PRIMARY KEY (`db_name`,`table_name`,`index_name`,`prefix_arity`) +) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Indexes' +DROP VIEW user; +DROP TABLE db, host, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, event, proxies_priv, general_log, slow_log, innodb_index_stats, innodb_table_stats, transaction_registry, table_stats, column_stats, index_stats, roles_mapping, gtid_slave_pos, global_priv, ndb_binlog_index; +show tables; +Tables_in_test diff --git a/mysql-test/main/system_mysql_db_fix50568.test b/mysql-test/main/system_mysql_db_fix50568.test new file mode 100644 index 00000000000..3429f8c5478 --- /dev/null +++ b/mysql-test/main/system_mysql_db_fix50568.test @@ -0,0 +1,99 @@ +# Embedded server doesn't support external clients +--source include/not_embedded.inc +--source include/have_innodb.inc + +# Don't run this test if $MYSQL_FIX_PRIVILEGE_TABLES isn't set +# to the location of mysql_fix_privilege_tables.sql +if (!$MYSQL_FIX_PRIVILEGE_TABLES) +{ + skip Test needs MYSQL_FIX_PRIVILEGE_TABLES; +} + +# +# This is the test for mysql_fix_privilege_tables +# It checks that a system tables from mysql 5.5.68 +# can be upgraded to current system table format +# +# Note: If this test fails, don't be confused about the errors reported +# by mysql-test-run This shows warnings generated by +# mysql_fix_system_tables which should be ignored. +# Instead, concentrate on the errors in r/system_mysql_db.reject + +use test; + +# create system tables as in mysql-5.5.68 +CREATE TABLE IF NOT EXISTS db ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db,User), KEY User (User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Database privileges'; + +CREATE TABLE IF NOT EXISTS host ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY Host (Host,Db) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Host privileges; Merged with database privileges'; + +CREATE TABLE IF NOT EXISTS user ( Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Password char(41) character set latin1 collate latin1_bin DEFAULT '' NOT NULL, Select_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Insert_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Update_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Delete_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Drop_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Reload_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Shutdown_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Process_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, File_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Grant_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, References_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Index_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_db_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Super_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tmp_table_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Lock_tables_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Execute_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_slave_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Repl_client_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Show_view_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Alter_routine_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_user_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Event_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Trigger_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, Create_tablespace_priv enum('N','Y') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, ssl_type enum('','ANY','X509', 'SPECIFIED') COLLATE utf8_general_ci DEFAULT '' NOT NULL, ssl_cipher BLOB NOT NULL, x509_issuer BLOB NOT NULL, x509_subject BLOB NOT NULL, max_questions int(11) unsigned DEFAULT 0 NOT NULL, max_updates int(11) unsigned DEFAULT 0 NOT NULL, max_connections int(11) unsigned DEFAULT 0 NOT NULL, max_user_connections int(11) DEFAULT 0 NOT NULL, plugin char(64) CHARACTER SET latin1 DEFAULT '' NOT NULL, authentication_string TEXT NOT NULL, PRIMARY KEY Host (Host,User) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Users and global privileges'; + +CREATE TABLE IF NOT EXISTS func ( name char(64) binary DEFAULT '' NOT NULL, ret tinyint(1) DEFAULT '0' NOT NULL, dl char(128) DEFAULT '' NOT NULL, type enum ('function','aggregate') COLLATE utf8_general_ci NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User defined functions'; + + +CREATE TABLE IF NOT EXISTS plugin ( name varchar(64) DEFAULT '' NOT NULL, dl varchar(128) DEFAULT '' NOT NULL, PRIMARY KEY (name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci comment='MySQL plugins'; + + +CREATE TABLE IF NOT EXISTS servers ( Server_name char(64) NOT NULL DEFAULT '', Host char(64) NOT NULL DEFAULT '', Db char(64) NOT NULL DEFAULT '', Username char(64) NOT NULL DEFAULT '', Password char(64) NOT NULL DEFAULT '', Port INT(4) NOT NULL DEFAULT '0', Socket char(64) NOT NULL DEFAULT '', Wrapper char(64) NOT NULL DEFAULT '', Owner char(64) NOT NULL DEFAULT '', PRIMARY KEY (Server_name)) CHARACTER SET utf8 comment='MySQL Foreign Servers table'; + + +CREATE TABLE IF NOT EXISTS tables_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, Table_priv set('Select','Insert','Update','Delete','Create','Drop','Grant','References','Index','Alter','Create View','Show view','Trigger') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Table privileges'; + +CREATE TABLE IF NOT EXISTS columns_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Table_name char(64) binary DEFAULT '' NOT NULL, Column_name char(64) binary DEFAULT '' NOT NULL, Timestamp timestamp, Column_priv set('Select','Insert','Update','References') COLLATE utf8_general_ci DEFAULT '' NOT NULL, PRIMARY KEY (Host,Db,User,Table_name,Column_name) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Column privileges'; + + +CREATE TABLE IF NOT EXISTS help_topic ( help_topic_id int unsigned not null, name char(64) not null, help_category_id smallint unsigned not null, description text not null, example text not null, url text not null, primary key (help_topic_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help topics'; + + +CREATE TABLE IF NOT EXISTS help_category ( help_category_id smallint unsigned not null, name char(64) not null, parent_category_id smallint unsigned null, url text not null, primary key (help_category_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help categories'; + + +CREATE TABLE IF NOT EXISTS help_relation ( help_topic_id int unsigned not null references help_topic, help_keyword_id int unsigned not null references help_keyword, primary key (help_keyword_id, help_topic_id) ) engine=MyISAM CHARACTER SET utf8 comment='keyword-topic relation'; + + +CREATE TABLE IF NOT EXISTS help_keyword ( help_keyword_id int unsigned not null, name char(64) not null, primary key (help_keyword_id), unique index (name) ) engine=MyISAM CHARACTER SET utf8 comment='help keywords'; + + +CREATE TABLE IF NOT EXISTS time_zone_name ( Name char(64) NOT NULL, Time_zone_id int unsigned NOT NULL, PRIMARY KEY Name (Name) ) engine=MyISAM CHARACTER SET utf8 comment='Time zone names'; + + +CREATE TABLE IF NOT EXISTS time_zone ( Time_zone_id int unsigned NOT NULL auto_increment, Use_leap_seconds enum('Y','N') COLLATE utf8_general_ci DEFAULT 'N' NOT NULL, PRIMARY KEY TzId (Time_zone_id) ) engine=MyISAM CHARACTER SET utf8 comment='Time zones'; + + +CREATE TABLE IF NOT EXISTS time_zone_transition ( Time_zone_id int unsigned NOT NULL, Transition_time bigint signed NOT NULL, Transition_type_id int unsigned NOT NULL, PRIMARY KEY TzIdTranTime (Time_zone_id, Transition_time) ) engine=MyISAM CHARACTER SET utf8 comment='Time zone transitions'; + + +CREATE TABLE IF NOT EXISTS time_zone_transition_type ( Time_zone_id int unsigned NOT NULL, Transition_type_id int unsigned NOT NULL, `Offset` int signed DEFAULT 0 NOT NULL, Is_DST tinyint unsigned DEFAULT 0 NOT NULL, Abbreviation char(8) DEFAULT '' NOT NULL, PRIMARY KEY TzIdTrTId (Time_zone_id, Transition_type_id) ) engine=MyISAM CHARACTER SET utf8 comment='Time zone transition types'; + + +CREATE TABLE IF NOT EXISTS time_zone_leap_second ( Transition_time bigint signed NOT NULL, Correction int signed NOT NULL, PRIMARY KEY TranTime (Transition_time) ) engine=MyISAM CHARACTER SET utf8 comment='Leap seconds information for time zones'; + +CREATE TABLE IF NOT EXISTS proc (db char(64) collate utf8_bin DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum( 'CONTAINS_SQL', 'NO_SQL', 'READS_SQL_DATA', 'MODIFIES_SQL_DATA') DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob NOT NULL, returns longblob DEFAULT '' NOT NULL, body longblob NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL, created timestamp, modified timestamp, sql_mode set( 'REAL_AS_FLOAT', 'PIPES_AS_CONCAT', 'ANSI_QUOTES', 'IGNORE_SPACE', 'IGNORE_BAD_TABLE_OPTIONS', 'ONLY_FULL_GROUP_BY', 'NO_UNSIGNED_SUBTRACTION', 'NO_DIR_IN_CREATE', 'POSTGRESQL', 'ORACLE', 'MSSQL', 'DB2', 'MAXDB', 'NO_KEY_OPTIONS', 'NO_TABLE_OPTIONS', 'NO_FIELD_OPTIONS', 'MYSQL323', 'MYSQL40', 'ANSI', 'NO_AUTO_VALUE_ON_ZERO', 'NO_BACKSLASH_ESCAPES', 'STRICT_TRANS_TABLES', 'STRICT_ALL_TABLES', 'NO_ZERO_IN_DATE', 'NO_ZERO_DATE', 'INVALID_DATES', 'ERROR_FOR_DIVISION_BY_ZERO', 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE', 'NO_ENGINE_SUBSTITUTION', 'PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment text collate utf8_bin NOT NULL, character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db,name,type)) engine=MyISAM character set utf8 comment='Stored Procedures'; + +CREATE TABLE IF NOT EXISTS procs_priv ( Host char(60) binary DEFAULT '' NOT NULL, Db char(64) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Routine_name char(64) COLLATE utf8_general_ci DEFAULT '' NOT NULL, Routine_type enum('FUNCTION','PROCEDURE') NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Proc_priv set('Execute','Alter Routine','Grant') COLLATE utf8_general_ci DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY (Host,Db,User,Routine_name,Routine_type), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='Procedure privileges'; + + +CREATE TABLE IF NOT EXISTS event ( db char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', name char(64) CHARACTER SET utf8 NOT NULL default '', body longblob NOT NULL, definer char(77) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', execute_at DATETIME default NULL, interval_value int(11) default NULL, interval_field ENUM('YEAR','QUARTER','MONTH','DAY','HOUR','MINUTE','WEEK','SECOND','MICROSECOND','YEAR_MONTH','DAY_HOUR','DAY_MINUTE','DAY_SECOND','HOUR_MINUTE','HOUR_SECOND','MINUTE_SECOND','DAY_MICROSECOND','HOUR_MICROSECOND','MINUTE_MICROSECOND','SECOND_MICROSECOND') default NULL, created TIMESTAMP NOT NULL, modified TIMESTAMP NOT NULL, last_executed DATETIME default NULL, starts DATETIME default NULL, ends DATETIME default NULL, status ENUM('ENABLED','DISABLED','SLAVESIDE_DISABLED') NOT NULL default 'ENABLED', on_completion ENUM('DROP','PRESERVE') NOT NULL default 'DROP', sql_mode set('REAL_AS_FLOAT','PIPES_AS_CONCAT','ANSI_QUOTES','IGNORE_SPACE','IGNORE_BAD_TABLE_OPTIONS','ONLY_FULL_GROUP_BY','NO_UNSIGNED_SUBTRACTION','NO_DIR_IN_CREATE','POSTGRESQL','ORACLE','MSSQL','DB2','MAXDB','NO_KEY_OPTIONS','NO_TABLE_OPTIONS','NO_FIELD_OPTIONS','MYSQL323','MYSQL40','ANSI','NO_AUTO_VALUE_ON_ZERO','NO_BACKSLASH_ESCAPES','STRICT_TRANS_TABLES','STRICT_ALL_TABLES','NO_ZERO_IN_DATE','NO_ZERO_DATE','INVALID_DATES','ERROR_FOR_DIVISION_BY_ZERO','TRADITIONAL','NO_AUTO_CREATE_USER','HIGH_NOT_PRECEDENCE','NO_ENGINE_SUBSTITUTION','PAD_CHAR_TO_FULL_LENGTH') DEFAULT '' NOT NULL, comment char(64) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL default '', originator INTEGER UNSIGNED NOT NULL, time_zone char(64) CHARACTER SET latin1 NOT NULL DEFAULT 'SYSTEM', character_set_client char(32) collate utf8_bin, collation_connection char(32) collate utf8_bin, db_collation char(32) collate utf8_bin, body_utf8 longblob, PRIMARY KEY (db, name) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT 'Events'; + + +CREATE TABLE IF NOT EXISTS ndb_binlog_index (Position BIGINT UNSIGNED NOT NULL, File VARCHAR(255) NOT NULL, epoch BIGINT UNSIGNED NOT NULL, inserts BIGINT UNSIGNED NOT NULL, updates BIGINT UNSIGNED NOT NULL, deletes BIGINT UNSIGNED NOT NULL, schemaops BIGINT UNSIGNED NOT NULL, PRIMARY KEY(epoch)) ENGINE=MYISAM; + +CREATE TABLE IF NOT EXISTS proxies_priv (Host char(60) binary DEFAULT '' NOT NULL, User char(16) binary DEFAULT '' NOT NULL, Proxied_host char(60) binary DEFAULT '' NOT NULL, Proxied_user char(16) binary DEFAULT '' NOT NULL, With_grant BOOL DEFAULT 0 NOT NULL, Grantor char(77) DEFAULT '' NOT NULL, Timestamp timestamp, PRIMARY KEY Host (Host,User,Proxied_host,Proxied_user), KEY Grantor (Grantor) ) engine=MyISAM CHARACTER SET utf8 COLLATE utf8_bin comment='User proxy privileges'; + + +-- disable_result_log +# Run the mysql_fix_privilege_tables.sql using "mysql --force" +--exec $MYSQL --force test < $MYSQL_FIX_PRIVILEGE_TABLES +-- enable_result_log + +# Dump the tables that should be compared +-- source include/system_db_struct.inc + +# Drop all tables created by this test +DROP VIEW user; +DROP TABLE db, host, func, plugin, tables_priv, columns_priv, procs_priv, servers, help_category, help_keyword, help_relation, help_topic, proc, time_zone, time_zone_leap_second, time_zone_name, time_zone_transition, time_zone_transition_type, event, proxies_priv, general_log, slow_log, innodb_index_stats, innodb_table_stats, transaction_registry, table_stats, column_stats, index_stats, roles_mapping, gtid_slave_pos, global_priv, ndb_binlog_index; + +# check that we dropped all system tables +show tables; + +# End of 4.1 tests diff --git a/mysql-test/main/table_value_constr.result b/mysql-test/main/table_value_constr.result index 86479c843c2..6d8dd6826e8 100644 --- a/mysql-test/main/table_value_constr.result +++ b/mysql-test/main/table_value_constr.result @@ -3156,5 +3156,124 @@ INSERT INTO t1 (VALUES (IGNORE) UNION VALUES (IGNORE)); ERROR HY000: 'ignore' is not allowed in this context DROP TABLE t1; # +# MDEV-28603: VIEW with table value constructor used as single-value +# subquery contains subquery as its first element +# +create table t1 (a int); +insert into t1 values (3), (7), (1); +create table t2 (b int); +insert into t2 values (1), (2); +create view v as select (values ((select * from t1 where a > 5))) as m from t2; +select (values ((select * from t1 where a > 5))) as m from t2; +m +7 +7 +select * from v; +m +7 +7 +with cte as ( select (values ((select * from t1 where a > 5))) as m from t2 ) select * from cte; +m +7 +7 +explain select (values ((select * from t1 where a > 5))) as m from t2; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 +4 SUBQUERY <derived2> ALL NULL NULL NULL NULL 2 +2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used +3 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where +explain select * from v; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 +5 SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used +4 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where +explain with cte as ( select (values ((select * from t1 where a > 5))) as m from t2 ) select * from cte; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t2 ALL NULL NULL NULL NULL 2 +5 SUBQUERY <derived3> ALL NULL NULL NULL NULL 2 +3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used +4 SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where +prepare stmt from "select (values ((select * from t1 where a > 5))) as m from t2"; +execute stmt; +m +7 +7 +execute stmt; +m +7 +7 +deallocate prepare stmt; +prepare stmt from "select * from v"; +execute stmt; +m +7 +7 +execute stmt; +m +7 +7 +deallocate prepare stmt; +prepare stmt from "with cte as ( select (values ((select * from t1 where a > 5))) as m from t2 ) select * from cte"; +execute stmt; +m +7 +7 +execute stmt; +m +7 +7 +deallocate prepare stmt; +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select (values ((select `t1`.`a` from `t1` where `t1`.`a` > 5))) AS `m` from `t2` latin1 latin1_swedish_ci +drop view v; +prepare stmt from "create view v as select (values ((select * from t1 where a > 5))) as m from t2"; +execute stmt; +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select (values ((select `t1`.`a` from `t1` where `t1`.`a` > 5))) AS `m` from `t2` latin1 latin1_swedish_ci +select * from v; +m +7 +7 +drop view v; +execute stmt; +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select (values ((select `t1`.`a` from `t1` where `t1`.`a` > 5))) AS `m` from `t2` latin1 latin1_swedish_ci +select * from v; +m +7 +7 +deallocate prepare stmt; +prepare stmt from "show create view v"; +execute stmt; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select (values ((select `t1`.`a` from `t1` where `t1`.`a` > 5))) AS `m` from `t2` latin1 latin1_swedish_ci +execute stmt; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select (values ((select `t1`.`a` from `t1` where `t1`.`a` > 5))) AS `m` from `t2` latin1 latin1_swedish_ci +deallocate prepare stmt; +drop view v; +create view v as select (values ((select * from t1 where a > 5 +union +select * from t1 where a > 7))) as m from t2; +select (values ((select * from t1 where a > 5 +union +select * from t1 where a > 7))) as m from t2; +m +7 +7 +select * from v; +m +7 +7 +show create view v; +View Create View character_set_client collation_connection +v CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v` AS select (values ((select `t1`.`a` from `t1` where `t1`.`a` > 5 union select `t1`.`a` from `t1` where `t1`.`a` > 7))) AS `m` from `t2` latin1 latin1_swedish_ci +drop view v; +drop table t1,t2; +# # End of 10.4 tests # diff --git a/mysql-test/main/table_value_constr.test b/mysql-test/main/table_value_constr.test index ade90400b63..ac623eaaf0b 100644 --- a/mysql-test/main/table_value_constr.test +++ b/mysql-test/main/table_value_constr.test @@ -1761,5 +1761,79 @@ INSERT INTO t1 (VALUES (IGNORE) UNION VALUES (IGNORE)); DROP TABLE t1; --echo # +--echo # MDEV-28603: VIEW with table value constructor used as single-value +--echo # subquery contains subquery as its first element +--echo # + +create table t1 (a int); +insert into t1 values (3), (7), (1); +create table t2 (b int); +insert into t2 values (1), (2); + +let $q= +select (values ((select * from t1 where a > 5))) as m from t2; + +eval create view v as $q; + +eval $q; +eval select * from v; +eval with cte as ( $q ) select * from cte; + +eval explain $q; +eval explain select * from v; +eval explain with cte as ( $q ) select * from cte; + +eval prepare stmt from "$q"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +eval prepare stmt from "select * from v"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +eval prepare stmt from "with cte as ( $q ) select * from cte"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +show create view v; + +drop view v; + +eval prepare stmt from "create view v as $q"; +execute stmt; +show create view v; +select * from v; +drop view v; +execute stmt; +show create view v; +select * from v; +deallocate prepare stmt; + +prepare stmt from "show create view v"; +execute stmt; +execute stmt; +deallocate prepare stmt; + +drop view v; + +let $q= +select (values ((select * from t1 where a > 5 + union + select * from t1 where a > 7))) as m from t2; + +eval create view v as $q; + +eval $q; +eval select * from v; + +show create view v; + +drop view v; +drop table t1,t2; + +--echo # --echo # End of 10.4 tests --echo # diff --git a/mysql-test/main/type_datetime.result b/mysql-test/main/type_datetime.result index 96f3c568446..0c351bcb3cd 100644 --- a/mysql-test/main/type_datetime.result +++ b/mysql-test/main/type_datetime.result @@ -545,7 +545,7 @@ select * from t1 where id in (select id from t1 as x1 where (t1.cur_date is null)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 2 100.00 Using where -1 PRIMARY x1 ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1) +1 PRIMARY x1 ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t1) Warnings: Note 1276 Field or reference 'test.t1.cur_date' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t1`.`id` AS `id`,`test`.`t1`.`cur_date` AS `cur_date` from `test`.`t1` semi join (`test`.`t1` `x1`) where `test`.`x1`.`id` = `test`.`t1`.`id` and `test`.`t1`.`cur_date` = 0 @@ -557,7 +557,7 @@ select * from t2 where id in (select id from t2 as x1 where (t2.cur_date is null)); id select_type table type possible_keys key key_len ref rows filtered Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where -1 PRIMARY x1 ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t2) +1 PRIMARY x1 ALL NULL NULL NULL NULL 2 50.00 Using where; FirstMatch(t2) Warnings: Note 1276 Field or reference 'test.t2.cur_date' of SELECT #2 was resolved in SELECT #1 Note 1003 select `test`.`t2`.`id` AS `id`,`test`.`t2`.`cur_date` AS `cur_date` from `test`.`t2` semi join (`test`.`t2` `x1`) where `test`.`x1`.`id` = `test`.`t2`.`id` and `test`.`t2`.`cur_date` = 0 diff --git a/mysql-test/main/type_time.result b/mysql-test/main/type_time.result index 40746345bdf..a863eaea686 100644 --- a/mysql-test/main/type_time.result +++ b/mysql-test/main/type_time.result @@ -2420,5 +2420,31 @@ SET @@global.mysql56_temporal_format=default; DROP PROCEDURE p1; SET timestamp=DEFAULT; # +# MDEV-26765 UNIX_TIMESTAMP(CURRENT_TIME()) return null ?!? +# +SET @@time_zone='+00:00'; +SET timestamp=1234567; +SELECT CURRENT_TIMESTAMP; +CURRENT_TIMESTAMP +1970-01-15 06:56:07 +SELECT UNIX_TIMESTAMP(CURRENT_TIME()); +UNIX_TIMESTAMP(CURRENT_TIME()) +1234567 +SELECT UNIX_TIMESTAMP(TIME'06:56:07'); +UNIX_TIMESTAMP(TIME'06:56:07') +1234567 +SELECT UNIX_TIMESTAMP(TIME'10:20:30'); +UNIX_TIMESTAMP(TIME'10:20:30') +1246830 +CREATE OR REPLACE TABLE t1 (a TIME); +INSERT INTO t1 VALUES (TIME'06:56:07'),('10:20:30'); +SELECT UNIX_TIMESTAMP(a) FROM t1 ORDER BY a; +UNIX_TIMESTAMP(a) +1234567 +1246830 +DROP TABLE t1; +SET @@time_zone=DEFAULT; +SET TIMESTAMP=DEFAULT; +# # End of 10.4 tests # diff --git a/mysql-test/main/type_time.test b/mysql-test/main/type_time.test index 0f67223238c..9ed5c3a73dc 100644 --- a/mysql-test/main/type_time.test +++ b/mysql-test/main/type_time.test @@ -1567,5 +1567,24 @@ DROP PROCEDURE p1; SET timestamp=DEFAULT; --echo # +--echo # MDEV-26765 UNIX_TIMESTAMP(CURRENT_TIME()) return null ?!? +--echo # + +SET @@time_zone='+00:00'; +SET timestamp=1234567; +SELECT CURRENT_TIMESTAMP; +SELECT UNIX_TIMESTAMP(CURRENT_TIME()); +SELECT UNIX_TIMESTAMP(TIME'06:56:07'); +SELECT UNIX_TIMESTAMP(TIME'10:20:30'); +CREATE OR REPLACE TABLE t1 (a TIME); +INSERT INTO t1 VALUES (TIME'06:56:07'),('10:20:30'); +SELECT UNIX_TIMESTAMP(a) FROM t1 ORDER BY a; +DROP TABLE t1; + +SET @@time_zone=DEFAULT; +SET TIMESTAMP=DEFAULT; + + +--echo # --echo # End of 10.4 tests --echo # diff --git a/mysql-test/main/update.result b/mysql-test/main/update.result index c6c55da229e..8dda69e4e78 100644 --- a/mysql-test/main/update.result +++ b/mysql-test/main/update.result @@ -735,6 +735,35 @@ ERROR 22007: Incorrect datetime value: '19' for column `test`.`t1`.`i1` at row 1 DROP TABLE t1,t2; # End of MariaDB 10.2 tests # +# MDEV-20773: UPDATE with LIKE predicate over non-indexed column +# of VARCHAR type +# +create table t1 (a1 varchar(30), a2 varchar(30) collate utf8_bin); +insert into t1 values +('aa','zzz'), ('b','xxaa'), ('ccc','yyy'), ('ddd','xxb'); +analyze table t1 persistent for all; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +explain extended +update t1 set a1 = 'u' + where a2 like 'xx%' and exists(select 1 from t1 where t1.a1 < 'c'); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t1 ALL NULL NULL NULL NULL 4 50.00 Using where +2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 50.00 Using where +Warnings: +Note 1003 /* select#1 */ update `test`.`t1` set `test`.`t1`.`a1` = 'u' where `test`.`t1`.`a2` like 'xx%' +update t1 set a1 = 'u' + where a2 like 'xx%' and exists(select 1 from t1 where t1.a1 < 'c'); +select * from t1; +a1 a2 +aa zzz +u xxaa +ccc yyy +u xxb +drop table t1; +# End of MariaDB 10.4 tests +# # MDEV-29189: Second execution of SF using UPDATE?DELETE # after reported error by the first execution # diff --git a/mysql-test/main/update.test b/mysql-test/main/update.test index 88fea88f120..c10c1b82a50 100644 --- a/mysql-test/main/update.test +++ b/mysql-test/main/update.test @@ -678,6 +678,29 @@ DROP TABLE t1,t2; --echo # End of MariaDB 10.2 tests --echo # +--echo # MDEV-20773: UPDATE with LIKE predicate over non-indexed column +--echo # of VARCHAR type +--echo # + +create table t1 (a1 varchar(30), a2 varchar(30) collate utf8_bin); +insert into t1 values + ('aa','zzz'), ('b','xxaa'), ('ccc','yyy'), ('ddd','xxb'); +analyze table t1 persistent for all; + +explain extended +update t1 set a1 = 'u' + where a2 like 'xx%' and exists(select 1 from t1 where t1.a1 < 'c'); + +update t1 set a1 = 'u' + where a2 like 'xx%' and exists(select 1 from t1 where t1.a1 < 'c'); + +select * from t1; + +drop table t1; + +--echo # End of MariaDB 10.4 tests + +--echo # --echo # MDEV-29189: Second execution of SF using UPDATE?DELETE --echo # after reported error by the first execution --echo # diff --git a/mysql-test/main/view.result b/mysql-test/main/view.result index b5c5564a7da..9a21c4d5c0a 100644 --- a/mysql-test/main/view.result +++ b/mysql-test/main/view.result @@ -6959,6 +6959,24 @@ create algorithm=merge view v as select * from t1 left join t2 on t1.a=t2.b and t1.a in (select d from t3); ERROR 42S22: Unknown column 'd' in 'field list' drop table t1,t2,t3; +# +# MDEV-31189: Server crash or assertion failure in upon 2nd +# execution of PS with views and HAVING +# +CREATE TABLE t (f INT); +INSERT INTO t VALUES (1),(2); +CREATE VIEW v1 AS SELECT 1 AS a; +CREATE VIEW v2 AS SELECT a FROM v1; +PREPARE stmt FROM "SELECT * FROM v2 HAVING 1 IN (SELECT f FROM t)"; +EXECUTE stmt; +a +1 +EXECUTE stmt; +a +1 +DROP VIEW v1; +DROP VIEW v2; +DROP TABLE t; # End of 10.4 tests # # MDEV-13115: SELECT .. SKIP LOCKED - ensure SHOW CREATE VIEW is correct diff --git a/mysql-test/main/view.test b/mysql-test/main/view.test index 3b3d1124a09..0892f00e65b 100644 --- a/mysql-test/main/view.test +++ b/mysql-test/main/view.test @@ -6704,6 +6704,25 @@ create algorithm=merge view v as drop table t1,t2,t3; +--echo # +--echo # MDEV-31189: Server crash or assertion failure in upon 2nd +--echo # execution of PS with views and HAVING +--echo # + +CREATE TABLE t (f INT); +INSERT INTO t VALUES (1),(2); # Optional, fails either way +CREATE VIEW v1 AS SELECT 1 AS a; +CREATE VIEW v2 AS SELECT a FROM v1; + +PREPARE stmt FROM "SELECT * FROM v2 HAVING 1 IN (SELECT f FROM t)"; +EXECUTE stmt; +EXECUTE stmt; + +# Cleanup +DROP VIEW v1; +DROP VIEW v2; +DROP TABLE t; + --echo # End of 10.4 tests --echo # |