summaryrefslogtreecommitdiff
path: root/mysql-test/main
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2018-11-10 14:52:57 -0800
committerIgor Babaev <igor@askmonty.org>2018-11-10 14:52:57 -0800
commit5f46670bd09babbee75a24ac82eb4ade0706da66 (patch)
tree85e2759b75650b8165c3e01638e9458eb4d1274c /mysql-test/main
parent8d5a11122c32f4d9eb87536886c6e893377bdd07 (diff)
parent3ea7de9a78a1410a9b79362774247e9e44b201b3 (diff)
downloadmariadb-git-5f46670bd09babbee75a24ac82eb4ade0706da66.tar.gz
Merge branch '10.4' into 10.4-mdev16188
Diffstat (limited to 'mysql-test/main')
-rw-r--r--mysql-test/main/1st.result1
-rw-r--r--mysql-test/main/alter_table.result53
-rw-r--r--mysql-test/main/alter_table.test50
-rw-r--r--mysql-test/main/alter_user.result35
-rw-r--r--mysql-test/main/alter_user.test8
-rw-r--r--mysql-test/main/auto_increment_ranges_innodb.result14
-rw-r--r--mysql-test/main/auto_increment_ranges_innodb.test13
-rw-r--r--mysql-test/main/bootstrap.result9
-rw-r--r--mysql-test/main/bootstrap.test27
-rw-r--r--mysql-test/main/brackets.result24
-rw-r--r--mysql-test/main/brackets.test18
-rw-r--r--mysql-test/main/case.result27
-rw-r--r--mysql-test/main/case.test22
-rw-r--r--mysql-test/main/cast.result2
-rw-r--r--mysql-test/main/connect.result19
-rw-r--r--mysql-test/main/connect.test19
-rw-r--r--mysql-test/main/constraints.result37
-rw-r--r--mysql-test/main/constraints.test25
-rw-r--r--mysql-test/main/contributors.result4
-rw-r--r--mysql-test/main/create_drop_user.result24
-rw-r--r--mysql-test/main/create_drop_user.test8
-rw-r--r--mysql-test/main/create_or_replace.result23
-rw-r--r--mysql-test/main/create_or_replace.test29
-rw-r--r--mysql-test/main/create_user.result24
-rw-r--r--mysql-test/main/cte_nonrecursive.result147
-rw-r--r--mysql-test/main/cte_nonrecursive.test111
-rw-r--r--mysql-test/main/cte_recursive.result303
-rw-r--r--mysql-test/main/cte_recursive.test176
-rw-r--r--mysql-test/main/ctype_binary.result23
-rw-r--r--mysql-test/main/ctype_binary.test3
-rw-r--r--mysql-test/main/ctype_eucjpms.result23
-rw-r--r--mysql-test/main/ctype_eucjpms.test2
-rw-r--r--mysql-test/main/ctype_euckr.result29
-rw-r--r--mysql-test/main/ctype_euckr.test10
-rw-r--r--mysql-test/main/ctype_gbk.result23
-rw-r--r--mysql-test/main/ctype_gbk.test3
-rw-r--r--mysql-test/main/ctype_latin1.result32
-rw-r--r--mysql-test/main/ctype_latin1.test15
-rw-r--r--mysql-test/main/ctype_uca.result21
-rw-r--r--mysql-test/main/ctype_uca.test18
-rw-r--r--mysql-test/main/ctype_ucs.result23
-rw-r--r--mysql-test/main/ctype_ucs.test4
-rw-r--r--mysql-test/main/ctype_ujis.result23
-rw-r--r--mysql-test/main/ctype_ujis.test4
-rw-r--r--mysql-test/main/ctype_upgrade.result2
-rw-r--r--mysql-test/main/ctype_utf16.result23
-rw-r--r--mysql-test/main/ctype_utf16.test5
-rw-r--r--mysql-test/main/ctype_utf16le.result29
-rw-r--r--mysql-test/main/ctype_utf16le.test13
-rw-r--r--mysql-test/main/ctype_utf32.result23
-rw-r--r--mysql-test/main/ctype_utf32.test8
-rw-r--r--mysql-test/main/ctype_utf8.result23
-rw-r--r--mysql-test/main/ctype_utf8.test7
-rw-r--r--mysql-test/main/ctype_utf8mb4.result23
-rw-r--r--mysql-test/main/ctype_utf8mb4.test8
-rw-r--r--mysql-test/main/date_formats.result2
-rw-r--r--mysql-test/main/delayed.result3
-rw-r--r--mysql-test/main/derived.result33
-rw-r--r--mysql-test/main/derived.test21
-rw-r--r--mysql-test/main/derived_cond_pushdown.result7427
-rw-r--r--mysql-test/main/derived_cond_pushdown.test2148
-rw-r--r--mysql-test/main/derived_opt.result38
-rw-r--r--mysql-test/main/derived_opt.test43
-rw-r--r--mysql-test/main/derived_split_innodb.result101
-rw-r--r--mysql-test/main/derived_split_innodb.test96
-rw-r--r--mysql-test/main/drop.test20
-rw-r--r--mysql-test/main/dyncol.result4
-rw-r--r--mysql-test/main/failed_auth_3909.result8
-rw-r--r--mysql-test/main/failed_auth_3909.test8
-rw-r--r--mysql-test/main/failed_auth_unixsocket.result11
-rw-r--r--mysql-test/main/failed_auth_unixsocket.test20
-rw-r--r--mysql-test/main/flush.result23
-rw-r--r--mysql-test/main/flush.test31
-rw-r--r--mysql-test/main/func_concat.result20
-rw-r--r--mysql-test/main/func_concat.test22
-rw-r--r--mysql-test/main/func_hybrid_type.result190
-rw-r--r--mysql-test/main/func_hybrid_type.test105
-rw-r--r--mysql-test/main/func_in.result2
-rw-r--r--mysql-test/main/func_isnull.result20
-rw-r--r--mysql-test/main/func_isnull.test16
-rw-r--r--mysql-test/main/func_json.result50
-rw-r--r--mysql-test/main/func_json.test44
-rw-r--r--mysql-test/main/func_like.result117
-rw-r--r--mysql-test/main/func_like.test50
-rw-r--r--mysql-test/main/func_sapdb.result6
-rw-r--r--mysql-test/main/func_time.result2691
-rw-r--r--mysql-test/main/func_time.test933
-rw-r--r--mysql-test/main/gis-precise.result3
-rw-r--r--mysql-test/main/gis-precise.test4
-rw-r--r--mysql-test/main/gis.result16
-rw-r--r--mysql-test/main/gis.test15
-rw-r--r--mysql-test/main/grant.result42
-rw-r--r--mysql-test/main/grant.test25
-rw-r--r--mysql-test/main/grant2.result89
-rw-r--r--mysql-test/main/grant2.test62
-rw-r--r--mysql-test/main/grant4.result16
-rw-r--r--mysql-test/main/grant5.result81
-rw-r--r--mysql-test/main/grant5.test60
-rw-r--r--mysql-test/main/grant_lowercase.result6
-rw-r--r--mysql-test/main/grant_lowercase.test4
-rw-r--r--mysql-test/main/group_min_max.result45
-rw-r--r--mysql-test/main/group_min_max.test44
-rw-r--r--mysql-test/main/help.result8
-rw-r--r--mysql-test/main/help.test8
-rw-r--r--mysql-test/main/in_subq_cond_pushdown.result32
-rw-r--r--mysql-test/main/in_subq_cond_pushdown.test39
-rw-r--r--mysql-test/main/index_merge_myisam.result50
-rw-r--r--mysql-test/main/index_merge_myisam.test35
-rw-r--r--mysql-test/main/information_schema-big.result2
-rw-r--r--mysql-test/main/information_schema.result3
-rw-r--r--mysql-test/main/information_schema_all_engines.result10
-rw-r--r--mysql-test/main/init_file_set_password-7656.result6
-rw-r--r--mysql-test/main/init_file_set_password-7656.test2
-rw-r--r--mysql-test/main/innodb_mrr_cpk.result2
-rw-r--r--mysql-test/main/invisible_field_debug.result5
-rw-r--r--mysql-test/main/invisible_field_debug.test6
-rw-r--r--mysql-test/main/join.result42
-rw-r--r--mysql-test/main/join.test54
-rw-r--r--mysql-test/main/join_cache.result33
-rw-r--r--mysql-test/main/join_cache.test32
-rw-r--r--mysql-test/main/join_nested_jcl6.result2
-rw-r--r--mysql-test/main/join_outer.result118
-rw-r--r--mysql-test/main/join_outer.test108
-rw-r--r--mysql-test/main/join_outer_jcl6.result118
-rw-r--r--mysql-test/main/lock.result4
-rw-r--r--mysql-test/main/lock.test4
-rw-r--r--mysql-test/main/lock_multi.result17
-rw-r--r--mysql-test/main/lock_multi.test18
-rw-r--r--mysql-test/main/log_tables_upgrade.result1
-rw-r--r--mysql-test/main/lowercase_fs_off.result68
-rw-r--r--mysql-test/main/lowercase_fs_off.test15
-rw-r--r--mysql-test/main/multi_update.result4
-rw-r--r--mysql-test/main/myisam.result2
-rw-r--r--mysql-test/main/myisam_recover.result4
-rw-r--r--mysql-test/main/mysql.result2
-rw-r--r--mysql-test/main/mysql.test5
-rw-r--r--mysql-test/main/mysql_not_windows.result2
-rw-r--r--mysql-test/main/mysql_not_windows.test7
-rw-r--r--mysql-test/main/mysql_protocols.result5
-rw-r--r--mysql-test/main/mysql_upgrade-6984.result1
-rw-r--r--mysql-test/main/mysql_upgrade.result10
-rw-r--r--mysql-test/main/mysql_upgrade_no_innodb.result1
-rw-r--r--mysql-test/main/mysql_upgrade_noengine.result3
-rw-r--r--mysql-test/main/mysql_upgrade_ssl.result1
-rw-r--r--mysql-test/main/mysql_upgrade_view.result3
-rw-r--r--mysql-test/main/mysqlbinlog_row_compressed.result16
-rw-r--r--mysql-test/main/mysqlbinlog_row_minimal.result16
-rw-r--r--mysql-test/main/mysqlcheck.result5
-rw-r--r--mysql-test/main/mysqld--help,win.rdiff45
-rw-r--r--mysql-test/main/mysqld--help.result11
-rw-r--r--mysql-test/main/mysqldump-max.result4
-rw-r--r--mysql-test/main/mysqldump-max.test2
-rw-r--r--mysql-test/main/mysqldump-utf8mb4.result86
-rw-r--r--mysql-test/main/mysqldump-utf8mb4.test49
-rw-r--r--mysql-test/main/mysqldump.result82
-rw-r--r--mysql-test/main/mysqldump.test4
-rw-r--r--mysql-test/main/mysqldump_restore.result20
-rw-r--r--mysql-test/main/no_password_column-mdev-11170.result2
-rw-r--r--mysql-test/main/null.result16
-rw-r--r--mysql-test/main/openssl_1.result6
-rw-r--r--mysql-test/main/openssl_1.test3
-rw-r--r--mysql-test/main/opt_tvc.result95
-rw-r--r--mysql-test/main/opt_tvc.test42
-rw-r--r--mysql-test/main/order_by_zerolength-4285.result20
-rw-r--r--mysql-test/main/order_by_zerolength-4285.test14
-rw-r--r--mysql-test/main/parser.result21
-rw-r--r--mysql-test/main/parser.test17
-rw-r--r--mysql-test/main/partition_error.result9
-rw-r--r--mysql-test/main/partition_error.test18
-rw-r--r--mysql-test/main/partition_explicit_prune.result19
-rw-r--r--mysql-test/main/partition_explicit_prune.test19
-rw-r--r--mysql-test/main/partition_pruning.result33
-rw-r--r--mysql-test/main/partition_pruning.test31
-rw-r--r--mysql-test/main/plugin.result45
-rw-r--r--mysql-test/main/plugin.test40
-rw-r--r--mysql-test/main/plugin_auth.result2
-rw-r--r--mysql-test/main/plugin_auth_qa.result32
-rw-r--r--mysql-test/main/plugin_auth_qa_1.result42
-rw-r--r--mysql-test/main/plugin_auth_qa_1.test2
-rw-r--r--mysql-test/main/plugin_auth_qa_2.result22
-rw-r--r--mysql-test/main/plugin_innodb.result2
-rw-r--r--mysql-test/main/plugin_innodb.test2
-rw-r--r--mysql-test/main/ps.result67
-rw-r--r--mysql-test/main/ps.test54
-rw-r--r--mysql-test/main/query_cache.result12
-rw-r--r--mysql-test/main/query_cache_innodb.result2
-rw-r--r--mysql-test/main/range.result73
-rw-r--r--mysql-test/main/range.test57
-rw-r--r--mysql-test/main/range_debug.result24
-rw-r--r--mysql-test/main/range_debug.test30
-rw-r--r--mysql-test/main/range_mrr_icp.result73
-rw-r--r--mysql-test/main/rename.result4
-rw-r--r--mysql-test/main/rename.test7
-rw-r--r--mysql-test/main/repair.result2
-rw-r--r--mysql-test/main/select.result32
-rw-r--r--mysql-test/main/select_jcl6.result32
-rw-r--r--mysql-test/main/select_pkeycache.result32
-rw-r--r--mysql-test/main/selectivity.result48
-rw-r--r--mysql-test/main/selectivity.test36
-rw-r--r--mysql-test/main/selectivity_innodb.result48
-rw-r--r--mysql-test/main/session_tracker_last_gtid.result6
-rw-r--r--mysql-test/main/set_password.result8
-rw-r--r--mysql-test/main/shm-master.opt1
-rw-r--r--mysql-test/main/shm.result2170
-rw-r--r--mysql-test/main/shm.test47
-rw-r--r--mysql-test/main/show_create_user.result4
-rw-r--r--mysql-test/main/show_create_user.test2
-rw-r--r--mysql-test/main/show_grants_with_plugin-7985.result4
-rw-r--r--mysql-test/main/sp-destruct.test28
-rw-r--r--mysql-test/main/sp-security.result36
-rw-r--r--mysql-test/main/sp-security.test23
-rw-r--r--mysql-test/main/sp.result17
-rw-r--r--mysql-test/main/sp.test21
-rw-r--r--mysql-test/main/sp_notembedded.result4
-rw-r--r--mysql-test/main/sp_notembedded.test2
-rw-r--r--mysql-test/main/sql_safe_updates.opt1
-rw-r--r--mysql-test/main/sql_safe_updates.result3
-rw-r--r--mysql-test/main/sql_safe_updates.test4
-rw-r--r--mysql-test/main/stat_tables.result89
-rw-r--r--mysql-test/main/stat_tables.test83
-rw-r--r--mysql-test/main/stat_tables_innodb.result89
-rw-r--r--mysql-test/main/str_to_datetime_457.result6
-rw-r--r--mysql-test/main/subselect.result22
-rw-r--r--mysql-test/main/subselect.test22
-rw-r--r--mysql-test/main/subselect_extra_no_semijoin.result22
-rw-r--r--mysql-test/main/subselect_extra_no_semijoin.test31
-rw-r--r--mysql-test/main/subselect_mat.result99
-rw-r--r--mysql-test/main/subselect_mat_cost_bugs.result2
-rw-r--r--mysql-test/main/subselect_no_exists_to_in.result22
-rw-r--r--mysql-test/main/subselect_no_mat.result22
-rw-r--r--mysql-test/main/subselect_no_opts.result22
-rw-r--r--mysql-test/main/subselect_no_scache.result22
-rw-r--r--mysql-test/main/subselect_no_semijoin.result22
-rw-r--r--mysql-test/main/subselect_sj2_mat.result51
-rw-r--r--mysql-test/main/subselect_sj2_mat.test49
-rw-r--r--mysql-test/main/subselect_sj_mat.result99
-rw-r--r--mysql-test/main/subselect_sj_mat.test79
-rw-r--r--mysql-test/main/system_mysql_db.result50
-rw-r--r--mysql-test/main/system_mysql_db_fix40123.result49
-rw-r--r--mysql-test/main/system_mysql_db_fix50030.result49
-rw-r--r--mysql-test/main/system_mysql_db_fix50117.result49
-rw-r--r--mysql-test/main/system_mysql_db_refs.result16
-rw-r--r--mysql-test/main/system_mysql_db_refs.test11
-rw-r--r--mysql-test/main/table_value_constr.result92
-rw-r--r--mysql-test/main/table_value_constr.test48
-rw-r--r--mysql-test/main/temp_table.result24
-rw-r--r--mysql-test/main/temp_table.test26
-rw-r--r--mysql-test/main/timezone2.result23
-rw-r--r--mysql-test/main/timezone2.test19
-rw-r--r--mysql-test/main/type_date.result38
-rw-r--r--mysql-test/main/type_date.test31
-rw-r--r--mysql-test/main/type_datetime.result76
-rw-r--r--mysql-test/main/type_datetime.test39
-rw-r--r--mysql-test/main/type_decimal.result14
-rw-r--r--mysql-test/main/type_decimal.test11
-rw-r--r--mysql-test/main/type_float.result40
-rw-r--r--mysql-test/main/type_float.test30
-rw-r--r--mysql-test/main/type_newdecimal.result44
-rw-r--r--mysql-test/main/type_newdecimal.test45
-rw-r--r--mysql-test/main/type_temporal_innodb.result36
-rw-r--r--mysql-test/main/type_time.result120
-rw-r--r--mysql-test/main/type_time.test70
-rw-r--r--mysql-test/main/type_timestamp.result19
-rw-r--r--mysql-test/main/type_timestamp.test22
-rw-r--r--mysql-test/main/type_year.result24
-rw-r--r--mysql-test/main/type_year.test22
-rw-r--r--mysql-test/main/union.result16
-rw-r--r--mysql-test/main/union.test15
-rw-r--r--mysql-test/main/win.result417
-rw-r--r--mysql-test/main/win.test59
-rw-r--r--mysql-test/main/win_big.result12
-rw-r--r--mysql-test/main/win_first_last_value.result20
-rw-r--r--mysql-test/main/win_lead_lag.result11
-rw-r--r--mysql-test/main/win_lead_lag.test13
-rw-r--r--mysql-test/main/win_percent_cume.result72
-rw-r--r--mysql-test/main/win_percent_cume.test6
-rw-r--r--mysql-test/main/win_percentile.result78
-rw-r--r--mysql-test/main/win_percentile.test19
-rw-r--r--mysql-test/main/win_rank.result81
-rw-r--r--mysql-test/main/win_rank.test17
-rw-r--r--mysql-test/main/win_std.test4
281 files changed, 16260 insertions, 7857 deletions
diff --git a/mysql-test/main/1st.result b/mysql-test/main/1st.result
index cb2da3505f5..2d49726c5f6 100644
--- a/mysql-test/main/1st.result
+++ b/mysql-test/main/1st.result
@@ -18,7 +18,6 @@ help_category
help_keyword
help_relation
help_topic
-host
index_stats
innodb_index_stats
innodb_table_stats
diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result
index cb3783eca5a..49c42479516 100644
--- a/mysql-test/main/alter_table.result
+++ b/mysql-test/main/alter_table.result
@@ -1411,6 +1411,59 @@ t1 CREATE TABLE `t1` (
`consultant_id` bigint(20) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8
DROP TABLE t1;
+#
+# BUG#27788685: NO WARNING WHEN TRUNCATING A STRING WITH DATA LOSS
+#
+SET GLOBAL max_allowed_packet=17825792;
+connect con1, localhost, root,,;
+CREATE TABLE t1 (t1_fld1 TEXT);
+CREATE TABLE t2 (t2_fld1 MEDIUMTEXT);
+CREATE TABLE t3 (t3_fld1 LONGTEXT);
+INSERT INTO t1 VALUES (REPEAT('a',300));
+INSERT INTO t2 VALUES (REPEAT('b',65680));
+INSERT INTO t3 VALUES (REPEAT('c',16777300));
+SELECT LENGTH(t1_fld1) FROM t1;
+LENGTH(t1_fld1)
+300
+SELECT LENGTH(t2_fld1) FROM t2;
+LENGTH(t2_fld1)
+65680
+SELECT LENGTH(t3_fld1) FROM t3;
+LENGTH(t3_fld1)
+16777300
+# With strict mode
+SET SQL_MODE='STRICT_ALL_TABLES';
+ALTER TABLE t1 CHANGE `t1_fld1` `my_t1_fld1` TINYTEXT;
+ERROR 22001: Data too long for column 'my_t1_fld1' at row 1
+ALTER TABLE t2 CHANGE `t2_fld1` `my_t2_fld1` TEXT;
+ERROR 22001: Data too long for column 'my_t2_fld1' at row 1
+ALTER TABLE t3 CHANGE `t3_fld1` `my_t3_fld1` MEDIUMTEXT;
+ERROR 22001: Data too long for column 'my_t3_fld1' at row 1
+# With non-strict mode
+SET SQL_MODE='';
+ALTER TABLE t1 CHANGE `t1_fld1` `my_t1_fld1` TINYTEXT;
+Warnings:
+Warning 1265 Data truncated for column 'my_t1_fld1' at row 1
+ALTER TABLE t2 CHANGE `t2_fld1` `my_t2_fld1` TEXT;
+Warnings:
+Warning 1265 Data truncated for column 'my_t2_fld1' at row 1
+ALTER TABLE t3 CHANGE `t3_fld1` `my_t3_fld1` MEDIUMTEXT;
+Warnings:
+Warning 1265 Data truncated for column 'my_t3_fld1' at row 1
+SELECT LENGTH(my_t1_fld1) FROM t1;
+LENGTH(my_t1_fld1)
+255
+SELECT LENGTH(my_t2_fld1) FROM t2;
+LENGTH(my_t2_fld1)
+65535
+SELECT LENGTH(my_t3_fld1) FROM t3;
+LENGTH(my_t3_fld1)
+16777215
+disconnect con1;
+connection default;
+DROP TABLE t1, t2, t3;
+SET SQL_MODE=default;
+SET GLOBAL max_allowed_packet=default;
CREATE TABLE t1 (
id INT(11) NOT NULL,
x_param INT(11) DEFAULT NULL,
diff --git a/mysql-test/main/alter_table.test b/mysql-test/main/alter_table.test
index 5c218c26923..dfa8e2e148b 100644
--- a/mysql-test/main/alter_table.test
+++ b/mysql-test/main/alter_table.test
@@ -1292,6 +1292,56 @@ MODIFY COLUMN `consultant_id` BIGINT;
SHOW CREATE TABLE t1;
DROP TABLE t1;
+--echo #
+--echo # BUG#27788685: NO WARNING WHEN TRUNCATING A STRING WITH DATA LOSS
+--echo #
+
+SET GLOBAL max_allowed_packet=17825792;
+
+--connect(con1, localhost, root,,)
+CREATE TABLE t1 (t1_fld1 TEXT);
+CREATE TABLE t2 (t2_fld1 MEDIUMTEXT);
+CREATE TABLE t3 (t3_fld1 LONGTEXT);
+
+INSERT INTO t1 VALUES (REPEAT('a',300));
+INSERT INTO t2 VALUES (REPEAT('b',65680));
+INSERT INTO t3 VALUES (REPEAT('c',16777300));
+
+SELECT LENGTH(t1_fld1) FROM t1;
+SELECT LENGTH(t2_fld1) FROM t2;
+SELECT LENGTH(t3_fld1) FROM t3;
+
+--echo # With strict mode
+SET SQL_MODE='STRICT_ALL_TABLES';
+
+--error ER_DATA_TOO_LONG
+ALTER TABLE t1 CHANGE `t1_fld1` `my_t1_fld1` TINYTEXT;
+--error ER_DATA_TOO_LONG
+ALTER TABLE t2 CHANGE `t2_fld1` `my_t2_fld1` TEXT;
+--error ER_DATA_TOO_LONG
+ALTER TABLE t3 CHANGE `t3_fld1` `my_t3_fld1` MEDIUMTEXT;
+
+--echo # With non-strict mode
+SET SQL_MODE='';
+
+ALTER TABLE t1 CHANGE `t1_fld1` `my_t1_fld1` TINYTEXT;
+ALTER TABLE t2 CHANGE `t2_fld1` `my_t2_fld1` TEXT;
+ALTER TABLE t3 CHANGE `t3_fld1` `my_t3_fld1` MEDIUMTEXT;
+
+SELECT LENGTH(my_t1_fld1) FROM t1;
+SELECT LENGTH(my_t2_fld1) FROM t2;
+SELECT LENGTH(my_t3_fld1) FROM t3;
+
+# Cleanup
+--disconnect con1
+--source include/wait_until_disconnected.inc
+
+--connection default
+DROP TABLE t1, t2, t3;
+
+SET SQL_MODE=default;
+SET GLOBAL max_allowed_packet=default;
+
#
# Test of ALTER TABLE IF [NOT] EXISTS
#
diff --git a/mysql-test/main/alter_user.result b/mysql-test/main/alter_user.result
index 76f811f18c7..68720b6d6c7 100644
--- a/mysql-test/main/alter_user.result
+++ b/mysql-test/main/alter_user.result
@@ -7,19 +7,19 @@ localhost root Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y
alter user CURRENT_USER;
select * from mysql.user where user = 'root' and host = 'localhost';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-localhost root Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y 0 0 0 0 N N 0.000000
+localhost root Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y 0 0 0 0 mysql_native_password N N 0.000000
alter user CURRENT_USER();
select * from mysql.user where user = 'root' and host = 'localhost';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-localhost root Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y 0 0 0 0 N N 0.000000
+localhost root Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y 0 0 0 0 mysql_native_password N N 0.000000
create user foo;
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 mysql_native_password N N 0.000000
alter user foo;
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 mysql_native_password N N 0.000000
# Test super privilege works correctly with a read only database.
SET @start_read_only = @@global.read_only;
SET GLOBAL read_only=1;
@@ -51,37 +51,43 @@ Note 1396 Operation ALTER USER failed for 'boo'
alter user foo identified by 'something';
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000
alter user foo identified by 'something2';
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *9CD58369E930E28C8996A89DB18B63294E6DC10C N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 mysql_native_password *9CD58369E930E28C8996A89DB18B63294E6DC10C N N 0.000000
alter user foo identified by password '*88C89BE093D4ECF72D039F62EBB7477EA1FD4D63';
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000
alter user foo identified with 'somecoolplugin';
+ERROR HY000: Operation ALTER USER failed for 'foo'@'%'
+show warnings;
+Level Code Message
+Warning 1524 Plugin 'somecoolplugin' is not loaded
+Error 1396 Operation ALTER USER failed for 'foo'@'%'
+alter user foo identified with 'mysql_old_password';
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 somecoolplugin N N 0.000000
-alter user foo identified with 'somecoolplugin' using 'somecoolpassphrase';
+% foo N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 mysql_old_password N N 0.000000
+alter user foo identified with 'mysql_old_password' using '0123456789ABCDEF';
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 somecoolplugin somecoolpassphrase N N 0.000000
+% foo N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N 0 0 0 0 mysql_old_password 0123456789ABCDEF N N 0.000000
# Test ssl related altering.
alter user foo identified by 'something' require SSL;
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N ANY 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N ANY 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000
alter user foo identified by 'something' require X509;
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N X509 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N X509 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000
alter user foo identified by 'something'
require cipher 'text' issuer 'foo_issuer' subject 'foo_subject';
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N SPECIFIED text foo_issuer foo_subject 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N SPECIFIED text foo_issuer foo_subject 0 0 0 0 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000
# Test resource limits altering.
alter user foo with MAX_QUERIES_PER_HOUR 10
MAX_UPDATES_PER_HOUR 20
@@ -89,5 +95,6 @@ MAX_CONNECTIONS_PER_HOUR 30
MAX_USER_CONNECTIONS 40;
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N SPECIFIED text foo_issuer foo_subject 10 20 30 40 N N 0.000000
+% foo N N N N N N N N N N N N N N N Y N N N N N N N N N Y N N N N SPECIFIED text foo_issuer foo_subject 10 20 30 40 mysql_native_password *88C89BE093D4ECF72D039F62EBB7477EA1FD4D63 N N 0.000000
drop user foo;
+update mysql.user set plugin='';
diff --git a/mysql-test/main/alter_user.test b/mysql-test/main/alter_user.test
index ca444f70a70..ef20f79a554 100644
--- a/mysql-test/main/alter_user.test
+++ b/mysql-test/main/alter_user.test
@@ -53,10 +53,14 @@ select * from mysql.user where user = 'foo';
alter user foo identified by password '*88C89BE093D4ECF72D039F62EBB7477EA1FD4D63';
select * from mysql.user where user = 'foo';
+--error ER_CANNOT_USER
alter user foo identified with 'somecoolplugin';
+show warnings;
+
+alter user foo identified with 'mysql_old_password';
select * from mysql.user where user = 'foo';
-alter user foo identified with 'somecoolplugin' using 'somecoolpassphrase';
+alter user foo identified with 'mysql_old_password' using '0123456789ABCDEF';
select * from mysql.user where user = 'foo';
--echo # Test ssl related altering.
@@ -77,3 +81,5 @@ alter user foo with MAX_QUERIES_PER_HOUR 10
MAX_USER_CONNECTIONS 40;
select * from mysql.user where user = 'foo';
drop user foo;
+
+update mysql.user set plugin='';
diff --git a/mysql-test/main/auto_increment_ranges_innodb.result b/mysql-test/main/auto_increment_ranges_innodb.result
index 1d827a5a166..0471a5a33ba 100644
--- a/mysql-test/main/auto_increment_ranges_innodb.result
+++ b/mysql-test/main/auto_increment_ranges_innodb.result
@@ -264,3 +264,17 @@ delete from t1 where a=32767;
insert into t1 values(NULL);
ERROR 22003: Out of range value for column 'a' at row 1
drop table t1;
+create table t1 (pk int auto_increment primary key, f varchar(20));
+insert t1 (f) values ('a'), ('b'), ('c'), ('d');
+select null, f into outfile 'load.data' from t1 limit 1;
+load data infile 'load.data' into table t1;
+insert t1 (f) values ('<===');
+select * from t1;
+pk f
+1 a
+2 b
+3 c
+4 d
+5 a
+6 <===
+drop table t1;
diff --git a/mysql-test/main/auto_increment_ranges_innodb.test b/mysql-test/main/auto_increment_ranges_innodb.test
index c2afee7ac66..016ca16bd91 100644
--- a/mysql-test/main/auto_increment_ranges_innodb.test
+++ b/mysql-test/main/auto_increment_ranges_innodb.test
@@ -5,3 +5,16 @@
--source include/have_innodb.inc
set default_storage_engine=innodb;
--source auto_increment_ranges.inc
+
+#
+# MDEV-17377 invalid gap in auto-increment values after LOAD DATA
+#
+create table t1 (pk int auto_increment primary key, f varchar(20));
+insert t1 (f) values ('a'), ('b'), ('c'), ('d');
+select null, f into outfile 'load.data' from t1 limit 1;
+load data infile 'load.data' into table t1;
+insert t1 (f) values ('<===');
+select * from t1;
+drop table t1;
+--let $datadir=`select @@datadir`
+--remove_file $datadir/test/load.data
diff --git a/mysql-test/main/bootstrap.result b/mysql-test/main/bootstrap.result
index 5cefc281996..eea0010b4e4 100644
--- a/mysql-test/main/bootstrap.result
+++ b/mysql-test/main/bootstrap.result
@@ -1,10 +1,10 @@
drop table if exists t1;
+# Kill the server
drop table t1;
+# Kill the server
drop table t1;
ERROR 42S02: Unknown table 'test.t1'
-set @my_max_allowed_packet= @@max_allowed_packet;
-set global max_allowed_packet=64*@@max_allowed_packet;
-set global max_allowed_packet=@my_max_allowed_packet;
+# Kill the server
drop table t1;
End of 5.1 tests
#
@@ -14,7 +14,9 @@ End of 5.1 tests
SELECT 'bug' as '' FROM INFORMATION_SCHEMA.ENGINES WHERE engine='innodb'
and SUPPORT='YES';
+# Kill the server
End of 5.5 tests
+# Kill the server
flush tables;
show create table t1;
Table Create Table
@@ -26,3 +28,4 @@ select * from mysql.plugin;
name dl
EXAMPLE ha_example.so
truncate table mysql.plugin;
+# Kill the server
diff --git a/mysql-test/main/bootstrap.test b/mysql-test/main/bootstrap.test
index 1ae9b13e050..d75be403f13 100644
--- a/mysql-test/main/bootstrap.test
+++ b/mysql-test/main/bootstrap.test
@@ -1,3 +1,4 @@
+--source include/not_embedded.inc
#
# test mysqld in bootstrap mode
#
@@ -15,7 +16,9 @@ let $MYSQLD_BOOTSTRAP_CMD= $MYSQLD_BOOTSTRAP_CMD --datadir=$MYSQLD_DATADIR --def
use test;
CREATE TABLE t1(a int);
EOF
+--source include/kill_mysqld.inc
--exec $MYSQLD_BOOTSTRAP_CMD < $MYSQLTEST_VARDIR/tmp/bootstrap_test.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1
+--source include/start_mysqld.inc
drop table t1;
remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_test.sql;
#
@@ -25,9 +28,11 @@ remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_test.sql;
use test;
CREATE TABLE t1;
EOF
+--source include/kill_mysqld.inc
--error 1
--exec $MYSQLD_BOOTSTRAP_CMD < $MYSQLTEST_VARDIR/tmp/bootstrap_error.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1
# Table t1 should not exists
+--source include/start_mysqld.inc
--error 1051
drop table t1;
remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_error.sql;
@@ -35,17 +40,15 @@ remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_error.sql;
#
# Bootstrap with a query larger than 2*thd->net.max_packet
#
-set @my_max_allowed_packet= @@max_allowed_packet;
-set global max_allowed_packet=64*@@max_allowed_packet;
--disable_query_log
create table t1 select 2 as a, concat(repeat('MySQL', @@max_allowed_packet/10), ';') as b;
eval select * into outfile '$MYSQLTEST_VARDIR/tmp/long_query.sql' from t1;
--enable_query_log
+--source include/kill_mysqld.inc
--error 1
--exec $MYSQLD_BOOTSTRAP_CMD < $MYSQLTEST_VARDIR/tmp/long_query.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1
remove_file $MYSQLTEST_VARDIR/tmp/long_query.sql;
-
-set global max_allowed_packet=@my_max_allowed_packet;
+--source include/start_mysqld.inc
drop table t1;
--echo End of 5.1 tests
@@ -62,8 +65,10 @@ SELECT 'bug' as '' FROM INFORMATION_SCHEMA.ENGINES WHERE engine='innodb'
#
# MDEV-13063 Server crashes in intern_plugin_lock or assertion `plugin_ptr->ref_count == 1' fails in plugin_init
#
+--source include/kill_mysqld.inc
--error 1
--exec $MYSQLD_BOOTSTRAP_CMD --myisam_recover_options=NONE
+--source include/start_mysqld.inc
--echo End of 5.5 tests
@@ -73,6 +78,7 @@ SELECT 'bug' as '' FROM INFORMATION_SCHEMA.ENGINES WHERE engine='innodb'
# Check that --bootstrap can install and uninstall plugins
#
let $PLUGIN_DIR=`select @@plugin_dir`;
+--source include/kill_mysqld.inc
--write_file $MYSQLTEST_VARDIR/tmp/install_plugin.sql
install soname 'ha_example';
uninstall plugin unusable;
@@ -90,6 +96,7 @@ create table t1(a int) engine=example charset=latin1;
EOF
--exec $MYSQLD_BOOTSTRAP_CMD --plugin-dir=$PLUGIN_DIR < $MYSQLTEST_VARDIR/tmp/bootstrap_plugins.sql >> $MYSQLTEST_VARDIR/tmp/bootstrap.log 2>&1
--remove_file $MYSQLTEST_VARDIR/tmp/bootstrap_plugins.sql
+--source include/start_mysqld.inc
flush tables;
show create table t1;
drop table t1;
@@ -104,5 +111,17 @@ truncate table mysql.plugin;
--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
+
+#
+# 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
+
+--source include/start_mysqld.inc
diff --git a/mysql-test/main/brackets.result b/mysql-test/main/brackets.result
index 479b74b69e4..e789cdeff76 100644
--- a/mysql-test/main/brackets.result
+++ b/mysql-test/main/brackets.result
@@ -219,4 +219,28 @@ select 1 union select 1 union select 1;
((select 1) union (select 1) union (select 1));
1
1
+#
+# MDEV-16357: union in brackets with tail
+# union with tail in brackets
+#
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES(1),(2),(3),(4);
+CREATE TABLE t2 (a int);
+INSERT INTO t2 VALUES (4),(5),(6),(7);
+(SELECT a FROM t1 UNION SELECT a FROM t2) LIMIT 1;
+a
+1
+(SELECT a FROM t1 UNION SELECT a FROM t2) ORDER BY a DESC;
+a
+7
+6
+5
+4
+3
+2
+1
+(SELECT a FROM t1 UNION SELECT a FROM t2 LIMIT 1);
+a
+1
+DROP TABLE t1,t2;
# End of 10.4 tests
diff --git a/mysql-test/main/brackets.test b/mysql-test/main/brackets.test
index 699c70a900f..0eaa3bfc0a2 100644
--- a/mysql-test/main/brackets.test
+++ b/mysql-test/main/brackets.test
@@ -88,5 +88,23 @@ select 1 union select 1 union select 1;
(select 1 union select 1 union select 1);
((select 1) union (select 1) union (select 1));
+--echo #
+--echo # MDEV-16357: union in brackets with tail
+--echo # union with tail in brackets
+--echo #
+
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES(1),(2),(3),(4);
+
+CREATE TABLE t2 (a int);
+INSERT INTO t2 VALUES (4),(5),(6),(7);
+
+(SELECT a FROM t1 UNION SELECT a FROM t2) LIMIT 1;
+(SELECT a FROM t1 UNION SELECT a FROM t2) ORDER BY a DESC;
+
+(SELECT a FROM t1 UNION SELECT a FROM t2 LIMIT 1);
+
+DROP TABLE t1,t2;
+
--echo # End of 10.4 tests
diff --git a/mysql-test/main/case.result b/mysql-test/main/case.result
index 1fd1ad86a8e..926ac000eb0 100644
--- a/mysql-test/main/case.result
+++ b/mysql-test/main/case.result
@@ -546,5 +546,32 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 'a'
DROP TABLE t1;
#
+# MDEV-17411 Wrong WHERE optimization with simple CASE and searched CASE
+#
+CREATE TABLE t1 (a INT, b INT, KEY(a));
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
+SELECT * FROM t1 WHERE CASE a WHEN b THEN 1 END=1;
+a b
+1 1
+2 2
+3 3
+SELECT * FROM t1 WHERE CASE WHEN a THEN b ELSE 1 END=3;
+a b
+3 3
+SELECT * FROM t1 WHERE
+CASE a WHEN b THEN 1 END=1 AND
+CASE WHEN a THEN b ELSE 1 END=3;
+a b
+3 3
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE
+CASE a WHEN b THEN 1 END=1 AND
+CASE WHEN a THEN b ELSE 1 END=3;
+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 select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where (case `test`.`t1`.`a` when `test`.`t1`.`b` then 1 end) = 1 and (case when `test`.`t1`.`a` then `test`.`t1`.`b` else 1 end) = 3
+DROP TABLE t1;
+#
# End of 10.3 test
#
diff --git a/mysql-test/main/case.test b/mysql-test/main/case.test
index d7dac112b3b..78d5b3a5951 100644
--- a/mysql-test/main/case.test
+++ b/mysql-test/main/case.test
@@ -390,6 +390,28 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='a' AND CASE 'a' WHEN 'a' THEN 'a' ELS
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-17411 Wrong WHERE optimization with simple CASE and searched CASE
+--echo #
+
+CREATE TABLE t1 (a INT, b INT, KEY(a));
+INSERT INTO t1 VALUES (1,1),(2,2),(3,3);
+SELECT * FROM t1 WHERE CASE a WHEN b THEN 1 END=1;
+SELECT * FROM t1 WHERE CASE WHEN a THEN b ELSE 1 END=3;
+
+SELECT * FROM t1 WHERE
+ CASE a WHEN b THEN 1 END=1 AND
+ CASE WHEN a THEN b ELSE 1 END=3;
+
+EXPLAIN EXTENDED
+SELECT * FROM t1 WHERE
+ CASE a WHEN b THEN 1 END=1 AND
+ CASE WHEN a THEN b ELSE 1 END=3;
+
+DROP TABLE t1;
+
+
--echo #
--echo # End of 10.3 test
--echo #
diff --git a/mysql-test/main/cast.result b/mysql-test/main/cast.result
index ca314573581..f1e7eb7b502 100644
--- a/mysql-test/main/cast.result
+++ b/mysql-test/main/cast.result
@@ -313,7 +313,7 @@ select cast('' as time);
cast('' as time)
NULL
Warnings:
-Warning 1292 Truncated incorrect time value: ''
+Warning 1292 Incorrect time value: ''
select cast(NULL as DATE);
cast(NULL as DATE)
NULL
diff --git a/mysql-test/main/connect.result b/mysql-test/main/connect.result
index b05d0ea9fea..c52c9edd578 100644
--- a/mysql-test/main/connect.result
+++ b/mysql-test/main/connect.result
@@ -14,7 +14,6 @@ help_category
help_keyword
help_relation
help_topic
-host
index_stats
innodb_index_stats
innodb_table_stats
@@ -62,7 +61,6 @@ help_category
help_keyword
help_relation
help_topic
-host
index_stats
innodb_index_stats
innodb_table_stats
@@ -100,11 +98,10 @@ ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
connect(localhost,test,zorro,test,MASTER_PORT,MASTER_SOCKET);
connect fail_con,localhost,test,zorro,;
ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
-update mysql.user set password=old_password("gambling2") where user=_binary"test";
+update mysql.user set plugin="", authentication_string="", password=old_password("gambling2") where user=_binary"test";
flush privileges;
connect con10,localhost,test,gambling2,;
connect con5,localhost,test,gambling2,mysql;
-connection con5;
set password="";
set password='gambling3';
ERROR HY000: Password hash should be a 41-digit hexadecimal number
@@ -122,7 +119,6 @@ help_category
help_keyword
help_relation
help_topic
-host
index_stats
innodb_index_stats
innodb_table_stats
@@ -164,7 +160,6 @@ ERROR 28000: Access denied for user 'test'@'localhost' (using password: YES)
delete from mysql.user where user=_binary"test";
flush privileges;
connect con7,localhost,root,,test;
-connection con7;
create table t1 (id integer not null auto_increment primary key);
create temporary table t2(id integer not null auto_increment primary key);
set @id := 1;
@@ -305,12 +300,10 @@ SET GLOBAL event_scheduler = OFF;
# -- End of Bug#35074.
connect extracon,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,;
-connection extracon;
SELECT 'Connection on extra port ok';
Connection on extra port ok
Connection on extra port ok
connect extracon2,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,;
-connection extracon2;
SELECT 'Connection on extra port 2 ok';
Connection on extra port 2 ok
Connection on extra port 2 ok
@@ -341,7 +334,6 @@ connect(localhost,mysqltest_up1,foo,test,MASTER_PORT,MASTER_SOCKET);
connect pcon1,localhost,mysqltest_up1,foo,,$MASTER_MYPORT,;
ERROR 28000: Access denied for user 'mysqltest_up1'@'localhost' (using password: YES)
connect pcon2,localhost,mysqltest_up1,bar,,$MASTER_MYPORT,;
-connection pcon2;
select user(), current_user();
user() current_user()
mysqltest_up1@localhost mysqltest_up1@%
@@ -350,7 +342,6 @@ connect(localhost,mysqltest_up2,newpw,test,MASTER_PORT,MASTER_SOCKET);
connect pcon3,localhost,mysqltest_up2,newpw,,$MASTER_MYPORT,;
ERROR 28000: Access denied for user 'mysqltest_up2'@'localhost' (using password: YES)
connect pcon4,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,;
-connection pcon4;
select user(), current_user();
user() current_user()
mysqltest_up2@localhost mysqltest_up2@%
@@ -367,17 +358,15 @@ update mysql.user set plugin='mysql_old_password' where user = 'mysqltest_up2';
select user, password, plugin, authentication_string from mysql.user
where user like 'mysqltest_up_';
user password plugin authentication_string
-mysqltest_up1 *E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB mysql_native_password
-mysqltest_up2 09301740536db389 mysql_old_password
+mysqltest_up1 mysql_native_password *E8D46CE25265E545D225A8A6F1BAF642FEBEE5CB
+mysqltest_up2 mysql_old_password 09301740536db389
flush privileges;
connect pcon6,localhost,mysqltest_up1,bar,,$MASTER_MYPORT,;
-connection pcon6;
select user(), current_user();
user() current_user()
mysqltest_up1@localhost mysqltest_up1@%
disconnect pcon6;
connect pcon7,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,;
-connection pcon7;
select user(), current_user();
user() current_user()
mysqltest_up2@localhost mysqltest_up2@%
@@ -386,7 +375,7 @@ connection default;
DROP USER mysqltest_up1@'%';
DROP USER mysqltest_up2@'%';
#
-# BUG#1010351: New "via" keyword in 5.2+ can't be used as identifier anymore
+# BUG#1010351: New "via" keyword in 5.2+ can't be used as identifier anymore
#
create table t1 (via int);
alter table t1 add key(via);
diff --git a/mysql-test/main/connect.test b/mysql-test/main/connect.test
index c2d44c08e22..9bc067f3236 100644
--- a/mysql-test/main/connect.test
+++ b/mysql-test/main/connect.test
@@ -66,12 +66,11 @@ connect (fail_con,localhost,test,zorro,test2);
connect (fail_con,localhost,test,zorro,);
# check if old password version also works
-update mysql.user set password=old_password("gambling2") where user=_binary"test";
+update mysql.user set plugin="", authentication_string="", password=old_password("gambling2") where user=_binary"test";
flush privileges;
connect (con10,localhost,test,gambling2,);
connect (con5,localhost,test,gambling2,mysql);
-connection con5;
set password="";
--error ER_PASSWD_LENGTH
set password='gambling3';
@@ -108,7 +107,6 @@ flush privileges;
# Bug#12517 Clear user variables and replication events before
# closing temp tables in thread cleanup.
connect (con7,localhost,root,,test);
-connection con7;
let $connection_id= `select connection_id()`;
create table t1 (id integer not null auto_increment primary key);
create temporary table t2(id integer not null auto_increment primary key);
@@ -314,11 +312,9 @@ SET GLOBAL event_scheduler = OFF;
# Test connections to the extra port.
connect(extracon,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
-connection extracon;
SELECT 'Connection on extra port ok';
connect(extracon2,127.0.0.1,root,,test,$MASTER_EXTRA_PORT,);
-connection extracon2;
SELECT 'Connection on extra port 2 ok';
--disable_abort_on_error
@@ -349,7 +345,6 @@ GRANT ALL ON test.* TO 'O1234567890123456789012345678901234567890123456789012345
FLUSH PRIVILEGES;
---replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
connect (con1,localhost,O1234567890123456789012345678901234567890123456789012345678901234567890123456789x,test123,test);
disconnect con1;
@@ -380,18 +375,14 @@ CREATE USER mysqltest_up2 IDENTIFIED VIA mysql_old_password using '09301740536db
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error ER_ACCESS_DENIED_ERROR
connect(pcon1,localhost,mysqltest_up1,foo,,$MASTER_MYPORT,);
---replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
connect(pcon2,localhost,mysqltest_up1,bar,,$MASTER_MYPORT,);
-connection pcon2;
select user(), current_user();
disconnect pcon2;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
--error ER_ACCESS_DENIED_ERROR
connect(pcon3,localhost,mysqltest_up2,newpw,,$MASTER_MYPORT,);
---replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
connect(pcon4,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,);
-connection pcon4;
select user(), current_user();
disconnect pcon4;
@@ -419,17 +410,13 @@ update mysql.user set plugin='mysql_native_password' where user = 'mysqltest_up1
update mysql.user set plugin='mysql_old_password' where user = 'mysqltest_up2';
select user, password, plugin, authentication_string from mysql.user
where user like 'mysqltest_up_';
-flush privileges;
+flush privileges;
---replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
connect(pcon6,localhost,mysqltest_up1,bar,,$MASTER_MYPORT,);
-connection pcon6;
select user(), current_user();
disconnect pcon6;
---replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
connect(pcon7,localhost,mysqltest_up2,oldpw,,$MASTER_MYPORT,);
-connection pcon7;
select user(), current_user();
disconnect pcon7;
connection default;
@@ -442,7 +429,7 @@ DROP USER mysqltest_up2@'%';
--echo #
---echo # BUG#1010351: New "via" keyword in 5.2+ can't be used as identifier anymore
+--echo # BUG#1010351: New "via" keyword in 5.2+ can't be used as identifier anymore
--echo #
create table t1 (via int);
alter table t1 add key(via);
diff --git a/mysql-test/main/constraints.result b/mysql-test/main/constraints.result
index 57cfbfb3d37..3c061989fd3 100644
--- a/mysql-test/main/constraints.result
+++ b/mysql-test/main/constraints.result
@@ -74,3 +74,40 @@ CREATE TABLE t_illegal (col_1 INT CHECK something (whatever));
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 'something (whatever))' at line 1
CREATE TABLE t_illegal (col_1 INT CHECK something);
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 'something)' at line 1
+CREATE TABLE long_enough_name (
+pk int(11) NOT NULL,
+f1 int(11) DEFAULT NULL,
+f2 int(11) NOT NULL,
+f3 int(11) DEFAULT NULL,
+f4 timestamp NOT NULL DEFAULT current_timestamp(),
+f5 varchar(32) COLLATE utf8_bin NOT NULL DEFAULT 'foo',
+f6 smallint(6) NOT NULL DEFAULT 1,
+f7 int(11) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY idx1 (f7),
+KEY idx2 (f1),
+KEY idx3 (f2),
+KEY idx4 (f3),
+CONSTRAINT constr CHECK (f6 >= 0)
+);
+SELECT * FROM long_enough_name AS tbl;
+pk f1 f2 f3 f4 f5 f6 f7
+SHOW CREATE TABLE long_enough_name;
+Table Create Table
+long_enough_name CREATE TABLE `long_enough_name` (
+ `pk` int(11) NOT NULL,
+ `f1` int(11) DEFAULT NULL,
+ `f2` int(11) NOT NULL,
+ `f3` int(11) DEFAULT NULL,
+ `f4` timestamp NOT NULL DEFAULT current_timestamp(),
+ `f5` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT 'foo',
+ `f6` smallint(6) NOT NULL DEFAULT 1,
+ `f7` int(11) DEFAULT NULL,
+ PRIMARY KEY (`pk`),
+ KEY `idx1` (`f7`),
+ KEY `idx2` (`f1`),
+ KEY `idx3` (`f2`),
+ KEY `idx4` (`f3`),
+ CONSTRAINT `constr` CHECK (`f6` >= 0)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE long_enough_name;
diff --git a/mysql-test/main/constraints.test b/mysql-test/main/constraints.test
index 1997c23bfa9..fe51e5060dc 100644
--- a/mysql-test/main/constraints.test
+++ b/mysql-test/main/constraints.test
@@ -77,3 +77,28 @@ CREATE TABLE t_illegal (col_1 INT CHECK something (whatever));
--error ER_PARSE_ERROR
CREATE TABLE t_illegal (col_1 INT CHECK something);
+#
+# MDEV-17065 Crash on SHOW CREATE TABLE with CHECK CONSTRAINT
+#
+
+CREATE TABLE long_enough_name (
+pk int(11) NOT NULL,
+f1 int(11) DEFAULT NULL,
+f2 int(11) NOT NULL,
+f3 int(11) DEFAULT NULL,
+f4 timestamp NOT NULL DEFAULT current_timestamp(),
+f5 varchar(32) COLLATE utf8_bin NOT NULL DEFAULT 'foo',
+f6 smallint(6) NOT NULL DEFAULT 1,
+f7 int(11) DEFAULT NULL,
+PRIMARY KEY (pk),
+KEY idx1 (f7),
+KEY idx2 (f1),
+KEY idx3 (f2),
+KEY idx4 (f3),
+CONSTRAINT constr CHECK (f6 >= 0)
+);
+
+SELECT * FROM long_enough_name AS tbl;
+SHOW CREATE TABLE long_enough_name;
+
+DROP TABLE long_enough_name;
diff --git a/mysql-test/main/contributors.result b/mysql-test/main/contributors.result
index 36d033f4cb3..3e4bf5f0d43 100644
--- a/mysql-test/main/contributors.result
+++ b/mysql-test/main/contributors.result
@@ -8,12 +8,14 @@ MariaDB Corporation https://mariadb.com Founding member, Platinum Sponsor of the
Visma https://visma.com Gold Sponsor of the MariaDB Foundation
DBS https://dbs.com Gold Sponsor of the MariaDB Foundation
IBM https://www.ibm.com Gold Sponsor of the MariaDB Foundation
+Tencent Games http://game.qq.com/ Gold Sponsor of the MariaDB Foundation
Nexedi https://www.nexedi.com Silver Sponsor of the MariaDB Foundation
-Acronis http://www.acronis.com Silver Sponsor of the MariaDB Foundation
+Acronis https://www.acronis.com Silver Sponsor of the MariaDB Foundation
Verkkokauppa.com https://www.verkkokauppa.com Bronze Sponsor of the MariaDB Foundation
Virtuozzo https://virtuozzo.com Bronze Sponsor of the MariaDB Foundation
Tencent Game DBA http://tencentdba.com/about Bronze Sponsor of the MariaDB Foundation
Tencent TDSQL http://tdsql.org Bronze Sponsor of the MariaDB Foundation
+Percona https://www.percona.com/ Bronze Sponsor of the MariaDB Foundation
Google USA Sponsoring encryption, parallel replication and GTID
Facebook USA Sponsoring non-blocking API, LIMIT ROWS EXAMINED etc
Ronald Bradford Brisbane, Australia EFF contribution for UC2006 Auction
diff --git a/mysql-test/main/create_drop_user.result b/mysql-test/main/create_drop_user.result
index dd75d1c257a..67717f3e4e0 100644
--- a/mysql-test/main/create_drop_user.result
+++ b/mysql-test/main/create_drop_user.result
@@ -1,22 +1,22 @@
CREATE USER IF NOT EXISTS u1@localhost IDENTIFIED BY 'pw1';
-SELECT password FROM mysql.user WHERE user='u1';
-password
-*2B602296A79E0A8784ACC5C88D92E46588CCA3C3
+SELECT plugin,authentication_string FROM mysql.user WHERE user='u1';
+plugin authentication_string
+mysql_native_password *2B602296A79E0A8784ACC5C88D92E46588CCA3C3
CREATE USER IF NOT EXISTS u1@localhost IDENTIFIED BY 'pw2';
Warnings:
Note 1973 Can't create user 'u1'@'localhost'; it already exists
-SELECT password FROM mysql.user WHERE user='u1';
-password
-*2B602296A79E0A8784ACC5C88D92E46588CCA3C3
+SELECT plugin,authentication_string FROM mysql.user WHERE user='u1';
+plugin authentication_string
+mysql_native_password *2B602296A79E0A8784ACC5C88D92E46588CCA3C3
CREATE OR REPLACE USER u1@localhost IDENTIFIED BY 'pw3';
-SELECT password FROM mysql.user WHERE user='u1';
-password
-*77B4A70CEFD76DB9415F36D291E74C110D2738E0
+SELECT plugin,authentication_string FROM mysql.user WHERE user='u1';
+plugin authentication_string
+mysql_native_password *77B4A70CEFD76DB9415F36D291E74C110D2738E0
CREATE OR REPLACE USER IF NOT EXISTS u1@localhost IDENTIFIED BY 'pw4';
ERROR HY000: Incorrect usage of OR REPLACE and IF NOT EXISTS
-SELECT password FROM mysql.user WHERE user='u1';
-password
-*77B4A70CEFD76DB9415F36D291E74C110D2738E0
+SELECT plugin,authentication_string FROM mysql.user WHERE user='u1';
+plugin authentication_string
+mysql_native_password *77B4A70CEFD76DB9415F36D291E74C110D2738E0
DROP USER IF EXISTS u1@localhost;
DROP USER IF EXISTS u1@localhost;
Warnings:
diff --git a/mysql-test/main/create_drop_user.test b/mysql-test/main/create_drop_user.test
index 949782a2daf..234383fb4ca 100644
--- a/mysql-test/main/create_drop_user.test
+++ b/mysql-test/main/create_drop_user.test
@@ -1,17 +1,17 @@
--source include/not_embedded.inc
CREATE USER IF NOT EXISTS u1@localhost IDENTIFIED BY 'pw1';
-SELECT password FROM mysql.user WHERE user='u1';
+SELECT plugin,authentication_string FROM mysql.user WHERE user='u1';
CREATE USER IF NOT EXISTS u1@localhost IDENTIFIED BY 'pw2';
-SELECT password FROM mysql.user WHERE user='u1';
+SELECT plugin,authentication_string FROM mysql.user WHERE user='u1';
CREATE OR REPLACE USER u1@localhost IDENTIFIED BY 'pw3';
-SELECT password FROM mysql.user WHERE user='u1';
+SELECT plugin,authentication_string FROM mysql.user WHERE user='u1';
--error ER_WRONG_USAGE
CREATE OR REPLACE USER IF NOT EXISTS u1@localhost IDENTIFIED BY 'pw4';
-SELECT password FROM mysql.user WHERE user='u1';
+SELECT plugin,authentication_string FROM mysql.user WHERE user='u1';
DROP USER IF EXISTS u1@localhost;
DROP USER IF EXISTS u1@localhost;
diff --git a/mysql-test/main/create_or_replace.result b/mysql-test/main/create_or_replace.result
index 0c1bccb861a..54bec5c3f9d 100644
--- a/mysql-test/main/create_or_replace.result
+++ b/mysql-test/main/create_or_replace.result
@@ -479,6 +479,21 @@ UNLOCK TABLES;
DROP FUNCTION f1;
DROP TABLE t1;
#
+# MDEV-14410 - Assertion `table->pos_in_locked_tables == __null ||
+# table->pos_in_locked_tables->table == table' failed in
+# mark_used_tables_as_free_for_reuse
+#
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (b INT);
+CREATE TABLE t3 (c INT);
+CREATE TRIGGER tr1 BEFORE INSERT ON t3 FOR EACH ROW INSERT INTO t1 VALUES ();
+CREATE TRIGGER tr2 BEFORE INSERT ON t2 FOR EACH ROW INSERT INTO t3 SELECT * FROM t1;
+LOCK TABLE t1 WRITE, t2 WRITE;
+CREATE OR REPLACE TABLE t1 (i INT);
+UNLOCK TABLES;
+INSERT INTO t2 VALUES (1);
+DROP TABLE t1, t2, t3;
+#
# MDEV-11071 - Assertion `thd->transaction.stmt.is_empty()' failed in
# Locked_tables_list::unlock_locked_tables
#
@@ -488,12 +503,12 @@ CREATE TABLE t3(a INT);
LOCK TABLE t2 WRITE;
SELECT * FROM t2;
a
-CREATE OR REPLACE TEMPORARY TABLE t1(a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
-ERROR HY000: CREATE TEMPORARY TABLE is not allowed with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE.
+CREATE OR REPLACE TEMPORARY TABLE t1(c INT DEFAULT '');
+ERROR 42000: Invalid default value for 'c'
SELECT * FROM t3;
ERROR HY000: Table 't3' was not locked with LOCK TABLES
-CREATE OR REPLACE TEMPORARY TABLE t2(a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
-ERROR HY000: CREATE TEMPORARY TABLE is not allowed with ROW_FORMAT=COMPRESSED or KEY_BLOCK_SIZE.
+CREATE OR REPLACE TEMPORARY TABLE t2(c INT DEFAULT '');
+ERROR 42000: Invalid default value for 'c'
SELECT * FROM t3;
ERROR HY000: Table 't3' was not locked with LOCK TABLES
UNLOCK TABLES;
diff --git a/mysql-test/main/create_or_replace.test b/mysql-test/main/create_or_replace.test
index 3ae882139bc..4b167663742 100644
--- a/mysql-test/main/create_or_replace.test
+++ b/mysql-test/main/create_or_replace.test
@@ -422,6 +422,27 @@ UNLOCK TABLES;
DROP FUNCTION f1;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-14410 - Assertion `table->pos_in_locked_tables == __null ||
+--echo # table->pos_in_locked_tables->table == table' failed in
+--echo # mark_used_tables_as_free_for_reuse
+--echo #
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (b INT);
+CREATE TABLE t3 (c INT);
+
+CREATE TRIGGER tr1 BEFORE INSERT ON t3 FOR EACH ROW INSERT INTO t1 VALUES ();
+CREATE TRIGGER tr2 BEFORE INSERT ON t2 FOR EACH ROW INSERT INTO t3 SELECT * FROM t1;
+
+LOCK TABLE t1 WRITE, t2 WRITE;
+CREATE OR REPLACE TABLE t1 (i INT);
+UNLOCK TABLES;
+INSERT INTO t2 VALUES (1);
+
+# Cleanup
+DROP TABLE t1, t2, t3;
+
--echo #
--echo # MDEV-11071 - Assertion `thd->transaction.stmt.is_empty()' failed in
--echo # Locked_tables_list::unlock_locked_tables
@@ -432,14 +453,14 @@ CREATE TABLE t3(a INT);
LOCK TABLE t2 WRITE;
SELECT * FROM t2;
# drops t2
---error ER_UNSUPPORT_COMPRESSED_TEMPORARY_TABLE
-CREATE OR REPLACE TEMPORARY TABLE t1(a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
+--error ER_INVALID_DEFAULT
+CREATE OR REPLACE TEMPORARY TABLE t1(c INT DEFAULT '');
# make sure we didn't leave locked tables mode
--error ER_TABLE_NOT_LOCKED
SELECT * FROM t3;
# drops t1
---error ER_UNSUPPORT_COMPRESSED_TEMPORARY_TABLE
-CREATE OR REPLACE TEMPORARY TABLE t2(a INT) ENGINE=InnoDB ROW_FORMAT=COMPRESSED;
+--error ER_INVALID_DEFAULT
+CREATE OR REPLACE TEMPORARY TABLE t2(c INT DEFAULT '');
# make sure we didn't leave locked tables mode
--error ER_TABLE_NOT_LOCKED
SELECT * FROM t3;
diff --git a/mysql-test/main/create_user.result b/mysql-test/main/create_user.result
index 8001b43221b..bd10c6aba3b 100644
--- a/mysql-test/main/create_user.result
+++ b/mysql-test/main/create_user.result
@@ -1,57 +1,57 @@
create user foo;
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 mysql_native_password N N 0.000000
drop user foo;
create user foo identified by 'password';
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 0 0 0 0 mysql_native_password *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N 0.000000
drop user foo;
create user foo identified by 'password' require SSL;
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ANY 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ANY 0 0 0 0 mysql_native_password *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N 0.000000
drop user foo;
create user foo identified by 'password' require X509;
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N X509 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N X509 0 0 0 0 mysql_native_password *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N 0.000000
drop user foo;
create user foo identified by 'password' require CIPHER 'cipher';
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED cipher 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED cipher 0 0 0 0 mysql_native_password *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N 0.000000
drop user foo;
create user foo identified by 'password' require ISSUER 'issuer';
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED issuer 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED issuer 0 0 0 0 mysql_native_password *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N 0.000000
drop user foo;
create user foo identified by 'password' require SUBJECT 'subject';
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED subject 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED subject 0 0 0 0 mysql_native_password *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N 0.000000
drop user foo;
create user foo identified by 'password' require CIPHER 'cipher'
SUBJECT 'subject';
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED cipher subject 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED cipher subject 0 0 0 0 mysql_native_password *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N 0.000000
drop user foo;
create user foo identified by 'password' require CIPHER 'cipher'
AND SUBJECT 'subject'
AND ISSUER 'issuer';
select * from mysql.user where user = 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED cipher issuer subject 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED cipher issuer subject 0 0 0 0 mysql_native_password *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 N N 0.000000
drop user foo;
create user foo, foo2 identified by 'password' require CIPHER 'cipher'
AND SUBJECT 'subject'
AND ISSUER 'issuer';
select * from mysql.user where user like 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED cipher issuer subject 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED cipher issuer subject 0 0 0 0 mysql_native_password N N 0.000000
#--warning ER_USER_CREATE_EXISTS
create user if not exists foo, foo2 identified by 'password2'
require CIPHER 'cipher2' AND SUBJECT 'subject2' AND ISSUER 'issuer2';
@@ -60,7 +60,7 @@ Note 1973 Can't create user 'foo'@'%'; it already exists
Note 1973 Can't create user 'foo2'@'%'; it already exists
select * from mysql.user where user like 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED cipher issuer subject 0 0 0 0 N N 0.000000
+% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N SPECIFIED cipher issuer subject 0 0 0 0 mysql_native_password N N 0.000000
drop user foo, foo2;
create user foo with MAX_QUERIES_PER_HOUR 10
MAX_UPDATES_PER_HOUR 20
@@ -68,5 +68,5 @@ MAX_CONNECTIONS_PER_HOUR 30
MAX_USER_CONNECTIONS 40;
select * from mysql.user where user like 'foo';
Host User Password Select_priv Insert_priv Update_priv Delete_priv Create_priv Drop_priv Reload_priv Shutdown_priv Process_priv File_priv Grant_priv References_priv Index_priv Alter_priv Show_db_priv Super_priv Create_tmp_table_priv Lock_tables_priv Execute_priv Repl_slave_priv Repl_client_priv Create_view_priv Show_view_priv Create_routine_priv Alter_routine_priv Create_user_priv Event_priv Trigger_priv Create_tablespace_priv Delete_history_priv ssl_type ssl_cipher x509_issuer x509_subject max_questions max_updates max_connections max_user_connections plugin authentication_string password_expired is_role default_role max_statement_time
-% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 10 20 30 40 N N 0.000000
+% foo N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N 10 20 30 40 mysql_native_password N N 0.000000
drop user foo;
diff --git a/mysql-test/main/cte_nonrecursive.result b/mysql-test/main/cte_nonrecursive.result
index 96e9f527253..eeae6d02476 100644
--- a/mysql-test/main/cte_nonrecursive.result
+++ b/mysql-test/main/cte_nonrecursive.result
@@ -1512,3 +1512,150 @@ a a
1 1
drop database db_mdev_16473;
use test;
+#
+# MDEV-17154: using parameter markers for PS within CTEs more than once
+# using local variables in SP within CTEs more than once
+#
+prepare stmt from "
+with cte(c) as (select ? ) select r.c, s.c+10 from cte as r, cte as s;
+";
+set @a=2;
+execute stmt using @a;
+c s.c+10
+2 12
+set @a=5;
+execute stmt using @a;
+c s.c+10
+5 15
+deallocate prepare stmt;
+prepare stmt from "
+with cte(c) as (select ? ) select c from cte union select c+10 from cte;
+";
+set @a=2;
+execute stmt using @a;
+c
+2
+12
+set @a=5;
+execute stmt using @a;
+c
+5
+15
+deallocate prepare stmt;
+prepare stmt from "
+with cte_e(a,b) as
+(
+ with cte_o(c) as (select ?)
+ select r.c+10, s.c+20 from cte_o as r, cte_o as s
+)
+select * from cte_e as cte_e1 where a > 12
+union all
+select * from cte_e as cte_e2;
+";
+set @a=2;
+execute stmt using @a;
+a b
+12 22
+set @a=5;
+execute stmt using @a;
+a b
+15 25
+15 25
+deallocate prepare stmt;
+create table t1 (a int, b int);
+insert into t1 values
+(3,33), (1,17), (7,72), (4,45), (2,27), (3,35), (4,47), (3,38), (2,22);
+prepare stmt from "
+with cte as (select * from t1 where a < ? and b > ?)
+ select r.a, r.b+10, s.a, s.b+20 from cte as r, cte as s where r.a=s.a+1;
+";
+set @a=4, @b=20;
+execute stmt using @a,@b;
+a r.b+10 a s.b+20
+3 43 2 47
+3 45 2 47
+3 48 2 47
+3 43 2 42
+3 45 2 42
+3 48 2 42
+set @a=5, @b=20;
+execute stmt using @a,@b;
+a r.b+10 a s.b+20
+4 55 3 53
+4 57 3 53
+3 43 2 47
+3 45 2 47
+3 48 2 47
+4 55 3 55
+4 57 3 55
+4 55 3 58
+4 57 3 58
+3 43 2 42
+3 45 2 42
+3 48 2 42
+deallocate prepare stmt;
+create procedure p1()
+begin
+declare i int;
+set i = 0;
+while i < 4 do
+insert into t1
+with cte(a) as (select i) select r.a-1, s.a+1 from cte as r, cte as s;
+set i = i+1;
+end while;
+end|
+create procedure p2(in i int)
+begin
+insert into t1
+with cte(a) as (select i) select r.a-1, s.a+1 from cte as r, cte as s;
+end|
+delete from t1;
+call p1();
+select * from t1;
+a b
+-1 1
+0 2
+1 3
+2 4
+call p1();
+select * from t1;
+a b
+-1 1
+0 2
+1 3
+2 4
+-1 1
+0 2
+1 3
+2 4
+delete from t1;
+call p2(3);
+select * from t1;
+a b
+2 4
+call p2(7);
+select * from t1;
+a b
+2 4
+6 8
+drop procedure p1;
+drop procedure p2;
+drop table t1;
+#
+# MDEV-17107: PS for CREATE OR REPLACE VIEW defined by SELECT with CTEs
+#
+create table t1(a int);
+insert into t1 values (3), (1), (2);
+create table t2 (b int);
+insert into t2 values (2), (10);
+prepare stmt from
+"create or replace view v1 as
+ with t as (select s.a from (select t1.a from t1) s),
+ r as(select t.a from t2, t where t2.b=t.a)
+ select a from r;";
+execute stmt;
+select * from v1;
+a
+2
+drop view v1;
+drop table t1,t2;
diff --git a/mysql-test/main/cte_nonrecursive.test b/mysql-test/main/cte_nonrecursive.test
index 11c864bcac1..920c27a70f9 100644
--- a/mysql-test/main/cte_nonrecursive.test
+++ b/mysql-test/main/cte_nonrecursive.test
@@ -1057,3 +1057,114 @@ select * from cte, db_mdev_16473.t1 as t where cte.a=t.a;
drop database db_mdev_16473;
use test;
+
+--echo #
+--echo # MDEV-17154: using parameter markers for PS within CTEs more than once
+--echo # using local variables in SP within CTEs more than once
+--echo #
+
+prepare stmt from "
+with cte(c) as (select ? ) select r.c, s.c+10 from cte as r, cte as s;
+";
+set @a=2;
+execute stmt using @a;
+set @a=5;
+execute stmt using @a;
+deallocate prepare stmt;
+
+prepare stmt from "
+with cte(c) as (select ? ) select c from cte union select c+10 from cte;
+";
+set @a=2;
+execute stmt using @a;
+set @a=5;
+execute stmt using @a;
+deallocate prepare stmt;
+
+prepare stmt from "
+with cte_e(a,b) as
+(
+ with cte_o(c) as (select ?)
+ select r.c+10, s.c+20 from cte_o as r, cte_o as s
+)
+select * from cte_e as cte_e1 where a > 12
+union all
+select * from cte_e as cte_e2;
+";
+set @a=2;
+execute stmt using @a;
+set @a=5;
+execute stmt using @a;
+deallocate prepare stmt;
+
+create table t1 (a int, b int);
+insert into t1 values
+ (3,33), (1,17), (7,72), (4,45), (2,27), (3,35), (4,47), (3,38), (2,22);
+
+prepare stmt from "
+with cte as (select * from t1 where a < ? and b > ?)
+ select r.a, r.b+10, s.a, s.b+20 from cte as r, cte as s where r.a=s.a+1;
+";
+set @a=4, @b=20;
+execute stmt using @a,@b;
+set @a=5, @b=20;
+execute stmt using @a,@b;
+deallocate prepare stmt;
+
+delimiter |;
+
+create procedure p1()
+begin
+ declare i int;
+ set i = 0;
+ while i < 4 do
+ insert into t1
+ with cte(a) as (select i) select r.a-1, s.a+1 from cte as r, cte as s;
+ set i = i+1;
+ end while;
+end|
+
+create procedure p2(in i int)
+begin
+ insert into t1
+ with cte(a) as (select i) select r.a-1, s.a+1 from cte as r, cte as s;
+end|
+
+delimiter ;|
+
+delete from t1;
+call p1();
+select * from t1;
+call p1();
+select * from t1;
+
+delete from t1;
+call p2(3);
+select * from t1;
+call p2(7);
+select * from t1;
+
+drop procedure p1;
+drop procedure p2;
+drop table t1;
+
+--echo #
+--echo # MDEV-17107: PS for CREATE OR REPLACE VIEW defined by SELECT with CTEs
+--echo #
+
+create table t1(a int);
+insert into t1 values (3), (1), (2);
+create table t2 (b int);
+insert into t2 values (2), (10);
+
+prepare stmt from
+"create or replace view v1 as
+ with t as (select s.a from (select t1.a from t1) s),
+ r as(select t.a from t2, t where t2.b=t.a)
+ select a from r;";
+
+execute stmt;
+select * from v1;
+
+drop view v1;
+drop table t1,t2;
diff --git a/mysql-test/main/cte_recursive.result b/mysql-test/main/cte_recursive.result
index 4becc038543..9e934b19efc 100644
--- a/mysql-test/main/cte_recursive.result
+++ b/mysql-test/main/cte_recursive.result
@@ -3306,7 +3306,307 @@ SELECT func();
func()
1
DROP FUNCTION func;
-# Start of 10.3 tests
+#
+# MDEV-17024: two materialized CTEs using the same recursive CTE
+#
+create table t1 (id int);
+insert into t1 values (1), (2), (3);
+with recursive
+rcte(a) as
+(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
+cte1 as
+(select count(*) as c1 from rcte,t1 where a between 3 and 5 and id=a-3),
+cte2 as
+(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
+select * from cte1, cte2;
+c1 c2
+2 1
+explain extended with recursive
+rcte(a) as
+(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
+cte1 as
+(select count(*) as c1 from rcte,t1 where a between 3 and 5 and id=a-3),
+cte2 as
+(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
+select * from cte1, cte2;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <derived4> ALL NULL NULL NULL NULL 6 100.00
+1 PRIMARY <derived5> ALL NULL NULL NULL NULL 6 100.00 Using join buffer (flat, BNL join)
+4 DERIVED <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
+4 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+5 DERIVED <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
+5 DERIVED t1 ALL NULL NULL NULL NULL 3 100.00 Using where; Using join buffer (flat, BNL join)
+2 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
+3 RECURSIVE UNION <derived2> ALL NULL NULL NULL NULL 2 100.00 Using where
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL NULL
+Warnings:
+Note 1003 with recursive rcte as (/* select#2 */ select 1 AS `a` union /* select#3 */ select cast(`rcte`.`a` + 1 as unsigned) AS `cast(a+1 as unsigned)` from `rcte` where `rcte`.`a` < 10), cte1 as (/* select#4 */ select count(0) AS `c1` from `rcte` join `test`.`t1` where `rcte`.`a` between 3 and 5 and `test`.`t1`.`id` = `rcte`.`a` - 3), cte2 as (/* select#5 */ select count(0) AS `c2` from `rcte` join `test`.`t1` where `rcte`.`a` between 7 and 8 and `test`.`t1`.`id` = `rcte`.`a` - 7)/* select#1 */ select `cte1`.`c1` AS `c1`,`cte2`.`c2` AS `c2` from `cte1` join `cte2`
+prepare stmt from "with recursive
+rcte(a) as
+(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
+cte1 as
+(select count(*) as c1 from rcte,t1 where a between 3 and 5 and id=a-3),
+cte2 as
+(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
+select * from cte1, cte2";
+execute stmt;
+c1 c2
+2 1
+execute stmt;
+c1 c2
+2 1
+create table t2 (c1 int, c2 int);
+create procedure p() insert into t2 with recursive
+rcte(a) as
+(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
+cte1 as
+(select count(*) as c1 from rcte,t1 where a between 3 and 5 and id=a-3),
+cte2 as
+(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
+select * from cte1, cte2;
+call p();
+select * from t2;
+c1 c2
+2 1
+with recursive
+rcte(a) as
+(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
+cte1 as
+(select count(*) as c1 from rcte,t1 where a between 3 and 5 and id=a-3),
+cte2 as
+(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
+select * from cte1;
+c1
+2
+with recursive
+rcte(a) as
+(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
+cte1 as
+(select count(*) as c1 from t1),
+cte2 as
+(select count(*) as c2 from t2)
+select * from cte1,cte2;
+c1 c2
+3 1
+with recursive
+rcte(a) as
+(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
+cte1 as
+(select count(*) as c1 from rcte,t1 where a between 3 and 5 and id=a-3),
+cte2 as
+(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
+select * from cte1, cte2 where cte1.c1 = 3;
+c1 c2
+drop procedure p;
+drop table t1,t2;
+#
+# MDEV-17201: recursive part with LIMIT
+#
+CREATE TABLE purchases (
+id int unsigned NOT NULL AUTO_INCREMENT,
+pdate date NOT NULL,
+quantity int unsigned NOT NULL,
+p_id int unsigned NOT NULL,
+PRIMARY KEY (id)
+);
+INSERT INTO purchases(pdate, quantity, p_id) VALUES
+('2014-11-01',5 ,1),('2014-11-03', 3 ,1),
+('2014-11-01',2 ,2),('2014-11-03', 4 ,2);
+CREATE TABLE expired (
+edate date NOT NULL,
+quantity int unsigned NOT NULL,
+p_id int unsigned NOT NULL,
+PRIMARY KEY (edate,p_id)
+);
+INSERT INTO expired VALUES ('2014-11-12', 5 ,1),('2014-11-08', 1 ,2);
+WITH RECURSIVE expired_map AS (
+SELECT edate AS expired_date,
+CAST(NULL AS date) AS purchase_date,
+0 AS quantity,
+e.p_id,
+(SELECT MAX(id)+1 FROM purchases p
+WHERE pdate <= edate AND p.p_id =p_id) AS purchase_processed,
+quantity AS unresolved
+FROM expired e
+UNION
+( SELECT expired_date,
+pdate,
+IF(p.quantity < m.unresolved, p.quantity, m.unresolved),
+p.p_id,
+p.id,
+IF(p.quantity < m.unresolved, m.unresolved - p.quantity, 0)
+FROM purchases p JOIN expired_map m ON p.p_id = m.p_id
+WHERE p.id < m.purchase_processed AND m.unresolved > 0
+ORDER BY p.id DESC
+LIMIT 1
+)
+)
+SELECT * FROM expired_map;
+expired_date purchase_date quantity p_id purchase_processed unresolved
+2014-11-12 NULL 0 1 5 5
+2014-11-08 NULL 0 2 5 1
+2014-11-08 2014-11-03 1 2 4 0
+DROP TABLE purchases, expired;
+#
+# MDEV-17635: Two recursive CTEs, the second using the first
+#
+WITH RECURSIVE
+x AS (SELECT 0 as k UNION ALL SELECT k + 1 FROM x WHERE k < 1),
+z AS
+( SELECT k1 AS cx, k2 AS cy, k1, k2
+FROM (SELECT k AS k1 FROM x) x1 JOIN (SELECT k AS k2 FROM x) y1
+UNION
+SELECT 1,1,1,1 FROM z)
+SELECT * FROM z;
+cx cy k1 k2
+0 0 0 0
+1 0 1 0
+0 1 0 1
+1 1 1 1
+# https://wiki.postgresql.org/wiki/Mandelbrot_set:
+WITH RECURSIVE x(i) AS (
+SELECT CAST(0 AS DECIMAL(13, 10))
+UNION ALL
+SELECT i + 1
+FROM x
+WHERE i < 101
+),
+Z(Ix, Iy, Cx, Cy, X, Y, I) AS (
+SELECT Ix, Iy, X, Y, X, Y, 0
+FROM (SELECT CAST(-2.2 + 0.031 * i AS DECIMAL(13, 10)) AS X,
+i AS Ix FROM x) AS xgen
+CROSS JOIN (
+SELECT CAST(-1.5 + 0.031 * i AS DECIMAL(13, 10)) AS Y,
+i AS iY FROM x
+) AS ygen
+UNION ALL
+SELECT Ix, Iy, Cx, Cy,
+CAST(X * X - Y * Y + Cx AS DECIMAL(13, 10)) AS X,
+CAST(Y * X * 2 + Cy AS DECIMAL(13, 10)), I + 1
+FROM Z
+WHERE X * X + Y * Y < 16.0
+AND I < 27
+),
+Zt (Ix, Iy, I) AS (
+SELECT Ix, Iy, MAX(I) AS I
+FROM Z
+GROUP BY Iy, Ix
+ORDER BY Iy, Ix
+)
+SELECT GROUP_CONCAT(
+SUBSTRING(
+' .,,,-----++++%%%%@@@@#### ',
+GREATEST(I, 1),
+1
+) ORDER BY Ix SEPARATOR ''
+ ) AS 'Mandelbrot Set'
+ FROM Zt
+GROUP BY Iy
+ORDER BY Iy;
+Mandelbrot Set
+ ....................................................................................
+ .......................................................................................
+ .........................................................................................
+ ...........................................................................................
+ ....................................................,,,,,,,,,.................................
+ ................................................,,,,,,,,,,,,,,,,,,.............................
+ ..............................................,,,,,,,,,,,,,,,,,,,,,,,,..........................
+ ............................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,........................
+ ..........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,......................
+ .........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,....................
+ ........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................
+ .......................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.................
+ .......................................,,,,,,,,,,,,,,,,,,,,,,,,--,,,,,,,,,,,,,,,,,,,,................
+......................................,,,,,,,,,,,,,,,,,,,,,,,,,,-+--,,,,,,,,,,,,,,,,,,,...............
+....................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----,,,,,,,,,,,,,,,,,,,..............
+...................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,--- -----,,,,,,,,,,,,,,,,,.............
+.................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---++--++,,,,,,,,,,,,,,,,,,............
+................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----%++---,,,,,,,,,,,,,,,,,............
+..............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+%----,,,,,,,,,,,,,,,,,,...........
+.............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----- %%+----,,,,,,,,,,,,,,,,,,..........
+...........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---%-+% ----,,,,,,,,,,,,,,,,,,,.........
+..........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---+ +## %+%---,,,,,,,,,,,,,,,,,,.........
+........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----# # +---,,,,,,,,,,,,,,,,,,........
+.......................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------% %-----,,,,,,,,,,,,,,,,,........
+.....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---------+ ------,,,,,,,,,,,,,,,,,.......
+....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----------+@ +-----------,,,,,,,,,,,,.......
+..................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----@-------++ ++-----------,,,,,,,,,,,,......
+.................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--+@% ---+ +@%%@ %%+@+@%------+-,,,,,,,,,,,......
+................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---- # ++% % @-----++--,,,,,,,,,,,.....
+..............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----+ % %%++ %+%@-,,,,,,,,,,,.....
+.............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+# #% ++-,,,,,,,,,,,,....
+............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,------+ @---,,,,,,,,,,,,....
+..........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------++% ---,,,,,,,,,,,,....
+.........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------+ + %+---,,,,,,,,,,,,,...
+........,,,,,,,,,,,,,,,,,,,,,--------------------@ +----,,,,,,,,,,,,...
+.......,,,,,,,,,,,,,,,,,,,,,,- +-----------------+ ----,,,,,,,,,,,,...
+.......,,,,,,,,,,,,,,,,,,,,,--++------+---------+% +++--,,,,,,,,,,,,..
+......,,,,,,,,,,,,,,,,,,,,,,--%+-----++--------- #+-,,,,,,,,,,,,..
+.....,,,,,,,,,,,,,,,,,,,,,,----#%++--+@ -+-----+% --,,,,,,,,,,,,..
+.....,,,,,,,,,,,,,,,,,,,,,,-----+## ++@ + +----% +--,,,,,,,,,,,,,..
+....,,,,,,,,,,,,,,,,,,,,,,------+@ @ @@++++# +--,,,,,,,,,,,,,..
+....,,,,,,,,,,,,,,,,,,,,,-------% #++% -,,,,,,,,,,,,,..
+...,,,,,,,,,,,,,,,,,,,,,------++%# %%@ %-,,,,,,,,,,,,,,.
+...,,,,,,,,,,,,,,,,,,,--------+ % +--,,,,,,,,,,,,,,.
+...,,,,,,,,,,,,,,,,,,-----+--++@ # --,,,,,,,,,,,,,,.
+..,,,,,,,,,,,,,,,,,-------%+++% @--,,,,,,,,,,,,,,,.
+..,,,,,,,,,,,-------------+ @#@ ---,,,,,,,,,,,,,,,.
+..,,,,,,,,,---@--------@-+% +---,,,,,,,,,,,,,,,.
+..,,,,,------- +-++++-+%%% +----,,,,,,,,,,,,,,,.
+..,,,,,,------%--------++% +----,,,,,,,,,,,,,,,.
+..,,,,,,,,,,--+----------++# ---,,,,,,,,,,,,,,,.
+..,,,,,,,,,,,,------------+@@@% +--,,,,,,,,,,,,,,,.
+..,,,,,,,,,,,,,,,,,------- +++% %--,,,,,,,,,,,,,,,.
+...,,,,,,,,,,,,,,,,,,---------+@ @ --,,,,,,,,,,,,,,.
+...,,,,,,,,,,,,,,,,,,,,------- # %@ +--,,,,,,,,,,,,,,.
+...,,,,,,,,,,,,,,,,,,,,,-------++@ %+ %-,,,,,,,,,,,,,,.
+....,,,,,,,,,,,,,,,,,,,,,------- %++% %-,,,,,,,,,,,,,..
+....,,,,,,,,,,,,,,,,,,,,,,------+# %# #@ ++++ +--,,,,,,,,,,,,,..
+.....,,,,,,,,,,,,,,,,,,,,,,-----+ %%++% +@+----+ +--,,,,,,,,,,,,,..
+.....,,,,,,,,,,,,,,,,,,,,,,,---%+++--+#+--------% #--,,,,,,,,,,,,..
+......,,,,,,,,,,,,,,,,,,,,,,--++-----%%--------- @#--,,,,,,,,,,,,..
+.......,,,,,,,,,,,,,,,,,,,,,---------------------+@ +-++,,,,,,,,,,,,...
+........,,,,,,,,,,,,,,,,,,,,,--------------------+ ----,,,,,,,,,,,,...
+.........,,,,,,,,,,,,,,,,,,,,----,,,------------- #+----,,,,,,,,,,,,...
+..........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------+ + +---,,,,,,,,,,,,,...
+...........,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------+%# #---,,,,,,,,,,,,....
+............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,------+# @ @---,,,,,,,,,,,,....
+.............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+# + @--,,,,,,,,,,,,....
+..............,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---+% %+@ %+-+ +++%-,,,,,,,,,,,.....
+................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----% %@++ # % -----++-,,,,,,,,,,,,.....
+.................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-- ++ ---+ + +%@ %++++++------%-,,,,,,,,,,,......
+...................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---- -------++ +------------,,,,,,,,,,,,......
+....................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----------+% +--------,,,,,,,,,,,,,,,.......
+......................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,--------+# -----,,,,,,,,,,,,,,,,,,.......
+.......................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-------+ #----,,,,,,,,,,,,,,,,,,........
+.........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,----+% %#---,,,,,,,,,,,,,,,,,,,........
+..........................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---+%+%@ %+%%--,,,,,,,,,,,,,,,,,,.........
+............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---+-+% %----,,,,,,,,,,,,,,,,,,..........
+.............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+%@+---,,,,,,,,,,,,,,,,,,,..........
+...............................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----+%----,,,,,,,,,,,,,,,,,,...........
+................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,-----%+ +--,,,,,,,,,,,,,,,,,............
+..................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,---++----,,,,,,,,,,,,,,,,,.............
+...................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,---@-----,,,,,,,,,,,,,,,,,.............
+.....................................,,,,,,,,,,,,,,,,,,,,,,,,,,,-----,,,,,,,,,,,,,,,,,,,..............
+ .....................................,,,,,,,,,,,,,,,,,,,,,,,,,,--%,,,,,,,,,,,,,,,,,,,,...............
+ .......................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.................
+ ........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,..................
+ ........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,...................
+ .........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,....................
+ ..........................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,......................
+ ............................................,,,,,,,,,,,,,,,,,,,,,,,,,,,,........................
+ .............................................,,,,,,,,,,,,,,,,,,,,,,,,..........................
+ ................................................,,,,,,,,,,,,,,,,,.............................
+ .....................................................,,,,....................................
+ ...........................................................................................
+ .........................................................................................
+ ......................................................................................
+ ....................................................................................
+ .................................................................................
+ ..............................................................................
+ ...........................................................................
+ ........................................................................
+# End of 10.2 tests
#
# MDEV-14217 [db crash] Recursive CTE when SELECT includes new field
#
@@ -3595,3 +3895,4 @@ a
0
NULL
DROP TABLE t1;
+# End of 10.3 tests
diff --git a/mysql-test/main/cte_recursive.test b/mysql-test/main/cte_recursive.test
index 109f7d73011..79809044c00 100644
--- a/mysql-test/main/cte_recursive.test
+++ b/mysql-test/main/cte_recursive.test
@@ -2324,7 +2324,179 @@ SELECT func();
DROP FUNCTION func;
---echo # Start of 10.3 tests
+--echo #
+--echo # MDEV-17024: two materialized CTEs using the same recursive CTE
+--echo #
+
+create table t1 (id int);
+insert into t1 values (1), (2), (3);
+
+let $q=
+with recursive
+rcte(a) as
+(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
+cte1 as
+(select count(*) as c1 from rcte,t1 where a between 3 and 5 and id=a-3),
+cte2 as
+(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
+select * from cte1, cte2;
+
+eval $q;
+eval explain extended $q;
+eval prepare stmt from "$q";
+execute stmt;
+execute stmt;
+
+create table t2 (c1 int, c2 int);
+eval create procedure p() insert into t2 $q;
+call p();
+select * from t2;
+
+let $q1=
+with recursive
+rcte(a) as
+(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
+cte1 as
+(select count(*) as c1 from rcte,t1 where a between 3 and 5 and id=a-3),
+cte2 as
+(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
+select * from cte1;
+
+eval $q1;
+
+let $q2=
+with recursive
+rcte(a) as
+(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
+cte1 as
+(select count(*) as c1 from t1),
+cte2 as
+(select count(*) as c2 from t2)
+select * from cte1,cte2;
+
+eval $q2;
+
+let $q3=
+with recursive
+rcte(a) as
+(select 1 union select cast(a+1 as unsigned) from rcte where a < 10),
+cte1 as
+(select count(*) as c1 from rcte,t1 where a between 3 and 5 and id=a-3),
+cte2 as
+(select count(*) as c2 from rcte,t1 where a between 7 and 8 and id=a-7)
+select * from cte1, cte2 where cte1.c1 = 3;
+
+eval $q3;
+
+drop procedure p;
+drop table t1,t2;
+
+--echo #
+--echo # MDEV-17201: recursive part with LIMIT
+--echo #
+
+CREATE TABLE purchases (
+ id int unsigned NOT NULL AUTO_INCREMENT,
+ pdate date NOT NULL,
+ quantity int unsigned NOT NULL,
+ p_id int unsigned NOT NULL,
+ PRIMARY KEY (id)
+);
+INSERT INTO purchases(pdate, quantity, p_id) VALUES
+ ('2014-11-01',5 ,1),('2014-11-03', 3 ,1),
+ ('2014-11-01',2 ,2),('2014-11-03', 4 ,2);
+
+CREATE TABLE expired (
+ edate date NOT NULL,
+ quantity int unsigned NOT NULL,
+ p_id int unsigned NOT NULL,
+ PRIMARY KEY (edate,p_id)
+);
+
+INSERT INTO expired VALUES ('2014-11-12', 5 ,1),('2014-11-08', 1 ,2);
+
+WITH RECURSIVE expired_map AS (
+ SELECT edate AS expired_date,
+ CAST(NULL AS date) AS purchase_date,
+ 0 AS quantity,
+ e.p_id,
+ (SELECT MAX(id)+1 FROM purchases p
+ WHERE pdate <= edate AND p.p_id =p_id) AS purchase_processed,
+ quantity AS unresolved
+ FROM expired e
+ UNION
+ ( SELECT expired_date,
+ pdate,
+ IF(p.quantity < m.unresolved, p.quantity, m.unresolved),
+ p.p_id,
+ p.id,
+ IF(p.quantity < m.unresolved, m.unresolved - p.quantity, 0)
+ FROM purchases p JOIN expired_map m ON p.p_id = m.p_id
+ WHERE p.id < m.purchase_processed AND m.unresolved > 0
+ ORDER BY p.id DESC
+ LIMIT 1
+ )
+)
+SELECT * FROM expired_map;
+
+DROP TABLE purchases, expired;
+
+--echo #
+--echo # MDEV-17635: Two recursive CTEs, the second using the first
+--echo #
+
+WITH RECURSIVE
+x AS (SELECT 0 as k UNION ALL SELECT k + 1 FROM x WHERE k < 1),
+z AS
+ ( SELECT k1 AS cx, k2 AS cy, k1, k2
+ FROM (SELECT k AS k1 FROM x) x1 JOIN (SELECT k AS k2 FROM x) y1
+ UNION
+ SELECT 1,1,1,1 FROM z)
+SELECT * FROM z;
+
+--echo # https://wiki.postgresql.org/wiki/Mandelbrot_set:
+
+WITH RECURSIVE x(i) AS (
+ SELECT CAST(0 AS DECIMAL(13, 10))
+ UNION ALL
+ SELECT i + 1
+ FROM x
+ WHERE i < 101
+),
+Z(Ix, Iy, Cx, Cy, X, Y, I) AS (
+ SELECT Ix, Iy, X, Y, X, Y, 0
+ FROM (SELECT CAST(-2.2 + 0.031 * i AS DECIMAL(13, 10)) AS X,
+ i AS Ix FROM x) AS xgen
+ CROSS JOIN (
+ SELECT CAST(-1.5 + 0.031 * i AS DECIMAL(13, 10)) AS Y,
+ i AS iY FROM x
+ ) AS ygen
+ UNION ALL
+ SELECT Ix, Iy, Cx, Cy,
+ CAST(X * X - Y * Y + Cx AS DECIMAL(13, 10)) AS X,
+ CAST(Y * X * 2 + Cy AS DECIMAL(13, 10)), I + 1
+ FROM Z
+ WHERE X * X + Y * Y < 16.0
+ AND I < 27
+),
+Zt (Ix, Iy, I) AS (
+ SELECT Ix, Iy, MAX(I) AS I
+ FROM Z
+ GROUP BY Iy, Ix
+ ORDER BY Iy, Ix
+)
+SELECT GROUP_CONCAT(
+ SUBSTRING(
+ ' .,,,-----++++%%%%@@@@#### ',
+ GREATEST(I, 1),
+ 1
+ ) ORDER BY Ix SEPARATOR ''
+ ) AS 'Mandelbrot Set'
+ FROM Zt
+GROUP BY Iy
+ORDER BY Iy;
+
+--echo # End of 10.2 tests
--echo #
--echo # MDEV-14217 [db crash] Recursive CTE when SELECT includes new field
@@ -2553,3 +2725,5 @@ WITH RECURSIVE cte AS
SELECT * FROM cte;
DROP TABLE t1;
+
+--echo # End of 10.3 tests
diff --git a/mysql-test/main/ctype_binary.result b/mysql-test/main/ctype_binary.result
index 0afe5298411..8059e02611e 100644
--- a/mysql-test/main/ctype_binary.result
+++ b/mysql-test/main/ctype_binary.result
@@ -3048,6 +3048,29 @@ DROP TABLE t1;
SELECT _binary 0x7E, _binary X'7E', _binary B'01111110';
_binary 0x7E _binary X'7E' _binary B'01111110'
~ ~ ~
+SET NAMES utf8, character_set_connection=binary;
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch=_latin1'derived_merge=on';
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t` varbinary(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
+c2
+ABCDEFGHI-ABCDEFGHI
+abcdefghi-abcdefghi
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
+c2
+ABCDEFGHI-ABCDEFGHI
+abcdefghi-abcdefghi
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#
diff --git a/mysql-test/main/ctype_binary.test b/mysql-test/main/ctype_binary.test
index 8da4eaff572..155d8548f77 100644
--- a/mysql-test/main/ctype_binary.test
+++ b/mysql-test/main/ctype_binary.test
@@ -24,6 +24,9 @@ SET NAMES binary;
--echo #
SELECT _binary 0x7E, _binary X'7E', _binary B'01111110';
+SET NAMES utf8, character_set_connection=binary;
+--source include/ctype_mdev13118.inc
+
--echo #
--echo # End of 10.0 tests
--echo #
diff --git a/mysql-test/main/ctype_eucjpms.result b/mysql-test/main/ctype_eucjpms.result
index bc7b4b9ef9d..507d0021a1f 100644
--- a/mysql-test/main/ctype_eucjpms.result
+++ b/mysql-test/main/ctype_eucjpms.result
@@ -33844,6 +33844,29 @@ HEX(a) CHAR_LENGTH(a)
DROP TABLE t1;
SELECT _eucjpms 0x8EA0;
ERROR HY000: Invalid eucjpms character string: '8EA0'
+SET NAMES eucjpms;
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch=_latin1'derived_merge=on';
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t` varchar(10) CHARACTER SET eucjpms DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
+c2
+abcdefghi-abcdefghi
+abcdefghi-abcdefghi
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
+c2
+ABCDEFGHI-ABCDEFGHI
+ABCDEFGHI-ABCDEFGHI
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#
diff --git a/mysql-test/main/ctype_eucjpms.test b/mysql-test/main/ctype_eucjpms.test
index c69abc32a03..867ca809dbf 100644
--- a/mysql-test/main/ctype_eucjpms.test
+++ b/mysql-test/main/ctype_eucjpms.test
@@ -537,6 +537,8 @@ DROP TABLE t1;
--error ER_INVALID_CHARACTER_STRING
SELECT _eucjpms 0x8EA0;
+SET NAMES eucjpms;
+--source include/ctype_mdev13118.inc
--echo #
--echo # End of 10.0 tests
diff --git a/mysql-test/main/ctype_euckr.result b/mysql-test/main/ctype_euckr.result
index 3fb6f98b2eb..cc50ddd20be 100644
--- a/mysql-test/main/ctype_euckr.result
+++ b/mysql-test/main/ctype_euckr.result
@@ -25405,6 +25405,35 @@ A1A1A1A1A1A120202020202020202020202020202020202020
# End of 5.6 tests
#
#
+# Start of 10.0 tests
+#
+SET NAMES utf8, character_set_connection=euckr;
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch=_latin1'derived_merge=on';
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t` varchar(10) CHARACTER SET euckr DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
+c2
+abcdefghi-abcdefghi
+abcdefghi-abcdefghi
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
+c2
+ABCDEFGHI-ABCDEFGHI
+ABCDEFGHI-ABCDEFGHI
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
+#
+# End of 10.0 tests
+#
+#
# Start of 10.2 tests
#
#
diff --git a/mysql-test/main/ctype_euckr.test b/mysql-test/main/ctype_euckr.test
index 950c60c47e5..46955360217 100644
--- a/mysql-test/main/ctype_euckr.test
+++ b/mysql-test/main/ctype_euckr.test
@@ -197,6 +197,16 @@ set collation_connection=euckr_bin;
--echo # End of 5.6 tests
--echo #
+--echo #
+--echo # Start of 10.0 tests
+--echo #
+
+SET NAMES utf8, character_set_connection=euckr;
+--source include/ctype_mdev13118.inc
+
+--echo #
+--echo # End of 10.0 tests
+--echo #
--echo #
--echo # Start of 10.2 tests
diff --git a/mysql-test/main/ctype_gbk.result b/mysql-test/main/ctype_gbk.result
index 6bbb9bb3094..4515b9fbdbf 100644
--- a/mysql-test/main/ctype_gbk.result
+++ b/mysql-test/main/ctype_gbk.result
@@ -5081,6 +5081,29 @@ E05C5B
E05B
DROP TABLE t1;
# Start of ctype_E05C.inc
+SET NAMES utf8, character_set_connection=gbk;
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch=_latin1'derived_merge=on';
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t` varchar(10) CHARACTER SET gbk DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
+c2
+abcdefghi-abcdefghi
+abcdefghi-abcdefghi
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
+c2
+ABCDEFGHI-ABCDEFGHI
+ABCDEFGHI-ABCDEFGHI
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
#
# MDEV-9886 Illegal mix of collations with a view comparing a field to a binary constant
#
diff --git a/mysql-test/main/ctype_gbk.test b/mysql-test/main/ctype_gbk.test
index a3dc7f4af44..d9d0a4d0ee4 100644
--- a/mysql-test/main/ctype_gbk.test
+++ b/mysql-test/main/ctype_gbk.test
@@ -199,6 +199,9 @@ let $ctype_unescape_combinations=selected;
SET NAMES gbk;
--source include/ctype_E05C.inc
+SET NAMES utf8, character_set_connection=gbk;
+--source include/ctype_mdev13118.inc
+
--echo #
--echo # MDEV-9886 Illegal mix of collations with a view comparing a field to a binary constant
--echo #
diff --git a/mysql-test/main/ctype_latin1.result b/mysql-test/main/ctype_latin1.result
index d5906cb74dd..233fd85a2c4 100644
--- a/mysql-test/main/ctype_latin1.result
+++ b/mysql-test/main/ctype_latin1.result
@@ -8022,6 +8022,38 @@ a
0
DROP VIEW v1;
DROP TABLE t1;
+SET NAMES latin1;
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch=_latin1'derived_merge=on';
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t` varchar(10) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
+c2
+abcdefghi-abcdefghi
+abcdefghi-abcdefghi
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
+c2
+ABCDEFGHI-ABCDEFGHI
+ABCDEFGHI-ABCDEFGHI
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
+#
+# MDEV-17298 ASAN unknown-crash / READ of size 1 in my_strntoul_8bit upon INSERT .. SELECT
+#
+SET NAMES latin1;
+CREATE TABLE t1 (a CHAR);
+CREATE TABLE t2 (b ENUM('foo','bar'));
+INSERT INTO t1 VALUES ('1');
+INSERT INTO t2 SELECT * FROM t1;
+DROP TABLE t1, t2;
#
# End of 10.0 tests
#
diff --git a/mysql-test/main/ctype_latin1.test b/mysql-test/main/ctype_latin1.test
index 38f147708b8..a556c86c016 100644
--- a/mysql-test/main/ctype_latin1.test
+++ b/mysql-test/main/ctype_latin1.test
@@ -262,6 +262,21 @@ SELECT * FROM v1;
DROP VIEW v1;
DROP TABLE t1;
+SET NAMES latin1;
+--source include/ctype_mdev13118.inc
+
+
+--echo #
+--echo # MDEV-17298 ASAN unknown-crash / READ of size 1 in my_strntoul_8bit upon INSERT .. SELECT
+--echo #
+
+SET NAMES latin1;
+CREATE TABLE t1 (a CHAR);
+CREATE TABLE t2 (b ENUM('foo','bar'));
+INSERT INTO t1 VALUES ('1');
+INSERT INTO t2 SELECT * FROM t1;
+DROP TABLE t1, t2;
+
--echo #
--echo # End of 10.0 tests
diff --git a/mysql-test/main/ctype_uca.result b/mysql-test/main/ctype_uca.result
index 725e744c44e..88fba0b3973 100644
--- a/mysql-test/main/ctype_uca.result
+++ b/mysql-test/main/ctype_uca.result
@@ -13940,6 +13940,27 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = 'oe' and `test`.`t1`.`a` = 'oe'
DROP TABLE t1;
#
+# MDEV-17064 LIKE function has error behavior on the fields in which the collation is xxx_unicode_xx
+#
+CREATE TABLE t1 (name VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci);
+INSERT INTO t1 VALUES ('radio! test');
+SELECT * FROM t1 WHERE name LIKE '%!!%' ESCAPE '!';
+name
+radio! test
+ALTER TABLE t1 CHANGE COLUMN name name VARCHAR(20) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';
+SELECT * FROM t1 WHERE name LIKE '%!!%' ESCAPE '!';
+name
+radio! test
+DROP TABLE t1;
+CREATE TABLE t1 (name VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci);
+INSERT INTO t1 VALUES ('radio! test');
+SELECT name LIKE '%!!%' ESCAPE '!' AS c1,
+name LIKE '%!!%' COLLATE utf8_general_ci ESCAPE '!' AS c2
+FROM t1;
+c1 c2
+1 1
+DROP TABLE t1;
+#
# End of MariaDB-10.0 tests
#
#
diff --git a/mysql-test/main/ctype_uca.test b/mysql-test/main/ctype_uca.test
index 15a945fde6d..82be0305f07 100644
--- a/mysql-test/main/ctype_uca.test
+++ b/mysql-test/main/ctype_uca.test
@@ -619,6 +619,24 @@ EXPLAIN EXTENDED SELECT * FROM t1 WHERE a='oe' COLLATE utf8_german2_ci AND a='oe
DROP TABLE t1;
--echo #
+--echo # MDEV-17064 LIKE function has error behavior on the fields in which the collation is xxx_unicode_xx
+--echo #
+
+CREATE TABLE t1 (name VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci);
+INSERT INTO t1 VALUES ('radio! test');
+SELECT * FROM t1 WHERE name LIKE '%!!%' ESCAPE '!';
+ALTER TABLE t1 CHANGE COLUMN name name VARCHAR(20) CHARACTER SET 'utf8' COLLATE 'utf8_general_ci';
+SELECT * FROM t1 WHERE name LIKE '%!!%' ESCAPE '!';
+DROP TABLE t1;
+
+CREATE TABLE t1 (name VARCHAR(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci);
+INSERT INTO t1 VALUES ('radio! test');
+SELECT name LIKE '%!!%' ESCAPE '!' AS c1,
+ name LIKE '%!!%' COLLATE utf8_general_ci ESCAPE '!' AS c2
+FROM t1;
+DROP TABLE t1;
+
+--echo #
--echo # End of MariaDB-10.0 tests
--echo #
diff --git a/mysql-test/main/ctype_ucs.result b/mysql-test/main/ctype_ucs.result
index a68309831c6..5641726a831 100644
--- a/mysql-test/main/ctype_ucs.result
+++ b/mysql-test/main/ctype_ucs.result
@@ -5690,6 +5690,29 @@ c2
YWJjZGVmZ2hp-YWJjZGVmZ2hp
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
+SET NAMES utf8, character_set_connection=ucs2;
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch=_latin1'derived_merge=on';
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t` varchar(10) CHARACTER SET ucs2 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
+c2
+abcdefghi-abcdefghi
+abcdefghi-abcdefghi
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
+c2
+ABCDEFGHI-ABCDEFGHI
+ABCDEFGHI-ABCDEFGHI
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#
diff --git a/mysql-test/main/ctype_ucs.test b/mysql-test/main/ctype_ucs.test
index 9592e27f8e1..d0d463c0340 100644
--- a/mysql-test/main/ctype_ucs.test
+++ b/mysql-test/main/ctype_ucs.test
@@ -992,6 +992,10 @@ DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
+SET NAMES utf8, character_set_connection=ucs2;
+--source include/ctype_mdev13118.inc
+
+
--echo #
--echo # End of 10.0 tests
--echo #
diff --git a/mysql-test/main/ctype_ujis.result b/mysql-test/main/ctype_ujis.result
index cb9de83fedc..0b1cf606f0b 100644
--- a/mysql-test/main/ctype_ujis.result
+++ b/mysql-test/main/ctype_ujis.result
@@ -26149,6 +26149,29 @@ HEX(a) CHAR_LENGTH(a)
DROP TABLE t1;
SELECT _ujis 0x8EA0;
ERROR HY000: Invalid ujis character string: '8EA0'
+SET NAMES ujis;
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch=_latin1'derived_merge=on';
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t` varchar(10) CHARACTER SET ujis DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
+c2
+abcdefghi-abcdefghi
+abcdefghi-abcdefghi
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
+c2
+ABCDEFGHI-ABCDEFGHI
+ABCDEFGHI-ABCDEFGHI
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#
diff --git a/mysql-test/main/ctype_ujis.test b/mysql-test/main/ctype_ujis.test
index ff9c61c05ba..cf247763b46 100644
--- a/mysql-test/main/ctype_ujis.test
+++ b/mysql-test/main/ctype_ujis.test
@@ -1368,6 +1368,10 @@ DROP TABLE t1;
SELECT _ujis 0x8EA0;
+SET NAMES ujis;
+--source include/ctype_mdev13118.inc
+
+
--echo #
--echo # End of 10.0 tests
--echo #
diff --git a/mysql-test/main/ctype_upgrade.result b/mysql-test/main/ctype_upgrade.result
index 5f0be66f8fb..7f8b594cbf8 100644
--- a/mysql-test/main/ctype_upgrade.result
+++ b/mysql-test/main/ctype_upgrade.result
@@ -240,7 +240,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
@@ -299,7 +298,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
diff --git a/mysql-test/main/ctype_utf16.result b/mysql-test/main/ctype_utf16.result
index 8de21a14bd9..a105017b726 100644
--- a/mysql-test/main/ctype_utf16.result
+++ b/mysql-test/main/ctype_utf16.result
@@ -2142,6 +2142,29 @@ EXECUTE stmt USING @arg00;
CONCAT(_utf16'a' COLLATE utf16_unicode_ci, ?)
aÿ
DEALLOCATE PREPARE stmt;
+SET NAMES utf8, character_set_connection=utf16;
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch=_latin1'derived_merge=on';
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t` varchar(10) CHARACTER SET utf16 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
+c2
+abcdefghi-abcdefghi
+abcdefghi-abcdefghi
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
+c2
+ABCDEFGHI-ABCDEFGHI
+ABCDEFGHI-ABCDEFGHI
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#
diff --git a/mysql-test/main/ctype_utf16.test b/mysql-test/main/ctype_utf16.test
index 526f5251055..504e62e3e89 100644
--- a/mysql-test/main/ctype_utf16.test
+++ b/mysql-test/main/ctype_utf16.test
@@ -870,6 +870,11 @@ SET @arg00=_binary 0x00FF;
EXECUTE stmt USING @arg00;
DEALLOCATE PREPARE stmt;
+
+SET NAMES utf8, character_set_connection=utf16;
+--source include/ctype_mdev13118.inc
+
+
--echo #
--echo # End of 10.0 tests
--echo #
diff --git a/mysql-test/main/ctype_utf16le.result b/mysql-test/main/ctype_utf16le.result
index 0fedff7d3bf..6d8d7ddca2a 100644
--- a/mysql-test/main/ctype_utf16le.result
+++ b/mysql-test/main/ctype_utf16le.result
@@ -2326,6 +2326,35 @@ DFFFFFDFFFFF9CFFFF9DFFFF9EFFFF
# End of 5.6 tests
#
#
+# Start of 10.0 tests
+#
+SET NAMES utf8, character_set_connection=utf16le;
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch=_latin1'derived_merge=on';
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t` varchar(10) CHARACTER SET utf16le DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
+c2
+abcdefghi-abcdefghi
+abcdefghi-abcdefghi
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
+c2
+ABCDEFGHI-ABCDEFGHI
+ABCDEFGHI-ABCDEFGHI
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
+#
+# Start of 10.0 tests
+#
+#
# Start of 10.1 tests
#
#
diff --git a/mysql-test/main/ctype_utf16le.test b/mysql-test/main/ctype_utf16le.test
index 79cf875852a..b8728b52db2 100644
--- a/mysql-test/main/ctype_utf16le.test
+++ b/mysql-test/main/ctype_utf16le.test
@@ -747,6 +747,19 @@ SET NAMES utf8, collation_connection=utf16le_bin;
--echo # End of 5.6 tests
--echo #
+
+--echo #
+--echo # Start of 10.0 tests
+--echo #
+
+
+SET NAMES utf8, character_set_connection=utf16le;
+--source include/ctype_mdev13118.inc
+
+--echo #
+--echo # Start of 10.0 tests
+--echo #
+
--echo #
--echo # Start of 10.1 tests
--echo #
diff --git a/mysql-test/main/ctype_utf32.result b/mysql-test/main/ctype_utf32.result
index 59ce4c2f445..28b9caf6ffe 100644
--- a/mysql-test/main/ctype_utf32.result
+++ b/mysql-test/main/ctype_utf32.result
@@ -2241,6 +2241,29 @@ EXECUTE stmt USING @arg00;
CONCAT(_utf32'a' COLLATE utf32_unicode_ci, ?)
aÿ
DEALLOCATE PREPARE stmt;
+SET NAMEs utf8, character_set_connection=utf32;
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch=_latin1'derived_merge=on';
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t` varchar(10) CHARACTER SET utf32 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
+c2
+abcdefghi-abcdefghi
+abcdefghi-abcdefghi
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
+c2
+ABCDEFGHI-ABCDEFGHI
+ABCDEFGHI-ABCDEFGHI
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#
diff --git a/mysql-test/main/ctype_utf32.test b/mysql-test/main/ctype_utf32.test
index 6f036898d15..2e739ebfdbc 100644
--- a/mysql-test/main/ctype_utf32.test
+++ b/mysql-test/main/ctype_utf32.test
@@ -983,6 +983,14 @@ SET @arg00=_binary 0x00FF;
EXECUTE stmt USING @arg00;
DEALLOCATE PREPARE stmt;
+
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET NAMEs utf8, character_set_connection=utf32;
+--source include/ctype_mdev13118.inc
+
+
--echo #
--echo # End of 10.0 tests
--echo #
diff --git a/mysql-test/main/ctype_utf8.result b/mysql-test/main/ctype_utf8.result
index 10d0efeff3c..d696ff78831 100644
--- a/mysql-test/main/ctype_utf8.result
+++ b/mysql-test/main/ctype_utf8.result
@@ -10286,6 +10286,29 @@ SELECT * FROM v1;
c
ß
DROP VIEW v1;
+SET NAMES utf8;
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch=_latin1'derived_merge=on';
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t` varchar(10) CHARACTER SET utf8 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
+c2
+abcdefghi-abcdefghi
+abcdefghi-abcdefghi
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
+c2
+ABCDEFGHI-ABCDEFGHI
+ABCDEFGHI-ABCDEFGHI
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#
diff --git a/mysql-test/main/ctype_utf8.test b/mysql-test/main/ctype_utf8.test
index 20a60d370a0..6f8657dacb5 100644
--- a/mysql-test/main/ctype_utf8.test
+++ b/mysql-test/main/ctype_utf8.test
@@ -1890,6 +1890,13 @@ SELECT * FROM v1;
DROP VIEW v1;
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET NAMES utf8;
+--source include/ctype_mdev13118.inc
+
+
--echo #
--echo # End of 10.0 tests
--echo #
diff --git a/mysql-test/main/ctype_utf8mb4.result b/mysql-test/main/ctype_utf8mb4.result
index 7e5e99354ea..27ffd5552fa 100644
--- a/mysql-test/main/ctype_utf8mb4.result
+++ b/mysql-test/main/ctype_utf8mb4.result
@@ -3478,6 +3478,29 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
SET NAMES default;
+SET NAMES utf8mb4;
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch=_latin1'derived_merge=on';
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `t` varchar(10) CHARACTER SET utf8mb4 DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
+c2
+abcdefghi-abcdefghi
+abcdefghi-abcdefghi
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
+c2
+ABCDEFGHI-ABCDEFGHI
+ABCDEFGHI-ABCDEFGHI
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
#
# End of 10.0 tests
#
diff --git a/mysql-test/main/ctype_utf8mb4.test b/mysql-test/main/ctype_utf8mb4.test
index 545347fcd26..9cf87d12340 100644
--- a/mysql-test/main/ctype_utf8mb4.test
+++ b/mysql-test/main/ctype_utf8mb4.test
@@ -1959,6 +1959,14 @@ DROP TABLE t1;
SET NAMES default;
+
+#
+# MDEV-13118 Wrong results with LOWER and UPPER and subquery
+#
+SET NAMES utf8mb4;
+--source include/ctype_mdev13118.inc
+
+
--echo #
--echo # End of 10.0 tests
--echo #
diff --git a/mysql-test/main/date_formats.result b/mysql-test/main/date_formats.result
index 16dbdf7969c..463cce39520 100644
--- a/mysql-test/main/date_formats.result
+++ b/mysql-test/main/date_formats.result
@@ -442,7 +442,7 @@ f1 f2 f3
Warnings:
Warning 1292 Truncated incorrect datetime value: '2003-01-02 10:11:12.0012ABCD'
Warning 1292 Truncated incorrect time value: '-01:01:01.01 GGG'
-Warning 1292 Truncated incorrect time value: '1997-12-31 23:59:59.01XXXX'
+Warning 1292 Truncated incorrect datetime value: '1997-12-31 23:59:59.01XXXX'
select str_to_date("2003-04-05 g", "%Y-%m-%d") as f1,
str_to_date("2003-04-05 10:11:12.101010234567", "%Y-%m-%d %H:%i:%S.%f") as f2;
f1 f2
diff --git a/mysql-test/main/delayed.result b/mysql-test/main/delayed.result
index d10f4ae22cf..26a1fc670f4 100644
--- a/mysql-test/main/delayed.result
+++ b/mysql-test/main/delayed.result
@@ -500,7 +500,8 @@ call mtr.add_suppression("Checking table");
insert delayed into t1 values (2,2);
Warnings:
Error 145 Table './test/t1' is marked as crashed and should be repaired
-Error 1034 1 client is using or hasn't closed the table properly
+Warning 1034 1 client is using or hasn't closed the table properly
+Note 1034 Table is fixed
insert delayed into t1 values (3,3);
flush tables t1;
select * from t1;
diff --git a/mysql-test/main/derived.result b/mysql-test/main/derived.result
index a1dd1a77d3b..9874f16aa8a 100644
--- a/mysql-test/main/derived.result
+++ b/mysql-test/main/derived.result
@@ -1053,6 +1053,7 @@ INSERT INTO t2 VALUES (NULL),(NULL);
CREATE TABLE t3 (c VARCHAR(1024) CHARACTER SET utf8, d INT) ENGINE=MyISAM;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3;
INSERT INTO t3 VALUES ('abc',NULL),('def',4);
+set @save_join_cache_level= @@join_cache_level;
SET join_cache_level= 8;
explain
SELECT * FROM v1, t2, v3 WHERE a = c AND b = d;
@@ -1082,6 +1083,38 @@ i
drop procedure pr;
drop view v1;
drop table t1;
+set @@join_cache_level= @save_join_cache_level;
+#
+# MDEV-16307: Incorrect results when using BNLH join instead of BNL join with views
+#
+CREATE TABLE t1 (c1 text, c2 int);
+INSERT INTO t1 VALUES ('a',1), ('c',3), ('g',7), ('d',4), ('c',3);
+CREATE TABLE t2 (c1 text, c2 int);
+INSERT INTO t2 VALUES ('b',2), ('c',3);
+CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+explain SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 5 Using where; Using join buffer (flat, BNL join)
+2 DERIVED t1 ALL NULL NULL NULL NULL 5
+SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
+c1 c2 c1 c2
+c 3 c 3
+c 3 c 3
+set @save_join_cache_level= @@join_cache_level;
+set @@join_cache_level=4;
+explain SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY <derived2> hash_ALL NULL #hash#$hj 3 test.t2.c1 5 Using where; Using join buffer (flat, BNLH join)
+2 DERIVED t1 ALL NULL NULL NULL NULL 5
+SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
+c1 c2 c1 c2
+c 3 c 3
+c 3 c 3
+drop table t1,t2;
+drop view v1;
+set @@join_cache_level= @save_join_cache_level;
# end of 5.5
#
# Start of 10.1 tests
diff --git a/mysql-test/main/derived.test b/mysql-test/main/derived.test
index 466d79af409..6c51f23c51e 100644
--- a/mysql-test/main/derived.test
+++ b/mysql-test/main/derived.test
@@ -913,6 +913,7 @@ CREATE TABLE t3 (c VARCHAR(1024) CHARACTER SET utf8, d INT) ENGINE=MyISAM;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3;
INSERT INTO t3 VALUES ('abc',NULL),('def',4);
+set @save_join_cache_level= @@join_cache_level;
SET join_cache_level= 8;
explain
SELECT * FROM v1, t2, v3 WHERE a = c AND b = d;
@@ -935,7 +936,27 @@ call pr(2);
drop procedure pr;
drop view v1;
drop table t1;
+set @@join_cache_level= @save_join_cache_level;
+--echo #
+--echo # MDEV-16307: Incorrect results when using BNLH join instead of BNL join with views
+--echo #
+
+CREATE TABLE t1 (c1 text, c2 int);
+INSERT INTO t1 VALUES ('a',1), ('c',3), ('g',7), ('d',4), ('c',3);
+CREATE TABLE t2 (c1 text, c2 int);
+INSERT INTO t2 VALUES ('b',2), ('c',3);
+CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+
+explain SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
+SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
+set @save_join_cache_level= @@join_cache_level;
+set @@join_cache_level=4;
+explain SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
+SELECT v1.c1, v1.c2, t2.c1, t2.c2 FROM v1, t2 WHERE v1.c1=t2.c1;
+drop table t1,t2;
+drop view v1;
+set @@join_cache_level= @save_join_cache_level;
--echo # end of 5.5
--echo #
diff --git a/mysql-test/main/derived_cond_pushdown.result b/mysql-test/main/derived_cond_pushdown.result
index f882dbba466..dac180301d7 100644
--- a/mysql-test/main/derived_cond_pushdown.result
+++ b/mysql-test/main/derived_cond_pushdown.result
@@ -1,23 +1,23 @@
create table t1 (a int, b int, c int);
create table t2 (a int, b int, c int, d decimal);
-insert into t1 values
+insert into t1 values
(1,21,345), (1,33,7), (8,33,114), (1,21,500), (1,19,107), (5,14,787),
(8,33,123), (9,10,211), (5,16,207), (1,33,988), (5,27,132), (1,21,104),
(6,20,309), (6,20,315), (1,21,101), (8,33,404), (9,10,800), (1,21,123),
(7,11,708), (6,20,214);
insert into t2 values
-(2,3,207,207.0000), (1,21,909,12.0000), (7,13,312,406.0000),
+(2,3,207,207.0000), (1,21,909,12.0000), (7,13,312,406.0000),
(8,64,248,107.0000), (6,20,315,279.3333), (1,19,203,107.0000),
(8,80,800,314.0000), (3,12,231,190.0000), (6,23,303,909.0000);
Warnings:
Note 1265 Data truncated for column 'd' at row 5
create table t1_double(a int, b double, c double);
-insert into t1_double values
+insert into t1_double values
(1,23.4,14.3333), (1,12.5,18.9), (3,12.5,18.9),
(4,33.4,14.3333), (4,14.3333,13.65), (5,17.89,7.22),
(6,33.4,14.3), (10,33.4,13.65), (11,33.4,13.65);
create table t2_double(a int, b double, c double);
-insert into t2_double values
+insert into t2_double values
(1,22.4,14.3333), (1,12.5,18.9), (2,22.4,18.9),
(4,33.4,14.3333), (5,22.4,13.65), (7,17.89,18.9),
(6,33.4,14.3333), (10,31.4,13.65), (12,33.4,13.65);
@@ -41,22 +41,22 @@ insert into t2_decimal values
(2,1,13),(2,2,11),(3,3,16),
(1,3,22),(1,3,14),(2,2,15),
(2,1,43),(2,3,11),(2,3,16);
-create view v1 as select a, b, max(c) as max_c, avg(c) as avg_c from t1
+create view v1 as select a, b, max(c) as max_c, avg(c) as avg_c from t1
group by a,b having max_c < 707;
-create view v2 as select a, b, max(c) as max_c, avg(c) as avg_c from t1
+create view v2 as select a, b, max(c) as max_c, avg(c) as avg_c from t1
where t1.a>5 group by a,b having max_c < 707;
create view v3 as select a, b, min(c) as min_c from t1
where t1.a<10 group by a,b having min_c > 109;
create view v4 as
select a, b, min(max_c) as min_c from v1
where (v1.a<15) group by a,b;
-create view v_union as
+create view v_union as
select a, b, min(c) as c from t1
where t1.a<10 group by a,b having c > 109
union
select a, b, max(c) as c from t1
where t1.b>10 group by a,b having c < 300;
-create view v2_union as
+create view v2_union as
select a, b, min(c) as c from t1
where t1.a<10 group by a,b having c > 109
union
@@ -65,13 +65,13 @@ where t1.b>10 group by a,b having c < 300
union
select a, b, avg(c) as c from t1
where t1.c>300 group by a,b having c < 707;
-create view v3_union as
+create view v3_union as
select a, b, (a+1) as c from t1
where t1.a<10
union
select a, b, c from t1
where t1.b>10 and t1.c>100;
-create view v4_union as
+create view v4_union as
select a, b, max(c)-100 as c from t1
where t1.a<10 group by a,b having c > 109
union
@@ -80,13 +80,13 @@ where t1.b>10;
create view v_double as
select a, avg(a/4) as avg_a, b, c from t1_double
where (b>12.2) group by b,c having (avg_a<22.333);
-create view v_char as
-select a, b, max(c) as max_c from t1_char
+create view v_char as
+select a, b, max(c) as max_c from t1_char
group by a,b having max_c < 9;
create view v_decimal as
select a, b, avg(c) as avg_c from t1_decimal
group by a,b having (avg_c>12);
-# conjunctive subformula : pushing into HAVING
+# conjunctive subformula : pushing into HAVING
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where (v1.max_c>214) and (t2.a>v1.a);
a b max_c avg_c a b c d
1 21 500 234.6000 2 3 207 207
@@ -161,7 +161,7 @@ EXPLAIN
}
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-group by a,b having max_c < 707) v1,
+group by a,b having max_c < 707) v1,
t2 where (v1.a=t2.a) and (v1.max_c>300);
a b max_c avg_c a b c d
1 21 500 234.6000 1 21 909 12
@@ -172,7 +172,7 @@ a b max_c avg_c a b c d
6 20 315 279.3333 6 23 303 909
select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-group by a,b having max_c < 707) v1,
+group by a,b having max_c < 707) v1,
t2 where (v1.a=t2.a) and (v1.max_c>300);
a b max_c avg_c a b c d
1 21 500 234.6000 1 21 909 12
@@ -183,7 +183,7 @@ a b max_c avg_c a b c d
6 20 315 279.3333 6 23 303 909
explain select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-group by a,b having max_c < 707) v1,
+group by a,b having max_c < 707) v1,
t2 where (v1.a=t2.a) and (v1.max_c>300);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
@@ -191,7 +191,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using temporary; Using filesort
explain format=json select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-group by a,b having max_c < 707) v1,
+group by a,b having max_c < 707) v1,
t2 where (v1.a=t2.a) and (v1.max_c>300);
EXPLAIN
{
@@ -235,8 +235,8 @@ EXPLAIN
}
}
}
-# extracted or formula : pushing into HAVING
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
+# extracted or formula : pushing into HAVING
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
((v1.max_c>400) and (t2.a>v1.a)) or ((v1.max_c<135) and (t2.a<v1.a));
a b max_c avg_c a b c d
1 21 500 234.6000 2 3 207 207
@@ -250,7 +250,7 @@ a b max_c avg_c a b c d
5 27 132 132.0000 1 21 909 12
5 27 132 132.0000 1 19 203 107
5 27 132 132.0000 3 12 231 190
-select * from v1,t2 where
+select * from v1,t2 where
((v1.max_c>400) and (t2.a>v1.a)) or ((v1.max_c<135) and (t2.a<v1.a));
a b max_c avg_c a b c d
1 21 500 234.6000 2 3 207 207
@@ -264,13 +264,13 @@ a b max_c avg_c a b c d
5 27 132 132.0000 1 21 909 12
5 27 132 132.0000 1 19 203 107
5 27 132 132.0000 3 12 231 190
-explain select * from v1,t2 where
+explain select * from v1,t2 where
((v1.max_c>400) and (t2.a>v1.a)) or ((v1.max_c<135) and (t2.a<v1.a));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using temporary; Using filesort
-explain format=json select * from v1,t2 where
+explain format=json select * from v1,t2 where
((v1.max_c>400) and (t2.a>v1.a)) or ((v1.max_c<135) and (t2.a<v1.a));
EXPLAIN
{
@@ -315,7 +315,7 @@ EXPLAIN
}
}
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
-((v1.max_c>300) and (v1.avg_c>t2.d) and (v1.b=t2.b)) or
+((v1.max_c>300) and (v1.avg_c>t2.d) and (v1.b=t2.b)) or
((v1.max_c<135) and (v1.max_c<t2.c) and (v1.a=t2.a));
a b max_c avg_c a b c d
1 19 107 107.0000 1 21 909 12
@@ -323,7 +323,7 @@ a b max_c avg_c a b c d
1 21 500 234.6000 1 21 909 12
6 20 315 279.3333 6 20 315 279
select * from v1,t2 where
-((v1.max_c>300) and (v1.avg_c>t2.d) and (v1.b=t2.b)) or
+((v1.max_c>300) and (v1.avg_c>t2.d) and (v1.b=t2.b)) or
((v1.max_c<135) and (v1.max_c<t2.c) and (v1.a=t2.a));
a b max_c avg_c a b c d
1 19 107 107.0000 1 21 909 12
@@ -331,14 +331,14 @@ a b max_c avg_c a b c d
1 21 500 234.6000 1 21 909 12
6 20 315 279.3333 6 20 315 279
explain select * from v1,t2 where
-((v1.max_c>300) and (v1.avg_c>t2.d) and (v1.b=t2.b)) or
+((v1.max_c>300) and (v1.avg_c>t2.d) and (v1.b=t2.b)) or
((v1.max_c<135) and (v1.max_c<t2.c) and (v1.a=t2.a));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using temporary; Using filesort
explain format=json select * from v1,t2 where
-((v1.max_c>300) and (v1.avg_c>t2.d) and (v1.b=t2.b)) or
+((v1.max_c>300) and (v1.avg_c>t2.d) and (v1.b=t2.b)) or
((v1.max_c<135) and (v1.max_c<t2.c) and (v1.a=t2.a));
EXPLAIN
{
@@ -508,7 +508,7 @@ EXPLAIN
}
}
# extracted or formula : pushing into WHERE
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
((v1.a>7) and (t2.c<v1.max_c)) or ((v1.a<2) and (t2.b<v1.b));
a b max_c avg_c a b c d
1 19 107 107.0000 2 3 207 207
@@ -526,7 +526,7 @@ a b max_c avg_c a b c d
8 33 404 213.6667 1 19 203 107
8 33 404 213.6667 3 12 231 190
8 33 404 213.6667 6 23 303 909
-select * from v1,t2 where
+select * from v1,t2 where
((v1.a>7) and (t2.c<v1.max_c)) or ((v1.a<2) and (t2.b<v1.b));
a b max_c avg_c a b c d
1 19 107 107.0000 2 3 207 207
@@ -544,13 +544,13 @@ a b max_c avg_c a b c d
8 33 404 213.6667 1 19 203 107
8 33 404 213.6667 3 12 231 190
8 33 404 213.6667 6 23 303 909
-explain select * from v1,t2 where
+explain select * from v1,t2 where
((v1.a>7) and (t2.c<v1.max_c)) or ((v1.a<2) and (t2.b<v1.b));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
-explain format=json select * from v1,t2 where
+explain format=json select * from v1,t2 where
((v1.a>7) and (t2.c<v1.max_c)) or ((v1.a<2) and (t2.b<v1.b));
EXPLAIN
{
@@ -595,7 +595,7 @@ EXPLAIN
}
}
}
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v2,t2 where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v2,t2 where
((v2.a>7) and (t2.c<v2.max_c)) or ((v2.a>5) and (t2.b<v2.b));
a b max_c avg_c a b c d
6 20 315 279.3333 2 3 207 207
@@ -610,7 +610,7 @@ a b max_c avg_c a b c d
8 33 404 213.6667 1 19 203 107
8 33 404 213.6667 3 12 231 190
8 33 404 213.6667 6 23 303 909
-select * from v2,t2 where
+select * from v2,t2 where
((v2.a>7) and (t2.c<v2.max_c)) or ((v2.a>5) and (t2.b<v2.b));
a b max_c avg_c a b c d
6 20 315 279.3333 2 3 207 207
@@ -625,13 +625,13 @@ a b max_c avg_c a b c d
8 33 404 213.6667 1 19 203 107
8 33 404 213.6667 3 12 231 190
8 33 404 213.6667 6 23 303 909
-explain select * from v2,t2 where
+explain select * from v2,t2 where
((v2.a>7) and (t2.c<v2.max_c)) or ((v2.a>5) and (t2.b<v2.b));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
-explain format=json select * from v2,t2 where
+explain format=json select * from v2,t2 where
((v2.a>7) and (t2.c<v2.max_c)) or ((v2.a>5) and (t2.b<v2.b));
EXPLAIN
{
@@ -676,29 +676,29 @@ EXPLAIN
}
}
}
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
-((v1.a>4) and (v1.b>t2.b) and (v1.max_c=t2.d)) or
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
+((v1.a>4) and (v1.b>t2.b) and (v1.max_c=t2.d)) or
((v1.a<2) and (v1.max_c<t2.c) and (v1.max_c=t2.d));
a b max_c avg_c a b c d
1 19 107 107.0000 8 64 248 107
1 19 107 107.0000 1 19 203 107
5 16 207 207.0000 2 3 207 207
-select * from v1,t2 where
-((v1.a>4) and (v1.b>t2.b) and (v1.max_c=t2.d)) or
+select * from v1,t2 where
+((v1.a>4) and (v1.b>t2.b) and (v1.max_c=t2.d)) or
((v1.a<2) and (v1.max_c<t2.c) and (v1.max_c=t2.d));
a b max_c avg_c a b c d
1 19 107 107.0000 8 64 248 107
1 19 107 107.0000 1 19 203 107
5 16 207 207.0000 2 3 207 207
-explain select * from v1,t2 where
-((v1.a>4) and (v1.b>t2.b) and (v1.max_c=t2.d)) or
+explain select * from v1,t2 where
+((v1.a>4) and (v1.b>t2.b) and (v1.max_c=t2.d)) or
((v1.a<2) and (v1.max_c<t2.c) and (v1.max_c=t2.d));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
-explain format=json select * from v1,t2 where
-((v1.a>4) and (v1.b>t2.b) and (v1.max_c=t2.d)) or
+explain format=json select * from v1,t2 where
+((v1.a>4) and (v1.b>t2.b) and (v1.max_c=t2.d)) or
((v1.a<2) and (v1.max_c<t2.c) and (v1.max_c=t2.d));
EXPLAIN
{
@@ -934,8 +934,8 @@ EXPLAIN
}
}
# extracted or formula : pushing into HAVING and WHERE
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
-((v1.a>7) and (v1.max_c>300) and (t2.c<v1.max_c)) or
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
+((v1.a>7) and (v1.max_c>300) and (t2.c<v1.max_c)) or
((v1.a<4) and (v1.max_c<500) and (t2.b<v1.b));
a b max_c avg_c a b c d
1 19 107 107.0000 2 3 207 207
@@ -948,8 +948,8 @@ a b max_c avg_c a b c d
8 33 404 213.6667 1 19 203 107
8 33 404 213.6667 3 12 231 190
8 33 404 213.6667 6 23 303 909
-select * from v1,t2 where
-((v1.a>7) and (v1.max_c>300) and (t2.c<v1.max_c)) or
+select * from v1,t2 where
+((v1.a>7) and (v1.max_c>300) and (t2.c<v1.max_c)) or
((v1.a<4) and (v1.max_c<500) and (t2.b<v1.b));
a b max_c avg_c a b c d
1 19 107 107.0000 2 3 207 207
@@ -962,15 +962,15 @@ a b max_c avg_c a b c d
8 33 404 213.6667 1 19 203 107
8 33 404 213.6667 3 12 231 190
8 33 404 213.6667 6 23 303 909
-explain select * from v1,t2 where
-((v1.a>7) and (v1.max_c>300) and (t2.c<v1.max_c)) or
+explain select * from v1,t2 where
+((v1.a>7) and (v1.max_c>300) and (t2.c<v1.max_c)) or
((v1.a<4) and (v1.max_c<500) and (t2.b<v1.b));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
-explain format=json select * from v1,t2 where
-((v1.a>7) and (v1.max_c>300) and (t2.c<v1.max_c)) or
+explain format=json select * from v1,t2 where
+((v1.a>7) and (v1.max_c>300) and (t2.c<v1.max_c)) or
((v1.a<4) and (v1.max_c<500) and (t2.b<v1.b));
EXPLAIN
{
@@ -1104,8 +1104,8 @@ EXPLAIN
}
}
}
-# extracted or formulas : pushing into WHERE and HAVING
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
+# extracted or formulas : pushing into WHERE and HAVING
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
((v1.a<2) and (v1.max_c>120) and (v1.b=t2.b)) or (v1.a>7);
a b max_c avg_c a b c d
1 21 500 234.6000 1 21 909 12
@@ -1118,7 +1118,7 @@ a b max_c avg_c a b c d
8 33 404 213.6667 8 80 800 314
8 33 404 213.6667 3 12 231 190
8 33 404 213.6667 6 23 303 909
-select * from v1,t2 where
+select * from v1,t2 where
((v1.a<2) and (v1.max_c>120) and (v1.b=t2.b)) or (v1.a>7);
a b max_c avg_c a b c d
1 21 500 234.6000 1 21 909 12
@@ -1131,13 +1131,13 @@ a b max_c avg_c a b c d
8 33 404 213.6667 8 80 800 314
8 33 404 213.6667 3 12 231 190
8 33 404 213.6667 6 23 303 909
-explain select * from v1,t2 where
+explain select * from v1,t2 where
((v1.a<2) and (v1.max_c>120) and (v1.b=t2.b)) or (v1.a>7);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
-explain format=json select * from v1,t2 where
+explain format=json select * from v1,t2 where
((v1.a<2) and (v1.max_c>120) and (v1.b=t2.b)) or (v1.a>7);
EXPLAIN
{
@@ -1250,7 +1250,7 @@ EXPLAIN
}
}
# prepare of a query containing extracted or formula
-prepare stmt from "select * from v1,t2 where
+prepare stmt from "select * from v1,t2 where
((v1.max_c>400) and (t2.a>v1.a)) or ((v1.max_c<135) and (t2.a<v1.a));";
execute stmt;
a b max_c avg_c a b c d
@@ -1279,8 +1279,8 @@ a b max_c avg_c a b c d
5 27 132 132.0000 1 19 203 107
5 27 132 132.0000 3 12 231 190
deallocate prepare stmt;
-prepare stmt from
-"explain format=json select * from v1,t2 where
+prepare stmt from
+"explain format=json select * from v1,t2 where
((v1.max_c>400) and (t2.a>v1.a)) or ((v1.max_c<135) and (t2.a<v1.a));";
execute stmt;
EXPLAIN
@@ -1652,7 +1652,7 @@ EXPLAIN
}
}
}
-# extracted and formula : pushing into WHERE
+# extracted and formula : pushing into WHERE
# pushing equalities
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where (v1.a=v1.b) and (v1.a=t2.a) and (v1.a=3);
a b max_c avg_c a b c d
@@ -1752,23 +1752,23 @@ EXPLAIN
}
}
}
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v_char as v,t2_char as t where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v_char as v,t2_char as t where
(v.a='c') and (v.b<'Hermes') and ((v.b=t.b) or (v.max_c>20));
a b max_c a b c
c Harry 4 d Harry 1
c Harry 4 b Harry 4
-select * from v_char as v,t2_char as t where
+select * from v_char as v,t2_char as t where
(v.a='c') and (v.b<'Hermes') and ((v.b=t.b) or (v.max_c>20));
a b max_c a b c
c Harry 4 d Harry 1
c Harry 4 b Harry 4
-explain select * from v_char as v,t2_char as t where
+explain select * from v_char as v,t2_char as t where
(v.a='c') and (v.b<'Hermes') and ((v.b=t.b) or (v.max_c>20));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 12 Using where
1 PRIMARY t ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1_char ALL NULL NULL NULL NULL 12 Using where; Using temporary; Using filesort
-explain format=json select * from v_char as v,t2_char as t where
+explain format=json select * from v_char as v,t2_char as t where
(v.a='c') and (v.b<'Hermes') and ((v.b=t.b) or (v.max_c>20));
EXPLAIN
{
@@ -1885,7 +1885,7 @@ EXPLAIN
}
}
}
-# extracted or formula : pushing into HAVING using equalities
+# extracted or formula : pushing into HAVING using equalities
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2
where ((t2.a<4) and (v1.a=t2.a)) or ((t2.c>150) and (v1.max_c=t2.c));
a b max_c avg_c a b c d
@@ -2014,24 +2014,24 @@ EXPLAIN
}
}
# conjunctive subformulas : pushing into WHERE and HAVING
-# pushing equalities
+# pushing equalities
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-group by a,b having max_c < 707) v1,
+group by a,b having max_c < 707) v1,
t2 where (v1.a=8) and (v1.a=t2.a) and (v1.max_c=404);
a b max_c avg_c a b c d
8 33 404 213.6667 8 64 248 107
8 33 404 213.6667 8 80 800 314
select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-group by a,b having max_c < 707) v1,
+group by a,b having max_c < 707) v1,
t2 where (v1.a=8) and (v1.a=t2.a) and (v1.max_c=404);
a b max_c avg_c a b c d
8 33 404 213.6667 8 64 248 107
8 33 404 213.6667 8 80 800 314
explain select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-group by a,b having max_c < 707) v1,
+group by a,b having max_c < 707) v1,
t2 where (v1.a=8) and (v1.a=t2.a) and (v1.max_c=404);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
@@ -2039,7 +2039,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
explain format=json select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-group by a,b having max_c < 707) v1,
+group by a,b having max_c < 707) v1,
t2 where (v1.a=8) and (v1.a=t2.a) and (v1.max_c=404);
EXPLAIN
{
@@ -2084,22 +2084,22 @@ EXPLAIN
}
}
}
-# conjunctive subformulas : pushing into WHERE and HAVING
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
+# conjunctive subformulas : pushing into WHERE and HAVING
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
(v1.a>3) and (v1.max_c>200) and (t2.b<v1.b) and (t2.d=v1.max_c);
a b max_c avg_c a b c d
5 16 207 207.0000 2 3 207 207
-select * from v1,t2 where
+select * from v1,t2 where
(v1.a>3) and (v1.max_c>200) and (t2.b<v1.b) and (t2.d=v1.max_c);
a b max_c avg_c a b c d
5 16 207 207.0000 2 3 207 207
-explain select * from v1,t2 where
+explain select * from v1,t2 where
(v1.a>3) and (v1.max_c>200) and (t2.b<v1.b) and (t2.d=v1.max_c);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
1 PRIMARY <derived2> ref key0 key0 5 test.t2.d 2 Using where
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
-explain format=json select * from v1,t2 where
+explain format=json select * from v1,t2 where
(v1.a>3) and (v1.max_c>200) and (t2.b<v1.b) and (t2.d=v1.max_c);
EXPLAIN
{
@@ -2205,7 +2205,7 @@ EXPLAIN
}
}
# conjunctive subformula : pushing into WHERE
-# extracted or formula : pushing into HAVING using equalities
+# extracted or formula : pushing into HAVING using equalities
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v_double as v,t2_double as t where
(((v.a>0.2) or (v.b<17)) or (t.c>17)) and (t.c=v.c) and (v.c>18);
a avg_a b c a b c
@@ -2366,17 +2366,17 @@ EXPLAIN
}
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-where t1.a>5 group by a,b having max_c < 707) v1,
+where t1.a>5 group by a,b having max_c < 707) v1,
t2 where (v1.a=t2.a) and (v1.max_c>300) and (v1.a=v1.b);
a b max_c avg_c a b c d
select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-where t1.a>5 group by a,b having max_c < 707) v1,
+where t1.a>5 group by a,b having max_c < 707) v1,
t2 where (v1.a=t2.a) and (v1.max_c>300) and (v1.a=v1.b);
a b max_c avg_c a b c d
explain select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-where t1.a>5 group by a,b having max_c < 707) v1,
+where t1.a>5 group by a,b having max_c < 707) v1,
t2 where (v1.a=t2.a) and (v1.max_c>300) and (v1.a=v1.b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
@@ -2384,7 +2384,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
explain format=json select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-where t1.a>5 group by a,b having max_c < 707) v1,
+where t1.a>5 group by a,b having max_c < 707) v1,
t2 where (v1.a=t2.a) and (v1.max_c>300) and (v1.a=v1.b);
EXPLAIN
{
@@ -2550,7 +2550,7 @@ EXPLAIN
}
}
}
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
(t2.a=v1.a) or (v1.b=t2.b) and ((v1.a=1) or (v1.a=6));
a b max_c avg_c a b c d
1 19 107 107.0000 1 21 909 12
@@ -2561,7 +2561,7 @@ a b max_c avg_c a b c d
6 20 315 279.3333 6 23 303 909
8 33 404 213.6667 8 64 248 107
8 33 404 213.6667 8 80 800 314
-select * from v1,t2 where
+select * from v1,t2 where
(t2.a=v1.a) or (v1.b=t2.b) and ((v1.a=1) or (v1.a=6));
a b max_c avg_c a b c d
1 19 107 107.0000 1 21 909 12
@@ -2572,13 +2572,13 @@ a b max_c avg_c a b c d
6 20 315 279.3333 6 23 303 909
8 33 404 213.6667 8 64 248 107
8 33 404 213.6667 8 80 800 314
-explain select * from v1,t2 where
+explain select * from v1,t2 where
(t2.a=v1.a) or (v1.b=t2.b) and ((v1.a=1) or (v1.a=6));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using temporary; Using filesort
-explain format=json select * from v1,t2 where
+explain format=json select * from v1,t2 where
(t2.a=v1.a) or (v1.b=t2.b) and ((v1.a=1) or (v1.a=6));
EXPLAIN
{
@@ -2716,7 +2716,7 @@ EXPLAIN
}
}
}
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
(t2.a<2) and (t2.c>900) and ((v1.a<t2.a) or (t2.a<11));
a b max_c avg_c a b c d
1 19 107 107.0000 1 21 909 12
@@ -2725,7 +2725,7 @@ a b max_c avg_c a b c d
5 27 132 132.0000 1 21 909 12
6 20 315 279.3333 1 21 909 12
8 33 404 213.6667 1 21 909 12
-select * from v1,t2 where
+select * from v1,t2 where
(t2.a<2) and (t2.c>900) and ((v1.a<t2.a) or (t2.a<11));
a b max_c avg_c a b c d
1 19 107 107.0000 1 21 909 12
@@ -2734,13 +2734,13 @@ a b max_c avg_c a b c d
5 27 132 132.0000 1 21 909 12
6 20 315 279.3333 1 21 909 12
8 33 404 213.6667 1 21 909 12
-explain select * from v1,t2 where
+explain select * from v1,t2 where
(t2.a<2) and (t2.c>900) and ((v1.a<t2.a) or (t2.a<11));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using temporary; Using filesort
-explain format=json select * from v1,t2 where
+explain format=json select * from v1,t2 where
(t2.a<2) and (t2.c>900) and ((v1.a<t2.a) or (t2.a<11));
EXPLAIN
{
@@ -2785,21 +2785,21 @@ EXPLAIN
}
}
# using several derived tables : nothing to push
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,v2,t2 where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,v2,t2 where
(v1.a=v2.a) and (v1.a=t2.a) and (v2.b<50);
a b max_c avg_c a b max_c avg_c a b c d
8 33 404 213.6667 8 33 404 213.6667 8 64 248 107
6 20 315 279.3333 6 20 315 279.3333 6 20 315 279
8 33 404 213.6667 8 33 404 213.6667 8 80 800 314
6 20 315 279.3333 6 20 315 279.3333 6 23 303 909
-select * from v1,v2,t2 where
+select * from v1,v2,t2 where
(v1.a=v2.a) and (v1.a=t2.a) and (v2.b<50);
a b max_c avg_c a b max_c avg_c a b c d
8 33 404 213.6667 8 33 404 213.6667 8 64 248 107
6 20 315 279.3333 6 20 315 279.3333 6 20 315 279
8 33 404 213.6667 8 33 404 213.6667 8 80 800 314
6 20 315 279.3333 6 20 315 279.3333 6 23 303 909
-explain select * from v1,v2,t2 where
+explain select * from v1,v2,t2 where
(v1.a=v2.a) and (v1.a=t2.a) and (v2.b<50);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
@@ -2807,7 +2807,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived3> ref key0 key0 5 test.t2.a 2 Using where
3 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using temporary; Using filesort
-explain format=json select * from v1,v2,t2 where
+explain format=json select * from v1,v2,t2 where
(v1.a=v2.a) and (v1.a=t2.a) and (v2.b<50);
EXPLAIN
{
@@ -2880,7 +2880,7 @@ EXPLAIN
}
}
}
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,v2,t2 where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,v2,t2 where
((v1.a=v2.a) or (v1.a=t2.a)) and (t2.b<50) and (v1.b=v2.b);
a b max_c avg_c a b max_c avg_c a b c d
6 20 315 279.3333 6 20 315 279.3333 2 3 207 207
@@ -2897,7 +2897,7 @@ a b max_c avg_c a b max_c avg_c a b c d
8 33 404 213.6667 8 33 404 213.6667 1 19 203 107
8 33 404 213.6667 8 33 404 213.6667 3 12 231 190
8 33 404 213.6667 8 33 404 213.6667 6 23 303 909
-select * from v1,v2,t2 where
+select * from v1,v2,t2 where
((v1.a=v2.a) or (v1.a=t2.a)) and (t2.b<50) and (v1.b=v2.b);
a b max_c avg_c a b max_c avg_c a b c d
6 20 315 279.3333 6 20 315 279.3333 2 3 207 207
@@ -2914,7 +2914,7 @@ a b max_c avg_c a b max_c avg_c a b c d
8 33 404 213.6667 8 33 404 213.6667 1 19 203 107
8 33 404 213.6667 8 33 404 213.6667 3 12 231 190
8 33 404 213.6667 8 33 404 213.6667 6 23 303 909
-explain select * from v1,v2,t2 where
+explain select * from v1,v2,t2 where
((v1.a=v2.a) or (v1.a=t2.a)) and (t2.b<50) and (v1.b=v2.b);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
@@ -2922,7 +2922,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived3> ref key0 key0 5 v1.b 2 Using where
3 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using temporary; Using filesort
-explain format=json select * from v1,v2,t2 where
+explain format=json select * from v1,v2,t2 where
((v1.a=v2.a) or (v1.a=t2.a)) and (t2.b<50) and (v1.b=v2.b);
EXPLAIN
{
@@ -2996,21 +2996,21 @@ EXPLAIN
}
}
}
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,v2,t2 where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,v2,t2 where
((v1.a=v2.a) and (v1.a=t2.a)) or ((v2.b>13) and (t2.c<115));
a b max_c avg_c a b max_c avg_c a b c d
6 20 315 279.3333 6 20 315 279.3333 6 20 315 279
6 20 315 279.3333 6 20 315 279.3333 6 23 303 909
8 33 404 213.6667 8 33 404 213.6667 8 64 248 107
8 33 404 213.6667 8 33 404 213.6667 8 80 800 314
-select * from v1,v2,t2 where
+select * from v1,v2,t2 where
((v1.a=v2.a) and (v1.a=t2.a)) or ((v2.b>13) and (t2.c<115));
a b max_c avg_c a b max_c avg_c a b c d
6 20 315 279.3333 6 20 315 279.3333 6 20 315 279
6 20 315 279.3333 6 20 315 279.3333 6 23 303 909
8 33 404 213.6667 8 33 404 213.6667 8 64 248 107
8 33 404 213.6667 8 33 404 213.6667 8 80 800 314
-explain select * from v1,v2,t2 where
+explain select * from v1,v2,t2 where
((v1.a=v2.a) and (v1.a=t2.a)) or ((v2.b>13) and (t2.c<115));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9
@@ -3018,7 +3018,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 20 Using where; Using join buffer (incremental, BNL join)
3 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using temporary; Using filesort
-explain format=json select * from v1,v2,t2 where
+explain format=json select * from v1,v2,t2 where
((v1.a=v2.a) and (v1.a=t2.a)) or ((v2.b>13) and (t2.c<115));
EXPLAIN
{
@@ -3094,22 +3094,22 @@ EXPLAIN
# using several derived tables : pushing in all tables
# conjunctive subformula : pushing into HAVING
# extracted or formula : pushing into WHERE
-# pushing equalities
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,v2,t2 where ((v1.a=v2.a) or (v1.a=t2.a)) and
+# pushing equalities
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,v2,t2 where ((v1.a=v2.a) or (v1.a=t2.a)) and
((v2.b<50) or (v2.b=19)) and (v1.max_c<300);
a b max_c avg_c a b max_c avg_c a b c d
1 19 107 107.0000 6 20 315 279.3333 1 21 909 12
1 19 107 107.0000 6 20 315 279.3333 1 19 203 107
1 19 107 107.0000 8 33 404 213.6667 1 21 909 12
1 19 107 107.0000 8 33 404 213.6667 1 19 203 107
-select * from v1,v2,t2 where ((v1.a=v2.a) or (v1.a=t2.a)) and
+select * from v1,v2,t2 where ((v1.a=v2.a) or (v1.a=t2.a)) and
((v2.b<50) or (v2.b=19)) and (v1.max_c<300);
a b max_c avg_c a b max_c avg_c a b c d
1 19 107 107.0000 6 20 315 279.3333 1 21 909 12
1 19 107 107.0000 6 20 315 279.3333 1 19 203 107
1 19 107 107.0000 8 33 404 213.6667 1 21 909 12
1 19 107 107.0000 8 33 404 213.6667 1 19 203 107
-explain select * from v1,v2,t2 where ((v1.a=v2.a) or (v1.a=t2.a)) and
+explain select * from v1,v2,t2 where ((v1.a=v2.a) or (v1.a=t2.a)) and
((v2.b<50) or (v2.b=19)) and (v1.max_c<300);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9
@@ -3117,7 +3117,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived3> ALL NULL NULL NULL NULL 20 Using where; Using join buffer (incremental, BNL join)
3 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using temporary; Using filesort
-explain format=json select * from v1,v2,t2 where ((v1.a=v2.a) or (v1.a=t2.a)) and
+explain format=json select * from v1,v2,t2 where ((v1.a=v2.a) or (v1.a=t2.a)) and
((v2.b<50) or (v2.b=19)) and (v1.max_c<300);
EXPLAIN
{
@@ -3194,13 +3194,13 @@ EXPLAIN
# using several derived tables : pushing only in one table
# conjunctive subformula : pushing into WHERE
# pushing equalities
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,v2,t2 where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,v2,t2 where
(v1.a=t2.a) and (v1.a=v1.b) and (v1.a=v2.a) and (v2.max_c<300);
a b max_c avg_c a b max_c avg_c a b c d
-select * from v1,v2,t2 where
+select * from v1,v2,t2 where
(v1.a=t2.a) and (v1.a=v1.b) and (v1.a=v2.a) and (v2.max_c<300);
a b max_c avg_c a b max_c avg_c a b c d
-explain select * from v1,v2,t2 where
+explain select * from v1,v2,t2 where
(v1.a=t2.a) and (v1.a=v1.b) and (v1.a=v2.a) and (v2.max_c<300);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
@@ -3208,7 +3208,7 @@ id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived3> ref key0 key0 5 test.t2.a 2 Using where
3 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
-explain format=json select * from v1,v2,t2 where
+explain format=json select * from v1,v2,t2 where
(v1.a=t2.a) and (v1.a=v1.b) and (v1.a=v2.a) and (v2.max_c<300);
EXPLAIN
{
@@ -3373,7 +3373,7 @@ EXPLAIN
# extracted or formula : pushing into WHERE
# conjunctive subformula : pushing into WHERE using equalities
# pushing equalities
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v_char as v,t2_char as t where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v_char as v,t2_char as t where
(v.a=t.a) and (t.a='b') and ((v.b='Vika') or (v.b='Ali'));
a b max_c a b c
b Vika 2 b Ivan 1
@@ -3381,7 +3381,7 @@ b Vika 2 b Ali 6
b Vika 2 b Hermes 3
b Vika 2 b Ivan 11
b Vika 2 b Harry 4
-select * from v_char as v,t2_char as t where
+select * from v_char as v,t2_char as t where
(v.a=t.a) and (t.a='b') and ((v.b='Vika') or (v.b='Ali'));
a b max_c a b c
b Vika 2 b Ivan 1
@@ -3389,13 +3389,13 @@ b Vika 2 b Ali 6
b Vika 2 b Hermes 3
b Vika 2 b Ivan 11
b Vika 2 b Harry 4
-explain select * from v_char as v,t2_char as t where
+explain select * from v_char as v,t2_char as t where
(v.a=t.a) and (t.a='b') and ((v.b='Vika') or (v.b='Ali'));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> ALL NULL NULL NULL NULL 12 Using where
1 PRIMARY t ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
2 DERIVED t1_char ALL NULL NULL NULL NULL 12 Using where; Using temporary; Using filesort
-explain format=json select * from v_char as v,t2_char as t where
+explain format=json select * from v_char as v,t2_char as t where
(v.a=t.a) and (t.a='b') and ((v.b='Vika') or (v.b='Ali'));
EXPLAIN
{
@@ -3442,10 +3442,10 @@ EXPLAIN
}
# using several derived tables : pushing in all tables
# extracted or formula : pushing into WHERE
-# conjunctive subformulas : pushing into HAVING
+# conjunctive subformulas : pushing into HAVING
# pushing equalities
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,v2,v3,t2 where
-((v1.a=v2.a) or (v1.a=t2.a)) and ((v3.b<50) or (v3.b=33))
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,v2,v3,t2 where
+((v1.a=v2.a) or (v1.a=t2.a)) and ((v3.b<50) or (v3.b=33))
and (v1.max_c<500) and (v3.a=t2.a) and (v2.max_c>300);
a b max_c avg_c a b max_c avg_c a b min_c a b c d
6 20 315 279.3333 6 20 315 279.3333 7 11 708 7 13 312 406
@@ -3462,8 +3462,8 @@ a b max_c avg_c a b max_c avg_c a b min_c a b c d
8 33 404 213.6667 8 33 404 213.6667 6 20 214 6 20 315 279
8 33 404 213.6667 8 33 404 213.6667 8 33 114 8 80 800 314
8 33 404 213.6667 8 33 404 213.6667 6 20 214 6 23 303 909
-select * from v1,v2,v3,t2 where
-((v1.a=v2.a) or (v1.a=t2.a)) and ((v3.b<50) or (v3.b=33))
+select * from v1,v2,v3,t2 where
+((v1.a=v2.a) or (v1.a=t2.a)) and ((v3.b<50) or (v3.b=33))
and (v1.max_c<500) and (v3.a=t2.a) and (v2.max_c>300);
a b max_c avg_c a b max_c avg_c a b min_c a b c d
6 20 315 279.3333 6 20 315 279.3333 7 11 708 7 13 312 406
@@ -3480,8 +3480,8 @@ a b max_c avg_c a b max_c avg_c a b min_c a b c d
8 33 404 213.6667 8 33 404 213.6667 6 20 214 6 20 315 279
8 33 404 213.6667 8 33 404 213.6667 8 33 114 8 80 800 314
8 33 404 213.6667 8 33 404 213.6667 6 20 214 6 23 303 909
-explain select * from v1,v2,v3,t2 where
-((v1.a=v2.a) or (v1.a=t2.a)) and ((v3.b<50) or (v3.b=33))
+explain select * from v1,v2,v3,t2 where
+((v1.a=v2.a) or (v1.a=t2.a)) and ((v3.b<50) or (v3.b=33))
and (v1.max_c<500) and (v3.a=t2.a) and (v2.max_c>300);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
@@ -3491,8 +3491,8 @@ id select_type table type possible_keys key key_len ref rows Extra
4 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
3 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using temporary; Using filesort
-explain format=json select * from v1,v2,v3,t2 where
-((v1.a=v2.a) or (v1.a=t2.a)) and ((v3.b<50) or (v3.b=33))
+explain format=json select * from v1,v2,v3,t2 where
+((v1.a=v2.a) or (v1.a=t2.a)) and ((v3.b<50) or (v3.b=33))
and (v1.max_c<500) and (v3.a=t2.a) and (v2.max_c>300);
EXPLAIN
{
@@ -3598,7 +3598,7 @@ EXPLAIN
}
}
# using several derived tables : pushing in all tables
-# conjunctive subformulas : pushing into HAVING
+# conjunctive subformulas : pushing into HAVING
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
where t1.a>5 group by a,b having max_c < 707) v1,
@@ -3706,7 +3706,7 @@ EXPLAIN
}
# using several derived tables : pushing in all tables
# extracted or formulas : pushing into HAVING
-# conjunctive subformula : pushing into HAVING
+# conjunctive subformula : pushing into HAVING
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
where t1.a>5 group by a,b having max_c < 707) v1,
@@ -3875,10 +3875,10 @@ EXPLAIN
}
}
# extracted or formula : pushing into HAVING
-# conjunctive subformula : pushing into WHERE
+# conjunctive subformula : pushing into WHERE
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-group by a,b having max_c < 707) v1,
+group by a,b having max_c < 707) v1,
t2 where ((v1.a=1) or (v1.max_c<300)) and (v1.b>25);
a b max_c avg_c a b c d
5 27 132 132.0000 2 3 207 207
@@ -3892,7 +3892,7 @@ a b max_c avg_c a b c d
5 27 132 132.0000 6 23 303 909
select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-group by a,b having max_c < 707) v1,
+group by a,b having max_c < 707) v1,
t2 where ((v1.a=1) or (v1.max_c<300)) and (v1.b>25);
a b max_c avg_c a b c d
5 27 132 132.0000 2 3 207 207
@@ -3906,7 +3906,7 @@ a b max_c avg_c a b c d
5 27 132 132.0000 6 23 303 909
explain select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-group by a,b having max_c < 707) v1,
+group by a,b having max_c < 707) v1,
t2 where ((v1.a=1) or (v1.max_c<300)) and (v1.b>25);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9
@@ -3914,7 +3914,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
explain format=json select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-group by a,b having max_c < 707) v1,
+group by a,b having max_c < 707) v1,
t2 where ((v1.a=1) or (v1.max_c<300)) and (v1.b>25);
EXPLAIN
{
@@ -3960,24 +3960,24 @@ EXPLAIN
}
}
# extracted and formula : pushing into WHERE
-# conjunctive subformula : pushing into HAVING
+# conjunctive subformula : pushing into HAVING
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-where t1.a>5 group by a,b having max_c < 707) v1,
+where t1.a>5 group by a,b having max_c < 707) v1,
t2 where (v1.a=t2.a) and (v1.max_c>300) and (v1.b<30);
a b max_c avg_c a b c d
6 20 315 279.3333 6 20 315 279
6 20 315 279.3333 6 23 303 909
select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-where t1.a>5 group by a,b having max_c < 707) v1,
+where t1.a>5 group by a,b having max_c < 707) v1,
t2 where (v1.a=t2.a) and (v1.max_c>300) and (v1.b<30);
a b max_c avg_c a b c d
6 20 315 279.3333 6 20 315 279
6 20 315 279.3333 6 23 303 909
explain select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-where t1.a>5 group by a,b having max_c < 707) v1,
+where t1.a>5 group by a,b having max_c < 707) v1,
t2 where (v1.a=t2.a) and (v1.max_c>300) and (v1.b<30);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
@@ -3985,7 +3985,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
explain format=json select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
-where t1.a>5 group by a,b having max_c < 707) v1,
+where t1.a>5 group by a,b having max_c < 707) v1,
t2 where (v1.a=t2.a) and (v1.max_c>300) and (v1.b<30);
EXPLAIN
{
@@ -4156,11 +4156,11 @@ EXPLAIN
}
}
# using query with union
-# extracted and formula : pushing into WHERE
-# extracted or formula : pushing into HAVING
+# extracted and formula : pushing into WHERE
+# extracted or formula : pushing into HAVING
# pushing equalities
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where (v1.a<5) and (v1.b=t2.b) and (v1.b=19)
-union
+union
select * from v1,t2 where ((v1.max_c>400) or (v1.avg_c>270)) and (v1.a<t2.a);
a b max_c avg_c a b c d
1 19 107 107.0000 1 19 203 107
@@ -4175,7 +4175,7 @@ a b max_c avg_c a b c d
6 20 315 279.3333 8 64 248 107
6 20 315 279.3333 8 80 800 314
select * from v1,t2 where (v1.a<5) and (v1.b=t2.b) and (v1.b=19)
-union
+union
select * from v1,t2 where ((v1.max_c>400) or (v1.avg_c>270)) and (v1.a<t2.a);
a b max_c avg_c a b c d
1 19 107 107.0000 1 19 203 107
@@ -4190,7 +4190,7 @@ a b max_c avg_c a b c d
6 20 315 279.3333 8 64 248 107
6 20 315 279.3333 8 80 800 314
explain select * from v1,t2 where (v1.a<5) and (v1.b=t2.b) and (v1.b=19)
-union
+union
select * from v1,t2 where ((v1.max_c>400) or (v1.avg_c>270)) and (v1.a<t2.a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
@@ -4201,7 +4201,7 @@ id select_type table type possible_keys key key_len ref rows Extra
4 DERIVED t1 ALL NULL NULL NULL NULL 20 Using temporary; Using filesort
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
explain format=json select * from v1,t2 where (v1.a<5) and (v1.b=t2.b) and (v1.b=19)
-union
+union
select * from v1,t2 where ((v1.max_c>400) or (v1.avg_c>270)) and (v1.a<t2.a);
EXPLAIN
{
@@ -4299,10 +4299,10 @@ EXPLAIN
}
}
# using query with union
-# extracted or formula : pushing into HAVING
+# extracted or formula : pushing into HAVING
# extracted or formula : pushing into WHERE
# pushing equalities
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
((t2.a=v1.a) or (v1.b=t2.b)) and ((v1.a=1) or (v1.a=6))
union
select * from v1,t2 where ((v1.a>3) and (v1.b>27)) or (v1.max_c>550);
@@ -4322,7 +4322,7 @@ a b max_c avg_c a b c d
8 33 404 213.6667 8 80 800 314
8 33 404 213.6667 3 12 231 190
8 33 404 213.6667 6 23 303 909
-select * from v1,t2 where
+select * from v1,t2 where
((t2.a=v1.a) or (v1.b=t2.b)) and ((v1.a=1) or (v1.a=6))
union
select * from v1,t2 where ((v1.a>3) and (v1.b>27)) or (v1.max_c>550);
@@ -4342,7 +4342,7 @@ a b max_c avg_c a b c d
8 33 404 213.6667 8 80 800 314
8 33 404 213.6667 3 12 231 190
8 33 404 213.6667 6 23 303 909
-explain select * from v1,t2 where
+explain select * from v1,t2 where
((t2.a=v1.a) or (v1.b=t2.b)) and ((v1.a=1) or (v1.a=6))
union
select * from v1,t2 where ((v1.a>3) and (v1.b>27)) or (v1.max_c>550);
@@ -4354,7 +4354,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 UNION <derived4> ALL NULL NULL NULL NULL 20 Using where; Using join buffer (flat, BNL join)
4 DERIVED t1 ALL NULL NULL NULL NULL 20 Using temporary; Using filesort
NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
-explain format=json select * from v1,t2 where
+explain format=json select * from v1,t2 where
((t2.a=v1.a) or (v1.b=t2.b)) and ((v1.a=1) or (v1.a=6))
union
select * from v1,t2 where ((v1.a>3) and (v1.b>27)) or (v1.max_c>550);
@@ -4454,10 +4454,10 @@ EXPLAIN
}
}
# using query with union
-# extracted or formula : pushing into HAVING
-# conjunctive subformulas : pushing into WHERE
+# extracted or formula : pushing into HAVING
+# conjunctive subformulas : pushing into WHERE
# pushing equalities
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v1,t2 where
((v1.a=1) and (v1.a=t2.a)) and ((v1.max_c<500) or (v1.avg_c>500))
union
select * from v2,t2 where
@@ -4472,7 +4472,7 @@ a b max_c avg_c a b c d
6 20 315 279.3333 1 19 203 107
8 33 404 213.6667 1 21 909 12
8 33 404 213.6667 1 19 203 107
-select * from v1,t2 where
+select * from v1,t2 where
((v1.a=1) and (v1.a=t2.a)) and ((v1.max_c<500) or (v1.avg_c>500))
union
select * from v2,t2 where
@@ -4487,7 +4487,7 @@ a b max_c avg_c a b c d
6 20 315 279.3333 1 19 203 107
8 33 404 213.6667 1 21 909 12
8 33 404 213.6667 1 19 203 107
-explain select * from v1,t2 where
+explain select * from v1,t2 where
((v1.a=1) and (v1.a=t2.a)) and ((v1.max_c<500) or (v1.avg_c>500))
union
select * from v2,t2 where
@@ -4506,7 +4506,7 @@ id select_type table type possible_keys key key_len ref rows Extra
3 UNION <derived6> ref key0 key0 5 test.t2.c 2 Using where
6 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
NULL UNION RESULT <union1,2,3> ALL NULL NULL NULL NULL NULL
-explain format=json select * from v1,t2 where
+explain format=json select * from v1,t2 where
((v1.a=1) and (v1.a=t2.a)) and ((v1.max_c<500) or (v1.avg_c>500))
union
select * from v2,t2 where
@@ -4760,7 +4760,7 @@ EXPLAIN
}
# using derived table with union
# conjunctive subformula : pushing into WHERE
-# extracted or formula : pushing into HAVING
+# extracted or formula : pushing into HAVING
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v_union,t2 where
((v_union.a<2) or (v_union.c>800)) and (v_union.b>12);
a b c a b c d
@@ -4963,27 +4963,27 @@ EXPLAIN
}
}
}
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v_char as v,t2_char as t where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v_char as v,t2_char as t where
(v.a=t.a) and (v.b='Vika') and (v.max_c>2);
a b max_c a b c
c Vika 7 c Vinny 3
c Vika 7 c Inga 9
c Vika 7 c Ivan 2
c Vika 7 c Inga 2
-select * from v_char as v,t2_char as t where
+select * from v_char as v,t2_char as t where
(v.a=t.a) and (v.b='Vika') and (v.max_c>2);
a b max_c a b c
c Vika 7 c Vinny 3
c Vika 7 c Inga 9
c Vika 7 c Ivan 2
c Vika 7 c Inga 2
-explain select * from v_char as v,t2_char as t where
+explain select * from v_char as v,t2_char as t where
(v.a=t.a) and (v.b='Vika') and (v.max_c>2);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t ALL NULL NULL NULL NULL 12 Using where
1 PRIMARY <derived2> ref key0 key0 2 test.t.a 2 Using where
2 DERIVED t1_char ALL NULL NULL NULL NULL 12 Using where; Using temporary; Using filesort
-explain format=json select * from v_char as v,t2_char as t where
+explain format=json select * from v_char as v,t2_char as t where
(v.a=t.a) and (v.b='Vika') and (v.max_c>2);
EXPLAIN
{
@@ -5033,19 +5033,19 @@ EXPLAIN
# conjunctive subformula : pushing into WHERE using equalities
# pushing equalities
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v_union,v1,t2 where
-(v_union.a=v1.a) and (v1.a=t2.a) and (t2.a=1)
+(v_union.a=v1.a) and (v1.a=t2.a) and (t2.a=1)
and ((v_union.c>800) or (v1.max_c>200));
a b c a b max_c avg_c a b c d
1 19 107 1 21 500 234.6000 1 21 909 12
1 19 107 1 21 500 234.6000 1 19 203 107
select * from v_union,v1,t2 where
-(v_union.a=v1.a) and (v1.a=t2.a) and (t2.a=1)
+(v_union.a=v1.a) and (v1.a=t2.a) and (t2.a=1)
and ((v_union.c>800) or (v1.max_c>200));
a b c a b max_c avg_c a b c d
1 19 107 1 21 500 234.6000 1 21 909 12
1 19 107 1 21 500 234.6000 1 19 203 107
explain select * from v_union,v1,t2 where
-(v_union.a=v1.a) and (v1.a=t2.a) and (t2.a=1)
+(v_union.a=v1.a) and (v1.a=t2.a) and (t2.a=1)
and ((v_union.c>800) or (v1.max_c>200));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
@@ -5056,7 +5056,7 @@ id select_type table type possible_keys key key_len ref rows Extra
3 UNION t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
explain format=json select * from v_union,v1,t2 where
-(v_union.a=v1.a) and (v1.a=t2.a) and (t2.a=1)
+(v_union.a=v1.a) and (v1.a=t2.a) and (t2.a=1)
and ((v_union.c>800) or (v1.max_c>200));
EXPLAIN
{
@@ -5161,11 +5161,11 @@ EXPLAIN
}
}
}
-# using derived table with union
-# extracted or formula : pushing into WHERE
+# using derived table with union
+# extracted or formula : pushing into WHERE
# conjunctive subformula : pushing into HAVING
# pushing equalities
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v2_union as v,t2 where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v2_union as v,t2 where
((v.a=6) or (v.a=8)) and (v.c>200) and (v.a=t2.a);
a b c a b c d
8 33 404.0000 8 64 248 107
@@ -5174,7 +5174,7 @@ a b c a b c d
8 33 404.0000 8 80 800 314
6 20 312.0000 6 23 303 909
6 20 214.0000 6 23 303 909
-select * from v2_union as v,t2 where
+select * from v2_union as v,t2 where
((v.a=6) or (v.a=8)) and (v.c>200) and (v.a=t2.a);
a b c a b c d
8 33 404.0000 8 64 248 107
@@ -5183,7 +5183,7 @@ a b c a b c d
8 33 404.0000 8 80 800 314
6 20 312.0000 6 23 303 909
6 20 214.0000 6 23 303 909
-explain select * from v2_union as v,t2 where
+explain select * from v2_union as v,t2 where
((v.a=6) or (v.a=8)) and (v.c>200) and (v.a=t2.a);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
@@ -5192,7 +5192,7 @@ id select_type table type possible_keys key key_len ref rows Extra
3 UNION t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
4 UNION t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
NULL UNION RESULT <union2,3,4> ALL NULL NULL NULL NULL NULL
-explain format=json select * from v2_union as v,t2 where
+explain format=json select * from v2_union as v,t2 where
((v.a=6) or (v.a=8)) and (v.c>200) and (v.a=t2.a);
EXPLAIN
{
@@ -5543,21 +5543,21 @@ EXPLAIN
}
# using derived table with union of selects without aggregation
# extracted the whole condition: in WHERE of both selects
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v3_union as v,t2 where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v3_union as v,t2 where
(v.a=t2.a) and ((v.b=19) or (v.b=21)) and ((v.c<3) or (v.c>600));
a b c a b c d
1 19 2 1 21 909 12
1 21 2 1 21 909 12
1 19 2 1 19 203 107
1 21 2 1 19 203 107
-select * from v3_union as v,t2 where
+select * from v3_union as v,t2 where
(v.a=t2.a) and ((v.b=19) or (v.b=21)) and ((v.c<3) or (v.c>600));
a b c a b c d
1 19 2 1 21 909 12
1 21 2 1 21 909 12
1 19 2 1 19 203 107
1 21 2 1 19 203 107
-explain select * from v3_union as v,t2 where
+explain select * from v3_union as v,t2 where
(v.a=t2.a) and ((v.b=19) or (v.b=21)) and ((v.c<3) or (v.c>600));
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
@@ -5565,7 +5565,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where
3 UNION t1 ALL NULL NULL NULL NULL 20 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
-explain format=json select * from v3_union as v,t2 where
+explain format=json select * from v3_union as v,t2 where
(v.a=t2.a) and ((v.b=19) or (v.b=21)) and ((v.c<3) or (v.c>600));
EXPLAIN
{
@@ -5627,7 +5627,7 @@ EXPLAIN
}
}
}
-# using derived table with union of
+# using derived table with union of
# a select without aggregation and a select with aggregation
# extracted conjunctive predicate: pushing in WHERE of both selects
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v4_union as v,t2 where (v.a=t2.a) and (v.b<20);
@@ -5716,13 +5716,13 @@ EXPLAIN
}
}
}
-# using derived table with union of
+# using derived table with union of
# a select without aggregation and a select with aggregation
# extracted subformula: pushing in WHERE of one select
# extracted subformula: pushing in HAVING of the other select
# extracted sub-subformula: pushing in WHERE of the other select
# using an equality in all pushdowns
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v4_union as v,t2 where
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v4_union as v,t2 where
(v.a=t2.a) and ((t2.a<3) or (v.b<40)) and (v.c>500);
a b c a b c d
1 33 1088 1 21 909 12
@@ -5735,7 +5735,7 @@ a b c a b c d
1 21 600 1 19 203 107
1 33 888 1 19 203 107
8 33 504 8 80 800 314
-select * from v4_union as v,t2 where
+select * from v4_union as v,t2 where
(v.a=t2.a) and ((t2.a<3) or (v.b<40)) and (v.c>500);
a b c a b c d
1 33 1088 1 21 909 12
@@ -5748,7 +5748,7 @@ a b c a b c d
1 21 600 1 19 203 107
1 33 888 1 19 203 107
8 33 504 8 80 800 314
-explain select * from v4_union as v,t2 where
+explain select * from v4_union as v,t2 where
(v.a=t2.a) and ((t2.a<3) or (v.b<40)) and (v.c>500);
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 9 Using where
@@ -5756,7 +5756,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DERIVED t1 ALL NULL NULL NULL NULL 20 Using where; Using temporary; Using filesort
3 UNION t1 ALL NULL NULL NULL NULL 20 Using where
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
-explain format=json select * from v4_union as v,t2 where
+explain format=json select * from v4_union as v,t2 where
(v.a=t2.a) and ((t2.a<3) or (v.b<40)) and (v.c>500);
EXPLAIN
{
@@ -6773,7 +6773,7 @@ EXPLAIN
# using several derived tables : pushing in all tables
# extracted or formula : pushing into WHERE
# conjunctive subformula : pushing into WHERE
-# pushing equalities
+# pushing equalities
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from v4,v2 where
(((v4.a<12) and (v4.b>13)) or (v4.a>10)) and
(v4.min_c=v2.max_c) and (v4.min_c>100);
@@ -6999,6 +6999,3412 @@ drop view v_union,v2_union,v3_union,v4_union;
drop view v_double,v_char,v_decimal;
drop table t1,t2,t1_double,t2_double,t1_char,t2_char,t1_decimal,t2_decimal;
#
+# MDEV-10782: condition extracted from a multiple equality
+# pushed into HAVING
+#
+CREATE TABLE t1 (i int);
+INSERT INTO t1 VALUES (1),(2);
+EXPLAIN EXTENDED
+SELECT *
+FROM ( SELECT * FROM ( SELECT MIN(i) as f FROM t1 ) sq1 ) AS sq2
+WHERE f = 8;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <derived3> ALL NULL NULL NULL NULL 2 100.00 Using where
+3 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00
+Warnings:
+Note 1003 /* select#1 */ select `sq1`.`f` AS `f` from (/* select#3 */ select min(`test`.`t1`.`i`) AS `f` from `test`.`t1` having `f` = 8) `sq1` where `sq1`.`f` = 8
+SELECT *
+FROM ( SELECT * FROM ( SELECT MIN(i) as f FROM t1 ) sq1 ) AS sq2
+WHERE f = 8;
+f
+SELECT *
+FROM ( SELECT * FROM ( SELECT MIN(i) as f FROM t1 ) sq1 ) AS sq2
+WHERE f = 1;
+f
+1
+DROP TABLE t1;
+#
+# MDEV-10783: pushdown into constant view
+#
+CREATE TABLE t1 (i int) ENGINE=MyISAM;
+CREATE VIEW v AS SELECT 5;
+SELECT * FROM t1 WHERE 1 IN ( SELECT * FROM v );
+i
+DROP VIEW v;
+DROP TABLE t1;
+#
+# MDEV-10785: second execution of a query with condition
+# pushed into view
+#
+CREATE TABLE t1 (i int);
+CREATE VIEW v1 AS SELECT i FROM t1 WHERE i < 5;
+CREATE FUNCTION f (in1 int) RETURNS int RETURN in1;
+CREATE VIEW v2 AS SELECT * FROM v1 GROUP BY i;
+PREPARE stmt FROM "SELECT * FROM v2 WHERE f(0) <> 2";
+EXECUTE stmt;
+i
+EXECUTE stmt;
+i
+DROP FUNCTION f;
+DROP VIEW v2,v1;
+DROP TABLE t1;
+#
+# MDEV-10884: condition pushdown into derived specified by
+# 1. unit with SELECT containing ORDER BY ... LIMIT
+# 2. unit containing global ORDER BY ... LIMIT
+#
+create table t1(a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+select a from t1 order by a limit 5;
+a
+0
+1
+2
+3
+4
+set statement optimizer_switch='condition_pushdown_for_derived=off' for
+select * from (select a from t1 order by a limit 5) t where t.a not in (1,2,3);
+a
+0
+4
+set statement optimizer_switch='condition_pushdown_for_derived=on' for
+select * from (select a from t1 order by a limit 5) t where t.a not in (1,2,3);
+a
+0
+4
+select a from t1 where a < 4 union select a from t1 where a > 5
+order by a limit 5;
+a
+0
+1
+2
+3
+6
+set statement optimizer_switch='condition_pushdown_for_derived=off' for
+select * from
+(select a from t1 where a < 4 union select a from t1 where a > 5
+order by a limit 5) t where t.a not in (2,9);
+a
+0
+1
+3
+6
+set statement optimizer_switch='condition_pushdown_for_derived=on' for
+select * from
+(select a from t1 where a < 4 union select a from t1 where a > 5
+order by a limit 5) t where t.a not in (2,9);
+a
+0
+1
+3
+6
+drop table t1;
+#
+# MDEV-11072: pushdown of the condition obtained
+# after constant row substitution
+#
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2;
+CREATE TABLE t3 (c INT) ENGINE=MyISAM;
+CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3;
+SELECT * FROM t1 WHERE a IN (
+SELECT b FROM v2 WHERE b < a OR b IN (
+SELECT c FROM v3 WHERE c = a
+)
+);
+a
+INSERT INTO t1 VALUES (2);
+INSERT INTO t2 VALUES (3), (2);
+INSERT INTO t3 VALUES (4), (1), (2), (7);
+SELECT * FROM t1 WHERE a IN (
+SELECT b FROM v2 WHERE b < a OR b IN (
+SELECT c FROM v3 WHERE c = a
+)
+);
+a
+2
+EXPLAIN FORMAT=JSON
+SELECT * FROM t1 WHERE a IN (
+SELECT b FROM v2 WHERE b < a OR b IN (
+SELECT c FROM v3 WHERE c = a
+)
+);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "const_condition": "0 or <in_optimizer>(2,<exists>(subquery#3))",
+ "table": {
+ "table_name": "t1",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100
+ },
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t2.b = 2",
+ "first_match": "t1"
+ },
+ "subqueries": [
+ {
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "table_name": "<derived5>",
+ "access_type": "index_subquery",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "5",
+ "used_key_parts": ["c"],
+ "ref": ["func"],
+ "rows": 2,
+ "filtered": 100,
+ "materialized": {
+ "query_block": {
+ "select_id": 5,
+ "table": {
+ "table_name": "t3",
+ "access_type": "ALL",
+ "rows": 4,
+ "filtered": 100,
+ "attached_condition": "t3.c = 2"
+ }
+ }
+ }
+ }
+ }
+ }
+ ]
+ }
+}
+CREATE TABLE t4 (d INT, e INT) ENGINE=MyISAM;
+INSERT INTO t4 VALUES (1,10),(3,11),(2,10),(2,20),(3,21);
+CREATE OR REPLACE VIEW v4 AS
+SELECT d, sum(e) AS s FROM t4 GROUP BY d;
+set statement optimizer_switch='condition_pushdown_for_derived=off' for SELECT * FROM t1 WHERE a IN (
+SELECT b FROM v2 WHERE b < a OR b IN (
+SELECT d FROM v4 WHERE s > a
+)
+);
+a
+2
+SELECT * FROM t1 WHERE a IN (
+SELECT b FROM v2 WHERE b < a OR b IN (
+SELECT d FROM v4 WHERE s > a
+)
+);
+a
+2
+explain SELECT * FROM t1 WHERE a IN (
+SELECT b FROM v2 WHERE b < a OR b IN (
+SELECT d FROM v4 WHERE s > a
+)
+);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 system NULL NULL NULL NULL 1
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
+3 DEPENDENT SUBQUERY <derived5> index_subquery key0 key0 5 func 2 Using where
+5 DERIVED t4 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
+explain format=json SELECT * FROM t1 WHERE a IN (
+SELECT b FROM v2 WHERE b < a OR b IN (
+SELECT d FROM v4 WHERE s > a
+)
+);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "const_condition": "0 or <in_optimizer>(2,<exists>(subquery#3))",
+ "table": {
+ "table_name": "t1",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100
+ },
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t2.b = 2",
+ "first_match": "t1"
+ },
+ "subqueries": [
+ {
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "table_name": "<derived5>",
+ "access_type": "index_subquery",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "5",
+ "used_key_parts": ["d"],
+ "ref": ["func"],
+ "rows": 2,
+ "filtered": 100,
+ "materialized": {
+ "query_block": {
+ "select_id": 5,
+ "having_condition": "s > 2",
+ "filesort": {
+ "sort_key": "t4.d",
+ "temporary_table": {
+ "table": {
+ "table_name": "t4",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ ]
+ }
+}
+DROP VIEW v2,v3,v4;
+DROP TABLE t1,t2,t3,t4;
+#
+# MDEV-10800: pushdown of the condition obtained
+# after constant row substitution
+#
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1);
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (3),(4);
+CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
+SELECT * FROM
+( SELECT * FROM t1
+WHERE EXISTS ( SELECT * FROM v2 WHERE b = a ) ) AS sq;
+a
+EXPLAIN FORMAT=JSON
+SELECT * FROM
+( SELECT * FROM t1
+WHERE EXISTS ( SELECT * FROM v2 WHERE b = a ) ) AS sq;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "const_condition": "<in_optimizer>(1,exists(subquery#3))",
+ "table": {
+ "table_name": "t1",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100
+ },
+ "subqueries": [
+ {
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "table_name": "<derived4>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "v2.b = 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 4,
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t2.b = 1"
+ }
+ }
+ }
+ }
+ }
+ }
+ ]
+ }
+}
+DROP VIEW v2;
+DROP TABLE t1,t2;
+#
+# MDEV-11102: condition pushdown into materialized inner table
+# of outer join is not applied as not being valid
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (0),(2);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (1),(2);
+CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
+SELECT * FROM t1 LEFT JOIN t2 ON a = b WHERE b IS NULL;
+a b
+0 NULL
+SELECT * FROM t1 LEFT JOIN v2 ON a = b WHERE b IS NULL;
+a b
+0 NULL
+EXPLAIN FORMAT=JSON
+SELECT * FROM t1 LEFT JOIN v2 ON a = b WHERE b IS NULL;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ref",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "5",
+ "used_key_parts": ["b"],
+ "ref": ["test.t1.a"],
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "trigcond(v2.b is null) and trigcond(trigcond(t1.a is not null))",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+}
+DROP VIEW v2;
+DROP TABLE t1,t2;
+#
+# MDEV-11103: pushdown condition with ANY subquery
+#
+CREATE TABLE t1 (i INT);
+CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 VALUES (1),(2);
+EXPLAIN FORMAT=JSON
+SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "<nop>(v1.i <= 3)",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "<nop>(t1.i <= 3)"
+ }
+ }
+ }
+ }
+ }
+}
+Warnings:
+Note 1249 Select 2 was reduced during optimization
+SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
+i
+1
+2
+DROP VIEW v1;
+DROP TABLE t1;
+#
+# MDEV-11315: condition with outer reference to mergeable derived
+#
+CREATE TABLE t1 (pk1 INT PRIMARY KEY, a INT, b INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (10,7,1),(11,0,2);
+CREATE TABLE t2 (pk2 INT PRIMARY KEY, c INT, d DATETIME) ENGINE=MyISAM;
+INSERT INTO t2 VALUES
+(1,4,'2008-09-27 00:34:58'),
+(2,5,'2007-05-28 00:00:00'),
+(3,6,'2009-07-25 09:21:20');
+CREATE VIEW v1 AS SELECT * FROM t1;
+CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
+SELECT * FROM v1 AS sq
+WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100;
+pk1 a b
+10 7 1
+11 0 2
+EXPLAIN FORMAT=JSON
+SELECT * FROM v1 AS sq
+WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "<in_optimizer>(t1.b,<exists>(subquery#2)) or t1.b = 100"
+ },
+ "subqueries": [
+ {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "<derived4>",
+ "access_type": "index_subquery",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "4",
+ "used_key_parts": ["pk2"],
+ "ref": ["func"],
+ "rows": 2,
+ "filtered": 100,
+ "materialized": {
+ "query_block": {
+ "select_id": 4,
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ ]
+ }
+}
+SELECT * FROM ( SELECT * FROM t1 ) AS sq
+WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100;
+pk1 a b
+10 7 1
+11 0 2
+EXPLAIN FORMAT=JSON
+SELECT * FROM ( SELECT * FROM t1 ) AS sq
+WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "<in_optimizer>(t1.b,<exists>(subquery#3)) or t1.b = 100"
+ },
+ "subqueries": [
+ {
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "table_name": "<derived4>",
+ "access_type": "index_subquery",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "4",
+ "used_key_parts": ["pk2"],
+ "ref": ["func"],
+ "rows": 2,
+ "filtered": 100,
+ "materialized": {
+ "query_block": {
+ "select_id": 4,
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ ]
+ }
+}
+DROP VIEW v1,v2;
+DROP TABLE t1,t2;
+#
+# MDEV-11313: pushdown of the condition obtained
+# after constant row substitution
+#
+CREATE TABLE t1 (a INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 (b INT) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (50);
+CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+SELECT ( SELECT COUNT(*) FROM v1 WHERE a = t2.b ) AS f FROM t2 GROUP BY f;
+f
+0
+EXPLAIN FORMAT=JSON
+SELECT ( SELECT COUNT(*) FROM v1 WHERE a = t2.b ) AS f FROM t2 GROUP BY f;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t2",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100
+ },
+ "subqueries": [
+ {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "v1.a = 50",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t1.a = 50"
+ }
+ }
+ }
+ }
+ }
+ }
+ ]
+ }
+}
+CREATE TABLE t3 (a INT, b INT) ENGINE=MYISAM;
+INSERT INTO t3 VALUES (1,10),(3,11),(2,10),(2,20),(3,21);
+CREATE VIEW v2 AS SELECT a, sum(b) AS s FROM t3 GROUP BY a ;
+SELECT ( SELECT COUNT(*) FROM v2 WHERE s < t2.b ) AS f FROM t2 GROUP BY f;
+f
+3
+EXPLAIN FORMAT=JSON
+SELECT ( SELECT COUNT(*) FROM v2 WHERE s < t2.b ) AS f FROM t2 GROUP BY f;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t2",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100
+ },
+ "subqueries": [
+ {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "v2.s < 50",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "s < 50",
+ "filesort": {
+ "sort_key": "t3.a",
+ "temporary_table": {
+ "table": {
+ "table_name": "t3",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ ]
+ }
+}
+DROP VIEW v1,v2;
+DROP TABLE t1,t2,t3;
+#
+# MDEV-10882: pushdown of the predicate with cached value
+#
+CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL) ENGINE=MyISAM;
+CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 VALUES (1,2),(3,4);
+CREATE TABLE t2 (c INT NOT NULL) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (5),(6);
+SELECT a, GROUP_CONCAT(b) FROM v1
+WHERE b IN ( SELECT COUNT(c) FROM t2 ) GROUP BY a;
+a GROUP_CONCAT(b)
+1 2
+EXPLAIN FORMAT=JSON
+SELECT a, GROUP_CONCAT(b) FROM v1
+WHERE b IN ( SELECT COUNT(c) FROM t2 ) GROUP BY a;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "message": "Select tables optimized away"
+ }
+ }
+ }
+ },
+ "read_sorted_file": {
+ "filesort": {
+ "sort_key": "v1.a",
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "v1.b = 2",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t1.b = 2"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+DROP VIEW v1;
+DROP TABLE t1,t2;
+#
+# MDEV-10836: pushdown of the predicate with cached value
+#
+CREATE TABLE t (pk INT PRIMARY KEY, f INT) ENGINE=MyISAM;
+CREATE ALGORITHM=TEMPTABLE VIEW v AS SELECT * FROM t;
+INSERT INTO t VALUES (1,1),(3,2);
+SELECT * FROM v AS v1, v AS v2
+WHERE v2.pk > v1.f AND v1.f IN ( SELECT COUNT(pk) FROM t );
+pk f pk f
+3 2 3 2
+EXPLAIN FORMAT=JSON
+SELECT * FROM v AS v1, v AS v2
+WHERE v2.pk > v1.f AND v1.f IN ( SELECT COUNT(pk) FROM t );
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "message": "Select tables optimized away"
+ }
+ }
+ }
+ },
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "v1.f = 2",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "table_name": "t",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t.f = 2"
+ }
+ }
+ }
+ },
+ "block-nl-join": {
+ "table": {
+ "table_name": "<derived4>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "v2.pk > 2"
+ },
+ "buffer_type": "flat",
+ "buffer_size": "256Kb",
+ "join_type": "BNL",
+ "materialized": {
+ "query_block": {
+ "select_id": 4,
+ "table": {
+ "table_name": "t",
+ "access_type": "range",
+ "possible_keys": ["PRIMARY"],
+ "key": "PRIMARY",
+ "key_length": "4",
+ "used_key_parts": ["pk"],
+ "rows": 2,
+ "filtered": 100,
+ "index_condition": "t.pk > 2"
+ }
+ }
+ }
+ }
+ }
+}
+DROP VIEW v;
+DROP TABLE t;
+#
+# MDEV-11488: pushdown of the predicate with cached value
+#
+CREATE TABLE t1 (i INT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(3),(2);
+CREATE TABLE t2 (j INT, KEY(j)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (3),(4);
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+i
+3
+EXPLAIN FORMAT=JSON
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<subquery3>",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "message": "Select tables optimized away"
+ }
+ }
+ }
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "sq.i = 3",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "t1.i = 3"
+ }
+ }
+ }
+ }
+ }
+}
+UPDATE t2 SET j = 2 WHERE j = 3;
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+i
+2
+DROP TABLE t1,t2;
+CREATE TABLE t1 (i FLOAT) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1.5),(3.2),(2.71);
+CREATE TABLE t2 (j FLOAT, KEY(j)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (3.2),(2.71);
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+i
+2.71
+EXPLAIN FORMAT=JSON
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<subquery3>",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "message": "Select tables optimized away"
+ }
+ }
+ }
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "sq.i = 2.7100000381469727",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "t1.i = 2.7100000381469727"
+ }
+ }
+ }
+ }
+ }
+}
+DROP TABLE t1,t2;
+CREATE TABLE t1 (i DECIMAL(10,2)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1.5),(3.21),(2.47);
+CREATE TABLE t2 (j DECIMAL(10,2), KEY(j)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (3.21),(4.55);
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+i
+3.21
+EXPLAIN FORMAT=JSON
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<subquery3>",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "message": "Select tables optimized away"
+ }
+ }
+ }
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "sq.i = 3.21",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "t1.i = 3.21"
+ }
+ }
+ }
+ }
+ }
+}
+DROP TABLE t1,t2;
+CREATE TABLE t1 (i VARCHAR(32)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('cc'),('aa'),('ddd');
+CREATE TABLE t2 (j VARCHAR(16), KEY(j)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('bbb'),('aa');
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+i
+aa
+EXPLAIN FORMAT=JSON
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<subquery3>",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "message": "Select tables optimized away"
+ }
+ }
+ }
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "sq.i = 'aa'",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "t1.i = 'aa'"
+ }
+ }
+ }
+ }
+ }
+}
+DROP TABLE t1,t2;
+CREATE TABLE t1 (i DATETIME) ENGINE=MyISAM;
+INSERT INTO t1 VALUES
+('2008-09-27 00:34:58'),('2007-05-28 00:00:00'), ('2009-07-25 09:21:20');
+CREATE TABLE t2 (j DATETIME, KEY(j)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES
+('2007-05-28 00:00:00'), ('2010-08-25 00:00:00');
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+i
+2007-05-28 00:00:00
+EXPLAIN FORMAT=JSON
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<subquery3>",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "message": "Select tables optimized away"
+ }
+ }
+ }
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "sq.i = '2007-05-28 00:00:00'",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "t1.i = TIMESTAMP'2007-05-28 00:00:00'"
+ }
+ }
+ }
+ }
+ }
+}
+DROP TABLE t1,t2;
+CREATE TABLE t1 (i DATE) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('2008-09-27'),('2007-05-28'), ('2009-07-25');
+CREATE TABLE t2 (j DATE, KEY(j)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('2007-05-28'), ('2010-08-25');
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+i
+2007-05-28
+EXPLAIN FORMAT=JSON
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<subquery3>",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "message": "Select tables optimized away"
+ }
+ }
+ }
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "sq.i = '2007-05-28'",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "t1.i = DATE'2007-05-28'"
+ }
+ }
+ }
+ }
+ }
+}
+DROP TABLE t1,t2;
+CREATE TABLE t1 (i TIME) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('00:34:58'),('10:00:02'), ('09:21:20');
+CREATE TABLE t2 (j TIME, KEY(j)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('10:00:02'), ('11:00:10');
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+i
+10:00:02
+EXPLAIN FORMAT=JSON
+SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
+WHERE i IN ( SELECT MIN(j) FROM t2 );
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<subquery3>",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "message": "Select tables optimized away"
+ }
+ }
+ }
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "sq.i = '10:00:02'",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "t1.i = TIME'10:00:02'"
+ }
+ }
+ }
+ }
+ }
+}
+DROP TABLE t1,t2;
+#
+# MDEV-11593: pushdown of condition with NULLIF
+#
+CREATE TABLE t1 (i INT);
+CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 VALUES (2), (1);
+SELECT * FROM v1 WHERE NULLIF(1, i);
+i
+2
+EXPLAIN FORMAT=JSON
+SELECT * FROM v1 WHERE NULLIF(1, i);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "nullif(1,v1.i)",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "nullif(1,t1.i)"
+ }
+ }
+ }
+ }
+ }
+}
+DROP VIEW v1;
+DROP TABLE t1;
+#
+# MDEV-11608: pushdown of the predicate with cached null value
+#
+CREATE TABLE t1 (c VARCHAR(3));
+CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 VALUES ('foo'),('bar');
+CREATE TABLE t2 (c VARCHAR(3));
+INSERT INTO t2 VALUES ('foo'),('xyz');
+SELECT * FROM v1 WHERE v1.c IN ( SELECT MIN(c) FROM t2 WHERE 0 );
+c
+EXPLAIN FORMAT=JSON
+SELECT * FROM v1 WHERE v1.c IN ( SELECT MIN(c) FROM t2 WHERE 0 );
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "system",
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "message": "Impossible WHERE"
+ }
+ }
+ }
+ },
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "v1.c = NULL",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t1.c = NULL"
+ }
+ }
+ }
+ }
+ }
+}
+DROP VIEW v1;
+DROP TABLE t1,t2;
+CREATE TABLE t1 (d DECIMAL(10,2));
+CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 VALUES (5.37),(1.1);
+CREATE TABLE t2 (d DECIMAL(10,2));
+INSERT INTO t2 VALUES ('1.1'),('2.23');
+SELECT * FROM v1 WHERE v1.d IN ( SELECT MIN(d) FROM t2 WHERE 0 );
+d
+DROP VIEW v1;
+DROP TABLE t1,t2;
+#
+# MDEV-11820: second execution of PS for query
+# with false subquery predicate in WHERE
+#
+CREATE TABLE t1 (c VARCHAR(3)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES ('foo'),('bar');
+CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
+CREATE TABLE t2 (a INT);
+INSERT INTO t2 VALUES (3), (4);
+PREPARE stmt1 FROM
+" SELECT * FROM v1 WHERE 1 IN (SELECT a FROM t2) OR c = 'foo'";
+PREPARE stmt2 FROM
+"EXPLAIN FORMAT=JSON
+ SELECT * FROM v1 WHERE 1 IN (SELECT a FROM t2) OR c = 'foo'";
+EXECUTE stmt1;
+c
+foo
+EXECUTE stmt2;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "v1.c = 'foo'",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t1.c = 'foo'"
+ }
+ }
+ }
+ },
+ "subqueries": [
+ {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "1 = t2.a"
+ }
+ }
+ }
+ ]
+ }
+}
+INSERT INTO t2 SELECT a+1 FROM t2;
+INSERT INTO t2 SELECT a+1 FROM t2;
+INSERT INTO t2 SELECT a+1 FROM t2;
+INSERT INTO t2 SELECT a+1 FROM t2;
+INSERT INTO t2 SELECT a+1 FROM t2;
+INSERT INTO t2 SELECT a+1 FROM t2;
+EXECUTE stmt1;
+c
+foo
+EXECUTE stmt2;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "<cache>(<in_optimizer>(1,<exists>(subquery#2))) or v1.c = 'foo'",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100
+ }
+ }
+ }
+ },
+ "subqueries": [
+ {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 128,
+ "filtered": 100,
+ "attached_condition": "1 = t2.a"
+ }
+ }
+ }
+ ]
+ }
+}
+DEALLOCATE PREPARE stmt1;
+DEALLOCATE PREPARE stmt2;
+DROP VIEW v1;
+DROP TABLE t1,t2;
+#
+# MDEV-12373: pushdown into derived with side effects is prohibited
+#
+CREATE TABLE sales_documents (
+id int NOT NULL AUTO_INCREMENT,
+sale_id int NULL DEFAULT NULL,
+type tinyint unsigned NULL DEFAULT NULL,
+data text NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
+date date NULL DEFAULT NULL,
+order_number int unsigned NULL DEFAULT NULL,
+created_at int NULL DEFAULT NULL,
+updated_at int NULL DEFAULT NULL,
+generated tinyint NOT NULL DEFAULT '0',
+synced_at int NOT NULL DEFAULT '0',
+sum decimal(13,2) NOT NULL DEFAULT '0',
+PRIMARY KEY (id)
+);
+INSERT INTO sales_documents
+(id, sale_id, type, order_number, data, created_at,
+updated_at, date, generated, synced_at, sum)
+VALUES
+(555, 165, 3, 5, '{}', 1486538300, 1486722835, '2017-02-17', 0, 1486538313, 2320.00),
+(556, 165, 2, 3, '{}', 1486538304, 1486563125, '2017-02-08', 1, 1486538302, 2320.00),
+(557, 158, 2, 2, '{}', 1486538661, 1486538661, '2017-02-08', 0, 1486538660, 2320.00),
+(558, 171, 1, 3, '{}', 1486539104, 1488203405, '2017-02-08', 1, 1486539102, 23230.00),
+(559, 171, 2, 5, '{}', 1486549233, 1487146010, '2017-02-08', 1, 1486549225, 37690.00),
+(560, 172, 1, 1, '{}', 1486658260, 1488203409, '2017-02-09', 1, 1486658256, 40312.00),
+(561, 172, 2, 1, '{}', 1486711997, 1486711997, '2017-02-10', 1, 1486711996, 40312.00),
+(562, 172, 3, 1, '{}', 1486712104, 1486721395, '2017-02-10', 1, 1486712101, 40312.00),
+(563, 171, 3, 2, '{}', 1486712953, 1486720244, '2017-02-10', 1, 1486712910, 23230.00),
+(564, 170, 1, 2, '{}', 1486715948, 1488203410, '2017-02-10', 1, 1486715930, 28873.00),
+(565, 170, 3, 3, '{}', 1486716782, 1486717426, '2017-02-10', 1, 1486716779, 61948.00),
+(566, 166, 3, 4, '{}', 1486720947, 1486720947, '2017-02-10', 1, 1486720945, 4640.00),
+(567, 167, 3, 5, '{}', 1486722741, 1486722783, '2017-02-26', 0, 1486722738, 14755.00),
+(568, 165, 1, 4, '{}', 1486722849, 1486722849, '2017-02-10', 0, 1486722846, 2320.00),
+(569, 173, 2, 2, '{}', 1486723073, 1487071275, '2017-02-10', 1, 1486723071, 14282.00),
+(570, 173, 1, 4, '{}', 1486723100, 1488203412, '2017-02-10', 1, 1486723099, 14282.00),
+(571, 167, 2, 4, '{}', 1486730859, 1486730859, '2017-02-10', 1, 1486730856, 18655.00),
+(572, 167, 1, 5, '{}', 1486730883, 1488203412, '2017-02-10', 1, 1486730877, 18655.00),
+(573, 174, 2, 51, '{}', 1486731622, 1487060259, '2017-02-10', 1, 1486731620, 7140.00),
+(574, 174, 3, 5, '{}', 1486993472, 1486993472, '2017-02-13', 1, 1488216147, 28020.00),
+(575, 174, 1, 6, '{}', 1486993530, 1488203412, '2017-02-13', 1, 1486993505, 7140.00),
+(576, 173, 3, 6, '{}', 1487071425, 1487071425, '2017-02-14', 0, 1487071422, 14282.00),
+(577, 178, 2, 6, '{}', 1487327372, 1487327372, '2017-02-17', 1, 1487327370, 12321.00),
+(578, 177, 2, 7, '{}', 1487327394, 1487327394, '2017-02-17', 0, 1487327391, 4270.00),
+(579, 182, 3, 6, '{}', 1487750589, 1487751693, '2017-02-22', 1, 1487751688, 4270.00),
+(580, 182, 2, 7, '{}', 1487750601, 1487750663, '2017-02-22', 1, 1487750598, 4270.00),
+(581, 182, 1, 7, '{}', 1487750694, 1488203412, '2017-02-22', 1, 1487750692, 4270.00),
+(582, 185, 3, 7, '{}', 1487774051, 1487774051, '2017-02-22', 0, 1487774043, 8913.00),
+(583, 184, 3, 7, '{}', 1487774071, 1487774235, '2017-02-22', 0, 1487774093, 3285.00),
+(584, 184, 2, 8, '{}', 1487774074, 1487774074, '2017-02-22', 0, 1487774073, 3285.00),
+(585, 184, 1, 8, '{}', 1487774081, 1487774081, '2017-02-22', 0, 1487774075, 3285.00),
+(586, 193, 2, 8, '{}', 1487955294, 1487955318, '2017-02-24', 0, 1487955311, 4270.00),
+(587, 193, 1, 8, '{}', 1487955324, 1487955324, '2017-02-24', 0, 1487955320, 4270.00),
+(588, 193, 3, 7, '{}', 1487955341, 1487955341, '2017-02-24', 0, 1487955325, 4270.00),
+(589, 186, 1, 8, '{}', 1487957291, 1487957464, '2017-02-24', 0, 1487957459, 6960.00),
+(590, 186, 2, 8, '{}', 1487957308, 1487957468, '2017-02-24', 0, 1487957465, 6960.00),
+(591, 186, 3, 7, '{}', 1487957312, 1487957473, '2017-02-24', 0, 1487957469, 6960.00),
+(592, 194, 1, 8, '{}', 1488193293, 1488203412, '2017-02-27', 1, 1488193280, 2320.00),
+(593, 194, 2, 8, '{}', 1488193304, 1488193304, '2017-02-27', 1, 1488193303, 2320.00),
+(594, 210, 1, 9, '{}', 1488198896, 1488198896, '2017-02-27', 0, 1488198885, 4270.00),
+(595, 210, 2, 12, '{}', 1488198901, 1488198901, '2017-02-27', 1, 1488532585, 4270.00),
+(596, 210, 3, 10, '{}', 1488198904, 1488198904, '2017-02-27', 1, 1488532565, 4270.00),
+(597, 209, 2, 9, '{}', 1488200016, 1488450772, '2017-02-27', 1, 1488450449, 4270.00),
+(598, 209, 1, 9, '{}', 1488200020, 1488200063, '2017-02-27', 1, 1488200017, 4271.00),
+(599, 209, 3, 7, '{}', 1488200053, 1488200053, '2017-02-27', 0, 1488200021, 4271.00),
+(600, 211, 2, 10, '{}', 1488216265, 1489402027, '2017-02-27', 1, 1488216264, 2320.00),
+(601, 211, 3, 7, '{}', 1488216281, 1488216281, '2017-02-27', 1, 1488216276, 2320.00),
+(602, 211, 1, 10, '{}', 1488216283, 1488216283, '2017-02-27', 1, 1488216282, 2320.00),
+(603, 198, 2, 11, '{}', 1488280125, 1488280125, '2017-02-28', 0, 1488280095, 4270.00),
+(604, 198, 1, 11, '{}', 1488280160, 1488280160, '2017-02-28', 0, 1488280126, 4270.00),
+(605, 198, 3, 8, '{}', 1488280440, 1488280440, '2017-02-28', 0, 1488280435, 4270.00),
+(606, 212, 1, 12, '{}', 1488286301, 1489402168, '2017-02-28', 1, 1488286295, 13825.00),
+(607, 212, 3, 8, '{}', 1488289644, 1488289690, '2017-02-28', 1, 1488289642, 25295.00),
+(608, 212, 2, 13, '{}', 1488290350, 1488290431, '2017-02-28', 1, 1488290347, 13133.75),
+(609, 213, 1, 11, '{}', 1488529470, 1488529470, '2017-03-03', 1, 1488529461, 5660.00),
+(610, 213, 2, 11, '{}', 1488529484, 1488529484, '2017-03-03', 1, 1488529479, 5660.00),
+(611, 213, 3, 9, '{}', 1488529493, 1488529493, '2017-03-03', 1, 1488529489, 5660.00),
+(612, 197, 2, 13, '{}', 1489400715, 1489400715, '2017-03-13', 0, 1489398959, 4270.00),
+(613, 219, 3, 11, '{}', 1490084337, 1490181958, '2017-03-21', 1, 1490084334, 73526.00),
+(614, 216, 3, 11, '{}', 1490085757, 1490086717, '2017-03-21', 0, 1490085755, 5377.00);
+SELECT * FROM
+(SELECT @row := @row + 1 as row, a.* from (
+SELECT t.order_number
+FROM sales_documents t
+WHERE
+t.type = 2 AND
+t.date >= '2017-01-01' AND
+t.date <= '2017-12-31' AND
+t.order_number IS NOT NULL AND
+t.generated = 1
+GROUP BY t.order_number
+) a, (SELECT @row := 0) r) t
+WHERE row <> order_number;
+row order_number
+14 51
+DROP TABLE sales_documents;
+#
+# MDEV-12845: pushdown from merged derived using equalities
+#
+create table t1 (a int);
+insert into t1 values
+(4), (8), (5), (3), (10), (2), (7);
+create table t2 (b int, c int);
+insert into t2 values
+(2,1), (5,2), (2,2), (4,1), (4,3),
+(5,3), (2,4), (4,6), (2,1);
+create view v1 as
+select b, sum(c) as s from t2 group by b;
+create view v2 as
+select distinct b, c from t2;
+create view v3 as
+select b, max(c) as m from t2 group by b;
+select b
+from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t
+where b > 2;
+b
+4
+5
+explain format=json select b
+from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t
+where b > 2;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 7,
+ "filtered": 100,
+ "attached_condition": "t1.a > 2 and t1.a is not null"
+ },
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ref",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "5",
+ "used_key_parts": ["b"],
+ "ref": ["test.t1.a"],
+ "rows": 2,
+ "filtered": 100,
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "filesort": {
+ "sort_key": "t2.b",
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 9,
+ "filtered": 100,
+ "attached_condition": "t2.b > 2"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+select a
+from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t
+where a > 2;
+a
+4
+5
+explain format=json select a
+from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t
+where a > 2;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 7,
+ "filtered": 100,
+ "attached_condition": "t1.a > 2 and t1.a is not null"
+ },
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ref",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "5",
+ "used_key_parts": ["b"],
+ "ref": ["test.t1.a"],
+ "rows": 2,
+ "filtered": 100,
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "filesort": {
+ "sort_key": "t2.b",
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 9,
+ "filtered": 100,
+ "attached_condition": "t2.b > 2"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+select a
+from ( select t1.a, v2.b, v2.c from t1, v2 where t1.a = v2.b ) as t
+where a > 2;
+a
+4
+4
+4
+5
+5
+explain format=json select a
+from ( select t1.a, v2.b, v2.c from t1, v2 where t1.a = v2.b ) as t
+where a > 2;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 7,
+ "filtered": 100,
+ "attached_condition": "t1.a > 2 and t1.a is not null"
+ },
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ref",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "5",
+ "used_key_parts": ["b"],
+ "ref": ["test.t1.a"],
+ "rows": 2,
+ "filtered": 100,
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 9,
+ "filtered": 100,
+ "attached_condition": "t2.b > 2"
+ }
+ }
+ }
+ }
+ }
+ }
+}
+select a
+from ( select t1.a, v3.b, v3.m from t1, v3 where t1.a = v3.m ) as t
+where a > 2;
+a
+4
+3
+explain format=json select a
+from ( select t1.a, v3.b, v3.m from t1, v3 where t1.a = v3.m ) as t
+where a > 2;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 7,
+ "filtered": 100,
+ "attached_condition": "t1.a > 2 and t1.a is not null"
+ },
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ref",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "5",
+ "used_key_parts": ["m"],
+ "ref": ["test.t1.a"],
+ "rows": 2,
+ "filtered": 100,
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "m > 2",
+ "filesort": {
+ "sort_key": "t2.b",
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 9,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+drop view v1,v2,v3;
+drop table t1,t2;
+#
+# MDEV-13166: pushdown from merged derived
+#
+CREATE TABLE t1 (i int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+CREATE VIEW v1 AS SELECT MAX(i) AS f FROM t1;
+SELECT * FROM ( SELECT * FROM v1 ) AS sq WHERE f > 0;
+f
+2
+explain format=json SELECT * FROM ( SELECT * FROM v1 ) AS sq WHERE f > 0;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "v1.f > 0",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "f > 0",
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+}
+DROP VIEW v1;
+DROP TABLE t1;
+#
+# MDEV-13193: pushdown of equality extracted from multiple equality
+#
+CREATE TABLE t1 (i1 int, KEY(i1)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (1),(2);
+CREATE TABLE t2 (i2 int) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (2),(4);
+CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
+SELECT * FROM t1, ( SELECT * FROM v2 ) AS sq
+WHERE i1 = 1 AND ( i1 = i2 OR i1 = 2 );
+i1 i2
+explain format=json SELECT * FROM t1, ( SELECT * FROM v2 ) AS sq
+WHERE i1 = 1 AND ( i1 = i2 OR i1 = 2 );
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ref",
+ "possible_keys": ["i1"],
+ "key": "i1",
+ "key_length": "5",
+ "used_key_parts": ["i1"],
+ "ref": ["const"],
+ "rows": 1,
+ "filtered": 100,
+ "using_index": true
+ },
+ "block-nl-join": {
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "v2.i2 = 1"
+ },
+ "buffer_type": "flat",
+ "buffer_size": "256Kb",
+ "join_type": "BNL",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t2.i2 = 1"
+ }
+ }
+ }
+ }
+ }
+}
+DROP VIEW v2;
+DROP TABLE t1,t2;
+#
+# MDEV-14237: derived with regexp_substr() in select list
+#
+create table t1 (a char(8));
+insert into t1 values ('b'), ('a'), ('xx');
+select *
+from ( select distinct regexp_substr(t1.a,'^[A-Za-z]+') as f from t1) as t
+where t.f = 'a' or t.f = 'b';
+f
+b
+a
+explain format=json select *
+from ( select distinct regexp_substr(t1.a,'^[A-Za-z]+') as f from t1) as t
+where t.f = 'a' or t.f = 'b';
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "t.f = 'a' or t.f = 'b'",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+}
+drop table t1;
+#
+# MDEV-13454: consequence of mdev-14368 fixed for 5.5
+#
+SET sql_mode = 'ONLY_FULL_GROUP_BY';
+create table t1 (id int, id2 int);
+insert into t1 values (1,1),(2,3),(3,4),(7,2);
+create table t2(id2 int);
+insert t2 values (1),(2),(3);
+SELECT * FROM t1
+LEFT OUTER JOIN
+(SELECT id2, COUNT(*) as ct FROM t2 GROUP BY id2) vc USING (id2)
+WHERE (vc.ct>0);
+id2 id ct
+1 1 1
+3 2 1
+2 7 1
+EXPLAIN FORMAT=JSON SELECT * FROM t1
+LEFT OUTER JOIN
+(SELECT id2, COUNT(*) as ct FROM t2 GROUP BY id2) vc USING (id2)
+WHERE (vc.ct>0);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "vc.ct > 0",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "having_condition": "ct > 0",
+ "filesort": {
+ "sort_key": "t2.id2",
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ },
+ "block-nl-join": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 4,
+ "filtered": 100
+ },
+ "buffer_type": "flat",
+ "buffer_size": "256Kb",
+ "join_type": "BNL",
+ "attached_condition": "t1.id2 = vc.id2"
+ }
+ }
+}
+DROP TABLE t1,t2;
+SET sql_mode = DEFAULT;
+#
+# MDEV-15579: incorrect removal of sub-formulas to be pushed
+# into WHERE of materialized derived with GROUP BY
+#
+CREATE TABLE t1 (a INT, b INT, c INT, d INT);
+CREATE TABLE t2 (x INT, y INT, z INT);
+INSERT INTO t1 VALUES (1,1,66,1), (1,1,56,2), (3,2,42,3);
+INSERT INTO t2 VALUES (1,1,66), (1,12,32);
+SELECT *
+FROM t2,
+(
+SELECT a, b, max(c) AS max_c
+FROM t1
+GROUP BY a
+HAVING max_c > 37
+) AS v1
+WHERE (v1.a=1) AND (v1.b=v1.a) AND
+(v1.a=t2.x) AND (v1.max_c>30);
+x y z a b max_c
+1 1 66 1 1 66
+1 12 32 1 1 66
+EXPLAIN SELECT *
+FROM t2,
+(
+SELECT a, b, max(c) AS max_c
+FROM t1
+GROUP BY a
+HAVING max_c > 37
+) AS v1
+WHERE (v1.a=1) AND (v1.b=v1.a) AND
+(v1.a=t2.x) AND (v1.max_c>30);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+2 DERIVED t1 ALL NULL NULL NULL NULL 3 Using where
+EXPLAIN FORMAT=JSON SELECT *
+FROM t2,
+(
+SELECT a, b, max(c) AS max_c
+FROM t1
+GROUP BY a
+HAVING max_c > 37
+) AS v1
+WHERE (v1.a=1) AND (v1.b=v1.a) AND
+(v1.a=t2.x) AND (v1.max_c>30);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t2.x = 1"
+ },
+ "block-nl-join": {
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "v1.a = 1 and v1.b = 1 and v1.max_c > 30"
+ },
+ "buffer_type": "flat",
+ "buffer_size": "256Kb",
+ "join_type": "BNL",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "having_condition": "max_c > 37 and max_c > 30 and t1.b = 1",
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "t1.a = 1"
+ }
+ }
+ }
+ }
+ }
+}
+SELECT *
+FROM t2,
+(
+SELECT a, b, d, max(c) AS max_c
+FROM t1
+GROUP BY a,d
+HAVING max_c > 37
+) AS v1
+WHERE (v1.a=1) AND (v1.b=v1.a) AND (v1.b=v1.d) AND
+(v1.a=t2.x) AND (v1.max_c>30);
+x y z a b d max_c
+1 1 66 1 1 1 66
+1 12 32 1 1 1 66
+EXPLAIN SELECT *
+FROM t2,
+(
+SELECT a, b, d, max(c) AS max_c
+FROM t1
+GROUP BY a,d
+HAVING max_c > 37
+) AS v1
+WHERE (v1.a=1) AND (v1.b=v1.a) AND (v1.b=v1.d) AND
+(v1.a=t2.x) AND (v1.max_c>30);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
+2 DERIVED t1 ALL NULL NULL NULL NULL 3 Using where
+EXPLAIN FORMAT=JSON SELECT *
+FROM t2,
+(
+SELECT a, b, d, max(c) AS max_c
+FROM t1
+GROUP BY a,d
+HAVING max_c > 37
+) AS v1
+WHERE (v1.a=1) AND (v1.b=v1.a) AND (v1.b=v1.d) AND
+(v1.a=t2.x) AND (v1.max_c>30);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t2.x = 1"
+ },
+ "block-nl-join": {
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "v1.a = 1 and v1.b = 1 and v1.d = 1 and v1.max_c > 30"
+ },
+ "buffer_type": "flat",
+ "buffer_size": "256Kb",
+ "join_type": "BNL",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "having_condition": "max_c > 37 and max_c > 30 and t1.b = 1",
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "t1.a = 1 and t1.d = 1"
+ }
+ }
+ }
+ }
+ }
+}
+DROP TABLE t1,t2;
+#
+# MDEV-15765: pushing condition with temporal constants
+# into constant tables
+#
+select * from (select date('2018-01-01') as d
+union all
+select date('2018-01-01') as d) as t
+where t.d between date ('2017-01-01') and date ('2019-01-01');
+d
+2018-01-01
+2018-01-01
+select * from (select date('2018-01-01') as d) as t
+where t.d between date ('2017-01-01') and date ('2019-01-01');
+d
+2018-01-01
+#
+# MDEV-16088: pushdown into derived defined in the IN subquery
+#
+CREATE TABLE t1 (a INT, b INT);
+CREATE TABLE t2 (e INT, f INT, g INT);
+INSERT INTO t1 VALUES (1,14),(2,13),(1,19),(2,32),(3,24);
+INSERT INTO t2 VALUES (1,19,2),(3,24,1),(1,12,2),(3,11,3),(2,32,1);
+SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e,d_tab.max_f
+FROM (
+SELECT t2.e, MAX(t2.f) AS max_f
+FROM t2
+GROUP BY t2.e
+HAVING max_f>18
+) as d_tab
+WHERE d_tab.e>1
+)
+;
+a b
+2 32
+3 24
+EXPLAIN SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e,d_tab.max_f
+FROM (
+SELECT t2.e, MAX(t2.f) AS max_f
+FROM t2
+GROUP BY t2.e
+HAVING max_f>18
+) as d_tab
+WHERE d_tab.e>1
+)
+;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1
+2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where
+3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+EXPLAIN FORMAT=JSON SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e,d_tab.max_f
+FROM (
+SELECT t2.e, MAX(t2.f) AS max_f
+FROM t2
+GROUP BY t2.e
+HAVING max_f>18
+) as d_tab
+WHERE d_tab.e>1
+)
+;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100
+ },
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "eq_ref",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
+ "key_length": "8",
+ "used_key_parts": ["e", "max_f"],
+ "ref": ["func", "func"],
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "d_tab.e > 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "max_f > 18",
+ "filesort": {
+ "sort_key": "t2.e",
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "t2.e > 1"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e,d_tab.max_f
+FROM (
+SELECT t2.e, MAX(t2.f) AS max_f
+FROM t2
+GROUP BY t2.e
+HAVING max_f>18
+) as d_tab
+WHERE d_tab.max_f<25
+)
+;
+a b
+1 19
+3 24
+EXPLAIN SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e,d_tab.max_f
+FROM (
+SELECT t2.e, MAX(t2.f) AS max_f
+FROM t2
+GROUP BY t2.e
+HAVING max_f>18
+) as d_tab
+WHERE d_tab.max_f<25
+)
+;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1
+2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where
+3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
+EXPLAIN FORMAT=JSON SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e,d_tab.max_f
+FROM (
+SELECT t2.e, MAX(t2.f) AS max_f
+FROM t2
+GROUP BY t2.e
+HAVING max_f>18
+) as d_tab
+WHERE d_tab.max_f<25
+)
+;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100
+ },
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "eq_ref",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
+ "key_length": "8",
+ "used_key_parts": ["e", "max_f"],
+ "ref": ["func", "func"],
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "d_tab.max_f < 25",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "max_f > 18 and max_f < 25",
+ "filesort": {
+ "sort_key": "t2.e",
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
+FROM (
+SELECT t2.e, MAX(t2.f) as max_f, t2.g
+FROM t2
+GROUP BY t2.e
+) as d_tab
+WHERE d_tab.e>1
+GROUP BY d_tab.g
+)
+;
+a b
+2 32
+EXPLAIN SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
+FROM (
+SELECT t2.e, MAX(t2.f) as max_f, t2.g
+FROM t2
+GROUP BY t2.e
+) as d_tab
+WHERE d_tab.e>1
+GROUP BY d_tab.g
+)
+;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 test.t1.a,test.t1.b 1
+2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where; Using temporary
+3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
+EXPLAIN FORMAT=JSON SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
+FROM (
+SELECT t2.e, MAX(t2.f) as max_f, t2.g
+FROM t2
+GROUP BY t2.e
+) as d_tab
+WHERE d_tab.e>1
+GROUP BY d_tab.g
+)
+;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "t1.a is not null and t1.b is not null"
+ },
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "eq_ref",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
+ "key_length": "8",
+ "used_key_parts": ["e", "max_f"],
+ "ref": ["test.t1.a", "test.t1.b"],
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "temporary_table": {
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "d_tab.e > 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "filesort": {
+ "sort_key": "t2.e",
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "t2.e > 1"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
+FROM (
+SELECT t2.e, MAX(t2.f) as max_f, t2.g
+FROM t2
+GROUP BY t2.e
+) as d_tab
+WHERE d_tab.max_f>20
+GROUP BY d_tab.g
+)
+;
+a b
+2 32
+EXPLAIN SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
+FROM (
+SELECT t2.e, MAX(t2.f) as max_f, t2.g
+FROM t2
+GROUP BY t2.e
+) as d_tab
+WHERE d_tab.max_f>20
+GROUP BY d_tab.g
+)
+;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 test.t1.a,test.t1.b 1
+2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where; Using temporary
+3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
+EXPLAIN FORMAT=JSON SELECT * FROM t1
+WHERE (t1.a,t1.b) IN
+(
+SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
+FROM (
+SELECT t2.e, MAX(t2.f) as max_f, t2.g
+FROM t2
+GROUP BY t2.e
+) as d_tab
+WHERE d_tab.max_f>20
+GROUP BY d_tab.g
+)
+;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "t1.a is not null and t1.b is not null"
+ },
+ "table": {
+ "table_name": "<subquery2>",
+ "access_type": "eq_ref",
+ "possible_keys": ["distinct_key"],
+ "key": "distinct_key",
+ "key_length": "8",
+ "used_key_parts": ["e", "max_f"],
+ "ref": ["test.t1.a", "test.t1.b"],
+ "rows": 1,
+ "filtered": 100,
+ "materialized": {
+ "unique": 1,
+ "query_block": {
+ "select_id": 2,
+ "temporary_table": {
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "d_tab.max_f > 20",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "max_f > 20",
+ "filesort": {
+ "sort_key": "t2.e",
+ "temporary_table": {
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+DROP TABLE t1,t2;
+#
+# MDEV-15765: pushing condition with IN subquery defined with constants
+# using substitution
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2);
+SELECT * FROM
+(
+SELECT DISTINCT * FROM t1
+) der_tab
+WHERE (a>0 AND a<2 OR a IN (2,3)) AND
+(a=2 OR 0);
+a
+2
+DROP TABLE t1;
+#
+# MDEV-16386: pushing condition into the HAVING clause when ambiguous
+# fields warning appears
+#
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES (1,2),(2,3),(3,4);
+SELECT * FROM
+(
+SELECT t1.b AS a
+FROM t1
+GROUP BY t1.a
+) dt
+WHERE (dt.a=2);
+a
+2
+EXPLAIN FORMAT=JSON SELECT * FROM
+(
+SELECT t1.b AS a
+FROM t1
+GROUP BY t1.a
+) dt
+WHERE (dt.a=2);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "dt.a = 2",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "having_condition": "a = 2",
+ "filesort": {
+ "sort_key": "t1.a",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT * FROM
+(
+SELECT t1.b AS a
+FROM t1
+GROUP BY t1.a
+HAVING (t1.a<3)
+) dt
+WHERE (dt.a>1);
+a
+2
+3
+EXPLAIN FORMAT=JSON SELECT * FROM
+(
+SELECT t1.b AS a
+FROM t1
+GROUP BY t1.a
+HAVING (t1.a<3)
+) dt
+WHERE (dt.a>1);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "dt.a > 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "having_condition": "t1.a < 3 and a > 1",
+ "filesort": {
+ "sort_key": "t1.a",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT * FROM
+(
+SELECT 'ab' AS a
+FROM t1
+GROUP BY t1.a
+) dt
+WHERE (dt.a='ab');
+a
+ab
+ab
+ab
+EXPLAIN FORMAT=JSON SELECT * FROM
+(
+SELECT 'ab' AS a
+FROM t1
+GROUP BY t1.a
+) dt
+WHERE (dt.a='ab');
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "dt.a = 'ab'",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "filesort": {
+ "sort_key": "t1.a",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT * FROM
+(
+SELECT 1 AS a
+FROM t1
+GROUP BY t1.a
+) dt
+WHERE (dt.a=1);
+a
+1
+1
+1
+EXPLAIN FORMAT=JSON SELECT * FROM
+(
+SELECT 1 AS a
+FROM t1
+GROUP BY t1.a
+) dt
+WHERE (dt.a=1);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "dt.a = 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "filesort": {
+ "sort_key": "t1.a",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+DROP TABLE t1;
+#
+# MDEV-16517: pushdown condition with the IN predicate defined
+# with non-constant values
+#
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES (1,2),(1,3);
+SELECT * FROM
+(
+SELECT t1.a
+FROM t1
+WHERE 1 IN (0,t1.a)
+GROUP BY t1.a
+) AS dt1
+JOIN
+(
+SELECT t1.a
+FROM t1
+WHERE 1 IN (0,t1.a)
+) AS dt2
+ON dt1.a = dt2.a;
+a a
+1 1
+1 1
+EXPLAIN FORMAT=JSON SELECT * FROM
+(
+SELECT t1.a
+FROM t1
+WHERE 1 IN (0,t1.a)
+GROUP BY t1.a
+) AS dt1
+JOIN
+(
+SELECT t1.a
+FROM t1
+WHERE 1 IN (0,t1.a)
+) AS dt2
+ON dt1.a = dt2.a;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "1 in (0,dt1.a)",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "filesort": {
+ "sort_key": "t1.a",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "1 in (0,t1.a) and 1 in (0,t1.a)"
+ }
+ }
+ }
+ }
+ }
+ },
+ "block-nl-join": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100
+ },
+ "buffer_type": "flat",
+ "buffer_size": "256Kb",
+ "join_type": "BNL",
+ "attached_condition": "t1.a = dt1.a"
+ }
+ }
+}
+SELECT * FROM
+(
+SELECT t1.a,MAX(t1.b)
+FROM t1
+GROUP BY t1.a
+) AS dt, t1
+WHERE dt.a=t1.a AND dt.a IN (1,t1.a);
+a MAX(t1.b) a b
+1 3 1 2
+1 3 1 3
+EXPLAIN FORMAT=JSON SELECT * FROM
+(
+SELECT t1.a,MAX(t1.b)
+FROM t1
+GROUP BY t1.a
+) AS dt, t1
+WHERE dt.a=t1.a AND dt.a IN (1,t1.a);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "dt.a in (1,dt.a)",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "filesort": {
+ "sort_key": "t1.a",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t1.a in (1,t1.a)"
+ }
+ }
+ }
+ }
+ }
+ },
+ "block-nl-join": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 2,
+ "filtered": 100
+ },
+ "buffer_type": "flat",
+ "buffer_size": "256Kb",
+ "join_type": "BNL",
+ "attached_condition": "t1.a = dt.a"
+ }
+ }
+}
+DROP TABLE t1;
+#
+# MDEV-15087: error from inexpensive subquery before check
+# for condition pushdown into derived
+#
+CREATE TABLE t1 (i1 int, v1 varchar(1));
+INSERT INTO t1 VALUES (7,'x');
+CREATE TABLE t2 (i1 int);
+INSERT INTO t2 VALUES (8);
+CREATE TABLE t3 (i1 int ,v1 varchar(1), v2 varchar(1));
+INSERT INTO t3 VALUES (4, 'v','v'),(62,'v','k'),(7, 'n', NULL);
+SELECT 1
+FROM (t1 AS a1
+JOIN (((SELECT DISTINCT t3.*
+FROM t3) AS a2
+JOIN t1 ON (t1.v1 = a2.v2))) ON (t1.v1 = a2.v1))
+WHERE (SELECT BIT_COUNT(t2.i1)
+FROM (t2 JOIN t3)) IS NULL;
+ERROR 21000: Subquery returns more than 1 row
+DROP TABLE t1, t2, t3;
+#
+# MDEV-16614 signal 7 after calling stored procedure, that uses regexp
+#
+CREATE PROCEDURE p1(m1 varchar(5), m2 varchar(5))
+BEGIN
+SELECT a FROM
+(SELECT "aa" a) t
+JOIN (SELECT "aa" b) t1 on t.a=t1.b
+WHERE t.a regexp m1 and t1.b regexp m2
+GROUP BY a;
+END$$
+CALL p1('a','a');
+a
+aa
+DROP PROCEDURE p1;
+CREATE PROCEDURE p1(m1 varchar(5))
+BEGIN
+SELECT a FROM (SELECT "aa" a) t WHERE t.a regexp m1;
+END$$
+CALL p1('a');
+a
+aa
+DROP PROCEDURE p1;
+SELECT a FROM (SELECT "aa" a) t WHERE REGEXP_INSTR(t.a, (SELECT MAX('aa') FROM DUAL LIMIT 1));
+a
+aa
+CREATE OR REPLACE FUNCTION f1(a VARCHAR(10), b VARCHAR(10)) RETURNS INT
+BEGIN
+RETURN 1;
+END;$$
+CREATE OR REPLACE PROCEDURE p1(m1 varchar(5))
+BEGIN
+SELECT a FROM (SELECT "aa" a) t WHERE f1(t.a, m1);
+END$$
+CALL p1('a');
+a
+aa
+DROP PROCEDURE p1;
+DROP FUNCTION f1;
+CREATE OR REPLACE FUNCTION f1(a VARCHAR(10), b VARCHAR(10)) RETURNS INT
+BEGIN
+RETURN 1;
+END;$$
+SELECT a FROM (SELECT "aa" a) t WHERE f1(t.a, (SELECT MAX('aa') FROM DUAL LIMIT 1));
+a
+aa
+DROP FUNCTION f1;
+#
+# MDEV-17011: condition pushdown into materialized derived used
+# in INSERT SELECT, multi-table UPDATE and DELETE
+#
+CREATE TABLE t1 (a int ,b int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES
+(1, 1), (1, 2), (2, 1), (2, 2), (3,1), (3,3), (4,2);
+CREATE TABLE t2 (a int) ENGINE MYISAM;
+INSERT INTO t2 VALUES
+(3), (7), (1), (4), (1);
+CREATE TABLE t3 (a int, b int) ENGINE MYISAM;
+EXPLAIN FORMAT=JSON INSERT INTO t3
+SELECT * FROM (SELECT a, count(*) as c FROM t1 GROUP BY a) t WHERE a<=2;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 7,
+ "filtered": 100,
+ "attached_condition": "t.a <= 2",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "filesort": {
+ "sort_key": "t1.a",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 7,
+ "filtered": 100,
+ "attached_condition": "t1.a <= 2"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+INSERT INTO t3
+SELECT * FROM (SELECT a, count(*) as c FROM t1 GROUP BY a) t WHERE a<=2;
+SELECT * FROM t3;
+a b
+1 2
+2 2
+EXPLAIN FORMAT=JSON UPDATE t2, (SELECT a, count(*) as c FROM t1 GROUP BY a) t SET t2.a=t.c+10
+WHERE t2.a= t.c and t.a>=3;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100,
+ "attached_condition": "t2.a is not null"
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ref",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "8",
+ "used_key_parts": ["c"],
+ "ref": ["test.t2.a"],
+ "rows": 2,
+ "filtered": 100,
+ "attached_condition": "t2.a = t.c and t.a >= 3",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "filesort": {
+ "sort_key": "t1.a",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 7,
+ "filtered": 100,
+ "attached_condition": "t1.a >= 3"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+UPDATE t2, (SELECT a, count(*) as c FROM t1 GROUP BY a) t SET t2.a=t.c+10
+WHERE t2.a= t.c and t.a>=3;
+SELECT * FROM t2;
+a
+3
+7
+11
+4
+11
+EXPLAIN FORMAT=JSON DELETE t2 FROM t2, (SELECT a, count(*) as c FROM t1 GROUP BY a) t
+WHERE t2.a= t.c+9 and t.a=2;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "t2",
+ "access_type": "ALL",
+ "rows": 5,
+ "filtered": 100
+ },
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 7,
+ "filtered": 100,
+ "attached_condition": "t.a = 2 and t2.a = t.c + 9",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 7,
+ "filtered": 100,
+ "attached_condition": "t1.a = 2"
+ }
+ }
+ }
+ }
+ }
+}
+DELETE t2 FROM t2, (SELECT a, count(*) as c FROM t1 GROUP BY a) t
+WHERE t2.a= t.c+9 and t.a=2;
+SELECT * FROM t2;
+a
+3
+7
+4
+DROP TABLE t1,t2,t3;
+#
+# MDEV-16765: pushdown condition with the CASE structure
+# defined with Item_cond item
+#
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 VALUES (1,2), (3,4), (2,3);
+SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.max_a=1) OR (tab2.max_a=2))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+max_a b
+1 2
+1 3
+EXPLAIN FORMAT=JSON SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.max_a=1) OR (tab2.max_a=2))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "case when (tab2.max_a = 1 or tab2.max_a = 2) then 1 else 0 end = 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "case when (max_a = 1 or max_a = 2) then 1 else 0 end = 1",
+ "filesort": {
+ "sort_key": "t1.b",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.max_a=1) OR ((tab2.max_a>2) AND (tab2.max_a<4)))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+max_a b
+1 2
+1 4
+EXPLAIN FORMAT=JSON SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.max_a=1) OR ((tab2.max_a>2) AND (tab2.max_a<4)))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "case when (tab2.max_a = 1 or tab2.max_a > 2 and tab2.max_a < 4) then 1 else 0 end = 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "case when (max_a = 1 or max_a > 2 and max_a < 4) then 1 else 0 end = 1",
+ "filesort": {
+ "sort_key": "t1.b",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.max_a>1) AND ((tab2.max_a=2) OR (tab2.max_a>2)))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+max_a b
+1 3
+1 4
+EXPLAIN FORMAT=JSON SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.max_a>1) AND ((tab2.max_a=2) OR (tab2.max_a>2)))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "case when (tab2.max_a > 1 and (tab2.max_a = 2 or tab2.max_a > 2)) then 1 else 0 end = 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "having_condition": "case when (max_a > 1 and (max_a = 2 or max_a > 2)) then 1 else 0 end = 1",
+ "filesort": {
+ "sort_key": "t1.b",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.b=2) OR (tab2.b=4))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+max_a b
+1 2
+1 4
+EXPLAIN FORMAT=JSON SELECT *
+FROM
+(
+SELECT CASE WHEN ((tab2.b=2) OR (tab2.b=4))
+THEN 1 ELSE 0 END AS max_a,b
+FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived3>",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "case when (tab2.b = 2 or tab2.b = 4) then 1 else 0 end = 1",
+ "materialized": {
+ "query_block": {
+ "select_id": 3,
+ "filesort": {
+ "sort_key": "t1.b",
+ "temporary_table": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 3,
+ "filtered": 100,
+ "attached_condition": "case when (t1.b = 2 or t1.b = 4) then 1 else 0 end = 1"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+DROP TABLE t1;
+#
+# MDEV-16803: pushdown condition with IN predicate in the derived table
+# defined with several SELECT statements
+#
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES (1,2),(3,2),(1,1);
+SELECT * FROM
+(
+SELECT a,b,1 as c
+FROM t1
+UNION ALL
+SELECT a,b,2 as c
+FROM t1
+) AS tab
+WHERE ((a,b) IN ((1,2),(3,2)));
+a b c
+1 2 1
+3 2 1
+1 2 2
+3 2 2
+DROP TABLE t1;
+#
+# MDEV-17354: INSERT SELECT with condition pushdown into derived
+#
+CREATE TABLE t1 (f INT NOT NULL);
+INSERT INTO t1 VALUES (3), (7), (3);
+CREATE ALGORITHM= TEMPTABLE VIEW v1 AS SELECT * FROM ( SELECT * FROM t1 ) AS sq;
+INSERT INTO t1
+SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ) AS t WHERE f IS NOT NULL;
+EXPLAIN INSERT INTO t1
+SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ) AS t WHERE f IS NOT NULL;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 144 Using where
+2 DERIVED <derived4> ALL NULL NULL NULL NULL 12
+2 DERIVED t1 ALL NULL NULL NULL NULL 12 Using where; Using join buffer (flat, BNL join)
+4 DERIVED t1 ALL NULL NULL NULL NULL 12
+EXPLAIN FORMAT=JSON INSERT INTO t1
+SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ) AS t WHERE f IS NOT NULL;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 144,
+ "filtered": 100,
+ "attached_condition": "t.f is not null",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "<derived4>",
+ "access_type": "ALL",
+ "rows": 12,
+ "filtered": 100,
+ "materialized": {
+ "query_block": {
+ "select_id": 4,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 12,
+ "filtered": 100
+ }
+ }
+ }
+ },
+ "block-nl-join": {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 12,
+ "filtered": 100,
+ "attached_condition": "t1.f is not null"
+ },
+ "buffer_type": "flat",
+ "buffer_size": "256Kb",
+ "join_type": "BNL"
+ }
+ }
+ }
+ }
+ }
+}
+SELECT * FROM t1;
+f
+3
+7
+3
+3
+3
+3
+7
+7
+7
+3
+3
+3
+DELETE FROM t1;
+INSERT INTO t1 VALUES (3), (7), (3);
+INSERT INTO t1
+SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ON v1.f=t1.f) AS t
+WHERE f IS NOT NULL;
+EXPLAIN FORMAT=JSON INSERT INTO t1
+SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ON v1.f=t1.f) AS t
+WHERE f IS NOT NULL;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "table": {
+ "table_name": "<derived2>",
+ "access_type": "ALL",
+ "rows": 16,
+ "filtered": 100,
+ "attached_condition": "t.f is not null",
+ "materialized": {
+ "query_block": {
+ "select_id": 2,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 8,
+ "filtered": 100,
+ "attached_condition": "t1.f is not null"
+ },
+ "table": {
+ "table_name": "<derived4>",
+ "access_type": "ref",
+ "possible_keys": ["key0"],
+ "key": "key0",
+ "key_length": "4",
+ "used_key_parts": ["f"],
+ "ref": ["test.t1.f"],
+ "rows": 2,
+ "filtered": 100,
+ "materialized": {
+ "query_block": {
+ "select_id": 4,
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 8,
+ "filtered": 100,
+ "attached_condition": "t1.f is not null"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+SELECT * FROM t1;
+f
+3
+7
+3
+3
+3
+7
+3
+3
+DROP VIEW v1;
+DROP TABLE t1;
+# End of 10.2 tests
+#
# MDEV-14579: pushdown conditions into materialized views/derived tables
# that are defined with EXIST or/and INTERSECT
#
@@ -10715,2833 +14121,7 @@ drop view v1;
alter table t3 drop index i1;
drop table t1,t2,t3;
#
-# MDEV-10782: condition extracted from a multiple equality
-# pushed into HAVING
-#
-CREATE TABLE t1 (i int);
-INSERT INTO t1 VALUES (1),(2);
-EXPLAIN EXTENDED
-SELECT *
-FROM ( SELECT * FROM ( SELECT MIN(i) as f FROM t1 ) sq1 ) AS sq2
-WHERE f = 8;
-id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <derived3> ALL NULL NULL NULL NULL 2 100.00 Using where
-3 DERIVED t1 ALL NULL NULL NULL NULL 2 100.00
-Warnings:
-Note 1003 /* select#1 */ select `sq1`.`f` AS `f` from (/* select#3 */ select min(`test`.`t1`.`i`) AS `f` from `test`.`t1` having `f` = 8) `sq1` where `sq1`.`f` = 8
-SELECT *
-FROM ( SELECT * FROM ( SELECT MIN(i) as f FROM t1 ) sq1 ) AS sq2
-WHERE f = 8;
-f
-SELECT *
-FROM ( SELECT * FROM ( SELECT MIN(i) as f FROM t1 ) sq1 ) AS sq2
-WHERE f = 1;
-f
-1
-DROP TABLE t1;
-#
-# MDEV-10783: pushdown into constant view
-#
-CREATE TABLE t1 (i int) ENGINE=MyISAM;
-CREATE VIEW v AS SELECT 5;
-SELECT * FROM t1 WHERE 1 IN ( SELECT * FROM v );
-i
-DROP VIEW v;
-DROP TABLE t1;
-#
-# MDEV-10785: second execution of a query with condition
-# pushed into view
-#
-CREATE TABLE t1 (i int);
-CREATE VIEW v1 AS SELECT i FROM t1 WHERE i < 5;
-CREATE FUNCTION f (in1 int) RETURNS int RETURN in1;
-CREATE VIEW v2 AS SELECT * FROM v1 GROUP BY i;
-PREPARE stmt FROM "SELECT * FROM v2 WHERE f(0) <> 2";
-EXECUTE stmt;
-i
-EXECUTE stmt;
-i
-DROP FUNCTION f;
-DROP VIEW v2,v1;
-DROP TABLE t1;
-#
-# MDEV-10884: condition pushdown into derived specified by
-# 1. unit with SELECT containing ORDER BY ... LIMIT
-# 2. unit containing global ORDER BY ... LIMIT
-#
-create table t1(a int);
-insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-select a from t1 order by a limit 5;
-a
-0
-1
-2
-3
-4
-set statement optimizer_switch='condition_pushdown_for_derived=off' for
-select * from (select a from t1 order by a limit 5) t where t.a not in (1,2,3);
-a
-0
-4
-set statement optimizer_switch='condition_pushdown_for_derived=on' for
-select * from (select a from t1 order by a limit 5) t where t.a not in (1,2,3);
-a
-0
-4
-select a from t1 where a < 4 union select a from t1 where a > 5
-order by a limit 5;
-a
-0
-1
-2
-3
-6
-set statement optimizer_switch='condition_pushdown_for_derived=off' for
-select * from
-(select a from t1 where a < 4 union select a from t1 where a > 5
-order by a limit 5) t where t.a not in (2,9);
-a
-0
-1
-3
-6
-set statement optimizer_switch='condition_pushdown_for_derived=on' for
-select * from
-(select a from t1 where a < 4 union select a from t1 where a > 5
-order by a limit 5) t where t.a not in (2,9);
-a
-0
-1
-3
-6
-drop table t1;
-#
-# MDEV-11072: pushdown of the condition obtained
-# after constant row substitution
-#
-CREATE TABLE t1 (a INT) ENGINE=MyISAM;
-CREATE TABLE t2 (b INT) ENGINE=MyISAM;
-CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2;
-CREATE TABLE t3 (c INT) ENGINE=MyISAM;
-CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3;
-SELECT * FROM t1 WHERE a IN (
-SELECT b FROM v2 WHERE b < a OR b IN (
-SELECT c FROM v3 WHERE c = a
-)
-);
-a
-INSERT INTO t1 VALUES (2);
-INSERT INTO t2 VALUES (3), (2);
-INSERT INTO t3 VALUES (4), (1), (2), (7);
-SELECT * FROM t1 WHERE a IN (
-SELECT b FROM v2 WHERE b < a OR b IN (
-SELECT c FROM v3 WHERE c = a
-)
-);
-a
-2
-EXPLAIN FORMAT=JSON
-SELECT * FROM t1 WHERE a IN (
-SELECT b FROM v2 WHERE b < a OR b IN (
-SELECT c FROM v3 WHERE c = a
-)
-);
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "const_condition": "0 or <in_optimizer>(2,<exists>(subquery#3))",
- "table": {
- "table_name": "t1",
- "access_type": "system",
- "rows": 1,
- "filtered": 100
- },
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "t2.b = 2",
- "first_match": "t1"
- },
- "subqueries": [
- {
- "query_block": {
- "select_id": 3,
- "table": {
- "table_name": "<derived5>",
- "access_type": "index_subquery",
- "possible_keys": ["key0"],
- "key": "key0",
- "key_length": "5",
- "used_key_parts": ["c"],
- "ref": ["func"],
- "rows": 2,
- "filtered": 100,
- "materialized": {
- "query_block": {
- "select_id": 5,
- "table": {
- "table_name": "t3",
- "access_type": "ALL",
- "rows": 4,
- "filtered": 100,
- "attached_condition": "t3.c = 2"
- }
- }
- }
- }
- }
- }
- ]
- }
-}
-CREATE TABLE t4 (d INT, e INT) ENGINE=MyISAM;
-INSERT INTO t4 VALUES (1,10),(3,11),(2,10),(2,20),(3,21);
-CREATE OR REPLACE VIEW v4 AS
-SELECT d, sum(e) AS s FROM t4 GROUP BY d;
-set statement optimizer_switch='condition_pushdown_for_derived=off' for SELECT * FROM t1 WHERE a IN (
-SELECT b FROM v2 WHERE b < a OR b IN (
-SELECT d FROM v4 WHERE s > a
-)
-);
-a
-2
-SELECT * FROM t1 WHERE a IN (
-SELECT b FROM v2 WHERE b < a OR b IN (
-SELECT d FROM v4 WHERE s > a
-)
-);
-a
-2
-explain SELECT * FROM t1 WHERE a IN (
-SELECT b FROM v2 WHERE b < a OR b IN (
-SELECT d FROM v4 WHERE s > a
-)
-);
-id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 system NULL NULL NULL NULL 1
-1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where; FirstMatch(t1)
-3 DEPENDENT SUBQUERY <derived5> index_subquery key0 key0 5 func 2 Using where
-5 DERIVED t4 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
-explain format=json SELECT * FROM t1 WHERE a IN (
-SELECT b FROM v2 WHERE b < a OR b IN (
-SELECT d FROM v4 WHERE s > a
-)
-);
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "const_condition": "0 or <in_optimizer>(2,<exists>(subquery#3))",
- "table": {
- "table_name": "t1",
- "access_type": "system",
- "rows": 1,
- "filtered": 100
- },
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "t2.b = 2",
- "first_match": "t1"
- },
- "subqueries": [
- {
- "query_block": {
- "select_id": 3,
- "table": {
- "table_name": "<derived5>",
- "access_type": "index_subquery",
- "possible_keys": ["key0"],
- "key": "key0",
- "key_length": "5",
- "used_key_parts": ["d"],
- "ref": ["func"],
- "rows": 2,
- "filtered": 100,
- "materialized": {
- "query_block": {
- "select_id": 5,
- "having_condition": "s > 2",
- "filesort": {
- "sort_key": "t4.d",
- "temporary_table": {
- "table": {
- "table_name": "t4",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100
- }
- }
- }
- }
- }
- }
- }
- }
- ]
- }
-}
-DROP VIEW v2,v3,v4;
-DROP TABLE t1,t2,t3,t4;
-#
-# MDEV-10800: pushdown of the condition obtained
-# after constant row substitution
-#
-CREATE TABLE t1 (a INT) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (1);
-CREATE TABLE t2 (b INT) ENGINE=MyISAM;
-INSERT INTO t2 VALUES (3),(4);
-CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
-SELECT * FROM
-( SELECT * FROM t1
-WHERE EXISTS ( SELECT * FROM v2 WHERE b = a ) ) AS sq;
-a
-EXPLAIN FORMAT=JSON
-SELECT * FROM
-( SELECT * FROM t1
-WHERE EXISTS ( SELECT * FROM v2 WHERE b = a ) ) AS sq;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "const_condition": "<in_optimizer>(1,exists(subquery#3))",
- "table": {
- "table_name": "t1",
- "access_type": "system",
- "rows": 1,
- "filtered": 100
- },
- "subqueries": [
- {
- "query_block": {
- "select_id": 3,
- "table": {
- "table_name": "<derived4>",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "v2.b = 1",
- "materialized": {
- "query_block": {
- "select_id": 4,
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "t2.b = 1"
- }
- }
- }
- }
- }
- }
- ]
- }
-}
-DROP VIEW v2;
-DROP TABLE t1,t2;
-#
-# MDEV-11102: condition pushdown into materialized inner table
-# of outer join is not applied as not being valid
-#
-CREATE TABLE t1 (a INT);
-INSERT INTO t1 VALUES (0),(2);
-CREATE TABLE t2 (b INT);
-INSERT INTO t2 VALUES (1),(2);
-CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
-SELECT * FROM t1 LEFT JOIN t2 ON a = b WHERE b IS NULL;
-a b
-0 NULL
-SELECT * FROM t1 LEFT JOIN v2 ON a = b WHERE b IS NULL;
-a b
-0 NULL
-EXPLAIN FORMAT=JSON
-SELECT * FROM t1 LEFT JOIN v2 ON a = b WHERE b IS NULL;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100
- },
- "table": {
- "table_name": "<derived2>",
- "access_type": "ref",
- "possible_keys": ["key0"],
- "key": "key0",
- "key_length": "5",
- "used_key_parts": ["b"],
- "ref": ["test.t1.a"],
- "rows": 2,
- "filtered": 100,
- "attached_condition": "trigcond(v2.b is null) and trigcond(trigcond(t1.a is not null))",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100
- }
- }
- }
- }
- }
-}
-DROP VIEW v2;
-DROP TABLE t1,t2;
-#
-# MDEV-11103: pushdown condition with ANY subquery
-#
-CREATE TABLE t1 (i INT);
-CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
-INSERT INTO t1 VALUES (1),(2);
-EXPLAIN FORMAT=JSON
-SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "<nop>(v1.i <= 3)",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "<nop>(t1.i <= 3)"
- }
- }
- }
- }
- }
-}
-Warnings:
-Note 1249 Select 2 was reduced during optimization
-SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
-i
-1
-2
-DROP VIEW v1;
-DROP TABLE t1;
-#
-# MDEV-11315: condition with outer reference to mergeable derived
-#
-CREATE TABLE t1 (pk1 INT PRIMARY KEY, a INT, b INT) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (10,7,1),(11,0,2);
-CREATE TABLE t2 (pk2 INT PRIMARY KEY, c INT, d DATETIME) ENGINE=MyISAM;
-INSERT INTO t2 VALUES
-(1,4,'2008-09-27 00:34:58'),
-(2,5,'2007-05-28 00:00:00'),
-(3,6,'2009-07-25 09:21:20');
-CREATE VIEW v1 AS SELECT * FROM t1;
-CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
-SELECT * FROM v1 AS sq
-WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100;
-pk1 a b
-10 7 1
-11 0 2
-EXPLAIN FORMAT=JSON
-SELECT * FROM v1 AS sq
-WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "<in_optimizer>(t1.b,<exists>(subquery#2)) or t1.b = 100"
- },
- "subqueries": [
- {
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "<derived4>",
- "access_type": "index_subquery",
- "possible_keys": ["key0"],
- "key": "key0",
- "key_length": "4",
- "used_key_parts": ["pk2"],
- "ref": ["func"],
- "rows": 2,
- "filtered": 100,
- "materialized": {
- "query_block": {
- "select_id": 4,
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100
- }
- }
- }
- }
- }
- }
- ]
- }
-}
-SELECT * FROM ( SELECT * FROM t1 ) AS sq
-WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100;
-pk1 a b
-10 7 1
-11 0 2
-EXPLAIN FORMAT=JSON
-SELECT * FROM ( SELECT * FROM t1 ) AS sq
-WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "<in_optimizer>(t1.b,<exists>(subquery#3)) or t1.b = 100"
- },
- "subqueries": [
- {
- "query_block": {
- "select_id": 3,
- "table": {
- "table_name": "<derived4>",
- "access_type": "index_subquery",
- "possible_keys": ["key0"],
- "key": "key0",
- "key_length": "4",
- "used_key_parts": ["pk2"],
- "ref": ["func"],
- "rows": 2,
- "filtered": 100,
- "materialized": {
- "query_block": {
- "select_id": 4,
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100
- }
- }
- }
- }
- }
- }
- ]
- }
-}
-DROP VIEW v1,v2;
-DROP TABLE t1,t2;
-#
-# MDEV-11313: pushdown of the condition obtained
-# after constant row substitution
-#
-CREATE TABLE t1 (a INT) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (1),(2);
-CREATE TABLE t2 (b INT) ENGINE=MyISAM;
-INSERT INTO t2 VALUES (50);
-CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
-SELECT ( SELECT COUNT(*) FROM v1 WHERE a = t2.b ) AS f FROM t2 GROUP BY f;
-f
-0
-EXPLAIN FORMAT=JSON
-SELECT ( SELECT COUNT(*) FROM v1 WHERE a = t2.b ) AS f FROM t2 GROUP BY f;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t2",
- "access_type": "system",
- "rows": 1,
- "filtered": 100
- },
- "subqueries": [
- {
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "v1.a = 50",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "t1.a = 50"
- }
- }
- }
- }
- }
- }
- ]
- }
-}
-CREATE TABLE t3 (a INT, b INT) ENGINE=MYISAM;
-INSERT INTO t3 VALUES (1,10),(3,11),(2,10),(2,20),(3,21);
-CREATE VIEW v2 AS SELECT a, sum(b) AS s FROM t3 GROUP BY a ;
-SELECT ( SELECT COUNT(*) FROM v2 WHERE s < t2.b ) AS f FROM t2 GROUP BY f;
-f
-3
-EXPLAIN FORMAT=JSON
-SELECT ( SELECT COUNT(*) FROM v2 WHERE s < t2.b ) AS f FROM t2 GROUP BY f;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t2",
- "access_type": "system",
- "rows": 1,
- "filtered": 100
- },
- "subqueries": [
- {
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100,
- "attached_condition": "v2.s < 50",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "having_condition": "s < 50",
- "filesort": {
- "sort_key": "t3.a",
- "temporary_table": {
- "table": {
- "table_name": "t3",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100
- }
- }
- }
- }
- }
- }
- }
- }
- ]
- }
-}
-DROP VIEW v1,v2;
-DROP TABLE t1,t2,t3;
-#
-# MDEV-10882: pushdown of the predicate with cached value
-#
-CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL) ENGINE=MyISAM;
-CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
-INSERT INTO t1 VALUES (1,2),(3,4);
-CREATE TABLE t2 (c INT NOT NULL) ENGINE=MyISAM;
-INSERT INTO t2 VALUES (5),(6);
-SELECT a, GROUP_CONCAT(b) FROM v1
-WHERE b IN ( SELECT COUNT(c) FROM t2 ) GROUP BY a;
-a GROUP_CONCAT(b)
-1 2
-EXPLAIN FORMAT=JSON
-SELECT a, GROUP_CONCAT(b) FROM v1
-WHERE b IN ( SELECT COUNT(c) FROM t2 ) GROUP BY a;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<subquery2>",
- "access_type": "system",
- "rows": 1,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 2,
- "table": {
- "message": "Select tables optimized away"
- }
- }
- }
- },
- "read_sorted_file": {
- "filesort": {
- "sort_key": "v1.a",
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "v1.b = 2",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "t1.b = 2"
- }
- }
- }
- }
- }
- }
- }
-}
-DROP VIEW v1;
-DROP TABLE t1,t2;
-#
-# MDEV-10836: pushdown of the predicate with cached value
-#
-CREATE TABLE t (pk INT PRIMARY KEY, f INT) ENGINE=MyISAM;
-CREATE ALGORITHM=TEMPTABLE VIEW v AS SELECT * FROM t;
-INSERT INTO t VALUES (1,1),(3,2);
-SELECT * FROM v AS v1, v AS v2
-WHERE v2.pk > v1.f AND v1.f IN ( SELECT COUNT(pk) FROM t );
-pk f pk f
-3 2 3 2
-EXPLAIN FORMAT=JSON
-SELECT * FROM v AS v1, v AS v2
-WHERE v2.pk > v1.f AND v1.f IN ( SELECT COUNT(pk) FROM t );
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<subquery2>",
- "access_type": "system",
- "rows": 1,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 2,
- "table": {
- "message": "Select tables optimized away"
- }
- }
- }
- },
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "v1.f = 2",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "table": {
- "table_name": "t",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "t.f = 2"
- }
- }
- }
- },
- "block-nl-join": {
- "table": {
- "table_name": "<derived4>",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "v2.pk > 2"
- },
- "buffer_type": "flat",
- "buffer_size": "256Kb",
- "join_type": "BNL",
- "materialized": {
- "query_block": {
- "select_id": 4,
- "table": {
- "table_name": "t",
- "access_type": "range",
- "possible_keys": ["PRIMARY"],
- "key": "PRIMARY",
- "key_length": "4",
- "used_key_parts": ["pk"],
- "rows": 2,
- "filtered": 100,
- "index_condition": "t.pk > 2"
- }
- }
- }
- }
- }
-}
-DROP VIEW v;
-DROP TABLE t;
-#
-# MDEV-11488: pushdown of the predicate with cached value
-#
-CREATE TABLE t1 (i INT) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (1),(3),(2);
-CREATE TABLE t2 (j INT, KEY(j)) ENGINE=MyISAM;
-INSERT INTO t2 VALUES (3),(4);
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-i
-3
-EXPLAIN FORMAT=JSON
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<subquery3>",
- "access_type": "system",
- "rows": 1,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 3,
- "table": {
- "message": "Select tables optimized away"
- }
- }
- }
- },
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "sq.i = 3",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "t1.i = 3"
- }
- }
- }
- }
- }
-}
-UPDATE t2 SET j = 2 WHERE j = 3;
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-i
-2
-DROP TABLE t1,t2;
-CREATE TABLE t1 (i FLOAT) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (1.5),(3.2),(2.71);
-CREATE TABLE t2 (j FLOAT, KEY(j)) ENGINE=MyISAM;
-INSERT INTO t2 VALUES (3.2),(2.71);
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-i
-2.71
-EXPLAIN FORMAT=JSON
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<subquery3>",
- "access_type": "system",
- "rows": 1,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 3,
- "table": {
- "message": "Select tables optimized away"
- }
- }
- }
- },
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "sq.i = 2.7100000381469727",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "t1.i = 2.7100000381469727"
- }
- }
- }
- }
- }
-}
-DROP TABLE t1,t2;
-CREATE TABLE t1 (i DECIMAL(10,2)) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (1.5),(3.21),(2.47);
-CREATE TABLE t2 (j DECIMAL(10,2), KEY(j)) ENGINE=MyISAM;
-INSERT INTO t2 VALUES (3.21),(4.55);
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-i
-3.21
-EXPLAIN FORMAT=JSON
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<subquery3>",
- "access_type": "system",
- "rows": 1,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 3,
- "table": {
- "message": "Select tables optimized away"
- }
- }
- }
- },
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "sq.i = 3.21",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "t1.i = 3.21"
- }
- }
- }
- }
- }
-}
-DROP TABLE t1,t2;
-CREATE TABLE t1 (i VARCHAR(32)) ENGINE=MyISAM;
-INSERT INTO t1 VALUES ('cc'),('aa'),('ddd');
-CREATE TABLE t2 (j VARCHAR(16), KEY(j)) ENGINE=MyISAM;
-INSERT INTO t2 VALUES ('bbb'),('aa');
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-i
-aa
-EXPLAIN FORMAT=JSON
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<subquery3>",
- "access_type": "system",
- "rows": 1,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 3,
- "table": {
- "message": "Select tables optimized away"
- }
- }
- }
- },
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "sq.i = 'aa'",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "t1.i = 'aa'"
- }
- }
- }
- }
- }
-}
-DROP TABLE t1,t2;
-CREATE TABLE t1 (i DATETIME) ENGINE=MyISAM;
-INSERT INTO t1 VALUES
-('2008-09-27 00:34:58'),('2007-05-28 00:00:00'), ('2009-07-25 09:21:20');
-CREATE TABLE t2 (j DATETIME, KEY(j)) ENGINE=MyISAM;
-INSERT INTO t2 VALUES
-('2007-05-28 00:00:00'), ('2010-08-25 00:00:00');
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-i
-2007-05-28 00:00:00
-EXPLAIN FORMAT=JSON
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<subquery3>",
- "access_type": "system",
- "rows": 1,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 3,
- "table": {
- "message": "Select tables optimized away"
- }
- }
- }
- },
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "sq.i = '2007-05-28 00:00:00'",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "t1.i = TIMESTAMP'2007-05-28 00:00:00'"
- }
- }
- }
- }
- }
-}
-DROP TABLE t1,t2;
-CREATE TABLE t1 (i DATE) ENGINE=MyISAM;
-INSERT INTO t1 VALUES ('2008-09-27'),('2007-05-28'), ('2009-07-25');
-CREATE TABLE t2 (j DATE, KEY(j)) ENGINE=MyISAM;
-INSERT INTO t2 VALUES ('2007-05-28'), ('2010-08-25');
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-i
-2007-05-28
-EXPLAIN FORMAT=JSON
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<subquery3>",
- "access_type": "system",
- "rows": 1,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 3,
- "table": {
- "message": "Select tables optimized away"
- }
- }
- }
- },
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "sq.i = '2007-05-28'",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "t1.i = DATE'2007-05-28'"
- }
- }
- }
- }
- }
-}
-DROP TABLE t1,t2;
-CREATE TABLE t1 (i TIME) ENGINE=MyISAM;
-INSERT INTO t1 VALUES ('00:34:58'),('10:00:02'), ('09:21:20');
-CREATE TABLE t2 (j TIME, KEY(j)) ENGINE=MyISAM;
-INSERT INTO t2 VALUES ('10:00:02'), ('11:00:10');
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-i
-10:00:02
-EXPLAIN FORMAT=JSON
-SELECT * FROM ( SELECT DISTINCT * FROM t1 ) AS sq
-WHERE i IN ( SELECT MIN(j) FROM t2 );
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<subquery3>",
- "access_type": "system",
- "rows": 1,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 3,
- "table": {
- "message": "Select tables optimized away"
- }
- }
- }
- },
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "sq.i = '10:00:02'",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "t1.i = TIME'10:00:02'"
- }
- }
- }
- }
- }
-}
-DROP TABLE t1,t2;
-#
-# MDEV-11593: pushdown of condition with NULLIF
-#
-CREATE TABLE t1 (i INT);
-CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
-INSERT INTO t1 VALUES (2), (1);
-SELECT * FROM v1 WHERE NULLIF(1, i);
-i
-2
-EXPLAIN FORMAT=JSON
-SELECT * FROM v1 WHERE NULLIF(1, i);
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "nullif(1,v1.i)",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "nullif(1,t1.i)"
- }
- }
- }
- }
- }
-}
-DROP VIEW v1;
-DROP TABLE t1;
-#
-# MDEV-11608: pushdown of the predicate with cached null value
-#
-CREATE TABLE t1 (c VARCHAR(3));
-CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
-INSERT INTO t1 VALUES ('foo'),('bar');
-CREATE TABLE t2 (c VARCHAR(3));
-INSERT INTO t2 VALUES ('foo'),('xyz');
-SELECT * FROM v1 WHERE v1.c IN ( SELECT MIN(c) FROM t2 WHERE 0 );
-c
-EXPLAIN FORMAT=JSON
-SELECT * FROM v1 WHERE v1.c IN ( SELECT MIN(c) FROM t2 WHERE 0 );
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<subquery2>",
- "access_type": "system",
- "rows": 1,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 2,
- "table": {
- "message": "Impossible WHERE"
- }
- }
- }
- },
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "v1.c = NULL",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "t1.c = NULL"
- }
- }
- }
- }
- }
-}
-DROP VIEW v1;
-DROP TABLE t1,t2;
-CREATE TABLE t1 (d DECIMAL(10,2));
-CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
-INSERT INTO t1 VALUES (5.37),(1.1);
-CREATE TABLE t2 (d DECIMAL(10,2));
-INSERT INTO t2 VALUES ('1.1'),('2.23');
-SELECT * FROM v1 WHERE v1.d IN ( SELECT MIN(d) FROM t2 WHERE 0 );
-d
-DROP VIEW v1;
-DROP TABLE t1,t2;
-#
-# MDEV-11820: second execution of PS for query
-# with false subquery predicate in WHERE
-#
-CREATE TABLE t1 (c VARCHAR(3)) ENGINE=MyISAM;
-INSERT INTO t1 VALUES ('foo'),('bar');
-CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
-CREATE TABLE t2 (a INT);
-INSERT INTO t2 VALUES (3), (4);
-PREPARE stmt1 FROM
-" SELECT * FROM v1 WHERE 1 IN (SELECT a FROM t2) OR c = 'foo'";
-PREPARE stmt2 FROM
-"EXPLAIN FORMAT=JSON
- SELECT * FROM v1 WHERE 1 IN (SELECT a FROM t2) OR c = 'foo'";
-EXECUTE stmt1;
-c
-foo
-EXECUTE stmt2;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "v1.c = 'foo'",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "t1.c = 'foo'"
- }
- }
- }
- },
- "subqueries": [
- {
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "1 = t2.a"
- }
- }
- }
- ]
- }
-}
-INSERT INTO t2 SELECT a+1 FROM t2;
-INSERT INTO t2 SELECT a+1 FROM t2;
-INSERT INTO t2 SELECT a+1 FROM t2;
-INSERT INTO t2 SELECT a+1 FROM t2;
-INSERT INTO t2 SELECT a+1 FROM t2;
-INSERT INTO t2 SELECT a+1 FROM t2;
-EXECUTE stmt1;
-c
-foo
-EXECUTE stmt2;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "<cache>(<in_optimizer>(1,<exists>(subquery#2))) or v1.c = 'foo'",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100
- }
- }
- }
- },
- "subqueries": [
- {
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 128,
- "filtered": 100,
- "attached_condition": "1 = t2.a"
- }
- }
- }
- ]
- }
-}
-DEALLOCATE PREPARE stmt1;
-DEALLOCATE PREPARE stmt2;
-DROP VIEW v1;
-DROP TABLE t1,t2;
-#
-# MDEV-12373: pushdown into derived with side effects is prohibited
-#
-CREATE TABLE sales_documents (
-id int NOT NULL AUTO_INCREMENT,
-sale_id int NULL DEFAULT NULL,
-type tinyint unsigned NULL DEFAULT NULL,
-data text NULL DEFAULT NULL COLLATE 'utf8_unicode_ci',
-date date NULL DEFAULT NULL,
-order_number int unsigned NULL DEFAULT NULL,
-created_at int NULL DEFAULT NULL,
-updated_at int NULL DEFAULT NULL,
-generated tinyint NOT NULL DEFAULT '0',
-synced_at int NOT NULL DEFAULT '0',
-sum decimal(13,2) NOT NULL DEFAULT '0',
-PRIMARY KEY (id)
-);
-INSERT INTO sales_documents
-(id, sale_id, type, order_number, data, created_at,
-updated_at, date, generated, synced_at, sum)
-VALUES
-(555, 165, 3, 5, '{}', 1486538300, 1486722835, '2017-02-17', 0, 1486538313, 2320.00),
-(556, 165, 2, 3, '{}', 1486538304, 1486563125, '2017-02-08', 1, 1486538302, 2320.00),
-(557, 158, 2, 2, '{}', 1486538661, 1486538661, '2017-02-08', 0, 1486538660, 2320.00),
-(558, 171, 1, 3, '{}', 1486539104, 1488203405, '2017-02-08', 1, 1486539102, 23230.00),
-(559, 171, 2, 5, '{}', 1486549233, 1487146010, '2017-02-08', 1, 1486549225, 37690.00),
-(560, 172, 1, 1, '{}', 1486658260, 1488203409, '2017-02-09', 1, 1486658256, 40312.00),
-(561, 172, 2, 1, '{}', 1486711997, 1486711997, '2017-02-10', 1, 1486711996, 40312.00),
-(562, 172, 3, 1, '{}', 1486712104, 1486721395, '2017-02-10', 1, 1486712101, 40312.00),
-(563, 171, 3, 2, '{}', 1486712953, 1486720244, '2017-02-10', 1, 1486712910, 23230.00),
-(564, 170, 1, 2, '{}', 1486715948, 1488203410, '2017-02-10', 1, 1486715930, 28873.00),
-(565, 170, 3, 3, '{}', 1486716782, 1486717426, '2017-02-10', 1, 1486716779, 61948.00),
-(566, 166, 3, 4, '{}', 1486720947, 1486720947, '2017-02-10', 1, 1486720945, 4640.00),
-(567, 167, 3, 5, '{}', 1486722741, 1486722783, '2017-02-26', 0, 1486722738, 14755.00),
-(568, 165, 1, 4, '{}', 1486722849, 1486722849, '2017-02-10', 0, 1486722846, 2320.00),
-(569, 173, 2, 2, '{}', 1486723073, 1487071275, '2017-02-10', 1, 1486723071, 14282.00),
-(570, 173, 1, 4, '{}', 1486723100, 1488203412, '2017-02-10', 1, 1486723099, 14282.00),
-(571, 167, 2, 4, '{}', 1486730859, 1486730859, '2017-02-10', 1, 1486730856, 18655.00),
-(572, 167, 1, 5, '{}', 1486730883, 1488203412, '2017-02-10', 1, 1486730877, 18655.00),
-(573, 174, 2, 51, '{}', 1486731622, 1487060259, '2017-02-10', 1, 1486731620, 7140.00),
-(574, 174, 3, 5, '{}', 1486993472, 1486993472, '2017-02-13', 1, 1488216147, 28020.00),
-(575, 174, 1, 6, '{}', 1486993530, 1488203412, '2017-02-13', 1, 1486993505, 7140.00),
-(576, 173, 3, 6, '{}', 1487071425, 1487071425, '2017-02-14', 0, 1487071422, 14282.00),
-(577, 178, 2, 6, '{}', 1487327372, 1487327372, '2017-02-17', 1, 1487327370, 12321.00),
-(578, 177, 2, 7, '{}', 1487327394, 1487327394, '2017-02-17', 0, 1487327391, 4270.00),
-(579, 182, 3, 6, '{}', 1487750589, 1487751693, '2017-02-22', 1, 1487751688, 4270.00),
-(580, 182, 2, 7, '{}', 1487750601, 1487750663, '2017-02-22', 1, 1487750598, 4270.00),
-(581, 182, 1, 7, '{}', 1487750694, 1488203412, '2017-02-22', 1, 1487750692, 4270.00),
-(582, 185, 3, 7, '{}', 1487774051, 1487774051, '2017-02-22', 0, 1487774043, 8913.00),
-(583, 184, 3, 7, '{}', 1487774071, 1487774235, '2017-02-22', 0, 1487774093, 3285.00),
-(584, 184, 2, 8, '{}', 1487774074, 1487774074, '2017-02-22', 0, 1487774073, 3285.00),
-(585, 184, 1, 8, '{}', 1487774081, 1487774081, '2017-02-22', 0, 1487774075, 3285.00),
-(586, 193, 2, 8, '{}', 1487955294, 1487955318, '2017-02-24', 0, 1487955311, 4270.00),
-(587, 193, 1, 8, '{}', 1487955324, 1487955324, '2017-02-24', 0, 1487955320, 4270.00),
-(588, 193, 3, 7, '{}', 1487955341, 1487955341, '2017-02-24', 0, 1487955325, 4270.00),
-(589, 186, 1, 8, '{}', 1487957291, 1487957464, '2017-02-24', 0, 1487957459, 6960.00),
-(590, 186, 2, 8, '{}', 1487957308, 1487957468, '2017-02-24', 0, 1487957465, 6960.00),
-(591, 186, 3, 7, '{}', 1487957312, 1487957473, '2017-02-24', 0, 1487957469, 6960.00),
-(592, 194, 1, 8, '{}', 1488193293, 1488203412, '2017-02-27', 1, 1488193280, 2320.00),
-(593, 194, 2, 8, '{}', 1488193304, 1488193304, '2017-02-27', 1, 1488193303, 2320.00),
-(594, 210, 1, 9, '{}', 1488198896, 1488198896, '2017-02-27', 0, 1488198885, 4270.00),
-(595, 210, 2, 12, '{}', 1488198901, 1488198901, '2017-02-27', 1, 1488532585, 4270.00),
-(596, 210, 3, 10, '{}', 1488198904, 1488198904, '2017-02-27', 1, 1488532565, 4270.00),
-(597, 209, 2, 9, '{}', 1488200016, 1488450772, '2017-02-27', 1, 1488450449, 4270.00),
-(598, 209, 1, 9, '{}', 1488200020, 1488200063, '2017-02-27', 1, 1488200017, 4271.00),
-(599, 209, 3, 7, '{}', 1488200053, 1488200053, '2017-02-27', 0, 1488200021, 4271.00),
-(600, 211, 2, 10, '{}', 1488216265, 1489402027, '2017-02-27', 1, 1488216264, 2320.00),
-(601, 211, 3, 7, '{}', 1488216281, 1488216281, '2017-02-27', 1, 1488216276, 2320.00),
-(602, 211, 1, 10, '{}', 1488216283, 1488216283, '2017-02-27', 1, 1488216282, 2320.00),
-(603, 198, 2, 11, '{}', 1488280125, 1488280125, '2017-02-28', 0, 1488280095, 4270.00),
-(604, 198, 1, 11, '{}', 1488280160, 1488280160, '2017-02-28', 0, 1488280126, 4270.00),
-(605, 198, 3, 8, '{}', 1488280440, 1488280440, '2017-02-28', 0, 1488280435, 4270.00),
-(606, 212, 1, 12, '{}', 1488286301, 1489402168, '2017-02-28', 1, 1488286295, 13825.00),
-(607, 212, 3, 8, '{}', 1488289644, 1488289690, '2017-02-28', 1, 1488289642, 25295.00),
-(608, 212, 2, 13, '{}', 1488290350, 1488290431, '2017-02-28', 1, 1488290347, 13133.75),
-(609, 213, 1, 11, '{}', 1488529470, 1488529470, '2017-03-03', 1, 1488529461, 5660.00),
-(610, 213, 2, 11, '{}', 1488529484, 1488529484, '2017-03-03', 1, 1488529479, 5660.00),
-(611, 213, 3, 9, '{}', 1488529493, 1488529493, '2017-03-03', 1, 1488529489, 5660.00),
-(612, 197, 2, 13, '{}', 1489400715, 1489400715, '2017-03-13', 0, 1489398959, 4270.00),
-(613, 219, 3, 11, '{}', 1490084337, 1490181958, '2017-03-21', 1, 1490084334, 73526.00),
-(614, 216, 3, 11, '{}', 1490085757, 1490086717, '2017-03-21', 0, 1490085755, 5377.00);
-SELECT * FROM
-(SELECT @row := @row + 1 as row, a.* from (
-SELECT t.order_number
-FROM sales_documents t
-WHERE
-t.type = 2 AND
-t.date >= '2017-01-01' AND
-t.date <= '2017-12-31' AND
-t.order_number IS NOT NULL AND
-t.generated = 1
-GROUP BY t.order_number
-) a, (SELECT @row := 0) r) t
-WHERE row <> order_number;
-row order_number
-14 51
-DROP TABLE sales_documents;
-#
-# MDEV-12845: pushdown from merged derived using equalities
-#
-create table t1 (a int);
-insert into t1 values
-(4), (8), (5), (3), (10), (2), (7);
-create table t2 (b int, c int);
-insert into t2 values
-(2,1), (5,2), (2,2), (4,1), (4,3),
-(5,3), (2,4), (4,6), (2,1);
-create view v1 as
-select b, sum(c) as s from t2 group by b;
-create view v2 as
-select distinct b, c from t2;
-create view v3 as
-select b, max(c) as m from t2 group by b;
-select b
-from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t
-where b > 2;
-b
-4
-5
-explain format=json select b
-from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t
-where b > 2;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 7,
- "filtered": 100,
- "attached_condition": "t1.a > 2 and t1.a is not null"
- },
- "table": {
- "table_name": "<derived3>",
- "access_type": "ref",
- "possible_keys": ["key0"],
- "key": "key0",
- "key_length": "5",
- "used_key_parts": ["b"],
- "ref": ["test.t1.a"],
- "rows": 2,
- "filtered": 100,
- "materialized": {
- "query_block": {
- "select_id": 3,
- "filesort": {
- "sort_key": "t2.b",
- "temporary_table": {
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 9,
- "filtered": 100,
- "attached_condition": "t2.b > 2"
- }
- }
- }
- }
- }
- }
- }
-}
-select a
-from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t
-where a > 2;
-a
-4
-5
-explain format=json select a
-from ( select t1.a, v1.b, v1.s from t1, v1 where t1.a = v1.b ) as t
-where a > 2;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 7,
- "filtered": 100,
- "attached_condition": "t1.a > 2 and t1.a is not null"
- },
- "table": {
- "table_name": "<derived3>",
- "access_type": "ref",
- "possible_keys": ["key0"],
- "key": "key0",
- "key_length": "5",
- "used_key_parts": ["b"],
- "ref": ["test.t1.a"],
- "rows": 2,
- "filtered": 100,
- "materialized": {
- "query_block": {
- "select_id": 3,
- "filesort": {
- "sort_key": "t2.b",
- "temporary_table": {
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 9,
- "filtered": 100,
- "attached_condition": "t2.b > 2"
- }
- }
- }
- }
- }
- }
- }
-}
-select a
-from ( select t1.a, v2.b, v2.c from t1, v2 where t1.a = v2.b ) as t
-where a > 2;
-a
-4
-4
-4
-5
-5
-explain format=json select a
-from ( select t1.a, v2.b, v2.c from t1, v2 where t1.a = v2.b ) as t
-where a > 2;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 7,
- "filtered": 100,
- "attached_condition": "t1.a > 2 and t1.a is not null"
- },
- "table": {
- "table_name": "<derived3>",
- "access_type": "ref",
- "possible_keys": ["key0"],
- "key": "key0",
- "key_length": "5",
- "used_key_parts": ["b"],
- "ref": ["test.t1.a"],
- "rows": 2,
- "filtered": 100,
- "materialized": {
- "query_block": {
- "select_id": 3,
- "temporary_table": {
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 9,
- "filtered": 100,
- "attached_condition": "t2.b > 2"
- }
- }
- }
- }
- }
- }
-}
-select a
-from ( select t1.a, v3.b, v3.m from t1, v3 where t1.a = v3.m ) as t
-where a > 2;
-a
-4
-3
-explain format=json select a
-from ( select t1.a, v3.b, v3.m from t1, v3 where t1.a = v3.m ) as t
-where a > 2;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 7,
- "filtered": 100,
- "attached_condition": "t1.a > 2 and t1.a is not null"
- },
- "table": {
- "table_name": "<derived3>",
- "access_type": "ref",
- "possible_keys": ["key0"],
- "key": "key0",
- "key_length": "5",
- "used_key_parts": ["m"],
- "ref": ["test.t1.a"],
- "rows": 2,
- "filtered": 100,
- "materialized": {
- "query_block": {
- "select_id": 3,
- "having_condition": "m > 2",
- "filesort": {
- "sort_key": "t2.b",
- "temporary_table": {
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 9,
- "filtered": 100
- }
- }
- }
- }
- }
- }
- }
-}
-drop view v1,v2,v3;
-drop table t1,t2;
-#
-# MDEV-13166: pushdown from merged derived
-#
-CREATE TABLE t1 (i int) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (1),(2);
-CREATE VIEW v1 AS SELECT MAX(i) AS f FROM t1;
-SELECT * FROM ( SELECT * FROM v1 ) AS sq WHERE f > 0;
-f
-2
-explain format=json SELECT * FROM ( SELECT * FROM v1 ) AS sq WHERE f > 0;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "v1.f > 0",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "having_condition": "f > 0",
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100
- }
- }
- }
- }
- }
-}
-DROP VIEW v1;
-DROP TABLE t1;
-#
-# MDEV-13193: pushdown of equality extracted from multiple equality
-#
-CREATE TABLE t1 (i1 int, KEY(i1)) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (1),(2);
-CREATE TABLE t2 (i2 int) ENGINE=MyISAM;
-INSERT INTO t2 VALUES (2),(4);
-CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
-SELECT * FROM t1, ( SELECT * FROM v2 ) AS sq
-WHERE i1 = 1 AND ( i1 = i2 OR i1 = 2 );
-i1 i2
-explain format=json SELECT * FROM t1, ( SELECT * FROM v2 ) AS sq
-WHERE i1 = 1 AND ( i1 = i2 OR i1 = 2 );
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t1",
- "access_type": "ref",
- "possible_keys": ["i1"],
- "key": "i1",
- "key_length": "5",
- "used_key_parts": ["i1"],
- "ref": ["const"],
- "rows": 1,
- "filtered": 100,
- "using_index": true
- },
- "block-nl-join": {
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "v2.i2 = 1"
- },
- "buffer_type": "flat",
- "buffer_size": "256Kb",
- "join_type": "BNL",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "t2.i2 = 1"
- }
- }
- }
- }
- }
-}
-DROP VIEW v2;
-DROP TABLE t1,t2;
-#
-# MDEV-14237: derived with regexp_substr() in select list
-#
-create table t1 (a char(8));
-insert into t1 values ('b'), ('a'), ('xx');
-select *
-from ( select distinct regexp_substr(t1.a,'^[A-Za-z]+') as f from t1) as t
-where t.f = 'a' or t.f = 'b';
-f
-b
-a
-explain format=json select *
-from ( select distinct regexp_substr(t1.a,'^[A-Za-z]+') as f from t1) as t
-where t.f = 'a' or t.f = 'b';
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "t.f = 'a' or t.f = 'b'",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "temporary_table": {
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100
- }
- }
- }
- }
- }
- }
-}
-drop table t1;
-#
-# MDEV-13454: consequence of mdev-14368 fixed for 5.5
-#
-SET sql_mode = 'ONLY_FULL_GROUP_BY';
-create table t1 (id int, id2 int);
-insert into t1 values (1,1),(2,3),(3,4),(7,2);
-create table t2(id2 int);
-insert t2 values (1),(2),(3);
-SELECT * FROM t1
-LEFT OUTER JOIN
-(SELECT id2, COUNT(*) as ct FROM t2 GROUP BY id2) vc USING (id2)
-WHERE (vc.ct>0);
-id2 id ct
-1 1 1
-3 2 1
-2 7 1
-EXPLAIN FORMAT=JSON SELECT * FROM t1
-LEFT OUTER JOIN
-(SELECT id2, COUNT(*) as ct FROM t2 GROUP BY id2) vc USING (id2)
-WHERE (vc.ct>0);
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "vc.ct > 0",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "having_condition": "ct > 0",
- "filesort": {
- "sort_key": "t2.id2",
- "temporary_table": {
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100
- }
- }
- }
- }
- }
- },
- "block-nl-join": {
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 4,
- "filtered": 100
- },
- "buffer_type": "flat",
- "buffer_size": "256Kb",
- "join_type": "BNL",
- "attached_condition": "t1.id2 = vc.id2"
- }
- }
-}
-DROP TABLE t1,t2;
-SET sql_mode = DEFAULT;
-#
-# MDEV-15579: incorrect removal of sub-formulas to be pushed
-# into WHERE of materialized derived with GROUP BY
-#
-CREATE TABLE t1 (a INT, b INT, c INT, d INT);
-CREATE TABLE t2 (x INT, y INT, z INT);
-INSERT INTO t1 VALUES (1,1,66,1), (1,1,56,2), (3,2,42,3);
-INSERT INTO t2 VALUES (1,1,66), (1,12,32);
-SELECT *
-FROM t2,
-(
-SELECT a, b, max(c) AS max_c
-FROM t1
-GROUP BY a
-HAVING max_c > 37
-) AS v1
-WHERE (v1.a=1) AND (v1.b=v1.a) AND
-(v1.a=t2.x) AND (v1.max_c>30);
-x y z a b max_c
-1 1 66 1 1 66
-1 12 32 1 1 66
-EXPLAIN SELECT *
-FROM t2,
-(
-SELECT a, b, max(c) AS max_c
-FROM t1
-GROUP BY a
-HAVING max_c > 37
-) AS v1
-WHERE (v1.a=1) AND (v1.b=v1.a) AND
-(v1.a=t2.x) AND (v1.max_c>30);
-id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-2 DERIVED t1 ALL NULL NULL NULL NULL 3 Using where
-EXPLAIN FORMAT=JSON SELECT *
-FROM t2,
-(
-SELECT a, b, max(c) AS max_c
-FROM t1
-GROUP BY a
-HAVING max_c > 37
-) AS v1
-WHERE (v1.a=1) AND (v1.b=v1.a) AND
-(v1.a=t2.x) AND (v1.max_c>30);
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "t2.x = 1"
- },
- "block-nl-join": {
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "v1.a = 1 and v1.b = 1 and v1.max_c > 30"
- },
- "buffer_type": "flat",
- "buffer_size": "256Kb",
- "join_type": "BNL",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "having_condition": "max_c > 37 and max_c > 30 and t1.b = 1",
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "t1.a = 1"
- }
- }
- }
- }
- }
-}
-SELECT *
-FROM t2,
-(
-SELECT a, b, d, max(c) AS max_c
-FROM t1
-GROUP BY a,d
-HAVING max_c > 37
-) AS v1
-WHERE (v1.a=1) AND (v1.b=v1.a) AND (v1.b=v1.d) AND
-(v1.a=t2.x) AND (v1.max_c>30);
-x y z a b d max_c
-1 1 66 1 1 1 66
-1 12 32 1 1 1 66
-EXPLAIN SELECT *
-FROM t2,
-(
-SELECT a, b, d, max(c) AS max_c
-FROM t1
-GROUP BY a,d
-HAVING max_c > 37
-) AS v1
-WHERE (v1.a=1) AND (v1.b=v1.a) AND (v1.b=v1.d) AND
-(v1.a=t2.x) AND (v1.max_c>30);
-id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 2 Using where
-1 PRIMARY <derived2> ALL NULL NULL NULL NULL 3 Using where; Using join buffer (flat, BNL join)
-2 DERIVED t1 ALL NULL NULL NULL NULL 3 Using where
-EXPLAIN FORMAT=JSON SELECT *
-FROM t2,
-(
-SELECT a, b, d, max(c) AS max_c
-FROM t1
-GROUP BY a,d
-HAVING max_c > 37
-) AS v1
-WHERE (v1.a=1) AND (v1.b=v1.a) AND (v1.b=v1.d) AND
-(v1.a=t2.x) AND (v1.max_c>30);
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "t2.x = 1"
- },
- "block-nl-join": {
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "v1.a = 1 and v1.b = 1 and v1.d = 1 and v1.max_c > 30"
- },
- "buffer_type": "flat",
- "buffer_size": "256Kb",
- "join_type": "BNL",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "having_condition": "max_c > 37 and max_c > 30 and t1.b = 1",
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "t1.a = 1 and t1.d = 1"
- }
- }
- }
- }
- }
-}
-DROP TABLE t1,t2;
-#
-# MDEV-15765: pushing condition with temporal constants
-# into constant tables
-#
-select * from (select date('2018-01-01') as d
-union all
-select date('2018-01-01') as d) as t
-where t.d between date ('2017-01-01') and date ('2019-01-01');
-d
-2018-01-01
-2018-01-01
-select * from (select date('2018-01-01') as d) as t
-where t.d between date ('2017-01-01') and date ('2019-01-01');
-d
-2018-01-01
-#
-# MDEV-16088: pushdown into derived defined in the IN subquery
-#
-CREATE TABLE t1 (a INT, b INT);
-CREATE TABLE t2 (e INT, f INT, g INT);
-INSERT INTO t1 VALUES (1,14),(2,13),(1,19),(2,32),(3,24);
-INSERT INTO t2 VALUES (1,19,2),(3,24,1),(1,12,2),(3,11,3),(2,32,1);
-SELECT * FROM t1
-WHERE (t1.a,t1.b) IN
-(
-SELECT d_tab.e,d_tab.max_f
-FROM (
-SELECT t2.e, MAX(t2.f) AS max_f
-FROM t2
-GROUP BY t2.e
-HAVING max_f>18
-) as d_tab
-WHERE d_tab.e>1
-)
-;
-a b
-2 32
-3 24
-EXPLAIN SELECT * FROM t1
-WHERE (t1.a,t1.b) IN
-(
-SELECT d_tab.e,d_tab.max_f
-FROM (
-SELECT t2.e, MAX(t2.f) AS max_f
-FROM t2
-GROUP BY t2.e
-HAVING max_f>18
-) as d_tab
-WHERE d_tab.e>1
-)
-;
-id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where
-3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
-EXPLAIN FORMAT=JSON SELECT * FROM t1
-WHERE (t1.a,t1.b) IN
-(
-SELECT d_tab.e,d_tab.max_f
-FROM (
-SELECT t2.e, MAX(t2.f) AS max_f
-FROM t2
-GROUP BY t2.e
-HAVING max_f>18
-) as d_tab
-WHERE d_tab.e>1
-)
-;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100
- },
- "table": {
- "table_name": "<subquery2>",
- "access_type": "eq_ref",
- "possible_keys": ["distinct_key"],
- "key": "distinct_key",
- "key_length": "8",
- "used_key_parts": ["e", "max_f"],
- "ref": ["func", "func"],
- "rows": 1,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100,
- "attached_condition": "d_tab.e > 1",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "having_condition": "max_f > 18",
- "filesort": {
- "sort_key": "t2.e",
- "temporary_table": {
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100,
- "attached_condition": "t2.e > 1"
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
-SELECT * FROM t1
-WHERE (t1.a,t1.b) IN
-(
-SELECT d_tab.e,d_tab.max_f
-FROM (
-SELECT t2.e, MAX(t2.f) AS max_f
-FROM t2
-GROUP BY t2.e
-HAVING max_f>18
-) as d_tab
-WHERE d_tab.max_f<25
-)
-;
-a b
-1 19
-3 24
-EXPLAIN SELECT * FROM t1
-WHERE (t1.a,t1.b) IN
-(
-SELECT d_tab.e,d_tab.max_f
-FROM (
-SELECT t2.e, MAX(t2.f) AS max_f
-FROM t2
-GROUP BY t2.e
-HAVING max_f>18
-) as d_tab
-WHERE d_tab.max_f<25
-)
-;
-id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 func,func 1
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where
-3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
-EXPLAIN FORMAT=JSON SELECT * FROM t1
-WHERE (t1.a,t1.b) IN
-(
-SELECT d_tab.e,d_tab.max_f
-FROM (
-SELECT t2.e, MAX(t2.f) AS max_f
-FROM t2
-GROUP BY t2.e
-HAVING max_f>18
-) as d_tab
-WHERE d_tab.max_f<25
-)
-;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100
- },
- "table": {
- "table_name": "<subquery2>",
- "access_type": "eq_ref",
- "possible_keys": ["distinct_key"],
- "key": "distinct_key",
- "key_length": "8",
- "used_key_parts": ["e", "max_f"],
- "ref": ["func", "func"],
- "rows": 1,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 2,
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100,
- "attached_condition": "d_tab.max_f < 25",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "having_condition": "max_f > 18 and max_f < 25",
- "filesort": {
- "sort_key": "t2.e",
- "temporary_table": {
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
-SELECT * FROM t1
-WHERE (t1.a,t1.b) IN
-(
-SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
-FROM (
-SELECT t2.e, MAX(t2.f) as max_f, t2.g
-FROM t2
-GROUP BY t2.e
-) as d_tab
-WHERE d_tab.e>1
-GROUP BY d_tab.g
-)
-;
-a b
-2 32
-EXPLAIN SELECT * FROM t1
-WHERE (t1.a,t1.b) IN
-(
-SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
-FROM (
-SELECT t2.e, MAX(t2.f) as max_f, t2.g
-FROM t2
-GROUP BY t2.e
-) as d_tab
-WHERE d_tab.e>1
-GROUP BY d_tab.g
-)
-;
-id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 test.t1.a,test.t1.b 1
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where; Using temporary
-3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using where; Using temporary; Using filesort
-EXPLAIN FORMAT=JSON SELECT * FROM t1
-WHERE (t1.a,t1.b) IN
-(
-SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
-FROM (
-SELECT t2.e, MAX(t2.f) as max_f, t2.g
-FROM t2
-GROUP BY t2.e
-) as d_tab
-WHERE d_tab.e>1
-GROUP BY d_tab.g
-)
-;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100,
- "attached_condition": "t1.a is not null and t1.b is not null"
- },
- "table": {
- "table_name": "<subquery2>",
- "access_type": "eq_ref",
- "possible_keys": ["distinct_key"],
- "key": "distinct_key",
- "key_length": "8",
- "used_key_parts": ["e", "max_f"],
- "ref": ["test.t1.a", "test.t1.b"],
- "rows": 1,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 2,
- "temporary_table": {
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100,
- "attached_condition": "d_tab.e > 1",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "filesort": {
- "sort_key": "t2.e",
- "temporary_table": {
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100,
- "attached_condition": "t2.e > 1"
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
-SELECT * FROM t1
-WHERE (t1.a,t1.b) IN
-(
-SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
-FROM (
-SELECT t2.e, MAX(t2.f) as max_f, t2.g
-FROM t2
-GROUP BY t2.e
-) as d_tab
-WHERE d_tab.max_f>20
-GROUP BY d_tab.g
-)
-;
-a b
-2 32
-EXPLAIN SELECT * FROM t1
-WHERE (t1.a,t1.b) IN
-(
-SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
-FROM (
-SELECT t2.e, MAX(t2.f) as max_f, t2.g
-FROM t2
-GROUP BY t2.e
-) as d_tab
-WHERE d_tab.max_f>20
-GROUP BY d_tab.g
-)
-;
-id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t1 ALL NULL NULL NULL NULL 5 Using where
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 8 test.t1.a,test.t1.b 1
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 5 Using where; Using temporary
-3 DERIVED t2 ALL NULL NULL NULL NULL 5 Using temporary; Using filesort
-EXPLAIN FORMAT=JSON SELECT * FROM t1
-WHERE (t1.a,t1.b) IN
-(
-SELECT d_tab.e, MAX(d_tab.max_f) AS max_f
-FROM (
-SELECT t2.e, MAX(t2.f) as max_f, t2.g
-FROM t2
-GROUP BY t2.e
-) as d_tab
-WHERE d_tab.max_f>20
-GROUP BY d_tab.g
-)
-;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100,
- "attached_condition": "t1.a is not null and t1.b is not null"
- },
- "table": {
- "table_name": "<subquery2>",
- "access_type": "eq_ref",
- "possible_keys": ["distinct_key"],
- "key": "distinct_key",
- "key_length": "8",
- "used_key_parts": ["e", "max_f"],
- "ref": ["test.t1.a", "test.t1.b"],
- "rows": 1,
- "filtered": 100,
- "materialized": {
- "unique": 1,
- "query_block": {
- "select_id": 2,
- "temporary_table": {
- "table": {
- "table_name": "<derived3>",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100,
- "attached_condition": "d_tab.max_f > 20",
- "materialized": {
- "query_block": {
- "select_id": 3,
- "having_condition": "max_f > 20",
- "filesort": {
- "sort_key": "t2.e",
- "temporary_table": {
- "table": {
- "table_name": "t2",
- "access_type": "ALL",
- "rows": 5,
- "filtered": 100
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
- }
-}
-DROP TABLE t1,t2;
-#
-# MDEV-15765: pushing condition with IN subquery defined with constants
-# using substitution
-#
-CREATE TABLE t1 (a INT);
-INSERT INTO t1 VALUES (1),(2);
-SELECT * FROM
-(
-SELECT DISTINCT * FROM t1
-) der_tab
-WHERE (a>0 AND a<2 OR a IN (2,3)) AND
-(a=2 OR 0);
-a
-2
-DROP TABLE t1;
-#
-# MDEV-16386: pushing condition into the HAVING clause when ambiguous
-# fields warning appears
-#
-CREATE TABLE t1 (a INT, b INT);
-INSERT INTO t1 VALUES (1,2),(2,3),(3,4);
-SELECT * FROM
-(
-SELECT t1.b AS a
-FROM t1
-GROUP BY t1.a
-) dt
-WHERE (dt.a=2);
-a
-2
-EXPLAIN FORMAT=JSON SELECT * FROM
-(
-SELECT t1.b AS a
-FROM t1
-GROUP BY t1.a
-) dt
-WHERE (dt.a=2);
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "dt.a = 2",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "having_condition": "a = 2",
- "filesort": {
- "sort_key": "t1.a",
- "temporary_table": {
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100
- }
- }
- }
- }
- }
- }
- }
-}
-SELECT * FROM
-(
-SELECT t1.b AS a
-FROM t1
-GROUP BY t1.a
-HAVING (t1.a<3)
-) dt
-WHERE (dt.a>1);
-a
-2
-3
-EXPLAIN FORMAT=JSON SELECT * FROM
-(
-SELECT t1.b AS a
-FROM t1
-GROUP BY t1.a
-HAVING (t1.a<3)
-) dt
-WHERE (dt.a>1);
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "dt.a > 1",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "having_condition": "t1.a < 3 and a > 1",
- "filesort": {
- "sort_key": "t1.a",
- "temporary_table": {
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100
- }
- }
- }
- }
- }
- }
- }
-}
-SELECT * FROM
-(
-SELECT 'ab' AS a
-FROM t1
-GROUP BY t1.a
-) dt
-WHERE (dt.a='ab');
-a
-ab
-ab
-ab
-EXPLAIN FORMAT=JSON SELECT * FROM
-(
-SELECT 'ab' AS a
-FROM t1
-GROUP BY t1.a
-) dt
-WHERE (dt.a='ab');
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "dt.a = 'ab'",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "filesort": {
- "sort_key": "t1.a",
- "temporary_table": {
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100
- }
- }
- }
- }
- }
- }
- }
-}
-SELECT * FROM
-(
-SELECT 1 AS a
-FROM t1
-GROUP BY t1.a
-) dt
-WHERE (dt.a=1);
-a
-1
-1
-1
-EXPLAIN FORMAT=JSON SELECT * FROM
-(
-SELECT 1 AS a
-FROM t1
-GROUP BY t1.a
-) dt
-WHERE (dt.a=1);
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100,
- "attached_condition": "dt.a = 1",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "filesort": {
- "sort_key": "t1.a",
- "temporary_table": {
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 3,
- "filtered": 100
- }
- }
- }
- }
- }
- }
- }
-}
-DROP TABLE t1;
-#
-# MDEV-16517: pushdown condition with the IN predicate defined
-# with non-constant values
-#
-CREATE TABLE t1 (a INT, b INT);
-INSERT INTO t1 VALUES (1,2),(1,3);
-SELECT * FROM
-(
-SELECT t1.a
-FROM t1
-WHERE 1 IN (0,t1.a)
-GROUP BY t1.a
-) AS dt1
-JOIN
-(
-SELECT t1.a
-FROM t1
-WHERE 1 IN (0,t1.a)
-) AS dt2
-ON dt1.a = dt2.a;
-a a
-1 1
-1 1
-EXPLAIN FORMAT=JSON SELECT * FROM
-(
-SELECT t1.a
-FROM t1
-WHERE 1 IN (0,t1.a)
-GROUP BY t1.a
-) AS dt1
-JOIN
-(
-SELECT t1.a
-FROM t1
-WHERE 1 IN (0,t1.a)
-) AS dt2
-ON dt1.a = dt2.a;
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "1 in (0,dt1.a)",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "filesort": {
- "sort_key": "t1.a",
- "temporary_table": {
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "1 in (0,t1.a) and 1 in (0,t1.a)"
- }
- }
- }
- }
- }
- },
- "block-nl-join": {
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100
- },
- "buffer_type": "flat",
- "buffer_size": "256Kb",
- "join_type": "BNL",
- "attached_condition": "t1.a = dt1.a"
- }
- }
-}
-SELECT * FROM
-(
-SELECT t1.a,MAX(t1.b)
-FROM t1
-GROUP BY t1.a
-) AS dt, t1
-WHERE dt.a=t1.a AND dt.a IN (1,t1.a);
-a MAX(t1.b) a b
-1 3 1 2
-1 3 1 3
-EXPLAIN FORMAT=JSON SELECT * FROM
-(
-SELECT t1.a,MAX(t1.b)
-FROM t1
-GROUP BY t1.a
-) AS dt, t1
-WHERE dt.a=t1.a AND dt.a IN (1,t1.a);
-EXPLAIN
-{
- "query_block": {
- "select_id": 1,
- "table": {
- "table_name": "<derived2>",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "dt.a in (1,dt.a)",
- "materialized": {
- "query_block": {
- "select_id": 2,
- "filesort": {
- "sort_key": "t1.a",
- "temporary_table": {
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100,
- "attached_condition": "t1.a in (1,t1.a)"
- }
- }
- }
- }
- }
- },
- "block-nl-join": {
- "table": {
- "table_name": "t1",
- "access_type": "ALL",
- "rows": 2,
- "filtered": 100
- },
- "buffer_type": "flat",
- "buffer_size": "256Kb",
- "join_type": "BNL",
- "attached_condition": "t1.a = dt.a"
- }
- }
-}
-DROP TABLE t1;
-#
-# MDEV-10855: Pushdown into derived with window functions
+# MDEV-10855: Pushdown into derived with window functions
#
set @save_optimizer_switch= @@optimizer_switch;
set optimizer_switch='split_materialized=off';
@@ -13558,27 +14138,27 @@ insert into t2 values
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from (select a, c, sum(b) over (partition by a,c) from t2) as t
where t.a > 2 and t.c in ('aa','bb','cc');
a c sum(b) over (partition by a,c)
-7 cc 28
-7 cc 28
3 aa 92
-7 bb 126
+3 aa 92
+3 bb 40
4 aa 15
7 bb 126
7 bb 126
-3 bb 40
-3 aa 92
+7 bb 126
+7 cc 28
+7 cc 28
select * from (select a, c, sum(b) over (partition by a,c) from t2) as t
where t.a > 2 and t.c in ('aa','bb','cc');
a c sum(b) over (partition by a,c)
-7 cc 28
-7 cc 28
3 aa 92
-7 bb 126
+3 aa 92
+3 bb 40
4 aa 15
7 bb 126
7 bb 126
-3 bb 40
-3 aa 92
+7 bb 126
+7 cc 28
+7 cc 28
explain select * from (select a, c, sum(b) over (partition by a,c) from t2) as t
where t.a > 2 and t.c in ('aa','bb','cc');
id select_type table type possible_keys key key_len ref rows Extra
@@ -13622,59 +14202,59 @@ EXPLAIN
}
}
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from
-(
+(
select 1 as n, a, c, sum(b) over (partition by a,c) as s from t2
union all
select 2 as n, a, c, sum(b) over (partition by a) as s from t2
) as t
where t.a > 2 and t.c in ('aa','bb','cc');
n a c s
-1 7 cc 28
-1 7 cc 28
1 3 aa 92
-1 7 bb 126
+1 3 aa 92
+1 3 bb 40
1 4 aa 15
1 7 bb 126
1 7 bb 126
-1 3 bb 40
-1 3 aa 92
-2 7 cc 154
-2 7 cc 154
+1 7 bb 126
+1 7 cc 28
+1 7 cc 28
2 3 aa 132
-2 7 bb 154
+2 3 aa 132
+2 3 bb 132
2 4 aa 139
2 7 bb 154
2 7 bb 154
-2 3 bb 132
-2 3 aa 132
+2 7 bb 154
+2 7 cc 154
+2 7 cc 154
select * from
-(
+(
select 1 as n, a, c, sum(b) over (partition by a,c) as s from t2
union all
select 2 as n, a, c, sum(b) over (partition by a) as s from t2
) as t
where t.a > 2 and t.c in ('aa','bb','cc');
n a c s
-1 7 cc 28
-1 7 cc 28
1 3 aa 92
-1 7 bb 126
+1 3 aa 92
+1 3 bb 40
1 4 aa 15
1 7 bb 126
1 7 bb 126
-1 3 bb 40
-1 3 aa 92
-2 7 cc 154
-2 7 cc 154
+1 7 bb 126
+1 7 cc 28
+1 7 cc 28
2 3 aa 132
-2 7 bb 154
+2 3 aa 132
+2 3 bb 132
2 4 aa 139
2 7 bb 154
2 7 bb 154
-2 3 bb 132
-2 3 aa 132
+2 7 bb 154
+2 7 cc 154
+2 7 cc 154
explain select * from
-(
+(
select 1 as n, a, c, sum(b) over (partition by a,c) as s from t2
union all
select 2 as n, a, c, sum(b) over (partition by a) as s from t2
@@ -13685,7 +14265,7 @@ id select_type table type possible_keys key key_len ref rows Extra
2 DERIVED t2 ALL idx NULL NULL NULL 20 Using where; Using temporary
3 UNION t2 ALL idx NULL NULL NULL 20 Using where; Using temporary
explain format=json select * from
-(
+(
select 1 as n, a, c, sum(b) over (partition by a,c) as s from t2
union all
select 2 as n, a, c, sum(b) over (partition by a) as s from t2
@@ -13759,7 +14339,7 @@ EXPLAIN
}
}
}
-set statement optimizer_switch='condition_pushdown_for_derived=off' for select *
+set statement optimizer_switch='condition_pushdown_for_derived=off' for select *
from (select a, c, sum(b) over (partition by a,c) as s from t2) as t, t1
where t1.a=t.a and t1.c=t.c and t1.c in ('aa','bb','cc');
a c s a c
@@ -13767,7 +14347,7 @@ a c s a c
7 bb 126 7 bb
7 bb 126 7 bb
7 bb 126 7 bb
-select *
+select *
from (select a, c, sum(b) over (partition by a,c) as s from t2) as t, t1
where t1.a=t.a and t1.c=t.c and t1.c in ('aa','bb','cc');
a c s a c
@@ -13775,14 +14355,14 @@ a c s a c
7 bb 126 7 bb
7 bb 126 7 bb
7 bb 126 7 bb
-explain select *
+explain select *
from (select a, c, sum(b) over (partition by a,c) as s from t2) as t, t1
where t1.a=t.a and t1.c=t.c and t1.c in ('aa','bb','cc');
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 8 Using where
1 PRIMARY <derived2> ref key0 key0 24 test.t1.a,test.t1.c 2
2 DERIVED t2 ALL NULL NULL NULL NULL 20 Using where; Using temporary
-explain format=json select *
+explain format=json select *
from (select a, c, sum(b) over (partition by a,c) as s from t2) as t, t1
where t1.a=t.a and t1.c=t.c and t1.c in ('aa','bb','cc');
EXPLAIN
@@ -13831,7 +14411,7 @@ EXPLAIN
}
}
set statement optimizer_switch='condition_pushdown_for_derived=off' for select * from
-(
+(
select 1 as n, a, c, sum(b) over (partition by a,c) as s from t2
union all
select 2 as n, a, c, sum(b) over (partition by a) as s from t2
@@ -13840,28 +14420,28 @@ select 3 as n, a, c, sum(b) as s from t2 group by a
) as t
where t.a > 2 and t.c in ('aa','bb','cc');
n a c s
-1 7 cc 28
-1 7 cc 28
1 3 aa 92
-1 7 bb 126
+1 3 aa 92
+1 3 bb 40
1 4 aa 15
1 7 bb 126
1 7 bb 126
-1 3 bb 40
-1 3 aa 92
-2 7 cc 154
-2 7 cc 154
+1 7 bb 126
+1 7 cc 28
+1 7 cc 28
2 3 aa 132
-2 7 bb 154
+2 3 aa 132
+2 3 bb 132
2 4 aa 139
2 7 bb 154
2 7 bb 154
-2 3 bb 132
-2 3 aa 132
+2 7 bb 154
+2 7 cc 154
+2 7 cc 154
3 3 aa 132
3 7 cc 154
select * from
-(
+(
select 1 as n, a, c, sum(b) over (partition by a,c) as s from t2
union all
select 2 as n, a, c, sum(b) over (partition by a) as s from t2
@@ -13870,28 +14450,28 @@ select 3 as n, a, c, sum(b) as s from t2 group by a
) as t
where t.a > 2 and t.c in ('aa','bb','cc');
n a c s
-1 7 cc 28
-1 7 cc 28
1 3 aa 92
-1 7 bb 126
+1 3 aa 92
+1 3 bb 40
1 4 aa 15
1 7 bb 126
1 7 bb 126
-1 3 bb 40
-1 3 aa 92
-2 7 cc 154
-2 7 cc 154
+1 7 bb 126
+1 7 cc 28
+1 7 cc 28
2 3 aa 132
-2 7 bb 154
+2 3 aa 132
+2 3 bb 132
2 4 aa 139
2 7 bb 154
2 7 bb 154
-2 3 bb 132
-2 3 aa 132
+2 7 bb 154
+2 7 cc 154
+2 7 cc 154
3 3 aa 132
3 7 cc 154
explain select * from
-(
+(
select 1 as n, a, c, sum(b) over (partition by a,c) as s from t2
union all
select 2 as n, a, c, sum(b) over (partition by a) as s from t2
@@ -13905,7 +14485,7 @@ id select_type table type possible_keys key key_len ref rows Extra
3 UNION t2 ALL idx NULL NULL NULL 20 Using where; Using temporary
4 UNION t2 ALL idx NULL NULL NULL 20 Using where; Using temporary; Using filesort
explain format=json select * from
-(
+(
select 1 as n, a, c, sum(b) over (partition by a,c) as s from t2
union all
select 2 as n, a, c, sum(b) over (partition by a) as s from t2
@@ -14007,30 +14587,30 @@ avg(b) over (partition by a,c) as avg_b
from t2 ) as t
where t.a > 2 and t.c in ('aa','bb','cc');
a c sum_b avg_b
-7 cc 28 14.0000
-7 cc 28 14.0000
3 aa 92 46.0000
-7 bb 126 42.0000
+3 aa 92 46.0000
+3 bb 40 40.0000
4 aa 15 15.0000
7 bb 126 42.0000
7 bb 126 42.0000
-3 bb 40 40.0000
-3 aa 92 46.0000
+7 bb 126 42.0000
+7 cc 28 14.0000
+7 cc 28 14.0000
select * from (select a, c,
sum(b) over (partition by a,c) as sum_b,
avg(b) over (partition by a,c) as avg_b
from t2 ) as t
where t.a > 2 and t.c in ('aa','bb','cc');
a c sum_b avg_b
-7 cc 28 14.0000
-7 cc 28 14.0000
3 aa 92 46.0000
-7 bb 126 42.0000
+3 aa 92 46.0000
+3 bb 40 40.0000
4 aa 15 15.0000
7 bb 126 42.0000
7 bb 126 42.0000
-3 bb 40 40.0000
-3 aa 92 46.0000
+7 bb 126 42.0000
+7 cc 28 14.0000
+7 cc 28 14.0000
explain select * from (select a, c,
sum(b) over (partition by a,c) as sum_b,
avg(b) over (partition by a,c) as avg_b
@@ -14085,30 +14665,30 @@ avg(b) over (partition by a) as avg_b
from t2 ) as t
where t.a > 2 and t.c in ('aa','bb','cc');
a c sum_b avg_b
-7 cc 28 30.8000
-7 cc 28 30.8000
3 aa 92 44.0000
-7 bb 126 30.8000
+3 aa 92 44.0000
+3 bb 40 44.0000
4 aa 15 46.3333
7 bb 126 30.8000
7 bb 126 30.8000
-3 bb 40 44.0000
-3 aa 92 44.0000
+7 bb 126 30.8000
+7 cc 28 30.8000
+7 cc 28 30.8000
select * from (select a, c,
sum(b) over (partition by a,c) as sum_b,
avg(b) over (partition by a) as avg_b
from t2 ) as t
where t.a > 2 and t.c in ('aa','bb','cc');
a c sum_b avg_b
-7 cc 28 30.8000
-7 cc 28 30.8000
3 aa 92 44.0000
-7 bb 126 30.8000
+3 aa 92 44.0000
+3 bb 40 44.0000
4 aa 15 46.3333
7 bb 126 30.8000
7 bb 126 30.8000
-3 bb 40 44.0000
-3 aa 92 44.0000
+7 bb 126 30.8000
+7 cc 28 30.8000
+7 cc 28 30.8000
explain select * from (select a, c,
sum(b) over (partition by a,c) as sum_b,
avg(b) over (partition by a) as avg_b
@@ -14163,30 +14743,30 @@ avg(b) over (partition by c) as avg_b
from t2 ) as t
where t.a > 2 and t.c in ('aa','bb','cc');
a c sum_b avg_b
-7 cc 28 14.0000
-7 cc 28 14.0000
3 aa 92 35.4000
-7 bb 126 36.5000
+3 aa 92 35.4000
+3 bb 40 36.5000
4 aa 15 35.4000
7 bb 126 36.5000
7 bb 126 36.5000
-3 bb 40 36.5000
-3 aa 92 35.4000
+7 bb 126 36.5000
+7 cc 28 14.0000
+7 cc 28 14.0000
select * from (select a, c,
sum(b) over (partition by a,c) as sum_b,
avg(b) over (partition by c) as avg_b
from t2 ) as t
where t.a > 2 and t.c in ('aa','bb','cc');
a c sum_b avg_b
-7 cc 28 14.0000
-7 cc 28 14.0000
3 aa 92 35.4000
-7 bb 126 36.5000
+3 aa 92 35.4000
+3 bb 40 36.5000
4 aa 15 35.4000
7 bb 126 36.5000
7 bb 126 36.5000
-3 bb 40 36.5000
-3 aa 92 35.4000
+7 bb 126 36.5000
+7 cc 28 14.0000
+7 cc 28 14.0000
explain select * from (select a, c,
sum(b) over (partition by a,c) as sum_b,
avg(b) over (partition by c) as avg_b
@@ -14240,7 +14820,7 @@ EXPLAIN
drop table t1,t2;
set optimizer_switch= @save_optimizer_switch;
#
-# MDEV-13369: Optimization for equi-joins of grouping derived tables
+# MDEV-13369: Optimization for equi-joins of grouping derived tables
# (Splitting derived tables / views with GROUP BY)
# MDEV-13389: Optimization for equi-joins of derived tables with WF
# (Splitting derived tables / views with window functions)
@@ -14893,16 +15473,16 @@ set statement optimizer_switch='split_materialized=off' for select t2.a,t2.b,t2.
from t2, t3, (select c, max(b) max, min(b) min from t4 group by c) t
where t2.b between 80 and 85 and t2.c in ('y','z') and t2.a=t3.a and t3.c=t.c;
a b c t_c max min
-7 82 y cc 18 10
7 82 y aa 82 15
7 82 y bb 40 23
+7 82 y cc 18 10
select t2.a,t2.b,t2.c,t.c as t_c,t.max,t.min
from t2, t3, (select c, max(b) max, min(b) min from t4 group by c) t
where t2.b between 80 and 85 and t2.c in ('y','z') and t2.a=t3.a and t3.c=t.c;
a b c t_c max min
-7 82 y cc 18 10
7 82 y aa 82 15
7 82 y bb 40 23
+7 82 y cc 18 10
explain extended select t2.a,t2.b,t2.c,t.c as t_c,t.max,t.min
from t2, t3, (select c, max(b) max, min(b) min from t4 group by c) t
where t2.b between 80 and 85 and t2.c in ('y','z') and t2.a=t3.a and t3.c=t.c;
@@ -15120,36 +15700,36 @@ set statement optimizer_switch='split_materialized=off' for select *
from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t
where t2.b between 80 and 85 and t2.c in ('y','z') and t2.a=t3.a and t3.c=t.c;
a b c a b c c b sum(b) over (partition by c)
+7 82 y 7 10 bb bb 23 125
+7 82 y 7 10 bb bb 30 125
+7 82 y 7 10 bb bb 32 125
+7 82 y 7 10 bb bb 40 125
+7 82 y 7 17 cc cc 10 40
7 82 y 7 17 cc cc 12 40
7 82 y 7 17 cc cc 18 40
-7 82 y 7 17 cc cc 10 40
-7 82 y 7 18 aa aa 77 259
-7 82 y 7 18 aa aa 50 259
7 82 y 7 18 aa aa 15 259
-7 82 y 7 18 aa aa 82 259
7 82 y 7 18 aa aa 15 259
7 82 y 7 18 aa aa 20 259
-7 82 y 7 10 bb bb 40 125
-7 82 y 7 10 bb bb 32 125
-7 82 y 7 10 bb bb 30 125
-7 82 y 7 10 bb bb 23 125
+7 82 y 7 18 aa aa 50 259
+7 82 y 7 18 aa aa 77 259
+7 82 y 7 18 aa aa 82 259
select *
from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t
where t2.b between 80 and 85 and t2.c in ('y','z') and t2.a=t3.a and t3.c=t.c;
a b c a b c c b sum(b) over (partition by c)
+7 82 y 7 10 bb bb 23 125
+7 82 y 7 10 bb bb 30 125
+7 82 y 7 10 bb bb 32 125
+7 82 y 7 10 bb bb 40 125
+7 82 y 7 17 cc cc 10 40
7 82 y 7 17 cc cc 12 40
7 82 y 7 17 cc cc 18 40
-7 82 y 7 17 cc cc 10 40
-7 82 y 7 18 aa aa 77 259
-7 82 y 7 18 aa aa 50 259
7 82 y 7 18 aa aa 15 259
-7 82 y 7 18 aa aa 82 259
7 82 y 7 18 aa aa 15 259
7 82 y 7 18 aa aa 20 259
-7 82 y 7 10 bb bb 40 125
-7 82 y 7 10 bb bb 32 125
-7 82 y 7 10 bb bb 30 125
-7 82 y 7 10 bb bb 23 125
+7 82 y 7 18 aa aa 50 259
+7 82 y 7 18 aa aa 77 259
+7 82 y 7 18 aa aa 82 259
explain extended select *
from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t
where t2.b between 80 and 85 and t2.c in ('y','z') and t2.a=t3.a and t3.c=t.c;
@@ -15234,318 +15814,318 @@ set statement optimizer_switch='split_materialized=off' for select *
from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t
where t2.b < 40 and t2.a=t3.a and t3.c=t.c;
a b c a b c c b sum(b) over (partition by c)
-7 10 x 7 17 cc cc 12 40
-7 10 x 7 17 cc cc 18 40
-7 10 x 7 17 cc cc 10 40
-7 10 x 7 18 aa aa 77 259
-7 10 x 7 18 aa aa 50 259
-7 10 x 7 18 aa aa 15 259
-7 10 x 7 18 aa aa 82 259
-7 10 x 7 18 aa aa 15 259
-7 10 x 7 18 aa aa 20 259
-7 10 x 7 10 bb bb 40 125
-7 10 x 7 10 bb bb 32 125
-7 10 x 7 10 bb bb 30 125
-7 10 x 7 10 bb bb 23 125
-1 20 a 1 14 bb bb 40 125
-1 20 a 1 14 bb bb 32 125
-1 20 a 1 14 bb bb 30 125
1 20 a 1 14 bb bb 23 125
-2 23 b 2 12 aa aa 77 259
-2 23 b 2 12 aa aa 50 259
-2 23 b 2 12 aa aa 15 259
-2 23 b 2 12 aa aa 82 259
-2 23 b 2 12 aa aa 15 259
-2 23 b 2 12 aa aa 20 259
-2 23 b 2 11 aa aa 77 259
-2 23 b 2 11 aa aa 50 259
-2 23 b 2 11 aa aa 15 259
-2 23 b 2 11 aa aa 82 259
-2 23 b 2 11 aa aa 15 259
-2 23 b 2 11 aa aa 20 259
-7 18 z 7 17 cc cc 12 40
-7 18 z 7 17 cc cc 18 40
-7 18 z 7 17 cc cc 10 40
-7 18 z 7 18 aa aa 77 259
-7 18 z 7 18 aa aa 50 259
-7 18 z 7 18 aa aa 15 259
-7 18 z 7 18 aa aa 82 259
-7 18 z 7 18 aa aa 15 259
-7 18 z 7 18 aa aa 20 259
-7 18 z 7 10 bb bb 40 125
-7 18 z 7 10 bb bb 32 125
-7 18 z 7 10 bb bb 30 125
-7 18 z 7 10 bb bb 23 125
-1 30 c 1 14 bb bb 40 125
-1 30 c 1 14 bb bb 32 125
-1 30 c 1 14 bb bb 30 125
+1 20 a 1 14 bb bb 30 125
+1 20 a 1 14 bb bb 32 125
+1 20 a 1 14 bb bb 40 125
1 30 c 1 14 bb bb 23 125
-3 15 x 3 11 dd dd 20 32
-3 15 x 3 11 dd dd 12 32
-8 12 t 8 11 aa aa 77 259
-8 12 t 8 11 aa aa 50 259
-8 12 t 8 11 aa aa 15 259
-8 12 t 8 11 aa aa 82 259
-8 12 t 8 11 aa aa 15 259
-8 12 t 8 11 aa aa 20 259
-11 33 a 11 24 bbf bbf 50 165
-11 33 a 11 24 bbf bbf 42 165
-11 33 a 11 24 bbf bbf 40 165
+1 30 c 1 14 bb bb 30 125
+1 30 c 1 14 bb bb 32 125
+1 30 c 1 14 bb bb 40 125
+11 20 v 11 24 bbf bbf 33 165
+11 20 v 11 24 bbf bbf 40 165
+11 20 v 11 24 bbf bbf 42 165
+11 20 v 11 24 bbf bbf 50 165
+11 30 af 11 24 bbf bbf 33 165
+11 30 af 11 24 bbf bbf 40 165
+11 30 af 11 24 bbf bbf 42 165
+11 30 af 11 24 bbf bbf 50 165
+11 30 d 11 24 bbf bbf 33 165
+11 30 d 11 24 bbf bbf 40 165
+11 30 d 11 24 bbf bbf 42 165
+11 30 d 11 24 bbf bbf 50 165
11 33 a 11 24 bbf bbf 33 165
+11 33 a 11 24 bbf bbf 40 165
+11 33 a 11 24 bbf bbf 42 165
+11 33 a 11 24 bbf bbf 50 165
+12 23 y 12 21 aaf aaf 25 319
+12 23 y 12 21 aaf aaf 25 319
+12 23 y 12 21 aaf aaf 30 319
+12 23 y 12 21 aaf aaf 60 319
+12 23 y 12 21 aaf aaf 87 319
+12 23 y 12 21 aaf aaf 92 319
+12 23 y 12 22 aaf aaf 25 319
+12 23 y 12 22 aaf aaf 25 319
+12 23 y 12 22 aaf aaf 30 319
+12 23 y 12 22 aaf aaf 60 319
+12 23 y 12 22 aaf aaf 87 319
+12 23 y 12 22 aaf aaf 92 319
+12 33 bf 12 21 aaf aaf 25 319
+12 33 bf 12 21 aaf aaf 25 319
+12 33 bf 12 21 aaf aaf 30 319
+12 33 bf 12 21 aaf aaf 60 319
+12 33 bf 12 21 aaf aaf 87 319
+12 33 bf 12 21 aaf aaf 92 319
+12 33 bf 12 22 aaf aaf 25 319
+12 33 bf 12 22 aaf aaf 25 319
+12 33 bf 12 22 aaf aaf 30 319
+12 33 bf 12 22 aaf aaf 60 319
+12 33 bf 12 22 aaf aaf 87 319
+12 33 bf 12 22 aaf aaf 92 319
+13 25 xf 13 21 ddf ddf 22 52
+13 25 xf 13 21 ddf ddf 30 52
+17 10 s 17 20 bbf bbf 33 165
+17 10 s 17 20 bbf bbf 40 165
+17 10 s 17 20 bbf bbf 42 165
+17 10 s 17 20 bbf bbf 50 165
+17 10 s 17 27 ccf ccf 20 70
17 10 s 17 27 ccf ccf 22 70
17 10 s 17 27 ccf ccf 28 70
-17 10 s 17 27 ccf ccf 20 70
-17 10 s 17 28 aaf aaf 87 319
-17 10 s 17 28 aaf aaf 60 319
17 10 s 17 28 aaf aaf 25 319
-17 10 s 17 28 aaf aaf 92 319
17 10 s 17 28 aaf aaf 25 319
17 10 s 17 28 aaf aaf 30 319
-17 10 s 17 20 bbf bbf 50 165
-17 10 s 17 20 bbf bbf 42 165
-17 10 s 17 20 bbf bbf 40 165
-17 10 s 17 20 bbf bbf 33 165
-11 20 v 11 24 bbf bbf 50 165
-11 20 v 11 24 bbf bbf 42 165
-11 20 v 11 24 bbf bbf 40 165
-11 20 v 11 24 bbf bbf 33 165
-12 23 y 12 22 aaf aaf 87 319
-12 23 y 12 22 aaf aaf 60 319
-12 23 y 12 22 aaf aaf 25 319
-12 23 y 12 22 aaf aaf 92 319
-12 23 y 12 22 aaf aaf 25 319
-12 23 y 12 22 aaf aaf 30 319
-12 23 y 12 21 aaf aaf 87 319
-12 23 y 12 21 aaf aaf 60 319
-12 23 y 12 21 aaf aaf 25 319
-12 23 y 12 21 aaf aaf 92 319
-12 23 y 12 21 aaf aaf 25 319
-12 23 y 12 21 aaf aaf 30 319
+17 10 s 17 28 aaf aaf 60 319
+17 10 s 17 28 aaf aaf 87 319
+17 10 s 17 28 aaf aaf 92 319
+17 18 a 17 20 bbf bbf 33 165
+17 18 a 17 20 bbf bbf 40 165
+17 18 a 17 20 bbf bbf 42 165
+17 18 a 17 20 bbf bbf 50 165
+17 18 a 17 27 ccf ccf 20 70
17 18 a 17 27 ccf ccf 22 70
17 18 a 17 27 ccf ccf 28 70
-17 18 a 17 27 ccf ccf 20 70
-17 18 a 17 28 aaf aaf 87 319
-17 18 a 17 28 aaf aaf 60 319
17 18 a 17 28 aaf aaf 25 319
-17 18 a 17 28 aaf aaf 92 319
17 18 a 17 28 aaf aaf 25 319
17 18 a 17 28 aaf aaf 30 319
-17 18 a 17 20 bbf bbf 50 165
-17 18 a 17 20 bbf bbf 42 165
-17 18 a 17 20 bbf bbf 40 165
-17 18 a 17 20 bbf bbf 33 165
-11 30 d 11 24 bbf bbf 50 165
-11 30 d 11 24 bbf bbf 42 165
-11 30 d 11 24 bbf bbf 40 165
-11 30 d 11 24 bbf bbf 33 165
+17 18 a 17 28 aaf aaf 60 319
+17 18 a 17 28 aaf aaf 87 319
+17 18 a 17 28 aaf aaf 92 319
+17 20 xf 17 20 bbf bbf 33 165
+17 20 xf 17 20 bbf bbf 40 165
+17 20 xf 17 20 bbf bbf 42 165
+17 20 xf 17 20 bbf bbf 50 165
+17 20 xf 17 27 ccf ccf 20 70
17 20 xf 17 27 ccf ccf 22 70
17 20 xf 17 27 ccf ccf 28 70
-17 20 xf 17 27 ccf ccf 20 70
-17 20 xf 17 28 aaf aaf 87 319
-17 20 xf 17 28 aaf aaf 60 319
17 20 xf 17 28 aaf aaf 25 319
-17 20 xf 17 28 aaf aaf 92 319
17 20 xf 17 28 aaf aaf 25 319
17 20 xf 17 28 aaf aaf 30 319
-17 20 xf 17 20 bbf bbf 50 165
-17 20 xf 17 20 bbf bbf 42 165
-17 20 xf 17 20 bbf bbf 40 165
-17 20 xf 17 20 bbf bbf 33 165
-11 30 af 11 24 bbf bbf 50 165
-11 30 af 11 24 bbf bbf 42 165
-11 30 af 11 24 bbf bbf 40 165
-11 30 af 11 24 bbf bbf 33 165
-12 33 bf 12 22 aaf aaf 87 319
-12 33 bf 12 22 aaf aaf 60 319
-12 33 bf 12 22 aaf aaf 25 319
-12 33 bf 12 22 aaf aaf 92 319
-12 33 bf 12 22 aaf aaf 25 319
-12 33 bf 12 22 aaf aaf 30 319
-12 33 bf 12 21 aaf aaf 87 319
-12 33 bf 12 21 aaf aaf 60 319
-12 33 bf 12 21 aaf aaf 25 319
-12 33 bf 12 21 aaf aaf 92 319
-12 33 bf 12 21 aaf aaf 25 319
-12 33 bf 12 21 aaf aaf 30 319
+17 20 xf 17 28 aaf aaf 60 319
+17 20 xf 17 28 aaf aaf 87 319
+17 20 xf 17 28 aaf aaf 92 319
+17 28 zf 17 20 bbf bbf 33 165
+17 28 zf 17 20 bbf bbf 40 165
+17 28 zf 17 20 bbf bbf 42 165
+17 28 zf 17 20 bbf bbf 50 165
+17 28 zf 17 27 ccf ccf 20 70
17 28 zf 17 27 ccf ccf 22 70
17 28 zf 17 27 ccf ccf 28 70
-17 28 zf 17 27 ccf ccf 20 70
-17 28 zf 17 28 aaf aaf 87 319
-17 28 zf 17 28 aaf aaf 60 319
17 28 zf 17 28 aaf aaf 25 319
-17 28 zf 17 28 aaf aaf 92 319
17 28 zf 17 28 aaf aaf 25 319
17 28 zf 17 28 aaf aaf 30 319
-17 28 zf 17 20 bbf bbf 50 165
-17 28 zf 17 20 bbf bbf 42 165
-17 28 zf 17 20 bbf bbf 40 165
-17 28 zf 17 20 bbf bbf 33 165
-13 25 xf 13 21 ddf ddf 30 52
-13 25 xf 13 21 ddf ddf 22 52
-18 22 tf 18 21 aaf aaf 87 319
-18 22 tf 18 21 aaf aaf 60 319
+17 28 zf 17 28 aaf aaf 60 319
+17 28 zf 17 28 aaf aaf 87 319
+17 28 zf 17 28 aaf aaf 92 319
18 22 tf 18 21 aaf aaf 25 319
-18 22 tf 18 21 aaf aaf 92 319
18 22 tf 18 21 aaf aaf 25 319
18 22 tf 18 21 aaf aaf 30 319
-select *
-from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t
-where t2.b < 40 and t2.a=t3.a and t3.c=t.c;
-a b c a b c c b sum(b) over (partition by c)
+18 22 tf 18 21 aaf aaf 60 319
+18 22 tf 18 21 aaf aaf 87 319
+18 22 tf 18 21 aaf aaf 92 319
+2 23 b 2 11 aa aa 15 259
+2 23 b 2 11 aa aa 15 259
+2 23 b 2 11 aa aa 20 259
+2 23 b 2 11 aa aa 50 259
+2 23 b 2 11 aa aa 77 259
+2 23 b 2 11 aa aa 82 259
+2 23 b 2 12 aa aa 15 259
+2 23 b 2 12 aa aa 15 259
+2 23 b 2 12 aa aa 20 259
+2 23 b 2 12 aa aa 50 259
+2 23 b 2 12 aa aa 77 259
+2 23 b 2 12 aa aa 82 259
+3 15 x 3 11 dd dd 12 32
+3 15 x 3 11 dd dd 20 32
+7 10 x 7 10 bb bb 23 125
+7 10 x 7 10 bb bb 30 125
+7 10 x 7 10 bb bb 32 125
+7 10 x 7 10 bb bb 40 125
+7 10 x 7 17 cc cc 10 40
7 10 x 7 17 cc cc 12 40
7 10 x 7 17 cc cc 18 40
-7 10 x 7 17 cc cc 10 40
-7 10 x 7 18 aa aa 77 259
-7 10 x 7 18 aa aa 50 259
7 10 x 7 18 aa aa 15 259
-7 10 x 7 18 aa aa 82 259
7 10 x 7 18 aa aa 15 259
7 10 x 7 18 aa aa 20 259
-7 10 x 7 10 bb bb 40 125
-7 10 x 7 10 bb bb 32 125
-7 10 x 7 10 bb bb 30 125
-7 10 x 7 10 bb bb 23 125
-1 20 a 1 14 bb bb 40 125
-1 20 a 1 14 bb bb 32 125
-1 20 a 1 14 bb bb 30 125
-1 20 a 1 14 bb bb 23 125
-2 23 b 2 12 aa aa 77 259
-2 23 b 2 12 aa aa 50 259
-2 23 b 2 12 aa aa 15 259
-2 23 b 2 12 aa aa 82 259
-2 23 b 2 12 aa aa 15 259
-2 23 b 2 12 aa aa 20 259
-2 23 b 2 11 aa aa 77 259
-2 23 b 2 11 aa aa 50 259
-2 23 b 2 11 aa aa 15 259
-2 23 b 2 11 aa aa 82 259
-2 23 b 2 11 aa aa 15 259
-2 23 b 2 11 aa aa 20 259
+7 10 x 7 18 aa aa 50 259
+7 10 x 7 18 aa aa 77 259
+7 10 x 7 18 aa aa 82 259
+7 18 z 7 10 bb bb 23 125
+7 18 z 7 10 bb bb 30 125
+7 18 z 7 10 bb bb 32 125
+7 18 z 7 10 bb bb 40 125
+7 18 z 7 17 cc cc 10 40
7 18 z 7 17 cc cc 12 40
7 18 z 7 17 cc cc 18 40
-7 18 z 7 17 cc cc 10 40
-7 18 z 7 18 aa aa 77 259
-7 18 z 7 18 aa aa 50 259
7 18 z 7 18 aa aa 15 259
-7 18 z 7 18 aa aa 82 259
7 18 z 7 18 aa aa 15 259
7 18 z 7 18 aa aa 20 259
-7 18 z 7 10 bb bb 40 125
-7 18 z 7 10 bb bb 32 125
-7 18 z 7 10 bb bb 30 125
-7 18 z 7 10 bb bb 23 125
-1 30 c 1 14 bb bb 40 125
-1 30 c 1 14 bb bb 32 125
-1 30 c 1 14 bb bb 30 125
-1 30 c 1 14 bb bb 23 125
-3 15 x 3 11 dd dd 20 32
-3 15 x 3 11 dd dd 12 32
-8 12 t 8 11 aa aa 77 259
-8 12 t 8 11 aa aa 50 259
+7 18 z 7 18 aa aa 50 259
+7 18 z 7 18 aa aa 77 259
+7 18 z 7 18 aa aa 82 259
8 12 t 8 11 aa aa 15 259
-8 12 t 8 11 aa aa 82 259
8 12 t 8 11 aa aa 15 259
8 12 t 8 11 aa aa 20 259
-11 33 a 11 24 bbf bbf 50 165
-11 33 a 11 24 bbf bbf 42 165
-11 33 a 11 24 bbf bbf 40 165
+8 12 t 8 11 aa aa 50 259
+8 12 t 8 11 aa aa 77 259
+8 12 t 8 11 aa aa 82 259
+select *
+from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t
+where t2.b < 40 and t2.a=t3.a and t3.c=t.c;
+a b c a b c c b sum(b) over (partition by c)
+1 20 a 1 14 bb bb 23 125
+1 20 a 1 14 bb bb 30 125
+1 20 a 1 14 bb bb 32 125
+1 20 a 1 14 bb bb 40 125
+1 30 c 1 14 bb bb 23 125
+1 30 c 1 14 bb bb 30 125
+1 30 c 1 14 bb bb 32 125
+1 30 c 1 14 bb bb 40 125
+11 20 v 11 24 bbf bbf 33 165
+11 20 v 11 24 bbf bbf 40 165
+11 20 v 11 24 bbf bbf 42 165
+11 20 v 11 24 bbf bbf 50 165
+11 30 af 11 24 bbf bbf 33 165
+11 30 af 11 24 bbf bbf 40 165
+11 30 af 11 24 bbf bbf 42 165
+11 30 af 11 24 bbf bbf 50 165
+11 30 d 11 24 bbf bbf 33 165
+11 30 d 11 24 bbf bbf 40 165
+11 30 d 11 24 bbf bbf 42 165
+11 30 d 11 24 bbf bbf 50 165
11 33 a 11 24 bbf bbf 33 165
+11 33 a 11 24 bbf bbf 40 165
+11 33 a 11 24 bbf bbf 42 165
+11 33 a 11 24 bbf bbf 50 165
+12 23 y 12 21 aaf aaf 25 319
+12 23 y 12 21 aaf aaf 25 319
+12 23 y 12 21 aaf aaf 30 319
+12 23 y 12 21 aaf aaf 60 319
+12 23 y 12 21 aaf aaf 87 319
+12 23 y 12 21 aaf aaf 92 319
+12 23 y 12 22 aaf aaf 25 319
+12 23 y 12 22 aaf aaf 25 319
+12 23 y 12 22 aaf aaf 30 319
+12 23 y 12 22 aaf aaf 60 319
+12 23 y 12 22 aaf aaf 87 319
+12 23 y 12 22 aaf aaf 92 319
+12 33 bf 12 21 aaf aaf 25 319
+12 33 bf 12 21 aaf aaf 25 319
+12 33 bf 12 21 aaf aaf 30 319
+12 33 bf 12 21 aaf aaf 60 319
+12 33 bf 12 21 aaf aaf 87 319
+12 33 bf 12 21 aaf aaf 92 319
+12 33 bf 12 22 aaf aaf 25 319
+12 33 bf 12 22 aaf aaf 25 319
+12 33 bf 12 22 aaf aaf 30 319
+12 33 bf 12 22 aaf aaf 60 319
+12 33 bf 12 22 aaf aaf 87 319
+12 33 bf 12 22 aaf aaf 92 319
+13 25 xf 13 21 ddf ddf 22 52
+13 25 xf 13 21 ddf ddf 30 52
+17 10 s 17 20 bbf bbf 33 165
+17 10 s 17 20 bbf bbf 40 165
+17 10 s 17 20 bbf bbf 42 165
+17 10 s 17 20 bbf bbf 50 165
+17 10 s 17 27 ccf ccf 20 70
17 10 s 17 27 ccf ccf 22 70
17 10 s 17 27 ccf ccf 28 70
-17 10 s 17 27 ccf ccf 20 70
-17 10 s 17 28 aaf aaf 87 319
-17 10 s 17 28 aaf aaf 60 319
17 10 s 17 28 aaf aaf 25 319
-17 10 s 17 28 aaf aaf 92 319
17 10 s 17 28 aaf aaf 25 319
17 10 s 17 28 aaf aaf 30 319
-17 10 s 17 20 bbf bbf 50 165
-17 10 s 17 20 bbf bbf 42 165
-17 10 s 17 20 bbf bbf 40 165
-17 10 s 17 20 bbf bbf 33 165
-11 20 v 11 24 bbf bbf 50 165
-11 20 v 11 24 bbf bbf 42 165
-11 20 v 11 24 bbf bbf 40 165
-11 20 v 11 24 bbf bbf 33 165
-12 23 y 12 22 aaf aaf 87 319
-12 23 y 12 22 aaf aaf 60 319
-12 23 y 12 22 aaf aaf 25 319
-12 23 y 12 22 aaf aaf 92 319
-12 23 y 12 22 aaf aaf 25 319
-12 23 y 12 22 aaf aaf 30 319
-12 23 y 12 21 aaf aaf 87 319
-12 23 y 12 21 aaf aaf 60 319
-12 23 y 12 21 aaf aaf 25 319
-12 23 y 12 21 aaf aaf 92 319
-12 23 y 12 21 aaf aaf 25 319
-12 23 y 12 21 aaf aaf 30 319
+17 10 s 17 28 aaf aaf 60 319
+17 10 s 17 28 aaf aaf 87 319
+17 10 s 17 28 aaf aaf 92 319
+17 18 a 17 20 bbf bbf 33 165
+17 18 a 17 20 bbf bbf 40 165
+17 18 a 17 20 bbf bbf 42 165
+17 18 a 17 20 bbf bbf 50 165
+17 18 a 17 27 ccf ccf 20 70
17 18 a 17 27 ccf ccf 22 70
17 18 a 17 27 ccf ccf 28 70
-17 18 a 17 27 ccf ccf 20 70
-17 18 a 17 28 aaf aaf 87 319
-17 18 a 17 28 aaf aaf 60 319
17 18 a 17 28 aaf aaf 25 319
-17 18 a 17 28 aaf aaf 92 319
17 18 a 17 28 aaf aaf 25 319
17 18 a 17 28 aaf aaf 30 319
-17 18 a 17 20 bbf bbf 50 165
-17 18 a 17 20 bbf bbf 42 165
-17 18 a 17 20 bbf bbf 40 165
-17 18 a 17 20 bbf bbf 33 165
-11 30 d 11 24 bbf bbf 50 165
-11 30 d 11 24 bbf bbf 42 165
-11 30 d 11 24 bbf bbf 40 165
-11 30 d 11 24 bbf bbf 33 165
+17 18 a 17 28 aaf aaf 60 319
+17 18 a 17 28 aaf aaf 87 319
+17 18 a 17 28 aaf aaf 92 319
+17 20 xf 17 20 bbf bbf 33 165
+17 20 xf 17 20 bbf bbf 40 165
+17 20 xf 17 20 bbf bbf 42 165
+17 20 xf 17 20 bbf bbf 50 165
+17 20 xf 17 27 ccf ccf 20 70
17 20 xf 17 27 ccf ccf 22 70
17 20 xf 17 27 ccf ccf 28 70
-17 20 xf 17 27 ccf ccf 20 70
-17 20 xf 17 28 aaf aaf 87 319
-17 20 xf 17 28 aaf aaf 60 319
17 20 xf 17 28 aaf aaf 25 319
-17 20 xf 17 28 aaf aaf 92 319
17 20 xf 17 28 aaf aaf 25 319
17 20 xf 17 28 aaf aaf 30 319
-17 20 xf 17 20 bbf bbf 50 165
-17 20 xf 17 20 bbf bbf 42 165
-17 20 xf 17 20 bbf bbf 40 165
-17 20 xf 17 20 bbf bbf 33 165
-11 30 af 11 24 bbf bbf 50 165
-11 30 af 11 24 bbf bbf 42 165
-11 30 af 11 24 bbf bbf 40 165
-11 30 af 11 24 bbf bbf 33 165
-12 33 bf 12 22 aaf aaf 87 319
-12 33 bf 12 22 aaf aaf 60 319
-12 33 bf 12 22 aaf aaf 25 319
-12 33 bf 12 22 aaf aaf 92 319
-12 33 bf 12 22 aaf aaf 25 319
-12 33 bf 12 22 aaf aaf 30 319
-12 33 bf 12 21 aaf aaf 87 319
-12 33 bf 12 21 aaf aaf 60 319
-12 33 bf 12 21 aaf aaf 25 319
-12 33 bf 12 21 aaf aaf 92 319
-12 33 bf 12 21 aaf aaf 25 319
-12 33 bf 12 21 aaf aaf 30 319
+17 20 xf 17 28 aaf aaf 60 319
+17 20 xf 17 28 aaf aaf 87 319
+17 20 xf 17 28 aaf aaf 92 319
+17 28 zf 17 20 bbf bbf 33 165
+17 28 zf 17 20 bbf bbf 40 165
+17 28 zf 17 20 bbf bbf 42 165
+17 28 zf 17 20 bbf bbf 50 165
+17 28 zf 17 27 ccf ccf 20 70
17 28 zf 17 27 ccf ccf 22 70
17 28 zf 17 27 ccf ccf 28 70
-17 28 zf 17 27 ccf ccf 20 70
-17 28 zf 17 28 aaf aaf 87 319
-17 28 zf 17 28 aaf aaf 60 319
17 28 zf 17 28 aaf aaf 25 319
-17 28 zf 17 28 aaf aaf 92 319
17 28 zf 17 28 aaf aaf 25 319
17 28 zf 17 28 aaf aaf 30 319
-17 28 zf 17 20 bbf bbf 50 165
-17 28 zf 17 20 bbf bbf 42 165
-17 28 zf 17 20 bbf bbf 40 165
-17 28 zf 17 20 bbf bbf 33 165
-13 25 xf 13 21 ddf ddf 30 52
-13 25 xf 13 21 ddf ddf 22 52
-18 22 tf 18 21 aaf aaf 87 319
-18 22 tf 18 21 aaf aaf 60 319
+17 28 zf 17 28 aaf aaf 60 319
+17 28 zf 17 28 aaf aaf 87 319
+17 28 zf 17 28 aaf aaf 92 319
18 22 tf 18 21 aaf aaf 25 319
-18 22 tf 18 21 aaf aaf 92 319
18 22 tf 18 21 aaf aaf 25 319
18 22 tf 18 21 aaf aaf 30 319
+18 22 tf 18 21 aaf aaf 60 319
+18 22 tf 18 21 aaf aaf 87 319
+18 22 tf 18 21 aaf aaf 92 319
+2 23 b 2 11 aa aa 15 259
+2 23 b 2 11 aa aa 15 259
+2 23 b 2 11 aa aa 20 259
+2 23 b 2 11 aa aa 50 259
+2 23 b 2 11 aa aa 77 259
+2 23 b 2 11 aa aa 82 259
+2 23 b 2 12 aa aa 15 259
+2 23 b 2 12 aa aa 15 259
+2 23 b 2 12 aa aa 20 259
+2 23 b 2 12 aa aa 50 259
+2 23 b 2 12 aa aa 77 259
+2 23 b 2 12 aa aa 82 259
+3 15 x 3 11 dd dd 12 32
+3 15 x 3 11 dd dd 20 32
+7 10 x 7 10 bb bb 23 125
+7 10 x 7 10 bb bb 30 125
+7 10 x 7 10 bb bb 32 125
+7 10 x 7 10 bb bb 40 125
+7 10 x 7 17 cc cc 10 40
+7 10 x 7 17 cc cc 12 40
+7 10 x 7 17 cc cc 18 40
+7 10 x 7 18 aa aa 15 259
+7 10 x 7 18 aa aa 15 259
+7 10 x 7 18 aa aa 20 259
+7 10 x 7 18 aa aa 50 259
+7 10 x 7 18 aa aa 77 259
+7 10 x 7 18 aa aa 82 259
+7 18 z 7 10 bb bb 23 125
+7 18 z 7 10 bb bb 30 125
+7 18 z 7 10 bb bb 32 125
+7 18 z 7 10 bb bb 40 125
+7 18 z 7 17 cc cc 10 40
+7 18 z 7 17 cc cc 12 40
+7 18 z 7 17 cc cc 18 40
+7 18 z 7 18 aa aa 15 259
+7 18 z 7 18 aa aa 15 259
+7 18 z 7 18 aa aa 20 259
+7 18 z 7 18 aa aa 50 259
+7 18 z 7 18 aa aa 77 259
+7 18 z 7 18 aa aa 82 259
+8 12 t 8 11 aa aa 15 259
+8 12 t 8 11 aa aa 15 259
+8 12 t 8 11 aa aa 20 259
+8 12 t 8 11 aa aa 50 259
+8 12 t 8 11 aa aa 77 259
+8 12 t 8 11 aa aa 82 259
explain extended select *
from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t
where t2.b < 40 and t2.a=t3.a and t3.c=t.c;
@@ -15892,31 +16472,31 @@ cte as (select median(f2) over (partition by f1) as k1 from t1 order by f1),
cte1 as (select median(f4) over (partition by f1) as k2 from t1)
select k1,k2 from cte1, cte;
k1 k2
-1.0000000000 9.0000000000
-1.0000000000 9.0000000000
-1.0000000000 8.0000000000
-1.0000000000 0.0000000000
-1.0000000000 9.0000000000
+0.0000000000 0.0000000000
+0.0000000000 0.0000000000
+0.0000000000 0.0000000000
+0.0000000000 0.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
+0.0000000000 8.0000000000
0.0000000000 9.0000000000
0.0000000000 9.0000000000
-0.0000000000 8.0000000000
-0.0000000000 0.0000000000
0.0000000000 9.0000000000
0.0000000000 9.0000000000
0.0000000000 9.0000000000
-0.0000000000 8.0000000000
-0.0000000000 0.0000000000
0.0000000000 9.0000000000
0.0000000000 9.0000000000
0.0000000000 9.0000000000
-0.0000000000 8.0000000000
-0.0000000000 0.0000000000
0.0000000000 9.0000000000
0.0000000000 9.0000000000
0.0000000000 9.0000000000
-0.0000000000 8.0000000000
-0.0000000000 0.0000000000
0.0000000000 9.0000000000
+1.0000000000 0.0000000000
+1.0000000000 8.0000000000
+1.0000000000 9.0000000000
+1.0000000000 9.0000000000
+1.0000000000 9.0000000000
explain with
cte as (select median(f2) over (partition by f1) as k1 from t1 order by f1),
cte1 as (select median(f4) over (partition by f1) as k2 from t1)
@@ -15960,3 +16540,98 @@ f c
9 1
DROP VIEW v1;
DROP TABLE t1;
+#
+# MDEV-16801: splittable materialized derived/views with
+# one grouping field from table without keys
+#
+CREATE TABLE t1 (a int, b int, INDEX idx_a(a), INDEX idx_b(b)) ENGINE=MYISAM;
+CREATE TABLE t2 (c int) ENGINE=MYISAM;
+CREATE TABLE t3 (d int) ENGINE=MYISAM;
+INSERT INTO t1 VALUES
+(77,7), (11,1), (33,3), (44,4), (8,88),
+(78,7), (98,9), (38,3), (28,2), (79,7),
+(58,5), (42,4), (71,7), (27,2), (91,9);
+INSERT INTO t1 SELECT a+100, b+10 FROM t1;
+INSERT INTO t2 VALUES
+(100), (700), (200), (100), (200);
+INSERT INTO t3 VALUES
+(3), (4), (1), (8), (3);
+ANALYZE tables t1,t2,t3;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+test.t2 analyze status OK
+test.t3 analyze status OK
+SELECT *
+FROM t3,
+(SELECT t1.b, t2.c
+FROM t1, t2
+GROUP BY t1.b,t2.c) dt
+WHERE t3.d = dt.b;
+d b c
+3 3 700
+3 3 200
+3 3 100
+4 4 700
+4 4 200
+4 4 100
+1 1 700
+1 1 200
+1 1 100
+3 3 700
+3 3 200
+3 3 100
+EXPLAIN EXTENDED SELECT *
+FROM t3,
+(SELECT t1.b, t2.c
+FROM t1, t2
+GROUP BY t1.b,t2.c) dt
+WHERE t3.d = dt.b;
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY t3 ALL NULL NULL NULL NULL 5 100.00 Using where
+1 PRIMARY <derived2> ref key0 key0 5 test.t3.d 2 100.00
+2 LATERAL DERIVED t1 ref idx_b idx_b 5 test.t3.d 2 100.00 Using index; Using temporary; Using filesort
+2 LATERAL DERIVED t2 ALL NULL NULL NULL NULL 5 100.00 Using join buffer (flat, BNL join)
+Warnings:
+Note 1003 /* select#1 */ select `test`.`t3`.`d` AS `d`,`dt`.`b` AS `b`,`dt`.`c` AS `c` from `test`.`t3` join (/* select#2 */ select `test`.`t1`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t1` join `test`.`t2` where `test`.`t1`.`b` = `test`.`t3`.`d` group by `test`.`t1`.`b`,`test`.`t2`.`c`) `dt` where `dt`.`b` = `test`.`t3`.`d`
+DROP TABLE t1,t2,t3;
+#
+# MDEV-17419: splittable materialized derived/view
+# when join_cache_level = 4
+#
+set join_cache_level = 4;
+CREATE TABLE t1 (
+id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+username VARCHAR(50) NULL DEFAULT '0',
+PRIMARY KEY (id)
+) COLLATE='utf8_general_ci';
+CREATE TABLE t2 (
+id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+userid INT UNSIGNED NOT NULL,
+logindate DATETIME NOT NULL,
+PRIMARY KEY (id)
+) COLLATE='utf8_general_ci';
+INSERT INTO t1 (id, username) VALUES
+(1,"user1"), (2, "user2");
+INSERT INTO t2 (id, userid, logindate) VALUES
+(1,1,"2015-06-19 12:17:02.828"),
+(2,1,"2016-06-19 12:17:02.828"),
+(3,2,"2017-06-19 12:17:02.828"),
+(4,2,"2018-06-19 12:17:02.828");
+EXPLAIN select * from t1 as u
+left join
+(select * from t2 as au group by au.userid) as auditlastlogin
+on u.id=auditlastlogin.userid;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY u ALL NULL NULL NULL NULL 2
+1 PRIMARY <derived2> ref key0 key0 5 test.u.id 2
+2 DERIVED au ALL NULL NULL NULL NULL 4 Using temporary; Using filesort
+select * from t1 as u
+left join
+(select * from t2 as au group by au.userid) as auditlastlogin
+on u.id=auditlastlogin.userid;
+id username id userid logindate
+1 user1 1 1 2015-06-19 12:17:02
+2 user2 3 2 2017-06-19 12:17:02
+set join_cache_level=default;
+DROP TABLE t1,t2;
+# End of 10.3 tests
diff --git a/mysql-test/main/derived_cond_pushdown.test b/mysql-test/main/derived_cond_pushdown.test
index e51646a9764..659bc2026ff 100644
--- a/mysql-test/main/derived_cond_pushdown.test
+++ b/mysql-test/main/derived_cond_pushdown.test
@@ -1,46 +1,46 @@
-let $no_pushdown= set statement optimizer_switch='condition_pushdown_for_derived=off' for;
+let $no_pushdown= set statement optimizer_switch='condition_pushdown_for_derived=off' for;
create table t1 (a int, b int, c int);
create table t2 (a int, b int, c int, d decimal);
-insert into t1 values
+insert into t1 values
(1,21,345), (1,33,7), (8,33,114), (1,21,500), (1,19,107), (5,14,787),
(8,33,123), (9,10,211), (5,16,207), (1,33,988), (5,27,132), (1,21,104),
(6,20,309), (6,20,315), (1,21,101), (8,33,404), (9,10,800), (1,21,123),
(7,11,708), (6,20,214);
insert into t2 values
- (2,3,207,207.0000), (1,21,909,12.0000), (7,13,312,406.0000),
+ (2,3,207,207.0000), (1,21,909,12.0000), (7,13,312,406.0000),
(8,64,248,107.0000), (6,20,315,279.3333), (1,19,203,107.0000),
(8,80,800,314.0000), (3,12,231,190.0000), (6,23,303,909.0000);
-
+
create table t1_double(a int, b double, c double);
-insert into t1_double values
+insert into t1_double values
(1,23.4,14.3333), (1,12.5,18.9), (3,12.5,18.9),
(4,33.4,14.3333), (4,14.3333,13.65), (5,17.89,7.22),
(6,33.4,14.3), (10,33.4,13.65), (11,33.4,13.65);
-
+
create table t2_double(a int, b double, c double);
-insert into t2_double values
+insert into t2_double values
(1,22.4,14.3333), (1,12.5,18.9), (2,22.4,18.9),
(4,33.4,14.3333), (5,22.4,13.65), (7,17.89,18.9),
- (6,33.4,14.3333), (10,31.4,13.65), (12,33.4,13.65);
-
+ (6,33.4,14.3333), (10,31.4,13.65), (12,33.4,13.65);
+
create table t1_char(a char, b char(8), c int);
insert into t1_char values
('a','Ivan',1), ('b','Vika',2), ('b','Inga',6), ('c','Vika',7),
('b','Ivan',7), ('a','Alex',6), ('b','Inga',5), ('d','Ron',9),
- ('d','Harry',2), ('d','Hermione',3), ('c','Ivan',3), ('c','Harry',4);
-
+ ('d','Harry',2), ('d','Hermione',3), ('c','Ivan',3), ('c','Harry',4);
+
create table t2_char(a char, b char(8), c int);
insert into t2_char values
('b','Ivan',1), ('c','Vinny',3), ('c','Inga',9), ('a','Vika',1),
('c','Ivan',2), ('b','Ali',6), ('c','Inga',2), ('a','Ron',9),
('d','Harry',1), ('b','Hermes',3), ('b','Ivan',11), ('b','Harry',4);
-
+
create table t1_decimal (a decimal(3,1), b decimal(3,1), c int);
insert into t1_decimal values
(1,1,23),(2,2,11),(3,3,16),
(1,1,12),(1,1,14),(2,3,15),
- (2,1,13),(2,3,11),(3,3,16);
+ (2,1,13),(2,3,11),(3,3,16);
create table t2_decimal (a decimal(3,1), b decimal(3,1), c int);
insert into t2_decimal values
@@ -48,27 +48,27 @@ insert into t2_decimal values
(1,3,22),(1,3,14),(2,2,15),
(2,1,43),(2,3,11),(2,3,16);
-create view v1 as select a, b, max(c) as max_c, avg(c) as avg_c from t1
+create view v1 as select a, b, max(c) as max_c, avg(c) as avg_c from t1
group by a,b having max_c < 707;
-
-create view v2 as select a, b, max(c) as max_c, avg(c) as avg_c from t1
- where t1.a>5 group by a,b having max_c < 707;
-
+
+create view v2 as select a, b, max(c) as max_c, avg(c) as avg_c from t1
+ where t1.a>5 group by a,b having max_c < 707;
+
create view v3 as select a, b, min(c) as min_c from t1
where t1.a<10 group by a,b having min_c > 109;
-
+
create view v4 as
select a, b, min(max_c) as min_c from v1
- where (v1.a<15) group by a,b;
-
-create view v_union as
+ where (v1.a<15) group by a,b;
+
+create view v_union as
select a, b, min(c) as c from t1
where t1.a<10 group by a,b having c > 109
union
select a, b, max(c) as c from t1
- where t1.b>10 group by a,b having c < 300;
-
-create view v2_union as
+ where t1.b>10 group by a,b having c < 300;
+
+create view v2_union as
select a, b, min(c) as c from t1
where t1.a<10 group by a,b having c > 109
union
@@ -76,117 +76,117 @@ create view v2_union as
where t1.b>10 group by a,b having c < 300
union
select a, b, avg(c) as c from t1
- where t1.c>300 group by a,b having c < 707;
+ where t1.c>300 group by a,b having c < 707;
-create view v3_union as
+create view v3_union as
select a, b, (a+1) as c from t1
where t1.a<10
union
select a, b, c from t1
- where t1.b>10 and t1.c>100;
-
-create view v4_union as
+ where t1.b>10 and t1.c>100;
+
+create view v4_union as
select a, b, max(c)-100 as c from t1
where t1.a<10 group by a,b having c > 109
union
select a, b, (c+100) as c from t1
- where t1.b>10;
+ where t1.b>10;
create view v_double as
select a, avg(a/4) as avg_a, b, c from t1_double
- where (b>12.2) group by b,c having (avg_a<22.333);
-
-create view v_char as
- select a, b, max(c) as max_c from t1_char
- group by a,b having max_c < 9;
-
+ where (b>12.2) group by b,c having (avg_a<22.333);
+
+create view v_char as
+ select a, b, max(c) as max_c from t1_char
+ group by a,b having max_c < 9;
+
create view v_decimal as
select a, b, avg(c) as avg_c from t1_decimal
- group by a,b having (avg_c>12);
+ group by a,b having (avg_c>12);
---echo # conjunctive subformula : pushing into HAVING
+--echo # conjunctive subformula : pushing into HAVING
let $query= select * from v1,t2 where (v1.max_c>214) and (t2.a>v1.a);
eval $no_pushdown $query;
eval $query;
eval explain $query;
eval explain format=json $query;
-let $query=
+let $query=
select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
- group by a,b having max_c < 707) v1,
+ group by a,b having max_c < 707) v1,
t2 where (v1.a=t2.a) and (v1.max_c>300);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
---echo # extracted or formula : pushing into HAVING
-let $query=
- select * from v1,t2 where
+--echo # extracted or formula : pushing into HAVING
+let $query=
+ select * from v1,t2 where
((v1.max_c>400) and (t2.a>v1.a)) or ((v1.max_c<135) and (t2.a<v1.a));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
-let $query=
+eval explain format=json $query;
+
+let $query=
select * from v1,t2 where
- ((v1.max_c>300) and (v1.avg_c>t2.d) and (v1.b=t2.b)) or
+ ((v1.max_c>300) and (v1.avg_c>t2.d) and (v1.b=t2.b)) or
((v1.max_c<135) and (v1.max_c<t2.c) and (v1.a=t2.a));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # conjunctive subformula : pushing into WHERE
let $query= select * from v1,t2 where (v1.a>6) and (t2.b>v1.b);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
let $query= select * from v2,t2 where (v2.b>25) and (t2.a<v2.a);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # extracted or formula : pushing into WHERE
-let $query=
- select * from v1,t2 where
+let $query=
+ select * from v1,t2 where
((v1.a>7) and (t2.c<v1.max_c)) or ((v1.a<2) and (t2.b<v1.b));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
-let $query=
- select * from v2,t2 where
+eval explain format=json $query;
+
+let $query=
+ select * from v2,t2 where
((v2.a>7) and (t2.c<v2.max_c)) or ((v2.a>5) and (t2.b<v2.b));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
-let $query=
- select * from v1,t2 where
- ((v1.a>4) and (v1.b>t2.b) and (v1.max_c=t2.d)) or
+eval explain format=json $query;
+
+let $query=
+ select * from v1,t2 where
+ ((v1.a>4) and (v1.b>t2.b) and (v1.max_c=t2.d)) or
((v1.a<2) and (v1.max_c<t2.c) and (v1.max_c=t2.d));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # conjunctive subformulas : pushing into HAVING and WHERE
-let $query=
- select * from v1,t2 where (v1.a<2) and (v1.max_c>400) and (t2.b>v1.b);
+let $query=
+ select * from v1,t2 where (v1.a<2) and (v1.max_c>400) and (t2.b>v1.b);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
-let $query=
+let $query=
select * from v_double as v,t2_double as t where
(v.a=t.a) and (v.avg_a>0.45) and (v.b>10);
eval $no_pushdown $query;
@@ -194,57 +194,57 @@ eval $query;
eval explain $query;
eval explain format=json $query;
-let $query=
+let $query=
select * from v_decimal as v,t2_decimal as t where
(v.a=t.a) and (v.avg_c>15) and (v.b>1);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
+eval explain format=json $query;
+
--echo # extracted or formula : pushing into HAVING and WHERE
-let $query=
- select * from v1,t2 where
- ((v1.a>7) and (v1.max_c>300) and (t2.c<v1.max_c)) or
- ((v1.a<4) and (v1.max_c<500) and (t2.b<v1.b));
+let $query=
+ select * from v1,t2 where
+ ((v1.a>7) and (v1.max_c>300) and (t2.c<v1.max_c)) or
+ ((v1.a<4) and (v1.max_c<500) and (t2.b<v1.b));
eval $no_pushdown $query;
eval $query;
eval explain $query;
eval explain format=json $query;
-
-let $query=
+
+let $query=
select * from v1,t2 where ((v1.a<2) and (v1.max_c>120)) or (v1.a>7);
eval $no_pushdown $query;
eval $query;
eval explain $query;
eval explain format=json $query;
-
---echo # extracted or formulas : pushing into WHERE and HAVING
-let $query=
- select * from v1,t2 where
+
+--echo # extracted or formulas : pushing into WHERE and HAVING
+let $query=
+ select * from v1,t2 where
((v1.a<2) and (v1.max_c>120) and (v1.b=t2.b)) or (v1.a>7);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
-let $query=
+eval explain format=json $query;
+
+let $query=
select * from v1,t2 where
((v1.a<2) and (v1.max_c<200) and (t2.c>v1.max_c) and (v1.max_c=t2.d)) or
- ((v1.a>4) and (v1.max_c<500) and (t2.b<v1.b) and (v1.max_c=t2.c));
+ ((v1.a>4) and (v1.max_c<500) and (t2.b<v1.b) and (v1.max_c=t2.c));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
+eval explain format=json $query;
+
--echo # prepare of a query containing extracted or formula
-prepare stmt from "select * from v1,t2 where
+prepare stmt from "select * from v1,t2 where
((v1.max_c>400) and (t2.a>v1.a)) or ((v1.max_c<135) and (t2.a<v1.a));";
execute stmt;
execute stmt;
deallocate prepare stmt;
-prepare stmt from
- "explain format=json select * from v1,t2 where
+prepare stmt from
+ "explain format=json select * from v1,t2 where
((v1.max_c>400) and (t2.a>v1.a)) or ((v1.max_c<135) and (t2.a<v1.a));";
execute stmt;
execute stmt;
@@ -252,12 +252,12 @@ deallocate prepare stmt;
--echo # conjunctive subformula : pushing into WHERE
--echo # pushing equalities
-let $query=
+let $query=
select * from v1,t2 where (t2.a=v1.a) and (v1.b=t2.b) and (v1.a=1);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
let $query= select * from v1,t2 where (v1.a=5) and (v1.max_c=t2.d);
eval $no_pushdown $query;
@@ -270,15 +270,15 @@ let $query= select * from v1,t2 where (t2.a<5) and (v1.a=t2.a);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
-let $query=
+eval explain format=json $query;
+
+let $query=
select * from v1,t2 where (v1.a=v1.b) and (v1.a=t2.a);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
+eval explain format=json $query;
+
--echo # conjunctive subformula : pushing into HAVING using equalities
let $query= select * from v1,t2 where (t2.c>150) and (v1.max_c=t2.c);
eval $no_pushdown $query;
@@ -286,73 +286,73 @@ eval $query;
eval explain $query;
eval explain format=json $query;
---echo # extracted and formula : pushing into WHERE
+--echo # extracted and formula : pushing into WHERE
--echo # pushing equalities
-let $query=
+let $query=
select * from v1,t2 where (v1.a=v1.b) and (v1.a=t2.a) and (v1.a=3);
eval $no_pushdown $query;
eval $query;
eval explain $query;
eval explain format=json $query;
-
-let $query=
+
+let $query=
select * from v1,t2 where (v1.a=1) and (v1.b=21) and (t2.a=2);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
-let $query=
- select * from v_char as v,t2_char as t where
- (v.a='c') and (v.b<'Hermes') and ((v.b=t.b) or (v.max_c>20));
+let $query=
+ select * from v_char as v,t2_char as t where
+ (v.a='c') and (v.b<'Hermes') and ((v.b=t.b) or (v.max_c>20));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # extracted and formula : pushing into WHERE using equalities
--echo # pushing equalities
-let $query=
+let $query=
select * from v_decimal as v,t2_decimal as t where
(v.a=v.b) and (v.b=t.b) and ((t.b>1) or (v.a=1));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
---echo # extracted or formula : pushing into HAVING using equalities
-let $query=
+--echo # extracted or formula : pushing into HAVING using equalities
+let $query=
select * from v1,t2
- where ((t2.a<4) and (v1.a=t2.a)) or ((t2.c>150) and (v1.max_c=t2.c));
+ where ((t2.a<4) and (v1.a=t2.a)) or ((t2.c>150) and (v1.max_c=t2.c));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # conjunctive subformulas : pushing into WHERE and HAVING using equalities
-let $query=
+let $query=
select * from v1,t2
where ((t2.a>5) and (v1.a=t2.a)) and ((t2.c>250) and (v1.max_c=t2.c));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # conjunctive subformulas : pushing into WHERE and HAVING
---echo # pushing equalities
-let $query=
+--echo # pushing equalities
+let $query=
select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
- group by a,b having max_c < 707) v1,
+ group by a,b having max_c < 707) v1,
t2 where (v1.a=8) and (v1.a=t2.a) and (v1.max_c=404);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
---echo # conjunctive subformulas : pushing into WHERE and HAVING
-let $query=
- select * from v1,t2 where
+eval explain format=json $query;
+
+--echo # conjunctive subformulas : pushing into WHERE and HAVING
+let $query=
+ select * from v1,t2 where
(v1.a>3) and (v1.max_c>200) and (t2.b<v1.b) and (t2.d=v1.max_c);
eval $no_pushdown $query;
eval $query;
@@ -362,17 +362,17 @@ eval explain format=json $query;
--echo # conjunctive subformula : pushing into WHERE
--echo # extracted or formula : pushing into HAVING using equalities
--echo # pushing equalities
-let $query=
+let $query=
select * from v_double as v,t2_double as t where
(v.b=v.c) and (v.c=t.c) and ((t.c>10) or (v.a=1));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # conjunctive subformula : pushing into WHERE
---echo # extracted or formula : pushing into HAVING using equalities
-let $query=
+--echo # extracted or formula : pushing into HAVING using equalities
+let $query=
select * from v_double as v,t2_double as t where
(((v.a>0.2) or (v.b<17)) or (t.c>17)) and (t.c=v.c) and (v.c>18);
eval $no_pushdown $query;
@@ -383,146 +383,146 @@ eval explain format=json $query;
--echo # extracted or formula : pushing into WHERE
--echo # conjunctive subformula : pushing into HAVING
--echo # pushing equalities
-let $query=
+let $query=
select * from v_decimal as v,t2_decimal as t where
- (((v.a>4) or (v.a=2)) or (v.b>3)) and (v.avg_c=13);
+ (((v.a>4) or (v.a=2)) or (v.b>3)) and (v.avg_c=13);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
-let $query=
+let $query=
select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
- where t1.a>5 group by a,b having max_c < 707) v1,
+ where t1.a>5 group by a,b having max_c < 707) v1,
t2 where (v1.a=t2.a) and (v1.max_c>300) and (v1.a=v1.b);
eval $no_pushdown $query;
eval $query;
eval explain $query;
eval explain format=json $query;
-
+
--echo # nothing to push
-let $query=
+let $query=
select * from v1,t2 where (t2.a<2) and (t2.c>900);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.b=t2.b);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
-let $query=
- select * from v1,t2 where
- (t2.a=v1.a) or (v1.b=t2.b) and ((v1.a=1) or (v1.a=6));
+eval explain format=json $query;
+
+let $query=
+ select * from v1,t2 where
+ (t2.a=v1.a) or (v1.b=t2.b) and ((v1.a=1) or (v1.a=6));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
-let $query=
+eval explain format=json $query;
+
+let $query=
select * from v1,t2 where (v1.a=1) or (v1.b=21) or (t2.a=2);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
-let $query=
- select * from v1,t2 where
+let $query=
+ select * from v1,t2 where
(t2.a<2) and (t2.c>900) and ((v1.a<t2.a) or (t2.a<11));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using several derived tables : nothing to push
-let $query= select * from v1,v2,t2 where
+let $query= select * from v1,v2,t2 where
(v1.a=v2.a) and (v1.a=t2.a) and (v2.b<50);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
-let $query=
- select * from v1,v2,t2 where
+let $query=
+ select * from v1,v2,t2 where
((v1.a=v2.a) or (v1.a=t2.a)) and (t2.b<50) and (v1.b=v2.b);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
-let $query=
- select * from v1,v2,t2 where
+let $query=
+ select * from v1,v2,t2 where
((v1.a=v2.a) and (v1.a=t2.a)) or ((v2.b>13) and (t2.c<115));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using several derived tables : pushing in all tables
--echo # conjunctive subformula : pushing into HAVING
--echo # extracted or formula : pushing into WHERE
---echo # pushing equalities
-let $query=
- select * from v1,v2,t2 where ((v1.a=v2.a) or (v1.a=t2.a)) and
+--echo # pushing equalities
+let $query=
+ select * from v1,v2,t2 where ((v1.a=v2.a) or (v1.a=t2.a)) and
((v2.b<50) or (v2.b=19)) and (v1.max_c<300);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
+eval explain format=json $query;
+
--echo # using several derived tables : pushing only in one table
--echo # conjunctive subformula : pushing into WHERE
--echo # pushing equalities
-let $query=
- select * from v1,v2,t2 where
- (v1.a=t2.a) and (v1.a=v1.b) and (v1.a=v2.a) and (v2.max_c<300);
+let $query=
+ select * from v1,v2,t2 where
+ (v1.a=t2.a) and (v1.a=v1.b) and (v1.a=v2.a) and (v2.max_c<300);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using several derived tables : pushing only in one table
--echo # extracted and formula : pushing into WHERE
--echo # conjunctive subformula : pushing into WHERE using equalities
--echo # pushing equalities
-let $query=
+let $query=
select * from v1,v2,t2 where (v1.a=1) and (v1.b>10) and (v1.b=v2.b);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # extracted or formula : pushing into WHERE
--echo # conjunctive subformula : pushing into WHERE using equalities
--echo # pushing equalities
-let $query=
- select * from v_char as v,t2_char as t where
+let $query=
+ select * from v_char as v,t2_char as t where
(v.a=t.a) and (t.a='b') and ((v.b='Vika') or (v.b='Ali'));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using several derived tables : pushing in all tables
--echo # extracted or formula : pushing into WHERE
---echo # conjunctive subformulas : pushing into HAVING
+--echo # conjunctive subformulas : pushing into HAVING
--echo # pushing equalities
-let $query=
- select * from v1,v2,v3,t2 where
- ((v1.a=v2.a) or (v1.a=t2.a)) and ((v3.b<50) or (v3.b=33))
+let $query=
+ select * from v1,v2,v3,t2 where
+ ((v1.a=v2.a) or (v1.a=t2.a)) and ((v3.b<50) or (v3.b=33))
and (v1.max_c<500) and (v3.a=t2.a) and (v2.max_c>300);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using several derived tables : pushing in all tables
---echo # conjunctive subformulas : pushing into HAVING
-let $query=
+--echo # conjunctive subformulas : pushing into HAVING
+let $query=
select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
where t1.a>5 group by a,b having max_c < 707) v1,
@@ -532,11 +532,11 @@ let $query=
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using several derived tables : pushing in all tables
--echo # extracted or formulas : pushing into HAVING
---echo # conjunctive subformula : pushing into HAVING
+--echo # conjunctive subformula : pushing into HAVING
let $query=
select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
@@ -550,51 +550,51 @@ let $query=
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
+eval explain format=json $query;
+
--echo # extracted or formula : pushing into HAVING
---echo # conjunctive subformula : pushing into WHERE
-let $query=
+--echo # conjunctive subformula : pushing into WHERE
+let $query=
select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
- group by a,b having max_c < 707) v1,
- t2 where ((v1.a=1) or (v1.max_c<300)) and (v1.b>25);
+ group by a,b having max_c < 707) v1,
+ t2 where ((v1.a=1) or (v1.max_c<300)) and (v1.b>25);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
+eval explain format=json $query;
+
--echo # extracted and formula : pushing into WHERE
---echo # conjunctive subformula : pushing into HAVING
-let $query=
+--echo # conjunctive subformula : pushing into HAVING
+let $query=
select * from
(select a, b, max(c) as max_c, avg(c) as avg_c from t1
- where t1.a>5 group by a,b having max_c < 707) v1,
- t2 where (v1.a=t2.a) and (v1.max_c>300) and (v1.b<30);
+ where t1.a>5 group by a,b having max_c < 707) v1,
+ t2 where (v1.a=t2.a) and (v1.max_c>300) and (v1.b<30);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using query with union
--echo # conjunctive subformula : pushing into WHERE
--echo # conjunctive subformulas : pushing into HAVING and WHERE
-let $query=
+let $query=
select * from v1,t2 where (v1.a<5) and (v1.b=t2.b) and (t2.c>800)
union
- select * from v1,t2 where (v1.max_c>100) and (v1.a>7) and (t2.d>800);
+ select * from v1,t2 where (v1.max_c>100) and (v1.a>7) and (t2.d>800);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using query with union
---echo # extracted and formula : pushing into WHERE
---echo # extracted or formula : pushing into HAVING
+--echo # extracted and formula : pushing into WHERE
+--echo # extracted or formula : pushing into HAVING
--echo # pushing equalities
-let $query=
+let $query=
select * from v1,t2 where (v1.a<5) and (v1.b=t2.b) and (v1.b=19)
- union
+ union
select * from v1,t2 where ((v1.max_c>400) or (v1.avg_c>270)) and (v1.a<t2.a);
eval $no_pushdown $query;
eval $query;
@@ -602,25 +602,25 @@ eval explain $query;
eval explain format=json $query;
--echo # using query with union
---echo # extracted or formula : pushing into HAVING
+--echo # extracted or formula : pushing into HAVING
--echo # extracted or formula : pushing into WHERE
--echo # pushing equalities
-let $query=
- select * from v1,t2 where
+let $query=
+ select * from v1,t2 where
((t2.a=v1.a) or (v1.b=t2.b)) and ((v1.a=1) or (v1.a=6))
union
- select * from v1,t2 where ((v1.a>3) and (v1.b>27)) or (v1.max_c>550);
+ select * from v1,t2 where ((v1.a>3) and (v1.b>27)) or (v1.max_c>550);
eval $no_pushdown $query;
eval $query;
eval explain $query;
eval explain format=json $query;
--echo # using query with union
---echo # extracted or formula : pushing into HAVING
---echo # conjunctive subformulas : pushing into WHERE
+--echo # extracted or formula : pushing into HAVING
+--echo # conjunctive subformulas : pushing into WHERE
--echo # pushing equalities
-let $query=
- select * from v1,t2 where
+let $query=
+ select * from v1,t2 where
((v1.a=1) and (v1.a=t2.a)) and ((v1.max_c<500) or (v1.avg_c>500))
union
select * from v2,t2 where
@@ -643,8 +643,8 @@ eval explain format=json $query;
--echo # using derived table with union
--echo # conjunctive subformula : pushing into WHERE
---echo # extracted or formula : pushing into HAVING
-let $query=
+--echo # extracted or formula : pushing into HAVING
+let $query=
select * from v_union,t2 where
((v_union.a<2) or (v_union.c>800)) and (v_union.b>12);
eval $no_pushdown $query;
@@ -656,7 +656,7 @@ eval explain format=json $query;
--echo # conjunctive subformula : pushing into HAVING
--echo # conjunctive subformula : pushing into WHERE
--echo # pushing equalities
-let $query=
+let $query=
select * from v_union,t2 where
(v_union.a=1) and (v_union.a=t2.a) and (v_union.c<200);
eval $no_pushdown $query;
@@ -664,215 +664,215 @@ eval $query;
eval explain $query;
eval explain format=json $query;
-let $query=
- select * from v_char as v,t2_char as t where
+let $query=
+ select * from v_char as v,t2_char as t where
(v.a=t.a) and (v.b='Vika') and (v.max_c>2);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using derived table with union
--echo # using several derived tables : pushing in all tables
--echo # conjunctive subformula : pushing into WHERE using equalities
--echo # pushing equalities
-let $query=
+let $query=
select * from v_union,v1,t2 where
- (v_union.a=v1.a) and (v1.a=t2.a) and (t2.a=1)
- and ((v_union.c>800) or (v1.max_c>200));
+ (v_union.a=v1.a) and (v1.a=t2.a) and (t2.a=1)
+ and ((v_union.c>800) or (v1.max_c>200));
eval $no_pushdown $query;
eval $query;
eval explain $query;
eval explain format=json $query;
---echo # using derived table with union
---echo # extracted or formula : pushing into WHERE
+--echo # using derived table with union
+--echo # extracted or formula : pushing into WHERE
--echo # conjunctive subformula : pushing into HAVING
--echo # pushing equalities
-let $query=
- select * from v2_union as v,t2 where
+let $query=
+ select * from v2_union as v,t2 where
((v.a=6) or (v.a=8)) and (v.c>200) and (v.a=t2.a);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using derived table with union of selects without aggregation
--echo # extracted conjunctive predicate: pushing in WHERE of both selects
-let $query=
+let $query=
select * from v3_union as v,t2 where (v.a=t2.a) and (v.c>6);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using derived table with union of selects without aggregation
--echo # extracted conjunctive OR subformula: pushing in WHERE using equalities
-let $query=
+let $query=
select * from v3_union as v,t2 where (v.a=t2.a) and ((t2.a>1) or (v.b<20));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using derived table with union of selects without aggregation
--echo # extracted the whole condition: in WHERE of both selects
-let $query=
- select * from v3_union as v,t2 where
+let $query=
+ select * from v3_union as v,t2 where
(v.a=t2.a) and ((v.b=19) or (v.b=21)) and ((v.c<3) or (v.c>600));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
---echo # using derived table with union of
+--echo # using derived table with union of
--echo # a select without aggregation and a select with aggregation
--echo # extracted conjunctive predicate: pushing in WHERE of both selects
-let $query=
+let $query=
select * from v4_union as v,t2 where (v.a=t2.a) and (v.b<20);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
---echo # using derived table with union of
+--echo # using derived table with union of
--echo # a select without aggregation and a select with aggregation
--echo # extracted subformula: pushing in WHERE of one select
--echo # extracted subformula: pushing in HAVING of the other select
--echo # extracted sub-subformula: pushing in WHERE of the other select
--echo # using an equality in all pushdowns
-let $query=
- select * from v4_union as v,t2 where
+let $query=
+ select * from v4_union as v,t2 where
(v.a=t2.a) and ((t2.a<3) or (v.b<40)) and (v.c>500);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using embedded derived table : pushing the same conditions
--echo # using several derived tables : pushing in all tables
--echo # conjunctive subformula : pushing into WHERE
--echo # extracted and formula : pushing into WHERE
-let $query=
+let $query=
select * from v4,v1 where
- (v4.a<13) and (v1.a>5) and (v1.b>12);
+ (v4.a<13) and (v1.a>5) and (v1.b>12);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using embedded view : nothing to push
--echo # using several derived tables : pushing only in one table
--echo # conjunctive subformula : pushing into WHERE
-let $query=
+let $query=
select * from v4,v1,t2 where
(v4.a=t2.a) and (v4.a=v1.a) and (v1.b>30);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using embedded view : pushing different conditions
--echo # using several derived tables : pushing in all tables
--echo # conjunctive subformula : pushing into WHERE using equalities
--echo # extracted and formula : pushing into WHERE using equalities
--echo # conjunctive subformula : pushing into HAVING
-let $query=
+let $query=
select * from v4,v1,t2 where
- (v4.a=t2.a) and (v4.a>1) and (v4.a=v1.a) and (v4.min_c>100) and (v1.b<30);
+ (v4.a=t2.a) and (v4.a>1) and (v4.a=v1.a) and (v4.min_c>100) and (v1.b<30);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using embedded view : pushing different conditions
--echo # using several derived tables : pushing in all tables
--echo # extracted or formula : pushing into WHERE
--echo # conjunctive subformula : pushing into HAVING
-let $query=
+let $query=
select * from v4,v1,t2 where
(((v4.b>10) and (v4.a>1)) or (v4.b<20)) and (v1.max_c>200) and (v1.a=v4.a);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
+eval explain format=json $query;
+
--echo # using embedded view : pushing different conditions
--echo # using several derived tables : pushing only in one table
--echo # extracted or formula : pushing into WHERE
--echo # extracted or formula : pushing into HAVING
-let $query=
+let $query=
select * from v4,v2 where
((v4.a>12) and (v4.min_c<300) and (v4.b>13)) or (v4.a<1);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
+eval explain format=json $query;
+
--echo # using embedded view : pushing different conditions
--echo # using several derived tables : pushing only in one table
--echo # conjunctive subformula : pushing into WHERE
--echo # conjunctive subformula : pushing into HAVING
--echo # pushing equalities
-let $query=
+let $query=
select * from v4,v2 where
- (v4.a=v2.b) and (v4.a=v4.b) and (v4.min_c<100);
+ (v4.a=v2.b) and (v4.a=v4.b) and (v4.min_c<100);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
+eval explain format=json $query;
+
--echo # using embedded view : pushing the same conditions
--echo # using several derived tables : pushing in all tables
--echo # extracted and formula : pushing into WHERE using equalities
--echo # conjunctive subformula : pushing into WHERE
--echo # pushing equalities
-let $query=
+let $query=
select * from v4,v2 where
- (v4.a=v2.b) and (v4.a=v4.b) and (v2.b<30);
+ (v4.a=v2.b) and (v4.a=v4.b) and (v2.b<30);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using embedded view : pushing the same conditions
--echo # using several derived tables : pushing in all tables
--echo # extracted or formula : pushing into WHERE using equalities
--echo # extracted and formula : pushing into WHERE using equalities
--echo # pushing equalities
-let $query=
+let $query=
select * from v4,v2 where
(v4.a=v2.b) and (v4.a=v4.b) and ((v2.b<30) or (v4.a>2));
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
-
+eval explain format=json $query;
+
--echo # using embedded view : pushing the same conditions
--echo # using several derived tables : pushing in all tables
--echo # extracted or formula : pushing into WHERE
--echo # conjunctive subformula : pushing into WHERE
---echo # pushing equalities
-let $query=
+--echo # pushing equalities
+let $query=
select * from v4,v2 where
(((v4.a<12) and (v4.b>13)) or (v4.a>10)) and
(v4.min_c=v2.max_c) and (v4.min_c>100);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
--echo # using embedded view : pushing the same conditions
--echo # using several derived tables : pushing only in one table
--echo # extracted or formula : pushing into WHERE
-let $query=
+let $query=
select * from v4,v2,t2 where
(((v4.a<12) and (t2.b>13)) or (v4.a>10)) and
(v4.min_c=t2.c) and (t2.c>100);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
drop view v1,v2,v3,v4;
drop view v_union,v2_union,v3_union,v4_union;
@@ -880,580 +880,6 @@ drop view v_double,v_char,v_decimal;
drop table t1,t2,t1_double,t2_double,t1_char,t2_char,t1_decimal,t2_decimal;
--echo #
---echo # MDEV-14579: pushdown conditions into materialized views/derived tables
---echo # that are defined with EXIST or/and INTERSECT
---echo #
-
-create table t1 (a int, b int, c int);
-create table t2 (a int, b int, c int);
-
-insert into t1 values
- (1,21,345), (1,33,7), (8,33,114), (1,21,500), (1,19,117), (5,14,787),
- (8,33,123), (9,10,211), (5,16,207), (1,33,988), (5,27,132), (1,21,104),
- (6,20,309), (6,20,315), (1,21,101), (4,33,404), (9,10,800), (1,21,123);
-
-insert into t2 values
- (2,3,207), (1,16,909), (5,14,312),
- (5,33,207), (6,20,211), (1,19,132),
- (8,33,117), (3,21,231), (6,23,303);
-
-create view v1 as
- select a, b, min(c) as c from t1
- where t1.a<9 group by a,b having c < 300
- intersect
- select a, b, min(c) as c from t1
- where t1.b>10 group by a,b having c > 100;
-
---echo # using intersect in view definition
---echo # conjunctive subformulas : pushing into WHERE
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<5);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using intersect in view definition
---echo # conjunctive subformulas : pushing into WHERE
---echo # pushing equalities
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a=8);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using intersect in view definition
---echo # conjunctive subformulas : pushing into WHERE using equalities
-let $query= select * from v1,t2 where (v1.a=t2.a) and (t2.a=8);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using intersect in view definition
---echo # conjunctive subformulas : pushing into HAVING
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.c>200);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using intersect in view definition
---echo # conjunctive subformulas : pushing into WHERE
---echo # conjunctive subformulas : pushing into HAVING
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<5) and (v1.c>110);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using intersect in view definition
---echo # extracted or formula : pushing into WHERE
-let $query=
- select * from v1,t2 where (v1.a=t2.a) and ((v1.b>27) or (v1.b<19));
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using intersect in view definition
---echo # extracted or formula : pushing into HAVING
-let $query=
- select * from v1,t2 where
- (v1.a=t2.a) and ((v1.c>200) or (v1.c<105));
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using intersect in view definition
---echo # extracted or formula : pushing into WHERE
---echo # extracted or formula : pushing into HAVING using equalities
---echo # pushing equalities
-let $query=
- select * from v1,t2 where
- ((v1.a>3) and (t2.c>110) and (v1.c=t2.c)) or
- ((v1.a=1) and (v1.c<110));
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using intersect in view definition
---echo # prepare of a query
---echo # conjunctive subformulas : pushing into WHERE
---echo # conjunctive subformulas : pushing into HAVING
-prepare stmt from "select * from v1,t2
- where (v1.a=t2.a) and (v1.a<5) and (v1.c>110);";
-execute stmt;
-execute stmt;
-deallocate prepare stmt;
-
---echo # using intersect in derived table definition
---echo # extracted or formula : pushing into WHERE using equalities
---echo # extracted or formula : pushing into HAVING
---echo # pushing equalities
-let $query=
- select *
- from t2,
- (select a, b, min(c) as c from t1
- where t1.a<9 group by a,b having c < 300
- intersect
- select a, b, min(c) as c from t1
- where t1.b>10 group by a,b having c > 100) as d1
- where
- (d1.b=t2.b) and
- (((t2.b>13) and (t2.c=909)) or
- ((d1.a<4) and (d1.c<200)));
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
-create view v1 as
- select a, b, max(c) as c from t1
- where t1.a<9 group by a,b having c > 200
- except
- select a, b, max(c) as c from t1
- where t1.b>10 group by a,b having c < 300;
-
---echo # using except in view definition
---echo # conjunctive subformulas : pushing into WHERE
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<5);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using except in view definition
---echo # conjunctive subformulas : pushing into WHERE
---echo # pushing equalities
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a=6);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using except in view definition
---echo # conjunctive subformulas : pushing into WHERE using equalities
-let $query= select * from v1,t2 where (v1.a=t2.a) and (t2.a=6);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using except in view definition
---echo # conjunctive subformulas : pushing into HAVING
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.c>500);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using except in view definition
---echo # conjunctive subformulas : pushing into WHERE
---echo # conjunctive subformulas : pushing into HAVING
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<5) and (v1.c>500);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using except in view definition
---echo # extracted or formula : pushing into WHERE
-let $query=
- select * from v1,t2 where (v1.a=t2.a) and ((v1.b>27) or (v1.b<19));
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using except in view definition
---echo # extracted or formula : pushing into HAVING
-let $query=
- select * from v1,t2 where
- (v1.a=t2.a) and ((v1.c<400) or (v1.c>800));
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using except in view definition
---echo # extracted or formula : pushing into WHERE
---echo # extracted or formula : pushing into HAVING using equalities
---echo # pushing equalities
-let $query=
- select * from v1,t2 where
- (v1.c=t2.c) and
- ((v1.a>1) and (t2.c<500)) or
- ((v1.a=1) and (v1.c>500));
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
---echo # using except in view definition
---echo # prepare of a query
---echo # conjunctive subformulas : pushing into WHERE
---echo # conjunctive subformulas : pushing into HAVING
-prepare stmt from "select * from v1,t2
- where (v1.a=t2.a) and (v1.a<5) and (v1.c>500);";
-execute stmt;
-execute stmt;
-deallocate prepare stmt;
-
---echo # using except in view definition
---echo # extracted or formula : pushing into WHERE using equalities
---echo # extracted or formula : pushing into HAVING
---echo # pushing equalities
-let $query=
- select *
- from t2,
- (select a, b, max(c) as c from t1
- where t1.a<9 group by a,b having c > 200
- except
- select a, b, max(c) as c from t1
- where t1.b>10 group by a,b having c < 300) as d1
- where
- (d1.b=t2.b) and
- (((t2.b>13) and (t2.c=988)) or
- ((d1.a>4) and (d1.c>500)));
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
---echo # using union and intersect in view definition
---echo # conjunctive subformulas : pushing into WHERE and HAVING
-create view v1 as
- select a, b, min(c) as c from t1
- where t1.a<9 group by a,b having c > 200
- union
- select a, b, max(c) as c from t1
- where t1.b>10 group by a,b having c < 300
- intersect
- select a, b, max(c) as c from t1
- where t1.a>3 group by a,b having c < 530;
-
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>5) and (v1.c>200);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
---echo # using union and intersect in view definition
---echo # conjunctive subformulas : pushing into WHERE and HAVING
-create view v1 as
- select a, b, min(c) as c from t1
- where t1.a<9 group by a,b having c > 200
- intersect
- select a, b, max(c) as c from t1
- where t1.a>3 group by a,b having c < 500
- union
- select a, b, max(c) as c from t1
- where t1.b>10 group by a,b having c < 300;
-
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<200);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
---echo # using union and except in view definition
---echo # conjunctive subformulas : pushing into WHERE and HAVING
-create view v1 as
- select a, b, min(c) as c from t1
- where t1.a<9 group by a,b having c > 200
- union
- select a, b, max(c) as c from t1
- where t1.b>10 group by a,b having c < 300
- except
- select a, b, max(c) as c from t1
- where t1.a>3 group by a,b having c < 530;
-
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>5) and (v1.c>200);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
---echo # using union and except in view definition
---echo # conjunctive subformulas : pushing into WHERE and HAVING
-create view v1 as
- select a, b, min(c) as c from t1
- where t1.a<9 group by a,b having c > 200
- except
- select a, b, max(c) as c from t1
- where t1.a>3 group by a,b having c < 500
- union
- select a, b, max(c) as c from t1
- where t1.b>10 group by a,b having c < 300;
-
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<200);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
---echo # using except and intersect in view definition
---echo # conjunctive subformulas : pushing into WHERE and HAVING
-create view v1 as
- select a, b, max(c) as c from t1
- where t1.b>10 group by a,b having c < 300
- intersect
- select a, b, max(c) as c from t1
- where t1.a<7 group by a,b having c < 500
- except
- select a, b, max(c) as c from t1
- where t1.a<9 group by a,b having c > 150;
-
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<150);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
---echo # using except and intersect in view definition
---echo # conjunctive subformulas : pushing into WHERE and HAVING
-create view v1 as
- select a, b, max(c) as c from t1
- where t1.b>10 group by a,b having c < 300
- except
- select a, b, max(c) as c from t1
- where t1.a<9 group by a,b having c > 150
- intersect
- select a, b, max(c) as c from t1
- where t1.a<7 group by a,b having c < 500;
-
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<130);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
---echo # using except, intersect and union in view definition
---echo # conjunctive subformulas : pushing into WHERE and HAVING
-create view v1 as
- select a, b, max(c) as c from t1
- where t1.b>10 group by a,b having c < 300
- except
- select a, b, max(c) as c from t1
- where t1.a<9 group by a,b having c > 150
- intersect
- select a, b, max(c) as c from t1
- where t1.a<7 group by a,b having c < 500
- union
- select a, b, max(c) as c from t1
- where t1.a<7 group by a,b having c < 120;
-
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<130);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
---echo # using intersect in view definition
---echo # using embedded view
---echo # conjunctive subformulas : pushing into WHERE and HAVING
-create view v1 as
- select a, b, max(c) as c from t1
- where t1.b>10 group by a,b having c < 300
- intersect
- select a, b, max(c) as c from t1
- where t1.a<9 group by a,b having c > 120;
-
-create view v2 as
- select a, b, max(c) as c from v1
- where v1.a<7 group by a,b;
-
-let $query= select * from v2,t2 where (v2.a=t2.a) and (v2.a>4) and (v2.c<150);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1,v2;
-
---echo # using except in view definition
---echo # using embedded view
---echo # conjunctive subformulas : pushing into WHERE and HAVING
-create view v1 as
- select a, b, max(c) as c from t1
- where t1.b>10 group by a,b having c < 300
- except
- select a, b, max(c) as c from t1
- where t1.a<9 group by a,b having c > 150;
-
-create view v2 as
- select a, b, max(c) as c from v1
- where v1.a<7 group by a,b;
-
-let $query= select * from v2,t2 where (v2.a=t2.a) and (v2.a>4) and (v2.c<150);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1,v2;
-
---echo # using intersect in view definition
---echo # conditions are pushed in different parts of selects
---echo # conjunctive subformulas : pushing into WHERE and HAVING
-create view v1 as
- select a, b, max(c) as c from t1
- where t1.a<9 group by a having c > 300
- intersect
- select a, b, max(c) as c from t1
- where t1.b<21 group by b having c > 200;
-
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.b>12) and (v1.c<450);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
---echo # using except in view definition
---echo # conditions are pushed in different parts of selects
---echo # conjunctive subformulas : pushing into WHERE and HAVING
-create view v1 as
- select a, b, max(c) as c from t1
- where t1.b>20 group by a having c > 300
- except
- select a, b, max(c) as c from t1
- where t1.a<7 group by b having c > 150;
-
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<2) and (v1.b<30) and (v1.c>450);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
---echo # using except and union in view definition
---echo # conditions are pushed in different parts of selects
---echo # conjunctive subformulas : pushing into HAVING
---echo # extracted or formula : pushing into WHERE
---echo # extracted or formula : pushing into HAVING
-create view v1 as
- select a, b, max(c) as c from t1
- where t1.b>20 group by a having c > 300
- except
- select a, b, max(c) as c from t1
- where t1.a<7 group by b having c > 150;
-
-let $query= select * from v1,t2 where (v1.a=t2.a) and ((v1.a<2) or (v1.a<5)) and (v1.c>450);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
---echo # using union and intersect in view definition
---echo # conditions are pushed in different parts of selects
---echo # conjunctive subformulas : pushing into WHERE and HAVING
-create view v1 as
- select a, b, max(c) as c from t1
- where t1.a<9 group by a having c > 100
- intersect
- select a, b, max(c) as c from t1
- where t1.a>3 group by b having c < 800
- union
- select a, b, max(c) as c from t1
- where t1.b>10 group by a,b having c > 300;
-
-let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>1) and (v1.b > 12) and (v1.c>400);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
-create table t3 (a int, b int, c int);
-insert into t3 values
- (1,21,345), (2,33,7), (8,33,114), (3,21,500), (1,19,107), (5,14,787),
- (4,33,123), (9,10,211), (11,16,207), (10,33,988), (5,27,132), (12,21,104),
- (6,20,309), (16,20,315), (16,21,101), (18,33,404), (19,10,800), (10,21,123),
- (17,11,708), (6,20,214);
-
-create index i1 on t3(a);
-
---echo # conjunctive subformulas : pushing into WHERE
---echo # pushed condition gives range access
-create view v1 as
- select a, b, max(c) as max_c from t3
- where a>0 group by a;
-
-let $query= select * from v1,t2 where (v1.b=t2.b) and (v1.a<5);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
---echo # using union in view definition
---echo # conjunctive subformulas : pushing into WHERE
---echo # pushed condition gives range access
-create view v1 as
- select a, b, max(c) as c from t3
- where t3.a>1 group by a
- union
- select a, b, max(c) as c from t3
- where t3.a>2 group by a;
-
-let $query= select * from v1,t2 where (v1.b=t2.b) and (v1.a<4);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
---echo # using union in view definition
---echo # conjunctive subformulas : pushing into WHERE
---echo # pushed condition gives range access in one of the selects
-create view v1 as
- select a, b, max(c) as c from t3
- where t3.a>1 group by a
- union
- select a, b, max(c) as c from t3
- where t3.b<21 group by b;
-
-let $query= select * from v1,t2 where (v1.b=t2.b) and (v1.a<3);
-eval $no_pushdown $query;
-eval $query;
-eval explain $query;
-eval explain format=json $query;
-
-drop view v1;
-
-alter table t3 drop index i1;
-
-drop table t1,t2,t3;
-
---echo #
--echo # MDEV-10782: condition extracted from a multiple equality
--echo # pushed into HAVING
--echo #
@@ -1480,8 +906,8 @@ CREATE TABLE t1 (i int) ENGINE=MyISAM;
CREATE VIEW v AS SELECT 5;
SELECT * FROM t1 WHERE 1 IN ( SELECT * FROM v );
DROP VIEW v;
-DROP TABLE t1;
-
+DROP TABLE t1;
+
--echo #
--echo # MDEV-10785: second execution of a query with condition
--echo # pushed into view
@@ -1510,17 +936,17 @@ select a from t1 order by a limit 5;
set statement optimizer_switch='condition_pushdown_for_derived=off' for
select * from (select a from t1 order by a limit 5) t where t.a not in (1,2,3);
-set statement optimizer_switch='condition_pushdown_for_derived=on' for
+set statement optimizer_switch='condition_pushdown_for_derived=on' for
select * from (select a from t1 order by a limit 5) t where t.a not in (1,2,3);
select a from t1 where a < 4 union select a from t1 where a > 5
order by a limit 5;
set statement optimizer_switch='condition_pushdown_for_derived=off' for
-select * from
+select * from
(select a from t1 where a < 4 union select a from t1 where a > 5
order by a limit 5) t where t.a not in (2,9);
-set statement optimizer_switch='condition_pushdown_for_derived=on' for
-select * from
+set statement optimizer_switch='condition_pushdown_for_derived=on' for
+select * from
(select a from t1 where a < 4 union select a from t1 where a > 5
order by a limit 5) t where t.a not in (2,9);
@@ -1537,45 +963,45 @@ CREATE OR REPLACE VIEW v2 AS SELECT * FROM t2;
CREATE TABLE t3 (c INT) ENGINE=MyISAM;
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v3 AS SELECT * FROM t3;
-SELECT * FROM t1 WHERE a IN (
- SELECT b FROM v2 WHERE b < a OR b IN (
- SELECT c FROM v3 WHERE c = a
- )
+SELECT * FROM t1 WHERE a IN (
+ SELECT b FROM v2 WHERE b < a OR b IN (
+ SELECT c FROM v3 WHERE c = a
+ )
);
INSERT INTO t1 VALUES (2);
INSERT INTO t2 VALUES (3), (2);
INSERT INTO t3 VALUES (4), (1), (2), (7);
-SELECT * FROM t1 WHERE a IN (
- SELECT b FROM v2 WHERE b < a OR b IN (
- SELECT c FROM v3 WHERE c = a
- )
+SELECT * FROM t1 WHERE a IN (
+ SELECT b FROM v2 WHERE b < a OR b IN (
+ SELECT c FROM v3 WHERE c = a
+ )
);
EXPLAIN FORMAT=JSON
-SELECT * FROM t1 WHERE a IN (
- SELECT b FROM v2 WHERE b < a OR b IN (
- SELECT c FROM v3 WHERE c = a
- )
+SELECT * FROM t1 WHERE a IN (
+ SELECT b FROM v2 WHERE b < a OR b IN (
+ SELECT c FROM v3 WHERE c = a
+ )
);
CREATE TABLE t4 (d INT, e INT) ENGINE=MyISAM;
INSERT INTO t4 VALUES (1,10),(3,11),(2,10),(2,20),(3,21);
-CREATE OR REPLACE VIEW v4 AS
+CREATE OR REPLACE VIEW v4 AS
SELECT d, sum(e) AS s FROM t4 GROUP BY d;
-let $query =
-SELECT * FROM t1 WHERE a IN (
- SELECT b FROM v2 WHERE b < a OR b IN (
- SELECT d FROM v4 WHERE s > a
- )
+let $query =
+SELECT * FROM t1 WHERE a IN (
+ SELECT b FROM v2 WHERE b < a OR b IN (
+ SELECT d FROM v4 WHERE s > a
+ )
);
eval $no_pushdown $query;
eval $query;
eval explain $query;
-eval explain format=json $query;
+eval explain format=json $query;
DROP VIEW v2,v3,v4;
DROP TABLE t1,t2,t3,t4;
@@ -1588,17 +1014,17 @@ DROP TABLE t1,t2,t3,t4;
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1);
-
+
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3),(4);
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
-
-SELECT * FROM
+
+SELECT * FROM
( SELECT * FROM t1
WHERE EXISTS ( SELECT * FROM v2 WHERE b = a ) ) AS sq;
EXPLAIN FORMAT=JSON
-SELECT * FROM
+SELECT * FROM
( SELECT * FROM t1
WHERE EXISTS ( SELECT * FROM v2 WHERE b = a ) ) AS sq;
@@ -1606,18 +1032,18 @@ DROP VIEW v2;
DROP TABLE t1,t2;
--echo #
---echo # MDEV-11102: condition pushdown into materialized inner table
---echo # of outer join is not applied as not being valid
+--echo # MDEV-11102: condition pushdown into materialized inner table
+--echo # of outer join is not applied as not being valid
--echo #
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (0),(2);
-
+
CREATE TABLE t2 (b INT);
INSERT INTO t2 VALUES (1),(2);
-
+
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
-
+
SELECT * FROM t1 LEFT JOIN t2 ON a = b WHERE b IS NULL;
SELECT * FROM t1 LEFT JOIN v2 ON a = b WHERE b IS NULL;
@@ -1650,26 +1076,26 @@ DROP TABLE t1;
CREATE TABLE t1 (pk1 INT PRIMARY KEY, a INT, b INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (10,7,1),(11,0,2);
-
+
CREATE TABLE t2 (pk2 INT PRIMARY KEY, c INT, d DATETIME) ENGINE=MyISAM;
-INSERT INTO t2 VALUES
+INSERT INTO t2 VALUES
(1,4,'2008-09-27 00:34:58'),
(2,5,'2007-05-28 00:00:00'),
(3,6,'2009-07-25 09:21:20');
-
+
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE ALGORITHM=TEMPTABLE VIEW v2 AS SELECT * FROM t2;
-SELECT * FROM v1 AS sq
+SELECT * FROM v1 AS sq
WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100;
EXPLAIN FORMAT=JSON
-SELECT * FROM v1 AS sq
+SELECT * FROM v1 AS sq
WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100;
-SELECT * FROM ( SELECT * FROM t1 ) AS sq
+SELECT * FROM ( SELECT * FROM t1 ) AS sq
WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100;
EXPLAIN FORMAT=JSON
-SELECT * FROM ( SELECT * FROM t1 ) AS sq
+SELECT * FROM ( SELECT * FROM t1 ) AS sq
WHERE b IN ( SELECT pk2 FROM v2 WHERE c > sq.b ) OR b = 100;
DROP VIEW v1,v2;
@@ -1729,7 +1155,7 @@ DROP TABLE t1,t2;
CREATE TABLE t (pk INT PRIMARY KEY, f INT) ENGINE=MyISAM;
CREATE ALGORITHM=TEMPTABLE VIEW v AS SELECT * FROM t;
INSERT INTO t VALUES (1,1),(3,2);
-
+
SELECT * FROM v AS v1, v AS v2
WHERE v2.pk > v1.f AND v1.f IN ( SELECT COUNT(pk) FROM t );
@@ -1871,10 +1297,10 @@ DROP TABLE t1;
CREATE TABLE t1 (c VARCHAR(3));
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES ('foo'),('bar');
-
+
CREATE TABLE t2 (c VARCHAR(3));
INSERT INTO t2 VALUES ('foo'),('xyz');
-
+
SELECT * FROM v1 WHERE v1.c IN ( SELECT MIN(c) FROM t2 WHERE 0 );
EXPLAIN FORMAT=JSON
SELECT * FROM v1 WHERE v1.c IN ( SELECT MIN(c) FROM t2 WHERE 0 );
@@ -1885,18 +1311,18 @@ DROP TABLE t1,t2;
CREATE TABLE t1 (d DECIMAL(10,2));
CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (5.37),(1.1);
-
+
CREATE TABLE t2 (d DECIMAL(10,2));
INSERT INTO t2 VALUES ('1.1'),('2.23');
-
+
SELECT * FROM v1 WHERE v1.d IN ( SELECT MIN(d) FROM t2 WHERE 0 );
DROP VIEW v1;
DROP TABLE t1,t2;
--echo #
---echo # MDEV-11820: second execution of PS for query
---echo # with false subquery predicate in WHERE
+--echo # MDEV-11820: second execution of PS for query
+--echo # with false subquery predicate in WHERE
--echo #
CREATE TABLE t1 (c VARCHAR(3)) ENGINE=MyISAM;
@@ -1905,10 +1331,10 @@ CREATE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
CREATE TABLE t2 (a INT);
INSERT INTO t2 VALUES (3), (4);
-PREPARE stmt1 FROM
+PREPARE stmt1 FROM
" SELECT * FROM v1 WHERE 1 IN (SELECT a FROM t2) OR c = 'foo'";
-PREPARE stmt2 FROM
-"EXPLAIN FORMAT=JSON
+PREPARE stmt2 FROM
+"EXPLAIN FORMAT=JSON
SELECT * FROM v1 WHERE 1 IN (SELECT a FROM t2) OR c = 'foo'";
EXECUTE stmt1;
EXECUTE stmt2;
@@ -1921,14 +1347,14 @@ INSERT INTO t2 SELECT a+1 FROM t2;
EXECUTE stmt1;
EXECUTE stmt2;
DEALLOCATE PREPARE stmt1;
-# the result here will change after the merge with the fix for mdev-11859
+# the result here will change after the merge with the fix for mdev-11859
DEALLOCATE PREPARE stmt2;
DROP VIEW v1;
DROP TABLE t1,t2;
--echo #
---echo # MDEV-12373: pushdown into derived with side effects is prohibited
+--echo # MDEV-12373: pushdown into derived with side effects is prohibited
--echo #
CREATE TABLE sales_documents (
@@ -1946,9 +1372,9 @@ CREATE TABLE sales_documents (
PRIMARY KEY (id)
);
-INSERT INTO sales_documents
-(id, sale_id, type, order_number, data, created_at,
- updated_at, date, generated, synced_at, sum)
+INSERT INTO sales_documents
+(id, sale_id, type, order_number, data, created_at,
+ updated_at, date, generated, synced_at, sum)
VALUES
(555, 165, 3, 5, '{}', 1486538300, 1486722835, '2017-02-17', 0, 1486538313, 2320.00),
(556, 165, 2, 3, '{}', 1486538304, 1486563125, '2017-02-08', 1, 1486538302, 2320.00),
@@ -2024,11 +1450,11 @@ SELECT * FROM
GROUP BY t.order_number
) a, (SELECT @row := 0) r) t
WHERE row <> order_number;
-
+
DROP TABLE sales_documents;
--echo #
---echo # MDEV-12845: pushdown from merged derived using equalities
+--echo # MDEV-12845: pushdown from merged derived using equalities
--echo #
create table t1 (a int);
@@ -2414,20 +1840,829 @@ eval $query;
eval EXPLAIN FORMAT=JSON $query;
DROP TABLE t1;
-# Start of 10.3 tests
+--echo #
+--echo # MDEV-15087: error from inexpensive subquery before check
+--echo # for condition pushdown into derived
+--echo #
+
+CREATE TABLE t1 (i1 int, v1 varchar(1));
+INSERT INTO t1 VALUES (7,'x');
+
+CREATE TABLE t2 (i1 int);
+INSERT INTO t2 VALUES (8);
+
+CREATE TABLE t3 (i1 int ,v1 varchar(1), v2 varchar(1));
+INSERT INTO t3 VALUES (4, 'v','v'),(62,'v','k'),(7, 'n', NULL);
+
+--error ER_SUBQUERY_NO_1_ROW
+SELECT 1
+FROM (t1 AS a1
+ JOIN (((SELECT DISTINCT t3.*
+ FROM t3) AS a2
+ JOIN t1 ON (t1.v1 = a2.v2))) ON (t1.v1 = a2.v1))
+WHERE (SELECT BIT_COUNT(t2.i1)
+ FROM (t2 JOIN t3)) IS NULL;
+
+DROP TABLE t1, t2, t3;
+
+--echo #
+--echo # MDEV-16614 signal 7 after calling stored procedure, that uses regexp
+--echo #
+
+DELIMITER $$;
+CREATE PROCEDURE p1(m1 varchar(5), m2 varchar(5))
+BEGIN
+SELECT a FROM
+ (SELECT "aa" a) t
+ JOIN (SELECT "aa" b) t1 on t.a=t1.b
+WHERE t.a regexp m1 and t1.b regexp m2
+GROUP BY a;
+END$$
+DELIMITER ;$$
+CALL p1('a','a');
+DROP PROCEDURE p1;
+
+
+DELIMITER $$;
+CREATE PROCEDURE p1(m1 varchar(5))
+BEGIN
+ SELECT a FROM (SELECT "aa" a) t WHERE t.a regexp m1;
+END$$
+DELIMITER ;$$
+CALL p1('a');
+DROP PROCEDURE p1;
+
+
+SELECT a FROM (SELECT "aa" a) t WHERE REGEXP_INSTR(t.a, (SELECT MAX('aa') FROM DUAL LIMIT 1));
+
+
+DELIMITER $$;
+CREATE OR REPLACE FUNCTION f1(a VARCHAR(10), b VARCHAR(10)) RETURNS INT
+BEGIN
+ RETURN 1;
+END;$$
+CREATE OR REPLACE PROCEDURE p1(m1 varchar(5))
+BEGIN
+ SELECT a FROM (SELECT "aa" a) t WHERE f1(t.a, m1);
+END$$
+DELIMITER ;$$
+CALL p1('a');
+DROP PROCEDURE p1;
+DROP FUNCTION f1;
+
+
+DELIMITER $$;
+CREATE OR REPLACE FUNCTION f1(a VARCHAR(10), b VARCHAR(10)) RETURNS INT
+BEGIN
+ RETURN 1;
+END;$$
+DELIMITER ;$$
+SELECT a FROM (SELECT "aa" a) t WHERE f1(t.a, (SELECT MAX('aa') FROM DUAL LIMIT 1));
+DROP FUNCTION f1;
+
+--echo #
+--echo # MDEV-17011: condition pushdown into materialized derived used
+--echo # in INSERT SELECT, multi-table UPDATE and DELETE
+--echo #
+
+CREATE TABLE t1 (a int ,b int) ENGINE=MyISAM;
+INSERT INTO t1 VALUES
+ (1, 1), (1, 2), (2, 1), (2, 2), (3,1), (3,3), (4,2);
+
+CREATE TABLE t2 (a int) ENGINE MYISAM;
+INSERT INTO t2 VALUES
+ (3), (7), (1), (4), (1);
+
+CREATE TABLE t3 (a int, b int) ENGINE MYISAM;
+
+let $q1=
+INSERT INTO t3
+SELECT * FROM (SELECT a, count(*) as c FROM t1 GROUP BY a) t WHERE a<=2;
+
+eval EXPLAIN FORMAT=JSON $q1;
+eval $q1;
+
+SELECT * FROM t3;
+
+let $q2=
+UPDATE t2, (SELECT a, count(*) as c FROM t1 GROUP BY a) t SET t2.a=t.c+10
+ WHERE t2.a= t.c and t.a>=3;
+
+eval EXPLAIN FORMAT=JSON $q2;
+eval $q2;
+
+SELECT * FROM t2;
+
+let $q3=
+DELETE t2 FROM t2, (SELECT a, count(*) as c FROM t1 GROUP BY a) t
+ WHERE t2.a= t.c+9 and t.a=2;
+
+eval EXPLAIN FORMAT=JSON $q3;
+eval $q3;
+
+SELECT * FROM t2;
+
+DROP TABLE t1,t2,t3;
+
+--echo #
+--echo # MDEV-16765: pushdown condition with the CASE structure
+--echo # defined with Item_cond item
+--echo #
+
+CREATE TABLE t1(a INT, b INT);
+INSERT INTO t1 VALUES (1,2), (3,4), (2,3);
+
+LET $query=
+SELECT *
+FROM
+(
+ SELECT CASE WHEN ((tab2.max_a=1) OR (tab2.max_a=2))
+ THEN 1 ELSE 0 END AS max_a,b
+ FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+EVAL $query;
+EVAL EXPLAIN FORMAT=JSON $query;
+
+LET $query=
+SELECT *
+FROM
+(
+ SELECT CASE WHEN ((tab2.max_a=1) OR ((tab2.max_a>2) AND (tab2.max_a<4)))
+ THEN 1 ELSE 0 END AS max_a,b
+ FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+EVAL $query;
+EVAL EXPLAIN FORMAT=JSON $query;
+
+LET $query=
+SELECT *
+FROM
+(
+ SELECT CASE WHEN ((tab2.max_a>1) AND ((tab2.max_a=2) OR (tab2.max_a>2)))
+ THEN 1 ELSE 0 END AS max_a,b
+ FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+EVAL $query;
+EVAL EXPLAIN FORMAT=JSON $query;
+
+LET $query=
+SELECT *
+FROM
+(
+ SELECT CASE WHEN ((tab2.b=2) OR (tab2.b=4))
+ THEN 1 ELSE 0 END AS max_a,b
+ FROM (SELECT MAX(a) as max_a,b FROM t1 GROUP BY t1.b) AS tab2
+) AS tab1
+WHERE (tab1.max_a=1);
+EVAL $query;
+EVAL EXPLAIN FORMAT=JSON $query;
+
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-16803: pushdown condition with IN predicate in the derived table
+--echo # defined with several SELECT statements
+--echo #
+
+CREATE TABLE t1 (a INT, b INT);
+INSERT INTO t1 VALUES (1,2),(3,2),(1,1);
+
+SELECT * FROM
+(
+ SELECT a,b,1 as c
+ FROM t1
+ UNION ALL
+ SELECT a,b,2 as c
+ FROM t1
+) AS tab
+WHERE ((a,b) IN ((1,2),(3,2)));
+
+DROP TABLE t1;
--echo #
---echo # MDEV-10855: Pushdown into derived with window functions
+--echo # MDEV-17354: INSERT SELECT with condition pushdown into derived
+--echo #
+
+CREATE TABLE t1 (f INT NOT NULL);
+INSERT INTO t1 VALUES (3), (7), (3);
+
+CREATE ALGORITHM= TEMPTABLE VIEW v1 AS SELECT * FROM ( SELECT * FROM t1 ) AS sq;
+
+let $q1=
+INSERT INTO t1
+SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ) AS t WHERE f IS NOT NULL;
+
+eval $q1;
+eval EXPLAIN $q1;
+eval EXPLAIN FORMAT=JSON $q1;
+SELECT * FROM t1;
+
+DELETE FROM t1;
+INSERT INTO t1 VALUES (3), (7), (3);
+
+let $q2=
+INSERT INTO t1
+SELECT * FROM ( SELECT t1.f FROM v1 JOIN t1 ON v1.f=t1.f) AS t
+ WHERE f IS NOT NULL;
+
+eval $q2;
+eval EXPLAIN FORMAT=JSON $q2;
+SELECT * FROM t1;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+--echo # End of 10.2 tests
+
+--echo #
+--echo # MDEV-14579: pushdown conditions into materialized views/derived tables
+--echo # that are defined with EXIST or/and INTERSECT
+--echo #
+
+create table t1 (a int, b int, c int);
+create table t2 (a int, b int, c int);
+
+insert into t1 values
+ (1,21,345), (1,33,7), (8,33,114), (1,21,500), (1,19,117), (5,14,787),
+ (8,33,123), (9,10,211), (5,16,207), (1,33,988), (5,27,132), (1,21,104),
+ (6,20,309), (6,20,315), (1,21,101), (4,33,404), (9,10,800), (1,21,123);
+
+insert into t2 values
+ (2,3,207), (1,16,909), (5,14,312),
+ (5,33,207), (6,20,211), (1,19,132),
+ (8,33,117), (3,21,231), (6,23,303);
+
+create view v1 as
+ select a, b, min(c) as c from t1
+ where t1.a<9 group by a,b having c < 300
+ intersect
+ select a, b, min(c) as c from t1
+ where t1.b>10 group by a,b having c > 100;
+
+--echo # using intersect in view definition
+--echo # conjunctive subformulas : pushing into WHERE
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<5);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using intersect in view definition
+--echo # conjunctive subformulas : pushing into WHERE
+--echo # pushing equalities
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a=8);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using intersect in view definition
+--echo # conjunctive subformulas : pushing into WHERE using equalities
+let $query= select * from v1,t2 where (v1.a=t2.a) and (t2.a=8);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using intersect in view definition
+--echo # conjunctive subformulas : pushing into HAVING
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.c>200);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using intersect in view definition
+--echo # conjunctive subformulas : pushing into WHERE
+--echo # conjunctive subformulas : pushing into HAVING
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<5) and (v1.c>110);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using intersect in view definition
+--echo # extracted or formula : pushing into WHERE
+let $query=
+ select * from v1,t2 where (v1.a=t2.a) and ((v1.b>27) or (v1.b<19));
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using intersect in view definition
+--echo # extracted or formula : pushing into HAVING
+let $query=
+ select * from v1,t2 where
+ (v1.a=t2.a) and ((v1.c>200) or (v1.c<105));
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using intersect in view definition
+--echo # extracted or formula : pushing into WHERE
+--echo # extracted or formula : pushing into HAVING using equalities
+--echo # pushing equalities
+let $query=
+ select * from v1,t2 where
+ ((v1.a>3) and (t2.c>110) and (v1.c=t2.c)) or
+ ((v1.a=1) and (v1.c<110));
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using intersect in view definition
+--echo # prepare of a query
+--echo # conjunctive subformulas : pushing into WHERE
+--echo # conjunctive subformulas : pushing into HAVING
+prepare stmt from "select * from v1,t2
+ where (v1.a=t2.a) and (v1.a<5) and (v1.c>110);";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+--echo # using intersect in derived table definition
+--echo # extracted or formula : pushing into WHERE using equalities
+--echo # extracted or formula : pushing into HAVING
+--echo # pushing equalities
+let $query=
+ select *
+ from t2,
+ (select a, b, min(c) as c from t1
+ where t1.a<9 group by a,b having c < 300
+ intersect
+ select a, b, min(c) as c from t1
+ where t1.b>10 group by a,b having c > 100) as d1
+ where
+ (d1.b=t2.b) and
+ (((t2.b>13) and (t2.c=909)) or
+ ((d1.a<4) and (d1.c<200)));
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+create view v1 as
+ select a, b, max(c) as c from t1
+ where t1.a<9 group by a,b having c > 200
+ except
+ select a, b, max(c) as c from t1
+ where t1.b>10 group by a,b having c < 300;
+
+--echo # using except in view definition
+--echo # conjunctive subformulas : pushing into WHERE
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<5);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using except in view definition
+--echo # conjunctive subformulas : pushing into WHERE
+--echo # pushing equalities
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a=6);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using except in view definition
+--echo # conjunctive subformulas : pushing into WHERE using equalities
+let $query= select * from v1,t2 where (v1.a=t2.a) and (t2.a=6);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using except in view definition
+--echo # conjunctive subformulas : pushing into HAVING
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.c>500);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using except in view definition
+--echo # conjunctive subformulas : pushing into WHERE
+--echo # conjunctive subformulas : pushing into HAVING
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<5) and (v1.c>500);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using except in view definition
+--echo # extracted or formula : pushing into WHERE
+let $query=
+ select * from v1,t2 where (v1.a=t2.a) and ((v1.b>27) or (v1.b<19));
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using except in view definition
+--echo # extracted or formula : pushing into HAVING
+let $query=
+ select * from v1,t2 where
+ (v1.a=t2.a) and ((v1.c<400) or (v1.c>800));
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using except in view definition
+--echo # extracted or formula : pushing into WHERE
+--echo # extracted or formula : pushing into HAVING using equalities
+--echo # pushing equalities
+let $query=
+ select * from v1,t2 where
+ (v1.c=t2.c) and
+ ((v1.a>1) and (t2.c<500)) or
+ ((v1.a=1) and (v1.c>500));
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+--echo # using except in view definition
+--echo # prepare of a query
+--echo # conjunctive subformulas : pushing into WHERE
+--echo # conjunctive subformulas : pushing into HAVING
+prepare stmt from "select * from v1,t2
+ where (v1.a=t2.a) and (v1.a<5) and (v1.c>500);";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+--echo # using except in view definition
+--echo # extracted or formula : pushing into WHERE using equalities
+--echo # extracted or formula : pushing into HAVING
+--echo # pushing equalities
+let $query=
+ select *
+ from t2,
+ (select a, b, max(c) as c from t1
+ where t1.a<9 group by a,b having c > 200
+ except
+ select a, b, max(c) as c from t1
+ where t1.b>10 group by a,b having c < 300) as d1
+ where
+ (d1.b=t2.b) and
+ (((t2.b>13) and (t2.c=988)) or
+ ((d1.a>4) and (d1.c>500)));
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+--echo # using union and intersect in view definition
+--echo # conjunctive subformulas : pushing into WHERE and HAVING
+create view v1 as
+ select a, b, min(c) as c from t1
+ where t1.a<9 group by a,b having c > 200
+ union
+ select a, b, max(c) as c from t1
+ where t1.b>10 group by a,b having c < 300
+ intersect
+ select a, b, max(c) as c from t1
+ where t1.a>3 group by a,b having c < 530;
+
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>5) and (v1.c>200);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+--echo # using union and intersect in view definition
+--echo # conjunctive subformulas : pushing into WHERE and HAVING
+create view v1 as
+ select a, b, min(c) as c from t1
+ where t1.a<9 group by a,b having c > 200
+ intersect
+ select a, b, max(c) as c from t1
+ where t1.a>3 group by a,b having c < 500
+ union
+ select a, b, max(c) as c from t1
+ where t1.b>10 group by a,b having c < 300;
+
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<200);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+--echo # using union and except in view definition
+--echo # conjunctive subformulas : pushing into WHERE and HAVING
+create view v1 as
+ select a, b, min(c) as c from t1
+ where t1.a<9 group by a,b having c > 200
+ union
+ select a, b, max(c) as c from t1
+ where t1.b>10 group by a,b having c < 300
+ except
+ select a, b, max(c) as c from t1
+ where t1.a>3 group by a,b having c < 530;
+
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>5) and (v1.c>200);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+--echo # using union and except in view definition
+--echo # conjunctive subformulas : pushing into WHERE and HAVING
+create view v1 as
+ select a, b, min(c) as c from t1
+ where t1.a<9 group by a,b having c > 200
+ except
+ select a, b, max(c) as c from t1
+ where t1.a>3 group by a,b having c < 500
+ union
+ select a, b, max(c) as c from t1
+ where t1.b>10 group by a,b having c < 300;
+
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<200);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+--echo # using except and intersect in view definition
+--echo # conjunctive subformulas : pushing into WHERE and HAVING
+create view v1 as
+ select a, b, max(c) as c from t1
+ where t1.b>10 group by a,b having c < 300
+ intersect
+ select a, b, max(c) as c from t1
+ where t1.a<7 group by a,b having c < 500
+ except
+ select a, b, max(c) as c from t1
+ where t1.a<9 group by a,b having c > 150;
+
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<150);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+--echo # using except and intersect in view definition
+--echo # conjunctive subformulas : pushing into WHERE and HAVING
+create view v1 as
+ select a, b, max(c) as c from t1
+ where t1.b>10 group by a,b having c < 300
+ except
+ select a, b, max(c) as c from t1
+ where t1.a<9 group by a,b having c > 150
+ intersect
+ select a, b, max(c) as c from t1
+ where t1.a<7 group by a,b having c < 500;
+
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<130);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+--echo # using except, intersect and union in view definition
+--echo # conjunctive subformulas : pushing into WHERE and HAVING
+create view v1 as
+ select a, b, max(c) as c from t1
+ where t1.b>10 group by a,b having c < 300
+ except
+ select a, b, max(c) as c from t1
+ where t1.a<9 group by a,b having c > 150
+ intersect
+ select a, b, max(c) as c from t1
+ where t1.a<7 group by a,b having c < 500
+ union
+ select a, b, max(c) as c from t1
+ where t1.a<7 group by a,b having c < 120;
+
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.c<130);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+--echo # using intersect in view definition
+--echo # using embedded view
+--echo # conjunctive subformulas : pushing into WHERE and HAVING
+create view v1 as
+ select a, b, max(c) as c from t1
+ where t1.b>10 group by a,b having c < 300
+ intersect
+ select a, b, max(c) as c from t1
+ where t1.a<9 group by a,b having c > 120;
+
+create view v2 as
+ select a, b, max(c) as c from v1
+ where v1.a<7 group by a,b;
+
+let $query= select * from v2,t2 where (v2.a=t2.a) and (v2.a>4) and (v2.c<150);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1,v2;
+
+--echo # using except in view definition
+--echo # using embedded view
+--echo # conjunctive subformulas : pushing into WHERE and HAVING
+create view v1 as
+ select a, b, max(c) as c from t1
+ where t1.b>10 group by a,b having c < 300
+ except
+ select a, b, max(c) as c from t1
+ where t1.a<9 group by a,b having c > 150;
+
+create view v2 as
+ select a, b, max(c) as c from v1
+ where v1.a<7 group by a,b;
+
+let $query= select * from v2,t2 where (v2.a=t2.a) and (v2.a>4) and (v2.c<150);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1,v2;
+
+--echo # using intersect in view definition
+--echo # conditions are pushed in different parts of selects
+--echo # conjunctive subformulas : pushing into WHERE and HAVING
+create view v1 as
+ select a, b, max(c) as c from t1
+ where t1.a<9 group by a having c > 300
+ intersect
+ select a, b, max(c) as c from t1
+ where t1.b<21 group by b having c > 200;
+
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>4) and (v1.b>12) and (v1.c<450);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+--echo # using except in view definition
+--echo # conditions are pushed in different parts of selects
+--echo # conjunctive subformulas : pushing into WHERE and HAVING
+create view v1 as
+ select a, b, max(c) as c from t1
+ where t1.b>20 group by a having c > 300
+ except
+ select a, b, max(c) as c from t1
+ where t1.a<7 group by b having c > 150;
+
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a<2) and (v1.b<30) and (v1.c>450);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+--echo # using except and union in view definition
+--echo # conditions are pushed in different parts of selects
+--echo # conjunctive subformulas : pushing into HAVING
+--echo # extracted or formula : pushing into WHERE
+--echo # extracted or formula : pushing into HAVING
+create view v1 as
+ select a, b, max(c) as c from t1
+ where t1.b>20 group by a having c > 300
+ except
+ select a, b, max(c) as c from t1
+ where t1.a<7 group by b having c > 150;
+
+let $query= select * from v1,t2 where (v1.a=t2.a) and ((v1.a<2) or (v1.a<5)) and (v1.c>450);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+--echo # using union and intersect in view definition
+--echo # conditions are pushed in different parts of selects
+--echo # conjunctive subformulas : pushing into WHERE and HAVING
+create view v1 as
+ select a, b, max(c) as c from t1
+ where t1.a<9 group by a having c > 100
+ intersect
+ select a, b, max(c) as c from t1
+ where t1.a>3 group by b having c < 800
+ union
+ select a, b, max(c) as c from t1
+ where t1.b>10 group by a,b having c > 300;
+
+let $query= select * from v1,t2 where (v1.a=t2.a) and (v1.a>1) and (v1.b > 12) and (v1.c>400);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+create table t3 (a int, b int, c int);
+insert into t3 values
+ (1,21,345), (2,33,7), (8,33,114), (3,21,500), (1,19,107), (5,14,787),
+ (4,33,123), (9,10,211), (11,16,207), (10,33,988), (5,27,132), (12,21,104),
+ (6,20,309), (16,20,315), (16,21,101), (18,33,404), (19,10,800), (10,21,123),
+ (17,11,708), (6,20,214);
+
+create index i1 on t3(a);
+
+--echo # conjunctive subformulas : pushing into WHERE
+--echo # pushed condition gives range access
+create view v1 as
+ select a, b, max(c) as max_c from t3
+ where a>0 group by a;
+
+let $query= select * from v1,t2 where (v1.b=t2.b) and (v1.a<5);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+--echo # using union in view definition
+--echo # conjunctive subformulas : pushing into WHERE
+--echo # pushed condition gives range access
+create view v1 as
+ select a, b, max(c) as c from t3
+ where t3.a>1 group by a
+ union
+ select a, b, max(c) as c from t3
+ where t3.a>2 group by a;
+
+let $query= select * from v1,t2 where (v1.b=t2.b) and (v1.a<4);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+--echo # using union in view definition
+--echo # conjunctive subformulas : pushing into WHERE
+--echo # pushed condition gives range access in one of the selects
+create view v1 as
+ select a, b, max(c) as c from t3
+ where t3.a>1 group by a
+ union
+ select a, b, max(c) as c from t3
+ where t3.b<21 group by b;
+
+let $query= select * from v1,t2 where (v1.b=t2.b) and (v1.a<3);
+eval $no_pushdown $query;
+eval $query;
+eval explain $query;
+eval explain format=json $query;
+
+drop view v1;
+
+alter table t3 drop index i1;
+
+drop table t1,t2,t3;
+
+--echo #
+--echo # MDEV-10855: Pushdown into derived with window functions
--echo #
set @save_optimizer_switch= @@optimizer_switch;
set optimizer_switch='split_materialized=off';
-
+
create table t1 (a int, c varchar(16));
insert into t1 values
(8,'aa'), (5,'cc'), (1,'bb'), (2,'aa'), (9,'cc'),
(7,'aa'), (2,'aa'), (7,'bb');
-
+
create table t2 (a int, b int, c varchar(16), index idx(a,c));
insert into t2 values
(7,10,'cc'), (1,20,'aa'), (2,23,'bb'), (7,18,'cc'), (1,30,'bb'),
@@ -2439,27 +2674,31 @@ let $q1=
select * from (select a, c, sum(b) over (partition by a,c) from t2) as t
where t.a > 2 and t.c in ('aa','bb','cc');
+--sorted_result
eval $no_pushdown $q1;
+--sorted_result
eval $q1;
eval explain $q1;
eval explain format=json $q1;
let $q2=
select * from
-(
+(
select 1 as n, a, c, sum(b) over (partition by a,c) as s from t2
union all
select 2 as n, a, c, sum(b) over (partition by a) as s from t2
) as t
where t.a > 2 and t.c in ('aa','bb','cc');
+--sorted_result
eval $no_pushdown $q2;
+--sorted_result
eval $q2;
eval explain $q2;
eval explain format=json $q2;
let $q3=
-select *
+select *
from (select a, c, sum(b) over (partition by a,c) as s from t2) as t, t1
where t1.a=t.a and t1.c=t.c and t1.c in ('aa','bb','cc');
@@ -2467,10 +2706,10 @@ eval $no_pushdown $q3;
eval $q3;
eval explain $q3;
eval explain format=json $q3;
-
+
let $q4=
select * from
-(
+(
select 1 as n, a, c, sum(b) over (partition by a,c) as s from t2
union all
select 2 as n, a, c, sum(b) over (partition by a) as s from t2
@@ -2479,7 +2718,9 @@ select * from
) as t
where t.a > 2 and t.c in ('aa','bb','cc');
+--sorted_result
eval $no_pushdown $q4;
+--sorted_result
eval $q4;
eval explain $q4;
eval explain format=json $q4;
@@ -2491,7 +2732,9 @@ select * from (select a, c,
from t2 ) as t
where t.a > 2 and t.c in ('aa','bb','cc');
+--sorted_result
eval $no_pushdown $q5;
+--sorted_result
eval $q5;
eval explain $q5;
eval explain format=json $q5;
@@ -2503,7 +2746,9 @@ select * from (select a, c,
from t2 ) as t
where t.a > 2 and t.c in ('aa','bb','cc');
+--sorted_result
eval $no_pushdown $q6;
+--sorted_result
eval $q6;
eval explain $q6;
eval explain format=json $q6;
@@ -2515,7 +2760,9 @@ select * from (select a, c,
from t2 ) as t
where t.a > 2 and t.c in ('aa','bb','cc');
+--sorted_result
eval $no_pushdown $q7;
+--sorted_result
eval $q7;
eval explain $q7;
eval explain format=json $q7;
@@ -2525,14 +2772,14 @@ drop table t1,t2;
set optimizer_switch= @save_optimizer_switch;
--echo #
---echo # MDEV-13369: Optimization for equi-joins of grouping derived tables
+--echo # MDEV-13369: Optimization for equi-joins of grouping derived tables
--echo # (Splitting derived tables / views with GROUP BY)
--echo # MDEV-13389: Optimization for equi-joins of derived tables with WF
--echo # (Splitting derived tables / views with window functions)
--echo #
let
-$no_splitting= set statement optimizer_switch='split_materialized=off' for;
+$no_splitting= set statement optimizer_switch='split_materialized=off' for;
create table t1 (a int, b int, index idx_b(b)) engine=myisam;
insert into t1 values
@@ -2605,7 +2852,7 @@ insert into t3 values
(8,11,'aa'), (5,15,'cc'), (1,14,'bb'), (2,12,'aa'), (7,17,'cc'),
(7,18,'aa'), (2,11,'aa'), (7,10,'bb'), (3,11,'dd'), (4,12,'ee'),
(5,14,'dd'), (9,12,'ee');
-
+
create table t4 (a int, b int, c char(127), index idx(a,c)) engine=myisam;
insert into t4 values
(7,10,'cc'), (1,20,'aa'), (2,23,'bb'), (7,18,'cc'), (1,30,'bb'),
@@ -2627,7 +2874,7 @@ where t3.b > 15;
eval $no_splitting $q3;
eval $q3;
eval explain extended $q3;
-eval explain format=json $q3;
+eval explain format=json $q3;
let $q30=
select t3.a,t3.c,t.max,t.min
@@ -2639,7 +2886,7 @@ where t3.b <= 15;
eval $no_splitting $q30;
eval $q30;
eval explain extended $q30;
-eval explain format=json $q30;
+eval explain format=json $q30;
let $q4=
select t3.a,t3.c,t.max,t.min
@@ -2651,7 +2898,7 @@ where t3.b > 15;
eval $no_splitting $q4;
eval $q4;
eval explain extended $q4;
-eval explain format=json $q4;
+eval explain format=json $q4;
let $q40=
select t3.a,t3.c,t.max,t.min
@@ -2663,7 +2910,7 @@ where t3.b <= 15;
eval $no_splitting $q40;
eval $q40;
eval explain extended $q40;
-eval explain format=json $q40;
+eval explain format=json $q40;
drop index idx_a on t2;
create index idx on t2(c,b);
@@ -2681,7 +2928,9 @@ select t2.a,t2.b,t2.c,t.c as t_c,t.max,t.min
from t2, t3, (select c, max(b) max, min(b) min from t4 group by c) t
where t2.b between 80 and 85 and t2.c in ('y','z') and t2.a=t3.a and t3.c=t.c;
+--sorted_result
eval $no_splitting $q5;
+--sorted_result
eval $q5;
eval explain extended $q5;
eval explain format=json $q5;
@@ -2701,7 +2950,9 @@ select *
from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t
where t2.b between 80 and 85 and t2.c in ('y','z') and t2.a=t3.a and t3.c=t.c;
+--sorted_result
eval $no_splitting $q6;
+--sorted_result
eval $q6;
eval explain extended $q6;
eval explain format=json $q6;
@@ -2711,7 +2962,9 @@ select *
from t2, t3, (select c, b, sum(b) over (partition by c) from t4 ) t
where t2.b < 40 and t2.a=t3.a and t3.c=t.c;
+--sorted_result
eval $no_splitting $q60;
+--sorted_result
eval $q60;
eval explain extended $q60;
eval explain format=json $q60;
@@ -2879,6 +3132,7 @@ cte as (select median(f2) over (partition by f1) as k1 from t1 order by f1),
cte1 as (select median(f4) over (partition by f1) as k2 from t1)
select k1,k2 from cte1, cte;
+--sorted_result
eval $q;
eval explain $q;
@@ -2906,3 +3160,79 @@ SELECT * FROM ( SELECT STRAIGHT_JOIN f, COUNT(*) as c FROM v1 GROUP BY f ) AS s;
DROP VIEW v1;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-16801: splittable materialized derived/views with
+--echo # one grouping field from table without keys
+--echo #
+
+CREATE TABLE t1 (a int, b int, INDEX idx_a(a), INDEX idx_b(b)) ENGINE=MYISAM;
+CREATE TABLE t2 (c int) ENGINE=MYISAM;
+CREATE TABLE t3 (d int) ENGINE=MYISAM;
+INSERT INTO t1 VALUES
+ (77,7), (11,1), (33,3), (44,4), (8,88),
+ (78,7), (98,9), (38,3), (28,2), (79,7),
+ (58,5), (42,4), (71,7), (27,2), (91,9);
+INSERT INTO t1 SELECT a+100, b+10 FROM t1;
+INSERT INTO t2 VALUES
+ (100), (700), (200), (100), (200);
+INSERT INTO t3 VALUES
+ (3), (4), (1), (8), (3);
+
+ANALYZE tables t1,t2,t3;
+
+let $q=
+SELECT *
+ FROM t3,
+ (SELECT t1.b, t2.c
+ FROM t1, t2
+ GROUP BY t1.b,t2.c) dt
+WHERE t3.d = dt.b;
+
+eval $q;
+eval EXPLAIN EXTENDED $q;
+
+DROP TABLE t1,t2,t3;
+
+--echo #
+--echo # MDEV-17419: splittable materialized derived/view
+--echo # when join_cache_level = 4
+--echo #
+
+set join_cache_level = 4;
+
+CREATE TABLE t1 (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ username VARCHAR(50) NULL DEFAULT '0',
+ PRIMARY KEY (id)
+) COLLATE='utf8_general_ci';
+
+CREATE TABLE t2 (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT,
+ userid INT UNSIGNED NOT NULL,
+ logindate DATETIME NOT NULL,
+ PRIMARY KEY (id)
+) COLLATE='utf8_general_ci';
+
+INSERT INTO t1 (id, username) VALUES
+ (1,"user1"), (2, "user2");
+INSERT INTO t2 (id, userid, logindate) VALUES
+ (1,1,"2015-06-19 12:17:02.828"),
+ (2,1,"2016-06-19 12:17:02.828"),
+ (3,2,"2017-06-19 12:17:02.828"),
+ (4,2,"2018-06-19 12:17:02.828");
+
+let $q=
+select * from t1 as u
+ left join
+ (select * from t2 as au group by au.userid) as auditlastlogin
+ on u.id=auditlastlogin.userid;
+
+eval EXPLAIN $q;
+eval $q;
+
+set join_cache_level=default;
+
+DROP TABLE t1,t2;
+
+--echo # End of 10.3 tests
diff --git a/mysql-test/main/derived_opt.result b/mysql-test/main/derived_opt.result
index 6e4ea1b5d36..48ac7e62653 100644
--- a/mysql-test/main/derived_opt.result
+++ b/mysql-test/main/derived_opt.result
@@ -499,9 +499,45 @@ where
D1.a= t1.a;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 10 Using where
-1 PRIMARY <derived2> hash_ALL key0 #hash#key0 5 test.t1.a 100 Using join buffer (flat, BNLH join)
+1 PRIMARY <derived2> ref key0 key0 5 test.t1.a 10
2 DERIVED t2 ALL NULL NULL NULL NULL 100 Using filesort
set join_cache_level=@tmp_jcl;
set optimizer_switch=@tmp_os;
drop table t1, t2;
+#
+# Bug mdev-17382: equi-join of derived table with join_cache_level=4
+#
+CREATE TABLE t1 (
+id int NOT NULL,
+amount decimal DEFAULT NULL,
+PRIMARY KEY (id)
+);
+CREATE TABLE t2 (
+id int NOT NULL,
+name varchar(50) DEFAULT NULL,
+PRIMARY KEY (id)
+);
+INSERT INTO t1 VALUES
+(1, 10.0000), (2, 20.0000), (3, 30.0000), (4, 40.0000),
+(5, NULL), (6, NULL), (7, 70.0000), (8, 80.0000);
+INSERT INTO t2 VALUES
+(1,'A'), (2,'B'), (3,'C'), (4,'D'), (5, NULL), (6, NULL),
+(7,'E'), (8,'F'), (9,'G'), (10,'H'), (11, NULL), (12, NULL);
+set @save_optimizer_switch= @@optimizer_switch;
+set optimizer_switch='split_materialized=off';
+set join_cache_level=4;
+EXPLAIN
+SELECT t2.id,t2.name,t.total_amt
+FROM t2
+LEFT JOIN
+(SELECT id, sum(amount) total_amt FROM t1 GROUP BY id) AS t
+ON t2.id=t.id
+WHERE t2.id < 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 3 Using index condition
+1 PRIMARY <derived2> ref key0 key0 5 test.t2.id 2
+2 DERIVED t1 ALL NULL NULL NULL NULL 8 Using temporary; Using filesort
+set join_cache_level=default;
+set optimizer_switch= @save_optimizer_switch;
+DROP TABLE t1,t2;
set optimizer_switch=@exit_optimizer_switch;
diff --git a/mysql-test/main/derived_opt.test b/mysql-test/main/derived_opt.test
index 7f19553e4e5..eccf4c13020 100644
--- a/mysql-test/main/derived_opt.test
+++ b/mysql-test/main/derived_opt.test
@@ -363,5 +363,48 @@ set join_cache_level=@tmp_jcl;
set optimizer_switch=@tmp_os;
drop table t1, t2;
+--echo #
+--echo # Bug mdev-17382: equi-join of derived table with join_cache_level=4
+--echo #
+
+CREATE TABLE t1 (
+ id int NOT NULL,
+ amount decimal DEFAULT NULL,
+PRIMARY KEY (id)
+);
+
+CREATE TABLE t2 (
+ id int NOT NULL,
+ name varchar(50) DEFAULT NULL,
+PRIMARY KEY (id)
+);
+
+INSERT INTO t1 VALUES
+(1, 10.0000), (2, 20.0000), (3, 30.0000), (4, 40.0000),
+(5, NULL), (6, NULL), (7, 70.0000), (8, 80.0000);
+
+INSERT INTO t2 VALUES
+(1,'A'), (2,'B'), (3,'C'), (4,'D'), (5, NULL), (6, NULL),
+(7,'E'), (8,'F'), (9,'G'), (10,'H'), (11, NULL), (12, NULL);
+
+set @save_optimizer_switch= @@optimizer_switch;
+set optimizer_switch='split_materialized=off';
+
+set join_cache_level=4;
+
+EXPLAIN
+SELECT t2.id,t2.name,t.total_amt
+ FROM t2
+ LEFT JOIN
+ (SELECT id, sum(amount) total_amt FROM t1 GROUP BY id) AS t
+ ON t2.id=t.id
+ WHERE t2.id < 3;
+
+set join_cache_level=default;
+
+set optimizer_switch= @save_optimizer_switch;
+
+DROP TABLE t1,t2;
+
# The following command must be the last one the file
set optimizer_switch=@exit_optimizer_switch;
diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result
new file mode 100644
index 00000000000..21dbd494e4b
--- /dev/null
+++ b/mysql-test/main/derived_split_innodb.result
@@ -0,0 +1,101 @@
+#
+# MDEV-16917: do not use splitting for derived with join cache
+#
+CREATE TABLE t1 (
+n1 int(10) NOT NULL,
+n2 int(10) NOT NULL,
+c1 char(1) NOT NULL,
+KEY c1 (c1),
+KEY n1_c1_n2 (n1,c1,n2)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (0, 2, 'a'), (1, 3, 'a');
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+EXPLAIN SELECT t1.n1 FROM t1, (SELECT n1, n2 FROM t1 WHERE c1 = 'a' GROUP BY n1) as t
+WHERE t.n1 = t1.n1 AND t.n2 = t1.n2 AND c1 = 'a' GROUP BY n1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index c1,n1_c1_n2 n1_c1_n2 9 NULL 2 Using where; Using index
+1 PRIMARY <derived2> ref key0 key0 8 test.t1.n1,test.t1.n2 2
+2 LATERAL DERIVED t1 ref c1,n1_c1_n2 n1_c1_n2 4 test.t1.n1 1 Using where; Using index
+SELECT t1.n1 FROM t1, (SELECT n1, n2 FROM t1 WHERE c1 = 'a' GROUP BY n1) as t
+WHERE t.n1 = t1.n1 AND t.n2 = t1.n2 AND c1 = 'a' GROUP BY n1;
+n1
+0
+1
+DROP TABLE t1;
+#
+# MDEV-17211: splittable materialized derived joining 3 tables with
+# GROUP BY list containing fields from 2 of them
+#
+CREATE TABLE t1 (
+id1 int, i1 int, id2 int,
+PRIMARY KEY (id1), KEY (i1), KEY (id2)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,1,1);
+CREATE TABLE t2 (id2 int, i2 int) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1, 1);
+CREATE TABLE t3 (id3 int, i3 int, PRIMARY KEY (id3)) ENGINE=InnoDB;
+INSERT INTO t3 VALUES (1,1);
+EXPLAIN SELECT id3
+FROM (SELECT t3.id3, t2.i2, t1.id2 FROM t3,t1,t2
+WHERE t3.i3=t1.id1 AND t2.id2=t1.id2
+GROUP BY t3.id3, t1.id2) AS t,
+t2
+WHERE t2.id2=t.id2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 ALL NULL NULL NULL NULL 1 Using where
+1 PRIMARY <derived2> ref key0 key0 5 test.t2.id2 2
+2 DERIVED t3 ALL NULL NULL NULL NULL 1 Using where; Using temporary; Using filesort
+2 DERIVED t1 eq_ref PRIMARY,id2 PRIMARY 4 test.t3.i3 1
+2 DERIVED t2 ALL NULL NULL NULL NULL 1 Using where; Using join buffer (flat, BNL join)
+SELECT id3
+FROM (SELECT t3.id3, t2.i2, t1.id2 FROM t3,t1,t2
+WHERE t3.i3=t1.id1 AND t2.id2=t1.id2
+GROUP BY t3.id3, t1.id2) AS t,
+t2
+WHERE t2.id2=t.id2;
+id3
+1
+DROP TABLE t1,t2,t3;
+#
+# Bug mdev-17381: equi-join of derived table with join_cache_level=4
+#
+CREATE TABLE t1 (
+id int NOT NULL,
+amount decimal DEFAULT NULL,
+PRIMARY KEY (id)
+) ENGINE=INNODB;
+CREATE TABLE t2 (
+id int NOT NULL,
+name varchar(50) DEFAULT NULL,
+PRIMARY KEY (id)
+) ENGINE=INNODB;
+INSERT INTO t1 VALUES
+(1, 10.0000), (2, 20.0000), (3, 30.0000), (4, 40.0000),
+(5, NULL), (6, NULL), (7, 70.0000), (8, 80.0000);
+INSERT INTO t2 VALUES
+(1,'A'), (2,'B'), (3,'C'), (4,'D'), (5, NULL), (6, NULL),
+(7,'E'), (8,'F'), (9,'G'), (10,'H'), (11, NULL), (12, NULL);
+set join_cache_level=4;
+SELECT t2.id,t2.name,t.total_amt
+FROM t2
+LEFT JOIN
+(SELECT id, sum(amount) total_amt FROM t1 GROUP BY id) AS t
+ON t2.id=t.id
+WHERE t2.id < 3;
+id name total_amt
+1 A 10
+2 B 20
+EXPLAIN SELECT t2.id,t2.name,t.total_amt
+FROM t2
+LEFT JOIN
+(SELECT id, sum(amount) total_amt FROM t1 GROUP BY id) AS t
+ON t2.id=t.id
+WHERE t2.id < 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 range PRIMARY PRIMARY 4 NULL 2 Using where
+1 PRIMARY <derived2> ref key0 key0 5 test.t2.id 2
+2 LATERAL DERIVED t1 eq_ref PRIMARY PRIMARY 4 test.t2.id 1
+set join_cache_level=default;
+DROP TABLE t1,t2;
diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test
new file mode 100644
index 00000000000..c3b3bcabede
--- /dev/null
+++ b/mysql-test/main/derived_split_innodb.test
@@ -0,0 +1,96 @@
+--source include/have_innodb.inc
+
+--echo #
+--echo # MDEV-16917: do not use splitting for derived with join cache
+--echo #
+
+CREATE TABLE t1 (
+ n1 int(10) NOT NULL,
+ n2 int(10) NOT NULL,
+ c1 char(1) NOT NULL,
+ KEY c1 (c1),
+ KEY n1_c1_n2 (n1,c1,n2)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (0, 2, 'a'), (1, 3, 'a');
+
+ANALYZE TABLE t1;
+
+Let $q=
+SELECT t1.n1 FROM t1, (SELECT n1, n2 FROM t1 WHERE c1 = 'a' GROUP BY n1) as t
+ WHERE t.n1 = t1.n1 AND t.n2 = t1.n2 AND c1 = 'a' GROUP BY n1;
+
+eval EXPLAIN $q;
+eval $q;
+
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-17211: splittable materialized derived joining 3 tables with
+--echo # GROUP BY list containing fields from 2 of them
+--echo #
+
+CREATE TABLE t1 (
+ id1 int, i1 int, id2 int,
+ PRIMARY KEY (id1), KEY (i1), KEY (id2)
+) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1,1,1);
+
+CREATE TABLE t2 (id2 int, i2 int) ENGINE=InnoDB;
+INSERT INTO t2 VALUES (1, 1);
+
+CREATE TABLE t3 (id3 int, i3 int, PRIMARY KEY (id3)) ENGINE=InnoDB;
+INSERT INTO t3 VALUES (1,1);
+
+let $q=
+SELECT id3
+ FROM (SELECT t3.id3, t2.i2, t1.id2 FROM t3,t1,t2
+ WHERE t3.i3=t1.id1 AND t2.id2=t1.id2
+ GROUP BY t3.id3, t1.id2) AS t,
+ t2
+ WHERE t2.id2=t.id2;
+
+eval EXPLAIN $q;
+eval $q;
+
+DROP TABLE t1,t2,t3;
+
+--echo #
+--echo # Bug mdev-17381: equi-join of derived table with join_cache_level=4
+--echo #
+
+CREATE TABLE t1 (
+ id int NOT NULL,
+ amount decimal DEFAULT NULL,
+PRIMARY KEY (id)
+) ENGINE=INNODB;
+
+CREATE TABLE t2 (
+ id int NOT NULL,
+ name varchar(50) DEFAULT NULL,
+PRIMARY KEY (id)
+) ENGINE=INNODB;
+
+INSERT INTO t1 VALUES
+(1, 10.0000), (2, 20.0000), (3, 30.0000), (4, 40.0000),
+(5, NULL), (6, NULL), (7, 70.0000), (8, 80.0000);
+
+INSERT INTO t2 VALUES
+(1,'A'), (2,'B'), (3,'C'), (4,'D'), (5, NULL), (6, NULL),
+(7,'E'), (8,'F'), (9,'G'), (10,'H'), (11, NULL), (12, NULL);
+
+set join_cache_level=4;
+
+let $q=
+SELECT t2.id,t2.name,t.total_amt
+ FROM t2
+ LEFT JOIN
+ (SELECT id, sum(amount) total_amt FROM t1 GROUP BY id) AS t
+ ON t2.id=t.id
+ WHERE t2.id < 3;
+
+eval $q;
+eval EXPLAIN $q;
+
+set join_cache_level=default;
+
+DROP TABLE t1,t2;
diff --git a/mysql-test/main/drop.test b/mysql-test/main/drop.test
index 6f506dd7215..fe8d39c0d7e 100644
--- a/mysql-test/main/drop.test
+++ b/mysql-test/main/drop.test
@@ -190,28 +190,28 @@ CREATE DATABASE mysql_test;
let $MYSQLD_DATADIR= `select @@datadir`;
--let $proc_frm = $MYSQLD_DATADIR/mysql/proc.frm
---let $proc_MYD = $MYSQLD_DATADIR/mysql/proc.MYD
---let $proc_MYI = $MYSQLD_DATADIR/mysql/proc.MYI
+--let $proc_MAD = $MYSQLD_DATADIR/mysql/proc.MAD
+--let $proc_MAI = $MYSQLD_DATADIR/mysql/proc.MAI
--let $copy_of_proc_frm = $MYSQLTEST_VARDIR/tmp/bug29958.copy.frm
---let $copy_of_proc_MYD = $MYSQLTEST_VARDIR/tmp/bug29958.copy.MYD
---let $copy_of_proc_MYI = $MYSQLTEST_VARDIR/tmp/bug29958.copy.MYI
+--let $copy_of_proc_MAD = $MYSQLTEST_VARDIR/tmp/bug29958.copy.MAD
+--let $copy_of_proc_MAI = $MYSQLTEST_VARDIR/tmp/bug29958.copy.MAI
--copy_file $proc_frm $copy_of_proc_frm
---copy_file $proc_MYD $copy_of_proc_MYD
---copy_file $proc_MYI $copy_of_proc_MYI
+--copy_file $proc_MAD $copy_of_proc_MAD
+--copy_file $proc_MAI $copy_of_proc_MAI
DROP TABLE mysql.proc;
DROP DATABASE mysql_test;
--copy_file $copy_of_proc_frm $proc_frm
---copy_file $copy_of_proc_MYD $proc_MYD
---copy_file $copy_of_proc_MYI $proc_MYI
+--copy_file $copy_of_proc_MAD $proc_MAD
+--copy_file $copy_of_proc_MAI $proc_MAI
--remove_file $copy_of_proc_frm
---remove_file $copy_of_proc_MYD
---remove_file $copy_of_proc_MYI
+--remove_file $copy_of_proc_MAD
+--remove_file $copy_of_proc_MAI
--echo
--echo # --
diff --git a/mysql-test/main/dyncol.result b/mysql-test/main/dyncol.result
index 7a5eeac67cc..cc9a94e74be 100644
--- a/mysql-test/main/dyncol.result
+++ b/mysql-test/main/dyncol.result
@@ -1028,12 +1028,12 @@ select column_get(column_create(1, "2011-02-32 8:46:06.23434" AS CHAR), 1 as tim
column_get(column_create(1, "2011-02-32 8:46:06.23434" AS CHAR), 1 as time)
NULL
Warnings:
-Warning 1292 Truncated incorrect time value: '2011-02-32 8:46:06.23434'
+Warning 1292 Incorrect time value: '2011-02-32 8:46:06.23434'
select column_get(column_create(1, "2011-13-01 8:46:06.23434" AS CHAR), 1 as time);
column_get(column_create(1, "2011-13-01 8:46:06.23434" AS CHAR), 1 as time)
NULL
Warnings:
-Warning 1292 Truncated incorrect time value: '2011-13-01 8:46:06.23434'
+Warning 1292 Incorrect time value: '2011-13-01 8:46:06.23434'
select column_get(column_create(1, "2011-02-30 8:46:06.23434" AS CHAR), 1 as time);
column_get(column_create(1, "2011-02-30 8:46:06.23434" AS CHAR), 1 as time)
08:46:06
diff --git a/mysql-test/main/failed_auth_3909.result b/mysql-test/main/failed_auth_3909.result
index d0fd2c41221..4c3c0aba9df 100644
--- a/mysql-test/main/failed_auth_3909.result
+++ b/mysql-test/main/failed_auth_3909.result
@@ -1,7 +1,7 @@
optimize table mysql.user;
Table Op Msg_type Msg_text
mysql.user optimize status OK
-insert ignore mysql.user (user,plugin) values ('foo','bar'),('bar','bar'),('baz','bar');
+insert ignore mysql.user (user,plugin) values ('foo','mysql_old_password'),('bar','mysql_old_password'),('baz','mysql_old_password');
Warnings:
Warning 1364 Field 'ssl_cipher' doesn't have a default value
Warning 1364 Field 'x509_issuer' doesn't have a default value
@@ -10,15 +10,15 @@ Warning 1364 Field 'authentication_string' doesn't have a default value
flush privileges;
connect(localhost,u1,,test,MASTER_PORT,MASTER_SOCKET);
connect fail,localhost,u1;
-ERROR HY000: Plugin 'bar' is not loaded
+ERROR HY000: Server is running in --secure-auth mode, but 'u1'@'localhost' has a password in the old format; please change the password to the new format
connect(localhost,u2,,test,MASTER_PORT,MASTER_SOCKET);
connect fail,localhost,u2;
ERROR 28000: Access denied for user 'u2'@'localhost' (using password: NO)
connect(localhost,u2,password,test,MASTER_PORT,MASTER_SOCKET);
connect fail,localhost,u2,password;
ERROR 28000: Access denied for user 'u2'@'localhost' (using password: YES)
-ERROR HY000: Plugin 'bar' is not loaded
+ERROR HY000: Server is running in --secure-auth mode, but 'u1'@'localhost' has a password in the old format; please change the password to the new format
ERROR 28000: Access denied for user 'u2'@'localhost' (using password: NO)
ERROR 28000: Access denied for user 'u2'@'localhost' (using password: YES)
-delete from mysql.user where plugin = 'bar';
+delete from mysql.user where plugin = 'mysql_old_password';
flush privileges;
diff --git a/mysql-test/main/failed_auth_3909.test b/mysql-test/main/failed_auth_3909.test
index f72460691ea..fb104cf4b81 100644
--- a/mysql-test/main/failed_auth_3909.test
+++ b/mysql-test/main/failed_auth_3909.test
@@ -7,11 +7,11 @@ source include/not_embedded.inc;
# the server requests a plugin
#
optimize table mysql.user;
-insert ignore mysql.user (user,plugin) values ('foo','bar'),('bar','bar'),('baz','bar');
+insert ignore mysql.user (user,plugin) values ('foo','mysql_old_password'),('bar','mysql_old_password'),('baz','mysql_old_password');
flush privileges;
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
---error ER_PLUGIN_IS_NOT_LOADED
+--error ER_SERVER_IS_IN_SECURE_AUTH_MODE
connect (fail,localhost,u1);
--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT
@@ -22,7 +22,7 @@ connect (fail,localhost,u2);
--error ER_ACCESS_DENIED_ERROR
connect (fail,localhost,u2,password);
---error ER_PLUGIN_IS_NOT_LOADED
+--error ER_SERVER_IS_IN_SECURE_AUTH_MODE
change_user u1;
--error ER_ACCESS_DENIED_ERROR
@@ -31,7 +31,7 @@ change_user u2;
--error ER_ACCESS_DENIED_ERROR
change_user u2,password;
-delete from mysql.user where plugin = 'bar';
+delete from mysql.user where plugin = 'mysql_old_password';
flush privileges;
diff --git a/mysql-test/main/failed_auth_unixsocket.result b/mysql-test/main/failed_auth_unixsocket.result
index 680d3b48a33..3b2cff7e845 100644
--- a/mysql-test/main/failed_auth_unixsocket.result
+++ b/mysql-test/main/failed_auth_unixsocket.result
@@ -1,10 +1,15 @@
update mysql.user set plugin='unix_socket';
flush privileges;
+Warnings:
+Warning 1524 Plugin 'unix_socket' is not loaded
+Warning 1524 Plugin 'unix_socket' is not loaded
+Warning 1524 Plugin 'unix_socket' is not loaded
+Warning 1524 Plugin 'unix_socket' is not loaded
connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET);
-connect fail,localhost,$USER;
-ERROR HY000: Plugin 'unix_socket' is not loaded
-ERROR HY000: Plugin 'unix_socket' is not loaded
+ERROR 28000: Access denied for user 'USER'@'localhost' (using password: NO)
+ERROR 28000: Access denied for user 'USER'@'localhost' (using password: NO)
install plugin unix_socket soname 'auth_socket.so';
+flush privileges;
connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET);
ERROR 28000: Access denied for user 'USER'@'localhost'
ERROR 28000: Access denied for user 'USER'@'localhost'
diff --git a/mysql-test/main/failed_auth_unixsocket.test b/mysql-test/main/failed_auth_unixsocket.test
index f7345f44698..5dfd9585882 100644
--- a/mysql-test/main/failed_auth_unixsocket.test
+++ b/mysql-test/main/failed_auth_unixsocket.test
@@ -7,20 +7,26 @@
update mysql.user set plugin='unix_socket';
flush privileges;
---replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT $USER USER
---error ER_PLUGIN_IS_NOT_LOADED
+# Make sure that the replace works, even if $USER is 'user' or something else
+# that matches other parts of the error message.
+let $replace=Access denied for user '$USER';
+
+--echo connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET);
+--replace_result $replace "Access denied for user 'USER'"
+--disable_query_log
+--error ER_ACCESS_DENIED_ERROR
connect (fail,localhost,$USER);
+--enable_query_log
---error ER_PLUGIN_IS_NOT_LOADED
+--replace_result $replace "Access denied for user 'USER'"
+--error ER_ACCESS_DENIED_ERROR
change_user $USER;
eval install plugin unix_socket soname '$AUTH_SOCKET_SO';
+flush privileges;
-# Make sure that the replace works, even if $USER is 'user' or something else
-# that matches other parts of the error message.
--echo connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET);
---let $replace=Access denied for user '$USER'
---replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT $replace "Access denied for user 'USER'"
+--replace_result $replace "Access denied for user 'USER'"
--disable_query_log
--error ER_ACCESS_DENIED_NO_PASSWORD_ERROR
connect (fail,localhost,$USER);
diff --git a/mysql-test/main/flush.result b/mysql-test/main/flush.result
index 5cd4fde477d..af8e327657b 100644
--- a/mysql-test/main/flush.result
+++ b/mysql-test/main/flush.result
@@ -542,3 +542,26 @@ flush relay logs,relay logs;
ERROR HY000: Incorrect usage of FLUSH and RELAY LOGS
flush slave,slave;
ERROR HY000: Incorrect usage of FLUSH and SLAVE
+#
+# MDEV-15890 Strange error message if you try to
+# FLUSH TABLES <view> after LOCK TABLES <view>.
+#
+CREATE TABLE t1 (qty INT, price INT);
+CREATE VIEW v1 AS SELECT qty, price, qty*price AS value FROM t1;
+LOCK TABLES v1 READ;
+FLUSH TABLES v1;
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
+UNLOCK TABLES;
+LOCK TABLES v1 WRITE;
+FLUSH TABLES v1;
+UNLOCK TABLES;
+LOCK TABLES v1 READ;
+FLUSH TABLES t1;
+ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
+UNLOCK TABLES;
+LOCK TABLES t1 READ;
+FLUSH TABLES v1;
+ERROR HY000: Table 'v1' was not locked with LOCK TABLES
+UNLOCK TABLES;
+DROP VIEW v1;
+DROP TABLE t1;
diff --git a/mysql-test/main/flush.test b/mysql-test/main/flush.test
index 81834b7de10..51b5c48c137 100644
--- a/mysql-test/main/flush.test
+++ b/mysql-test/main/flush.test
@@ -673,3 +673,34 @@ DROP TABLE t1;
flush relay logs,relay logs;
--error ER_WRONG_USAGE
flush slave,slave;
+
+--echo #
+--echo # MDEV-15890 Strange error message if you try to
+--echo # FLUSH TABLES <view> after LOCK TABLES <view>.
+--echo #
+
+CREATE TABLE t1 (qty INT, price INT);
+CREATE VIEW v1 AS SELECT qty, price, qty*price AS value FROM t1;
+
+LOCK TABLES v1 READ;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+FLUSH TABLES v1;
+UNLOCK TABLES;
+
+LOCK TABLES v1 WRITE;
+FLUSH TABLES v1;
+UNLOCK TABLES;
+
+LOCK TABLES v1 READ;
+--error ER_TABLE_NOT_LOCKED_FOR_WRITE
+FLUSH TABLES t1;
+UNLOCK TABLES;
+
+LOCK TABLES t1 READ;
+--error ER_TABLE_NOT_LOCKED
+FLUSH TABLES v1;
+UNLOCK TABLES;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
diff --git a/mysql-test/main/func_concat.result b/mysql-test/main/func_concat.result
index 9ab6f74653e..acde1be051b 100644
--- a/mysql-test/main/func_concat.result
+++ b/mysql-test/main/func_concat.result
@@ -268,3 +268,23 @@ SET optimizer_switch=@save_optimizer_switch;
SELECT UNHEX(CONCAT('414C2', HEX(8 + ROUND(RAND()*7)), SUBSTR(SHA(UUID()),6,33),HEX(2+ROUND(RAND()*8)))) IS NULL AS c1;
c1
0
+#
+# MDEV-13119 Wrong results with CAST(AS CHAR) and subquery
+#
+SET optimizer_switch=_utf8'derived_merge=on';
+CREATE TABLE t1 (t VARCHAR(10) CHARSET latin1);
+INSERT INTO t1 VALUES('abcdefghi');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT CAST(t AS CHAR CHARACTER SET utf8) t2 FROM t1) sub;
+c2
+abcdefghi-abcdefghi
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
+#
+# MDEV-13120 Wrong results with MAKE_SET() and subquery
+#
+CREATE TABLE t1 (t VARCHAR(10) CHARSET latin1);
+INSERT INTO t1 VALUES('abcdefghi');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT MAKE_SET(3,t,t) t2 FROM t1) sub;
+c2
+abcdefghi,abcdefghi-abcdefghi,abcdefghi
+DROP TABLE t1;
diff --git a/mysql-test/main/func_concat.test b/mysql-test/main/func_concat.test
index 69dd2c4063e..e1bda4be29e 100644
--- a/mysql-test/main/func_concat.test
+++ b/mysql-test/main/func_concat.test
@@ -242,3 +242,25 @@ SET optimizer_switch=@save_optimizer_switch;
--echo #
SELECT UNHEX(CONCAT('414C2', HEX(8 + ROUND(RAND()*7)), SUBSTR(SHA(UUID()),6,33),HEX(2+ROUND(RAND()*8)))) IS NULL AS c1;
+
+
+--echo #
+--echo # MDEV-13119 Wrong results with CAST(AS CHAR) and subquery
+--echo #
+
+SET optimizer_switch=_utf8'derived_merge=on';
+CREATE TABLE t1 (t VARCHAR(10) CHARSET latin1);
+INSERT INTO t1 VALUES('abcdefghi');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT CAST(t AS CHAR CHARACTER SET utf8) t2 FROM t1) sub;
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
+
+
+--echo #
+--echo # MDEV-13120 Wrong results with MAKE_SET() and subquery
+--echo #
+
+CREATE TABLE t1 (t VARCHAR(10) CHARSET latin1);
+INSERT INTO t1 VALUES('abcdefghi');
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT MAKE_SET(3,t,t) t2 FROM t1) sub;
+DROP TABLE t1;
diff --git a/mysql-test/main/func_hybrid_type.result b/mysql-test/main/func_hybrid_type.result
index ebf7191a3f7..a86fd8d1d6f 100644
--- a/mysql-test/main/func_hybrid_type.result
+++ b/mysql-test/main/func_hybrid_type.result
@@ -3755,3 +3755,193 @@ DROP TABLE t1;
#
# End of 10.3 tests
#
+#
+# Start of 10.4 tests
+#
+#
+# MDEV-17325 NULL-ability problems with LEAST() in combination with NO_ZERO_DATE and NO_ZERO_IN_DATE
+#
+SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE';
+SELECT
+LEAST('0000-00-00',DATE'2001-01-01') AS s1,
+LEAST('0001-00-01',DATE'2001-01-01') AS s2,
+LEAST('0000-00-00',TIMESTAMP'2001-01-01 00:00:00') AS s3,
+LEAST('0001-00-01',TIMESTAMP'2001-01-01 00:00:00') AS s4,
+LEAST(0,DATE'2001-01-01') AS i1,
+LEAST(20010001,DATE'2001-01-01') AS i2,
+LEAST(0,TIMESTAMP'2001-01-01 00:00:00') AS i3,
+LEAST(20010001,TIMESTAMP'2001-01-01 00:00:00') AS i4;
+Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
+def s1 10 10 0 Y 128 0 63
+def s2 10 10 0 Y 128 0 63
+def s3 12 26 0 Y 128 0 63
+def s4 12 26 0 Y 128 0 63
+def i1 10 10 0 Y 128 0 63
+def i2 10 10 0 Y 128 0 63
+def i3 12 19 0 Y 128 0 63
+def i4 12 19 0 Y 128 0 63
+s1 s2 s3 s4 i1 i2 i3 i4
+NULL NULL NULL NULL NULL NULL NULL NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0001-00-01'
+Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
+Warning 1292 Incorrect datetime value: '0001-00-01 00:00:00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '2001-00-01'
+Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
+Warning 1292 Incorrect datetime value: '2001-00-01 00:00:00'
+SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE';
+CREATE TABLE t1 AS SELECT
+LEAST('0000-00-00',DATE'2001-01-01') AS s1,
+LEAST('0001-00-01',DATE'2001-01-01') AS s2,
+LEAST('0000-00-00',TIMESTAMP'2001-01-01 00:00:00') AS s3,
+LEAST('0001-00-01',TIMESTAMP'2001-01-01 00:00:00') AS s4,
+LEAST(0,DATE'2001-01-01') AS i1,
+LEAST(20010001,DATE'2001-01-01') AS i2,
+LEAST(0,TIMESTAMP'2001-01-01 00:00:00') AS i3,
+LEAST(20010001,TIMESTAMP'2001-01-01 00:00:00') AS i4;
+Warnings:
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0001-00-01'
+Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
+Warning 1292 Incorrect datetime value: '0001-00-01 00:00:00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '2001-00-01'
+Warning 1292 Incorrect datetime value: '0000-00-00 00:00:00'
+Warning 1292 Incorrect datetime value: '2001-00-01 00:00:00'
+SELECT * FROM t1;
+s1 s2 s3 s4 i1 i2 i3 i4
+NULL NULL NULL NULL NULL NULL NULL NULL
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `s1` date DEFAULT NULL,
+ `s2` date DEFAULT NULL,
+ `s3` datetime DEFAULT NULL,
+ `s4` datetime DEFAULT NULL,
+ `i1` date DEFAULT NULL,
+ `i2` date DEFAULT NULL,
+ `i3` datetime DEFAULT NULL,
+ `i4` datetime DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30');
+CREATE TABLE t1 AS SELECT LEAST(CURRENT_DATE,CURRENT_TIME) AS c1;
+SELECT * FROM t1;
+c1
+2001-01-01 00:00:00
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` datetime NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SET old_mode=ZERO_DATE_TIME_CAST;
+CREATE TABLE t1 AS SELECT LEAST(CURRENT_DATE,CURRENT_TIME) AS c1;
+Warnings:
+Warning 1292 Incorrect datetime value: '0000-00-00 10:20:30'
+SELECT * FROM t1;
+c1
+NULL
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` datetime DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SET old_mode=DEFAULT;
+SET timestamp=DEFAULT;
+SET sql_mode=DEFAULT;
+SET sql_mode='';
+SELECT LEAST(999,TIME'10:20:30') AS c1;
+c1
+NULL
+Warnings:
+Warning 1292 Incorrect time value: '999'
+CREATE TABLE t1 AS SELECT LEAST(999,TIME'10:20:30') AS c1;
+Warnings:
+Warning 1292 Incorrect time value: '999'
+SELECT * FROM t1;
+c1
+NULL
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` time DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+#
+# MDEV-17318 CAST(LEAST(zero_date,non_zero_date) AS numeric_data_type) returns a wrong result
+#
+SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE';
+SELECT
+LEAST('0000-00-00',DATE'2001-01-01') AS c0,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS CHAR) AS string,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DATE) AS date,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DATETIME) AS datetime,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS TIME) AS time,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DECIMAL) AS dc,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DOUBLE) AS dbl,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS SIGNED) AS sint,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS UNSIGNED) AS uint;
+c0 string date datetime time dc dbl sint uint
+NULL NULL NULL NULL NULL NULL NULL NULL NULL
+Warnings:
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+CREATE TABLE t1 AS SELECT
+LEAST('0000-00-00',DATE'2001-01-01') AS c0,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS CHAR) AS string,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DATE) AS date,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DATETIME) AS datetime,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS TIME) AS time,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DECIMAL) AS dc,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DOUBLE) AS dbl,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS SIGNED) AS sint,
+CAST(LEAST('0000-00-00',DATE'2001-01-01') AS UNSIGNED) AS uint;
+Warnings:
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+Warning 1292 Incorrect datetime value: '0000-00-00'
+SELECT * FROM t1;
+c0 string date datetime time dc dbl sint uint
+NULL NULL NULL NULL NULL NULL NULL NULL NULL
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c0` date DEFAULT NULL,
+ `string` varchar(10) DEFAULT NULL,
+ `date` date DEFAULT NULL,
+ `datetime` datetime DEFAULT NULL,
+ `time` time DEFAULT NULL,
+ `dc` decimal(10,0) DEFAULT NULL,
+ `dbl` double DEFAULT NULL,
+ `sint` bigint(10) DEFAULT NULL,
+ `uint` bigint(20) unsigned DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+#
+# MDEV-17330 Wrong result for 0 + LEAST(TIME'-10:00:00',TIME'10:00:00')
+#
+SELECT 0 + LEAST(TIME'-10:00:00',TIME'10:00:00') AS c;
+c
+-100000
+#
+# End of 10.4 tests
+#
diff --git a/mysql-test/main/func_hybrid_type.test b/mysql-test/main/func_hybrid_type.test
index 954c7de53fa..6b32f331d34 100644
--- a/mysql-test/main/func_hybrid_type.test
+++ b/mysql-test/main/func_hybrid_type.test
@@ -615,3 +615,108 @@ DROP TABLE t1;
--echo # End of 10.3 tests
--echo #
+--echo #
+--echo # Start of 10.4 tests
+--echo #
+
+--echo #
+--echo # MDEV-17325 NULL-ability problems with LEAST() in combination with NO_ZERO_DATE and NO_ZERO_IN_DATE
+--echo #
+
+SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE';
+
+--disable_ps_protocol
+--enable_metadata
+SELECT
+ LEAST('0000-00-00',DATE'2001-01-01') AS s1,
+ LEAST('0001-00-01',DATE'2001-01-01') AS s2,
+ LEAST('0000-00-00',TIMESTAMP'2001-01-01 00:00:00') AS s3,
+ LEAST('0001-00-01',TIMESTAMP'2001-01-01 00:00:00') AS s4,
+ LEAST(0,DATE'2001-01-01') AS i1,
+ LEAST(20010001,DATE'2001-01-01') AS i2,
+ LEAST(0,TIMESTAMP'2001-01-01 00:00:00') AS i3,
+ LEAST(20010001,TIMESTAMP'2001-01-01 00:00:00') AS i4;
+--disable_metadata
+--enable_ps_protocol
+
+SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE';
+CREATE TABLE t1 AS SELECT
+ LEAST('0000-00-00',DATE'2001-01-01') AS s1,
+ LEAST('0001-00-01',DATE'2001-01-01') AS s2,
+ LEAST('0000-00-00',TIMESTAMP'2001-01-01 00:00:00') AS s3,
+ LEAST('0001-00-01',TIMESTAMP'2001-01-01 00:00:00') AS s4,
+ LEAST(0,DATE'2001-01-01') AS i1,
+ LEAST(20010001,DATE'2001-01-01') AS i2,
+ LEAST(0,TIMESTAMP'2001-01-01 00:00:00') AS i3,
+ LEAST(20010001,TIMESTAMP'2001-01-01 00:00:00') AS i4;
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+SET timestamp=UNIX_TIMESTAMP('2001-01-01 10:20:30');
+
+# A TIME always converts to a non-NULL DATETIME with the new CAST style
+# Expect a NOT NULL column
+CREATE TABLE t1 AS SELECT LEAST(CURRENT_DATE,CURRENT_TIME) AS c1;
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+# A TIME can convert to a NULL DATETIME with old CAST style
+# Expect a NULL-able column
+SET old_mode=ZERO_DATE_TIME_CAST;
+CREATE TABLE t1 AS SELECT LEAST(CURRENT_DATE,CURRENT_TIME) AS c1;
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+SET old_mode=DEFAULT;
+SET timestamp=DEFAULT;
+
+SET sql_mode=DEFAULT;
+
+SET sql_mode='';
+SELECT LEAST(999,TIME'10:20:30') AS c1;
+CREATE TABLE t1 AS SELECT LEAST(999,TIME'10:20:30') AS c1;
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+--echo #
+--echo # MDEV-17318 CAST(LEAST(zero_date,non_zero_date) AS numeric_data_type) returns a wrong result
+--echo #
+SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE';
+SELECT
+ LEAST('0000-00-00',DATE'2001-01-01') AS c0,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS CHAR) AS string,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DATE) AS date,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DATETIME) AS datetime,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS TIME) AS time,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DECIMAL) AS dc,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DOUBLE) AS dbl,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS SIGNED) AS sint,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS UNSIGNED) AS uint;
+CREATE TABLE t1 AS SELECT
+ LEAST('0000-00-00',DATE'2001-01-01') AS c0,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS CHAR) AS string,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DATE) AS date,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DATETIME) AS datetime,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS TIME) AS time,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DECIMAL) AS dc,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS DOUBLE) AS dbl,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS SIGNED) AS sint,
+ CAST(LEAST('0000-00-00',DATE'2001-01-01') AS UNSIGNED) AS uint;
+SELECT * FROM t1;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+--echo #
+--echo # MDEV-17330 Wrong result for 0 + LEAST(TIME'-10:00:00',TIME'10:00:00')
+--echo #
+SELECT 0 + LEAST(TIME'-10:00:00',TIME'10:00:00') AS c;
+
+
+--echo #
+--echo # End of 10.4 tests
+--echo #
diff --git a/mysql-test/main/func_in.result b/mysql-test/main/func_in.result
index a86781b156c..acf718c453e 100644
--- a/mysql-test/main/func_in.result
+++ b/mysql-test/main/func_in.result
@@ -481,7 +481,7 @@ SELECT * FROM t4 WHERE a IN ('1972-02-06','19772-07-29');
a
1972-02-06
Warnings:
-Warning 1292 Incorrect datetime value: '19772-07-29'
+Warning 1292 Truncated incorrect datetime value: '19772-07-29'
DROP TABLE t1,t2,t3,t4;
CREATE TABLE t1 (id int not null);
INSERT INTO t1 VALUES (1),(2);
diff --git a/mysql-test/main/func_isnull.result b/mysql-test/main/func_isnull.result
index 15d87997e29..8cbd528f2de 100644
--- a/mysql-test/main/func_isnull.result
+++ b/mysql-test/main/func_isnull.result
@@ -106,5 +106,25 @@ Note 1003 select `test`.`t2`.`d1` AS `d1`,`test`.`t1`.`d1` AS `d1` from `test`.`
DROP VIEW v1;
DROP TABLE t1,t2;
#
+# MDEV-15475: Assertion `!table || (!table->read_set ||
+# bitmap_is_set(table->read_set, field_index))'
+# failed on EXPLAIN EXTENDED with constant table and view
+#
+CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=MyISAM;
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 VALUES (1);
+EXPLAIN EXTENDED SELECT ISNULL(pk) FROM v1;
+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
+Warnings:
+Note 1003 select /*always not null*/ 1 is null AS `ISNULL(pk)` from dual
+EXPLAIN EXTENDED SELECT IFNULL(pk,0) FROM v1;
+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
+Warnings:
+Note 1003 select ifnull(1,0) AS `IFNULL(pk,0)` from dual
+DROP VIEW v1;
+DROP TABLE t1;
+#
# End of 5.5 tests
#
diff --git a/mysql-test/main/func_isnull.test b/mysql-test/main/func_isnull.test
index 4c59fa3cbe8..7d1a7e83a1a 100644
--- a/mysql-test/main/func_isnull.test
+++ b/mysql-test/main/func_isnull.test
@@ -83,6 +83,22 @@ SELECT * FROM t2 LEFT JOIN v1 ON t2.d1=v1.d1 WHERE v1.d1 IS NULL;
DROP VIEW v1;
DROP TABLE t1,t2;
+
+--echo #
+--echo # MDEV-15475: Assertion `!table || (!table->read_set ||
+--echo # bitmap_is_set(table->read_set, field_index))'
+--echo # failed on EXPLAIN EXTENDED with constant table and view
+--echo #
+
+CREATE TABLE t1 (pk INT PRIMARY KEY) ENGINE=MyISAM;
+CREATE VIEW v1 AS SELECT * FROM t1;
+INSERT INTO t1 VALUES (1);
+EXPLAIN EXTENDED SELECT ISNULL(pk) FROM v1;
+EXPLAIN EXTENDED SELECT IFNULL(pk,0) FROM v1;
+# Cleanup
+DROP VIEW v1;
+DROP TABLE t1;
+
--echo #
--echo # End of 5.5 tests
--echo #
diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result
index a7e8b5c9e59..cc9fd146e63 100644
--- a/mysql-test/main/func_json.result
+++ b/mysql-test/main/func_json.result
@@ -761,6 +761,56 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
#
+# MDEV-16054 simple json functions flatline cpu on garbage input.
+#
+select json_array(1,uuid(),compress(5.140264e+307));
+json_array(1,uuid(),compress(5.140264e+307))
+NULL
+#
+# MDEV-16869 String functions don't respect character set of JSON_VALUE.
+#
+create table t1(json_col TEXT) DEFAULT CHARSET=latin1;
+insert into t1 values (_latin1 X'7B226B657931223A2253EC227D');
+select JSON_VALUE(json_col, '$.key1')= _latin1 X'53EC' from t1;
+JSON_VALUE(json_col, '$.key1')= _latin1 X'53EC'
+1
+select REPLACE(JSON_VALUE(json_col, '$.key1'), 'null', '') = _latin1 X'53EC' from t1;
+REPLACE(JSON_VALUE(json_col, '$.key1'), 'null', '') = _latin1 X'53EC'
+1
+drop table t1;
+#
+# MDEV-16750 JSON_SET mishandles unicode every second pair of arguments.
+#
+SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6);
+JSON_SET('{}', '$.a', _utf8 0xC3B6)
+{"a": "ö"}
+SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6);
+JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6)
+{"a": "ö", "b": "ö"}
+SELECT JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6');
+JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6')
+{"a": "ö", "x": 1, "b": "ö"}
+#
+# MDEV-17121 JSON_ARRAY_APPEND
+#
+select json_array_append('[ ]', '$', 'aue');
+json_array_append('[ ]', '$', 'aue')
+["aue"]
+#
+# MDEV-17018 JSON_SEARCH and User-Defined Variables.
+#
+SET @`json` := '["A", [{"B": "1"}], {"C": "AB"}, {"D": "BC"}]', @`value` := 'AB';
+SELECT JSON_SEARCH(@`json`, 'one', @`value`);
+JSON_SEARCH(@`json`, 'one', @`value`)
+"$[2].C"
+SET @`json` := NULL, @`value` := NULL;
+#
+# MDEV-17001 JSON_MERGE returns nullwhen merging empty array.
+#
+SELECT JSON_MERGE('[1]', '[]');
+JSON_MERGE('[1]', '[]')
+[1]
+#
# End of 10.2 tests
#
#
diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test
index 8d72e5afa59..9a0699ac23d 100644
--- a/mysql-test/main/func_json.test
+++ b/mysql-test/main/func_json.test
@@ -423,6 +423,50 @@ SHOW CREATE TABLE t1;
DROP TABLE t1;
--echo #
+--echo # MDEV-16054 simple json functions flatline cpu on garbage input.
+--echo #
+
+select json_array(1,uuid(),compress(5.140264e+307));
+
+--echo #
+--echo # MDEV-16869 String functions don't respect character set of JSON_VALUE.
+--echo #
+
+create table t1(json_col TEXT) DEFAULT CHARSET=latin1;
+insert into t1 values (_latin1 X'7B226B657931223A2253EC227D');
+select JSON_VALUE(json_col, '$.key1')= _latin1 X'53EC' from t1;
+select REPLACE(JSON_VALUE(json_col, '$.key1'), 'null', '') = _latin1 X'53EC' from t1;
+drop table t1;
+
+--echo #
+--echo # MDEV-16750 JSON_SET mishandles unicode every second pair of arguments.
+--echo #
+
+SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6);
+SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6);
+SELECT JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6');
+
+--echo #
+--echo # MDEV-17121 JSON_ARRAY_APPEND
+--echo #
+
+select json_array_append('[ ]', '$', 'aue');
+
+--echo #
+--echo # MDEV-17018 JSON_SEARCH and User-Defined Variables.
+--echo #
+
+SET @`json` := '["A", [{"B": "1"}], {"C": "AB"}, {"D": "BC"}]', @`value` := 'AB';
+SELECT JSON_SEARCH(@`json`, 'one', @`value`);
+SET @`json` := NULL, @`value` := NULL;
+
+--echo #
+--echo # MDEV-17001 JSON_MERGE returns nullwhen merging empty array.
+--echo #
+
+SELECT JSON_MERGE('[1]', '[]');
+
+--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/main/func_like.result b/mysql-test/main/func_like.result
index 0ba8e41f164..06a549e94b2 100644
--- a/mysql-test/main/func_like.result
+++ b/mysql-test/main/func_like.result
@@ -289,3 +289,120 @@ a b c d
3 f_ 1 0 1
3 f\_ 0 1 0
drop table t1;
+#
+# MDEV-17359 - Extend expression supported by like (| & << >> || + - * / DIV MOD ^ )
+#
+SELECT 1 LIKE +1;
+1 LIKE +1
+1
+SELECT -1 LIKE -1;
+-1 LIKE -1
+1
+SELECT 1 LIKE (1);
+1 LIKE (1)
+1
+SELECT 1 LIKE 1|2, 3 LIKE 1|2;
+1 LIKE 1|2 3 LIKE 1|2
+0 1
+SELECT 1 LIKE 3&2, 2 LIKE 3&2;
+1 LIKE 3&2 2 LIKE 3&2
+0 1
+SELECT 1 LIKE 1>>0, 1 LIKE 1>>1 , 64 LIKE 256>>2;
+1 LIKE 1>>0 1 LIKE 1>>1 64 LIKE 256>>2
+1 0 1
+SELECT 1 LIKE 1<<0, 1 LIKE 0<<2, 32 LIKE 1<<5;
+1 LIKE 1<<0 1 LIKE 0<<2 32 LIKE 1<<5
+1 0 1
+SELECT 1 LIKE 1||2, 1 LIKE 0||2;
+1 LIKE 1||2 1 LIKE 0||2
+1 1
+SELECT 2 LIKE 1+1, 2.0 LIKE 1+1.0, 2 LIKE 1+1.0, 1+1 LIKE 2, 1+1 LIKE 0+2;
+2 LIKE 1+1 2.0 LIKE 1+1.0 2 LIKE 1+1.0 1+1 LIKE 2 1+1 LIKE 0+2
+1 1 0 1 1
+SELECT 0 LIKE 1-1, 2.0 LIKE 3-1.0, 2 LIKE 3-1.0, 2-1 LIKE 1, 3-1 LIKE 4-1;
+0 LIKE 1-1 2.0 LIKE 3-1.0 2 LIKE 3-1.0 2-1 LIKE 1 3-1 LIKE 4-1
+1 1 0 1 0
+SELECT 1 LIKE 1*1, 2.0 LIKE 2*1.0, 2 LIKE 2*1.0, 2*1 LIKE 2, 2*3 LIKE 6*1;
+1 LIKE 1*1 2.0 LIKE 2*1.0 2 LIKE 2*1.0 2*1 LIKE 2 2*3 LIKE 6*1
+1 1 0 1 1
+SELECT 1 LIKE 1/1, 1.0000 LIKE 1/1, 1.0000 LIKE 1/1.000000, 1.000000 LIKE 1.0/1.000000, 1/1 like 1/1;
+1 LIKE 1/1 1.0000 LIKE 1/1 1.0000 LIKE 1/1.000000 1.000000 LIKE 1.0/1.000000 1/1 like 1/1
+0 1 1 0 1
+SELECT 1 LIKE 1 DIV 1, 1 LIKE 1.0 DIV 1.0 ;
+1 LIKE 1 DIV 1 1 LIKE 1.0 DIV 1.0
+1 1
+SELECT 2 LIKE 10 MOD 8, 1.9 LIKE 10 MOD 8.1, 1.9 LIKE 10 MOD 8.10 ;
+2 LIKE 10 MOD 8 1.9 LIKE 10 MOD 8.1 1.9 LIKE 10 MOD 8.10
+1 1 0
+SELECT 1 LIKE CAST(1 AS CHAR(10));
+1 LIKE CAST(1 AS CHAR(10))
+1
+SELECT 1 LIKE CASE WHEN 1=1 THEN '1' ELSE '0' END;
+1 LIKE CASE WHEN 1=1 THEN '1' ELSE '0' END
+1
+SELECT 1 LIKE COALESCE(1+0, 1);
+1 LIKE COALESCE(1+0, 1)
+1
+CREATE TABLE t1(c1 INTEGER, c2 INTEGER);
+INSERT INTO t1 VALUES(1,1);
+INSERT INTO t1 VALUES(1,2);
+SELECT c1, c2, c1|c2, 1 LIKE c1|c2 FROM t1 ORDER BY c2;
+c1 c2 c1|c2 1 LIKE c1|c2
+1 1 1 1
+1 2 3 0
+SELECT c1, c2, c1&c2, 1 LIKE c1&c2 FROM t1 ORDER BY c2;
+c1 c2 c1&c2 1 LIKE c1&c2
+1 1 1 1
+1 2 0 0
+SELECT c1, c2, c2>>c1, 1 LIKE c2>>c1 FROM t1 ORDER BY c2;
+c1 c2 c2>>c1 1 LIKE c2>>c1
+1 1 0 0
+1 2 1 1
+SELECT c1, c2, c2<<c1, 2 LIKE c2<<c1 FROM t1 ORDER BY c2;
+c1 c2 c2<<c1 2 LIKE c2<<c1
+1 1 2 1
+1 2 4 0
+SELECT c1, c2, c1||c2, 1 LIKE c1||c2 FROM t1 ORDER BY c2;
+c1 c2 c1||c2 1 LIKE c1||c2
+1 1 1 1
+1 2 1 1
+SELECT c1, c2, c1+c2, 2 LIKE c1+c2 FROM t1 ORDER BY c2;
+c1 c2 c1+c2 2 LIKE c1+c2
+1 1 2 1
+1 2 3 0
+SELECT c1, c2, c1-c2, -1 LIKE c1-c2 FROM t1 ORDER BY c2;
+c1 c2 c1-c2 -1 LIKE c1-c2
+1 1 0 0
+1 2 -1 1
+SELECT c1, c2, c1*c2, 2 LIKE c1*c2 FROM t1 ORDER BY c2;
+c1 c2 c1*c2 2 LIKE c1*c2
+1 1 1 0
+1 2 2 1
+SELECT c1, c2, c1/c2, 0.5000 LIKE c1/c2 FROM t1 ORDER BY c2;
+c1 c2 c1/c2 0.5000 LIKE c1/c2
+1 1 1.0000 0
+1 2 0.5000 1
+SELECT c1, c2, c1 DIV c2, 0 LIKE c1 DIV c2 FROM t1 ORDER BY c2;
+c1 c2 c1 DIV c2 0 LIKE c1 DIV c2
+1 1 1 0
+1 2 0 1
+SELECT c1, c2, c1 MOD c2, 0 LIKE c1 MOD c2 FROM t1 ORDER BY c2;
+c1 c2 c1 MOD c2 0 LIKE c1 MOD c2
+1 1 0 1
+1 2 1 0
+CREATE VIEW v1 AS
+SELECT 1 LIKE c1|c2, 1 LIKE c1&c2, 1 LIKE c2>>c1, 2 LIKE c2<<c1,
+1 LIKE c1||c2, 2 LIKE c1+c2, -1 LIKE c1-c2, 2 LIKE c1*c2,
+0.5000 LIKE c1/c2, 0 LIKE c1 DIV c2, 0 LIKE c1 MOD c2
+FROM t1 ORDER BY c2;
+SELECT * FROM v1;
+1 LIKE c1|c2 1 LIKE c1&c2 1 LIKE c2>>c1 2 LIKE c2<<c1 1 LIKE c1||c2 2 LIKE c1+c2 -1 LIKE c1-c2 2 LIKE c1*c2 0.5000 LIKE c1/c2 0 LIKE c1 DIV c2 0 LIKE c1 MOD c2
+1 1 0 1 1 1 0 0 0 0 1
+0 0 1 0 1 0 1 1 1 1 0
+EXPLAIN EXTENDED SELECT * FROM v1;
+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 Using filesort
+Warnings:
+Note 1003 select 1 like `test`.`t1`.`c1` | `test`.`t1`.`c2` AS `1 LIKE c1|c2`,1 like `test`.`t1`.`c1` & `test`.`t1`.`c2` AS `1 LIKE c1&c2`,1 like `test`.`t1`.`c2` >> `test`.`t1`.`c1` AS `1 LIKE c2>>c1`,2 like `test`.`t1`.`c2` << `test`.`t1`.`c1` AS `2 LIKE c2<<c1`,1 like `test`.`t1`.`c1` or `test`.`t1`.`c2` <> 0 AS `1 LIKE c1||c2`,2 like `test`.`t1`.`c1` + `test`.`t1`.`c2` AS `2 LIKE c1+c2`,-1 like `test`.`t1`.`c1` - `test`.`t1`.`c2` AS `-1 LIKE c1-c2`,2 like `test`.`t1`.`c1` * `test`.`t1`.`c2` AS `2 LIKE c1*c2`,0.5000 like `test`.`t1`.`c1` / `test`.`t1`.`c2` AS `0.5000 LIKE c1/c2`,0 like `test`.`t1`.`c1` DIV `test`.`t1`.`c2` AS `0 LIKE c1 DIV c2`,0 like `test`.`t1`.`c1` MOD `test`.`t1`.`c2` AS `0 LIKE c1 MOD c2` from `test`.`t1` order by `test`.`t1`.`c2`
+DROP VIEW v1;
+DROP TABLE t1;
diff --git a/mysql-test/main/func_like.test b/mysql-test/main/func_like.test
index 5026bb76aa3..cb50fb91879 100644
--- a/mysql-test/main/func_like.test
+++ b/mysql-test/main/func_like.test
@@ -207,3 +207,53 @@ insert t1 (a) values ('3 f_'), ('3 f\_');
set sql_mode=default;
select * from t1;
drop table t1;
+
+--echo #
+--echo # MDEV-17359 - Extend expression supported by like (| & << >> || + - * / DIV MOD ^ )
+--echo #
+
+SELECT 1 LIKE +1;
+SELECT -1 LIKE -1;
+SELECT 1 LIKE (1);
+SELECT 1 LIKE 1|2, 3 LIKE 1|2;
+SELECT 1 LIKE 3&2, 2 LIKE 3&2;
+SELECT 1 LIKE 1>>0, 1 LIKE 1>>1 , 64 LIKE 256>>2;
+SELECT 1 LIKE 1<<0, 1 LIKE 0<<2, 32 LIKE 1<<5;
+SELECT 1 LIKE 1||2, 1 LIKE 0||2;
+SELECT 2 LIKE 1+1, 2.0 LIKE 1+1.0, 2 LIKE 1+1.0, 1+1 LIKE 2, 1+1 LIKE 0+2;
+SELECT 0 LIKE 1-1, 2.0 LIKE 3-1.0, 2 LIKE 3-1.0, 2-1 LIKE 1, 3-1 LIKE 4-1;
+SELECT 1 LIKE 1*1, 2.0 LIKE 2*1.0, 2 LIKE 2*1.0, 2*1 LIKE 2, 2*3 LIKE 6*1;
+SELECT 1 LIKE 1/1, 1.0000 LIKE 1/1, 1.0000 LIKE 1/1.000000, 1.000000 LIKE 1.0/1.000000, 1/1 like 1/1;
+SELECT 1 LIKE 1 DIV 1, 1 LIKE 1.0 DIV 1.0 ;
+SELECT 2 LIKE 10 MOD 8, 1.9 LIKE 10 MOD 8.1, 1.9 LIKE 10 MOD 8.10 ;
+
+SELECT 1 LIKE CAST(1 AS CHAR(10));
+SELECT 1 LIKE CASE WHEN 1=1 THEN '1' ELSE '0' END;
+SELECT 1 LIKE COALESCE(1+0, 1);
+
+CREATE TABLE t1(c1 INTEGER, c2 INTEGER);
+INSERT INTO t1 VALUES(1,1);
+INSERT INTO t1 VALUES(1,2);
+
+SELECT c1, c2, c1|c2, 1 LIKE c1|c2 FROM t1 ORDER BY c2;
+SELECT c1, c2, c1&c2, 1 LIKE c1&c2 FROM t1 ORDER BY c2;
+SELECT c1, c2, c2>>c1, 1 LIKE c2>>c1 FROM t1 ORDER BY c2;
+SELECT c1, c2, c2<<c1, 2 LIKE c2<<c1 FROM t1 ORDER BY c2;
+SELECT c1, c2, c1||c2, 1 LIKE c1||c2 FROM t1 ORDER BY c2;
+SELECT c1, c2, c1+c2, 2 LIKE c1+c2 FROM t1 ORDER BY c2;
+SELECT c1, c2, c1-c2, -1 LIKE c1-c2 FROM t1 ORDER BY c2;
+SELECT c1, c2, c1*c2, 2 LIKE c1*c2 FROM t1 ORDER BY c2;
+SELECT c1, c2, c1/c2, 0.5000 LIKE c1/c2 FROM t1 ORDER BY c2;
+SELECT c1, c2, c1 DIV c2, 0 LIKE c1 DIV c2 FROM t1 ORDER BY c2;
+SELECT c1, c2, c1 MOD c2, 0 LIKE c1 MOD c2 FROM t1 ORDER BY c2;
+
+CREATE VIEW v1 AS
+SELECT 1 LIKE c1|c2, 1 LIKE c1&c2, 1 LIKE c2>>c1, 2 LIKE c2<<c1,
+ 1 LIKE c1||c2, 2 LIKE c1+c2, -1 LIKE c1-c2, 2 LIKE c1*c2,
+ 0.5000 LIKE c1/c2, 0 LIKE c1 DIV c2, 0 LIKE c1 MOD c2
+ FROM t1 ORDER BY c2;
+
+SELECT * FROM v1;
+EXPLAIN EXTENDED SELECT * FROM v1;
+DROP VIEW v1;
+DROP TABLE t1;
diff --git a/mysql-test/main/func_sapdb.result b/mysql-test/main/func_sapdb.result
index 5b9743fb33f..27f1d74bc41 100644
--- a/mysql-test/main/func_sapdb.result
+++ b/mysql-test/main/func_sapdb.result
@@ -107,9 +107,13 @@ subtime("1997-12-31 23:59:59.000001", "1 1:1:1.000002")
select addtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
addtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999")
NULL
+Warnings:
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '1998-01-01 01:01:01.999999'
select subtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999");
subtime("1997-12-31 23:59:59.999999", "1998-01-01 01:01:01.999999")
NULL
+Warnings:
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '1998-01-01 01:01:01.999999'
select subtime("01:00:00.999999", "02:00:00.999998");
subtime("01:00:00.999999", "02:00:00.999998")
-00:59:59.999999
@@ -180,7 +184,7 @@ select time("1997-12-31 25:59:59.000001");
time("1997-12-31 25:59:59.000001")
NULL
Warnings:
-Warning 1292 Truncated incorrect time value: '1997-12-31 25:59:59.000001'
+Warning 1292 Incorrect time value: '1997-12-31 25:59:59.000001'
select microsecond("1997-12-31 23:59:59.000001");
microsecond("1997-12-31 23:59:59.000001")
1
diff --git a/mysql-test/main/func_time.result b/mysql-test/main/func_time.result
index 075f5b9ec51..a6e1ed9cb19 100644
--- a/mysql-test/main/func_time.result
+++ b/mysql-test/main/func_time.result
@@ -941,7 +941,7 @@ f1
select f1 from t1 where cast("2006-1-1" as date) between f1 and cast('zzz' as date);
f1
Warnings:
-Warning 1292 Incorrect datetime value: 'zzz'
+Warning 1292 Truncated incorrect datetime value: 'zzz'
select f1 from t1 where makedate(2006,1) between date(f1) and date(f3);
f1
2006-01-01
@@ -1105,7 +1105,7 @@ week(20061108), week(20061108.01), week(20061108085411.000002);
isnull(week(now() + 0)) isnull(week(now() + 0.2)) week(20061108) week(20061108.01) week(20061108085411.000002)
0 0 45 45 45
Warnings:
-Warning 1292 Truncated incorrect datetime value: '20061108.01'
+Note 1292 Truncated incorrect date value: '20061108.01'
End of 4.1 tests
select time_format('100:00:00', '%H %k %h %I %l');
time_format('100:00:00', '%H %k %h %I %l')
@@ -1382,9 +1382,9 @@ SELECT COUNT(*) FROM t1 GROUP BY TIME_TO_SEC(a);
COUNT(*)
2
Warnings:
-Warning 1292 Truncated incorrect time value: ''
-Warning 1292 Truncated incorrect time value: ''
-Warning 1292 Truncated incorrect time value: ''
+Warning 1292 Incorrect time value: ''
+Warning 1292 Incorrect time value: ''
+Warning 1292 Incorrect time value: ''
DROP TABLE t1;
#
# Bug#11766112 59151:UNINITIALIZED VALUES IN EXTRACT_DATE_TIME WITH STR_TO_DATE(SPACE(..) ...
@@ -1735,7 +1735,7 @@ select 1 from t1 where 1 < some (select cast(a as datetime) from t1);
1
1
Warnings:
-Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
drop table t1;
SET timestamp=DEFAULT;
#
@@ -1842,7 +1842,7 @@ select cast('131415.123e0' as time);
cast('131415.123e0' as time)
NULL
Warnings:
-Warning 1292 Truncated incorrect time value: '131415.123e0'
+Warning 1292 Incorrect time value: '131415.123e0'
select cast('2010-01-02 03:04:05' as datetime) between null and '2010-01-02 03:04:04';
cast('2010-01-02 03:04:05' as datetime) between null and '2010-01-02 03:04:04'
0
@@ -1918,7 +1918,7 @@ select least(1, f1) from t1;
least(1, f1)
0000-00-00 00:00:00
Warnings:
-Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
drop table t1;
SET timestamp=UNIX_TIMESTAMP('2014-04-14 10:10:10');
select now() > coalesce(time('21:43:24'), date('2010-05-03'));
@@ -2519,7 +2519,7 @@ TIMESTAMP('2001-01-01','10:10:10.12345'),
TIMESTAMP('2001-01-01','10:10:10.123456'),
TIMESTAMP('2001-01-01','10:10:10.1234567');
Warnings:
-Note 1292 Truncated incorrect time value: '10:10:10.1234567'
+Note 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '10:10:10.1234567'
SHOW COLUMNS FROM t1;
Field Type Null Key Default Extra
TIMESTAMP('2001-01-01','10:10:10') datetime YES NULL
@@ -2805,6 +2805,169 @@ SEC_TO_TIME(MAKEDATE(0,RAND(~0)))
838:59:59
Warnings:
Warning 1292 Truncated incorrect seconds value: '20000101'
+SELECT PERIOD_DIFF(2018, AES_ENCRYPT('Rae Bareli', 'Rae Bareli'));
+PERIOD_DIFF(2018, AES_ENCRYPT('Rae Bareli', 'Rae Bareli'))
+24257
+Warnings:
+Warning 1292 Truncated incorrect INTEGER value: '-3S\xFA\xDE?\x00\x00\xCA\xB3\xEEE\xA4\xD1\xC1\xA8'
+#
+# MDEV-17249 MAKETIME(-1e50,0,0) returns a wrong result
+#
+SELECT
+MAKETIME(1e10,0,0),
+MAKETIME(-1e10,0,0),
+MAKETIME(1e50,0,0),
+MAKETIME(-1e50,0,0),
+MAKETIME(COALESCE(1e50),0,0),
+MAKETIME(COALESCE(-1e50),0,0);
+MAKETIME(1e10,0,0) 838:59:59
+MAKETIME(-1e10,0,0) -838:59:59
+MAKETIME(1e50,0,0) 838:59:59
+MAKETIME(-1e50,0,0) -838:59:59
+MAKETIME(COALESCE(1e50),0,0) 838:59:59
+MAKETIME(COALESCE(-1e50),0,0) -838:59:59
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '10000000000:00:00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '-10000000000:00:00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '9223372036854775807:00:00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '-9223372036854775808:00:00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '9223372036854775807:00:00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '-9223372036854775808:00:00'
+CREATE TABLE t1 (a FLOAT);
+INSERT INTO t1 VALUES (1e30),(-1e30);
+SELECT MAKETIME(a,0,0) FROM t1;
+MAKETIME(a,0,0)
+838:59:59
+-838:59:59
+Warnings:
+Warning 1292 Truncated incorrect time value: '9223372036854775807:00:00'
+Warning 1292 Truncated incorrect time value: '-9223372036854775808:00:00'
+DROP TABLE t1;
+#
+# MDEV-17244 MAKETIME(900,0,0.111) returns a wrong result
+#
+SELECT MAKETIME(900,0,0);
+MAKETIME(900,0,0)
+838:59:59
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.1);
+MAKETIME(900,0,0.1)
+838:59:59.9
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.11);
+MAKETIME(900,0,0.11)
+838:59:59.99
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.111);
+MAKETIME(900,0,0.111)
+838:59:59.999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.1111);
+MAKETIME(900,0,0.1111)
+838:59:59.9999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.11111);
+MAKETIME(900,0,0.11111)
+838:59:59.99999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.111111);
+MAKETIME(900,0,0.111111)
+838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.1111111);
+MAKETIME(900,0,0.1111111)
+838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.11111111);
+MAKETIME(900,0,0.11111111)
+838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,0.111111111);
+MAKETIME(900,0,0.111111111)
+838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:00'
+SELECT MAKETIME(900,0,EXP(1));
+MAKETIME(900,0,EXP(1))
+838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '900:00:02'
+SELECT MAKETIME(-900,0,0);
+MAKETIME(-900,0,0)
+-838:59:59
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.1);
+MAKETIME(-900,0,0.1)
+-838:59:59.9
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.11);
+MAKETIME(-900,0,0.11)
+-838:59:59.99
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.111);
+MAKETIME(-900,0,0.111)
+-838:59:59.999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.1111);
+MAKETIME(-900,0,0.1111)
+-838:59:59.9999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.11111);
+MAKETIME(-900,0,0.11111)
+-838:59:59.99999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.111111);
+MAKETIME(-900,0,0.111111)
+-838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.1111111);
+MAKETIME(-900,0,0.1111111)
+-838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.11111111);
+MAKETIME(-900,0,0.11111111)
+-838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,0.111111111);
+MAKETIME(-900,0,0.111111111)
+-838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:00'
+SELECT MAKETIME(-900,0,EXP(1));
+MAKETIME(-900,0,EXP(1))
+-838:59:59.999999
+Warnings:
+Warning 1292 Truncated incorrect time value: '-900:00:02'
#
# End of 5.5 tests
#
@@ -2977,7 +3140,7 @@ def EXTRACT(YEAR_MONTH FROM a) 3 6 6 Y 32896 0 63
def EXTRACT(QUARTER FROM a) 3 2 1 Y 32896 0 63
def EXTRACT(MONTH FROM a) 3 2 2 Y 32896 0 63
def EXTRACT(WEEK FROM a) 3 2 2 Y 32896 0 63
-def EXTRACT(DAY FROM a) 3 2 2 Y 32896 0 63
+def EXTRACT(DAY FROM a) 3 3 2 Y 32896 0 63
def EXTRACT(DAY_HOUR FROM a) 3 5 4 Y 32896 0 63
def EXTRACT(DAY_MINUTE FROM a) 3 7 6 Y 32896 0 63
def EXTRACT(DAY_SECOND FROM a) 3 9 8 Y 32896 0 63
@@ -3067,7 +3230,7 @@ t2 CREATE TABLE `t2` (
`EXTRACT(QUARTER FROM a)` int(2) DEFAULT NULL,
`EXTRACT(MONTH FROM a)` int(2) DEFAULT NULL,
`EXTRACT(WEEK FROM a)` int(2) DEFAULT NULL,
- `EXTRACT(DAY FROM a)` int(2) DEFAULT NULL,
+ `EXTRACT(DAY FROM a)` int(3) DEFAULT NULL,
`EXTRACT(DAY_HOUR FROM a)` int(5) DEFAULT NULL,
`EXTRACT(DAY_MINUTE FROM a)` int(7) DEFAULT NULL,
`EXTRACT(DAY_SECOND FROM a)` int(9) DEFAULT NULL,
@@ -3116,7 +3279,7 @@ def EXTRACT(YEAR_MONTH FROM a) 3 6 1 Y 32896 0 63
def EXTRACT(QUARTER FROM a) 3 2 1 Y 32896 0 63
def EXTRACT(MONTH FROM a) 3 2 1 Y 32896 0 63
def EXTRACT(WEEK FROM a) 3 2 9 Y 32896 0 63
-def EXTRACT(DAY FROM a) 3 2 2 Y 32896 0 63
+def EXTRACT(DAY FROM a) 3 3 3 Y 32896 0 63
def EXTRACT(DAY_HOUR FROM a) 3 5 5 Y 32896 0 63
def EXTRACT(DAY_MINUTE FROM a) 3 7 7 Y 32896 0 63
def EXTRACT(DAY_SECOND FROM a) 3 9 9 Y 32896 0 63
@@ -3137,7 +3300,7 @@ EXTRACT(YEAR_MONTH FROM a) 0
EXTRACT(QUARTER FROM a) 0
EXTRACT(MONTH FROM a) 0
EXTRACT(WEEK FROM a) 613566757
-EXTRACT(DAY FROM a) 34
+EXTRACT(DAY FROM a) -34
EXTRACT(DAY_HOUR FROM a) -3422
EXTRACT(DAY_MINUTE FROM a) -342259
EXTRACT(DAY_SECOND FROM a) -34225959
@@ -3203,7 +3366,7 @@ EXTRACT(YEAR_MONTH FROM a) 0
EXTRACT(QUARTER FROM a) 0
EXTRACT(MONTH FROM a) 0
EXTRACT(WEEK FROM a) 613566757
-EXTRACT(DAY FROM a) 34
+EXTRACT(DAY FROM a) -34
EXTRACT(DAY_HOUR FROM a) -3422
EXTRACT(DAY_MINUTE FROM a) -342259
EXTRACT(DAY_SECOND FROM a) -34225959
@@ -3248,7 +3411,7 @@ t2 CREATE TABLE `t2` (
`EXTRACT(QUARTER FROM a)` int(2) DEFAULT NULL,
`EXTRACT(MONTH FROM a)` int(2) DEFAULT NULL,
`EXTRACT(WEEK FROM a)` int(2) DEFAULT NULL,
- `EXTRACT(DAY FROM a)` int(2) DEFAULT NULL,
+ `EXTRACT(DAY FROM a)` int(3) DEFAULT NULL,
`EXTRACT(DAY_HOUR FROM a)` int(5) DEFAULT NULL,
`EXTRACT(DAY_MINUTE FROM a)` int(7) DEFAULT NULL,
`EXTRACT(DAY_SECOND FROM a)` int(9) DEFAULT NULL,
@@ -3414,6 +3577,11 @@ ADDTIME(TIME'10:20:30', DATE'2001-01-01') AS c3,
ADDTIME(TIME'10:20:30', COALESCE(DATE'2001-01-01',TIMESTAMP'2001-01-01 00:00:00')) AS c4;
c1 c2 c3 c4
NULL NULL NULL NULL
+Warnings:
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '2001-01-01 00:00:00'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '2001-01-01 00:00:00'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '2001-01-01'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '2001-01-01 00:00:00'
SELECT
HOUR(TIMESTAMP'0000-00-01 10:00:00') AS h0,
TIME_TO_SEC(TIMESTAMP'0000-00-01 10:00:00') AS tts0,
@@ -3554,6 +3722,39 @@ DROP FUNCTION fn_sleep_before_now;
DROP TRIGGER trg_insert_t_ts;
DROP TABLE t_ts, t_trig;
#
+# MDEV-16878 Functions ADDTIME and SUBTIME get wrongly removed from WHERE by the equal expression optimizer
+#
+CREATE TABLE t1 (a TIME);
+INSERT INTO t1 VALUES ('00:00:10'),('00:00:20');
+SELECT a, SUBTIME(a,TIME'00:00:01'), ADDTIME(a,TIME'00:00:01') FROM t1;
+a SUBTIME(a,TIME'00:00:01') ADDTIME(a,TIME'00:00:01')
+00:00:10 00:00:09 00:00:11
+00:00:20 00:00:19 00:00:21
+SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09';
+a
+00:00:10
+SELECT * FROM t1 WHERE ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
+a
+SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09' AND ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
+a
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09' AND ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
+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 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where subtime(`test`.`t1`.`a`,TIME'00:00:01') = TIME'00:00:09' and addtime(`test`.`t1`.`a`,TIME'00:00:01') <= TIME'00:00:09'
+DROP TABLE t1;
+#
+# MDEV-15363 Wrong result for CAST(LAST_DAY(TIME'00:00:00') AS TIME)
+#
+set timestamp=unix_timestamp('2018-08-02 10:10:10');
+SELECT
+LAST_DAY(TIME'00:00:00') AS c1,
+CAST(CAST(LAST_DAY(TIME'00:00:00') AS DATE) AS TIME) AS c2,
+CAST(LAST_DAY(TIME'00:00:00') AS TIME) AS c3;
+c1 c2 c3
+2018-08-31 00:00:00 00:00:00
+# End of 10.3 tests
+#
# MDEV-14032 SEC_TO_TIME executes side effect two times
#
SET @a=10000000;
@@ -3582,3 +3783,2463 @@ a
f1 was called
DROP TABLE t1;
DROP FUNCTION f1;
+#
+# MDEV-17351 MICROSECOND(XXX(int_number_out_of_range)) erroneously returns 999999
+#
+# Reject anything that's parsed as DATETIME or DATE
+CREATE TABLE t1 (a VARCHAR(64));
+INSERT INTO t1 VALUES
+('2001-01-01 10:20:30'),
+('01-01-01 10:20:30'),
+('2001-01-01 '),
+('20010101102030'),
+('010101102030');
+SELECT ADDTIME(DATE'2001-01-01',a), a FROM t1;
+ADDTIME(DATE'2001-01-01',a) a
+NULL 2001-01-01 10:20:30
+NULL 01-01-01 10:20:30
+NULL 2001-01-01
+NULL 20010101102030
+NULL 010101102030
+Warnings:
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '2001-01-01 10:20:30'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '01-01-01 10:20:30'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '2001-01-01 '
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '20010101102030'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '010101102030'
+DROP TABLE t1;
+# GREATEST(decimal, time)
+SELECT
+GREATEST(8395959, TIME'00:00:00') AS c0,
+GREATEST(8395959.0, TIME'00:00:00') AS c1,
+GREATEST(8395959.00, TIME'00:00:00') AS c2,
+GREATEST(8395959.000, TIME'00:00:00') AS c3,
+GREATEST(8395959.0000, TIME'00:00:00') AS c4,
+GREATEST(8395959.00000, TIME'00:00:00') AS c5,
+GREATEST(8395959.000000, TIME'00:00:00') AS c6,
+GREATEST(8395959.0000000, TIME'00:00:00') AS c7;
+c0 838:59:59
+c1 838:59:59.9
+c2 838:59:59.99
+c3 838:59:59.999
+c4 838:59:59.9999
+c5 838:59:59.99999
+c6 838:59:59.999999
+c7 838:59:59.999999
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959.0'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959.00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959.000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959.0000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959.00000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959.000000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959.0000000'
+SELECT
+MICROSECOND(GREATEST(8395959, TIME'00:00:00')) AS c0,
+MICROSECOND(GREATEST(8395959.0, TIME'00:00:00')) AS c1,
+MICROSECOND(GREATEST(8395959.00, TIME'00:00:00')) AS c2,
+MICROSECOND(GREATEST(8395959.000, TIME'00:00:00')) AS c3,
+MICROSECOND(GREATEST(8395959.0000, TIME'00:00:00')) AS c4,
+MICROSECOND(GREATEST(8395959.00000, TIME'00:00:00')) AS c5,
+MICROSECOND(GREATEST(8395959.000000, TIME'00:00:00')) AS c6,
+MICROSECOND(GREATEST(8395959.0000000, TIME'00:00:00')) AS c7;
+c0 0
+c1 900000
+c2 990000
+c3 999000
+c4 999900
+c5 999990
+c6 999999
+c7 999999
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959.0'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959.00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959.000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959.0000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959.00000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959.000000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959.0000000'
+SELECT
+CAST(GREATEST(8395959, TIME'00:00:00') AS SIGNED) AS ci,
+CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,0)) AS c0,
+CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,1)) AS c1,
+CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,2)) AS c2,
+CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,3)) AS c3,
+CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,4)) AS c4,
+CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,5)) AS c5,
+CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,6)) AS c6,
+CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,7)) AS c7;
+ci 8385959
+c0 8385959
+c1 8385959.0
+c2 8385959.00
+c3 8385959.000
+c4 8385959.0000
+c5 8385959.00000
+c6 8385959.000000
+c7 8385959.0000000
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+SELECT
+GREATEST(8395959, TIME'00:00:00') AS ci,
+GREATEST(8395959, TIME'00:00:00')+0 AS c0,
+GREATEST(8395959, TIME'00:00:00')+0.0 AS c1,
+GREATEST(8395959, TIME'00:00:00')+0.00 AS c2,
+GREATEST(8395959, TIME'00:00:00')+0.000 AS c3,
+GREATEST(8395959, TIME'00:00:00')+0.0000 AS c4,
+GREATEST(8395959, TIME'00:00:00')+0.00000 AS c5,
+GREATEST(8395959, TIME'00:00:00')+0.000000 AS c6,
+GREATEST(8395959, TIME'00:00:00')+0.0000000 AS c7;
+ci 838:59:59
+c0 8385959
+c1 8385959.0
+c2 8385959.00
+c3 8385959.000
+c4 8385959.0000
+c5 8385959.00000
+c6 8385959.000000
+c7 8385959.0000000
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '8395959'
+# GREATEST(string, time)
+SELECT
+GREATEST('839:59:59', TIME'00:00:00') AS ci,
+GREATEST('839:59:59.0', TIME'00:00:00') AS c1,
+GREATEST('839:59:59.00', TIME'00:00:00') AS c2,
+GREATEST('839:59:59.000', TIME'00:00:00') AS c3,
+GREATEST('839:59:59.0000', TIME'00:00:00') AS c4,
+GREATEST('839:59:59.00000', TIME'00:00:00') AS c5,
+GREATEST('839:59:59.000000', TIME'00:00:00') AS c6,
+GREATEST('839:59:59.0000000', TIME'00:00:00') AS c7;
+ci 838:59:59
+c1 838:59:59.9
+c2 838:59:59.99
+c3 838:59:59.999
+c4 838:59:59.9999
+c5 838:59:59.99999
+c6 838:59:59.999999
+c7 838:59:59.999999
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59.0'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59.00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59.000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59.0000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59.00000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59.000000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59.0000000'
+SELECT
+MICROSECOND(GREATEST('839:59:59', TIME'00:00:00')) AS ci,
+MICROSECOND(GREATEST('839:59:59.0', TIME'00:00:00')) AS c1,
+MICROSECOND(GREATEST('839:59:59.00', TIME'00:00:00')) AS c2,
+MICROSECOND(GREATEST('839:59:59.000', TIME'00:00:00')) AS c3,
+MICROSECOND(GREATEST('839:59:59.0000', TIME'00:00:00')) AS c4,
+MICROSECOND(GREATEST('839:59:59.00000', TIME'00:00:00')) AS c5,
+MICROSECOND(GREATEST('839:59:59.000000', TIME'00:00:00')) AS c6,
+MICROSECOND(GREATEST('839:59:59.0000000', TIME'00:00:00')) AS c7;
+ci 0
+c1 900000
+c2 990000
+c3 999000
+c4 999900
+c5 999990
+c6 999999
+c7 999999
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59.0'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59.00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59.000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59.0000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59.00000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59.000000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59.0000000'
+SELECT
+CAST(GREATEST('839:59:59', TIME'00:00:00') AS SIGNED) AS ci,
+CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,0)) AS c0,
+CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,1)) AS c1,
+CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,2)) AS c2,
+CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,3)) AS c3,
+CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,4)) AS c4,
+CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,5)) AS c5,
+CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,6)) AS c6,
+CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,7)) AS c7;
+ci 8385959
+c0 8385959
+c1 8385959.0
+c2 8385959.00
+c3 8385959.000
+c4 8385959.0000
+c5 8385959.00000
+c6 8385959.000000
+c7 8385959.0000000
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+SELECT
+GREATEST('839:59:59', TIME'00:00:00') AS ci,
+GREATEST('839:59:59', TIME'00:00:00')+0 AS c0,
+GREATEST('839:59:59', TIME'00:00:00')+0.0 AS c1,
+GREATEST('839:59:59', TIME'00:00:00')+0.00 AS c2,
+GREATEST('839:59:59', TIME'00:00:00')+0.000 AS c3,
+GREATEST('839:59:59', TIME'00:00:00')+0.0000 AS c4,
+GREATEST('839:59:59', TIME'00:00:00')+0.00000 AS c5,
+GREATEST('839:59:59', TIME'00:00:00')+0.000000 AS c6,
+GREATEST('839:59:59', TIME'00:00:00')+0.0000000 AS c7;
+ci 838:59:59
+c0 8385959
+c1 8385959.0
+c2 8385959.00
+c3 8385959.000
+c4 8385959.0000
+c5 8385959.00000
+c6 8385959.000000
+c7 8385959.0000000
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+# ADDTIME(datetime, decimal)
+SELECT
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS c0,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0) AS c1,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.00) AS c2,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.000) AS c3,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0000) AS c4,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.00000) AS c5,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.000000) AS c6,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0000000) AS c7;
+c0 2001-02-04 23:59:59
+c1 2001-02-04 23:59:59.0
+c2 2001-02-04 23:59:59.00
+c3 2001-02-04 23:59:59.000
+c4 2001-02-04 23:59:59.0000
+c5 2001-02-04 23:59:59.00000
+c6 2001-02-04 23:59:59.000000
+c7 2001-02-04 23:59:59.000000
+Warnings:
+Level Note
+Code 1292
+Message Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
+SELECT
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)) AS c0,
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0)) AS c1,
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.00)) AS c2,
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.000)) AS c3,
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0000)) AS c4,
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.00000)) AS c5,
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.000000)) AS c6,
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0000000)) AS c7;
+c0 0
+c1 0
+c2 0
+c3 0
+c4 0
+c5 0
+c6 0
+c7 0
+Warnings:
+Level Note
+Code 1292
+Message Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
+SELECT
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS SIGNED) AS ci,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,0)) AS c0,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,1)) AS c1,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,2)) AS c2,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,3)) AS c3,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,4)) AS c4,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,5)) AS c5,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,6)) AS c6,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,7)) AS c7;
+ci 20010204235959
+c0 20010204235959
+c1 20010204235959.0
+c2 20010204235959.00
+c3 20010204235959.000
+c4 20010204235959.0000
+c5 20010204235959.00000
+c6 20010204235959.000000
+c7 20010204235959.0000000
+SELECT
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS ci,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0 AS c0,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.0 AS c1,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.00 AS c2,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.000 AS c3,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.0000 AS c4,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.00000 AS c5,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.000000 AS c6,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.0000000 AS c7;
+ci 2001-02-04 23:59:59
+c0 20010204235959
+c1 20010204235959.0
+c2 20010204235959.00
+c3 20010204235959.000
+c4 20010204235959.0000
+c5 20010204235959.00000
+c6 20010204235959.000000
+c7 20010204235959.0000000
+# ADDTIME(datetime, string)
+SELECT
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS c0,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0') AS c1,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.00') AS c2,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.000') AS c3,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0000') AS c4,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.00000') AS c5,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.000000') AS c6,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0000000') AS c7;
+c0 2001-02-04 23:59:59
+c1 2001-02-04 23:59:59.0
+c2 2001-02-04 23:59:59.00
+c3 2001-02-04 23:59:59.000
+c4 2001-02-04 23:59:59.0000
+c5 2001-02-04 23:59:59.00000
+c6 2001-02-04 23:59:59.000000
+c7 2001-02-04 23:59:59.000000
+Warnings:
+Level Note
+Code 1292
+Message Truncated incorrect INTERVAL DAY TO SECOND value: '839:59:59.0000000'
+SELECT
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')) AS c0,
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0')) AS c1,
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.00')) AS c2,
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.000')) AS c3,
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0000')) AS c4,
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.00000')) AS c5,
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.000000')) AS c6,
+MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0000000')) AS c7;
+c0 0
+c1 0
+c2 0
+c3 0
+c4 0
+c5 0
+c6 0
+c7 0
+Warnings:
+Level Note
+Code 1292
+Message Truncated incorrect INTERVAL DAY TO SECOND value: '839:59:59.0000000'
+SELECT
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS SIGNED) AS ci,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,0)) AS c0,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,1)) AS c1,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,2)) AS c2,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,3)) AS c3,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,4)) AS c4,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,5)) AS c5,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,6)) AS c6,
+CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,7)) AS c7;
+ci 20010204235959
+c0 20010204235959
+c1 20010204235959.0
+c2 20010204235959.00
+c3 20010204235959.000
+c4 20010204235959.0000
+c5 20010204235959.00000
+c6 20010204235959.000000
+c7 20010204235959.0000000
+SELECT
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS ci,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0 AS c0,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.0 AS c1,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.00 AS c2,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.000 AS c3,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.0000 AS c4,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.00000 AS c5,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.000000 AS c6,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.0000000 AS c7;
+ci 2001-02-04 23:59:59
+c0 20010204235959
+c1 20010204235959.0
+c2 20010204235959.00
+c3 20010204235959.000
+c4 20010204235959.0000
+c5 20010204235959.00000
+c6 20010204235959.000000
+c7 20010204235959.0000000
+# ADDTIME(time, decimal)
+SELECT
+ADDTIME(TIME'00:00:00', 8395959) AS c0,
+ADDTIME(TIME'00:00:00', 8395959.0) AS c1,
+ADDTIME(TIME'00:00:00', 8395959.00) AS c2,
+ADDTIME(TIME'00:00:00', 8395959.000) AS c3,
+ADDTIME(TIME'00:00:00', 8395959.0000) AS c4,
+ADDTIME(TIME'00:00:00', 8395959.00000) AS c5,
+ADDTIME(TIME'00:00:00', 8395959.000000) AS c6,
+ADDTIME(TIME'00:00:00', 8395959.0000000) AS c7;
+c0 838:59:59
+c1 838:59:59.9
+c2 838:59:59.99
+c3 838:59:59.999
+c4 838:59:59.9999
+c5 838:59:59.99999
+c6 838:59:59.999999
+c7 838:59:59.999999
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Note
+Code 1292
+Message Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+SELECT
+MICROSECOND(ADDTIME(TIME'00:00:00', 8395959)) AS c0,
+MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.0)) AS c1,
+MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.00)) AS c2,
+MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.000)) AS c3,
+MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.0000)) AS c4,
+MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.00000)) AS c5,
+MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.000000)) AS c6,
+MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.0000000)) AS c7;
+c0 0
+c1 900000
+c2 990000
+c3 999000
+c4 999900
+c5 999990
+c6 999999
+c7 999999
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Note
+Code 1292
+Message Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+SELECT
+CAST(ADDTIME(TIME'00:00:00', 8395959) AS SIGNED) AS ci,
+CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,0)) AS c0,
+CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,1)) AS c1,
+CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,2)) AS c2,
+CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,3)) AS c3,
+CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,4)) AS c4,
+CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,5)) AS c5,
+CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,6)) AS c6,
+CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,7)) AS c7;
+ci 8385959
+c0 8385959
+c1 8385959.0
+c2 8385959.00
+c3 8385959.000
+c4 8385959.0000
+c5 8385959.00000
+c6 8385959.000000
+c7 8385959.0000000
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+SELECT
+ADDTIME(TIME'00:00:00', 8395959) AS ci,
+ADDTIME(TIME'00:00:00', 8395959)+0 AS c0,
+ADDTIME(TIME'00:00:00', 8395959)+0.0 AS c1,
+ADDTIME(TIME'00:00:00', 8395959)+0.00 AS c2,
+ADDTIME(TIME'00:00:00', 8395959)+0.000 AS c3,
+ADDTIME(TIME'00:00:00', 8395959)+0.0000 AS c4,
+ADDTIME(TIME'00:00:00', 8395959)+0.00000 AS c5,
+ADDTIME(TIME'00:00:00', 8395959)+0.000000 AS c6,
+ADDTIME(TIME'00:00:00', 8395959)+0.0000000 AS c7;
+ci 838:59:59
+c0 8385959
+c1 8385959.0
+c2 8385959.00
+c3 8385959.000
+c4 8385959.0000
+c5 8385959.00000
+c6 8385959.000000
+c7 8385959.0000000
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+# ADDTIME(time,string)
+SELECT
+ADDTIME(TIME'00:00:00', '839:59:59') AS c0,
+ADDTIME(TIME'00:00:00', '839:59:59.0') AS c1,
+ADDTIME(TIME'00:00:00', '839:59:59.00') AS c2,
+ADDTIME(TIME'00:00:00', '839:59:59.000') AS c3,
+ADDTIME(TIME'00:00:00', '839:59:59.0000') AS c4,
+ADDTIME(TIME'00:00:00', '839:59:59.00000') AS c5,
+ADDTIME(TIME'00:00:00', '839:59:59.000000') AS c6,
+ADDTIME(TIME'00:00:00', '839:59:59.0000000') AS c7;
+c0 838:59:59
+c1 838:59:59.9
+c2 838:59:59.99
+c3 838:59:59.999
+c4 838:59:59.9999
+c5 838:59:59.99999
+c6 838:59:59.999999
+c7 838:59:59.999999
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Note
+Code 1292
+Message Truncated incorrect INTERVAL DAY TO SECOND value: '839:59:59.0000000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+SELECT
+MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59')) AS c0,
+MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.0')) AS c1,
+MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.00')) AS c2,
+MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.000')) AS c3,
+MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.0000')) AS c4,
+MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.00000')) AS c5,
+MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.000000')) AS c6,
+MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.0000000')) AS c7;
+c0 0
+c1 900000
+c2 990000
+c3 999000
+c4 999900
+c5 999990
+c6 999999
+c7 999999
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Note
+Code 1292
+Message Truncated incorrect INTERVAL DAY TO SECOND value: '839:59:59.0000000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+SELECT
+CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS SIGNED) AS ci,
+CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,0)) AS c0,
+CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,1)) AS c1,
+CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,2)) AS c2,
+CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,3)) AS c3,
+CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,4)) AS c4,
+CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,5)) AS c5,
+CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,6)) AS c6,
+CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,7)) AS c7;
+ci 8385959
+c0 8385959
+c1 8385959.0
+c2 8385959.00
+c3 8385959.000
+c4 8385959.0000
+c5 8385959.00000
+c6 8385959.000000
+c7 8385959.0000000
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+SELECT
+ADDTIME(TIME'00:00:00', '839:59:59') AS ci,
+ADDTIME(TIME'00:00:00', '839:59:59')+0 AS c0,
+ADDTIME(TIME'00:00:00', '839:59:59')+0.0 AS c1,
+ADDTIME(TIME'00:00:00', '839:59:59')+0.00 AS c2,
+ADDTIME(TIME'00:00:00', '839:59:59')+0.000 AS c3,
+ADDTIME(TIME'00:00:00', '839:59:59')+0.0000 AS c4,
+ADDTIME(TIME'00:00:00', '839:59:59')+0.00000 AS c5,
+ADDTIME(TIME'00:00:00', '839:59:59')+0.000000 AS c6,
+ADDTIME(TIME'00:00:00', '839:59:59')+0.0000000 AS c7;
+ci 838:59:59
+c0 8385959
+c1 8385959.0
+c2 8385959.00
+c3 8385959.000
+c4 8385959.0000
+c5 8385959.00000
+c6 8385959.000000
+c7 8385959.0000000
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+# ADDTIME(int,int)
+SELECT
+ADDTIME(0, 8395959) AS c,
+MICROSECOND(ADDTIME(0, 8395959)) AS cm,
+CAST(ADDTIME(0, 8395959) AS SIGNED) AS cs_fixme_mdev_17384,
+CAST(ADDTIME(0, 8395959) AS DECIMAL(30,0)) AS cd300;
+c 838:59:59
+cm 0
+cs_fixme_mdev_17384 838
+cd300 8385959
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect INTEGER value: '838:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+SELECT
+ADDTIME(20010101000000, 8395959) AS c,
+MICROSECOND(ADDTIME(20010101000000, 8395959)) AS cm,
+CAST(ADDTIME(20010101000000, 8395959) AS SIGNED) AS cs_fixme_mdev_17384,
+CAST(ADDTIME(20010101000000, 8395959) AS DECIMAL(30,0)) AS cd300;
+c 2001-02-04 23:59:59
+cm 0
+cs_fixme_mdev_17384 2001
+cd300 20010204235959
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect INTEGER value: '2001-02-04 23:59:59'
+# ADDTIME(decimal,int)
+# 8385960 in cd300 is correct: addtime returns '838:59:59.9'
+# which is further *rounded* to a decimals(30,0)
+SELECT
+ADDTIME(0.0, 8395959) AS c,
+MICROSECOND(ADDTIME(0.0, 8395959)) AS cm,
+CAST(ADDTIME(0.0, 8395959) AS SIGNED) AS cs_fixme_mdev_17384,
+CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,0)) AS cd300;
+c 838:59:59.9
+cm 900000
+cs_fixme_mdev_17384 838
+cd300 8385960
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect INTEGER value: '838:59:59.9'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+SELECT
+ADDTIME(20010101000000.0, 8395959) AS c,
+MICROSECOND(ADDTIME(20010101000000.0, 8395959)) AS cm,
+CAST(ADDTIME(20010101000000.0, 8395959) AS SIGNED) AS cs_fixme_mdev_17384,
+CAST(ADDTIME(20010101000000.0, 8395959) AS DECIMAL(30,0)) AS cd300;
+c 2001-02-04 23:59:59.0
+cm 0
+cs_fixme_mdev_17384 2001
+cd300 20010204235959
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect INTEGER value: '2001-02-04 23:59:59.0'
+# ADDTIME(decimal,decimal)
+SELECT
+ADDTIME(0.0, 8395959.0) AS c1,
+ADDTIME(0.0, 8395959.00) AS c2,
+ADDTIME(0.0, 8395959.000) AS c3,
+ADDTIME(0.0, 8395959.0000) AS c4,
+ADDTIME(0.0, 8395959.00000) AS c5,
+ADDTIME(0.0, 8395959.000000) AS c6,
+ADDTIME(0.0, 8395959.0000000) AS c7;
+c1 838:59:59.9
+c2 838:59:59.99
+c3 838:59:59.999
+c4 838:59:59.9999
+c5 838:59:59.99999
+c6 838:59:59.999999
+c7 838:59:59.999999
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Note
+Code 1292
+Message Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+SELECT
+MICROSECOND(ADDTIME(0.0, 8395959.0)) AS c1,
+MICROSECOND(ADDTIME(0.0, 8395959.00)) AS c2,
+MICROSECOND(ADDTIME(0.0, 8395959.000)) AS c3,
+MICROSECOND(ADDTIME(0.0, 8395959.0000)) AS c4,
+MICROSECOND(ADDTIME(0.0, 8395959.00000)) AS c5,
+MICROSECOND(ADDTIME(0.0, 8395959.000000)) AS c6,
+MICROSECOND(ADDTIME(0.0, 8395959.0000000)) AS c7;
+c1 900000
+c2 990000
+c3 999000
+c4 999900
+c5 999990
+c6 999999
+c7 999999
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Note
+Code 1292
+Message Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+# 8385960 in c1 is correct: addtime returns '838:59:59.9'
+# which is further *rounded* to a decimals(30,0)
+SELECT
+CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,0)) AS c0,
+CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,1)) AS c1,
+CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,2)) AS c2,
+CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,3)) AS c3,
+CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,4)) AS c4,
+CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,5)) AS c5,
+CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,6)) AS c6,
+CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,7)) AS c7;
+c0 8385960
+c1 8385959.9
+c2 8385959.90
+c3 8385959.900
+c4 8385959.9000
+c5 8385959.90000
+c6 8385959.900000
+c7 8385959.9000000
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+SELECT
+ADDTIME(0.0, 8395959)+0 AS c0,
+ADDTIME(0.0, 8395959)+0.0 AS c1,
+ADDTIME(0.0, 8395959)+0.00 AS c2,
+ADDTIME(0.0, 8395959)+0.000 AS c3,
+ADDTIME(0.0, 8395959)+0.0000 AS c4,
+ADDTIME(0.0, 8395959)+0.00000 AS c5,
+ADDTIME(0.0, 8395959)+0.000000 AS c6,
+ADDTIME(0.0, 8395959)+0.0000000 AS c7;
+c0 8385959.9
+c1 8385959.9
+c2 8385959.90
+c3 8385959.900
+c4 8385959.9000
+c5 8385959.90000
+c6 8385959.900000
+c7 8385959.9000000
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '839:59:59'
+# TIMESTAMP(string,decimal)
+SELECT
+TIMESTAMP('2001-01-01', 8395959) AS ci,
+TIMESTAMP('2001-01-01', 8395959.0) AS c1,
+TIMESTAMP('2001-01-01', 8395959.00) AS c2,
+TIMESTAMP('2001-01-01', 8395959.000) AS c3,
+TIMESTAMP('2001-01-01', 8395959.0000) AS c4,
+TIMESTAMP('2001-01-01', 8395959.00000) AS c5,
+TIMESTAMP('2001-01-01', 8395959.000000) AS c6,
+TIMESTAMP('2001-01-01', 8395959.0000000) AS c7;
+ci 2001-02-04 23:59:59
+c1 2001-02-04 23:59:59.0
+c2 2001-02-04 23:59:59.00
+c3 2001-02-04 23:59:59.000
+c4 2001-02-04 23:59:59.0000
+c5 2001-02-04 23:59:59.00000
+c6 2001-02-04 23:59:59.000000
+c7 2001-02-04 23:59:59.000000
+Warnings:
+Level Note
+Code 1292
+Message Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
+SELECT
+MICROSECOND(TIMESTAMP('2001-01-01', 8395959)) AS ci,
+MICROSECOND(TIMESTAMP('2001-01-01', 8395959.0)) AS c1,
+MICROSECOND(TIMESTAMP('2001-01-01', 8395959.00)) AS c2,
+MICROSECOND(TIMESTAMP('2001-01-01', 8395959.000)) AS c3,
+MICROSECOND(TIMESTAMP('2001-01-01', 8395959.0000)) AS c4,
+MICROSECOND(TIMESTAMP('2001-01-01', 8395959.00000)) AS c5,
+MICROSECOND(TIMESTAMP('2001-01-01', 8395959.000000)) AS c6,
+MICROSECOND(TIMESTAMP('2001-01-01', 8395959.0000000)) AS c7;
+ci 0
+c1 0
+c2 0
+c3 0
+c4 0
+c5 0
+c6 0
+c7 0
+Warnings:
+Level Note
+Code 1292
+Message Truncated incorrect INTERVAL DAY TO SECOND value: '8395959.0000000'
+SELECT
+CAST(TIMESTAMP('2001-01-01', 8395959) AS SIGNED) AS ci,
+CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,0)) AS c0,
+CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,1)) AS c1,
+CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,2)) AS c2,
+CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,3)) AS c3,
+CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,4)) AS c4,
+CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,5)) AS c5,
+CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,6)) AS c6;
+ci 20010204235959
+c0 20010204235959
+c1 20010204235959.0
+c2 20010204235959.00
+c3 20010204235959.000
+c4 20010204235959.0000
+c5 20010204235959.00000
+c6 20010204235959.000000
+SELECT
+TIMESTAMP('2001-01-01', 8395959) AS ci,
+TIMESTAMP('2001-01-01', 8395959)+0 AS c0,
+TIMESTAMP('2001-01-01', 8395959)+0.0 AS c1,
+TIMESTAMP('2001-01-01', 8395959)+0.00 AS c2,
+TIMESTAMP('2001-01-01', 8395959)+0.000 AS c3,
+TIMESTAMP('2001-01-01', 8395959)+0.0000 AS c4,
+TIMESTAMP('2001-01-01', 8395959)+0.00000 AS c5,
+TIMESTAMP('2001-01-01', 8395959)+0.000000 AS c6,
+TIMESTAMP('2001-01-01', 8395959)+0.0000000 AS c7;
+ci 2001-02-04 23:59:59
+c0 20010204235959
+c1 20010204235959.0
+c2 20010204235959.00
+c3 20010204235959.000
+c4 20010204235959.0000
+c5 20010204235959.00000
+c6 20010204235959.000000
+c7 20010204235959.0000000
+# TIMESTAMP(string,string)
+SELECT
+TIMESTAMP('2001-01-01', '839:59:59') AS ci,
+TIMESTAMP('2001-01-01', '839:59:59.0') AS c1,
+TIMESTAMP('2001-01-01', '839:59:59.00') AS c2,
+TIMESTAMP('2001-01-01', '839:59:59.000') AS c3,
+TIMESTAMP('2001-01-01', '839:59:59.0000') AS c4,
+TIMESTAMP('2001-01-01', '839:59:59.00000') AS c5,
+TIMESTAMP('2001-01-01', '839:59:59.000000') AS c6,
+TIMESTAMP('2001-01-01', '839:59:59.0000000') AS c7;
+ci 2001-02-04 23:59:59
+c1 2001-02-04 23:59:59.0
+c2 2001-02-04 23:59:59.00
+c3 2001-02-04 23:59:59.000
+c4 2001-02-04 23:59:59.0000
+c5 2001-02-04 23:59:59.00000
+c6 2001-02-04 23:59:59.000000
+c7 2001-02-04 23:59:59.000000
+Warnings:
+Level Note
+Code 1292
+Message Truncated incorrect INTERVAL DAY TO SECOND value: '839:59:59.0000000'
+SELECT
+MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59')) AS ci,
+MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.0')) AS c1,
+MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.00')) AS c2,
+MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.000')) AS c3,
+MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.0000')) AS c4,
+MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.00000')) AS c5,
+MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.000000')) AS c6,
+MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.0000000')) AS c7;
+ci 0
+c1 0
+c2 0
+c3 0
+c4 0
+c5 0
+c6 0
+c7 0
+Warnings:
+Level Note
+Code 1292
+Message Truncated incorrect INTERVAL DAY TO SECOND value: '839:59:59.0000000'
+SELECT
+CAST(TIMESTAMP('2001-01-01', '839:59:59') AS SIGNED) AS ci,
+CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,0)) AS c0,
+CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,1)) AS c1,
+CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,2)) AS c2,
+CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,3)) AS c3,
+CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,4)) AS c4,
+CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,5)) AS c5,
+CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,6)) AS c6;
+ci 20010204235959
+c0 20010204235959
+c1 20010204235959.0
+c2 20010204235959.00
+c3 20010204235959.000
+c4 20010204235959.0000
+c5 20010204235959.00000
+c6 20010204235959.000000
+SELECT
+TIMESTAMP('2001-01-01', '839:59:59') AS ci,
+TIMESTAMP('2001-01-01', '839:59:59')+0 AS c0,
+TIMESTAMP('2001-01-01', '839:59:59')+0.0 AS c1,
+TIMESTAMP('2001-01-01', '839:59:59')+0.00 AS c2,
+TIMESTAMP('2001-01-01', '839:59:59')+0.000 AS c3,
+TIMESTAMP('2001-01-01', '839:59:59')+0.0000 AS c4,
+TIMESTAMP('2001-01-01', '839:59:59')+0.00000 AS c5,
+TIMESTAMP('2001-01-01', '839:59:59')+0.000000 AS c6,
+TIMESTAMP('2001-01-01', '839:59:59')+0.0000000 AS c7;
+ci 2001-02-04 23:59:59
+c0 20010204235959
+c1 20010204235959.0
+c2 20010204235959.00
+c3 20010204235959.000
+c4 20010204235959.0000
+c5 20010204235959.00000
+c6 20010204235959.000000
+c7 20010204235959.0000000
+# Corner cases for TIMESTAMP(timestamp,xxx)
+# HOUR is outside of supported INTERVAL DAYS TO SECONDS range
+# Expect NULL with INTERVAL warnings
+CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
+INSERT INTO t1 VALUES ('4294967296:00:00', '178956970 16:00:00');
+INSERT INTO t1 VALUES ('4294967295:59:59', '178956970 15:59:59');
+INSERT INTO t1 VALUES ('4294967294:59:59', '178956970 14:59:59');
+INSERT INTO t1 VALUES ('87649416:00:00', '3652059 00:00:00');
+SELECT TIMESTAMP('0001-01-01 00:00:00', a) AS ta, TIMESTAMP('0001-01-01 00:00:00', b) AS tb FROM t1;
+ta tb
+NULL NULL
+NULL NULL
+NULL NULL
+NULL NULL
+Warnings:
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '4294967296:00:00'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '178956970 16:00:00'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '178956970 15:59:59'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '4294967294:59:59'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '178956970 14:59:59'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '87649416:00:00'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '3652059 00:00:00'
+DROP TABLE t1;
+CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
+INSERT INTO t1 VALUES ('-4294967296:00:00', '-178956970 16:00:00');
+INSERT INTO t1 VALUES ('-4294967295:59:59', '-178956970 15:59:59');
+INSERT INTO t1 VALUES ('-4294967294:59:59', '-178956970 14:59:59');
+INSERT INTO t1 VALUES ('-87649416:00:00', '-3652059 00:00:00');
+SELECT TIMESTAMP('9999-12-31 23:59:59', a) AS ta, TIMESTAMP('9999-12-31 23:59:59.999999', b) AS tb FROM t1;
+ta tb
+NULL NULL
+NULL NULL
+NULL NULL
+NULL NULL
+Warnings:
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '-4294967296:00:00'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '-178956970 16:00:00'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '-4294967295:59:59'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '-178956970 15:59:59'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '-4294967294:59:59'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '-178956970 14:59:59'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '-87649416:00:00'
+Warning 1292 Incorrect INTERVAL DAY TO SECOND value: '-3652059 00:00:00'
+DROP TABLE t1;
+# HOUR is OK
+# Expect max or near-max DATETIME value + no INTERVAL warnings
+CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
+INSERT INTO t1 VALUES ('87649415:59:59.999999', '3652058 23:59:59.999999');
+INSERT INTO t1 VALUES ('87649415:59:59', '3652058 23:59:59');
+SELECT TIMESTAMP('0001-01-01 00:00:00', a) AS ta, TIMESTAMP('0001-01-01 00:00:00', b) AS tb FROM t1;
+ta tb
+9999-12-31 23:59:59.999999 9999-12-31 23:59:59.999999
+9999-12-31 23:59:59.000000 9999-12-31 23:59:59.000000
+DROP TABLE t1;
+# HOUR is OK
+# Expect near '0001-01-01 00:00:00' DATETIME value + no INTERVAL warnings
+CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
+INSERT INTO t1 VALUES ('-87649415:59:59.999999', '-3652058 23:59:59.999999');
+INSERT INTO t1 VALUES ('-87649415:59:59', '-3652058 23:59:59');
+SELECT TIMESTAMP('9999-12-31 23:59:59', a) AS ta, TIMESTAMP('9999-12-31 23:59:59.999999', b) AS tb FROM t1;
+ta tb
+NULL 0001-01-01 00:00:00.000000
+0001-01-01 00:00:00.000000 0001-01-01 00:00:00.999999
+DROP TABLE t1;
+# HOUR is OK
+# Expect NULL on datetime arithmetic overflow + no INTERVAL warnings
+CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
+INSERT INTO t1 VALUES ('-00:00:00.000001', '-0 00:00:00.000001');
+SELECT TIMESTAMP('0001-01-01 00:00:00', a) AS ta, TIMESTAMP('0001-01-01 00:00:00', b) AS tb FROM t1;
+ta tb
+NULL NULL
+DROP TABLE t1;
+# Corner cases for ADDTIME(timestamp,xxx)
+# HOUR is outside of UINT_MAX32 range
+# Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
+SELECT
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959) AS ci,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0 AS c0,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.0 AS c1,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.00 AS c2,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.000 AS c3,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.0000 AS c4,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.00000 AS c5,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.000000 AS c6,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.0000000 AS c7;
+ci NULL
+c0 NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+c7 NULL
+Warnings:
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+SELECT
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59') AS ci,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0 AS c0,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.0 AS c1,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.00 AS c2,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.000 AS c3,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.0000 AS c4,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.00000 AS c5,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.000000 AS c6,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.0000000 AS c7;
+ci NULL
+c0 NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+c7 NULL
+Warnings:
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+# HOUR UINT_MAX32
+# Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
+SELECT
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959) AS ci,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0 AS c0,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.0 AS c1,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.00 AS c2,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.000 AS c3,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.0000 AS c4,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.00000 AS c5,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.000000 AS c6,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.0000000 AS c7;
+ci NULL
+c0 NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+c7 NULL
+Warnings:
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+SELECT
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59') AS ci,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0 AS c0,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.0 AS c1,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.00 AS c2,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.000 AS c3,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.0000 AS c4,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.00000 AS c5,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.000000 AS c6,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.0000000 AS c7;
+ci NULL
+c0 NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+c7 NULL
+Warnings:
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+# HOUR is max_useful_hour()+1
+# Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
+SELECT
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959) AS ci,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0 AS c0,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.0 AS c1,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.00 AS c2,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.000 AS c3,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.0000 AS c4,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.00000 AS c5,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.000000 AS c6,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.0000000 AS c7;
+ci NULL
+c0 NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+c7 NULL
+Warnings:
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+SELECT
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59') AS ci,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0 AS c0,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.0 AS c1,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.00 AS c2,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.000 AS c3,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.0000 AS c4,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.00000 AS c5,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.000000 AS c6,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.0000000 AS c7;
+ci NULL
+c0 NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+c7 NULL
+Warnings:
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+# HOUR is max_useful_hour()
+# Expect NULL (calc_time_diff overflows ) + no INTERVAL warnings
+SELECT
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959) AS ci,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0 AS c0,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.0 AS c1,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.00 AS c2,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.000 AS c3,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.0000 AS c4,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.00000 AS c5,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.000000 AS c6,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.0000000 AS c7;
+ci NULL
+c0 NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+c7 NULL
+SELECT
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59') AS ci,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0 AS c0,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.0 AS c1,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.00 AS c2,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.000 AS c3,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.0000 AS c4,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.00000 AS c5,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.000000 AS c6,
+ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.0000000 AS c7;
+ci NULL
+c0 NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+c7 NULL
+# HOUR is max_useful_hour()
+# Expect non-NULL + no warnings
+SELECT
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959) AS ci,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0 AS c0,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.0 AS c1,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.00 AS c2,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.000 AS c3,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.0000 AS c4,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.00000 AS c5,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.000000 AS c6,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.0000000 AS c7;
+ci 9999-12-31 23:59:59
+c0 99991231235959
+c1 99991231235959.0
+c2 99991231235959.00
+c3 99991231235959.000
+c4 99991231235959.0000
+c5 99991231235959.00000
+c6 99991231235959.000000
+c7 99991231235959.0000000
+SELECT
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59') AS ci,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0 AS c0,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.0 AS c1,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.00 AS c2,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.000 AS c3,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.0000 AS c4,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.00000 AS c5,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.000000 AS c6,
+ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.0000000 AS c7;
+ci 9999-12-31 23:59:59
+c0 99991231235959
+c1 99991231235959.0
+c2 99991231235959.00
+c3 99991231235959.000
+c4 99991231235959.0000
+c5 99991231235959.00000
+c6 99991231235959.000000
+c7 99991231235959.0000000
+# Corner cases for ADDTIME(time,xxx)
+# HOUR outside of UINT32 range
+# Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
+SELECT
+ADDTIME(TIME'00:00:00', 42949672965959) AS ci,
+ADDTIME(TIME'00:00:00', 42949672965959)+0 AS c0,
+ADDTIME(TIME'00:00:00', 42949672965959)+0.0 AS c1,
+ADDTIME(TIME'00:00:00', 42949672965959)+0.00 AS c2,
+ADDTIME(TIME'00:00:00', 42949672965959)+0.000 AS c3,
+ADDTIME(TIME'00:00:00', 42949672965959)+0.0000 AS c4,
+ADDTIME(TIME'00:00:00', 42949672965959)+0.00000 AS c5,
+ADDTIME(TIME'00:00:00', 42949672965959)+0.000000 AS c6,
+ADDTIME(TIME'00:00:00', 42949672965959)+0.0000000 AS c7;
+ci NULL
+c0 NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+c7 NULL
+Warnings:
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672965959'
+SELECT
+ADDTIME(TIME'00:00:00', '4294967296:59:59') AS ci,
+ADDTIME(TIME'00:00:00', '4294967296:59:59')+0 AS c0,
+ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.0 AS c1,
+ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.00 AS c2,
+ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.000 AS c3,
+ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.0000 AS c4,
+ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.00000 AS c5,
+ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.000000 AS c6,
+ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.0000000 AS c7;
+ci NULL
+c0 NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+c7 NULL
+Warnings:
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967296:59:59'
+# HOUR is UINT_MAX32 (outside of INTERVAL DAY TO SECOND range)
+# Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
+SELECT
+ADDTIME(TIME'00:00:00', 42949672955959) AS ci,
+ADDTIME(TIME'00:00:00', 42949672955959)+0 AS c0,
+ADDTIME(TIME'00:00:00', 42949672955959)+0.0 AS c1,
+ADDTIME(TIME'00:00:00', 42949672955959)+0.00 AS c2,
+ADDTIME(TIME'00:00:00', 42949672955959)+0.000 AS c3,
+ADDTIME(TIME'00:00:00', 42949672955959)+0.0000 AS c4,
+ADDTIME(TIME'00:00:00', 42949672955959)+0.00000 AS c5,
+ADDTIME(TIME'00:00:00', 42949672955959)+0.000000 AS c6,
+ADDTIME(TIME'00:00:00', 42949672955959)+0.0000000 AS c7;
+ci NULL
+c0 NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+c7 NULL
+Warnings:
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '42949672955959'
+SELECT
+ADDTIME(TIME'00:00:00', '4294967295:59:59') AS ci,
+ADDTIME(TIME'00:00:00', '4294967295:59:59')+0 AS c0,
+ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.0 AS c1,
+ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.00 AS c2,
+ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.000 AS c3,
+ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.0000 AS c4,
+ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.00000 AS c5,
+ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.000000 AS c6,
+ADDTIME(TIME'00:00:00', '4294967295;00:00')+0.0000000 AS c7;
+ci NULL
+c0 NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+c7 NULL
+Warnings:
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '4294967295;00:00'
+# HOUR is max_useful_hour()+1 (outside of INTERVAL DAY TO SECOND range)
+# Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
+SELECT
+ADDTIME(TIME'00:00:00', 876494165959) AS ci,
+ADDTIME(TIME'00:00:00', 876494165959)+0 AS c0,
+ADDTIME(TIME'00:00:00', 876494165959)+0.0 AS c1,
+ADDTIME(TIME'00:00:00', 876494165959)+0.00 AS c2,
+ADDTIME(TIME'00:00:00', 876494165959)+0.000 AS c3,
+ADDTIME(TIME'00:00:00', 876494165959)+0.0000 AS c4,
+ADDTIME(TIME'00:00:00', 876494165959)+0.00000 AS c5,
+ADDTIME(TIME'00:00:00', 876494165959)+0.000000 AS c6,
+ADDTIME(TIME'00:00:00', 876494165959)+0.0000000 AS c7;
+ci NULL
+c0 NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+c7 NULL
+Warnings:
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+SELECT
+ADDTIME(TIME'00:00:00', '87649416:59:59') AS ci,
+ADDTIME(TIME'00:00:00', '87649416:59:59')+0 AS c0,
+ADDTIME(TIME'00:00:00', '87649416:59:59')+0.0 AS c1,
+ADDTIME(TIME'00:00:00', '87649416:59:59')+0.00 AS c2,
+ADDTIME(TIME'00:00:00', '87649416:59:59')+0.000 AS c3,
+ADDTIME(TIME'00:00:00', '87649416:59:59')+0.0000 AS c4,
+ADDTIME(TIME'00:00:00', '87649416:59:59')+0.00000 AS c5,
+ADDTIME(TIME'00:00:00', '87649416:59:59')+0.000000 AS c6,
+ADDTIME(TIME'00:00:00', '87649416:59:59')+0.0000000 AS c7;
+ci NULL
+c0 NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+c7 NULL
+Warnings:
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+# HOUR is max_useful_hour()+1 (outside of INTERVAL DAY TO SECOND range)
+# Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
+SELECT
+ADDTIME(TIME'-838:59:59', 876494165959) AS ci,
+ADDTIME(TIME'-838:59:59.9', 876494165959) AS c1,
+ADDTIME(TIME'-838:59:59.99', 876494165959) AS c2,
+ADDTIME(TIME'-838:59:59.999', 876494165959) AS c3,
+ADDTIME(TIME'-838:59:59.9999', 876494165959) AS c4,
+ADDTIME(TIME'-838:59:59.99999', 876494165959) AS c5,
+ADDTIME(TIME'-838:59:59.999999', 876494165959) AS c6;
+ci NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+Warnings:
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '876494165959'
+SELECT
+ADDTIME(TIME'-838:59:59', '87649416:59:59') AS ci,
+ADDTIME(TIME'-838:59:59.9', '87649416:59:59') AS c1,
+ADDTIME(TIME'-838:59:59.99', '87649416:59:59') AS c2,
+ADDTIME(TIME'-838:59:59.999', '87649416:59:59') AS c3,
+ADDTIME(TIME'-838:59:59.9999', '87649416:59:59') AS c4,
+ADDTIME(TIME'-838:59:59.99999', '87649416:59:59') AS c5,
+ADDTIME(TIME'-838:59:59.999999', '87649416:59:59') AS c6;
+ci NULL
+c1 NULL
+c2 NULL
+c3 NULL
+c4 NULL
+c5 NULL
+c6 NULL
+Warnings:
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+Level Warning
+Code 1292
+Message Incorrect INTERVAL DAY TO SECOND value: '87649416:59:59'
+SELECT
+ADDTIME(TIME'-838:59:59.9999999', '87649416:59:59') AS c7;
+c7 NULL
+# HOUR is max_useful_hour() (inside INTERVAL DAY TO SECOND range)
+# Expect max TIME(0) + zero fraction + TIME warnings + no INTEVAL warnings
+SELECT
+ADDTIME(TIME'00:00:00', 876494155959) AS ci,
+ADDTIME(TIME'00:00:00', 876494155959)+0 AS c0,
+ADDTIME(TIME'00:00:00', 876494155959)+0.0 AS c1,
+ADDTIME(TIME'00:00:00', 876494155959)+0.00 AS c2,
+ADDTIME(TIME'00:00:00', 876494155959)+0.000 AS c3,
+ADDTIME(TIME'00:00:00', 876494155959)+0.0000 AS c4,
+ADDTIME(TIME'00:00:00', 876494155959)+0.00000 AS c5,
+ADDTIME(TIME'00:00:00', 876494155959)+0.000000 AS c6,
+ADDTIME(TIME'00:00:00', 876494155959)+0.0000000 AS c7;
+ci 838:59:59
+c0 8385959
+c1 8385959.0
+c2 8385959.00
+c3 8385959.000
+c4 8385959.0000
+c5 8385959.00000
+c6 8385959.000000
+c7 8385959.0000000
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+SELECT
+ADDTIME(TIME'00:00:00', '87649415:59:59') AS ci,
+ADDTIME(TIME'00:00:00', '87649415:59:59')+0 AS c0,
+ADDTIME(TIME'00:00:00', '87649415:59:59')+0.0 AS c1,
+ADDTIME(TIME'00:00:00', '87649415:59:59')+0.00 AS c2,
+ADDTIME(TIME'00:00:00', '87649415:59:59')+0.000 AS c3,
+ADDTIME(TIME'00:00:00', '87649415:59:59')+0.0000 AS c4,
+ADDTIME(TIME'00:00:00', '87649415:59:59')+0.00000 AS c5,
+ADDTIME(TIME'00:00:00', '87649415:59:59')+0.000000 AS c6,
+ADDTIME(TIME'00:00:00', '87649415:59:59')+0.0000000 AS c7;
+ci 838:59:59
+c0 8385959
+c1 8385959.0
+c2 8385959.00
+c3 8385959.000
+c4 8385959.0000
+c5 8385959.00000
+c6 8385959.000000
+c7 8385959.0000000
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87649415:59:59'
+# HOUR is max_useful_hour() (inside INTERVAL DAY TO SECOND range)
+# Expect max TIME(N) + TIME warnings + no INTERVAL warnings
+SELECT
+ADDTIME(TIME'-838:59:59', 876494155959) AS ci,
+ADDTIME(TIME'-838:59:59.9', 876494155959) AS c1,
+ADDTIME(TIME'-838:59:59.99', 876494155959) AS c2,
+ADDTIME(TIME'-838:59:59.999', 876494155959) AS c3,
+ADDTIME(TIME'-838:59:59.9999', 876494155959) AS c4,
+ADDTIME(TIME'-838:59:59.99999', 876494155959) AS c5,
+ADDTIME(TIME'-838:59:59.999999', 876494155959) AS c6;
+ci 838:59:59
+c1 838:59:59.9
+c2 838:59:59.99
+c3 838:59:59.999
+c4 838:59:59.9999
+c5 838:59:59.99999
+c6 838:59:59.999999
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87648577:00:00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87648576:59:59.100000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87648576:59:59.010000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87648576:59:59.001000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87648576:59:59.000100'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87648576:59:59.000010'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87648576:59:59.000001'
+SELECT
+ADDTIME(TIME'-838:59:59', '87649415:59:59') AS ci,
+ADDTIME(TIME'-838:59:59.9', '87649415:59:59') AS c1,
+ADDTIME(TIME'-838:59:59.99', '87649415:59:59') AS c2,
+ADDTIME(TIME'-838:59:59.999', '87649415:59:59') AS c3,
+ADDTIME(TIME'-838:59:59.9999', '87649415:59:59') AS c4,
+ADDTIME(TIME'-838:59:59.99999', '87649415:59:59') AS c5,
+ADDTIME(TIME'-838:59:59.999999', '87649415:59:59') AS c6;
+ci 838:59:59
+c1 838:59:59.9
+c2 838:59:59.99
+c3 838:59:59.999
+c4 838:59:59.9999
+c5 838:59:59.99999
+c6 838:59:59.999999
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87648577:00:00'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87648576:59:59.100000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87648576:59:59.010000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87648576:59:59.001000'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87648576:59:59.000100'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87648576:59:59.000010'
+Level Warning
+Code 1292
+Message Truncated incorrect time value: '87648576:59:59.000001'
+SELECT
+ADDTIME(TIME'-838:59:59.9999999', '87649415:59:59') AS c7;
+c7 838:59:59.999999
+#
+# MDEV-17400 The result of TIME('42949672965959-01') depends on architecture
+#
+SELECT TIME('42949672955959-01'), TIME('42949672965959-01');
+TIME('42949672955959-01') TIME('42949672965959-01')
+NULL NULL
+Warnings:
+Warning 1292 Incorrect time value: '42949672955959-01'
+Warning 1292 Incorrect time value: '42949672965959-01'
+SELECT TIME('18446744073709551615-01'), TIME('18446744073709551616-01');
+TIME('18446744073709551615-01') TIME('18446744073709551616-01')
+NULL NULL
+Warnings:
+Warning 1292 Incorrect time value: '18446744073709551615-01'
+Warning 1292 Incorrect time value: '18446744073709551616-01'
+#
+# MDEV-17434 EXTRACT(DAY FROM negative_time) returns wrong result
+#
+CREATE TABLE t1 (a TIME(6));
+INSERT INTO t1 VALUES ('-24:10:10.10');
+SELECT
+EXTRACT(MINUTE FROM a),
+EXTRACT(SECOND FROM a),
+EXTRACT(MICROSECOND FROM a),
+EXTRACT(DAY FROM a),
+EXTRACT(DAY_HOUR FROM a),
+EXTRACT(DAY_MINUTE FROM a),
+EXTRACT(DAY_SECOND FROM a),
+EXTRACT(DAY_MICROSECOND FROM a)
+FROM t1;
+EXTRACT(MINUTE FROM a) EXTRACT(SECOND FROM a) EXTRACT(MICROSECOND FROM a) EXTRACT(DAY FROM a) EXTRACT(DAY_HOUR FROM a) EXTRACT(DAY_MINUTE FROM a) EXTRACT(DAY_SECOND FROM a) EXTRACT(DAY_MICROSECOND FROM a)
+-10 -10 -100000 -1 -100 -10010 -1001010 -1001010100000
+CREATE TABLE t2 AS
+SELECT
+EXTRACT(MINUTE FROM a),
+EXTRACT(SECOND FROM a),
+EXTRACT(MICROSECOND FROM a),
+EXTRACT(DAY FROM a),
+EXTRACT(DAY_HOUR FROM a),
+EXTRACT(DAY_MINUTE FROM a),
+EXTRACT(DAY_SECOND FROM a),
+EXTRACT(DAY_MICROSECOND FROM a)
+FROM t1;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `EXTRACT(MINUTE FROM a)` int(3) DEFAULT NULL,
+ `EXTRACT(SECOND FROM a)` int(3) DEFAULT NULL,
+ `EXTRACT(MICROSECOND FROM a)` int(7) DEFAULT NULL,
+ `EXTRACT(DAY FROM a)` int(3) DEFAULT NULL,
+ `EXTRACT(DAY_HOUR FROM a)` int(5) DEFAULT NULL,
+ `EXTRACT(DAY_MINUTE FROM a)` int(7) DEFAULT NULL,
+ `EXTRACT(DAY_SECOND FROM a)` int(9) DEFAULT NULL,
+ `EXTRACT(DAY_MICROSECOND FROM a)` bigint(15) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t2;
+DROP TABLE t1;
+#
+# MDEV-17478 Wrong result for TIME('+100:20:30')
+#
+SELECT TIME('+100:20:30');
+TIME('+100:20:30')
+100:20:30
+#
+# MDEV-17477 Wrong result for TIME('-2001-01-01 10:20:30')
+#
+SELECT TIME('-2001-01-01 10:20:30');
+TIME('-2001-01-01 10:20:30')
+NULL
+Warnings:
+Warning 1292 Incorrect time value: '-2001-01-01 10:20:30'
+SELECT TIME('2001-01-01') AS c1, TIME('2001-01-01 ') AS c2;
+c1 c2
+00:20:01 00:20:01
+Warnings:
+Warning 1292 Truncated incorrect time value: '2001-01-01'
+Warning 1292 Truncated incorrect time value: '2001-01-01 '
+SELECT TIME('0001:01:01 '), TIME('0001:01:01 ');
+TIME('0001:01:01 ') TIME('0001:01:01 ')
+01:01:01 01:01:01
+SELECT TIME('1 2'), TIME('1 2 ');
+TIME('1 2') TIME('1 2 ')
+00:00:01 00:00:01
+Warnings:
+Warning 1292 Truncated incorrect time value: '1 2'
+Warning 1292 Truncated incorrect time value: '1 2 '
+SELECT TIME('2001-01-01T'), TIME('2001-01-01T ');
+TIME('2001-01-01T') TIME('2001-01-01T ')
+00:00:00 00:00:00
+SELECT TIME('901-01-01T1'), TIME('901-01-01T10');
+TIME('901-01-01T1') TIME('901-01-01T10')
+01:00:00 10:00:00
+SELECT TIME('091-01-01T1'), TIME('091-01-01T10');
+TIME('091-01-01T1') TIME('091-01-01T10')
+01:00:00 10:00:00
+SELECT TIME('0001:01:01x'), TIME('0001:01:01xx');
+TIME('0001:01:01x') TIME('0001:01:01xx')
+01:01:01 01:01:01
+Warnings:
+Warning 1292 Truncated incorrect time value: '0001:01:01x'
+Warning 1292 Truncated incorrect time value: '0001:01:01xx'
+SELECT TIME('0001:01:01.'), TIME('0001:01:01..');
+TIME('0001:01:01.') TIME('0001:01:01..')
+01:01:01 01:01:01
+Warnings:
+Warning 1292 Truncated incorrect time value: '0001:01:01..'
+SELECT TIME('0001:01:01-'), TIME('0001:01:01--');
+TIME('0001:01:01-') TIME('0001:01:01--')
+01:01:01 01:01:01
+Warnings:
+Warning 1292 Truncated incorrect time value: '0001:01:01-'
+Warning 1292 Truncated incorrect time value: '0001:01:01--'
+SELECT TIME('0001:01:01-'), TIME('0001:01:01--');
+TIME('0001:01:01-') TIME('0001:01:01--')
+01:01:01 01:01:01
+Warnings:
+Warning 1292 Truncated incorrect time value: '0001:01:01-'
+Warning 1292 Truncated incorrect time value: '0001:01:01--'
+SELECT TIME('-xxx'), TIME('-xxxxxxxxxxxxxxxxxxxx');
+TIME('-xxx') TIME('-xxxxxxxxxxxxxxxxxxxx')
+NULL NULL
+Warnings:
+Warning 1292 Incorrect time value: '-xxx'
+Warning 1292 Incorrect time value: '-xxxxxxxxxxxxxxxxxxxx'
+SELECT TIME('- '), TIME('- ');
+TIME('- ') TIME('- ')
+NULL NULL
+Warnings:
+Warning 1292 Incorrect time value: '- '
+Warning 1292 Incorrect time value: '- '
+SELECT TIME('-'), TIME('-');
+TIME('-') TIME('-')
+NULL NULL
+Warnings:
+Warning 1292 Incorrect time value: '-'
+Warning 1292 Incorrect time value: '-'
+SELECT TIME('1-1-1 1:1:1'), TIME('1-1-1 1:1:1.0');
+TIME('1-1-1 1:1:1') TIME('1-1-1 1:1:1.0')
+01:01:01 01:01:01.0
+SELECT TIME('1-1-1 1:2:3'), TIME('1-1-1 1:2:3.0');
+TIME('1-1-1 1:2:3') TIME('1-1-1 1:2:3.0')
+01:02:03 01:02:03.0
+SELECT
+CAST('20050326112233 garbage' as datetime),
+CAST('20050326 garbage' as date),
+CAST('50326 garbage' as time);
+CAST('20050326112233 garbage' as datetime) CAST('20050326 garbage' as date) CAST('50326 garbage' as time)
+2005-03-26 11:22:33 2005-03-26 05:03:26
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '20050326112233 garbage'
+Warning 1292 Truncated incorrect date value: '20050326 garbage'
+Warning 1292 Truncated incorrect time value: '50326 garbage'
+SELECT TIME('- 01:00:00'), TIME('- 1 01:00:00');
+TIME('- 01:00:00') TIME('- 1 01:00:00')
+-01:00:00 -25:00:00
diff --git a/mysql-test/main/func_time.test b/mysql-test/main/func_time.test
index f6f39d967f2..4c9315629f1 100644
--- a/mysql-test/main/func_time.test
+++ b/mysql-test/main/func_time.test
@@ -1705,6 +1705,59 @@ DO TO_DAYS(SEC_TO_TIME(TIME(CEILING(UUID()))));
DO TO_DAYS(SEC_TO_TIME(MAKEDATE('',RAND(~('')))));
SELECT SEC_TO_TIME(MAKEDATE(0,RAND(~0)));
+#
+# MDEV-16810 AddressSanitizer: stack-buffer-overflow in int10_to_str
+#
+SELECT PERIOD_DIFF(2018, AES_ENCRYPT('Rae Bareli', 'Rae Bareli'));
+
+
+--echo #
+--echo # MDEV-17249 MAKETIME(-1e50,0,0) returns a wrong result
+--echo #
+
+--vertical_results
+SELECT
+ MAKETIME(1e10,0,0),
+ MAKETIME(-1e10,0,0),
+ MAKETIME(1e50,0,0),
+ MAKETIME(-1e50,0,0),
+ MAKETIME(COALESCE(1e50),0,0),
+ MAKETIME(COALESCE(-1e50),0,0);
+--horizontal_results
+
+CREATE TABLE t1 (a FLOAT);
+INSERT INTO t1 VALUES (1e30),(-1e30);
+SELECT MAKETIME(a,0,0) FROM t1;
+DROP TABLE t1;
+
+--echo #
+--echo # MDEV-17244 MAKETIME(900,0,0.111) returns a wrong result
+--echo #
+
+SELECT MAKETIME(900,0,0);
+SELECT MAKETIME(900,0,0.1);
+SELECT MAKETIME(900,0,0.11);
+SELECT MAKETIME(900,0,0.111);
+SELECT MAKETIME(900,0,0.1111);
+SELECT MAKETIME(900,0,0.11111);
+SELECT MAKETIME(900,0,0.111111);
+SELECT MAKETIME(900,0,0.1111111);
+SELECT MAKETIME(900,0,0.11111111);
+SELECT MAKETIME(900,0,0.111111111);
+SELECT MAKETIME(900,0,EXP(1));
+
+SELECT MAKETIME(-900,0,0);
+SELECT MAKETIME(-900,0,0.1);
+SELECT MAKETIME(-900,0,0.11);
+SELECT MAKETIME(-900,0,0.111);
+SELECT MAKETIME(-900,0,0.1111);
+SELECT MAKETIME(-900,0,0.11111);
+SELECT MAKETIME(-900,0,0.111111);
+SELECT MAKETIME(-900,0,0.1111111);
+SELECT MAKETIME(-900,0,0.11111111);
+SELECT MAKETIME(-900,0,0.111111111);
+SELECT MAKETIME(-900,0,EXP(1));
+
--echo #
--echo # End of 5.5 tests
@@ -2141,6 +2194,32 @@ DROP TABLE t_ts, t_trig;
--echo #
+--echo # MDEV-16878 Functions ADDTIME and SUBTIME get wrongly removed from WHERE by the equal expression optimizer
+--echo #
+
+CREATE TABLE t1 (a TIME);
+INSERT INTO t1 VALUES ('00:00:10'),('00:00:20');
+SELECT a, SUBTIME(a,TIME'00:00:01'), ADDTIME(a,TIME'00:00:01') FROM t1;
+SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09';
+SELECT * FROM t1 WHERE ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
+SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09' AND ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE SUBTIME(a,TIME'00:00:01')=TIME'00:00:09' AND ADDTIME(a,TIME'00:00:01')<=TIME'00:00:09';
+DROP TABLE t1;
+
+
+--echo #
+--echo # MDEV-15363 Wrong result for CAST(LAST_DAY(TIME'00:00:00') AS TIME)
+--echo #
+
+set timestamp=unix_timestamp('2018-08-02 10:10:10');
+SELECT
+ LAST_DAY(TIME'00:00:00') AS c1,
+ CAST(CAST(LAST_DAY(TIME'00:00:00') AS DATE) AS TIME) AS c2,
+ CAST(LAST_DAY(TIME'00:00:00') AS TIME) AS c3;
+
+--echo # End of 10.3 tests
+
+--echo #
--echo # MDEV-14032 SEC_TO_TIME executes side effect two times
--echo #
@@ -2161,3 +2240,857 @@ SELECT SEC_TO_TIME(f1());
SELECT * FROM t1;
DROP TABLE t1;
DROP FUNCTION f1;
+
+--echo #
+--echo # MDEV-17351 MICROSECOND(XXX(int_number_out_of_range)) erroneously returns 999999
+--echo #
+
+--echo # Reject anything that's parsed as DATETIME or DATE
+
+CREATE TABLE t1 (a VARCHAR(64));
+INSERT INTO t1 VALUES
+('2001-01-01 10:20:30'),
+('01-01-01 10:20:30'),
+('2001-01-01 '),
+('20010101102030'),
+('010101102030');
+SELECT ADDTIME(DATE'2001-01-01',a), a FROM t1;
+DROP TABLE t1;
+
+
+--vertical_results
+
+--echo # GREATEST(decimal, time)
+
+SELECT
+ GREATEST(8395959, TIME'00:00:00') AS c0,
+ GREATEST(8395959.0, TIME'00:00:00') AS c1,
+ GREATEST(8395959.00, TIME'00:00:00') AS c2,
+ GREATEST(8395959.000, TIME'00:00:00') AS c3,
+ GREATEST(8395959.0000, TIME'00:00:00') AS c4,
+ GREATEST(8395959.00000, TIME'00:00:00') AS c5,
+ GREATEST(8395959.000000, TIME'00:00:00') AS c6,
+ GREATEST(8395959.0000000, TIME'00:00:00') AS c7;
+
+SELECT
+ MICROSECOND(GREATEST(8395959, TIME'00:00:00')) AS c0,
+ MICROSECOND(GREATEST(8395959.0, TIME'00:00:00')) AS c1,
+ MICROSECOND(GREATEST(8395959.00, TIME'00:00:00')) AS c2,
+ MICROSECOND(GREATEST(8395959.000, TIME'00:00:00')) AS c3,
+ MICROSECOND(GREATEST(8395959.0000, TIME'00:00:00')) AS c4,
+ MICROSECOND(GREATEST(8395959.00000, TIME'00:00:00')) AS c5,
+ MICROSECOND(GREATEST(8395959.000000, TIME'00:00:00')) AS c6,
+ MICROSECOND(GREATEST(8395959.0000000, TIME'00:00:00')) AS c7;
+
+SELECT
+ CAST(GREATEST(8395959, TIME'00:00:00') AS SIGNED) AS ci,
+ CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,0)) AS c0,
+ CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,1)) AS c1,
+ CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,2)) AS c2,
+ CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,3)) AS c3,
+ CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,4)) AS c4,
+ CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,5)) AS c5,
+ CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,6)) AS c6,
+ CAST(GREATEST(8395959, TIME'00:00:00') AS DECIMAL(30,7)) AS c7;
+
+SELECT
+ GREATEST(8395959, TIME'00:00:00') AS ci,
+ GREATEST(8395959, TIME'00:00:00')+0 AS c0,
+ GREATEST(8395959, TIME'00:00:00')+0.0 AS c1,
+ GREATEST(8395959, TIME'00:00:00')+0.00 AS c2,
+ GREATEST(8395959, TIME'00:00:00')+0.000 AS c3,
+ GREATEST(8395959, TIME'00:00:00')+0.0000 AS c4,
+ GREATEST(8395959, TIME'00:00:00')+0.00000 AS c5,
+ GREATEST(8395959, TIME'00:00:00')+0.000000 AS c6,
+ GREATEST(8395959, TIME'00:00:00')+0.0000000 AS c7;
+
+
+
+--echo # GREATEST(string, time)
+
+SELECT
+ GREATEST('839:59:59', TIME'00:00:00') AS ci,
+ GREATEST('839:59:59.0', TIME'00:00:00') AS c1,
+ GREATEST('839:59:59.00', TIME'00:00:00') AS c2,
+ GREATEST('839:59:59.000', TIME'00:00:00') AS c3,
+ GREATEST('839:59:59.0000', TIME'00:00:00') AS c4,
+ GREATEST('839:59:59.00000', TIME'00:00:00') AS c5,
+ GREATEST('839:59:59.000000', TIME'00:00:00') AS c6,
+ GREATEST('839:59:59.0000000', TIME'00:00:00') AS c7;
+
+SELECT
+ MICROSECOND(GREATEST('839:59:59', TIME'00:00:00')) AS ci,
+ MICROSECOND(GREATEST('839:59:59.0', TIME'00:00:00')) AS c1,
+ MICROSECOND(GREATEST('839:59:59.00', TIME'00:00:00')) AS c2,
+ MICROSECOND(GREATEST('839:59:59.000', TIME'00:00:00')) AS c3,
+ MICROSECOND(GREATEST('839:59:59.0000', TIME'00:00:00')) AS c4,
+ MICROSECOND(GREATEST('839:59:59.00000', TIME'00:00:00')) AS c5,
+ MICROSECOND(GREATEST('839:59:59.000000', TIME'00:00:00')) AS c6,
+ MICROSECOND(GREATEST('839:59:59.0000000', TIME'00:00:00')) AS c7;
+
+SELECT
+ CAST(GREATEST('839:59:59', TIME'00:00:00') AS SIGNED) AS ci,
+ CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,0)) AS c0,
+ CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,1)) AS c1,
+ CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,2)) AS c2,
+ CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,3)) AS c3,
+ CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,4)) AS c4,
+ CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,5)) AS c5,
+ CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,6)) AS c6,
+ CAST(GREATEST('839:59:59', TIME'00:00:00') AS DECIMAL(30,7)) AS c7;
+
+SELECT
+ GREATEST('839:59:59', TIME'00:00:00') AS ci,
+ GREATEST('839:59:59', TIME'00:00:00')+0 AS c0,
+ GREATEST('839:59:59', TIME'00:00:00')+0.0 AS c1,
+ GREATEST('839:59:59', TIME'00:00:00')+0.00 AS c2,
+ GREATEST('839:59:59', TIME'00:00:00')+0.000 AS c3,
+ GREATEST('839:59:59', TIME'00:00:00')+0.0000 AS c4,
+ GREATEST('839:59:59', TIME'00:00:00')+0.00000 AS c5,
+ GREATEST('839:59:59', TIME'00:00:00')+0.000000 AS c6,
+ GREATEST('839:59:59', TIME'00:00:00')+0.0000000 AS c7;
+
+
+--echo # ADDTIME(datetime, decimal)
+
+SELECT
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS c0,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0) AS c1,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.00) AS c2,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.000) AS c3,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0000) AS c4,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.00000) AS c5,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.000000) AS c6,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0000000) AS c7;
+
+SELECT
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)) AS c0,
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0)) AS c1,
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.00)) AS c2,
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.000)) AS c3,
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0000)) AS c4,
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.00000)) AS c5,
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.000000)) AS c6,
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959.0000000)) AS c7;
+
+SELECT
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS SIGNED) AS ci,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,0)) AS c0,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,1)) AS c1,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,2)) AS c2,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,3)) AS c3,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,4)) AS c4,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,5)) AS c5,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,6)) AS c6,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS DECIMAL(30,7)) AS c7;
+
+SELECT
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959) AS ci,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0 AS c0,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.0 AS c1,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.00 AS c2,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.000 AS c3,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.0000 AS c4,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.00000 AS c5,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.000000 AS c6,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 8395959)+0.0000000 AS c7;
+
+--echo # ADDTIME(datetime, string)
+
+SELECT
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS c0,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0') AS c1,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.00') AS c2,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.000') AS c3,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0000') AS c4,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.00000') AS c5,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.000000') AS c6,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0000000') AS c7;
+
+SELECT
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')) AS c0,
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0')) AS c1,
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.00')) AS c2,
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.000')) AS c3,
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0000')) AS c4,
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.00000')) AS c5,
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.000000')) AS c6,
+ MICROSECOND(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59.0000000')) AS c7;
+
+SELECT
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS SIGNED) AS ci,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,0)) AS c0,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,1)) AS c1,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,2)) AS c2,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,3)) AS c3,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,4)) AS c4,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,5)) AS c5,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,6)) AS c6,
+ CAST(ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS DECIMAL(30,7)) AS c7;
+
+SELECT
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59') AS ci,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0 AS c0,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.0 AS c1,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.00 AS c2,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.000 AS c3,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.0000 AS c4,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.00000 AS c5,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.000000 AS c6,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '839:59:59')+0.0000000 AS c7;
+
+--echo # ADDTIME(time, decimal)
+
+SELECT
+ ADDTIME(TIME'00:00:00', 8395959) AS c0,
+ ADDTIME(TIME'00:00:00', 8395959.0) AS c1,
+ ADDTIME(TIME'00:00:00', 8395959.00) AS c2,
+ ADDTIME(TIME'00:00:00', 8395959.000) AS c3,
+ ADDTIME(TIME'00:00:00', 8395959.0000) AS c4,
+ ADDTIME(TIME'00:00:00', 8395959.00000) AS c5,
+ ADDTIME(TIME'00:00:00', 8395959.000000) AS c6,
+ ADDTIME(TIME'00:00:00', 8395959.0000000) AS c7;
+
+SELECT
+ MICROSECOND(ADDTIME(TIME'00:00:00', 8395959)) AS c0,
+ MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.0)) AS c1,
+ MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.00)) AS c2,
+ MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.000)) AS c3,
+ MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.0000)) AS c4,
+ MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.00000)) AS c5,
+ MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.000000)) AS c6,
+ MICROSECOND(ADDTIME(TIME'00:00:00', 8395959.0000000)) AS c7;
+
+SELECT
+ CAST(ADDTIME(TIME'00:00:00', 8395959) AS SIGNED) AS ci,
+ CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,0)) AS c0,
+ CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,1)) AS c1,
+ CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,2)) AS c2,
+ CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,3)) AS c3,
+ CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,4)) AS c4,
+ CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,5)) AS c5,
+ CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,6)) AS c6,
+ CAST(ADDTIME(TIME'00:00:00', 8395959) AS DECIMAL(30,7)) AS c7;
+
+SELECT
+ ADDTIME(TIME'00:00:00', 8395959) AS ci,
+ ADDTIME(TIME'00:00:00', 8395959)+0 AS c0,
+ ADDTIME(TIME'00:00:00', 8395959)+0.0 AS c1,
+ ADDTIME(TIME'00:00:00', 8395959)+0.00 AS c2,
+ ADDTIME(TIME'00:00:00', 8395959)+0.000 AS c3,
+ ADDTIME(TIME'00:00:00', 8395959)+0.0000 AS c4,
+ ADDTIME(TIME'00:00:00', 8395959)+0.00000 AS c5,
+ ADDTIME(TIME'00:00:00', 8395959)+0.000000 AS c6,
+ ADDTIME(TIME'00:00:00', 8395959)+0.0000000 AS c7;
+
+--echo # ADDTIME(time,string)
+
+SELECT
+ ADDTIME(TIME'00:00:00', '839:59:59') AS c0,
+ ADDTIME(TIME'00:00:00', '839:59:59.0') AS c1,
+ ADDTIME(TIME'00:00:00', '839:59:59.00') AS c2,
+ ADDTIME(TIME'00:00:00', '839:59:59.000') AS c3,
+ ADDTIME(TIME'00:00:00', '839:59:59.0000') AS c4,
+ ADDTIME(TIME'00:00:00', '839:59:59.00000') AS c5,
+ ADDTIME(TIME'00:00:00', '839:59:59.000000') AS c6,
+ ADDTIME(TIME'00:00:00', '839:59:59.0000000') AS c7;
+
+SELECT
+ MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59')) AS c0,
+ MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.0')) AS c1,
+ MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.00')) AS c2,
+ MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.000')) AS c3,
+ MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.0000')) AS c4,
+ MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.00000')) AS c5,
+ MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.000000')) AS c6,
+ MICROSECOND(ADDTIME(TIME'00:00:00', '839:59:59.0000000')) AS c7;
+
+SELECT
+ CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS SIGNED) AS ci,
+ CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,0)) AS c0,
+ CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,1)) AS c1,
+ CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,2)) AS c2,
+ CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,3)) AS c3,
+ CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,4)) AS c4,
+ CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,5)) AS c5,
+ CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,6)) AS c6,
+ CAST(ADDTIME(TIME'00:00:00', '839:59:59') AS DECIMAL(30,7)) AS c7;
+
+SELECT
+ ADDTIME(TIME'00:00:00', '839:59:59') AS ci,
+ ADDTIME(TIME'00:00:00', '839:59:59')+0 AS c0,
+ ADDTIME(TIME'00:00:00', '839:59:59')+0.0 AS c1,
+ ADDTIME(TIME'00:00:00', '839:59:59')+0.00 AS c2,
+ ADDTIME(TIME'00:00:00', '839:59:59')+0.000 AS c3,
+ ADDTIME(TIME'00:00:00', '839:59:59')+0.0000 AS c4,
+ ADDTIME(TIME'00:00:00', '839:59:59')+0.00000 AS c5,
+ ADDTIME(TIME'00:00:00', '839:59:59')+0.000000 AS c6,
+ ADDTIME(TIME'00:00:00', '839:59:59')+0.0000000 AS c7;
+
+--echo # ADDTIME(int,int)
+SELECT
+ ADDTIME(0, 8395959) AS c,
+ MICROSECOND(ADDTIME(0, 8395959)) AS cm,
+ CAST(ADDTIME(0, 8395959) AS SIGNED) AS cs_fixme_mdev_17384,
+ CAST(ADDTIME(0, 8395959) AS DECIMAL(30,0)) AS cd300;
+
+SELECT
+ ADDTIME(20010101000000, 8395959) AS c,
+ MICROSECOND(ADDTIME(20010101000000, 8395959)) AS cm,
+ CAST(ADDTIME(20010101000000, 8395959) AS SIGNED) AS cs_fixme_mdev_17384,
+ CAST(ADDTIME(20010101000000, 8395959) AS DECIMAL(30,0)) AS cd300;
+
+--echo # ADDTIME(decimal,int)
+--echo # 8385960 in cd300 is correct: addtime returns '838:59:59.9'
+--echo # which is further *rounded* to a decimals(30,0)
+SELECT
+ ADDTIME(0.0, 8395959) AS c,
+ MICROSECOND(ADDTIME(0.0, 8395959)) AS cm,
+ CAST(ADDTIME(0.0, 8395959) AS SIGNED) AS cs_fixme_mdev_17384,
+ CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,0)) AS cd300;
+
+SELECT
+ ADDTIME(20010101000000.0, 8395959) AS c,
+ MICROSECOND(ADDTIME(20010101000000.0, 8395959)) AS cm,
+ CAST(ADDTIME(20010101000000.0, 8395959) AS SIGNED) AS cs_fixme_mdev_17384,
+ CAST(ADDTIME(20010101000000.0, 8395959) AS DECIMAL(30,0)) AS cd300;
+
+
+--echo # ADDTIME(decimal,decimal)
+
+SELECT
+ ADDTIME(0.0, 8395959.0) AS c1,
+ ADDTIME(0.0, 8395959.00) AS c2,
+ ADDTIME(0.0, 8395959.000) AS c3,
+ ADDTIME(0.0, 8395959.0000) AS c4,
+ ADDTIME(0.0, 8395959.00000) AS c5,
+ ADDTIME(0.0, 8395959.000000) AS c6,
+ ADDTIME(0.0, 8395959.0000000) AS c7;
+
+SELECT
+ MICROSECOND(ADDTIME(0.0, 8395959.0)) AS c1,
+ MICROSECOND(ADDTIME(0.0, 8395959.00)) AS c2,
+ MICROSECOND(ADDTIME(0.0, 8395959.000)) AS c3,
+ MICROSECOND(ADDTIME(0.0, 8395959.0000)) AS c4,
+ MICROSECOND(ADDTIME(0.0, 8395959.00000)) AS c5,
+ MICROSECOND(ADDTIME(0.0, 8395959.000000)) AS c6,
+ MICROSECOND(ADDTIME(0.0, 8395959.0000000)) AS c7;
+
+--echo # 8385960 in c1 is correct: addtime returns '838:59:59.9'
+--echo # which is further *rounded* to a decimals(30,0)
+SELECT
+ CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,0)) AS c0,
+ CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,1)) AS c1,
+ CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,2)) AS c2,
+ CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,3)) AS c3,
+ CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,4)) AS c4,
+ CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,5)) AS c5,
+ CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,6)) AS c6,
+ CAST(ADDTIME(0.0, 8395959) AS DECIMAL(30,7)) AS c7;
+
+SELECT
+ ADDTIME(0.0, 8395959)+0 AS c0,
+ ADDTIME(0.0, 8395959)+0.0 AS c1,
+ ADDTIME(0.0, 8395959)+0.00 AS c2,
+ ADDTIME(0.0, 8395959)+0.000 AS c3,
+ ADDTIME(0.0, 8395959)+0.0000 AS c4,
+ ADDTIME(0.0, 8395959)+0.00000 AS c5,
+ ADDTIME(0.0, 8395959)+0.000000 AS c6,
+ ADDTIME(0.0, 8395959)+0.0000000 AS c7;
+
+
+--echo # TIMESTAMP(string,decimal)
+
+SELECT
+ TIMESTAMP('2001-01-01', 8395959) AS ci,
+ TIMESTAMP('2001-01-01', 8395959.0) AS c1,
+ TIMESTAMP('2001-01-01', 8395959.00) AS c2,
+ TIMESTAMP('2001-01-01', 8395959.000) AS c3,
+ TIMESTAMP('2001-01-01', 8395959.0000) AS c4,
+ TIMESTAMP('2001-01-01', 8395959.00000) AS c5,
+ TIMESTAMP('2001-01-01', 8395959.000000) AS c6,
+ TIMESTAMP('2001-01-01', 8395959.0000000) AS c7;
+
+SELECT
+ MICROSECOND(TIMESTAMP('2001-01-01', 8395959)) AS ci,
+ MICROSECOND(TIMESTAMP('2001-01-01', 8395959.0)) AS c1,
+ MICROSECOND(TIMESTAMP('2001-01-01', 8395959.00)) AS c2,
+ MICROSECOND(TIMESTAMP('2001-01-01', 8395959.000)) AS c3,
+ MICROSECOND(TIMESTAMP('2001-01-01', 8395959.0000)) AS c4,
+ MICROSECOND(TIMESTAMP('2001-01-01', 8395959.00000)) AS c5,
+ MICROSECOND(TIMESTAMP('2001-01-01', 8395959.000000)) AS c6,
+ MICROSECOND(TIMESTAMP('2001-01-01', 8395959.0000000)) AS c7;
+
+SELECT
+ CAST(TIMESTAMP('2001-01-01', 8395959) AS SIGNED) AS ci,
+ CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,0)) AS c0,
+ CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,1)) AS c1,
+ CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,2)) AS c2,
+ CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,3)) AS c3,
+ CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,4)) AS c4,
+ CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,5)) AS c5,
+ CAST(TIMESTAMP('2001-01-01', 8395959) AS DECIMAL(30,6)) AS c6;
+
+SELECT
+ TIMESTAMP('2001-01-01', 8395959) AS ci,
+ TIMESTAMP('2001-01-01', 8395959)+0 AS c0,
+ TIMESTAMP('2001-01-01', 8395959)+0.0 AS c1,
+ TIMESTAMP('2001-01-01', 8395959)+0.00 AS c2,
+ TIMESTAMP('2001-01-01', 8395959)+0.000 AS c3,
+ TIMESTAMP('2001-01-01', 8395959)+0.0000 AS c4,
+ TIMESTAMP('2001-01-01', 8395959)+0.00000 AS c5,
+ TIMESTAMP('2001-01-01', 8395959)+0.000000 AS c6,
+ TIMESTAMP('2001-01-01', 8395959)+0.0000000 AS c7;
+
+--echo # TIMESTAMP(string,string)
+
+SELECT
+ TIMESTAMP('2001-01-01', '839:59:59') AS ci,
+ TIMESTAMP('2001-01-01', '839:59:59.0') AS c1,
+ TIMESTAMP('2001-01-01', '839:59:59.00') AS c2,
+ TIMESTAMP('2001-01-01', '839:59:59.000') AS c3,
+ TIMESTAMP('2001-01-01', '839:59:59.0000') AS c4,
+ TIMESTAMP('2001-01-01', '839:59:59.00000') AS c5,
+ TIMESTAMP('2001-01-01', '839:59:59.000000') AS c6,
+ TIMESTAMP('2001-01-01', '839:59:59.0000000') AS c7;
+
+SELECT
+ MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59')) AS ci,
+ MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.0')) AS c1,
+ MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.00')) AS c2,
+ MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.000')) AS c3,
+ MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.0000')) AS c4,
+ MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.00000')) AS c5,
+ MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.000000')) AS c6,
+ MICROSECOND(TIMESTAMP('2001-01-01', '839:59:59.0000000')) AS c7;
+
+SELECT
+ CAST(TIMESTAMP('2001-01-01', '839:59:59') AS SIGNED) AS ci,
+ CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,0)) AS c0,
+ CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,1)) AS c1,
+ CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,2)) AS c2,
+ CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,3)) AS c3,
+ CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,4)) AS c4,
+ CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,5)) AS c5,
+ CAST(TIMESTAMP('2001-01-01', '839:59:59') AS DECIMAL(30,6)) AS c6;
+
+SELECT
+ TIMESTAMP('2001-01-01', '839:59:59') AS ci,
+ TIMESTAMP('2001-01-01', '839:59:59')+0 AS c0,
+ TIMESTAMP('2001-01-01', '839:59:59')+0.0 AS c1,
+ TIMESTAMP('2001-01-01', '839:59:59')+0.00 AS c2,
+ TIMESTAMP('2001-01-01', '839:59:59')+0.000 AS c3,
+ TIMESTAMP('2001-01-01', '839:59:59')+0.0000 AS c4,
+ TIMESTAMP('2001-01-01', '839:59:59')+0.00000 AS c5,
+ TIMESTAMP('2001-01-01', '839:59:59')+0.000000 AS c6,
+ TIMESTAMP('2001-01-01', '839:59:59')+0.0000000 AS c7;
+
+--horizontal_results
+
+--echo # Corner cases for TIMESTAMP(timestamp,xxx)
+
+--echo # HOUR is outside of supported INTERVAL DAYS TO SECONDS range
+--echo # Expect NULL with INTERVAL warnings
+CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
+INSERT INTO t1 VALUES ('4294967296:00:00', '178956970 16:00:00');
+INSERT INTO t1 VALUES ('4294967295:59:59', '178956970 15:59:59');
+INSERT INTO t1 VALUES ('4294967294:59:59', '178956970 14:59:59');
+INSERT INTO t1 VALUES ('87649416:00:00', '3652059 00:00:00');
+SELECT TIMESTAMP('0001-01-01 00:00:00', a) AS ta, TIMESTAMP('0001-01-01 00:00:00', b) AS tb FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
+INSERT INTO t1 VALUES ('-4294967296:00:00', '-178956970 16:00:00');
+INSERT INTO t1 VALUES ('-4294967295:59:59', '-178956970 15:59:59');
+INSERT INTO t1 VALUES ('-4294967294:59:59', '-178956970 14:59:59');
+INSERT INTO t1 VALUES ('-87649416:00:00', '-3652059 00:00:00');
+SELECT TIMESTAMP('9999-12-31 23:59:59', a) AS ta, TIMESTAMP('9999-12-31 23:59:59.999999', b) AS tb FROM t1;
+DROP TABLE t1;
+
+--echo # HOUR is OK
+--echo # Expect max or near-max DATETIME value + no INTERVAL warnings
+CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
+INSERT INTO t1 VALUES ('87649415:59:59.999999', '3652058 23:59:59.999999');
+INSERT INTO t1 VALUES ('87649415:59:59', '3652058 23:59:59');
+SELECT TIMESTAMP('0001-01-01 00:00:00', a) AS ta, TIMESTAMP('0001-01-01 00:00:00', b) AS tb FROM t1;
+DROP TABLE t1;
+
+--echo # HOUR is OK
+--echo # Expect near '0001-01-01 00:00:00' DATETIME value + no INTERVAL warnings
+CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
+INSERT INTO t1 VALUES ('-87649415:59:59.999999', '-3652058 23:59:59.999999');
+INSERT INTO t1 VALUES ('-87649415:59:59', '-3652058 23:59:59');
+SELECT TIMESTAMP('9999-12-31 23:59:59', a) AS ta, TIMESTAMP('9999-12-31 23:59:59.999999', b) AS tb FROM t1;
+DROP TABLE t1;
+
+--echo # HOUR is OK
+--echo # Expect NULL on datetime arithmetic overflow + no INTERVAL warnings
+CREATE TABLE t1 (a VARCHAR(64), b VARCHAR(64));
+INSERT INTO t1 VALUES ('-00:00:00.000001', '-0 00:00:00.000001');
+SELECT TIMESTAMP('0001-01-01 00:00:00', a) AS ta, TIMESTAMP('0001-01-01 00:00:00', b) AS tb FROM t1;
+DROP TABLE t1;
+
+
+--echo # Corner cases for ADDTIME(timestamp,xxx)
+--vertical_results
+
+--echo # HOUR is outside of UINT_MAX32 range
+--echo # Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
+
+SELECT
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959) AS ci,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0 AS c0,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.0 AS c1,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.00 AS c2,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.000 AS c3,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.0000 AS c4,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.00000 AS c5,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.000000 AS c6,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672965959)+0.0000000 AS c7;
+
+SELECT
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59') AS ci,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0 AS c0,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.0 AS c1,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.00 AS c2,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.000 AS c3,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.0000 AS c4,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.00000 AS c5,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.000000 AS c6,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967296:59:59')+0.0000000 AS c7;
+
+## TODO: add '0001-01-01 00:00:00'
+
+--echo # HOUR UINT_MAX32
+--echo # Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
+SELECT
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959) AS ci,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0 AS c0,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.0 AS c1,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.00 AS c2,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.000 AS c3,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.0000 AS c4,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.00000 AS c5,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.000000 AS c6,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 42949672955959)+0.0000000 AS c7;
+
+SELECT
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59') AS ci,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0 AS c0,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.0 AS c1,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.00 AS c2,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.000 AS c3,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.0000 AS c4,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.00000 AS c5,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.000000 AS c6,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '4294967295:59:59')+0.0000000 AS c7;
+
+--echo # HOUR is max_useful_hour()+1
+--echo # Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
+SELECT
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959) AS ci,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0 AS c0,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.0 AS c1,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.00 AS c2,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.000 AS c3,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.0000 AS c4,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.00000 AS c5,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.000000 AS c6,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494165959)+0.0000000 AS c7;
+
+SELECT
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59') AS ci,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0 AS c0,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.0 AS c1,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.00 AS c2,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.000 AS c3,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.0000 AS c4,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.00000 AS c5,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.000000 AS c6,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649416:59:59')+0.0000000 AS c7;
+
+--echo # HOUR is max_useful_hour()
+--echo # Expect NULL (calc_time_diff overflows ) + no INTERVAL warnings
+SELECT
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959) AS ci,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0 AS c0,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.0 AS c1,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.00 AS c2,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.000 AS c3,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.0000 AS c4,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.00000 AS c5,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.000000 AS c6,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', 876494155959)+0.0000000 AS c7;
+
+SELECT
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59') AS ci,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0 AS c0,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.0 AS c1,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.00 AS c2,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.000 AS c3,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.0000 AS c4,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.00000 AS c5,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.000000 AS c6,
+ ADDTIME(TIMESTAMP'2001-01-01 00:00:00', '87649415:59:59')+0.0000000 AS c7;
+
+--echo # HOUR is max_useful_hour()
+--echo # Expect non-NULL + no warnings
+SELECT
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959) AS ci,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0 AS c0,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.0 AS c1,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.00 AS c2,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.000 AS c3,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.0000 AS c4,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.00000 AS c5,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.000000 AS c6,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', 876494155959)+0.0000000 AS c7;
+
+SELECT
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59') AS ci,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0 AS c0,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.0 AS c1,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.00 AS c2,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.000 AS c3,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.0000 AS c4,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.00000 AS c5,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.000000 AS c6,
+ ADDTIME(TIMESTAMP'0001-01-01 00:00:00', '87649415:59:59')+0.0000000 AS c7;
+--horizontal_results
+
+
+--echo # Corner cases for ADDTIME(time,xxx)
+--vertical_results
+
+--echo # HOUR outside of UINT32 range
+--echo # Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
+SELECT
+ ADDTIME(TIME'00:00:00', 42949672965959) AS ci,
+ ADDTIME(TIME'00:00:00', 42949672965959)+0 AS c0,
+ ADDTIME(TIME'00:00:00', 42949672965959)+0.0 AS c1,
+ ADDTIME(TIME'00:00:00', 42949672965959)+0.00 AS c2,
+ ADDTIME(TIME'00:00:00', 42949672965959)+0.000 AS c3,
+ ADDTIME(TIME'00:00:00', 42949672965959)+0.0000 AS c4,
+ ADDTIME(TIME'00:00:00', 42949672965959)+0.00000 AS c5,
+ ADDTIME(TIME'00:00:00', 42949672965959)+0.000000 AS c6,
+ ADDTIME(TIME'00:00:00', 42949672965959)+0.0000000 AS c7;
+
+SELECT
+ ADDTIME(TIME'00:00:00', '4294967296:59:59') AS ci,
+ ADDTIME(TIME'00:00:00', '4294967296:59:59')+0 AS c0,
+ ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.0 AS c1,
+ ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.00 AS c2,
+ ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.000 AS c3,
+ ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.0000 AS c4,
+ ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.00000 AS c5,
+ ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.000000 AS c6,
+ ADDTIME(TIME'00:00:00', '4294967296:59:59')+0.0000000 AS c7;
+
+--echo # HOUR is UINT_MAX32 (outside of INTERVAL DAY TO SECOND range)
+--echo # Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
+SELECT
+ ADDTIME(TIME'00:00:00', 42949672955959) AS ci,
+ ADDTIME(TIME'00:00:00', 42949672955959)+0 AS c0,
+ ADDTIME(TIME'00:00:00', 42949672955959)+0.0 AS c1,
+ ADDTIME(TIME'00:00:00', 42949672955959)+0.00 AS c2,
+ ADDTIME(TIME'00:00:00', 42949672955959)+0.000 AS c3,
+ ADDTIME(TIME'00:00:00', 42949672955959)+0.0000 AS c4,
+ ADDTIME(TIME'00:00:00', 42949672955959)+0.00000 AS c5,
+ ADDTIME(TIME'00:00:00', 42949672955959)+0.000000 AS c6,
+ ADDTIME(TIME'00:00:00', 42949672955959)+0.0000000 AS c7;
+
+SELECT
+ ADDTIME(TIME'00:00:00', '4294967295:59:59') AS ci,
+ ADDTIME(TIME'00:00:00', '4294967295:59:59')+0 AS c0,
+ ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.0 AS c1,
+ ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.00 AS c2,
+ ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.000 AS c3,
+ ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.0000 AS c4,
+ ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.00000 AS c5,
+ ADDTIME(TIME'00:00:00', '4294967295:59:59')+0.000000 AS c6,
+ ADDTIME(TIME'00:00:00', '4294967295;00:00')+0.0000000 AS c7;
+
+--echo # HOUR is max_useful_hour()+1 (outside of INTERVAL DAY TO SECOND range)
+--echo # Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
+
+SELECT
+ ADDTIME(TIME'00:00:00', 876494165959) AS ci,
+ ADDTIME(TIME'00:00:00', 876494165959)+0 AS c0,
+ ADDTIME(TIME'00:00:00', 876494165959)+0.0 AS c1,
+ ADDTIME(TIME'00:00:00', 876494165959)+0.00 AS c2,
+ ADDTIME(TIME'00:00:00', 876494165959)+0.000 AS c3,
+ ADDTIME(TIME'00:00:00', 876494165959)+0.0000 AS c4,
+ ADDTIME(TIME'00:00:00', 876494165959)+0.00000 AS c5,
+ ADDTIME(TIME'00:00:00', 876494165959)+0.000000 AS c6,
+ ADDTIME(TIME'00:00:00', 876494165959)+0.0000000 AS c7;
+
+SELECT
+ ADDTIME(TIME'00:00:00', '87649416:59:59') AS ci,
+ ADDTIME(TIME'00:00:00', '87649416:59:59')+0 AS c0,
+ ADDTIME(TIME'00:00:00', '87649416:59:59')+0.0 AS c1,
+ ADDTIME(TIME'00:00:00', '87649416:59:59')+0.00 AS c2,
+ ADDTIME(TIME'00:00:00', '87649416:59:59')+0.000 AS c3,
+ ADDTIME(TIME'00:00:00', '87649416:59:59')+0.0000 AS c4,
+ ADDTIME(TIME'00:00:00', '87649416:59:59')+0.00000 AS c5,
+ ADDTIME(TIME'00:00:00', '87649416:59:59')+0.000000 AS c6,
+ ADDTIME(TIME'00:00:00', '87649416:59:59')+0.0000000 AS c7;
+
+--echo # HOUR is max_useful_hour()+1 (outside of INTERVAL DAY TO SECOND range)
+--echo # Expect NULL + "Incorrect INTERVAL DAY TO SECOND value"
+
+SELECT
+ ADDTIME(TIME'-838:59:59', 876494165959) AS ci,
+ ADDTIME(TIME'-838:59:59.9', 876494165959) AS c1,
+ ADDTIME(TIME'-838:59:59.99', 876494165959) AS c2,
+ ADDTIME(TIME'-838:59:59.999', 876494165959) AS c3,
+ ADDTIME(TIME'-838:59:59.9999', 876494165959) AS c4,
+ ADDTIME(TIME'-838:59:59.99999', 876494165959) AS c5,
+ ADDTIME(TIME'-838:59:59.999999', 876494165959) AS c6;
+
+SELECT
+ ADDTIME(TIME'-838:59:59', '87649416:59:59') AS ci,
+ ADDTIME(TIME'-838:59:59.9', '87649416:59:59') AS c1,
+ ADDTIME(TIME'-838:59:59.99', '87649416:59:59') AS c2,
+ ADDTIME(TIME'-838:59:59.999', '87649416:59:59') AS c3,
+ ADDTIME(TIME'-838:59:59.9999', '87649416:59:59') AS c4,
+ ADDTIME(TIME'-838:59:59.99999', '87649416:59:59') AS c5,
+ ADDTIME(TIME'-838:59:59.999999', '87649416:59:59') AS c6;
+
+# This does not give a warning about nanosecond truncation in --ps runs
+# so disable warnings
+--disable_warnings
+SELECT
+ ADDTIME(TIME'-838:59:59.9999999', '87649416:59:59') AS c7;
+--enable_warnings
+
+--echo # HOUR is max_useful_hour() (inside INTERVAL DAY TO SECOND range)
+--echo # Expect max TIME(0) + zero fraction + TIME warnings + no INTEVAL warnings
+SELECT
+ ADDTIME(TIME'00:00:00', 876494155959) AS ci,
+ ADDTIME(TIME'00:00:00', 876494155959)+0 AS c0,
+ ADDTIME(TIME'00:00:00', 876494155959)+0.0 AS c1,
+ ADDTIME(TIME'00:00:00', 876494155959)+0.00 AS c2,
+ ADDTIME(TIME'00:00:00', 876494155959)+0.000 AS c3,
+ ADDTIME(TIME'00:00:00', 876494155959)+0.0000 AS c4,
+ ADDTIME(TIME'00:00:00', 876494155959)+0.00000 AS c5,
+ ADDTIME(TIME'00:00:00', 876494155959)+0.000000 AS c6,
+ ADDTIME(TIME'00:00:00', 876494155959)+0.0000000 AS c7;
+
+SELECT
+ ADDTIME(TIME'00:00:00', '87649415:59:59') AS ci,
+ ADDTIME(TIME'00:00:00', '87649415:59:59')+0 AS c0,
+ ADDTIME(TIME'00:00:00', '87649415:59:59')+0.0 AS c1,
+ ADDTIME(TIME'00:00:00', '87649415:59:59')+0.00 AS c2,
+ ADDTIME(TIME'00:00:00', '87649415:59:59')+0.000 AS c3,
+ ADDTIME(TIME'00:00:00', '87649415:59:59')+0.0000 AS c4,
+ ADDTIME(TIME'00:00:00', '87649415:59:59')+0.00000 AS c5,
+ ADDTIME(TIME'00:00:00', '87649415:59:59')+0.000000 AS c6,
+ ADDTIME(TIME'00:00:00', '87649415:59:59')+0.0000000 AS c7;
+
+
+--echo # HOUR is max_useful_hour() (inside INTERVAL DAY TO SECOND range)
+--echo # Expect max TIME(N) + TIME warnings + no INTERVAL warnings
+
+SELECT
+ ADDTIME(TIME'-838:59:59', 876494155959) AS ci,
+ ADDTIME(TIME'-838:59:59.9', 876494155959) AS c1,
+ ADDTIME(TIME'-838:59:59.99', 876494155959) AS c2,
+ ADDTIME(TIME'-838:59:59.999', 876494155959) AS c3,
+ ADDTIME(TIME'-838:59:59.9999', 876494155959) AS c4,
+ ADDTIME(TIME'-838:59:59.99999', 876494155959) AS c5,
+ ADDTIME(TIME'-838:59:59.999999', 876494155959) AS c6;
+
+SELECT
+ ADDTIME(TIME'-838:59:59', '87649415:59:59') AS ci,
+ ADDTIME(TIME'-838:59:59.9', '87649415:59:59') AS c1,
+ ADDTIME(TIME'-838:59:59.99', '87649415:59:59') AS c2,
+ ADDTIME(TIME'-838:59:59.999', '87649415:59:59') AS c3,
+ ADDTIME(TIME'-838:59:59.9999', '87649415:59:59') AS c4,
+ ADDTIME(TIME'-838:59:59.99999', '87649415:59:59') AS c5,
+ ADDTIME(TIME'-838:59:59.999999', '87649415:59:59') AS c6;
+
+# This does not give a warning about nanosecond truncation in --ps runs
+# so disable warnings
+--disable_warnings
+SELECT
+ ADDTIME(TIME'-838:59:59.9999999', '87649415:59:59') AS c7;
+--enable_warnings
+
+--horizontal_results
+
+
+--echo #
+--echo # MDEV-17400 The result of TIME('42949672965959-01') depends on architecture
+--echo #
+
+SELECT TIME('42949672955959-01'), TIME('42949672965959-01');
+SELECT TIME('18446744073709551615-01'), TIME('18446744073709551616-01');
+
+--echo #
+--echo # MDEV-17434 EXTRACT(DAY FROM negative_time) returns wrong result
+--echo #
+
+CREATE TABLE t1 (a TIME(6));
+INSERT INTO t1 VALUES ('-24:10:10.10');
+SELECT
+ EXTRACT(MINUTE FROM a),
+ EXTRACT(SECOND FROM a),
+ EXTRACT(MICROSECOND FROM a),
+ EXTRACT(DAY FROM a),
+ EXTRACT(DAY_HOUR FROM a),
+ EXTRACT(DAY_MINUTE FROM a),
+ EXTRACT(DAY_SECOND FROM a),
+ EXTRACT(DAY_MICROSECOND FROM a)
+FROM t1;
+CREATE TABLE t2 AS
+SELECT
+ EXTRACT(MINUTE FROM a),
+ EXTRACT(SECOND FROM a),
+ EXTRACT(MICROSECOND FROM a),
+ EXTRACT(DAY FROM a),
+ EXTRACT(DAY_HOUR FROM a),
+ EXTRACT(DAY_MINUTE FROM a),
+ EXTRACT(DAY_SECOND FROM a),
+ EXTRACT(DAY_MICROSECOND FROM a)
+FROM t1;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+
+--echo #
+--echo # MDEV-17478 Wrong result for TIME('+100:20:30')
+--echo #
+
+SELECT TIME('+100:20:30');
+
+--echo #
+--echo # MDEV-17477 Wrong result for TIME('-2001-01-01 10:20:30')
+--echo #
+
+SELECT TIME('-2001-01-01 10:20:30');
+SELECT TIME('2001-01-01') AS c1, TIME('2001-01-01 ') AS c2;
+SELECT TIME('0001:01:01 '), TIME('0001:01:01 ');
+SELECT TIME('1 2'), TIME('1 2 ');
+
+SELECT TIME('2001-01-01T'), TIME('2001-01-01T ');
+SELECT TIME('901-01-01T1'), TIME('901-01-01T10');
+SELECT TIME('091-01-01T1'), TIME('091-01-01T10');
+
+SELECT TIME('0001:01:01x'), TIME('0001:01:01xx');
+SELECT TIME('0001:01:01.'), TIME('0001:01:01..');
+SELECT TIME('0001:01:01-'), TIME('0001:01:01--');
+SELECT TIME('0001:01:01-'), TIME('0001:01:01--');
+
+SELECT TIME('-xxx'), TIME('-xxxxxxxxxxxxxxxxxxxx');
+SELECT TIME('- '), TIME('- ');
+SELECT TIME('-'), TIME('-');
+SELECT TIME('1-1-1 1:1:1'), TIME('1-1-1 1:1:1.0');
+SELECT TIME('1-1-1 1:2:3'), TIME('1-1-1 1:2:3.0');
+
+SELECT
+ CAST('20050326112233 garbage' as datetime),
+ CAST('20050326 garbage' as date),
+ CAST('50326 garbage' as time);
+
+SELECT TIME('- 01:00:00'), TIME('- 1 01:00:00');
diff --git a/mysql-test/main/gis-precise.result b/mysql-test/main/gis-precise.result
index 7b553387fde..8382a94e358 100644
--- a/mysql-test/main/gis-precise.result
+++ b/mysql-test/main/gis-precise.result
@@ -504,6 +504,9 @@ GEOMETRYFROMTEXT('POINT(4599 60359)'),
) as relate_res;
relate_res
0
+with cte1 as( select (st_symdifference(point(1,1),point(1,1))) as a1 ), cte2 as(select 1 as a2) select 1 from cte1 where cte1.a1 < '1';
+1
+1
DROP TABLE IF EXISTS p1;
CREATE PROCEDURE p1(dist DOUBLE, geom TEXT)
BEGIN
diff --git a/mysql-test/main/gis-precise.test b/mysql-test/main/gis-precise.test
index 07fabae6025..0bb445924b8 100644
--- a/mysql-test/main/gis-precise.test
+++ b/mysql-test/main/gis-precise.test
@@ -382,5 +382,9 @@ SELECT ST_RELATE(
'F*FFFF**F'
) as relate_res;
+# MDEV- 16050 cte + geometry functions lead to crash.
+
+with cte1 as( select (st_symdifference(point(1,1),point(1,1))) as a1 ), cte2 as(select 1 as a2) select 1 from cte1 where cte1.a1 < '1';
+
--source include/gis_debug.inc
diff --git a/mysql-test/main/gis.result b/mysql-test/main/gis.result
index 886b1b5f6a8..05e6e41852a 100644
--- a/mysql-test/main/gis.result
+++ b/mysql-test/main/gis.result
@@ -1721,6 +1721,22 @@ c2
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
#
+# MDEV-16995: ER_CANT_CREATE_GEOMETRY_OBJECT encountered for a query with
+# optimizer_use_condition_selectivity>=3
+#
+CREATE TABLE t1 (a POINT);
+INSERT INTO t1 VALUES (POINT(1,1)),(POINT(1,2)),(POINT(1,3));
+set @save_use_stat_tables= @@use_stat_tables;
+set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+set @@use_stat_tables= PREFERABLY;
+set @@optimizer_use_condition_selectivity=3;
+SELECT COUNT(*) FROM t1 WHERE a IN ('test','test1');
+COUNT(*)
+0
+set @@use_stat_tables= @save_use_stat_tables;
+set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+drop table t1;
+#
# End 10.0 tests
#
SHOW CREATE TABLE information_schema.geometry_columns;
diff --git a/mysql-test/main/gis.test b/mysql-test/main/gis.test
index 97a655bf51e..c3d0fb43520 100644
--- a/mysql-test/main/gis.test
+++ b/mysql-test/main/gis.test
@@ -1481,6 +1481,21 @@ SELECT LENGTH(CONCAT(t2,'--',t2)) c2 FROM (SELECT ST_BUFFER(POINT(x,y), 0) t2 FR
DROP TABLE t1;
SET optimizer_switch=@save_optimizer_switch;
+--echo #
+--echo # MDEV-16995: ER_CANT_CREATE_GEOMETRY_OBJECT encountered for a query with
+--echo # optimizer_use_condition_selectivity>=3
+--echo #
+
+CREATE TABLE t1 (a POINT);
+INSERT INTO t1 VALUES (POINT(1,1)),(POINT(1,2)),(POINT(1,3));
+set @save_use_stat_tables= @@use_stat_tables;
+set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+set @@use_stat_tables= PREFERABLY;
+set @@optimizer_use_condition_selectivity=3;
+SELECT COUNT(*) FROM t1 WHERE a IN ('test','test1');
+set @@use_stat_tables= @save_use_stat_tables;
+set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+drop table t1;
--echo #
--echo # End 10.0 tests
diff --git a/mysql-test/main/grant.result b/mysql-test/main/grant.result
index ff7ff2b3611..74f86edd4ea 100644
--- a/mysql-test/main/grant.result
+++ b/mysql-test/main/grant.result
@@ -58,7 +58,7 @@ max_questions 0
max_updates 0
max_connections 0
max_user_connections 0
-plugin
+plugin mysql_native_password
authentication_string
password_expired N
is_role N
@@ -134,7 +134,7 @@ max_questions 10
max_updates 0
max_connections 0
max_user_connections 0
-plugin
+plugin mysql_native_password
authentication_string
password_expired N
is_role N
@@ -186,7 +186,7 @@ max_questions 10
max_updates 20
max_connections 30
max_user_connections 0
-plugin
+plugin mysql_native_password
authentication_string
password_expired N
is_role N
@@ -1759,6 +1759,7 @@ drop user mysqltest@localhost;
disconnect user1;
drop database mysqltest;
use test;
+call mtr.add_suppression("Can't open and lock privilege tables");
FLUSH PRIVILEGES without procs_priv table.
RENAME TABLE mysql.procs_priv TO mysql.procs_gone;
FLUSH PRIVILEGES;
@@ -1852,8 +1853,6 @@ BEGIN
SET @x = 0;
REPEAT SET @x = @x + 1; UNTIL @x > p1 END REPEAT;
END ;||
-Warnings:
-Warning 1404 Failed to grant EXECUTE and ALTER ROUTINE privileges
connection default;
SHOW GRANTS FOR 'user1'@'localhost';
Grants for user1@localhost
@@ -1864,6 +1863,7 @@ SHOW GRANTS FOR 'user2';
Grants for user2@%
GRANT USAGE ON *.* TO 'user2'@'%'
GRANT CREATE, CREATE ROUTINE ON `db1`.* TO 'user2'@'%'
+GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `db1`.`proc2` TO 'user2'@'%'
disconnect con1;
disconnect con2;
DROP PROCEDURE db1.proc1;
@@ -2672,6 +2672,38 @@ disconnect conn2;
disconnect conn3;
DROP USER foo@'127.0.0.1';
# End of Bug#12766319
+create user foo@localhost;
+create database foodb;
+grant create routine on foodb.* to foo@localhost;
+connect con1,localhost,foo;
+create procedure fooproc() select 'i am fooproc';
+show grants;
+Grants for foo@localhost
+GRANT USAGE ON *.* TO 'foo'@'localhost'
+GRANT CREATE ROUTINE ON `foodb`.* TO 'foo'@'localhost'
+GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `test`.`fooproc` TO 'foo'@'localhost'
+disconnect con1;
+connection default;
+rename table mysql.procs_priv to mysql.procs_priv1;
+flush privileges;
+show grants for foo@localhost;
+Grants for foo@localhost
+GRANT USAGE ON *.* TO 'foo'@'localhost'
+GRANT CREATE ROUTINE ON `foodb`.* TO 'foo'@'localhost'
+rename table mysql.procs_priv1 to mysql.procs_priv;
+show grants for foo@localhost;
+Grants for foo@localhost
+GRANT USAGE ON *.* TO 'foo'@'localhost'
+GRANT CREATE ROUTINE ON `foodb`.* TO 'foo'@'localhost'
+flush privileges;
+show grants for foo@localhost;
+Grants for foo@localhost
+GRANT USAGE ON *.* TO 'foo'@'localhost'
+GRANT CREATE ROUTINE ON `foodb`.* TO 'foo'@'localhost'
+GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `test`.`fooproc` TO 'foo'@'localhost'
+drop user foo@localhost;
+drop procedure fooproc;
+drop database foodb;
#
# Bug#11756966 - 48958: STORED PROCEDURES CAN BE LEVERAGED TO BYPASS
# DATABASE SECURITY
diff --git a/mysql-test/main/grant.test b/mysql-test/main/grant.test
index cb4254fe8c6..f54c4bd981d 100644
--- a/mysql-test/main/grant.test
+++ b/mysql-test/main/grant.test
@@ -1598,6 +1598,9 @@ use test;
#
# Bug#16470 crash on grant if old grant tables
#
+
+call mtr.add_suppression("Can't open and lock privilege tables");
+
--echo FLUSH PRIVILEGES without procs_priv table.
RENAME TABLE mysql.procs_priv TO mysql.procs_gone;
FLUSH PRIVILEGES;
@@ -2172,6 +2175,28 @@ DROP USER foo@'127.0.0.1';
--echo # End of Bug#12766319
+#
+# Bug#27230925: HANDLE_FATAL_SIGNAL (SIG=11) IN SHOW_ROUTINE_GRANTS
+#
+create user foo@localhost;
+create database foodb;
+grant create routine on foodb.* to foo@localhost;
+connect con1,localhost,foo;
+create procedure fooproc() select 'i am fooproc';
+show grants;
+disconnect con1;
+connection default;
+rename table mysql.procs_priv to mysql.procs_priv1;
+flush privileges;
+show grants for foo@localhost;
+rename table mysql.procs_priv1 to mysql.procs_priv;
+show grants for foo@localhost;
+flush privileges;
+show grants for foo@localhost;
+drop user foo@localhost;
+drop procedure fooproc;
+drop database foodb;
+
--echo #
--echo # Bug#11756966 - 48958: STORED PROCEDURES CAN BE LEVERAGED TO BYPASS
diff --git a/mysql-test/main/grant2.result b/mysql-test/main/grant2.result
index 632a9524b45..4fd1a6c3fe7 100644
--- a/mysql-test/main/grant2.result
+++ b/mysql-test/main/grant2.result
@@ -181,19 +181,19 @@ grant select on *.* to 'mysqltest_2';
grant insert on test.* to 'mysqltest_2';
grant update on test.t1 to 'mysqltest_2';
grant update (c2) on test.t2 to 'mysqltest_2';
-select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
-host user password
-% mysqltest_1
-% mysqltest_2 *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
-% mysqltest_3 fffffffffffffffffffffffffffffffffffffffff
-select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
+select host,user,password,plugin,authentication_string from mysql.user where user like 'mysqltest_%';
+host user password plugin authentication_string
+% mysqltest_1 mysql_native_password
+% mysqltest_2 mysql_native_password *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
+% mysqltest_3 mysql_native_password fffffffffffffffffffffffffffffffffffffffff
+select host,db,user from mysql.db where user like 'mysqltest_%';
host db user
% test mysqltest_2
-select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
+select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%';
host db user table_name
% test mysqltest_2 t1
% test mysqltest_2 t2
-select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
+select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%';
host db user table_name column_name
% test mysqltest_2 t2 c2
show grants for 'mysqltest_1';
@@ -206,35 +206,35 @@ GRANT INSERT ON "test".* TO 'mysqltest_2'@'%'
GRANT UPDATE (c2) ON "test"."t2" TO 'mysqltest_2'@'%'
GRANT UPDATE ON "test"."t1" TO 'mysqltest_2'@'%'
drop user 'mysqltest_1';
-select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
-host user password
-% mysqltest_2 *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
-% mysqltest_3 fffffffffffffffffffffffffffffffffffffffff
-select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
+select host,user,password,plugin,authentication_string from mysql.user where user like 'mysqltest_%';
+host user password plugin authentication_string
+% mysqltest_2 mysql_native_password *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
+% mysqltest_3 mysql_native_password fffffffffffffffffffffffffffffffffffffffff
+select host,db,user from mysql.db where user like 'mysqltest_%';
host db user
% test mysqltest_2
-select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
+select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%';
host db user table_name
% test mysqltest_2 t1
% test mysqltest_2 t2
-select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
+select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%';
host db user table_name column_name
% test mysqltest_2 t2 c2
show grants for 'mysqltest_1';
ERROR 42000: There is no such grant defined for user 'mysqltest_1' on host '%'
rename user 'mysqltest_2' to 'mysqltest_1';
-select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
-host user password
-% mysqltest_1 *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
-% mysqltest_3 fffffffffffffffffffffffffffffffffffffffff
-select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
+select host,user,password,plugin,authentication_string from mysql.user where user like 'mysqltest_%' ;
+host user password plugin authentication_string
+% mysqltest_1 mysql_native_password *BD447CBA355AF58578D3AE33BA2E2CD388BA08D1
+% mysqltest_3 mysql_native_password fffffffffffffffffffffffffffffffffffffffff
+select host,db,user from mysql.db where user like 'mysqltest_%' ;
host db user
% test mysqltest_1
-select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
+select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' ;
host db user table_name
% test mysqltest_1 t1
% test mysqltest_1 t2
-select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
+select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' ;
host db user table_name column_name
% test mysqltest_1 t2 c2
show grants for 'mysqltest_1';
@@ -254,21 +254,21 @@ ERROR 42000: There is no such grant defined for user 'mysqltest_1' on host '%'
revoke all privileges, grant option from 'mysqltest_1';
ERROR HY000: Can't revoke all privileges for one or more of the requested users
drop user 'mysqltest_1';
-select host,db,user from mysql.db where user = 'mysqltest_1' order by host,db,user;
+select host,db,user from mysql.db where user = 'mysqltest_1' ;
host db user
insert into mysql.tables_priv set host='%', db='test', user='mysqltest_1', table_name='t1';
flush privileges;
show grants for 'mysqltest_1';
ERROR 42000: There is no such grant defined for user 'mysqltest_1' on host '%'
drop user 'mysqltest_1';
-select host,db,user,table_name from mysql.tables_priv where user = 'mysqltest_1' order by host,db,user,table_name;
+select host,db,user,table_name from mysql.tables_priv where user = 'mysqltest_1' ;
host db user table_name
insert into mysql.columns_priv set host='%', db='test', user='mysqltest_1', table_name='t1', column_name='c1';
flush privileges;
show grants for 'mysqltest_1';
ERROR 42000: There is no such grant defined for user 'mysqltest_1' on host '%'
drop user 'mysqltest_1';
-select host,db,user,table_name,column_name from mysql.columns_priv where user = 'mysqltest_1' order by host,db,user,table_name,column_name;
+select host,db,user,table_name,column_name from mysql.columns_priv where user = 'mysqltest_1' ;
host db user table_name column_name
create user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
drop user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
@@ -310,7 +310,7 @@ create user mysqltest_2@localhost;
grant create user on *.* to mysqltest_2@localhost;
connect user3,localhost,mysqltest_2,,;
connection user3;
-select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
+select host,user,password,plugin,authentication_string from mysql.user where user like 'mysqltest_%' ;
ERROR 42000: SELECT command denied to user 'mysqltest_2'@'localhost' for table 'user'
create user mysqltest_A@'%';
rename user mysqltest_A@'%' to mysqltest_B@'%';
@@ -326,7 +326,7 @@ show grants;
Grants for mysqltest_3@localhost
GRANT USAGE ON *.* TO 'mysqltest_3'@'localhost'
GRANT INSERT, UPDATE, DELETE ON `mysql`.* TO 'mysqltest_3'@'localhost'
-select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
+select host,user,password,plugin,authentication_string from mysql.user where user like 'mysqltest_%' ;
ERROR 42000: SELECT command denied to user 'mysqltest_3'@'localhost' for table 'user'
insert into mysql.user set host='%', user='mysqltest_B';
Warnings:
@@ -555,29 +555,26 @@ End of 5.0 tests
USE mysql;
SELECT LEFT(CURRENT_USER(),INSTR(CURRENT_USER(),'@')-1) INTO @u;
SELECT MID(CURRENT_USER(),INSTR(CURRENT_USER(),'@')+1) INTO @h;
-SELECT password FROM user WHERE user=@u AND host=@h INTO @pwd;
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
-SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
-user host password insert_priv
-root localhost Y
+SELECT user,host,password,plugin,authentication_string,insert_priv FROM user WHERE user=@u AND host=@h;
+user host password plugin authentication_string insert_priv
+root localhost Y
UPDATE user SET insert_priv='N' WHERE user=@u AND host=@h;
-SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
-user host password insert_priv
-root localhost N
+SELECT user,host,password,plugin,authentication_string,insert_priv FROM user WHERE user=@u AND host=@h;
+user host password plugin authentication_string insert_priv
+root localhost N
GRANT INSERT ON *.* TO CURRENT_USER();
-SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
-user host password insert_priv
-root localhost Y
+SELECT user,host,password,plugin,authentication_string,insert_priv FROM user WHERE user=@u AND host=@h;
+user host password plugin authentication_string insert_priv
+root localhost mysql_native_password Y
UPDATE user SET insert_priv='N' WHERE user=@u AND host=@h;
GRANT INSERT ON *.* TO CURRENT_USER() IDENTIFIED BY 'keksdose';
-SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
-user host password insert_priv
-root localhost *0BB7188CF0DE9B403BA66E9DD810D82652D002EB Y
-UPDATE user SET password=@pwd WHERE user=@u AND host=@h;
-SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
-user host password insert_priv
-root localhost Y
+SELECT user,host,password,plugin,authentication_string,insert_priv FROM user WHERE user=@u AND host=@h;
+user host password plugin authentication_string insert_priv
+root localhost mysql_native_password *0BB7188CF0DE9B403BA66E9DD810D82652D002EB Y
+UPDATE user SET plugin='', authentication_string='' WHERE user=@u AND host=@h;
+SELECT user,host,password,plugin,authentication_string,insert_priv FROM user WHERE user=@u AND host=@h;
+user host password plugin authentication_string insert_priv
+root localhost Y
FLUSH PRIVILEGES;
USE test;
End of 5.1 tests
diff --git a/mysql-test/main/grant2.test b/mysql-test/main/grant2.test
index 1f7450df6c1..f0b58da4cb5 100644
--- a/mysql-test/main/grant2.test
+++ b/mysql-test/main/grant2.test
@@ -231,28 +231,40 @@ grant select on *.* to 'mysqltest_2';
grant insert on test.* to 'mysqltest_2';
grant update on test.t1 to 'mysqltest_2';
grant update (c2) on test.t2 to 'mysqltest_2';
-select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
-select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
-select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
-select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
+--sorted_result
+select host,user,password,plugin,authentication_string from mysql.user where user like 'mysqltest_%';
+--sorted_result
+select host,db,user from mysql.db where user like 'mysqltest_%';
+--sorted_result
+select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%';
+--sorted_result
+select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%';
show grants for 'mysqltest_1';
show grants for 'mysqltest_2';
#
# Drop
drop user 'mysqltest_1';
-select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
-select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
-select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
-select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
+--sorted_result
+select host,user,password,plugin,authentication_string from mysql.user where user like 'mysqltest_%';
+--sorted_result
+select host,db,user from mysql.db where user like 'mysqltest_%';
+--sorted_result
+select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%';
+--sorted_result
+select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%';
--error ER_NONEXISTING_GRANT
show grants for 'mysqltest_1';
#
# Rename
rename user 'mysqltest_2' to 'mysqltest_1';
-select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
-select host,db,user from mysql.db where user like 'mysqltest_%' order by host,db,user;
-select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' order by host,db,user,table_name;
-select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' order by host,db,user,table_name,column_name;
+--sorted_result
+select host,user,password,plugin,authentication_string from mysql.user where user like 'mysqltest_%' ;
+--sorted_result
+select host,db,user from mysql.db where user like 'mysqltest_%' ;
+--sorted_result
+select host,db,user,table_name from mysql.tables_priv where user like 'mysqltest_%' ;
+--sorted_result
+select host,db,user,table_name,column_name from mysql.columns_priv where user like 'mysqltest_%' ;
show grants for 'mysqltest_1';
drop user 'mysqltest_1', 'mysqltest_3';
--error ER_CANNOT_USER
@@ -269,7 +281,8 @@ show grants for 'mysqltest_1';
--error ER_REVOKE_GRANTS
revoke all privileges, grant option from 'mysqltest_1';
drop user 'mysqltest_1';
-select host,db,user from mysql.db where user = 'mysqltest_1' order by host,db,user;
+--sorted_result
+select host,db,user from mysql.db where user = 'mysqltest_1' ;
#
# Add a stray record
insert into mysql.tables_priv set host='%', db='test', user='mysqltest_1', table_name='t1';
@@ -277,7 +290,8 @@ flush privileges;
--error ER_NONEXISTING_GRANT
show grants for 'mysqltest_1';
drop user 'mysqltest_1';
-select host,db,user,table_name from mysql.tables_priv where user = 'mysqltest_1' order by host,db,user,table_name;
+--sorted_result
+select host,db,user,table_name from mysql.tables_priv where user = 'mysqltest_1' ;
#
# Add a stray record
insert into mysql.columns_priv set host='%', db='test', user='mysqltest_1', table_name='t1', column_name='c1';
@@ -285,7 +299,8 @@ flush privileges;
--error ER_NONEXISTING_GRANT
show grants for 'mysqltest_1';
drop user 'mysqltest_1';
-select host,db,user,table_name,column_name from mysql.columns_priv where user = 'mysqltest_1' order by host,db,user,table_name,column_name;
+--sorted_result
+select host,db,user,table_name,column_name from mysql.columns_priv where user = 'mysqltest_1' ;
#
# Handle multi user lists
create user 'mysqltest_1', 'mysqltest_2', 'mysqltest_3';
@@ -330,7 +345,7 @@ grant create user on *.* to mysqltest_2@localhost;
connect (user3,localhost,mysqltest_2,,);
connection user3;
--error ER_TABLEACCESS_DENIED_ERROR
-select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
+select host,user,password,plugin,authentication_string from mysql.user where user like 'mysqltest_%' ;
create user mysqltest_A@'%';
rename user mysqltest_A@'%' to mysqltest_B@'%';
drop user mysqltest_B@'%';
@@ -345,7 +360,7 @@ connect (user4,localhost,mysqltest_3,,);
connection user4;
show grants;
--error ER_TABLEACCESS_DENIED_ERROR
-select host,user,password from mysql.user where user like 'mysqltest_%' order by host,user,password;
+select host,user,password,plugin,authentication_string from mysql.user where user like 'mysqltest_%' ;
insert into mysql.user set host='%', user='mysqltest_B';
create user mysqltest_A@'%';
rename user mysqltest_B@'%' to mysqltest_C@'%';
@@ -642,26 +657,25 @@ DROP DATABASE db1;
USE mysql;
SELECT LEFT(CURRENT_USER(),INSTR(CURRENT_USER(),'@')-1) INTO @u;
SELECT MID(CURRENT_USER(),INSTR(CURRENT_USER(),'@')+1) INTO @h;
-SELECT password FROM user WHERE user=@u AND host=@h INTO @pwd;
# show current privs.
-SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
+SELECT user,host,password,plugin,authentication_string,insert_priv FROM user WHERE user=@u AND host=@h;
# toggle INSERT
UPDATE user SET insert_priv='N' WHERE user=@u AND host=@h;
-SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
+SELECT user,host,password,plugin,authentication_string,insert_priv FROM user WHERE user=@u AND host=@h;
# show that GRANT ... TO CURRENT_USER() no longer crashes
GRANT INSERT ON *.* TO CURRENT_USER();
-SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
+SELECT user,host,password,plugin,authentication_string,insert_priv FROM user WHERE user=@u AND host=@h;
UPDATE user SET insert_priv='N' WHERE user=@u AND host=@h;
# show that GRANT ... TO CURRENT_USER() IDENTIFIED BY ... works now
GRANT INSERT ON *.* TO CURRENT_USER() IDENTIFIED BY 'keksdose';
-SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
+SELECT user,host,password,plugin,authentication_string,insert_priv FROM user WHERE user=@u AND host=@h;
-UPDATE user SET password=@pwd WHERE user=@u AND host=@h;
-SELECT user,host,password,insert_priv FROM user WHERE user=@u AND host=@h;
+UPDATE user SET plugin='', authentication_string='' WHERE user=@u AND host=@h;
+SELECT user,host,password,plugin,authentication_string,insert_priv FROM user WHERE user=@u AND host=@h;
FLUSH PRIVILEGES;
diff --git a/mysql-test/main/grant4.result b/mysql-test/main/grant4.result
index c3db2e03e3e..735b8260fce 100644
--- a/mysql-test/main/grant4.result
+++ b/mysql-test/main/grant4.result
@@ -199,14 +199,14 @@ grant select on test.* to foo7 identified via mysql_native_password using '11111
grant select on test.* to foo8 identified via mysql_old_password using '2222222222222222';
select user,password,plugin,authentication_string from mysql.user where user like 'foo%';
user password plugin authentication_string
-foo1 11111111111111111111111111111111111111111
-foo2 2222222222222222
-foo3 11111111111111111111111111111111111111111
-foo4 2222222222222222
-foo5 11111111111111111111111111111111111111111
-foo6 2222222222222222
-foo7 11111111111111111111111111111111111111111
-foo8 2222222222222222
+foo1 mysql_native_password 11111111111111111111111111111111111111111
+foo2 mysql_old_password 2222222222222222
+foo3 mysql_native_password 11111111111111111111111111111111111111111
+foo4 mysql_old_password 2222222222222222
+foo5 mysql_native_password 11111111111111111111111111111111111111111
+foo6 mysql_old_password 2222222222222222
+foo7 mysql_native_password 11111111111111111111111111111111111111111
+foo8 mysql_old_password 2222222222222222
drop user foo1;
drop user foo2;
drop user foo3;
diff --git a/mysql-test/main/grant5.result b/mysql-test/main/grant5.result
index 24abc61a348..af7b75277b8 100644
--- a/mysql-test/main/grant5.result
+++ b/mysql-test/main/grant5.result
@@ -18,3 +18,84 @@ ERROR 42000: Access denied for user 'test'@'%' to database 'mysql'
connection default;
drop user test, foo;
drop role foo;
+create user u1@h identified with 'mysql_native_password' using 'pwd';
+ERROR HY000: Password hash should be a 41-digit hexadecimal number
+create user u1@h identified with 'mysql_native_password' using password('pwd');
+create user u2@h identified with 'mysql_native_password' using '*975B2CD4FF9AE554FE8AD33168FBFC326D2021DD';
+create user u3@h identified with 'mysql_native_password';
+set password for u3@h = 'pwd';
+ERROR HY000: Password hash should be a 41-digit hexadecimal number
+set password for u3@h = password('pwd');
+create user u4@h identified with 'mysql_native_password';
+set password for u4@h = '*975B2CD4FF9AE554FE8AD33168FBFC326D2021DD';
+create user u5@h identified with 'mysql_old_password' using 'pwd';
+ERROR HY000: Password hash should be a 16-digit hexadecimal number
+create user u5@h identified with 'mysql_old_password' using password('pwd');
+create user u6@h identified with 'mysql_old_password' using '78a302dd267f6044';
+create user u7@h identified with 'mysql_old_password';
+set password for u7@h = 'pwd';
+ERROR HY000: Password hash should be a 41-digit hexadecimal number
+set password for u7@h = old_password('pwd');
+create user u8@h identified with 'mysql_old_password';
+set password for u8@h = '78a302dd267f6044';
+select user,host,password,plugin,authentication_string from mysql.user where host='h';
+user host password plugin authentication_string
+u1 h mysql_native_password *975B2CD4FF9AE554FE8AD33168FBFC326D2021DD
+u2 h mysql_native_password *975B2CD4FF9AE554FE8AD33168FBFC326D2021DD
+u3 h mysql_native_password *975B2CD4FF9AE554FE8AD33168FBFC326D2021DD
+u4 h mysql_native_password *975B2CD4FF9AE554FE8AD33168FBFC326D2021DD
+u5 h mysql_old_password 78a302dd267f6044
+u6 h mysql_old_password 78a302dd267f6044
+u7 h mysql_old_password 78a302dd267f6044
+u8 h mysql_old_password 78a302dd267f6044
+update mysql.user set authentication_string='bad' where user='u1';
+update mysql.user set authentication_string='bad' where user='u5';
+update mysql.user set plugin='nonexistent' where user='u8';
+flush privileges;
+Warnings:
+Error 1372 Password hash should be a 41-digit hexadecimal number
+Error 1372 Password hash should be a 16-digit hexadecimal number
+Warning 1524 Plugin 'nonexistent' is not loaded
+show create user u1@h;
+ERROR 28000: Can't find any matching row in the user table
+show create user u2@h;
+CREATE USER for u2@h
+CREATE USER 'u2'@'h' IDENTIFIED BY PASSWORD '*975B2CD4FF9AE554FE8AD33168FBFC326D2021DD'
+show create user u3@h;
+CREATE USER for u3@h
+CREATE USER 'u3'@'h' IDENTIFIED BY PASSWORD '*975B2CD4FF9AE554FE8AD33168FBFC326D2021DD'
+show create user u4@h;
+CREATE USER for u4@h
+CREATE USER 'u4'@'h' IDENTIFIED BY PASSWORD '*975B2CD4FF9AE554FE8AD33168FBFC326D2021DD'
+show create user u5@h;
+ERROR 28000: Can't find any matching row in the user table
+show create user u6@h;
+CREATE USER for u6@h
+CREATE USER 'u6'@'h' IDENTIFIED BY PASSWORD '78a302dd267f6044'
+show create user u7@h;
+CREATE USER for u7@h
+CREATE USER 'u7'@'h' IDENTIFIED BY PASSWORD '78a302dd267f6044'
+show create user u8@h;
+ERROR 28000: Can't find any matching row in the user table
+grant select on *.* to u1@h;
+ERROR 28000: Can't find any matching row in the user table
+grant select on *.* to u2@h;
+grant select on *.* to u3@h;
+grant select on *.* to u4@h;
+grant select on *.* to u5@h;
+ERROR 28000: Can't find any matching row in the user table
+grant select on *.* to u6@h;
+grant select on *.* to u7@h;
+grant select on *.* to u8@h;
+ERROR 28000: Can't find any matching row in the user table
+select user,select_priv,plugin,authentication_string from mysql.user where user like 'u_';
+user select_priv plugin authentication_string
+u1 N mysql_native_password bad
+u2 Y mysql_native_password *975B2CD4FF9AE554FE8AD33168FBFC326D2021DD
+u3 Y mysql_native_password *975B2CD4FF9AE554FE8AD33168FBFC326D2021DD
+u4 Y mysql_native_password *975B2CD4FF9AE554FE8AD33168FBFC326D2021DD
+u5 N mysql_old_password bad
+u6 Y mysql_old_password 78a302dd267f6044
+u7 Y mysql_old_password 78a302dd267f6044
+u8 N nonexistent 78a302dd267f6044
+drop user u1@h, u2@h, u3@h, u4@h, u5@h, u6@h, u7@h, u8@h;
diff --git a/mysql-test/main/grant5.test b/mysql-test/main/grant5.test
index 14f2fd65020..1ab68b82066 100644
--- a/mysql-test/main/grant5.test
+++ b/mysql-test/main/grant5.test
@@ -23,3 +23,63 @@ show grants for foo@'%'; # user
drop user test, foo;
drop role foo;
+#
+# MDEV-12321 authentication plugin: SET PASSWORD support
+#
+error ER_PASSWD_LENGTH;
+create user u1@h identified with 'mysql_native_password' using 'pwd';
+create user u1@h identified with 'mysql_native_password' using password('pwd');
+let p=`select password('pwd')`;
+eval create user u2@h identified with 'mysql_native_password' using '$p';
+create user u3@h identified with 'mysql_native_password';
+error ER_PASSWD_LENGTH;
+set password for u3@h = 'pwd';
+set password for u3@h = password('pwd');
+create user u4@h identified with 'mysql_native_password';
+eval set password for u4@h = '$p';
+error ER_PASSWD_LENGTH;
+create user u5@h identified with 'mysql_old_password' using 'pwd';
+create user u5@h identified with 'mysql_old_password' using password('pwd');
+let p=`select old_password('pwd')`;
+eval create user u6@h identified with 'mysql_old_password' using '$p';
+create user u7@h identified with 'mysql_old_password';
+error ER_PASSWD_LENGTH;
+set password for u7@h = 'pwd';
+set password for u7@h = old_password('pwd');
+create user u8@h identified with 'mysql_old_password';
+eval set password for u8@h = '$p';
+sorted_result;
+select user,host,password,plugin,authentication_string from mysql.user where host='h';
+# test with invalid entries
+update mysql.user set authentication_string='bad' where user='u1';
+update mysql.user set authentication_string='bad' where user='u5';
+update mysql.user set plugin='nonexistent' where user='u8';
+flush privileges;
+# invalid entries are skipped, users don't exist
+error ER_PASSWORD_NO_MATCH;
+show create user u1@h;
+show create user u2@h;
+show create user u3@h;
+show create user u4@h;
+error ER_PASSWORD_NO_MATCH;
+show create user u5@h;
+show create user u6@h;
+show create user u7@h;
+error ER_PASSWORD_NO_MATCH;
+show create user u8@h;
+#grants don't work either
+error ER_PASSWORD_NO_MATCH;
+grant select on *.* to u1@h;
+grant select on *.* to u2@h;
+grant select on *.* to u3@h;
+grant select on *.* to u4@h;
+error ER_PASSWORD_NO_MATCH;
+grant select on *.* to u5@h;
+grant select on *.* to u6@h;
+grant select on *.* to u7@h;
+error ER_PASSWORD_NO_MATCH;
+grant select on *.* to u8@h;
+select user,select_priv,plugin,authentication_string from mysql.user where user like 'u_';
+
+# but they still can be dropped
+drop user u1@h, u2@h, u3@h, u4@h, u5@h, u6@h, u7@h, u8@h;
diff --git a/mysql-test/main/grant_lowercase.result b/mysql-test/main/grant_lowercase.result
index d4a1667595e..a87f74721bc 100644
--- a/mysql-test/main/grant_lowercase.result
+++ b/mysql-test/main/grant_lowercase.result
@@ -9,17 +9,11 @@ connection default;
disconnect conn1;
drop user user1@localhost;
call mtr.add_suppression("Incorrect database name");
-alter table mysql.host modify Db varchar(200);
alter table mysql.db modify User char(16) default "", modify Db varchar(200) default "";
-insert mysql.host set db=concat('=>', repeat(_utf8 'й', 200));
-Warnings:
-Warning 1265 Data truncated for column 'Db' at row 1
insert mysql.db set db=concat('=>', repeat(_utf8 'й', 200));
Warnings:
Warning 1265 Data truncated for column 'Db' at row 1
flush privileges;
-delete from mysql.host where db like '=>%';
delete from mysql.db where db like '=>%';
-alter table mysql.host modify Db char(64) default "";
alter table mysql.db modify Db char(64) default "", modify User char(80) default "";
flush privileges;
diff --git a/mysql-test/main/grant_lowercase.test b/mysql-test/main/grant_lowercase.test
index e31a72b890e..ffd1d4682a0 100644
--- a/mysql-test/main/grant_lowercase.test
+++ b/mysql-test/main/grant_lowercase.test
@@ -18,13 +18,9 @@ drop user user1@localhost;
# in acl_load()
call mtr.add_suppression("Incorrect database name");
-alter table mysql.host modify Db varchar(200);
alter table mysql.db modify User char(16) default "", modify Db varchar(200) default "";
-insert mysql.host set db=concat('=>', repeat(_utf8 'й', 200));
insert mysql.db set db=concat('=>', repeat(_utf8 'й', 200));
flush privileges; # shouldn't crash here
-delete from mysql.host where db like '=>%';
delete from mysql.db where db like '=>%';
-alter table mysql.host modify Db char(64) default "";
alter table mysql.db modify Db char(64) default "", modify User char(80) default "";
flush privileges;
diff --git a/mysql-test/main/group_min_max.result b/mysql-test/main/group_min_max.result
index 36a44b05817..cfdf9ef9865 100644
--- a/mysql-test/main/group_min_max.result
+++ b/mysql-test/main/group_min_max.result
@@ -3733,6 +3733,34 @@ id MIN(a) MAX(a)
4 2001-01-04 2001-01-04
DROP TABLE t1;
#
+# MDEV-17039: Query plan changes when we use GROUP BY optimization with optimizer_use_condition_selectivity=4
+# and use_stat_tables= PREFERABLY
+#
+CREATE TABLE t1 (a INT, b INT,c INT DEFAULT 0, INDEX (a,b));
+INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),
+(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
+set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+set @save_use_stat_tables= @@use_stat_tables;
+set @@optimizer_use_condition_selectivity=4;
+set @@use_stat_tables=PREFERABLY;
+explain extended SELECT a FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 8 100.00
+1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 2 100.00 Using index
+2 MATERIALIZED t1 range NULL a 5 NULL 8 100.00 Using index for group-by
+Warnings:
+Note 1003 /* select#1 */ select `test`.`t1_outer`.`a` AS `a` from <materialize> (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` `t1_outer` where `test`.`t1_outer`.`a` = `<subquery2>`.`max(b)`
+set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+set @@use_stat_tables=@save_use_stat_tables;
+explain extended SELECT a FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a);
+id select_type table type possible_keys key key_len ref rows filtered Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 8 100.00
+1 PRIMARY t1_outer ref a a 5 <subquery2>.max(b) 2 100.00 Using index
+2 MATERIALIZED t1 range NULL a 5 NULL 8 100.00 Using index for group-by
+Warnings:
+Note 1003 /* select#1 */ select `test`.`t1_outer`.`a` AS `a` from <materialize> (/* select#2 */ select max(`test`.`t1`.`b`) from `test`.`t1` group by `test`.`t1`.`a`) join `test`.`t1` `t1_outer` where `test`.`t1_outer`.`a` = `<subquery2>`.`max(b)`
+drop table t1;
+#
# End of 10.0 tests
#
#
@@ -3893,5 +3921,22 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index a a 13 NULL 2 Using where; Using index
drop table t1;
#
+# MDEV-15433: Optimizer does not use group by optimization with distinct
+#
+CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, a INT NOT NULL, KEY(a));
+OPTIMIZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 optimize status OK
+EXPLAIN SELECT DISTINCT a FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range NULL a 4 NULL 5 Using index for group-by
+SELECT DISTINCT a FROM t1;
+a
+1
+2
+3
+4
+drop table t1;
+#
# End of 10.1 tests
#
diff --git a/mysql-test/main/group_min_max.test b/mysql-test/main/group_min_max.test
index b0bc42d7f8c..e8245dd2898 100644
--- a/mysql-test/main/group_min_max.test
+++ b/mysql-test/main/group_min_max.test
@@ -1519,6 +1519,23 @@ ALTER TABLE t1 ADD KEY(id,a);
SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=DATE'2001-01-04' GROUP BY id;
DROP TABLE t1;
+--echo #
+--echo # MDEV-17039: Query plan changes when we use GROUP BY optimization with optimizer_use_condition_selectivity=4
+--echo # and use_stat_tables= PREFERABLY
+--echo #
+
+CREATE TABLE t1 (a INT, b INT,c INT DEFAULT 0, INDEX (a,b));
+INSERT INTO t1 (a, b) VALUES (1,1), (1,2), (1,3), (1,4), (1,5),
+(2,2), (2,3), (2,1), (3,1), (4,1), (4,2), (4,3), (4,4), (4,5), (4,6);
+set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+set @save_use_stat_tables= @@use_stat_tables;
+set @@optimizer_use_condition_selectivity=4;
+set @@use_stat_tables=PREFERABLY;
+explain extended SELECT a FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a);
+set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+set @@use_stat_tables=@save_use_stat_tables;
+explain extended SELECT a FROM t1 AS t1_outer WHERE a IN (SELECT max(b) FROM t1 GROUP BY a);
+drop table t1;
--echo #
--echo # End of 10.0 tests
@@ -1609,5 +1626,32 @@ explain select min(a) from t1 where a between "abbbbbbbbbbbbbbbbbbbb" and "Cafe2
drop table t1;
--echo #
+--echo # MDEV-15433: Optimizer does not use group by optimization with distinct
+--echo #
+
+CREATE TABLE t1 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, a INT NOT NULL, KEY(a));
+--disable_query_log
+INSERT INTO t1(a) VALUES (1), (2), (3), (4);
+INSERT INTO t1(a) SELECT a FROM t1;
+INSERT INTO t1(a) SELECT a FROM t1;
+INSERT INTO t1(a) SELECT a FROM t1;
+INSERT INTO t1(a) SELECT a FROM t1;
+INSERT INTO t1(a) SELECT a FROM t1;
+INSERT INTO t1(a) SELECT a FROM t1;
+INSERT INTO t1(a) SELECT a FROM t1;
+INSERT INTO t1(a) SELECT a FROM t1;
+INSERT INTO t1(a) SELECT a FROM t1;
+INSERT INTO t1(a) SELECT a FROM t1;
+INSERT INTO t1(a) SELECT a FROM t1;
+INSERT INTO t1(a) SELECT a FROM t1;
+INSERT INTO t1(a) SELECT a FROM t1;
+INSERT INTO t1(a) SELECT a FROM t1;
+--enable_query_log
+OPTIMIZE TABLE t1;
+EXPLAIN SELECT DISTINCT a FROM t1;
+SELECT DISTINCT a FROM t1;
+drop table t1;
+
+--echo #
--echo # End of 10.1 tests
--echo #
diff --git a/mysql-test/main/help.result b/mysql-test/main/help.result
index 66850e75dc1..130aacf6644 100644
--- a/mysql-test/main/help.result
+++ b/mysql-test/main/help.result
@@ -255,10 +255,10 @@ help 'impossible_category_1';
source_category_name name is_it_category
impossible_category_1 impossible_function_1 N
impossible_category_1 impossible_function_2 N
-alter table mysql.help_relation engine=myisam;
-alter table mysql.help_keyword engine=myisam;
-alter table mysql.help_topic engine=myisam;
-alter table mysql.help_category engine=myisam;
+alter table mysql.help_relation engine=aria;
+alter table mysql.help_keyword engine=aria;
+alter table mysql.help_topic engine=aria;
+alter table mysql.help_category engine=aria;
delete from mysql.help_topic where help_topic_id=@topic1_id;
delete from mysql.help_topic where help_topic_id=@topic2_id;
delete from mysql.help_topic where help_topic_id=@topic3_id;
diff --git a/mysql-test/main/help.test b/mysql-test/main/help.test
index 802f24f80a9..725eec2771f 100644
--- a/mysql-test/main/help.test
+++ b/mysql-test/main/help.test
@@ -98,10 +98,10 @@ help 'impossible_function_1';
help 'impossible_category_1';
##############
-alter table mysql.help_relation engine=myisam;
-alter table mysql.help_keyword engine=myisam;
-alter table mysql.help_topic engine=myisam;
-alter table mysql.help_category engine=myisam;
+alter table mysql.help_relation engine=aria;
+alter table mysql.help_keyword engine=aria;
+alter table mysql.help_topic engine=aria;
+alter table mysql.help_category engine=aria;
delete from mysql.help_topic where help_topic_id=@topic1_id;
delete from mysql.help_topic where help_topic_id=@topic2_id;
diff --git a/mysql-test/main/in_subq_cond_pushdown.result b/mysql-test/main/in_subq_cond_pushdown.result
index c9319a5fb86..06248895bd3 100644
--- a/mysql-test/main/in_subq_cond_pushdown.result
+++ b/mysql-test/main/in_subq_cond_pushdown.result
@@ -3855,3 +3855,35 @@ ORDER BY t4.d
a b c
x x NULL
DROP TABLE t1,t2,t3,t4;
+#
+# MDEV-17360: IN subquery predicate with outer reference in the left part
+# that refers to a field of a mergeable derived table
+#
+CREATE TABLE t1 (id1 int) ENGINE=MYISAM;
+INSERT INTO t1 VALUES (1814),(0),(NULL),(1);
+CREATE TABLE t2 (id2 int) ENGINE=MYISAM;
+SELECT 1 AS r FROM t2,t1,(SELECT * FROM t1) dt1
+WHERE NOT EXISTS (SELECT id2 FROM t2
+WHERE dt1.id1 IN (SELECT t2.id2 FROM t2
+HAVING t2.id2 >= 1));
+r
+DROP TABLE t1,t2;
+#
+# MDEV-17027: IN subquery predicate with outer reference in the left part
+# conjuncted with equality predicate
+#
+CREATE TABLE t1 (pk int, i1 int, v1 varchar(1));
+INSERT INTO t1 VALUES (3,2,'x'), (1,1,'y'), (4,2,'z');
+CREATE TABLE t2 (pk int, i1 int, v1 varchar(1));
+INSERT INTO t2 VALUES (5,2,'x'), (7,1,'x');
+CREATE TABLE t3 (pk int, i1 int, v1 varchar(1));
+INSERT INTO t3 VALUES (8,2,'x'), (7,1,'z');
+SELECT t3.i1 FROM t3
+WHERE EXISTS ( SELECT t2.v1 FROM t1,t2
+WHERE t1.v1 = t2.v1 AND
+t3.i1 IN (SELECT t.i1 FROM t1 as t
+GROUP BY i1 HAVING t.i1 < 3));
+i1
+2
+1
+DROP TABLE t1,t2,t3;
diff --git a/mysql-test/main/in_subq_cond_pushdown.test b/mysql-test/main/in_subq_cond_pushdown.test
index 3c673fb128b..2482fd91103 100644
--- a/mysql-test/main/in_subq_cond_pushdown.test
+++ b/mysql-test/main/in_subq_cond_pushdown.test
@@ -821,3 +821,42 @@ WHERE (t1.a) IN
);
DROP TABLE t1,t2,t3,t4;
+
+--echo #
+--echo # MDEV-17360: IN subquery predicate with outer reference in the left part
+--echo # that refers to a field of a mergeable derived table
+--echo #
+
+CREATE TABLE t1 (id1 int) ENGINE=MYISAM;
+INSERT INTO t1 VALUES (1814),(0),(NULL),(1);
+
+CREATE TABLE t2 (id2 int) ENGINE=MYISAM;
+
+SELECT 1 AS r FROM t2,t1,(SELECT * FROM t1) dt1
+ WHERE NOT EXISTS (SELECT id2 FROM t2
+ WHERE dt1.id1 IN (SELECT t2.id2 FROM t2
+ HAVING t2.id2 >= 1));
+
+DROP TABLE t1,t2;
+
+--echo #
+--echo # MDEV-17027: IN subquery predicate with outer reference in the left part
+--echo # conjuncted with equality predicate
+--echo #
+
+CREATE TABLE t1 (pk int, i1 int, v1 varchar(1));
+INSERT INTO t1 VALUES (3,2,'x'), (1,1,'y'), (4,2,'z');
+
+CREATE TABLE t2 (pk int, i1 int, v1 varchar(1));
+INSERT INTO t2 VALUES (5,2,'x'), (7,1,'x');
+
+CREATE TABLE t3 (pk int, i1 int, v1 varchar(1));
+INSERT INTO t3 VALUES (8,2,'x'), (7,1,'z');
+
+SELECT t3.i1 FROM t3
+ WHERE EXISTS ( SELECT t2.v1 FROM t1,t2
+ WHERE t1.v1 = t2.v1 AND
+ t3.i1 IN (SELECT t.i1 FROM t1 as t
+ GROUP BY i1 HAVING t.i1 < 3));
+
+DROP TABLE t1,t2,t3;
diff --git a/mysql-test/main/index_merge_myisam.result b/mysql-test/main/index_merge_myisam.result
index 992e1d831b5..725a888c914 100644
--- a/mysql-test/main/index_merge_myisam.result
+++ b/mysql-test/main/index_merge_myisam.result
@@ -1715,3 +1715,53 @@ id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL PRIMARY,c1,i,c2 NULL NULL NULL 69 Using where
DROP TABLE t1;
set optimizer_switch= @optimizer_switch_save;
+#
+# MDEV-16695: Estimate for rows of derived tables is very high when we are using index_merge union
+#
+create table t0
+(
+key1 int not null,
+INDEX i1(key1)
+);
+insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8);
+set @d=8;
+insert into t0 select key1+ @d from t0;
+set @d=@d*2;
+insert into t0 select key1+ @d from t0;
+set @d=@d*2;
+insert into t0 select key1+ @d from t0;
+set @d=@d*2;
+insert into t0 select key1+ @d from t0;
+set @d=@d*2;
+insert into t0 select key1+ @d from t0;
+set @d=@d*2;
+insert into t0 select key1+ @d from t0;
+set @d=@d*2;
+insert into t0 select key1+ @d from t0;
+set @d=@d*2;
+alter table t0 add key2 int not null, add index i2(key2);
+alter table t0 add key3 int not null, add index i3(key3);
+alter table t0 add key8 int not null, add index i8(key8);
+update t0 set key2=key1,key3=key1,key8=1024-key1;
+analyze table t0;
+Table Op Msg_type Msg_text
+test.t0 analyze status OK
+set @optimizer_switch_save=@@optimizer_switch;
+set optimizer_switch='derived_merge=off,derived_with_keys=off';
+explain select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where
+2 DERIVED t0 index_merge i1,i2,i8 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where
+select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+key1 key2 key3 key8
+3 3 3 1021
+set optimizer_use_condition_selectivity=2;
+explain select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 2 Using where
+2 DERIVED t0 index_merge i1,i2,i8 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where
+select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+key1 key2 key3 key8
+3 3 3 1021
+set @@optimizer_switch= @optimizer_switch_save;
+drop table t0;
diff --git a/mysql-test/main/index_merge_myisam.test b/mysql-test/main/index_merge_myisam.test
index d265007431e..75beb9bd883 100644
--- a/mysql-test/main/index_merge_myisam.test
+++ b/mysql-test/main/index_merge_myisam.test
@@ -243,3 +243,38 @@ DROP TABLE t1;
set optimizer_switch= @optimizer_switch_save;
+--echo #
+--echo # MDEV-16695: Estimate for rows of derived tables is very high when we are using index_merge union
+--echo #
+
+create table t0
+(
+ key1 int not null,
+ INDEX i1(key1)
+);
+
+insert into t0 values (1),(2),(3),(4),(5),(6),(7),(8);
+let $1=7;
+set @d=8;
+while ($1)
+{
+ eval insert into t0 select key1+ @d from t0;
+ eval set @d=@d*2;
+ dec $1;
+}
+alter table t0 add key2 int not null, add index i2(key2);
+alter table t0 add key3 int not null, add index i3(key3);
+alter table t0 add key8 int not null, add index i8(key8);
+
+update t0 set key2=key1,key3=key1,key8=1024-key1;
+analyze table t0;
+
+set @optimizer_switch_save=@@optimizer_switch;
+set optimizer_switch='derived_merge=off,derived_with_keys=off';
+explain select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+set optimizer_use_condition_selectivity=2;
+explain select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+select * from (select * from t0 where key1 = 3 or key2 =3) as Z where Z.key8 > 5;
+set @@optimizer_switch= @optimizer_switch_save;
+drop table t0;
diff --git a/mysql-test/main/information_schema-big.result b/mysql-test/main/information_schema-big.result
index cbd8191bc54..d4aa6deb2e2 100644
--- a/mysql-test/main/information_schema-big.result
+++ b/mysql-test/main/information_schema-big.result
@@ -20,6 +20,7 @@ table_name column_name
ALL_PLUGINS PLUGIN_NAME
APPLICABLE_ROLES GRANTEE
CHARACTER_SETS CHARACTER_SET_NAME
+CHECK_CONSTRAINTS CONSTRAINT_SCHEMA
CLIENT_STATISTICS CLIENT
COLLATIONS COLLATION_NAME
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
@@ -77,6 +78,7 @@ table_name column_name
ALL_PLUGINS PLUGIN_NAME
APPLICABLE_ROLES GRANTEE
CHARACTER_SETS CHARACTER_SET_NAME
+CHECK_CONSTRAINTS CONSTRAINT_SCHEMA
CLIENT_STATISTICS CLIENT
COLLATIONS COLLATION_NAME
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
diff --git a/mysql-test/main/information_schema.result b/mysql-test/main/information_schema.result
index 0e6b4168ea5..b6e331a0382 100644
--- a/mysql-test/main/information_schema.result
+++ b/mysql-test/main/information_schema.result
@@ -51,6 +51,7 @@ c
ALL_PLUGINS
APPLICABLE_ROLES
CHARACTER_SETS
+CHECK_CONSTRAINTS
CLIENT_STATISTICS
COLLATIONS
COLLATION_CHARACTER_SET_APPLICABILITY
@@ -100,7 +101,6 @@ help_category
help_keyword
help_relation
help_topic
-host
index_stats
plugin
proc
@@ -938,6 +938,7 @@ connection user10261;
SELECT TABLE_NAME, COLUMN_NAME, PRIVILEGES FROM INFORMATION_SCHEMA.COLUMNS
where COLUMN_NAME='TABLE_NAME' and table_name not like 'innodb%';
TABLE_NAME COLUMN_NAME PRIVILEGES
+CHECK_CONSTRAINTS TABLE_NAME select
COLUMNS TABLE_NAME select
COLUMN_PRIVILEGES TABLE_NAME select
FILES TABLE_NAME select
diff --git a/mysql-test/main/information_schema_all_engines.result b/mysql-test/main/information_schema_all_engines.result
index 8a92f0226ff..0ce9f15f753 100644
--- a/mysql-test/main/information_schema_all_engines.result
+++ b/mysql-test/main/information_schema_all_engines.result
@@ -4,6 +4,7 @@ Tables_in_information_schema
ALL_PLUGINS
APPLICABLE_ROLES
CHARACTER_SETS
+CHECK_CONSTRAINTS
CLIENT_STATISTICS
COLLATIONS
COLLATION_CHARACTER_SET_APPLICABILITY
@@ -83,6 +84,7 @@ table_name column_name
ALL_PLUGINS PLUGIN_NAME
APPLICABLE_ROLES GRANTEE
CHARACTER_SETS CHARACTER_SET_NAME
+CHECK_CONSTRAINTS CONSTRAINT_SCHEMA
CLIENT_STATISTICS CLIENT
COLLATIONS COLLATION_NAME
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
@@ -162,6 +164,7 @@ table_name column_name
ALL_PLUGINS PLUGIN_NAME
APPLICABLE_ROLES GRANTEE
CHARACTER_SETS CHARACTER_SET_NAME
+CHECK_CONSTRAINTS CONSTRAINT_SCHEMA
CLIENT_STATISTICS CLIENT
COLLATIONS COLLATION_NAME
COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
@@ -247,6 +250,7 @@ table_name group_concat(t.table_schema, '.', t.table_name) num1
ALL_PLUGINS information_schema.ALL_PLUGINS 1
APPLICABLE_ROLES information_schema.APPLICABLE_ROLES 1
CHARACTER_SETS information_schema.CHARACTER_SETS 1
+CHECK_CONSTRAINTS information_schema.CHECK_CONSTRAINTS 1
CLIENT_STATISTICS information_schema.CLIENT_STATISTICS 1
COLLATIONS information_schema.COLLATIONS 1
COLLATION_CHARACTER_SET_APPLICABILITY information_schema.COLLATION_CHARACTER_SET_APPLICABILITY 1
@@ -315,6 +319,7 @@ Database: information_schema
| ALL_PLUGINS |
| APPLICABLE_ROLES |
| CHARACTER_SETS |
+| CHECK_CONSTRAINTS |
| CLIENT_STATISTICS |
| COLLATIONS |
| COLLATION_CHARACTER_SET_APPLICABILITY |
@@ -384,6 +389,7 @@ Database: INFORMATION_SCHEMA
| ALL_PLUGINS |
| APPLICABLE_ROLES |
| CHARACTER_SETS |
+| CHECK_CONSTRAINTS |
| CLIENT_STATISTICS |
| COLLATIONS |
| COLLATION_CHARACTER_SET_APPLICABILITY |
@@ -453,5 +459,5 @@ Wildcard: inf_rmation_schema
| information_schema |
SELECT table_schema, count(*) FROM information_schema.TABLES WHERE table_schema IN ('mysql', 'INFORMATION_SCHEMA', 'test', 'mysqltest') GROUP BY TABLE_SCHEMA;
table_schema count(*)
-information_schema 64
-mysql 31
+information_schema 65
+mysql 30
diff --git a/mysql-test/main/init_file_set_password-7656.result b/mysql-test/main/init_file_set_password-7656.result
index e5b3fc75706..99a16a395d7 100644
--- a/mysql-test/main/init_file_set_password-7656.result
+++ b/mysql-test/main/init_file_set_password-7656.result
@@ -2,7 +2,7 @@ create user foo@localhost;
select user,host,password from mysql.user where user='foo';
user host password
foo localhost
-select user,host,password from mysql.user where user='foo';
-user host password
-foo localhost *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29
+select user,host,password,plugin,authentication_string from mysql.user where user='foo';
+user host password plugin authentication_string
+foo localhost mysql_native_password *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29
drop user foo@localhost;
diff --git a/mysql-test/main/init_file_set_password-7656.test b/mysql-test/main/init_file_set_password-7656.test
index ecee3924355..c695d01b675 100644
--- a/mysql-test/main/init_file_set_password-7656.test
+++ b/mysql-test/main/init_file_set_password-7656.test
@@ -21,6 +21,6 @@ EOF
--exec echo "restart:--init-file=$MYSQLTEST_VARDIR/init.file " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/wait_until_connected_again.inc
-select user,host,password from mysql.user where user='foo';
+select user,host,password,plugin,authentication_string from mysql.user where user='foo';
drop user foo@localhost;
diff --git a/mysql-test/main/innodb_mrr_cpk.result b/mysql-test/main/innodb_mrr_cpk.result
index 28d7dd51df8..a2e43d7d127 100644
--- a/mysql-test/main/innodb_mrr_cpk.result
+++ b/mysql-test/main/innodb_mrr_cpk.result
@@ -226,7 +226,7 @@ set join_cache_level=3;
explain SELECT 1 FROM (SELECT url, id FROM t2 LIMIT 1 OFFSET 20) derived RIGHT JOIN t1 ON t1.id = derived.id;
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL #
-1 PRIMARY <derived2> hash_ALL key0 #hash#key0 25 test.t1.id # Using join buffer (flat, BNLH join)
+1 PRIMARY <derived2> ref key0 key0 25 test.t1.id #
2 DERIVED t2 ALL NULL NULL NULL NULL #
set join_cache_level= @tmp_mdev5037;
drop table t0,t1,t2;
diff --git a/mysql-test/main/invisible_field_debug.result b/mysql-test/main/invisible_field_debug.result
index 4c4ebffbdfc..b3c84d18333 100644
--- a/mysql-test/main/invisible_field_debug.result
+++ b/mysql-test/main/invisible_field_debug.result
@@ -369,3 +369,8 @@ t1 1 invisible 1 c A NULL NULL NULL YES BTREE
t1 1 invisible_2 1 invisible A NULL NULL NULL YES BTREE
drop table t1;
set @old_debug= @@debug_dbug;
+CREATE TABLE t1 (i INT );
+SET debug_dbug="+d,test_completely_invisible,test_invisible_index";
+CREATE TABLE t2 LIKE t1;
+SET debug_dbug= DEFAULT;
+DROP TABLE t1, t2;
diff --git a/mysql-test/main/invisible_field_debug.test b/mysql-test/main/invisible_field_debug.test
index 8674620e055..c1d6899d16e 100644
--- a/mysql-test/main/invisible_field_debug.test
+++ b/mysql-test/main/invisible_field_debug.test
@@ -270,3 +270,9 @@ explain select * from t1 where invisible =9;
show indexes in t1;
drop table t1;
set @old_debug= @@debug_dbug;
+## MDEV 15127
+CREATE TABLE t1 (i INT );
+SET debug_dbug="+d,test_completely_invisible,test_invisible_index";
+CREATE TABLE t2 LIKE t1;
+SET debug_dbug= DEFAULT;
+DROP TABLE t1, t2;
diff --git a/mysql-test/main/join.result b/mysql-test/main/join.result
index 5978b261b3a..6ff294906e7 100644
--- a/mysql-test/main/join.result
+++ b/mysql-test/main/join.result
@@ -1506,6 +1506,48 @@ DROP VIEW v2;
DROP TABLE t1,t2;
SET optimizer_switch=@save_optimizer_switch;
#
+# MDEV-16512
+# Server crashes in find_field_in_table_ref on 2nd execution of SP referring to
+# non-existing field
+#
+CREATE TABLE t (i INT);
+CREATE PROCEDURE p() SELECT t1.f FROM t AS t1 JOIN t AS t2 USING (f);
+CALL p;
+ERROR 42S22: Unknown column 'f' in 'from clause'
+CALL p;
+ERROR 42S22: Unknown column 'f' in 'from clause'
+FLUSH TABLES;
+CALL p;
+ERROR 42S22: Unknown column 'f' in 'from clause'
+DROP TABLE t;
+CREATE TABLE t (f INT);
+CALL p;
+f
+DROP TABLE t;
+CREATE TABLE t (i INT);
+CALL p;
+ERROR 42S22: Unknown column 't1.f' in 'field list'
+CALL p;
+ERROR 42S22: Unknown column 't1.f' in 'field list'
+DROP PROCEDURE p;
+DROP TABLE t;
+CREATE TABLE t1 (a INT, b INT);
+CREATE TABLE t2 (a INT);
+CREATE TABLE t3 (a INT, c INT);
+CREATE TABLE t4 (a INT, c INT);
+CREATE TABLE t5 (a INT, c INT);
+CREATE PROCEDURE p1() SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a)
+LEFT JOIN t5 USING (a)) USING (a);
+CALL p1;
+ERROR 23000: Column 'c' in field list is ambiguous
+CALL p1;
+ERROR 23000: Column 'c' in field list is ambiguous
+DROP PROCEDURE p1;
+DROP TABLE t1,t2,t3,t4,t5;
+#
+# End of MariaDB 5.5 tests
+#
+#
# Bug #35268: Parser can't handle STRAIGHT_JOIN with USING
#
CREATE TABLE t1 (a int);
diff --git a/mysql-test/main/join.test b/mysql-test/main/join.test
index e07a3665920..3d2a02e2346 100644
--- a/mysql-test/main/join.test
+++ b/mysql-test/main/join.test
@@ -1161,6 +1161,60 @@ DROP TABLE t1,t2;
SET optimizer_switch=@save_optimizer_switch;
--echo #
+--echo # MDEV-16512
+--echo # Server crashes in find_field_in_table_ref on 2nd execution of SP referring to
+--echo # non-existing field
+--echo #
+
+CREATE TABLE t (i INT);
+CREATE PROCEDURE p() SELECT t1.f FROM t AS t1 JOIN t AS t2 USING (f);
+--error ER_BAD_FIELD_ERROR
+CALL p;
+--error ER_BAD_FIELD_ERROR
+CALL p;
+FLUSH TABLES;
+--error ER_BAD_FIELD_ERROR
+CALL p;
+DROP TABLE t;
+
+#
+# Fix the table definition to match the using
+#
+
+CREATE TABLE t (f INT);
+#
+# The following shouldn't fail as the table is now matching the using
+#
+CALL p;
+DROP TABLE t;
+CREATE TABLE t (i INT);
+--error ER_BAD_FIELD_ERROR
+CALL p;
+--error ER_BAD_FIELD_ERROR
+CALL p;
+DROP PROCEDURE p;
+DROP TABLE t;
+
+CREATE TABLE t1 (a INT, b INT);
+CREATE TABLE t2 (a INT);
+CREATE TABLE t3 (a INT, c INT);
+CREATE TABLE t4 (a INT, c INT);
+CREATE TABLE t5 (a INT, c INT);
+CREATE PROCEDURE p1() SELECT c FROM t1 JOIN (t2 LEFT JOIN t3 USING (a) LEFT JOIN t4 USING (a)
+LEFT JOIN t5 USING (a)) USING (a);
+--error ER_NON_UNIQ_ERROR
+CALL p1;
+--error ER_NON_UNIQ_ERROR
+CALL p1;
+DROP PROCEDURE p1;
+DROP TABLE t1,t2,t3,t4,t5;
+
+--echo #
+--echo # End of MariaDB 5.5 tests
+--echo #
+
+
+--echo #
--echo # Bug #35268: Parser can't handle STRAIGHT_JOIN with USING
--echo #
diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result
index eea397402ad..fde6e0fec6b 100644
--- a/mysql-test/main/join_cache.result
+++ b/mysql-test/main/join_cache.result
@@ -5925,6 +5925,39 @@ SET join_buffer_space_limit= default;
set optimizer_switch=@save_optimizer_switch;
DROP TABLE t1,t4,t5,t2;
#
+# MDEV-16603: BNLH for query with materialized semi-join
+#
+set join_cache_level=4;
+CREATE TABLE t1 ( i1 int, v1 varchar(1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (7,'x');
+CREATE TABLE t2 (i1 int, v1 varchar(1), KEY v1 (v1,i1)) ENGINE=InnoDB;
+INSERT INTO t2 VALUES
+(NULL,'x'),(1,'x'),(3,'x'),(5,'x'),(8,'x'),(48,'x'),
+(228,'x'),(3,'y'),(1,'z'),(9,'z');
+CREATE TABLE temp
+SELECT t1.i1 AS f1, t1.v1 AS f2 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1));
+SELECT * FROM temp
+WHERE (f1,f2) IN (SELECT t1.i1, t1.v1 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1)));
+f1 f2
+7 x
+7 x
+7 x
+7 x
+7 x
+7 x
+7 x
+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 <subquery2> ALL distinct_key NULL NULL NULL 1 100.00
+1 PRIMARY temp hash_ALL NULL #hash#$hj 9 test.t1.i1,test.t1.v1 7 100.00 Using where; Using join buffer (flat, BNLH join)
+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 10.00 Using index; Using join buffer (flat, 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`.`temp`.`f1` = `test`.`t1`.`i1` and `test`.`t2`.`v1` = `test`.`t1`.`v1` and `test`.`temp`.`f2` = `test`.`t1`.`v1`
+DROP TABLE t1,t2,temp;
+SET join_cache_level = default;
+#
# MDEV-5123 Remove duplicated conditions pushed both to join_tab->select_cond and join_tab->cache_select->cond for blocked joins.
#
set join_cache_level=default;
diff --git a/mysql-test/main/join_cache.test b/mysql-test/main/join_cache.test
index b775725903c..df89fc30dee 100644
--- a/mysql-test/main/join_cache.test
+++ b/mysql-test/main/join_cache.test
@@ -3870,6 +3870,37 @@ set optimizer_switch=@save_optimizer_switch;
DROP TABLE t1,t4,t5,t2;
--echo #
+--echo # MDEV-16603: BNLH for query with materialized semi-join
+--echo #
+
+--source include/have_innodb.inc
+
+set join_cache_level=4;
+
+CREATE TABLE t1 ( i1 int, v1 varchar(1)) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (7,'x');
+
+CREATE TABLE t2 (i1 int, v1 varchar(1), KEY v1 (v1,i1)) ENGINE=InnoDB;
+
+INSERT INTO t2 VALUES
+ (NULL,'x'),(1,'x'),(3,'x'),(5,'x'),(8,'x'),(48,'x'),
+ (228,'x'),(3,'y'),(1,'z'),(9,'z');
+
+CREATE TABLE temp
+SELECT t1.i1 AS f1, t1.v1 AS f2 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1));
+
+let $q =
+SELECT * FROM temp
+WHERE (f1,f2) IN (SELECT t1.i1, t1.v1 FROM (t2 JOIN t1 ON (t1.v1 = t2.v1)));
+
+eval $q;
+eval EXPLAIN EXTENDED $q;
+
+DROP TABLE t1,t2,temp;
+
+SET join_cache_level = default;
+
+--echo #
--echo # MDEV-5123 Remove duplicated conditions pushed both to join_tab->select_cond and join_tab->cache_select->cond for blocked joins.
--echo #
@@ -3958,5 +3989,4 @@ drop table t1, t2;
set join_buffer_size = default;
# The following command must be the last one the file
-# this must be the last command in the file
set @@optimizer_switch=@save_optimizer_switch;
diff --git a/mysql-test/main/join_nested_jcl6.result b/mysql-test/main/join_nested_jcl6.result
index de5ebfbe989..6b1901d8642 100644
--- a/mysql-test/main/join_nested_jcl6.result
+++ b/mysql-test/main/join_nested_jcl6.result
@@ -2055,7 +2055,7 @@ ON (t5.b=t8.b);
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t5 ALL NULL NULL NULL NULL 2
1 SIMPLE t6 ALL NULL NULL NULL NULL 1 Using join buffer (flat, BNL join)
-1 SIMPLE t7 ref b_i b_i 5 const 0 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
+1 SIMPLE t7 ref b_i b_i 5 const 1 Using join buffer (incremental, BKA join); Key-ordered Rowid-ordered scan
1 SIMPLE t8 ALL b_i NULL NULL NULL 1 Using where; Using join buffer (incremental, BNL join)
SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b
FROM t5 LEFT JOIN
diff --git a/mysql-test/main/join_outer.result b/mysql-test/main/join_outer.result
index 6753349dece..6b671a0759f 100644
--- a/mysql-test/main/join_outer.result
+++ b/mysql-test/main/join_outer.result
@@ -2460,5 +2460,123 @@ id sid id
1 NULL NULL
2 NULL NULL
drop table t1, t2;
+#
+# MDEV-16726: SELECT with STRAGHT JOIN containing NESTED RIGHT JOIN
+# converted to INNER JOIN with first constant inner table
+#
+CREATE TABLE t1 (
+pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1), KEY v1 (v1,i1)
+) engine=MyISAM;
+INSERT INTO t1 VALUES
+(8,3,'c','c'),(9,4,'z','z'),(10,3,'i','i'),(11,186,'x','x'),
+(14,226,'m','m'),(15,133,'p','p');
+CREATE TABLE t2 (
+pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1)
+) engine=MyISAM;
+INSERT INTO t2 VALUES (10,6,'p','p');
+EXPLAIN EXTENDED
+SELECT STRAIGHT_JOIN t2.v2
+FROM
+(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
+RIGHT JOIN
+(t2,t1)
+ON t1.pk = t2.pk AND t2.v2 = tb1.v1
+WHERE tb1.pk = 40
+ORDER BY tb1.i1;
+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 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(NULL, NULL)) where 0 order by NULL
+EXPLAIN EXTENDED
+SELECT STRAIGHT_JOIN t2.v2
+FROM
+(t2,t1)
+LEFT JOIN
+(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
+ON t1.pk = t2.pk AND t2.v2 = tb1.v1
+WHERE tb1.pk = 40
+ORDER BY tb1.i1;
+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 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(NULL, NULL)) where 0 order by NULL
+SELECT STRAIGHT_JOIN DISTINCT t2.v2
+FROM
+(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
+RIGHT JOIN
+(t2,t1)
+ON t1.pk = t2.pk AND t2.v2 = tb1.v1
+WHERE tb1.pk = 40
+ORDER BY tb1.i1;
+v2
+DROP TABLE t1,t2;
# end of 5.5 tests
+#
+# MDEV-17518: Range optimization doesn't use ON expressions from nested outer joins
+#
+create table t1(a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2(a int);
+insert into t2 values (0),(1);
+create table t3 (a int, b int, key(a));
+insert into t3 select A.a + B.a* 10 + C.a * 100, 12345 from t1 A, t1 B, t1 C;
+# Uses range for table t3:
+explain select * from t1 left join t3 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 t3 range a a 5 NULL 5 Using where
+# This must use range for table t3, too:
+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
+1 SIMPLE t3 range a a 5 NULL 5 Using where
+#
+# .. part 2: make sure condition selectivity can use the condition too.
+#
+alter table t3 drop key a;
+set @tmp1=@@optimizer_use_condition_selectivity;
+set @tmp2=@@use_stat_tables;
+set @tmp3=@@histogram_size;
+set use_stat_tables=preferably;
+set optimizer_use_condition_selectivity=4;
+set histogram_size=100;
+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
+# t3.filtered is less than 100%:
+explain extended select * from t1 left join t3 on t1.a=t3.b and t3.a<5;
+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
+1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 0.99 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` left join `test`.`t3` on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5) where 1
+# t3.filtered must less than 100%, too:
+explain extended 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 filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00
+1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 0.99 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5) where 1
+drop table t1,t2,t3;
+set optimizer_use_condition_selectivity= @tmp1;
+set use_stat_tables= @tmp2;
+set histogram_size= @tmp3;
+# Another test
+CREATE TABLE t1 (i1 int) ;
+CREATE TABLE t2 (pk int NOT NULL PRIMARY KEY) ;
+CREATE TABLE t3 (pk int NOT NULL, i1 int, PRIMARY KEY (pk)) ;
+INSERT INTO t3 VALUES (2, NULL);
+CREATE TABLE t4 (pk int NOT NULL, i1 int, PRIMARY KEY (pk), KEY i1 (i1)) ;
+CREATE VIEW v4 AS SELECT * FROM t4;
+SELECT 1
+FROM t3 RIGHT JOIN t1 ON t3.i1 = t1.i1
+LEFT JOIN v4
+RIGHT JOIN t2 ON v4.i1 = t2.pk ON t1.i1 = t2.pk
+WHERE t3.pk IN (2);
+1
+drop view v4;
+drop table t1,t2,t3,t4;
SET optimizer_switch=@save_optimizer_switch;
diff --git a/mysql-test/main/join_outer.test b/mysql-test/main/join_outer.test
index 34b0551a32e..82127397bee 100644
--- a/mysql-test/main/join_outer.test
+++ b/mysql-test/main/join_outer.test
@@ -1992,6 +1992,114 @@ select * from t1 t
on t.id=r.id ;
drop table t1, t2;
+--echo #
+--echo # MDEV-16726: SELECT with STRAGHT JOIN containing NESTED RIGHT JOIN
+--echo # converted to INNER JOIN with first constant inner table
+--echo #
+
+CREATE TABLE t1 (
+ pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1), KEY v1 (v1,i1)
+) engine=MyISAM;
+INSERT INTO t1 VALUES
+ (8,3,'c','c'),(9,4,'z','z'),(10,3,'i','i'),(11,186,'x','x'),
+ (14,226,'m','m'),(15,133,'p','p');
+
+CREATE TABLE t2 (
+ pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1)
+) engine=MyISAM;
+INSERT INTO t2 VALUES (10,6,'p','p');
+
+EXPLAIN EXTENDED
+SELECT STRAIGHT_JOIN t2.v2
+FROM
+ (t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
+ RIGHT JOIN
+ (t2,t1)
+ ON t1.pk = t2.pk AND t2.v2 = tb1.v1
+WHERE tb1.pk = 40
+ORDER BY tb1.i1;
+
+EXPLAIN EXTENDED
+SELECT STRAIGHT_JOIN t2.v2
+FROM
+ (t2,t1)
+ LEFT JOIN
+ (t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
+ ON t1.pk = t2.pk AND t2.v2 = tb1.v1
+WHERE tb1.pk = 40
+ORDER BY tb1.i1;
+
+SELECT STRAIGHT_JOIN DISTINCT t2.v2
+FROM
+ (t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
+ RIGHT JOIN
+ (t2,t1)
+ ON t1.pk = t2.pk AND t2.v2 = tb1.v1
+WHERE tb1.pk = 40
+ORDER BY tb1.i1;
+
+DROP TABLE t1,t2;
+
--echo # end of 5.5 tests
+--echo #
+--echo # MDEV-17518: Range optimization doesn't use ON expressions from nested outer joins
+--echo #
+create table t1(a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+
+create table t2(a int);
+insert into t2 values (0),(1);
+
+create table t3 (a int, b int, key(a));
+insert into t3 select A.a + B.a* 10 + C.a * 100, 12345 from t1 A, t1 B, t1 C;
+
+--echo # Uses range for table t3:
+explain select * from t1 left join t3 on t1.a=t3.b and t3.a<5;
+
+--echo # This must use range for table t3, too:
+explain select * from t1 left join (t3 join t2) on t1.a=t3.b and t3.a<5;
+
+--echo #
+--echo # .. part 2: make sure condition selectivity can use the condition too.
+--echo #
+alter table t3 drop key a;
+set @tmp1=@@optimizer_use_condition_selectivity;
+set @tmp2=@@use_stat_tables;
+set @tmp3=@@histogram_size;
+set use_stat_tables=preferably;
+set optimizer_use_condition_selectivity=4;
+set histogram_size=100;
+
+analyze table t3 persistent for all;
+
+--echo # t3.filtered is less than 100%:
+explain extended select * from t1 left join t3 on t1.a=t3.b and t3.a<5;
+
+--echo # t3.filtered must less than 100%, too:
+explain extended select * from t1 left join (t3 join t2) on t1.a=t3.b and t3.a<5;
+
+drop table t1,t2,t3;
+set optimizer_use_condition_selectivity= @tmp1;
+set use_stat_tables= @tmp2;
+set histogram_size= @tmp3;
+
+--echo # Another test
+CREATE TABLE t1 (i1 int) ;
+CREATE TABLE t2 (pk int NOT NULL PRIMARY KEY) ;
+CREATE TABLE t3 (pk int NOT NULL, i1 int, PRIMARY KEY (pk)) ;
+INSERT INTO t3 VALUES (2, NULL);
+
+CREATE TABLE t4 (pk int NOT NULL, i1 int, PRIMARY KEY (pk), KEY i1 (i1)) ;
+CREATE VIEW v4 AS SELECT * FROM t4;
+
+SELECT 1
+FROM t3 RIGHT JOIN t1 ON t3.i1 = t1.i1
+ LEFT JOIN v4
+ RIGHT JOIN t2 ON v4.i1 = t2.pk ON t1.i1 = t2.pk
+WHERE t3.pk IN (2);
+
+drop view v4;
+drop table t1,t2,t3,t4;
+
SET optimizer_switch=@save_optimizer_switch;
diff --git a/mysql-test/main/join_outer_jcl6.result b/mysql-test/main/join_outer_jcl6.result
index 9ff501baf6a..f46f3e2df21 100644
--- a/mysql-test/main/join_outer_jcl6.result
+++ b/mysql-test/main/join_outer_jcl6.result
@@ -2471,7 +2471,125 @@ id sid id
1 NULL NULL
2 NULL NULL
drop table t1, t2;
+#
+# MDEV-16726: SELECT with STRAGHT JOIN containing NESTED RIGHT JOIN
+# converted to INNER JOIN with first constant inner table
+#
+CREATE TABLE t1 (
+pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1), KEY v1 (v1,i1)
+) engine=MyISAM;
+INSERT INTO t1 VALUES
+(8,3,'c','c'),(9,4,'z','z'),(10,3,'i','i'),(11,186,'x','x'),
+(14,226,'m','m'),(15,133,'p','p');
+CREATE TABLE t2 (
+pk int PRIMARY KEY, i1 int, v1 varchar(1), v2 varchar(1)
+) engine=MyISAM;
+INSERT INTO t2 VALUES (10,6,'p','p');
+EXPLAIN EXTENDED
+SELECT STRAIGHT_JOIN t2.v2
+FROM
+(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
+RIGHT JOIN
+(t2,t1)
+ON t1.pk = t2.pk AND t2.v2 = tb1.v1
+WHERE tb1.pk = 40
+ORDER BY tb1.i1;
+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 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(NULL, NULL)) where 0 order by NULL
+EXPLAIN EXTENDED
+SELECT STRAIGHT_JOIN t2.v2
+FROM
+(t2,t1)
+LEFT JOIN
+(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
+ON t1.pk = t2.pk AND t2.v2 = tb1.v1
+WHERE tb1.pk = 40
+ORDER BY tb1.i1;
+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 select straight_join 'p' AS `v2` from `test`.`t1` join `test`.`t1` `tb1` left join `test`.`t1` `tb2` on(multiple equal(NULL, NULL)) where 0 order by NULL
+SELECT STRAIGHT_JOIN DISTINCT t2.v2
+FROM
+(t1 as tb1 LEFT JOIN t1 AS tb2 ON tb2.v1 = tb1.v2)
+RIGHT JOIN
+(t2,t1)
+ON t1.pk = t2.pk AND t2.v2 = tb1.v1
+WHERE tb1.pk = 40
+ORDER BY tb1.i1;
+v2
+DROP TABLE t1,t2;
# end of 5.5 tests
+#
+# MDEV-17518: Range optimization doesn't use ON expressions from nested outer joins
+#
+create table t1(a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2(a int);
+insert into t2 values (0),(1);
+create table t3 (a int, b int, key(a));
+insert into t3 select A.a + B.a* 10 + C.a * 100, 12345 from t1 A, t1 B, t1 C;
+# Uses range for table t3:
+explain select * from t1 left join t3 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 t3 range a a 5 NULL 5 Using where; Rowid-ordered scan; Using join buffer (flat, BNL join)
+# This must use range for table t3, too:
+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 join buffer (flat, BNL join)
+1 SIMPLE t3 range a a 5 NULL 5 Using where; Rowid-ordered scan; Using join buffer (incremental, BNL join)
+#
+# .. part 2: make sure condition selectivity can use the condition too.
+#
+alter table t3 drop key a;
+set @tmp1=@@optimizer_use_condition_selectivity;
+set @tmp2=@@use_stat_tables;
+set @tmp3=@@histogram_size;
+set use_stat_tables=preferably;
+set optimizer_use_condition_selectivity=4;
+set histogram_size=100;
+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
+# t3.filtered is less than 100%:
+explain extended select * from t1 left join t3 on t1.a=t3.b and t3.a<5;
+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
+1 SIMPLE t3 hash_ALL NULL #hash#$hj 5 test.t1.a 1000 0.99 Using where; Using join buffer (flat, BNLH join)
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t1` left join `test`.`t3` on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5 and `test`.`t1`.`a` is not null) where 1
+# t3.filtered must less than 100%, too:
+explain extended 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 filtered Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 10 100.00
+1 SIMPLE t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 SIMPLE t3 ALL NULL NULL NULL NULL 1000 0.99 Using where
+Warnings:
+Note 1003 select `test`.`t1`.`a` AS `a`,`test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b`,`test`.`t2`.`a` AS `a` from `test`.`t1` left join (`test`.`t3` join `test`.`t2`) on(`test`.`t3`.`b` = `test`.`t1`.`a` and `test`.`t3`.`a` < 5 and `test`.`t1`.`a` is not null) where 1
+drop table t1,t2,t3;
+set optimizer_use_condition_selectivity= @tmp1;
+set use_stat_tables= @tmp2;
+set histogram_size= @tmp3;
+# Another test
+CREATE TABLE t1 (i1 int) ;
+CREATE TABLE t2 (pk int NOT NULL PRIMARY KEY) ;
+CREATE TABLE t3 (pk int NOT NULL, i1 int, PRIMARY KEY (pk)) ;
+INSERT INTO t3 VALUES (2, NULL);
+CREATE TABLE t4 (pk int NOT NULL, i1 int, PRIMARY KEY (pk), KEY i1 (i1)) ;
+CREATE VIEW v4 AS SELECT * FROM t4;
+SELECT 1
+FROM t3 RIGHT JOIN t1 ON t3.i1 = t1.i1
+LEFT JOIN v4
+RIGHT JOIN t2 ON v4.i1 = t2.pk ON t1.i1 = t2.pk
+WHERE t3.pk IN (2);
+1
+drop view v4;
+drop table t1,t2,t3,t4;
SET optimizer_switch=@save_optimizer_switch;
set join_cache_level=default;
show variables like 'join_cache_level';
diff --git a/mysql-test/main/lock.result b/mysql-test/main/lock.result
index 0805fd45864..339cfcaa441 100644
--- a/mysql-test/main/lock.result
+++ b/mysql-test/main/lock.result
@@ -136,7 +136,7 @@ select * from t1;
ERROR HY000: Table 't1' was not locked with LOCK TABLES
unlock tables;
create or replace view v_bug5719 as select * from t1;
-lock tables v_bug5719 write;
+lock tables v_bug5719 read;
select * from v_bug5719;
a
@@ -303,7 +303,7 @@ create table t2 (j int);
#
# Try to perform DDL on table which is locked through view.
create view v1 as select * from t2;
-lock tables t1 write, v1 write;
+lock tables t1 write, v1 read;
flush table t2;
ERROR HY000: Table 't2' was locked with a READ lock and can't be updated
drop table t2;
diff --git a/mysql-test/main/lock.test b/mysql-test/main/lock.test
index 92ab8294273..ff77b4991c0 100644
--- a/mysql-test/main/lock.test
+++ b/mysql-test/main/lock.test
@@ -192,7 +192,7 @@ drop view v_bug5719;
select * from t1;
unlock tables;
create or replace view v_bug5719 as select * from t1;
-lock tables v_bug5719 write;
+lock tables v_bug5719 read;
select * from v_bug5719;
--echo
--echo Allowed to use an underlying table under LOCK TABLES <view>
@@ -368,7 +368,7 @@ create table t2 (j int);
--echo #
--echo # Try to perform DDL on table which is locked through view.
create view v1 as select * from t2;
-lock tables t1 write, v1 write;
+lock tables t1 write, v1 read;
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
flush table t2;
--error ER_TABLE_NOT_LOCKED_FOR_WRITE
diff --git a/mysql-test/main/lock_multi.result b/mysql-test/main/lock_multi.result
index d4e0edaf1c2..52b4608fdd2 100644
--- a/mysql-test/main/lock_multi.result
+++ b/mysql-test/main/lock_multi.result
@@ -114,17 +114,16 @@ unlock tables;
drop table t1;
connection locker;
USE mysql;
-LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
+LOCK TABLES columns_priv WRITE, db WRITE, user WRITE;
FLUSH TABLES;
connection reader;
USE mysql;
SELECT user.Select_priv FROM user, db WHERE user.user = db.user LIMIT 1;
connection locker;
-OPTIMIZE TABLES columns_priv, db, host, user;
+OPTIMIZE TABLES columns_priv, db, user;
Table Op Msg_type Msg_text
mysql.columns_priv optimize status OK
mysql.db optimize status OK
-mysql.host optimize status OK
mysql.user optimize status OK
UNLOCK TABLES;
connection reader;
@@ -395,15 +394,17 @@ DROP VIEW IF EXISTS v1;
#
# Test 1: LOCK TABLES v1 WRITE, t1 READ;
#
-# Thanks to the fact that we no longer allow DDL on tables
-# which are locked for write implicitly, the exact scenario
-# in which assert was failing is no longer repeatable.
CREATE TABLE t1 ( f1 integer );
CREATE VIEW v1 AS SELECT f1 FROM t1 ;
+# Connection 2
+connect con2,localhost,root;
LOCK TABLES v1 WRITE, t1 READ;
FLUSH TABLE t1;
-ERROR HY000: Table 't1' was locked with a READ lock and can't be updated
-UNLOCK TABLES;
+disconnect con2;
+# Connection 1
+connection default;
+LOCK TABLES t1 WRITE;
+FLUSH TABLE t1;
DROP TABLE t1;
DROP VIEW v1;
#
diff --git a/mysql-test/main/lock_multi.test b/mysql-test/main/lock_multi.test
index 51cc4a50233..ce901126ce5 100644
--- a/mysql-test/main/lock_multi.test
+++ b/mysql-test/main/lock_multi.test
@@ -184,7 +184,7 @@ drop table t1;
connection locker;
USE mysql;
-LOCK TABLES columns_priv WRITE, db WRITE, host WRITE, user WRITE;
+LOCK TABLES columns_priv WRITE, db WRITE, user WRITE;
FLUSH TABLES;
#
connection reader;
@@ -202,7 +202,7 @@ let $wait_condition=
--source include/wait_condition.inc
# Make test case independent from earlier grants.
--replace_result "Table is already up to date" "OK"
-OPTIMIZE TABLES columns_priv, db, host, user;
+OPTIMIZE TABLES columns_priv, db, user;
UNLOCK TABLES;
#
connection reader;
@@ -734,17 +734,21 @@ DROP VIEW IF EXISTS v1;
--echo #
--echo # Test 1: LOCK TABLES v1 WRITE, t1 READ;
--echo #
---echo # Thanks to the fact that we no longer allow DDL on tables
---echo # which are locked for write implicitly, the exact scenario
---echo # in which assert was failing is no longer repeatable.
CREATE TABLE t1 ( f1 integer );
CREATE VIEW v1 AS SELECT f1 FROM t1 ;
+--echo # Connection 2
+connect (con2,localhost,root);
LOCK TABLES v1 WRITE, t1 READ;
---error ER_TABLE_NOT_LOCKED_FOR_WRITE
FLUSH TABLE t1;
-UNLOCK TABLES;
+disconnect con2;
+--source include/wait_until_disconnected.inc
+
+--echo # Connection 1
+connection default;
+LOCK TABLES t1 WRITE;
+FLUSH TABLE t1; # Assertion happened here
# Cleanup
DROP TABLE t1;
diff --git a/mysql-test/main/log_tables_upgrade.result b/mysql-test/main/log_tables_upgrade.result
index 8f822d56020..df6ea72f3ca 100644
--- a/mysql-test/main/log_tables_upgrade.result
+++ b/mysql-test/main/log_tables_upgrade.result
@@ -24,7 +24,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
diff --git a/mysql-test/main/lowercase_fs_off.result b/mysql-test/main/lowercase_fs_off.result
index 91bd2924096..e05fd50caeb 100644
--- a/mysql-test/main/lowercase_fs_off.result
+++ b/mysql-test/main/lowercase_fs_off.result
@@ -83,6 +83,74 @@ CREATE TRIGGER t1_bi BEFORE INSERT ON t1 FOR EACH ROW SET new.a= 1;
RENAME TABLE t1 TO T1;
ALTER TABLE T1 RENAME t1;
DROP TABLE t1;
+create database TEST;
+create procedure TEST.pr() begin end;
+create procedure test.pr() begin end;
+Phase 1/7: Checking and upgrading mysql database
+Processing databases
+mysql
+mysql.column_stats OK
+mysql.columns_priv OK
+mysql.db OK
+mysql.event OK
+mysql.func OK
+mysql.gtid_slave_pos OK
+mysql.help_category OK
+mysql.help_keyword OK
+mysql.help_relation OK
+mysql.help_topic OK
+mysql.index_stats OK
+mysql.innodb_index_stats
+Error : Unknown storage engine 'InnoDB'
+error : Corrupt
+mysql.innodb_table_stats
+Error : Unknown storage engine 'InnoDB'
+error : Corrupt
+mysql.plugin OK
+mysql.proc OK
+mysql.procs_priv OK
+mysql.proxies_priv OK
+mysql.roles_mapping OK
+mysql.servers OK
+mysql.table_stats OK
+mysql.tables_priv OK
+mysql.time_zone OK
+mysql.time_zone_leap_second OK
+mysql.time_zone_name OK
+mysql.time_zone_transition OK
+mysql.time_zone_transition_type OK
+mysql.transaction_registry
+Error : Unknown storage engine 'InnoDB'
+error : Corrupt
+mysql.user OK
+
+Repairing tables
+mysql.innodb_index_stats
+Error : Unknown storage engine 'InnoDB'
+error : Corrupt
+mysql.innodb_table_stats
+Error : Unknown storage engine 'InnoDB'
+error : Corrupt
+mysql.transaction_registry
+Error : Unknown storage engine 'InnoDB'
+error : Corrupt
+Phase 2/7: Installing used storage engines... Skipped
+Phase 3/7: Fixing views
+Phase 4/7: Running 'mysql_fix_privilege_tables'
+Phase 5/7: Fixing table and database names
+Phase 6/7: Checking and upgrading tables
+Processing databases
+TEST
+information_schema
+mtr
+mtr.global_suppressions OK
+mtr.test_suppressions OK
+performance_schema
+test
+Phase 7/7: Running 'FLUSH PRIVILEGES'
+OK
+drop procedure test.pr;
+drop database TEST;
create table t1 (a int);
create trigger t1_bi before insert on t1 for each row set new.a= 1;
show triggers like '%T1%';
diff --git a/mysql-test/main/lowercase_fs_off.test b/mysql-test/main/lowercase_fs_off.test
index b8a9795db9a..7c5811f9cc3 100644
--- a/mysql-test/main/lowercase_fs_off.test
+++ b/mysql-test/main/lowercase_fs_off.test
@@ -106,6 +106,18 @@ ALTER TABLE T1 RENAME t1;
DROP TABLE t1;
#
+# MDEV-13912 mysql_upgrade: case (in)sensitivity for stored procedures
+#
+create database TEST;
+create procedure TEST.pr() begin end;
+create procedure test.pr() begin end;
+--exec $MYSQL_UPGRADE --force 2>&1
+drop procedure test.pr;
+drop database TEST;
+
+# End of 5.5 tests
+
+#
# MDEV-9014 SHOW TRIGGERS not case sensitive
#
create table t1 (a int);
@@ -113,4 +125,7 @@ create trigger t1_bi before insert on t1 for each row set new.a= 1;
show triggers like '%T1%';
drop table t1;
+let $datadir= `select @@datadir`;
+remove_file $datadir/mysql_upgrade_info;
+
set GLOBAL sql_mode=default;
diff --git a/mysql-test/main/multi_update.result b/mysql-test/main/multi_update.result
index c40de47668a..9f9af8f79f8 100644
--- a/mysql-test/main/multi_update.result
+++ b/mysql-test/main/multi_update.result
@@ -603,11 +603,11 @@ CREATE TABLE t1 (f1 DATE);
INSERT INTO t1 VALUES('2001-01-01');
UPDATE IGNORE (SELECT 1 FROM t1 WHERE f1 = (SELECT f1() FROM t1)) x, t1 SET f1 = 1;
Warnings:
-Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
CREATE view v1 as SELECT f1() FROM t1;
UPDATE IGNORE (SELECT 1 FROM t1 WHERE f1 = (select * from v1)) x, t1 SET f1 = 1;
Warnings:
-Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
DROP VIEW v1;
DROP FUNCTION f1;
DROP TABLE t1;
diff --git a/mysql-test/main/myisam.result b/mysql-test/main/myisam.result
index 4864ef0bb13..bef8790e141 100644
--- a/mysql-test/main/myisam.result
+++ b/mysql-test/main/myisam.result
@@ -2545,7 +2545,7 @@ INSERT INTO t1 VALUES
('0'),('0'),('0'),('0'),('0'),('0'),('0');
Warnings:
Error 1034 myisam_sort_buffer_size is too small. X
-Error 1034 Number of rows changed from 0 to 157
+Warning 1034 Number of rows changed from 0 to 157
SET myisam_sort_buffer_size=@@global.myisam_sort_buffer_size;
INSERT INTO t1 VALUES('1');
SELECT * FROM t1, t1 AS a1 WHERE t1.a=1 AND a1.a=1;
diff --git a/mysql-test/main/myisam_recover.result b/mysql-test/main/myisam_recover.result
index 92df67b42d1..3a2c424c8b2 100644
--- a/mysql-test/main/myisam_recover.result
+++ b/mysql-test/main/myisam_recover.result
@@ -87,7 +87,7 @@ a
6
Warnings:
Error 145 Table 't1' is marked as crashed and should be repaired
-Error 1034 Number of rows changed from 3 to 6
+Warning 1034 Number of rows changed from 3 to 6
#
# Cleanup
#
@@ -139,7 +139,7 @@ a
4
Warnings:
Error 145 Table 't1' is marked as crashed and should be repaired
-Error 1034 Number of rows changed from 1 to 2
+Warning 1034 Number of rows changed from 1 to 2
connect con2, localhost, root;
ALTER TABLE t2 ADD val INT;
connection default;
diff --git a/mysql-test/main/mysql.result b/mysql-test/main/mysql.result
index 09f014da627..06ef7e95bc9 100644
--- a/mysql-test/main/mysql.result
+++ b/mysql-test/main/mysql.result
@@ -538,8 +538,6 @@ a
#
# End of 10.1 tests
#
-ERROR 1300 (HY000): Invalid utf8 character string: 'test\xF0\x9F\x98\x81 '
-ERROR 1300 (HY000): Invalid binary character string: 'test\xF0\x9F\x98\x81 '
ERROR 1300 (HY000) at line 2: Invalid utf8 character string: 'test\xF0\x9F\x98\x81'
set GLOBAL sql_mode=default;
diff --git a/mysql-test/main/mysql.test b/mysql-test/main/mysql.test
index 01953ba2112..c65860eb822 100644
--- a/mysql-test/main/mysql.test
+++ b/mysql-test/main/mysql.test
@@ -638,10 +638,7 @@ EOF
--echo # End of 10.1 tests
--echo #
---error 1
---exec $MYSQL --default-character-set=utf8 -e "select 1" "test😠" 2>&1
---error 1
---exec $MYSQL --default-character-set=binary -e "select 1" "test😠" 2>&1
+
--write_file $MYSQLTEST_VARDIR/tmp/mdev-6572.sql
SET NAMES utf8;
USE test😠;
diff --git a/mysql-test/main/mysql_not_windows.result b/mysql-test/main/mysql_not_windows.result
index 1df62d9a12d..96210a366a6 100644
--- a/mysql-test/main/mysql_not_windows.result
+++ b/mysql-test/main/mysql_not_windows.result
@@ -9,3 +9,5 @@ End of tests
2
X
3
+ERROR 1300 (HY000): Invalid utf8 character string: 'test\xF0\x9F\x98\x81 '
+ERROR 1300 (HY000): Invalid binary character string: 'test\xF0\x9F\x98\x81 '
diff --git a/mysql-test/main/mysql_not_windows.test b/mysql-test/main/mysql_not_windows.test
index 591de74cbbf..816160c4f3e 100644
--- a/mysql-test/main/mysql_not_windows.test
+++ b/mysql-test/main/mysql_not_windows.test
@@ -22,3 +22,10 @@ exec $MYSQL test -e "select
let $query = select 3
as X;
exec $MYSQL test -e "$query";
+
+# Not ran on Windows, since non-ASCII does not work on command line.
+# (MDEV-16220)
+--error 1
+--exec $MYSQL --default-character-set=utf8 -e "select 1" "test😠" 2>&1
+--error 1
+--exec $MYSQL --default-character-set=binary -e "select 1" "test😠" 2>&1
diff --git a/mysql-test/main/mysql_protocols.result b/mysql-test/main/mysql_protocols.result
index c6207c4f4f5..746e4a46100 100644
--- a/mysql-test/main/mysql_protocols.result
+++ b/mysql-test/main/mysql_protocols.result
@@ -5,6 +5,7 @@ TCP
SOCKET
ok
ERROR 2047 (HY000): Wrong or unknown protocol
-ERROR 2047 (HY000): Wrong or unknown protocol
+Unknown option to protocol: MEMORY
+Alternatives are: 'TCP','SOCKET','PIPE'
Unknown option to protocol: NullS
-Alternatives are: 'TCP','SOCKET','PIPE','MEMORY'
+Alternatives are: 'TCP','SOCKET','PIPE'
diff --git a/mysql-test/main/mysql_upgrade-6984.result b/mysql-test/main/mysql_upgrade-6984.result
index 6c711b4847f..a7b5bcb86bf 100644
--- a/mysql-test/main/mysql_upgrade-6984.result
+++ b/mysql-test/main/mysql_upgrade-6984.result
@@ -12,7 +12,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats
Error : Unknown storage engine 'InnoDB'
diff --git a/mysql-test/main/mysql_upgrade.result b/mysql-test/main/mysql_upgrade.result
index 08efe0e8bc8..54146787123 100644
--- a/mysql-test/main/mysql_upgrade.result
+++ b/mysql-test/main/mysql_upgrade.result
@@ -13,7 +13,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
@@ -62,7 +61,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
@@ -111,7 +109,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
@@ -165,7 +162,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
@@ -220,7 +216,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
@@ -278,7 +273,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
@@ -331,7 +325,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
@@ -376,7 +369,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
@@ -442,7 +434,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
@@ -525,7 +516,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
diff --git a/mysql-test/main/mysql_upgrade_no_innodb.result b/mysql-test/main/mysql_upgrade_no_innodb.result
index 8e051bb7c16..90e96800bff 100644
--- a/mysql-test/main/mysql_upgrade_no_innodb.result
+++ b/mysql-test/main/mysql_upgrade_no_innodb.result
@@ -12,7 +12,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats
Error : Unknown storage engine 'InnoDB'
diff --git a/mysql-test/main/mysql_upgrade_noengine.result b/mysql-test/main/mysql_upgrade_noengine.result
index 7b3b1610ee0..5dfe8aeb289 100644
--- a/mysql-test/main/mysql_upgrade_noengine.result
+++ b/mysql-test/main/mysql_upgrade_noengine.result
@@ -66,7 +66,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
@@ -155,7 +154,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
@@ -244,7 +242,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
diff --git a/mysql-test/main/mysql_upgrade_ssl.result b/mysql-test/main/mysql_upgrade_ssl.result
index 172a1401cdb..6c6d0859016 100644
--- a/mysql-test/main/mysql_upgrade_ssl.result
+++ b/mysql-test/main/mysql_upgrade_ssl.result
@@ -14,7 +14,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
diff --git a/mysql-test/main/mysql_upgrade_view.result b/mysql-test/main/mysql_upgrade_view.result
index 813138b57a8..3d885c569bb 100644
--- a/mysql-test/main/mysql_upgrade_view.result
+++ b/mysql-test/main/mysql_upgrade_view.result
@@ -76,7 +76,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats
Error : Unknown storage engine 'InnoDB'
@@ -226,7 +225,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats
Error : Unknown storage engine 'InnoDB'
@@ -351,7 +349,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats
Error : Unknown storage engine 'InnoDB'
diff --git a/mysql-test/main/mysqlbinlog_row_compressed.result b/mysql-test/main/mysqlbinlog_row_compressed.result
index cbea1cf9def..705683322f8 100644
--- a/mysql-test/main/mysqlbinlog_row_compressed.result
+++ b/mysql-test/main/mysqlbinlog_row_compressed.result
@@ -61,7 +61,7 @@ BEGIN
#Q> INSERT INTO t1 VALUES (10, 1, 2, 3, 4, 5, 6, 7, "")
#<date> server id 1 end_log_pos 899 CRC32 XXX Table_map: `test`.`t1` mapped to number num
# at 899
-#<date> server id 1 end_log_pos 967 CRC32 XXX Write_compressed_rows: table id 31 flags: STMT_END_F
+#<date> server id 1 end_log_pos 967 CRC32 XXX Write_compressed_rows: table id 30 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -90,7 +90,7 @@ BEGIN
#Q> INSERT INTO t1 VALUES (11, 1, 2, 3, 4, 5, 6, 7, NULL)
#<date> server id 1 end_log_pos 1214 CRC32 XXX Table_map: `test`.`t1` mapped to number num
# at 1214
-#<date> server id 1 end_log_pos 1281 CRC32 XXX Write_compressed_rows: table id 31 flags: STMT_END_F
+#<date> server id 1 end_log_pos 1281 CRC32 XXX Write_compressed_rows: table id 30 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=11 /* INT meta=0 nullable=0 is_null=0 */
@@ -119,7 +119,7 @@ BEGIN
#Q> INSERT INTO t1 VALUES (12, 1, 2, 3, NULL, 5, 6, 7, "A")
#<date> server id 1 end_log_pos 1530 CRC32 XXX Table_map: `test`.`t1` mapped to number num
# at 1530
-#<date> server id 1 end_log_pos 1596 CRC32 XXX Write_compressed_rows: table id 31 flags: STMT_END_F
+#<date> server id 1 end_log_pos 1596 CRC32 XXX Write_compressed_rows: table id 30 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=12 /* INT meta=0 nullable=0 is_null=0 */
@@ -148,7 +148,7 @@ BEGIN
#Q> INSERT INTO t1 VALUES (13, 1, 2, 3, 0, 5, 6, 7, "A")
#<date> server id 1 end_log_pos 1842 CRC32 XXX Table_map: `test`.`t1` mapped to number num
# at 1842
-#<date> server id 1 end_log_pos 1909 CRC32 XXX Write_compressed_rows: table id 31 flags: STMT_END_F
+#<date> server id 1 end_log_pos 1909 CRC32 XXX Write_compressed_rows: table id 30 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=13 /* INT meta=0 nullable=0 is_null=0 */
@@ -177,7 +177,7 @@ BEGIN
#Q> INSERT INTO t2 SELECT * FROM t1
#<date> server id 1 end_log_pos 2134 CRC32 XXX Table_map: `test`.`t2` mapped to number num
# at 2134
-#<date> server id 1 end_log_pos 2225 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 2225 CRC32 XXX Write_compressed_rows: table id 31 flags: STMT_END_F
### INSERT INTO `test`.`t2`
### SET
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -239,7 +239,7 @@ BEGIN
#Q> UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL
#<date> server id 1 end_log_pos 2462 CRC32 XXX Table_map: `test`.`t2` mapped to number num
# at 2462
-#<date> server id 1 end_log_pos 2561 CRC32 XXX Update_compressed_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 2561 CRC32 XXX Update_compressed_rows: table id 31 flags: STMT_END_F
### UPDATE `test`.`t2`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -320,7 +320,7 @@ BEGIN
#Q> DELETE FROM t1
#<date> server id 1 end_log_pos 2769 CRC32 XXX Table_map: `test`.`t1` mapped to number num
# at 2769
-#<date> server id 1 end_log_pos 2861 CRC32 XXX Delete_compressed_rows: table id 31 flags: STMT_END_F
+#<date> server id 1 end_log_pos 2861 CRC32 XXX Delete_compressed_rows: table id 30 flags: STMT_END_F
### DELETE FROM `test`.`t1`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -382,7 +382,7 @@ BEGIN
#Q> DELETE FROM t2
#<date> server id 1 end_log_pos 3069 CRC32 XXX Table_map: `test`.`t2` mapped to number num
# at 3069
-#<date> server id 1 end_log_pos 3154 CRC32 XXX Delete_compressed_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 3154 CRC32 XXX Delete_compressed_rows: table id 31 flags: STMT_END_F
### DELETE FROM `test`.`t2`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
diff --git a/mysql-test/main/mysqlbinlog_row_minimal.result b/mysql-test/main/mysqlbinlog_row_minimal.result
index 6417a528638..a030f202f45 100644
--- a/mysql-test/main/mysqlbinlog_row_minimal.result
+++ b/mysql-test/main/mysqlbinlog_row_minimal.result
@@ -59,7 +59,7 @@ BEGIN
#Q> INSERT INTO t1 VALUES (10, 1, 2, 3, 4, 5, 6, 7, "")
#<date> server id 1 end_log_pos 946 CRC32 XXX Table_map: `test`.`t1` mapped to number num
# at 946
-#<date> server id 1 end_log_pos 1015 CRC32 XXX Write_rows: table id 31 flags: STMT_END_F
+#<date> server id 1 end_log_pos 1015 CRC32 XXX Write_rows: table id 30 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -88,7 +88,7 @@ BEGIN
#Q> INSERT INTO t1 VALUES (11, 1, 2, 3, 4, 5, 6, 7, NULL)
#<date> server id 1 end_log_pos 1262 CRC32 XXX Table_map: `test`.`t1` mapped to number num
# at 1262
-#<date> server id 1 end_log_pos 1330 CRC32 XXX Write_rows: table id 31 flags: STMT_END_F
+#<date> server id 1 end_log_pos 1330 CRC32 XXX Write_rows: table id 30 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=11 /* INT meta=0 nullable=0 is_null=0 */
@@ -117,7 +117,7 @@ BEGIN
#Q> INSERT INTO t1 VALUES (12, 1, 2, 3, NULL, 5, 6, 7, "A")
#<date> server id 1 end_log_pos 1579 CRC32 XXX Table_map: `test`.`t1` mapped to number num
# at 1579
-#<date> server id 1 end_log_pos 1646 CRC32 XXX Write_rows: table id 31 flags: STMT_END_F
+#<date> server id 1 end_log_pos 1646 CRC32 XXX Write_rows: table id 30 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=12 /* INT meta=0 nullable=0 is_null=0 */
@@ -146,7 +146,7 @@ BEGIN
#Q> INSERT INTO t1 VALUES (13, 1, 2, 3, 0, 5, 6, 7, "A")
#<date> server id 1 end_log_pos 1892 CRC32 XXX Table_map: `test`.`t1` mapped to number num
# at 1892
-#<date> server id 1 end_log_pos 1962 CRC32 XXX Write_rows: table id 31 flags: STMT_END_F
+#<date> server id 1 end_log_pos 1962 CRC32 XXX Write_rows: table id 30 flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=13 /* INT meta=0 nullable=0 is_null=0 */
@@ -175,7 +175,7 @@ BEGIN
#Q> INSERT INTO t2 SELECT * FROM t1
#<date> server id 1 end_log_pos 2187 CRC32 XXX Table_map: `test`.`t2` mapped to number num
# at 2187
-#<date> server id 1 end_log_pos 2354 CRC32 XXX Write_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 2354 CRC32 XXX Write_rows: table id 31 flags: STMT_END_F
### INSERT INTO `test`.`t2`
### SET
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -237,7 +237,7 @@ BEGIN
#Q> UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL
#<date> server id 1 end_log_pos 2591 CRC32 XXX Table_map: `test`.`t2` mapped to number num
# at 2591
-#<date> server id 1 end_log_pos 2665 CRC32 XXX Update_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 2665 CRC32 XXX Update_rows: table id 31 flags: STMT_END_F
### UPDATE `test`.`t2`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -273,7 +273,7 @@ BEGIN
#Q> DELETE FROM t1
#<date> server id 1 end_log_pos 2873 CRC32 XXX Table_map: `test`.`t1` mapped to number num
# at 2873
-#<date> server id 1 end_log_pos 2927 CRC32 XXX Delete_rows: table id 31 flags: STMT_END_F
+#<date> server id 1 end_log_pos 2927 CRC32 XXX Delete_rows: table id 30 flags: STMT_END_F
### DELETE FROM `test`.`t1`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -303,7 +303,7 @@ BEGIN
#Q> DELETE FROM t2
#<date> server id 1 end_log_pos 3135 CRC32 XXX Table_map: `test`.`t2` mapped to number num
# at 3135
-#<date> server id 1 end_log_pos 3189 CRC32 XXX Delete_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos 3189 CRC32 XXX Delete_rows: table id 31 flags: STMT_END_F
### DELETE FROM `test`.`t2`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
diff --git a/mysql-test/main/mysqlcheck.result b/mysql-test/main/mysqlcheck.result
index 7259b68be50..2b4d4cb5647 100644
--- a/mysql-test/main/mysqlcheck.result
+++ b/mysql-test/main/mysqlcheck.result
@@ -14,7 +14,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
@@ -45,7 +44,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats
note : Table does not support optimize, doing recreate + analyze instead
@@ -80,7 +78,6 @@ mysql.help_category OK
mysql.help_keyword OK
mysql.help_relation OK
mysql.help_topic OK
-mysql.host OK
mysql.index_stats OK
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
@@ -109,7 +106,6 @@ mysql.help_category Table is already up to date
mysql.help_keyword Table is already up to date
mysql.help_relation Table is already up to date
mysql.help_topic Table is already up to date
-mysql.host Table is already up to date
mysql.index_stats Table is already up to date
mysql.innodb_index_stats
note : Table does not support optimize, doing recreate + analyze instead
@@ -438,7 +434,6 @@ mysql.help_category Table is already up to date
mysql.help_keyword Table is already up to date
mysql.help_relation Table is already up to date
mysql.help_topic Table is already up to date
-mysql.host Table is already up to date
mysql.index_stats Table is already up to date
mysql.innodb_index_stats OK
mysql.innodb_table_stats OK
diff --git a/mysql-test/main/mysqld--help,win.rdiff b/mysql-test/main/mysqld--help,win.rdiff
index 89d2cd36112..6aba3acab28 100644
--- a/mysql-test/main/mysqld--help,win.rdiff
+++ b/mysql-test/main/mysqld--help,win.rdiff
@@ -1,6 +1,6 @@
---- a/mysql-test/r/mysqld--help.result
-+++ b/mysql-test/r/mysqld--help.result
-@@ -381,7 +381,6 @@ The following options may be given as the first argument:
+--- mysqld--help.result 2018-08-12 00:10:13.694793500 +0100
++++ mysqld--help,win.reject 2018-08-16 20:31:08.353317200 +0100
+@@ -386,7 +386,6 @@
The number of segments in a key cache
-L, --language=name Client error messages in given language. May be given as
a full path. Deprecated. Use --lc-messages-dir instead.
@@ -8,7 +8,7 @@
--lc-messages=name Set the language used for the error messages.
-L, --lc-messages-dir=name
Directory where error messages are
-@@ -603,6 +602,7 @@ The following options may be given as the first argument:
+@@ -608,6 +607,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.)
@@ -16,17 +16,7 @@
--net-buffer-length=#
Buffer length for TCP/IP and socket communication
--net-read-timeout=#
-@@ -1048,6 +1048,9 @@ The following options may be given as the first argument:
- characteristics (isolation level, read only/read
- write,snapshot - but not any work done / data modified
- within the transaction).
-+ --shared-memory Enable the shared memory
-+ --shared-memory-base-name=name
-+ Base name of shared memory
- --show-slave-auth-info
- Show user and password in SHOW SLAVE HOSTS on this
- master.
-@@ -1171,6 +1174,10 @@ The following options may be given as the first argument:
+@@ -1188,6 +1188,10 @@
Log slow queries to given log file. Defaults logging to
'hostname'-slow.log. Must be enabled to activate other
slow log options
@@ -37,7 +27,7 @@
--socket=name Socket file to use for connection
--sort-buffer-size=#
Each thread that needs to do a sort allocates a buffer of
-@@ -1190,6 +1197,7 @@ The following options may be given as the first argument:
+@@ -1207,6 +1211,7 @@
EMPTY_STRING_IS_NULL, SIMULTANEOUS_ASSIGNMENT
--stack-trace Print a symbolic stack trace on failure
(Defaults to on; use --skip-stack-trace to disable.)
@@ -45,7 +35,7 @@
--standard-compliant-cte
Allow only CTEs compliant to SQL standard
(Defaults to on; use --skip-standard-compliant-cte to disable.)
-@@ -1257,6 +1265,11 @@ The following options may be given as the first argument:
+@@ -1277,6 +1282,11 @@
--thread-pool-max-threads=#
Maximum allowed number of worker threads in the thread
pool
@@ -57,7 +47,7 @@
--thread-pool-oversubscribe=#
How many additional active worker threads in a group are
allowed.
-@@ -1295,8 +1308,8 @@ The following options may be given as the first argument:
+@@ -1315,8 +1325,8 @@
automatically convert it to an on-disk MyISAM or Aria
table.
-t, --tmpdir=name Path for temporary files. Several paths may be specified,
@@ -68,7 +58,7 @@
--transaction-alloc-block-size=#
Allocation block size for transactions to be stored in
binary log
-@@ -1430,7 +1443,6 @@ key-cache-block-size 1024
+@@ -1451,7 +1461,6 @@
key-cache-division-limit 100
key-cache-file-hash-size 512
key-cache-segments 0
@@ -76,7 +66,7 @@
lc-messages en_US
lc-messages-dir MYSQL_SHAREDIR/
lc-time-names en_US
-@@ -1502,6 +1514,7 @@ myisam-sort-buffer-size 134216704
+@@ -1523,6 +1532,7 @@
myisam-stats-method NULLS_UNEQUAL
myisam-use-mmap FALSE
mysql56-temporal-format TRUE
@@ -84,16 +74,7 @@
net-buffer-length 16384
net-read-timeout 30
net-retry-count 10
-@@ -1612,6 +1625,8 @@ session-track-schema TRUE
- session-track-state-change FALSE
- session-track-system-variables autocommit,character_set_client,character_set_connection,character_set_results,time_zone
- session-track-transaction-info OFF
-+shared-memory FALSE
-+shared-memory-base-name MYSQL
- show-slave-auth-info FALSE
- silent-startup FALSE
- skip-grant-tables TRUE
-@@ -1638,6 +1653,7 @@ slave-transaction-retry-interval 0
+@@ -1660,6 +1670,7 @@
slave-type-conversions
slow-launch-time 2
slow-query-log FALSE
@@ -101,7 +82,7 @@
sort-buffer-size 2097152
sql-mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
stack-trace TRUE
-@@ -1652,9 +1668,9 @@ sync-relay-log 10000
+@@ -1674,9 +1685,9 @@
sync-relay-log-info 10000
sysdate-is-now FALSE
system-versioning-alter-history ERROR
@@ -113,7 +94,7 @@
table-open-cache-instances 8
tc-heuristic-recover OFF
tcp-keepalive-interval 0
-@@ -1663,6 +1679,8 @@ tcp-keepalive-time 0
+@@ -1686,6 +1697,8 @@
thread-cache-size 151
thread-pool-idle-timeout 60
thread-pool-max-threads 65536
diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result
index ac490afe229..5ee85eee7de 100644
--- a/mysql-test/main/mysqld--help.result
+++ b/mysql-test/main/mysqld--help.result
@@ -231,6 +231,11 @@ The following specify which files/extra groups are read (specified before remain
cache, etc)
--enforce-storage-engine=name
Force the use of a storage engine for new tables
+ --eq-range-index-dive-limit=#
+ The optimizer will use existing index statistics instead
+ of doing index dives for equality ranges if the number of
+ equality ranges for the index is larger than or equal to
+ this number. If set to 0, index dives are always used.
--event-scheduler[=name]
Enable the event scheduler. Possible values are ON, OFF,
and DISABLED (keep the event scheduler completely
@@ -1205,6 +1210,10 @@ The following specify which files/extra groups are read (specified before remain
NO_AUTO_CREATE_USER, HIGH_NOT_PRECEDENCE,
NO_ENGINE_SUBSTITUTION, PAD_CHAR_TO_FULL_LENGTH,
EMPTY_STRING_IS_NULL, SIMULTANEOUS_ASSIGNMENT
+ --sql-safe-updates If set to 1, UPDATEs and DELETEs need either a key in the
+ WHERE clause, or a LIMIT clause, or else they will
+ aborted. Prevents the common mistake of accidentally
+ deleting or updating every row in a table.
--stack-trace Print a symbolic stack trace on failure
(Defaults to on; use --skip-stack-trace to disable.)
--standard-compliant-cte
@@ -1404,6 +1413,7 @@ encrypt-binlog FALSE
encrypt-tmp-disk-tables FALSE
encrypt-tmp-files FALSE
enforce-storage-engine (No default value)
+eq-range-index-dive-limit 0
event-scheduler OFF
expensive-subquery-limit 100
expire-logs-days 0
@@ -1662,6 +1672,7 @@ slow-launch-time 2
slow-query-log FALSE
sort-buffer-size 2097152
sql-mode STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
+sql-safe-updates FALSE
stack-trace TRUE
standard-compliant-cte TRUE
stored-program-cache 256
diff --git a/mysql-test/main/mysqldump-max.result b/mysql-test/main/mysqldump-max.result
index b75eb969da6..f936184849f 100644
--- a/mysql-test/main/mysqldump-max.result
+++ b/mysql-test/main/mysqldump-max.result
@@ -81,7 +81,7 @@ id name
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -178,7 +178,7 @@ INSERT IGNORE INTO `t6` VALUES (1,'first value'),(2,'first value'),(3,'first va
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
diff --git a/mysql-test/main/mysqldump-max.test b/mysql-test/main/mysqldump-max.test
index c0596f27e4f..4aadb09de53 100644
--- a/mysql-test/main/mysqldump-max.test
+++ b/mysql-test/main/mysqldump-max.test
@@ -1,3 +1,5 @@
+--source include/have_utf8mb4.inc
+
# Embedded server doesn't support external clients
--source include/not_embedded.inc
--source include/have_innodb.inc
diff --git a/mysql-test/main/mysqldump-utf8mb4.result b/mysql-test/main/mysqldump-utf8mb4.result
new file mode 100644
index 00000000000..3bafd6da6c9
--- /dev/null
+++ b/mysql-test/main/mysqldump-utf8mb4.result
@@ -0,0 +1,86 @@
+SET NAMES utf8mb4;
+#
+# MDEV-8765 mysqldump silently corrupts 4-byte UTF-8 data
+#
+CREATE TABLE t1 (
+point VARCHAR(10) PRIMARY KEY,
+data VARCHAR(10),
+comment VARCHAR(64)
+) CHARACTER SET utf8mb4;
+INSERT INTO t1 VALUES ('01f300', UNHEX('f09f8c80'), 'U+1F300 CYCLONE');
+----
+Testing XML format output
+----
+<?xml version="1.0"?>
+<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+<database name="test">
+ <table_structure name="t1">
+ <field Field="point" Type="varchar(10)" Null="NO" Key="PRI" Extra="" Comment="" />
+ <field Field="data" Type="varchar(10)" Null="YES" Key="" Default="NULL" Extra="" Comment="" />
+ <field Field="comment" Type="varchar(64)" Null="YES" Key="" Default="NULL" Extra="" Comment="" />
+ <key Table="t1" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="point" Collation="A" Cardinality="1" Null="" Index_type="BTREE" Comment="" Index_comment="" />
+ </table_structure>
+ <table_data name="t1">
+ <row>
+ <field name="point">01f300</field>
+ <field name="data">🌀</field>
+ <field name="comment">U+1F300 CYCLONE</field>
+ </row>
+ </table_data>
+</database>
+</mysqldump>
+----
+Testing text format output
+----
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+DROP TABLE IF EXISTS `t1`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `t1` (
+ `point` varchar(10) NOT NULL,
+ `data` varchar(10) DEFAULT NULL,
+ `comment` varchar(64) DEFAULT NULL,
+ PRIMARY KEY (`point`)
+);
+/*!40101 SET character_set_client = @saved_cs_client */;
+
+LOCK TABLES `t1` WRITE;
+/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
+INSERT INTO `t1` VALUES ('01f300','🌀','U+1F300 CYCLONE');
+/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+DROP TABLE t1;
+----
+Testing text format dump/restore
+----
+CREATE TABLE t1 (
+point VARCHAR(10) PRIMARY KEY,
+data VARCHAR(10),
+comment VARCHAR(64)
+) CHARACTER SET utf8mb4;
+INSERT INTO t1 VALUES ('01f300', UNHEX('f09f8c80'), 'U+1F300 CYCLONE');
+DROP TABLE t1;
+SELECT * FROM t1;
+point data comment
+01f300 🌀 U+1F300 CYCLONE
+DROP TABLE t1;
diff --git a/mysql-test/main/mysqldump-utf8mb4.test b/mysql-test/main/mysqldump-utf8mb4.test
new file mode 100644
index 00000000000..f8512c9bd7b
--- /dev/null
+++ b/mysql-test/main/mysqldump-utf8mb4.test
@@ -0,0 +1,49 @@
+--source include/have_utf8mb4.inc
+--source include/not_embedded.inc
+
+SET NAMES utf8mb4;
+
+--echo #
+--echo # MDEV-8765 mysqldump silently corrupts 4-byte UTF-8 data
+--echo #
+
+CREATE TABLE t1 (
+ point VARCHAR(10) PRIMARY KEY,
+ data VARCHAR(10),
+ comment VARCHAR(64)
+) CHARACTER SET utf8mb4;
+INSERT INTO t1 VALUES ('01f300', UNHEX('f09f8c80'), 'U+1F300 CYCLONE');
+
+--echo ----
+--echo Testing XML format output
+--echo ----
+
+--exec $MYSQL_DUMP --skip-create-options --skip-comments -X test t1
+
+
+--echo ----
+--echo Testing text format output
+--echo ----
+
+--exec $MYSQL_DUMP --skip-create-options --skip-comments test t1
+DROP TABLE t1;
+
+
+--echo ----
+--echo Testing text format dump/restore
+--echo ----
+
+--let $file = $MYSQLTEST_VARDIR/tmp/mysqldump-utf8mb4.sql
+
+CREATE TABLE t1 (
+ point VARCHAR(10) PRIMARY KEY,
+ data VARCHAR(10),
+ comment VARCHAR(64)
+) CHARACTER SET utf8mb4;
+INSERT INTO t1 VALUES ('01f300', UNHEX('f09f8c80'), 'U+1F300 CYCLONE');
+
+--exec $MYSQL_DUMP test t1 > $file
+DROP TABLE t1;
+--exec $MYSQL test < $file
+SELECT * FROM t1;
+DROP TABLE t1;
diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result
index cc4d182552b..1a3b927f981 100644
--- a/mysql-test/main/mysqldump.result
+++ b/mysql-test/main/mysqldump.result
@@ -91,7 +91,7 @@ INSERT INTO `t1` VALUES (1.23450,2.3456),(1.23450,2.3456),(1.23450,2.3456),(1.23
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -202,7 +202,7 @@ INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -305,7 +305,7 @@ create table t1(a int);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -364,7 +364,7 @@ set global sql_mode='ANSI_QUOTES';
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -429,7 +429,7 @@ insert into t1 values (1),(2),(3);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='' */;
@@ -461,7 +461,7 @@ drop table t1;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -487,7 +487,7 @@ create database mysqldump_test_db character set latin2 collate latin2_bin;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -521,7 +521,7 @@ INSERT INTO t1 VALUES (_latin1 'ÄÖÜß');
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -639,7 +639,7 @@ INSERT INTO t2 VALUES (4),(5),(6);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -680,7 +680,7 @@ INSERT INTO `t1` VALUES (0x602010000280100005E71A);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -721,7 +721,7 @@ INSERT INTO t1 VALUES (4),(5),(6);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -755,7 +755,7 @@ UNLOCK TABLES;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -1124,7 +1124,7 @@ insert into t1 (F_8d3bba7425e7c98c50f52ca1b52d3735) values (1);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -1493,7 +1493,7 @@ INSERT INTO t1 VALUES (1),(2),(3);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -1543,7 +1543,7 @@ INSERT INTO t2 VALUES (1), (2);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -1578,7 +1578,7 @@ CREATE TABLE `t2` (
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -1726,7 +1726,7 @@ insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thir
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
@@ -1757,7 +1757,7 @@ UNLOCK TABLES;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -1874,7 +1874,7 @@ create table t3(a int);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -1923,7 +1923,7 @@ mysqldump: Got error: 1064: "You have an error in your SQL syntax; check the man
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -1993,7 +1993,7 @@ UNLOCK TABLES;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -2047,7 +2047,7 @@ create view v2 as select * from t2 where a like 'a%' with check option;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -2143,7 +2143,7 @@ create view v1 as select * from t1;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -2215,7 +2215,7 @@ create view v2 as select * from t2 where a like 'a%' with check option;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -2282,7 +2282,7 @@ INSERT INTO t1 VALUES ('\'');
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -2328,7 +2328,7 @@ select v3.a from v3, v1 where v1.a=v3.a and v3.b=3 limit 1;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -2483,7 +2483,7 @@ update t1 set a = 4 where a=3;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -2612,7 +2612,7 @@ DELIMITER ;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -2759,7 +2759,7 @@ set sql_mode='';
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -2910,7 +2910,7 @@ set global time_zone='Europe/Moscow';
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -2949,7 +2949,7 @@ UNLOCK TABLES;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
@@ -3083,7 +3083,7 @@ a b c
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -3214,7 +3214,7 @@ SET SQL_MODE = @old_sql_mode;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -3277,7 +3277,7 @@ insert into t1 values ('','');
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -3312,7 +3312,7 @@ UNLOCK TABLES;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -3485,7 +3485,7 @@ insert into t1 values (0815);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -3769,7 +3769,7 @@ CREATE TABLE t1 (a INT) ENGINE=merge UNION=(t2, t3);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -3961,7 +3961,7 @@ create view db42635.v2 (c) as select * from db42635.t1;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -4107,7 +4107,7 @@ INSERT INTO t1 VALUES (3,4), (4,5);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -4370,7 +4370,7 @@ insert into t1 values (0815);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -5636,7 +5636,7 @@ INSERT INTO t1 (a) VALUES (1),(2),(3);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
diff --git a/mysql-test/main/mysqldump.test b/mysql-test/main/mysqldump.test
index 1eed0f9cf3f..57462fcf2e2 100644
--- a/mysql-test/main/mysqldump.test
+++ b/mysql-test/main/mysqldump.test
@@ -1,3 +1,5 @@
+--source include/have_utf8mb4.inc
+
call mtr.add_suppression("@003f.frm' \\(errno: 22\\)");
#select * from mysql.user;
#checksum table mysql.user;
@@ -705,7 +707,7 @@ drop table t1;
--echo # Bug#15328 Segmentation fault occurred if my.cnf is invalid for escape sequence
--echo #
---exec $MYSQL_MY_PRINT_DEFAULTS --config-file=$MYSQL_TEST_DIR/std_data/bug15328.cnf mysqldump
+--exec $MYSQL_MY_PRINT_DEFAULTS --defaults-file=$MYSQL_TEST_DIR/std_data/bug15328.cnf mysqldump
--echo #
--echo # Bug#19025 mysqldump doesn't correctly dump "auto_increment = [int]"
diff --git a/mysql-test/main/mysqldump_restore.result b/mysql-test/main/mysqldump_restore.result
index 4f9d55096ae..9eac8b253de 100644
--- a/mysql-test/main/mysqldump_restore.result
+++ b/mysql-test/main/mysqldump_restore.result
@@ -21,10 +21,6 @@ ALTER TABLE test.t1 RENAME to test.t1_orig;
# Recreated table: test.t1
# Original table: test.t1_orig
include/diff_tables.inc [test.t1, test.t1_orig]
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
# Cleanup
DROP TABLE test.t1, test.t1_orig;
#
@@ -50,10 +46,6 @@ ALTER TABLE test.t1 RENAME to test.t1_orig;
# Recreated table: test.t1
# Original table: test.t1_orig
include/diff_tables.inc [test.t1, test.t1_orig]
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
# Cleanup
DROP TABLE test.t1, test.t1_orig;
#
@@ -72,10 +64,6 @@ ALTER TABLE test.t1 RENAME to test.t1_orig;
# Recreated table: test.t1
# Original table: test.t1_orig
include/diff_tables.inc [test.t1, test.t1_orig]
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
# Cleanup
DROP TABLE test.t1, test.t1_orig;
#
@@ -95,10 +83,6 @@ ALTER TABLE test.t2 RENAME to test.t2_orig;
# Recreated table: test.t2
# Original table: test.t2_orig
include/diff_tables.inc [test.t2, test.t2_orig]
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
# Cleanup
DROP TABLE test.t2, test.t2_orig;
DROP TABLE t1;
@@ -117,10 +101,6 @@ ALTER TABLE test.t1 RENAME to test.t1_orig;
# Recreated table: test.t1
# Original table: test.t1_orig
include/diff_tables.inc [test.t1, test.t1_orig]
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
# Cleanup
DROP TABLE test.t1, test.t1_orig;
# End tests
diff --git a/mysql-test/main/no_password_column-mdev-11170.result b/mysql-test/main/no_password_column-mdev-11170.result
index 6195100436d..94d49a4e762 100644
--- a/mysql-test/main/no_password_column-mdev-11170.result
+++ b/mysql-test/main/no_password_column-mdev-11170.result
@@ -87,7 +87,7 @@ select user, host, select_priv, plugin, authentication_string from mysql.user
where user like "%oo"
order by user;
user host select_priv plugin authentication_string
-foo % N
+foo % N mysql_native_password
goo % N mysql_native_password *F3A2A51A9B0F2BE2468926B4132313728C250DBF
ioo % N mysql_old_password 7a8f886d28473e85
#
diff --git a/mysql-test/main/null.result b/mysql-test/main/null.result
index 2fa89a2d001..6601c5e1ed4 100644
--- a/mysql-test/main/null.result
+++ b/mysql-test/main/null.result
@@ -515,9 +515,9 @@ NULLIF(TIMESTAMP'2001-01-01 00:00:00',1e0),
NULLIF(TIMESTAMP'2001-01-01 00:00:00','2001-01-01'),
NULLIF(TIMESTAMP'2001-01-01 00:00:00',TIME'00:00:00');
Warnings:
-Warning 1292 Incorrect datetime value: '1'
-Warning 1292 Incorrect datetime value: '1.0'
-Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1.0'
+Warning 1292 Truncated incorrect datetime value: '1'
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -536,9 +536,9 @@ NULLIF(DATE'2001-01-01',1e0),
NULLIF(DATE'2001-01-01','2001-01-01'),
NULLIF(DATE'2001-01-01',TIME'00:00:00');
Warnings:
-Warning 1292 Incorrect datetime value: '1'
-Warning 1292 Incorrect datetime value: '1.0'
-Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1.0'
+Warning 1292 Truncated incorrect datetime value: '1'
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
@@ -1640,8 +1640,8 @@ CASE WHEN TIMESTAMP'2001-01-01 00:00:00'=1 THEN NULL
ELSE TIMESTAMP'2001-01-01 00:00:00'
END AS b;
Warnings:
-Warning 1292 Incorrect datetime value: '1'
-Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
DROP TABLE t1;
#
# MDEV-8785 Wrong results for EXPLAIN EXTENDED...WHERE NULLIF(latin1_col, _utf8'a' COLLATE utf8_bin) IS NOT NULL
diff --git a/mysql-test/main/openssl_1.result b/mysql-test/main/openssl_1.result
index ca8d71895e2..3f0483b1e64 100644
--- a/mysql-test/main/openssl_1.result
+++ b/mysql-test/main/openssl_1.result
@@ -106,7 +106,7 @@ INSERT INTO t1 VALUES (1), (2);
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -140,7 +140,7 @@ UNLOCK TABLES;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -174,7 +174,7 @@ UNLOCK TABLES;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
-/*!40101 SET NAMES utf8 */;
+/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
diff --git a/mysql-test/main/openssl_1.test b/mysql-test/main/openssl_1.test
index a3db700f787..dce4f88b6bb 100644
--- a/mysql-test/main/openssl_1.test
+++ b/mysql-test/main/openssl_1.test
@@ -1,3 +1,6 @@
+# Needed for mysqldump
+--source include/have_utf8mb4.inc
+
# Tests for SSL connections, only run if mysqld is compiled
# with support for SSL.
diff --git a/mysql-test/main/opt_tvc.result b/mysql-test/main/opt_tvc.result
index 0ecae5bf157..d503dab4d99 100644
--- a/mysql-test/main/opt_tvc.result
+++ b/mysql-test/main/opt_tvc.result
@@ -51,7 +51,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1`
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`_col_1`
explain extended select * from t1
where a in
(
@@ -98,7 +98,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) semi join ((values (1),(5)) `tvc_1`) where `test`.`t1`.`b` = `tvc_1`.`1`
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) semi join ((values (1),(5)) `tvc_1`) where `test`.`t1`.`b` = `tvc_1`.`_col_1`
explain extended select * from t1
where a in
(
@@ -154,7 +154,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (3),(4)) `tvc_0` join `test`.`t2`) where `test`.`t2`.`b` = `tvc_0`.`3`
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (3),(4)) `tvc_0` join `test`.`t2`) where `test`.`t2`.`b` = `tvc_0`.`_col_1`
explain extended select * from t1
where a in
(
@@ -211,7 +211,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 2 100.00
4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1`
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`_col_1`
explain extended select * from
(
select *
@@ -270,7 +270,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 2 100.00
4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 with tvc_0 as (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` in (1,2))/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1`
+Note 1003 with tvc_0 as (/* select#2 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` in (1,2))/* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`_col_1`
explain extended select * from
(
select *
@@ -321,7 +321,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
3 MATERIALIZED <derived4> ALL NULL NULL NULL NULL 2 100.00
4 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1`
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`_col_1`
explain extended select * from v2;
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <subquery3> ALL distinct_key NULL NULL NULL 2 100.00
@@ -386,7 +386,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 MATERIALIZED t1 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
5 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0` join `test`.`t1`) where `test`.`t1`.`a` = 1 and `test`.`t1`.`a` = `tvc_0`.`1`
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1),(2)) `tvc_0` join `test`.`t1`) where `test`.`t1`.`a` = 1 and `test`.`t1`.`a` = `tvc_0`.`_col_1`
explain extended select * from t1
where a in
(
@@ -486,34 +486,32 @@ a b
deallocate prepare stmt;
# use inside out access from tvc rows
set @@in_predicate_conversion_threshold= default;
-select * from t3 where a in (1,4,10);
+select * from t3 where a in (1,4);
a b
1 abc
1 todd
1 sm
4 yq
-10 abc
-explain extended select * from t3 where a in (1,4,10);
+explain extended select * from t3 where a in (1,4);
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t3 range idx idx 5 NULL 5 100.00 Using index condition
+1 SIMPLE t3 range idx idx 5 NULL 4 100.00 Using index condition
Warnings:
-Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where `test`.`t3`.`a` in (1,4,10)
+Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` where `test`.`t3`.`a` in (1,4)
set @@in_predicate_conversion_threshold= 2;
-select * from t3 where a in (1,4,10);
+select * from t3 where a in (1,4);
a b
1 abc
1 todd
1 sm
4 yq
-10 abc
-explain extended select * from t3 where a in (1,4,10);
+explain extended select * from t3 where a in (1,4);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 100.00
-1 PRIMARY t3 ref idx idx 5 tvc_0.1 3 100.00
+1 PRIMARY t3 ref idx idx 5 tvc_0._col_1 3 100.00
2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` semi join ((values (1),(4),(10)) `tvc_0`) where `test`.`t3`.`a` = `tvc_0`.`1`
+Note 1003 /* select#1 */ select `test`.`t3`.`a` AS `a`,`test`.`t3`.`b` AS `b` from `test`.`t3` semi join ((values (1),(4)) `tvc_0`) where `test`.`t3`.`a` = `tvc_0`.`_col_1`
# use vectors in IN predeicate
set @@in_predicate_conversion_threshold= 4;
select * from t1 where (a,b) in ((1,2),(3,4));
@@ -526,7 +524,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1,2),(3,4)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`1` and `test`.`t1`.`b` = `tvc_0`.`2`
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` semi join ((values (1,2),(3,4)) `tvc_0`) where `test`.`t1`.`a` = `tvc_0`.`_col_1` and `test`.`t1`.`b` = `tvc_0`.`_col_2`
set @@in_predicate_conversion_threshold= 2;
# trasformation works for the one IN predicate and doesn't work for the other
set @@in_predicate_conversion_threshold= 5;
@@ -540,12 +538,12 @@ explain extended select * from t2
where (a,b) in ((1,2),(8,9)) and
(a,c) in ((1,3),(8,0),(5,1));
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 2 100.00
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3 100.00
1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where; Using join buffer (flat, BNL join)
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
+2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` semi join ((values (1,3),(8,0),(5,1)) `tvc_0`) where `test`.`t2`.`a` = `tvc_0`.`1` and `test`.`t2`.`c` = `tvc_0`.`3` and (`tvc_0`.`1`,`test`.`t2`.`b`) in (<cache>((1,2)),<cache>((8,9)))
+Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` semi join ((values (1,3),(8,0),(5,1)) `tvc_0`) where `test`.`t2`.`a` = `tvc_0`.`_col_1` and `test`.`t2`.`c` = `tvc_0`.`_col_2` and (`tvc_0`.`_col_1`,`test`.`t2`.`b`) in (<cache>((1,2)),<cache>((8,9)))
set @@in_predicate_conversion_threshold= 2;
#
# mdev-14281: conversion of NOT IN predicate into subquery predicate
@@ -570,15 +568,15 @@ explain extended select * from t1
where (a,b) not in ((1,2),(8,9), (5,1));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
+2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( <materialize> (/* select#2 */ select `tvc_0`.`1`,`tvc_0`.`2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`1` and `test`.`t1`.`b` = `<subquery2>`.`2`))))
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( <materialize> (/* select#2 */ select `tvc_0`.`_col_1`,`tvc_0`.`_col_2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`_col_1` and `test`.`t1`.`b` = `<subquery2>`.`_col_2`))))
explain extended select * from t1
where (a,b) not in (select * from (values (1,2),(8,9), (5,1)) as tvc_0);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
+2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( <materialize> (/* select#2 */ select `tvc_0`.`1`,`tvc_0`.`2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`1` and `test`.`t1`.`b` = `<subquery2>`.`2`))))
@@ -592,10 +590,10 @@ explain extended select * from t1
where b < 7 and (a,b) not in ((1,2),(8,9), (5,1));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t1 ALL NULL NULL NULL NULL 6 100.00 Using where
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
+2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` < 7 and !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( <materialize> (/* select#2 */ select `tvc_0`.`1`,`tvc_0`.`2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`1` and `test`.`t1`.`b` = `<subquery2>`.`2`))))
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from `test`.`t1` where `test`.`t1`.`b` < 7 and !<expr_cache><`test`.`t1`.`a`,`test`.`t1`.`b`>(<in_optimizer>((`test`.`t1`.`a`,`test`.`t1`.`b`),(`test`.`t1`.`a`,`test`.`t1`.`b`) in ( <materialize> (/* select#2 */ select `tvc_0`.`_col_1`,`tvc_0`.`_col_2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t1`.`a` in <temporary table> on distinct_key where `test`.`t1`.`a` = `<subquery2>`.`_col_1` and `test`.`t1`.`b` = `<subquery2>`.`_col_2`))))
select * from t2
where (a,c) not in ((1,2),(8,9), (5,1));
a b c
@@ -608,14 +606,14 @@ explain extended select * from t2
where (a,c) not in ((1,2),(8,9), (5,1));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 6 100.00 Using where
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2 100.00
+2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 3 100.00
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where !<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`c`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`c`),(`test`.`t2`.`a`,`test`.`t2`.`c`) in ( <materialize> (/* select#2 */ select `tvc_0`.`1`,`tvc_0`.`2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where `test`.`t2`.`a` = `<subquery2>`.`1` and `test`.`t2`.`c` = `<subquery2>`.`2`))))
+Note 1003 /* select#1 */ select `test`.`t2`.`a` AS `a`,`test`.`t2`.`b` AS `b`,`test`.`t2`.`c` AS `c` from `test`.`t2` where !<expr_cache><`test`.`t2`.`a`,`test`.`t2`.`c`>(<in_optimizer>((`test`.`t2`.`a`,`test`.`t2`.`c`),(`test`.`t2`.`a`,`test`.`t2`.`c`) in ( <materialize> (/* select#2 */ select `tvc_0`.`_col_1`,`tvc_0`.`_col_2` from (values (1,2),(8,9),(5,1)) `tvc_0` ), <primary_index_lookup>(`test`.`t2`.`a` in <temporary table> on distinct_key where `test`.`t2`.`a` = `<subquery2>`.`_col_1` and `test`.`t2`.`c` = `<subquery2>`.`_col_2`))))
drop table t1, t2, t3;
set @@in_predicate_conversion_threshold= default;
#
-# MDEV-14947: conversion of TVC with only NULL values
+# MDEV-14947: conversion to TVC with only NULL values
#
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (3), (2), (7);
@@ -632,14 +630,14 @@ i
EXPLAIN EXTENDED SELECT * FROM t1 WHERE i IN (NULL, NULL, NULL, NULL, NULL);
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 <derived3> ALL NULL NULL NULL NULL 2 100.00 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
+1 PRIMARY <derived3> ALL NULL NULL NULL NULL 5 100.00 Using where; FirstMatch(t1); Using join buffer (flat, BNL join)
3 DERIVED NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join ((values (NULL),(NULL),(NULL),(NULL),(NULL)) `tvc_0`) where `test`.`t1`.`i` = `tvc_0`.`NULL`
+Note 1003 /* select#1 */ select `test`.`t1`.`i` AS `i` from `test`.`t1` semi join ((values (NULL),(NULL),(NULL),(NULL),(NULL)) `tvc_0`) where `test`.`t1`.`i` = `tvc_0`.`_col_1`
SET in_predicate_conversion_threshold= default;
DROP TABLE t1;
#
-# MDEV-14835: conversion of TVC with BIGINT or YEAR values
+# MDEV-14835: conversion to TVC with BIGINT or YEAR values
#
SET @@in_predicate_conversion_threshold= 2;
CREATE TABLE t1 (a BIGINT);
@@ -656,3 +654,36 @@ y
2011
DROP TABLE t1,t2;
SET @@in_predicate_conversion_threshold= default;
+#
+# MDEV-17222: conversion to TVC with no names for constants
+# conversion to TVC with the same constants in the first row
+#
+SET @@in_predicate_conversion_threshold= 2;
+CREATE TABLE t1 (f BINARY(16)) ENGINE=MYISAM;
+INSERT INTO t1 VALUES
+(x'BAE56AF2B1C2397D99D58E2A06761DDB'), (x'9B9B698BCCB939EE8F1EA56C1A2E5DAA'),
+(x'A0A1C4FE39A239BABD3E0D8985E6BEA5');
+SELECT COUNT(*) FROM t1 WHERE f IN
+(x'9B9B698BCCB939EE8F1EA56C1A2E5DAA', x'E2362DBAB5EA30B5804917A0A7D881E2',
+x'B78B2EEAD13635088D93EA3309E24802', x'BAE56AF2B1C2397D99D58E2A06761DDB');
+COUNT(*)
+2
+CREATE TABLE t2 (f1 BINARY(16), f2 BINARY(16)) ENGINE=MYISAM;
+INSERT INTO t2 VALUES
+(x'55FB3B14D6B83D39859E42533906350D', x'00F3458C47FA39DDBEAD918A13F8342E'),
+(x'86052C062AAF368D84247ED0F6346A70', x'BF5C35045C6037C79E11026ABB9A3A4E');
+SELECT COUNT(*) FROM t2 WHERE (f1,f2) IN
+((x'9B9B698BCCB939EE8F1EA56C1A2E5DAA', x'E2362DBAB5EA30B5804917A0A7D881E2'),
+(x'B78B2EEAD13635088D93EA3309E24802', x'BAE56AF2B1C2397D99D58E2A06761DDB'),
+(x'55FB3B14D6B83D39859E42533906350D', x'00F3458C47FA39DDBEAD918A13F8342E'),
+(x'1606014E7C4A312F83EDC9D91BBFCACA', x'33F6068E56FD3A1D8326517F0D81CB5A'));
+COUNT(*)
+1
+CREATE TABLE t3 (f1 int, f2 int) ENGINE=MYISAM;
+INSERT INTO t3 VALUES (2,5), (2,3), (1,2), (7,8), (1,1);
+SELECT * FROM t3 WHERE (f1,f2) IN ((2, 2), (1, 2), (3, 5), (1, 1));
+f1 f2
+1 2
+1 1
+DROP TABLE t1,t2,t3;
+SET @@in_predicate_conversion_threshold= default;
diff --git a/mysql-test/main/opt_tvc.test b/mysql-test/main/opt_tvc.test
index d5c9a5cbd3d..733ee0792fe 100644
--- a/mysql-test/main/opt_tvc.test
+++ b/mysql-test/main/opt_tvc.test
@@ -255,7 +255,7 @@ deallocate prepare stmt;
--echo # use inside out access from tvc rows
-let $query= select * from t3 where a in (1,4,10);
+let $query= select * from t3 where a in (1,4);
set @@in_predicate_conversion_threshold= default;
eval $query;
eval explain extended $query;
@@ -320,7 +320,7 @@ drop table t1, t2, t3;
set @@in_predicate_conversion_threshold= default;
--echo #
---echo # MDEV-14947: conversion of TVC with only NULL values
+--echo # MDEV-14947: conversion to TVC with only NULL values
--echo #
CREATE TABLE t1 (i INT);
@@ -342,7 +342,7 @@ SET in_predicate_conversion_threshold= default;
DROP TABLE t1;
--echo #
---echo # MDEV-14835: conversion of TVC with BIGINT or YEAR values
+--echo # MDEV-14835: conversion to TVC with BIGINT or YEAR values
--echo #
SET @@in_predicate_conversion_threshold= 2;
@@ -360,3 +360,39 @@ SELECT * FROM t2 WHERE y IN ('2009','2011');
DROP TABLE t1,t2;
SET @@in_predicate_conversion_threshold= default;
+
+--echo #
+--echo # MDEV-17222: conversion to TVC with no names for constants
+--echo # conversion to TVC with the same constants in the first row
+--echo #
+
+SET @@in_predicate_conversion_threshold= 2;
+
+CREATE TABLE t1 (f BINARY(16)) ENGINE=MYISAM;
+INSERT INTO t1 VALUES
+(x'BAE56AF2B1C2397D99D58E2A06761DDB'), (x'9B9B698BCCB939EE8F1EA56C1A2E5DAA'),
+(x'A0A1C4FE39A239BABD3E0D8985E6BEA5');
+
+SELECT COUNT(*) FROM t1 WHERE f IN
+(x'9B9B698BCCB939EE8F1EA56C1A2E5DAA', x'E2362DBAB5EA30B5804917A0A7D881E2',
+ x'B78B2EEAD13635088D93EA3309E24802', x'BAE56AF2B1C2397D99D58E2A06761DDB');
+
+CREATE TABLE t2 (f1 BINARY(16), f2 BINARY(16)) ENGINE=MYISAM;
+INSERT INTO t2 VALUES
+(x'55FB3B14D6B83D39859E42533906350D', x'00F3458C47FA39DDBEAD918A13F8342E'),
+(x'86052C062AAF368D84247ED0F6346A70', x'BF5C35045C6037C79E11026ABB9A3A4E');
+
+SELECT COUNT(*) FROM t2 WHERE (f1,f2) IN
+((x'9B9B698BCCB939EE8F1EA56C1A2E5DAA', x'E2362DBAB5EA30B5804917A0A7D881E2'),
+ (x'B78B2EEAD13635088D93EA3309E24802', x'BAE56AF2B1C2397D99D58E2A06761DDB'),
+ (x'55FB3B14D6B83D39859E42533906350D', x'00F3458C47FA39DDBEAD918A13F8342E'),
+ (x'1606014E7C4A312F83EDC9D91BBFCACA', x'33F6068E56FD3A1D8326517F0D81CB5A'));
+
+CREATE TABLE t3 (f1 int, f2 int) ENGINE=MYISAM;
+INSERT INTO t3 VALUES (2,5), (2,3), (1,2), (7,8), (1,1);
+
+SELECT * FROM t3 WHERE (f1,f2) IN ((2, 2), (1, 2), (3, 5), (1, 1));
+
+DROP TABLE t1,t2,t3;
+
+SET @@in_predicate_conversion_threshold= default;
diff --git a/mysql-test/main/order_by_zerolength-4285.result b/mysql-test/main/order_by_zerolength-4285.result
index e6902105f20..95b4224f5a2 100644
--- a/mysql-test/main/order_by_zerolength-4285.result
+++ b/mysql-test/main/order_by_zerolength-4285.result
@@ -25,3 +25,23 @@ Warning 1292 Truncated incorrect CHAR(0) value: '8'
Warning 1292 Truncated incorrect CHAR(0) value: '9'
Warning 1292 Truncated incorrect CHAR(0) value: '10'
drop table t1;
+#
+# MDEV-17020: Assertion `length > 0' failed in ptr_compare upon ORDER BY with bad conversion
+#
+set @save_sql_mode= @@sql_mode;
+SET @@sql_mode= '';
+CREATE TABLE t1 (pk INT PRIMARY KEY);
+INSERT INTO t1 VALUES (1),(2);
+explain
+SELECT * FROM t1 ORDER BY 'foo', CONVERT(pk, CHAR(0)) LIMIT 2;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index NULL PRIMARY 4 NULL 2 Using index; Using filesort
+SELECT * FROM t1 ORDER BY 'foo', Cast(pk as CHAR(0)) LIMIT 2;
+pk
+1
+2
+Warnings:
+Warning 1292 Truncated incorrect CHAR(0) value: '1'
+Warning 1292 Truncated incorrect CHAR(0) value: '2'
+set @@sql_mode= @save_sql_mode;
+drop table t1;
diff --git a/mysql-test/main/order_by_zerolength-4285.test b/mysql-test/main/order_by_zerolength-4285.test
index 079ce8da71e..52672aa4595 100644
--- a/mysql-test/main/order_by_zerolength-4285.test
+++ b/mysql-test/main/order_by_zerolength-4285.test
@@ -13,3 +13,17 @@ select * from t1 order by now(), cast(pk as char(0));
--enable_warnings
show warnings;
drop table t1;
+
+--echo #
+--echo # MDEV-17020: Assertion `length > 0' failed in ptr_compare upon ORDER BY with bad conversion
+--echo #
+
+set @save_sql_mode= @@sql_mode;
+SET @@sql_mode= '';
+CREATE TABLE t1 (pk INT PRIMARY KEY);
+INSERT INTO t1 VALUES (1),(2);
+explain
+SELECT * FROM t1 ORDER BY 'foo', CONVERT(pk, CHAR(0)) LIMIT 2;
+SELECT * FROM t1 ORDER BY 'foo', Cast(pk as CHAR(0)) LIMIT 2;
+set @@sql_mode= @save_sql_mode;
+drop table t1;
diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result
index 69207f7ca23..4a3a9ed2380 100644
--- a/mysql-test/main/parser.result
+++ b/mysql-test/main/parser.result
@@ -1684,3 +1684,24 @@ SELECT without VERSIONING FROM t1
SELECT without WITHOUT FROM t1
DROP PROCEDURE p2;
DROP PROCEDURE p1;
+#
+# MDEV-16697: Fix difference between 32bit/windows and 64bit
+# systems in allowed select nest level
+#
+SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+1
+)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT
+1
+End of 10.3 tests
diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test
index 33316d42b95..1806816ca5d 100644
--- a/mysql-test/main/parser.test
+++ b/mysql-test/main/parser.test
@@ -1446,3 +1446,20 @@ CALL p2('without');
DROP PROCEDURE p2;
DROP PROCEDURE p1;
+
+
+--echo #
+--echo # MDEV-16697: Fix difference between 32bit/windows and 64bit
+--echo # systems in allowed select nest level
+--echo #
+ SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+(SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT (SELECT
+1
+)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
+--echo End of 10.3 tests
diff --git a/mysql-test/main/partition_error.result b/mysql-test/main/partition_error.result
index 349e9771367..868eb3b0924 100644
--- a/mysql-test/main/partition_error.result
+++ b/mysql-test/main/partition_error.result
@@ -1866,3 +1866,12 @@ pUpTo10 p-10sp1 This is a long comment (2050 ascii characters) 50 pUpTo10 part
pMax pMaxsp0 This is a long comment (2050 ascii characters) 50 pMax partition comment .80-!
pMax pMaxsp1 This is a long comment (2050 ascii characters) 50 pMax partition comment .80-!
DROP TABLE t1;
+CREATE OR REPLACE TABLE t1 (
+pk INT PRIMARY KEY,
+c CHAR(3) NOT NULL,
+v CHAR(4) AS (c) VIRTUAL
+) WITH SYSTEM VERSIONING PARTITION BY HASH(pk);
+INSERT INTO t1 (pk,c) VALUES (1,'foo'),(2,'bar');
+UPDATE t1 SET v = 'qux' WHERE pk = 2;
+ERROR HY000: The value specified for generated column 'v' in table 't1' ignored
+DROP TABLE t1;
diff --git a/mysql-test/main/partition_error.test b/mysql-test/main/partition_error.test
index 3ee54605c36..8739c93fe92 100644
--- a/mysql-test/main/partition_error.test
+++ b/mysql-test/main/partition_error.test
@@ -2074,3 +2074,21 @@ SELECT PARTITION_NAME, SUBPARTITION_NAME, PARTITION_COMMENT FROM INFORMATION_SCH
WHERE TABLE_NAME = 't1' AND TABLE_SCHEMA = 'test';
DROP TABLE t1;
+
+#
+# MDEV-16429
+# Assertion `!table || (!table->read_set
+# || bitmap_is_set(table->read_set, field_index))'
+# fails upon attempt to update virtual column on partitioned versioned table
+#
+CREATE OR REPLACE TABLE t1 (
+ pk INT PRIMARY KEY,
+ c CHAR(3) NOT NULL,
+ v CHAR(4) AS (c) VIRTUAL
+) WITH SYSTEM VERSIONING PARTITION BY HASH(pk);
+
+INSERT INTO t1 (pk,c) VALUES (1,'foo'),(2,'bar');
+-- error ER_WARNING_NON_DEFAULT_VALUE_FOR_GENERATED_COLUMN
+UPDATE t1 SET v = 'qux' WHERE pk = 2;
+
+DROP TABLE t1;
diff --git a/mysql-test/main/partition_explicit_prune.result b/mysql-test/main/partition_explicit_prune.result
index c6b3dd35e08..8780c75eba4 100644
--- a/mysql-test/main/partition_explicit_prune.result
+++ b/mysql-test/main/partition_explicit_prune.result
@@ -1872,3 +1872,22 @@ CREATE TABLE t2 LIKE t1 PARTITION (p0, p2);
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 'PARTITION (p0, p2)' at line 1
DROP TABLE t1;
SET @@default_storage_engine = @old_default_storage_engine;
+#
+# MDEV-14815 - Server crash or AddressSanitizer errors or valgrind warnings in thr_lock / has_old_lock upon FLUSH TABLES
+#
+CREATE TABLE t1 (i INT) ENGINE=MEMORY PARTITION BY RANGE (i) (PARTITION p0 VALUES LESS THAN (4), PARTITION pm VALUES LESS THAN MAXVALUE);
+CREATE TABLE t2 (i INT) ENGINE=MEMORY;
+LOCK TABLE t1 WRITE, t2 WRITE;
+SELECT * FROM t1 PARTITION (p0);
+i
+FLUSH TABLES;
+SELECT * FROM t1 PARTITION (p0);
+i
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+SELECT * FROM t1 PARTITION (p0);
+i
+ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
+SELECT * FROM t1 PARTITION (p0);
+i
+UNLOCK TABLES;
+DROP TABLE t1, t2;
diff --git a/mysql-test/main/partition_explicit_prune.test b/mysql-test/main/partition_explicit_prune.test
index 68b829fbcc3..b8b6e480ce9 100644
--- a/mysql-test/main/partition_explicit_prune.test
+++ b/mysql-test/main/partition_explicit_prune.test
@@ -858,3 +858,22 @@ CREATE TABLE t2 LIKE t1 PARTITION (p0, p2);
DROP TABLE t1;
SET @@default_storage_engine = @old_default_storage_engine;
+
+
+--echo #
+--echo # MDEV-14815 - Server crash or AddressSanitizer errors or valgrind warnings in thr_lock / has_old_lock upon FLUSH TABLES
+--echo #
+CREATE TABLE t1 (i INT) ENGINE=MEMORY PARTITION BY RANGE (i) (PARTITION p0 VALUES LESS THAN (4), PARTITION pm VALUES LESS THAN MAXVALUE);
+CREATE TABLE t2 (i INT) ENGINE=MEMORY;
+LOCK TABLE t1 WRITE, t2 WRITE;
+SELECT * FROM t1 PARTITION (p0);
+FLUSH TABLES;
+SELECT * FROM t1 PARTITION (p0);
+ALTER TABLE t1 TRUNCATE PARTITION p0;
+SELECT * FROM t1 PARTITION (p0);
+ALTER TABLE t1 EXCHANGE PARTITION p0 WITH TABLE t2;
+SELECT * FROM t1 PARTITION (p0);
+UNLOCK TABLES;
+
+# Cleanup
+DROP TABLE t1, t2;
diff --git a/mysql-test/main/partition_pruning.result b/mysql-test/main/partition_pruning.result
index 422132dd1c3..00bd24101d6 100644
--- a/mysql-test/main/partition_pruning.result
+++ b/mysql-test/main/partition_pruning.result
@@ -3484,3 +3484,36 @@ select * from t1 where (a = 1 AND b < 'd' AND (c = 'b' OR (c = 'c' AND d = 1)) O
a b c d
1 a b 1
drop table t1;
+#
+# MDEV-17493: Partition pruning doesn't work for nested outer joins
+#
+create table t0(a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (a int, b int, c int);
+insert into t1 select a,a,a from t0;
+create table t2 (a int, b int, c int);
+insert into t2 select a,a,a from t0;
+create table t3 (
+part_id int,
+a int
+) partition by list (part_id) (
+partition p0 values in (0),
+partition p1 values in (1),
+partition p2 values in (2),
+partition p3 values in (3),
+partition p4 values in (4)
+);
+insert into t3 select mod(a,5), a from t0;
+explain partitions
+select * from t1 left join t3 on (t1.a=t3.a and t3.part_id=3);
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10
+1 SIMPLE t3 p3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
+# The following should have partitions="p3", NOT p0,p1,p2,p3,p4:
+explain partitions
+select * from t1 left join (t3 join t2) on (t1.a=t3.a and t3.a=t2.b and t3.part_id=3);
+id select_type table partitions type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 NULL ALL NULL NULL NULL NULL 10
+1 SIMPLE t3 p3 ALL NULL NULL NULL NULL 2 Using where; Using join buffer (flat, BNL join)
+1 SIMPLE t2 NULL ALL NULL NULL NULL NULL 10 Using where; Using join buffer (incremental, BNL join)
+drop table t0,t1,t2,t3;
diff --git a/mysql-test/main/partition_pruning.test b/mysql-test/main/partition_pruning.test
index 9d72e9c0d01..2879b0eae6c 100644
--- a/mysql-test/main/partition_pruning.test
+++ b/mysql-test/main/partition_pruning.test
@@ -1535,4 +1535,35 @@ select * from t1 where (a = 1 AND b < 'd' AND (c = 'b' OR (c = 'c' AND d = 1)) O
(a = 1 AND b >= 'a' AND (c = 'c' OR (c = 'd' AND d = 2))));
drop table t1;
+--echo #
+--echo # MDEV-17493: Partition pruning doesn't work for nested outer joins
+--echo #
+
+create table t0(a int);
+insert into t0 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t1 (a int, b int, c int);
+insert into t1 select a,a,a from t0;
+create table t2 (a int, b int, c int);
+insert into t2 select a,a,a from t0;
+
+create table t3 (
+ part_id int,
+ a int
+) partition by list (part_id) (
+ partition p0 values in (0),
+ partition p1 values in (1),
+ partition p2 values in (2),
+ partition p3 values in (3),
+ partition p4 values in (4)
+);
+insert into t3 select mod(a,5), a from t0;
+
+explain partitions
+select * from t1 left join t3 on (t1.a=t3.a and t3.part_id=3);
+
+--echo # The following should have partitions="p3", NOT p0,p1,p2,p3,p4:
+explain partitions
+select * from t1 left join (t3 join t2) on (t1.a=t3.a and t3.a=t2.b and t3.part_id=3);
+
+drop table t0,t1,t2,t3;
diff --git a/mysql-test/main/plugin.result b/mysql-test/main/plugin.result
index 3a141a25b5c..38a03920039 100644
--- a/mysql-test/main/plugin.result
+++ b/mysql-test/main/plugin.result
@@ -331,3 +331,48 @@ UNINSTALL PLUGIN example;
RENAME TABLE t1 TO t2;
ERROR 42S02: Table 'test.t1' doesn't exist
DROP TABLE t1;
+#
+# INSTALL IF NOT EXISTS PLUGIN name SONAME library /
+# UNINSTALL IF EXISTS PLUGIN|SONAME name
+#
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+PLUGIN_NAME PLUGIN_STATUS PLUGIN_TYPE
+INSTALL PLUGIN IF NOT EXISTS example SONAME 'ha_example';
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+PLUGIN_NAME PLUGIN_STATUS PLUGIN_TYPE
+EXAMPLE ACTIVE STORAGE ENGINE
+INSTALL PLUGIN example SONAME 'ha_example';
+ERROR HY000: Plugin 'example' already installed
+INSTALL PLUGIN IF NOT EXISTS example SONAME 'ha_example';
+Warnings:
+Note 1968 Plugin 'example' already installed
+SHOW WARNINGS;
+Level Code Message
+Note 1968 Plugin 'example' already installed
+UNINSTALL PLUGIN IF EXISTS example;
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+PLUGIN_NAME PLUGIN_STATUS PLUGIN_TYPE
+UNINSTALL PLUGIN IF EXISTS example;
+Warnings:
+Note 1305 PLUGIN example does not exist
+SHOW WARNINGS;
+Level Code Message
+Note 1305 PLUGIN example does not exist
+UNINSTALL PLUGIN example;
+ERROR 42000: PLUGIN example does not exist
+INSTALL SONAME 'ha_example';
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+PLUGIN_NAME PLUGIN_STATUS PLUGIN_TYPE
+EXAMPLE ACTIVE STORAGE ENGINE
+UNUSABLE ACTIVE DAEMON
+UNINSTALL SONAME IF EXISTS 'ha_example';
+UNINSTALL SONAME IF EXISTS 'ha_example';
+Warnings:
+Note 1305 SONAME ha_example.so does not exist
+SHOW WARNINGS;
+Level Code Message
+Note 1305 SONAME ha_example.so does not exist
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+PLUGIN_NAME PLUGIN_STATUS PLUGIN_TYPE
+UNINSTALL SONAME 'ha_example';
+ERROR 42000: SONAME ha_example.so does not exist
diff --git a/mysql-test/main/plugin.test b/mysql-test/main/plugin.test
index 68c4d5afd64..273e1e064a5 100644
--- a/mysql-test/main/plugin.test
+++ b/mysql-test/main/plugin.test
@@ -265,3 +265,43 @@ UNINSTALL PLUGIN example;
--error ER_NO_SUCH_TABLE
RENAME TABLE t1 TO t2;
DROP TABLE t1;
+
+--echo #
+--echo # INSTALL IF NOT EXISTS PLUGIN name SONAME library /
+--echo # UNINSTALL IF EXISTS PLUGIN|SONAME name
+--echo #
+
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+INSTALL PLUGIN IF NOT EXISTS example SONAME 'ha_example';
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+
+--replace_regex /\.dll/.so/
+--error ER_PLUGIN_INSTALLED
+INSTALL PLUGIN example SONAME 'ha_example';
+
+INSTALL PLUGIN IF NOT EXISTS example SONAME 'ha_example';
+SHOW WARNINGS;
+
+UNINSTALL PLUGIN IF EXISTS example;
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+
+UNINSTALL PLUGIN IF EXISTS example;
+SHOW WARNINGS;
+
+--error 1305
+UNINSTALL PLUGIN example;
+
+INSTALL SONAME 'ha_example';
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+
+UNINSTALL SONAME IF EXISTS 'ha_example';
+
+--replace_regex /\.dll/.so/
+UNINSTALL SONAME IF EXISTS 'ha_example';
+--replace_regex /\.dll/.so/
+SHOW WARNINGS;
+select PLUGIN_NAME,PLUGIN_STATUS,PLUGIN_TYPE from information_schema.plugins where plugin_library like 'ha_example%';
+
+--replace_regex /\.dll/.so/
+--error 1305
+UNINSTALL SONAME 'ha_example';
diff --git a/mysql-test/main/plugin_auth.result b/mysql-test/main/plugin_auth.result
index e470cc010c0..899e0292142 100644
--- a/mysql-test/main/plugin_auth.result
+++ b/mysql-test/main/plugin_auth.result
@@ -30,7 +30,7 @@ proxies_priv CREATE TABLE `proxies_priv` (
`Timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`Host`,`User`,`Proxied_host`,`Proxied_user`),
KEY `Grantor` (`Grantor`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User proxy privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='User proxy privileges'
connect plug_con,localhost,plug,plug_dest;
connection plug_con;
select USER(),CURRENT_USER();
diff --git a/mysql-test/main/plugin_auth_qa.result b/mysql-test/main/plugin_auth_qa.result
index 4f274c45971..2353bc80f84 100644
--- a/mysql-test/main/plugin_auth_qa.result
+++ b/mysql-test/main/plugin_auth_qa.result
@@ -106,7 +106,7 @@ CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
plug test_plugin_server plug_dest
-plug_dest
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
DROP USER plug, plug_dest;
CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
@@ -116,7 +116,7 @@ DROP USER plug;
CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-plug_dest
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
DROP USER plug_dest;
GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
@@ -126,7 +126,7 @@ CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
plug test_plugin_server plug_dest
-plug_dest
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
DROP USER plug, plug_dest;
GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH test_plugin_server AS 'plug_dest';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
@@ -136,7 +136,7 @@ DROP USER plug;
CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-plug_dest
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
DROP USER plug_dest;
CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
@@ -146,7 +146,7 @@ GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest IDENTIFIED BY 'plug_dest_pas
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
plug test_plugin_server plug_dest
-plug_dest
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
DROP USER plug, plug_dest;
CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
@@ -156,7 +156,7 @@ DROP USER plug;
GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest IDENTIFIED BY 'plug_dest_passwd';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-plug_dest
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
DROP USER plug_dest;
CREATE USER plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH 'test_plugin_server' AS 'plug_dest';
@@ -175,7 +175,7 @@ plug test_plugin_server plug_dest
GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED BY 'plug_dest_passwd';
SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root';
user plugin authentication_string password
-plug *939AEE68989794C0F408277411C26055CDF41119
+plug mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
DROP USER plug;
GRANT ALL PRIVILEGES ON test_user_db.* TO plug IDENTIFIED WITH test_plugin_server AS 'plug_dest';
CREATE USER plug IDENTIFIED BY 'plug_dest_passwd';
@@ -209,7 +209,7 @@ DROP USER plüg;
CREATE USER plüg_dest IDENTIFIED BY 'plug_dest_passwd';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-plüg_dest
+plüg_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
DROP USER plüg_dest;
SET NAMES ascii;
CREATE USER 'plüg' IDENTIFIED WITH 'test_plugin_server' AS 'plüg_dest';
@@ -220,7 +220,7 @@ DROP USER 'plüg';
CREATE USER 'plüg_dest' IDENTIFIED BY 'plug_dest_passwd';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-pl??g_dest
+pl??g_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
DROP USER 'plüg_dest';
SET NAMES latin1;
========== test 1.1.1.5 ====================================
@@ -234,7 +234,7 @@ DROP USER 'plug';
CREATE USER 'plüg_dest' IDENTIFIED BY 'plug_dest_passwd';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-plüg_dest
+plüg_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
DROP USER 'plüg_dest';
SET NAMES utf8;
CREATE USER plüg IDENTIFIED WITH 'test_plügin_server' AS 'plüg_dest';
@@ -247,7 +247,7 @@ DROP USER 'plüg';
CREATE USER 'plüg_dest' IDENTIFIED BY 'plug_dest_passwd';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-plüg_dest
+plüg_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
DROP USER 'plüg_dest';
CREATE USER plüg IDENTIFIED WITH test_plugin_server AS 'plüg_dest';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
@@ -257,7 +257,7 @@ DROP USER plüg;
CREATE USER plüg_dest IDENTIFIED BY 'plug_dest_passwd';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-plüg_dest
+plüg_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
DROP USER plüg_dest;
========== test 1.1.1.2/1.1.2.2=============================
SET @auth_name= 'test_plugin_server';
@@ -277,7 +277,7 @@ DROP USER plug;
CREATE USER 'hh''s_plug_dest' IDENTIFIED BY 'plug_dest_passwd';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-hh's_plug_dest
+hh's_plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
DROP USER 'hh''s_plug_dest';
========== test 1.1.1.4 ====================================
CREATE USER plug IDENTIFIED WITH hh''s_test_plugin_server AS 'plug_dest';
@@ -293,7 +293,7 @@ GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest;
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
grant_user test_plugin_server plug_dest
-plug_dest
+plug_dest mysql_native_password
DROP USER grant_user,plug_dest;
set @save_sql_mode= @@sql_mode;
SET @@sql_mode=no_auto_create_user;
@@ -314,13 +314,13 @@ CREATE USER plug_dest IDENTIFIED BY 'plug_dest_passwd';
SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root';
user plugin authentication_string password
grant_user test_plugin_server plug_dest
-plug_dest *939AEE68989794C0F408277411C26055CDF41119
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
DROP USER plug_dest;
GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest IDENTIFIED BY 'plug_user_passwd';
SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root';
user plugin authentication_string password
grant_user test_plugin_server plug_dest
-plug_dest *560881EB651416CEF77314D07D55EDCD5FC1BD6D
+plug_dest mysql_native_password *560881EB651416CEF77314D07D55EDCD5FC1BD6D
DROP USER grant_user,plug_dest;
set @@sql_mode= @save_sql_mode;
DROP DATABASE test_user_db;
diff --git a/mysql-test/main/plugin_auth_qa_1.result b/mysql-test/main/plugin_auth_qa_1.result
index 42a7b1491c0..b04483722b8 100644
--- a/mysql-test/main/plugin_auth_qa_1.result
+++ b/mysql-test/main/plugin_auth_qa_1.result
@@ -20,7 +20,7 @@ GRANT ALL PRIVILEGES ON test_user_db.* TO plug_dest IDENTIFIED BY 'plug_dest_pas
GRANT PROXY ON plug_dest TO plug_user;
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-plug_dest
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
plug_user test_plugin_server plug_dest
1)
current_user()
@@ -71,7 +71,7 @@ GRANT PROXY ON new_dest TO plug_user;
ERROR 1045 (28000): Access denied for user 'plug_user'@'localhost' (using password: YES)
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-new_dest
+new_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
plug_user test_plugin_server plug_dest
DROP USER plug_user,new_dest;
CREATE USER plug_user
@@ -89,7 +89,7 @@ GRANT PROXY ON new_dest TO plug_user;
ERROR 1045 (28000): Access denied for user 'plug_user'@'localhost' (using password: YES)
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-new_dest
+new_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
plug_user test_plugin_server plug_dest
DROP USER plug_user,new_dest;
CREATE USER plug_user
@@ -111,13 +111,13 @@ connection default;
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
new_user test_plugin_server plug_dest
-plug_dest
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
disconnect plug_user;
UPDATE mysql.user SET user='plug_user' WHERE user='new_user';
FLUSH PRIVILEGES;
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-plug_dest
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
plug_user test_plugin_server plug_dest
DROP USER plug_dest,plug_user;
========== test 1.3 ========================================
@@ -133,34 +133,36 @@ connection default;
disconnect plug_user;
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-plug_dest
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
plug_user test_plugin_server plug_dest
UPDATE mysql.user SET user='new_user' WHERE user='plug_user';
FLUSH PRIVILEGES;
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
new_user test_plugin_server plug_dest
-plug_dest
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
UPDATE mysql.user SET authentication_string='new_dest' WHERE user='new_user';
FLUSH PRIVILEGES;
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
new_user test_plugin_server new_dest
-plug_dest
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
UPDATE mysql.user SET plugin='new_plugin_server' WHERE user='new_user';
FLUSH PRIVILEGES;
+Warnings:
+Warning 1524 Plugin 'new_plugin_server' is not loaded
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
new_user new_plugin_server new_dest
-plug_dest
-ERROR HY000: Plugin 'new_plugin_server' is not loaded
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
+ERROR 28000: Access denied for user 'new_user'@'localhost' (using password: YES)
UPDATE mysql.user SET plugin='test_plugin_server' WHERE user='new_user';
UPDATE mysql.user SET USER='new_dest' WHERE user='plug_dest';
FLUSH PRIVILEGES;
GRANT PROXY ON new_dest TO new_user;
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-new_dest
+new_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
new_user test_plugin_server new_dest
connect plug_user,localhost,new_user,new_dest;
select USER(),CURRENT_USER();
@@ -173,9 +175,9 @@ FLUSH PRIVILEGES;
CREATE USER new_dest IDENTIFIED BY 'new_dest_passwd';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-new_dest
+new_dest mysql_native_password *01422E86A6FFF84618914AF149F9AEF64B84170A
new_user test_plugin_server new_dest
-plug_dest
+plug_dest mysql_native_password *939AEE68989794C0F408277411C26055CDF41119
GRANT ALL PRIVILEGES ON test.* TO new_user;
connect plug_user,localhost,new_dest,new_dest_passwd;
select USER(),CURRENT_USER();
@@ -190,7 +192,7 @@ CREATE USER proxied_user IDENTIFIED BY 'proxied_user_passwd';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
test_plugin_server proxied_user
-proxied_user
+proxied_user mysql_native_password *D7A51428CD38DB3C5293B9321DA1228BFB1611DD
connect proxy_con,localhost,proxied_user,proxied_user_passwd;
SELECT USER(),CURRENT_USER();
USER() CURRENT_USER()
@@ -226,7 +228,7 @@ CREATE USER proxied_user IDENTIFIED BY 'proxied_user_passwd';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
test_plugin_server proxied_user
-proxied_user
+proxied_user mysql_native_password *D7A51428CD38DB3C5293B9321DA1228BFB1611DD
connect proxy_con,localhost,proxied_user,proxied_user_passwd;
SELECT USER(),CURRENT_USER();
USER() CURRENT_USER()
@@ -268,11 +270,11 @@ GRANT PROXY ON proxied_user_5 TO ''@'%%';
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
test_plugin_server proxied_user
-proxied_user_1
-proxied_user_2
-proxied_user_3
-proxied_user_4
-proxied_user_5
+proxied_user_1 mysql_native_password *551D5A5177FCC3340F7D2FB0F4D8D1EEA7F7EF71
+proxied_user_2 mysql_native_password *3D948F77C6A988AFDCA9755AB2A6724362557220
+proxied_user_3 mysql_native_password *41A18925D237DEE738C76581153990B037F462E3
+proxied_user_4 mysql_native_password *F990073A9B96FF535C2D0721406042B8751E593F
+proxied_user_5 mysql_native_password *5AA915C5D0B5B1336336FD2BF7768BC09FD1F5B2
connect proxy_con_1,localhost,proxied_user_1,'proxied_user_1_pwd';
connect proxy_con_2,localhost,proxied_user_2,proxied_user_2_pwd;
connect proxy_con_3,localhost,proxied_user_3,proxied_user_3_pwd;
diff --git a/mysql-test/main/plugin_auth_qa_1.test b/mysql-test/main/plugin_auth_qa_1.test
index b0b8ffb3544..4f45a8aced6 100644
--- a/mysql-test/main/plugin_auth_qa_1.test
+++ b/mysql-test/main/plugin_auth_qa_1.test
@@ -141,7 +141,7 @@ FLUSH PRIVILEGES;
--sorted_result
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
--disable_query_log
---error ER_PLUGIN_IS_NOT_LOADED
+--error ER_ACCESS_DENIED_ERROR
connect(plug_user,localhost,new_user,new_dest);
--enable_query_log
UPDATE mysql.user SET plugin='test_plugin_server' WHERE user='new_user';
diff --git a/mysql-test/main/plugin_auth_qa_2.result b/mysql-test/main/plugin_auth_qa_2.result
index fa88530be6a..ec62840ac4a 100644
--- a/mysql-test/main/plugin_auth_qa_2.result
+++ b/mysql-test/main/plugin_auth_qa_2.result
@@ -7,7 +7,7 @@ GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_1_dest identified by 'dest_pas
GRANT PROXY ON qa_test_1_dest TO qa_test_1_user;
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-qa_test_1_dest
+qa_test_1_dest mysql_native_password *DFCACE76914AD7BD801FC1A1ECF6562272621A22
qa_test_1_user qa_auth_interface qa_test_1_dest
SELECT @@proxy_user;
@@proxy_user
@@ -20,7 +20,7 @@ current_user() user() @@local.proxy_user @@local.external_user
qa_test_1_user@% qa_test_1_user@localhost NULL NULL
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-qa_test_1_dest
+qa_test_1_dest mysql_native_password *DFCACE76914AD7BD801FC1A1ECF6562272621A22
qa_test_1_user qa_auth_interface qa_test_1_dest
DROP USER qa_test_1_user;
DROP USER qa_test_1_dest;
@@ -33,8 +33,8 @@ GRANT PROXY ON qa_test_2_dest TO qa_test_2_user;
GRANT PROXY ON authenticated_as TO qa_test_2_user;
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-authenticated_as
-qa_test_2_dest
+authenticated_as mysql_native_password *DFCACE76914AD7BD801FC1A1ECF6562272621A22
+qa_test_2_dest mysql_native_password *DFCACE76914AD7BD801FC1A1ECF6562272621A22
qa_test_2_user qa_auth_interface qa_test_2_dest
SELECT @@proxy_user;
@@proxy_user
@@ -47,8 +47,8 @@ current_user() user() @@local.proxy_user @@local.external_user
authenticated_as@% user_name@localhost 'qa_test_2_user'@'%' externaluser
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-authenticated_as
-qa_test_2_dest
+authenticated_as mysql_native_password *DFCACE76914AD7BD801FC1A1ECF6562272621A22
+qa_test_2_dest mysql_native_password *DFCACE76914AD7BD801FC1A1ECF6562272621A22
qa_test_2_user qa_auth_interface qa_test_2_dest
DROP USER qa_test_2_user;
DROP USER qa_test_2_dest;
@@ -83,8 +83,8 @@ GRANT PROXY ON qa_test_5_dest TO qa_test_5_user;
GRANT PROXY ON qa_test_5_dest TO ''@'localhost';
SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root';
user plugin authentication_string password
- *DFCACE76914AD7BD801FC1A1ECF6562272621A22
-qa_test_5_dest *DFCACE76914AD7BD801FC1A1ECF6562272621A22
+ mysql_native_password *DFCACE76914AD7BD801FC1A1ECF6562272621A22
+qa_test_5_dest mysql_native_password *DFCACE76914AD7BD801FC1A1ECF6562272621A22
qa_test_5_user qa_auth_interface qa_test_5_dest
exec MYSQL -h localhost -P MASTER_MYPORT --user=qa_test_5_user --password=qa_test_5_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
ERROR 1045 (28000): Access denied for user 'qa_test_5_user'@'localhost' (using password: YES)
@@ -98,21 +98,21 @@ GRANT ALL PRIVILEGES ON test_user_db.* TO qa_test_6_dest identified by 'dest_pas
GRANT PROXY ON qa_test_6_dest TO qa_test_6_user;
SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root';
user plugin authentication_string password
-qa_test_6_dest *DFCACE76914AD7BD801FC1A1ECF6562272621A22
+qa_test_6_dest mysql_native_password *DFCACE76914AD7BD801FC1A1ECF6562272621A22
qa_test_6_user qa_auth_interface qa_test_6_dest
exec MYSQL -h localhost -P MASTER_MYPORT --user=qa_test_6_user --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
ERROR 1045 (28000): Access denied for user 'qa_test_6_user'@'localhost' (using password: YES)
GRANT PROXY ON qa_test_6_dest TO root IDENTIFIED WITH qa_auth_interface AS 'qa_test_6_dest';
SELECT user,plugin,authentication_string,password FROM mysql.user WHERE user != 'root';
user plugin authentication_string password
-qa_test_6_dest *DFCACE76914AD7BD801FC1A1ECF6562272621A22
+qa_test_6_dest mysql_native_password *DFCACE76914AD7BD801FC1A1ECF6562272621A22
qa_test_6_user qa_auth_interface qa_test_6_dest
exec MYSQL -h localhost -P MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
REVOKE PROXY ON qa_test_6_dest FROM root;
SELECT user,plugin,authentication_string FROM mysql.user WHERE user != 'root';
user plugin authentication_string
-qa_test_6_dest
+qa_test_6_dest mysql_native_password *DFCACE76914AD7BD801FC1A1ECF6562272621A22
qa_test_6_user qa_auth_interface qa_test_6_dest
exec MYSQL -h localhost -P MASTER_MYPORT --user=root --password=qa_test_6_dest test_user_db -e "SELECT current_user(),user(),@@local.proxy_user,@@local.external_user;" 2>&1
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
diff --git a/mysql-test/main/plugin_innodb.result b/mysql-test/main/plugin_innodb.result
index 48510ad8745..d8cc777d9cb 100644
--- a/mysql-test/main/plugin_innodb.result
+++ b/mysql-test/main/plugin_innodb.result
@@ -7,5 +7,5 @@ create table t1(a int) engine=example;
select * from t1;
a
drop table t1;
-alter table mysql.plugin engine=myisam;
+alter table mysql.plugin engine=aria;
uninstall plugin example;
diff --git a/mysql-test/main/plugin_innodb.test b/mysql-test/main/plugin_innodb.test
index fb5dd84b997..5700486b218 100644
--- a/mysql-test/main/plugin_innodb.test
+++ b/mysql-test/main/plugin_innodb.test
@@ -22,6 +22,6 @@ create table t1(a int) engine=example;
select * from t1;
drop table t1;
-alter table mysql.plugin engine=myisam;
+alter table mysql.plugin engine=aria;
uninstall plugin example;
diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result
index 10a617ea6c9..d619b213508 100644
--- a/mysql-test/main/ps.result
+++ b/mysql-test/main/ps.result
@@ -2134,12 +2134,9 @@ Database Table In_use Name_locked
mysql general_log 0 0
select Host, User from mysql.user limit 0;
Host User
-select Host, Db from mysql.host limit 0;
-Host Db
show open tables from mysql;
Database Table In_use Name_locked
mysql general_log 0 0
-mysql host 0 0
mysql user 0 0
call proc_1();
show open tables from mysql;
@@ -2147,12 +2144,9 @@ Database Table In_use Name_locked
mysql general_log 0 0
select Host, User from mysql.user limit 0;
Host User
-select Host, Db from mysql.host limit 0;
-Host Db
show open tables from mysql;
Database Table In_use Name_locked
mysql general_log 0 0
-mysql host 0 0
mysql user 0 0
call proc_1();
show open tables from mysql;
@@ -2160,12 +2154,9 @@ Database Table In_use Name_locked
mysql general_log 0 0
select Host, User from mysql.user limit 0;
Host User
-select Host, Db from mysql.host limit 0;
-Host Db
show open tables from mysql;
Database Table In_use Name_locked
mysql general_log 0 0
-mysql host 0 0
mysql user 0 0
call proc_1();
show open tables from mysql;
@@ -2173,12 +2164,9 @@ Database Table In_use Name_locked
mysql general_log 0 0
select Host, User from mysql.user limit 0;
Host User
-select Host, Db from mysql.host limit 0;
-Host Db
show open tables from mysql;
Database Table In_use Name_locked
mysql general_log 0 0
-mysql host 0 0
mysql user 0 0
flush tables;
create function func_1() returns int begin flush tables; return 1; end|
@@ -2191,12 +2179,9 @@ drop procedure proc_1;
flush tables;
select Host, User from mysql.user limit 0;
Host User
-select Host, Db from mysql.host limit 0;
-Host Db
show open tables from mysql;
Database Table In_use Name_locked
mysql general_log 0 0
-mysql host 0 0
mysql user 0 0
prepare abc from "flush tables";
execute abc;
@@ -2205,12 +2190,9 @@ Database Table In_use Name_locked
mysql general_log 0 0
select Host, User from mysql.user limit 0;
Host User
-select Host, Db from mysql.host limit 0;
-Host Db
show open tables from mysql;
Database Table In_use Name_locked
mysql general_log 0 0
-mysql host 0 0
mysql user 0 0
execute abc;
show open tables from mysql;
@@ -2218,12 +2200,9 @@ Database Table In_use Name_locked
mysql general_log 0 0
select Host, User from mysql.user limit 0;
Host User
-select Host, Db from mysql.host limit 0;
-Host Db
show open tables from mysql;
Database Table In_use Name_locked
mysql general_log 0 0
-mysql host 0 0
mysql user 0 0
execute abc;
show open tables from mysql;
@@ -2231,12 +2210,9 @@ Database Table In_use Name_locked
mysql general_log 0 0
select Host, User from mysql.user limit 0;
Host User
-select Host, Db from mysql.host limit 0;
-Host Db
show open tables from mysql;
Database Table In_use Name_locked
mysql general_log 0 0
-mysql host 0 0
mysql user 0 0
flush tables;
deallocate prepare abc;
@@ -5323,5 +5299,48 @@ DROP PROCEDURE p2;
DROP PROCEDURE p1;
DROP ROLE testrole;
#
+# MDEV-16992: prepare of CREATE TABLE, CREATE VIEW, DO, SET, CALL
+# statements with CTE containing materialized derived
+# (the bug is reproducible on 10.4)
+#
+prepare stmt from
+"CREATE TABLE t1 AS
+ WITH cte(a) AS (SELECT * FROM (SELECT 1) AS t) SELECT * FROM cte;";
+execute stmt;
+select * from t1;
+a
+1
+prepare stmt from
+"CREATE VIEW v1 AS
+ WITH cte(a) AS (SELECT * FROM (SELECT 1) AS t) SELECT * FROM cte;";
+execute stmt;
+select * from v1;
+a
+1
+prepare stmt from
+"DO (SELECT 1
+ FROM (WITH cte AS (SELECT * FROM (SELECT 1) AS t)
+ SELECT * FROM cte) AS tt);";
+execute stmt;
+prepare stmt from
+"SET @a = (SELECT 1
+ FROM (WITH cte AS (SELECT * FROM (SELECT 1) AS t)
+ SELECT * FROM cte) AS t);";
+execute stmt;
+create procedure p (i int) insert into t1 values(i);
+prepare stmt from
+"CALL p
+ ((SELECT 1
+ FROM (WITH cte AS (SELECT * FROM (SELECT 1) AS t)
+ SELECT * FROM cte) AS tt));";
+execute stmt;
+select * from t1;
+a
+1
+1
+drop procedure p;
+drop view v1;
+drop table t1;
+#
# End of 10.2 tests
#
diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test
index 79c08d62290..86ae11ccb61 100644
--- a/mysql-test/main/ps.test
+++ b/mysql-test/main/ps.test
@@ -2228,28 +2228,24 @@ flush tables;
--sorted_result
show open tables from mysql;
select Host, User from mysql.user limit 0;
-select Host, Db from mysql.host limit 0;
--sorted_result
show open tables from mysql;
call proc_1();
--sorted_result
show open tables from mysql;
select Host, User from mysql.user limit 0;
-select Host, Db from mysql.host limit 0;
--sorted_result
show open tables from mysql;
call proc_1();
--sorted_result
show open tables from mysql;
select Host, User from mysql.user limit 0;
-select Host, Db from mysql.host limit 0;
--sorted_result
show open tables from mysql;
call proc_1();
--sorted_result
show open tables from mysql;
select Host, User from mysql.user limit 0;
-select Host, Db from mysql.host limit 0;
--sorted_result
show open tables from mysql;
flush tables;
@@ -2269,7 +2265,6 @@ drop procedure proc_1;
--disable_ps_protocol
flush tables;
select Host, User from mysql.user limit 0;
-select Host, Db from mysql.host limit 0;
--sorted_result
show open tables from mysql;
--enable_ps_protocol
@@ -2279,21 +2274,18 @@ execute abc;
--sorted_result
show open tables from mysql;
select Host, User from mysql.user limit 0;
-select Host, Db from mysql.host limit 0;
--sorted_result
show open tables from mysql;
execute abc;
--sorted_result
show open tables from mysql;
select Host, User from mysql.user limit 0;
-select Host, Db from mysql.host limit 0;
--sorted_result
show open tables from mysql;
execute abc;
--sorted_result
show open tables from mysql;
select Host, User from mysql.user limit 0;
-select Host, Db from mysql.host limit 0;
--sorted_result
show open tables from mysql;
flush tables;
@@ -4785,5 +4777,51 @@ DROP PROCEDURE p1;
DROP ROLE testrole;
--echo #
+--echo # MDEV-16992: prepare of CREATE TABLE, CREATE VIEW, DO, SET, CALL
+--echo # statements with CTE containing materialized derived
+--echo # (the bug is reproducible on 10.4)
+--echo #
+
+--enable_result_log
+
+prepare stmt from
+"CREATE TABLE t1 AS
+ WITH cte(a) AS (SELECT * FROM (SELECT 1) AS t) SELECT * FROM cte;";
+execute stmt;
+select * from t1;
+
+prepare stmt from
+"CREATE VIEW v1 AS
+ WITH cte(a) AS (SELECT * FROM (SELECT 1) AS t) SELECT * FROM cte;";
+execute stmt;
+select * from v1;
+
+prepare stmt from
+"DO (SELECT 1
+ FROM (WITH cte AS (SELECT * FROM (SELECT 1) AS t)
+ SELECT * FROM cte) AS tt);";
+execute stmt;
+
+prepare stmt from
+"SET @a = (SELECT 1
+ FROM (WITH cte AS (SELECT * FROM (SELECT 1) AS t)
+ SELECT * FROM cte) AS t);";
+execute stmt;
+
+create procedure p (i int) insert into t1 values(i);
+
+prepare stmt from
+"CALL p
+ ((SELECT 1
+ FROM (WITH cte AS (SELECT * FROM (SELECT 1) AS t)
+ SELECT * FROM cte) AS tt));";
+execute stmt;
+select * from t1;
+
+drop procedure p;
+drop view v1;
+drop table t1;
+
+--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/main/query_cache.result b/mysql-test/main/query_cache.result
index e1123b1cb8b..f5d8b5eb461 100644
--- a/mysql-test/main/query_cache.result
+++ b/mysql-test/main/query_cache.result
@@ -967,19 +967,19 @@ INSERT INTO t1 VALUES ('20050326');
INSERT INTO t1 VALUES ('20050325');
SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050327 invalid';
COUNT(*)
-0
+1
Warnings:
-Warning 1292 Incorrect datetime value: '20050327 invalid'
+Warning 1292 Truncated incorrect date value: '20050327 invalid'
SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050328 invalid';
COUNT(*)
-0
+1
Warnings:
-Warning 1292 Incorrect datetime value: '20050328 invalid'
+Warning 1292 Truncated incorrect date value: '20050328 invalid'
SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050327 invalid';
COUNT(*)
-0
+1
Warnings:
-Warning 1292 Incorrect datetime value: '20050327 invalid'
+Warning 1292 Truncated incorrect date value: '20050327 invalid'
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
diff --git a/mysql-test/main/query_cache_innodb.result b/mysql-test/main/query_cache_innodb.result
index 643a065612f..146a6fbc289 100644
--- a/mysql-test/main/query_cache_innodb.result
+++ b/mysql-test/main/query_cache_innodb.result
@@ -84,7 +84,7 @@ t2id id
use test;
drop database `#mysql50#-`;
SET NAMES default;
-FOUND 12 /\[ERROR\] Invalid \(old\?\) table or database name/ in mysqld.1.err
+FOUND 8 /\[ERROR\] Invalid \(old\?\) table or database name/ in mysqld.1.err
set global query_cache_type=DEFAULT;
set global query_cache_size=DEFAULT;
End of 10.2 tests
diff --git a/mysql-test/main/range.result b/mysql-test/main/range.result
index e2996b963bc..50de308045b 100644
--- a/mysql-test/main/range.result
+++ b/mysql-test/main/range.result
@@ -1048,30 +1048,6 @@ select a, hex(filler) from t1 where a not between 'b' and 'b';
a hex(filler)
a 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
drop table t1,t2,t3;
-create table t1 (a int);
-insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-create table t2 (a int, key(a));
-insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C;
-set @a="select * from t2 force index (a) where a NOT IN(0";
-select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z;
-count(*)
-1000
-set @a=concat(@a, ')');
-insert into t2 values (11),(13),(15);
-set @b= concat("explain ", @a);
-prepare stmt1 from @b;
-execute stmt1;
-id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 index NULL a 5 NULL 1003 Using where; Using index
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2
-3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
-prepare stmt1 from @a;
-execute stmt1;
-a
-11
-13
-15
-drop table t1, t2;
CREATE TABLE t1 (
id int NOT NULL DEFAULT '0',
b int NOT NULL DEFAULT '0',
@@ -1125,7 +1101,7 @@ id select_type table type possible_keys key key_len ref rows Extra
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
item started price
Warnings:
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00'
+Warning 1292 Truncated incorrect datetime value: '2005-12-01 24:00:00'
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
item started price
A1 2005-11-01 08:00:00 1000.000
@@ -1137,7 +1113,7 @@ id select_type table type possible_keys key key_len ref rows Extra
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
item started price
Warnings:
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00'
+Warning 1292 Truncated incorrect datetime value: '2005-12-01 24:00:00'
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
item started price
A1 2005-11-01 08:00:00 1000.000
@@ -1587,7 +1563,7 @@ str_to_date('2007-10-00', '%Y-%m-%d') >= '' AND
str_to_date('2007-10-00', '%Y-%m-%d') <= '2007/10/20'
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND
str_to_date('2007-20-00', '%Y-%m-%d') <= '';
str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND
@@ -1602,7 +1578,7 @@ SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20';
str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND '';
str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND ''
NULL
@@ -3005,5 +2981,46 @@ deallocate prepare stmt;
set optimizer_switch=@save_optimizer_switch;
drop table t1,t2,t3;
#
+# MDEV-16934: using system variable eq_range_index_dive_limit
+# to reduce the number of index dives
+#
+create table t1 (a int, b varchar(31), index idx(a));
+insert into t1 values
+(7,'xxxx'), (1,'yy'), (3,'aaa'), (1,'bbb'), (2,'zz'),
+(4,'vvvvv'), (7,'ddd'), (9,'zzzzz'), (1,'cc'), (5,'ffff');
+insert into t1 select a+10, concat(b,'zz') from t1;
+insert into t1 select a+15, concat(b,'yy') from t1;
+insert into t1 select a+100, concat(b,'xx') from t1;
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+select cast(count(a)/count(distinct a) as unsigned) as rec_per_key from t1;
+rec_per_key
+2
+set eq_range_index_dive_limit=0;
+explain select * from t1 where a in (8, 15, 31, 1, 9);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx idx 5 NULL 7 Using index condition
+select * from t1 where a in (8, 15, 31, 1, 9);
+a b
+1 yy
+1 bbb
+1 cc
+9 zzzzz
+15 ffffzz
+set eq_range_index_dive_limit=2;
+explain select * from t1 where a in (8, 15, 31, 1, 9);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx idx 5 NULL 10 Using index condition
+select * from t1 where a in (8, 15, 31, 1, 9);
+a b
+1 yy
+1 bbb
+1 cc
+9 zzzzz
+15 ffffzz
+set eq_range_index_dive_limit=default;
+drop table t1;
+#
# End of 10.2 tests
#
diff --git a/mysql-test/main/range.test b/mysql-test/main/range.test
index 36e0e32b28b..bd2299bac5f 100644
--- a/mysql-test/main/range.test
+++ b/mysql-test/main/range.test
@@ -863,30 +863,6 @@ select a, hex(filler) from t1 where a not between 'b' and 'b';
drop table t1,t2,t3;
#
-# BUG#21282
-#
-create table t1 (a int);
-insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-create table t2 (a int, key(a));
-insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C;
-
-set @a="select * from t2 force index (a) where a NOT IN(0";
-select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z;
-set @a=concat(@a, ')');
-
-insert into t2 values (11),(13),(15);
-
-set @b= concat("explain ", @a);
-
-prepare stmt1 from @b;
-execute stmt1;
-
-prepare stmt1 from @a;
-execute stmt1;
-
-drop table t1, t2;
-
-#
# Bug #18165: range access for BETWEEN with a constant for the first argument
#
@@ -2042,5 +2018,38 @@ set optimizer_switch=@save_optimizer_switch;
drop table t1,t2,t3;
--echo #
+--echo # MDEV-16934: using system variable eq_range_index_dive_limit
+--echo # to reduce the number of index dives
+--echo #
+
+create table t1 (a int, b varchar(31), index idx(a));
+
+insert into t1 values
+ (7,'xxxx'), (1,'yy'), (3,'aaa'), (1,'bbb'), (2,'zz'),
+ (4,'vvvvv'), (7,'ddd'), (9,'zzzzz'), (1,'cc'), (5,'ffff');
+insert into t1 select a+10, concat(b,'zz') from t1;
+insert into t1 select a+15, concat(b,'yy') from t1;
+insert into t1 select a+100, concat(b,'xx') from t1;
+
+analyze table t1;
+
+select cast(count(a)/count(distinct a) as unsigned) as rec_per_key from t1;
+
+let $q=
+select * from t1 where a in (8, 15, 31, 1, 9);
+
+set eq_range_index_dive_limit=0;
+eval explain $q;
+eval $q;
+
+set eq_range_index_dive_limit=2;
+eval explain $q;
+eval $q;
+
+set eq_range_index_dive_limit=default;
+
+drop table t1;
+
+--echo #
--echo # End of 10.2 tests
--echo #
diff --git a/mysql-test/main/range_debug.result b/mysql-test/main/range_debug.result
new file mode 100644
index 00000000000..5597671071e
--- /dev/null
+++ b/mysql-test/main/range_debug.result
@@ -0,0 +1,24 @@
+create table t1 (a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2 (a int, key(a));
+insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C;
+set in_predicate_conversion_threshold= 2000;
+set @a="select * from t2 force index (a) where a NOT IN(0";
+select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z;
+count(*)
+1000
+set @a=concat(@a, ')');
+insert into t2 values (11),(13),(15);
+set @b= concat("explain ", @a);
+prepare stmt1 from @b;
+execute stmt1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 index a a 5 NULL 1003 Using where; Using index
+prepare stmt1 from @a;
+execute stmt1;
+a
+11
+13
+15
+set in_predicate_conversion_threshold= default;
+drop table t1, t2;
diff --git a/mysql-test/main/range_debug.test b/mysql-test/main/range_debug.test
new file mode 100644
index 00000000000..ef331cdc84f
--- /dev/null
+++ b/mysql-test/main/range_debug.test
@@ -0,0 +1,30 @@
+source include/have_debug.inc;
+#
+# BUG#21282
+#
+create table t1 (a int);
+insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
+create table t2 (a int, key(a));
+insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C;
+
+set in_predicate_conversion_threshold= 2000;
+
+set @a="select * from t2 force index (a) where a NOT IN(0";
+select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z;
+set @a=concat(@a, ')');
+
+insert into t2 values (11),(13),(15);
+
+set @b= concat("explain ", @a);
+
+prepare stmt1 from @b;
+execute stmt1;
+
+prepare stmt1 from @a;
+execute stmt1;
+
+set in_predicate_conversion_threshold= default;
+
+drop table t1, t2;
+
+
diff --git a/mysql-test/main/range_mrr_icp.result b/mysql-test/main/range_mrr_icp.result
index 629d183bee7..a6c57378f9c 100644
--- a/mysql-test/main/range_mrr_icp.result
+++ b/mysql-test/main/range_mrr_icp.result
@@ -1050,30 +1050,6 @@ select a, hex(filler) from t1 where a not between 'b' and 'b';
a hex(filler)
a 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
drop table t1,t2,t3;
-create table t1 (a int);
-insert into t1 values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
-create table t2 (a int, key(a));
-insert into t2 select 2*(A.a + 10*(B.a + 10*C.a)) from t1 A, t1 B, t1 C;
-set @a="select * from t2 force index (a) where a NOT IN(0";
-select count(*) from (select @a:=concat(@a, ',', a) from t2 ) Z;
-count(*)
-1000
-set @a=concat(@a, ')');
-insert into t2 values (11),(13),(15);
-set @b= concat("explain ", @a);
-prepare stmt1 from @b;
-execute stmt1;
-id select_type table type possible_keys key key_len ref rows Extra
-1 PRIMARY t2 index NULL a 5 NULL 1003 Using where; Using index
-2 MATERIALIZED <derived3> ALL NULL NULL NULL NULL 2
-3 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
-prepare stmt1 from @a;
-execute stmt1;
-a
-11
-13
-15
-drop table t1, t2;
CREATE TABLE t1 (
id int NOT NULL DEFAULT '0',
b int NOT NULL DEFAULT '0',
@@ -1127,7 +1103,7 @@ id select_type table type possible_keys key key_len ref rows Extra
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
item started price
Warnings:
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00'
+Warning 1292 Truncated incorrect datetime value: '2005-12-01 24:00:00'
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
item started price
A1 2005-11-01 08:00:00 1000.000
@@ -1139,7 +1115,7 @@ id select_type table type possible_keys key key_len ref rows Extra
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-01 24:00:00';
item started price
Warnings:
-Warning 1292 Incorrect datetime value: '2005-12-01 24:00:00'
+Warning 1292 Truncated incorrect datetime value: '2005-12-01 24:00:00'
SELECT * FROM t1 WHERE item='A1' AND started<='2005-12-02 00:00:00';
item started price
A1 2005-11-01 08:00:00 1000.000
@@ -1589,7 +1565,7 @@ str_to_date('2007-10-00', '%Y-%m-%d') >= '' AND
str_to_date('2007-10-00', '%Y-%m-%d') <= '2007/10/20'
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND
str_to_date('2007-20-00', '%Y-%m-%d') <= '';
str_to_date('2007-20-00', '%Y-%m-%d') >= '2007/10/20' AND
@@ -1604,7 +1580,7 @@ SELECT str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20';
str_to_date('2007-10-00', '%Y-%m-%d') BETWEEN '' AND '2007/10/20'
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND '';
str_to_date('2007-20-00', '%Y-%m-%d') BETWEEN '2007/10/20' AND ''
NULL
@@ -3017,6 +2993,47 @@ deallocate prepare stmt;
set optimizer_switch=@save_optimizer_switch;
drop table t1,t2,t3;
#
+# MDEV-16934: using system variable eq_range_index_dive_limit
+# to reduce the number of index dives
+#
+create table t1 (a int, b varchar(31), index idx(a));
+insert into t1 values
+(7,'xxxx'), (1,'yy'), (3,'aaa'), (1,'bbb'), (2,'zz'),
+(4,'vvvvv'), (7,'ddd'), (9,'zzzzz'), (1,'cc'), (5,'ffff');
+insert into t1 select a+10, concat(b,'zz') from t1;
+insert into t1 select a+15, concat(b,'yy') from t1;
+insert into t1 select a+100, concat(b,'xx') from t1;
+analyze table t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status OK
+select cast(count(a)/count(distinct a) as unsigned) as rec_per_key from t1;
+rec_per_key
+2
+set eq_range_index_dive_limit=0;
+explain select * from t1 where a in (8, 15, 31, 1, 9);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx idx 5 NULL 7 Using index condition; Rowid-ordered scan
+select * from t1 where a in (8, 15, 31, 1, 9);
+a b
+1 yy
+1 bbb
+9 zzzzz
+1 cc
+15 ffffzz
+set eq_range_index_dive_limit=2;
+explain select * from t1 where a in (8, 15, 31, 1, 9);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range idx idx 5 NULL 10 Using index condition; Rowid-ordered scan
+select * from t1 where a in (8, 15, 31, 1, 9);
+a b
+1 yy
+1 bbb
+9 zzzzz
+1 cc
+15 ffffzz
+set eq_range_index_dive_limit=default;
+drop table t1;
+#
# End of 10.2 tests
#
set optimizer_switch=@mrr_icp_extra_tmp;
diff --git a/mysql-test/main/rename.result b/mysql-test/main/rename.result
index 3ee9dd593d4..da9e4b62ecd 100644
--- a/mysql-test/main/rename.result
+++ b/mysql-test/main/rename.result
@@ -144,3 +144,7 @@ select * from t2;
a
1
drop table tmp,t2;
+create table t1 (a int) engine=memory;
+rename table t1 to non_existent.t2;
+ERROR 42000: Unknown database 'non_existent'
+drop table t1;
diff --git a/mysql-test/main/rename.test b/mysql-test/main/rename.test
index 67732d5b5b9..215ecbcbb18 100644
--- a/mysql-test/main/rename.test
+++ b/mysql-test/main/rename.test
@@ -141,3 +141,10 @@ select * from tmp;
select * from t2;
drop table tmp,t2;
+#
+# MDEV-11741 handler::ha_reset(): Assertion `bitmap_is_set_all(&table->s->all_set)' failed or server crash in mi_reset or buffer overrun or unexpected ER_CANT_REMOVE_ALL_FIELDS
+#
+create table t1 (a int) engine=memory;
+--error ER_BAD_DB_ERROR
+rename table t1 to non_existent.t2;
+drop table t1;
diff --git a/mysql-test/main/repair.result b/mysql-test/main/repair.result
index 75d7525ee71..18a7cf509c4 100644
--- a/mysql-test/main/repair.result
+++ b/mysql-test/main/repair.result
@@ -78,7 +78,7 @@ INSERT INTO t1 VALUES
('0'),('0'),('0'),('0'),('0'),('0'),('0');
Warnings:
Error 1034 myisam_sort_buffer_size is too small. X
-Error 1034 Number of rows changed from 0 to 157
+Warning 1034 Number of rows changed from 0 to 157
SET myisam_repair_threads=2;
REPAIR TABLE t1;
Table Op Msg_type Msg_text
diff --git a/mysql-test/main/select.result b/mysql-test/main/select.result
index 9b6a570717b..94a92315acc 100644
--- a/mysql-test/main/select.result
+++ b/mysql-test/main/select.result
@@ -2118,8 +2118,8 @@ INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
Warnings:
-Warning 1292 Incorrect datetime value: 'wrong-date-value'
-Warning 1292 Incorrect datetime value: 'wrong-date-value'
+Warning 1292 Truncated incorrect datetime value: 'wrong-date-value'
+Warning 1292 Truncated incorrect datetime value: 'wrong-date-value'
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
DROP TABLE t1,t2;
@@ -4111,7 +4111,7 @@ select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6';
str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'
0
Warnings:
-Warning 1292 Incorrect datetime value: '2007/10/2000:00:00 GMT-6'
+Warning 1292 Truncated incorrect datetime value: '2007/10/2000:00:00 GMT-6'
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6';
str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'
1
@@ -4198,7 +4198,7 @@ select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20';
str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'
0
@@ -4212,22 +4212,22 @@ select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '';
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''
0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
select str_to_date('1','%Y-%m-%d') = '1';
str_to_date('1','%Y-%m-%d') = '1'
0
Warnings:
-Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
select str_to_date('1','%Y-%m-%d') = '1';
str_to_date('1','%Y-%m-%d') = '1'
0
Warnings:
-Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
select str_to_date('','%Y-%m-%d') = '';
str_to_date('','%Y-%m-%d') = ''
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
select str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and '2001-01-01';
str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and '2001-01-01'
1
@@ -5282,30 +5282,30 @@ SELECT * FROM t1 HAVING f1 = 'zz';
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'zz'
+Warning 1292 Truncated incorrect datetime value: 'zz'
SELECT * FROM t1 HAVING f1 <= 'aa' ;
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'aa'
+Warning 1292 Truncated incorrect datetime value: 'aa'
SELECT * FROM t1 HAVING f1 = 'zz' AND f1 <= 'aa' ;
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'zz'
-Warning 1292 Incorrect datetime value: 'aa'
+Warning 1292 Truncated incorrect datetime value: 'zz'
+Warning 1292 Truncated incorrect datetime value: 'aa'
SELECT * FROM t1 WHERE f1 = 'zz' AND f1 <= 'aa' ;
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'zz'
-Warning 1292 Incorrect datetime value: 'aa'
+Warning 1292 Truncated incorrect datetime value: 'zz'
+Warning 1292 Truncated incorrect datetime value: 'aa'
SELECT * FROM v1 HAVING f1 = 'zz' AND f1 <= 'aa' ;
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'zz'
-Warning 1292 Incorrect datetime value: 'aa'
+Warning 1292 Truncated incorrect datetime value: 'zz'
+Warning 1292 Truncated incorrect datetime value: 'aa'
DROP TABLE t1;
DROP VIEW v1;
#
diff --git a/mysql-test/main/select_jcl6.result b/mysql-test/main/select_jcl6.result
index d78fad15da1..b45fb8c4c10 100644
--- a/mysql-test/main/select_jcl6.result
+++ b/mysql-test/main/select_jcl6.result
@@ -2129,8 +2129,8 @@ INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
Warnings:
-Warning 1292 Incorrect datetime value: 'wrong-date-value'
-Warning 1292 Incorrect datetime value: 'wrong-date-value'
+Warning 1292 Truncated incorrect datetime value: 'wrong-date-value'
+Warning 1292 Truncated incorrect datetime value: 'wrong-date-value'
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
DROP TABLE t1,t2;
@@ -4122,7 +4122,7 @@ select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6';
str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'
0
Warnings:
-Warning 1292 Incorrect datetime value: '2007/10/2000:00:00 GMT-6'
+Warning 1292 Truncated incorrect datetime value: '2007/10/2000:00:00 GMT-6'
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6';
str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'
1
@@ -4209,7 +4209,7 @@ select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20';
str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'
0
@@ -4223,22 +4223,22 @@ select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '';
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''
0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
select str_to_date('1','%Y-%m-%d') = '1';
str_to_date('1','%Y-%m-%d') = '1'
0
Warnings:
-Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
select str_to_date('1','%Y-%m-%d') = '1';
str_to_date('1','%Y-%m-%d') = '1'
0
Warnings:
-Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
select str_to_date('','%Y-%m-%d') = '';
str_to_date('','%Y-%m-%d') = ''
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
select str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and '2001-01-01';
str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and '2001-01-01'
1
@@ -5293,30 +5293,30 @@ SELECT * FROM t1 HAVING f1 = 'zz';
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'zz'
+Warning 1292 Truncated incorrect datetime value: 'zz'
SELECT * FROM t1 HAVING f1 <= 'aa' ;
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'aa'
+Warning 1292 Truncated incorrect datetime value: 'aa'
SELECT * FROM t1 HAVING f1 = 'zz' AND f1 <= 'aa' ;
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'zz'
-Warning 1292 Incorrect datetime value: 'aa'
+Warning 1292 Truncated incorrect datetime value: 'zz'
+Warning 1292 Truncated incorrect datetime value: 'aa'
SELECT * FROM t1 WHERE f1 = 'zz' AND f1 <= 'aa' ;
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'zz'
-Warning 1292 Incorrect datetime value: 'aa'
+Warning 1292 Truncated incorrect datetime value: 'zz'
+Warning 1292 Truncated incorrect datetime value: 'aa'
SELECT * FROM v1 HAVING f1 = 'zz' AND f1 <= 'aa' ;
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'zz'
-Warning 1292 Incorrect datetime value: 'aa'
+Warning 1292 Truncated incorrect datetime value: 'zz'
+Warning 1292 Truncated incorrect datetime value: 'aa'
DROP TABLE t1;
DROP VIEW v1;
#
diff --git a/mysql-test/main/select_pkeycache.result b/mysql-test/main/select_pkeycache.result
index 9b6a570717b..94a92315acc 100644
--- a/mysql-test/main/select_pkeycache.result
+++ b/mysql-test/main/select_pkeycache.result
@@ -2118,8 +2118,8 @@ INSERT INTO t2 VALUES (1,3,10,'2002-06-01 08:00:00',35),(1,3,1010,'2002-06-01 12
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= 'wrong-date-value' AND b.sampletime < 'wrong-date-value' AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
Warnings:
-Warning 1292 Incorrect datetime value: 'wrong-date-value'
-Warning 1292 Incorrect datetime value: 'wrong-date-value'
+Warning 1292 Truncated incorrect datetime value: 'wrong-date-value'
+Warning 1292 Truncated incorrect datetime value: 'wrong-date-value'
SELECT a.gvid, (SUM(CASE b.sampletid WHEN 140 THEN b.samplevalue ELSE 0 END)) as the_success,(SUM(CASE b.sampletid WHEN 141 THEN b.samplevalue ELSE 0 END)) as the_fail,(SUM(CASE b.sampletid WHEN 142 THEN b.samplevalue ELSE 0 END)) as the_size,(SUM(CASE b.sampletid WHEN 143 THEN b.samplevalue ELSE 0 END)) as the_time FROM t1 a, t2 b WHERE a.hmid = b.hmid AND a.volid = b.volid AND b.sampletime >= NULL AND b.sampletime < NULL AND b.sampletid IN (140, 141, 142, 143) GROUP BY a.gvid;
gvid the_success the_fail the_size the_time
DROP TABLE t1,t2;
@@ -4111,7 +4111,7 @@ select str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6';
str_to_date('2007-10-09','%Y-%m-%d') <= '2007/10/2000:00:00 GMT-6'
0
Warnings:
-Warning 1292 Incorrect datetime value: '2007/10/2000:00:00 GMT-6'
+Warning 1292 Truncated incorrect datetime value: '2007/10/2000:00:00 GMT-6'
select str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6';
str_to_date('2007-10-01','%Y-%m-%d') = '2007-10-1 00:00:00 GMT-6'
1
@@ -4198,7 +4198,7 @@ select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
select str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20';
str_to_date('','%Y-%m-%d') between '2007/10/01' and '2007/10/20'
0
@@ -4212,22 +4212,22 @@ select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '';
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = ''
0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
select str_to_date('1','%Y-%m-%d') = '1';
str_to_date('1','%Y-%m-%d') = '1'
0
Warnings:
-Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
select str_to_date('1','%Y-%m-%d') = '1';
str_to_date('1','%Y-%m-%d') = '1'
0
Warnings:
-Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
select str_to_date('','%Y-%m-%d') = '';
str_to_date('','%Y-%m-%d') = ''
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
select str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and '2001-01-01';
str_to_date('2000-01-01','%Y-%m-%d') between '1000-01-01' and '2001-01-01'
1
@@ -5282,30 +5282,30 @@ SELECT * FROM t1 HAVING f1 = 'zz';
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'zz'
+Warning 1292 Truncated incorrect datetime value: 'zz'
SELECT * FROM t1 HAVING f1 <= 'aa' ;
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'aa'
+Warning 1292 Truncated incorrect datetime value: 'aa'
SELECT * FROM t1 HAVING f1 = 'zz' AND f1 <= 'aa' ;
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'zz'
-Warning 1292 Incorrect datetime value: 'aa'
+Warning 1292 Truncated incorrect datetime value: 'zz'
+Warning 1292 Truncated incorrect datetime value: 'aa'
SELECT * FROM t1 WHERE f1 = 'zz' AND f1 <= 'aa' ;
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'zz'
-Warning 1292 Incorrect datetime value: 'aa'
+Warning 1292 Truncated incorrect datetime value: 'zz'
+Warning 1292 Truncated incorrect datetime value: 'aa'
SELECT * FROM v1 HAVING f1 = 'zz' AND f1 <= 'aa' ;
f1
0000-00-00
Warnings:
-Warning 1292 Incorrect datetime value: 'zz'
-Warning 1292 Incorrect datetime value: 'aa'
+Warning 1292 Truncated incorrect datetime value: 'zz'
+Warning 1292 Truncated incorrect datetime value: 'aa'
DROP TABLE t1;
DROP VIEW v1;
#
diff --git a/mysql-test/main/selectivity.result b/mysql-test/main/selectivity.result
index aff14b23ccb..00907235ecc 100644
--- a/mysql-test/main/selectivity.result
+++ b/mysql-test/main/selectivity.result
@@ -782,9 +782,9 @@ set optimizer_use_condition_selectivity=3;
explain extended
select * from t1 where a < 1 and a > 7;
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
+1 SIMPLE t1 ALL NULL NULL NULL NULL 8 100.00 Using where
Warnings:
-Note 1003 select 7 AS `a` from `test`.`t1` where 0
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` < 1 and `test`.`t1`.`a` > 7
select * from t1 where a < 1 and a > 7;
a
drop table t1;
@@ -1506,9 +1506,9 @@ col1
explain extended
select * from t2 where col1 < 'b' and col1 > 'd';
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
+1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where
Warnings:
-Note 1003 select 'd' AS `col1` from `test`.`t2` where 0
+Note 1003 select `test`.`t2`.`col1` AS `col1` from `test`.`t2` where `test`.`t2`.`col1` < 'b' and `test`.`t2`.`col1` > 'd'
drop table t1,t2;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set use_stat_tables=@save_use_stat_tables;
@@ -1595,3 +1595,43 @@ drop table t1,t0;
set histogram_size=@save_histogram_size;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set use_stat_tables=@save_use_stat_tables;
+#
+# MDEV-15306: Wrong/Unexpected result with the value
+# optimizer_use_condition_selectivity set to 4
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+CREATE FUNCTION f1() RETURNS INT DETERMINISTIC
+BEGIN
+SET @cnt := @cnt + 1;
+RETURN 1;
+END;|
+set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
+set @save_use_stat_tables= @@use_stat_tables;
+set @@use_stat_tables='complementary';
+set @@optimizer_use_condition_selectivity=4;
+SET @cnt= 0;
+SELECT * FROM t1 WHERE a = f1();
+a
+1
+SELECT @cnt;
+@cnt
+1
+set @@use_stat_tables='preferably';
+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
+SET @cnt := 0;
+set @@optimizer_use_condition_selectivity=4;
+SELECT * FROM t1 WHERE a = f1();
+a
+1
+SELECT @cnt;
+@cnt
+2
+alter table t1 force;
+set @@use_stat_tables= @save_use_stat_tables;
+set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+drop table t1;
+drop function f1;
diff --git a/mysql-test/main/selectivity.test b/mysql-test/main/selectivity.test
index cf12bdaea21..3df49456332 100644
--- a/mysql-test/main/selectivity.test
+++ b/mysql-test/main/selectivity.test
@@ -1066,3 +1066,39 @@ drop table t1,t0;
set histogram_size=@save_histogram_size;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set use_stat_tables=@save_use_stat_tables;
+
+--echo #
+--echo # MDEV-15306: Wrong/Unexpected result with the value
+--echo # optimizer_use_condition_selectivity set to 4
+--echo #
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+
+delimiter |;
+CREATE FUNCTION f1() RETURNS INT DETERMINISTIC
+BEGIN
+ SET @cnt := @cnt + 1;
+ RETURN 1;
+END;|
+delimiter ;|
+set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
+set @save_use_stat_tables= @@use_stat_tables;
+set @@use_stat_tables='complementary';
+set @@optimizer_use_condition_selectivity=4;
+SET @cnt= 0;
+SELECT * FROM t1 WHERE a = f1();
+SELECT @cnt;
+
+set @@use_stat_tables='preferably';
+analyze table t1 persistent for all;
+SET @cnt := 0;
+set @@optimizer_use_condition_selectivity=4;
+SELECT * FROM t1 WHERE a = f1();
+SELECT @cnt;
+alter table t1 force;
+set @@use_stat_tables= @save_use_stat_tables;
+set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+drop table t1;
+drop function f1;
+
diff --git a/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result
index ab698760c55..921bd20fc69 100644
--- a/mysql-test/main/selectivity_innodb.result
+++ b/mysql-test/main/selectivity_innodb.result
@@ -789,9 +789,9 @@ set optimizer_use_condition_selectivity=3;
explain extended
select * from t1 where a < 1 and a > 7;
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
+1 SIMPLE t1 ALL NULL NULL NULL NULL 8 100.00 Using where
Warnings:
-Note 1003 select 7 AS `a` from `test`.`t1` where 0
+Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` < 1 and `test`.`t1`.`a` > 7
select * from t1 where a < 1 and a > 7;
a
drop table t1;
@@ -1517,9 +1517,9 @@ col1
explain extended
select * from t2 where col1 < 'b' and col1 > 'd';
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
+1 SIMPLE t2 ALL NULL NULL NULL NULL 8 100.00 Using where
Warnings:
-Note 1003 select 'd' AS `col1` from `test`.`t2` where 0
+Note 1003 select `test`.`t2`.`col1` AS `col1` from `test`.`t2` where `test`.`t2`.`col1` < 'b' and `test`.`t2`.`col1` > 'd'
drop table t1,t2;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set use_stat_tables=@save_use_stat_tables;
@@ -1606,6 +1606,46 @@ drop table t1,t0;
set histogram_size=@save_histogram_size;
set optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
set use_stat_tables=@save_use_stat_tables;
+#
+# MDEV-15306: Wrong/Unexpected result with the value
+# optimizer_use_condition_selectivity set to 4
+#
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10);
+CREATE FUNCTION f1() RETURNS INT DETERMINISTIC
+BEGIN
+SET @cnt := @cnt + 1;
+RETURN 1;
+END;|
+set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
+set @save_use_stat_tables= @@use_stat_tables;
+set @@use_stat_tables='complementary';
+set @@optimizer_use_condition_selectivity=4;
+SET @cnt= 0;
+SELECT * FROM t1 WHERE a = f1();
+a
+1
+SELECT @cnt;
+@cnt
+1
+set @@use_stat_tables='preferably';
+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
+SET @cnt := 0;
+set @@optimizer_use_condition_selectivity=4;
+SELECT * FROM t1 WHERE a = f1();
+a
+1
+SELECT @cnt;
+@cnt
+2
+alter table t1 force;
+set @@use_stat_tables= @save_use_stat_tables;
+set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+drop table t1;
+drop function f1;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
set @tmp_ust= @@use_stat_tables;
set @tmp_oucs= @@optimizer_use_condition_selectivity;
diff --git a/mysql-test/main/session_tracker_last_gtid.result b/mysql-test/main/session_tracker_last_gtid.result
index 795d0aaa2a2..deffeca1333 100644
--- a/mysql-test/main/session_tracker_last_gtid.result
+++ b/mysql-test/main/session_tracker_last_gtid.result
@@ -2,7 +2,13 @@
# MDEV-15477: SESSION_SYSVARS_TRACKER does not track last_gtid
#
SET gtid_seq_no=1000;
+-- Tracker : SESSION_TRACK_SCHEMA
+-- test
+
SET @@session.session_track_system_variables='last_gtid';
+-- Tracker : SESSION_TRACK_SCHEMA
+-- test
+
create table t1 (a int) engine=innodb;
-- Tracker : SESSION_TRACK_SYSTEM_VARIABLES
-- last_gtid
diff --git a/mysql-test/main/set_password.result b/mysql-test/main/set_password.result
index 315d0bef9fb..82154c6ae8c 100644
--- a/mysql-test/main/set_password.result
+++ b/mysql-test/main/set_password.result
@@ -9,11 +9,11 @@ create user oldpassold@localhost identified with 'mysql_old_password';
set password for oldpassold@localhost = '378b243e220ca493';
select user, host, password, plugin, authentication_string from mysql.user where user != 'root';
user host password plugin authentication_string
-natauth localhost *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29
-newpass localhost *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29
+natauth localhost mysql_native_password *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29
+newpass localhost mysql_native_password *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29
newpassnat localhost mysql_native_password *94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29
-oldauth localhost 378b243e220ca493
-oldpass localhost 378b243e220ca493
+oldauth localhost mysql_old_password 378b243e220ca493
+oldpass localhost mysql_old_password 378b243e220ca493
oldpassold localhost mysql_old_password 378b243e220ca493
connect con,localhost,natauth,test,;
select current_user();
diff --git a/mysql-test/main/shm-master.opt b/mysql-test/main/shm-master.opt
deleted file mode 100644
index d71395213b1..00000000000
--- a/mysql-test/main/shm-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---skip-grant-tables --loose-shared-memory-base-name=HeyMrBaseNameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX$MTR_BUILD_THREAD --loose-shared-memory=1
diff --git a/mysql-test/main/shm.result b/mysql-test/main/shm.result
deleted file mode 100644
index 65187b6b19b..00000000000
--- a/mysql-test/main/shm.result
+++ /dev/null
@@ -1,2170 +0,0 @@
-connect shm_con,localhost,root,,,,$shm_name,SHM;
-drop table if exists t1,t2,t3,t4;
-CREATE TABLE t1 (
-Period smallint(4) unsigned zerofill DEFAULT '0000' NOT NULL,
-Varor_period smallint(4) unsigned DEFAULT '0' NOT NULL
-);
-INSERT INTO t1 VALUES (9410,9412);
-select period from t1;
-period
-9410
-select * from t1;
-Period Varor_period
-9410 9412
-select t1.* from t1;
-Period Varor_period
-9410 9412
-CREATE TABLE t2 (
-auto int not null auto_increment,
-fld1 int(6) unsigned zerofill DEFAULT '000000' NOT NULL,
-companynr tinyint(2) unsigned zerofill DEFAULT '00' NOT NULL,
-fld3 char(30) DEFAULT '' NOT NULL,
-fld4 char(35) DEFAULT '' NOT NULL,
-fld5 char(35) DEFAULT '' NOT NULL,
-fld6 char(4) DEFAULT '' NOT NULL,
-UNIQUE fld1 (fld1),
-KEY fld3 (fld3),
-PRIMARY KEY (auto)
-);
-select t2.fld3 from t2 where companynr = 58 and fld3 like "%imaginable%";
-fld3
-imaginable
-select fld3 from t2 where fld3 like "%cultivation" ;
-fld3
-cultivation
-select t2.fld3,companynr from t2 where companynr = 57+1 order by fld3;
-fld3 companynr
-concoct 58
-druggists 58
-engrossing 58
-Eurydice 58
-exclaimers 58
-ferociousness 58
-hopelessness 58
-Huey 58
-imaginable 58
-judges 58
-merging 58
-ostrich 58
-peering 58
-Phelps 58
-presumes 58
-Ruth 58
-sentences 58
-Shylock 58
-straggled 58
-synergy 58
-thanking 58
-tying 58
-unlocks 58
-select fld3,companynr from t2 where companynr = 58 order by fld3;
-fld3 companynr
-concoct 58
-druggists 58
-engrossing 58
-Eurydice 58
-exclaimers 58
-ferociousness 58
-hopelessness 58
-Huey 58
-imaginable 58
-judges 58
-merging 58
-ostrich 58
-peering 58
-Phelps 58
-presumes 58
-Ruth 58
-sentences 58
-Shylock 58
-straggled 58
-synergy 58
-thanking 58
-tying 58
-unlocks 58
-select fld3 from t2 order by fld3 desc limit 10;
-fld3
-youthfulness
-yelped
-Wotan
-workers
-Witt
-witchcraft
-Winsett
-Willy
-willed
-wildcats
-select fld3 from t2 order by fld3 desc limit 5;
-fld3
-youthfulness
-yelped
-Wotan
-workers
-Witt
-select fld3 from t2 order by fld3 desc limit 5,5;
-fld3
-witchcraft
-Winsett
-Willy
-willed
-wildcats
-select t2.fld3 from t2 where fld3 = 'honeysuckle';
-fld3
-honeysuckle
-select t2.fld3 from t2 where fld3 LIKE 'honeysuckl_';
-fld3
-honeysuckle
-select t2.fld3 from t2 where fld3 LIKE 'hon_ysuckl_';
-fld3
-honeysuckle
-select t2.fld3 from t2 where fld3 LIKE 'honeysuckle%';
-fld3
-honeysuckle
-select t2.fld3 from t2 where fld3 LIKE 'h%le';
-fld3
-honeysuckle
-select t2.fld3 from t2 where fld3 LIKE 'honeysuckle_';
-fld3
-select t2.fld3 from t2 where fld3 LIKE 'don_t_find_me_please%';
-fld3
-explain select t2.fld3 from t2 where fld3 = 'honeysuckle';
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index
-explain select fld3 from t2 ignore index (fld3) where fld3 = 'honeysuckle';
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
-explain select fld3 from t2 use index (fld1) where fld3 = 'honeysuckle';
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
-explain select fld3 from t2 use index (fld3) where fld3 = 'honeysuckle';
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index
-explain select fld3 from t2 use index (fld1,fld3) where fld3 = 'honeysuckle';
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ref fld3 fld3 30 const 1 Using where; Using index
-explain select fld3 from t2 ignore index (fld3,not_used);
-ERROR 42000: Key 'not_used' doesn't exist in table 't2'
-explain select fld3 from t2 use index (not_used);
-ERROR 42000: Key 'not_used' doesn't exist in table 't2'
-select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
-fld3
-honeysuckle
-honoring
-explain select t2.fld3 from t2 where fld3 >= 'honeysuckle' and fld3 <= 'honoring' order by fld3;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range fld3 fld3 30 NULL 2 Using where; Using index
-select fld1,fld3 from t2 where fld3="Colombo" or fld3 = "nondecreasing" order by fld3;
-fld1 fld3
-148504 Colombo
-068305 Colombo
-000000 nondecreasing
-select fld1,fld3 from t2 where companynr = 37 and fld3 = 'appendixes';
-fld1 fld3
-232605 appendixes
-1232605 appendixes
-1232606 appendixes
-1232607 appendixes
-1232608 appendixes
-1232609 appendixes
-select fld1 from t2 where fld1=250501 or fld1="250502";
-fld1
-250501
-250502
-explain select fld1 from t2 where fld1=250501 or fld1="250502";
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range fld1 fld1 4 NULL 2 Using where; Using index
-select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
-fld1
-250501
-250502
-250505
-250601
-explain select fld1 from t2 where fld1=250501 or fld1=250502 or fld1 >= 250505 and fld1 <= 250601 or fld1 between 250501 and 250502;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 range fld1 fld1 4 NULL 4 Using where; Using index
-select fld1,fld3 from t2 where companynr = 37 and fld3 like 'f%';
-fld1 fld3
-012001 flanking
-013602 foldout
-013606 fingerings
-018007 fanatic
-018017 featherweight
-018054 fetters
-018103 flint
-018104 flopping
-036002 funereal
-038017 fetched
-038205 firearm
-058004 Fenton
-088303 feminine
-186002 freakish
-188007 flurried
-188505 fitting
-198006 furthermore
-202301 Fitzpatrick
-208101 fiftieth
-208113 freest
-218008 finishers
-218022 feed
-218401 faithful
-226205 foothill
-226209 furnishings
-228306 forthcoming
-228311 fated
-231315 freezes
-232102 forgivably
-238007 filial
-238008 fixedly
-select fld3 from t2 where fld3 like "L%" and fld3 = "ok";
-fld3
-select fld3 from t2 where (fld3 like "C%" and fld3 = "Chantilly");
-fld3
-Chantilly
-select fld1,fld3 from t2 where fld1 like "25050%";
-fld1 fld3
-250501 poisoning
-250502 Iraqis
-250503 heaving
-250504 population
-250505 bomb
-select fld1,fld3 from t2 where fld1 like "25050_";
-fld1 fld3
-250501 poisoning
-250502 Iraqis
-250503 heaving
-250504 population
-250505 bomb
-select distinct companynr from t2;
-companynr
-00
-37
-36
-50
-58
-29
-40
-53
-65
-41
-34
-68
-select distinct companynr from t2 order by companynr;
-companynr
-00
-29
-34
-36
-37
-40
-41
-50
-53
-58
-65
-68
-select distinct companynr from t2 order by companynr desc;
-companynr
-68
-65
-58
-53
-50
-41
-40
-37
-36
-34
-29
-00
-select distinct t2.fld3,period from t2,t1 where companynr=37 and fld3 like "O%";
-fld3 period
-obliterates 9410
-offload 9410
-opaquely 9410
-organizer 9410
-overestimating 9410
-overlay 9410
-select distinct fld3 from t2 where companynr = 34 order by fld3;
-fld3
-absentee
-accessed
-ahead
-alphabetic
-Asiaticizations
-attitude
-aye
-bankruptcies
-belays
-Blythe
-bomb
-boulevard
-bulldozes
-cannot
-caressing
-charcoal
-checksumming
-chess
-clubroom
-colorful
-cosy
-creator
-crying
-Darius
-diffusing
-duality
-Eiffel
-Epiphany
-Ernestine
-explorers
-exterminated
-famine
-forked
-Gershwins
-heaving
-Hodges
-Iraqis
-Italianization
-Lagos
-landslide
-libretto
-Majorca
-mastering
-narrowed
-occurred
-offerers
-Palestine
-Peruvianizes
-pharmaceutic
-poisoning
-population
-Pygmalion
-rats
-realest
-recording
-regimented
-retransmitting
-reviver
-rouses
-scars
-sicker
-sleepwalk
-stopped
-sugars
-translatable
-uncles
-unexpected
-uprisings
-versatility
-vest
-select distinct fld3 from t2 limit 10;
-fld3
-abates
-abiding
-Abraham
-abrogating
-absentee
-abut
-accessed
-accruing
-accumulating
-accuracies
-select distinct fld3 from t2 having fld3 like "A%" limit 10;
-fld3
-abates
-abiding
-Abraham
-abrogating
-absentee
-abut
-accessed
-accruing
-accumulating
-accuracies
-select distinct substring(fld3,1,3) from t2 where fld3 like "A%";
-substring(fld3,1,3)
-aba
-abi
-Abr
-abs
-abu
-acc
-acq
-acu
-Ade
-adj
-Adl
-adm
-Ado
-ads
-adv
-aer
-aff
-afi
-afl
-afo
-agi
-ahe
-aim
-air
-Ald
-alg
-ali
-all
-alp
-alr
-ama
-ame
-amm
-ana
-and
-ane
-Ang
-ani
-Ann
-Ant
-api
-app
-aqu
-Ara
-arc
-Arm
-arr
-Art
-Asi
-ask
-asp
-ass
-ast
-att
-aud
-Aug
-aut
-ave
-avo
-awe
-aye
-Azt
-select distinct substring(fld3,1,3) as a from t2 having a like "A%" order by a limit 10;
-a
-aba
-abi
-Abr
-abs
-abu
-acc
-acq
-acu
-Ade
-adj
-select distinct substring(fld3,1,3) from t2 where fld3 like "A%" limit 10;
-substring(fld3,1,3)
-aba
-abi
-Abr
-abs
-abu
-acc
-acq
-acu
-Ade
-adj
-select distinct substring(fld3,1,3) as a from t2 having a like "A%" limit 10;
-a
-aba
-abi
-Abr
-abs
-abu
-acc
-acq
-acu
-Ade
-adj
-create table t3 (
-period int not null,
-name char(32) not null,
-companynr int not null,
-price double(11,0),
-price2 double(11,0),
-key (period),
-key (name)
-);
-create temporary table tmp engine = myisam select * from t3;
-insert into t3 select * from tmp;
-insert into tmp select * from t3;
-insert into t3 select * from tmp;
-insert into tmp select * from t3;
-insert into t3 select * from tmp;
-insert into tmp select * from t3;
-insert into t3 select * from tmp;
-insert into tmp select * from t3;
-insert into t3 select * from tmp;
-insert into tmp select * from t3;
-insert into t3 select * from tmp;
-insert into tmp select * from t3;
-insert into t3 select * from tmp;
-insert into tmp select * from t3;
-insert into t3 select * from tmp;
-insert into tmp select * from t3;
-insert into t3 select * from tmp;
-alter table t3 add t2nr int not null auto_increment primary key first;
-drop table tmp;
-SET BIG_TABLES=1;
-select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10;
-namn
-Abraham Abraham
-abrogating abrogating
-admonishing admonishing
-Adolph Adolph
-afield afield
-aging aging
-ammonium ammonium
-analyzable analyzable
-animals animals
-animized animized
-SET BIG_TABLES=0;
-select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10;
-concat(fld3," ",fld3)
-Abraham Abraham
-abrogating abrogating
-admonishing admonishing
-Adolph Adolph
-afield afield
-aging aging
-ammonium ammonium
-analyzable analyzable
-animals animals
-animized animized
-select distinct fld5 from t2 limit 10;
-fld5
-neat
-Steinberg
-jarring
-tinily
-balled
-persist
-attainments
-fanatic
-measures
-rightfulness
-select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10;
-fld3 count(*)
-affixed 1
-and 1
-annoyers 1
-Anthony 1
-assayed 1
-assurers 1
-attendants 1
-bedlam 1
-bedpost 1
-boasted 1
-SET BIG_TABLES=1;
-select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10;
-fld3 count(*)
-affixed 1
-and 1
-annoyers 1
-Anthony 1
-assayed 1
-assurers 1
-attendants 1
-bedlam 1
-bedpost 1
-boasted 1
-SET BIG_TABLES=0;
-select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10;
-fld3 repeat("a",length(fld3)) count(*)
-circus aaaaaa 1
-cited aaaaa 1
-Colombo aaaaaaa 1
-congresswoman aaaaaaaaaaaaa 1
-contrition aaaaaaaaaa 1
-corny aaaaa 1
-cultivation aaaaaaaaaaa 1
-definiteness aaaaaaaaaaaa 1
-demultiplex aaaaaaaaaaa 1
-disappointing aaaaaaaaaaaaa 1
-select distinct companynr,rtrim(space(512+companynr)) from t3 order by 1,2;
-companynr rtrim(space(512+companynr))
-37
-78
-101
-154
-311
-447
-512
-select distinct fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by fld3;
-fld3
-explain select t3.t2nr,fld3 from t2,t3 where t2.companynr = 34 and t2.fld1=t3.t2nr order by t3.t2nr,fld3;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL fld1 NULL NULL NULL 1199 Using where; Using temporary; Using filesort
-1 SIMPLE t3 eq_ref PRIMARY PRIMARY 4 test.t2.fld1 1 Using where; Using index
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 ALL period NULL NULL NULL 41810 Using filesort
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t3.period limit 10;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t3 index period period 4 NULL 1
-1 SIMPLE t1 ref period period 4 test.t3.period 4181
-explain select * from t3 as t1,t3 where t1.period=t3.period order by t1.period limit 10;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t1 index period period 4 NULL 1
-1 SIMPLE t3 ref period period 4 test.t1.period 4181
-select period from t1;
-period
-9410
-select period from t1 where period=1900;
-period
-select fld3,period from t1,t2 where fld1 = 011401 order by period;
-fld3 period
-breaking 9410
-select fld3,period from t2,t3 where t2.fld1 = 011401 and t2.fld1=t3.t2nr and t3.period=1001;
-fld3 period
-breaking 1001
-explain select fld3,period from t2,t3 where t2.fld1 = 011401 and t3.t2nr=t2.fld1 and 1001 = t3.period;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 const fld1 fld1 4 const 1
-1 SIMPLE t3 const PRIMARY,period PRIMARY 4 const 1
-select fld3,period from t2,t1 where companynr*10 = 37*10;
-fld3 period
-breaking 9410
-Romans 9410
-intercepted 9410
-bewilderingly 9410
-astound 9410
-admonishing 9410
-sumac 9410
-flanking 9410
-combed 9410
-subjective 9410
-scatterbrain 9410
-Eulerian 9410
-Kane 9410
-overlay 9410
-perturb 9410
-goblins 9410
-annihilates 9410
-Wotan 9410
-snatching 9410
-concludes 9410
-laterally 9410
-yelped 9410
-grazing 9410
-Baird 9410
-celery 9410
-misunderstander 9410
-handgun 9410
-foldout 9410
-mystic 9410
-succumbed 9410
-Nabisco 9410
-fingerings 9410
-aging 9410
-afield 9410
-ammonium 9410
-boat 9410
-intelligibility 9410
-Augustine 9410
-teethe 9410
-dreaded 9410
-scholastics 9410
-audiology 9410
-wallet 9410
-parters 9410
-eschew 9410
-quitter 9410
-neat 9410
-Steinberg 9410
-jarring 9410
-tinily 9410
-balled 9410
-persist 9410
-attainments 9410
-fanatic 9410
-measures 9410
-rightfulness 9410
-capably 9410
-impulsive 9410
-starlet 9410
-terminators 9410
-untying 9410
-announces 9410
-featherweight 9410
-pessimist 9410
-daughter 9410
-decliner 9410
-lawgiver 9410
-stated 9410
-readable 9410
-attrition 9410
-cascade 9410
-motors 9410
-interrogate 9410
-pests 9410
-stairway 9410
-dopers 9410
-testicle 9410
-Parsifal 9410
-leavings 9410
-postulation 9410
-squeaking 9410
-contrasted 9410
-leftover 9410
-whiteners 9410
-erases 9410
-Punjab 9410
-Merritt 9410
-Quixotism 9410
-sweetish 9410
-dogging 9410
-scornfully 9410
-bellow 9410
-bills 9410
-cupboard 9410
-sureties 9410
-puddings 9410
-fetters 9410
-bivalves 9410
-incurring 9410
-Adolph 9410
-pithed 9410
-Miles 9410
-trimmings 9410
-tragedies 9410
-skulking 9410
-flint 9410
-flopping 9410
-relaxing 9410
-offload 9410
-suites 9410
-lists 9410
-animized 9410
-multilayer 9410
-standardizes 9410
-Judas 9410
-vacuuming 9410
-dentally 9410
-humanness 9410
-inch 9410
-Weissmuller 9410
-irresponsibly 9410
-luckily 9410
-culled 9410
-medical 9410
-bloodbath 9410
-subschema 9410
-animals 9410
-Micronesia 9410
-repetitions 9410
-Antares 9410
-ventilate 9410
-pityingly 9410
-interdependent 9410
-Graves 9410
-neonatal 9410
-chafe 9410
-honoring 9410
-realtor 9410
-elite 9410
-funereal 9410
-abrogating 9410
-sorters 9410
-Conley 9410
-lectured 9410
-Abraham 9410
-Hawaii 9410
-cage 9410
-hushes 9410
-Simla 9410
-reporters 9410
-Dutchman 9410
-descendants 9410
-groupings 9410
-dissociate 9410
-coexist 9410
-Beebe 9410
-Taoism 9410
-Connally 9410
-fetched 9410
-checkpoints 9410
-rusting 9410
-galling 9410
-obliterates 9410
-traitor 9410
-resumes 9410
-analyzable 9410
-terminator 9410
-gritty 9410
-firearm 9410
-minima 9410
-Selfridge 9410
-disable 9410
-witchcraft 9410
-betroth 9410
-Manhattanize 9410
-imprint 9410
-peeked 9410
-swelling 9410
-interrelationships 9410
-riser 9410
-Gandhian 9410
-peacock 9410
-bee 9410
-kanji 9410
-dental 9410
-scarf 9410
-chasm 9410
-insolence 9410
-syndicate 9410
-alike 9410
-imperial 9410
-convulsion 9410
-railway 9410
-validate 9410
-normalizes 9410
-comprehensive 9410
-chewing 9410
-denizen 9410
-schemer 9410
-chronicle 9410
-Kline 9410
-Anatole 9410
-partridges 9410
-brunch 9410
-recruited 9410
-dimensions 9410
-Chicana 9410
-announced 9410
-praised 9410
-employing 9410
-linear 9410
-quagmire 9410
-western 9410
-relishing 9410
-serving 9410
-scheduling 9410
-lore 9410
-eventful 9410
-arteriole 9410
-disentangle 9410
-cured 9410
-Fenton 9410
-avoidable 9410
-drains 9410
-detectably 9410
-husky 9410
-impelling 9410
-undoes 9410
-evened 9410
-squeezes 9410
-destroyer 9410
-rudeness 9410
-beaner 9410
-boorish 9410
-Everhart 9410
-encompass 9410
-mushrooms 9410
-Alison 9410
-externally 9410
-pellagra 9410
-cult 9410
-creek 9410
-Huffman 9410
-Majorca 9410
-governing 9410
-gadfly 9410
-reassigned 9410
-intentness 9410
-craziness 9410
-psychic 9410
-squabbled 9410
-burlesque 9410
-capped 9410
-extracted 9410
-DiMaggio 9410
-exclamation 9410
-subdirectory 9410
-Gothicism 9410
-feminine 9410
-metaphysically 9410
-sanding 9410
-Miltonism 9410
-freakish 9410
-index 9410
-straight 9410
-flurried 9410
-denotative 9410
-coming 9410
-commencements 9410
-gentleman 9410
-gifted 9410
-Shanghais 9410
-sportswriting 9410
-sloping 9410
-navies 9410
-leaflet 9410
-shooter 9410
-Joplin 9410
-babies 9410
-assails 9410
-admiring 9410
-swaying 9410
-Goldstine 9410
-fitting 9410
-Norwalk 9410
-analogy 9410
-deludes 9410
-cokes 9410
-Clayton 9410
-exhausts 9410
-causality 9410
-sating 9410
-icon 9410
-throttles 9410
-communicants 9410
-dehydrate 9410
-priceless 9410
-publicly 9410
-incidentals 9410
-commonplace 9410
-mumbles 9410
-furthermore 9410
-cautioned 9410
-parametrized 9410
-registration 9410
-sadly 9410
-positioning 9410
-babysitting 9410
-eternal 9410
-hoarder 9410
-congregates 9410
-rains 9410
-workers 9410
-sags 9410
-unplug 9410
-garage 9410
-boulder 9410
-specifics 9410
-Teresa 9410
-Winsett 9410
-convenient 9410
-buckboards 9410
-amenities 9410
-resplendent 9410
-sews 9410
-participated 9410
-Simon 9410
-certificates 9410
-Fitzpatrick 9410
-Evanston 9410
-misted 9410
-textures 9410
-save 9410
-count 9410
-rightful 9410
-chaperone 9410
-Lizzy 9410
-clenched 9410
-effortlessly 9410
-accessed 9410
-beaters 9410
-Hornblower 9410
-vests 9410
-indulgences 9410
-infallibly 9410
-unwilling 9410
-excrete 9410
-spools 9410
-crunches 9410
-overestimating 9410
-ineffective 9410
-humiliation 9410
-sophomore 9410
-star 9410
-rifles 9410
-dialysis 9410
-arriving 9410
-indulge 9410
-clockers 9410
-languages 9410
-Antarctica 9410
-percentage 9410
-ceiling 9410
-specification 9410
-regimented 9410
-ciphers 9410
-pictures 9410
-serpents 9410
-allot 9410
-realized 9410
-mayoral 9410
-opaquely 9410
-hostess 9410
-fiftieth 9410
-incorrectly 9410
-decomposition 9410
-stranglings 9410
-mixture 9410
-electroencephalography 9410
-similarities 9410
-charges 9410
-freest 9410
-Greenberg 9410
-tinting 9410
-expelled 9410
-warm 9410
-smoothed 9410
-deductions 9410
-Romano 9410
-bitterroot 9410
-corset 9410
-securing 9410
-environing 9410
-cute 9410
-Crays 9410
-heiress 9410
-inform 9410
-avenge 9410
-universals 9410
-Kinsey 9410
-ravines 9410
-bestseller 9410
-equilibrium 9410
-extents 9410
-relatively 9410
-pressure 9410
-critiques 9410
-befouled 9410
-rightfully 9410
-mechanizing 9410
-Latinizes 9410
-timesharing 9410
-Aden 9410
-embassies 9410
-males 9410
-shapelessly 9410
-mastering 9410
-Newtonian 9410
-finishers 9410
-abates 9410
-teem 9410
-kiting 9410
-stodgy 9410
-feed 9410
-guitars 9410
-airships 9410
-store 9410
-denounces 9410
-Pyle 9410
-Saxony 9410
-serializations 9410
-Peruvian 9410
-taxonomically 9410
-kingdom 9410
-stint 9410
-Sault 9410
-faithful 9410
-Ganymede 9410
-tidiness 9410
-gainful 9410
-contrary 9410
-Tipperary 9410
-tropics 9410
-theorizers 9410
-renew 9410
-already 9410
-terminal 9410
-Hegelian 9410
-hypothesizer 9410
-warningly 9410
-journalizing 9410
-nested 9410
-Lars 9410
-saplings 9410
-foothill 9410
-labeled 9410
-imperiously 9410
-reporters 9410
-furnishings 9410
-precipitable 9410
-discounts 9410
-excises 9410
-Stalin 9410
-despot 9410
-ripeness 9410
-Arabia 9410
-unruly 9410
-mournfulness 9410
-boom 9410
-slaughter 9410
-Sabine 9410
-handy 9410
-rural 9410
-organizer 9410
-shipyard 9410
-civics 9410
-inaccuracy 9410
-rules 9410
-juveniles 9410
-comprised 9410
-investigations 9410
-stabilizes 9410
-seminaries 9410
-Hunter 9410
-sporty 9410
-test 9410
-weasels 9410
-CERN 9410
-tempering 9410
-afore 9410
-Galatean 9410
-techniques 9410
-error 9410
-veranda 9410
-severely 9410
-Cassites 9410
-forthcoming 9410
-guides 9410
-vanish 9410
-lied 9410
-sawtooth 9410
-fated 9410
-gradually 9410
-widens 9410
-preclude 9410
-evenhandedly 9410
-percentage 9410
-disobedience 9410
-humility 9410
-gleaning 9410
-petted 9410
-bloater 9410
-minion 9410
-marginal 9410
-apiary 9410
-measures 9410
-precaution 9410
-repelled 9410
-primary 9410
-coverings 9410
-Artemia 9410
-navigate 9410
-spatial 9410
-Gurkha 9410
-meanwhile 9410
-Melinda 9410
-Butterfield 9410
-Aldrich 9410
-previewing 9410
-glut 9410
-unaffected 9410
-inmate 9410
-mineral 9410
-impending 9410
-meditation 9410
-ideas 9410
-miniaturizes 9410
-lewdly 9410
-title 9410
-youthfulness 9410
-creak 9410
-Chippewa 9410
-clamored 9410
-freezes 9410
-forgivably 9410
-reduce 9410
-McGovern 9410
-Nazis 9410
-epistle 9410
-socializes 9410
-conceptions 9410
-Kevin 9410
-uncovering 9410
-chews 9410
-appendixes 9410
-appendixes 9410
-appendixes 9410
-appendixes 9410
-appendixes 9410
-appendixes 9410
-raining 9410
-infest 9410
-compartment 9410
-minting 9410
-ducks 9410
-roped 9410
-waltz 9410
-Lillian 9410
-repressions 9410
-chillingly 9410
-noncritical 9410
-lithograph 9410
-spongers 9410
-parenthood 9410
-posed 9410
-instruments 9410
-filial 9410
-fixedly 9410
-relives 9410
-Pandora 9410
-watering 9410
-ungrateful 9410
-secures 9410
-poison 9410
-dusted 9410
-encompasses 9410
-presentation 9410
-Kantian 9410
-select fld3,period,price,price2 from t2,t3 where t2.fld1=t3.t2nr and period >= 1001 and period <= 1002 and t2.companynr = 37 order by fld3,period, price;
-fld3 period price price2
-admonishing 1002 28357832 8723648
-analyzable 1002 28357832 8723648
-annihilates 1001 5987435 234724
-Antares 1002 28357832 8723648
-astound 1001 5987435 234724
-audiology 1001 5987435 234724
-Augustine 1002 28357832 8723648
-Baird 1002 28357832 8723648
-bewilderingly 1001 5987435 234724
-breaking 1001 5987435 234724
-Conley 1001 5987435 234724
-dentally 1002 28357832 8723648
-dissociate 1002 28357832 8723648
-elite 1001 5987435 234724
-eschew 1001 5987435 234724
-Eulerian 1001 5987435 234724
-flanking 1001 5987435 234724
-foldout 1002 28357832 8723648
-funereal 1002 28357832 8723648
-galling 1002 28357832 8723648
-Graves 1001 5987435 234724
-grazing 1001 5987435 234724
-groupings 1001 5987435 234724
-handgun 1001 5987435 234724
-humility 1002 28357832 8723648
-impulsive 1002 28357832 8723648
-inch 1001 5987435 234724
-intelligibility 1001 5987435 234724
-jarring 1001 5987435 234724
-lawgiver 1001 5987435 234724
-lectured 1002 28357832 8723648
-Merritt 1002 28357832 8723648
-neonatal 1001 5987435 234724
-offload 1002 28357832 8723648
-parters 1002 28357832 8723648
-pityingly 1002 28357832 8723648
-puddings 1002 28357832 8723648
-Punjab 1001 5987435 234724
-quitter 1002 28357832 8723648
-realtor 1001 5987435 234724
-relaxing 1001 5987435 234724
-repetitions 1001 5987435 234724
-resumes 1001 5987435 234724
-Romans 1002 28357832 8723648
-rusting 1001 5987435 234724
-scholastics 1001 5987435 234724
-skulking 1002 28357832 8723648
-stated 1002 28357832 8723648
-suites 1002 28357832 8723648
-sureties 1001 5987435 234724
-testicle 1002 28357832 8723648
-tinily 1002 28357832 8723648
-tragedies 1001 5987435 234724
-trimmings 1001 5987435 234724
-vacuuming 1001 5987435 234724
-ventilate 1001 5987435 234724
-wallet 1001 5987435 234724
-Weissmuller 1002 28357832 8723648
-Wotan 1002 28357832 8723648
-select t2.fld1,fld3,period,price,price2 from t2,t3 where t2.fld1>= 18201 and t2.fld1 <= 18811 and t2.fld1=t3.t2nr and period = 1001 and t2.companynr = 37;
-fld1 fld3 period price price2
-018201 relaxing 1001 5987435 234724
-018601 vacuuming 1001 5987435 234724
-018801 inch 1001 5987435 234724
-018811 repetitions 1001 5987435 234724
-create table t4 (
-companynr tinyint(2) unsigned zerofill NOT NULL default '00',
-companyname char(30) NOT NULL default '',
-PRIMARY KEY (companynr),
-UNIQUE KEY companyname(companyname)
-) ENGINE=MyISAM MAX_ROWS=50 PACK_KEYS=1 COMMENT='companynames';
-select STRAIGHT_JOIN t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr;
-companynr companyname
-00 Unknown
-29 company 1
-34 company 2
-36 company 3
-37 company 4
-40 company 5
-41 company 6
-50 company 11
-53 company 7
-58 company 8
-65 company 9
-68 company 10
-select SQL_SMALL_RESULT t2.companynr,companyname from t4,t2 where t2.companynr=t4.companynr group by t2.companynr;
-companynr companyname
-00 Unknown
-29 company 1
-34 company 2
-36 company 3
-37 company 4
-40 company 5
-41 company 6
-50 company 11
-53 company 7
-58 company 8
-65 company 9
-68 company 10
-select * from t1,t1 t12;
-Period Varor_period Period Varor_period
-9410 9412 9410 9412
-select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 250505 and t22.fld1 >= 250501 and t22.fld1 <= 250505;
-fld1 fld1
-250501 250501
-250502 250501
-250503 250501
-250504 250501
-250505 250501
-250501 250502
-250502 250502
-250503 250502
-250504 250502
-250505 250502
-250501 250503
-250502 250503
-250503 250503
-250504 250503
-250505 250503
-250501 250504
-250502 250504
-250503 250504
-250504 250504
-250505 250504
-250501 250505
-250502 250505
-250503 250505
-250504 250505
-250505 250505
-SET @save_optimizer_switch=@@optimizer_switch;
-SET optimizer_switch='outer_join_with_cache=off';
-insert into t2 (fld1, companynr) values (999999,99);
-select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
-companynr companyname
-99 NULL
-select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null;
-count(*)
-1199
-explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1200
-1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1 Using where; Not exists
-explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 12
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1200 Using where; Not exists
-select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
-companynr companyname
-select count(*) from t2 left join t4 using (companynr) where companynr is not null;
-count(*)
-1200
-explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
-explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
-delete from t2 where fld1=999999;
-explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
-1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
-explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
-1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
-explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
-1 SIMPLE t4 eq_ref PRIMARY PRIMARY 1 test.t2.companynr 1
-explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
-explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
-explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
-explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 12
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
-explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
-explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 12
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
-explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
-explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL PRIMARY NULL NULL NULL 12 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
-explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 ALL NULL NULL NULL NULL 12 Using where
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where
-SET optimizer_switch=@save_optimizer_switch;
-select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
-companynr companynr
-37 36
-41 40
-explain select distinct t2.companynr,t4.companynr from t2,t4 where t2.companynr=t4.companynr+1;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t4 index NULL PRIMARY 1 NULL 12 Using index; Using temporary
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 Using where; Using join buffer (flat, BNL join)
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where t2.fld1 = 38208 and t2.fld1=t3.t2nr and period = 1008 or t2.fld1 = 38008 and t2.fld1 =t3.t2nr and period = 1008;
-fld1 companynr fld3 period
-038008 37 reporters 1008
-038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t2.fld1 = 38208 or t2.fld1 = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
-038008 37 reporters 1008
-038208 37 Selfridge 1008
-select t2.fld1,t2.companynr,fld3,period from t3,t2 where (t3.t2nr = 38208 or t3.t2nr = 38008) and t2.fld1=t3.t2nr and period>=1008 and period<=1009;
-fld1 companynr fld3 period
-038008 37 reporters 1008
-038208 37 Selfridge 1008
-select period from t1 where (((period > 0) or period < 10000 or (period = 1900)) and (period=1900 and period <= 1901) or (period=1903 and (period=1903)) and period>=1902) or ((period=1904 or period=1905) or (period=1906 or period>1907)) or (period=1908 and period = 1909);
-period
-9410
-select period from t1 where ((period > 0 and period < 1) or (((period > 0 and period < 100) and (period > 10)) or (period > 10)) or (period > 0 and (period > 5 or period > 6)));
-period
-9410
-select a.fld1 from t2 as a,t2 b where ((a.fld1 = 250501 and a.fld1=b.fld1) or a.fld1=250502 or a.fld1=250503 or (a.fld1=250505 and a.fld1<=b.fld1 and b.fld1>=a.fld1)) and a.fld1=b.fld1;
-fld1
-250501
-250502
-250503
-250505
-select fld1 from t2 where fld1 in (250502,98005,98006,250503,250605,250606) and fld1 >=250502 and fld1 not in (250605,250606);
-fld1
-250502
-250503
-select fld1 from t2 where fld1 between 250502 and 250504;
-fld1
-250502
-250503
-250504
-select fld3 from t2 where (((fld3 like "_%L%" ) or (fld3 like "%ok%")) and ( fld3 like "L%" or fld3 like "G%")) and fld3 like "L%" ;
-fld3
-label
-labeled
-labeled
-landslide
-laterally
-leaflet
-lewdly
-Lillian
-luckily
-select count(*) from t1;
-count(*)
-1
-select companynr,count(*),sum(fld1) from t2 group by companynr;
-companynr count(*) sum(fld1)
-00 82 10355753
-29 95 14473298
-34 70 17788966
-36 215 22786296
-37 588 83602098
-40 37 6618386
-41 52 12816335
-50 11 1595438
-53 4 793210
-58 23 2254293
-65 10 2284055
-68 12 3097288
-select companynr,count(*) from t2 group by companynr order by companynr desc limit 5;
-companynr count(*)
-68 12
-65 10
-58 23
-53 4
-50 11
-select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
-count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1)
-70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069
-explain extended select count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 where companynr = 34 and fld4<>"";
-id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199 100.00 Using where
-Warnings:
-Note 1003 select count(0) AS `count(*)`,min(`test`.`t2`.`fld4`) AS `min(fld4)`,max(`test`.`t2`.`fld4`) AS `max(fld4)`,sum(`test`.`t2`.`fld1`) AS `sum(fld1)`,avg(`test`.`t2`.`fld1`) AS `avg(fld1)`,std(`test`.`t2`.`fld1`) AS `std(fld1)`,variance(`test`.`t2`.`fld1`) AS `variance(fld1)` from `test`.`t2` where `test`.`t2`.`companynr` = 34 and `test`.`t2`.`fld4` <> ''
-select companynr,count(*),min(fld4),max(fld4),sum(fld1),avg(fld1),std(fld1),variance(fld1) from t2 group by companynr limit 3;
-companynr count(*) min(fld4) max(fld4) sum(fld1) avg(fld1) std(fld1) variance(fld1)
-00 82 Anthony windmills 10355753 126289.6707 115550.9757 13352027981.7087
-29 95 abut wetness 14473298 152350.5053 8368.5480 70032594.9026
-34 70 absentee vest 17788966 254128.0857 3272.5940 10709871.3069
-select companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;
-companynr t2nr count(price) sum(price) min(price) max(price) avg(price)
-37 1 1 5987435 5987435 5987435 5987435.0000
-37 2 1 28357832 28357832 28357832 28357832.0000
-37 3 1 39654943 39654943 39654943 39654943.0000
-37 11 1 5987435 5987435 5987435 5987435.0000
-37 12 1 28357832 28357832 28357832 28357832.0000
-37 13 1 39654943 39654943 39654943 39654943.0000
-37 21 1 5987435 5987435 5987435 5987435.0000
-37 22 1 28357832 28357832 28357832 28357832.0000
-37 23 1 39654943 39654943 39654943 39654943.0000
-37 31 1 5987435 5987435 5987435 5987435.0000
-select /*! SQL_SMALL_RESULT */ companynr,t2nr,count(price),sum(price),min(price),max(price),avg(price) from t3 where companynr = 37 group by companynr,t2nr limit 10;
-companynr t2nr count(price) sum(price) min(price) max(price) avg(price)
-37 1 1 5987435 5987435 5987435 5987435.0000
-37 2 1 28357832 28357832 28357832 28357832.0000
-37 3 1 39654943 39654943 39654943 39654943.0000
-37 11 1 5987435 5987435 5987435 5987435.0000
-37 12 1 28357832 28357832 28357832 28357832.0000
-37 13 1 39654943 39654943 39654943 39654943.0000
-37 21 1 5987435 5987435 5987435 5987435.0000
-37 22 1 28357832 28357832 28357832 28357832.0000
-37 23 1 39654943 39654943 39654943 39654943.0000
-37 31 1 5987435 5987435 5987435 5987435.0000
-select companynr,count(price),sum(price),min(price),max(price),avg(price) from t3 group by companynr ;
-companynr count(price) sum(price) min(price) max(price) avg(price)
-37 12543 309394878010 5987435 39654943 24666736.6667
-78 8362 414611089292 726498 98439034 49582766.0000
-101 4181 3489454238 834598 834598 834598.0000
-154 4181 4112197254950 983543950 983543950 983543950.0000
-311 4181 979599938 234298 234298 234298.0000
-447 4181 9929180954 2374834 2374834 2374834.0000
-512 4181 3288532102 786542 786542 786542.0000
-select distinct mod(companynr,10) from t4 group by companynr;
-mod(companynr,10)
-0
-9
-4
-6
-7
-1
-3
-8
-5
-select distinct 1 from t4 group by companynr;
-1
-1
-select count(distinct fld1) from t2;
-count(distinct fld1)
-1199
-select companynr,count(distinct fld1) from t2 group by companynr;
-companynr count(distinct fld1)
-00 82
-29 95
-34 70
-36 215
-37 588
-40 37
-41 52
-50 11
-53 4
-58 23
-65 10
-68 12
-select companynr,count(*) from t2 group by companynr;
-companynr count(*)
-00 82
-29 95
-34 70
-36 215
-37 588
-40 37
-41 52
-50 11
-53 4
-58 23
-65 10
-68 12
-select companynr,count(distinct concat(fld1,repeat(65,1000))) from t2 group by companynr;
-companynr count(distinct concat(fld1,repeat(65,1000)))
-00 82
-29 95
-34 70
-36 215
-37 588
-40 37
-41 52
-50 11
-53 4
-58 23
-65 10
-68 12
-select companynr,count(distinct concat(fld1,repeat(65,200))) from t2 group by companynr;
-companynr count(distinct concat(fld1,repeat(65,200)))
-00 82
-29 95
-34 70
-36 215
-37 588
-40 37
-41 52
-50 11
-53 4
-58 23
-65 10
-68 12
-select companynr,count(distinct floor(fld1/100)) from t2 group by companynr;
-companynr count(distinct floor(fld1/100))
-00 47
-29 35
-34 14
-36 69
-37 108
-40 16
-41 11
-50 9
-53 1
-58 1
-65 1
-68 1
-select companynr,count(distinct concat(repeat(65,1000),floor(fld1/100))) from t2 group by companynr;
-companynr count(distinct concat(repeat(65,1000),floor(fld1/100)))
-00 47
-29 35
-34 14
-36 69
-37 108
-40 16
-41 11
-50 9
-53 1
-58 1
-65 1
-68 1
-select sum(fld1),fld3 from t2 where fld3="Romans" group by fld1 limit 10;
-sum(fld1) fld3
-11402 Romans
-select name,count(*) from t3 where name='cloakroom' group by name;
-name count(*)
-cloakroom 4181
-select name,count(*) from t3 where name='cloakroom' and price>10 group by name;
-name count(*)
-cloakroom 4181
-select count(*) from t3 where name='cloakroom' and price2=823742;
-count(*)
-4181
-select name,count(*) from t3 where name='cloakroom' and price2=823742 group by name;
-name count(*)
-cloakroom 4181
-select name,count(*) from t3 where name >= "extramarital" and price <= 39654943 group by name;
-name count(*)
-extramarital 4181
-gazer 4181
-gems 4181
-Iranizes 4181
-spates 4181
-tucked 4181
-violinist 4181
-select t2.fld3,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
-fld3 count(*)
-spates 4181
-select companynr|0,companyname from t4 group by 1;
-companynr|0 companyname
-0 Unknown
-29 company 1
-34 company 2
-36 company 3
-37 company 4
-40 company 5
-41 company 6
-50 company 11
-53 company 7
-58 company 8
-65 company 9
-68 company 10
-select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by t2.companynr order by companyname;
-companynr companyname count(*)
-29 company 1 95
-68 company 10 12
-50 company 11 11
-34 company 2 70
-36 company 3 215
-37 company 4 588
-40 company 5 37
-41 company 6 52
-53 company 7 4
-58 company 8 23
-65 company 9 10
-00 Unknown 82
-select t2.fld1,count(*) from t2,t3 where t2.fld1=158402 and t3.name=t2.fld3 group by t3.name;
-fld1 count(*)
-158402 4181
-select sum(Period)/count(*) from t1;
-sum(Period)/count(*)
-9410.0000
-select companynr,count(price) as "count",sum(price) as "sum" ,abs(sum(price)/count(price)-avg(price)) as "diff",(0+count(price))*companynr as func from t3 group by companynr;
-companynr count sum diff func
-37 12543 309394878010 0.0000 464091
-78 8362 414611089292 0.0000 652236
-101 4181 3489454238 0.0000 422281
-154 4181 4112197254950 0.0000 643874
-311 4181 979599938 0.0000 1300291
-447 4181 9929180954 0.0000 1868907
-512 4181 3288532102 0.0000 2140672
-select companynr,sum(price)/count(price) as avg from t3 group by companynr having avg > 70000000 order by avg;
-companynr avg
-154 983543950.0000
-select companynr,count(*) from t2 group by companynr order by 2 desc;
-companynr count(*)
-37 588
-36 215
-29 95
-00 82
-34 70
-41 52
-40 37
-58 23
-68 12
-50 11
-65 10
-53 4
-select companynr,count(*) from t2 where companynr > 40 group by companynr order by 2 desc;
-companynr count(*)
-41 52
-58 23
-68 12
-50 11
-65 10
-53 4
-select t2.fld4,t2.fld1,count(price),sum(price),min(price),max(price),avg(price) from t3,t2 where t3.companynr = 37 and t2.fld1 = t3.t2nr group by fld1,t2.fld4;
-fld4 fld1 count(price) sum(price) min(price) max(price) avg(price)
-teethe 000001 1 5987435 5987435 5987435 5987435.0000
-dreaded 011401 1 5987435 5987435 5987435 5987435.0000
-scholastics 011402 1 28357832 28357832 28357832 28357832.0000
-audiology 011403 1 39654943 39654943 39654943 39654943.0000
-wallet 011501 1 5987435 5987435 5987435 5987435.0000
-parters 011701 1 5987435 5987435 5987435 5987435.0000
-eschew 011702 1 28357832 28357832 28357832 28357832.0000
-quitter 011703 1 39654943 39654943 39654943 39654943.0000
-neat 012001 1 5987435 5987435 5987435 5987435.0000
-Steinberg 012003 1 39654943 39654943 39654943 39654943.0000
-balled 012301 1 5987435 5987435 5987435 5987435.0000
-persist 012302 1 28357832 28357832 28357832 28357832.0000
-attainments 012303 1 39654943 39654943 39654943 39654943.0000
-capably 012501 1 5987435 5987435 5987435 5987435.0000
-impulsive 012602 1 28357832 28357832 28357832 28357832.0000
-starlet 012603 1 39654943 39654943 39654943 39654943.0000
-featherweight 012701 1 5987435 5987435 5987435 5987435.0000
-pessimist 012702 1 28357832 28357832 28357832 28357832.0000
-daughter 012703 1 39654943 39654943 39654943 39654943.0000
-lawgiver 013601 1 5987435 5987435 5987435 5987435.0000
-stated 013602 1 28357832 28357832 28357832 28357832.0000
-readable 013603 1 39654943 39654943 39654943 39654943.0000
-testicle 013801 1 5987435 5987435 5987435 5987435.0000
-Parsifal 013802 1 28357832 28357832 28357832 28357832.0000
-leavings 013803 1 39654943 39654943 39654943 39654943.0000
-squeaking 013901 1 5987435 5987435 5987435 5987435.0000
-contrasted 016001 1 5987435 5987435 5987435 5987435.0000
-leftover 016201 1 5987435 5987435 5987435 5987435.0000
-whiteners 016202 1 28357832 28357832 28357832 28357832.0000
-erases 016301 1 5987435 5987435 5987435 5987435.0000
-Punjab 016302 1 28357832 28357832 28357832 28357832.0000
-Merritt 016303 1 39654943 39654943 39654943 39654943.0000
-sweetish 018001 1 5987435 5987435 5987435 5987435.0000
-dogging 018002 1 28357832 28357832 28357832 28357832.0000
-scornfully 018003 1 39654943 39654943 39654943 39654943.0000
-fetters 018012 1 28357832 28357832 28357832 28357832.0000
-bivalves 018013 1 39654943 39654943 39654943 39654943.0000
-skulking 018021 1 5987435 5987435 5987435 5987435.0000
-flint 018022 1 28357832 28357832 28357832 28357832.0000
-flopping 018023 1 39654943 39654943 39654943 39654943.0000
-Judas 018032 1 28357832 28357832 28357832 28357832.0000
-vacuuming 018033 1 39654943 39654943 39654943 39654943.0000
-medical 018041 1 5987435 5987435 5987435 5987435.0000
-bloodbath 018042 1 28357832 28357832 28357832 28357832.0000
-subschema 018043 1 39654943 39654943 39654943 39654943.0000
-interdependent 018051 1 5987435 5987435 5987435 5987435.0000
-Graves 018052 1 28357832 28357832 28357832 28357832.0000
-neonatal 018053 1 39654943 39654943 39654943 39654943.0000
-sorters 018061 1 5987435 5987435 5987435 5987435.0000
-epistle 018062 1 28357832 28357832 28357832 28357832.0000
-Conley 018101 1 5987435 5987435 5987435 5987435.0000
-lectured 018102 1 28357832 28357832 28357832 28357832.0000
-Abraham 018103 1 39654943 39654943 39654943 39654943.0000
-cage 018201 1 5987435 5987435 5987435 5987435.0000
-hushes 018202 1 28357832 28357832 28357832 28357832.0000
-Simla 018402 1 28357832 28357832 28357832 28357832.0000
-reporters 018403 1 39654943 39654943 39654943 39654943.0000
-coexist 018601 1 5987435 5987435 5987435 5987435.0000
-Beebe 018602 1 28357832 28357832 28357832 28357832.0000
-Taoism 018603 1 39654943 39654943 39654943 39654943.0000
-Connally 018801 1 5987435 5987435 5987435 5987435.0000
-fetched 018802 1 28357832 28357832 28357832 28357832.0000
-checkpoints 018803 1 39654943 39654943 39654943 39654943.0000
-gritty 018811 1 5987435 5987435 5987435 5987435.0000
-firearm 018812 1 28357832 28357832 28357832 28357832.0000
-minima 019101 1 5987435 5987435 5987435 5987435.0000
-Selfridge 019102 1 28357832 28357832 28357832 28357832.0000
-disable 019103 1 39654943 39654943 39654943 39654943.0000
-witchcraft 019201 1 5987435 5987435 5987435 5987435.0000
-betroth 030501 1 5987435 5987435 5987435 5987435.0000
-Manhattanize 030502 1 28357832 28357832 28357832 28357832.0000
-imprint 030503 1 39654943 39654943 39654943 39654943.0000
-swelling 031901 1 5987435 5987435 5987435 5987435.0000
-interrelationships 036001 1 5987435 5987435 5987435 5987435.0000
-riser 036002 1 28357832 28357832 28357832 28357832.0000
-bee 038001 1 5987435 5987435 5987435 5987435.0000
-kanji 038002 1 28357832 28357832 28357832 28357832.0000
-dental 038003 1 39654943 39654943 39654943 39654943.0000
-railway 038011 1 5987435 5987435 5987435 5987435.0000
-validate 038012 1 28357832 28357832 28357832 28357832.0000
-normalizes 038013 1 39654943 39654943 39654943 39654943.0000
-Kline 038101 1 5987435 5987435 5987435 5987435.0000
-Anatole 038102 1 28357832 28357832 28357832 28357832.0000
-partridges 038103 1 39654943 39654943 39654943 39654943.0000
-recruited 038201 1 5987435 5987435 5987435 5987435.0000
-dimensions 038202 1 28357832 28357832 28357832 28357832.0000
-Chicana 038203 1 39654943 39654943 39654943 39654943.0000
-select t3.companynr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 group by companynr,fld3;
-companynr fld3 sum(price)
-512 boat 786542
-512 capably 786542
-512 cupboard 786542
-512 decliner 786542
-512 descendants 786542
-512 dopers 786542
-512 erases 786542
-512 Micronesia 786542
-512 Miles 786542
-512 skies 786542
-select t2.companynr,count(*),min(fld3),max(fld3),sum(price),avg(price) from t2,t3 where t3.companynr >= 30 and t3.companynr <= 58 and t3.t2nr = t2.fld1 and 1+1=2 group by t2.companynr;
-companynr count(*) min(fld3) max(fld3) sum(price) avg(price)
-00 1 Omaha Omaha 5987435 5987435.0000
-36 1 dubbed dubbed 28357832 28357832.0000
-37 83 Abraham Wotan 1908978016 22999735.1325
-50 2 scribbled tapestry 68012775 34006387.5000
-select t3.companynr+0,t3.t2nr,fld3,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 37 group by 1,t3.t2nr,fld3,fld3,fld3,fld3,fld3 order by fld1;
-t3.companynr+0 t2nr fld3 sum(price)
-37 1 Omaha 5987435
-37 11401 breaking 5987435
-37 11402 Romans 28357832
-37 11403 intercepted 39654943
-37 11501 bewilderingly 5987435
-37 11701 astound 5987435
-37 11702 admonishing 28357832
-37 11703 sumac 39654943
-37 12001 flanking 5987435
-37 12003 combed 39654943
-37 12301 Eulerian 5987435
-37 12302 dubbed 28357832
-37 12303 Kane 39654943
-37 12501 annihilates 5987435
-37 12602 Wotan 28357832
-37 12603 snatching 39654943
-37 12701 grazing 5987435
-37 12702 Baird 28357832
-37 12703 celery 39654943
-37 13601 handgun 5987435
-37 13602 foldout 28357832
-37 13603 mystic 39654943
-37 13801 intelligibility 5987435
-37 13802 Augustine 28357832
-37 13803 teethe 39654943
-37 13901 scholastics 5987435
-37 16001 audiology 5987435
-37 16201 wallet 5987435
-37 16202 parters 28357832
-37 16301 eschew 5987435
-37 16302 quitter 28357832
-37 16303 neat 39654943
-37 18001 jarring 5987435
-37 18002 tinily 28357832
-37 18003 balled 39654943
-37 18012 impulsive 28357832
-37 18013 starlet 39654943
-37 18021 lawgiver 5987435
-37 18022 stated 28357832
-37 18023 readable 39654943
-37 18032 testicle 28357832
-37 18033 Parsifal 39654943
-37 18041 Punjab 5987435
-37 18042 Merritt 28357832
-37 18043 Quixotism 39654943
-37 18051 sureties 5987435
-37 18052 puddings 28357832
-37 18053 tapestry 39654943
-37 18061 trimmings 5987435
-37 18062 humility 28357832
-37 18101 tragedies 5987435
-37 18102 skulking 28357832
-37 18103 flint 39654943
-37 18201 relaxing 5987435
-37 18202 offload 28357832
-37 18402 suites 28357832
-37 18403 lists 39654943
-37 18601 vacuuming 5987435
-37 18602 dentally 28357832
-37 18603 humanness 39654943
-37 18801 inch 5987435
-37 18802 Weissmuller 28357832
-37 18803 irresponsibly 39654943
-37 18811 repetitions 5987435
-37 18812 Antares 28357832
-37 19101 ventilate 5987435
-37 19102 pityingly 28357832
-37 19103 interdependent 39654943
-37 19201 Graves 5987435
-37 30501 neonatal 5987435
-37 30502 scribbled 28357832
-37 30503 chafe 39654943
-37 31901 realtor 5987435
-37 36001 elite 5987435
-37 36002 funereal 28357832
-37 38001 Conley 5987435
-37 38002 lectured 28357832
-37 38003 Abraham 39654943
-37 38011 groupings 5987435
-37 38012 dissociate 28357832
-37 38013 coexist 39654943
-37 38101 rusting 5987435
-37 38102 galling 28357832
-37 38103 obliterates 39654943
-37 38201 resumes 5987435
-37 38202 analyzable 28357832
-37 38203 terminator 39654943
-select sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1= t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008;
-sum(price)
-234298
-select t2.fld1,sum(price) from t3,t2 where t2.fld1 = t3.t2nr and t3.companynr = 512 and t3.t2nr = 38008 and t2.fld1 = 38008 or t2.fld1 = t3.t2nr and t3.t2nr = 38008 and t2.fld1 = 38008 or t3.t2nr = t2.fld1 and t2.fld1 = 38008 group by t2.fld1;
-fld1 sum(price)
-038008 234298
-explain select fld3 from t2 where 1>2 or 2>3;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
-explain select fld3 from t2 where fld1=fld1;
-id select_type table type possible_keys key key_len ref rows Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 1199
-select companynr,fld1 from t2 HAVING fld1=250501 or fld1=250502;
-companynr fld1
-34 250501
-34 250502
-select companynr,fld1 from t2 WHERE fld1>=250501 HAVING fld1<=250502;
-companynr fld1
-34 250501
-34 250502
-select companynr,count(*) as count,sum(fld1) as sum from t2 group by companynr having count > 40 and sum/count >= 120000;
-companynr count sum
-00 82 10355753
-29 95 14473298
-34 70 17788966
-37 588 83602098
-41 52 12816335
-select companynr from t2 group by companynr having count(*) > 40 and sum(fld1)/count(*) >= 120000 ;
-companynr
-00
-29
-34
-37
-41
-select t2.companynr,companyname,count(*) from t2,t4 where t2.companynr=t4.companynr group by companyname having t2.companynr >= 40;
-companynr companyname count(*)
-68 company 10 12
-50 company 11 11
-40 company 5 37
-41 company 6 52
-53 company 7 4
-58 company 8 23
-65 company 9 10
-select count(*) from t2;
-count(*)
-1199
-select count(*) from t2 where fld1 < 098024;
-count(*)
-387
-select min(fld1) from t2 where fld1>= 098024;
-min(fld1)
-98024
-select max(fld1) from t2 where fld1>= 098024;
-max(fld1)
-1232609
-select count(*) from t3 where price2=76234234;
-count(*)
-4181
-select count(*) from t3 where companynr=512 and price2=76234234;
-count(*)
-4181
-explain select min(fld1),max(fld1),count(*) from t2;
-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
-select min(fld1),max(fld1),count(*) from t2;
-min(fld1) max(fld1) count(*)
-0 1232609 1199
-select min(t2nr),max(t2nr) from t3 where t2nr=2115 and price2=823742;
-min(t2nr) max(t2nr)
-2115 2115
-select count(*),min(t2nr),max(t2nr) from t3 where name='spates' and companynr=78;
-count(*) min(t2nr) max(t2nr)
-4181 4 41804
-select t2nr,count(*) from t3 where name='gems' group by t2nr limit 20;
-t2nr count(*)
-9 1
-19 1
-29 1
-39 1
-49 1
-59 1
-69 1
-79 1
-89 1
-99 1
-109 1
-119 1
-129 1
-139 1
-149 1
-159 1
-169 1
-179 1
-189 1
-199 1
-select max(t2nr) from t3 where price=983543950;
-max(t2nr)
-41807
-select t1.period from t3 = t1 limit 1;
-period
-1001
-select t1.period from t1 as t1 limit 1;
-period
-9410
-select t1.period as "Nuvarande period" from t1 as t1 limit 1;
-Nuvarande period
-9410
-select period as ok_period from t1 limit 1;
-ok_period
-9410
-select period as ok_period from t1 group by ok_period limit 1;
-ok_period
-9410
-select 1+1 as summa from t1 group by summa limit 1;
-summa
-2
-select period as "Nuvarande period" from t1 group by "Nuvarande period" limit 1;
-Nuvarande period
-9410
-show tables;
-Tables_in_test
-t1
-t2
-t3
-t4
-show tables from test like "s%";
-Tables_in_test (s%)
-show tables from test like "t?";
-Tables_in_test (t?)
-show full columns from t2;
-Field Type Collation Null Key Default Extra Privileges Comment
-auto int(11) NULL NO PRI NULL auto_increment #
-fld1 int(6) unsigned zerofill NULL NO UNI 000000 #
-companynr tinyint(2) unsigned zerofill NULL NO 00 #
-fld3 char(30) latin1_swedish_ci NO MUL #
-fld4 char(35) latin1_swedish_ci NO #
-fld5 char(35) latin1_swedish_ci NO #
-fld6 char(4) latin1_swedish_ci NO #
-show full columns from t2 from test like 'f%';
-Field Type Collation Null Key Default Extra Privileges Comment
-fld1 int(6) unsigned zerofill NULL NO UNI 000000 #
-fld3 char(30) latin1_swedish_ci NO MUL #
-fld4 char(35) latin1_swedish_ci NO #
-fld5 char(35) latin1_swedish_ci NO #
-fld6 char(4) latin1_swedish_ci NO #
-show full columns from t2 from test like 's%';
-Field Type Collation Null Key Default Extra Privileges Comment
-show keys from t2;
-Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
-t2 0 PRIMARY 1 auto A 1199 NULL NULL BTREE
-t2 0 fld1 1 fld1 A 1199 NULL NULL BTREE
-t2 1 fld3 1 fld3 A NULL NULL NULL BTREE
-drop table t4, t3, t2, t1;
-CREATE TABLE t1 (
-cont_nr int(11) NOT NULL auto_increment,
-ver_nr int(11) NOT NULL default '0',
-aufnr int(11) NOT NULL default '0',
-username varchar(50) NOT NULL default '',
-hdl_nr int(11) NOT NULL default '0',
-eintrag date NOT NULL default '0000-00-00',
-st_klasse varchar(40) NOT NULL default '',
-st_wert varchar(40) NOT NULL default '',
-st_zusatz varchar(40) NOT NULL default '',
-st_bemerkung varchar(255) NOT NULL default '',
-kunden_art varchar(40) NOT NULL default '',
-mcbs_knr int(11) default NULL,
-mcbs_aufnr int(11) NOT NULL default '0',
-schufa_status char(1) default '?',
-bemerkung text,
-wirknetz text,
-wf_igz int(11) NOT NULL default '0',
-tarifcode varchar(80) default NULL,
-recycle char(1) default NULL,
-sim varchar(30) default NULL,
-mcbs_tpl varchar(30) default NULL,
-emp_nr int(11) NOT NULL default '0',
-laufzeit int(11) default NULL,
-hdl_name varchar(30) default NULL,
-prov_hdl_nr int(11) NOT NULL default '0',
-auto_wirknetz varchar(50) default NULL,
-auto_billing varchar(50) default NULL,
-touch timestamp NOT NULL,
-kategorie varchar(50) default NULL,
-kundentyp varchar(20) NOT NULL default '',
-sammel_rech_msisdn varchar(30) NOT NULL default '',
-p_nr varchar(9) NOT NULL default '',
-suffix char(3) NOT NULL default '',
-PRIMARY KEY (cont_nr),
-KEY idx_aufnr(aufnr),
-KEY idx_hdl_nr(hdl_nr),
-KEY idx_st_klasse(st_klasse),
-KEY ver_nr(ver_nr),
-KEY eintrag_idx(eintrag),
-KEY emp_nr_idx(emp_nr),
-KEY wf_igz(wf_igz),
-KEY touch(touch),
-KEY hdl_tag(eintrag,hdl_nr),
-KEY prov_hdl_nr(prov_hdl_nr),
-KEY mcbs_aufnr(mcbs_aufnr),
-KEY kundentyp(kundentyp),
-KEY p_nr(p_nr,suffix)
-) ENGINE=MyISAM;
-INSERT INTO t1 VALUES (3359356,405,3359356,'Mustermann Musterfrau',52500,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1485525,2122316,'+','','N',1909160,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',3,24,'MobilCom Shop Koeln',52500,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
-INSERT INTO t1 VALUES (3359357,468,3359357,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1503580,2139699,'+','','P',1909171,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
-INSERT INTO t1 VALUES (3359358,407,3359358,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1501358,2137473,'N','','N',1909159,'MobilComSuper92000D2',NULL,NULL,'MS9ND2',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
-INSERT INTO t1 VALUES (3359359,468,3359359,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1507831,2143894,'+','','P',1909162,'MobilComSuper9D1T10SFreisprech(Akquise)',NULL,NULL,'MS9NS1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
-INSERT INTO t1 VALUES (3359360,0,0,'Mustermann Musterfrau',29674907,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1900169997,2414578,'+',NULL,'N',1909148,'',NULL,NULL,'RV99066_2',20,NULL,'POS',29674907,NULL,NULL,20010202105916,'Mobilfunk','','','97317481','007');
-INSERT INTO t1 VALUES (3359361,406,3359361,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag storniert','','(7001-84):Storno, Kd. möchte nicht mehr','privat',NULL,0,'+','','P',1909150,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',325,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
-INSERT INTO t1 VALUES (3359362,406,3359362,'Mustermann Musterfrau',7001,'2000-05-20','workflow','Auftrag erledigt','Originalvertrag eingegangen und geprüft','','privat',1509984,2145874,'+','','P',1909154,'MobilComSuper92000D1(Akquise)',NULL,NULL,'MS9ND1',327,24,'MobilCom Intern',7003,NULL,'auto',20010202105916,'Mobilfunk','PP','','','');
-SELECT ELT(FIELD(kundentyp,'PP','PPA','PG','PGA','FK','FKA','FP','FPA','K','KA','V','VA',''), 'Privat (Private Nutzung)','Privat (Private Nutzung) Sitz im Ausland','Privat (geschaeftliche Nutzung)','Privat (geschaeftliche Nutzung) Sitz im Ausland','Firma (Kapitalgesellschaft)','Firma (Kapitalgesellschaft) Sitz im Ausland','Firma (Personengesellschaft)','Firma (Personengesellschaft) Sitz im Ausland','oeff. rechtl. Koerperschaft','oeff. rechtl. Koerperschaft Sitz im Ausland','Eingetragener Verein','Eingetragener Verein Sitz im Ausland','Typ unbekannt') AS Kundentyp ,kategorie FROM t1 WHERE hdl_nr < 2000000 AND kategorie IN ('Prepaid','Mobilfunk') AND st_klasse = 'Workflow' GROUP BY kundentyp ORDER BY kategorie;
-Kundentyp kategorie
-Privat (Private Nutzung) Mobilfunk
-Warnings:
-Warning 1052 Column 'kundentyp' in group statement is ambiguous
-drop table t1;
-connection default;
-disconnect shm_con;
-mysqld is alive
-SET @max_allowed_packet= @@global.max_allowed_packet;
-SET @net_buffer_length= @@global.net_buffer_length;
-SET GLOBAL max_allowed_packet= 1024;
-Warnings:
-Warning 1708 The value of 'max_allowed_packet' should be no less than the value of 'net_buffer_length'
-SET GLOBAL net_buffer_length= 1024;
-ERROR 1153 (08S01) at line 1: Got a packet bigger than 'max_allowed_packet' bytes
-SET GLOBAL max_allowed_packet= @max_allowed_packet;
-SET GLOBAL net_buffer_length= @net_buffer_length;
-End of 5.0 tests.
diff --git a/mysql-test/main/shm.test b/mysql-test/main/shm.test
deleted file mode 100644
index 346ce49476e..00000000000
--- a/mysql-test/main/shm.test
+++ /dev/null
@@ -1,47 +0,0 @@
-# We currently only have shm support on windows, so in order
-# to optimize things we skip this test on all other platforms
---source include/windows.inc
-
-# thread pool causes different results
--- source include/not_threadpool.inc
-
-# Only run this test if shared memory is avaliable
-let $shm= query_get_value("SHOW VARIABLES LIKE 'shared_memory'", Value, 1);
-if ($shm != ON){
- skip No shm support;
-}
-let $shm_name= query_get_value("SHOW GLOBAL VARIABLES LIKE 'shared_memory_base_name'", Value, 1);
-
-# Connect using SHM for testing
-connect(shm_con,localhost,root,,,,$shm_name,SHM);
-
-# Source select test case
--- source include/common-tests.inc
-
-connection default;
-disconnect shm_con;
-
-#
-# Bug #24924: shared-memory-base-name that is too long causes buffer overflow
-#
---exec $MYSQLADMIN --user=root --host=127.0.0.1 --port=$MASTER_MYPORT --shared-memory-base-name=HeyMrBaseNameXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ping
-
-#
-# Bug #33899: Deadlock in mysql_real_query with shared memory connections
-#
-
-let $stmt= `SELECT REPEAT('a', 2048)`;
-
-SET @max_allowed_packet= @@global.max_allowed_packet;
-SET @net_buffer_length= @@global.net_buffer_length;
-
-SET GLOBAL max_allowed_packet= 1024;
-SET GLOBAL net_buffer_length= 1024;
-
---error 1
---exec echo SELECT '$stmt'| $MYSQL --protocol=memory --shared-memory-base-name=$shm_name 2>&1
-
-SET GLOBAL max_allowed_packet= @max_allowed_packet;
-SET GLOBAL net_buffer_length= @net_buffer_length;
-
---echo End of 5.0 tests.
diff --git a/mysql-test/main/show_create_user.result b/mysql-test/main/show_create_user.result
index 63013eca074..1205b658b6e 100644
--- a/mysql-test/main/show_create_user.result
+++ b/mysql-test/main/show_create_user.result
@@ -10,10 +10,10 @@ create user foo2@test identified by 'password';
show create user foo2@test;
CREATE USER for foo2@test
CREATE USER 'foo2'@'test' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19'
-alter user foo2@test identified with 'someplugin' as 'somepassword';
+alter user foo2@test identified with 'mysql_old_password' as '0123456789ABCDEF';
show create user foo2@test;
CREATE USER for foo2@test
-CREATE USER 'foo2'@'test' IDENTIFIED VIA someplugin USING 'somepassword'
+CREATE USER 'foo2'@'test' IDENTIFIED BY PASSWORD '0123456789ABCDEF'
create user foo3@test require SSL;
show create user foo3@test;
CREATE USER for foo3@test
diff --git a/mysql-test/main/show_create_user.test b/mysql-test/main/show_create_user.test
index a10c8aeeda6..03852b5abbc 100644
--- a/mysql-test/main/show_create_user.test
+++ b/mysql-test/main/show_create_user.test
@@ -9,7 +9,7 @@ show create user foo@test;
create user foo2@test identified by 'password';
show create user foo2@test;
-alter user foo2@test identified with 'someplugin' as 'somepassword';
+alter user foo2@test identified with 'mysql_old_password' as '0123456789ABCDEF';
show create user foo2@test;
create user foo3@test require SSL;
diff --git a/mysql-test/main/show_grants_with_plugin-7985.result b/mysql-test/main/show_grants_with_plugin-7985.result
index 0f8e1e39969..14d7b98bcf4 100644
--- a/mysql-test/main/show_grants_with_plugin-7985.result
+++ b/mysql-test/main/show_grants_with_plugin-7985.result
@@ -7,7 +7,7 @@ create user u1;
GRANT SELECT ON mysql.* to u1 IDENTIFIED VIA mysql_native_password;
select user, host, password, plugin, authentication_string from mysql.user where user = 'u1';
user host password plugin authentication_string
-u1 %
+u1 % mysql_native_password
#
# The user's grants should show no password at all.
#
@@ -43,7 +43,7 @@ GRANT SELECT ON mysql.* to u1 IDENTIFIED VIA mysql_native_password
USING '*7AFEFD08B6B720E781FB000CAA418F54FA662626';
select user, host, password, plugin, authentication_string from mysql.user where user = 'u1';
user host password plugin authentication_string
-u1 % *7AFEFD08B6B720E781FB000CAA418F54FA662626
+u1 % mysql_native_password *7AFEFD08B6B720E781FB000CAA418F54FA662626
#
# Test to see if connecting with password is succesful.
#
diff --git a/mysql-test/main/sp-destruct.test b/mysql-test/main/sp-destruct.test
index 8870df29299..12299fa230b 100644
--- a/mysql-test/main/sp-destruct.test
+++ b/mysql-test/main/sp-destruct.test
@@ -17,8 +17,8 @@ call mtr.add_suppression("Stored routine .test...bug14233_[123].: invalid value
let $MYSQLD_DATADIR= `select @@datadir`;
flush table mysql.proc;
--copy_file $MYSQLD_DATADIR/mysql/proc.frm $MYSQLTEST_VARDIR/tmp/proc.frm
---copy_file $MYSQLD_DATADIR/mysql/proc.MYD $MYSQLTEST_VARDIR/tmp/proc.MYD
---copy_file $MYSQLD_DATADIR/mysql/proc.MYI $MYSQLTEST_VARDIR/tmp/proc.MYI
+--copy_file $MYSQLD_DATADIR/mysql/proc.MAD $MYSQLTEST_VARDIR/tmp/proc.MAD
+--copy_file $MYSQLD_DATADIR/mysql/proc.MAI $MYSQLTEST_VARDIR/tmp/proc.MAI
use test;
@@ -70,8 +70,8 @@ flush table mysql.proc;
# Drop the mysql.proc table
--remove_file $MYSQLD_DATADIR/mysql/proc.frm
---remove_file $MYSQLD_DATADIR/mysql/proc.MYD
---remove_file $MYSQLD_DATADIR/mysql/proc.MYI
+--remove_file $MYSQLD_DATADIR/mysql/proc.MAD
+--remove_file $MYSQLD_DATADIR/mysql/proc.MAI
--error ER_NO_SUCH_TABLE
call bug14233();
--error ER_NO_SUCH_TABLE
@@ -81,11 +81,11 @@ insert into t1 values (0);
# Restore mysql.proc
--copy_file $MYSQLTEST_VARDIR/tmp/proc.frm $MYSQLD_DATADIR/mysql/proc.frm
---copy_file $MYSQLTEST_VARDIR/tmp/proc.MYD $MYSQLD_DATADIR/mysql/proc.MYD
---copy_file $MYSQLTEST_VARDIR/tmp/proc.MYI $MYSQLD_DATADIR/mysql/proc.MYI
+--copy_file $MYSQLTEST_VARDIR/tmp/proc.MAD $MYSQLD_DATADIR/mysql/proc.MAD
+--copy_file $MYSQLTEST_VARDIR/tmp/proc.MAI $MYSQLD_DATADIR/mysql/proc.MAI
--remove_file $MYSQLTEST_VARDIR/tmp/proc.frm
---remove_file $MYSQLTEST_VARDIR/tmp/proc.MYD
---remove_file $MYSQLTEST_VARDIR/tmp/proc.MYI
+--remove_file $MYSQLTEST_VARDIR/tmp/proc.MAD
+--remove_file $MYSQLTEST_VARDIR/tmp/proc.MAI
flush table mysql.proc;
flush privileges;
@@ -233,8 +233,8 @@ drop database if exists mysqltest;
flush table mysql.proc;
let $MYSQLD_DATADIR= `select @@datadir`;
--copy_file $MYSQLD_DATADIR/mysql/proc.frm $MYSQLTEST_VARDIR/tmp/proc.frm
---copy_file $MYSQLD_DATADIR/mysql/proc.MYD $MYSQLTEST_VARDIR/tmp/proc.MYD
---copy_file $MYSQLD_DATADIR/mysql/proc.MYI $MYSQLTEST_VARDIR/tmp/proc.MYI
+--copy_file $MYSQLD_DATADIR/mysql/proc.MAD $MYSQLTEST_VARDIR/tmp/proc.MAD
+--copy_file $MYSQLD_DATADIR/mysql/proc.MAI $MYSQLTEST_VARDIR/tmp/proc.MAI
create database mysqltest;
--echo # Corrupt mysql.proc to make it unusable by current version of server.
@@ -245,11 +245,11 @@ drop database mysqltest;
--echo # Restore mysql.proc.
drop table mysql.proc;
--copy_file $MYSQLTEST_VARDIR/tmp/proc.frm $MYSQLD_DATADIR/mysql/proc.frm
---copy_file $MYSQLTEST_VARDIR/tmp/proc.MYD $MYSQLD_DATADIR/mysql/proc.MYD
---copy_file $MYSQLTEST_VARDIR/tmp/proc.MYI $MYSQLD_DATADIR/mysql/proc.MYI
+--copy_file $MYSQLTEST_VARDIR/tmp/proc.MAD $MYSQLD_DATADIR/mysql/proc.MAD
+--copy_file $MYSQLTEST_VARDIR/tmp/proc.MAI $MYSQLD_DATADIR/mysql/proc.MAI
--remove_file $MYSQLTEST_VARDIR/tmp/proc.frm
---remove_file $MYSQLTEST_VARDIR/tmp/proc.MYD
---remove_file $MYSQLTEST_VARDIR/tmp/proc.MYI
+--remove_file $MYSQLTEST_VARDIR/tmp/proc.MAD
+--remove_file $MYSQLTEST_VARDIR/tmp/proc.MAI
--echo #
diff --git a/mysql-test/main/sp-security.result b/mysql-test/main/sp-security.result
index 7813ab6a192..051fbf3a7e8 100644
--- a/mysql-test/main/sp-security.result
+++ b/mysql-test/main/sp-security.result
@@ -506,9 +506,9 @@ DROP DATABASE mysqltest;
GRANT USAGE ON *.* TO user19857@localhost IDENTIFIED BY 'meow';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE ROUTINE, ALTER ROUTINE ON test.* TO
user19857@localhost;
-SELECT Host,User,Password FROM mysql.user WHERE User='user19857';
-Host User Password
-localhost user19857 *82DC221D557298F6CE9961037DB1C90604792F5C
+SELECT Host,User,Plugin,Authentication_string FROM mysql.user WHERE User='user19857';
+Host User Plugin Authentication_string
+localhost user19857 mysql_native_password *82DC221D557298F6CE9961037DB1C90604792F5C
connect mysqltest_2_con,localhost,user19857,meow,test;
connection mysqltest_2_con;
USE test;
@@ -533,9 +533,9 @@ connection mysqltest_2_con;
DROP PROCEDURE IF EXISTS test.sp19857;
connection con1root;
disconnect mysqltest_2_con;
-SELECT Host,User,Password FROM mysql.user WHERE User='user19857';
-Host User Password
-localhost user19857 *82DC221D557298F6CE9961037DB1C90604792F5C
+SELECT Host,User,Plugin,Authentication_string FROM mysql.user WHERE User='user19857';
+Host User Plugin Authentication_string
+localhost user19857 mysql_native_password *82DC221D557298F6CE9961037DB1C90604792F5C
DROP USER user19857@localhost;
disconnect con1root;
connection default;
@@ -710,6 +710,30 @@ connection default;
disconnect con2;
DROP USER user2@localhost;
DROP DATABASE db1;
+create user foo@local_ost;
+create user foo@`local\_ost` identified via mysql_old_password using '0123456789ABCDEF';
+create database foodb;
+grant create routine on foodb.* to foo@local_ost;
+connect con1,localhost,foo;
+select user(), current_user();
+user() current_user()
+foo@localhost foo@local_ost
+show grants;
+Grants for foo@local_ost
+GRANT USAGE ON *.* TO 'foo'@'local_ost'
+GRANT CREATE ROUTINE ON `foodb`.* TO 'foo'@'local_ost'
+create procedure fooproc() select 'i am fooproc';
+show grants;
+Grants for foo@local_ost
+GRANT USAGE ON *.* TO 'foo'@'local_ost'
+GRANT CREATE ROUTINE ON `foodb`.* TO 'foo'@'local_ost'
+GRANT EXECUTE, ALTER ROUTINE ON PROCEDURE `test`.`fooproc` TO 'foo'@'local_ost'
+disconnect con1;
+connection default;
+drop user foo@local_ost;
+drop user foo@`local\_ost`;
+drop procedure fooproc;
+drop database foodb;
#
# Test for bug#12602983 - User without privilege on routine can discover
# its existence by executing "select non_existing_func();" or by
diff --git a/mysql-test/main/sp-security.test b/mysql-test/main/sp-security.test
index 73d0263dd69..dd917eed671 100644
--- a/mysql-test/main/sp-security.test
+++ b/mysql-test/main/sp-security.test
@@ -742,7 +742,7 @@ DROP DATABASE mysqltest;
GRANT USAGE ON *.* TO user19857@localhost IDENTIFIED BY 'meow';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE ROUTINE, ALTER ROUTINE ON test.* TO
user19857@localhost;
-SELECT Host,User,Password FROM mysql.user WHERE User='user19857';
+SELECT Host,User,Plugin,Authentication_string FROM mysql.user WHERE User='user19857';
--connect (mysqltest_2_con,localhost,user19857,meow,test)
--connection mysqltest_2_con
@@ -770,7 +770,7 @@ DROP PROCEDURE IF EXISTS test.sp19857;
--disconnect mysqltest_2_con
-SELECT Host,User,Password FROM mysql.user WHERE User='user19857';
+SELECT Host,User,Plugin,Authentication_string FROM mysql.user WHERE User='user19857';
DROP USER user19857@localhost;
@@ -973,6 +973,25 @@ disconnect con2;
DROP USER user2@localhost;
DROP DATABASE db1;
+#
+# Bug#27407480: AUTOMATIC_SP_PRIVILEGES REQUIRES NEED THE INSERT PRIVILEGES FOR MYSQL.USER TABLE
+#
+create user foo@local_ost;
+create user foo@`local\_ost` identified via mysql_old_password using '0123456789ABCDEF';
+create database foodb;
+grant create routine on foodb.* to foo@local_ost;
+connect con1,localhost,foo;
+select user(), current_user();
+show grants;
+create procedure fooproc() select 'i am fooproc';
+show grants;
+disconnect con1;
+connection default;
+drop user foo@local_ost;
+drop user foo@`local\_ost`;
+drop procedure fooproc;
+drop database foodb;
+
--echo #
--echo # Test for bug#12602983 - User without privilege on routine can discover
--echo # its existence by executing "select non_existing_func();" or by
diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result
index ac4840cb37b..16b0b1d60e5 100644
--- a/mysql-test/main/sp.result
+++ b/mysql-test/main/sp.result
@@ -7878,6 +7878,23 @@ SET S.CLOSE_YN = ''
where 1=1;
drop function if exists f1;
drop table t1,t2;
+#
+# MDEV-16957: Server crashes in Field_iterator_natural_join::next
+# upon 2nd execution of SP
+#
+CREATE TABLE t1 (a INT, b VARCHAR(32));
+CREATE PROCEDURE sp() SELECT * FROM t1 AS t1x JOIN t1 AS t1y USING (c);
+CALL sp;
+ERROR 42S22: Unknown column 'c' in 'from clause'
+CALL sp;
+ERROR 42S22: Unknown column 'c' in 'from clause'
+CALL sp;
+ERROR 42S22: Unknown column 'c' in 'from clause'
+alter table t1 add column c int;
+CALL sp;
+c a b a b
+DROP PROCEDURE sp;
+DROP TABLE t1;
# End of 5.5 test
#
# MDEV-7040: Crash in field_conv, memcpy_field_possible, part#2
diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test
index 5f18f6585a7..4f520f321c5 100644
--- a/mysql-test/main/sp.test
+++ b/mysql-test/main/sp.test
@@ -9332,6 +9332,27 @@ where 1=1;
drop function if exists f1;
drop table t1,t2;
+--echo #
+--echo # MDEV-16957: Server crashes in Field_iterator_natural_join::next
+--echo # upon 2nd execution of SP
+--echo #
+
+CREATE TABLE t1 (a INT, b VARCHAR(32));
+CREATE PROCEDURE sp() SELECT * FROM t1 AS t1x JOIN t1 AS t1y USING (c);
+--error ER_BAD_FIELD_ERROR
+CALL sp;
+--error ER_BAD_FIELD_ERROR
+CALL sp;
+--error ER_BAD_FIELD_ERROR
+CALL sp;
+alter table t1 add column c int;
+CALL sp;
+
+# Cleanup
+DROP PROCEDURE sp;
+DROP TABLE t1;
+
+
--echo # End of 5.5 test
--echo #
diff --git a/mysql-test/main/sp_notembedded.result b/mysql-test/main/sp_notembedded.result
index 190f8f78d23..860f82ebd93 100644
--- a/mysql-test/main/sp_notembedded.result
+++ b/mysql-test/main/sp_notembedded.result
@@ -228,8 +228,6 @@ FLUSH PRIVILEGES;
connect con1, localhost, mysqltest_1,,;
connection con1;
CREATE PROCEDURE p1(i INT) BEGIN END;
-Warnings:
-Warning 1404 Failed to grant EXECUTE and ALTER ROUTINE privileges
disconnect con1;
connection default;
DROP PROCEDURE p1;
@@ -326,7 +324,7 @@ DROP EVENT teste_bug11763507;
# -- End of 5.1 tests
# ------------------------------------------------------------------
grant create routine on test.* to foo1@localhost identified by 'foo';
-update mysql.user set password = replace(password, '*', '-') where user='foo1';
+update mysql.user set authentication_string = replace(authentication_string, '*', '-') where user='foo1';
connect foo,localhost,foo1,foo;
show grants;
Grants for foo1@localhost
diff --git a/mysql-test/main/sp_notembedded.test b/mysql-test/main/sp_notembedded.test
index 41bfd871c39..64f1daeaeb9 100644
--- a/mysql-test/main/sp_notembedded.test
+++ b/mysql-test/main/sp_notembedded.test
@@ -465,7 +465,7 @@ DROP EVENT teste_bug11763507;
# (creating a new procedure changes the password)
#
grant create routine on test.* to foo1@localhost identified by 'foo';
-update mysql.user set password = replace(password, '*', '-') where user='foo1';
+update mysql.user set authentication_string = replace(authentication_string, '*', '-') where user='foo1';
--connect (foo,localhost,foo1,foo)
show grants;
--connection default
diff --git a/mysql-test/main/sql_safe_updates.opt b/mysql-test/main/sql_safe_updates.opt
new file mode 100644
index 00000000000..7ffaa462d01
--- /dev/null
+++ b/mysql-test/main/sql_safe_updates.opt
@@ -0,0 +1 @@
+--enable-sql-safe-updates
diff --git a/mysql-test/main/sql_safe_updates.result b/mysql-test/main/sql_safe_updates.result
new file mode 100644
index 00000000000..356cd36bad9
--- /dev/null
+++ b/mysql-test/main/sql_safe_updates.result
@@ -0,0 +1,3 @@
+select @@sql_safe_updates;
+@@sql_safe_updates
+1
diff --git a/mysql-test/main/sql_safe_updates.test b/mysql-test/main/sql_safe_updates.test
new file mode 100644
index 00000000000..18decd0ff2c
--- /dev/null
+++ b/mysql-test/main/sql_safe_updates.test
@@ -0,0 +1,4 @@
+#
+# MDEV-14429 sql_safe_updates in my.cnf not work
+#
+select @@sql_safe_updates;
diff --git a/mysql-test/main/stat_tables.result b/mysql-test/main/stat_tables.result
index fcced761283..40290ca9879 100644
--- a/mysql-test/main/stat_tables.result
+++ b/mysql-test/main/stat_tables.result
@@ -516,4 +516,93 @@ use test;
drop database db1;
drop database db2;
drop table t1;
+#
+# MDEV-16552: [10.0] ASAN global-buffer-overflow in is_stat_table / statistics_for_tables_is_needed
+#
+SET use_stat_tables = PREFERABLY;
+SELECT CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' );
+CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' )
+NULL
+set use_stat_tables=@save_use_stat_tables;
+#
+# MDEV-16757: manual addition of min/max statistics for BLOB
+#
+SET use_stat_tables= PREFERABLY;
+CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
+INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze Warning Engine-independent statistics are not collected for column 't'
+test.t1 analyze status OK
+SELECT * FROM mysql.column_stats;
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
+test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
+DELETE FROM mysql.column_stats
+WHERE db_name='test' AND table_name='t1' AND column_name='t';
+INSERT INTO mysql.column_stats VALUES
+('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
+SELECT * FROM mysql.column_stats;
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
+test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
+test t1 t bar foo 0.0000 3.0000 1.0000 0 NULL NULL
+SELECT pk FROM t1;
+pk
+1
+2
+DROP TABLE t1;
+set use_stat_tables=@save_use_stat_tables;
+#
+# MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
+#
+SET use_stat_tables= PREFERABLY;
+CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
+INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+SELECT * FROM t1;
+pk c
+1 foo
+2 bar
+SELECT * FROM mysql.column_stats;
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
+test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
+test t1 c bar foo 0.0000 3.0000 1.0000 0 NULL NULL
+CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
+SELECT * FROM t1;
+pk a
+SELECT * FROM mysql.column_stats;
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
+DROP TABLE t1;
+set use_stat_tables=@save_use_stat_tables;
+#
+# MDEV-17023: Crash during read_histogram_for_table with optimizer_use_condition_selectivity set to 4
+#
+set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
+set @@optimizer_use_condition_selectivity=4;
+set @@use_stat_tables= PREFERABLY;
+explain
+SELECT * FROM INFORMATION_SCHEMA.PROFILING, mysql.user;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE PROFILING ALL NULL NULL NULL NULL NULL
+1 SIMPLE user ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
+set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+set use_stat_tables=@save_use_stat_tables;
+#
+# MDEV-16711:CREATE OR REPLACE TABLE introducing BLOB column
+#
+SET use_stat_tables= PREFERABLY;
+CREATE TABLE t1 (pk INT PRIMARY KEY, t CHAR(60));
+INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
+SELECT MAX(pk) FROM t1;
+MAX(pk)
+NULL
+DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
diff --git a/mysql-test/main/stat_tables.test b/mysql-test/main/stat_tables.test
index 4cbaa9e27c8..19bc0fa2f46 100644
--- a/mysql-test/main/stat_tables.test
+++ b/mysql-test/main/stat_tables.test
@@ -191,7 +191,7 @@ FLUSH TABLE t1;
SET use_stat_tables='never';
EXPLAIN SELECT * FROM t1;
---move_file $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stats.MYD $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stats.MYD.save
+--move_file $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stats.MAD $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stats.MAD.save
FLUSH TABLES;
SET use_stat_tables='preferably';
@@ -200,7 +200,7 @@ EXPLAIN SELECT * FROM t1;
--enable_warnings
# Cleanup
---move_file $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stats.MYD.save $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stats.MYD
+--move_file $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stats.MAD.save $MYSQLTEST_VARDIR/mysqld.1/data/mysql/table_stats.MAD
DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
@@ -305,4 +305,83 @@ drop database db1;
drop database db2;
drop table t1;
+--echo #
+--echo # MDEV-16552: [10.0] ASAN global-buffer-overflow in is_stat_table / statistics_for_tables_is_needed
+--echo #
+
+SET use_stat_tables = PREFERABLY;
+SELECT CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' );
+set use_stat_tables=@save_use_stat_tables;
+
+--echo #
+--echo # MDEV-16757: manual addition of min/max statistics for BLOB
+--echo #
+
+SET use_stat_tables= PREFERABLY;
+
+CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
+INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
+ANALYZE TABLE t1;
+--sorted_result
+SELECT * FROM mysql.column_stats;
+DELETE FROM mysql.column_stats
+ WHERE db_name='test' AND table_name='t1' AND column_name='t';
+INSERT INTO mysql.column_stats VALUES
+ ('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
+--sorted_result
+SELECT * FROM mysql.column_stats;
+
+SELECT pk FROM t1;
+
+DROP TABLE t1;
+
+set use_stat_tables=@save_use_stat_tables;
+
+--echo #
+--echo # MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
+--echo #
+
+SET use_stat_tables= PREFERABLY;
+
+CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
+INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
+ANALYZE TABLE t1;
+SELECT * FROM t1;
+SELECT * FROM mysql.column_stats;
+
+CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
+SELECT * FROM t1;
+SELECT * FROM mysql.column_stats;
+
+DROP TABLE t1;
+
+set use_stat_tables=@save_use_stat_tables;
+
+--echo #
+--echo # MDEV-17023: Crash during read_histogram_for_table with optimizer_use_condition_selectivity set to 4
+--echo #
+
+set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
+set @@optimizer_use_condition_selectivity=4;
+set @@use_stat_tables= PREFERABLY;
+explain
+SELECT * FROM INFORMATION_SCHEMA.PROFILING, mysql.user;
+set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+set use_stat_tables=@save_use_stat_tables;
+
+--echo #
+--echo # MDEV-16711:CREATE OR REPLACE TABLE introducing BLOB column
+--echo #
+
+SET use_stat_tables= PREFERABLY;
+
+CREATE TABLE t1 (pk INT PRIMARY KEY, t CHAR(60));
+INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
+ANALYZE TABLE t1;
+CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
+
+SELECT MAX(pk) FROM t1;
+
+DROP TABLE t1;
+
set use_stat_tables=@save_use_stat_tables;
diff --git a/mysql-test/main/stat_tables_innodb.result b/mysql-test/main/stat_tables_innodb.result
index 42443bfcb72..070d13d9bb1 100644
--- a/mysql-test/main/stat_tables_innodb.result
+++ b/mysql-test/main/stat_tables_innodb.result
@@ -543,6 +543,95 @@ use test;
drop database db1;
drop database db2;
drop table t1;
+#
+# MDEV-16552: [10.0] ASAN global-buffer-overflow in is_stat_table / statistics_for_tables_is_needed
+#
+SET use_stat_tables = PREFERABLY;
+SELECT CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' );
+CONVERT_TZ( '1991-09-20 10:11:02', '+00:00', 'GMT' )
+NULL
+set use_stat_tables=@save_use_stat_tables;
+#
+# MDEV-16757: manual addition of min/max statistics for BLOB
+#
+SET use_stat_tables= PREFERABLY;
+CREATE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
+INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze Warning Engine-independent statistics are not collected for column 't'
+test.t1 analyze status OK
+SELECT * FROM mysql.column_stats;
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
+test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
+DELETE FROM mysql.column_stats
+WHERE db_name='test' AND table_name='t1' AND column_name='t';
+INSERT INTO mysql.column_stats VALUES
+('test','t1','t','bar','foo', 0.0, 3.0, 1.0, 0, NULL, NULL);
+SELECT * FROM mysql.column_stats;
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
+test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
+test t1 t bar foo 0.0000 3.0000 1.0000 0 NULL NULL
+SELECT pk FROM t1;
+pk
+1
+2
+DROP TABLE t1;
+set use_stat_tables=@save_use_stat_tables;
+#
+# MDEV-16760: CREATE OR REPLACE TABLE after ANALYZE TABLE
+#
+SET use_stat_tables= PREFERABLY;
+CREATE TABLE t1 (pk int PRIMARY KEY, c varchar(32));
+INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+SELECT * FROM t1;
+pk c
+1 foo
+2 bar
+SELECT * FROM mysql.column_stats;
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
+test t1 pk 1 2 0.0000 4.0000 1.0000 0 NULL NULL
+test t1 c bar foo 0.0000 3.0000 1.0000 0 NULL NULL
+CREATE OR REPLACE TABLE t1 (pk int PRIMARY KEY, a char(7));
+SELECT * FROM t1;
+pk a
+SELECT * FROM mysql.column_stats;
+db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
+DROP TABLE t1;
+set use_stat_tables=@save_use_stat_tables;
+#
+# MDEV-17023: Crash during read_histogram_for_table with optimizer_use_condition_selectivity set to 4
+#
+set @save_optimizer_use_condition_selectivity=@@optimizer_use_condition_selectivity;
+set @@optimizer_use_condition_selectivity=4;
+set @@use_stat_tables= PREFERABLY;
+explain
+SELECT * FROM INFORMATION_SCHEMA.PROFILING, mysql.user;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE PROFILING ALL NULL NULL NULL NULL NULL
+1 SIMPLE user ALL NULL NULL NULL NULL 4 Using join buffer (flat, BNL join)
+set @@optimizer_use_condition_selectivity=@save_optimizer_use_condition_selectivity;
+set use_stat_tables=@save_use_stat_tables;
+#
+# MDEV-16711:CREATE OR REPLACE TABLE introducing BLOB column
+#
+SET use_stat_tables= PREFERABLY;
+CREATE TABLE t1 (pk INT PRIMARY KEY, t CHAR(60));
+INSERT INTO t1 VALUES (1,'foo'),(2,'bar');
+ANALYZE TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+CREATE OR REPLACE TABLE t1 (pk INT PRIMARY KEY, t TEXT);
+SELECT MAX(pk) FROM t1;
+MAX(pk)
+NULL
+DROP TABLE t1;
set use_stat_tables=@save_use_stat_tables;
set optimizer_switch=@save_optimizer_switch_for_stat_tables_test;
SET SESSION STORAGE_ENGINE=DEFAULT;
diff --git a/mysql-test/main/str_to_datetime_457.result b/mysql-test/main/str_to_datetime_457.result
index 4fd0d00691c..a024b30944c 100644
--- a/mysql-test/main/str_to_datetime_457.result
+++ b/mysql-test/main/str_to_datetime_457.result
@@ -1,6 +1,6 @@
select cast('01:02:03 ' as time), cast('01:02:03 ' as time);
cast('01:02:03 ' as time) cast('01:02:03 ' as time)
-01:02:03 00:00:00
+01:02:03 01:02:03
select cast('2002-011-012' as date), cast('2002.11.12' as date), cast('2002.011.012' as date);
cast('2002-011-012' as date) cast('2002.11.12' as date) cast('2002.011.012' as date)
2002-11-12 2002-11-12 2002-11-12
@@ -19,8 +19,8 @@ select extract(hour from '100000:02:03'), extract(hour from '100000:02:03 ');
extract(hour from '100000:02:03') extract(hour from '100000:02:03 ')
NULL NULL
Warnings:
-Warning 1292 Truncated incorrect time value: '100000:02:03'
-Warning 1292 Truncated incorrect time value: '100000:02:03 '
+Warning 1292 Incorrect time value: '100000:02:03'
+Warning 1292 Incorrect time value: '100000:02:03 '
#
# backward compatibility craziness
#
diff --git a/mysql-test/main/subselect.result b/mysql-test/main/subselect.result
index d5034bc49b0..404d878a9ec 100644
--- a/mysql-test/main/subselect.result
+++ b/mysql-test/main/subselect.result
@@ -7079,12 +7079,6 @@ call procedure2();
ControlRev
NULL
drop procedure procedure2;
-SELECT
-(SELECT user FROM mysql.user
-WHERE h.host in (SELECT host FROM mysql.user)
-) AS sq
-FROM mysql.host h GROUP BY h.host;
-sq
#
# MDEV-7846:Server crashes in Item_subselect::fix
#_fields or fails with Thread stack overrun
@@ -7237,6 +7231,22 @@ a
5
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
+#
+# MDEV-16820: impossible where with inexpensive subquery
+#
+create table t1 (a int) engine=myisam;
+insert into t1 values (3), (1), (7);
+create table t2 (b int, index idx(b));
+insert into t2 values (2), (5), (3), (2);
+explain select * from t1 where (select max(b) from t2) = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+drop table t1,t2;
End of 5.5 tests
# End of 10.0 tests
#
diff --git a/mysql-test/main/subselect.test b/mysql-test/main/subselect.test
index 37d57e51f1b..d7c266cafb0 100644
--- a/mysql-test/main/subselect.test
+++ b/mysql-test/main/subselect.test
@@ -5927,13 +5927,6 @@ call procedure2();
drop procedure procedure2;
-SELECT
- (SELECT user FROM mysql.user
- WHERE h.host in (SELECT host FROM mysql.user)
- ) AS sq
-FROM mysql.host h GROUP BY h.host;
-
-
--echo #
--echo # MDEV-7846:Server crashes in Item_subselect::fix
--echo #_fields or fails with Thread stack overrun
@@ -6098,6 +6091,21 @@ and t1.a in (select `test`.`t3`.`c` from `test`.`t3`);
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
+--echo #
+--echo # MDEV-16820: impossible where with inexpensive subquery
+--echo #
+
+create table t1 (a int) engine=myisam;
+insert into t1 values (3), (1), (7);
+
+create table t2 (b int, index idx(b));
+insert into t2 values (2), (5), (3), (2);
+
+explain select * from t1 where (select max(b) from t2) = 10;
+explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
+
+drop table t1,t2;
+
--echo End of 5.5 tests
--echo # End of 10.0 tests
diff --git a/mysql-test/main/subselect_extra_no_semijoin.result b/mysql-test/main/subselect_extra_no_semijoin.result
index fc8d5759945..ec9ddb0452e 100644
--- a/mysql-test/main/subselect_extra_no_semijoin.result
+++ b/mysql-test/main/subselect_extra_no_semijoin.result
@@ -482,3 +482,25 @@ DROP TABLE t1,t2;
set optimizer_switch= @tmp_subselect_extra_derived;
set optimizer_switch= @subselect_extra_no_sj_tmp;
set @optimizer_switch_for_subselect_extra_test=null;
+#
+# MDEV-6439: Server crashes in Explain_union::print_explain with explain in slow log, tis620 charset
+#
+connect con1,localhost,root,,;
+SET NAMES tis620;
+set @tmp= @@global.slow_query_log;
+SET GLOBAL slow_query_log = 1;
+SET long_query_time = 0.000001;
+SET log_slow_verbosity = 'explain';
+CREATE TABLE t1 (a VARCHAR(3)) ENGINE=MyISAM;
+SELECT * FROM t1 WHERE a >= ANY ( SELECT 'foo');
+a
+SELECT * FROM t1 WHERE a >= ANY ( SELECT 'foo' UNION SELECT 'bar' );
+ERROR HY000: Illegal mix of collations (tis620_thai_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation '<='
+create table t2 (b int);
+insert into t2 values (1),(2),(3);
+SELECT * FROM t1 WHERE a >= ANY ( SELECT 'foo' FROM t2);
+ERROR HY000: Illegal mix of collations (tis620_thai_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation '<='
+drop table t1,t2;
+SET GLOBAL slow_query_log=@tmp;
+disconnect con1;
+connection default;
diff --git a/mysql-test/main/subselect_extra_no_semijoin.test b/mysql-test/main/subselect_extra_no_semijoin.test
index 4340f4165e7..681f92bd8c4 100644
--- a/mysql-test/main/subselect_extra_no_semijoin.test
+++ b/mysql-test/main/subselect_extra_no_semijoin.test
@@ -6,4 +6,33 @@ set @optimizer_switch_for_subselect_extra_test='semijoin=off,firstmatch=off,loo
set optimizer_switch= @subselect_extra_no_sj_tmp;
-set @optimizer_switch_for_subselect_extra_test=null; \ No newline at end of file
+set @optimizer_switch_for_subselect_extra_test=null;
+
+--echo #
+--echo # MDEV-6439: Server crashes in Explain_union::print_explain with explain in slow log, tis620 charset
+--echo #
+
+## Using a separate client connection is easier than restoring state
+connect(con1,localhost,root,,);
+
+SET NAMES tis620;
+set @tmp= @@global.slow_query_log;
+SET GLOBAL slow_query_log = 1;
+SET long_query_time = 0.000001;
+SET log_slow_verbosity = 'explain';
+
+CREATE TABLE t1 (a VARCHAR(3)) ENGINE=MyISAM;
+SELECT * FROM t1 WHERE a >= ANY ( SELECT 'foo');
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT * FROM t1 WHERE a >= ANY ( SELECT 'foo' UNION SELECT 'bar' );
+
+create table t2 (b int);
+insert into t2 values (1),(2),(3);
+
+--error ER_CANT_AGGREGATE_2COLLATIONS
+SELECT * FROM t1 WHERE a >= ANY ( SELECT 'foo' FROM t2);
+
+drop table t1,t2;
+SET GLOBAL slow_query_log=@tmp;
+disconnect con1;
+connection default;
diff --git a/mysql-test/main/subselect_mat.result b/mysql-test/main/subselect_mat.result
index 39c0d1dd22b..010ba03153b 100644
--- a/mysql-test/main/subselect_mat.result
+++ b/mysql-test/main/subselect_mat.result
@@ -499,7 +499,7 @@ 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
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select '1 - 01','2 - 01' having (<cache>(`test`.`t1`.`a1`) = '1 - 01' or '1 - 01' is null) and (<cache>(`test`.`t1`.`a2`) = '2 - 01' or '2 - 01' is null) and '1 - 01' is null and '2 - 01' is null)))
+Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select '1 - 01','2 - 01' having (<cache>(`test`.`t1`.`a1`) = '1 - 01' or /*always not null*/ 1 is null) and (<cache>(`test`.`t1`.`a2`) = '2 - 01' or /*always not null*/ 1 is null) and '1 - 01' is null and '2 - 01' is null)))
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
a1 a2
1 - 01 2 - 01
@@ -509,7 +509,7 @@ 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
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select '1 - 01','2 - 01' having (<cache>(`test`.`t1`.`a1`) = '1 - 01' or '1 - 01' is null) and (<cache>(`test`.`t1`.`a2`) = '2 - 01' or '2 - 01' is null) and '1 - 01' is null and '2 - 01' is null)))
+Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select '1 - 01','2 - 01' having (<cache>(`test`.`t1`.`a1`) = '1 - 01' or /*always not null*/ 1 is null) and (<cache>(`test`.`t1`.`a2`) = '2 - 01' or /*always not null*/ 1 is null) and '1 - 01' is null and '2 - 01' is null)))
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01' from dual);
a1 a2
1 - 01 2 - 01
@@ -1925,7 +1925,7 @@ 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; Using join buffer (flat, BNL join)
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from <materialize> (/* select#2 */ select max(`test`.`t2`.`c`) from `test`.`t2` having `MAX(c)` is null or `MAX(c)` = 7) join `test`.`t1` where `test`.`t1`.`b` = 7 and `test`.`t1`.`a` = `<subquery2>`.`MAX(c)` and (<cache>(`<subquery2>`.`MAX(c)` is null) or `<subquery2>`.`MAX(c)` = 7)
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from <materialize> (/* select#2 */ select max(`test`.`t2`.`c`) from `test`.`t2` having `MAX(c)` is null or `MAX(c)` = 7) join `test`.`t1` where `test`.`t1`.`b` = 7 and `test`.`t1`.`a` = `<subquery2>`.`MAX(c)` and (<cache>(/*always not null*/ 1 is null) or `<subquery2>`.`MAX(c)` = 7)
SELECT * FROM t1
WHERE a IN (SELECT MAX(c) FROM t2) AND b=7 AND (a IS NULL OR a=b);
a b
@@ -2391,6 +2391,99 @@ ec70316637232000158bbfc8bcbe5d60
ebb4620037332000158bbfc8bcbe5d89
DROP TABLE t1,t2,t3;
set optimizer_switch=@save_optimizer_switch;
+#
+# MDEV-16751: Server crashes in st_join_table::cleanup or
+# TABLE_LIST::is_with_table_recursive_reference with join_cache_level>2
+#
+set @save_join_cache_level= @@join_cache_level;
+set join_cache_level=4;
+CREATE TABLE t1 ( id int NOT NULL);
+INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
+CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL) ;
+INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
+explain
+SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
+1 PRIMARY t1 hash_ALL NULL #hash#$hj 4 test.t2.i1 9 Using where; Using join buffer (flat, BNLH join)
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
+SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
+1
+1
+1
+1
+set @@join_cache_level= @save_join_cache_level;
+alter table t1 add key(id);
+explain
+SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
+1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
+SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
+1
+1
+1
+1
+drop table t1,t2;
+#
+# MDEV-15454: Nested SELECT IN returns wrong results
+#
+CREATE TABLE t1 ( a int NOT NULL PRIMARY KEY);
+CREATE TABLE t2 ( a int, b int );
+INSERT INTO t2 VALUES (7878, 96),(3465, 96),(1403, 96),(4189, 96),(8732, 96), (5,96);
+CREATE TABLE t3 (c int unsigned NOT NULL, b int unsigned NOT NULL, PRIMARY KEY (c,b));
+INSERT INTO t3 (c, b) VALUES (27, 96);
+CREATE PROCEDURE prepare_data()
+BEGIN
+DECLARE i INT DEFAULT 1;
+WHILE i < 1000 DO
+INSERT INTO t1 (a) VALUES (i);
+INSERT INTO t2 (a,b) VALUES (i,56);
+INSERT INTO t3 (c,b) VALUES (i,i);
+SET i = i + 1;
+END WHILE;
+END$$
+CALL prepare_data();
+SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27);
+a
+7878
+3465
+1403
+4189
+8732
+5
+set @save_optimizer_switch= @@optimizer_switch;
+SET optimizer_switch='materialization=off';
+SELECT t1.a FROM t1
+WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
+a
+5
+SET optimizer_switch='materialization=on';
+SELECT t1.a FROM t1
+WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
+a
+5
+drop procedure prepare_data;
+set @@optimizer_switch= @save_optimizer_switch;
+drop table t1,t2,t3;
+CREATE TABLE t1 ( id int NOT NULL, key(id));
+INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
+CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL);
+INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
+CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2;
+explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
+1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
+SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
+1
+1
+1
+1
+drop table t1,t2;
+drop view v1;
# End of 5.5 tests
#
# MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT
diff --git a/mysql-test/main/subselect_mat_cost_bugs.result b/mysql-test/main/subselect_mat_cost_bugs.result
index 658722112d2..6377ae556d2 100644
--- a/mysql-test/main/subselect_mat_cost_bugs.result
+++ b/mysql-test/main/subselect_mat_cost_bugs.result
@@ -442,7 +442,7 @@ SELECT i2 FROM t2 RIGHT JOIN t3 ON (c3 = c2) WHERE pk3 = i1
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY t1 system NULL NULL NULL NULL 1
2 DEPENDENT SUBQUERY t3 const PRIMARY PRIMARY 4 const 1
-2 DEPENDENT SUBQUERY t2 index NULL i2 11 NULL 2 Using where; Using index
+2 DEPENDENT SUBQUERY t2 index i2 i2 11 NULL 2 Using where; Using index
DROP TABLE t1,t2,t3;
#
# MDEV-7599: in-to-exists chosen after min/max optimization
diff --git a/mysql-test/main/subselect_no_exists_to_in.result b/mysql-test/main/subselect_no_exists_to_in.result
index afbd82fb359..6463aa4e4e2 100644
--- a/mysql-test/main/subselect_no_exists_to_in.result
+++ b/mysql-test/main/subselect_no_exists_to_in.result
@@ -7079,12 +7079,6 @@ call procedure2();
ControlRev
NULL
drop procedure procedure2;
-SELECT
-(SELECT user FROM mysql.user
-WHERE h.host in (SELECT host FROM mysql.user)
-) AS sq
-FROM mysql.host h GROUP BY h.host;
-sq
#
# MDEV-7846:Server crashes in Item_subselect::fix
#_fields or fails with Thread stack overrun
@@ -7237,6 +7231,22 @@ a
5
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
+#
+# MDEV-16820: impossible where with inexpensive subquery
+#
+create table t1 (a int) engine=myisam;
+insert into t1 values (3), (1), (7);
+create table t2 (b int, index idx(b));
+insert into t2 values (2), (5), (3), (2);
+explain select * from t1 where (select max(b) from t2) = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+drop table t1,t2;
End of 5.5 tests
# End of 10.0 tests
#
diff --git a/mysql-test/main/subselect_no_mat.result b/mysql-test/main/subselect_no_mat.result
index 2e9caf22ca0..0fa338ef222 100644
--- a/mysql-test/main/subselect_no_mat.result
+++ b/mysql-test/main/subselect_no_mat.result
@@ -7072,12 +7072,6 @@ call procedure2();
ControlRev
NULL
drop procedure procedure2;
-SELECT
-(SELECT user FROM mysql.user
-WHERE h.host in (SELECT host FROM mysql.user)
-) AS sq
-FROM mysql.host h GROUP BY h.host;
-sq
#
# MDEV-7846:Server crashes in Item_subselect::fix
#_fields or fails with Thread stack overrun
@@ -7230,6 +7224,22 @@ a
5
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
+#
+# MDEV-16820: impossible where with inexpensive subquery
+#
+create table t1 (a int) engine=myisam;
+insert into t1 values (3), (1), (7);
+create table t2 (b int, index idx(b));
+insert into t2 values (2), (5), (3), (2);
+explain select * from t1 where (select max(b) from t2) = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+drop table t1,t2;
End of 5.5 tests
# End of 10.0 tests
#
diff --git a/mysql-test/main/subselect_no_opts.result b/mysql-test/main/subselect_no_opts.result
index 2e82f98e01e..7704667a2dc 100644
--- a/mysql-test/main/subselect_no_opts.result
+++ b/mysql-test/main/subselect_no_opts.result
@@ -7070,12 +7070,6 @@ call procedure2();
ControlRev
NULL
drop procedure procedure2;
-SELECT
-(SELECT user FROM mysql.user
-WHERE h.host in (SELECT host FROM mysql.user)
-) AS sq
-FROM mysql.host h GROUP BY h.host;
-sq
#
# MDEV-7846:Server crashes in Item_subselect::fix
#_fields or fails with Thread stack overrun
@@ -7228,6 +7222,22 @@ a
5
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
+#
+# MDEV-16820: impossible where with inexpensive subquery
+#
+create table t1 (a int) engine=myisam;
+insert into t1 values (3), (1), (7);
+create table t2 (b int, index idx(b));
+insert into t2 values (2), (5), (3), (2);
+explain select * from t1 where (select max(b) from t2) = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+drop table t1,t2;
End of 5.5 tests
# End of 10.0 tests
#
diff --git a/mysql-test/main/subselect_no_scache.result b/mysql-test/main/subselect_no_scache.result
index 0dc83d85a74..af1157321e2 100644
--- a/mysql-test/main/subselect_no_scache.result
+++ b/mysql-test/main/subselect_no_scache.result
@@ -7085,12 +7085,6 @@ call procedure2();
ControlRev
NULL
drop procedure procedure2;
-SELECT
-(SELECT user FROM mysql.user
-WHERE h.host in (SELECT host FROM mysql.user)
-) AS sq
-FROM mysql.host h GROUP BY h.host;
-sq
#
# MDEV-7846:Server crashes in Item_subselect::fix
#_fields or fails with Thread stack overrun
@@ -7243,6 +7237,22 @@ a
5
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
+#
+# MDEV-16820: impossible where with inexpensive subquery
+#
+create table t1 (a int) engine=myisam;
+insert into t1 values (3), (1), (7);
+create table t2 (b int, index idx(b));
+insert into t2 values (2), (5), (3), (2);
+explain select * from t1 where (select max(b) from t2) = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+drop table t1,t2;
End of 5.5 tests
# End of 10.0 tests
#
diff --git a/mysql-test/main/subselect_no_semijoin.result b/mysql-test/main/subselect_no_semijoin.result
index 18333df11cb..13f4cb8b2b5 100644
--- a/mysql-test/main/subselect_no_semijoin.result
+++ b/mysql-test/main/subselect_no_semijoin.result
@@ -7070,12 +7070,6 @@ call procedure2();
ControlRev
NULL
drop procedure procedure2;
-SELECT
-(SELECT user FROM mysql.user
-WHERE h.host in (SELECT host FROM mysql.user)
-) AS sq
-FROM mysql.host h GROUP BY h.host;
-sq
#
# MDEV-7846:Server crashes in Item_subselect::fix
#_fields or fails with Thread stack overrun
@@ -7228,6 +7222,22 @@ a
5
SET @@optimizer_switch= @optimiser_switch_save;
DROP TABLE t1, t2, t3;
+#
+# MDEV-16820: impossible where with inexpensive subquery
+#
+create table t1 (a int) engine=myisam;
+insert into t1 values (3), (1), (7);
+create table t2 (b int, index idx(b));
+insert into t2 values (2), (5), (3), (2);
+explain select * from t1 where (select max(b) from t2) = 10;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+explain select * from t1 where (select max(b) from t2) = 10 and t1.a > 3;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE
+2 SUBQUERY NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+drop table t1,t2;
End of 5.5 tests
# End of 10.0 tests
#
diff --git a/mysql-test/main/subselect_sj2_mat.result b/mysql-test/main/subselect_sj2_mat.result
index 62248536e34..884451d7dff 100644
--- a/mysql-test/main/subselect_sj2_mat.result
+++ b/mysql-test/main/subselect_sj2_mat.result
@@ -1728,6 +1728,57 @@ id
13
drop table t1;
#
+# MDEV-15982: Incorrect results when subquery is materialized
+#
+CREATE TABLE `t1` (`id` int(32) NOT NULL primary key);
+INSERT INTO `t1` VALUES
+(45), (46), (47), (48), (49), (50), (51), (52), (53), (54), (55), (56), (57), (58), (59), (60), (61), (62),
+(63), (64), (65), (66), (67), (68), (69), (70), (71), (72), (73), (74), (75), (76), (77), (78), (79), (80),
+(81), (82), (83), (84), (85), (86), (87), (88), (89), (90), (91), (92),(93),(94),(95),(96), (97), (98),
+(99), (100), (101), (102), (103), (104), (105), (106), (107), (108), (109), (110), (111), (112), (113),
+(114), (115), (116), (117), (118), (119), (120), (121), (122), (123), (124), (125), (126), (127), (128),
+(129), (130), (131), (132), (133), (134), (135), (136), (137), (138), (139), (140), (141), (142), (143), (144), (145), (146),
+(147), (148), (149), (150), (151), (152), (153), (154), (155), (156), (157), (158), (159), (160), (161),
+(162), (163), (164), (165), (166), (167), (168), (169), (170), (171), (172), (173),
+(174), (175), (176), (177), (178), (179), (180), (181), (182), (183), (2), (3), (4), (5), (6), (19), (35),
+(7), (20), (8), (36), (219), (22), (10), (23), (37), (11), (24);
+CREATE TABLE `t2` (`type` int , `id` int(32) NOT NULL primary key);
+INSERT INTO `t2` VALUES
+(2,2),(2,3),(1,4),(2,5),(1,6),(1,19),(5,7),(1,20),(1,8),(1,21),(1,9),
+(1,22),(2,10),(1,23),(2,11),(1,24),(1,12),(1,25),(2,13),(2,26),(2,14),
+(2,27),(1,15),(1,28),(3,16),(1,29),(2,17),(1,30),(5,18),(2,1);
+CREATE TABLE `t3` (`ref_id` int(32) unsigned ,`type` varchar(80),`id` int(32) NOT NULL );
+INSERT INTO `t3` VALUES
+(1,'incident',31),(2,'faux pas',32),
+(5,'oopsies',33),(3,'deniable',34),
+(11,'wasntme',35),(10,'wasntme',36),
+(17,'faux pas',37),(13,'unlikely',38),
+(13,'improbable',39),(14,'incident',40),
+(26,'problem',41),(14,'problem',42),
+(26,'incident',43),(27,'incident',44);
+explain
+SELECT t2.id FROM t2,t1
+WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t2 index PRIMARY PRIMARY 4 NULL 30 Using index
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 Using where
+1 PRIMARY t1 eq_ref PRIMARY PRIMARY 4 test.t2.id 1 Using index
+2 MATERIALIZED t3 ALL NULL NULL NULL NULL 14
+2 MATERIALIZED t1 eq_ref PRIMARY PRIMARY 4 test.t3.id 1 Using index
+SELECT t2.id FROM t2,t1
+WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
+id
+10
+11
+set optimizer_switch='materialization=off';
+SELECT t2.id FROM t2,t1
+WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
+id
+11
+10
+set optimizer_switch='materialization=on';
+DROP TABLE t1,t2,t3;
+#
# MDEV-15247: Crash when SET NAMES 'utf8' is set
#
CREATE TABLE t1 (
diff --git a/mysql-test/main/subselect_sj2_mat.test b/mysql-test/main/subselect_sj2_mat.test
index bba436078e3..6ae687aa99a 100644
--- a/mysql-test/main/subselect_sj2_mat.test
+++ b/mysql-test/main/subselect_sj2_mat.test
@@ -347,6 +347,55 @@ WHERE (
drop table t1;
--echo #
+--echo # MDEV-15982: Incorrect results when subquery is materialized
+--echo #
+
+CREATE TABLE `t1` (`id` int(32) NOT NULL primary key);
+INSERT INTO `t1` VALUES
+(45), (46), (47), (48), (49), (50), (51), (52), (53), (54), (55), (56), (57), (58), (59), (60), (61), (62),
+(63), (64), (65), (66), (67), (68), (69), (70), (71), (72), (73), (74), (75), (76), (77), (78), (79), (80),
+(81), (82), (83), (84), (85), (86), (87), (88), (89), (90), (91), (92),(93),(94),(95),(96), (97), (98),
+(99), (100), (101), (102), (103), (104), (105), (106), (107), (108), (109), (110), (111), (112), (113),
+(114), (115), (116), (117), (118), (119), (120), (121), (122), (123), (124), (125), (126), (127), (128),
+(129), (130), (131), (132), (133), (134), (135), (136), (137), (138), (139), (140), (141), (142), (143), (144), (145), (146),
+(147), (148), (149), (150), (151), (152), (153), (154), (155), (156), (157), (158), (159), (160), (161),
+(162), (163), (164), (165), (166), (167), (168), (169), (170), (171), (172), (173),
+(174), (175), (176), (177), (178), (179), (180), (181), (182), (183), (2), (3), (4), (5), (6), (19), (35),
+(7), (20), (8), (36), (219), (22), (10), (23), (37), (11), (24);
+
+CREATE TABLE `t2` (`type` int , `id` int(32) NOT NULL primary key);
+INSERT INTO `t2` VALUES
+(2,2),(2,3),(1,4),(2,5),(1,6),(1,19),(5,7),(1,20),(1,8),(1,21),(1,9),
+(1,22),(2,10),(1,23),(2,11),(1,24),(1,12),(1,25),(2,13),(2,26),(2,14),
+(2,27),(1,15),(1,28),(3,16),(1,29),(2,17),(1,30),(5,18),(2,1);
+
+CREATE TABLE `t3` (`ref_id` int(32) unsigned ,`type` varchar(80),`id` int(32) NOT NULL );
+INSERT INTO `t3` VALUES
+(1,'incident',31),(2,'faux pas',32),
+(5,'oopsies',33),(3,'deniable',34),
+(11,'wasntme',35),(10,'wasntme',36),
+(17,'faux pas',37),(13,'unlikely',38),
+(13,'improbable',39),(14,'incident',40),
+(26,'problem',41),(14,'problem',42),
+(26,'incident',43),(27,'incident',44);
+
+explain
+SELECT t2.id FROM t2,t1
+ WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
+
+SELECT t2.id FROM t2,t1
+ WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
+
+set optimizer_switch='materialization=off';
+
+SELECT t2.id FROM t2,t1
+ WHERE t2.id IN (SELECT t3.ref_id FROM t3,t1 where t3.id = t1.id) and t2.id = t1.id;
+set optimizer_switch='materialization=on';
+
+DROP TABLE t1,t2,t3;
+
+
+--echo #
--echo # MDEV-15247: Crash when SET NAMES 'utf8' is set
--echo #
diff --git a/mysql-test/main/subselect_sj_mat.result b/mysql-test/main/subselect_sj_mat.result
index b241be77df7..983c6c31c65 100644
--- a/mysql-test/main/subselect_sj_mat.result
+++ b/mysql-test/main/subselect_sj_mat.result
@@ -520,7 +520,7 @@ 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
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select '1 - 01','2 - 01' having (<cache>(`test`.`t1`.`a1`) = '1 - 01' or '1 - 01' is null) and (<cache>(`test`.`t1`.`a2`) = '2 - 01' or '2 - 01' is null) and '1 - 01' is null and '2 - 01' is null)))
+Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select '1 - 01','2 - 01' having (<cache>(`test`.`t1`.`a1`) = '1 - 01' or /*always not null*/ 1 is null) and (<cache>(`test`.`t1`.`a2`) = '2 - 01' or /*always not null*/ 1 is null) and '1 - 01' is null and '2 - 01' is null)))
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01');
a1 a2
1 - 01 2 - 01
@@ -530,7 +530,7 @@ 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
2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select '1 - 01','2 - 01' having (<cache>(`test`.`t1`.`a1`) = '1 - 01' or '1 - 01' is null) and (<cache>(`test`.`t1`.`a2`) = '2 - 01' or '2 - 01' is null) and '1 - 01' is null and '2 - 01' is null)))
+Note 1003 /* select#1 */ select `test`.`t1`.`a1` AS `a1`,`test`.`t1`.`a2` AS `a2` from `test`.`t1` where <expr_cache><`test`.`t1`.`a1`,`test`.`t1`.`a2`>(<in_optimizer>((`test`.`t1`.`a1`,`test`.`t1`.`a2`),<exists>(/* select#2 */ select '1 - 01','2 - 01' having (<cache>(`test`.`t1`.`a1`) = '1 - 01' or /*always not null*/ 1 is null) and (<cache>(`test`.`t1`.`a2`) = '2 - 01' or /*always not null*/ 1 is null) and '1 - 01' is null and '2 - 01' is null)))
select * from t1 where (a1, a2) in (select '1 - 01', '2 - 01' from dual);
a1 a2
1 - 01 2 - 01
@@ -1963,7 +1963,7 @@ 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; Using join buffer (flat, BNL join)
2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 100.00
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from <materialize> (/* select#2 */ select max(`test`.`t2`.`c`) from `test`.`t2` having `MAX(c)` is null or `MAX(c)` = 7) join `test`.`t1` where `test`.`t1`.`b` = 7 and `test`.`t1`.`a` = `<subquery2>`.`MAX(c)` and (<cache>(`<subquery2>`.`MAX(c)` is null) or `<subquery2>`.`MAX(c)` = 7)
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a`,`test`.`t1`.`b` AS `b` from <materialize> (/* select#2 */ select max(`test`.`t2`.`c`) from `test`.`t2` having `MAX(c)` is null or `MAX(c)` = 7) join `test`.`t1` where `test`.`t1`.`b` = 7 and `test`.`t1`.`a` = `<subquery2>`.`MAX(c)` and (<cache>(/*always not null*/ 1 is null) or `<subquery2>`.`MAX(c)` = 7)
SELECT * FROM t1
WHERE a IN (SELECT MAX(c) FROM t2) AND b=7 AND (a IS NULL OR a=b);
a b
@@ -2431,6 +2431,99 @@ ec70316637232000158bbfc8bcbe5d60
ebb4620037332000158bbfc8bcbe5d89
DROP TABLE t1,t2,t3;
set optimizer_switch=@save_optimizer_switch;
+#
+# MDEV-16751: Server crashes in st_join_table::cleanup or
+# TABLE_LIST::is_with_table_recursive_reference with join_cache_level>2
+#
+set @save_join_cache_level= @@join_cache_level;
+set join_cache_level=4;
+CREATE TABLE t1 ( id int NOT NULL);
+INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
+CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL) ;
+INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
+explain
+SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
+1 PRIMARY t1 hash_ALL NULL #hash#$hj 4 test.t2.i1 9 Using where; Using join buffer (flat, BNLH join)
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
+SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
+1
+1
+1
+1
+set @@join_cache_level= @save_join_cache_level;
+alter table t1 add key(id);
+explain
+SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
+1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
+SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
+1
+1
+1
+1
+drop table t1,t2;
+#
+# MDEV-15454: Nested SELECT IN returns wrong results
+#
+CREATE TABLE t1 ( a int NOT NULL PRIMARY KEY);
+CREATE TABLE t2 ( a int, b int );
+INSERT INTO t2 VALUES (7878, 96),(3465, 96),(1403, 96),(4189, 96),(8732, 96), (5,96);
+CREATE TABLE t3 (c int unsigned NOT NULL, b int unsigned NOT NULL, PRIMARY KEY (c,b));
+INSERT INTO t3 (c, b) VALUES (27, 96);
+CREATE PROCEDURE prepare_data()
+BEGIN
+DECLARE i INT DEFAULT 1;
+WHILE i < 1000 DO
+INSERT INTO t1 (a) VALUES (i);
+INSERT INTO t2 (a,b) VALUES (i,56);
+INSERT INTO t3 (c,b) VALUES (i,i);
+SET i = i + 1;
+END WHILE;
+END$$
+CALL prepare_data();
+SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27);
+a
+7878
+3465
+1403
+4189
+8732
+5
+set @save_optimizer_switch= @@optimizer_switch;
+SET optimizer_switch='materialization=off';
+SELECT t1.a FROM t1
+WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
+a
+5
+SET optimizer_switch='materialization=on';
+SELECT t1.a FROM t1
+WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
+a
+5
+drop procedure prepare_data;
+set @@optimizer_switch= @save_optimizer_switch;
+drop table t1,t2,t3;
+CREATE TABLE t1 ( id int NOT NULL, key(id));
+INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
+CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL);
+INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
+CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2;
+explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <subquery2> ALL distinct_key NULL NULL NULL 3
+1 PRIMARY t1 ref id id 4 test.t2.i1 2 Using index
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 3 Using where
+SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
+1
+1
+1
+1
+drop table t1,t2;
+drop view v1;
# End of 5.5 tests
#
# MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT
diff --git a/mysql-test/main/subselect_sj_mat.test b/mysql-test/main/subselect_sj_mat.test
index 66c11b61435..7b8179bba38 100644
--- a/mysql-test/main/subselect_sj_mat.test
+++ b/mysql-test/main/subselect_sj_mat.test
@@ -2157,6 +2157,85 @@ eval $q;
DROP TABLE t1,t2,t3;
set optimizer_switch=@save_optimizer_switch;
+--echo #
+--echo # MDEV-16751: Server crashes in st_join_table::cleanup or
+--echo # TABLE_LIST::is_with_table_recursive_reference with join_cache_level>2
+--echo #
+
+set @save_join_cache_level= @@join_cache_level;
+set join_cache_level=4;
+CREATE TABLE t1 ( id int NOT NULL);
+INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
+
+CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL) ;
+INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
+
+explain
+SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
+SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
+
+set @@join_cache_level= @save_join_cache_level;
+alter table t1 add key(id);
+
+explain
+SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
+SELECT 1 FROM t1 where t1.id IN (SELECT t2.i1 FROM t2 WHERE t2.i1 = t2.i2);
+
+drop table t1,t2;
+
+--echo #
+--echo # MDEV-15454: Nested SELECT IN returns wrong results
+--echo #
+
+CREATE TABLE t1 ( a int NOT NULL PRIMARY KEY);
+
+CREATE TABLE t2 ( a int, b int );
+INSERT INTO t2 VALUES (7878, 96),(3465, 96),(1403, 96),(4189, 96),(8732, 96), (5,96);
+
+CREATE TABLE t3 (c int unsigned NOT NULL, b int unsigned NOT NULL, PRIMARY KEY (c,b));
+INSERT INTO t3 (c, b) VALUES (27, 96);
+
+DELIMITER $$;
+CREATE PROCEDURE prepare_data()
+BEGIN
+ DECLARE i INT DEFAULT 1;
+ WHILE i < 1000 DO
+ INSERT INTO t1 (a) VALUES (i);
+ INSERT INTO t2 (a,b) VALUES (i,56);
+ INSERT INTO t3 (c,b) VALUES (i,i);
+ SET i = i + 1;
+ END WHILE;
+END$$
+DELIMITER ;$$
+
+CALL prepare_data();
+
+SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27);
+
+set @save_optimizer_switch= @@optimizer_switch;
+SET optimizer_switch='materialization=off';
+
+SELECT t1.a FROM t1
+WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
+
+SET optimizer_switch='materialization=on';
+
+SELECT t1.a FROM t1
+WHERE t1.a IN (SELECT t2.a FROM t2 WHERE t2.b IN (SELECT t3.b FROM t3 WHERE t3.c= 27)) LIMIT 5;
+
+drop procedure prepare_data;
+set @@optimizer_switch= @save_optimizer_switch;
+drop table t1,t2,t3;
+
+CREATE TABLE t1 ( id int NOT NULL, key(id));
+INSERT INTO t1 VALUES (11),(12),(13),(14),(15),(16),(17),(18),(19);
+CREATE TABLE t2 (i1 int NOT NULL, i2 int NOT NULL);
+INSERT INTO t2 VALUES (11,11),(12,12),(13,13);
+CREATE VIEW v1 AS SELECT t2.i1 FROM t2 where t2.i1 = t2.i2;
+explain SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
+SELECT 1 FROM t1 where t1.id IN (SELECT v1.i1 from v1);
+drop table t1,t2;
+drop view v1;
--echo # End of 5.5 tests
--echo #
--echo # MDEV-7220: Materialization strategy is not used for REPLACE ... SELECT
diff --git a/mysql-test/main/system_mysql_db.result b/mysql-test/main/system_mysql_db.result
index 2abcfb92ffa..a4c414888ca 100644
--- a/mysql-test/main/system_mysql_db.result
+++ b/mysql-test/main/system_mysql_db.result
@@ -11,7 +11,6 @@ help_category
help_keyword
help_relation
help_topic
-host
index_stats
innodb_index_stats
innodb_table_stats
@@ -59,32 +58,7 @@ db CREATE TABLE `db` (
`Delete_history_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
PRIMARY KEY (`Host`,`Db`,`User`),
KEY `User` (`User`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Database privileges'
-show create table host;
-Table Create Table
-host CREATE TABLE `host` (
- `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
- `Db` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
- `Select_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Insert_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Update_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Delete_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Drop_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Grant_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `References_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Index_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Alter_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Lock_tables_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Show_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Alter_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Execute_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Trigger_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- PRIMARY KEY (`Host`,`Db`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Host privileges; Merged with database privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Database privileges'
show create table user;
Table Create Table
user CREATE TABLE `user` (
@@ -136,7 +110,7 @@ user CREATE TABLE `user` (
`default_role` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
`max_statement_time` decimal(12,6) NOT NULL DEFAULT 0.000000,
PRIMARY KEY (`Host`,`User`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Users and global privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Users and global privileges'
show create table func;
Table Create Table
func CREATE TABLE `func` (
@@ -145,7 +119,7 @@ func CREATE TABLE `func` (
`dl` char(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`type` enum('function','aggregate') CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User defined functions'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='User defined functions'
show create table tables_priv;
Table Create Table
tables_priv CREATE TABLE `tables_priv` (
@@ -159,7 +133,7 @@ tables_priv CREATE TABLE `tables_priv` (
`Column_priv` set('Select','Insert','Update','References') CHARACTER SET utf8 NOT NULL DEFAULT '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`),
KEY `Grantor` (`Grantor`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Table privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Table privileges'
show create table columns_priv;
Table Create Table
columns_priv CREATE TABLE `columns_priv` (
@@ -171,7 +145,7 @@ columns_priv CREATE TABLE `columns_priv` (
`Timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`Column_priv` set('Select','Insert','Update','References') CHARACTER SET utf8 NOT NULL DEFAULT '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`,`Column_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Column privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Column privileges'
show create table procs_priv;
Table Create Table
procs_priv CREATE TABLE `procs_priv` (
@@ -185,7 +159,7 @@ procs_priv CREATE TABLE `procs_priv` (
`Timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`Host`,`Db`,`User`,`Routine_name`,`Routine_type`),
KEY `Grantor` (`Grantor`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Procedure privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Procedure privileges'
show create table servers;
Table Create Table
servers CREATE TABLE `servers` (
@@ -199,7 +173,7 @@ servers CREATE TABLE `servers` (
`Wrapper` char(64) NOT NULL DEFAULT '',
`Owner` char(64) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='MySQL Foreign Servers table'
+) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='MySQL Foreign Servers table'
show create table proc;
Table Create Table
proc CREATE TABLE `proc` (
@@ -225,7 +199,7 @@ proc CREATE TABLE `proc` (
`body_utf8` longblob DEFAULT NULL,
`aggregate` enum('NONE','GROUP') NOT NULL DEFAULT 'NONE',
PRIMARY KEY (`db`,`name`,`type`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stored Procedures'
+) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Stored Procedures'
show create table event;
Table Create Table
event CREATE TABLE `event` (
@@ -252,7 +226,7 @@ event CREATE TABLE `event` (
`db_collation` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
`body_utf8` longblob DEFAULT NULL,
PRIMARY KEY (`db`,`name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Events'
+) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Events'
show create table general_log;
Table Create Table
general_log CREATE TABLE `general_log` (
@@ -287,7 +261,7 @@ table_stats CREATE TABLE `table_stats` (
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`cardinality` bigint(21) unsigned DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Tables'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Tables'
show create table column_stats;
Table Create Table
column_stats CREATE TABLE `column_stats` (
@@ -303,7 +277,7 @@ column_stats CREATE TABLE `column_stats` (
`hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') COLLATE utf8_bin DEFAULT NULL,
`histogram` varbinary(255) DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Columns'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'
show create table index_stats;
Table Create Table
index_stats CREATE TABLE `index_stats` (
@@ -313,6 +287,6 @@ index_stats CREATE TABLE `index_stats` (
`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=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Indexes'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Indexes'
show tables;
Tables_in_test
diff --git a/mysql-test/main/system_mysql_db_fix40123.result b/mysql-test/main/system_mysql_db_fix40123.result
index 2abcfb92ffa..d76a2ef923e 100644
--- a/mysql-test/main/system_mysql_db_fix40123.result
+++ b/mysql-test/main/system_mysql_db_fix40123.result
@@ -59,32 +59,7 @@ db CREATE TABLE `db` (
`Delete_history_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
PRIMARY KEY (`Host`,`Db`,`User`),
KEY `User` (`User`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Database privileges'
-show create table host;
-Table Create Table
-host CREATE TABLE `host` (
- `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
- `Db` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
- `Select_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Insert_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Update_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Delete_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Drop_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Grant_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `References_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Index_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Alter_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Lock_tables_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Show_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Alter_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Execute_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Trigger_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- PRIMARY KEY (`Host`,`Db`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Host privileges; Merged with database privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Database privileges'
show create table user;
Table Create Table
user CREATE TABLE `user` (
@@ -136,7 +111,7 @@ user CREATE TABLE `user` (
`default_role` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
`max_statement_time` decimal(12,6) NOT NULL DEFAULT 0.000000,
PRIMARY KEY (`Host`,`User`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Users and global privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Users and global privileges'
show create table func;
Table Create Table
func CREATE TABLE `func` (
@@ -145,7 +120,7 @@ func CREATE TABLE `func` (
`dl` char(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`type` enum('function','aggregate') CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User defined functions'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='User defined functions'
show create table tables_priv;
Table Create Table
tables_priv CREATE TABLE `tables_priv` (
@@ -159,7 +134,7 @@ tables_priv CREATE TABLE `tables_priv` (
`Column_priv` set('Select','Insert','Update','References') CHARACTER SET utf8 NOT NULL DEFAULT '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`),
KEY `Grantor` (`Grantor`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Table privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Table privileges'
show create table columns_priv;
Table Create Table
columns_priv CREATE TABLE `columns_priv` (
@@ -171,7 +146,7 @@ columns_priv CREATE TABLE `columns_priv` (
`Timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`Column_priv` set('Select','Insert','Update','References') CHARACTER SET utf8 NOT NULL DEFAULT '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`,`Column_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Column privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Column privileges'
show create table procs_priv;
Table Create Table
procs_priv CREATE TABLE `procs_priv` (
@@ -185,7 +160,7 @@ procs_priv CREATE TABLE `procs_priv` (
`Timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`Host`,`Db`,`User`,`Routine_name`,`Routine_type`),
KEY `Grantor` (`Grantor`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Procedure privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Procedure privileges'
show create table servers;
Table Create Table
servers CREATE TABLE `servers` (
@@ -199,7 +174,7 @@ servers CREATE TABLE `servers` (
`Wrapper` char(64) NOT NULL DEFAULT '',
`Owner` char(64) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='MySQL Foreign Servers table'
+) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='MySQL Foreign Servers table'
show create table proc;
Table Create Table
proc CREATE TABLE `proc` (
@@ -225,7 +200,7 @@ proc CREATE TABLE `proc` (
`body_utf8` longblob DEFAULT NULL,
`aggregate` enum('NONE','GROUP') NOT NULL DEFAULT 'NONE',
PRIMARY KEY (`db`,`name`,`type`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stored Procedures'
+) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Stored Procedures'
show create table event;
Table Create Table
event CREATE TABLE `event` (
@@ -252,7 +227,7 @@ event CREATE TABLE `event` (
`db_collation` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
`body_utf8` longblob DEFAULT NULL,
PRIMARY KEY (`db`,`name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Events'
+) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Events'
show create table general_log;
Table Create Table
general_log CREATE TABLE `general_log` (
@@ -287,7 +262,7 @@ table_stats CREATE TABLE `table_stats` (
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`cardinality` bigint(21) unsigned DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Tables'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Tables'
show create table column_stats;
Table Create Table
column_stats CREATE TABLE `column_stats` (
@@ -303,7 +278,7 @@ column_stats CREATE TABLE `column_stats` (
`hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') COLLATE utf8_bin DEFAULT NULL,
`histogram` varbinary(255) DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Columns'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'
show create table index_stats;
Table Create Table
index_stats CREATE TABLE `index_stats` (
@@ -313,6 +288,6 @@ index_stats CREATE TABLE `index_stats` (
`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=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Indexes'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Indexes'
show tables;
Tables_in_test
diff --git a/mysql-test/main/system_mysql_db_fix50030.result b/mysql-test/main/system_mysql_db_fix50030.result
index 81b6da4c16d..fdc708db313 100644
--- a/mysql-test/main/system_mysql_db_fix50030.result
+++ b/mysql-test/main/system_mysql_db_fix50030.result
@@ -59,32 +59,7 @@ db CREATE TABLE `db` (
`Delete_history_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
PRIMARY KEY (`Host`,`Db`,`User`),
KEY `User` (`User`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Database privileges'
-show create table host;
-Table Create Table
-host CREATE TABLE `host` (
- `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
- `Db` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
- `Select_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Insert_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Update_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Delete_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Drop_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Grant_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `References_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Index_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Alter_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Lock_tables_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Show_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Alter_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Execute_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Trigger_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- PRIMARY KEY (`Host`,`Db`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Host privileges; Merged with database privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Database privileges'
show create table user;
Table Create Table
user CREATE TABLE `user` (
@@ -136,7 +111,7 @@ user CREATE TABLE `user` (
`default_role` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
`max_statement_time` decimal(12,6) NOT NULL DEFAULT 0.000000,
PRIMARY KEY (`Host`,`User`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Users and global privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Users and global privileges'
show create table func;
Table Create Table
func CREATE TABLE `func` (
@@ -145,7 +120,7 @@ func CREATE TABLE `func` (
`dl` char(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`type` enum('function','aggregate') CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User defined functions'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='User defined functions'
show create table tables_priv;
Table Create Table
tables_priv CREATE TABLE `tables_priv` (
@@ -159,7 +134,7 @@ tables_priv CREATE TABLE `tables_priv` (
`Column_priv` set('Select','Insert','Update','References') CHARACTER SET utf8 NOT NULL DEFAULT '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`),
KEY `Grantor` (`Grantor`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Table privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Table privileges'
show create table columns_priv;
Table Create Table
columns_priv CREATE TABLE `columns_priv` (
@@ -171,7 +146,7 @@ columns_priv CREATE TABLE `columns_priv` (
`Timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`Column_priv` set('Select','Insert','Update','References') CHARACTER SET utf8 NOT NULL DEFAULT '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`,`Column_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Column privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Column privileges'
show create table procs_priv;
Table Create Table
procs_priv CREATE TABLE `procs_priv` (
@@ -185,7 +160,7 @@ procs_priv CREATE TABLE `procs_priv` (
`Timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`Host`,`Db`,`User`,`Routine_name`,`Routine_type`),
KEY `Grantor` (`Grantor`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Procedure privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Procedure privileges'
show create table servers;
Table Create Table
servers CREATE TABLE `servers` (
@@ -199,7 +174,7 @@ servers CREATE TABLE `servers` (
`Wrapper` char(64) NOT NULL DEFAULT '',
`Owner` char(64) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='MySQL Foreign Servers table'
+) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='MySQL Foreign Servers table'
show create table proc;
Table Create Table
proc CREATE TABLE `proc` (
@@ -225,7 +200,7 @@ proc CREATE TABLE `proc` (
`body_utf8` longblob DEFAULT NULL,
`aggregate` enum('NONE','GROUP') NOT NULL DEFAULT 'NONE',
PRIMARY KEY (`db`,`name`,`type`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stored Procedures'
+) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Stored Procedures'
show create table event;
Table Create Table
event CREATE TABLE `event` (
@@ -252,7 +227,7 @@ event CREATE TABLE `event` (
`db_collation` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
`body_utf8` longblob DEFAULT NULL,
PRIMARY KEY (`db`,`name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Events'
+) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Events'
show create table general_log;
Table Create Table
general_log CREATE TABLE `general_log` (
@@ -287,7 +262,7 @@ table_stats CREATE TABLE `table_stats` (
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`cardinality` bigint(21) unsigned DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Tables'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Tables'
show create table column_stats;
Table Create Table
column_stats CREATE TABLE `column_stats` (
@@ -303,7 +278,7 @@ column_stats CREATE TABLE `column_stats` (
`hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') COLLATE utf8_bin DEFAULT NULL,
`histogram` varbinary(255) DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Columns'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'
show create table index_stats;
Table Create Table
index_stats CREATE TABLE `index_stats` (
@@ -313,6 +288,6 @@ index_stats CREATE TABLE `index_stats` (
`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=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Indexes'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Indexes'
show tables;
Tables_in_test
diff --git a/mysql-test/main/system_mysql_db_fix50117.result b/mysql-test/main/system_mysql_db_fix50117.result
index 2abcfb92ffa..d76a2ef923e 100644
--- a/mysql-test/main/system_mysql_db_fix50117.result
+++ b/mysql-test/main/system_mysql_db_fix50117.result
@@ -59,32 +59,7 @@ db CREATE TABLE `db` (
`Delete_history_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
PRIMARY KEY (`Host`,`Db`,`User`),
KEY `User` (`User`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Database privileges'
-show create table host;
-Table Create Table
-host CREATE TABLE `host` (
- `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT '',
- `Db` char(64) COLLATE utf8_bin NOT NULL DEFAULT '',
- `Select_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Insert_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Update_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Delete_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Drop_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Grant_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `References_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Index_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Alter_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_tmp_table_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Lock_tables_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Show_view_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Create_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Alter_routine_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Execute_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- `Trigger_priv` enum('N','Y') CHARACTER SET utf8 NOT NULL DEFAULT 'N',
- PRIMARY KEY (`Host`,`Db`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Host privileges; Merged with database privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Database privileges'
show create table user;
Table Create Table
user CREATE TABLE `user` (
@@ -136,7 +111,7 @@ user CREATE TABLE `user` (
`default_role` char(80) COLLATE utf8_bin NOT NULL DEFAULT '',
`max_statement_time` decimal(12,6) NOT NULL DEFAULT 0.000000,
PRIMARY KEY (`Host`,`User`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Users and global privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Users and global privileges'
show create table func;
Table Create Table
func CREATE TABLE `func` (
@@ -145,7 +120,7 @@ func CREATE TABLE `func` (
`dl` char(128) COLLATE utf8_bin NOT NULL DEFAULT '',
`type` enum('function','aggregate') CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='User defined functions'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='User defined functions'
show create table tables_priv;
Table Create Table
tables_priv CREATE TABLE `tables_priv` (
@@ -159,7 +134,7 @@ tables_priv CREATE TABLE `tables_priv` (
`Column_priv` set('Select','Insert','Update','References') CHARACTER SET utf8 NOT NULL DEFAULT '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`),
KEY `Grantor` (`Grantor`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Table privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Table privileges'
show create table columns_priv;
Table Create Table
columns_priv CREATE TABLE `columns_priv` (
@@ -171,7 +146,7 @@ columns_priv CREATE TABLE `columns_priv` (
`Timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`Column_priv` set('Select','Insert','Update','References') CHARACTER SET utf8 NOT NULL DEFAULT '',
PRIMARY KEY (`Host`,`Db`,`User`,`Table_name`,`Column_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Column privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Column privileges'
show create table procs_priv;
Table Create Table
procs_priv CREATE TABLE `procs_priv` (
@@ -185,7 +160,7 @@ procs_priv CREATE TABLE `procs_priv` (
`Timestamp` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`Host`,`Db`,`User`,`Routine_name`,`Routine_type`),
KEY `Grantor` (`Grantor`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Procedure privileges'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Procedure privileges'
show create table servers;
Table Create Table
servers CREATE TABLE `servers` (
@@ -199,7 +174,7 @@ servers CREATE TABLE `servers` (
`Wrapper` char(64) NOT NULL DEFAULT '',
`Owner` char(64) NOT NULL DEFAULT '',
PRIMARY KEY (`Server_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='MySQL Foreign Servers table'
+) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='MySQL Foreign Servers table'
show create table proc;
Table Create Table
proc CREATE TABLE `proc` (
@@ -225,7 +200,7 @@ proc CREATE TABLE `proc` (
`body_utf8` longblob DEFAULT NULL,
`aggregate` enum('NONE','GROUP') NOT NULL DEFAULT 'NONE',
PRIMARY KEY (`db`,`name`,`type`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Stored Procedures'
+) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Stored Procedures'
show create table event;
Table Create Table
event CREATE TABLE `event` (
@@ -252,7 +227,7 @@ event CREATE TABLE `event` (
`db_collation` char(32) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,
`body_utf8` longblob DEFAULT NULL,
PRIMARY KEY (`db`,`name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Events'
+) ENGINE=Aria DEFAULT CHARSET=utf8 PAGE_CHECKSUM=1 TRANSACTIONAL=1 COMMENT='Events'
show create table general_log;
Table Create Table
general_log CREATE TABLE `general_log` (
@@ -287,7 +262,7 @@ table_stats CREATE TABLE `table_stats` (
`table_name` varchar(64) COLLATE utf8_bin NOT NULL,
`cardinality` bigint(21) unsigned DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Tables'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Tables'
show create table column_stats;
Table Create Table
column_stats CREATE TABLE `column_stats` (
@@ -303,7 +278,7 @@ column_stats CREATE TABLE `column_stats` (
`hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') COLLATE utf8_bin DEFAULT NULL,
`histogram` varbinary(255) DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Columns'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'
show create table index_stats;
Table Create Table
index_stats CREATE TABLE `index_stats` (
@@ -313,6 +288,6 @@ index_stats CREATE TABLE `index_stats` (
`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=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Statistics on Indexes'
+) ENGINE=Aria DEFAULT CHARSET=utf8 COLLATE=utf8_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Indexes'
show tables;
Tables_in_test
diff --git a/mysql-test/main/system_mysql_db_refs.result b/mysql-test/main/system_mysql_db_refs.result
index 96ecd2f27c0..870a550bb95 100644
--- a/mysql-test/main/system_mysql_db_refs.result
+++ b/mysql-test/main/system_mysql_db_refs.result
@@ -2,9 +2,6 @@ set @name="This is a very long string, that mustn't find room in a system field
create table test_db select * from mysql.db;
delete from test_db;
insert ignore into test_db (Host,Db,User) values (@name,@name,@name);
-create table test_host select * from mysql.host;
-delete from test_host;
-insert ignore into test_host (Host,Db) values (@name,@name);
create table test_user select * from mysql.user;
delete from test_user;
insert ignore into test_user (Host,User) values (@name,@name);
@@ -19,28 +16,24 @@ delete from test_columns_priv;
insert ignore into test_columns_priv (Host,Db,User,Table_name,Column_name) values (@name,@name,@name,@name,@name);
select
if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_Host,
-if(isnull(test_host.Host),'WRONG!!!','ok') as test_host_Host,
if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_Host,
if(isnull(test_tables_priv.Host),'WRONG!!!','ok') as test_tables_priv_Host,
if(isnull(test_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host
from test_db
-left join test_host on test_db.Host=test_host.Host
left join test_user on test_db.Host=test_user.Host
left join test_tables_priv on test_db.Host=test_tables_priv.Host
left join test_columns_priv on test_db.Host=test_columns_priv.Host;
-test_db_Host test_host_Host test_user_Host test_tables_priv_Host test_columns_priv_Host
-ok ok ok ok ok
+test_db_Host test_user_Host test_tables_priv_Host test_columns_priv_Host
+ok ok ok ok
select
if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db,
-if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db,
if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db,
if(isnull(test_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db
from test_db
-left join test_host on test_db.Db=test_host.Db
left join test_tables_priv on test_db.Db=test_tables_priv.Db
left join test_columns_priv on test_db.Db=test_columns_priv.Db;
-test_db_Db test_host_Db test_tables_priv_Db est_columns_priv_Db
-ok ok ok ok
+test_db_Db test_tables_priv_Db est_columns_priv_Db
+ok ok ok
select
if(isnull(test_db.User),'WRONG!!!','ok') as test_db_User,
if(isnull(test_user.User),'WRONG!!!','ok') as test_user_User,
@@ -62,6 +55,5 @@ ok ok
drop table test_columns_priv;
drop table test_tables_priv;
drop table test_func;
-drop table test_host;
drop table test_user;
drop table test_db;
diff --git a/mysql-test/main/system_mysql_db_refs.test b/mysql-test/main/system_mysql_db_refs.test
index 63f30e7db63..084d5bbf868 100644
--- a/mysql-test/main/system_mysql_db_refs.test
+++ b/mysql-test/main/system_mysql_db_refs.test
@@ -14,12 +14,6 @@ delete from test_db;
insert ignore into test_db (Host,Db,User) values (@name,@name,@name);
--enable_warnings
-create table test_host select * from mysql.host;
-delete from test_host;
---disable_warnings
-insert ignore into test_host (Host,Db) values (@name,@name);
---enable_warnings
-
create table test_user select * from mysql.user;
delete from test_user;
--disable_warnings
@@ -48,13 +42,11 @@ insert ignore into test_columns_priv (Host,Db,User,Table_name,Column_name) value
select
if(isnull(test_db.Host),'WRONG!!!','ok') as test_db_Host,
- if(isnull(test_host.Host),'WRONG!!!','ok') as test_host_Host,
if(isnull(test_user.Host),'WRONG!!!','ok') as test_user_Host,
if(isnull(test_tables_priv.Host),'WRONG!!!','ok') as test_tables_priv_Host,
if(isnull(test_columns_priv.Host),'WRONG!!!','ok') as test_columns_priv_Host
from test_db
-left join test_host on test_db.Host=test_host.Host
left join test_user on test_db.Host=test_user.Host
left join test_tables_priv on test_db.Host=test_tables_priv.Host
left join test_columns_priv on test_db.Host=test_columns_priv.Host;
@@ -63,12 +55,10 @@ left join test_columns_priv on test_db.Host=test_columns_priv.Host;
select
if(isnull(test_db.Db),'WRONG!!!','ok') as test_db_Db,
- if(isnull(test_host.Db),'WRONG!!!','ok') as test_host_Db,
if(isnull(test_tables_priv.Db),'WRONG!!!','ok') as test_tables_priv_Db,
if(isnull(test_columns_priv.Db),'WRONG!!!','ok') as est_columns_priv_Db
from test_db
-left join test_host on test_db.Db=test_host.Db
left join test_tables_priv on test_db.Db=test_tables_priv.Db
left join test_columns_priv on test_db.Db=test_columns_priv.Db;
@@ -96,7 +86,6 @@ left join test_columns_priv on test_tables_priv.Table_name=test_columns_priv.Tab
drop table test_columns_priv;
drop table test_tables_priv;
drop table test_func;
-drop table test_host;
drop table test_user;
drop table test_db;
diff --git a/mysql-test/main/table_value_constr.result b/mysql-test/main/table_value_constr.result
index 9129fd0a23b..454356bb5fb 100644
--- a/mysql-test/main/table_value_constr.result
+++ b/mysql-test/main/table_value_constr.result
@@ -2096,3 +2096,95 @@ v
#
with t as (values (),()) select 1 from t;
ERROR HY000: Row with no elements is not allowed in table value constructor in this context
+#
+# MDEV-17017: TVC in derived table
+#
+create table t1 (a int);
+insert into t1 values (9), (3), (2);
+select * from (values (7), (5), (8), (1), (3), (8), (1)) t;
+7
+7
+5
+8
+1
+3
+8
+1
+explain select * from (values (7), (5), (8), (1), (3), (8), (1)) t;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 7
+2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
+select * from (values (1,11), (7,77), (3,31), (4,42)) t;
+1 11
+1 11
+7 77
+3 31
+4 42
+explain select * from (values (1,11), (7,77), (3,31), (4,42)) t;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 4
+2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
+select * from (values (7), (5), (8), (1) union values (3), (8), (1)) t;
+7
+7
+5
+8
+1
+3
+explain select * from (values (7), (5), (8), (1) union values (3), (8), (1)) t;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 7
+2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
+3 UNION NULL NULL NULL NULL NULL NULL NULL No tables used
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+select * from (values (7), (5), (8), (1) union select * from t1) t;
+7
+7
+5
+8
+1
+9
+3
+2
+explain select * from (values (7), (5), (8), (1) union select * from t1) t;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY <derived2> ALL NULL NULL NULL NULL 7
+2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
+3 UNION t1 ALL NULL NULL NULL NULL 3
+NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
+drop table t1;
+#
+# MDEV-16930: expression in the first row of TVC specifying derived table
+#
+SELECT 1 + 1, 2, "abc";
+1 + 1 2 abc
+2 2 abc
+SELECT * FROM (SELECT 1 + 1, 2, "abc") t;
+1 + 1 2 abc
+2 2 abc
+WITH cte AS (SELECT 1 + 1, 2, "abc") SELECT * FROM cte;
+1 + 1 2 abc
+2 2 abc
+SELECT 1 + 1, 2, "abc" UNION SELECT 3+4, 3, "abc";
+1 + 1 2 abc
+2 2 abc
+7 3 abc
+CREATE VIEW v1 AS SELECT 1 + 1, 2, "abc";
+SELECT * FROM v1;
+1 + 1 2 abc
+2 2 abc
+DROP VIEW v1;
+VALUES(1 + 1,2,"abc");
+1 + 1 2 abc
+2 2 abc
+SELECT * FROM (VALUES(1 + 1,2,"abc")) t;
+1 + 1 2 abc
+2 2 abc
+PREPARE stmt FROM "SELECT * FROM (VALUES(1 + 1,2,'abc')) t";
+EXECUTE stmt;
+1 + 1 2 abc
+2 2 abc
+EXECUTE stmt;
+1 + 1 2 abc
+2 2 abc
+DEALLOCATE PREPARE stmt;
diff --git a/mysql-test/main/table_value_constr.test b/mysql-test/main/table_value_constr.test
index eb5ea59f829..0dd0a7a04b0 100644
--- a/mysql-test/main/table_value_constr.test
+++ b/mysql-test/main/table_value_constr.test
@@ -1075,3 +1075,51 @@ DELIMITER ;|
--error ER_EMPTY_ROW_IN_TVC
with t as (values (),()) select 1 from t;
+
+--echo #
+--echo # MDEV-17017: TVC in derived table
+--echo #
+
+create table t1 (a int);
+insert into t1 values (9), (3), (2);
+
+let $q1=
+select * from (values (7), (5), (8), (1), (3), (8), (1)) t;
+eval $q1;
+eval explain $q1;
+
+let $q2=
+select * from (values (1,11), (7,77), (3,31), (4,42)) t;
+eval $q2;
+eval explain $q2;
+
+let $q3=
+select * from (values (7), (5), (8), (1) union values (3), (8), (1)) t;
+eval $q3;
+eval explain $q3;
+
+let $q4=
+select * from (values (7), (5), (8), (1) union select * from t1) t;
+eval $q4;
+eval explain $q4;
+
+drop table t1;
+
+--echo #
+--echo # MDEV-16930: expression in the first row of TVC specifying derived table
+--echo #
+
+SELECT 1 + 1, 2, "abc";
+SELECT * FROM (SELECT 1 + 1, 2, "abc") t;
+WITH cte AS (SELECT 1 + 1, 2, "abc") SELECT * FROM cte;
+SELECT 1 + 1, 2, "abc" UNION SELECT 3+4, 3, "abc";
+CREATE VIEW v1 AS SELECT 1 + 1, 2, "abc";
+SELECT * FROM v1;
+DROP VIEW v1;
+
+VALUES(1 + 1,2,"abc");
+SELECT * FROM (VALUES(1 + 1,2,"abc")) t;
+PREPARE stmt FROM "SELECT * FROM (VALUES(1 + 1,2,'abc')) t";
+EXECUTE stmt;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
diff --git a/mysql-test/main/temp_table.result b/mysql-test/main/temp_table.result
index d1bec4a2af5..5de86e47fb1 100644
--- a/mysql-test/main/temp_table.result
+++ b/mysql-test/main/temp_table.result
@@ -548,3 +548,27 @@ DROP TABLE nonexisting_table, t1;
ERROR 42S02: Unknown table 'temp_db.nonexisting_table'
# Cleanup
DROP DATABASE temp_db;
+USE test;
+#
+# MDEV-17167 - InnoDB: Failing assertion: table->get_ref_count() == 0
+# upon truncating a temporary table
+#
+CREATE TEMPORARY TABLE t1(a INT) ENGINE=InnoDB;
+SELECT * FROM t1 AS t1a1, t1 AS t2a2;
+a a
+TRUNCATE TABLE t1;
+LOCK TABLES t1 WRITE;
+TRUNCATE TABLE t1;
+SELECT * FROM t1;
+a
+UNLOCK TABLES;
+LOCK TABLES t1 AS t1a1 WRITE, t1 AS t1a2 WRITE;
+TRUNCATE TABLE t1;
+SELECT * FROM t1 AS t1a1, t1 AS t1a2;
+a a
+UNLOCK TABLES;
+CREATE TABLE t2(a INT) ENGINE=InnoDB;
+LOCK TABLES t2 WRITE;
+TRUNCATE TABLE t1;
+UNLOCK TABLES;
+DROP TABLE t1, t2;
diff --git a/mysql-test/main/temp_table.test b/mysql-test/main/temp_table.test
index fb44362b537..a528e27b890 100644
--- a/mysql-test/main/temp_table.test
+++ b/mysql-test/main/temp_table.test
@@ -594,4 +594,30 @@ DROP TABLE nonexisting_table, t1;
--echo # Cleanup
DROP DATABASE temp_db;
+USE test;
+
+--echo #
+--echo # MDEV-17167 - InnoDB: Failing assertion: table->get_ref_count() == 0
+--echo # upon truncating a temporary table
+--echo #
+CREATE TEMPORARY TABLE t1(a INT) ENGINE=InnoDB;
+SELECT * FROM t1 AS t1a1, t1 AS t2a2;
+TRUNCATE TABLE t1;
+
+LOCK TABLES t1 WRITE;
+TRUNCATE TABLE t1;
+SELECT * FROM t1;
+UNLOCK TABLES;
+
+LOCK TABLES t1 AS t1a1 WRITE, t1 AS t1a2 WRITE;
+TRUNCATE TABLE t1;
+SELECT * FROM t1 AS t1a1, t1 AS t1a2;
+UNLOCK TABLES;
+
+CREATE TABLE t2(a INT) ENGINE=InnoDB;
+LOCK TABLES t2 WRITE;
+TRUNCATE TABLE t1;
+UNLOCK TABLES;
+
+DROP TABLE t1, t2;
diff --git a/mysql-test/main/timezone2.result b/mysql-test/main/timezone2.result
index 096e996bffb..6de62d7ea30 100644
--- a/mysql-test/main/timezone2.result
+++ b/mysql-test/main/timezone2.result
@@ -332,3 +332,26 @@ NULL
#
# End of 5.3 tests
#
+#
+# Start of 10.4 tests
+#
+#
+# MDEV-17203 Move fractional second truncation from Item_xxx_typecast::get_date() to Time and Datetime constructors
+# (an addition for the test for MDEV-4653)
+SET timestamp=unix_timestamp('2001-02-03 10:20:30');
+SET old_mode=ZERO_DATE_TIME_CAST;
+SELECT CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5');
+CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5')
+NULL
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '00:00:00'
+SELECT CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5');
+CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5')
+NULL
+Warnings:
+Warning 1292 Truncated incorrect datetime value: '00:00:00'
+SET old_mode=DEFAULT;
+SET timestamp=DEFAULT;
+#
+# End of 10.4 tests
+#
diff --git a/mysql-test/main/timezone2.test b/mysql-test/main/timezone2.test
index 7a38610ad95..773b40ec86c 100644
--- a/mysql-test/main/timezone2.test
+++ b/mysql-test/main/timezone2.test
@@ -308,3 +308,22 @@ SELECT CONVERT_TZ('2001-10-08 00:00:00', MAKE_SET(0,'+01:00'), '+00:00' );
--echo #
--echo # End of 5.3 tests
--echo #
+
+--echo #
+--echo # Start of 10.4 tests
+--echo #
+
+--echo #
+--echo # MDEV-17203 Move fractional second truncation from Item_xxx_typecast::get_date() to Time and Datetime constructors
+--echo # (an addition for the test for MDEV-4653)
+
+SET timestamp=unix_timestamp('2001-02-03 10:20:30');
+SET old_mode=ZERO_DATE_TIME_CAST;
+SELECT CONVERT_TZ(TIME('00:00:00'),'+00:00','+7:5');
+SELECT CONVERT_TZ(TIME('2010-01-01 00:00:00'),'+00:00','+7:5');
+SET old_mode=DEFAULT;
+SET timestamp=DEFAULT;
+
+--echo #
+--echo # End of 10.4 tests
+--echo #
diff --git a/mysql-test/main/type_date.result b/mysql-test/main/type_date.result
index 897f42a2ec4..2c268cfdd88 100644
--- a/mysql-test/main/type_date.result
+++ b/mysql-test/main/type_date.result
@@ -621,7 +621,7 @@ SELECT * FROM t1 WHERE LENGTH(a)=11+RAND() AND a=' garbage ';
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 Using where
Warnings:
-Warning 1292 Incorrect datetime value: ' garbage '
+Warning 1292 Truncated incorrect datetime value: ' garbage '
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = DATE'0000-00-00' and <cache>(octet_length(DATE'0000-00-00')) = 11 + rand()
DROP TABLE t1;
CREATE TABLE t1 (a DATE);
@@ -962,5 +962,41 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where coalesce(<cache>(DATE'2001-01-02'),`test`.`t1`.`a`) <=> coalesce(DATE'2001-01-01',`test`.`t1`.`a`)
DROP TABLE t1;
#
+# MDEV-15406 NO_ZERO_IN_DATE erroneously affects how CAST(AS DATE) warns about fractional digit truncation
+#
+SET sql_mode='';
+CREATE TABLE t1 (a DATE);
+SELECT CAST(20061108.01 AS DATE);
+CAST(20061108.01 AS DATE)
+2006-11-08
+Warnings:
+Note 1292 Truncated incorrect date value: '20061108.01'
+INSERT INTO t1 VALUES (20061108.01);
+Warnings:
+Note 1265 Data truncated for column 'a' at row 1
+DROP TABLE t1;
+SET sql_mode=NO_ZERO_IN_DATE;
+SELECT CAST(20061108.01 AS DATE);
+CAST(20061108.01 AS DATE)
+2006-11-08
+Warnings:
+Note 1292 Truncated incorrect date value: '20061108.01'
+CREATE TABLE t1 (a DATE);
+INSERT INTO t1 VALUES (20061108.01);
+Warnings:
+Note 1265 Data truncated for column 'a' at row 1
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+#
+# MDEV-17216 Assertion `!dt->fraction_remainder(decimals())' failed in Field_temporal_with_date::store_TIME_with_warning
+#
+SET sql_mode='';
+CREATE TABLE t1 (i1 date );
+CREATE TABLE t2 (i2 int unsigned );
+INSERT INTO t2 VALUES (0);
+INSERT INTO t1 SELECT * FROM t2;
+DROP TABLE t1,t2;
+SET sql_mode=DEFAULT;
+#
# End of 10.4 tests
#
diff --git a/mysql-test/main/type_date.test b/mysql-test/main/type_date.test
index cbd6cc846aa..75bbfb3b916 100644
--- a/mysql-test/main/type_date.test
+++ b/mysql-test/main/type_date.test
@@ -646,6 +646,37 @@ EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE COALESCE(?,a)<=>COALE
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-15406 NO_ZERO_IN_DATE erroneously affects how CAST(AS DATE) warns about fractional digit truncation
+--echo #
+
+SET sql_mode='';
+CREATE TABLE t1 (a DATE);
+SELECT CAST(20061108.01 AS DATE);
+INSERT INTO t1 VALUES (20061108.01);
+DROP TABLE t1;
+
+SET sql_mode=NO_ZERO_IN_DATE;
+SELECT CAST(20061108.01 AS DATE);
+CREATE TABLE t1 (a DATE);
+INSERT INTO t1 VALUES (20061108.01);
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+
+--echo #
+--echo # MDEV-17216 Assertion `!dt->fraction_remainder(decimals())' failed in Field_temporal_with_date::store_TIME_with_warning
+--echo #
+SET sql_mode='';
+CREATE TABLE t1 (i1 date );
+CREATE TABLE t2 (i2 int unsigned );
+INSERT INTO t2 VALUES (0);
+INSERT INTO t1 SELECT * FROM t2;
+DROP TABLE t1,t2;
+SET sql_mode=DEFAULT;
+
+
--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 86dddc93a70..7a213842e03 100644
--- a/mysql-test/main/type_datetime.result
+++ b/mysql-test/main/type_datetime.result
@@ -361,7 +361,7 @@ greatest(cast('01-01-01' as date), '01-01-02') + 0
20010102
select least(cast('01-01-01' as datetime), '01-01-02') + 0;
least(cast('01-01-01' as datetime), '01-01-02') + 0
-20010101000000.000000
+20010101000000
select cast(least(cast('01-01-01' as datetime), '01-01-02') as signed);
cast(least(cast('01-01-01' as datetime), '01-01-02') as signed)
20010101000000
@@ -399,7 +399,7 @@ if(@bug28261 = f1, '', @bug28261:= f1)
2001-01-01
2002-02-02
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
select if(@bug28261 = f1, '', @bug28261:= f1) from t1;
if(@bug28261 = f1, '', @bug28261:= f1)
2001-01-01
@@ -423,11 +423,11 @@ f1
2001-01-01 00:00:00
2002-02-02 00:00:00
Warnings:
-Warning 1292 Incorrect datetime value: '2002010'
+Warning 1292 Truncated incorrect datetime value: '2002010'
select * from t1 where f1 between 20020101 and 2007010100000;
f1
Warnings:
-Warning 1292 Incorrect datetime value: '2007010100000'
+Warning 1292 Truncated incorrect datetime value: '2007010100000'
drop table t1;
#
# Bug#27216: functions with parameters of different date types may
@@ -498,7 +498,7 @@ f1
45:44:44
15:44:44
Warnings:
-Warning 1292 Incorrect datetime value: '1'
+Warning 1292 Truncated incorrect datetime value: '1'
drop table t1;
create table t1 (a tinyint);
insert into t1 values (), (), ();
@@ -575,18 +575,18 @@ CAST('NULL' AS DATE) < CAST('NULL' AS DATE) n9;
n1 n2 n3 n4 n5 n6 n7 n8 n9
0 0 1 1 1 0 1 0 0
Warnings:
-Warning 1292 Incorrect datetime value: 'NULL'
-Warning 1292 Incorrect datetime value: 'NULL'
-Warning 1292 Incorrect datetime value: 'NULL'
-Warning 1292 Incorrect datetime value: 'NULL'
-Warning 1292 Incorrect datetime value: 'NULL'
-Warning 1292 Incorrect datetime value: 'NULL'
-Warning 1292 Incorrect datetime value: 'NULL'
-Warning 1292 Incorrect datetime value: 'NULL'
-Warning 1292 Incorrect datetime value: 'NULL'
-Warning 1292 Incorrect datetime value: 'NULL'
-Warning 1292 Incorrect datetime value: 'NULL'
-Warning 1292 Incorrect datetime value: 'NULL'
+Warning 1292 Truncated incorrect datetime value: 'NULL'
+Warning 1292 Truncated incorrect datetime value: 'NULL'
+Warning 1292 Truncated incorrect datetime value: 'NULL'
+Warning 1292 Truncated incorrect datetime value: 'NULL'
+Warning 1292 Truncated incorrect datetime value: 'NULL'
+Warning 1292 Truncated incorrect datetime value: 'NULL'
+Warning 1292 Truncated incorrect datetime value: 'NULL'
+Warning 1292 Truncated incorrect datetime value: 'NULL'
+Warning 1292 Truncated incorrect datetime value: 'NULL'
+Warning 1292 Truncated incorrect datetime value: 'NULL'
+Warning 1292 Truncated incorrect datetime value: 'NULL'
+Warning 1292 Truncated incorrect datetime value: 'NULL'
End of 5.0 tests
set @org_mode=@@sql_mode;
create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03');
@@ -917,7 +917,7 @@ CREATE TABLE t1 (a DATETIME);
INSERT INTO t1 VALUES ('0000-00-00 10:20:30');
SELECT a, LEAST(a,'2001-01-01 10:20:30') FROM t1;
a LEAST(a,'2001-01-01 10:20:30')
-0000-00-00 10:20:30 0000-00-00 10:20:30.000000
+0000-00-00 10:20:30 0000-00-00 10:20:30
DROP TABLE t1;
CREATE TABLE t1 (a DATETIME(6));
INSERT INTO t1 VALUES ('0000-00-00 00:00:00.000001');
@@ -1012,7 +1012,7 @@ SELECT * FROM t1 WHERE LENGTH(a)=30+RAND() AND a=' garbage ';
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 Using where
Warnings:
-Warning 1292 Incorrect datetime value: ' garbage '
+Warning 1292 Truncated incorrect datetime value: ' garbage '
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'0000-00-00 00:00:00' and <cache>(octet_length(TIMESTAMP'0000-00-00 00:00:00')) = 30 + rand()
DROP TABLE t1;
CREATE TABLE t1 (a DATETIME);;
@@ -1131,11 +1131,11 @@ INSERT INTO t1 VALUES ('00:00:00'),('00:01:00');
SELECT 1 FROM t1 WHERE 2016 > SOME (SELECT CAST(a AS DATETIME) FROM t1);
1
Warnings:
-Warning 1292 Incorrect datetime value: '2016'
+Warning 1292 Truncated incorrect datetime value: '2016'
SELECT * FROM t1 WHERE 2016 > CAST(a AS DATETIME);
a
Warnings:
-Warning 1292 Incorrect datetime value: '2016'
+Warning 1292 Truncated incorrect datetime value: '2016'
SELECT 1 FROM t1 WHERE 20160101 > SOME (SELECT CAST(a AS DATETIME) FROM t1);
1
1
@@ -1400,5 +1400,39 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where octet_length(coalesce(TIME'00:00:00.0',`test`.`t1`.`a`)) <=> octet_length(coalesce(<cache>(TIMESTAMP'2001-01-01 00:00:00.00'),`test`.`t1`.`a`))
DROP TABLE t1;
#
+# MDEV-17216 Assertion `!dt->fraction_remainder(decimals())' failed in Field_temporal_with_date::store_TIME_with_warning
+#
+CREATE TABLE t1 (b BIT(20));
+CREATE TABLE t2 (t DATETIME);
+INSERT IGNORE INTO t1 VALUES (b'000001001100000');
+INSERT INTO t2 SELECT * FROM t1;
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a DATETIME);
+INSERT INTO t1 SELECT CAST(20010101 AS UNSIGNED);
+DROP TABLE t1;
+#
+# MDEV-17563 Different results using table or view when comparing values of time type
+#
+CREATE TABLE t1 (pk int, x1 datetime, x2 varchar(1));
+INSERT INTO t1 VALUES (17,'2001-01-01 09:16:37','');
+INSERT INTO t1 VALUES (18,'2001-01-01 09:16:37','k');
+CREATE VIEW v1 AS SELECT * FROM t1;
+SELECT pk FROM t1 WHERE x1 >x2;
+pk
+17
+18
+Warnings:
+Warning 1292 Truncated incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: 'k'
+SELECT pk FROM v1 WHERE x1 >x2;
+pk
+17
+18
+Warnings:
+Warning 1292 Truncated incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: 'k'
+DROP VIEW v1;
+DROP TABLE t1;
+#
# End of 10.4 tests
#
diff --git a/mysql-test/main/type_datetime.test b/mysql-test/main/type_datetime.test
index 3c8287f8793..7bd7883f469 100644
--- a/mysql-test/main/type_datetime.test
+++ b/mysql-test/main/type_datetime.test
@@ -175,12 +175,12 @@ set @@sql_mode= @org_mode;
## ( Bug#29290 type_datetime.test failure in 5.1 )
## Therefore we sleep a bit if we are too close to midnight.
## The complete test itself needs around 1 second.
-## Therefore a time_distance to midnight of 5 seconds should be sufficient.
-if (`SELECT CURTIME() > SEC_TO_TIME(24 * 3600 - 5)`)
+## Therefore a time_distance to midnight of 10 seconds should be sufficient.
+if (`SELECT CURTIME() > SEC_TO_TIME(24 * 3600 - 10)`)
{
- # We are here when CURTIME() is between '23:59:56' and '23:59:59'.
- # So a sleep time of 5 seconds brings us between '00:00:01' and '00:00:04'.
- --real_sleep 5
+ # We are here when CURTIME() is between '23:59:51' and '23:59:59'.
+ # So a sleep time of 10 seconds brings us between '00:00:01' and '00:00:09'.
+ --real_sleep 10
}
create table t1 (f1 date, f2 datetime, f3 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP);
insert into t1(f1) values(curdate());
@@ -899,5 +899,34 @@ DROP TABLE t1;
--echo #
+--echo # MDEV-17216 Assertion `!dt->fraction_remainder(decimals())' failed in Field_temporal_with_date::store_TIME_with_warning
+--echo #
+
+CREATE TABLE t1 (b BIT(20));
+CREATE TABLE t2 (t DATETIME);
+INSERT IGNORE INTO t1 VALUES (b'000001001100000');
+INSERT INTO t2 SELECT * FROM t1;
+DROP TABLE t1, t2;
+
+CREATE TABLE t1 (a DATETIME);
+INSERT INTO t1 SELECT CAST(20010101 AS UNSIGNED);
+DROP TABLE t1;
+
+
+--echo #
+--echo # MDEV-17563 Different results using table or view when comparing values of time type
+--echo #
+
+CREATE TABLE t1 (pk int, x1 datetime, x2 varchar(1));
+INSERT INTO t1 VALUES (17,'2001-01-01 09:16:37','');
+INSERT INTO t1 VALUES (18,'2001-01-01 09:16:37','k');
+CREATE VIEW v1 AS SELECT * FROM t1;
+SELECT pk FROM t1 WHERE x1 >x2;
+SELECT pk FROM v1 WHERE x1 >x2;
+DROP VIEW v1;
+DROP TABLE t1;
+
+
+--echo #
--echo # End of 10.4 tests
--echo #
diff --git a/mysql-test/main/type_decimal.result b/mysql-test/main/type_decimal.result
index aed56164a39..dadaa5a4b77 100644
--- a/mysql-test/main/type_decimal.result
+++ b/mysql-test/main/type_decimal.result
@@ -1204,5 +1204,19 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where <cache>(octet_length(10.0)) + `test`.`t1`.`a` <=> <cache>(octet_length(10.00)) + `test`.`t1`.`a`
DROP TABLE t1;
#
+# MDEV-16984 Assertion `dec' failed in Dec_ptr::cmp
+#
+SET sql_mode='';
+CREATE TABLE t1 (dc decimal(10));
+INSERT INTO t1 VALUES (0000000),(NULL);
+SELECT 1 FROM t1 GROUP BY 'm' <=> dc;
+1
+1
+1
+Warnings:
+Warning 1292 Truncated incorrect DECIMAL value: 'm'
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+#
# End of 10.4 tests
#
diff --git a/mysql-test/main/type_decimal.test b/mysql-test/main/type_decimal.test
index 3921e86a940..53ad2698f50 100644
--- a/mysql-test/main/type_decimal.test
+++ b/mysql-test/main/type_decimal.test
@@ -745,5 +745,16 @@ DROP TABLE t1;
--echo #
+--echo # MDEV-16984 Assertion `dec' failed in Dec_ptr::cmp
+--echo #
+SET sql_mode='';
+CREATE TABLE t1 (dc decimal(10));
+INSERT INTO t1 VALUES (0000000),(NULL);
+SELECT 1 FROM t1 GROUP BY 'm' <=> dc;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+
+--echo #
--echo # End of 10.4 tests
--echo #
diff --git a/mysql-test/main/type_float.result b/mysql-test/main/type_float.result
index 0ac018379d1..bd1a722f80b 100644
--- a/mysql-test/main/type_float.result
+++ b/mysql-test/main/type_float.result
@@ -448,6 +448,46 @@ select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo;
foo
0
#
+# MDEV-17249 MAKETIME(-1e50,0,0) returns a wrong result
+#
+SELECT LEFT('a',EXP(50));
+LEFT('a',EXP(50))
+a
+SELECT LEFT('a', COALESCE(1e30));
+LEFT('a', COALESCE(1e30))
+a
+CREATE TABLE t1 (a FLOAT);
+INSERT INTO t1 VALUES (1e30);
+SELECT LEFT('a',a), LEFT('a',1e30) FROM t1;
+LEFT('a',a) LEFT('a',1e30)
+a a
+DROP TABLE t1;
+PREPARE stmt FROM 'SELECT LEFT(111,?)';
+SET @a=1e30;
+EXECUTE stmt USING @a;
+LEFT(111,?)
+111
+DEALLOCATE PREPARE stmt;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+SELECT LEFT('a',(SELECT 1e30 FROM t1 LIMIT 1));
+LEFT('a',(SELECT 1e30 FROM t1 LIMIT 1))
+a
+DROP TABLE t1;
+CREATE TABLE t1 (a DOUBLE);
+INSERT INTO t1 VALUES (1e30),(0);
+SELECT LEFT('a', SUM(a)) FROM t1;
+LEFT('a', SUM(a))
+a
+Warnings:
+Warning 1916 Got overflow when converting '1e30' to INT. Value truncated
+SELECT LEFT('a', AVG(a)) FROM t1;
+LEFT('a', AVG(a))
+a
+Warnings:
+Warning 1916 Got overflow when converting '5e29' to INT. Value truncated
+DROP TABLE t1;
+#
# Bug #13500371 63704: CONVERSION OF '1.' TO A NUMBER GIVES ERROR 1265
# (WARN_DATA_TRUNCATED)
#
diff --git a/mysql-test/main/type_float.test b/mysql-test/main/type_float.test
index 3d0131b3bb0..f42d3445e2a 100644
--- a/mysql-test/main/type_float.test
+++ b/mysql-test/main/type_float.test
@@ -332,6 +332,36 @@ eval select concat((truncate((-1.7976931348623157E+307),(0x1e))),
select format(truncate('1.7976931348623157E+308',-12),1,'fr_BE') as foo;
+
+--echo #
+--echo # MDEV-17249 MAKETIME(-1e50,0,0) returns a wrong result
+--echo #
+
+SELECT LEFT('a',EXP(50));
+SELECT LEFT('a', COALESCE(1e30));
+
+CREATE TABLE t1 (a FLOAT);
+INSERT INTO t1 VALUES (1e30);
+SELECT LEFT('a',a), LEFT('a',1e30) FROM t1;
+DROP TABLE t1;
+
+PREPARE stmt FROM 'SELECT LEFT(111,?)';
+SET @a=1e30;
+EXECUTE stmt USING @a;
+DEALLOCATE PREPARE stmt;
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+SELECT LEFT('a',(SELECT 1e30 FROM t1 LIMIT 1));
+DROP TABLE t1;
+
+CREATE TABLE t1 (a DOUBLE);
+INSERT INTO t1 VALUES (1e30),(0);
+SELECT LEFT('a', SUM(a)) FROM t1;
+SELECT LEFT('a', AVG(a)) FROM t1;
+DROP TABLE t1;
+
+
--echo #
--echo # Bug #13500371 63704: CONVERSION OF '1.' TO A NUMBER GIVES ERROR 1265
--echo # (WARN_DATA_TRUNCATED)
diff --git a/mysql-test/main/type_newdecimal.result b/mysql-test/main/type_newdecimal.result
index ba84ff50504..140f36b1261 100644
--- a/mysql-test/main/type_newdecimal.result
+++ b/mysql-test/main/type_newdecimal.result
@@ -1995,8 +1995,50 @@ select 0.0000000001 mod 1;
select 0.01 mod 1;
0.01 mod 1
0.01
+CREATE TABLE t1 (
+`FLD1` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD2` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD3` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD4` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD5` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD6` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD7` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD8` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD9` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD10` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD11` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD12` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD13` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD14` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD15` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD16` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD17` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD18` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD19` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD20` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD21` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD22` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+`FLD23` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000
+);
+INSERT INTO t1 VALUES (001.0760,000.9500,001.0000,001.0000,001.0000,
+001.0000,001.0000,001.0000,001.0000,001.0000,001.0000,000.5949,001.0194,
+001.0000,001.0000,001.0000,001.0000,001.0000,001.0000,000.9220,001.1890,001.2130,327.2690);
+select FLD1*FLD2*FLD3*FLD4*FLD5*FLD6*FLD7*FLD8*FLD9*FLD10*FLD11*FLD12*FLD13*FLD14*FLD15*FLD16*FLD17*FLD18*FLD19*FLD20*FLD21*FLD22*FLD23 as calc1 from t1;
+calc1
+269.77575757644053032218703200000000000000
+select FLD23*FLD2*FLD1*FLD4*FLD5*FLD11*FLD12*FLD13*FLD3*FLD15*FLD16*FLD17*FLD18*FLD19*FLD20*FLD21*FLD22*FLD14*FLD6*FLD7*FLD8*FLD9*FLD10 as calc2 from t1;
+calc2
+269.77575757644053032218703200000000000000
+DROP TABLE t1;
+CREATE TABLE t1 AS SELECT 1.0 * 2.000;
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `1.0 * 2.000` decimal(6,4) NOT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+DROP TABLE t1;
#
-# Start of 10.0 tests
+# End of 5.5 tests
#
#
# MDEV-6950 Bad results with joins comparing DATE and INT/ENUM/VARCHAR columns
diff --git a/mysql-test/main/type_newdecimal.test b/mysql-test/main/type_newdecimal.test
index dd5311e4be3..d2d64b0baee 100644
--- a/mysql-test/main/type_newdecimal.test
+++ b/mysql-test/main/type_newdecimal.test
@@ -1583,8 +1583,51 @@ select 0.000000000000000000000000000000000000000000000000001 mod 1;
select 0.0000000001 mod 1;
select 0.01 mod 1;
+#
+# MDEV-17256 Decimal field multiplication bug
+#
+
+CREATE TABLE t1 (
+ `FLD1` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD2` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD3` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD4` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD5` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD6` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD7` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD8` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD9` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD10` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD11` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD12` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD13` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD14` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD15` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD16` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD17` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD18` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD19` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD20` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD21` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD22` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000,
+ `FLD23` decimal(7,4) unsigned zerofill NOT NULL DEFAULT 001.0000
+);
+
+INSERT INTO t1 VALUES (001.0760,000.9500,001.0000,001.0000,001.0000,
+ 001.0000,001.0000,001.0000,001.0000,001.0000,001.0000,000.5949,001.0194,
+ 001.0000,001.0000,001.0000,001.0000,001.0000,001.0000,000.9220,001.1890,001.2130,327.2690);
+
+select FLD1*FLD2*FLD3*FLD4*FLD5*FLD6*FLD7*FLD8*FLD9*FLD10*FLD11*FLD12*FLD13*FLD14*FLD15*FLD16*FLD17*FLD18*FLD19*FLD20*FLD21*FLD22*FLD23 as calc1 from t1;
+select FLD23*FLD2*FLD1*FLD4*FLD5*FLD11*FLD12*FLD13*FLD3*FLD15*FLD16*FLD17*FLD18*FLD19*FLD20*FLD21*FLD22*FLD14*FLD6*FLD7*FLD8*FLD9*FLD10 as calc2 from t1;
+
+DROP TABLE t1;
+
+CREATE TABLE t1 AS SELECT 1.0 * 2.000;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
--echo #
---echo # Start of 10.0 tests
+--echo # End of 5.5 tests
--echo #
--echo #
diff --git a/mysql-test/main/type_temporal_innodb.result b/mysql-test/main/type_temporal_innodb.result
index b869822722d..f8d8bc018bd 100644
--- a/mysql-test/main/type_temporal_innodb.result
+++ b/mysql-test/main/type_temporal_innodb.result
@@ -56,7 +56,7 @@ SELECT DATE'0000-00-00'='';
DATE'0000-00-00'=''
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
CREATE TABLE t1 (a ENUM('a'), b DATE, c INT, KEY(b)) ENGINE=InnoDB;
INSERT IGNORE INTO t1 VALUES ('','0000-00-00',0);
Warnings:
@@ -65,49 +65,49 @@ SELECT * FROM t1 WHERE b='';
a b c
0000-00-00 0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT * FROM t1 IGNORE KEY (b) WHERE b='';
a b c
0000-00-00 0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT * FROM t1 WHERE a=b;
a b c
0000-00-00 0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT 1 FROM t1 WHERE (SELECT a FROM t1 group by c) = b;
1
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
ALTER TABLE t1 ENGINE=MyISAM;
SELECT * FROM t1 WHERE b='';
a b c
0000-00-00 0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT * FROM t1 IGNORE KEY (b) WHERE b='';
a b c
0000-00-00 0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT * FROM t1 WHERE a=b;
a b c
0000-00-00 0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT 1 FROM t1 WHERE (SELECT a FROM t1 group by c) = b;
1
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
DROP TABLE t1;
SELECT TIMESTAMP'0000-00-00 00:00:00'='';
TIMESTAMP'0000-00-00 00:00:00'=''
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
CREATE TABLE t1 (a ENUM('a'), b DATETIME, c INT, KEY(b)) ENGINE=InnoDB;
INSERT IGNORE INTO t1 VALUES ('','0000-00-00 00:00:00',0);
Warnings:
@@ -116,43 +116,43 @@ SELECT * FROM t1 WHERE b='';
a b c
0000-00-00 00:00:00 0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT * FROM t1 IGNORE KEY (b) WHERE b='';
a b c
0000-00-00 00:00:00 0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT * FROM t1 WHERE a=b;
a b c
0000-00-00 00:00:00 0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT 1 FROM t1 WHERE (SELECT a FROM t1 group by c) = b;
1
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
ALTER TABLE t1 ENGINE=MyISAM;
SELECT * FROM t1 WHERE b='';
a b c
0000-00-00 00:00:00 0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT * FROM t1 IGNORE KEY (b) WHERE b='';
a b c
0000-00-00 00:00:00 0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT * FROM t1 WHERE a=b;
a b c
0000-00-00 00:00:00 0
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
SELECT 1 FROM t1 WHERE (SELECT a FROM t1 group by c) = b;
1
1
Warnings:
-Warning 1292 Incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
DROP TABLE t1;
CREATE TABLE t1 (d DATE) ENGINE=InnoDB;
INSERT INTO t1 VALUES ('2012-12-21');
diff --git a/mysql-test/main/type_time.result b/mysql-test/main/type_time.result
index 8f50d49d4b9..0a66a94db69 100644
--- a/mysql-test/main/type_time.result
+++ b/mysql-test/main/type_time.result
@@ -1463,9 +1463,9 @@ GREATEST('2010-01-01 10:10:10',TIME('-20:20:20')) AS gt_minus20_implicit,
GREATEST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('-20:20:20')) AS gt_minis20_explicit,
GREATEST('2010-01-01 10:10:10',TIME('20:20:20')) AS gt_plus20_implicit,
GREATEST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('20:20:20')) AS gt_plus20_explicit;
-gt_minus20_implicit 10:10:10.000000
+gt_minus20_implicit 10:10:10
gt_minis20_explicit 10:10:10.000000
-gt_plus20_implicit 20:20:20.000000
+gt_plus20_implicit 20:20:20
gt_plus20_explicit 20:20:20.000000
SELECT
HOUR(GREATEST('2010-01-01 10:10:10',TIME('-20:20:20'))) AS gt_minus20_implicit,
@@ -1481,9 +1481,9 @@ LEAST('2010-01-01 10:10:10',TIME('-20:20:20')) AS lt_minus20_implicit,
LEAST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('-20:20:20')) AS lt_minus20_explicit,
LEAST('2010-01-01 10:10:10',TIME('20:20:20')) AS lt_plus20_implicit,
LEAST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('20:20:20')) AS lt_plus20_explicit;
-lt_minus20_implicit -20:20:20.000000
+lt_minus20_implicit -20:20:20
lt_minus20_explicit -20:20:20.000000
-lt_plus20_implicit 10:10:10.000000
+lt_plus20_implicit 10:10:10
lt_plus20_explicit 10:10:10.000000
SELECT
HOUR(LEAST('2010-01-01 10:10:10',TIME('-20:20:20'))) AS lt_minus20_implicit,
@@ -1499,9 +1499,9 @@ GREATEST('2010-01-01 10:10:10',TIME('-200:20:20')) AS gt_minus200_implicit,
GREATEST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('-200:20:20')) AS gt_minus200_explictit,
GREATEST('2010-01-01 10:10:10',TIME('200:20:20')) AS gt_plus200_implicit,
GREATEST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('200:20:20')) AS gt_plus200_explicit;
-gt_minus200_implicit 10:10:10.000000
+gt_minus200_implicit 10:10:10
gt_minus200_explictit 10:10:10.000000
-gt_plus200_implicit 200:20:20.000000
+gt_plus200_implicit 200:20:20
gt_plus200_explicit 200:20:20.000000
SELECT
HOUR(GREATEST('2010-01-01 10:10:10',TIME('-200:20:20'))) AS gt_minus200_implicit,
@@ -1517,9 +1517,9 @@ LEAST('2010-01-01 10:10:10',TIME('-200:20:20')) AS lt_minus200_implicit,
LEAST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('-200:20:20')) AS lt_minus200_explictit,
LEAST('2010-01-01 10:10:10',TIME('200:20:20')) AS lt_plus200_implicit,
LEAST(CAST('2010-01-01 10:10:10' AS TIME(6)),TIME('200:20:20')) AS lt_plus200_explicit;
-lt_minus200_implicit -200:20:20.000000
+lt_minus200_implicit -200:20:20
lt_minus200_explictit -200:20:20.000000
-lt_plus200_implicit 10:10:10.000000
+lt_plus200_implicit 10:10:10
lt_plus200_explicit 10:10:10.000000
SELECT
HOUR(LEAST('2010-01-01 10:10:10',TIME('-200:20:20'))) AS lt_minus200_implicit,
@@ -2064,5 +2064,109 @@ Warnings:
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where octet_length(coalesce(TIME'00:00:00.0',`test`.`t1`.`a`)) <=> octet_length(coalesce(<cache>(TIME'00:00:00.00'),`test`.`t1`.`a`))
DROP TABLE t1;
#
+# MDEV-16971 Assertion `is_valid_value_slow()' failed in Time::adjust_time_range_or_invalidate
+#
+SET sql_mode='';
+CREATE TABLE t1 (d1 date, t1 time, KEY t1 (t1));
+INSERT INTO t1 VALUES ('1982-12-19','08:16:31'),('1981-04-19','21:52:59'),('1971-06-09','07:15:44'),('2007-08-15','03:55:02'),('1993-06-05','04:17:51'),('2034-07-01','17:31:12'),('1998-08-24','08:09:27'),('1991-01-15','01:14:07'),('2001-02-25','10:41:28'),('1974-06-24','10:21:58'),('1977-04-21','16:38:05'),('1981-12-03','01:24:42'),('1972-06-15','20:19:16'),('1989-08-10','08:53:47'),('2018-05-19','15:06:49'),('1984-01-12','15:56:11'),('2013-01-23','04:16:16'),('2000-06-10','02:06:44'),('1995-01-03','04:51:38');
+CREATE TABLE t2 (d1 date );
+INSERT INTO t2 VALUES ('2018-06-01'),('1979-10-25'),('1974-08-22'),('1980-06-17');
+SELECT * FROM (t1 JOIN t2 ON (t2.d1 = t1.t1)) WHERE (t1.d1 > 70 );
+d1 t1 d1
+UPDATE (t1 JOIN t2 ON (t2.d1 = t1.t1)) SET t1.d1 = '2018-07-07' WHERE (t1.d1 > 70 );
+DROP TABLE t1,t2;
+#
+# MDEV-17219 Assertion `!t->fraction_remainder(decimals())' failed in Field_time::store_TIME_with_warning
+#
+SET optimizer_use_condition_selectivity=3;
+CREATE TABLE t1 (it TIME NOT NULL);
+INSERT INTO t1 VALUES ('07:25:13'),('05:15:55'),('09:58:01'),('04:23:57'),('19:37:28'),('01:38:05'),('20:50:52');
+SELECT 1 FROM t1 WHERE it < -7487797330456870912;
+1
+Warnings:
+Warning 1292 Truncated incorrect time value: '-7487797330456870912'
+DROP TABLE t1;
+SET optimizer_use_condition_selectivity=DEFAULT;
+#
+# MDEV-17417 TIME(99991231235959) returns 838:59:59 instead of 23:59:58
+#
+SELECT TIME(99991231235957), TIME(99991231235958), TIME(99991231235959);
+TIME(99991231235957) TIME(99991231235958) TIME(99991231235959)
+23:59:57 23:59:58 23:59:59
+#
+# MDEV-17634 Regression: TIME(0)=TIME('z') returns NULL vs 1
+#
+SELECT
+TIMESTAMP(0)=TIMESTAMP('z') AS ts,
+DATE(0)=DATE('z') AS d,
+TIME(0)=TIME('z') AS t;
+ts d t
+1 1 1
+Warnings:
+Warning 1292 Truncated incorrect datetime value: 'z'
+Warning 1292 Truncated incorrect datetime value: 'z'
+Warning 1292 Truncated incorrect time value: 'z'
+SELECT
+TIMESTAMP(0)=TIMESTAMP('') AS ts,
+DATE(0)=DATE('') AS d,
+TIME(0)=TIME('') AS t;
+ts d t
+1 1 1
+Warnings:
+Warning 1292 Truncated incorrect datetime value: ''
+Warning 1292 Truncated incorrect datetime value: ''
+Warning 1292 Truncated incorrect time value: ''
+#
+# MDEV-17563 Different results using table or view when comparing values of time type
+#
+CREATE TABLE t1 (pk int, x1 time, x2 varchar(1));
+INSERT INTO t1 VALUES (17,'09:16:37','k'),(70,'19:44:22','k');
+CREATE VIEW v1 AS SELECT * FROM t1;
+SELECT pk FROM t1 WHERE x1 >x2;
+pk
+17
+70
+Warnings:
+Warning 1292 Truncated incorrect time value: 'k'
+Warning 1292 Truncated incorrect time value: 'k'
+SELECT pk FROM v1 WHERE x1 >x2;
+pk
+17
+70
+Warnings:
+Warning 1292 Truncated incorrect time value: 'k'
+Warning 1292 Truncated incorrect time value: 'k'
+DROP VIEW v1;
+DROP TABLE t1;
+CREATE TABLE t1 (pk int, x1 time, x2 varchar(1));
+INSERT INTO t1 VALUES (17,'09:16:37',''),(70,'19:44:22','k');
+CREATE VIEW v1 AS SELECT * FROM t1;
+SELECT pk FROM t1 WHERE x1 >x2;
+pk
+17
+70
+Warnings:
+Warning 1292 Truncated incorrect time value: ''
+Warning 1292 Truncated incorrect time value: 'k'
+SELECT pk FROM v1 WHERE x1 >x2;
+pk
+17
+70
+Warnings:
+Warning 1292 Truncated incorrect time value: ''
+Warning 1292 Truncated incorrect time value: 'k'
+DROP VIEW IF EXISTS v1;
+DROP TABLE IF EXISTS t1;
+#
+# MDEV-17625 Different warnings when comparing a garbage to DATETIME vs TIME
+#
+SELECT TIMESTAMP(0)='z', DATE(0)='z', TIME(0)='z';
+TIMESTAMP(0)='z' DATE(0)='z' TIME(0)='z'
+1 1 1
+Warnings:
+Warning 1292 Truncated incorrect datetime value: 'z'
+Warning 1292 Truncated incorrect datetime value: 'z'
+Warning 1292 Truncated incorrect time value: 'z'
+#
# End of 10.4 tests
#
diff --git a/mysql-test/main/type_time.test b/mysql-test/main/type_time.test
index f4a1a474046..5e4090f48a4 100644
--- a/mysql-test/main/type_time.test
+++ b/mysql-test/main/type_time.test
@@ -1340,5 +1340,75 @@ EXECUTE IMMEDIATE 'EXPLAIN EXTENDED SELECT * FROM t1 WHERE LENGTH(COALESCE(TIME'
DROP TABLE t1;
--echo #
+--echo # MDEV-16971 Assertion `is_valid_value_slow()' failed in Time::adjust_time_range_or_invalidate
+--echo #
+SET sql_mode='';
+CREATE TABLE t1 (d1 date, t1 time, KEY t1 (t1));
+INSERT INTO t1 VALUES ('1982-12-19','08:16:31'),('1981-04-19','21:52:59'),('1971-06-09','07:15:44'),('2007-08-15','03:55:02'),('1993-06-05','04:17:51'),('2034-07-01','17:31:12'),('1998-08-24','08:09:27'),('1991-01-15','01:14:07'),('2001-02-25','10:41:28'),('1974-06-24','10:21:58'),('1977-04-21','16:38:05'),('1981-12-03','01:24:42'),('1972-06-15','20:19:16'),('1989-08-10','08:53:47'),('2018-05-19','15:06:49'),('1984-01-12','15:56:11'),('2013-01-23','04:16:16'),('2000-06-10','02:06:44'),('1995-01-03','04:51:38');
+CREATE TABLE t2 (d1 date );
+INSERT INTO t2 VALUES ('2018-06-01'),('1979-10-25'),('1974-08-22'),('1980-06-17');
+SELECT * FROM (t1 JOIN t2 ON (t2.d1 = t1.t1)) WHERE (t1.d1 > 70 );
+UPDATE (t1 JOIN t2 ON (t2.d1 = t1.t1)) SET t1.d1 = '2018-07-07' WHERE (t1.d1 > 70 );
+DROP TABLE t1,t2;
+
+--echo #
+--echo # MDEV-17219 Assertion `!t->fraction_remainder(decimals())' failed in Field_time::store_TIME_with_warning
+--echo #
+SET optimizer_use_condition_selectivity=3;
+CREATE TABLE t1 (it TIME NOT NULL);
+INSERT INTO t1 VALUES ('07:25:13'),('05:15:55'),('09:58:01'),('04:23:57'),('19:37:28'),('01:38:05'),('20:50:52');
+SELECT 1 FROM t1 WHERE it < -7487797330456870912;
+DROP TABLE t1;
+SET optimizer_use_condition_selectivity=DEFAULT;
+
+--echo #
+--echo # MDEV-17417 TIME(99991231235959) returns 838:59:59 instead of 23:59:58
+--echo #
+SELECT TIME(99991231235957), TIME(99991231235958), TIME(99991231235959);
+
+--echo #
+--echo # MDEV-17634 Regression: TIME(0)=TIME('z') returns NULL vs 1
+--echo #
+SELECT
+ TIMESTAMP(0)=TIMESTAMP('z') AS ts,
+ DATE(0)=DATE('z') AS d,
+ TIME(0)=TIME('z') AS t;
+
+SELECT
+ TIMESTAMP(0)=TIMESTAMP('') AS ts,
+ DATE(0)=DATE('') AS d,
+ TIME(0)=TIME('') AS t;
+
+
+--echo #
+--echo # MDEV-17563 Different results using table or view when comparing values of time type
+--echo #
+
+CREATE TABLE t1 (pk int, x1 time, x2 varchar(1));
+INSERT INTO t1 VALUES (17,'09:16:37','k'),(70,'19:44:22','k');
+CREATE VIEW v1 AS SELECT * FROM t1;
+SELECT pk FROM t1 WHERE x1 >x2;
+SELECT pk FROM v1 WHERE x1 >x2;
+DROP VIEW v1;
+DROP TABLE t1;
+
+
+CREATE TABLE t1 (pk int, x1 time, x2 varchar(1));
+INSERT INTO t1 VALUES (17,'09:16:37',''),(70,'19:44:22','k');
+CREATE VIEW v1 AS SELECT * FROM t1;
+SELECT pk FROM t1 WHERE x1 >x2;
+SELECT pk FROM v1 WHERE x1 >x2;
+DROP VIEW IF EXISTS v1;
+DROP TABLE IF EXISTS t1;
+
+
+--echo #
+--echo # MDEV-17625 Different warnings when comparing a garbage to DATETIME vs TIME
+--echo #
+
+SELECT TIMESTAMP(0)='z', DATE(0)='z', TIME(0)='z';
+
+
+--echo #
--echo # End of 10.4 tests
--echo #
diff --git a/mysql-test/main/type_timestamp.result b/mysql-test/main/type_timestamp.result
index 6fcc802b91a..a708ef5ec34 100644
--- a/mysql-test/main/type_timestamp.result
+++ b/mysql-test/main/type_timestamp.result
@@ -872,7 +872,7 @@ SELECT * FROM t1 WHERE LENGTH(a)=30+RAND() AND a=' garbage ';
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 Using where
Warnings:
-Warning 1292 Incorrect datetime value: ' garbage '
+Warning 1292 Truncated incorrect datetime value: ' garbage '
Note 1003 select `test`.`t1`.`a` AS `a` from `test`.`t1` where `test`.`t1`.`a` = TIMESTAMP'0000-00-00 00:00:00' and <cache>(octet_length(TIMESTAMP'0000-00-00 00:00:00')) = 30 + rand()
DROP TABLE t1;
CREATE TABLE t1 (a TIMESTAMP);;
@@ -1018,3 +1018,20 @@ DROP TABLE t1;
#
# End of 10.3 tests
#
+#
+# Start of 10.4 tests
+#
+#
+# MDEV-17216 Assertion `!dt->fraction_remainder(decimals())' failed in Field_temporal_with_date::store_TIME_with_warning
+#
+CREATE TABLE t1 (b BIT(20));
+CREATE TABLE t2 (t TIMESTAMP);
+INSERT IGNORE INTO t1 VALUES (b'000001001100000');
+INSERT INTO t2 SELECT * FROM t1;
+DROP TABLE t1, t2;
+CREATE TABLE t1 (a TIMESTAMP);
+INSERT INTO t1 SELECT CAST(20010101 AS UNSIGNED);
+DROP TABLE t1;
+#
+# End of 10.4 tests
+#
diff --git a/mysql-test/main/type_timestamp.test b/mysql-test/main/type_timestamp.test
index 6d81a86331a..eeb6e2f8213 100644
--- a/mysql-test/main/type_timestamp.test
+++ b/mysql-test/main/type_timestamp.test
@@ -606,3 +606,25 @@ DROP TABLE t1;
--echo #
--echo # End of 10.3 tests
--echo #
+
+--echo #
+--echo # Start of 10.4 tests
+--echo #
+
+--echo #
+--echo # MDEV-17216 Assertion `!dt->fraction_remainder(decimals())' failed in Field_temporal_with_date::store_TIME_with_warning
+--echo #
+
+CREATE TABLE t1 (b BIT(20));
+CREATE TABLE t2 (t TIMESTAMP);
+INSERT IGNORE INTO t1 VALUES (b'000001001100000');
+INSERT INTO t2 SELECT * FROM t1;
+DROP TABLE t1, t2;
+
+CREATE TABLE t1 (a TIMESTAMP);
+INSERT INTO t1 SELECT CAST(20010101 AS UNSIGNED);
+DROP TABLE t1;
+
+--echo #
+--echo # End of 10.4 tests
+--echo #
diff --git a/mysql-test/main/type_year.result b/mysql-test/main/type_year.result
index 3fdca099a94..3f589f38267 100644
--- a/mysql-test/main/type_year.result
+++ b/mysql-test/main/type_year.result
@@ -396,7 +396,14 @@ a
drop table t1;
drop function y2k;
#
-# Start of 10.1 tests
+# MDEV-17257 Server crashes in Item::field_type_for_temporal_comparison or in get_datetime_value on SELECT with YEAR field and IN
+#
+CREATE TABLE t1 (y YEAR);
+SELECT * FROM t1 WHERE y IN ( CAST( '1993-03-26 10:14:20' AS DATE ), NULL );
+y
+DROP TABLE t1;
+#
+# End of 10.0 tests
#
#
# MDEV-8741 Equal field propagation leaves some remainders after simplifying WHERE zerofill_column=2010 AND zerofill_column>=2010
@@ -554,5 +561,20 @@ MIN(a) MAX(a)
70 69
DROP TABLE t1;
#
+# MDEV-17015 Assertion `m_year <= 9999' failed in Year::Year upon bad argument to MAKEDATE
+#
+SELECT MAKEDATE(18446744073709551615, 1);
+MAKEDATE(18446744073709551615, 1)
+NULL
+#
+# MDEV-17607 DATE(COALESCE(year_column)) returns a wrong result
+#
+CREATE TABLE t1 (a YEAR);
+INSERT INTO t1 VALUES (NULL);
+SELECT COALESCE(a), DATE(COALESCE(a)) FROM t1;
+COALESCE(a) DATE(COALESCE(a))
+NULL NULL
+DROP TABLE t1;
+#
# End of 10.4 tests
#
diff --git a/mysql-test/main/type_year.test b/mysql-test/main/type_year.test
index 657940a62a8..ea7514898cd 100644
--- a/mysql-test/main/type_year.test
+++ b/mysql-test/main/type_year.test
@@ -187,9 +187,16 @@ select a from t1 where a=b; # not a constant
drop table t1;
drop function y2k;
+--echo #
+--echo # MDEV-17257 Server crashes in Item::field_type_for_temporal_comparison or in get_datetime_value on SELECT with YEAR field and IN
+--echo #
+
+CREATE TABLE t1 (y YEAR);
+SELECT * FROM t1 WHERE y IN ( CAST( '1993-03-26 10:14:20' AS DATE ), NULL );
+DROP TABLE t1;
--echo #
---echo # Start of 10.1 tests
+--echo # End of 10.0 tests
--echo #
--echo #
@@ -294,6 +301,19 @@ SELECT a, CAST(a AS DATE), CAST(COALESCE(a) AS DATE) FROM t1;
SELECT MIN(a), MAX(a) FROM t1;
DROP TABLE t1;
+--echo #
+--echo # MDEV-17015 Assertion `m_year <= 9999' failed in Year::Year upon bad argument to MAKEDATE
+--echo #
+SELECT MAKEDATE(18446744073709551615, 1);
+
+--echo #
+--echo # MDEV-17607 DATE(COALESCE(year_column)) returns a wrong result
+--echo #
+
+CREATE TABLE t1 (a YEAR);
+INSERT INTO t1 VALUES (NULL);
+SELECT COALESCE(a), DATE(COALESCE(a)) FROM t1;
+DROP TABLE t1;
--echo #
--echo # End of 10.4 tests
diff --git a/mysql-test/main/union.result b/mysql-test/main/union.result
index fe80f67045c..0c6ddd3675a 100644
--- a/mysql-test/main/union.result
+++ b/mysql-test/main/union.result
@@ -2149,6 +2149,22 @@ DROP VIEW v1;
UNION
(SELECT 2, 2);
ERROR 42S02: Table 'test.v1' doesn't exist
+#
+# Bug#27197235 USER VARIABLE + UINON + DECIMAL COLUMN RETURNS
+# WRONG VALUES
+#
+SET NAMES utf8;
+SET @advertAcctId = 1000003;
+select @advertAcctId as a from dual union all select 1.0 from dual;
+a
+1000003.0
+1.0
+SET NAMES latin1;
+SET @advertAcctId = 1000003;
+select @advertAcctId as a from dual union all select 1.0 from dual;
+a
+1000003.0
+1.0
End of 5.5 tests
#
# WL#1763 Avoid creating temporary table in UNION ALL
diff --git a/mysql-test/main/union.test b/mysql-test/main/union.test
index d0a8e335d88..ca14731600e 100644
--- a/mysql-test/main/union.test
+++ b/mysql-test/main/union.test
@@ -1480,6 +1480,21 @@ DROP VIEW v1;
UNION
(SELECT 2, 2);
+--echo #
+--echo # Bug#27197235 USER VARIABLE + UINON + DECIMAL COLUMN RETURNS
+--echo # WRONG VALUES
+--echo #
+
+let $old_charset= `SELECT @@character_set_client`;
+
+SET NAMES utf8;
+SET @advertAcctId = 1000003;
+select @advertAcctId as a from dual union all select 1.0 from dual;
+
+eval SET NAMES $old_charset;
+SET @advertAcctId = 1000003;
+select @advertAcctId as a from dual union all select 1.0 from dual;
+
--echo End of 5.5 tests
--echo #
diff --git a/mysql-test/main/win.result b/mysql-test/main/win.result
index fd0fbefdcc5..2f757756117 100644
--- a/mysql-test/main/win.result
+++ b/mysql-test/main/win.result
@@ -38,10 +38,10 @@ a row_number() over (partition by a order by b)
select a, b, x, row_number() over (partition by a order by x) from t1;
a b x row_number() over (partition by a order by x)
2 10 xx 1
-2 10 zz 3
2 20 yy 2
-3 10 xxx 2
+2 10 zz 3
3 20 vvv 1
+3 10 xxx 2
drop table t1;
create table t1 (pk int primary key, a int, b int);
insert into t1 values
@@ -54,13 +54,14 @@ select
pk, a, b,
row_number() over (order by a),
row_number() over (order by b)
-from t1;
+from t1
+order by b;
pk a b row_number() over (order by a) row_number() over (order by b)
-1 10 22 1 5
-2 11 21 2 4
-3 12 20 3 3
-4 13 19 4 2
5 14 18 5 1
+4 13 19 4 2
+3 12 20 3 3
+2 11 21 2 4
+1 10 22 1 5
drop table t1;
#
# Try RANK() function
@@ -228,16 +229,16 @@ count(*) over (partition by c order by pk desc
rows between 2 preceding and 2 following) as CNT
from t1;
pk c CNT
-1 1 3
-2 1 4
-3 1 4
4 1 3
-5 2 3
-6 2 4
-7 2 5
-8 2 5
-9 2 4
+3 1 4
+2 1 4
+1 1 3
10 2 3
+9 2 4
+8 2 5
+7 2 5
+6 2 4
+5 2 3
drop table t0,t1;
#
# Resolution of window names
@@ -535,42 +536,40 @@ insert into t3 values
(5, 2),
(6, 2);
select
-pk,
val,
count(val) over (order by val
range between current row and
current row)
as CNT
from t3;
-pk val CNT
-0 1 3
-1 1 3
-2 1 3
-3 2 4
-4 2 4
-5 2 4
-6 2 4
+val CNT
+1 3
+1 3
+1 3
+2 4
+2 4
+2 4
+2 4
insert into t3 values
(7, 3),
(8, 3);
select
-pk,
val,
count(val) over (order by val
range between current row and
current row)
as CNT
from t3;
-pk val CNT
-0 1 3
-1 1 3
-2 1 3
-3 2 4
-4 2 4
-5 2 4
-6 2 4
-7 3 2
-8 3 2
+val CNT
+1 3
+1 3
+1 3
+2 4
+2 4
+2 4
+2 4
+3 2
+3 2
drop table t3;
# Now, check with PARTITION BY
create table t4 (
@@ -599,7 +598,6 @@ insert into t4 values
(5678, 208, 3);
select
part_id,
-pk,
val,
count(val) over (partition by part_id
order by val
@@ -607,31 +605,30 @@ range between current row and
current row)
as CNT
from t4;
-part_id pk val CNT
-1234 100 1 3
-1234 101 1 3
-1234 102 1 3
-1234 103 2 4
-1234 104 2 4
-1234 105 2 4
-1234 106 2 4
-1234 107 3 2
-1234 108 3 2
-5678 200 1 3
-5678 201 1 3
-5678 202 1 3
-5678 203 2 4
-5678 204 2 4
-5678 205 2 4
-5678 206 2 4
-5678 207 3 2
-5678 208 3 2
+part_id val CNT
+1234 1 3
+1234 1 3
+1234 1 3
+1234 2 4
+1234 2 4
+1234 2 4
+1234 2 4
+1234 3 2
+1234 3 2
+5678 1 3
+5678 1 3
+5678 1 3
+5678 2 4
+5678 2 4
+5678 2 4
+5678 2 4
+5678 3 2
+5678 3 2
#
# Try RANGE UNBOUNDED PRECEDING | FOLLOWING
#
select
part_id,
-pk,
val,
count(val) over (partition by part_id
order by val
@@ -639,28 +636,27 @@ range between unbounded preceding and
current row)
as CNT
from t4;
-part_id pk val CNT
-1234 100 1 3
-1234 101 1 3
-1234 102 1 3
-1234 103 2 7
-1234 104 2 7
-1234 105 2 7
-1234 106 2 7
-1234 107 3 9
-1234 108 3 9
-5678 200 1 3
-5678 201 1 3
-5678 202 1 3
-5678 203 2 7
-5678 204 2 7
-5678 205 2 7
-5678 206 2 7
-5678 207 3 9
-5678 208 3 9
+part_id val CNT
+1234 1 3
+1234 1 3
+1234 1 3
+1234 2 7
+1234 2 7
+1234 2 7
+1234 2 7
+1234 3 9
+1234 3 9
+5678 1 3
+5678 1 3
+5678 1 3
+5678 2 7
+5678 2 7
+5678 2 7
+5678 2 7
+5678 3 9
+5678 3 9
select
part_id,
-pk,
val,
count(val) over (partition by part_id
order by val
@@ -668,28 +664,27 @@ range between current row and
unbounded following)
as CNT
from t4;
-part_id pk val CNT
-1234 100 1 9
-1234 101 1 9
-1234 102 1 9
-1234 103 2 6
-1234 104 2 6
-1234 105 2 6
-1234 106 2 6
-1234 107 3 2
-1234 108 3 2
-5678 200 1 9
-5678 201 1 9
-5678 202 1 9
-5678 203 2 6
-5678 204 2 6
-5678 205 2 6
-5678 206 2 6
-5678 207 3 2
-5678 208 3 2
+part_id val CNT
+1234 1 9
+1234 1 9
+1234 1 9
+1234 2 6
+1234 2 6
+1234 2 6
+1234 2 6
+1234 3 2
+1234 3 2
+5678 1 9
+5678 1 9
+5678 1 9
+5678 2 6
+5678 2 6
+5678 2 6
+5678 2 6
+5678 3 2
+5678 3 2
select
part_id,
-pk,
val,
count(val) over (partition by part_id
order by val
@@ -697,25 +692,25 @@ range between unbounded preceding and
unbounded following)
as CNT
from t4;
-part_id pk val CNT
-1234 100 1 9
-1234 101 1 9
-1234 102 1 9
-1234 103 2 9
-1234 104 2 9
-1234 105 2 9
-1234 106 2 9
-1234 107 3 9
-1234 108 3 9
-5678 200 1 9
-5678 201 1 9
-5678 202 1 9
-5678 203 2 9
-5678 204 2 9
-5678 205 2 9
-5678 206 2 9
-5678 207 3 9
-5678 208 3 9
+part_id val CNT
+1234 1 9
+1234 1 9
+1234 1 9
+1234 2 9
+1234 2 9
+1234 2 9
+1234 2 9
+1234 3 9
+1234 3 9
+5678 1 9
+5678 1 9
+5678 1 9
+5678 2 9
+5678 2 9
+5678 2 9
+5678 2 9
+5678 3 9
+5678 3 9
drop table t4;
#
# MDEV-9695: Wrong window frame when using RANGE BETWEEN N FOLLOWING AND PRECEDING
@@ -881,15 +876,15 @@ RANGE BETWEEN UNBOUNDED PRECEDING
AND 10 FOLLOWING) as cnt
from t1;
pk a cnt
-1 1 9
-2 2 9
-3 4 9
-4 8 9
-5 26 5
-6 27 5
-7 40 3
-8 71 2
9 72 2
+8 71 2
+7 40 3
+6 27 5
+5 26 5
+4 8 9
+3 4 9
+2 2 9
+1 1 9
select
pk, a,
count(a) over (ORDER BY a
@@ -929,15 +924,15 @@ RANGE BETWEEN UNBOUNDED PRECEDING
AND 10 PRECEDING) as cnt
from t1;
pk a cnt
-1 1 5
-2 2 5
-3 4 5
-4 8 5
-5 26 3
-6 27 3
-7 40 2
-8 71 0
9 72 0
+8 71 0
+7 40 2
+6 27 3
+5 26 3
+4 8 5
+3 4 5
+2 2 5
+1 1 5
select
pk, a,
count(a) over (ORDER BY a
@@ -977,15 +972,15 @@ RANGE BETWEEN 1 PRECEDING
AND CURRENT ROW) as cnt
from t1;
pk a cnt
-1 1 2
-2 2 1
-3 4 1
-4 8 1
-5 26 2
-6 27 1
-7 40 1
-8 71 2
9 72 1
+8 71 2
+7 40 1
+6 27 1
+5 26 2
+4 8 1
+3 4 1
+2 2 1
+1 1 2
select
pk, a,
count(a) over (ORDER BY a
@@ -1026,15 +1021,15 @@ range between current row
and 1 following) as cnt
from t1;
pk a cnt
-1 1 1
-2 2 2
-3 4 1
-4 8 1
-5 26 1
-6 27 2
-7 40 1
-8 71 1
9 72 2
+8 71 1
+7 40 1
+6 27 2
+5 26 1
+4 8 1
+3 4 1
+2 2 2
+1 1 1
insert into t1 select 22, pk, a from t1;
select
part_id, pk, a,
@@ -1137,7 +1132,8 @@ pk, a,
count(b) over (order by a
range between 2 preceding
and 2 following) as CNT
-from t1;
+from t1
+order by a, pk;
pk a CNT
1 NULL 3
2 NULL 3
@@ -1969,12 +1965,12 @@ ROW_NUMBER() OVER (order by s1),
CUME_DIST() OVER (order by -s1)
from t1;
s1 s2 ROW_NUMBER() OVER (order by s1) CUME_DIST() OVER (order by -s1)
+-1 2 1.0000000000
1 a 3 0.8333333333
-NULL NULL 1 0.1666666667
+2 b 4 0.6666666667
3 NULL 5 0.5000000000
4 a 6 0.3333333333
-2 b 4 0.6666666667
--1 2 1.0000000000
+NULL NULL 1 0.1666666667
drop table t1;
#
# MDEV-9925: Wrong result with aggregate function as a window function
@@ -2012,8 +2008,8 @@ o_custkey avg(o_custkey) OVER (PARTITION BY abs(o_custkey)
ORDER BY o_custkey
RANGE BETWEEN 15 FOLLOWING
AND 15 FOLLOWING)
-242 NULL
238 NULL
+242 NULL
DROP table orders;
#
# MDEV-10842: window functions with the same order column
@@ -2042,20 +2038,20 @@ row_number() over (order by pk desc) as r_desc,
row_number() over (order by pk asc) as r_asc
from t1;
pk r_desc r_asc
-1 11 1
-2 10 2
-3 9 3
-4 8 4
-5 7 5
-6 6 6
-7 5 7
-8 4 8
-9 3 9
-10 2 10
11 1 11
+10 2 10
+9 3 9
+8 4 8
+7 5 7
+6 6 6
+5 7 5
+4 8 4
+3 9 3
+2 10 2
+1 11 1
drop table t1;
#
-# MDEV-10874: two window functions with ccompatible sorting
+# MDEV-10874: two window functions with compatible sorting
#
create table t1 (
pk int primary key,
@@ -2130,17 +2126,17 @@ sum(d) over (order by a
ROWS BETWEEN 1 preceding and 2 following) as sum_2
from t1;
pk a d sum_1 sum_2
-1 0 0.100 0.300 1.400
-2 0 0.200 0.500 1.200
3 0 0.300 0.300 0.600
-4 1 0.400 0.900 2.600
-5 1 0.500 1.100 2.400
+2 0 0.200 0.500 1.200
+1 0 0.100 0.300 1.400
6 1 0.600 0.600 1.600
-7 2 0.500 0.500 0.500
-8 2 NULL 0.700 1.200
-9 2 0.700 1.500 2.000
-10 2 0.800 1.700 2.400
+5 1 0.500 1.100 2.400
+4 1 0.400 0.900 2.600
11 2 0.900 0.900 2.800
+10 2 0.800 1.700 2.400
+9 2 0.700 1.500 2.000
+8 2 NULL 0.700 1.200
+7 2 0.500 0.500 0.500
drop table t1;
#
# MDEV-9941: two window functions with compatible partitions
@@ -2232,9 +2228,9 @@ SELECT sum(t.a) over (partition by t.b order by a),
sqrt(ifnull((sum(t.a) over (partition by t.b order by a)), 0))
from t;
sum(t.a) over (partition by t.b order by a) sqrt(ifnull((sum(t.a) over (partition by t.b order by a)), 0))
+0.0000000000 0
1.0000000000 1
3.0000000000 1.7320508075688772
-0.0000000000 0
drop table t;
#
# MDEV-10868: view definitions with window functions
@@ -2391,9 +2387,9 @@ CREATE TABLE t2 (c VARCHAR(8));
INSERT INTO t2 VALUES ('foo'),('bar'),('foo');
SELECT COUNT(*) OVER (PARTITION BY c) FROM t2;
COUNT(*) OVER (PARTITION BY c)
-2
1
2
+2
SELECT * FROM t1 WHERE i IN ( SELECT COUNT(*) OVER (PARTITION BY c) FROM t2 );
i
1
@@ -2511,14 +2507,14 @@ select id, rank() over (order by id) from t1;
id rank() over (order by id)
1 1
2 2
-3 4
2 2
+3 4
select * from v1;
id rnk
1 1
2 2
-3 4
2 2
+3 4
drop view v1;
drop table t1;
#
@@ -2879,64 +2875,64 @@ CDEC min(TDEC.CDEC) over ()
NULL -1
-1 -1
0 -1
-1 -1
0 -1
+1 -1
10 -1
select VDEC.CDEC, min(VDEC.CDEC) over () from VDEC;
CDEC min(VDEC.CDEC) over ()
NULL -1
-1 -1
0 -1
-1 -1
0 -1
+1 -1
10 -1
select TDEC.CDEC, max(TDEC.CDEC) over () from TDEC;
CDEC max(TDEC.CDEC) over ()
NULL 10
-1 10
0 10
-1 10
0 10
+1 10
10 10
select VDEC.CDEC, max(VDEC.CDEC) over () from VDEC;
CDEC max(VDEC.CDEC) over ()
NULL 10
-1 10
0 10
-1 10
0 10
+1 10
10 10
select TDEC.CDEC, min(distinct TDEC.CDEC) over () from TDEC;
CDEC min(distinct TDEC.CDEC) over ()
NULL -1
-1 -1
0 -1
-1 -1
0 -1
+1 -1
10 -1
select VDEC.CDEC, min(distinct VDEC.CDEC) over () from VDEC;
CDEC min(distinct VDEC.CDEC) over ()
NULL -1
-1 -1
0 -1
-1 -1
0 -1
+1 -1
10 -1
select TDEC.CDEC, max(distinct TDEC.CDEC) over () from TDEC;
CDEC max(distinct TDEC.CDEC) over ()
NULL 10
-1 10
0 10
-1 10
0 10
+1 10
10 10
select VDEC.CDEC, max(distinct VDEC.CDEC) over () from VDEC;
CDEC max(distinct VDEC.CDEC) over ()
NULL 10
-1 10
0 10
-1 10
0 10
+1 10
10 10
#
# These should be removed once support for them is added.
@@ -3219,8 +3215,8 @@ DROP TABLE fv_test, fv_result;
#
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (0),(1),(2);
-SELECT LEAD(a) OVER (PARTITION BY a) as lead,
-a AND LEAD(a) OVER (PARTITION BY a) AS a_and_lead_part
+SELECT LEAD(a) OVER (PARTITION BY a ORDER BY a) as lead,
+a AND LEAD(a) OVER (PARTITION BY a ORDER BY a) AS a_and_lead_part
FROM t1;
lead a_and_lead_part
NULL 0
@@ -3315,6 +3311,57 @@ COUNT(DISTINCT t2.a2) rank() OVER (ORDER BY t2.b1)
1 3
DROP TABLE t1,t2;
#
+# MDEV-16990: server crashes in base_list_iterator::next
+#
+CREATE TABLE t1(i int);
+insert into t1 values (1),(2);
+SELECT DISTINCT row_number() OVER (), MAX(1) FROM t1;
+row_number() OVER () MAX(1)
+1 1
+SELECT DISTINCT BIT_AND(0) OVER (), MAX(1) FROM t1;
+BIT_AND(0) OVER () MAX(1)
+0 1
+drop table t1;
+#
+# MDEV-17525: Window functions not working in ONLY_FULL_GROUP_BY mode
+#
+CREATE TABLE t1 (name CHAR(10), test CHAR(10), score TINYINT);
+INSERT INTO t1 VALUES
+('Chun', 'SQL', 75), ('Chun', 'Tuning', 73),
+('Esben', 'SQL', 43), ('Esben', 'Tuning', 31),
+('Kaolin', 'SQL', 56), ('Kaolin', 'Tuning', 88),
+('Tatiana', 'SQL', 87), ('Tatiana', 'Tuning', 83);
+SET @save_sql_mode= @@sql_mode;
+SET sql_mode = 'ONLY_FULL_GROUP_BY';
+SELECT name, test, score,
+AVG(score) OVER (PARTITION BY test) AS average_by_test
+FROM t1
+ORDER BY test, name;
+name test score average_by_test
+Chun SQL 75 65.2500
+Esben SQL 43 65.2500
+Kaolin SQL 56 65.2500
+Tatiana SQL 87 65.2500
+Chun Tuning 73 68.7500
+Esben Tuning 31 68.7500
+Kaolin Tuning 88 68.7500
+Tatiana Tuning 83 68.7500
+set @@sql_mode= @save_sql_mode;
+SELECT name, test, score,
+AVG(score) OVER (PARTITION BY test) AS average_by_test
+FROM t1
+ORDER BY test, name;
+name test score average_by_test
+Chun SQL 75 65.2500
+Esben SQL 43 65.2500
+Kaolin SQL 56 65.2500
+Tatiana SQL 87 65.2500
+Chun Tuning 73 68.7500
+Esben Tuning 31 68.7500
+Kaolin Tuning 88 68.7500
+Tatiana Tuning 83 68.7500
+drop table t1;
+#
# Start of 10.3 tests
#
#
diff --git a/mysql-test/main/win.test b/mysql-test/main/win.test
index cc16595fcd4..cd340a17a0d 100644
--- a/mysql-test/main/win.test
+++ b/mysql-test/main/win.test
@@ -58,7 +58,8 @@ select
pk, a, b,
row_number() over (order by a),
row_number() over (order by b)
-from t1;
+from t1
+order by b;
drop table t1;
@@ -391,7 +392,6 @@ insert into t3 values
(6, 2);
select
- pk,
val,
count(val) over (order by val
range between current row and
@@ -404,7 +404,6 @@ insert into t3 values
(8, 3);
select
- pk,
val,
count(val) over (order by val
range between current row and
@@ -444,7 +443,6 @@ insert into t4 values
select
part_id,
- pk,
val,
count(val) over (partition by part_id
order by val
@@ -458,7 +456,6 @@ from t4;
--echo #
select
part_id,
- pk,
val,
count(val) over (partition by part_id
order by val
@@ -469,7 +466,6 @@ from t4;
select
part_id,
- pk,
val,
count(val) over (partition by part_id
order by val
@@ -480,7 +476,6 @@ from t4;
select
part_id,
- pk,
val,
count(val) over (partition by part_id
order by val
@@ -723,7 +718,8 @@ select
count(b) over (order by a
range between 2 preceding
and 2 following) as CNT
-from t1;
+from t1
+order by a, pk;
drop table t1;
--echo #
@@ -1023,6 +1019,7 @@ insert into t1 values
--echo # Check using counters
flush status;
+--sorted_result
select
rank() over (partition by c order by a),
rank() over (partition by c order by b)
@@ -1030,6 +1027,7 @@ from t1;
show status like '%sort%';
flush status;
+--sorted_result
select
rank() over (partition by c order by a),
rank() over (partition by c order by a)
@@ -1101,6 +1099,7 @@ insert into t1 values
(2,2),
(3,1);
+--sorted_result
select
a, b,
rank() over (order by a), rank() over (order by b),
@@ -1192,6 +1191,7 @@ insert into t1 values (4,'a');
insert into t1 values (2,'b');
insert into t1 values (-1,'');
+--sorted_result
select
*,
ROW_NUMBER() OVER (order by s1),
@@ -1267,7 +1267,7 @@ from t1;
drop table t1;
--echo #
---echo # MDEV-10874: two window functions with ccompatible sorting
+--echo # MDEV-10874: two window functions with compatible sorting
--echo #
create table t1 (
@@ -2000,8 +2000,8 @@ DROP TABLE fv_test, fv_result;
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (0),(1),(2);
-SELECT LEAD(a) OVER (PARTITION BY a) as lead,
- a AND LEAD(a) OVER (PARTITION BY a) AS a_and_lead_part
+SELECT LEAD(a) OVER (PARTITION BY a ORDER BY a) as lead,
+ a AND LEAD(a) OVER (PARTITION BY a ORDER BY a) AS a_and_lead_part
FROM t1;
SELECT a OR LEAD(a) OVER (ORDER BY a) AS a_or_lead_order
@@ -2084,6 +2084,43 @@ FROM t2 ,t1 GROUP BY t2.b1 ORDER BY t1.a1;
DROP TABLE t1,t2;
--echo #
+--echo # MDEV-16990: server crashes in base_list_iterator::next
+--echo #
+
+CREATE TABLE t1(i int);
+insert into t1 values (1),(2);
+SELECT DISTINCT row_number() OVER (), MAX(1) FROM t1;
+SELECT DISTINCT BIT_AND(0) OVER (), MAX(1) FROM t1;
+drop table t1;
+
+--echo #
+--echo # MDEV-17525: Window functions not working in ONLY_FULL_GROUP_BY mode
+--echo #
+
+CREATE TABLE t1 (name CHAR(10), test CHAR(10), score TINYINT);
+
+INSERT INTO t1 VALUES
+('Chun', 'SQL', 75), ('Chun', 'Tuning', 73),
+('Esben', 'SQL', 43), ('Esben', 'Tuning', 31),
+('Kaolin', 'SQL', 56), ('Kaolin', 'Tuning', 88),
+('Tatiana', 'SQL', 87), ('Tatiana', 'Tuning', 83);
+
+SET @save_sql_mode= @@sql_mode;
+SET sql_mode = 'ONLY_FULL_GROUP_BY';
+
+SELECT name, test, score,
+ AVG(score) OVER (PARTITION BY test) AS average_by_test
+FROM t1
+ORDER BY test, name;
+
+set @@sql_mode= @save_sql_mode;
+SELECT name, test, score,
+ AVG(score) OVER (PARTITION BY test) AS average_by_test
+FROM t1
+ORDER BY test, name;
+drop table t1;
+
+--echo #
--echo # Start of 10.3 tests
--echo #
diff --git a/mysql-test/main/win_big.result b/mysql-test/main/win_big.result
index 225ecae3224..c8b27b9a1aa 100644
--- a/mysql-test/main/win_big.result
+++ b/mysql-test/main/win_big.result
@@ -38,10 +38,6 @@ where variable_name like 'Sort_merge_passes';
variable_name case when variable_value > 0 then 'WITH PASSES' else 'NO PASSES' end
SORT_MERGE_PASSES WITH PASSES
include/diff_tables.inc [t21, t22]
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
drop table t21, t22;
#################################################################
# Try many cursors
@@ -76,10 +72,6 @@ where variable_name like 'Sort_merge_passes';
variable_name case when variable_value > 0 then 'WITH PASSES' else 'NO PASSES' end
SORT_MERGE_PASSES WITH PASSES
include/diff_tables.inc [t21, t22]
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
drop table t21, t22;
#################################################################
# Try having cursors pointing at different IO_CACHE pages
@@ -113,10 +105,6 @@ where variable_name like 'Sort_merge_passes';
variable_name case when variable_value > 0 then 'WITH PASSES' else 'NO PASSES' end
SORT_MERGE_PASSES WITH PASSES
include/diff_tables.inc [t21, t22]
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
-Warnings:
-Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be removed in a future release. Please use 'SELECT <select list> INTO <destination> FROM...' instead
drop table t21, t22;
#################################################################
drop table t10;
diff --git a/mysql-test/main/win_first_last_value.result b/mysql-test/main/win_first_last_value.result
index 9de394ef9e0..4c3aa6a7161 100644
--- a/mysql-test/main/win_first_last_value.result
+++ b/mysql-test/main/win_first_last_value.result
@@ -68,17 +68,17 @@ first_value(pk) over (order by pk desc),
last_value(pk) over (order by pk desc)
from t1;
pk first_value(pk) over (order by pk desc) last_value(pk) over (order by pk desc)
-1 11 1
-2 11 2
-3 11 3
-4 11 4
-5 11 5
-6 11 6
-7 11 7
-8 11 8
-9 11 9
-10 11 10
11 11 11
+10 11 10
+9 11 9
+8 11 8
+7 11 7
+6 11 6
+5 11 5
+4 11 4
+3 11 3
+2 11 2
+1 11 1
select pk, a, b, c, d, e,
first_value(b) over (partition by a order by pk) as fst_b,
last_value(b) over (partition by a order by pk) as lst_b,
diff --git a/mysql-test/main/win_lead_lag.result b/mysql-test/main/win_lead_lag.result
index 5ead58fa11a..f3c0b8f7ef2 100644
--- a/mysql-test/main/win_lead_lag.result
+++ b/mysql-test/main/win_lead_lag.result
@@ -226,4 +226,15 @@ pk a b a+b lag(a + b) over (partition by a order by pk) + pk
9 2 2 4 12
10 2 0 2 14
11 2 10 12 13
+#
+# MDEV-15204 - LAG function doesn't require ORDER BY in OVER clause
+#
+select pk,
+lag(pk, 1) over ()
+from t1;
+ERROR HY000: No order list in window specification for 'lag'
+select pk,
+lead(pk, 1) over ()
+from t1;
+ERROR HY000: No order list in window specification for 'lead'
drop table t1;
diff --git a/mysql-test/main/win_lead_lag.test b/mysql-test/main/win_lead_lag.test
index 2824f83789c..d154244ecd0 100644
--- a/mysql-test/main/win_lead_lag.test
+++ b/mysql-test/main/win_lead_lag.test
@@ -107,4 +107,17 @@ select pk, a, b, a+b,
from t1
order by pk asc;
+--echo #
+--echo # MDEV-15204 - LAG function doesn't require ORDER BY in OVER clause
+--echo #
+--error ER_NO_ORDER_LIST_IN_WINDOW_SPEC
+select pk,
+ lag(pk, 1) over ()
+from t1;
+
+--error ER_NO_ORDER_LIST_IN_WINDOW_SPEC
+select pk,
+ lead(pk, 1) over ()
+from t1;
+
drop table t1;
diff --git a/mysql-test/main/win_percent_cume.result b/mysql-test/main/win_percent_cume.result
index d38c95c9ea7..bc2a4182e30 100644
--- a/mysql-test/main/win_percent_cume.result
+++ b/mysql-test/main/win_percent_cume.result
@@ -14,49 +14,49 @@ insert into t1 values
( 7 , 2, 20),
( 9 , 4, 20),
(10 , 4, 20);
-select pk, a, b,
+select a,
percent_rank() over (order by a),
cume_dist() over (order by a)
from t1;
-pk a b percent_rank() over (order by a) cume_dist() over (order by a)
-1 0 10 0.0000000000 0.2000000000
-2 0 10 0.0000000000 0.2000000000
-3 1 10 0.2222222222 0.4000000000
-4 1 10 0.2222222222 0.4000000000
-8 2 10 0.4444444444 0.8000000000
-5 2 20 0.4444444444 0.8000000000
-6 2 20 0.4444444444 0.8000000000
-7 2 20 0.4444444444 0.8000000000
-9 4 20 0.8888888889 1.0000000000
-10 4 20 0.8888888889 1.0000000000
-select pk, a, b,
+a percent_rank() over (order by a) cume_dist() over (order by a)
+0 0.0000000000 0.2000000000
+0 0.0000000000 0.2000000000
+1 0.2222222222 0.4000000000
+1 0.2222222222 0.4000000000
+2 0.4444444444 0.8000000000
+2 0.4444444444 0.8000000000
+2 0.4444444444 0.8000000000
+2 0.4444444444 0.8000000000
+4 0.8888888889 1.0000000000
+4 0.8888888889 1.0000000000
+select pk,
percent_rank() over (order by pk),
cume_dist() over (order by pk)
from t1 order by pk;
-pk a b percent_rank() over (order by pk) cume_dist() over (order by pk)
-1 0 10 0.0000000000 0.1000000000
-2 0 10 0.1111111111 0.2000000000
-3 1 10 0.2222222222 0.3000000000
-4 1 10 0.3333333333 0.4000000000
-5 2 20 0.4444444444 0.5000000000
-6 2 20 0.5555555556 0.6000000000
-7 2 20 0.6666666667 0.7000000000
-8 2 10 0.7777777778 0.8000000000
-9 4 20 0.8888888889 0.9000000000
-10 4 20 1.0000000000 1.0000000000
-select pk, a, b,
+pk percent_rank() over (order by pk) cume_dist() over (order by pk)
+1 0.0000000000 0.1000000000
+2 0.1111111111 0.2000000000
+3 0.2222222222 0.3000000000
+4 0.3333333333 0.4000000000
+5 0.4444444444 0.5000000000
+6 0.5555555556 0.6000000000
+7 0.6666666667 0.7000000000
+8 0.7777777778 0.8000000000
+9 0.8888888889 0.9000000000
+10 1.0000000000 1.0000000000
+select a,
percent_rank() over (partition by a order by a),
cume_dist() over (partition by a order by a)
from t1;
-pk a b percent_rank() over (partition by a order by a) cume_dist() over (partition by a order by a)
-1 0 10 0.0000000000 1.0000000000
-2 0 10 0.0000000000 1.0000000000
-3 1 10 0.0000000000 1.0000000000
-4 1 10 0.0000000000 1.0000000000
-8 2 10 0.0000000000 1.0000000000
-5 2 20 0.0000000000 1.0000000000
-6 2 20 0.0000000000 1.0000000000
-7 2 20 0.0000000000 1.0000000000
-9 4 20 0.0000000000 1.0000000000
-10 4 20 0.0000000000 1.0000000000
+a percent_rank() over (partition by a order by a) cume_dist() over (partition by a order by a)
+0 0.0000000000 1.0000000000
+0 0.0000000000 1.0000000000
+1 0.0000000000 1.0000000000
+1 0.0000000000 1.0000000000
+2 0.0000000000 1.0000000000
+2 0.0000000000 1.0000000000
+2 0.0000000000 1.0000000000
+2 0.0000000000 1.0000000000
+4 0.0000000000 1.0000000000
+4 0.0000000000 1.0000000000
drop table t1;
diff --git a/mysql-test/main/win_percent_cume.test b/mysql-test/main/win_percent_cume.test
index b851185cb32..05ace95d571 100644
--- a/mysql-test/main/win_percent_cume.test
+++ b/mysql-test/main/win_percent_cume.test
@@ -17,17 +17,17 @@ insert into t1 values
( 9 , 4, 20),
(10 , 4, 20);
-select pk, a, b,
+select a,
percent_rank() over (order by a),
cume_dist() over (order by a)
from t1;
-select pk, a, b,
+select pk,
percent_rank() over (order by pk),
cume_dist() over (order by pk)
from t1 order by pk;
-select pk, a, b,
+select a,
percent_rank() over (partition by a order by a),
cume_dist() over (partition by a order by a)
from t1;
diff --git a/mysql-test/main/win_percentile.result b/mysql-test/main/win_percentile.result
index f46fad80d16..4a918bad17f 100644
--- a/mysql-test/main/win_percentile.result
+++ b/mysql-test/main/win_percentile.result
@@ -32,8 +32,8 @@ Chun 5.0000000000
Kaolin 4.0000000000
Kaolin 4.0000000000
Kaolin 4.0000000000
-Tatiana 4.0000000000
Tata 4.0000000000
+Tatiana 4.0000000000
select name, percentile_disc(0.5) within group(order by score) over (partition by name) as c from t1;
name c
Chun 3.0000000000
@@ -41,8 +41,8 @@ Chun 3.0000000000
Kaolin 4.0000000000
Kaolin 4.0000000000
Kaolin 4.0000000000
-Tatiana 4.0000000000
Tata 4.0000000000
+Tatiana 4.0000000000
# no partition clause
select name, percentile_disc(0.5) within group(order by score) over () from t1;
name percentile_disc(0.5) within group(order by score) over ()
@@ -51,8 +51,8 @@ Chun 4.0000000000
Kaolin 4.0000000000
Kaolin 4.0000000000
Kaolin 4.0000000000
-Tatiana 4.0000000000
Tata 4.0000000000
+Tatiana 4.0000000000
select name, percentile_cont(0.5) within group(order by score) over () from t1;
name percentile_cont(0.5) within group(order by score) over ()
Chun 4.0000000000
@@ -60,8 +60,8 @@ Chun 4.0000000000
Kaolin 4.0000000000
Kaolin 4.0000000000
Kaolin 4.0000000000
-Tatiana 4.0000000000
Tata 4.0000000000
+Tatiana 4.0000000000
# argument set to null
select name, percentile_cont(null) within group(order by score) over (partition by name) from t1;
ERROR HY000: percentile_cont function only accepts arguments that can be converted to numerical types
@@ -75,8 +75,8 @@ Chun 5.0000000000
Kaolin 4.0000000000
Kaolin 4.0000000000
Kaolin 4.0000000000
-Tatiana 4.0000000000
Tata 4.0000000000
+Tatiana 4.0000000000
select * from ( select name , percentile_disc(0.5) within group ( order by score) over (partition by name ) from t1 ) as t;
name percentile_disc(0.5) within group ( order by score) over (partition by name )
Chun 3.0000000000
@@ -84,8 +84,8 @@ Chun 3.0000000000
Kaolin 4.0000000000
Kaolin 4.0000000000
Kaolin 4.0000000000
-Tatiana 4.0000000000
Tata 4.0000000000
+Tatiana 4.0000000000
select name from t1 a where (select percentile_disc(0.5) within group (order by score) over (partition by name) from t1 b limit 1) >= 0.5;
name
Chun
@@ -93,8 +93,8 @@ Chun
Kaolin
Kaolin
Kaolin
-Tatiana
Tata
+Tatiana
#disallowed fields in order by
select score, percentile_cont(0.5) within group(order by name) over (partition by score) from t1;
ERROR HY000: Numeric datatype is required for percentile_cont function
@@ -121,10 +121,10 @@ name cume_dist() over (partition by name order by score) c
Chun 0.5000000000 3.0000000000
Chun 1.0000000000 3.0000000000
Kaolin 0.3333333333 4.0000000000
-Kaolin 1.0000000000 4.0000000000
Kaolin 0.6666666667 4.0000000000
-Tatiana 1.0000000000 4.0000000000
+Kaolin 1.0000000000 4.0000000000
Tata 1.0000000000 4.0000000000
+Tatiana 1.0000000000 4.0000000000
select name, percentile_cont(0.5) within group(order by score) over (partition by name) as c from t1;
name c
Chun 5.0000000000
@@ -132,98 +132,98 @@ Chun 5.0000000000
Kaolin 4.0000000000
Kaolin 4.0000000000
Kaolin 4.0000000000
-Tatiana 4.0000000000
Tata 4.0000000000
+Tatiana 4.0000000000
select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.1) within group(order by score) over (partition by name) as c from t1;
name b c
Chun 0.5000000000 3.0000000000
Chun 1.0000000000 3.0000000000
Kaolin 0.3333333333 3.0000000000
-Kaolin 1.0000000000 3.0000000000
Kaolin 0.6666666667 3.0000000000
-Tatiana 1.0000000000 4.0000000000
+Kaolin 1.0000000000 3.0000000000
Tata 1.0000000000 4.0000000000
+Tatiana 1.0000000000 4.0000000000
select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.2) within group(order by score) over (partition by name) as c from t1;
name b c
Chun 0.5000000000 3.0000000000
Chun 1.0000000000 3.0000000000
Kaolin 0.3333333333 3.0000000000
-Kaolin 1.0000000000 3.0000000000
Kaolin 0.6666666667 3.0000000000
-Tatiana 1.0000000000 4.0000000000
+Kaolin 1.0000000000 3.0000000000
Tata 1.0000000000 4.0000000000
+Tatiana 1.0000000000 4.0000000000
select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.3) within group(order by score) over (partition by name) as c from t1;
name b c
Chun 0.5000000000 3.0000000000
Chun 1.0000000000 3.0000000000
Kaolin 0.3333333333 3.0000000000
-Kaolin 1.0000000000 3.0000000000
Kaolin 0.6666666667 3.0000000000
-Tatiana 1.0000000000 4.0000000000
+Kaolin 1.0000000000 3.0000000000
Tata 1.0000000000 4.0000000000
+Tatiana 1.0000000000 4.0000000000
select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.4) within group(order by score) over (partition by name) as c from t1;
name b c
Chun 0.5000000000 3.0000000000
Chun 1.0000000000 3.0000000000
Kaolin 0.3333333333 4.0000000000
-Kaolin 1.0000000000 4.0000000000
Kaolin 0.6666666667 4.0000000000
-Tatiana 1.0000000000 4.0000000000
+Kaolin 1.0000000000 4.0000000000
Tata 1.0000000000 4.0000000000
+Tatiana 1.0000000000 4.0000000000
select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.5) within group(order by score) over (partition by name) as c from t1;
name b c
Chun 0.5000000000 3.0000000000
Chun 1.0000000000 3.0000000000
Kaolin 0.3333333333 4.0000000000
-Kaolin 1.0000000000 4.0000000000
Kaolin 0.6666666667 4.0000000000
-Tatiana 1.0000000000 4.0000000000
+Kaolin 1.0000000000 4.0000000000
Tata 1.0000000000 4.0000000000
+Tatiana 1.0000000000 4.0000000000
select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.6) within group(order by score) over (partition by name) as c from t1;
name b c
Chun 0.5000000000 7.0000000000
Chun 1.0000000000 7.0000000000
Kaolin 0.3333333333 4.0000000000
-Kaolin 1.0000000000 4.0000000000
Kaolin 0.6666666667 4.0000000000
-Tatiana 1.0000000000 4.0000000000
+Kaolin 1.0000000000 4.0000000000
Tata 1.0000000000 4.0000000000
+Tatiana 1.0000000000 4.0000000000
select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.7) within group(order by score) over (partition by name) as c from t1;
name b c
Chun 0.5000000000 7.0000000000
Chun 1.0000000000 7.0000000000
Kaolin 0.3333333333 7.0000000000
-Kaolin 1.0000000000 7.0000000000
Kaolin 0.6666666667 7.0000000000
-Tatiana 1.0000000000 4.0000000000
+Kaolin 1.0000000000 7.0000000000
Tata 1.0000000000 4.0000000000
+Tatiana 1.0000000000 4.0000000000
select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.8) within group(order by score) over (partition by name) as c from t1;
name b c
Chun 0.5000000000 7.0000000000
Chun 1.0000000000 7.0000000000
Kaolin 0.3333333333 7.0000000000
-Kaolin 1.0000000000 7.0000000000
Kaolin 0.6666666667 7.0000000000
-Tatiana 1.0000000000 4.0000000000
+Kaolin 1.0000000000 7.0000000000
Tata 1.0000000000 4.0000000000
+Tatiana 1.0000000000 4.0000000000
select name,cume_dist() over (partition by name order by score) as b, percentile_disc(0.9) within group(order by score) over (partition by name) as c from t1;
name b c
Chun 0.5000000000 7.0000000000
Chun 1.0000000000 7.0000000000
Kaolin 0.3333333333 7.0000000000
-Kaolin 1.0000000000 7.0000000000
Kaolin 0.6666666667 7.0000000000
-Tatiana 1.0000000000 4.0000000000
+Kaolin 1.0000000000 7.0000000000
Tata 1.0000000000 4.0000000000
+Tatiana 1.0000000000 4.0000000000
select name,cume_dist() over (partition by name order by score) as b, percentile_disc(1) within group(order by score) over (partition by name) as c from t1;
name b c
Chun 0.5000000000 7.0000000000
Chun 1.0000000000 7.0000000000
Kaolin 0.3333333333 7.0000000000
-Kaolin 1.0000000000 7.0000000000
Kaolin 0.6666666667 7.0000000000
-Tatiana 1.0000000000 4.0000000000
+Kaolin 1.0000000000 7.0000000000
Tata 1.0000000000 4.0000000000
+Tatiana 1.0000000000 4.0000000000
select median(score) over (partition by name), percentile_cont(0) within group(order by score) over (partition by name) as c from t1;
median(score) over (partition by name) c
5.0000000000 3.0000000000
@@ -348,3 +348,21 @@ MEDIAN(`a2`) OVER (PARTITION BY `pk`)
FROM t1;
MEDIAN(`a1`) OVER () MEDIAN(`a2`) OVER (PARTITION BY `pk`)
DROP TABLE t1;
+#
+# MDEV-17137: Syntax errors with VIEW using MEDIAN
+#
+CREATE TABLE t1(val int);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE VIEW v1 AS SELECT MEDIAN(val) OVER() FROM t1;
+select * from v1;
+MEDIAN(val) OVER()
+2.0000000000
+2.0000000000
+2.0000000000
+select median(val) OVER () FROM t1;
+median(val) OVER ()
+2.0000000000
+2.0000000000
+2.0000000000
+drop table t1;
+drop view v1;
diff --git a/mysql-test/main/win_percentile.test b/mysql-test/main/win_percentile.test
index e39af8cfd39..d36b365dd9b 100644
--- a/mysql-test/main/win_percentile.test
+++ b/mysql-test/main/win_percentile.test
@@ -33,11 +33,15 @@ select percentile_cont() within group() over (partition by name) from t1;
--echo # Test simple syntax
--echo #
+--sorted_result
select name, percentile_cont(0.5) within group(order by score) over (partition by name) as c from t1;
+--sorted_result
select name, percentile_disc(0.5) within group(order by score) over (partition by name) as c from t1;
--echo # no partition clause
+--sorted_result
select name, percentile_disc(0.5) within group(order by score) over () from t1;
+--sorted_result
select name, percentile_cont(0.5) within group(order by score) over () from t1;
--echo # argument set to null
@@ -47,8 +51,11 @@ select name, percentile_cont(null) within group(order by score) over (partition
select name, percentile_disc(null) within group(order by score) over (partition by name) from t1;
--echo #subqueries having percentile functions
+--sorted_result
select * from ( select name , percentile_cont(0.5) within group ( order by score) over (partition by name ) from t1 ) as t;
+--sorted_result
select * from ( select name , percentile_disc(0.5) within group ( order by score) over (partition by name ) from t1 ) as t;
+--sorted_result
select name from t1 a where (select percentile_disc(0.5) within group (order by score) over (partition by name) from t1 b limit 1) >= 0.5;
--echo #disallowed fields in order by
@@ -127,3 +134,15 @@ SELECT MEDIAN(`a1`) OVER (),
MEDIAN(`a2`) OVER (PARTITION BY `pk`)
FROM t1;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-17137: Syntax errors with VIEW using MEDIAN
+--echo #
+
+CREATE TABLE t1(val int);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE VIEW v1 AS SELECT MEDIAN(val) OVER() FROM t1;
+select * from v1;
+select median(val) OVER () FROM t1;
+drop table t1;
+drop view v1;
diff --git a/mysql-test/main/win_rank.result b/mysql-test/main/win_rank.result
index 725683d3869..e74c2edd662 100644
--- a/mysql-test/main/win_rank.result
+++ b/mysql-test/main/win_rank.result
@@ -17,34 +17,34 @@ insert into t1 values
( 7 , 2, 20),
( 9 , 4, 20),
(10 , 4, 20);
-select pk, a, b, rank() over (order by a) as rank,
+select a, rank() over (order by a) as rank,
dense_rank() over (order by a) as dense_rank
from t1;
-pk a b rank dense_rank
-1 0 10 1 1
-2 0 10 1 1
-3 1 10 3 2
-4 1 10 3 2
-8 2 10 5 3
-5 2 20 5 3
-6 2 20 5 3
-7 2 20 5 3
-9 4 20 9 4
-10 4 20 9 4
-select pk, a, b, rank() over (partition by b order by a) as rank,
+a rank dense_rank
+0 1 1
+0 1 1
+1 3 2
+1 3 2
+2 5 3
+2 5 3
+2 5 3
+2 5 3
+4 9 4
+4 9 4
+select a, b, rank() over (partition by b order by a) as rank,
dense_rank() over (partition by b order by a) as dense_rank
from t1;
-pk a b rank dense_rank
-1 0 10 1 1
-2 0 10 1 1
-3 1 10 3 2
-4 1 10 3 2
-8 2 10 5 3
-5 2 20 1 1
-6 2 20 1 1
-7 2 20 1 1
-9 4 20 4 2
-10 4 20 4 2
+a b rank dense_rank
+0 10 1 1
+0 10 1 1
+1 10 3 2
+1 10 3 2
+2 10 5 3
+2 20 1 1
+2 20 1 1
+2 20 1 1
+4 20 4 2
+4 20 4 2
drop table t1;
#
# Test with null values in the table.
@@ -59,46 +59,49 @@ insert into t2 values (2,'b');
insert into t2 values (-1,'');
select *, rank() over (order by s1) as rank,
dense_rank() over (order by s1) as dense_rank
-from t2;
+from t2
+order by s1, s2;
s1 s2 rank dense_rank
-1 a 5 3
NULL NULL 1 1
-1 NULL 5 3
NULL a 1 1
NULL c 1 1
-2 b 7 4
-1 4 2
+1 NULL 5 3
+1 a 5 3
+2 b 7 4
select *, rank() over (partition by s2 order by s1) as rank,
dense_rank() over (partition by s2 order by s1) as dense_rank
-from t2;
+from t2
+order by s1, s2;
s1 s2 rank dense_rank
-1 a 2 2
NULL NULL 1 1
-1 NULL 2 2
NULL a 1 1
NULL c 1 1
-2 b 1 1
-1 1 1
+1 NULL 2 2
+1 a 2 2
+2 b 1 1
select *, rank() over (order by s2) as rank,
dense_rank() over (order by s2) as dense_rank
-from t2;
+from t2
+order by s2, s1;
s1 s2 rank dense_rank
-1 a 4 3
NULL NULL 1 1
1 NULL 1 1
+-1 3 2
NULL a 4 3
-NULL c 7 5
+1 a 4 3
2 b 6 4
--1 3 2
+NULL c 7 5
select *, rank() over (partition by s1 order by s2) as rank,
dense_rank() over (partition by s1 order by s2) as dense_rank
from t2;
s1 s2 rank dense_rank
-1 a 2 2
NULL NULL 1 1
-1 NULL 1 1
NULL a 2 2
NULL c 3 3
-2 b 1 1
-1 1 1
+1 NULL 1 1
+1 a 2 2
+2 b 1 1
drop table t2;
diff --git a/mysql-test/main/win_rank.test b/mysql-test/main/win_rank.test
index eda1f458205..c58ff054117 100644
--- a/mysql-test/main/win_rank.test
+++ b/mysql-test/main/win_rank.test
@@ -20,11 +20,11 @@ insert into t1 values
( 9 , 4, 20),
(10 , 4, 20);
-select pk, a, b, rank() over (order by a) as rank,
- dense_rank() over (order by a) as dense_rank
+select a, rank() over (order by a) as rank,
+ dense_rank() over (order by a) as dense_rank
from t1;
-select pk, a, b, rank() over (partition by b order by a) as rank,
- dense_rank() over (partition by b order by a) as dense_rank
+select a, b, rank() over (partition by b order by a) as rank,
+ dense_rank() over (partition by b order by a) as dense_rank
from t1;
drop table t1;
@@ -44,13 +44,16 @@ insert into t2 values (-1,'');
select *, rank() over (order by s1) as rank,
dense_rank() over (order by s1) as dense_rank
-from t2;
+from t2
+order by s1, s2;
select *, rank() over (partition by s2 order by s1) as rank,
dense_rank() over (partition by s2 order by s1) as dense_rank
-from t2;
+from t2
+order by s1, s2;
select *, rank() over (order by s2) as rank,
dense_rank() over (order by s2) as dense_rank
-from t2;
+from t2
+order by s2, s1;
select *, rank() over (partition by s1 order by s2) as rank,
dense_rank() over (partition by s1 order by s2) as dense_rank
from t2;
diff --git a/mysql-test/main/win_std.test b/mysql-test/main/win_std.test
index 5ed999431c0..c1964ecac98 100644
--- a/mysql-test/main/win_std.test
+++ b/mysql-test/main/win_std.test
@@ -80,9 +80,11 @@ select std(b) over (order by a rows between current row and 0 following)
from t2;
--echo # Only peers frame.
+--sorted_result
select a, b, std(b) over (order by a range between 0 preceding and 0 preceding)
from t2;
+--sorted_result
select a, b, std(b) over (order by a range between 0 preceding and current row)
from t2;
@@ -90,9 +92,11 @@ from t2;
select a, b, std(b) over (order by a range between current row and 0 preceding)
from t2;
+--sorted_result
select a, b, std(b) over (order by a range between current row and 0 following)
from t2;
+--sorted_result
select a, b, std(b) over (order by a range between 0 following and 0 following)
from t2;