summaryrefslogtreecommitdiffstats
path: root/mysql-test/main
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/main')
-rw-r--r--mysql-test/main/alter_table.result8
-rw-r--r--mysql-test/main/alter_table.test9
-rw-r--r--mysql-test/main/bootstrap.test2
-rw-r--r--mysql-test/main/column_compression_parts.result1
-rw-r--r--mysql-test/main/commit_1innodb.result13
-rw-r--r--mysql-test/main/constraints.result13
-rw-r--r--mysql-test/main/constraints.test15
-rw-r--r--mysql-test/main/crash_commit_before.test2
-rw-r--r--mysql-test/main/create.result2
-rw-r--r--mysql-test/main/ctype_collate.result24
-rw-r--r--mysql-test/main/ctype_collate.test15
-rw-r--r--mysql-test/main/ctype_ucs.result20
-rw-r--r--mysql-test/main/ctype_ucs.test17
-rw-r--r--mysql-test/main/ddl_i18n_koi8r.result6
-rw-r--r--mysql-test/main/ddl_i18n_utf8.result6
-rw-r--r--mysql-test/main/deadlock_innodb.result5
-rw-r--r--mysql-test/main/derived_split_innodb.result57
-rw-r--r--mysql-test/main/derived_split_innodb.test42
-rw-r--r--mysql-test/main/derived_view.result66
-rw-r--r--mysql-test/main/derived_view.test72
-rw-r--r--mysql-test/main/distinct_notembedded.result322
-rw-r--r--mysql-test/main/distinct_notembedded.test109
-rw-r--r--mysql-test/main/dyncol.result28
-rw-r--r--mysql-test/main/dyncol.test21
-rw-r--r--mysql-test/main/empty_server_name-8224.test4
-rw-r--r--mysql-test/main/empty_string_literal.result26
-rw-r--r--mysql-test/main/empty_string_literal.test15
-rw-r--r--mysql-test/main/func_encrypt_nossl.result42
-rw-r--r--mysql-test/main/func_extract.result882
-rw-r--r--mysql-test/main/func_extract.test251
-rw-r--r--mysql-test/main/func_gconcat.result95
-rw-r--r--mysql-test/main/func_gconcat.test56
-rw-r--r--mysql-test/main/func_hybrid_type.result25
-rw-r--r--mysql-test/main/func_hybrid_type.test23
-rw-r--r--mysql-test/main/func_in.result78
-rw-r--r--mysql-test/main/func_in.test60
-rw-r--r--mysql-test/main/func_json.result29
-rw-r--r--mysql-test/main/func_json.test51
-rw-r--r--mysql-test/main/func_json_notembedded.result3
-rw-r--r--mysql-test/main/func_json_notembedded.test4
-rw-r--r--mysql-test/main/func_math.result15
-rw-r--r--mysql-test/main/func_math.test10
-rw-r--r--mysql-test/main/func_regexp.result52
-rw-r--r--mysql-test/main/func_regexp.test47
-rw-r--r--mysql-test/main/func_sformat.result38
-rw-r--r--mysql-test/main/func_sformat.test56
-rw-r--r--mysql-test/main/func_str.result36
-rw-r--r--mysql-test/main/func_str.test22
-rw-r--r--mysql-test/main/func_time.result74
-rw-r--r--mysql-test/main/func_time.test39
-rw-r--r--mysql-test/main/function_defaults.result25
-rw-r--r--mysql-test/main/function_defaults.test23
-rw-r--r--mysql-test/main/gis.result32
-rw-r--r--mysql-test/main/host_cache_size_functionality.test8
-rw-r--r--mysql-test/main/information_schema2.result18
-rw-r--r--mysql-test/main/information_schema2.test23
-rw-r--r--mysql-test/main/init_file_set_password-7656.test4
-rw-r--r--mysql-test/main/innodb_ext_key,covering,on.rdiff (renamed from mysql-test/main/innodb_ext_key,covering,innodb,on.rdiff)0
-rw-r--r--mysql-test/main/innodb_ext_key,off.rdiff6
-rw-r--r--mysql-test/main/innodb_ext_key,on,unoptimized.rdiff (renamed from mysql-test/main/innodb_ext_key,innodb,on,unoptimized.rdiff)0
-rw-r--r--mysql-test/main/innodb_ext_key.result28
-rw-r--r--mysql-test/main/innodb_ext_key.test30
-rw-r--r--mysql-test/main/insert_select.result8
-rw-r--r--mysql-test/main/join.result58
-rw-r--r--mysql-test/main/join.test46
-rw-r--r--mysql-test/main/join_cache.result22
-rw-r--r--mysql-test/main/join_cache.test21
-rw-r--r--mysql-test/main/join_outer.test18
-rw-r--r--mysql-test/main/kill_processlist-6619.test14
-rw-r--r--mysql-test/main/load_timezones_with_alter_algorithm_inplace.result18
-rw-r--r--mysql-test/main/load_timezones_with_alter_algorithm_inplace.test40
-rw-r--r--mysql-test/main/lock_sync.result24
-rw-r--r--mysql-test/main/lock_sync.test27
-rw-r--r--mysql-test/main/lock_view.result2
-rw-r--r--mysql-test/main/log_errchk.test4
-rw-r--r--mysql-test/main/long_unique_bugs.result55
-rw-r--r--mysql-test/main/long_unique_bugs.test47
-rw-r--r--mysql-test/main/lowercase_fs_on.test4
-rw-r--r--[-rwxr-xr-x]mysql-test/main/lowercase_table2.result0
-rw-r--r--mysql-test/main/mdl_sync.result4
-rw-r--r--mysql-test/main/mdl_sync.test7
-rw-r--r--mysql-test/main/myisam.result1
-rw-r--r--mysql-test/main/myisam.test3
-rw-r--r--mysql-test/main/myisam_crash_before_flush_keys.test4
-rw-r--r--mysql-test/main/mysql-interactive.test2
-rw-r--r--mysql-test/main/mysql.result32
-rw-r--r--mysql-test/main/mysql.test44
-rw-r--r--mysql-test/main/mysql_client_test.result1
-rw-r--r--mysql-test/main/mysql_client_test.test8
-rw-r--r--mysql-test/main/mysql_client_test_comp.test2
-rw-r--r--mysql-test/main/mysql_client_test_nonblock.test2
-rw-r--r--mysql-test/main/mysql_connector_net.test2
-rw-r--r--mysql-test/main/mysql_install_db_win_admin.result6
-rw-r--r--mysql-test/main/mysql_install_db_win_admin.test5
-rw-r--r--mysql-test/main/mysql_tzinfo_to_sql_symlink.result12
-rw-r--r--mysql-test/main/mysqlbinlog_row_compressed.result194
-rw-r--r--mysql-test/main/mysqlbinlog_row_compressed.test5
-rw-r--r--mysql-test/main/mysqlbinlog_row_minimal.result2
-rw-r--r--mysql-test/main/mysqlbinlog_stmt_compressed.result128
-rw-r--r--mysql-test/main/mysqlbinlog_stmt_compressed.test3
-rw-r--r--mysql-test/main/mysqld--help.result22
-rw-r--r--mysql-test/main/mysqld_option_err.result11
-rw-r--r--mysql-test/main/mysqld_option_err.test34
-rw-r--r--mysql-test/main/mysqldump-compat-102.result1
-rw-r--r--mysql-test/main/mysqldump-max.result24
-rw-r--r--mysql-test/main/mysqldump-nl.result2
-rw-r--r--mysql-test/main/mysqldump-no-binlog.result1
-rw-r--r--mysql-test/main/mysqldump-order-by-size.result1
-rw-r--r--mysql-test/main/mysqldump-system.result23
-rw-r--r--mysql-test/main/mysqldump-timing.result2
-rw-r--r--mysql-test/main/mysqldump-utf8mb4.result1
-rw-r--r--mysql-test/main/mysqldump.result130
-rw-r--r--mysql-test/main/mysqldump.test31
-rw-r--r--mysql-test/main/openssl_1.result3
-rw-r--r--mysql-test/main/openssl_1.test2
-rw-r--r--mysql-test/main/opt_trace.result37
-rw-r--r--mysql-test/main/opt_trace.test10
-rw-r--r--mysql-test/main/partition.result1
-rw-r--r--mysql-test/main/partition_binlog.result1
-rw-r--r--mysql-test/main/plugin_auth.result1
-rw-r--r--mysql-test/main/plugin_loaderr.test4
-rw-r--r--mysql-test/main/ps.result181
-rw-r--r--mysql-test/main/ps.test185
-rw-r--r--mysql-test/main/ps_2myisam.result4
-rw-r--r--mysql-test/main/ps_3innodb.result4
-rw-r--r--mysql-test/main/ps_4heap.result4
-rw-r--r--mysql-test/main/ps_5merge.result8
-rw-r--r--mysql-test/main/query_cache.result33
-rw-r--r--mysql-test/main/query_cache.test43
-rw-r--r--mysql-test/main/read_only_innodb.result25
-rw-r--r--mysql-test/main/read_only_innodb.test28
-rw-r--r--mysql-test/main/rowid_filter_innodb.result102
-rw-r--r--mysql-test/main/rowid_filter_innodb.test80
-rw-r--r--mysql-test/main/rpl_mysqldump_slave.result179
-rw-r--r--mysql-test/main/rpl_mysqldump_slave.test73
-rw-r--r--mysql-test/main/secondary_key_costs.result35
-rw-r--r--mysql-test/main/secondary_key_costs.test21
-rw-r--r--mysql-test/main/selectivity_innodb_notembedded.result131
-rw-r--r--mysql-test/main/selectivity_notembedded.result131
-rw-r--r--mysql-test/main/selectivity_notembedded.test102
-rw-r--r--mysql-test/main/show_analyze.result8
-rw-r--r--mysql-test/main/show_analyze.test12
-rw-r--r--mysql-test/main/show_explain_json.result8
-rw-r--r--mysql-test/main/show_explain_json.test12
-rw-r--r--mysql-test/main/shutdown.test4
-rw-r--r--mysql-test/main/skip_grants.test4
-rw-r--r--mysql-test/main/sp.result3
-rw-r--r--mysql-test/main/sp.test2
-rw-r--r--mysql-test/main/ssl_and_innodb.test2
-rw-r--r--mysql-test/main/ssl_crl.result2
-rw-r--r--mysql-test/main/ssl_crl.test4
-rw-r--r--mysql-test/main/ssl_timeout.result2
-rw-r--r--mysql-test/main/ssl_timeout.test3
-rw-r--r--mysql-test/main/stat_tables_partition.result3
-rw-r--r--mysql-test/main/stat_tables_rbr.result1
-rw-r--r--mysql-test/main/subselect4.result79
-rw-r--r--mysql-test/main/subselect4.test15
-rw-r--r--mysql-test/main/subselect_elimination.result268
-rw-r--r--mysql-test/main/subselect_elimination.test242
-rw-r--r--mysql-test/main/subselect_sj_mat.test9
-rw-r--r--mysql-test/main/system_mysql_db_fix50030.result2
-rw-r--r--mysql-test/main/system_mysql_db_fix50117.result2
-rw-r--r--mysql-test/main/system_mysql_db_fix50568.result2
-rw-r--r--mysql-test/main/table_value_constr.result4
-rw-r--r--mysql-test/main/table_value_constr.test4
-rw-r--r--mysql-test/main/temp_table.result49
-rw-r--r--mysql-test/main/temp_table.test54
-rw-r--r--mysql-test/main/trigger.result6
-rw-r--r--mysql-test/main/trigger.test9
-rw-r--r--mysql-test/main/trigger_wl3253.result2
-rw-r--r--mysql-test/main/type_decimal.result173
-rw-r--r--mysql-test/main/type_decimal.test90
-rw-r--r--mysql-test/main/type_json.result2
-rw-r--r--mysql-test/main/type_timestamp.result116
-rw-r--r--mysql-test/main/type_timestamp.test92
-rw-r--r--mysql-test/main/type_varchar_mysql41.result149
-rw-r--r--mysql-test/main/type_varchar_mysql41.test85
-rw-r--r--mysql-test/main/udf.result64
-rw-r--r--mysql-test/main/udf.test34
179 files changed, 6673 insertions, 640 deletions
diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result
index 2e7047f3..949f36e2 100644
--- a/mysql-test/main/alter_table.result
+++ b/mysql-test/main/alter_table.result
@@ -3124,6 +3124,14 @@ CREATE TEMPORARY TABLE t2 LIKE t1;
DROP TEMPORARY TABLE t2;
DROP TABLE t1;
#
+# MDEV-33313 Incorrect error message for "ALTER TABLE ... DROP CONSTRAINT ..., DROP col, DROP col"
+#
+create table t2(id int primary key) engine=innodb;
+create table t1(id int primary key, t2_id int, constraint t1_fk_t2_id foreign key(t2_id) references t2(id)) engine=innodb;
+alter table t1 drop constraint t1_fk_t2_id, drop t2_id, drop t2_id;
+ERROR 42000: Can't DROP COLUMN `t2_id`; check that it exists
+drop table t1, t2;
+#
# End of 10.6 tests
#
#
diff --git a/mysql-test/main/alter_table.test b/mysql-test/main/alter_table.test
index 17d71d8e..5ffa300f 100644
--- a/mysql-test/main/alter_table.test
+++ b/mysql-test/main/alter_table.test
@@ -2407,6 +2407,15 @@ DROP TEMPORARY TABLE t2;
DROP TABLE t1;
--echo #
+--echo # MDEV-33313 Incorrect error message for "ALTER TABLE ... DROP CONSTRAINT ..., DROP col, DROP col"
+--echo #
+create table t2(id int primary key) engine=innodb;
+create table t1(id int primary key, t2_id int, constraint t1_fk_t2_id foreign key(t2_id) references t2(id)) engine=innodb;
+--error ER_CANT_DROP_FIELD_OR_KEY
+alter table t1 drop constraint t1_fk_t2_id, drop t2_id, drop t2_id;
+drop table t1, t2;
+
+--echo #
--echo # End of 10.6 tests
--echo #
diff --git a/mysql-test/main/bootstrap.test b/mysql-test/main/bootstrap.test
index 76d5ed00..68fbc001 100644
--- a/mysql-test/main/bootstrap.test
+++ b/mysql-test/main/bootstrap.test
@@ -74,7 +74,7 @@ SELECT 'bug' as '' FROM INFORMATION_SCHEMA.ENGINES WHERE engine='innodb'
--echo # MDEV-13063 Server crashes in intern_plugin_lock or assertion `plugin_ptr->ref_count == 1' fails in plugin_init
--echo #
--error 1
---exec $MYSQLD_BOOTSTRAP_CMD --myisam_recover_options=NONE
+--exec $MYSQLD_BOOTSTRAP_CMD --myisam_recover_options=NONE 2>/dev/null
--echo #
--echo # MDEV-19349 mysql_install_db: segfault at tmp_file_prefix check
diff --git a/mysql-test/main/column_compression_parts.result b/mysql-test/main/column_compression_parts.result
index fa12217c..5f5539b7 100644
--- a/mysql-test/main/column_compression_parts.result
+++ b/mysql-test/main/column_compression_parts.result
@@ -12,7 +12,6 @@ INSERT INTO t1 VALUES (1,REPEAT('a',100)),(2,REPEAT('v',200)),(3,REPEAT('r',300)
INSERT INTO t1 VALUES (5,REPEAT('k',500)),(6,'April'),(7,7),(8,""),(9,"M"),(10,DEFAULT);
ALTER TABLE t1 ANALYZE PARTITION p1;
Table Op Msg_type Msg_text
-test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
ALTER TABLE t1 CHECK PARTITION p2;
Table Op Msg_type Msg_text
diff --git a/mysql-test/main/commit_1innodb.result b/mysql-test/main/commit_1innodb.result
index d090844c..973be9fd 100644
--- a/mysql-test/main/commit_1innodb.result
+++ b/mysql-test/main/commit_1innodb.result
@@ -634,7 +634,7 @@ SUCCESS
drop table t2;
set sql_mode=no_engine_substitution;
create temporary table t2 (a int);
-call p_verify_status_increment(1, 0, 0, 0);
+call p_verify_status_increment(3, 0, 2, 0);
SUCCESS
set sql_mode=default;
@@ -643,8 +643,9 @@ set sql_mode=default;
select f1();
f1()
2
-# Two commits because a binary log record is written
-call p_verify_status_increment(2, 0, 1, 0);
+# Two commits because a binary log record is written, and another two
+# as the function f1() is reloaded after creating temporary table.
+call p_verify_status_increment(4, 0, 3, 0);
SUCCESS
commit;
@@ -715,11 +716,11 @@ SUCCESS
# 25. DDL: DROP TEMPORARY TABLE, does not start a transaction
#
drop temporary table t2;
-call p_verify_status_increment(1, 0, 1, 0);
+call p_verify_status_increment(3, 0, 2, 0);
SUCCESS
commit;
-call p_verify_status_increment(1, 0, 1, 0);
+call p_verify_status_increment(1, 0, 0, 0);
SUCCESS
# 26. Verify that SET AUTOCOMMIT issues an implicit commit
@@ -801,7 +802,7 @@ call p_verify_status_increment(0, 0, 0, 0);
SUCCESS
do (select f1() from t1 where a=2);
-call p_verify_status_increment(2, 2, 2, 2);
+call p_verify_status_increment(4, 2, 4, 2);
SUCCESS
commit;
diff --git a/mysql-test/main/constraints.result b/mysql-test/main/constraints.result
index 143c2232..d2a19040 100644
--- a/mysql-test/main/constraints.result
+++ b/mysql-test/main/constraints.result
@@ -235,3 +235,16 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop procedure sp;
drop table t1;
+#
+# MDEV-33768: Memory leak found in the test main.constraints run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT
+# This test case was added by reviewer's request.
+#
+PREPARE stmt FROM 'CREATE TABLE t1 (a INT)';
+EXECUTE stmt;
+DROP TABLE t1;
+EXECUTE stmt;
+EXECUTE stmt;
+ERROR 42S01: Table 't1' already exists
+# Clean up
+DROP TABLE t1;
+DEALLOCATE PREPARE stmt;
diff --git a/mysql-test/main/constraints.test b/mysql-test/main/constraints.test
index 5c673f9b..83f3394d 100644
--- a/mysql-test/main/constraints.test
+++ b/mysql-test/main/constraints.test
@@ -189,3 +189,18 @@ call sp;
show create table t1;
drop procedure sp;
drop table t1;
+
+--echo #
+--echo # MDEV-33768: Memory leak found in the test main.constraints run with --ps-protocol against a server built with the option -DWITH_PROTECT_STATEMENT_MEMROOT
+--echo # This test case was added by reviewer's request.
+--echo #
+PREPARE stmt FROM 'CREATE TABLE t1 (a INT)';
+EXECUTE stmt;
+DROP TABLE t1;
+EXECUTE stmt;
+--error ER_TABLE_EXISTS_ERROR
+EXECUTE stmt;
+
+--echo # Clean up
+DROP TABLE t1;
+DEALLOCATE PREPARE stmt;
diff --git a/mysql-test/main/crash_commit_before.test b/mysql-test/main/crash_commit_before.test
index 93b96de6..30b59ce4 100644
--- a/mysql-test/main/crash_commit_before.test
+++ b/mysql-test/main/crash_commit_before.test
@@ -17,7 +17,7 @@ insert into t1 values(9);
SET GLOBAL debug_dbug="d,crash_commit_before";
# Write file to make mysql-test-run.pl expect crash and restart
---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
# Run the crashing query
--error 2013
diff --git a/mysql-test/main/create.result b/mysql-test/main/create.result
index d6c68fdd..9db7d5ca 100644
--- a/mysql-test/main/create.result
+++ b/mysql-test/main/create.result
@@ -1803,7 +1803,7 @@ show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`color` char(32) GENERATED ALWAYS AS (column_get(`dynamic_cols`,1 as char charset latin1)) STORED,
- `cl` char(32) GENERATED ALWAYS AS (column_get(column_add(column_create(1,'blue' AS char charset latin1 ),2,'ttt'),`i` as char charset latin1)) STORED,
+ `cl` char(32) GENERATED ALWAYS AS (column_get(column_add(column_create(1,'blue' AS char charset latin1 collate latin1_swedish_ci ),2,'ttt'),`i` as char charset latin1)) STORED,
`item_name` varchar(32) NOT NULL,
`i` int(11) DEFAULT NULL,
`dynamic_cols` blob DEFAULT NULL,
diff --git a/mysql-test/main/ctype_collate.result b/mysql-test/main/ctype_collate.result
index eafe7ff3..7b713df7 100644
--- a/mysql-test/main/ctype_collate.result
+++ b/mysql-test/main/ctype_collate.result
@@ -780,3 +780,27 @@ string
#
# End of 10.2 tests
#
+#
+# MDEV-33318 ORDER BY COLLATE improperly applied to non-character columns
+#
+set names utf8;
+create table t1 (ts datetime);
+insert t1 values ('2024-01-26 21:37:54'), ('2024-01-26 21:37:54'),
+('2024-01-26 21:37:54'), ('2024-01-26 21:37:54'),
+('2024-01-26 21:37:58'), ('2024-01-26 21:37:58'),
+('2024-01-26 21:37:58'), ('2024-01-26 21:38:02'),
+('2024-01-26 21:38:02'), ('2024-01-26 21:38:02');
+select * from t1 order by ts collate utf8_bin;
+ts
+2024-01-26 21:37:54
+2024-01-26 21:37:54
+2024-01-26 21:37:54
+2024-01-26 21:37:54
+2024-01-26 21:37:58
+2024-01-26 21:37:58
+2024-01-26 21:37:58
+2024-01-26 21:38:02
+2024-01-26 21:38:02
+2024-01-26 21:38:02
+drop table t1;
+# End of 10.6 tests
diff --git a/mysql-test/main/ctype_collate.test b/mysql-test/main/ctype_collate.test
index 2366b130..96ad216d 100644
--- a/mysql-test/main/ctype_collate.test
+++ b/mysql-test/main/ctype_collate.test
@@ -357,3 +357,18 @@ SELECT COLUMN_GET(COLUMN_CREATE(0, 'string'),0 AS CHAR CHARACTER SET latin1 COLL
--echo #
--echo # End of 10.2 tests
--echo #
+
+--echo #
+--echo # MDEV-33318 ORDER BY COLLATE improperly applied to non-character columns
+--echo #
+set names utf8;
+create table t1 (ts datetime);
+insert t1 values ('2024-01-26 21:37:54'), ('2024-01-26 21:37:54'),
+ ('2024-01-26 21:37:54'), ('2024-01-26 21:37:54'),
+ ('2024-01-26 21:37:58'), ('2024-01-26 21:37:58'),
+ ('2024-01-26 21:37:58'), ('2024-01-26 21:38:02'),
+ ('2024-01-26 21:38:02'), ('2024-01-26 21:38:02');
+select * from t1 order by ts collate utf8_bin;
+drop table t1;
+
+--echo # End of 10.6 tests
diff --git a/mysql-test/main/ctype_ucs.result b/mysql-test/main/ctype_ucs.result
index eb1220f9..cab41feb 100644
--- a/mysql-test/main/ctype_ucs.result
+++ b/mysql-test/main/ctype_ucs.result
@@ -6520,5 +6520,25 @@ SELECT 1 COLLATE latin1_swedish_ci;
ERROR 42000: COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'ucs2'
SET NAMES utf8;
#
+# MDEV-33772 Bad SEPARATOR value in GROUP_CONCAT on character set conversion
+#
+SET NAMES utf8mb3, @@collation_connection=ucs2_general_ci;
+CREATE TABLE t1 (c VARCHAR(10)) CHARACTER SET ucs2;
+INSERT INTO t1 VALUES ('a'),('A');
+CREATE OR REPLACE VIEW v1 AS
+SELECT COUNT(*) AS cnt, GROUP_CONCAT(c) AS c1 FROM t1 GROUP BY c;
+SELECT * FROM v1;
+cnt c1
+2 a,A
+SELECT HEX(c1) FROM v1;
+HEX(c1)
+0061002C0041
+SHOW CREATE VIEW v1;
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select count(0) AS `cnt`,group_concat(`t1`.`c` separator ',') AS `c1` from `t1` group by `t1`.`c` utf8mb3 ucs2_general_ci
+DROP VIEW v1;
+DROP TABLE t1;
+SET NAMES utf8mb3;
+#
# End of 10.5 tests
#
diff --git a/mysql-test/main/ctype_ucs.test b/mysql-test/main/ctype_ucs.test
index 993f9be5..93ddcb86 100644
--- a/mysql-test/main/ctype_ucs.test
+++ b/mysql-test/main/ctype_ucs.test
@@ -1194,5 +1194,22 @@ SELECT 1 COLLATE latin1_swedish_ci;
SET NAMES utf8;
--echo #
+--echo # MDEV-33772 Bad SEPARATOR value in GROUP_CONCAT on character set conversion
+--echo #
+
+SET NAMES utf8mb3, @@collation_connection=ucs2_general_ci;
+CREATE TABLE t1 (c VARCHAR(10)) CHARACTER SET ucs2;
+INSERT INTO t1 VALUES ('a'),('A');
+CREATE OR REPLACE VIEW v1 AS
+ SELECT COUNT(*) AS cnt, GROUP_CONCAT(c) AS c1 FROM t1 GROUP BY c;
+SELECT * FROM v1;
+SELECT HEX(c1) FROM v1;
+SHOW CREATE VIEW v1;
+DROP VIEW v1;
+DROP TABLE t1;
+SET NAMES utf8mb3;
+
+
+--echo #
--echo # End of 10.5 tests
--echo #
diff --git a/mysql-test/main/ddl_i18n_koi8r.result b/mysql-test/main/ddl_i18n_koi8r.result
index f588374a..bc4ef5ca 100644
--- a/mysql-test/main/ddl_i18n_koi8r.result
+++ b/mysql-test/main/ddl_i18n_koi8r.result
@@ -719,6 +719,7 @@ ca cb
utf8mb3_general_ci utf8mb3_general_ci
---> Dump of mysqltest1
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */;
@@ -795,6 +796,7 @@ ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
---> Dumping mysqltest1 to ddl_i18n_koi8r.sp.mysqltest1.sql
---> Dump of mysqltest2
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */;
@@ -1723,6 +1725,7 @@ koi8r_general_ci utf8mb3_general_ci koi8r_general_ci koi8r_general_ci utf8mb3_ge
DELETE FROM mysqltest2.log|
---> Dump of mysqltest1
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */;
@@ -1805,6 +1808,7 @@ ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
---> Dumping mysqltest1 to ddl_i18n_koi8r.triggers.mysqltest1.sql
---> Dump of mysqltest2
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */;
@@ -2491,6 +2495,7 @@ COLLATION( 'ÔÅËÓÔ') AS c4,
END ONE TIME 1970-01-02 00:00:00 NULL NULL NULL NULL DISABLED PRESERVE CREATED LAST_ALTERED NULL 1 koi8r koi8r_general_ci utf8mb3_unicode_ci
---> Dump of mysqltest1
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */;
@@ -2558,6 +2563,7 @@ DELIMITER ;
---> Dumping mysqltest1 to ddl_i18n_koi8r.events.mysqltest1.sql
---> Dump of mysqltest2
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */;
diff --git a/mysql-test/main/ddl_i18n_utf8.result b/mysql-test/main/ddl_i18n_utf8.result
index cb57bc5e..9561c914 100644
--- a/mysql-test/main/ddl_i18n_utf8.result
+++ b/mysql-test/main/ddl_i18n_utf8.result
@@ -719,6 +719,7 @@ ca cb
utf8mb3_general_ci utf8mb3_general_ci
---> Dump of mysqltest1
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */;
@@ -795,6 +796,7 @@ ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
---> Dumping mysqltest1 to ddl_i18n_utf8sp.mysqltest1.sql
---> Dump of mysqltest2
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */;
@@ -1723,6 +1725,7 @@ utf8mb3_general_ci utf8mb3_general_ci koi8r_general_ci utf8mb3_general_ci utf8mb
DELETE FROM mysqltest2.log|
---> Dump of mysqltest1
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */;
@@ -1805,6 +1808,7 @@ ALTER DATABASE `mysqltest1` CHARACTER SET cp866 COLLATE cp866_general_ci ;
---> Dumping mysqltest1 to ddl_i18n_utf8triggers.mysqltest1.sql
---> Dump of mysqltest2
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */;
@@ -2491,6 +2495,7 @@ COLLATION( 'текÑÑ‚') AS c4,
END ONE TIME 1970-01-02 00:00:00 NULL NULL NULL NULL DISABLED PRESERVE CREATED LAST_ALTERED NULL 1 utf8mb3 utf8mb3_general_ci utf8mb3_unicode_ci
---> Dump of mysqltest1
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */;
@@ -2558,6 +2563,7 @@ DELIMITER ;
---> Dumping mysqltest1 to ddl_i18n_utf8events.mysqltest1.sql
---> Dump of mysqltest2
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest2` /*!40100 DEFAULT CHARACTER SET cp866 COLLATE cp866_general_ci */;
diff --git a/mysql-test/main/deadlock_innodb.result b/mysql-test/main/deadlock_innodb.result
index 09958bf0..9236f21c 100644
--- a/mysql-test/main/deadlock_innodb.result
+++ b/mysql-test/main/deadlock_innodb.result
@@ -89,11 +89,6 @@ id x
300 300
connection con2;
update t2 set a=2 where b = 0;
-select * from t2;
-b a
-0 2
-1 20
-2 30
update t1 set x=2 where id = 0;
connection con1;
update t1 set x=1 where id = 0;
diff --git a/mysql-test/main/derived_split_innodb.result b/mysql-test/main/derived_split_innodb.result
index b9ee3f0a..6346b44d 100644
--- a/mysql-test/main/derived_split_innodb.result
+++ b/mysql-test/main/derived_split_innodb.result
@@ -877,5 +877,62 @@ SELECT * FROM t1 WHERE t1.a IN (SELECT b FROM
(SELECT t2.b FROM t2 WHERE NOT EXISTS (SELECT 1 FROM t3) GROUP BY b) sq);
a
DROP TABLE t1, t2, t3;
+#
+# MDEV-23878: Wrong result with semi-join and splittable derived table
+#
+CREATE TABLE t1 (
+groupId int,
+id int unsigned,
+PRIMARY KEY (groupId, id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+INSERT INTO t1 VALUES
+(8,1),(8,2),(8,3),(8,4),(8,5),(8,6),(8,7),(8,8),(8,9),(8,10),
+(8,11),(8,12),(8,13),(8,14),(8,15),(8,16),(8,17),(8,18),(8,19);
+set statement in_predicate_conversion_threshold=2 for SELECT COUNT(*) AS cnt FROM t1
+JOIN
+(
+SELECT groupId, id
+FROM t1
+WHERE id IN (1,2,3,4,5,6)
+GROUP BY groupId, id
+) AS t2
+USING (groupId, id)
+WHERE id IN (1,2,3,4,5,6,7,8);
+cnt
+6
+set statement in_predicate_conversion_threshold=2 for EXPLAIN SELECT COUNT(*) AS cnt FROM t1
+JOIN
+(
+SELECT groupId, id
+FROM t1
+WHERE id IN (1,2,3,4,5,6)
+GROUP BY groupId, id
+) AS t2
+USING (groupId, id)
+WHERE id IN (1,2,3,4,5,6,7,8);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index PRIMARY PRIMARY 8 NULL 19 Using index
+1 PRIMARY <subquery4> eq_ref distinct_key distinct_key 4 func 1 Using where
+1 PRIMARY <derived3> ref key0 key0 8 test.t1.groupId,test.t1.id 2
+4 MATERIALIZED <derived5> ALL NULL NULL NULL NULL 8
+5 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
+3 LATERAL DERIVED t1 eq_ref PRIMARY PRIMARY 8 test.t1.groupId,test.t1.id 1 Using index
+3 LATERAL DERIVED <derived7> ref key0 key0 4 test.t1.id 2 Using where; FirstMatch(t1)
+7 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used
+set statement optimizer_switch='split_materialized=off, loosescan=off' for
+set statement in_predicate_conversion_threshold=2 for
+SELECT COUNT(*) AS cnt FROM t1
+JOIN
+(
+SELECT groupId, id
+FROM t1
+WHERE id IN (1,2,3,4,5,6)
+GROUP BY groupId, id
+) AS t2
+USING (groupId, id)
+WHERE id IN (1,2,3,4,5,6,7,8);
+cnt
+6
+DROP TABLE t1;
# End of 10.4 tests
SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent;
diff --git a/mysql-test/main/derived_split_innodb.test b/mysql-test/main/derived_split_innodb.test
index 075d6e81..67db02f7 100644
--- a/mysql-test/main/derived_split_innodb.test
+++ b/mysql-test/main/derived_split_innodb.test
@@ -505,6 +505,48 @@ SELECT * FROM t1 WHERE t1.a IN (SELECT b FROM
DROP TABLE t1, t2, t3;
+--echo #
+--echo # MDEV-23878: Wrong result with semi-join and splittable derived table
+--echo #
+
+CREATE TABLE t1 (
+ groupId int,
+ id int unsigned,
+ PRIMARY KEY (groupId, id)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+INSERT INTO t1 VALUES
+ (8,1),(8,2),(8,3),(8,4),(8,5),(8,6),(8,7),(8,8),(8,9),(8,10),
+ (8,11),(8,12),(8,13),(8,14),(8,15),(8,16),(8,17),(8,18),(8,19);
+
+let $query=
+SELECT COUNT(*) AS cnt FROM t1
+JOIN
+(
+ SELECT groupId, id
+ FROM t1
+ WHERE id IN (1,2,3,4,5,6)
+ GROUP BY groupId, id
+) AS t2
+USING (groupId, id)
+WHERE id IN (1,2,3,4,5,6,7,8);
+
+let $tvc_conversion_threshold =
+ set statement in_predicate_conversion_threshold=2 for;
+
+eval $tvc_conversion_threshold $query;
+eval $tvc_conversion_threshold EXPLAIN $query;
+
+let $no_split_materialized_loosescan=
+ set statement optimizer_switch='split_materialized=off, loosescan=off' for;
+
+# Correct result with split materializied optimization disabled
+eval $no_split_materialized_loosescan
+ $tvc_conversion_threshold
+ $query;
+
+DROP TABLE t1;
+
--echo # End of 10.4 tests
SET GLOBAL innodb_stats_persistent=@save_innodb_stats_persistent;
diff --git a/mysql-test/main/derived_view.result b/mysql-test/main/derived_view.result
index 3ac06c20..432d4e7d 100644
--- a/mysql-test/main/derived_view.result
+++ b/mysql-test/main/derived_view.result
@@ -4291,8 +4291,74 @@ a
drop table t1, t2;
drop view v1;
drop procedure aproc;
+#
+# MDEV-31305: Aggregation over materialized derived table
+#
+CREATE VIEW v AS
+SELECT seq1.seq AS dim1, seq2.seq AS dim2, seq3.seq AS dim3,
+FLOOR(RAND(13) * 5) AS p
+FROM seq_100_to_105 seq1
+JOIN seq_10_to_15 seq2
+JOIN seq_1_to_5 seq3;
+SELECT v.*, SUM(p) from v;
+dim1 dim2 dim3 p SUM(p)
+100 10 1 2 371
+SELECT d.*, SUM(p)
+FROM (
+SELECT seq1.seq AS dim1, seq2.seq AS dim2, seq3.seq AS dim3,
+FLOOR(RAND(13) * 5) AS p
+FROM seq_100_to_105 seq1
+JOIN seq_10_to_15 seq2
+JOIN seq_1_to_5 seq3
+) d;
+dim1 dim2 dim3 p SUM(p)
+100 10 1 2 371
+WITH demo AS
+(
+SELECT seq1.seq AS dim1, seq2.seq AS dim2, seq3.seq AS dim3,
+FLOOR(RAND(13) * 5) AS p
+FROM seq_100_to_105 seq1
+JOIN seq_10_to_15 seq2
+JOIN seq_1_to_5 seq3
+)
+SELECT d.*, SUM(p) FROM demo d;
+dim1 dim2 dim3 p SUM(p)
+100 10 1 2 371
+DROP VIEW v;
# End of 10.4 tests
#
+# MDEV-31277: 2-nd execution of PS to select from materialized view
+# specified as left join whose inner table is mergeable
+# derived containing a constant column
+#
+create table t1 (
+Election int(10) unsigned NOT NULL
+) engine=MyISAM;
+insert into t1 (Election) values (1), (4);
+create table t2 (
+VoteID int(10),
+ElectionID int(10),
+UserID int(10)
+);
+insert into t2 (ElectionID, UserID) values (2, 30), (3, 30);
+create view v1 as select * from t1
+left join ( select 'Y' AS Voted, ElectionID from t2 ) AS T
+on T.ElectionID = t1.Election
+limit 9;
+prepare stmt1 from "select * from v1";
+execute stmt1;
+Election Voted ElectionID
+1 NULL NULL
+4 NULL NULL
+execute stmt1;
+Election Voted ElectionID
+1 NULL NULL
+4 NULL NULL
+deallocate prepare stmt1;
+drop view v1;
+drop table t1, t2;
+# End of 10.5 tests
+#
# MDEV-31143: view with ORDER BY used in query with rownum() in WHERE
#
create table t1 (id int primary key);
diff --git a/mysql-test/main/derived_view.test b/mysql-test/main/derived_view.test
index ddead30a..0f2c8d14 100644
--- a/mysql-test/main/derived_view.test
+++ b/mysql-test/main/derived_view.test
@@ -2795,9 +2795,81 @@ drop table t1, t2;
drop view v1;
drop procedure aproc;
+--echo #
+--echo # MDEV-31305: Aggregation over materialized derived table
+--echo #
+
+--source include/have_sequence.inc
+
+CREATE VIEW v AS
+ SELECT seq1.seq AS dim1, seq2.seq AS dim2, seq3.seq AS dim3,
+ FLOOR(RAND(13) * 5) AS p
+ FROM seq_100_to_105 seq1
+ JOIN seq_10_to_15 seq2
+ JOIN seq_1_to_5 seq3;
+
+SELECT v.*, SUM(p) from v;
+
+SELECT d.*, SUM(p)
+ FROM (
+ SELECT seq1.seq AS dim1, seq2.seq AS dim2, seq3.seq AS dim3,
+ FLOOR(RAND(13) * 5) AS p
+ FROM seq_100_to_105 seq1
+ JOIN seq_10_to_15 seq2
+ JOIN seq_1_to_5 seq3
+) d;
+
+WITH demo AS
+(
+ SELECT seq1.seq AS dim1, seq2.seq AS dim2, seq3.seq AS dim3,
+ FLOOR(RAND(13) * 5) AS p
+ FROM seq_100_to_105 seq1
+ JOIN seq_10_to_15 seq2
+ JOIN seq_1_to_5 seq3
+)
+SELECT d.*, SUM(p) FROM demo d;
+
+DROP VIEW v;
+
--echo # End of 10.4 tests
--echo #
+--echo # MDEV-31277: 2-nd execution of PS to select from materialized view
+--echo # specified as left join whose inner table is mergeable
+--echo # derived containing a constant column
+--echo #
+
+create table t1 (
+ Election int(10) unsigned NOT NULL
+) engine=MyISAM;
+
+insert into t1 (Election) values (1), (4);
+
+create table t2 (
+ VoteID int(10),
+ ElectionID int(10),
+ UserID int(10)
+);
+
+insert into t2 (ElectionID, UserID) values (2, 30), (3, 30);
+create view v1 as select * from t1
+ left join ( select 'Y' AS Voted, ElectionID from t2 ) AS T
+ on T.ElectionID = t1.Election
+limit 9;
+
+prepare stmt1 from "select * from v1";
+
+execute stmt1;
+execute stmt1;
+
+deallocate prepare stmt1;
+
+drop view v1;
+drop table t1, t2;
+
+--echo # End of 10.5 tests
+
+--echo #
--echo # MDEV-31143: view with ORDER BY used in query with rownum() in WHERE
--echo #
diff --git a/mysql-test/main/distinct_notembedded.result b/mysql-test/main/distinct_notembedded.result
new file mode 100644
index 00000000..df81fe1c
--- /dev/null
+++ b/mysql-test/main/distinct_notembedded.result
@@ -0,0 +1,322 @@
+#
+# MDEV-30660 COUNT DISTINCT seems unnecessarily slow when run on a PK
+#
+set @save_optimizer_trace = @@optimizer_trace;
+SET optimizer_trace='enabled=on';
+CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b INT NOT NULL);
+INSERT INTO t1 VALUES (1,1), (2,1), (3,1);
+# Optimization is applied (aggregator=simple):
+SELECT COUNT(DISTINCT a) FROM t1;
+COUNT(DISTINCT a)
+3
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "count(distinct t1.a)",
+ "aggregator_type": "simple"
+ }
+]
+SELECT AVG(DISTINCT a), SUM(DISTINCT b) FROM t1;
+AVG(DISTINCT a) SUM(DISTINCT b)
+2.0000 1
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "avg(distinct t1.a)",
+ "aggregator_type": "simple"
+ },
+ {
+ "function": "sum(distinct t1.b)",
+ "aggregator_type": "distinct"
+ }
+]
+# Only `a` is unique but it's enough to eliminate DISTINCT:
+SELECT COUNT(DISTINCT b, a) FROM t1;
+COUNT(DISTINCT b, a)
+3
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "count(distinct t1.b,t1.a)",
+ "aggregator_type": "simple"
+ }
+]
+SELECT COUNT(DISTINCT a, a + b) FROM t1;
+COUNT(DISTINCT a, a + b)
+3
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "count(distinct t1.a,t1.a + t1.b)",
+ "aggregator_type": "simple"
+ }
+]
+SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t1 WHERE a > 1;
+SUM(DISTINCT a) AVG(DISTINCT a) COUNT(DISTINCT a)
+5 2.5000 2
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "sum(distinct t1.a)",
+ "aggregator_type": "simple"
+ },
+ {
+ "function": "avg(distinct t1.a)",
+ "aggregator_type": "simple"
+ },
+ {
+ "function": "count(distinct t1.a)",
+ "aggregator_type": "simple"
+ }
+]
+# Optimization is not applied 'cause function argument is not a field
+# (aggregator=distinct):
+SELECT SUM(DISTINCT a + b) FROM t1;
+SUM(DISTINCT a + b)
+9
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "sum(distinct t1.a + t1.b)",
+ "aggregator_type": "distinct"
+ }
+]
+SELECT COUNT(DISTINCT b) FROM t1;
+COUNT(DISTINCT b)
+1
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "count(distinct t1.b)",
+ "aggregator_type": "distinct"
+ }
+]
+SELECT AVG(DISTINCT b / a) FROM t1;
+AVG(DISTINCT b / a)
+0.61110000
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "avg(distinct t1.b / t1.a)",
+ "aggregator_type": "distinct"
+ }
+]
+EXPLAIN SELECT COUNT(DISTINCT (SELECT a)) FROM t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 index NULL PRIMARY 4 NULL 3 Using index
+2 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "count(distinct (/* select#2 */ select t1.a))",
+ "aggregator_type": "distinct"
+ }
+]
+CREATE TABLE t2 (a INT);
+INSERT INTO t2 VALUES (1), (2);
+# Optimization is not applied 'cause there is more than one table
+SELECT COUNT(DISTINCT t1.a) FROM t1, t2;
+COUNT(DISTINCT t1.a)
+3
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "count(distinct t1.a)",
+ "aggregator_type": "distinct"
+ }
+]
+SELECT AVG(DISTINCT t1.a) FROM t1, t2;
+AVG(DISTINCT t1.a)
+2.0000
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "avg(distinct t1.a)",
+ "aggregator_type": "distinct"
+ }
+]
+# Const tables, optimization is applied
+SELECT COUNT(DISTINCT a) FROM t1, (SELECT 1) AS t2;
+COUNT(DISTINCT a)
+3
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "count(distinct t1.a)",
+ "aggregator_type": "simple"
+ }
+]
+SELECT AVG(DISTINCT t1.a) FROM (SELECT 1 AS a) AS t2, t1, (SELECT 2 AS a) AS t3;
+AVG(DISTINCT t1.a)
+2.0000
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "avg(distinct t1.a)",
+ "aggregator_type": "simple"
+ }
+]
+SELECT COUNT(DISTINCT a) FROM t1, (SELECT 1 UNION SELECT 2) AS t2;
+COUNT(DISTINCT a)
+3
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "count(distinct t1.a)",
+ "aggregator_type": "distinct"
+ }
+]
+# Unique index on two columns
+CREATE TABLE t3 (a INT NOT NULL, b INT NOT NULL);
+INSERT INTO t3 VALUES (1,1), (1,2), (1,3), (2,1), (2,2), (3,1), (3,2);
+CREATE UNIQUE INDEX t3_a_b ON t3 (a, b);
+# Optimization is applied:
+SELECT COUNT(DISTINCT a, b) FROM t3;
+COUNT(DISTINCT a, b)
+7
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "count(distinct t3.a,t3.b)",
+ "aggregator_type": "simple"
+ }
+]
+SELECT COUNT(DISTINCT b, a) FROM t3;
+COUNT(DISTINCT b, a)
+7
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "count(distinct t3.b,t3.a)",
+ "aggregator_type": "simple"
+ }
+]
+SELECT COUNT(DISTINCT b, a) FROM t3 WHERE a < 3;
+COUNT(DISTINCT b, a)
+5
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "count(distinct t3.b,t3.a)",
+ "aggregator_type": "simple"
+ }
+]
+# Optimization is applied to one of the functions:
+SELECT COUNT(DISTINCT b), SUM(DISTINCT a), SUM(DISTINCT a + b) FROM t3 GROUP BY a;
+COUNT(DISTINCT b) SUM(DISTINCT a) SUM(DISTINCT a + b)
+3 1 9
+2 2 7
+2 3 9
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "count(distinct t3.b)",
+ "aggregator_type": "simple"
+ },
+ {
+ "function": "sum(distinct t3.a)",
+ "aggregator_type": "distinct"
+ },
+ {
+ "function": "sum(distinct t3.a + t3.b)",
+ "aggregator_type": "distinct"
+ }
+]
+# Can't apply optimization 'cause GROUP BY argument is not a field:
+SELECT COUNT(DISTINCT b) FROM t3 GROUP BY a+b;
+COUNT(DISTINCT b)
+1
+2
+3
+1
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "count(distinct t3.b)",
+ "aggregator_type": "distinct"
+ }
+]
+# Test merged view
+CREATE VIEW v1 AS SELECT * FROM t1;
+# Optimization is applied
+SELECT COUNT(DISTINCT a, b) FROM v1;
+COUNT(DISTINCT a, b)
+3
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "count(distinct t1.a,t1.b)",
+ "aggregator_type": "simple"
+ }
+]
+# GROUP_CONCAT implements non-standard distinct aggregator
+SELECT GROUP_CONCAT(b) FROM t1;
+GROUP_CONCAT(b)
+1,1,1
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "group_concat(t1.b separator ',')",
+ "aggregator_type": "simple"
+ }
+]
+SELECT GROUP_CONCAT(DISTINCT b) FROM t1;
+GROUP_CONCAT(DISTINCT b)
+1
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '$**.prepare_sum_aggregators')) AS JS
+FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+JS
+[
+ {
+ "function": "group_concat(distinct t1.b separator ',')",
+ "aggregator_type": "distinct"
+ }
+]
+DROP TABLE t1, t2, t3;
+DROP VIEW v1;
+SET optimizer_trace = @save_optimizer_trace;
+#
+# end of 10.5 tests
+#
diff --git a/mysql-test/main/distinct_notembedded.test b/mysql-test/main/distinct_notembedded.test
new file mode 100644
index 00000000..9ef2f459
--- /dev/null
+++ b/mysql-test/main/distinct_notembedded.test
@@ -0,0 +1,109 @@
+# Embedded doesn't have optimizer trace:
+--source include/not_embedded.inc
+--source include/have_sequence.inc
+
+--echo #
+--echo # MDEV-30660 COUNT DISTINCT seems unnecessarily slow when run on a PK
+--echo #
+
+set @save_optimizer_trace = @@optimizer_trace;
+SET optimizer_trace='enabled=on';
+let $trace=
+SELECT JSON_DETAILED(JSON_EXTRACT(trace, '\$**.prepare_sum_aggregators')) AS JS
+ FROM INFORMATION_SCHEMA.OPTIMIZER_TRACE;
+
+CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY, b INT NOT NULL);
+INSERT INTO t1 VALUES (1,1), (2,1), (3,1);
+
+--echo # Optimization is applied (aggregator=simple):
+SELECT COUNT(DISTINCT a) FROM t1;
+eval $trace;
+
+SELECT AVG(DISTINCT a), SUM(DISTINCT b) FROM t1;
+eval $trace;
+
+--echo # Only `a` is unique but it's enough to eliminate DISTINCT:
+SELECT COUNT(DISTINCT b, a) FROM t1;
+eval $trace;
+
+SELECT COUNT(DISTINCT a, a + b) FROM t1;
+eval $trace;
+
+SELECT SUM(DISTINCT a), AVG(DISTINCT a), COUNT(DISTINCT a) FROM t1 WHERE a > 1;
+eval $trace;
+
+--echo # Optimization is not applied 'cause function argument is not a field
+--echo # (aggregator=distinct):
+SELECT SUM(DISTINCT a + b) FROM t1;
+eval $trace;
+
+SELECT COUNT(DISTINCT b) FROM t1;
+eval $trace;
+
+SELECT AVG(DISTINCT b / a) FROM t1;
+eval $trace;
+
+EXPLAIN SELECT COUNT(DISTINCT (SELECT a)) FROM t1;
+eval $trace;
+
+CREATE TABLE t2 (a INT);
+INSERT INTO t2 VALUES (1), (2);
+
+--echo # Optimization is not applied 'cause there is more than one table
+SELECT COUNT(DISTINCT t1.a) FROM t1, t2;
+eval $trace;
+
+SELECT AVG(DISTINCT t1.a) FROM t1, t2;
+eval $trace;
+
+--echo # Const tables, optimization is applied
+SELECT COUNT(DISTINCT a) FROM t1, (SELECT 1) AS t2;
+eval $trace;
+
+SELECT AVG(DISTINCT t1.a) FROM (SELECT 1 AS a) AS t2, t1, (SELECT 2 AS a) AS t3;
+eval $trace;
+
+SELECT COUNT(DISTINCT a) FROM t1, (SELECT 1 UNION SELECT 2) AS t2;
+eval $trace;
+
+--echo # Unique index on two columns
+CREATE TABLE t3 (a INT NOT NULL, b INT NOT NULL);
+INSERT INTO t3 VALUES (1,1), (1,2), (1,3), (2,1), (2,2), (3,1), (3,2);
+CREATE UNIQUE INDEX t3_a_b ON t3 (a, b);
+--echo # Optimization is applied:
+SELECT COUNT(DISTINCT a, b) FROM t3;
+eval $trace;
+
+SELECT COUNT(DISTINCT b, a) FROM t3;
+eval $trace;
+
+SELECT COUNT(DISTINCT b, a) FROM t3 WHERE a < 3;
+eval $trace;
+
+--echo # Optimization is applied to one of the functions:
+SELECT COUNT(DISTINCT b), SUM(DISTINCT a), SUM(DISTINCT a + b) FROM t3 GROUP BY a;
+eval $trace;
+
+--echo # Can't apply optimization 'cause GROUP BY argument is not a field:
+SELECT COUNT(DISTINCT b) FROM t3 GROUP BY a+b;
+eval $trace;
+
+--echo # Test merged view
+CREATE VIEW v1 AS SELECT * FROM t1;
+--echo # Optimization is applied
+SELECT COUNT(DISTINCT a, b) FROM v1;
+eval $trace;
+
+--echo # GROUP_CONCAT implements non-standard distinct aggregator
+SELECT GROUP_CONCAT(b) FROM t1;
+eval $trace;
+
+SELECT GROUP_CONCAT(DISTINCT b) FROM t1;
+eval $trace;
+
+DROP TABLE t1, t2, t3;
+DROP VIEW v1;
+SET optimizer_trace = @save_optimizer_trace;
+--echo #
+--echo # end of 10.5 tests
+--echo #
diff --git a/mysql-test/main/dyncol.result b/mysql-test/main/dyncol.result
index 88cec1c5..64ce60b4 100644
--- a/mysql-test/main/dyncol.result
+++ b/mysql-test/main/dyncol.result
@@ -150,7 +150,7 @@ select hex(COLUMN_CREATE(1, "afaf" AS char character set utf8,
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 select hex(column_create(1,'afaf' AS char charset utf8mb3 ,2,1212 AS unsigned int,3,1212 AS int,4,12.12 AS double,4 + 1,12.12 AS decimal,6,'2011-04-05' AS date,7,'- 0:45:49.000001' AS time,8,'2011-04-05 0:45:49.000001' AS datetime)) AS `ex`
+Note 1003 select hex(column_create(1,'afaf' AS char charset utf8mb3 collate utf8mb3_general_ci ,2,1212 AS unsigned int,3,1212 AS int,4,12.12 AS double,4 + 1,12.12 AS decimal,6,'2011-04-05' AS date,7,'- 0:45:49.000001' AS time,8,'2011-04-05 0:45:49.000001' AS datetime)) AS `ex`
select hex(column_create(1, 0.0 AS decimal));
hex(column_create(1, 0.0 AS decimal))
000100010004
@@ -354,7 +354,7 @@ select column_get(column_create(1, "1212" AS char charset utf8), 1 as char chars
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 select column_get(column_create(1,'1212' AS char charset utf8mb3 ),1 as char charset utf8mb3) AS `ex`
+Note 1003 select column_get(column_create(1,'1212' AS char charset utf8mb3 collate utf8mb3_general_ci ),1 as char charset utf8mb3) AS `ex`
select column_get(column_create(1, 1212 AS unsigned int), 1 as char charset utf8) as ex;
ex
1212
@@ -414,7 +414,7 @@ select column_get(column_create(1, "1212" AS char charset utf8), 1 as char chars
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
Warnings:
-Note 1003 select column_get(column_create(1,'1212' AS char charset utf8mb3 ),1 as char charset binary) AS `ex`
+Note 1003 select column_get(column_create(1,'1212' AS char charset utf8mb3 collate utf8mb3_general_ci ),1 as char charset binary) AS `ex`
#
# column get real
#
@@ -1882,7 +1882,7 @@ drop table t1;
create view v1 as select column_get(column_add(column_create(1 , 'blue' as char), 2, 'ttt'), 1 as char);
show create view v1;
View Create View character_set_client collation_connection
-v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select column_get(column_add(column_create(1,'blue' AS char charset utf8mb3 ),2,'ttt'),1 as char charset utf8mb3) AS `Name_exp_1` utf8mb3 utf8mb3_general_ci
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select column_get(column_add(column_create(1,'blue' AS char charset utf8mb3 collate utf8mb3_general_ci ),2,'ttt'),1 as char charset utf8mb3) AS `Name_exp_1` utf8mb3 utf8mb3_general_ci
select * from v1;
Name_exp_1
blue
@@ -1949,3 +1949,23 @@ ex
#
# End of 10.4 tests
#
+#
+# Start of 10.5 tests
+#
+#
+# Start of 10.5 tests
+#
+#
+# MDEV-33788 HEX(COLUMN_CREATE(.. AS CHAR ...)) fails with --view-protocol
+#
+SELECT hex(column_create(1,'a' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin)) AS ex;
+ex
+0001000100035361
+SELECT hex(column_add(column_create(
+1, 'a' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin),
+2, 'b' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci)) AS ex;
+ex
+00020001000302001353612162
+#
+# Start of 10.5 tests
+#
diff --git a/mysql-test/main/dyncol.test b/mysql-test/main/dyncol.test
index 8b316421..1343025d 100644
--- a/mysql-test/main/dyncol.test
+++ b/mysql-test/main/dyncol.test
@@ -1000,3 +1000,24 @@ SELECT HEX(COLUMN_ADD(COLUMN_CREATE(1,10),2,NULL,1,NULL)) as ex;
--echo #
--echo # End of 10.4 tests
--echo #
+
+--echo #
+--echo # Start of 10.5 tests
+--echo #
+
+--echo #
+--echo # Start of 10.5 tests
+--echo #
+
+--echo #
+--echo # MDEV-33788 HEX(COLUMN_CREATE(.. AS CHAR ...)) fails with --view-protocol
+--echo #
+
+SELECT hex(column_create(1,'a' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin)) AS ex;
+SELECT hex(column_add(column_create(
+ 1, 'a' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_bin),
+ 2, 'b' AS CHAR CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci)) AS ex;
+
+--echo #
+--echo # Start of 10.5 tests
+--echo #
diff --git a/mysql-test/main/empty_server_name-8224.test b/mysql-test/main/empty_server_name-8224.test
index 5c5140be..31760713 100644
--- a/mysql-test/main/empty_server_name-8224.test
+++ b/mysql-test/main/empty_server_name-8224.test
@@ -3,10 +3,10 @@
#
--source include/not_embedded.inc
create server '' foreign data wrapper w2 options (host '127.0.0.1');
---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-- enable_reconnect
-- source include/wait_until_connected_again.inc
diff --git a/mysql-test/main/empty_string_literal.result b/mysql-test/main/empty_string_literal.result
index 732e8e6d..447bad8a 100644
--- a/mysql-test/main/empty_string_literal.result
+++ b/mysql-test/main/empty_string_literal.result
@@ -64,7 +64,7 @@ SET sql_mode=@mode;
# Test litteral concat
#
SELECT 'a' 'b';
-a
+ab
ab
SELECT 'a' '';
a
@@ -76,13 +76,13 @@ SELECT '' '';
NULL
NULL
SELECT '' 'b' 'c';
-b
+bc
bc
SELECT '' '' 'c';
c
c
SELECT 'a' '' 'c';
-a
+ac
ac
SELECT 'a' '' '';
a
@@ -208,3 +208,23 @@ t1 CREATE TABLE `t1` (
KEY `a` (`a`,`b`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1;
+set sql_mode= default;
+#
+# MDEV-33460 select '123' 'x'; unexpected result
+#
+SELECT '';
+
+
+SELECT '' 'b' 'c';
+bc
+bc
+SELECT '' '' 'c';
+c
+c
+SELECT 'a' '' 'c';
+ac
+ac
+SELECT 'a' '' '';
+a
+a
+# End of 10.5 test
diff --git a/mysql-test/main/empty_string_literal.test b/mysql-test/main/empty_string_literal.test
index 9174a771..e3ae0094 100644
--- a/mysql-test/main/empty_string_literal.test
+++ b/mysql-test/main/empty_string_literal.test
@@ -25,3 +25,18 @@ flush tables;
update t1 set a = 2;
show create table t1;
drop table t1;
+set sql_mode= default;
+
+--echo #
+--echo # MDEV-33460 select '123' 'x'; unexpected result
+--echo #
+
+--disable_view_protocol
+SELECT '';
+--enable_view_protocol
+SELECT '' 'b' 'c';
+SELECT '' '' 'c';
+SELECT 'a' '' 'c';
+SELECT 'a' '' '';
+
+--echo # End of 10.5 test
diff --git a/mysql-test/main/func_encrypt_nossl.result b/mysql-test/main/func_encrypt_nossl.result
index b28d4811..7afc9fa6 100644
--- a/mysql-test/main/func_encrypt_nossl.result
+++ b/mysql-test/main/func_encrypt_nossl.result
@@ -3,56 +3,56 @@ des_encrypt("test", 'akeystr')
NULL
Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select des_encrypt("test", 1);
des_encrypt("test", 1)
NULL
Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select des_encrypt("test", 9);
des_encrypt("test", 9)
NULL
Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select des_encrypt("test", 100);
des_encrypt("test", 100)
NULL
Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select des_encrypt("test", NULL);
des_encrypt("test", NULL)
NULL
Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select des_encrypt(NULL, NULL);
des_encrypt(NULL, NULL)
NULL
Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select des_decrypt("test", 'anotherkeystr');
des_decrypt("test", 'anotherkeystr')
NULL
Warnings:
Note 1287 'des_decrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select des_decrypt(1, 1);
des_decrypt(1, 1)
NULL
Warnings:
Note 1287 'des_decrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select des_decrypt(des_encrypt("test", 'thekey'));
des_decrypt(des_encrypt("test", 'thekey'))
NULL
Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
Note 1287 'des_decrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select hex(des_encrypt("hello")),des_decrypt(des_encrypt("hello"));
hex(des_encrypt("hello")) des_decrypt(des_encrypt("hello"))
NULL NULL
@@ -60,22 +60,22 @@ Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
Note 1287 'des_decrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
-Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
+Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select des_decrypt(des_encrypt("hello",4));
des_decrypt(des_encrypt("hello",4))
NULL
Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
Note 1287 'des_decrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select des_decrypt(des_encrypt("hello",'test'),'test');
des_decrypt(des_encrypt("hello",'test'),'test')
NULL
Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
Note 1287 'des_decrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select hex(des_encrypt("hello")),hex(des_encrypt("hello",5)),hex(des_encrypt("hello",'default_password'));
hex(des_encrypt("hello")) hex(des_encrypt("hello",5)) hex(des_encrypt("hello",'default_password'))
NULL NULL NULL
@@ -83,28 +83,28 @@ Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
-Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
-Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
+Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
+Warning 1289 The 'des_encrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select des_decrypt(des_encrypt("hello"),'default_password');
des_decrypt(des_encrypt("hello"),'default_password')
NULL
Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
Note 1287 'des_decrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select des_decrypt(des_encrypt("hello",4),'password4');
des_decrypt(des_encrypt("hello",4),'password4')
NULL
Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
Note 1287 'des_decrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
SET @a=des_decrypt(des_encrypt("hello"));
Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
Note 1287 'des_decrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
flush des_key_file;
select @a = des_decrypt(des_encrypt("hello"));
@a = des_decrypt(des_encrypt("hello"))
@@ -121,11 +121,11 @@ NULL
Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
Note 1287 'des_decrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
select hex(des_decrypt(des_encrypt("hello","hidden")));
hex(des_decrypt(des_encrypt("hello","hidden")))
NULL
Warnings:
Note 1287 'des_encrypt' is deprecated and will be removed in a future release
Note 1287 'des_decrypt' is deprecated and will be removed in a future release
-Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with '--with-ssl' to have it working
+Warning 1289 The 'des_decrypt' feature is disabled; you need MariaDB built with 'openssl des cipher (HAVE_des)' to have it working
diff --git a/mysql-test/main/func_extract.result b/mysql-test/main/func_extract.result
index bebb8c71..dc71f6ae 100644
--- a/mysql-test/main/func_extract.result
+++ b/mysql-test/main/func_extract.result
@@ -590,3 +590,885 @@ Warning 1292 Truncated incorrect time value: '01:02:03/'
Warning 1292 Truncated incorrect time value: '01:02:03/'
Warning 1292 Truncated incorrect INTERVAL DAY TO SECOND value: '01:02:03/'
DROP TABLE t1;
+#
+# Start of 10.5 tests
+#
+#
+# MDEV-33496 Out of range error in AVG(YEAR(datetime)) due to a wrong data type
+#
+CREATE FUNCTION select01() RETURNS TEXT RETURN 'SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?';
+CREATE FUNCTION select02() RETURNS TEXT RETURN 'SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)';
+CREATE TABLE t1 (a DATETIME(6));
+INSERT INTO t1 VALUES ('2001-12-31 10:20:30.999999');
+CREATE FUNCTION params(expr TEXT, count INT) RETURNS TEXT
+BEGIN
+RETURN CONCAT(expr, REPEAT(CONCAT(', ', expr), count-1));
+END;
+$$
+CREATE PROCEDURE show_drop()
+BEGIN
+SELECT TABLE_NAME, COLUMN_TYPE, COLUMN_NAME
+FROM INFORMATION_SCHEMA.COLUMNS
+WHERE TABLE_SCHEMA='test'
+ AND TABLE_NAME IN ('t1e_nm','t2e_nm','t1f_nm','t2f_nm',
+'t1e_ps','t1f_ps','t2e_ps','t2f_ps')
+ORDER BY LEFT(TABLE_NAME, 2), ORDINAL_POSITION, TABLE_NAME;
+FOR rec IN (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
+WHERE TABLE_SCHEMA='test'
+ AND TABLE_NAME IN ('t1e_nm','t2e_nm','t1f_nm','t2f_nm',
+'t1e_ps','t1f_ps','t2e_ps','t2f_ps'))
+DO
+EXECUTE IMMEDIATE CONCAT('DROP TABLE ', rec.TABLE_NAME);
+END FOR;
+END;
+$$
+CREATE PROCEDURE p1(unit VARCHAR(32))
+BEGIN
+DECLARE do_extract BOOL DEFAULT unit NOT IN('DAYOFYEAR');
+DECLARE query01 TEXT DEFAULT
+CONCAT('CREATE TABLE t2 AS ', select01(), ' FROM t1');
+DECLARE query02 TEXT DEFAULT
+CONCAT('CREATE TABLE t2 AS ', select02(), ' FROM t1');
+IF (do_extract)
+THEN
+EXECUTE IMMEDIATE REPLACE(REPLACE(query01,'t2','t1e_nm'),'?', CONCAT('EXTRACT(',unit,' FROM a)'));
+EXECUTE IMMEDIATE REPLACE(REPLACE(query02,'t2','t2e_nm'),'?', CONCAT('EXTRACT(',unit,' FROM a)'));
+END IF;
+EXECUTE IMMEDIATE REPLACE(REPLACE(query01,'t2','t1f_nm'),'?', CONCAT(unit,'(a)'));
+EXECUTE IMMEDIATE REPLACE(REPLACE(query02,'t2','t2f_nm'),'?', CONCAT(unit,'(a)'));
+END;
+$$
+
+
+# EXTRACT(YEAR FROM expr) and YEAR(expr) are equivalent
+CALL p1('YEAR');
+EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(YEAR FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), YEAR(TIMESTAMP'2001-12-13 10:20:30.999999');
+CALL show_drop;
+TABLE_NAME COLUMN_TYPE COLUMN_NAME
+t1e_nm int(5) EXTRACT(YEAR FROM a)
+t1e_ps int(5) ?
+t1f_nm int(5) YEAR(a)
+t1f_ps int(5) ?
+t1e_nm int(4) unsigned CAST(EXTRACT(YEAR FROM a) AS UNSIGNED)
+t1e_ps int(4) unsigned CAST(? AS UNSIGNED)
+t1f_nm int(4) unsigned CAST(YEAR(a) AS UNSIGNED)
+t1f_ps int(4) unsigned CAST(? AS UNSIGNED)
+t1e_nm int(5) CAST(EXTRACT(YEAR FROM a) AS SIGNED)
+t1e_ps int(5) CAST(? AS SIGNED)
+t1f_nm int(5) CAST(YEAR(a) AS SIGNED)
+t1f_ps int(5) CAST(? AS SIGNED)
+t1e_nm int(5) ABS(EXTRACT(YEAR FROM a))
+t1e_ps int(5) ABS(?)
+t1f_nm int(5) ABS(YEAR(a))
+t1f_ps int(5) ABS(?)
+t1e_nm int(5) ROUND(EXTRACT(YEAR FROM a))
+t1e_ps int(5) ROUND(?)
+t1f_nm int(5) ROUND(YEAR(a))
+t1f_ps int(5) ROUND(?)
+t1e_nm int(5) -EXTRACT(YEAR FROM a)
+t1e_ps int(5) -?
+t1f_nm int(5) -YEAR(a)
+t1f_ps int(5) -?
+t1e_nm int(6) ROUND(EXTRACT(YEAR FROM a),-1)
+t1e_ps int(6) ROUND(?,-1)
+t1f_nm int(6) ROUND(YEAR(a),-1)
+t1f_ps int(6) ROUND(?,-1)
+t1e_nm int(6) EXTRACT(YEAR FROM a)+0
+t1e_ps int(6) ?+0
+t1f_nm int(6) YEAR(a)+0
+t1f_ps int(6) ?+0
+t1e_nm decimal(6,1) EXTRACT(YEAR FROM a)+0.0
+t1e_ps decimal(6,1) ?+0.0
+t1f_nm decimal(6,1) YEAR(a)+0.0
+t1f_ps decimal(6,1) ?+0.0
+t1e_nm varchar(4) CONCAT(EXTRACT(YEAR FROM a))
+t1e_ps varchar(4) CONCAT(?)
+t1f_nm varchar(4) CONCAT(YEAR(a))
+t1f_ps varchar(4) CONCAT(?)
+t1e_nm int(5) LEAST(EXTRACT(YEAR FROM a),EXTRACT(YEAR FROM a))
+t1e_ps int(5) LEAST(?,?)
+t1f_nm int(5) LEAST(YEAR(a),YEAR(a))
+t1f_ps int(5) LEAST(?,?)
+t1e_nm int(5) COALESCE(EXTRACT(YEAR FROM a))
+t1e_ps int(5) COALESCE(?)
+t1f_nm int(5) COALESCE(YEAR(a))
+t1f_ps int(5) COALESCE(?)
+t1e_nm int(5) COALESCE(EXTRACT(YEAR FROM a),CAST(1 AS SIGNED))
+t1e_ps int(5) COALESCE(?,CAST(1 AS SIGNED))
+t1f_nm int(5) COALESCE(YEAR(a),CAST(1 AS SIGNED))
+t1f_ps int(5) COALESCE(?,CAST(1 AS SIGNED))
+t1e_nm decimal(4,0) COALESCE(EXTRACT(YEAR FROM a),CAST(1 AS UNSIGNED))
+t1e_ps decimal(4,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1f_nm decimal(4,0) COALESCE(YEAR(a),CAST(1 AS UNSIGNED))
+t1f_ps decimal(4,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1e_nm int(5) @a:=EXTRACT(YEAR FROM a)
+t1e_ps int(5) @a:=?
+t1f_nm int(5) @a:=YEAR(a)
+t1f_ps int(5) @a:=?
+t2e_nm decimal(8,4) AVG(EXTRACT(YEAR FROM a))
+t2e_ps decimal(8,4) AVG(?)
+t2f_nm decimal(8,4) AVG(YEAR(a))
+t2f_ps decimal(8,4) AVG(?)
+t2e_nm bigint(5) MIN(EXTRACT(YEAR FROM a))
+t2e_ps bigint(5) MIN(?)
+t2f_nm bigint(5) MIN(YEAR(a))
+t2f_ps bigint(5) MIN(?)
+t2e_nm bigint(5) MAX(EXTRACT(YEAR FROM a))
+t2e_ps bigint(5) MAX(?)
+t2f_nm bigint(5) MAX(YEAR(a))
+t2f_ps bigint(5) MAX(?)
+t2e_nm mediumtext GROUP_CONCAT(EXTRACT(YEAR FROM a))
+t2e_ps mediumtext GROUP_CONCAT(?)
+t2f_nm mediumtext GROUP_CONCAT(YEAR(a))
+t2f_ps mediumtext GROUP_CONCAT(?)
+
+
+# EXTRACT(QUARTER FROM expr) and QUARTER(expr) are equavalent
+CALL p1('QUARTER');
+EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(QUARTER FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999'), QUARTER(TIMESTAMP'2001-12-13 10:20:30.999999');
+CALL show_drop;
+TABLE_NAME COLUMN_TYPE COLUMN_NAME
+t1e_nm int(2) EXTRACT(QUARTER FROM a)
+t1e_ps int(2) ?
+t1f_nm int(2) QUARTER(a)
+t1f_ps int(2) ?
+t1e_nm int(1) unsigned CAST(EXTRACT(QUARTER FROM a) AS UNSIGNED)
+t1e_ps int(1) unsigned CAST(? AS UNSIGNED)
+t1f_nm int(1) unsigned CAST(QUARTER(a) AS UNSIGNED)
+t1f_ps int(1) unsigned CAST(? AS UNSIGNED)
+t1e_nm int(2) CAST(EXTRACT(QUARTER FROM a) AS SIGNED)
+t1e_ps int(2) CAST(? AS SIGNED)
+t1f_nm int(2) CAST(QUARTER(a) AS SIGNED)
+t1f_ps int(2) CAST(? AS SIGNED)
+t1e_nm int(2) ABS(EXTRACT(QUARTER FROM a))
+t1e_ps int(2) ABS(?)
+t1f_nm int(2) ABS(QUARTER(a))
+t1f_ps int(2) ABS(?)
+t1e_nm int(2) ROUND(EXTRACT(QUARTER FROM a))
+t1e_ps int(2) ROUND(?)
+t1f_nm int(2) ROUND(QUARTER(a))
+t1f_ps int(2) ROUND(?)
+t1e_nm int(2) -EXTRACT(QUARTER FROM a)
+t1e_ps int(2) -?
+t1f_nm int(2) -QUARTER(a)
+t1f_ps int(2) -?
+t1e_nm int(3) ROUND(EXTRACT(QUARTER FROM a),-1)
+t1e_ps int(3) ROUND(?,-1)
+t1f_nm int(3) ROUND(QUARTER(a),-1)
+t1f_ps int(3) ROUND(?,-1)
+t1e_nm int(3) EXTRACT(QUARTER FROM a)+0
+t1e_ps int(3) ?+0
+t1f_nm int(3) QUARTER(a)+0
+t1f_ps int(3) ?+0
+t1e_nm decimal(3,1) EXTRACT(QUARTER FROM a)+0.0
+t1e_ps decimal(3,1) ?+0.0
+t1f_nm decimal(3,1) QUARTER(a)+0.0
+t1f_ps decimal(3,1) ?+0.0
+t1e_nm varchar(1) CONCAT(EXTRACT(QUARTER FROM a))
+t1e_ps varchar(1) CONCAT(?)
+t1f_nm varchar(1) CONCAT(QUARTER(a))
+t1f_ps varchar(1) CONCAT(?)
+t1e_nm int(2) LEAST(EXTRACT(QUARTER FROM a),EXTRACT(QUARTER FROM a))
+t1e_ps int(2) LEAST(?,?)
+t1f_nm int(2) LEAST(QUARTER(a),QUARTER(a))
+t1f_ps int(2) LEAST(?,?)
+t1e_nm int(2) COALESCE(EXTRACT(QUARTER FROM a))
+t1e_ps int(2) COALESCE(?)
+t1f_nm int(2) COALESCE(QUARTER(a))
+t1f_ps int(2) COALESCE(?)
+t1e_nm int(2) COALESCE(EXTRACT(QUARTER FROM a),CAST(1 AS SIGNED))
+t1e_ps int(2) COALESCE(?,CAST(1 AS SIGNED))
+t1f_nm int(2) COALESCE(QUARTER(a),CAST(1 AS SIGNED))
+t1f_ps int(2) COALESCE(?,CAST(1 AS SIGNED))
+t1e_nm decimal(1,0) COALESCE(EXTRACT(QUARTER FROM a),CAST(1 AS UNSIGNED))
+t1e_ps decimal(1,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1f_nm decimal(1,0) COALESCE(QUARTER(a),CAST(1 AS UNSIGNED))
+t1f_ps decimal(1,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1e_nm int(2) @a:=EXTRACT(QUARTER FROM a)
+t1e_ps int(2) @a:=?
+t1f_nm int(2) @a:=QUARTER(a)
+t1f_ps int(2) @a:=?
+t2e_nm decimal(5,4) AVG(EXTRACT(QUARTER FROM a))
+t2e_ps decimal(5,4) AVG(?)
+t2f_nm decimal(5,4) AVG(QUARTER(a))
+t2f_ps decimal(5,4) AVG(?)
+t2e_nm bigint(2) MIN(EXTRACT(QUARTER FROM a))
+t2e_ps bigint(2) MIN(?)
+t2f_nm bigint(2) MIN(QUARTER(a))
+t2f_ps bigint(2) MIN(?)
+t2e_nm bigint(2) MAX(EXTRACT(QUARTER FROM a))
+t2e_ps bigint(2) MAX(?)
+t2f_nm bigint(2) MAX(QUARTER(a))
+t2f_ps bigint(2) MAX(?)
+t2e_nm mediumtext GROUP_CONCAT(EXTRACT(QUARTER FROM a))
+t2e_ps mediumtext GROUP_CONCAT(?)
+t2f_nm mediumtext GROUP_CONCAT(QUARTER(a))
+t2f_ps mediumtext GROUP_CONCAT(?)
+
+
+# EXTRACT(MONTH FROM expr) and MONTH(expr) are equavalent
+CALL p1('MONTH');
+EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MONTH FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999'), MONTH(TIMESTAMP'2001-12-13 10:20:30.999999');
+CALL show_drop;
+TABLE_NAME COLUMN_TYPE COLUMN_NAME
+t1e_nm int(3) EXTRACT(MONTH FROM a)
+t1e_ps int(3) ?
+t1f_nm int(3) MONTH(a)
+t1f_ps int(3) ?
+t1e_nm int(2) unsigned CAST(EXTRACT(MONTH FROM a) AS UNSIGNED)
+t1e_ps int(2) unsigned CAST(? AS UNSIGNED)
+t1f_nm int(2) unsigned CAST(MONTH(a) AS UNSIGNED)
+t1f_ps int(2) unsigned CAST(? AS UNSIGNED)
+t1e_nm int(3) CAST(EXTRACT(MONTH FROM a) AS SIGNED)
+t1e_ps int(3) CAST(? AS SIGNED)
+t1f_nm int(3) CAST(MONTH(a) AS SIGNED)
+t1f_ps int(3) CAST(? AS SIGNED)
+t1e_nm int(3) ABS(EXTRACT(MONTH FROM a))
+t1e_ps int(3) ABS(?)
+t1f_nm int(3) ABS(MONTH(a))
+t1f_ps int(3) ABS(?)
+t1e_nm int(3) ROUND(EXTRACT(MONTH FROM a))
+t1e_ps int(3) ROUND(?)
+t1f_nm int(3) ROUND(MONTH(a))
+t1f_ps int(3) ROUND(?)
+t1e_nm int(3) -EXTRACT(MONTH FROM a)
+t1e_ps int(3) -?
+t1f_nm int(3) -MONTH(a)
+t1f_ps int(3) -?
+t1e_nm int(4) ROUND(EXTRACT(MONTH FROM a),-1)
+t1e_ps int(4) ROUND(?,-1)
+t1f_nm int(4) ROUND(MONTH(a),-1)
+t1f_ps int(4) ROUND(?,-1)
+t1e_nm int(4) EXTRACT(MONTH FROM a)+0
+t1e_ps int(4) ?+0
+t1f_nm int(4) MONTH(a)+0
+t1f_ps int(4) ?+0
+t1e_nm decimal(4,1) EXTRACT(MONTH FROM a)+0.0
+t1e_ps decimal(4,1) ?+0.0
+t1f_nm decimal(4,1) MONTH(a)+0.0
+t1f_ps decimal(4,1) ?+0.0
+t1e_nm varchar(2) CONCAT(EXTRACT(MONTH FROM a))
+t1e_ps varchar(2) CONCAT(?)
+t1f_nm varchar(2) CONCAT(MONTH(a))
+t1f_ps varchar(2) CONCAT(?)
+t1e_nm int(3) LEAST(EXTRACT(MONTH FROM a),EXTRACT(MONTH FROM a))
+t1e_ps int(3) LEAST(?,?)
+t1f_nm int(3) LEAST(MONTH(a),MONTH(a))
+t1f_ps int(3) LEAST(?,?)
+t1e_nm int(3) COALESCE(EXTRACT(MONTH FROM a))
+t1e_ps int(3) COALESCE(?)
+t1f_nm int(3) COALESCE(MONTH(a))
+t1f_ps int(3) COALESCE(?)
+t1e_nm int(3) COALESCE(EXTRACT(MONTH FROM a),CAST(1 AS SIGNED))
+t1e_ps int(3) COALESCE(?,CAST(1 AS SIGNED))
+t1f_nm int(3) COALESCE(MONTH(a),CAST(1 AS SIGNED))
+t1f_ps int(3) COALESCE(?,CAST(1 AS SIGNED))
+t1e_nm decimal(2,0) COALESCE(EXTRACT(MONTH FROM a),CAST(1 AS UNSIGNED))
+t1e_ps decimal(2,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1f_nm decimal(2,0) COALESCE(MONTH(a),CAST(1 AS UNSIGNED))
+t1f_ps decimal(2,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1e_nm int(3) @a:=EXTRACT(MONTH FROM a)
+t1e_ps int(3) @a:=?
+t1f_nm int(3) @a:=MONTH(a)
+t1f_ps int(3) @a:=?
+t2e_nm decimal(6,4) AVG(EXTRACT(MONTH FROM a))
+t2e_ps decimal(6,4) AVG(?)
+t2f_nm decimal(6,4) AVG(MONTH(a))
+t2f_ps decimal(6,4) AVG(?)
+t2e_nm bigint(3) MIN(EXTRACT(MONTH FROM a))
+t2e_ps bigint(3) MIN(?)
+t2f_nm bigint(3) MIN(MONTH(a))
+t2f_ps bigint(3) MIN(?)
+t2e_nm bigint(3) MAX(EXTRACT(MONTH FROM a))
+t2e_ps bigint(3) MAX(?)
+t2f_nm bigint(3) MAX(MONTH(a))
+t2f_ps bigint(3) MAX(?)
+t2e_nm mediumtext GROUP_CONCAT(EXTRACT(MONTH FROM a))
+t2e_ps mediumtext GROUP_CONCAT(?)
+t2f_nm mediumtext GROUP_CONCAT(MONTH(a))
+t2f_ps mediumtext GROUP_CONCAT(?)
+
+
+# EXTRACT(WEEK FROM expr) and WEEK(expr) are equavalent
+CALL p1('WEEK');
+EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(WEEK FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999'), WEEK(TIMESTAMP'2001-12-13 10:20:30.999999');
+CALL show_drop;
+TABLE_NAME COLUMN_TYPE COLUMN_NAME
+t1e_nm int(3) EXTRACT(WEEK FROM a)
+t1e_ps int(3) ?
+t1f_nm int(3) WEEK(a)
+t1f_ps int(3) ?
+t1e_nm int(2) unsigned CAST(EXTRACT(WEEK FROM a) AS UNSIGNED)
+t1e_ps int(2) unsigned CAST(? AS UNSIGNED)
+t1f_nm int(2) unsigned CAST(WEEK(a) AS UNSIGNED)
+t1f_ps int(2) unsigned CAST(? AS UNSIGNED)
+t1e_nm int(3) CAST(EXTRACT(WEEK FROM a) AS SIGNED)
+t1e_ps int(3) CAST(? AS SIGNED)
+t1f_nm int(3) CAST(WEEK(a) AS SIGNED)
+t1f_ps int(3) CAST(? AS SIGNED)
+t1e_nm int(3) ABS(EXTRACT(WEEK FROM a))
+t1e_ps int(3) ABS(?)
+t1f_nm int(3) ABS(WEEK(a))
+t1f_ps int(3) ABS(?)
+t1e_nm int(3) ROUND(EXTRACT(WEEK FROM a))
+t1e_ps int(3) ROUND(?)
+t1f_nm int(3) ROUND(WEEK(a))
+t1f_ps int(3) ROUND(?)
+t1e_nm int(3) -EXTRACT(WEEK FROM a)
+t1e_ps int(3) -?
+t1f_nm int(3) -WEEK(a)
+t1f_ps int(3) -?
+t1e_nm int(4) ROUND(EXTRACT(WEEK FROM a),-1)
+t1e_ps int(4) ROUND(?,-1)
+t1f_nm int(4) ROUND(WEEK(a),-1)
+t1f_ps int(4) ROUND(?,-1)
+t1e_nm int(4) EXTRACT(WEEK FROM a)+0
+t1e_ps int(4) ?+0
+t1f_nm int(4) WEEK(a)+0
+t1f_ps int(4) ?+0
+t1e_nm decimal(4,1) EXTRACT(WEEK FROM a)+0.0
+t1e_ps decimal(4,1) ?+0.0
+t1f_nm decimal(4,1) WEEK(a)+0.0
+t1f_ps decimal(4,1) ?+0.0
+t1e_nm varchar(2) CONCAT(EXTRACT(WEEK FROM a))
+t1e_ps varchar(2) CONCAT(?)
+t1f_nm varchar(2) CONCAT(WEEK(a))
+t1f_ps varchar(2) CONCAT(?)
+t1e_nm int(3) LEAST(EXTRACT(WEEK FROM a),EXTRACT(WEEK FROM a))
+t1e_ps int(3) LEAST(?,?)
+t1f_nm int(3) LEAST(WEEK(a),WEEK(a))
+t1f_ps int(3) LEAST(?,?)
+t1e_nm int(3) COALESCE(EXTRACT(WEEK FROM a))
+t1e_ps int(3) COALESCE(?)
+t1f_nm int(3) COALESCE(WEEK(a))
+t1f_ps int(3) COALESCE(?)
+t1e_nm int(3) COALESCE(EXTRACT(WEEK FROM a),CAST(1 AS SIGNED))
+t1e_ps int(3) COALESCE(?,CAST(1 AS SIGNED))
+t1f_nm int(3) COALESCE(WEEK(a),CAST(1 AS SIGNED))
+t1f_ps int(3) COALESCE(?,CAST(1 AS SIGNED))
+t1e_nm decimal(2,0) COALESCE(EXTRACT(WEEK FROM a),CAST(1 AS UNSIGNED))
+t1e_ps decimal(2,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1f_nm decimal(2,0) COALESCE(WEEK(a),CAST(1 AS UNSIGNED))
+t1f_ps decimal(2,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1e_nm int(3) @a:=EXTRACT(WEEK FROM a)
+t1e_ps int(3) @a:=?
+t1f_nm int(3) @a:=WEEK(a)
+t1f_ps int(3) @a:=?
+t2e_nm decimal(6,4) AVG(EXTRACT(WEEK FROM a))
+t2e_ps decimal(6,4) AVG(?)
+t2f_nm decimal(6,4) AVG(WEEK(a))
+t2f_ps decimal(6,4) AVG(?)
+t2e_nm bigint(3) MIN(EXTRACT(WEEK FROM a))
+t2e_ps bigint(3) MIN(?)
+t2f_nm bigint(3) MIN(WEEK(a))
+t2f_ps bigint(3) MIN(?)
+t2e_nm bigint(3) MAX(EXTRACT(WEEK FROM a))
+t2e_ps bigint(3) MAX(?)
+t2f_nm bigint(3) MAX(WEEK(a))
+t2f_ps bigint(3) MAX(?)
+t2e_nm mediumtext GROUP_CONCAT(EXTRACT(WEEK FROM a))
+t2e_ps mediumtext GROUP_CONCAT(?)
+t2f_nm mediumtext GROUP_CONCAT(WEEK(a))
+t2f_ps mediumtext GROUP_CONCAT(?)
+
+
+# EXTRACT(DAY FROM expr) returns hours/24 and includes the sign for TIME
+# DAY(expr) returns the DD part of CAST(expr AS DATETIME)
+CALL p1('DAY');
+EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(DAY FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999'), DAY(TIMESTAMP'2001-12-13 10:20:30.999999');
+CALL show_drop;
+TABLE_NAME COLUMN_TYPE COLUMN_NAME
+t1e_nm int(3) EXTRACT(DAY FROM a)
+t1e_ps int(3) ?
+t1f_nm int(3) DAY(a)
+t1f_ps int(3) ?
+t1e_nm bigint(20) unsigned CAST(EXTRACT(DAY FROM a) AS UNSIGNED)
+t1e_ps bigint(20) unsigned CAST(? AS UNSIGNED)
+t1f_nm int(2) unsigned CAST(DAY(a) AS UNSIGNED)
+t1f_ps int(2) unsigned CAST(? AS UNSIGNED)
+t1e_nm int(3) CAST(EXTRACT(DAY FROM a) AS SIGNED)
+t1e_ps int(3) CAST(? AS SIGNED)
+t1f_nm int(3) CAST(DAY(a) AS SIGNED)
+t1f_ps int(3) CAST(? AS SIGNED)
+t1e_nm int(3) ABS(EXTRACT(DAY FROM a))
+t1e_ps int(3) ABS(?)
+t1f_nm int(3) ABS(DAY(a))
+t1f_ps int(3) ABS(?)
+t1e_nm int(3) ROUND(EXTRACT(DAY FROM a))
+t1e_ps int(3) ROUND(?)
+t1f_nm int(3) ROUND(DAY(a))
+t1f_ps int(3) ROUND(?)
+t1e_nm int(4) -EXTRACT(DAY FROM a)
+t1e_ps int(4) -?
+t1f_nm int(3) -DAY(a)
+t1f_ps int(3) -?
+t1e_nm int(4) ROUND(EXTRACT(DAY FROM a),-1)
+t1e_ps int(4) ROUND(?,-1)
+t1f_nm int(4) ROUND(DAY(a),-1)
+t1f_ps int(4) ROUND(?,-1)
+t1e_nm int(4) EXTRACT(DAY FROM a)+0
+t1e_ps int(4) ?+0
+t1f_nm int(4) DAY(a)+0
+t1f_ps int(4) ?+0
+t1e_nm decimal(4,1) EXTRACT(DAY FROM a)+0.0
+t1e_ps decimal(4,1) ?+0.0
+t1f_nm decimal(4,1) DAY(a)+0.0
+t1f_ps decimal(4,1) ?+0.0
+t1e_nm varchar(3) CONCAT(EXTRACT(DAY FROM a))
+t1e_ps varchar(3) CONCAT(?)
+t1f_nm varchar(2) CONCAT(DAY(a))
+t1f_ps varchar(2) CONCAT(?)
+t1e_nm int(3) LEAST(EXTRACT(DAY FROM a),EXTRACT(DAY FROM a))
+t1e_ps int(3) LEAST(?,?)
+t1f_nm int(3) LEAST(DAY(a),DAY(a))
+t1f_ps int(3) LEAST(?,?)
+t1e_nm int(3) COALESCE(EXTRACT(DAY FROM a))
+t1e_ps int(3) COALESCE(?)
+t1f_nm int(3) COALESCE(DAY(a))
+t1f_ps int(3) COALESCE(?)
+t1e_nm int(3) COALESCE(EXTRACT(DAY FROM a),CAST(1 AS SIGNED))
+t1e_ps int(3) COALESCE(?,CAST(1 AS SIGNED))
+t1f_nm int(3) COALESCE(DAY(a),CAST(1 AS SIGNED))
+t1f_ps int(3) COALESCE(?,CAST(1 AS SIGNED))
+t1e_nm decimal(2,0) COALESCE(EXTRACT(DAY FROM a),CAST(1 AS UNSIGNED))
+t1e_ps decimal(2,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1f_nm decimal(2,0) COALESCE(DAY(a),CAST(1 AS UNSIGNED))
+t1f_ps decimal(2,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1e_nm int(3) @a:=EXTRACT(DAY FROM a)
+t1e_ps int(3) @a:=?
+t1f_nm int(3) @a:=DAY(a)
+t1f_ps int(3) @a:=?
+t2e_nm decimal(6,4) AVG(EXTRACT(DAY FROM a))
+t2e_ps decimal(6,4) AVG(?)
+t2f_nm decimal(6,4) AVG(DAY(a))
+t2f_ps decimal(6,4) AVG(?)
+t2e_nm bigint(3) MIN(EXTRACT(DAY FROM a))
+t2e_ps bigint(3) MIN(?)
+t2f_nm bigint(3) MIN(DAY(a))
+t2f_ps bigint(3) MIN(?)
+t2e_nm bigint(3) MAX(EXTRACT(DAY FROM a))
+t2e_ps bigint(3) MAX(?)
+t2f_nm bigint(3) MAX(DAY(a))
+t2f_ps bigint(3) MAX(?)
+t2e_nm mediumtext GROUP_CONCAT(EXTRACT(DAY FROM a))
+t2e_ps mediumtext GROUP_CONCAT(?)
+t2f_nm mediumtext GROUP_CONCAT(DAY(a))
+t2f_ps mediumtext GROUP_CONCAT(?)
+
+
+# EXTRACT(HOUR FROM expr) returns hours%24 and includes the sign for TIME
+# HOUR(expr) returns the hh part of CAST(expr AS DATETIME)
+CALL p1('HOUR');
+EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(HOUR FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999'), HOUR(TIMESTAMP'2001-12-13 10:20:30.999999');
+CALL show_drop;
+TABLE_NAME COLUMN_TYPE COLUMN_NAME
+t1e_nm int(3) EXTRACT(HOUR FROM a)
+t1e_ps int(3) ?
+t1f_nm int(3) HOUR(a)
+t1f_ps int(3) ?
+t1e_nm bigint(20) unsigned CAST(EXTRACT(HOUR FROM a) AS UNSIGNED)
+t1e_ps bigint(20) unsigned CAST(? AS UNSIGNED)
+t1f_nm int(2) unsigned CAST(HOUR(a) AS UNSIGNED)
+t1f_ps int(2) unsigned CAST(? AS UNSIGNED)
+t1e_nm int(3) CAST(EXTRACT(HOUR FROM a) AS SIGNED)
+t1e_ps int(3) CAST(? AS SIGNED)
+t1f_nm int(3) CAST(HOUR(a) AS SIGNED)
+t1f_ps int(3) CAST(? AS SIGNED)
+t1e_nm int(3) ABS(EXTRACT(HOUR FROM a))
+t1e_ps int(3) ABS(?)
+t1f_nm int(3) ABS(HOUR(a))
+t1f_ps int(3) ABS(?)
+t1e_nm int(3) ROUND(EXTRACT(HOUR FROM a))
+t1e_ps int(3) ROUND(?)
+t1f_nm int(3) ROUND(HOUR(a))
+t1f_ps int(3) ROUND(?)
+t1e_nm int(4) -EXTRACT(HOUR FROM a)
+t1e_ps int(4) -?
+t1f_nm int(3) -HOUR(a)
+t1f_ps int(3) -?
+t1e_nm int(4) ROUND(EXTRACT(HOUR FROM a),-1)
+t1e_ps int(4) ROUND(?,-1)
+t1f_nm int(4) ROUND(HOUR(a),-1)
+t1f_ps int(4) ROUND(?,-1)
+t1e_nm int(4) EXTRACT(HOUR FROM a)+0
+t1e_ps int(4) ?+0
+t1f_nm int(4) HOUR(a)+0
+t1f_ps int(4) ?+0
+t1e_nm decimal(4,1) EXTRACT(HOUR FROM a)+0.0
+t1e_ps decimal(4,1) ?+0.0
+t1f_nm decimal(4,1) HOUR(a)+0.0
+t1f_ps decimal(4,1) ?+0.0
+t1e_nm varchar(3) CONCAT(EXTRACT(HOUR FROM a))
+t1e_ps varchar(3) CONCAT(?)
+t1f_nm varchar(2) CONCAT(HOUR(a))
+t1f_ps varchar(2) CONCAT(?)
+t1e_nm int(3) LEAST(EXTRACT(HOUR FROM a),EXTRACT(HOUR FROM a))
+t1e_ps int(3) LEAST(?,?)
+t1f_nm int(3) LEAST(HOUR(a),HOUR(a))
+t1f_ps int(3) LEAST(?,?)
+t1e_nm int(3) COALESCE(EXTRACT(HOUR FROM a))
+t1e_ps int(3) COALESCE(?)
+t1f_nm int(3) COALESCE(HOUR(a))
+t1f_ps int(3) COALESCE(?)
+t1e_nm int(3) COALESCE(EXTRACT(HOUR FROM a),CAST(1 AS SIGNED))
+t1e_ps int(3) COALESCE(?,CAST(1 AS SIGNED))
+t1f_nm int(3) COALESCE(HOUR(a),CAST(1 AS SIGNED))
+t1f_ps int(3) COALESCE(?,CAST(1 AS SIGNED))
+t1e_nm decimal(2,0) COALESCE(EXTRACT(HOUR FROM a),CAST(1 AS UNSIGNED))
+t1e_ps decimal(2,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1f_nm decimal(2,0) COALESCE(HOUR(a),CAST(1 AS UNSIGNED))
+t1f_ps decimal(2,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1e_nm int(3) @a:=EXTRACT(HOUR FROM a)
+t1e_ps int(3) @a:=?
+t1f_nm int(3) @a:=HOUR(a)
+t1f_ps int(3) @a:=?
+t2e_nm decimal(6,4) AVG(EXTRACT(HOUR FROM a))
+t2e_ps decimal(6,4) AVG(?)
+t2f_nm decimal(6,4) AVG(HOUR(a))
+t2f_ps decimal(6,4) AVG(?)
+t2e_nm bigint(3) MIN(EXTRACT(HOUR FROM a))
+t2e_ps bigint(3) MIN(?)
+t2f_nm bigint(3) MIN(HOUR(a))
+t2f_ps bigint(3) MIN(?)
+t2e_nm bigint(3) MAX(EXTRACT(HOUR FROM a))
+t2e_ps bigint(3) MAX(?)
+t2f_nm bigint(3) MAX(HOUR(a))
+t2f_ps bigint(3) MAX(?)
+t2e_nm mediumtext GROUP_CONCAT(EXTRACT(HOUR FROM a))
+t2e_ps mediumtext GROUP_CONCAT(?)
+t2f_nm mediumtext GROUP_CONCAT(HOUR(a))
+t2f_ps mediumtext GROUP_CONCAT(?)
+
+
+# EXTRACT(MINUTE FROM expr) includes the sign for TIME
+# MINUTE(expr) returns the absolute value
+CALL p1('MINUTE');
+EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MINUTE FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999'), MINUTE(TIMESTAMP'2001-12-13 10:20:30.999999');
+CALL show_drop;
+TABLE_NAME COLUMN_TYPE COLUMN_NAME
+t1e_nm int(3) EXTRACT(MINUTE FROM a)
+t1e_ps int(3) ?
+t1f_nm int(3) MINUTE(a)
+t1f_ps int(3) ?
+t1e_nm bigint(20) unsigned CAST(EXTRACT(MINUTE FROM a) AS UNSIGNED)
+t1e_ps bigint(20) unsigned CAST(? AS UNSIGNED)
+t1f_nm int(2) unsigned CAST(MINUTE(a) AS UNSIGNED)
+t1f_ps int(2) unsigned CAST(? AS UNSIGNED)
+t1e_nm int(3) CAST(EXTRACT(MINUTE FROM a) AS SIGNED)
+t1e_ps int(3) CAST(? AS SIGNED)
+t1f_nm int(3) CAST(MINUTE(a) AS SIGNED)
+t1f_ps int(3) CAST(? AS SIGNED)
+t1e_nm int(3) ABS(EXTRACT(MINUTE FROM a))
+t1e_ps int(3) ABS(?)
+t1f_nm int(3) ABS(MINUTE(a))
+t1f_ps int(3) ABS(?)
+t1e_nm int(3) ROUND(EXTRACT(MINUTE FROM a))
+t1e_ps int(3) ROUND(?)
+t1f_nm int(3) ROUND(MINUTE(a))
+t1f_ps int(3) ROUND(?)
+t1e_nm int(4) -EXTRACT(MINUTE FROM a)
+t1e_ps int(4) -?
+t1f_nm int(3) -MINUTE(a)
+t1f_ps int(3) -?
+t1e_nm int(4) ROUND(EXTRACT(MINUTE FROM a),-1)
+t1e_ps int(4) ROUND(?,-1)
+t1f_nm int(4) ROUND(MINUTE(a),-1)
+t1f_ps int(4) ROUND(?,-1)
+t1e_nm int(4) EXTRACT(MINUTE FROM a)+0
+t1e_ps int(4) ?+0
+t1f_nm int(4) MINUTE(a)+0
+t1f_ps int(4) ?+0
+t1e_nm decimal(4,1) EXTRACT(MINUTE FROM a)+0.0
+t1e_ps decimal(4,1) ?+0.0
+t1f_nm decimal(4,1) MINUTE(a)+0.0
+t1f_ps decimal(4,1) ?+0.0
+t1e_nm varchar(3) CONCAT(EXTRACT(MINUTE FROM a))
+t1e_ps varchar(3) CONCAT(?)
+t1f_nm varchar(2) CONCAT(MINUTE(a))
+t1f_ps varchar(2) CONCAT(?)
+t1e_nm int(3) LEAST(EXTRACT(MINUTE FROM a),EXTRACT(MINUTE FROM a))
+t1e_ps int(3) LEAST(?,?)
+t1f_nm int(3) LEAST(MINUTE(a),MINUTE(a))
+t1f_ps int(3) LEAST(?,?)
+t1e_nm int(3) COALESCE(EXTRACT(MINUTE FROM a))
+t1e_ps int(3) COALESCE(?)
+t1f_nm int(3) COALESCE(MINUTE(a))
+t1f_ps int(3) COALESCE(?)
+t1e_nm int(3) COALESCE(EXTRACT(MINUTE FROM a),CAST(1 AS SIGNED))
+t1e_ps int(3) COALESCE(?,CAST(1 AS SIGNED))
+t1f_nm int(3) COALESCE(MINUTE(a),CAST(1 AS SIGNED))
+t1f_ps int(3) COALESCE(?,CAST(1 AS SIGNED))
+t1e_nm decimal(2,0) COALESCE(EXTRACT(MINUTE FROM a),CAST(1 AS UNSIGNED))
+t1e_ps decimal(2,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1f_nm decimal(2,0) COALESCE(MINUTE(a),CAST(1 AS UNSIGNED))
+t1f_ps decimal(2,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1e_nm int(3) @a:=EXTRACT(MINUTE FROM a)
+t1e_ps int(3) @a:=?
+t1f_nm int(3) @a:=MINUTE(a)
+t1f_ps int(3) @a:=?
+t2e_nm decimal(6,4) AVG(EXTRACT(MINUTE FROM a))
+t2e_ps decimal(6,4) AVG(?)
+t2f_nm decimal(6,4) AVG(MINUTE(a))
+t2f_ps decimal(6,4) AVG(?)
+t2e_nm bigint(3) MIN(EXTRACT(MINUTE FROM a))
+t2e_ps bigint(3) MIN(?)
+t2f_nm bigint(3) MIN(MINUTE(a))
+t2f_ps bigint(3) MIN(?)
+t2e_nm bigint(3) MAX(EXTRACT(MINUTE FROM a))
+t2e_ps bigint(3) MAX(?)
+t2f_nm bigint(3) MAX(MINUTE(a))
+t2f_ps bigint(3) MAX(?)
+t2e_nm mediumtext GROUP_CONCAT(EXTRACT(MINUTE FROM a))
+t2e_ps mediumtext GROUP_CONCAT(?)
+t2f_nm mediumtext GROUP_CONCAT(MINUTE(a))
+t2f_ps mediumtext GROUP_CONCAT(?)
+
+
+# EXTRACT(SECONDS FROM expr) includes the sign for TIME
+# SECONDS(expr) returns the absolute value
+CALL p1('SECOND');
+EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(SECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), SECOND(TIMESTAMP'2001-12-13 10:20:30.999999');
+CALL show_drop;
+TABLE_NAME COLUMN_TYPE COLUMN_NAME
+t1e_nm int(3) EXTRACT(SECOND FROM a)
+t1e_ps int(3) ?
+t1f_nm int(3) SECOND(a)
+t1f_ps int(3) ?
+t1e_nm bigint(20) unsigned CAST(EXTRACT(SECOND FROM a) AS UNSIGNED)
+t1e_ps bigint(20) unsigned CAST(? AS UNSIGNED)
+t1f_nm int(2) unsigned CAST(SECOND(a) AS UNSIGNED)
+t1f_ps int(2) unsigned CAST(? AS UNSIGNED)
+t1e_nm int(3) CAST(EXTRACT(SECOND FROM a) AS SIGNED)
+t1e_ps int(3) CAST(? AS SIGNED)
+t1f_nm int(3) CAST(SECOND(a) AS SIGNED)
+t1f_ps int(3) CAST(? AS SIGNED)
+t1e_nm int(3) ABS(EXTRACT(SECOND FROM a))
+t1e_ps int(3) ABS(?)
+t1f_nm int(3) ABS(SECOND(a))
+t1f_ps int(3) ABS(?)
+t1e_nm int(3) ROUND(EXTRACT(SECOND FROM a))
+t1e_ps int(3) ROUND(?)
+t1f_nm int(3) ROUND(SECOND(a))
+t1f_ps int(3) ROUND(?)
+t1e_nm int(4) -EXTRACT(SECOND FROM a)
+t1e_ps int(4) -?
+t1f_nm int(3) -SECOND(a)
+t1f_ps int(3) -?
+t1e_nm int(4) ROUND(EXTRACT(SECOND FROM a),-1)
+t1e_ps int(4) ROUND(?,-1)
+t1f_nm int(4) ROUND(SECOND(a),-1)
+t1f_ps int(4) ROUND(?,-1)
+t1e_nm int(4) EXTRACT(SECOND FROM a)+0
+t1e_ps int(4) ?+0
+t1f_nm int(4) SECOND(a)+0
+t1f_ps int(4) ?+0
+t1e_nm decimal(4,1) EXTRACT(SECOND FROM a)+0.0
+t1e_ps decimal(4,1) ?+0.0
+t1f_nm decimal(4,1) SECOND(a)+0.0
+t1f_ps decimal(4,1) ?+0.0
+t1e_nm varchar(3) CONCAT(EXTRACT(SECOND FROM a))
+t1e_ps varchar(3) CONCAT(?)
+t1f_nm varchar(2) CONCAT(SECOND(a))
+t1f_ps varchar(2) CONCAT(?)
+t1e_nm int(3) LEAST(EXTRACT(SECOND FROM a),EXTRACT(SECOND FROM a))
+t1e_ps int(3) LEAST(?,?)
+t1f_nm int(3) LEAST(SECOND(a),SECOND(a))
+t1f_ps int(3) LEAST(?,?)
+t1e_nm int(3) COALESCE(EXTRACT(SECOND FROM a))
+t1e_ps int(3) COALESCE(?)
+t1f_nm int(3) COALESCE(SECOND(a))
+t1f_ps int(3) COALESCE(?)
+t1e_nm int(3) COALESCE(EXTRACT(SECOND FROM a),CAST(1 AS SIGNED))
+t1e_ps int(3) COALESCE(?,CAST(1 AS SIGNED))
+t1f_nm int(3) COALESCE(SECOND(a),CAST(1 AS SIGNED))
+t1f_ps int(3) COALESCE(?,CAST(1 AS SIGNED))
+t1e_nm decimal(2,0) COALESCE(EXTRACT(SECOND FROM a),CAST(1 AS UNSIGNED))
+t1e_ps decimal(2,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1f_nm decimal(2,0) COALESCE(SECOND(a),CAST(1 AS UNSIGNED))
+t1f_ps decimal(2,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1e_nm int(3) @a:=EXTRACT(SECOND FROM a)
+t1e_ps int(3) @a:=?
+t1f_nm int(3) @a:=SECOND(a)
+t1f_ps int(3) @a:=?
+t2e_nm decimal(6,4) AVG(EXTRACT(SECOND FROM a))
+t2e_ps decimal(6,4) AVG(?)
+t2f_nm decimal(6,4) AVG(SECOND(a))
+t2f_ps decimal(6,4) AVG(?)
+t2e_nm bigint(3) MIN(EXTRACT(SECOND FROM a))
+t2e_ps bigint(3) MIN(?)
+t2f_nm bigint(3) MIN(SECOND(a))
+t2f_ps bigint(3) MIN(?)
+t2e_nm bigint(3) MAX(EXTRACT(SECOND FROM a))
+t2e_ps bigint(3) MAX(?)
+t2f_nm bigint(3) MAX(SECOND(a))
+t2f_ps bigint(3) MAX(?)
+t2e_nm mediumtext GROUP_CONCAT(EXTRACT(SECOND FROM a))
+t2e_ps mediumtext GROUP_CONCAT(?)
+t2f_nm mediumtext GROUP_CONCAT(SECOND(a))
+t2f_ps mediumtext GROUP_CONCAT(?)
+
+
+# EXTRACT(MICROSECONDS FROM expr) includes the sign for TIME
+# MICROSECONDS(expr) returns the absolute value
+CALL p1('MICROSECOND');
+EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999'), EXTRACT(MICROSECOND FROM TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999'), MICROSECOND(TIMESTAMP'2001-12-13 10:20:30.999999');
+CALL show_drop;
+TABLE_NAME COLUMN_TYPE COLUMN_NAME
+t1e_nm int(7) EXTRACT(MICROSECOND FROM a)
+t1e_ps int(7) ?
+t1f_nm int(7) MICROSECOND(a)
+t1f_ps int(7) ?
+t1e_nm bigint(20) unsigned CAST(EXTRACT(MICROSECOND FROM a) AS UNSIGNED)
+t1e_ps bigint(20) unsigned CAST(? AS UNSIGNED)
+t1f_nm int(6) unsigned CAST(MICROSECOND(a) AS UNSIGNED)
+t1f_ps int(6) unsigned CAST(? AS UNSIGNED)
+t1e_nm int(7) CAST(EXTRACT(MICROSECOND FROM a) AS SIGNED)
+t1e_ps int(7) CAST(? AS SIGNED)
+t1f_nm int(7) CAST(MICROSECOND(a) AS SIGNED)
+t1f_ps int(7) CAST(? AS SIGNED)
+t1e_nm int(7) ABS(EXTRACT(MICROSECOND FROM a))
+t1e_ps int(7) ABS(?)
+t1f_nm int(7) ABS(MICROSECOND(a))
+t1f_ps int(7) ABS(?)
+t1e_nm int(7) ROUND(EXTRACT(MICROSECOND FROM a))
+t1e_ps int(7) ROUND(?)
+t1f_nm int(7) ROUND(MICROSECOND(a))
+t1f_ps int(7) ROUND(?)
+t1e_nm int(8) -EXTRACT(MICROSECOND FROM a)
+t1e_ps int(8) -?
+t1f_nm int(7) -MICROSECOND(a)
+t1f_ps int(7) -?
+t1e_nm int(8) ROUND(EXTRACT(MICROSECOND FROM a),-1)
+t1e_ps int(8) ROUND(?,-1)
+t1f_nm int(8) ROUND(MICROSECOND(a),-1)
+t1f_ps int(8) ROUND(?,-1)
+t1e_nm int(8) EXTRACT(MICROSECOND FROM a)+0
+t1e_ps int(8) ?+0
+t1f_nm int(8) MICROSECOND(a)+0
+t1f_ps int(8) ?+0
+t1e_nm decimal(8,1) EXTRACT(MICROSECOND FROM a)+0.0
+t1e_ps decimal(8,1) ?+0.0
+t1f_nm decimal(8,1) MICROSECOND(a)+0.0
+t1f_ps decimal(8,1) ?+0.0
+t1e_nm varchar(7) CONCAT(EXTRACT(MICROSECOND FROM a))
+t1e_ps varchar(7) CONCAT(?)
+t1f_nm varchar(6) CONCAT(MICROSECOND(a))
+t1f_ps varchar(6) CONCAT(?)
+t1e_nm int(7) LEAST(EXTRACT(MICROSECOND FROM a),EXTRACT(MICROSECOND FROM a))
+t1e_ps int(7) LEAST(?,?)
+t1f_nm int(7) LEAST(MICROSECOND(a),MICROSECOND(a))
+t1f_ps int(7) LEAST(?,?)
+t1e_nm int(7) COALESCE(EXTRACT(MICROSECOND FROM a))
+t1e_ps int(7) COALESCE(?)
+t1f_nm int(7) COALESCE(MICROSECOND(a))
+t1f_ps int(7) COALESCE(?)
+t1e_nm int(7) COALESCE(EXTRACT(MICROSECOND FROM a),CAST(1 AS SIGNED))
+t1e_ps int(7) COALESCE(?,CAST(1 AS SIGNED))
+t1f_nm int(7) COALESCE(MICROSECOND(a),CAST(1 AS SIGNED))
+t1f_ps int(7) COALESCE(?,CAST(1 AS SIGNED))
+t1e_nm decimal(6,0) COALESCE(EXTRACT(MICROSECOND FROM a),CAST(1 AS UNSIGNED))
+t1e_ps decimal(6,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1f_nm decimal(6,0) COALESCE(MICROSECOND(a),CAST(1 AS UNSIGNED))
+t1f_ps decimal(6,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1e_nm int(7) @a:=EXTRACT(MICROSECOND FROM a)
+t1e_ps int(7) @a:=?
+t1f_nm int(7) @a:=MICROSECOND(a)
+t1f_ps int(7) @a:=?
+t2e_nm decimal(10,4) AVG(EXTRACT(MICROSECOND FROM a))
+t2e_ps decimal(10,4) AVG(?)
+t2f_nm decimal(10,4) AVG(MICROSECOND(a))
+t2f_ps decimal(10,4) AVG(?)
+t2e_nm bigint(7) MIN(EXTRACT(MICROSECOND FROM a))
+t2e_ps bigint(7) MIN(?)
+t2f_nm bigint(7) MIN(MICROSECOND(a))
+t2f_ps bigint(7) MIN(?)
+t2e_nm bigint(7) MAX(EXTRACT(MICROSECOND FROM a))
+t2e_ps bigint(7) MAX(?)
+t2f_nm bigint(7) MAX(MICROSECOND(a))
+t2f_ps bigint(7) MAX(?)
+t2e_nm mediumtext GROUP_CONCAT(EXTRACT(MICROSECOND FROM a))
+t2e_ps mediumtext GROUP_CONCAT(?)
+t2f_nm mediumtext GROUP_CONCAT(MICROSECOND(a))
+t2f_ps mediumtext GROUP_CONCAT(?)
+
+
+# DAYOFYEAR
+CALL p1('DAYOFYEAR');
+EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?' USING DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999');
+EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?)' USING DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999'), DAYOFYEAR(TIMESTAMP'2001-12-13 10:20:30.999999');
+CALL show_drop;
+TABLE_NAME COLUMN_TYPE COLUMN_NAME
+t1f_nm int(4) DAYOFYEAR(a)
+t1f_ps int(4) ?
+t1f_nm int(3) unsigned CAST(DAYOFYEAR(a) AS UNSIGNED)
+t1f_ps int(3) unsigned CAST(? AS UNSIGNED)
+t1f_nm int(4) CAST(DAYOFYEAR(a) AS SIGNED)
+t1f_ps int(4) CAST(? AS SIGNED)
+t1f_nm int(4) ABS(DAYOFYEAR(a))
+t1f_ps int(4) ABS(?)
+t1f_nm int(4) ROUND(DAYOFYEAR(a))
+t1f_ps int(4) ROUND(?)
+t1f_nm int(4) -DAYOFYEAR(a)
+t1f_ps int(4) -?
+t1f_nm int(5) ROUND(DAYOFYEAR(a),-1)
+t1f_ps int(5) ROUND(?,-1)
+t1f_nm int(5) DAYOFYEAR(a)+0
+t1f_ps int(5) ?+0
+t1f_nm decimal(5,1) DAYOFYEAR(a)+0.0
+t1f_ps decimal(5,1) ?+0.0
+t1f_nm varchar(3) CONCAT(DAYOFYEAR(a))
+t1f_ps varchar(3) CONCAT(?)
+t1f_nm int(4) LEAST(DAYOFYEAR(a),DAYOFYEAR(a))
+t1f_ps int(4) LEAST(?,?)
+t1f_nm int(4) COALESCE(DAYOFYEAR(a))
+t1f_ps int(4) COALESCE(?)
+t1f_nm int(4) COALESCE(DAYOFYEAR(a),CAST(1 AS SIGNED))
+t1f_ps int(4) COALESCE(?,CAST(1 AS SIGNED))
+t1f_nm decimal(3,0) COALESCE(DAYOFYEAR(a),CAST(1 AS UNSIGNED))
+t1f_ps decimal(3,0) COALESCE(?,CAST(1 AS UNSIGNED))
+t1f_nm int(4) @a:=DAYOFYEAR(a)
+t1f_ps int(4) @a:=?
+t2f_nm decimal(7,4) AVG(DAYOFYEAR(a))
+t2f_ps decimal(7,4) AVG(?)
+t2f_nm bigint(4) MIN(DAYOFYEAR(a))
+t2f_ps bigint(4) MIN(?)
+t2f_nm bigint(4) MAX(DAYOFYEAR(a))
+t2f_ps bigint(4) MAX(?)
+t2f_nm mediumtext GROUP_CONCAT(DAYOFYEAR(a))
+t2f_ps mediumtext GROUP_CONCAT(?)
+DROP TABLE t1;
+DROP PROCEDURE p1;
+DROP PROCEDURE show_drop;
+DROP FUNCTION params;
+DROP FUNCTION select01;
+DROP FUNCTION select02;
+#
+# End of 10.5 tests
+#
diff --git a/mysql-test/main/func_extract.test b/mysql-test/main/func_extract.test
index 97920f18..dd808443 100644
--- a/mysql-test/main/func_extract.test
+++ b/mysql-test/main/func_extract.test
@@ -263,3 +263,254 @@ SELECT
FROM t1;
DROP TABLE t1;
--enable_view_protocol
+
+
+--echo #
+--echo # Start of 10.5 tests
+--echo #
+
+--echo #
+--echo # MDEV-33496 Out of range error in AVG(YEAR(datetime)) due to a wrong data type
+--echo #
+
+let select01=SELECT ?, CAST(? AS UNSIGNED), CAST(? AS SIGNED), ABS(?), ROUND(?), -?, ROUND(?,-1), ?+0, ?+0.0, CONCAT(?), LEAST(?,?), COALESCE(?), COALESCE(?,CAST(1 AS SIGNED)), COALESCE(?,CAST(1 AS UNSIGNED)), @a:=?;
+let pcount01=16;
+let select02=SELECT AVG(?), MIN(?), MAX(?), GROUP_CONCAT(?);
+let pcount02=4;
+let ts=TIMESTAMP'2001-12-13 10:20:30.999999';
+
+eval CREATE FUNCTION select01() RETURNS TEXT RETURN '$select01';
+eval CREATE FUNCTION select02() RETURNS TEXT RETURN '$select02';
+
+CREATE TABLE t1 (a DATETIME(6));
+INSERT INTO t1 VALUES ('2001-12-31 10:20:30.999999');
+
+DELIMITER $$;
+CREATE FUNCTION params(expr TEXT, count INT) RETURNS TEXT
+BEGIN
+ RETURN CONCAT(expr, REPEAT(CONCAT(', ', expr), count-1));
+END;
+$$
+CREATE PROCEDURE show_drop()
+BEGIN
+ SELECT TABLE_NAME, COLUMN_TYPE, COLUMN_NAME
+ FROM INFORMATION_SCHEMA.COLUMNS
+ WHERE TABLE_SCHEMA='test'
+ AND TABLE_NAME IN ('t1e_nm','t2e_nm','t1f_nm','t2f_nm',
+ 't1e_ps','t1f_ps','t2e_ps','t2f_ps')
+ ORDER BY LEFT(TABLE_NAME, 2), ORDINAL_POSITION, TABLE_NAME;
+
+ FOR rec IN (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES
+ WHERE TABLE_SCHEMA='test'
+ AND TABLE_NAME IN ('t1e_nm','t2e_nm','t1f_nm','t2f_nm',
+ 't1e_ps','t1f_ps','t2e_ps','t2f_ps'))
+ DO
+ EXECUTE IMMEDIATE CONCAT('DROP TABLE ', rec.TABLE_NAME);
+ END FOR;
+END;
+$$
+CREATE PROCEDURE p1(unit VARCHAR(32))
+BEGIN
+ DECLARE do_extract BOOL DEFAULT unit NOT IN('DAYOFYEAR');
+
+ DECLARE query01 TEXT DEFAULT
+ CONCAT('CREATE TABLE t2 AS ', select01(), ' FROM t1');
+
+ DECLARE query02 TEXT DEFAULT
+ CONCAT('CREATE TABLE t2 AS ', select02(), ' FROM t1');
+
+ IF (do_extract)
+ THEN
+ EXECUTE IMMEDIATE REPLACE(REPLACE(query01,'t2','t1e_nm'),'?', CONCAT('EXTRACT(',unit,' FROM a)'));
+ EXECUTE IMMEDIATE REPLACE(REPLACE(query02,'t2','t2e_nm'),'?', CONCAT('EXTRACT(',unit,' FROM a)'));
+ END IF;
+ EXECUTE IMMEDIATE REPLACE(REPLACE(query01,'t2','t1f_nm'),'?', CONCAT(unit,'(a)'));
+ EXECUTE IMMEDIATE REPLACE(REPLACE(query02,'t2','t2f_nm'),'?', CONCAT(unit,'(a)'));
+END;
+$$
+DELIMITER ;$$
+
+
+--echo
+--echo
+--echo # EXTRACT(YEAR FROM expr) and YEAR(expr) are equivalent
+
+CALL p1('YEAR');
+let extr=EXTRACT(YEAR FROM $ts);
+let func=YEAR($ts);
+let extr01=`SELECT params("$extr", $pcount01) AS p`;
+let func01=`SELECT params("$func", $pcount01) AS p`;
+let extr02=`SELECT params("$extr", $pcount02) AS p`;
+let func02=`SELECT params("$func", $pcount02) AS p`;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS $select01' USING $extr01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS $select01' USING $func01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS $select02' USING $extr02;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS $select02' USING $func02;
+CALL show_drop;
+
+
+--echo
+--echo
+--echo # EXTRACT(QUARTER FROM expr) and QUARTER(expr) are equavalent
+
+CALL p1('QUARTER');
+let extr=EXTRACT(QUARTER FROM $ts);
+let func=QUARTER($ts);
+let extr01=`SELECT params("$extr", $pcount01) AS p`;
+let func01=`SELECT params("$func", $pcount01) AS p`;
+let extr02=`SELECT params("$extr", $pcount02) AS p`;
+let func02=`SELECT params("$func", $pcount02) AS p`;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS $select01' USING $extr01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS $select01' USING $func01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS $select02' USING $extr02;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS $select02' USING $func02;
+CALL show_drop;
+
+--echo
+--echo
+--echo # EXTRACT(MONTH FROM expr) and MONTH(expr) are equavalent
+
+CALL p1('MONTH');
+let extr=EXTRACT(MONTH FROM $ts);
+let func=MONTH($ts);
+let extr01=`SELECT params("$extr", $pcount01) AS p`;
+let func01=`SELECT params("$func", $pcount01) AS p`;
+let extr02=`SELECT params("$extr", $pcount02) AS p`;
+let func02=`SELECT params("$func", $pcount02) AS p`;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS $select01' USING $extr01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS $select01' USING $func01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS $select02' USING $extr02;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS $select02' USING $func02;
+CALL show_drop;
+
+--echo
+--echo
+--echo # EXTRACT(WEEK FROM expr) and WEEK(expr) are equavalent
+
+CALL p1('WEEK');
+let extr=EXTRACT(WEEK FROM $ts);
+let func=WEEK($ts);
+let extr01=`SELECT params("$extr", $pcount01) AS p`;
+let func01=`SELECT params("$func", $pcount01) AS p`;
+let extr02=`SELECT params("$extr", $pcount02) AS p`;
+let func02=`SELECT params("$func", $pcount02) AS p`;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS $select01' USING $extr01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS $select01' USING $func01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS $select02' USING $extr02;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS $select02' USING $func02;
+CALL show_drop;
+
+--echo
+--echo
+--echo # EXTRACT(DAY FROM expr) returns hours/24 and includes the sign for TIME
+--echo # DAY(expr) returns the DD part of CAST(expr AS DATETIME)
+
+CALL p1('DAY');
+let extr=EXTRACT(DAY FROM $ts);
+let func=DAY($ts);
+let extr01=`SELECT params("$extr", $pcount01) AS p`;
+let func01=`SELECT params("$func", $pcount01) AS p`;
+let extr02=`SELECT params("$extr", $pcount02) AS p`;
+let func02=`SELECT params("$func", $pcount02) AS p`;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS $select01' USING $extr01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS $select01' USING $func01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS $select02' USING $extr02;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS $select02' USING $func02;
+CALL show_drop;
+
+--echo
+--echo
+--echo # EXTRACT(HOUR FROM expr) returns hours%24 and includes the sign for TIME
+--echo # HOUR(expr) returns the hh part of CAST(expr AS DATETIME)
+
+CALL p1('HOUR');
+let extr=EXTRACT(HOUR FROM $ts);
+let func=HOUR($ts);
+let extr01=`SELECT params("$extr", $pcount01) AS p`;
+let func01=`SELECT params("$func", $pcount01) AS p`;
+let extr02=`SELECT params("$extr", $pcount02) AS p`;
+let func02=`SELECT params("$func", $pcount02) AS p`;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS $select01' USING $extr01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS $select01' USING $func01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS $select02' USING $extr02;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS $select02' USING $func02;
+CALL show_drop;
+
+--echo
+--echo
+--echo # EXTRACT(MINUTE FROM expr) includes the sign for TIME
+--echo # MINUTE(expr) returns the absolute value
+
+CALL p1('MINUTE');
+let extr=EXTRACT(MINUTE FROM $ts);
+let func=MINUTE($ts);
+let extr01=`SELECT params("$extr", $pcount01) AS p`;
+let func01=`SELECT params("$func", $pcount01) AS p`;
+let extr02=`SELECT params("$extr", $pcount02) AS p`;
+let func02=`SELECT params("$func", $pcount02) AS p`;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS $select01' USING $extr01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS $select01' USING $func01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS $select02' USING $extr02;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS $select02' USING $func02;
+CALL show_drop;
+
+--echo
+--echo
+--echo # EXTRACT(SECONDS FROM expr) includes the sign for TIME
+--echo # SECONDS(expr) returns the absolute value
+
+CALL p1('SECOND');
+let extr=EXTRACT(SECOND FROM $ts);
+let func=SECOND($ts);
+let extr01=`SELECT params("$extr", $pcount01) AS p`;
+let func01=`SELECT params("$func", $pcount01) AS p`;
+let extr02=`SELECT params("$extr", $pcount02) AS p`;
+let func02=`SELECT params("$func", $pcount02) AS p`;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS $select01' USING $extr01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS $select01' USING $func01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS $select02' USING $extr02;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS $select02' USING $func02;
+CALL show_drop;
+
+--echo
+--echo
+--echo # EXTRACT(MICROSECONDS FROM expr) includes the sign for TIME
+--echo # MICROSECONDS(expr) returns the absolute value
+
+CALL p1('MICROSECOND');
+let extr=EXTRACT(MICROSECOND FROM $ts);
+let func=MICROSECOND($ts);
+let extr01=`SELECT params("$extr", $pcount01) AS p`;
+let func01=`SELECT params("$func", $pcount01) AS p`;
+let extr02=`SELECT params("$extr", $pcount02) AS p`;
+let func02=`SELECT params("$func", $pcount02) AS p`;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1e_ps AS $select01' USING $extr01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS $select01' USING $func01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2e_ps AS $select02' USING $extr02;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS $select02' USING $func02;
+CALL show_drop;
+
+--echo
+--echo
+--echo # DAYOFYEAR
+
+CALL p1('DAYOFYEAR');
+let func=DAYOFYEAR($ts);
+let func01=`SELECT params("$func", $pcount01) AS p`;
+let func02=`SELECT params("$func", $pcount02) AS p`;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t1f_ps AS $select01' USING $func01;
+eval EXECUTE IMMEDIATE 'CREATE TABLE t2f_ps AS $select02' USING $func02;
+CALL show_drop;
+
+
+DROP TABLE t1;
+DROP PROCEDURE p1;
+DROP PROCEDURE show_drop;
+DROP FUNCTION params;
+
+DROP FUNCTION select01;
+DROP FUNCTION select02;
+
+--echo #
+--echo # End of 10.5 tests
+--echo #
diff --git a/mysql-test/main/func_gconcat.result b/mysql-test/main/func_gconcat.result
index fea25124..f817a117 100644
--- a/mysql-test/main/func_gconcat.result
+++ b/mysql-test/main/func_gconcat.result
@@ -1443,3 +1443,98 @@ drop table t1;
#
# End of 10.3 tests
#
+#
+# MDEV-31276: Execution of PS from grouping query with join
+# and GROUP_CONCAT set function
+#
+create table t1 (a int, b varchar(20)) engine=myisam;
+create table t2 (a int, c varchar(20)) engine=myisam;
+insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb");
+insert into t2 values (1,"cccccccccc"),(2,"dddddddddd");
+insert into t2 values (1,"eeeeeee"),(2,"fffffff");
+set group_concat_max_len=5;
+select count(*), group_concat(t1.b,t2.c)
+from t1 join t2 on t1.a=t2.a group by t1.a;
+count(*) group_concat(t1.b,t2.c)
+2 aaaaa
+2 bbbbb
+Warnings:
+Warning 1260 Row 1 was cut by GROUP_CONCAT()
+Warning 1260 Row 2 was cut by GROUP_CONCAT()
+explain select count(*), group_concat(t1.b,t2.c)
+from t1 join t2 on t1.a=t2.a group by t1.a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where; Using join buffer (flat, BNL join)
+prepare stmt from "select count(*), group_concat(t1.b,t2.c)
+from t1 join t2 on t1.a=t2.a group by t1.a";
+execute stmt;
+count(*) group_concat(t1.b,t2.c)
+2 aaaaa
+2 bbbbb
+Warnings:
+Warning 1260 Row 1 was cut by GROUP_CONCAT()
+Warning 1260 Row 2 was cut by GROUP_CONCAT()
+execute stmt;
+count(*) group_concat(t1.b,t2.c)
+2 aaaaa
+2 bbbbb
+Warnings:
+Warning 1260 Row 1 was cut by GROUP_CONCAT()
+Warning 1260 Row 2 was cut by GROUP_CONCAT()
+deallocate prepare stmt;
+set join_cache_level=0;
+select count(*), group_concat(t1.b,t2.c)
+from t1 join t2 on t1.a=t2.a group by t1.a;
+count(*) group_concat(t1.b,t2.c)
+2 aaaaa
+2 bbbbb
+Warnings:
+Warning 1260 Row 1 was cut by GROUP_CONCAT()
+Warning 1260 Row 2 was cut by GROUP_CONCAT()
+explain select count(*), group_concat(t1.b,t2.c)
+from t1 join t2 on t1.a=t2.a group by t1.a;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using filesort
+1 SIMPLE t2 ALL NULL NULL NULL NULL 4 Using where
+prepare stmt from "select count(*), group_concat(t1.b,t2.c)
+from t1 join t2 on t1.a=t2.a group by t1.a";
+execute stmt;
+count(*) group_concat(t1.b,t2.c)
+2 aaaaa
+2 bbbbb
+Warnings:
+Warning 1260 Row 1 was cut by GROUP_CONCAT()
+Warning 1260 Row 2 was cut by GROUP_CONCAT()
+execute stmt;
+count(*) group_concat(t1.b,t2.c)
+2 aaaaa
+2 bbbbb
+Warnings:
+Warning 1260 Row 1 was cut by GROUP_CONCAT()
+Warning 1260 Row 2 was cut by GROUP_CONCAT()
+deallocate prepare stmt;
+set join_cache_level=default;
+set group_concat_max_len=default;
+drop table t1,t2;
+#
+# MDEV-33772 Bad SEPARATOR value in GROUP_CONCAT on character set conversion
+#
+SET NAMES utf8, @@collation_connection=latin1_swedish_ci;
+CREATE TABLE t1 (c VARCHAR(10)) CHARACTER SET latin1;
+INSERT INTO t1 VALUES ('a'),('A');
+CREATE OR REPLACE VIEW v1 AS
+SELECT GROUP_CONCAT(c SEPARATOR 'ß') AS c1 FROM t1 GROUP BY c;
+SELECT * FROM v1;
+c1
+aßA
+SELECT HEX(c1) FROM v1;
+HEX(c1)
+61DF41
+SHOW CREATE VIEW v1;
+View Create View character_set_client collation_connection
+v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select group_concat(`t1`.`c` separator 'ß') AS `c1` from `t1` group by `t1`.`c` utf8mb3 latin1_swedish_ci
+DROP VIEW v1;
+DROP TABLE t1;
+SET NAMES latin1;
+# End of 10.5 tests
diff --git a/mysql-test/main/func_gconcat.test b/mysql-test/main/func_gconcat.test
index cc5236a1..c9787ce4 100644
--- a/mysql-test/main/func_gconcat.test
+++ b/mysql-test/main/func_gconcat.test
@@ -1066,3 +1066,59 @@ drop table t1;
--echo #
--echo # End of 10.3 tests
--echo #
+
+--echo #
+--echo # MDEV-31276: Execution of PS from grouping query with join
+--echo # and GROUP_CONCAT set function
+--echo #
+
+create table t1 (a int, b varchar(20)) engine=myisam;
+create table t2 (a int, c varchar(20)) engine=myisam;
+insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb");
+insert into t2 values (1,"cccccccccc"),(2,"dddddddddd");
+insert into t2 values (1,"eeeeeee"),(2,"fffffff");
+
+let $q=
+select count(*), group_concat(t1.b,t2.c)
+ from t1 join t2 on t1.a=t2.a group by t1.a;
+
+set group_concat_max_len=5;
+
+eval $q;
+eval explain $q;
+eval prepare stmt from "$q";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+set join_cache_level=0;
+
+eval $q;
+eval explain $q;
+eval prepare stmt from "$q";
+execute stmt;
+execute stmt;
+deallocate prepare stmt;
+
+set join_cache_level=default;
+set group_concat_max_len=default;
+
+drop table t1,t2;
+
+--echo #
+--echo # MDEV-33772 Bad SEPARATOR value in GROUP_CONCAT on character set conversion
+--echo #
+
+SET NAMES utf8, @@collation_connection=latin1_swedish_ci;
+CREATE TABLE t1 (c VARCHAR(10)) CHARACTER SET latin1;
+INSERT INTO t1 VALUES ('a'),('A');
+CREATE OR REPLACE VIEW v1 AS
+ SELECT GROUP_CONCAT(c SEPARATOR 'ß') AS c1 FROM t1 GROUP BY c;
+SELECT * FROM v1;
+SELECT HEX(c1) FROM v1;
+SHOW CREATE VIEW v1;
+DROP VIEW v1;
+DROP TABLE t1;
+SET NAMES latin1;
+
+--echo # End of 10.5 tests
diff --git a/mysql-test/main/func_hybrid_type.result b/mysql-test/main/func_hybrid_type.result
index bf965a9f..e6c08dab 100644
--- a/mysql-test/main/func_hybrid_type.result
+++ b/mysql-test/main/func_hybrid_type.result
@@ -4313,5 +4313,30 @@ ERROR HY000: Illegal parameter data types bigint unsigned and row for operation
SELECT @@max_allowed_packet=ROW(1,1);
ERROR HY000: Illegal parameter data types bigint unsigned and row for operation '='
#
+# MDEV-21034 GREATEST() and LEAST() malfunction for NULL
+#
+SELECT 5 AS c1 FROM dual WHERE GREATEST(1, NULL);
+c1
+SELECT 5 AS c1 FROM dual WHERE LEAST(1, NULL);
+c1
+CREATE TABLE t0 (c0 INT);
+INSERT INTO t0 VALUES (1);
+SELECT * FROM t0 WHERE GREATEST(c0, NULL);
+c0
+SELECT * FROM t0 WHERE LEAST(c0, NULL);
+c0
+DROP TABLE t0;
+SELECT 5 AS c1 FROM dual WHERE GREATEST(1e0, NULL);
+c1
+SELECT 5 AS c1 FROM dual WHERE LEAST(1e0, NULL);
+c1
+CREATE TABLE t0 (c0 DOUBLE);
+INSERT INTO t0 VALUES (1);
+SELECT * FROM t0 WHERE GREATEST(c0, NULL);
+c0
+SELECT * FROM t0 WHERE LEAST(c0, NULL);
+c0
+DROP TABLE t0;
+#
# End of 10.5 tests
#
diff --git a/mysql-test/main/func_hybrid_type.test b/mysql-test/main/func_hybrid_type.test
index 508cdcfb..2ebfb3cf 100644
--- a/mysql-test/main/func_hybrid_type.test
+++ b/mysql-test/main/func_hybrid_type.test
@@ -1116,5 +1116,28 @@ SELECT 0x20+ROW(1,1);
SELECT @@max_allowed_packet=ROW(1,1);
--echo #
+--echo # MDEV-21034 GREATEST() and LEAST() malfunction for NULL
+--echo #
+
+SELECT 5 AS c1 FROM dual WHERE GREATEST(1, NULL);
+SELECT 5 AS c1 FROM dual WHERE LEAST(1, NULL);
+
+CREATE TABLE t0 (c0 INT);
+INSERT INTO t0 VALUES (1);
+SELECT * FROM t0 WHERE GREATEST(c0, NULL);
+SELECT * FROM t0 WHERE LEAST(c0, NULL);
+DROP TABLE t0;
+
+SELECT 5 AS c1 FROM dual WHERE GREATEST(1e0, NULL);
+SELECT 5 AS c1 FROM dual WHERE LEAST(1e0, NULL);
+
+CREATE TABLE t0 (c0 DOUBLE);
+INSERT INTO t0 VALUES (1);
+SELECT * FROM t0 WHERE GREATEST(c0, NULL);
+SELECT * FROM t0 WHERE LEAST(c0, NULL);
+DROP TABLE t0;
+
+
+--echo #
--echo # End of 10.5 tests
--echo #
diff --git a/mysql-test/main/func_in.result b/mysql-test/main/func_in.result
index b3865bab..1ddb5257 100644
--- a/mysql-test/main/func_in.result
+++ b/mysql-test/main/func_in.result
@@ -971,6 +971,84 @@ c1
9223372036854775808
drop table `a`;
#
+# MDEV-18319 BIGINT UNSIGNED Performance issue
+#
+CREATE OR REPLACE TABLE t1 (
+id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY
+);
+FOR i IN 0..255
+DO
+INSERT INTO t1 VALUES ();
+END FOR
+$$
+SELECT MIN(id), MAX(id), COUNT(*) FROM t1;
+MIN(id) MAX(id) COUNT(*)
+1 256 256
+EXPLAIN SELECT id FROM t1 WHERE id IN (1,2);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL 2 Using where; Using index
+EXPLAIN SELECT id FROM t1 WHERE id IN (9223372036854775806, 9223372036854775807);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL 2 Using where; Using index
+EXPLAIN SELECT id FROM t1 WHERE id IN (9223372036854775807, 9223372036854775808);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 8 NULL 2 Using where; Using index
+DROP TABLE t1;
+#
+# MDEV-18898 SELECT using wrong index when using operator IN with mixed types
+#
+CREATE TEMPORARY TABLE t1 (
+id int(10) unsigned NOT NULL AUTO_INCREMENT,
+name varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+PRIMARY KEY (`id`),
+UNIQUE KEY `name` (`name`)
+);
+FOR i IN 1..255
+DO
+INSERT INTO t1 VALUES (i, MD5(i));
+END FOR
+$$
+#
+# Constants alone
+#
+ANALYZE SELECT id, name FROM t1 WHERE id = 1;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 NULL 100.00 NULL
+ANALYZE SELECT id, name FROM t1 WHERE id = '2';
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE t1 const PRIMARY PRIMARY 4 const 1 NULL 100.00 NULL
+#
+# Two constants using IN
+#
+ANALYZE SELECT id, name FROM t1 WHERE id IN (1, 2);
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition
+ANALYZE SELECT id, name FROM t1 WHERE id IN ('1', 2) /* Used a wrong index */;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition
+ANALYZE SELECT id, name FROM t1 WHERE id IN (1, '2') /* Used a wrong index */;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition
+ANALYZE SELECT id, name FROM t1 WHERE id IN ('1', '2');
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition
+#
+# Two constants using OR
+#
+ANALYZE SELECT id, name FROM t1 WHERE id = 1 OR id = 2;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition
+ANALYZE SELECT id, name FROM t1 WHERE id = '1' OR id = '2';
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition
+ANALYZE SELECT id, name FROM t1 WHERE id = 1 OR id = '2';
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition
+ANALYZE SELECT id, name FROM t1 WHERE id = '1' OR id = 2;
+id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
+1 SIMPLE t1 range PRIMARY PRIMARY 4 NULL 2 2.00 100.00 100.00 Using index condition
+DROP TABLE t1;
+#
# End of 10.5 tests
#
#
diff --git a/mysql-test/main/func_in.test b/mysql-test/main/func_in.test
index e39932a2..b88b68f2 100644
--- a/mysql-test/main/func_in.test
+++ b/mysql-test/main/func_in.test
@@ -743,6 +743,66 @@ SELECT c1 FROM a WHERE c1 IN ( 1, 9223372036854775808 );
drop table `a`;
--echo #
+--echo # MDEV-18319 BIGINT UNSIGNED Performance issue
+--echo #
+
+CREATE OR REPLACE TABLE t1 (
+ id bigint(20) unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY
+);
+DELIMITER $$;
+FOR i IN 0..255
+DO
+ INSERT INTO t1 VALUES ();
+END FOR
+$$
+DELIMITER ;$$
+SELECT MIN(id), MAX(id), COUNT(*) FROM t1;
+EXPLAIN SELECT id FROM t1 WHERE id IN (1,2);
+EXPLAIN SELECT id FROM t1 WHERE id IN (9223372036854775806, 9223372036854775807);
+EXPLAIN SELECT id FROM t1 WHERE id IN (9223372036854775807, 9223372036854775808);
+DROP TABLE t1;
+
+
+--echo #
+--echo # MDEV-18898 SELECT using wrong index when using operator IN with mixed types
+--echo #
+
+CREATE TEMPORARY TABLE t1 (
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ name varchar(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+ PRIMARY KEY (`id`),
+ UNIQUE KEY `name` (`name`)
+);
+DELIMITER $$;
+FOR i IN 1..255
+DO
+ INSERT INTO t1 VALUES (i, MD5(i));
+END FOR
+$$
+DELIMITER ;$$
+--echo #
+--echo # Constants alone
+--echo #
+ANALYZE SELECT id, name FROM t1 WHERE id = 1;
+ANALYZE SELECT id, name FROM t1 WHERE id = '2';
+--echo #
+--echo # Two constants using IN
+--echo #
+ANALYZE SELECT id, name FROM t1 WHERE id IN (1, 2);
+ANALYZE SELECT id, name FROM t1 WHERE id IN ('1', 2) /* Used a wrong index */;
+ANALYZE SELECT id, name FROM t1 WHERE id IN (1, '2') /* Used a wrong index */;
+ANALYZE SELECT id, name FROM t1 WHERE id IN ('1', '2');
+--echo #
+--echo # Two constants using OR
+--echo #
+ANALYZE SELECT id, name FROM t1 WHERE id = 1 OR id = 2;
+ANALYZE SELECT id, name FROM t1 WHERE id = '1' OR id = '2';
+ANALYZE SELECT id, name FROM t1 WHERE id = 1 OR id = '2';
+ANALYZE SELECT id, name FROM t1 WHERE id = '1' OR id = 2;
+DROP TABLE t1;
+
+
+--echo #
--echo # End of 10.5 tests
--echo #
diff --git a/mysql-test/main/func_json.result b/mysql-test/main/func_json.result
index ea1767af..268a721a 100644
--- a/mysql-test/main/func_json.result
+++ b/mysql-test/main/func_json.result
@@ -272,7 +272,7 @@ create table t1 as select json_object('id', 87, 'name', 'carrot') as f;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
- `f` varchar(32) DEFAULT NULL
+ `f` varchar(46) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
select * from t1;
f
@@ -1690,6 +1690,33 @@ select json_arrayagg('ä'), json_objectagg(1, 'ä');
json_arrayagg('ä') json_objectagg(1, 'ä')
["ä"] {"1":"ä"}
#
+# MDEV-32287: JSON_EXTRACT not returning multiple values for same path
+#
+select JSON_EXTRACT("[1, 2, [30, 40]]", '$[2][1]', '$[2][1]');
+JSON_EXTRACT("[1, 2, [30, 40]]", '$[2][1]', '$[2][1]')
+[40, 40]
+#
+# MDEV-31402: SIGSEGV in json_get_path_next | Item_func_json_extract::read_json
+#
+CREATE TABLE t (id CHAR AS (JSON_COMPACT (JSON_EXTRACT(doc,"$._id"))) UNIQUE KEY,doc JSON,CONSTRAINT notnu CHECK (id IS NOT NULL));
+INSERT INTO t (doc) VALUES ('{ "_id" : { "$oid" : "0ca0b0f0" },"a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" :0} ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] }');
+ERROR 22001: Data too long for column 'id' at row 1
+DROP TABLE t;
+#
+# MDEV-19487: JSON_TYPE doesnt detect the type of String Values (returns NULL) and for Date/DateTime returns "INTEGER"
+#
+SELECT JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('2019-01-01' as Date) ), '$.date')) as x;
+x
+NULL
+Warnings:
+Warning 4038 Syntax error in JSON text in argument 1 to function 'json_type' at position 5
+#
+# MDEV-22141: JSON_REMOVE returns NULL on valid arguments
+#
+SELECT JSON_REMOVE('{"A": { "B": 1 }}', '$.A.B.C.D');
+JSON_REMOVE('{"A": { "B": 1 }}', '$.A.B.C.D')
+{"A": {"B": 1}}
+#
# End of 10.5 tests
#
#
diff --git a/mysql-test/main/func_json.test b/mysql-test/main/func_json.test
index f8a656c9..54d7d73d 100644
--- a/mysql-test/main/func_json.test
+++ b/mysql-test/main/func_json.test
@@ -87,15 +87,12 @@ select json_extract('[10, 20, [30, 40], 1, 10]', '$[1]') as exp;
select json_extract('[10, 20, [30, 40], 1, 10]', '$[1]', '$[25]') as exp;
select json_extract( '[{"a": [3, 4]}, {"b": 2}]', '$[0].a', '$[1].a') as exp;
-#enable after MDEV-32454 fix
---disable_view_protocol
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.k1', 'word') as exp;
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.d[3]', 3) as exp;
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.a[2]', 2) as exp;
select json_insert('{"a":1, "b":{"c":1}, "d":[1, 2]}', '$.b.c', 'word') as exp;
select json_set('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.c', '[true, false]') as exp;
---enable_view_protocol
select json_replace('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.c', '[true, false]') as exp;
select json_replace('{ "a": 1, "b": [2, 3]}', '$.a', 10, '$.b', '[true, false]') as exp;
@@ -137,14 +134,11 @@ select json_merge('a','b');
select json_merge('{"a":"b"}','{"c":"d"}');
SELECT JSON_MERGE('[1, 2]', '{"id": 47}');
-#enable after MDEV-32454 fix
---disable_view_protocol
select json_type('{"k1":123, "k2":345}');
select json_type('[123, "k2", 345]');
select json_type("true");
select json_type('123');
select json_type('123.12');
---enable_view_protocol
select json_keys('{"a":{"c":1, "d":2}, "b":2}');
select json_keys('{"a":{"c":1, "d":2}, "b":2}', "$.a");
@@ -173,11 +167,8 @@ select json_search( json_col, 'all', 'foot' ) as ex from t1;
drop table t1;
-#enable after MDEV-32454 fix
---disable_view_protocol
select json_unquote('"abc"');
select json_unquote('abc');
---enable_view_protocol
#
# MDEV-13703 Illegal mix of collations for operation 'json_object' on using JSON_UNQUOTE as an argument.
#
@@ -188,13 +179,9 @@ select json_object('foo', json_unquote(json_object('bar', c)),'qux', c) as fld f
drop table t1;
-#enable after MDEV-32454 fix
---disable_view_protocol
select json_object("a", json_object("b", "abcd"));
select json_object("a", '{"b": "abcd"}');
select json_object("a", json_compact('{"b": "abcd"}'));
---enable_view_protocol
-
select json_compact(NULL);
select json_depth(json_compact(NULL));
@@ -270,11 +257,8 @@ select json_merge('{"a":{"u":12, "x":"b"}}', '{"a":{"x":"c"}}') as ex ;
select json_merge('{"a":{"u":12, "x":"b", "r":1}}', '{"a":{"x":"c", "r":2}}') as ex ;
select json_compact('{"a":1, "b":[1,2,3], "c":{"aa":"v1", "bb": "v2"}}') as ex;
-#enable after MDEV-32454 fix
---disable_view_protocol
select json_loose('{"a":1, "b":[1,2,3], "c":{"aa":"v1", "bb": "v2"}}') as ex;
select json_detailed('{"a":1, "b":[1,2,3], "c":{"aa":"v1", "bb": "v2"}}') as ex;
---enable_view_protocol
#
# MDEV-11856 json_search doesn't search for values with double quotes character (")
@@ -469,12 +453,9 @@ drop table t1;
--echo # MDEV-16750 JSON_SET mishandles unicode every second pair of arguments.
--echo #
-#enable after MDEV-32454 fix
---disable_view_protocol
SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6) as exp;
SELECT JSON_SET('{}', '$.a', _utf8 0xC3B6, '$.b', _utf8 0xC3B6) as exp;
SELECT JSON_SET('{}', '$.a', _utf8 X'C3B6', '$.x', 1, '$.b', _utf8 X'C3B6') as exp;
---enable_view_protocol
--echo #
--echo # MDEV-17121 JSON_ARRAY_APPEND
@@ -1137,6 +1118,38 @@ set names latin1;
select json_arrayagg('ä'), json_objectagg(1, 'ä');
--enable_service_connection
+
+--echo #
+--echo # MDEV-32287: JSON_EXTRACT not returning multiple values for same path
+--echo #
+
+select JSON_EXTRACT("[1, 2, [30, 40]]", '$[2][1]', '$[2][1]');
+
+
+--echo #
+--echo # MDEV-31402: SIGSEGV in json_get_path_next | Item_func_json_extract::read_json
+--echo #
+
+CREATE TABLE t (id CHAR AS (JSON_COMPACT (JSON_EXTRACT(doc,"$._id"))) UNIQUE KEY,doc JSON,CONSTRAINT notnu CHECK (id IS NOT NULL));
+--error ER_DATA_TOO_LONG
+INSERT INTO t (doc) VALUES ('{ "_id" : { "$oid" : "0ca0b0f0" },"a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" : [ { "a" :0} ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] } ] }');
+
+DROP TABLE t;
+
+--echo #
+--echo # MDEV-19487: JSON_TYPE doesnt detect the type of String Values (returns NULL) and for Date/DateTime returns "INTEGER"
+--echo #
+
+SELECT JSON_TYPE(json_value(JSON_OBJECT("id", 1, "name", 'Monty', "date", Cast('2019-01-01' as Date) ), '$.date')) as x;
+
+
+--echo #
+--echo # MDEV-22141: JSON_REMOVE returns NULL on valid arguments
+--echo #
+
+SELECT JSON_REMOVE('{"A": { "B": 1 }}', '$.A.B.C.D');
+
+
--echo #
--echo # End of 10.5 tests
--echo #
diff --git a/mysql-test/main/func_json_notembedded.result b/mysql-test/main/func_json_notembedded.result
index 756d2e85..ba4d38dd 100644
--- a/mysql-test/main/func_json_notembedded.result
+++ b/mysql-test/main/func_json_notembedded.result
@@ -10,6 +10,8 @@ select length(@obj), length(@arr);
length(@obj) length(@arr)
5000009 5000009
set max_statement_time=0.0001;
+SET @old_debug= @@debug_dbug;
+SET debug_dbug='+d,debug_max_statement_time exceeded';
select json_array_append(@arr, '$[0]', 1);
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
select json_array_insert(@arr, '$[0]', 1);
@@ -34,6 +36,7 @@ select json_replace(@obj,'$.foo',1);
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
select json_set(@arr,'$[1000]',1);
ERROR 70100: Query execution was interrupted (max_statement_time exceeded)
+SET debug_dbug= @old_debug;
disconnect u;
connection default;
set global max_allowed_packet=default;
diff --git a/mysql-test/main/func_json_notembedded.test b/mysql-test/main/func_json_notembedded.test
index 893b2483..1e05571e 100644
--- a/mysql-test/main/func_json_notembedded.test
+++ b/mysql-test/main/func_json_notembedded.test
@@ -1,6 +1,7 @@
source include/have_profiling.inc;
source include/not_embedded.inc;
source include/no_valgrind_without_big.inc;
+source include/have_debug.inc;
set global max_allowed_packet=1073741824;
connect u,localhost,root;
@@ -16,6 +17,8 @@ select length(@obj), length(@arr);
set max_statement_time=0.0001;
disable_abort_on_error;
+SET @old_debug= @@debug_dbug;
+SET debug_dbug='+d,debug_max_statement_time exceeded';
select json_array_append(@arr, '$[0]', 1);
select json_array_insert(@arr, '$[0]', 1);
select json_insert(@obj, '$.meta', 1);
@@ -29,6 +32,7 @@ select json_remove(@obj,'$.foo');
select json_replace(@obj,'$.foo',1);
select json_set(@arr,'$[1000]',1);
enable_abort_on_error;
+SET debug_dbug= @old_debug;
disconnect u;
connection default;
set global max_allowed_packet=default;
diff --git a/mysql-test/main/func_math.result b/mysql-test/main/func_math.result
index 1c6c780e..5422cae4 100644
--- a/mysql-test/main/func_math.result
+++ b/mysql-test/main/func_math.result
@@ -3711,5 +3711,20 @@ SELECT CRC32(ExtractValue('<a><b/></a>', '/a/b')) AS f;
f
0
#
+# MDEV-33534 UBSAN: Negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_double_round from sql/item_func.cc|
+#
+SELECT TRUNCATE(EXP(-1.e-2),-1.e+30) AS c1;
+c1
+0
+SELECT (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) AS c1;
+c1
+0
+SELECT (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) * (LAST_DAY('1-03-30 1:29:12') MOD 1 + COS(-1)) AS c1;
+c1
+0
+SELECT(ASIN(-1)+ LN(-1)) % (ATAN(-1) MOD FLOOR(1)) * (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) * (LAST_DAY('1-03-30 1:29:12') MOD 1 + COS(-1)) AS c1;
+c1
+NULL
+#
# End of 10.5 tests
#
diff --git a/mysql-test/main/func_math.test b/mysql-test/main/func_math.test
index d4e85393..b32a1a46 100644
--- a/mysql-test/main/func_math.test
+++ b/mysql-test/main/func_math.test
@@ -1981,5 +1981,15 @@ SELECT CRC32(ExtractValue('<a><b/></a>', '/a/b')) AS f;
--echo #
+--echo # MDEV-33534 UBSAN: Negation of -X cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself in my_double_round from sql/item_func.cc|
+--echo #
+
+SELECT TRUNCATE(EXP(-1.e-2),-1.e+30) AS c1;
+SELECT (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) AS c1;
+SELECT (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) * (LAST_DAY('1-03-30 1:29:12') MOD 1 + COS(-1)) AS c1;
+SELECT(ASIN(-1)+ LN(-1)) % (ATAN(-1) MOD FLOOR(1)) * (TRUNCATE(EXP(-1.e-2),-1.e+30) % RADIANS(-1)) * (LAST_DAY('1-03-30 1:29:12') MOD 1 + COS(-1)) AS c1;
+
+
+--echo #
--echo # End of 10.5 tests
--echo #
diff --git a/mysql-test/main/func_regexp.result b/mysql-test/main/func_regexp.result
index b883c818..7a9e24f8 100644
--- a/mysql-test/main/func_regexp.result
+++ b/mysql-test/main/func_regexp.result
@@ -110,7 +110,7 @@ R2
R3
deallocate prepare stmt1;
drop table t1;
-End of 4.1 tests
+# End of 4.1 tests
SELECT 1 REGEXP NULL;
1 REGEXP NULL
NULL
@@ -126,7 +126,7 @@ NULL
SELECT "ABC" REGEXP BINARY NULL;
"ABC" REGEXP BINARY NULL
NULL
-End of 5.0 tests
+# End of 5.0 tests
CREATE TABLE t1(a INT, b CHAR(4));
INSERT INTO t1 VALUES (1, '6.1'), (1, '7.0'), (1, '8.0');
PREPARE stmt1 FROM "SELECT a FROM t1 WHERE a=1 AND '7.0' REGEXP b LIMIT 1";
@@ -144,7 +144,7 @@ a
1
DEALLOCATE PREPARE stmt1;
DROP TABLE t1;
-End of 5.1 tests
+# End of 5.1 tests
SELECT ' ' REGEXP '[[:blank:]]';
' ' REGEXP '[[:blank:]]'
1
@@ -163,3 +163,49 @@ SELECT '\t' REGEXP '[[:space:]]';
SELECT REGEXP_INSTR('111222333',2);
REGEXP_INSTR('111222333',2)
4
+# End of 10.3 tests
+#
+# MDEV-33344 REGEXP empty string inconsistent
+#
+create table t1 (x char(5));
+insert t1 values (''), ('x');
+select 'foo' regexp x from t1 order by x asc;
+'foo' regexp x
+1
+0
+select 'foo' regexp x from t1 order by x desc;
+'foo' regexp x
+0
+1
+drop table t1;
+#
+# MDEV-21076 NOT NULL and UNIQUE constraints cause SUM() to yield an incorrect result
+#
+CREATE TABLE t0(c0 INT NOT NULL, c1 CHAR UNIQUE);
+INSERT INTO t0 VALUES (0, 1);
+INSERT INTO t0 VALUES (0, '');
+SELECT (c1 RLIKE c1), (c0 IS NULL) FROM t0;
+(c1 RLIKE c1) (c0 IS NULL)
+1 0
+1 0
+SELECT SUM(a.t) FROM (SELECT (c1 RLIKE c1) = (c0 IS NULL) as t FROM t0) as a;
+SUM(a.t)
+0
+DROP TABLE t0;
+#
+# MDEV-21058 CREATE TABLE with generated column and RLIKE results in sigabrt
+#
+CREATE TABLE t1 (c0 INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+SELECT ('' RLIKE '[') AS c1 FROM t1;
+ERROR 42000: Regex error 'missing terminating ] for character class at offset 1'
+SELECT REGEXP_INSTR('','[') AS c1 FROM t1;
+ERROR 42000: Regex error 'missing terminating ] for character class at offset 1'
+SELECT c0, '' RLIKE NULL AS c1, REGEXP_INSTR('', NULL) AS c2
+FROM t1 ORDER BY c0;
+c0 c1 c2
+1 NULL NULL
+2 NULL NULL
+3 NULL NULL
+DROP TABLE t1;
+# End of 10.5 tests
diff --git a/mysql-test/main/func_regexp.test b/mysql-test/main/func_regexp.test
index 6d518626..fb441bde 100644
--- a/mysql-test/main/func_regexp.test
+++ b/mysql-test/main/func_regexp.test
@@ -55,7 +55,7 @@ execute stmt1 using @a;
deallocate prepare stmt1;
drop table t1;
---echo End of 4.1 tests
+--echo # End of 4.1 tests
#
@@ -74,7 +74,7 @@ SELECT NULL REGEXP BINARY NULL;
SELECT 'A' REGEXP BINARY NULL;
SELECT "ABC" REGEXP BINARY NULL;
---echo End of 5.0 tests
+--echo # End of 5.0 tests
#
@@ -91,7 +91,7 @@ DEALLOCATE PREPARE stmt1;
DROP TABLE t1;
---echo End of 5.1 tests
+--echo # End of 5.1 tests
#
# MDEV-5820 MySQL Bug #54805 definitions in regex/my_regex.h conflict with /usr/include/regex.h
@@ -110,3 +110,44 @@ SELECT '\t' REGEXP '[[:space:]]';
--echo #
SELECT REGEXP_INSTR('111222333',2);
+--echo # End of 10.3 tests
+
+--echo #
+--echo # MDEV-33344 REGEXP empty string inconsistent
+--echo #
+create table t1 (x char(5));
+insert t1 values (''), ('x');
+select 'foo' regexp x from t1 order by x asc;
+select 'foo' regexp x from t1 order by x desc;
+drop table t1;
+
+--echo #
+--echo # MDEV-21076 NOT NULL and UNIQUE constraints cause SUM() to yield an incorrect result
+--echo #
+
+CREATE TABLE t0(c0 INT NOT NULL, c1 CHAR UNIQUE);
+INSERT INTO t0 VALUES (0, 1);
+INSERT INTO t0 VALUES (0, '');
+SELECT (c1 RLIKE c1), (c0 IS NULL) FROM t0;
+SELECT SUM(a.t) FROM (SELECT (c1 RLIKE c1) = (c0 IS NULL) as t FROM t0) as a;
+DROP TABLE t0;
+
+--echo #
+--echo # MDEV-21058 CREATE TABLE with generated column and RLIKE results in sigabrt
+--echo #
+
+CREATE TABLE t1 (c0 INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+
+--error ER_REGEXP_ERROR
+SELECT ('' RLIKE '[') AS c1 FROM t1;
+
+--error ER_REGEXP_ERROR
+SELECT REGEXP_INSTR('','[') AS c1 FROM t1;
+
+SELECT c0, '' RLIKE NULL AS c1, REGEXP_INSTR('', NULL) AS c2
+FROM t1 ORDER BY c0;
+
+DROP TABLE t1;
+
+--echo # End of 10.5 tests
diff --git a/mysql-test/main/func_sformat.result b/mysql-test/main/func_sformat.result
index 9e8a1167..11825604 100644
--- a/mysql-test/main/func_sformat.result
+++ b/mysql-test/main/func_sformat.result
@@ -23,10 +23,8 @@ select sformat('{} {}', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
-sformat('{} {}', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) as x;
+x
0 0
select sformat('{{{}}}', 0);
sformat('{{{}}}', 0)
@@ -78,10 +76,8 @@ select sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 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);
-sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
- {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
- {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120) as x;
+x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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
@@ -97,10 +93,8 @@ select sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {
'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');
-sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
- {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
- {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
+'115', '116', '117', '118', '119', '120') as x;
+x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 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
@@ -159,8 +153,8 @@ insert into t2 values (0.0025, 25, 'A', DATE('2020-06-29')),
(0.0005, 5, 'B', DATE('2020-6-29')),
(5.5555, -5, 'C', DATE('200629')),
(-9, -9, 'D', DATE('20*06*29'));
-select sformat('p1 {:.4f} p2 {} p3 {} p4 {}', param1, param2, param3, param4) from t2;
-sformat('p1 {:.4f} p2 {} p3 {} p4 {}', param1, param2, param3, param4)
+select sformat('p1 {:.4f} p2 {} p3 {} p4 {}', param1, param2, param3, param4) x from t2;
+x
p1 0.0025 p2 25 p3 A p4 2020-06-29
p1 0.0005 p2 5 p3 B p4 2020-06-29
p1 5.5555 p2 -5 p3 C p4 2020-06-29
@@ -279,14 +273,14 @@ sformat('{: f}; {: f}', 3.14, -3.14)
select sformat('{:-f}; {:-f}', 3.14, -3.14);
sformat('{:-f}; {:-f}', 3.14, -3.14)
3.140000; -3.140000
-select sformat('The temperature is between {: } and {: } degrees celsius.', -3, 7);
-sformat('The temperature is between {: } and {: } degrees celsius.', -3, 7)
+select sformat('The temperature is between {: } and {: } degrees celsius.', -3, 7) x;
+x
The temperature is between -3 and 7 degrees celsius.
-select sformat('The temperature is between {:-} and {:-} degrees celsius.', -3, 7);
-sformat('The temperature is between {:-} and {:-} degrees celsius.', -3, 7)
+select sformat('The temperature is between {:-} and {:-} degrees celsius.', -3, 7) x;
+x
The temperature is between -3 and 7 degrees celsius.
-select sformat('The temperature is between {:+} and {:+} degrees celsius.', -3, 7);
-sformat('The temperature is between {:+} and {:+} degrees celsius.', -3, 7)
+select sformat('The temperature is between {:+} and {:+} degrees celsius.', -3, 7) x;
+x
The temperature is between -3 and +7 degrees celsius.
select sformat('We have {:<8} chickens.', 49);
sformat('We have {:<8} chickens.', 49)
@@ -427,8 +421,8 @@ set names utf8;
select sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442');
sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442')
=теÑÑ‚=
-select hex(sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442'));
-hex(sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442'))
+select hex(sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442')) x;
+x
003D0442043504410442003D
create table t1 as select sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442') as x;
show create table t1;
diff --git a/mysql-test/main/func_sformat.test b/mysql-test/main/func_sformat.test
index 65e4b639..4744229e 100644
--- a/mysql-test/main/func_sformat.test
+++ b/mysql-test/main/func_sformat.test
@@ -14,14 +14,11 @@ select sformat(0);
select sformat('C');
select sformat(-4.2);
select sformat(5, 5, 5);
-#enable after fix MDEV-27871
---disable_view_protocol
select sformat('{} {}', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
---enable_view_protocol
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0) as x;
select sformat('{{{}}}', 0);
select sformat('{{{}{{', 0);
select sformat('{{{{{}{{', 'param1');
@@ -29,18 +26,13 @@ select sformat(' {{ {{ {} {{ ', 'param1');
select sformat(' {{ {} {}', 'param1', 'param2');
select sformat('A{}C{}E{}', 'B', 'D', 'F');
select sformat('{} {}', FALSE, TRUE);
-#enable after fix MDEV-29601
---disable_service_connection
select sformat('Add € != {} != {}?', '$', '£');
select sformat('Check {} != {} != {}?', '€', '$', '£');
---enable_service_connection
select sformat('{}{}{}', 1, 2, 3);
select sformat('Float {} Boolean {} Number {}', 3.14159, True, -50);
select sformat('SUM {} + {} = {}', 2, 3, 2+3);
select sformat('Numbers {} {} {}', 1, 1.11, 1.111);
select sformat('what {} is {}?', 'time', 'it');
-#enable after fix MDEV-27871
---disable_view_protocol
select sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
@@ -49,7 +41,7 @@ select sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 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);
+ 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120) as x;
select sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
@@ -61,8 +53,7 @@ select sformat('{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {
'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');
---enable_view_protocol
+ '115', '116', '117', '118', '119', '120') as x;
echo #;
echo # Error Test Cases;
@@ -92,10 +83,7 @@ insert into t2 values (0.0025, 25, 'A', DATE('2020-06-29')),
(0.0005, 5, 'B', DATE('2020-6-29')),
(5.5555, -5, 'C', DATE('200629')),
(-9, -9, 'D', DATE('20*06*29'));
-#enable after fix MDEV-27871
---disable_view_protocol
-select sformat('p1 {:.4f} p2 {} p3 {} p4 {}', param1, param2, param3, param4) from t2;
---enable_view_protocol
+select sformat('p1 {:.4f} p2 {} p3 {} p4 {}', param1, param2, param3, param4) x from t2;
drop table t2;
set names utf8;
@@ -127,10 +115,7 @@ echo #;
echo # Format Test Cases;
echo #;
select sformat('Num {:L}', 13800000000);
-#enable after fix MDEV-29646
---disable_view_protocol
select sformat('Num [{:20}]', 42);
---enable_view_protocol
select sformat('Number: {:*^{}}', 4, 5);
select sformat('{:02} - {:02} - {:02}', 1, 2, 3);
select sformat('Character {:c}', 104);
@@ -141,10 +126,7 @@ select sformat('Float {:.2f}', 42.0);
select sformat('Float {:f}', 42.0);
select sformat('Number {:d}', 42);
select sformat('Number {:{}}', 5, 5);
-#enable after fix MDEV-29646
---disable_view_protocol
select sformat('Number [{:10}]', 9999);
---enable_view_protocol
select sformat('Number {:.3}', 3.1416);
select sformat('int: {0:d}; hex: {0:x}; oct: {0:o}', 42);
select sformat('int: {0:d}; hex: {0:#x}; oct: {0:#o}', 42);
@@ -155,16 +137,10 @@ select sformat('The binary version of {0} is {0:b}', 5);
select sformat('{:+f}; {:+f}', 3.14, -3.14);
select sformat('{: f}; {: f}', 3.14, -3.14);
select sformat('{:-f}; {:-f}', 3.14, -3.14);
-#enable after fix MDEV-27871
---disable_view_protocol
-select sformat('The temperature is between {: } and {: } degrees celsius.', -3, 7);
-select sformat('The temperature is between {:-} and {:-} degrees celsius.', -3, 7);
-select sformat('The temperature is between {:+} and {:+} degrees celsius.', -3, 7);
---enable_view_protocol
-#check after fix MDEV-29646
---disable_view_protocol
+select sformat('The temperature is between {: } and {: } degrees celsius.', -3, 7) x;
+select sformat('The temperature is between {:-} and {:-} degrees celsius.', -3, 7) x;
+select sformat('The temperature is between {:+} and {:+} degrees celsius.', -3, 7) x;
select sformat('We have {:<8} chickens.', 49);
---enable_view_protocol
select sformat('Center alimgn [{:*^10}]', 'data');
select sformat('Center aling [{:^10}].', 'data');
select sformat('Right aling [{:>10}].', 'data');
@@ -175,20 +151,31 @@ select sformat('Change Order {1} {0}', 'second', 'first');
echo #;
echo # Failed Format Test Cases;
echo #;
+--replace_regex /invalid format specifier/invalid type specifier/
select sformat('Test {:c}', 'word');
select sformat('Test {one} {two} {three}', 1, 2, 3);
select sformat('Number {:{<}', 8);
select sformat('Number {:10000000000}', 5);
select sformat('1={1} 2={2} 0={0}', 0, 1);
+--replace_regex /invalid format specifier/precision not allowed for this argument type/
select sformat('Number {:.2d}', 42);
+--replace_regex /invalid format specifier/invalid type specifier/
select sformat('You scored {:.0%}', 0.25);
+--replace_regex /invalid format specifier/invalid type specifier/
select sformat('You scored {:%}', 0.25);
+--replace_regex /invalid format specifier/invalid type specifier/
select sformat('The price is {:f} dollars.', 45);
+--replace_regex /invalid format specifier/precision not allowed for this argument type/
select sformat('The price is {:.2f} dollars.', 45);
+--replace_regex /invalid format specifier/invalid type specifier/
select sformat('We have {:E} chickens.', 5);
+--replace_regex /invalid format specifier/invalid type specifier/
select sformat('We have {:e} chickens.', 5);
+--replace_regex /invalid format specifier/invalid type specifier/
select sformat('The universe is {:,} years old.', 13800000000);
+--replace_regex /invalid format specifier/invalid type specifier/
select sformat('The universe is {:_} years old.', 13800000000);
+--replace_regex /invalid format specifier/format specifier requires numeric argument/
select sformat('String {:-}', 'hello');
echo #;
@@ -211,6 +198,7 @@ drop table t2;
echo #;
echo # Unsupported/disabled features;
echo #;
+--replace_regex /invalid format specifier/invalid type specifier/
select sformat('{:p}', '50');
echo #;
@@ -219,10 +207,7 @@ echo #;
select sformat('={}=', _ucs2 x'006100620063');
set names utf8;
select sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442');
-#enable after fix MDEV-27871
---disable_view_protocol
-select hex(sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442'));
---enable_view_protocol
+select hex(sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442')) x;
create table t1 as select sformat(_ucs2 x'003D007B007D003D', _ucs2 x'0442043504410442') as x;
show create table t1;
drop table t1;
@@ -233,6 +218,7 @@ echo # ps parameters;
echo #;
prepare s from 'select sformat("={:d}=", ?)';
execute s using 100;
+--replace_regex /invalid format specifier/invalid type specifier/
execute s using 'abc';
echo #;
diff --git a/mysql-test/main/func_str.result b/mysql-test/main/func_str.result
index 0d46453c..20817dba 100644
--- a/mysql-test/main/func_str.result
+++ b/mysql-test/main/func_str.result
@@ -7,7 +7,7 @@ select 'hello',"'hello'",'""hello""','''h''e''l''l''o''',"hel""lo",'hel\'lo';
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
hello 'hello' ""hello"" 'h'e'l'l'o' hel"lo hel'lo
select 'hello' 'monty';
-hello
+hellomonty
hellomonty
select length('\n\t\r\b\0\_\%\\');
length('\n\t\r\b\0\_\%\\')
@@ -5487,3 +5487,37 @@ Warning 1292 Truncated incorrect BINARY(2) value: '...random bytes...'
#
# End of 10.10 tests
#
+#
+# Start of 10.11 tests
+#
+#
+# MDEV-33392 Server crashes when using RANDOM_BYTES function and GROUP BY clause on a column with a negative value
+#
+SET sql_mode='';
+CREATE TABLE t1 (a VARCHAR(255)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (9494),(9495),(9496),(9497),(9498),(9499),(9500),(9501),(9502),(9503);
+SELECT RANDOM_BYTES (-1) f1,a f2 FROM t1 GROUP BY f1,f2;
+f1 f2
+NULL 9494
+NULL 9495
+NULL 9496
+NULL 9497
+NULL 9498
+NULL 9499
+NULL 9500
+NULL 9501
+NULL 9502
+NULL 9503
+CREATE TABLE t2 AS SELECT RANDOM_BYTES (-1) f1,a f2 FROM t1 GROUP BY f1,f2;
+SHOW CREATE TABLE t2;
+Table Create Table
+t2 CREATE TABLE `t2` (
+ `f1` binary(0) DEFAULT NULL,
+ `f2` varchar(255) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+DROP TABLE t2;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+#
+# End of 10.11 tests
+#
diff --git a/mysql-test/main/func_str.test b/mysql-test/main/func_str.test
index e939b21e..b34623d9 100644
--- a/mysql-test/main/func_str.test
+++ b/mysql-test/main/func_str.test
@@ -2457,3 +2457,25 @@ select "a" in ("abc", (convert(random_bytes(8) ,binary(2))));
--echo #
--echo # End of 10.10 tests
--echo #
+
+--echo #
+--echo # Start of 10.11 tests
+--echo #
+
+--echo #
+--echo # MDEV-33392 Server crashes when using RANDOM_BYTES function and GROUP BY clause on a column with a negative value
+--echo #
+
+SET sql_mode='';
+CREATE TABLE t1 (a VARCHAR(255)) ENGINE=MyISAM;
+INSERT INTO t1 VALUES (9494),(9495),(9496),(9497),(9498),(9499),(9500),(9501),(9502),(9503);
+SELECT RANDOM_BYTES (-1) f1,a f2 FROM t1 GROUP BY f1,f2;
+CREATE TABLE t2 AS SELECT RANDOM_BYTES (-1) f1,a f2 FROM t1 GROUP BY f1,f2;
+SHOW CREATE TABLE t2;
+DROP TABLE t2;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+--echo #
+--echo # End of 10.11 tests
+--echo #
diff --git a/mysql-test/main/func_time.result b/mysql-test/main/func_time.result
index 8b21906d..bf7d9748 100644
--- a/mysql-test/main/func_time.result
+++ b/mysql-test/main/func_time.result
@@ -3142,7 +3142,7 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is
def test t1 t1 a a 12 26 26 Y 128 6 63
def EXTRACT(YEAR FROM a) 3 4 4 Y 32896 0 63
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(QUARTER FROM a) 3 1 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 3 2 Y 32896 0 63
@@ -3230,11 +3230,11 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` datetime(6) DEFAULT NULL,
- `EXTRACT(YEAR FROM a)` int(4) DEFAULT NULL,
- `EXTRACT(YEAR_MONTH FROM a)` int(6) DEFAULT NULL,
+ `EXTRACT(YEAR FROM a)` int(5) DEFAULT NULL,
+ `EXTRACT(YEAR_MONTH FROM a)` int(7) DEFAULT NULL,
`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(MONTH FROM a)` int(3) DEFAULT NULL,
+ `EXTRACT(WEEK FROM a)` int(3) 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,
@@ -3281,7 +3281,7 @@ Catalog Database Table Table_alias Column Column_alias Type Length Max length Is
def test t1 t1 a a 11 17 17 Y 128 6 63
def EXTRACT(YEAR FROM a) 3 4 1 Y 32896 0 63
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(QUARTER FROM a) 3 1 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 3 3 Y 32896 0 63
@@ -3411,11 +3411,11 @@ SHOW CREATE TABLE t2;
Table Create Table
t2 CREATE TABLE `t2` (
`a` time(6) DEFAULT NULL,
- `EXTRACT(YEAR FROM a)` int(4) DEFAULT NULL,
- `EXTRACT(YEAR_MONTH FROM a)` int(6) DEFAULT NULL,
+ `EXTRACT(YEAR FROM a)` int(5) DEFAULT NULL,
+ `EXTRACT(YEAR_MONTH FROM a)` int(7) DEFAULT NULL,
`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(MONTH FROM a)` int(3) DEFAULT NULL,
+ `EXTRACT(WEEK FROM a)` int(3) 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,
@@ -6373,3 +6373,57 @@ NULL
SELECT FROM_UNIXTIME(LEAST(3696610869, NULL));
FROM_UNIXTIME(LEAST(3696610869, NULL))
NULL
+#
+# Start of 10.5 tests
+#
+#
+# MDEV-29149 Assertion `!is_valid_datetime() || fraction_remainder(((item->decimals) < (6) ? (item->decimals) : (6))) == 0' failed in Datetime_truncation_not_needed::Datetime_truncation_not_needed
+#
+SET @@timestamp= UNIX_TIMESTAMP('2022-07-21 23:00:00');
+SELECT DATE_SUB('2022-07-21 00:00:00', INTERVAL 800 HOUR) AS expected_result;
+expected_result
+2022-06-17 16:00:00
+SELECT
+IF(1,TIMEDIFF('38:59:59','839:00:00'),CAST('2022-12-12' AS DATE)) AS c1,
+IF(1,TIMEDIFF('-839:00:00','-38:59:59'),CAST('2022-12-12' AS DATE)) AS c2;
+c1 c2
+2022-06-17 16:00:00 2022-06-17 16:00:00
+Warnings:
+Warning 1292 Truncated incorrect time value: '839:00:00'
+Warning 1292 Truncated incorrect time value: '-839:00:00'
+SELECT
+IF(1,TIMEDIFF(385959,8390000),CAST('2022-12-12' AS DATE)) AS c1,
+IF(1,TIMEDIFF(-8390000,-385959),CAST('2022-12-12' AS DATE)) AS c2;
+c1 c2
+2022-06-17 16:00:00 2022-06-17 16:00:00
+Warnings:
+Warning 1292 Truncated incorrect time value: '8390000'
+Warning 1292 Truncated incorrect time value: '-8390000'
+SELECT
+TIMEDIFF('38:59:59','839:00:00') AS c1,
+CAST(TIMEDIFF('38:59:59','839:00:00') AS TIME(6)) AS c2,
+TIMEDIFF('839:00:00','38:59:59') AS c3,
+CAST(TIMEDIFF('839:00:00','38:59:59') AS TIME(6)) AS c4;
+c1 c2 c3 c4
+-800:00:00 -800:00:00.000000 800:00:00 800:00:00.000000
+Warnings:
+Warning 1292 Truncated incorrect time value: '839:00:00'
+Warning 1292 Truncated incorrect time value: '839:00:00'
+Warning 1292 Truncated incorrect time value: '839:00:00'
+Warning 1292 Truncated incorrect time value: '839:00:00'
+SELECT
+TIMEDIFF(385959,8390000) AS c1,
+CAST(TIMEDIFF(385959,8390000) AS TIME(6)) AS c2,
+TIMEDIFF(8390000,385959) AS c3,
+CAST(TIMEDIFF(8390000,385959) AS TIME(6)) AS c4;
+c1 c2 c3 c4
+-800:00:00 -800:00:00.000000 800:00:00 800:00:00.000000
+Warnings:
+Warning 1292 Truncated incorrect time value: '8390000'
+Warning 1292 Truncated incorrect time value: '8390000'
+Warning 1292 Truncated incorrect time value: '8390000'
+Warning 1292 Truncated incorrect time value: '8390000'
+SET @@timestamp= DEFAULT;
+#
+# End of 10.5 tests
+#
diff --git a/mysql-test/main/func_time.test b/mysql-test/main/func_time.test
index fb184ab4..caf6ec1c 100644
--- a/mysql-test/main/func_time.test
+++ b/mysql-test/main/func_time.test
@@ -3218,3 +3218,42 @@ SELECT CONCAT(MAKETIME('01', '01', LEAST( -100, NULL )));
--echo #
SELECT FROM_UNIXTIME(LEAST(3696610869, NULL));
+
+
+--echo #
+--echo # Start of 10.5 tests
+--echo #
+
+--echo #
+--echo # MDEV-29149 Assertion `!is_valid_datetime() || fraction_remainder(((item->decimals) < (6) ? (item->decimals) : (6))) == 0' failed in Datetime_truncation_not_needed::Datetime_truncation_not_needed
+--echo #
+
+SET @@timestamp= UNIX_TIMESTAMP('2022-07-21 23:00:00');
+
+SELECT DATE_SUB('2022-07-21 00:00:00', INTERVAL 800 HOUR) AS expected_result;
+
+SELECT
+ IF(1,TIMEDIFF('38:59:59','839:00:00'),CAST('2022-12-12' AS DATE)) AS c1,
+ IF(1,TIMEDIFF('-839:00:00','-38:59:59'),CAST('2022-12-12' AS DATE)) AS c2;
+
+SELECT
+ IF(1,TIMEDIFF(385959,8390000),CAST('2022-12-12' AS DATE)) AS c1,
+ IF(1,TIMEDIFF(-8390000,-385959),CAST('2022-12-12' AS DATE)) AS c2;
+
+SELECT
+ TIMEDIFF('38:59:59','839:00:00') AS c1,
+ CAST(TIMEDIFF('38:59:59','839:00:00') AS TIME(6)) AS c2,
+ TIMEDIFF('839:00:00','38:59:59') AS c3,
+ CAST(TIMEDIFF('839:00:00','38:59:59') AS TIME(6)) AS c4;
+
+SELECT
+ TIMEDIFF(385959,8390000) AS c1,
+ CAST(TIMEDIFF(385959,8390000) AS TIME(6)) AS c2,
+ TIMEDIFF(8390000,385959) AS c3,
+ CAST(TIMEDIFF(8390000,385959) AS TIME(6)) AS c4;
+
+SET @@timestamp= DEFAULT;
+
+--echo #
+--echo # End of 10.5 tests
+--echo #
diff --git a/mysql-test/main/function_defaults.result b/mysql-test/main/function_defaults.result
index d53e929c..5f5a4c87 100644
--- a/mysql-test/main/function_defaults.result
+++ b/mysql-test/main/function_defaults.result
@@ -3145,3 +3145,28 @@ a b c
2 2010-10-10 10:10:10 x
drop table t1;
set timestamp=default;
+#
+# MDEV-33790: Incorrect DEFAULT expression evaluated in UPDATE
+#
+create table t1 (
+a int,
+b timestamp default '2010-10-10 10:10:10' on update now(),
+c varchar(100) default 'x');
+create table t2 (a int primary key);
+insert t1 (a) values (1),(2);
+insert t2 (a) values (1),(2);
+select * from t1;
+a b c
+1 2010-10-10 10:10:10 x
+2 2010-10-10 10:10:10 x
+set timestamp=unix_timestamp('2011-11-11 11-11-11');
+update t1,t2 set b=default, c=default(b) where t1.a=1 and t1.a= t2.a;
+select * from t1;
+a b c
+1 2010-10-10 10:10:10 2010-10-10 10:10:10
+2 2010-10-10 10:10:10 x
+drop table t1, t2;
+set timestamp=default;
+#
+# End of 10.4 tests
+#
diff --git a/mysql-test/main/function_defaults.test b/mysql-test/main/function_defaults.test
index dd3ba109..59776118 100644
--- a/mysql-test/main/function_defaults.test
+++ b/mysql-test/main/function_defaults.test
@@ -67,3 +67,26 @@ update t1 set b=default, c=default(b) where a=1;
select * from t1;
drop table t1;
set timestamp=default;
+
+--echo #
+--echo # MDEV-33790: Incorrect DEFAULT expression evaluated in UPDATE
+--echo #
+
+create table t1 (
+ a int,
+ b timestamp default '2010-10-10 10:10:10' on update now(),
+ c varchar(100) default 'x');
+create table t2 (a int primary key);
+insert t1 (a) values (1),(2);
+insert t2 (a) values (1),(2);
+
+select * from t1;
+set timestamp=unix_timestamp('2011-11-11 11-11-11');
+update t1,t2 set b=default, c=default(b) where t1.a=1 and t1.a= t2.a;
+select * from t1;
+drop table t1, t2;
+set timestamp=default;
+
+--echo #
+--echo # End of 10.4 tests
+--echo #
diff --git a/mysql-test/main/gis.result b/mysql-test/main/gis.result
index d8d42489..8097c7a8 100644
--- a/mysql-test/main/gis.result
+++ b/mysql-test/main/gis.result
@@ -5072,37 +5072,37 @@ ERROR 42000: Incorrect parameter count in the call to native function 'WITHIN(PO
# MDEV-20009 Add CAST(expr AS pluggable_type)
#
SELECT CAST(1 AS GEOMETRY);
-ERROR HY000: Operator does not exists: 'CAST(expr AS geometry)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS geometry)'
SELECT CAST(1 AS GEOMETRYCOLLECTION);
-ERROR HY000: Operator does not exists: 'CAST(expr AS geometrycollection)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS geometrycollection)'
SELECT CAST(1 AS POINT);
-ERROR HY000: Operator does not exists: 'CAST(expr AS point)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS point)'
SELECT CAST(1 AS LINESTRING);
-ERROR HY000: Operator does not exists: 'CAST(expr AS linestring)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS linestring)'
SELECT CAST(1 AS POLYGON);
-ERROR HY000: Operator does not exists: 'CAST(expr AS polygon)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS polygon)'
SELECT CAST(1 AS MULTIPOINT);
-ERROR HY000: Operator does not exists: 'CAST(expr AS multipoint)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS multipoint)'
SELECT CAST(1 AS MULTILINESTRING);
-ERROR HY000: Operator does not exists: 'CAST(expr AS multilinestring)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS multilinestring)'
SELECT CAST(1 AS MULTIPOLYGON);
-ERROR HY000: Operator does not exists: 'CAST(expr AS multipolygon)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS multipolygon)'
SELECT CONVERT(1, GEOMETRY);
-ERROR HY000: Operator does not exists: 'CAST(expr AS geometry)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS geometry)'
SELECT CONVERT(1, GEOMETRYCOLLECTION);
-ERROR HY000: Operator does not exists: 'CAST(expr AS geometrycollection)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS geometrycollection)'
SELECT CONVERT(1, POINT);
-ERROR HY000: Operator does not exists: 'CAST(expr AS point)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS point)'
SELECT CONVERT(1, LINESTRING);
-ERROR HY000: Operator does not exists: 'CAST(expr AS linestring)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS linestring)'
SELECT CONVERT(1, POLYGON);
-ERROR HY000: Operator does not exists: 'CAST(expr AS polygon)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS polygon)'
SELECT CONVERT(1, MULTIPOINT);
-ERROR HY000: Operator does not exists: 'CAST(expr AS multipoint)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS multipoint)'
SELECT CONVERT(1, MULTILINESTRING);
-ERROR HY000: Operator does not exists: 'CAST(expr AS multilinestring)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS multilinestring)'
SELECT CONVERT(1, MULTIPOLYGON);
-ERROR HY000: Operator does not exists: 'CAST(expr AS multipolygon)'
+ERROR HY000: Operator does not exist: 'CAST(expr AS multipolygon)'
#
# MDEV-17832 Protocol: extensions for Pluggable types and JSON, GEOMETRY
#
diff --git a/mysql-test/main/host_cache_size_functionality.test b/mysql-test/main/host_cache_size_functionality.test
index 9ec26010..f37b2ab8 100644
--- a/mysql-test/main/host_cache_size_functionality.test
+++ b/mysql-test/main/host_cache_size_functionality.test
@@ -43,10 +43,10 @@ select @@global.Host_Cache_Size > 0;
--echo # Restart server with Host_Cache_Size 1
let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
---exec echo "wait" > $restart_file
+--write_line wait $restart_file
--shutdown_server
--source include/wait_until_disconnected.inc
--- exec echo "restart:--host_cache_size=1 " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--write_line "restart:--host_cache_size=1 " $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
-- enable_reconnect
-- source include/wait_until_connected_again.inc
@@ -142,10 +142,10 @@ SELECT Host_Cache_Size = @@SESSION.Host_Cache_Size;
#--remove_file $MYSQL_TMP_DIR/bind_ip
#let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
-#--exec echo "wait" > $restart_file
+#--write_line wait $restart_file
#--shutdown_server
#--source include/wait_until_disconnected.inc
-#-- exec echo "restart:--bind-address=$bind_ip " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+#-- write_line "restart:--bind-address=$bind_ip " $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
#-- enable_reconnect
#-- source include/wait_until_connected_again.inc
diff --git a/mysql-test/main/information_schema2.result b/mysql-test/main/information_schema2.result
index e23e81b8..fa4d71bf 100644
--- a/mysql-test/main/information_schema2.result
+++ b/mysql-test/main/information_schema2.result
@@ -1,3 +1,6 @@
+#
+# MDEV-4029 SELECT on information_schema using a subquery locks up the information_schema table due to incorrect mutexes handling
+#
select variable_name from information_schema.session_status where variable_name =
(select variable_name from information_schema.session_status where variable_name = 'uptime');
variable_name
@@ -6,6 +9,9 @@ select variable_name from information_schema.session_variables where variable_na
(select variable_name from information_schema.session_variables where variable_name = 'basedir');
variable_name
BASEDIR
+#
+# MDEV-8796 Delete with sub query with information_schema.TABLES deletes too many rows
+#
create table t1 (x int);
create table t2 (x int);
create table t3 (x int);
@@ -18,3 +24,15 @@ t2
t3
t4
drop table t1, t2, t3, t4;
+# End of 5.5 tests
+# INFORMATION_SCHEMA.STATISTICS doesn't show if the index is disabled
+create table t1 (a int, key(a));
+select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1';
+index_name comment
+a
+alter table t1 disable keys;
+select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1';
+index_name comment
+a disabled
+drop table t1;
+# End of 10.5 tests
diff --git a/mysql-test/main/information_schema2.test b/mysql-test/main/information_schema2.test
index d2fa3da2..50ceec2c 100644
--- a/mysql-test/main/information_schema2.test
+++ b/mysql-test/main/information_schema2.test
@@ -1,15 +1,15 @@
-#
-# MDEV-4029 SELECT on information_schema using a subquery locks up the information_schema table due to incorrect mutexes handling
-#
+--echo #
+--echo # MDEV-4029 SELECT on information_schema using a subquery locks up the information_schema table due to incorrect mutexes handling
+--echo #
select variable_name from information_schema.session_status where variable_name =
(select variable_name from information_schema.session_status where variable_name = 'uptime');
select variable_name from information_schema.session_variables where variable_name =
(select variable_name from information_schema.session_variables where variable_name = 'basedir');
-#
-# MDEV-8796 Delete with sub query with information_schema.TABLES deletes too many rows
-#
+--echo #
+--echo # MDEV-8796 Delete with sub query with information_schema.TABLES deletes too many rows
+--echo #
create table t1 (x int);
create table t2 (x int);
create table t3 (x int);
@@ -17,3 +17,14 @@ create table t4 AS select table_name from information_schema.TABLES where table_
delete from t4 where table_name not in (select table_name from information_schema.TABLES where table_schema = database() and table_type = 'BASE TABLE');
select * from t4 order by table_name;
drop table t1, t2, t3, t4;
+
+--echo # End of 5.5 tests
+
+--echo # INFORMATION_SCHEMA.STATISTICS doesn't show if the index is disabled
+create table t1 (a int, key(a));
+select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1';
+alter table t1 disable keys;
+select index_name, comment from information_schema.statistics where table_schema='test' and table_name='t1';
+drop table t1;
+
+--echo # End of 10.5 tests
diff --git a/mysql-test/main/init_file_set_password-7656.test b/mysql-test/main/init_file_set_password-7656.test
index 7bca34a0..ac5baa3b 100644
--- a/mysql-test/main/init_file_set_password-7656.test
+++ b/mysql-test/main/init_file_set_password-7656.test
@@ -15,12 +15,12 @@ EOF
--enable_reconnect
---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
---exec echo "restart:--init-file=$MYSQLTEST_VARDIR/init.file " > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--write_line "restart:--init-file=$MYSQLTEST_VARDIR/init.file " $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/wait_until_connected_again.inc
select user,host,password,plugin,authentication_string from mysql.user where user='foo';
diff --git a/mysql-test/main/innodb_ext_key,covering,innodb,on.rdiff b/mysql-test/main/innodb_ext_key,covering,on.rdiff
index 0d8bcc6c..0d8bcc6c 100644
--- a/mysql-test/main/innodb_ext_key,covering,innodb,on.rdiff
+++ b/mysql-test/main/innodb_ext_key,covering,on.rdiff
diff --git a/mysql-test/main/innodb_ext_key,off.rdiff b/mysql-test/main/innodb_ext_key,off.rdiff
index 378c639e..f27df1d0 100644
--- a/mysql-test/main/innodb_ext_key,off.rdiff
+++ b/mysql-test/main/innodb_ext_key,off.rdiff
@@ -163,7 +163,7 @@
where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000
@@ -220,12 +220,12 @@
5959 3
- show status like 'handler_read_next';
+ show /*a*/ status like 'handler_read_next';
Variable_name Value
-Handler_read_next 3
+Handler_read_next 9
@@ -177,7 +177,7 @@
select max(l_orderkey) from lineitem
where l_partkey between 1 and 10 group by l_partkey;
@@ -243,9 +243,9 @@
- show status like 'handler_read%';
+ show /*b*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
-Handler_read_key 21
@@ -199,7 +199,7 @@
select max(l_orderkey) from lineitem
where l_suppkey in (1,4) group by l_suppkey;
@@ -265,9 +265,9 @@
- show status like 'handler_read%';
+ show /*c*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
-Handler_read_key 6
diff --git a/mysql-test/main/innodb_ext_key,innodb,on,unoptimized.rdiff b/mysql-test/main/innodb_ext_key,on,unoptimized.rdiff
index 0d8bcc6c..0d8bcc6c 100644
--- a/mysql-test/main/innodb_ext_key,innodb,on,unoptimized.rdiff
+++ b/mysql-test/main/innodb_ext_key,on,unoptimized.rdiff
diff --git a/mysql-test/main/innodb_ext_key.result b/mysql-test/main/innodb_ext_key.result
index 456513dc..ba91b57a 100644
--- a/mysql-test/main/innodb_ext_key.result
+++ b/mysql-test/main/innodb_ext_key.result
@@ -14,7 +14,7 @@ flush status;
select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01';
count(*)
1
-show status like 'handler_read%';
+show /*1*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
@@ -35,7 +35,7 @@ select count(*) from lineitem use index(primary)
where l_orderkey=130 and l_linenumber=2 and l_shipdate='1992-07-01';
count(*)
1
-show status like 'handler_read%';
+show /*2*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
@@ -56,7 +56,7 @@ select count(*) from lineitem
where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000;
count(*)
1
-show status like 'handler_read%';
+show /*3*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
@@ -79,7 +79,7 @@ l_orderkey l_linenumber
1088 3
1217 1
1221 3
-show status like 'handler_read%';
+show /*4*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
@@ -98,7 +98,7 @@ flush status;
select min(l_orderkey) from lineitem where l_shipdate='1992-07-01';
min(l_orderkey)
130
-show status like 'handler_read%';
+show /*5*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
@@ -119,7 +119,7 @@ select min(l_orderkey) from lineitem
where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000;
min(l_orderkey)
1088
-show status like 'handler_read%';
+show /*6*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
@@ -140,7 +140,7 @@ select max(l_linenumber) from lineitem
where l_shipdate='1992-07-01' and l_orderkey=130;
max(l_linenumber)
2
-show status like 'handler_read%';
+show /*7*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 1
@@ -166,7 +166,7 @@ or l_receiptdate='1992-07-01' and l_orderkey=5603;
l_orderkey l_linenumber
130 2
5603 2
-show status like 'handler_read%';
+show /*8*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 2
@@ -193,7 +193,7 @@ l_orderkey l_linenumber
130 2
5603 2
5959 3
-show status like 'handler_read%';
+show /*9*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 2
@@ -218,7 +218,7 @@ l_orderkey l_linenumber
130 2
5603 2
5959 3
-show status like 'handler_read_next';
+show /*a*/ status like 'handler_read_next';
Variable_name Value
Handler_read_next 3
explain
@@ -240,7 +240,7 @@ max(l_orderkey)
5894
5859
5632
-show status like 'handler_read%';
+show /*b*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 21
@@ -262,7 +262,7 @@ where l_suppkey in (1,4) group by l_suppkey;
max(l_orderkey)
5988
5984
-show status like 'handler_read%';
+show /*c*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 6
@@ -292,7 +292,7 @@ where p_retailprice > 1100 and o_orderdate='1997-01-01'
and o_orderkey=l_orderkey and p_partkey=l_partkey;
o_orderkey p_partkey
5895 200
-show status like 'handler_read%';
+show /*d*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 3
@@ -457,7 +457,7 @@ select * from t1, t2 where t2.a=t1.a and t2.b < 2;
a pk a b
0 0 0 0
1 1 1 1
-show status like 'handler_read%';
+show /*e*/ status like 'handler_read%';
Variable_name Value
Handler_read_first 0
Handler_read_key 10
diff --git a/mysql-test/main/innodb_ext_key.test b/mysql-test/main/innodb_ext_key.test
index abec58a1..3d3a14c8 100644
--- a/mysql-test/main/innodb_ext_key.test
+++ b/mysql-test/main/innodb_ext_key.test
@@ -5,6 +5,8 @@
--source include/innodb_prefix_index_cluster_optimization.inc
--source include/no_valgrind_without_big.inc
+--source include/innodb_stable_estimates.inc
+
SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB';
set @innodb_stats_persistent_save= @@innodb_stats_persistent;
@@ -32,7 +34,7 @@ explain
select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01';
flush status;
select count(*) from lineitem where l_orderkey=130 and l_shipdate='1992-07-01';
-show status like 'handler_read%';
+show /*1*/ status like 'handler_read%';
explain
select count(*) from lineitem use index(primary)
@@ -40,7 +42,7 @@ select count(*) from lineitem use index(primary)
flush status;
select count(*) from lineitem use index(primary)
where l_orderkey=130 and l_linenumber=2 and l_shipdate='1992-07-01';
-show status like 'handler_read%';
+show /*2*/ status like 'handler_read%';
explain
select count(*) from lineitem
@@ -48,7 +50,7 @@ select count(*) from lineitem
flush status;
select count(*) from lineitem
where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000;
-show status like 'handler_read%';
+show /*3*/ status like 'handler_read%';
explain
select l_orderkey, l_linenumber from lineitem
@@ -56,13 +58,13 @@ select l_orderkey, l_linenumber from lineitem
flush status;
select l_orderkey, l_linenumber from lineitem
where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000;
-show status like 'handler_read%';
+show /*4*/ status like 'handler_read%';
explain
select min(l_orderkey) from lineitem where l_shipdate='1992-07-01';
flush status;
select min(l_orderkey) from lineitem where l_shipdate='1992-07-01';
-show status like 'handler_read%';
+show /*5*/ status like 'handler_read%';
explain
select min(l_orderkey) from lineitem
@@ -70,7 +72,7 @@ select min(l_orderkey) from lineitem
flush status;
select min(l_orderkey) from lineitem
where l_shipdate='1992-07-01' and l_orderkey between 1001 and 2000;
-show status like 'handler_read%';
+show /*6*/ status like 'handler_read%';
explain
select max(l_linenumber) from lineitem
@@ -78,7 +80,7 @@ select max(l_linenumber) from lineitem
flush status;
select max(l_linenumber) from lineitem
where l_shipdate='1992-07-01' and l_orderkey=130;
-show status like 'handler_read%';
+show /*7*/ status like 'handler_read%';
explain
select l_orderkey, l_linenumber
@@ -90,7 +92,7 @@ select l_orderkey, l_linenumber
from lineitem use index (i_l_shipdate, i_l_receiptdate)
where l_shipdate='1992-07-01' and l_orderkey=130
or l_receiptdate='1992-07-01' and l_orderkey=5603;
-show status like 'handler_read%';
+show /*8*/ status like 'handler_read%';
--replace_column 7 #
explain
@@ -103,7 +105,7 @@ select l_orderkey, l_linenumber
from lineitem use index (i_l_shipdate, i_l_receiptdate)
where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000
or l_receiptdate='1992-07-01' and l_orderkey between 5001 and 6000;
-show status like 'handler_read%';
+show /*9*/ status like 'handler_read%';
--replace_column 7 # 9 # 10 Using
explain
@@ -114,7 +116,7 @@ flush status;
select l_orderkey, l_linenumber from lineitem
where l_shipdate='1992-07-01' and l_orderkey between 1 and 1000
or l_receiptdate='1992-07-01' and l_orderkey between 5001 and 6000;
-show status like 'handler_read_next';
+show /*a*/ status like 'handler_read_next';
--replace_column 9 #
explain
@@ -123,7 +125,7 @@ select max(l_orderkey) from lineitem
flush status;
select max(l_orderkey) from lineitem
where l_partkey between 1 and 10 group by l_partkey;
-show status like 'handler_read%';
+show /*b*/ status like 'handler_read%';
--replace_column 9 #
explain
@@ -132,7 +134,7 @@ select max(l_orderkey) from lineitem
flush status;
select max(l_orderkey) from lineitem
where l_suppkey in (1,4) group by l_suppkey;
-show status like 'handler_read%';
+show /*c*/ status like 'handler_read%';
create index i_p_retailprice on part(p_retailprice);
@@ -149,7 +151,7 @@ select o_orderkey, p_partkey
lineitem use index (i_l_partkey), orders
where p_retailprice > 1100 and o_orderdate='1997-01-01'
and o_orderkey=l_orderkey and p_partkey=l_partkey;
-show status like 'handler_read%';
+show /*d*/ status like 'handler_read%';
--enable_ps2_protocol
--echo #
@@ -325,7 +327,7 @@ explain
select * from t1, t2 where t2.a=t1.a and t2.b < 2;
flush status;
select * from t1, t2 where t2.a=t1.a and t2.b < 2;
-show status like 'handler_read%';
+show /*e*/ status like 'handler_read%';
--enable_ps2_protocol
drop table t1,t2;
diff --git a/mysql-test/main/insert_select.result b/mysql-test/main/insert_select.result
index 29618c6d..463f571b 100644
--- a/mysql-test/main/insert_select.result
+++ b/mysql-test/main/insert_select.result
@@ -973,7 +973,6 @@ select * from t1;
a
3
1
-2
delete from t1;
insert into t1 values (3), (1);
insert into t1
@@ -984,8 +983,6 @@ select * from t1;
a
3
1
-3
-2
delete from t1;
insert into t1 values (3), (1);
insert into t1
@@ -996,6 +993,7 @@ select * from t1;
a
3
1
+3
2
delete from t1;
insert into t1 values (3), (1);
@@ -1022,7 +1020,6 @@ select * from t1;
a
3
1
-2
delete from t1;
insert into t1 values (3), (1);
execute stmt;
@@ -1030,7 +1027,6 @@ select * from t1;
a
3
1
-2
delete from t1;
insert into t1 values (3), (1);
delete from t1
@@ -1040,6 +1036,8 @@ group by (select * from (select a from t1) dt
where a = 1)));
select * from t1;
a
+3
+1
deallocate prepare stmt;
drop table t1,t2,t3;
#
diff --git a/mysql-test/main/join.result b/mysql-test/main/join.result
index fe195cd8..b5789142 100644
--- a/mysql-test/main/join.result
+++ b/mysql-test/main/join.result
@@ -894,7 +894,7 @@ show status like 'Last_query_cost';
Variable_name Value
Last_query_cost 4.016090
select 'The cost of accessing t1 (dont care if it changes' '^';
-The cost of accessing t1 (dont care if it changes
+The cost of accessing t1 (dont care if it changes^
The cost of accessing t1 (dont care if it changes^
select 'vv: Following query must use ALL(t1), eq_ref(A), eq_ref(B): vv' Z;
Z
@@ -3423,6 +3423,62 @@ SELECT COUNT(*) FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.b = t3.c) ON t1.a = t2.
COUNT(*)
2
DROP TABLE t1, t2, t3;
+#
+# MDEV-30975: Wrong result with cross Join given join order
+#
+CREATE TABLE `t1` (
+`t1_seq` INT NOT NULL,
+`c1` VARCHAR(10) NOT NULL ,
+PRIMARY KEY (`t1_seq`) USING BTREE
+);
+CREATE TABLE `t2` (
+`t2_seq` INT NOT NULL,
+`t1_seq` INT NOT NULL,
+`c2` VARCHAR(10) NOT NULL ,
+PRIMARY KEY (`t2_seq`, `t1_seq`) USING BTREE
+);
+INSERT INTO t1 VALUES(1, 'A');
+INSERT INTO t2 VALUES(1, 1, 'T2-1-1');
+INSERT INTO t2 VALUES(2, 1, 'T2-1-2');
+INSERT INTO t2 VALUES(3, 1, 'T2-1-3');
+SELECT LPAD(@rownum := @rownum + 1, 8, 0) AS str_num
+, t1.t1_seq
+, t2.t2_seq
+, t1.c1
+, t2.c2
+FROM t1
+INNER JOIN t2 ON (t1.t1_seq = t2.t1_seq)
+CROSS JOIN ( SELECT @rownum := 0 ) X;
+str_num t1_seq t2_seq c1 c2
+00000001 1 1 A T2-1-1
+00000002 1 2 A T2-1-2
+00000003 1 3 A T2-1-3
+SELECT STRAIGHT_JOIN LPAD(@rownum := @rownum + 1, 8, 0) AS str_num
+, t1.t1_seq
+, t2.t2_seq
+, t1.c1
+, t2.c2
+FROM t1
+INNER JOIN t2 ON (t1.t1_seq = t2.t1_seq)
+CROSS JOIN ( SELECT @rownum := 0 ) X;
+str_num t1_seq t2_seq c1 c2
+00000001 1 1 A T2-1-1
+00000002 1 2 A T2-1-2
+00000003 1 3 A T2-1-3
+SELECT STRAIGHT_JOIN * FROM t1 JOIN t2 ON (t1.t1_seq = t2.t1_seq) JOIN (SELECT @a := 0) x;
+t1_seq c1 t2_seq t1_seq c2 @a := 0
+1 A 1 1 T2-1-1 0
+1 A 2 1 T2-1-2 0
+1 A 3 1 T2-1-3 0
+SELECT * FROM t1 JOIN t2 ON (t1.t1_seq = t2.t1_seq) JOIN (SELECT @a := 0) x;
+t1_seq c1 t2_seq t1_seq c2 @a := 0
+1 A 1 1 T2-1-1 0
+1 A 2 1 T2-1-2 0
+1 A 3 1 T2-1-3 0
+SELECT STRAIGHT_JOIN c1 FROM t1 JOIN (SELECT @a := 0) x;
+c1
+A
+DROP TABLE t1, t2;
# End of 10.5 tests
#
# MDEV-31449: Assertion s->table->opt_range_condition_rows <= s->found_records
diff --git a/mysql-test/main/join.test b/mysql-test/main/join.test
index a59e53d8..a4d34f41 100644
--- a/mysql-test/main/join.test
+++ b/mysql-test/main/join.test
@@ -1838,6 +1838,52 @@ SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.b = t3.c) ON t1.a = t2.b;
SELECT COUNT(*) FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON t2.b = t3.c) ON t1.a = t2.b;
DROP TABLE t1, t2, t3;
+--echo #
+--echo # MDEV-30975: Wrong result with cross Join given join order
+--echo #
+
+CREATE TABLE `t1` (
+ `t1_seq` INT NOT NULL,
+ `c1` VARCHAR(10) NOT NULL ,
+ PRIMARY KEY (`t1_seq`) USING BTREE
+);
+
+CREATE TABLE `t2` (
+ `t2_seq` INT NOT NULL,
+ `t1_seq` INT NOT NULL,
+ `c2` VARCHAR(10) NOT NULL ,
+ PRIMARY KEY (`t2_seq`, `t1_seq`) USING BTREE
+);
+
+INSERT INTO t1 VALUES(1, 'A');
+INSERT INTO t2 VALUES(1, 1, 'T2-1-1');
+INSERT INTO t2 VALUES(2, 1, 'T2-1-2');
+INSERT INTO t2 VALUES(3, 1, 'T2-1-3');
+
+SELECT LPAD(@rownum := @rownum + 1, 8, 0) AS str_num
+ , t1.t1_seq
+ , t2.t2_seq
+ , t1.c1
+ , t2.c2
+ FROM t1
+ INNER JOIN t2 ON (t1.t1_seq = t2.t1_seq)
+ CROSS JOIN ( SELECT @rownum := 0 ) X;
+
+SELECT STRAIGHT_JOIN LPAD(@rownum := @rownum + 1, 8, 0) AS str_num
+ , t1.t1_seq
+ , t2.t2_seq
+ , t1.c1
+ , t2.c2
+ FROM t1
+ INNER JOIN t2 ON (t1.t1_seq = t2.t1_seq)
+ CROSS JOIN ( SELECT @rownum := 0 ) X;
+
+SELECT STRAIGHT_JOIN * FROM t1 JOIN t2 ON (t1.t1_seq = t2.t1_seq) JOIN (SELECT @a := 0) x;
+SELECT * FROM t1 JOIN t2 ON (t1.t1_seq = t2.t1_seq) JOIN (SELECT @a := 0) x;
+SELECT STRAIGHT_JOIN c1 FROM t1 JOIN (SELECT @a := 0) x;
+
+DROP TABLE t1, t2;
+
--echo # End of 10.5 tests
--echo #
diff --git a/mysql-test/main/join_cache.result b/mysql-test/main/join_cache.result
index b8dddff9..323c4a73 100644
--- a/mysql-test/main/join_cache.result
+++ b/mysql-test/main/join_cache.result
@@ -6401,5 +6401,27 @@ b b d c c
10 NULL NULL NULL NULL
DROP TABLE t1,t2,t3,t4;
#
+# MDEV-21102: Server crashes in JOIN_CACHE::write_record_data upon EXPLAIN with subqueries and constant tables
+#
+CREATE TABLE t1 (a int, b int) ENGINE=MyISAM;
+CREATE TABLE t2 (c int, d int) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,10);
+CREATE TABLE t3 (e int, key (e)) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (2),(3);
+# Must not crash, must use join buffer in subquery
+EXPLAIN
+SELECT * FROM t1
+WHERE a > b OR a IN (
+SELECT c FROM t2 WHERE EXISTS (
+SELECT * FROM t3 t3a JOIN t3 t3b WHERE t3a.e < d
+)
+);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY NULL NULL NULL NULL NULL NULL NULL Impossible WHERE noticed after reading const tables
+2 DEPENDENT SUBQUERY t2 system NULL NULL NULL NULL 1
+3 SUBQUERY t3a range e e 5 NULL 2 Using where; Using index
+3 SUBQUERY t3b index NULL e 5 NULL 2 Using index; Using join buffer (flat, BNL join)
+DROP TABLE t1,t2,t3;
+#
# End of 10.4 tests
#
diff --git a/mysql-test/main/join_cache.test b/mysql-test/main/join_cache.test
index be33d116..4d13a96c 100644
--- a/mysql-test/main/join_cache.test
+++ b/mysql-test/main/join_cache.test
@@ -4305,5 +4305,26 @@ eval $q2;
DROP TABLE t1,t2,t3,t4;
--echo #
+--echo # MDEV-21102: Server crashes in JOIN_CACHE::write_record_data upon EXPLAIN with subqueries and constant tables
+--echo #
+CREATE TABLE t1 (a int, b int) ENGINE=MyISAM;
+
+CREATE TABLE t2 (c int, d int) ENGINE=MyISAM;
+INSERT INTO t2 VALUES (1,10);
+
+CREATE TABLE t3 (e int, key (e)) ENGINE=MyISAM;
+INSERT INTO t3 VALUES (2),(3);
+
+--echo # Must not crash, must use join buffer in subquery
+EXPLAIN
+SELECT * FROM t1
+WHERE a > b OR a IN (
+ SELECT c FROM t2 WHERE EXISTS (
+ SELECT * FROM t3 t3a JOIN t3 t3b WHERE t3a.e < d
+ )
+);
+DROP TABLE t1,t2,t3;
+
+--echo #
--echo # End of 10.4 tests
--echo #
diff --git a/mysql-test/main/join_outer.test b/mysql-test/main/join_outer.test
index 857a9ced..83bb7fde 100644
--- a/mysql-test/main/join_outer.test
+++ b/mysql-test/main/join_outer.test
@@ -685,15 +685,9 @@ create table t1 (a int, b varchar(20));
create table t2 (a int, c varchar(20));
insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb");
insert into t2 values (1,"cccccccccc"),(2,"dddddddddd");
-#Enable after fix MDEV-31276
---disable_ps2_protocol
select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a;
---enable_ps2_protocol
select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a;
-#Enable after fix MDEV-31276
---disable_ps2_protocol
select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by a;
---enable_ps2_protocol
select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by a;
drop table t1, t2;
set group_concat_max_len=default;
@@ -2372,11 +2366,8 @@ create view v1 as select * from t1
left join ( select 'Y' AS Voted, ElectionID from t2 ) AS T
on T.ElectionID = t1.Election
limit 9;
-#enable after fix MDEV-31277
---disable_ps2_protocol
# limit X causes merge algorithm select as opposed to temp table
select * from v1;
---enable_ps2_protocol
drop table t1, t2;
drop view v1;
@@ -2391,10 +2382,7 @@ create view v10 as select *, 'U' as u from t10 left join (select 'Y' as y, t20.b
create table t30 (c int);
insert into t30 values (1),(3);
create view v20 as select * from t30 left join (select 'X' as x, v10.u, v10.y, v10.b from v10) dt2 on t30.c=dt2.b limit 6;
-#check after fix MDEV-31277
---disable_ps2_protocol
select * from v20 limit 9;
---enable_ps2_protocol
drop view v10, v20;
drop table t10, t20, t30;
@@ -2408,8 +2396,6 @@ insert into t3 values (3),(1);
create table t1 (a int);
insert into t1 values (1),(2),(7),(1);
-#check after fix MDEV-31277
---disable_ps2_protocol
select * from
(
select * from
@@ -2422,7 +2408,6 @@ select * from
on dt1.a=dt2.b
limit 9
) dt;
---enable_ps2_protocol
## Same as dt3 above
create view v3(x,c) as select * from (select 'X' as x, t3.c from t3) dt3;
@@ -2436,10 +2421,7 @@ create view v0(y,b,x,c) as select * from v2 left join v3 on v2.b=v3.c;
# Same as above select statement
create view v1 as select 'Z' as z, t1.a, v0.* from t1 left join v0 on t1.a=v0.b limit 9;
-#check after fix MDEV-31277
---disable_ps2_protocol
select * from v1;
---enable_ps2_protocol
set statement join_cache_level=0 for
select * from v1;
diff --git a/mysql-test/main/kill_processlist-6619.test b/mysql-test/main/kill_processlist-6619.test
index c272e68a..0f53034e 100644
--- a/mysql-test/main/kill_processlist-6619.test
+++ b/mysql-test/main/kill_processlist-6619.test
@@ -4,8 +4,18 @@
--source include/not_embedded.inc
--source include/have_debug_sync.inc
+--disable_ps_protocol
+# Ensure no lingering connections from an earlier test run, which can very
+# rarely still be visible in SHOW PROCESSLIST here.
+--let $wait_condition= SELECT COUNT(*) = 1 from information_schema.processlist
+--source include/wait_condition.inc
+
--connect (con1,localhost,root,,)
--let $con_id = `SELECT CONNECTION_ID()`
+
+let $wait_condition=select command = 'sleep' from information_schema.processlist where id != $con_id;
+source include/wait_condition.inc;
+
--replace_result Execute Query
--replace_column 1 # 3 # 6 # 7 #
SHOW PROCESSLIST;
@@ -25,9 +35,7 @@ reap;
SET DEBUG_SYNC='reset';
# Wait until default connection has reset query string
-let $wait_condition=
- SELECT COUNT(*) = 1 from information_schema.processlist
- WHERE info is NULL;
+let $wait_condition=select command = 'sleep' from information_schema.processlist where id != $con_id;
--source include/wait_condition.inc
--replace_result Execute Query
diff --git a/mysql-test/main/load_timezones_with_alter_algorithm_inplace.result b/mysql-test/main/load_timezones_with_alter_algorithm_inplace.result
new file mode 100644
index 00000000..4992e7ed
--- /dev/null
+++ b/mysql-test/main/load_timezones_with_alter_algorithm_inplace.result
@@ -0,0 +1,18 @@
+set global alter_algorithm=INPLACE;
+RENAME TABLE mysql.time_zone TO mysql.time_zone_BACKUP;
+RENAME TABLE mysql.time_zone_name TO mysql.time_zone_name_BACKUP;
+RENAME TABLE mysql.time_zone_transition TO mysql.time_zone_transition_BACKUP;
+RENAME TABLE mysql.time_zone_transition_type TO mysql.time_zone_transition_type_BACKUP;
+CREATE TABLE mysql.time_zone LIKE mysql.time_zone_BACKUP;
+CREATE TABLE mysql.time_zone_name LIKE mysql.time_zone_name_BACKUP;
+CREATE TABLE mysql.time_zone_transition LIKE mysql.time_zone_transition_BACKUP;
+CREATE TABLE mysql.time_zone_transition_type LIKE mysql.time_zone_transition_type_BACKUP;
+DROP TABLE mysql.time_zone;
+DROP TABLE mysql.time_zone_name;
+DROP TABLE mysql.time_zone_transition;
+DROP TABLE mysql.time_zone_transition_type;
+RENAME TABLE mysql.time_zone_BACKUP TO mysql.time_zone;
+RENAME TABLE mysql.time_zone_name_BACKUP TO mysql.time_zone_name;
+RENAME TABLE mysql.time_zone_transition_BACKUP TO mysql.time_zone_transition;
+RENAME TABLE mysql.time_zone_transition_type_BACKUP TO mysql.time_zone_transition_type;
+set global alter_algorithm=DEFAULT;
diff --git a/mysql-test/main/load_timezones_with_alter_algorithm_inplace.test b/mysql-test/main/load_timezones_with_alter_algorithm_inplace.test
new file mode 100644
index 00000000..809f147f
--- /dev/null
+++ b/mysql-test/main/load_timezones_with_alter_algorithm_inplace.test
@@ -0,0 +1,40 @@
+--source include/not_embedded.inc
+
+# MDEV-33044 Loading time zones does not work with alter_algorithm INPLACE
+
+set global alter_algorithm=INPLACE;
+
+# Because loading timezones alters the mysql tables,
+# this test will leave mysql in a different state than when it started.
+# Furthermore, checksums on the various mysql.timezone_x tables will fail.
+
+# Therefore we:
+# 1. Make "backups" of the existing tables by renaming them
+# 2. Make dummy clones of the tables we just backed up
+# 3. Load timezones with alterations made to the dummy clone tables
+# 4. Drop the newly made tables with changes made to them
+# 5. Restore the backed up tables so the checksums will pass
+
+RENAME TABLE mysql.time_zone TO mysql.time_zone_BACKUP;
+RENAME TABLE mysql.time_zone_name TO mysql.time_zone_name_BACKUP;
+RENAME TABLE mysql.time_zone_transition TO mysql.time_zone_transition_BACKUP;
+RENAME TABLE mysql.time_zone_transition_type TO mysql.time_zone_transition_type_BACKUP;
+
+CREATE TABLE mysql.time_zone LIKE mysql.time_zone_BACKUP;
+CREATE TABLE mysql.time_zone_name LIKE mysql.time_zone_name_BACKUP;
+CREATE TABLE mysql.time_zone_transition LIKE mysql.time_zone_transition_BACKUP;
+CREATE TABLE mysql.time_zone_transition_type LIKE mysql.time_zone_transition_type_BACKUP;
+
+--exec $MYSQL_TZINFO_TO_SQL std_data/zoneinfo | $MYSQL mysql
+
+DROP TABLE mysql.time_zone;
+DROP TABLE mysql.time_zone_name;
+DROP TABLE mysql.time_zone_transition;
+DROP TABLE mysql.time_zone_transition_type;
+
+RENAME TABLE mysql.time_zone_BACKUP TO mysql.time_zone;
+RENAME TABLE mysql.time_zone_name_BACKUP TO mysql.time_zone_name;
+RENAME TABLE mysql.time_zone_transition_BACKUP TO mysql.time_zone_transition;
+RENAME TABLE mysql.time_zone_transition_type_BACKUP TO mysql.time_zone_transition_type;
+
+set global alter_algorithm=DEFAULT;
diff --git a/mysql-test/main/lock_sync.result b/mysql-test/main/lock_sync.result
index 2d7a175e..6e665b35 100644
--- a/mysql-test/main/lock_sync.result
+++ b/mysql-test/main/lock_sync.result
@@ -26,28 +26,6 @@ ALWAYS
connect con1, localhost, root,,;
connect con2, localhost, root,,;
connection default;
-drop table if exists t0, t1, t2, t3, t4, t5;
-drop view if exists v1, v2;
-drop procedure if exists p1;
-drop procedure if exists p2;
-drop procedure if exists p3;
-drop function if exists f1;
-drop function if exists f2;
-drop function if exists f3;
-drop function if exists f4;
-drop function if exists f5;
-drop function if exists f6;
-drop function if exists f7;
-drop function if exists f8;
-drop function if exists f9;
-drop function if exists f10;
-drop function if exists f11;
-drop function if exists f12;
-drop function if exists f13;
-drop function if exists f14;
-drop function if exists f15;
-drop function if exists f16;
-drop function if exists f17;
create table t1 (i int primary key);
insert into t1 values (1), (2), (3), (4), (5);
create table t2 (j int primary key);
@@ -900,6 +878,6 @@ set debug_sync= 'now wait_for s1';
SELECT * FROM ( SELECT * FROM v1 ) sq;
COMMIT;
DROP VIEW v1;
-DROP FUNCTION f;
+DROP FUNCTION IF EXISTS f;
DROP TABLE t1, t2;
set debug_sync= 'reset';
diff --git a/mysql-test/main/lock_sync.test b/mysql-test/main/lock_sync.test
index 0d15f845..998c6529 100644
--- a/mysql-test/main/lock_sync.test
+++ b/mysql-test/main/lock_sync.test
@@ -44,30 +44,6 @@ select @@global.concurrent_insert;
connect (con1, localhost, root,,);
connect (con2, localhost, root,,);
connection default;
---disable_warnings
-drop table if exists t0, t1, t2, t3, t4, t5;
-drop view if exists v1, v2;
-drop procedure if exists p1;
-drop procedure if exists p2;
-drop procedure if exists p3;
-drop function if exists f1;
-drop function if exists f2;
-drop function if exists f3;
-drop function if exists f4;
-drop function if exists f5;
-drop function if exists f6;
-drop function if exists f7;
-drop function if exists f8;
-drop function if exists f9;
-drop function if exists f10;
-drop function if exists f11;
-drop function if exists f12;
-drop function if exists f13;
-drop function if exists f14;
-drop function if exists f15;
-drop function if exists f16;
-drop function if exists f17;
---enable_warnings
create table t1 (i int primary key);
insert into t1 values (1), (2), (3), (4), (5);
create table t2 (j int primary key);
@@ -1218,7 +1194,8 @@ COMMIT;
--disconnect con1
--disconnect con2
--connection default
+--source include/wait_until_count_sessions.inc
DROP VIEW v1;
-DROP FUNCTION f;
+DROP FUNCTION IF EXISTS f;
DROP TABLE t1, t2;
set debug_sync= 'reset';
diff --git a/mysql-test/main/lock_view.result b/mysql-test/main/lock_view.result
index 8137300f..e4c666bf 100644
--- a/mysql-test/main/lock_view.result
+++ b/mysql-test/main/lock_view.result
@@ -16,6 +16,7 @@ create definer=definer@localhost view mysqltest3.v3is as select schema_name from
create definer=definer@localhost view mysqltest3.v3ps as select user from performance_schema.users where current_connections>0 order by user;
create definer=definer@localhost view mysqltest3.v3nt as select 1;
create definer=definer@localhost sql security invoker view mysqltest3.v3i as select * from mysqltest1.t1;
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqltest1` /*!40100 DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci */;
@@ -234,6 +235,7 @@ create view v1 as select * from (select * from t1) dt;
lock table v1 read;
disconnect con1;
connection default;
+/*!999999\- enable the sandbox mode */
SET @saved_cs_client = @@character_set_client;
SET character_set_client = utf8;
/*!50001 CREATE VIEW `v1` AS SELECT
diff --git a/mysql-test/main/log_errchk.test b/mysql-test/main/log_errchk.test
index 1afc0e29..c64f6e3c 100644
--- a/mysql-test/main/log_errchk.test
+++ b/mysql-test/main/log_errchk.test
@@ -30,12 +30,12 @@
--echo # Case 2: Starting server with fifo file as general log file
--echo # and slow query log file.
# Restart server with fifo file as general log file.
---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--enable_reconnect
# Write file to make mysql-test-run.pl start up the server again
---exec echo "restart: --general-log-file=$gen_log_file --slow-query-log-file=$slow_query_log_file" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--write_line "restart: --general-log-file=$gen_log_file --slow-query-log-file=$slow_query_log_file" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/wait_until_connected_again.inc
# Error 6 is reported, because the other end is closed
diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result
index b8fbd40b..03d40be8 100644
--- a/mysql-test/main/long_unique_bugs.result
+++ b/mysql-test/main/long_unique_bugs.result
@@ -676,6 +676,59 @@ SELECT * FROM t1;
a b c
3 2 2
DROP TABLE t1;
+# MDEV-30046 wrong row targeted with "insert ... on duplicate" and
+# "replace", leading to data corruption
+create table t (s blob, n int, unique (s)) engine=innodb;
+insert into t values ('Hrecvx_0004ln-00',1), ('Hrecvx_0004mm-00',1);
+replace into t values ('Hrecvx_0004mm-00',2);
+select * from t;
+s n
+Hrecvx_0004ln-00 1
+Hrecvx_0004mm-00 2
+drop table t;
+create table t (s blob, n int, unique (s)) engine=innodb;
+insert into t values ('Hrecvx_0004ln-00',1), ('Hrecvx_0004mm-00',1);
+insert into t values ('Hrecvx_0004mm-00',2)
+on duplicate key update n = values (n);
+select * from t;
+s n
+Hrecvx_0004ln-00 1
+Hrecvx_0004mm-00 2
+drop table t;
#
-# End of 10.5 tests
+# MDEV-29345 update case insensitive (large) unique key with insensitive change of value - duplicate key
#
+create table t1 (a int, b text, unique (b));
+insert ignore t1 values (1, 'a'), (2, 'A');
+Warnings:
+Warning 1062 Duplicate entry 'A' for key 'b'
+select * from t1;
+a b
+1 a
+update t1 set b='A' where a=1;
+select * from t1;
+a b
+1 A
+drop table t1;
+create table t1 (a int, b blob, unique (b));
+insert t1 values (1, 'a'), (2, 'A');
+select * from t1;
+a b
+1 a
+2 A
+update t1 set b='A' where a=1;
+ERROR 23000: Duplicate entry 'A' for key 'b'
+drop table t1;
+#
+# MDEV-25102 UNIQUE USING HASH error after ALTER ... DISABLE KEYS
+#
+create table t1 (i int, unique key (i) using hash);
+alter table t1 disable keys;
+insert into t1 values (1),(2);
+insert into t1 values (1);
+ERROR 23000: Duplicate entry '1' for key 'i'
+alter table t1 enable keys;
+insert into t1 values (2);
+ERROR 23000: Duplicate entry '2' for key 'i'
+drop table t1;
+# End of 10.5 tests
diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test
index 01c3f736..8acb5e9e 100644
--- a/mysql-test/main/long_unique_bugs.test
+++ b/mysql-test/main/long_unique_bugs.test
@@ -503,7 +503,6 @@ start transaction;
alter table tmp alter column a set default 8;
unlock tables;
drop table t2;
---source include/have_innodb.inc
--echo #
--echo # MDEV-22218 InnoDB: Failing assertion: node->pcur->rel_pos == BTR_PCUR_ON upon LOAD DATA with NO_BACKSLASH_ESCAPES in SQL_MODE and unique blob in table
@@ -642,7 +641,6 @@ insert into t1 values (0);
check table t1 extended;
drop table t1;
-
--echo #
--echo # MDEV-32837 long unique does not work like unique key when using replace
--echo #
@@ -655,6 +653,49 @@ REPLACE INTO t1 VALUES (3,2,2);
SELECT * FROM t1;
DROP TABLE t1;
+--echo # MDEV-30046 wrong row targeted with "insert ... on duplicate" and
+--echo # "replace", leading to data corruption
+--source include/have_innodb.inc
+create table t (s blob, n int, unique (s)) engine=innodb;
+insert into t values ('Hrecvx_0004ln-00',1), ('Hrecvx_0004mm-00',1);
+replace into t values ('Hrecvx_0004mm-00',2);
+select * from t;
+drop table t;
+
+create table t (s blob, n int, unique (s)) engine=innodb;
+insert into t values ('Hrecvx_0004ln-00',1), ('Hrecvx_0004mm-00',1);
+insert into t values ('Hrecvx_0004mm-00',2)
+ on duplicate key update n = values (n);
+select * from t;
+drop table t;
--echo #
---echo # End of 10.5 tests
+--echo # MDEV-29345 update case insensitive (large) unique key with insensitive change of value - duplicate key
--echo #
+create table t1 (a int, b text, unique (b));
+insert ignore t1 values (1, 'a'), (2, 'A');
+select * from t1;
+update t1 set b='A' where a=1;
+select * from t1;
+drop table t1;
+
+create table t1 (a int, b blob, unique (b));
+insert t1 values (1, 'a'), (2, 'A');
+select * from t1;
+--error ER_DUP_ENTRY
+update t1 set b='A' where a=1;
+drop table t1;
+
+--echo #
+--echo # MDEV-25102 UNIQUE USING HASH error after ALTER ... DISABLE KEYS
+--echo #
+create table t1 (i int, unique key (i) using hash);
+alter table t1 disable keys;
+insert into t1 values (1),(2);
+--error ER_DUP_ENTRY
+insert into t1 values (1);
+alter table t1 enable keys;
+--error ER_DUP_ENTRY
+insert into t1 values (2);
+drop table t1;
+
+--echo # End of 10.5 tests
diff --git a/mysql-test/main/lowercase_fs_on.test b/mysql-test/main/lowercase_fs_on.test
index 1d306826..9a7fc369 100644
--- a/mysql-test/main/lowercase_fs_on.test
+++ b/mysql-test/main/lowercase_fs_on.test
@@ -16,7 +16,7 @@ let SEARCH_FILE= $MYSQLTEST_VARDIR/log/my_restart.err;
--remove_file $SEARCH_FILE
#Shutdown the server
---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
@@ -30,7 +30,7 @@ let SEARCH_PATTERN= \[ERROR\] The server option \'lower_case_table_names\' is co
--source include/search_pattern_in_file.inc
#Restart the server
---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/wait_until_connected_again.inc
#Cleanup
diff --git a/mysql-test/main/lowercase_table2.result b/mysql-test/main/lowercase_table2.result
index 3a4c46eb..3a4c46eb 100755..100644
--- a/mysql-test/main/lowercase_table2.result
+++ b/mysql-test/main/lowercase_table2.result
diff --git a/mysql-test/main/mdl_sync.result b/mysql-test/main/mdl_sync.result
index 0324c261..c6b80c50 100644
--- a/mysql-test/main/mdl_sync.result
+++ b/mysql-test/main/mdl_sync.result
@@ -2431,6 +2431,9 @@ create table t1 (a int) engine=myisam;
create table t2 (a int) stats_persistent=0, engine=innodb;
insert into t1 values (1);
insert into t2 values (1);
+connect con1, localhost, root;
+start transaction with consistent snapshot;
+connection default;
SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL table_opened WAIT_FOR grlwait execute 2';
update t1,t2 set t1.a=2,t2.a=3;
connection con2;
@@ -2462,6 +2465,7 @@ connection default;
SET DEBUG_SYNC= 'RESET';
drop table t1,t2;
disconnect con2;
+disconnect con1;
#
# Bug#50786 Assertion `thd->mdl_context.trans_sentinel() == __null'
# failed in open_ltable()
diff --git a/mysql-test/main/mdl_sync.test b/mysql-test/main/mdl_sync.test
index 7a928a4c..29d95460 100644
--- a/mysql-test/main/mdl_sync.test
+++ b/mysql-test/main/mdl_sync.test
@@ -3115,6 +3115,12 @@ create table t2 (a int) stats_persistent=0, engine=innodb;
insert into t1 values (1);
insert into t2 values (1);
+connect (con1, localhost, root);
+# disable innodb purge thread, otherwise it might start purging t2,
+# and will take an mdl, affecting metadata_lock_info output.
+start transaction with consistent snapshot;
+connection default;
+
SET DEBUG_SYNC= 'after_open_table_mdl_shared SIGNAL table_opened WAIT_FOR grlwait execute 2';
--send update t1,t2 set t1.a=2,t2.a=3
@@ -3160,6 +3166,7 @@ connection default;
SET DEBUG_SYNC= 'RESET';
drop table t1,t2;
disconnect con2;
+disconnect con1;
--echo #
--echo # Bug#50786 Assertion `thd->mdl_context.trans_sentinel() == __null'
diff --git a/mysql-test/main/myisam.result b/mysql-test/main/myisam.result
index 4d79a851..7d930f1a 100644
--- a/mysql-test/main/myisam.result
+++ b/mysql-test/main/myisam.result
@@ -1,6 +1,5 @@
call mtr.add_suppression("Can't find record in '.*'");
call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired");
-SET SQL_WARNINGS=1;
CREATE TABLE t1 (
STRING_DATA char(255) default NULL,
KEY string_data (STRING_DATA)
diff --git a/mysql-test/main/myisam.test b/mysql-test/main/myisam.test
index ec49e71b..538603c6 100644
--- a/mysql-test/main/myisam.test
+++ b/mysql-test/main/myisam.test
@@ -7,9 +7,6 @@
call mtr.add_suppression("Can't find record in '.*'");
call mtr.add_suppression("Table 't1' is marked as crashed and should be repaired");
-# Initialise
-SET SQL_WARNINGS=1;
-
#
# Test problem with CHECK TABLE;
#
diff --git a/mysql-test/main/myisam_crash_before_flush_keys.test b/mysql-test/main/myisam_crash_before_flush_keys.test
index 791e43b0..c48f2b42 100644
--- a/mysql-test/main/myisam_crash_before_flush_keys.test
+++ b/mysql-test/main/myisam_crash_before_flush_keys.test
@@ -26,14 +26,14 @@ INSERT INTO t1 VALUES (1,2),(2,3),(3,4),(4,5),(5,6);
SET SESSION debug_dbug="d,crash_before_flush_keys";
--echo # Write file to make mysql-test-run.pl expect crash
---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--echo # Run the crashing query
--error 2013
FLUSH TABLE t1;
--echo # Write file to make mysql-test-run.pl start the server
---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--echo # Turn on reconnect
--enable_reconnect
diff --git a/mysql-test/main/mysql-interactive.test b/mysql-test/main/mysql-interactive.test
index 2015e9d6..0051d8e5 100644
--- a/mysql-test/main/mysql-interactive.test
+++ b/mysql-test/main/mysql-interactive.test
@@ -3,6 +3,8 @@
--echo #
source include/not_embedded.inc;
source include/not_windows.inc;
+# this would need an instrumented ncurses library
+source include/not_msan.inc;
error 0,1;
exec $MYSQL -V|grep -q readline;
diff --git a/mysql-test/main/mysql.result b/mysql-test/main/mysql.result
index 0b91b513..ac716b46 100644
--- a/mysql-test/main/mysql.result
+++ b/mysql-test/main/mysql.result
@@ -552,6 +552,7 @@ Table Create Table
a1\`b1 CREATE TABLE `a1\``b1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `a1\``b1` (
@@ -583,6 +584,7 @@ Table Create Table
a1\"b1 CREATE TABLE "a1\""b1" (
"a" int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE "a1\""b1" (
@@ -607,11 +609,11 @@ set sql_mode=default;
create table t1 (a text);
select count(*) from t1;
count(*)
-43
+44
truncate table t1;
select count(*) from t1;
count(*)
-43
+44
truncate table t1;
select count(*) from t1;
count(*)
@@ -623,7 +625,7 @@ count(*)
truncate table t1;
select count(*) from t1;
count(*)
-43
+44
truncate table t1;
select count(*) from t1;
count(*)
@@ -637,3 +639,27 @@ drop table t1;
WARNING: option '--enable-cleartext-plugin' is obsolete.
1
1
+# End of 10.3 tests
+#
+# MDEV-21778 Disable system commands in mysql/mariadb client
+#
+ERROR at line 1: Not allowed in the sandbox mode
+1
+ERROR at line 1: Not allowed in the sandbox mode
+2
+ERROR at line 1: Not allowed in the sandbox mode
+3
+1
+entering sandbox
+system
+tee
+source
+^^^
+2
+entering sandbox
+system
+tee
+source
+^^^
+3
+# End of 10.5 tests
diff --git a/mysql-test/main/mysql.test b/mysql-test/main/mysql.test
index 0f41add8..2f189e70 100644
--- a/mysql-test/main/mysql.test
+++ b/mysql-test/main/mysql.test
@@ -610,6 +610,7 @@ EOF
create database `aa``bb````cc`;
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/backticks.sql
drop database `aa``bb````cc`;
+--remove_file $MYSQLTEST_VARDIR/tmp/backticks.sql
#
# MySQL Bug#13639125 DELIMITER STRIPS THE NEXT NEW LINE IN A SQL STATEMENT
@@ -620,6 +621,7 @@ delimiter
<<" as a;
EOF
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/13639125.sql
+--remove_file $MYSQLTEST_VARDIR/tmp/13639125.sql
#
# --skip-column-names and alignment
@@ -702,7 +704,7 @@ select count(*) from t1; truncate table t1;
--exec $MYSQL --disable-local-infile -e "/*q*/$ldli"
select count(*) from t1; truncate table t1;
drop table t1;
-
+--remove_file $MYSQLTEST_VARDIR/tmp/bug.sql
--echo #
--echo # MDEV-15538 '-N' Produce html output wrong
@@ -716,3 +718,43 @@ drop table t1;
#
--echo
--exec $MYSQL test --enable-cleartext-plugin -e "select 1"
+
+--echo # End of 10.3 tests
+
+--echo #
+--echo # MDEV-21778 Disable system commands in mysql/mariadb client
+--echo #
+
+--error 1
+--exec $MYSQL --sandbox -Ne "select 1; \! echo foo; select 0" 2>&1
+--error 1
+--exec $MYSQL --sandbox -Ne "select 2; \T echo foo; select 0" 2>&1
+--error 1
+--exec $MYSQL --sandbox -Ne "select 3; \. echo.foo; select 0" 2>&1
+
+--write_file $MYSQL_TMP_DIR/mysql_in
+select 'entering sandbox';
+\-
+select 'system';
+\! echo foo
+select 'tee';
+\T echo foo
+select 'source';
+\. echo.foo
+select '^^^';
+EOF
+
+write_line "select 1;
+source $MYSQL_TMP_DIR/mysql_in;
+select 2;
+source $MYSQL_TMP_DIR/mysql_in;
+sandbox;
+select 3;
+source $MYSQL_TMP_DIR/mysql_in;" $MYSQL_TMP_DIR/mysql_in2;
+
+--exec $MYSQL -fN <$MYSQL_TMP_DIR/mysql_in2
+
+--remove_file $MYSQL_TMP_DIR/mysql_in
+--remove_file $MYSQL_TMP_DIR/mysql_in2
+
+--echo # End of 10.5 tests
diff --git a/mysql-test/main/mysql_client_test.result b/mysql-test/main/mysql_client_test.result
index dbc1feaa..dbd5aaea 100644
--- a/mysql-test/main/mysql_client_test.result
+++ b/mysql-test/main/mysql_client_test.result
@@ -261,3 +261,4 @@ SET @@global.character_set_server= @save_character_set_server;
SET @@global.collation_server= @save_collation_server;
SET @@global.character_set_client= @save_character_set_client;
SET @@global.collation_connection= @save_collation_connection;
+FOUND 1 /Aborted connection.*'u' host: '192.0.2.1' real ip: '(localhost|::1)'/ in mysqld.1.err
diff --git a/mysql-test/main/mysql_client_test.test b/mysql-test/main/mysql_client_test.test
index bcb246a8..d620f4c7 100644
--- a/mysql-test/main/mysql_client_test.test
+++ b/mysql-test/main/mysql_client_test.test
@@ -23,7 +23,7 @@ call mtr.add_suppression(" IP address .* could not be resolved");
# server or run mysql-test-run --debug mysql_client_test and check
# var/log/mysql_client_test.trace
---exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1
+--write_line "$MYSQL_CLIENT_TEST" $MYSQLTEST_VARDIR/log/mysql_client_test.out.log
--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1
# End of 4.1 tests
@@ -57,3 +57,9 @@ SET @@global.character_set_server= @save_character_set_server;
SET @@global.collation_server= @save_collation_server;
SET @@global.character_set_client= @save_character_set_client;
SET @@global.collation_connection= @save_collation_connection;
+
+# Search for "real ip" in Aborted message
+# This is indicator for abort of the proxied connections.
+let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err;
+let SEARCH_PATTERN= Aborted connection.*'u' host: '192.0.2.1' real ip: '(localhost|::1)';
+source include/search_pattern_in_file.inc;
diff --git a/mysql-test/main/mysql_client_test_comp.test b/mysql-test/main/mysql_client_test_comp.test
index 36a12b66..f37d82a2 100644
--- a/mysql-test/main/mysql_client_test_comp.test
+++ b/mysql-test/main/mysql_client_test_comp.test
@@ -12,7 +12,7 @@ SET @old_slow_query_log= @@global.slow_query_log;
call mtr.add_suppression(" Error reading file './client_test_db/test_frm_bug.frm'");
call mtr.add_suppression(" IP address .* could not be resolved");
---exec echo "$MYSQL_CLIENT_TEST" > $MYSQLTEST_VARDIR/log/mysql_client_test_comp.out.log 2>&1
+--write_line "$MYSQL_CLIENT_TEST" $MYSQLTEST_VARDIR/log/mysql_client_test_comp.out.log
--exec $MYSQL_CLIENT_TEST --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test_comp.out.log 2>&1
# End of test
diff --git a/mysql-test/main/mysql_client_test_nonblock.test b/mysql-test/main/mysql_client_test_nonblock.test
index 73e7a6d3..c4bc4304 100644
--- a/mysql-test/main/mysql_client_test_nonblock.test
+++ b/mysql-test/main/mysql_client_test_nonblock.test
@@ -19,7 +19,7 @@ call mtr.add_suppression(" IP address .* could not be resolved");
# server or run mysql-test-run --debug mysql_client_test and check
# var/log/mysql_client_test.trace
---exec echo "$MYSQL_CLIENT_TEST --non-blocking-api" > $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1
+--write_line "$MYSQL_CLIENT_TEST --non-blocking-api" $MYSQLTEST_VARDIR/log/mysql_client_test.out.log
--exec $MYSQL_CLIENT_TEST --non-blocking-api --getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1
# End of 4.1 tests
diff --git a/mysql-test/main/mysql_connector_net.test b/mysql-test/main/mysql_connector_net.test
index c1dce65a..ad048c20 100644
--- a/mysql-test/main/mysql_connector_net.test
+++ b/mysql-test/main/mysql_connector_net.test
@@ -4,7 +4,7 @@ let $sys_errno=0;
# Error 100 is returned by the powershell script
# if MySql.Data is not installed
--error 0,100
---exec powershell -NoLogo -NoProfile -File main\mysql_connector_net.ps1
+--exec powershell -ExecutionPolicy Bypass -NoLogo -NoProfile -File main\mysql_connector_net.ps1
if ($sys_errno != 0)
{
--skip Connector/NET is not installed
diff --git a/mysql-test/main/mysql_install_db_win_admin.result b/mysql-test/main/mysql_install_db_win_admin.result
index 06d3d677..dd0e4e3b 100644
--- a/mysql-test/main/mysql_install_db_win_admin.result
+++ b/mysql-test/main/mysql_install_db_win_admin.result
@@ -1,10 +1,4 @@
use mysql;
-Running bootstrap
-Creating my.ini file
-Removing default user
-Allowing remote access for user root
-Setting root password
-Creation of the database was successful
# Kill the server
# restart: --datadir=MYSQLTEST_VARDIR/tmp/ddir
connect root,localhost,root,wrongpass,mysql;
diff --git a/mysql-test/main/mysql_install_db_win_admin.test b/mysql-test/main/mysql_install_db_win_admin.test
index a6b98f97..28a2356c 100644
--- a/mysql-test/main/mysql_install_db_win_admin.test
+++ b/mysql-test/main/mysql_install_db_win_admin.test
@@ -6,12 +6,15 @@
# and start server from this directory.
let $ddir= $MYSQLTEST_VARDIR/tmp/ddir;
use mysql;
-exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --password=foo -R;
+--disable_result_log
+exec $MYSQL_INSTALL_DB_EXE --datadir=$ddir --password=foo --verbose-bootstrap -R;
+--enable_result_log
--source include/kill_mysqld.inc
let $restart_parameters=--datadir=$ddir;
--source include/start_mysqld.inc
# Check that connect with wrong password succeeds
+# (because it can alternatively connect with GSSAPI as admin)
connect (root,localhost,root,wrongpass,mysql);
--source include/kill_mysqld.inc
diff --git a/mysql-test/main/mysql_tzinfo_to_sql_symlink.result b/mysql-test/main/mysql_tzinfo_to_sql_symlink.result
index 97548768..86ff8179 100644
--- a/mysql-test/main/mysql_tzinfo_to_sql_symlink.result
+++ b/mysql-test/main/mysql_tzinfo_to_sql_symlink.result
@@ -18,6 +18,8 @@ execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_
execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition ENGINE=InnoDB', 'do 0');
execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_transition_type''', 'do 0');
execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition_type ENGINE=InnoDB', 'do 0');
+SET @old_alter_alg=@@SESSION.alter_algorithm;
+SET session alter_algorithm='COPY';
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
@@ -52,6 +54,7 @@ execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone E
execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_name ENGINE=', @time_zone_name_engine), 'do 0');
execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_transition ENGINE=', @time_zone_transition_engine, ', ORDER BY Time_zone_id, Transition_time'), 'do 0');
execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_transition_type ENGINE=', @time_zone_transition_type_engine, ', ORDER BY Time_zone_id, Transition_type_id'), 'do 0');
+SET session alter_algorithm=@old_alter_alg;
#
# MDEV-28263: mariadb-tzinfo-to-sql improve wsrep and binlog cases
#
@@ -67,6 +70,8 @@ execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_
execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition ENGINE=InnoDB', 'do 0');
execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_transition_type''', 'do 0');
execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition_type ENGINE=InnoDB', 'do 0');
+SET @old_alter_alg=@@SESSION.alter_algorithm;
+SET session alter_algorithm='COPY';
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
@@ -98,6 +103,7 @@ execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone E
execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_name ENGINE=', @time_zone_name_engine), 'do 0');
execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_transition ENGINE=', @time_zone_transition_engine, ', ORDER BY Time_zone_id, Transition_time'), 'do 0');
execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_transition_type ENGINE=', @time_zone_transition_type_engine, ', ORDER BY Time_zone_id, Transition_type_id'), 'do 0');
+SET session alter_algorithm=@old_alter_alg;
SELECT COUNT(*) FROM time_zone;
COUNT(*)
2
@@ -123,6 +129,8 @@ execute immediate if(@wsrep_is_on, 'SET @save_wsrep_on=@@WSREP_ON, WSREP_ON=OFF'
SET @save_sql_log_bin=@@SQL_LOG_BIN;
SET SESSION SQL_LOG_BIN=0;
SET @wsrep_cannot_replicate_tz=0;
+SET @old_alter_alg=@@SESSION.alter_algorithm;
+SET session alter_algorithm='COPY';
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
@@ -152,6 +160,7 @@ execute immediate if(@wsrep_cannot_replicate_tz, 'do 0','ALTER TABLE time_zone_t
execute immediate if(@wsrep_cannot_replicate_tz, 'do 0','ALTER TABLE time_zone_transition_type ORDER BY Time_zone_id, Transition_type_id');
SET SESSION SQL_LOG_BIN=@save_sql_log_bin;
execute immediate if(@wsrep_is_on, 'SET SESSION WSREP_ON=@save_wsrep_on', 'do 0');
+SET session alter_algorithm=@old_alter_alg;
SELECT COUNT(*) FROM time_zone;
COUNT(*)
2
@@ -505,6 +514,8 @@ execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_
execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition ENGINE=InnoDB', 'do 0');
execute immediate if(@wsrep_cannot_replicate_tz, 'select ENGINE into @time_zone_transition_type_engine from information_schema.TABLES where TABLE_SCHEMA=DATABASE() and TABLE_NAME=''time_zone_transition_type''', 'do 0');
execute immediate if(@wsrep_cannot_replicate_tz, 'ALTER TABLE time_zone_transition_type ENGINE=InnoDB', 'do 0');
+SET @old_alter_alg=@@SESSION.alter_algorithm;
+SET session alter_algorithm='COPY';
TRUNCATE TABLE time_zone;
TRUNCATE TABLE time_zone_name;
TRUNCATE TABLE time_zone_transition;
@@ -522,6 +533,7 @@ execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone E
execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_name ENGINE=', @time_zone_name_engine), 'do 0');
execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_transition ENGINE=', @time_zone_transition_engine, ', ORDER BY Time_zone_id, Transition_time'), 'do 0');
execute immediate if(@wsrep_cannot_replicate_tz, concat('ALTER TABLE time_zone_transition_type ENGINE=', @time_zone_transition_type_engine, ', ORDER BY Time_zone_id, Transition_type_id'), 'do 0');
+SET session alter_algorithm=@old_alter_alg;
DROP TABLE baseline;
DROP TABLE time_zone;
DROP TABLE time_zone_name;
diff --git a/mysql-test/main/mysqlbinlog_row_compressed.result b/mysql-test/main/mysqlbinlog_row_compressed.result
index 2cf65265..410af544 100644
--- a/mysql-test/main/mysqlbinlog_row_compressed.result
+++ b/mysql-test/main/mysqlbinlog_row_compressed.result
@@ -1,3 +1,5 @@
+set pseudo_thread_id=5;
+reset master;
SET GLOBAL log_bin_compress=on;
SET GLOBAL log_bin_compress_min_len=10;
CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1));
@@ -15,21 +17,21 @@ FLUSH BINARY LOGS;
/*!40019 SET @@session.max_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
-# at 4
-#<date> server id 1 end_log_pos 256 CRC32 XXX Start: xxx
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Start: xxx
ROLLBACK/*!*/;
-# at 256
-#<date> server id 1 end_log_pos 285 CRC32 XXX Gtid list []
-# at 285
-#<date> server id 1 end_log_pos 329 CRC32 XXX Binlog checkpoint master-bin.000001
-# at 329
-#<date> server id 1 end_log_pos 371 CRC32 XXX GTID 0-1-1 ddl
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Gtid list []
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Binlog checkpoint master-bin.000001
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-1 ddl
/*!100101 SET @@session.skip_parallel_replication=0*//*!*/;
/*!100001 SET @@session.gtid_domain_id=0*//*!*/;
/*!100001 SET @@session.server_id=1*//*!*/;
/*!100001 SET @@session.gtid_seq_no=1*//*!*/;
-# at 371
-#<date> server id 1 end_log_pos 542 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
use `test`/*!*/;
SET TIMESTAMP=X/*!*/;
SET @@session.pseudo_thread_id=5/*!*/;
@@ -42,26 +44,26 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1))
/*!*/;
-# at 542
-#<date> server id 1 end_log_pos 584 CRC32 XXX GTID 0-1-2 ddl
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-2 ddl
/*!100001 SET @@session.gtid_seq_no=2*//*!*/;
-# at 584
-#<date> server id 1 end_log_pos 745 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 INT, f4 INT, f5 MEDIUMINT, f6 INT, f7 INT, f8 char(1))
/*!*/;
-# at 745
-#<date> server id 1 end_log_pos 787 CRC32 XXX GTID 0-1-3
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-3
/*!100001 SET @@session.gtid_seq_no=3*//*!*/;
START TRANSACTION
/*!*/;
-# at 787
-# at 861
-#<date> server id 1 end_log_pos 861 CRC32 XXX Annotate_rows:
+# at <pos>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Annotate_rows:
#Q> INSERT INTO t1 VALUES (10, 1, 2, 3, 4, 5, 6, 7, "")
-#<date> server id 1 end_log_pos 917 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 917
-#<date> server id 1 end_log_pos 985 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Write_compressed_rows: table id <tblid> flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -74,23 +76,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 1
-# at 985
-#<date> server id 1 end_log_pos 1058 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1058
-#<date> server id 1 end_log_pos 1100 CRC32 XXX GTID 0-1-4
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-4
/*!100001 SET @@session.gtid_seq_no=4*//*!*/;
START TRANSACTION
/*!*/;
-# at 1100
-# at 1176
-#<date> server id 1 end_log_pos 1176 CRC32 XXX Annotate_rows:
+# at <pos>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Annotate_rows:
#Q> INSERT INTO t1 VALUES (11, 1, 2, 3, 4, 5, 6, 7, NULL)
-#<date> server id 1 end_log_pos 1232 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 1232
-#<date> server id 1 end_log_pos 1299 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Write_compressed_rows: table id <tblid> flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=11 /* INT meta=0 nullable=0 is_null=0 */
@@ -103,23 +105,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9=NULL /* STRING(1) meta=65025 nullable=1 is_null=1 */
# Number of rows: 1
-# at 1299
-#<date> server id 1 end_log_pos 1372 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1372
-#<date> server id 1 end_log_pos 1414 CRC32 XXX GTID 0-1-5
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-5
/*!100001 SET @@session.gtid_seq_no=5*//*!*/;
START TRANSACTION
/*!*/;
-# at 1414
-# at 1492
-#<date> server id 1 end_log_pos 1492 CRC32 XXX Annotate_rows:
+# at <pos>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Annotate_rows:
#Q> INSERT INTO t1 VALUES (12, 1, 2, 3, NULL, 5, 6, 7, "A")
-#<date> server id 1 end_log_pos 1548 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 1548
-#<date> server id 1 end_log_pos 1614 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Write_compressed_rows: table id <tblid> flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=12 /* INT meta=0 nullable=0 is_null=0 */
@@ -132,23 +134,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 1
-# at 1614
-#<date> server id 1 end_log_pos 1687 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1687
-#<date> server id 1 end_log_pos 1729 CRC32 XXX GTID 0-1-6
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-6
/*!100001 SET @@session.gtid_seq_no=6*//*!*/;
START TRANSACTION
/*!*/;
-# at 1729
-# at 1804
-#<date> server id 1 end_log_pos 1804 CRC32 XXX Annotate_rows:
+# at <pos>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Annotate_rows:
#Q> INSERT INTO t1 VALUES (13, 1, 2, 3, 0, 5, 6, 7, "A")
-#<date> server id 1 end_log_pos 1860 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 1860
-#<date> server id 1 end_log_pos 1927 CRC32 XXX Write_compressed_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Write_compressed_rows: table id <tblid> flags: STMT_END_F
### INSERT INTO `test`.`t1`
### SET
### @1=13 /* INT meta=0 nullable=0 is_null=0 */
@@ -161,23 +163,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 1
-# at 1927
-#<date> server id 1 end_log_pos 2000 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2000
-#<date> server id 1 end_log_pos 2042 CRC32 XXX GTID 0-1-7
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-7
/*!100001 SET @@session.gtid_seq_no=7*//*!*/;
START TRANSACTION
/*!*/;
-# at 2042
-# at 2096
-#<date> server id 1 end_log_pos 2096 CRC32 XXX Annotate_rows:
+# at <pos>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Annotate_rows:
#Q> INSERT INTO t2 SELECT * FROM t1
-#<date> server id 1 end_log_pos 2152 CRC32 XXX Table_map: `test`.`t2` mapped to number num
-# at 2152
-#<date> server id 1 end_log_pos 2243 CRC32 XXX Write_compressed_rows: table id 33 flags: STMT_END_F
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Table_map: `test`.`t2` mapped to number num
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Write_compressed_rows: table id <tblid> flags: STMT_END_F
### INSERT INTO `test`.`t2`
### SET
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -223,23 +225,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 4
-# at 2243
-#<date> server id 1 end_log_pos 2316 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2316
-#<date> server id 1 end_log_pos 2358 CRC32 XXX GTID 0-1-8
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-8
/*!100001 SET @@session.gtid_seq_no=8*//*!*/;
START TRANSACTION
/*!*/;
-# at 2358
-# at 2424
-#<date> server id 1 end_log_pos 2424 CRC32 XXX Annotate_rows:
+# at <pos>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Annotate_rows:
#Q> UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL
-#<date> server id 1 end_log_pos 2480 CRC32 XXX Table_map: `test`.`t2` mapped to number num
-# at 2480
-#<date> server id 1 end_log_pos 2579 CRC32 XXX Update_compressed_rows: table id 33 flags: STMT_END_F
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Table_map: `test`.`t2` mapped to number num
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Update_compressed_rows: table id <tblid> flags: STMT_END_F
### UPDATE `test`.`t2`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -304,23 +306,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 3
-# at 2579
-#<date> server id 1 end_log_pos 2652 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2652
-#<date> server id 1 end_log_pos 2694 CRC32 XXX GTID 0-1-9
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-9
/*!100001 SET @@session.gtid_seq_no=9*//*!*/;
START TRANSACTION
/*!*/;
-# at 2694
-# at 2731
-#<date> server id 1 end_log_pos 2731 CRC32 XXX Annotate_rows:
+# at <pos>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Annotate_rows:
#Q> DELETE FROM t1
-#<date> server id 1 end_log_pos 2787 CRC32 XXX Table_map: `test`.`t1` mapped to number num
-# at 2787
-#<date> server id 1 end_log_pos 2879 CRC32 XXX Delete_compressed_rows: table id 32 flags: STMT_END_F
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Table_map: `test`.`t1` mapped to number num
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Delete_compressed_rows: table id <tblid> flags: STMT_END_F
### DELETE FROM `test`.`t1`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -366,23 +368,23 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 4
-# at 2879
-#<date> server id 1 end_log_pos 2952 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2952
-#<date> server id 1 end_log_pos 2994 CRC32 XXX GTID 0-1-10
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-10
/*!100001 SET @@session.gtid_seq_no=10*//*!*/;
START TRANSACTION
/*!*/;
-# at 2994
-# at 3031
-#<date> server id 1 end_log_pos 3031 CRC32 XXX Annotate_rows:
+# at <pos>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Annotate_rows:
#Q> DELETE FROM t2
-#<date> server id 1 end_log_pos 3087 CRC32 XXX Table_map: `test`.`t2` mapped to number num
-# at 3087
-#<date> server id 1 end_log_pos 3172 CRC32 XXX Delete_compressed_rows: table id 33 flags: STMT_END_F
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Table_map: `test`.`t2` mapped to number num
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Delete_compressed_rows: table id <tblid> flags: STMT_END_F
### DELETE FROM `test`.`t2`
### WHERE
### @1=10 /* INT meta=0 nullable=0 is_null=0 */
@@ -428,13 +430,13 @@ START TRANSACTION
### @8=7 /* INT meta=0 nullable=1 is_null=0 */
### @9='A' /* STRING(1) meta=65025 nullable=1 is_null=0 */
# Number of rows: 4
-# at 3172
-#<date> server id 1 end_log_pos 3245 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 3245
-#<date> server id 1 end_log_pos 3293 CRC32 XXX Rotate to master-bin.000002 pos: 4
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Rotate to master-bin.000002 pos: 4
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
diff --git a/mysql-test/main/mysqlbinlog_row_compressed.test b/mysql-test/main/mysqlbinlog_row_compressed.test
index 03868d3e..b3a6add4 100644
--- a/mysql-test/main/mysqlbinlog_row_compressed.test
+++ b/mysql-test/main/mysqlbinlog_row_compressed.test
@@ -4,13 +4,14 @@
--source include/have_log_bin.inc
--source include/have_binlog_format_row.inc
---source include/have_normal_zlib.inc
#
#
# mysqlbinlog: compressed row event
#
#
+set pseudo_thread_id=5;
+reset master;
SET GLOBAL log_bin_compress=on;
SET GLOBAL log_bin_compress_min_len=10;
@@ -30,7 +31,7 @@ DELETE FROM t2;
FLUSH BINARY LOGS;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---replace_regex /\d{6} *\d*:\d\d:\d\d/<date>/ /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ /xid=\d*/xid=<xid>/
+--replace_regex /\d{6} *\d*:\d\d:\d\d/<date>/ /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ /xid=\d*/xid=<xid>/ /table id \d+/table id <tblid>/ /end_log_pos \d+/end_log_pos <pos>/ /# at \d+/# at <pos>/
--exec $MYSQL_BINLOG --verbose --verbose --base64-output=DECODE-ROWS $datadir/$binlog
--echo
diff --git a/mysql-test/main/mysqlbinlog_row_minimal.result b/mysql-test/main/mysqlbinlog_row_minimal.result
index 69aa91a8..f8795433 100644
--- a/mysql-test/main/mysqlbinlog_row_minimal.result
+++ b/mysql-test/main/mysqlbinlog_row_minimal.result
@@ -382,7 +382,7 @@ START TRANSACTION
#<date> server id 1 end_log_pos END_LOG_POS CRC32 XXX Annotate_rows:
#Q> UPDATE t1 t1 INNER JOIN t2 t2 ON t1.ref_id = t2.id
#Q> SET t1.is_deleted = TRUE
-#Q> WHERE t1.id =
+#Q> WHERE t1.id = 1
#<date> server id 1 end_log_pos END_LOG_POS CRC32 XXX Table_map: `test`.`t1` mapped to number TID
# at POS
#<date> server id 1 end_log_pos END_LOG_POS CRC32 XXX Update_rows: table id TID flags: STMT_END_F
diff --git a/mysql-test/main/mysqlbinlog_stmt_compressed.result b/mysql-test/main/mysqlbinlog_stmt_compressed.result
index c0d26f3f..471cb4b7 100644
--- a/mysql-test/main/mysqlbinlog_stmt_compressed.result
+++ b/mysql-test/main/mysqlbinlog_stmt_compressed.result
@@ -15,21 +15,21 @@ FLUSH BINARY LOGS;
/*!40019 SET @@session.max_delayed_threads=0*/;
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
DELIMITER /*!*/;
-# at 4
-#<date> server id 1 end_log_pos 256 CRC32 XXX Start: xxx
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Start: xxx
ROLLBACK/*!*/;
-# at 256
-#<date> server id 1 end_log_pos 285 CRC32 XXX Gtid list []
-# at 285
-#<date> server id 1 end_log_pos 329 CRC32 XXX Binlog checkpoint master-bin.000001
-# at 329
-#<date> server id 1 end_log_pos 371 CRC32 XXX GTID 0-1-1 ddl
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Gtid list []
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Binlog checkpoint master-bin.000001
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-1 ddl
/*!100101 SET @@session.skip_parallel_replication=0*//*!*/;
/*!100001 SET @@session.gtid_domain_id=0*//*!*/;
/*!100001 SET @@session.server_id=1*//*!*/;
/*!100001 SET @@session.gtid_seq_no=1*//*!*/;
-# at 371
-#<date> server id 1 end_log_pos 542 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
use `test`/*!*/;
SET TIMESTAMP=X/*!*/;
SET @@session.pseudo_thread_id=5/*!*/;
@@ -42,136 +42,136 @@ SET @@session.lc_time_names=0/*!*/;
SET @@session.collation_database=DEFAULT/*!*/;
CREATE TABLE t1 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 TINYINT, f4 MEDIUMINT, f5 BIGINT, f6 INT, f7 INT, f8 char(1))
/*!*/;
-# at 542
-#<date> server id 1 end_log_pos 584 CRC32 XXX GTID 0-1-2 ddl
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-2 ddl
/*!100001 SET @@session.gtid_seq_no=2*//*!*/;
-# at 584
-#<date> server id 1 end_log_pos 745 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
CREATE TABLE t2 (pk INT PRIMARY KEY, f1 INT, f2 INT, f3 INT, f4 INT, f5 MEDIUMINT, f6 INT, f7 INT, f8 char(1))
/*!*/;
-# at 745
-#<date> server id 1 end_log_pos 787 CRC32 XXX GTID 0-1-3
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-3
/*!100001 SET @@session.gtid_seq_no=3*//*!*/;
START TRANSACTION
/*!*/;
-# at 787
-#<date> server id 1 end_log_pos 915 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
INSERT INTO t1 VALUES (10, 1, 2, 3, 4, 5, 6, 7, "")
/*!*/;
-# at 915
-#<date> server id 1 end_log_pos 988 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 988
-#<date> server id 1 end_log_pos 1030 CRC32 XXX GTID 0-1-4
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-4
/*!100001 SET @@session.gtid_seq_no=4*//*!*/;
START TRANSACTION
/*!*/;
-# at 1030
-#<date> server id 1 end_log_pos 1158 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
INSERT INTO t1 VALUES (11, 1, 2, 3, 4, 5, 6, 7, NULL)
/*!*/;
-# at 1158
-#<date> server id 1 end_log_pos 1231 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1231
-#<date> server id 1 end_log_pos 1273 CRC32 XXX GTID 0-1-5
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-5
/*!100001 SET @@session.gtid_seq_no=5*//*!*/;
START TRANSACTION
/*!*/;
-# at 1273
-#<date> server id 1 end_log_pos 1403 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
INSERT INTO t1 VALUES (12, 1, 2, 3, NULL, 5, 6, 7, "A")
/*!*/;
-# at 1403
-#<date> server id 1 end_log_pos 1476 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1476
-#<date> server id 1 end_log_pos 1518 CRC32 XXX GTID 0-1-6
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-6
/*!100001 SET @@session.gtid_seq_no=6*//*!*/;
START TRANSACTION
/*!*/;
-# at 1518
-#<date> server id 1 end_log_pos 1645 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
INSERT INTO t1 VALUES (13, 1, 2, 3, 0, 5, 6, 7, "A")
/*!*/;
-# at 1645
-#<date> server id 1 end_log_pos 1718 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1718
-#<date> server id 1 end_log_pos 1760 CRC32 XXX GTID 0-1-7
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-7
/*!100001 SET @@session.gtid_seq_no=7*//*!*/;
START TRANSACTION
/*!*/;
-# at 1760
-#<date> server id 1 end_log_pos 1868 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
INSERT INTO t2 SELECT * FROM t1
/*!*/;
-# at 1868
-#<date> server id 1 end_log_pos 1941 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 1941
-#<date> server id 1 end_log_pos 1983 CRC32 XXX GTID 0-1-8
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-8
/*!100001 SET @@session.gtid_seq_no=8*//*!*/;
START TRANSACTION
/*!*/;
-# at 1983
-#<date> server id 1 end_log_pos 2100 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
UPDATE t2 SET f4=5 WHERE f4>0 or f4 is NULL
/*!*/;
-# at 2100
-#<date> server id 1 end_log_pos 2173 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2173
-#<date> server id 1 end_log_pos 2215 CRC32 XXX GTID 0-1-9
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-9
/*!100001 SET @@session.gtid_seq_no=9*//*!*/;
START TRANSACTION
/*!*/;
-# at 2215
-#<date> server id 1 end_log_pos 2306 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
DELETE FROM t1
/*!*/;
-# at 2306
-#<date> server id 1 end_log_pos 2379 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2379
-#<date> server id 1 end_log_pos 2421 CRC32 XXX GTID 0-1-10
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX GTID 0-1-10
/*!100001 SET @@session.gtid_seq_no=10*//*!*/;
START TRANSACTION
/*!*/;
-# at 2421
-#<date> server id 1 end_log_pos 2512 CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query_compressed thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
DELETE FROM t2
/*!*/;
-# at 2512
-#<date> server id 1 end_log_pos 2585 CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Query thread_id=5 exec_time=x error_code=0 xid=<xid>
SET TIMESTAMP=X/*!*/;
COMMIT
/*!*/;
-# at 2585
-#<date> server id 1 end_log_pos 2633 CRC32 XXX Rotate to master-bin.000002 pos: 4
+# at <pos>
+#<date> server id 1 end_log_pos <pos> CRC32 XXX Rotate to master-bin.000002 pos: 4
DELIMITER ;
# End of log file
ROLLBACK /* added by mysqlbinlog */;
diff --git a/mysql-test/main/mysqlbinlog_stmt_compressed.test b/mysql-test/main/mysqlbinlog_stmt_compressed.test
index 4a651243..5c3fb58c 100644
--- a/mysql-test/main/mysqlbinlog_stmt_compressed.test
+++ b/mysql-test/main/mysqlbinlog_stmt_compressed.test
@@ -4,7 +4,6 @@
--source include/have_log_bin.inc
--source include/have_binlog_format_statement.inc
---source include/have_normal_zlib.inc
#
#
# mysqlbinlog: compressed query event
@@ -29,7 +28,7 @@ DELETE FROM t2;
FLUSH BINARY LOGS;
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
---replace_regex /\d{6} *\d*:\d\d:\d\d/<date>/ /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ /xid=\d*/xid=<xid>/
+--replace_regex /\d{6} *\d*:\d\d:\d\d/<date>/ /Start:.*at startup/Start: xxx/ /SET TIMESTAMP=\d*/SET TIMESTAMP=X/ /exec_time=\d*/exec_time=x/ /mapped to number \d*/mapped to number num/ /CRC32 0x[0-9a-f]+/CRC32 XXX/ /@@session.sql_mode=\d+/@@session.sql_mode=#/ /collation_server=\d+/collation_server=#/ /xid=\d*/xid=<xid>/ /table id \d+/table id <tblid>/ /end_log_pos \d+/end_log_pos <pos>/ /# at \d+/# at <pos>/
--exec $MYSQL_BINLOG --verbose --verbose --base64-output=DECODE-ROWS $datadir/$binlog
--echo
diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result
index 2a3a9f00..ebff8143 100644
--- a/mysql-test/main/mysqld--help.result
+++ b/mysql-test/main/mysqld--help.result
@@ -736,13 +736,17 @@ The following specify which files/extra groups are read (specified before remain
max_connections*5 or max_connections + table_cache*2
(whichever is larger) number of file descriptors
(Automatically configured unless set explicitly)
- --optimizer-adjust-secondary-key-costs=#
- 0 = No changes. 1 = Update secondary key costs for ranges
- to be at least 5x of clustered primary key costs. 2 =
- Remove 'max_seek optimization' for secondary keys and
- slight adjustment of filter cost. This option will be
- deleted in MariaDB 11.0 as it is not needed with the new
- 11.0 optimizer.
+ --optimizer-adjust-secondary-key-costs=name
+ A bit field with the following values:
+ adjust_secondary_key_cost = Update secondary key costs
+ for ranges to be at least 5x of clustered primary key
+ costs. disable_max_seek = Disable 'max_seek optimization'
+ for secondary keys and slight adjustment of filter cost.
+ disable_forced_index_in_group_by = Disable automatic
+ forced index in GROUP BY. This variable will be deleted
+ in MariaDB 11.0 as it is not needed with the new 11.0
+ optimizer.
+ Use 'ALL' to set all combinations.
--optimizer-extra-pruning-depth=#
If the optimizer needs to enumerate join prefix of this
size or larger, then it will try aggressively prune away
@@ -1732,7 +1736,7 @@ old-alter-table DEFAULT
old-mode UTF8_IS_UTF8MB3
old-passwords FALSE
old-style-user-limits FALSE
-optimizer-adjust-secondary-key-costs 0
+optimizer-adjust-secondary-key-costs
optimizer-extra-pruning-depth 8
optimizer-max-sel-arg-weight 32000
optimizer-max-sel-args 16000
@@ -1876,7 +1880,7 @@ slave-run-triggers-for-rbr NO
slave-skip-errors OFF
slave-sql-verify-checksum TRUE
slave-transaction-retries 10
-slave-transaction-retry-errors 1158,1159,1160,1161,1205,1213,1429,2013,12701
+slave-transaction-retry-errors 1158,1159,1160,1161,1205,1213,1020,1429,2013,12701
slave-transaction-retry-interval 0
slave-type-conversions
slow-launch-time 2
diff --git a/mysql-test/main/mysqld_option_err.result b/mysql-test/main/mysqld_option_err.result
index 4afcc5e0..157edb58 100644
--- a/mysql-test/main/mysqld_option_err.result
+++ b/mysql-test/main/mysqld_option_err.result
@@ -3,6 +3,17 @@ Test bad binlog format.
Test bad default storage engine.
Test non-numeric value passed to number option.
Test that bad value for plugin enum option is rejected correctly.
+Test to see if multiple unknown options will be displayed in the error output
+FOUND 1 /unknown option '--nonexistentoption2'/ in mysqltest.log
+FOUND 1 /unknown option '--alsononexistent'/ in mysqltest.log
+FOUND 1 /unknown variable 'nonexistentvariable=1'/ in mysqltest.log
+Test to see if multiple ambiguous options and invalid arguments will be displayed in the error output
+FOUND 1 /Error while setting value 'invalid_value' to 'sql_mode'/ in mysqltest.log
+FOUND 1 /ambiguous option '--character'/ in mysqltest.log
+FOUND 1 /option '--bootstrap' cannot take an argument/ in mysqltest.log
+FOUND 1 /Integer value out of range for uint64: '18446744073709551616' for binlog_cache_size/ in mysqltest.log
+FOUND 1 /Unknown suffix 'y' used for variable 'bulk_insert_buffer_size' \(value '123y'\). Legal suffix characters are: K, M, G, T, P, E/ in mysqltest.log
+FOUND 1 /Error while setting value '123y' to 'bulk_insert_buffer_size'/ in mysqltest.log
Test that --help --verbose works
Test that --not-known-option --help --verbose gives error
Done.
diff --git a/mysql-test/main/mysqld_option_err.test b/mysql-test/main/mysqld_option_err.test
index e9655fd4..c2b943ba 100644
--- a/mysql-test/main/mysqld_option_err.test
+++ b/mysql-test/main/mysqld_option_err.test
@@ -25,7 +25,7 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err;
--echo Test bad binlog format.
---error 1
+--error 13
--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --log-bin --binlog-format=badformat >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
@@ -35,7 +35,7 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err;
--echo Test non-numeric value passed to number option.
---error 1
+--error 9
--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --min-examined-row-limit=notanumber >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
@@ -46,6 +46,36 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_option_err;
--error 7
--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --plugin-dir=$MYSQLTEST_VARDIR/plugins --plugin-load=example=ha_example.so --plugin-example-enum-var=noexist >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
+--let SEARCH_FILE = $MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log
+
+--echo Test to see if multiple unknown options will be displayed in the error output
+--error 7
+--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --nonexistentoption2 --alsononexistent --nonexistentvariable=1 >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
+
+--let SEARCH_PATTERN=unknown option '--nonexistentoption2'
+--source include/search_pattern_in_file.inc
+--let SEARCH_PATTERN=unknown option '--alsononexistent'
+--source include/search_pattern_in_file.inc
+--let SEARCH_PATTERN=unknown variable 'nonexistentvariable=1'
+--source include/search_pattern_in_file.inc
+
+--echo Test to see if multiple ambiguous options and invalid arguments will be displayed in the error output
+--error 9
+--exec $MYSQLD_BOOTSTRAP_CMD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables --getopt-prefix-matching --sql-mode=invalid_value --character --bootstrap=partstoob --binlog_cache_size=18446744073709551616 --bulk_insert_buffer_size=123y >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
+
+--let SEARCH_PATTERN=Error while setting value 'invalid_value' to 'sql_mode'
+--source include/search_pattern_in_file.inc
+--let SEARCH_PATTERN=ambiguous option '--character'
+--source include/search_pattern_in_file.inc
+--let SEARCH_PATTERN=option '--bootstrap' cannot take an argument
+--source include/search_pattern_in_file.inc
+--let SEARCH_PATTERN=Integer value out of range for uint64: '18446744073709551616' for binlog_cache_size
+--source include/search_pattern_in_file.inc
+--let SEARCH_PATTERN=Unknown suffix 'y' used for variable 'bulk_insert_buffer_size' \(value '123y'\). Legal suffix characters are: K, M, G, T, P, E
+--source include/search_pattern_in_file.inc
+--let SEARCH_PATTERN=Error while setting value '123y' to 'bulk_insert_buffer_size'
+--source include/search_pattern_in_file.inc
+
#
# Test that an wrong option with --help --verbose gives an error
#
diff --git a/mysql-test/main/mysqldump-compat-102.result b/mysql-test/main/mysqldump-compat-102.result
index 86a2ebc4..d5ed5457 100644
--- a/mysql-test/main/mysqldump-compat-102.result
+++ b/mysql-test/main/mysqldump-compat-102.result
@@ -58,6 +58,7 @@ BEGIN
log(0, 'Session ' || connection_id() || ' ' || current_user || ' started');
END;
$$
+/*!999999\- enable the sandbox mode */
-- MariaDB dump DUMPVERSION Distrib DISTVERSION, for OS
--
-- Host: localhost Database: db1_mdev17429
diff --git a/mysql-test/main/mysqldump-max.result b/mysql-test/main/mysqldump-max.result
index 7dd1030e..e76193ac 100644
--- a/mysql-test/main/mysqldump-max.result
+++ b/mysql-test/main/mysqldump-max.result
@@ -77,6 +77,7 @@ id name
3 first value
4 first value
5 first value
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -102,7 +103,7 @@ CREATE TABLE `t1` (
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
-INSERT DELAYED IGNORE INTO `t1` VALUES
+INSERT DELAYED IGNORE INTO `t1` VALUES
(1,'first value'),
(2,'first value'),
(3,'first value'),
@@ -119,7 +120,7 @@ CREATE TABLE `t2` (
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
-INSERT DELAYED IGNORE INTO `t2` VALUES
+INSERT DELAYED IGNORE INTO `t2` VALUES
(1,'first value'),
(2,'first value'),
(3,'first value'),
@@ -136,7 +137,7 @@ CREATE TABLE `t3` (
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t3` DISABLE KEYS */;
-INSERT DELAYED IGNORE INTO `t3` VALUES
+INSERT DELAYED IGNORE INTO `t3` VALUES
(1,'first value'),
(2,'first value'),
(3,'first value'),
@@ -153,7 +154,7 @@ CREATE TABLE `t4` (
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t4` DISABLE KEYS */;
-INSERT DELAYED IGNORE INTO `t4` VALUES
+INSERT DELAYED IGNORE INTO `t4` VALUES
(1,'first value'),
(2,'first value'),
(3,'first value'),
@@ -170,7 +171,7 @@ CREATE TABLE `t5` (
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t5` DISABLE KEYS */;
-INSERT DELAYED IGNORE INTO `t5` VALUES
+INSERT DELAYED IGNORE INTO `t5` VALUES
(1,'first value'),
(2,'first value'),
(3,'first value'),
@@ -187,7 +188,7 @@ CREATE TABLE `t6` (
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t6` DISABLE KEYS */;
-INSERT IGNORE INTO `t6` VALUES
+INSERT IGNORE INTO `t6` VALUES
(1,'first value'),
(2,'first value'),
(3,'first value'),
@@ -204,6 +205,7 @@ INSERT IGNORE INTO `t6` VALUES
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -229,7 +231,7 @@ CREATE TABLE `t1` (
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
-INSERT DELAYED INTO `t1` VALUES
+INSERT DELAYED INTO `t1` VALUES
(1,'first value'),
(2,'first value'),
(3,'first value'),
@@ -246,7 +248,7 @@ CREATE TABLE `t2` (
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t2` DISABLE KEYS */;
-INSERT DELAYED INTO `t2` VALUES
+INSERT DELAYED INTO `t2` VALUES
(1,'first value'),
(2,'first value'),
(3,'first value'),
@@ -263,7 +265,7 @@ CREATE TABLE `t3` (
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t3` DISABLE KEYS */;
-INSERT DELAYED INTO `t3` VALUES
+INSERT DELAYED INTO `t3` VALUES
(1,'first value'),
(2,'first value'),
(3,'first value'),
@@ -280,7 +282,7 @@ CREATE TABLE `t4` (
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t4` DISABLE KEYS */;
-INSERT DELAYED INTO `t4` VALUES
+INSERT DELAYED INTO `t4` VALUES
(1,'first value'),
(2,'first value'),
(3,'first value'),
@@ -297,7 +299,7 @@ CREATE TABLE `t5` (
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t5` DISABLE KEYS */;
-INSERT DELAYED INTO `t5` VALUES
+INSERT DELAYED INTO `t5` VALUES
(1,'first value'),
(2,'first value'),
(3,'first value'),
diff --git a/mysql-test/main/mysqldump-nl.result b/mysql-test/main/mysqldump-nl.result
index 66902492..1e992830 100644
--- a/mysql-test/main/mysqldump-nl.result
+++ b/mysql-test/main/mysqldump-nl.result
@@ -12,6 +12,7 @@ create procedure sp() select * from `v1
1v`;
flush tables;
use test;
+/*!999999\- enable the sandbox mode */
--
-- Current Database: `mysqltest1
@@ -134,6 +135,7 @@ test\`
\! ls
#
test`
+/*!999999\- enable the sandbox mode */
--
-- Current Database: `test```
diff --git a/mysql-test/main/mysqldump-no-binlog.result b/mysql-test/main/mysqldump-no-binlog.result
index 223034d8..669675ff 100644
--- a/mysql-test/main/mysqldump-no-binlog.result
+++ b/mysql-test/main/mysqldump-no-binlog.result
@@ -1 +1,2 @@
mariadb-dump: Error: Binlogging on server not active
+/*!999999\- enable the sandbox mode */
diff --git a/mysql-test/main/mysqldump-order-by-size.result b/mysql-test/main/mysqldump-order-by-size.result
index 36185290..3bd953b8 100644
--- a/mysql-test/main/mysqldump-order-by-size.result
+++ b/mysql-test/main/mysqldump-order-by-size.result
@@ -21,6 +21,7 @@ test.t3 analyze status OK
test.t4 analyze status Engine-independent statistics collected
test.t4 analyze Warning Engine-independent statistics are not collected for column 'a'
test.t4 analyze status OK
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t4` (
diff --git a/mysql-test/main/mysqldump-system.result b/mysql-test/main/mysqldump-system.result
index 559f6f29..240a8499 100644
--- a/mysql-test/main/mysqldump-system.result
+++ b/mysql-test/main/mysqldump-system.result
@@ -41,6 +41,7 @@ CREATE FUNCTION metaphon RETURNS STRING SONAME "UDF_EXAMPLE_LIB";
#
# mysqldump of system tables with --system=all
#
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -632,6 +633,7 @@ UNLOCK TABLES;
#
# mysqldump of system tables with --system=all --replace
#
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -1246,6 +1248,7 @@ UNLOCK TABLES;
#
# mysqldump of system tables with --system=all --insert-ignore
#
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -1300,28 +1303,28 @@ USE mysql;
LOCK TABLES `column_stats` WRITE;
/*!40000 ALTER TABLE `column_stats` DISABLE KEYS */;
-INSERT IGNORE INTO `column_stats` VALUES
+INSERT IGNORE INTO `column_stats` VALUES
('mysql','tz','Time_zone_id','1','5',0.0000,4.0000,98.2500,4,'JSON_HB','{\"target_histogram_size\": 254, \"collected_at\": \"2022-01-07 07:07:00\", \"collected_by\": \"version\", \"histogram_hb\": [{\"start\": \"1\", \"size\": 0.340966921, \"ndv\": 1}, {\"start\": \"3\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"4\", \"size\": 0.328244275, \"ndv\": 1}, {\"start\": \"5\", \"end\": \"5\", \"size\": 0.002544529, \"ndv\": 1}]}');
/*!40000 ALTER TABLE `column_stats` ENABLE KEYS */;
UNLOCK TABLES;
LOCK TABLES `index_stats` WRITE;
/*!40000 ALTER TABLE `index_stats` DISABLE KEYS */;
-INSERT IGNORE INTO `index_stats` VALUES
+INSERT IGNORE INTO `index_stats` VALUES
('mysql','tz','PRIMARY',1,98.2500);
/*!40000 ALTER TABLE `index_stats` ENABLE KEYS */;
UNLOCK TABLES;
LOCK TABLES `table_stats` WRITE;
/*!40000 ALTER TABLE `table_stats` DISABLE KEYS */;
-INSERT IGNORE INTO `table_stats` VALUES
+INSERT IGNORE INTO `table_stats` VALUES
('mysql','tz',393);
/*!40000 ALTER TABLE `table_stats` ENABLE KEYS */;
UNLOCK TABLES;
LOCK TABLES `innodb_index_stats` WRITE;
/*!40000 ALTER TABLE `innodb_index_stats` DISABLE KEYS */;
-INSERT IGNORE INTO `innodb_index_stats` VALUES
+INSERT IGNORE INTO `innodb_index_stats` VALUES
('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx01',4,1,'Time_zone_id'),
('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_diff_pfx02',393,1,'Time_zone_id,Transition_time'),
('mysql','tz','PRIMARY','2019-12-31 21:00:00','n_leaf_pages',1,NULL,'Number of leaf pages in the index'),
@@ -1331,7 +1334,7 @@ UNLOCK TABLES;
LOCK TABLES `innodb_table_stats` WRITE;
/*!40000 ALTER TABLE `innodb_table_stats` DISABLE KEYS */;
-INSERT IGNORE INTO `innodb_table_stats` VALUES
+INSERT IGNORE INTO `innodb_table_stats` VALUES
('mysql','tz','2019-12-31 21:00:00',393,1,0);
/*!40000 ALTER TABLE `innodb_table_stats` ENABLE KEYS */;
UNLOCK TABLES;
@@ -1340,7 +1343,7 @@ USE mysql;
LOCK TABLES `time_zone` WRITE;
/*!40000 ALTER TABLE `time_zone` DISABLE KEYS */;
-INSERT IGNORE INTO `time_zone` VALUES
+INSERT IGNORE INTO `time_zone` VALUES
(1,'N'),
(2,'N'),
(3,'N'),
@@ -1351,7 +1354,7 @@ UNLOCK TABLES;
LOCK TABLES `time_zone_name` WRITE;
/*!40000 ALTER TABLE `time_zone_name` DISABLE KEYS */;
-INSERT IGNORE INTO `time_zone_name` VALUES
+INSERT IGNORE INTO `time_zone_name` VALUES
('Europe/Moscow',3),
('Japan',5),
('leap/Europe/Moscow',4),
@@ -1363,7 +1366,7 @@ UNLOCK TABLES;
LOCK TABLES `time_zone_leap_second` WRITE;
/*!40000 ALTER TABLE `time_zone_leap_second` DISABLE KEYS */;
-INSERT IGNORE INTO `time_zone_leap_second` VALUES
+INSERT IGNORE INTO `time_zone_leap_second` VALUES
(78796800,1),
(94694401,2),
(126230402,3),
@@ -1391,7 +1394,7 @@ UNLOCK TABLES;
LOCK TABLES `time_zone_transition` WRITE;
/*!40000 ALTER TABLE `time_zone_transition` DISABLE KEYS */;
-INSERT IGNORE INTO `time_zone_transition` VALUES
+INSERT IGNORE INTO `time_zone_transition` VALUES
(1,-1693706400,0),
(1,-1680483600,1),
(1,-1663455600,2),
@@ -1790,7 +1793,7 @@ UNLOCK TABLES;
LOCK TABLES `time_zone_transition_type` WRITE;
/*!40000 ALTER TABLE `time_zone_transition_type` DISABLE KEYS */;
-INSERT IGNORE INTO `time_zone_transition_type` VALUES
+INSERT IGNORE INTO `time_zone_transition_type` VALUES
(1,0,7200,1,'MEST'),
(1,1,3600,0,'MET'),
(1,2,7200,1,'MEST'),
diff --git a/mysql-test/main/mysqldump-timing.result b/mysql-test/main/mysqldump-timing.result
index 7fa11893..5e2851b8 100644
--- a/mysql-test/main/mysqldump-timing.result
+++ b/mysql-test/main/mysqldump-timing.result
@@ -7,6 +7,7 @@ CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (0);
LOCK TABLE t1 WRITE;
timeout without t1 contents expected
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -30,6 +31,7 @@ SET @save_max_statement_time=@@max_statement_time;
SET GLOBAL max_statement_time=0.1;
UNLOCK TABLES;;
This would be a race condition otherwise, but default max_statement_time=0 makes it succeed
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
diff --git a/mysql-test/main/mysqldump-utf8mb4.result b/mysql-test/main/mysqldump-utf8mb4.result
index 90477130..7c5aea5f 100644
--- a/mysql-test/main/mysqldump-utf8mb4.result
+++ b/mysql-test/main/mysqldump-utf8mb4.result
@@ -32,6 +32,7 @@ Testing XML format output
----
Testing text format output
----
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
diff --git a/mysql-test/main/mysqldump.result b/mysql-test/main/mysqldump.result
index 9fb5f0bd..b1279320 100644
--- a/mysql-test/main/mysqldump.result
+++ b/mysql-test/main/mysqldump.result
@@ -31,6 +31,7 @@ DROP TABLE t1;
CREATE TABLE t1 (a decimal(64, 20));
INSERT INTO t1 VALUES ("1234567890123456789012345678901234567890"),
("0987654321098765432109876543210987654321");
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
@@ -48,6 +49,7 @@ CREATE TABLE t1 (a double);
INSERT IGNORE INTO t1 VALUES ('-9e999999');
Warnings:
Warning 1264 Out of range value for column 'a' at row 1
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
@@ -70,6 +72,7 @@ INSERT INTO t1 VALUES ('1.2345', 2.3456);
INSERT INTO t1 VALUES ("1.2345", 2.3456);
ERROR 42S22: Unknown column '1.2345' in 'field list'
SET SQL_MODE=@OLD_SQL_MODE;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
@@ -83,6 +86,7 @@ INSERT INTO `t1` VALUES
(1.23450,2.3456),
(1.23450,2.3456),
(1.23450,2.3456);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
@@ -96,6 +100,7 @@ INSERT INTO `t1` VALUES
(1.23450,2.3456),
(1.23450,2.3456),
(1.23450,2.3456);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -136,6 +141,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -217,6 +223,7 @@ DROP TABLE t1;
#
CREATE TABLE t1 (a VARCHAR(255)) DEFAULT CHARSET koi8r;
INSERT INTO t1 VALUES (_koi8r x'C1C2C3C4C5'), (NULL);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -258,6 +265,7 @@ DROP TABLE t1;
#
CREATE TABLE t1 (a int) ENGINE=MYISAM;
INSERT INTO t1 VALUES (1), (2);
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -283,6 +291,7 @@ UNLOCK TABLES;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -313,6 +322,7 @@ DROP TABLE t1;
# Bug#2592 mysqldump doesn't quote "tricky" names correctly
#
create table ```a` (i int);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE ```a` (
@@ -324,6 +334,7 @@ drop table ```a`;
# Bug#2591 mysqldump quotes names inconsistently
#
create table t1(a int);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -357,6 +368,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -383,6 +395,7 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
set global sql_mode='ANSI_QUOTES';
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -416,6 +429,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -448,6 +462,7 @@ drop table t1;
#
create table t1(a int);
insert into t1 values (1),(2),(3);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -480,6 +495,7 @@ drop table t1;
#
# Bug#6101 create database problem
#
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -506,6 +522,7 @@ USE `test`;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
create database mysqldump_test_db character set latin2 collate latin2_bin;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -540,6 +557,7 @@ drop database mysqldump_test_db;
# if it is explicitly set.
CREATE TABLE t1 (a CHAR(10));
INSERT INTO t1 VALUES (_latin1 'ÄÖÜß');
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -582,6 +600,7 @@ UNLOCK TABLES;
# If the future we can move this command into a separate test with
# checking that "mysqldump" is compiled with "latin1"
#
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -606,6 +625,7 @@ UNLOCK TABLES;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -630,6 +650,7 @@ UNLOCK TABLES;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -662,6 +683,7 @@ CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int);
INSERT INTO t1 VALUES (1),(2),(3);
INSERT INTO t2 VALUES (4),(5),(6);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -706,6 +728,7 @@ DROP TABLE t2;
#
CREATE TABLE t1 (`b` blob);
INSERT INTO `t1` VALUES (0x602010000280100005E71A);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -747,6 +770,7 @@ DROP TABLE t1;
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2),(3);
INSERT INTO t1 VALUES (4),(5),(6);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -768,7 +792,7 @@ CREATE TABLE `t1` (
LOCK TABLES `t1` WRITE;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
-INSERT IGNORE INTO `t1` VALUES
+INSERT IGNORE INTO `t1` VALUES
(1),
(2),
(3),
@@ -787,6 +811,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -807,7 +832,7 @@ CREATE TABLE `t1` (
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
-INSERT DELAYED IGNORE INTO `t1` VALUES
+INSERT DELAYED IGNORE INTO `t1` VALUES
(1),
(2),
(3),
@@ -1162,6 +1187,7 @@ F_cd00692c3bfe59267d5ecfac5310286c int,
F_6faa8040da20ef399b63a72d0e4ab575 int,
F_fe73f687e5bc5280214e0486b273a5f9 int);
insert into t1 (F_8d3bba7425e7c98c50f52ca1b52d3735) values (1);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -1531,6 +1557,7 @@ drop table t1;
#
CREATE TABLE t1 (a int);
INSERT INTO t1 VALUES (1),(2),(3);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -1584,6 +1611,7 @@ CREATE TABLE t1 ( a INT );
CREATE TABLE t2 ( a INT );
INSERT INTO t1 VALUES (1), (2);
INSERT INTO t2 VALUES (1), (2);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -1619,6 +1647,7 @@ CREATE TABLE `t2` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -1691,21 +1720,35 @@ create table t3(a varchar(30) primary key, b int not null);
test_sequence
------ Testing with illegal table names ------
mariadb-dump: Couldn't find table: "\d-2-1.sql"
+/*!999999\- enable the sandbox mode */
mariadb-dump: Couldn't find table: "\t1"
+/*!999999\- enable the sandbox mode */
mariadb-dump: Couldn't find table: "\t1"
+/*!999999\- enable the sandbox mode */
mariadb-dump: Couldn't find table: "\\t1"
+/*!999999\- enable the sandbox mode */
mariadb-dump: Couldn't find table: "t\1"
+/*!999999\- enable the sandbox mode */
mariadb-dump: Couldn't find table: "t\1"
+/*!999999\- enable the sandbox mode */
mariadb-dump: Couldn't find table: "t/1"
+/*!999999\- enable the sandbox mode */
mariadb-dump: Couldn't find table: "T_1"
+/*!999999\- enable the sandbox mode */
mariadb-dump: Couldn't find table: "T%1"
+/*!999999\- enable the sandbox mode */
mariadb-dump: Couldn't find table: "T'1"
+/*!999999\- enable the sandbox mode */
mariadb-dump: Couldn't find table: "T_1"
+/*!999999\- enable the sandbox mode */
mariadb-dump: Couldn't find table: "T_"
+/*!999999\- enable the sandbox mode */
test_sequence
------ Testing with illegal database names ------
mariadb-dump: Got error: 1049: "Unknown database 'mysqldump_test_d'" when selecting the database
+/*!999999\- enable the sandbox mode */
mariadb-dump: Got error: 1049: "Unknown database 'mysqld\ump_test_db'" when selecting the database
+/*!999999\- enable the sandbox mode */
drop table t1, t2, t3;
drop database mysqldump_test_db;
use test;
@@ -1767,6 +1810,7 @@ insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thir
</table_data>
</database>
</mysqldump>
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -1805,6 +1849,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -1930,6 +1975,7 @@ create table t1(a int);
create table t2(a int);
create table t3(a int);
mariadb-dump: Couldn't find table: "non_existing"
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -1979,6 +2025,7 @@ drop table t1, t2, t3;
create table t1 (a int);
mariadb-dump: Couldn't execute 'SELECT /*!40001 SQL_NO_CACHE */ `a` FROM `t1` WHERE xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx': 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 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1 (1064)
mariadb-dump: Got error: 1064: "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 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' at line 1" when retrieving data from server
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -2020,6 +2067,7 @@ CREATE TABLE `t1` (
PRIMARY KEY (`a b`, `c"d`, `e``f`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
insert into t1 values (0815, 4711, 2006);
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -2050,6 +2098,7 @@ UNLOCK TABLES;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -2105,6 +2154,7 @@ INSERT INTO t2 VALUES ('bingo');
INSERT INTO t2 VALUES ('waffle');
INSERT INTO t2 VALUES ('lemon');
create view v2 as select * from t2 where a like 'a%' with check option;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -2204,6 +2254,7 @@ drop database db1;
use test;
create table t1(a int);
create view v1 as select * from t1;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -2274,6 +2325,7 @@ INSERT INTO t2 VALUES ('bingo');
INSERT INTO t2 VALUES ('waffle');
INSERT INTO t2 VALUES ('lemon');
create view v2 as select * from t2 where a like 'a%' with check option;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -2344,6 +2396,7 @@ use test;
#
CREATE TABLE t1 (a char(10));
INSERT INTO t1 VALUES ('\'');
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -2391,6 +2444,7 @@ create view v1 as
select * from v3 where b in (1, 2, 3, 4, 5, 6, 7);
create view v2 as
select v3.a from v3, v1 where v1.a=v3.a and v3.b=3 limit 1;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -2543,6 +2597,7 @@ end if;
end AFTER 0000-00-00 00:00:00 STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,TRADITIONAL,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
INSERT INTO t1 (a) VALUES (1),(2),(3),(22);
update t1 set a = 4 where a=3;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -2676,6 +2731,7 @@ DELIMITER ;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -2827,6 +2883,7 @@ Warning 1287 '<select expression> INTO <destination>;' is deprecated and will be
set sql_mode='ansi';
create procedure `a'b` () select 1;
set sql_mode='';
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -2983,6 +3040,7 @@ d
2003-10-26 02:00:00
2003-10-26 02:00:00
set global time_zone='Europe/Moscow';
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -3024,6 +3082,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -3086,6 +3145,7 @@ a2
1
2
3
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -3166,6 +3226,7 @@ a b c
1 first value xxxx
2 second value tttt
3 third value vvv vvv
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -3294,6 +3355,7 @@ BEGIN
SET new.a = 0;
END|
SET SQL_MODE = @old_sql_mode;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -3357,6 +3419,7 @@ DROP TABLE t1;
#
create table t1 (a binary(1), b blob);
insert into t1 values ('','');
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -3392,6 +3455,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -3492,6 +3556,7 @@ insert into t values(5, 51);
create view v1 as select qty, price, qty*price as value from t;
create view v2 as select qty from v1;
mysqldump {
+/*!999999\- enable the sandbox mode */
/*!50001 DROP VIEW IF EXISTS `v1`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -3507,6 +3572,7 @@ mysqldump {
/*!50001 SET collation_connection = @saved_col_connection */;
} mysqldump {
+/*!999999\- enable the sandbox mode */
/*!50001 DROP VIEW IF EXISTS `v2`*/;
/*!50001 SET @saved_cs_client = @@character_set_client */;
/*!50001 SET @saved_cs_results = @@character_set_results */;
@@ -3552,6 +3618,7 @@ drop table t1;
mysqldump {
mariadb-dump: Got error: 1356: "View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them" when using LOCK TABLES
mariadb-dump: Couldn't execute 'SHOW FIELDS FROM `v1`': View 'test.v1' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them (1356)
+/*!999999\- enable the sandbox mode */
-- failed on view `v1`: CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`t1`.`id` AS `id` from `t1`
@@ -3568,6 +3635,7 @@ insert into t1 values (1232131);
insert into t1 values (4711);
insert into t1 values (3231);
insert into t1 values (0815);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -3646,6 +3714,7 @@ create table basetable ( id serial, tag varchar(64) );
create database mysqldump_views;
use mysqldump_views;
create view nasishnasifu as select mysqldump_tables.basetable.id from mysqldump_tables.basetable;
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `mysqldump_tables` /*!40100 DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci */;
@@ -3731,10 +3800,14 @@ grant all on test.* to mysqltest_1@localhost;
create table t1(a int, b varchar(34));
reset master;
mariadb-dump: Couldn't execute 'FLUSH /*!40101 LOCAL */ TABLES': Access denied; you need (at least one of) the RELOAD privilege(s) for this operation (1227)
+/*!999999\- enable the sandbox mode */
mariadb-dump: Couldn't execute 'FLUSH /*!40101 LOCAL */ TABLES': Access denied; you need (at least one of) the RELOAD privilege(s) for this operation (1227)
+/*!999999\- enable the sandbox mode */
grant RELOAD on *.* to mysqltest_1@localhost;
mariadb-dump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need (at least one of) the SUPER, BINLOG MONITOR privilege(s) for this operation (1227)
+/*!999999\- enable the sandbox mode */
mariadb-dump: Couldn't execute 'SHOW MASTER STATUS': Access denied; you need (at least one of) the SUPER, BINLOG MONITOR privilege(s) for this operation (1227)
+/*!999999\- enable the sandbox mode */
grant REPLICATION CLIENT on *.* to mysqltest_1@localhost;
drop table t1;
drop user mysqltest_1@localhost;
@@ -3793,6 +3866,7 @@ use test;
#
# Bug #33762: mysqldump can not dump INFORMATION_SCHEMA
#
+/*!999999\- enable the sandbox mode */
DROP TABLE IF EXISTS `TABLES`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
@@ -3857,6 +3931,7 @@ DROP TABLE t1;
CREATE TABLE t2 (a INT) ENGINE=MyISAM;
CREATE TABLE t3 (a INT) ENGINE=MyISAM;
CREATE TABLE t1 (a INT) ENGINE=merge UNION=(t2, t3);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -3947,10 +4022,12 @@ connect user27293,localhost,user1,,mysqldump_test_db,$MASTER_MYPORT,$MASTER_MYS
connection user27293;
create procedure mysqldump_test_db.sp1() select 'hello';
mariadb-dump: user2 has insufficient privileges to SHOW CREATE PROCEDURE `sp1`!
+/*!999999\- enable the sandbox mode */
-- insufficient privileges to SHOW CREATE PROCEDURE `sp1`
-- does user2 have permissions on mysql.proc?
+/*!999999\- enable the sandbox mode */
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION' */ ;
/*!50003 SET @saved_cs_client = @@character_set_client */ ;
@@ -3978,6 +4055,7 @@ drop database mysqldump_test_db;
#
CREATE TABLE t1 (c1 INT, c2 LONGBLOB);
INSERT INTO t1 SET c1=11, c2=REPEAT('q',509);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
@@ -4051,6 +4129,7 @@ use db42635;
create table t1 (id int);
create view db42635.v1 (c) as select * from db42635.t1;
create view db42635.v2 (c) as select * from db42635.t1;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -4111,6 +4190,7 @@ drop database db42635;
#
SET NAMES utf8;
CREATE TABLE `straße` ( f1 INT );
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -4133,6 +4213,7 @@ UNLOCK TABLES;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -4157,6 +4238,7 @@ UNLOCK TABLES;
DROP TABLE `straße`;
CREATE TABLE `כדשגכחךלדגכחשךדגחכךלדגכ` ( f1 INT );
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -4180,6 +4262,7 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
mariadb-dump: Got error: 1146: "Table 'test.???????????????????????' doesn't exist" when using LOCK TABLES
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -4196,6 +4279,7 @@ CREATE TABLE t1(a int, b int);
INSERT INTO t1 VALUES (1,1);
INSERT INTO t1 VALUES (2,3);
INSERT INTO t1 VALUES (3,4), (4,5);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -4470,6 +4554,7 @@ insert into t1 values (1232131);
insert into t1 values (4711);
insert into t1 values (3231);
insert into t1 values (0815);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -4602,6 +4687,7 @@ CREATE DATABASE test;
create database `test-database`;
use `test-database`;
create table test (a int);
+/*!999999\- enable the sandbox mode */
DROP TABLE IF EXISTS `test`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
@@ -4824,6 +4910,7 @@ CREATE TRIGGER `trig` BEFORE INSERT ON `test` FOR EACH ROW BEGIN
END |
ALTER DATABASE `test-database` CHARACTER SET latin1 COLLATE latin1_swedish_ci;
ALTER DATABASE `test-database` CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `test` (
@@ -5307,6 +5394,7 @@ USE test;
# Also verify that a prefix of the mode's name is enough.
#
CREATE TABLE t1 (a INT);
+/*!999999\- enable the sandbox mode */
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
@@ -5539,6 +5627,7 @@ CREATE DATABASE `a\"'``b`;
USE `a\"'``b`;
CREATE PROCEDURE p1() BEGIN END;
ALTER DATABASE `a\"'``b` COLLATE utf8_general_ci;
+/*!999999\- enable the sandbox mode */
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = '' */ ;
ALTER DATABASE `a\"'``b` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
@@ -5587,6 +5676,7 @@ CREATE VIEW nonunique_table_view_name AS SELECT 1;
##################################################
# --compact --databases db1 db2
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `db1` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */;
@@ -5655,6 +5745,7 @@ USE `db2`;
##################################################
# --compact db2
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `nonunique_table_name` (
@@ -5677,6 +5768,7 @@ INSERT INTO `nonunique_table_view_name` VALUES
##################################################
# --compact --delayed-insert --no-data-med=0 --databases db2 db1
+/*!999999\- enable the sandbox mode */
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `db2` /*!40100 DEFAULT CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci */;
@@ -5688,7 +5780,7 @@ CREATE TABLE `nonunique_table_name` (
UNIQUE KEY `i1` (`i1`)
) ENGINE=MEMORY AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
-INSERT DELAYED INTO `nonunique_table_name` VALUES
+INSERT DELAYED INTO `nonunique_table_name` VALUES
(1),
(2);
/*!40101 SET @saved_cs_client = @@character_set_client */;
@@ -5710,7 +5802,7 @@ CREATE TABLE `basetable` (
`id` smallint(6) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
-INSERT DELAYED INTO `basetable` VALUES
+INSERT DELAYED INTO `basetable` VALUES
(5),
(6);
/*!40101 SET @saved_cs_client = @@character_set_client */;
@@ -5811,6 +5903,7 @@ CREATE TABLE t1 (a int, b int);
CREATE TRIGGER tt1_t1 BEFORE INSERT ON t1 FOR EACH ROW
SET NEW.b=NEW.a + 10;
INSERT INTO t1 (a) VALUES (1),(2),(3);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -5859,6 +5952,7 @@ DROP TABLE t1;
#
# Without --replace and --insert-ignore
#
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -5954,6 +6048,7 @@ CREATE TABLE IF NOT EXISTS `transaction_registry` (
#
# With --replace
#
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -6059,6 +6154,7 @@ CREATE TABLE IF NOT EXISTS `transaction_registry` (
#
# With --insert-ignore
#
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -6183,6 +6279,7 @@ insert into t3 values(2);
insert into t3(`invisible`, `a b c & $!@#$%^&*( )`, `ds=~!@ \# $% ^ & * ( ) _ - = +` ) values(1,2,3);
CREATE TABLE t4(ËÃÃŒÃÎËÃ1 INT);
insert into t4 values(1);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
@@ -6223,6 +6320,7 @@ CREATE TABLE `t4` (
INSERT INTO `t4` VALUES
(1);
#Check side effect on --complete insert
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
@@ -6468,7 +6566,7 @@ j integer
INSERT INTO t VALUES (1,1),(2,2),(3,3),(4,4);
# Dump database 1
# Restore from database 1 to database 2
-ERROR 1100 (HY000) at line 45: Table 'seq_t_i' was not locked with LOCK TABLES
+ERROR 1100 (HY000) at line 46: Table 'seq_t_i' was not locked with LOCK TABLES
SETVAL(`seq_t_i`, 1, 0)
1
DROP DATABASE IF EXISTS test1;
@@ -6589,10 +6687,8 @@ TABLE 1
SET GLOBAL LOG_OUTPUT=DEFAULT, GLOBAL GENERAL_LOG=@save_general_log;
TRUNCATE TABLE mysql.general_log;
DROP DATABASE test1;
-#
# End of 10.3 tests
#
-#
# MDEV-31092 mysqldump --force doesn't ignore error as it should
#
create function f1() returns int return 1;
@@ -6603,6 +6699,7 @@ Warnings:
Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it.
update mysql.event set body ='select not_a_value' where db='test' and name='e1';
create table t1 (i int);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
@@ -6650,7 +6747,24 @@ drop function f1;
drop function f2;
drop event e1;
drop table t1;
-#
# End of 10.4 tests
#
+# MDEV-33727 mariadb-dump trusts the server and does not validate the data
+#
+create table t1 (a int);
+/*!999999\- enable the sandbox mode */
+DROP TABLE IF EXISTS `t1`;
+/*!40101 SET @saved_cs_client = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `t1` (
+`a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci;
+/*!40101 SET character_set_client = @saved_cs_client */;
+ERROR at line 9: Not allowed in the sandbox mode
+drop table t1;
+# End of 10.5 tests
+#
+# MDEV-16733 mysqldump --tab and --xml options are conflicting
+#
mariadb-dump: --xml can't be used with --tab.
+# End of 10.11 tests
diff --git a/mysql-test/main/mysqldump.test b/mysql-test/main/mysqldump.test
index 1d479dde..0f513a7f 100644
--- a/mysql-test/main/mysqldump.test
+++ b/mysql-test/main/mysqldump.test
@@ -2989,9 +2989,7 @@ TRUNCATE TABLE mysql.general_log;
DROP DATABASE test1;
--remove_file $MYSQLTEST_VARDIR/tmp/dumptest1.sql
---echo #
--echo # End of 10.3 tests
---echo #
--echo #
--echo # MDEV-31092 mysqldump --force doesn't ignore error as it should
@@ -3010,13 +3008,34 @@ drop function f2;
drop event e1;
drop table t1;
---echo #
--echo # End of 10.4 tests
+
+--echo #
+--echo # MDEV-33727 mariadb-dump trusts the server and does not validate the data
--echo #
-#
-# MDEV-16733 mysqldump --tab and --xml options are conflicting
-#
+create table t1 (a int);
+--exec $MYSQL_DUMP --compact --add-drop-table test > $MYSQLTEST_VARDIR/tmp/mdev33727.sql
+
+# first let's verify it can be loaded not only by mariadb client
+--source $MYSQLTEST_VARDIR/tmp/mdev33727.sql
+
+# and now test the mariadb client sandbox protection
+--append_file $MYSQLTEST_VARDIR/tmp/mdev33727.sql
+\! echo foo
+EOF
+--error 1
+--exec $MYSQL test < $MYSQLTEST_VARDIR/tmp/mdev33727.sql 2>&1
+--remove_file $MYSQLTEST_VARDIR/tmp/mdev33727.sql
+drop table t1;
+
+--echo # End of 10.5 tests
+
+--echo #
+--echo # MDEV-16733 mysqldump --tab and --xml options are conflicting
+--echo #
--replace_result mariadb-dump.exe mariadb-dump
--error 1
--exec $MYSQL_DUMP --xml --tab=$MYSQLTEST_VARDIR/tmp 2>&1
+
+--echo # End of 10.11 tests
diff --git a/mysql-test/main/openssl_1.result b/mysql-test/main/openssl_1.result
index be6c2998..b022ce23 100644
--- a/mysql-test/main/openssl_1.result
+++ b/mysql-test/main/openssl_1.result
@@ -77,6 +77,7 @@ DROP TABLE thread_status;
SET GLOBAL event_scheduler=0;
CREATE TABLE t1(a int);
INSERT INTO t1 VALUES (1), (2);
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -113,6 +114,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@@ -149,6 +151,7 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
diff --git a/mysql-test/main/openssl_1.test b/mysql-test/main/openssl_1.test
index 9232868b..24525287 100644
--- a/mysql-test/main/openssl_1.test
+++ b/mysql-test/main/openssl_1.test
@@ -68,7 +68,7 @@ drop table t1;
# Test that we can't open connection to server if we are using
# a different cacert
#
---exec echo "this query should not execute;" > $MYSQLTEST_VARDIR/tmp/test.sql
+--write_line "this query should not execute;" $MYSQLTEST_VARDIR/tmp/test.sql
# Handle that openssl gives different error messages from YaSSL.
--replace_regex /2026 TLS\/SSL error.*/2026 TLS\/SSL error: xxxx/
--error 1
diff --git a/mysql-test/main/opt_trace.result b/mysql-test/main/opt_trace.result
index aeaff29a..3c90e97c 100644
--- a/mysql-test/main/opt_trace.result
+++ b/mysql-test/main/opt_trace.result
@@ -1609,6 +1609,12 @@ EXPLAIN SELECT MIN(d) FROM t1 where b=2 and c=3 group by a {
},
{
"test_if_skip_sort_order": []
+ },
+ {
+ "prepare_sum_aggregators": {
+ "function": "min(t1.d)",
+ "aggregator_type": "simple"
+ }
}
]
}
@@ -1818,6 +1824,18 @@ EXPLAIN SELECT id,MIN(a),MAX(a) FROM t1 WHERE a>=20010104e0 GROUP BY id {
},
{
"test_if_skip_sort_order": []
+ },
+ {
+ "prepare_sum_aggregators": {
+ "function": "min(t1.a)",
+ "aggregator_type": "simple"
+ }
+ },
+ {
+ "prepare_sum_aggregators": {
+ "function": "max(t1.a)",
+ "aggregator_type": "simple"
+ }
}
]
}
@@ -10528,6 +10546,25 @@ JS
drop table t1,t2,t3,t10,t11;
set optimizer_trace=DEFAULT;
#
+# MDEV-29179 Condition pushdown from HAVING into WHERE is not shown in optimizer trace
+#
+CREATE TABLE t1 (a INT, b VARCHAR(1), KEY (a), KEY(b,a)) ENGINE=MEMORY;
+INSERT INTO t1 VALUES (4,'n'),(1,'h'),(NULL,'w');
+SET optimizer_trace= 'enabled=on';
+SELECT b, a FROM t1 WHERE b <> 'p' OR a = 4 GROUP BY b, a HAVING a <= 7;
+b a
+h 1
+n 4
+SELECT json_detailed(json_extract(trace, '$**.steps[*].join_optimization.steps[*].condition_pushdown_from_having') ) exp1, JSON_VALID(trace) exp2 FROM information_schema.optimizer_trace;
+exp1 exp2
+[
+ {
+ "conds": "(t1.b <> 'p' or multiple equal(4, t1.a)) and t1.a <= 7",
+ "having": null
+ }
+] 1
+DROP TABLE t1;
+#
# End of 10.4 tests
#
set optimizer_trace='enabled=on';
diff --git a/mysql-test/main/opt_trace.test b/mysql-test/main/opt_trace.test
index 7b0ee5be..58a6b23d 100644
--- a/mysql-test/main/opt_trace.test
+++ b/mysql-test/main/opt_trace.test
@@ -804,6 +804,16 @@ drop table t1,t2,t3,t10,t11;
set optimizer_trace=DEFAULT;
--echo #
+--echo # MDEV-29179 Condition pushdown from HAVING into WHERE is not shown in optimizer trace
+--echo #
+
+CREATE TABLE t1 (a INT, b VARCHAR(1), KEY (a), KEY(b,a)) ENGINE=MEMORY;
+INSERT INTO t1 VALUES (4,'n'),(1,'h'),(NULL,'w');
+SET optimizer_trace= 'enabled=on';
+SELECT b, a FROM t1 WHERE b <> 'p' OR a = 4 GROUP BY b, a HAVING a <= 7; SELECT json_detailed(json_extract(trace, '$**.steps[*].join_optimization.steps[*].condition_pushdown_from_having') ) exp1, JSON_VALID(trace) exp2 FROM information_schema.optimizer_trace;
+DROP TABLE t1;
+
+--echo #
--echo # End of 10.4 tests
--echo #
diff --git a/mysql-test/main/partition.result b/mysql-test/main/partition.result
index 4f2a55ad..4c762a1d 100644
--- a/mysql-test/main/partition.result
+++ b/mysql-test/main/partition.result
@@ -2063,7 +2063,6 @@ ALTER TABLE t1 ANALYZE PARTITION p1 EXTENDED;
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 'EXTENDED' at line 1
ALTER TABLE t1 ANALYZE PARTITION p1;
Table Op Msg_type Msg_text
-test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
ALTER TABLE t1 CHECK PARTITION p1;
Table Op Msg_type Msg_text
diff --git a/mysql-test/main/partition_binlog.result b/mysql-test/main/partition_binlog.result
index 45cd636c..5ecccde4 100644
--- a/mysql-test/main/partition_binlog.result
+++ b/mysql-test/main/partition_binlog.result
@@ -27,7 +27,6 @@ Table Op Msg_type Msg_text
test.t1 repair error Wrong partition name or partition list
ALTER TABLE t1 ANALYZE PARTITION p0;
Table Op Msg_type Msg_text
-test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
ALTER TABLE t1 CHECK PARTITION p0;
Table Op Msg_type Msg_text
diff --git a/mysql-test/main/plugin_auth.result b/mysql-test/main/plugin_auth.result
index 12a5156e..9a13b9ba 100644
--- a/mysql-test/main/plugin_auth.result
+++ b/mysql-test/main/plugin_auth.result
@@ -338,6 +338,7 @@ FLUSH PRIVILEGES;
# Executing 'mysqladmin'
mysqld is alive
# Executing 'mysqldump'
+/*!999999\- enable the sandbox mode */
# Executing 'mysql_upgrade'
#
# Bug #59657: Move the client authentication_pam plugin into the
diff --git a/mysql-test/main/plugin_loaderr.test b/mysql-test/main/plugin_loaderr.test
index 85621ad0..1623630b 100644
--- a/mysql-test/main/plugin_loaderr.test
+++ b/mysql-test/main/plugin_loaderr.test
@@ -13,14 +13,14 @@ FROM INFORMATION_SCHEMA.PLUGINS WHERE plugin_name = 'innodb';
--echo #
--echo # MDEV-6351 --plugin=force has no effect for built-in plugins
--echo #
---exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--shutdown_server
--source include/wait_until_disconnected.inc
--error 1
--exec $MYSQLD_CMD --innodb=force --innodb-page-size=6000 --disable-log-error
---exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
+--write_line restart $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--enable_reconnect
--source include/wait_until_connected_again.inc
--disable_reconnect
diff --git a/mysql-test/main/ps.result b/mysql-test/main/ps.result
index 7fd30f3e..fb3681ca 100644
--- a/mysql-test/main/ps.result
+++ b/mysql-test/main/ps.result
@@ -5812,5 +5812,186 @@ GROUP_CONCAT(@x)
0
DROP TABLE t;
#
+# MDEV-15703: Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
+#
+PREPARE stmt FROM 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)';
+EXECUTE stmt USING DEFAULT;
+ERROR HY000: Default/ignore value is not supported for such parameter usage
+DEALLOCATE PREPARE stmt;
+PREPARE stmt FROM 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)';
+EXECUTE stmt USING IGNORE;
+ERROR HY000: Default/ignore value is not supported for such parameter usage
+DEALLOCATE PREPARE stmt;
+EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT;
+ERROR HY000: Default/ignore value is not supported for such parameter usage
+EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING IGNORE;
+ERROR HY000: Default/ignore value is not supported for such parameter usage
+EXECUTE IMMEDIATE 'BEGIN NOT ATOMIC DECLARE a INT DEFAULT ?; END' USING DEFAULT;
+ERROR HY000: Default/ignore value is not supported for such parameter usage
+EXECUTE IMMEDIATE 'BEGIN NOT ATOMIC DECLARE a INT DEFAULT ?; END' USING IGNORE;
+ERROR HY000: Default/ignore value is not supported for such parameter usage
+CREATE PROCEDURE p1(a INT) SELECT 1;
+EXECUTE IMMEDIATE 'CALL p1(?)' USING DEFAULT;
+ERROR HY000: Default/ignore value is not supported for such parameter usage
+EXECUTE IMMEDIATE 'CALL p1(?)' USING IGNORE;
+ERROR HY000: Default/ignore value is not supported for such parameter usage
+DROP PROCEDURE p1;
+EXECUTE IMMEDIATE 'SELECT ? UNION SELECT 1' USING DEFAULT;
+ERROR HY000: Default/ignore value is not supported for such parameter usage
+EXECUTE IMMEDIATE 'SELECT ? UNION SELECT 1' USING IGNORE;
+ERROR HY000: Default/ignore value is not supported for such parameter usage
+EXECUTE IMMEDIATE 'SELECT * FROM (SELECT ? UNION ALL SELECT 1) AS derived' USING DEFAULT;
+ERROR HY000: Default/ignore value is not supported for such parameter usage
+EXECUTE IMMEDIATE 'SELECT * FROM (SELECT ? UNION ALL SELECT 1) AS derived' USING IGNORE;
+ERROR HY000: Default/ignore value is not supported for such parameter usage
+EXECUTE IMMEDIATE 'SELECT * FROM (SELECT ? UNION DISTINCT SELECT 1) AS derived' USING DEFAULT;
+ERROR HY000: Default/ignore value is not supported for such parameter usage
+EXECUTE IMMEDIATE 'SELECT * FROM (SELECT ? UNION DISTINCT SELECT 1) AS derived' USING IGNORE;
+ERROR HY000: Default/ignore value is not supported for such parameter usage
+# multi-update and DEFAULT
+CREATE TABLE t1 (a INT, b INT DEFAULT a);
+INSERT into t1 VALUES (1,2),(2,3);
+CREATE TABLE t2 (a INT, b INT DEFAULT a);
+INSERT INTO t2 VALUES (1,10),(2,30);
+UPDATE t1,t2 SET t1.b = DEFAULT, t2.b = DEFAULT WHERE t1.a=t2.a;
+SELECT * FROM t1;
+a b
+1 1
+2 2
+SELECT * FROM t2;
+a b
+1 1
+2 2
+# re-check the case for Prepared Statement with parameters
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+INSERT INTO t1 VALUES (1,2),(2,3);
+INSERT INTO t2 VALUES (1,10),(2,30);
+EXECUTE IMMEDIATE 'UPDATE t1,t2 SET t1.b = ?, t2.b = ? WHERE t1.a=t2.a' USING DEFAULT, DEFAULT;
+SELECT * FROM t1;
+a b
+1 1
+2 2
+SELECT * FROM t2;
+a b
+1 1
+2 2
+DROP TABLE t1, t2;
+# multi-update and IGNORE
+CREATE TABLE t1 (a INT, b INT default a);
+INSERT INTO t1 VALUES (1,2),(2,3);
+CREATE TABLE t2 (a INT, b INT default a);
+INSERT INTO t2 VALUES (1,10),(2,30);
+UPDATE t1,t2 SET t1.b = IGNORE, t2.b = IGNORE WHERE t1.a=t2.a;
+SELECT * FROM t1;
+a b
+1 2
+2 3
+SELECT * FROM t2;
+a b
+1 NULL
+2 NULL
+# re-check the case for Prepared Statement with parameters
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+INSERT INTO t1 VALUES (1,2),(2,3);
+INSERT INTO t2 VALUES (1,10),(2,30);
+EXECUTE IMMEDIATE 'UPDATE t1,t2 SET t1.b = ?, t2.b = ? WHERE t1.a=t2.a' USING IGNORE, IGNORE;
+SELECT * FROM t1;
+a b
+1 2
+2 3
+SELECT * FROM t2;
+a b
+1 10
+2 30
+DROP TABLE t1, t2;
+# multi-update and DEFAULT parameter (no default)
+CREATE TABLE t1 (a INT, b INT NOT NULL);
+INSERT INTO t1 VALUES (1,2),(2,3);
+CREATE TABLE t2 (a INT, b INT NOT NULL);
+INSERT INTO t2 VALUES (1,10),(2,30);
+EXECUTE IMMEDIATE 'UPDATE t1,t2 SET t1.b = ?, t2.b = ? WHERE t1.a=t2.a' USING DEFAULT, DEFAULT;
+ERROR HY000: Field 'b' doesn't have a default value
+DROP TABLE t1, t2;
+# multi-update and IGNORE parameter (no default)
+CREATE TABLE t1 (a INT, b INT NOT NULL);
+INSERT INTO t1 VALUES (1,2),(2,3);
+CREATE TABLE t2 (a INT, b INT NOT NULL);
+INSERT INTO t2 VALUES (1,10),(2,30);
+EXECUTE IMMEDIATE 'UPDATE t1,t2 SET t1.b = ?, t2.b = ? WHERE t1.a=t2.a' USING IGNORE, IGNORE;
+SELECT * FROM t1;
+a b
+1 2
+2 3
+SELECT * FROM t2;
+a b
+1 10
+2 30
+DROP TABLE t1, t2;
+#
+# MDEV-33549: Incorrect handling of UPDATE in PS mode in case a table's colum declared as NOT NULL
+#
+CREATE TABLE t1 (a INT, b INT DEFAULT NULL);
+INSERT INTO t1 VALUES (20, 30);
+EXECUTE IMMEDIATE 'UPDATE t1 SET b=?' USING DEFAULT;
+SELECT * FROM t1;
+a b
+20 NULL
+# Run twice the same update in PS mode to check
+# that no memory relating issues taken place.
+PREPARE stmt FROM 'UPDATE t1 SET b=?';
+EXECUTE stmt USING DEFAULT;
+EXECUTE stmt USING DEFAULT;
+# Clean up
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+# The same test for multi-table update
+CREATE TABLE t1 (a INT, b INT DEFAULT NULL);
+CREATE TABLE t2 (a INT, c INT DEFAULT NULL);
+INSERT INTO t1 VALUES (20, 30);
+INSERT INTO t2 VALUES (20, 30);
+EXECUTE IMMEDIATE 'UPDATE t1,t2 SET b=? WHERE t1.a=t2.a' USING DEFAULT;
+SELECT * FROM t1;
+a b
+20 NULL
+# Run twice the same multi-table update in PS mode to check
+# that no memory relating issues taken place.
+PREPARE stmt FROM 'UPDATE t1,t2 SET b=? WHERE t1.a=t2.a';
+EXECUTE stmt USING DEFAULT;
+EXECUTE stmt USING DEFAULT;
+DEALLOCATE PREPARE stmt;
+# Clean up
+DROP TABLE t1;
+# This time checks that a default value for table's column
+# represented by a function call is handled correctly on UPDATE in PS mode
+CREATE TABLE t1 (a INT, b INT DEFAULT MOD(a, 3));
+INSERT INTO t1 VALUES (20, 30);
+EXECUTE IMMEDIATE 'UPDATE t1, t2 SET b=? WHERE t1.a=t2.a' USING DEFAULT;
+SELECT * FROM t1;
+a b
+20 2
+# Run twice the same multi-table update in PS mode to check
+# that no memory relating issues taken place.
+PREPARE stmt FROM 'UPDATE t1, t2 SET b=? WHERE t1.a=t2.a';
+EXECUTE stmt USING DEFAULT;
+EXECUTE stmt USING DEFAULT;
+# Clean up
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1, t2;
+# MDEV-33218: Assertion `active_arena->is_stmt_prepare_or_first_stmt_execute() || active_arena->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed. in st_select_lex::fix_prepare_information
+CREATE TABLE t1 AS SELECT 1 f;
+PREPARE stmt FROM 'SHOW CREATE TABLE t1';
+DROP TABLE t1;
+EXECUTE stmt;
+ERROR 42S02: Table 'test.t1' doesn't exist
+CREATE VIEW t1 AS SELECT 1;
+EXECUTE stmt;
+View Create View character_set_client collation_connection
+t1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `t1` AS select 1 AS `1` latin1 latin1_swedish_ci
+# Clean up
+DEALLOCATE PREPARE stmt;
+DROP VIEW t1;
+#
# End of 10.4 tests
#
diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test
index 675c5102..c7568f73 100644
--- a/mysql-test/main/ps.test
+++ b/mysql-test/main/ps.test
@@ -5249,5 +5249,190 @@ EXECUTE IMMEDIATE 'SELECT GROUP_CONCAT(@x) FROM t GROUP BY @x := f';
DROP TABLE t;
--echo #
+--echo # MDEV-15703: Crash in EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT
+--echo #
+
+PREPARE stmt FROM 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)';
+--error ER_INVALID_DEFAULT_PARAM
+EXECUTE stmt USING DEFAULT;
+DEALLOCATE PREPARE stmt;
+
+PREPARE stmt FROM 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)';
+--error ER_INVALID_DEFAULT_PARAM
+EXECUTE stmt USING IGNORE;
+DEALLOCATE PREPARE stmt;
+
+--error ER_INVALID_DEFAULT_PARAM
+EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING DEFAULT;
+
+--error ER_INVALID_DEFAULT_PARAM
+EXECUTE IMMEDIATE 'CREATE OR REPLACE TABLE t1 (a INT DEFAULT ?)' USING IGNORE;
+
+--error ER_INVALID_DEFAULT_PARAM
+EXECUTE IMMEDIATE 'BEGIN NOT ATOMIC DECLARE a INT DEFAULT ?; END' USING DEFAULT;
+
+--error ER_INVALID_DEFAULT_PARAM
+EXECUTE IMMEDIATE 'BEGIN NOT ATOMIC DECLARE a INT DEFAULT ?; END' USING IGNORE;
+
+CREATE PROCEDURE p1(a INT) SELECT 1;
+--error ER_INVALID_DEFAULT_PARAM
+EXECUTE IMMEDIATE 'CALL p1(?)' USING DEFAULT;
+--error ER_INVALID_DEFAULT_PARAM
+EXECUTE IMMEDIATE 'CALL p1(?)' USING IGNORE;
+DROP PROCEDURE p1;
+
+--error ER_INVALID_DEFAULT_PARAM
+EXECUTE IMMEDIATE 'SELECT ? UNION SELECT 1' USING DEFAULT;
+--error ER_INVALID_DEFAULT_PARAM
+EXECUTE IMMEDIATE 'SELECT ? UNION SELECT 1' USING IGNORE;
+
+--error ER_INVALID_DEFAULT_PARAM
+EXECUTE IMMEDIATE 'SELECT * FROM (SELECT ? UNION ALL SELECT 1) AS derived' USING DEFAULT;
+--error ER_INVALID_DEFAULT_PARAM
+EXECUTE IMMEDIATE 'SELECT * FROM (SELECT ? UNION ALL SELECT 1) AS derived' USING IGNORE;
+
+--error ER_INVALID_DEFAULT_PARAM
+EXECUTE IMMEDIATE 'SELECT * FROM (SELECT ? UNION DISTINCT SELECT 1) AS derived' USING DEFAULT;
+--error ER_INVALID_DEFAULT_PARAM
+EXECUTE IMMEDIATE 'SELECT * FROM (SELECT ? UNION DISTINCT SELECT 1) AS derived' USING IGNORE;
+
+--echo # multi-update and DEFAULT
+CREATE TABLE t1 (a INT, b INT DEFAULT a);
+INSERT into t1 VALUES (1,2),(2,3);
+CREATE TABLE t2 (a INT, b INT DEFAULT a);
+INSERT INTO t2 VALUES (1,10),(2,30);
+
+UPDATE t1,t2 SET t1.b = DEFAULT, t2.b = DEFAULT WHERE t1.a=t2.a;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+--echo # re-check the case for Prepared Statement with parameters
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+INSERT INTO t1 VALUES (1,2),(2,3);
+INSERT INTO t2 VALUES (1,10),(2,30);
+
+EXECUTE IMMEDIATE 'UPDATE t1,t2 SET t1.b = ?, t2.b = ? WHERE t1.a=t2.a' USING DEFAULT, DEFAULT;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+# Cleanup
+DROP TABLE t1, t2;
+
+--echo # multi-update and IGNORE
+CREATE TABLE t1 (a INT, b INT default a);
+INSERT INTO t1 VALUES (1,2),(2,3);
+CREATE TABLE t2 (a INT, b INT default a);
+INSERT INTO t2 VALUES (1,10),(2,30);
+
+UPDATE t1,t2 SET t1.b = IGNORE, t2.b = IGNORE WHERE t1.a=t2.a;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+--echo # re-check the case for Prepared Statement with parameters
+TRUNCATE TABLE t1;
+TRUNCATE TABLE t2;
+INSERT INTO t1 VALUES (1,2),(2,3);
+INSERT INTO t2 VALUES (1,10),(2,30);
+
+EXECUTE IMMEDIATE 'UPDATE t1,t2 SET t1.b = ?, t2.b = ? WHERE t1.a=t2.a' USING IGNORE, IGNORE;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+# Cleanup
+DROP TABLE t1, t2;
+
+--echo # multi-update and DEFAULT parameter (no default)
+CREATE TABLE t1 (a INT, b INT NOT NULL);
+INSERT INTO t1 VALUES (1,2),(2,3);
+CREATE TABLE t2 (a INT, b INT NOT NULL);
+INSERT INTO t2 VALUES (1,10),(2,30);
+
+--error ER_NO_DEFAULT_FOR_FIELD
+EXECUTE IMMEDIATE 'UPDATE t1,t2 SET t1.b = ?, t2.b = ? WHERE t1.a=t2.a' USING DEFAULT, DEFAULT;
+
+# Cleanup
+DROP TABLE t1, t2;
+
+--echo # multi-update and IGNORE parameter (no default)
+CREATE TABLE t1 (a INT, b INT NOT NULL);
+INSERT INTO t1 VALUES (1,2),(2,3);
+CREATE TABLE t2 (a INT, b INT NOT NULL);
+INSERT INTO t2 VALUES (1,10),(2,30);
+
+EXECUTE IMMEDIATE 'UPDATE t1,t2 SET t1.b = ?, t2.b = ? WHERE t1.a=t2.a' USING IGNORE, IGNORE;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+# Cleanup
+DROP TABLE t1, t2;
+
+--echo #
+--echo # MDEV-33549: Incorrect handling of UPDATE in PS mode in case a table's colum declared as NOT NULL
+--echo #
+
+CREATE TABLE t1 (a INT, b INT DEFAULT NULL);
+INSERT INTO t1 VALUES (20, 30);
+EXECUTE IMMEDIATE 'UPDATE t1 SET b=?' USING DEFAULT;
+SELECT * FROM t1;
+
+--echo # Run twice the same update in PS mode to check
+--echo # that no memory relating issues taken place.
+PREPARE stmt FROM 'UPDATE t1 SET b=?';
+EXECUTE stmt USING DEFAULT;
+EXECUTE stmt USING DEFAULT;
+
+--echo # Clean up
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1;
+
+--echo # The same test for multi-table update
+CREATE TABLE t1 (a INT, b INT DEFAULT NULL);
+CREATE TABLE t2 (a INT, c INT DEFAULT NULL);
+
+INSERT INTO t1 VALUES (20, 30);
+INSERT INTO t2 VALUES (20, 30);
+
+EXECUTE IMMEDIATE 'UPDATE t1,t2 SET b=? WHERE t1.a=t2.a' USING DEFAULT;
+SELECT * FROM t1;
+--echo # Run twice the same multi-table update in PS mode to check
+--echo # that no memory relating issues taken place.
+PREPARE stmt FROM 'UPDATE t1,t2 SET b=? WHERE t1.a=t2.a';
+EXECUTE stmt USING DEFAULT;
+EXECUTE stmt USING DEFAULT;
+DEALLOCATE PREPARE stmt;
+--echo # Clean up
+DROP TABLE t1;
+
+--echo # This time checks that a default value for table's column
+--echo # represented by a function call is handled correctly on UPDATE in PS mode
+CREATE TABLE t1 (a INT, b INT DEFAULT MOD(a, 3));
+INSERT INTO t1 VALUES (20, 30);
+EXECUTE IMMEDIATE 'UPDATE t1, t2 SET b=? WHERE t1.a=t2.a' USING DEFAULT;
+SELECT * FROM t1;
+
+--echo # Run twice the same multi-table update in PS mode to check
+--echo # that no memory relating issues taken place.
+PREPARE stmt FROM 'UPDATE t1, t2 SET b=? WHERE t1.a=t2.a';
+EXECUTE stmt USING DEFAULT;
+EXECUTE stmt USING DEFAULT;
+
+--echo # Clean up
+DEALLOCATE PREPARE stmt;
+DROP TABLE t1, t2;
+
+--echo # MDEV-33218: Assertion `active_arena->is_stmt_prepare_or_first_stmt_execute() || active_arena->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed. in st_select_lex::fix_prepare_information
+CREATE TABLE t1 AS SELECT 1 f;
+PREPARE stmt FROM 'SHOW CREATE TABLE t1';
+DROP TABLE t1;
+--error ER_NO_SUCH_TABLE
+EXECUTE stmt;
+CREATE VIEW t1 AS SELECT 1;
+EXECUTE stmt;
+--echo # Clean up
+DEALLOCATE PREPARE stmt;
+DROP VIEW t1;
+
+--echo #
--echo # End of 10.4 tests
--echo #
diff --git a/mysql-test/main/ps_2myisam.result b/mysql-test/main/ps_2myisam.result
index 256665ce..ec365498 100644
--- a/mysql-test/main/ps_2myisam.result
+++ b/mysql-test/main/ps_2myisam.result
@@ -1798,7 +1798,7 @@ t5 CREATE TABLE `t5` (
`param09` longtext DEFAULT NULL,
`const10` bigint(17) DEFAULT NULL,
`param10` bigint(20) DEFAULT NULL,
- `const11` int(4) DEFAULT NULL,
+ `const11` int(5) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
`param12` bigint(20) DEFAULT NULL,
@@ -1828,7 +1828,7 @@ def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8
def test t5 t5 const10 const10 8 17 9 Y 32768 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
-def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
+def test t5 t5 const11 const11 3 5 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63
diff --git a/mysql-test/main/ps_3innodb.result b/mysql-test/main/ps_3innodb.result
index 675587e0..1c98a59c 100644
--- a/mysql-test/main/ps_3innodb.result
+++ b/mysql-test/main/ps_3innodb.result
@@ -1781,7 +1781,7 @@ t5 CREATE TABLE `t5` (
`param09` longtext DEFAULT NULL,
`const10` bigint(17) DEFAULT NULL,
`param10` bigint(20) DEFAULT NULL,
- `const11` int(4) DEFAULT NULL,
+ `const11` int(5) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
`param12` bigint(20) DEFAULT NULL,
@@ -1811,7 +1811,7 @@ def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8
def test t5 t5 const10 const10 8 17 9 Y 32768 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
-def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
+def test t5 t5 const11 const11 3 5 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63
diff --git a/mysql-test/main/ps_4heap.result b/mysql-test/main/ps_4heap.result
index dcde7613..db182536 100644
--- a/mysql-test/main/ps_4heap.result
+++ b/mysql-test/main/ps_4heap.result
@@ -1782,7 +1782,7 @@ t5 CREATE TABLE `t5` (
`param09` longtext DEFAULT NULL,
`const10` bigint(17) DEFAULT NULL,
`param10` bigint(20) DEFAULT NULL,
- `const11` int(4) DEFAULT NULL,
+ `const11` int(5) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
`param12` bigint(20) DEFAULT NULL,
@@ -1812,7 +1812,7 @@ def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8
def test t5 t5 const10 const10 8 17 9 Y 32768 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
-def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
+def test t5 t5 const11 const11 3 5 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63
diff --git a/mysql-test/main/ps_5merge.result b/mysql-test/main/ps_5merge.result
index c9d33dbb..963a3a60 100644
--- a/mysql-test/main/ps_5merge.result
+++ b/mysql-test/main/ps_5merge.result
@@ -1719,7 +1719,7 @@ t5 CREATE TABLE `t5` (
`param09` longtext DEFAULT NULL,
`const10` bigint(17) DEFAULT NULL,
`param10` bigint(20) DEFAULT NULL,
- `const11` int(4) DEFAULT NULL,
+ `const11` int(5) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
`param12` bigint(20) DEFAULT NULL,
@@ -1749,7 +1749,7 @@ def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8
def test t5 t5 const10 const10 8 17 9 Y 32768 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
-def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
+def test t5 t5 const11 const11 3 5 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63
@@ -5087,7 +5087,7 @@ t5 CREATE TABLE `t5` (
`param09` longtext DEFAULT NULL,
`const10` bigint(17) DEFAULT NULL,
`param10` bigint(20) DEFAULT NULL,
- `const11` int(4) DEFAULT NULL,
+ `const11` int(5) DEFAULT NULL,
`param11` bigint(20) DEFAULT NULL,
`const12` binary(0) DEFAULT NULL,
`param12` bigint(20) DEFAULT NULL,
@@ -5117,7 +5117,7 @@ def test t5 t5 const09 const09 12 19 19 Y 128 0 63
def test t5 t5 param09 param09 252 4294967295 19 Y 16 0 8
def test t5 t5 const10 const10 8 17 9 Y 32768 0 63
def test t5 t5 param10 param10 8 20 9 Y 32768 0 63
-def test t5 t5 const11 const11 3 4 4 Y 32768 0 63
+def test t5 t5 const11 const11 3 5 4 Y 32768 0 63
def test t5 t5 param11 param11 8 20 4 Y 32768 0 63
def test t5 t5 const12 const12 254 0 0 Y 128 0 63
def test t5 t5 param12 param12 8 20 0 Y 32768 0 63
diff --git a/mysql-test/main/query_cache.result b/mysql-test/main/query_cache.result
index f78a6ccc..f68f619f 100644
--- a/mysql-test/main/query_cache.result
+++ b/mysql-test/main/query_cache.result
@@ -2208,12 +2208,42 @@ Qcache_queries_in_cache 0
DROP FUNCTION foo;
drop table t1;
#
+# MDEV-33861: main.query_cache fails with embedded after
+# enabling WITH_PROTECT_STATEMENT_MEMROOT
+#
+create table t1 (s1 int);
+create procedure f3 () begin
+select * from t1;
+end;
+//
+create procedure f4 () begin
+select * from t1;
+end;
+//
+Call f4();
+s1
+cAll f3();
+s1
+insert into t1 values (2);
+caLl f3();
+s1
+2
+drop procedure f3;
+drop procedure f4;
+drop table t1;
+#
+# End of 10.4 tests
+#
+#
# MDEV-24858 SIGABRT in DbugExit from my_malloc in Query_cache::init_cache Regression
#
SET @qc= @@query_cache_size;
set global Query_cache_size=18446744073709547520;
SET GLOBAL query_cache_size= @qc;
#
+# End of 10.5 tests
+#
+#
# MDEV-22301 JSON_TABLE: Queries are not inserted into query cache.
#
create table t1 (a text);
@@ -2239,6 +2269,7 @@ DROP TABLE t;
restore defaults
SET GLOBAL query_cache_type= default;
SET GLOBAL query_cache_size=@save_query_cache_size;
+# End of 10.6 tests
#
# MDEV-29028: Queries using RANDOM_BYTES get stored in query cache
#
@@ -2261,6 +2292,4 @@ improbable
0
drop table t1;
set global query_cache_type= @qcache;
-#
# End of 10.10 tests
-#
diff --git a/mysql-test/main/query_cache.test b/mysql-test/main/query_cache.test
index 08756b80..feb9ecf5 100644
--- a/mysql-test/main/query_cache.test
+++ b/mysql-test/main/query_cache.test
@@ -1808,6 +1808,40 @@ DROP FUNCTION foo;
drop table t1;
--echo #
+--echo # MDEV-33861: main.query_cache fails with embedded after
+--echo # enabling WITH_PROTECT_STATEMENT_MEMROOT
+--echo #
+
+create table t1 (s1 int);
+--delimiter //
+create procedure f3 () begin
+select * from t1;
+end;
+//
+create procedure f4 () begin
+select * from t1;
+end;
+//
+--delimiter ;
+
+Call f4();
+
+cAll f3();
+
+insert into t1 values (2);
+
+caLl f3();
+
+drop procedure f3;
+drop procedure f4;
+drop table t1;
+
+
+--echo #
+--echo # End of 10.4 tests
+--echo #
+
+--echo #
--echo # MDEV-24858 SIGABRT in DbugExit from my_malloc in Query_cache::init_cache Regression
--echo #
--disable_warnings
@@ -1817,6 +1851,10 @@ SET GLOBAL query_cache_size= @qc;
--enable_warnings
--echo #
+--echo # End of 10.5 tests
+--echo #
+
+--echo #
--echo # MDEV-22301 JSON_TABLE: Queries are not inserted into query cache.
--echo #
create table t1 (a text);
@@ -1838,6 +1876,8 @@ DROP TABLE t;
SET GLOBAL query_cache_type= default;
SET GLOBAL query_cache_size=@save_query_cache_size;
+--echo # End of 10.6 tests
+
--echo #
--echo # MDEV-29028: Queries using RANDOM_BYTES get stored in query cache
--echo #
@@ -1866,7 +1906,6 @@ select random_bytes(1024) = random_bytes(1024) as improbable;
drop table t1;
set global query_cache_type= @qcache;
---echo #
--echo # End of 10.10 tests
---echo #
+
--enable_ps2_protocol
diff --git a/mysql-test/main/read_only_innodb.result b/mysql-test/main/read_only_innodb.result
index cfc8f2ec..85aee640 100644
--- a/mysql-test/main/read_only_innodb.result
+++ b/mysql-test/main/read_only_innodb.result
@@ -70,7 +70,7 @@ UNLOCK TABLES;
DROP TABLE t1;
DROP USER test@localhost;
disconnect con1;
-echo End of 5.1 tests
+# End of 5.1 tests
#
# Bug#33669: Transactional temporary tables do not work under --read-only
#
@@ -244,3 +244,26 @@ connection default;
SET GLOBAL READ_ONLY = OFF;
DROP USER bug33669@localhost;
DROP DATABASE db1;
+# End of 5.5 tests
+#
+# MDEV-33889 Read only server throws error when running a create temporary table as select statement
+#
+create table t1(a int) engine=innodb;
+create user u1@localhost;
+grant insert, select, update, delete, create temporary tables on test.* to u1@localhost;
+insert into t1 values (1);
+set global read_only=1;
+connect u1,localhost,u1;
+set default_tmp_storage_engine=innodb;
+create temporary table tt1 (a int);
+create temporary table tt2 like t1;
+create temporary table tt3 as select * from t1;
+select * from tt3;
+a
+1
+disconnect u1;
+connection default;
+drop table t1;
+drop user u1@localhost;
+set global read_only=0;
+# End of 10.5 tests
diff --git a/mysql-test/main/read_only_innodb.test b/mysql-test/main/read_only_innodb.test
index e2c2979c..59af952d 100644
--- a/mysql-test/main/read_only_innodb.test
+++ b/mysql-test/main/read_only_innodb.test
@@ -103,7 +103,7 @@ DROP USER test@localhost;
disconnect con1;
---echo echo End of 5.1 tests
+--echo # End of 5.1 tests
--echo #
--echo # Bug#33669: Transactional temporary tables do not work under --read-only
@@ -250,3 +250,29 @@ SET GLOBAL READ_ONLY = OFF;
DROP USER bug33669@localhost;
DROP DATABASE db1;
+--echo # End of 5.5 tests
+
+--echo #
+--echo # MDEV-33889 Read only server throws error when running a create temporary table as select statement
+--echo #
+create table t1(a int) engine=innodb;
+create user u1@localhost;
+grant insert, select, update, delete, create temporary tables on test.* to u1@localhost;
+insert into t1 values (1);
+set global read_only=1;
+
+connect u1,localhost,u1;
+set default_tmp_storage_engine=innodb;
+
+create temporary table tt1 (a int);
+create temporary table tt2 like t1;
+create temporary table tt3 as select * from t1;
+select * from tt3;
+disconnect u1;
+
+connection default;
+drop table t1;
+drop user u1@localhost;
+set global read_only=0;
+
+--echo # End of 10.5 tests
diff --git a/mysql-test/main/rowid_filter_innodb.result b/mysql-test/main/rowid_filter_innodb.result
index db52e4dc..85a3008c 100644
--- a/mysql-test/main/rowid_filter_innodb.result
+++ b/mysql-test/main/rowid_filter_innodb.result
@@ -4170,5 +4170,105 @@ Warnings:
Note 1276 Field or reference 'test.t1.pk' of SELECT #2 was resolved in SELECT #1
Note 1003 /* select#1 */ select `test`.`t1`.`pk` AS `pk`,`test`.`t1`.`c1` AS `c1` from `test`.`t1` where !<expr_cache><`test`.`t1`.`c1`,`test`.`t1`.`pk`>(<in_optimizer>(`test`.`t1`.`c1`,<exists>(/* select#2 */ select `test`.`t2`.`c1` from `test`.`t2` join `test`.`t1` `a1` where `test`.`t2`.`i1` = `test`.`t1`.`pk` and `test`.`t2`.`i1` between 3 and 5 and trigcond(<cache>(`test`.`t1`.`c1`) = `test`.`t2`.`c1`))))
DROP TABLE t1,t2;
-set global innodb_stats_persistent= @stats.save;
+#
+# MDEV-31154: Fatal InnoDB error or assertion `!is_v' failure upon multi-update with indexed virtual column
+#
+# Test with auto generated Primary Key
+#
+SET @save_optimizer_switch= @@optimizer_switch;
+SET optimizer_switch='rowid_filter=on';
+CREATE TABLE t0(a int);
+INSERT INTO t0 SELECT seq FROM seq_1_to_20;
+ANALYZE TABLE t0 PERSISTENT FOR ALL;
+Table Op Msg_type Msg_text
+test.t0 analyze status Engine-independent statistics collected
+test.t0 analyze status OK
+CREATE TABLE t1 (
+a int,
+b int as (a * 2) VIRTUAL,
+f char(200), /* Filler */
+key (b),
+key (a)
+) engine=innodb;
+INSERT INTO t1 (a, f) SELECT seq, seq FROM seq_1_to_1000;
+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
+# Test for type 'ref|filter'
+EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 ALL NULL NULL NULL NULL 20 Using where
+1 SIMPLE t1 ref|filter b,a b|a 5|5 test.t0.a 1 (2%) Using where; Using rowid filter
+SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20;
+count(*)
+10
+EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 ALL NULL NULL NULL NULL 20 Using where
+1 SIMPLE t1 ref|filter b,a b|a 5|5 test.t0.a 1 (2%) Using where; Using rowid filter
+SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE;
+count(*)
+10
+# Test for type 'range|filter'
+EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range|filter b,a b|a 5|5 NULL 49 (10%) Using where; Using rowid filter
+SELECT count(*) FROM t1 WHERE a<100 and b <100;
+count(*)
+49
+EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range|filter b,a b|a 5|5 NULL 49 (10%) Using where; Using rowid filter
+SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE;
+count(*)
+49
+# Test with Primary Key
+#
+DROP TABLE t1;
+CREATE TABLE t1 (
+p int PRIMARY KEY AUTO_INCREMENT,
+a int,
+b int as (a * 2) VIRTUAL,
+f char(200), /* Filler */
+key (b),
+key (a)
+) engine=innodb;
+INSERT INTO t1 (a, f) SELECT seq, seq FROM seq_1_to_1000;
+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
+# Test for type 'ref|filter'
+EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 ALL NULL NULL NULL NULL 20 Using where
+1 SIMPLE t1 ref|filter b,a b|a 5|5 test.t0.a 1 (2%) Using where; Using rowid filter
+SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20;
+count(*)
+10
+EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t0 ALL NULL NULL NULL NULL 20 Using where
+1 SIMPLE t1 ref|filter b,a b|a 5|5 test.t0.a 1 (2%) Using where; Using rowid filter
+SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE;
+count(*)
+10
+# Test for type 'range|filter'
+EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range|filter b,a b|a 5|5 NULL 49 (10%) Using where; Using rowid filter
+SELECT count(*) FROM t1 WHERE a<100 and b <100;
+count(*)
+49
+EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 range|filter b,a b|a 5|5 NULL 49 (10%) Using where; Using rowid filter
+SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE;
+count(*)
+49
+SET optimizer_switch=@save_optimizer_switch;
+DROP TABLE t0, t1;
# End of 10.4 tests
+# End of 10.6 tests
+set global innodb_stats_persistent= @stats.save;
diff --git a/mysql-test/main/rowid_filter_innodb.test b/mysql-test/main/rowid_filter_innodb.test
index 6777baf8..b0d65837 100644
--- a/mysql-test/main/rowid_filter_innodb.test
+++ b/mysql-test/main/rowid_filter_innodb.test
@@ -1,6 +1,8 @@
--source include/no_valgrind_without_big.inc
--source include/have_innodb.inc
--source include/have_debug.inc
+--source include/have_sequence.inc
+--source include/innodb_stable_estimates.inc
SET SESSION DEFAULT_STORAGE_ENGINE='InnoDB';
@@ -683,6 +685,82 @@ eval EXPLAIN EXTENDED $q;
DROP TABLE t1,t2;
-set global innodb_stats_persistent= @stats.save;
+--echo #
+--echo # MDEV-31154: Fatal InnoDB error or assertion `!is_v' failure upon multi-update with indexed virtual column
+--echo #
+
+--echo # Test with auto generated Primary Key
+--echo #
+
+SET @save_optimizer_switch= @@optimizer_switch;
+SET optimizer_switch='rowid_filter=on';
+
+CREATE TABLE t0(a int);
+INSERT INTO t0 SELECT seq FROM seq_1_to_20;
+ANALYZE TABLE t0 PERSISTENT FOR ALL;
+
+CREATE TABLE t1 (
+ a int,
+ b int as (a * 2) VIRTUAL,
+ f char(200), /* Filler */
+ key (b),
+ key (a)
+) engine=innodb;
+
+INSERT INTO t1 (a, f) SELECT seq, seq FROM seq_1_to_1000;
+ANALYZE TABLE t1 PERSISTENT FOR ALL;
+
+--echo # Test for type 'ref|filter'
+EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20;
+SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20;
+
+EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE;
+SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE;
+
+--echo # Test for type 'range|filter'
+EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100;
+SELECT count(*) FROM t1 WHERE a<100 and b <100;
+
+EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE;
+SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE;
+
+--echo # Test with Primary Key
+--echo #
+
+DROP TABLE t1;
+CREATE TABLE t1 (
+ p int PRIMARY KEY AUTO_INCREMENT,
+ a int,
+ b int as (a * 2) VIRTUAL,
+ f char(200), /* Filler */
+ key (b),
+ key (a)
+) engine=innodb;
+
+INSERT INTO t1 (a, f) SELECT seq, seq FROM seq_1_to_1000;
+ANALYZE TABLE t1 PERSISTENT FOR ALL;
+
+--echo # Test for type 'ref|filter'
+EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20;
+SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20;
+
+EXPLAIN SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE;
+SELECT count(*) from t0,t1 WHERE t0.a=t1.b AND t1.a<20 FOR UPDATE;
+
+--echo # Test for type 'range|filter'
+EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100;
+SELECT count(*) FROM t1 WHERE a<100 and b <100;
+
+EXPLAIN SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE;
+SELECT count(*) FROM t1 WHERE a<100 and b <100 FOR UPDATE;
+
+SET optimizer_switch=@save_optimizer_switch;
+
+DROP TABLE t0, t1;
--echo # End of 10.4 tests
+
+--echo # End of 10.6 tests
+
+set global innodb_stats_persistent= @stats.save;
+
diff --git a/mysql-test/main/rpl_mysqldump_slave.result b/mysql-test/main/rpl_mysqldump_slave.result
index 9f93e3c4..8d6f0994 100644
--- a/mysql-test/main/rpl_mysqldump_slave.result
+++ b/mysql-test/main/rpl_mysqldump_slave.result
@@ -7,25 +7,33 @@ connection slave;
connection master;
use test;
connection slave;
+/*!999999\- enable the sandbox mode */
-- SET GLOBAL gtid_slave_pos='';
CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
+/*!999999\- enable the sandbox mode */
STOP ALL SLAVES;
-- SET GLOBAL gtid_slave_pos='';
CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
START ALL SLAVES;
+/*!999999\- enable the sandbox mode */
STOP ALL SLAVES;
-- SET GLOBAL gtid_slave_pos='';
CHANGE MASTER '' TO MASTER_HOST='127.0.0.1', MASTER_PORT=MASTER_MYPORT, MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
START ALL SLAVES;
start slave;
Warnings:
Note 1254 Slave is already running
+/*!999999\- enable the sandbox mode */
-- SET GLOBAL gtid_slave_pos='';
CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
start slave;
Warnings:
Note 1254 Slave is already running
-*** Test mysqldump --dump-slave GTID functionality.
+*** Test mysqldump --dump-slave GTID/non-gtid functionality.
connection master;
SET gtid_seq_no = 1000;
CREATE TABLE t1 (a INT PRIMARY KEY);
@@ -35,36 +43,182 @@ connection slave;
CREATE TABLE t2 (a INT PRIMARY KEY);
DROP TABLE t2;
-1. --dump-slave=1
+1. --dump-slave=1 --gtid
+/*!999999\- enable the sandbox mode */
SET GLOBAL gtid_slave_pos='0-1-1001';
CHANGE MASTER '' TO MASTER_USE_GTID=slave_pos;
-- CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
-2. --dump-slave=2
+1a. --dump-slave=1
+
+/*!999999\- enable the sandbox mode */
+-- SET GLOBAL gtid_slave_pos='0-1-1001';
+CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
+
+2. --dump-slave=2 --gtid
+
+/*!999999\- enable the sandbox mode */
-- SET GLOBAL gtid_slave_pos='0-1-1001';
-- CHANGE MASTER '' TO MASTER_USE_GTID=slave_pos;
-- CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
-*** Test mysqldump --master-data GTID functionality.
-1. --master-data=1
--- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START;
+2. --dump-slave=2
+
+/*!999999\- enable the sandbox mode */
+-- SET GLOBAL gtid_slave_pos='0-1-1001';
+-- CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
+*** Test mysqldump --master-data GTID/non-gtid functionality.
+
+1. --master-data=1 --gtid
+
+/*!999999\- enable the sandbox mode */
CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
SET GLOBAL gtid_slave_pos='0-2-1003';
+-- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START;
-2. --master-data=2
+1a. --master-data=1
--- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START;
+/*!999999\- enable the sandbox mode */
+-- SET GLOBAL gtid_slave_pos='0-2-1003';
+CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
+2. --master-data=2 --gtid
+
+/*!999999\- enable the sandbox mode */
-- CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
-- SET GLOBAL gtid_slave_pos='0-2-1003';
+-- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START;
-3. --master-data --single-transaction
+2a. --master-data=2
+/*!999999\- enable the sandbox mode */
+-- SET GLOBAL gtid_slave_pos='0-2-1003';
-- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
+3. --master-data --single-transaction --gtid
+
+/*!999999\- enable the sandbox mode */
CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
SET GLOBAL gtid_slave_pos='0-2-1003';
+-- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
+3a. --master-data --single-transaction
+
+/*!999999\- enable the sandbox mode */
+-- SET GLOBAL gtid_slave_pos='0-2-1003';
+CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
+4. --master-data=2 --dump-slave=2 --single-transaction --gtid (MDEV-4827)
+
+/*!999999\- enable the sandbox mode */
+-- MariaDB dump--
+-- Host: localhost Database: test
+-- ------------------------------------------------------
+-- Server version
+/*!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 */;
+
+-- Preferably use GTID to start replication from GTID position:
+
+-- CHANGE MASTER TO MASTER_USE_GTID=slave_pos;
+-- SET GLOBAL gtid_slave_pos='0-2-1003';
+
+--
+-- Alternately, following is the position of the binary logging from SHOW MASTER STATUS at point of backup.
+-- Use this when creating a replica of the primary server where the backup was made.
+-- The new server will be connecting to the primary server where the backup was taken.
+--
+
+-- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
+--
+-- The following is the SQL position of the replication taken from SHOW SLAVE STATUS at the time of backup.
+-- Use this position when creating a clone of, or replacement server, from where the backup was taken.
+-- This new server will connects to the same primary server(s).
+--
+-- GTID position to start replication:
+-- SET GLOBAL gtid_slave_pos='0-1-1001';
+
+-- Use only the MASTER_USE_GTID=slave_pos or MASTER_LOG_FILE/MASTER_LOG_POS in the statements below.
+
+-- CHANGE MASTER '' TO MASTER_USE_GTID=slave_pos;
+-- CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
+/*!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 */;
+
+-- Dump completed
+
+4a. --master-data=2 --dump-slave=2 --single-transaction (MDEV-4827)
+
+/*!999999\- enable the sandbox mode */
+-- MariaDB dump--
+-- Host: localhost Database: test
+-- ------------------------------------------------------
+-- Server version
+/*!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 */;
+
+-- Preferably use GTID to start replication from GTID position:
+
+-- SET GLOBAL gtid_slave_pos='0-2-1003';
+
+--
+-- Alternately, following is the position of the binary logging from SHOW MASTER STATUS at point of backup.
+-- Use this when creating a replica of the primary server where the backup was made.
+-- The new server will be connecting to the primary server where the backup was taken.
+--
+
+-- CHANGE MASTER TO MASTER_LOG_FILE='slave-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
+--
+-- The following is the SQL position of the replication taken from SHOW SLAVE STATUS at the time of backup.
+-- Use this position when creating a clone of, or replacement server, from where the backup was taken.
+-- This new server will connects to the same primary server(s).
+--
+-- GTID position to start replication:
+-- SET GLOBAL gtid_slave_pos='0-1-1001';
+-- CHANGE MASTER '' TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=BINLOG_START;
+
+/*!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 */;
+
+-- Dump completed
connection master;
CREATE TABLE t (
id int
@@ -77,8 +231,13 @@ include/stop_slave.inc
change master to master_use_gtid=slave_pos;
connection master;
# Ensuring the binlog dump thread is killed on primary...
--- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000002', MASTER_LOG_POS=BINLOG_START;
+/*!999999\- enable the sandbox mode */
-- SET GLOBAL gtid_slave_pos='0-1-1005';
+-- CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000002', MASTER_LOG_POS=BINLOG_START;
connection slave;
include/start_slave.inc
+connection master;
+connection slave;
+connection master;
+FOUND 1 matches in MDEV-33212.sql
include/rpl_end.inc
diff --git a/mysql-test/main/rpl_mysqldump_slave.test b/mysql-test/main/rpl_mysqldump_slave.test
index 0273e196..75bb85db 100644
--- a/mysql-test/main/rpl_mysqldump_slave.test
+++ b/mysql-test/main/rpl_mysqldump_slave.test
@@ -37,7 +37,7 @@ start slave;
start slave;
---echo *** Test mysqldump --dump-slave GTID functionality.
+--echo *** Test mysqldump --dump-slave GTID/non-gtid functionality.
--connection master
SET gtid_seq_no = 1000;
@@ -52,37 +52,80 @@ CREATE TABLE t2 (a INT PRIMARY KEY);
DROP TABLE t2;
--echo
---echo 1. --dump-slave=1
+--echo 1. --dump-slave=1 --gtid
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=1 --gtid test
--echo
---echo 2. --dump-slave=2
+--echo 1a. --dump-slave=1
+--echo
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=1 test
+
+--echo
+--echo 2. --dump-slave=2 --gtid
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=2 --gtid test
+--echo
+--echo 2. --dump-slave=2
+--echo
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=2 test
+
---echo *** Test mysqldump --master-data GTID functionality.
+--echo *** Test mysqldump --master-data GTID/non-gtid functionality.
--echo
---echo 1. --master-data=1
+--echo 1. --master-data=1 --gtid
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --master-data=1 --gtid test
--echo
---echo 2. --master-data=2
+--echo 1a. --master-data=1
+--echo
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec $MYSQL_DUMP_SLAVE --compact --master-data=1 test
+
+--echo
+--echo 2. --master-data=2 --gtid
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --master-data=2 --gtid test
--echo
---echo 3. --master-data --single-transaction
+--echo 2a. --master-data=2
+--echo
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec $MYSQL_DUMP_SLAVE --compact --master-data=2 test
+
+--echo
+--echo 3. --master-data --single-transaction --gtid
--echo
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
--exec $MYSQL_DUMP_SLAVE --compact --master-data --single-transaction --gtid test
+--echo
+--echo 3a. --master-data --single-transaction
+--echo
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
+--exec $MYSQL_DUMP_SLAVE --compact --master-data --single-transaction test
+
+--echo
+--echo 4. --master-data=2 --dump-slave=2 --single-transaction --gtid (MDEV-4827)
+--echo
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/ /MariaDB dump.*/MariaDB dump/ /Dump completed.*/Dump completed/ /Server version.*/Server version/
+--exec $MYSQL_DUMP_SLAVE --master-data=2 --dump-slave=2 --single-transaction --gtid test
+--echo
+
+--echo
+--echo 4a. --master-data=2 --dump-slave=2 --single-transaction (MDEV-4827)
+--echo
+--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/ /MariaDB dump.*/MariaDB dump/ /Dump completed.*/Dump completed/ /Server version.*/Server version/
+--exec $MYSQL_DUMP_SLAVE --master-data=2 --dump-slave=2 --single-transaction test
+--echo
#
# MDEV-32611 Added test for mysqldump --delete-master-logs option.
# This options is alias of
@@ -155,4 +198,20 @@ if ($postdump_first_binary_log_filename != $postdump_binlog_filename)
connection slave;
--source include/start_slave.inc
+# MDEV-33212: mysqldump uses MASTER_LOG_POS with dump-slave
+# The bug was that the MASTER_LOG_POS was wrong. So check that it is correct.
+--connection master
+--let $pos= query_get_value(SHOW MASTER STATUS, Position, 1)
+--sync_slave_with_master
+--connection master
+--exec $MYSQL_DUMP_SLAVE --compact --dump-slave test >$MYSQLTEST_VARDIR/tmp/MDEV-33212.sql
+--let SEARCH_RANGE=500000000
+--let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/MDEV-33212.sql
+--let SEARCH_PATTERN= MASTER_LOG_POS=$pos
+--let SEARCH_OUTPUT=count
+--source include/search_pattern_in_file.inc
+
+--remove_file $MYSQLTEST_VARDIR/tmp/MDEV-33212.sql
+
+
--source include/rpl_end.inc
diff --git a/mysql-test/main/secondary_key_costs.result b/mysql-test/main/secondary_key_costs.result
index 55c84705..dbdaaa3e 100644
--- a/mysql-test/main/secondary_key_costs.result
+++ b/mysql-test/main/secondary_key_costs.result
@@ -80,3 +80,38 @@ json_detailed(json_extract(@trace, '$**.considered_access_paths'))
]
]
drop table t1, name, flag2;
+select @@optimizer_adjust_secondary_key_costs;
+@@optimizer_adjust_secondary_key_costs
+
+set @@optimizer_adjust_secondary_key_costs=7;
+select @@optimizer_adjust_secondary_key_costs;
+@@optimizer_adjust_secondary_key_costs
+adjust_secondary_key_cost,disable_max_seek,disable_forced_index_in_group_by
+set @@optimizer_adjust_secondary_key_costs=default;
+#
+# MDEV-33306 Optimizer choosing incorrect index in 10.6, 10.5 but not in 10.4
+#
+create table t1 (a int primary key, b int, c int, d int, key(b),key(c)) engine=innodb;
+insert into t1 select seq, mod(seq,10), mod(seq,2), seq from seq_1_to_50000;
+explain select b, sum(d) from t1 where c=0 group by b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 index c b 5 NULL # Using where
+select b, sum(d) from t1 where c=0 group by b;
+b sum(d)
+0 125025000
+2 124985000
+4 124995000
+6 125005000
+8 125015000
+set @@optimizer_adjust_secondary_key_costs="disable_forced_index_in_group_by";
+explain select b, sum(d) from t1 where c=0 group by b;
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL c NULL NULL NULL # Using where; Using temporary; Using filesort
+select b, sum(d) from t1 where c=0 group by b;
+b sum(d)
+0 125025000
+2 124985000
+4 124995000
+6 125005000
+8 125015000
+drop table t1;
diff --git a/mysql-test/main/secondary_key_costs.test b/mysql-test/main/secondary_key_costs.test
index d3db1376..bf662d40 100644
--- a/mysql-test/main/secondary_key_costs.test
+++ b/mysql-test/main/secondary_key_costs.test
@@ -1,5 +1,6 @@
--source include/have_sequence.inc
--source include/not_embedded.inc
+--source include/have_innodb.inc
#
# Show the costs for rowid filter
@@ -51,3 +52,23 @@ select json_detailed(json_extract(@trace, '$**.considered_access_paths'));
--enable_ps_protocol
drop table t1, name, flag2;
+
+select @@optimizer_adjust_secondary_key_costs;
+set @@optimizer_adjust_secondary_key_costs=7;
+select @@optimizer_adjust_secondary_key_costs;
+set @@optimizer_adjust_secondary_key_costs=default;
+
+--echo #
+--echo # MDEV-33306 Optimizer choosing incorrect index in 10.6, 10.5 but not in 10.4
+--echo #
+
+create table t1 (a int primary key, b int, c int, d int, key(b),key(c)) engine=innodb;
+insert into t1 select seq, mod(seq,10), mod(seq,2), seq from seq_1_to_50000;
+--replace_column 9 #
+explain select b, sum(d) from t1 where c=0 group by b;
+select b, sum(d) from t1 where c=0 group by b;
+set @@optimizer_adjust_secondary_key_costs="disable_forced_index_in_group_by";
+--replace_column 9 #
+explain select b, sum(d) from t1 where c=0 group by b;
+select b, sum(d) from t1 where c=0 group by b;
+drop table t1;
diff --git a/mysql-test/main/selectivity_innodb_notembedded.result b/mysql-test/main/selectivity_innodb_notembedded.result
index 8b06fe75..a387d241 100644
--- a/mysql-test/main/selectivity_innodb_notembedded.result
+++ b/mysql-test/main/selectivity_innodb_notembedded.result
@@ -88,15 +88,142 @@ sel
]
set optimizer_trace=@tmp;
drop table t0,t1,t10;
-set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
set histogram_size=@save_histogram_size;
-set use_stat_tables= @save_use_stat_tables;
#
# End of 10.4 tests
#
#
+# MDEV-33314: Crash inside calculate_cond_selectivity_for_table() with many columns
+#
+set optimizer_use_condition_selectivity= 4;
+set use_stat_tables= preferably;
+#
+# create table t1 (col0 int, col1 int, col2 int, ...);
+#
+$create_tbl;
+#
+# insert into t1 select seq, ... seq from seq_1_to_10;
+#
+$insert_cmd;
+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 @trace_tmp=@@optimizer_trace;
+set optimizer_trace=1;
+#
+# Basic testcase: don't crash for many-column selectivity
+# explain extended select * from t1 where col0>1 and col1>1 and col2>1 and ...
+#
+$query_tbl;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 100,
+ "filtered": 53.32928848,
+ "attached_condition": "t1.col0 > 1 and t1.col1 > 1 and t1.col2 > 1 and t1.col3 > 1 and t1.col4 > 1 and t1.col5 > 1 and t1.col6 > 1 and t1.col7 > 1 and t1.col8 > 1 and t1.col9 > 1 and t1.col10 > 1 and t1.col11 > 1 and t1.col12 > 1 and t1.col13 > 1 and t1.col14 > 1 and t1.col15 > 1 and t1.col16 > 1 and t1.col17 > 1 and t1.col18 > 1 and t1.col19 > 1 and t1.col20 > 1 and t1.col21 > 1 and t1.col22 > 1 and t1.col23 > 1 and t1.col24 > 1 and t1.col25 > 1 and t1.col26 > 1 and t1.col27 > 1 and t1.col28 > 1 and t1.col29 > 1 and t1.col30 > 1 and t1.col31 > 1 and t1.col32 > 1 and t1.col33 > 1 and t1.col34 > 1 and t1.col35 > 1 and t1.col36 > 1 and t1.col37 > 1 and t1.col38 > 1 and t1.col39 > 1 and t1.col40 > 1 and t1.col41 > 1 and t1.col42 > 1 and t1.col43 > 1 and t1.col44 > 1 and t1.col45 > 1 and t1.col46 > 1 and t1.col47 > 1 and t1.col48 > 1 and t1.col49 > 1 and t1.col50 > 1 and t1.col51 > 1 and t1.col52 > 1 and t1.col53 > 1 and t1.col54 > 1 and t1.col55 > 1 and t1.col56 > 1 and t1.col57 > 1 and t1.col58 > 1 and t1.col59 > 1 and t1.col60 > 1 and t1.col61 > 1 and t1.col62 > 1 and t1.col63 > 1 and t1.col64 > 1 and t1.col65 > 1 and t1.col66 > 1 and t1.col67 > 1 and t1.col68 > 1 and t1.col69 > 1 and t1.col70 > 1 and t1.col71 > 1 and t1.col72 > 1 and t1.col73 > 1 and t1.col74 > 1 and t1.col75 > 1 and t1.col76 > 1 and t1.col77 > 1 and t1.col78 > 1 and t1.col79 > 1 and t1.col80 > 1 and t1.col81 > 1 and t1.col82 > 1 and t1.col83 > 1 and t1.col84 > 1 and t1.col85 > 1 and t1.col86 > 1 and t1.col87 > 1 and t1.col88 > 1 and t1.col89 > 1 and t1.col90 > 1 and t1.col91 > 1 and t1.col92 > 1 and t1.col93 > 1 and t1.col94 > 1 and t1.col95 > 1 and t1.col96 > 1 and t1.col97 > 1 and t1.col98 > 1 and t1.col99 > 1 and t1.col100 > 1 and t1.col101 > 1 and t1.col102 > 1 and t1.col103 > 1 and t1.col104 > 1 and t1.col105 > 1 and t1.col106 > 1 and t1.col107 > 1 and t1.col108 > 1 and t1.col109 > 1 and t1.col110 > 1 and t1.col111 > 1 and t1.col112 > 1 and t1.col113 > 1 and t1.col114 > 1 and t1.col115 > 1 and t1.col116 > 1 and t1.col117 > 1 and t1.col118 > 1 and t1.col119 > 1 and t1.col120 > 1 and t1.col121 > 1 and t1.col122 > 1 and t1.col123 > 1 and t1.col124 > 1 and t1.col125 > 1 and t1.col126 > 1 and t1.col127 > 1 and t1.col128 > 1 and t1.col129 > 1 and t1.col130 > 1 and t1.col131 > 1 and t1.col132 > 1 and t1.col133 > 1 and t1.col134 > 1 and t1.col135 > 1 and t1.col136 > 1 and t1.col137 > 1 and t1.col138 > 1 and t1.col139 > 1 and t1.col140 > 1 and t1.col141 > 1 and t1.col142 > 1 and t1.col143 > 1 and t1.col144 > 1 and t1.col145 > 1 and t1.col146 > 1 and t1.col147 > 1 and t1.col148 > 1 and t1.col149 > 1 and t1.col150 > 1 and t1.col151 > 1 and t1.col152 > 1 and t1.col153 > 1 and t1.col154 > 1 and t1.col155 > 1 and t1.col156 > 1 and t1.col157 > 1 and t1.col158 > 1 and t1.col159 > 1"
+ }
+ }
+ ]
+ }
+}
+select
+json_detailed(json_extract(trace,'$**.selectivity_for_columns[0]')) as JS
+from
+information_schema.optimizer_trace;
+JS
+[
+ {
+ "column_name": "col0",
+ "ranges":
+ ["1 < col0"],
+ "selectivity_from_histogram": 0.996078431
+ }
+]
+$query_tbl;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 100,
+ "filtered": 53.32928848,
+ "attached_condition": "t1.col0 > 1 and t1.col1 > 1 and t1.col2 > 1 and t1.col3 > 1 and t1.col4 > 1 and t1.col5 > 1 and t1.col6 > 1 and t1.col7 > 1 and t1.col8 > 1 and t1.col9 > 1 and t1.col10 > 1 and t1.col11 > 1 and t1.col12 > 1 and t1.col13 > 1 and t1.col14 > 1 and t1.col15 > 1 and t1.col16 > 1 and t1.col17 > 1 and t1.col18 > 1 and t1.col19 > 1 and t1.col20 > 1 and t1.col21 > 1 and t1.col22 > 1 and t1.col23 > 1 and t1.col24 > 1 and t1.col25 > 1 and t1.col26 > 1 and t1.col27 > 1 and t1.col28 > 1 and t1.col29 > 1 and t1.col30 > 1 and t1.col31 > 1 and t1.col32 > 1 and t1.col33 > 1 and t1.col34 > 1 and t1.col35 > 1 and t1.col36 > 1 and t1.col37 > 1 and t1.col38 > 1 and t1.col39 > 1 and t1.col40 > 1 and t1.col41 > 1 and t1.col42 > 1 and t1.col43 > 1 and t1.col44 > 1 and t1.col45 > 1 and t1.col46 > 1 and t1.col47 > 1 and t1.col48 > 1 and t1.col49 > 1 and t1.col50 > 1 and t1.col51 > 1 and t1.col52 > 1 and t1.col53 > 1 and t1.col54 > 1 and t1.col55 > 1 and t1.col56 > 1 and t1.col57 > 1 and t1.col58 > 1 and t1.col59 > 1 and t1.col60 > 1 and t1.col61 > 1 and t1.col62 > 1 and t1.col63 > 1 and t1.col64 > 1 and t1.col65 > 1 and t1.col66 > 1 and t1.col67 > 1 and t1.col68 > 1 and t1.col69 > 1 and t1.col70 > 1 and t1.col71 > 1 and t1.col72 > 1 and t1.col73 > 1 and t1.col74 > 1 and t1.col75 > 1 and t1.col76 > 1 and t1.col77 > 1 and t1.col78 > 1 and t1.col79 > 1 and t1.col80 > 1 and t1.col81 > 1 and t1.col82 > 1 and t1.col83 > 1 and t1.col84 > 1 and t1.col85 > 1 and t1.col86 > 1 and t1.col87 > 1 and t1.col88 > 1 and t1.col89 > 1 and t1.col90 > 1 and t1.col91 > 1 and t1.col92 > 1 and t1.col93 > 1 and t1.col94 > 1 and t1.col95 > 1 and t1.col96 > 1 and t1.col97 > 1 and t1.col98 > 1 and t1.col99 > 1 and t1.col100 > 1 and t1.col101 > 1 and t1.col102 > 1 and t1.col103 > 1 and t1.col104 > 1 and t1.col105 > 1 and t1.col106 > 1 and t1.col107 > 1 and t1.col108 > 1 and t1.col109 > 1 and t1.col110 > 1 and t1.col111 > 1 and t1.col112 > 1 and t1.col113 > 1 and t1.col114 > 1 and t1.col115 > 1 and t1.col116 > 1 and t1.col117 > 1 and t1.col118 > 1 and t1.col119 > 1 and t1.col120 > 1 and t1.col121 > 1 and t1.col122 > 1 and t1.col123 > 1 and t1.col124 > 1 and t1.col125 > 1 and t1.col126 > 1 and t1.col127 > 1 and t1.col128 > 1 and t1.col129 > 1 and t1.col130 > 1 and t1.col131 > 1 and t1.col132 > 1 and t1.col133 > 1 and t1.col134 > 1 and t1.col135 > 1 and t1.col136 > 1 and t1.col137 > 1 and t1.col138 > 1 and t1.col139 > 1 and t1.col140 > 1 and t1.col141 > 1 and t1.col142 > 1 and t1.col143 > 1 and t1.col144 > 1 and t1.col145 > 1 and t1.col146 > 1 and t1.col147 > 1 and t1.col148 > 1 and t1.col149 > 1 and t1.col150 > 1 and t1.col151 > 1 and t1.col152 > 1 and t1.col153 > 1 and t1.col154 > 1 and t1.col155 > 1 and t1.col156 > 1 and t1.col157 > 1 and t1.col158 > 1 and t1.col159 > 1"
+ }
+ }
+ ]
+ }
+}
+select
+json_detailed(json_extract(trace,'$**.selectivity_for_columns[159]')) as JS
+from
+information_schema.optimizer_trace;
+JS
+[
+ {
+ "column_name": "col159",
+ "ranges":
+ ["1 < col159"],
+ "selectivity_from_histogram": 0.996078431
+ }
+]
+#
+# Check if not being able to infer anything for the first MAX_KEY
+# columns doesn't prevent further inferences.
+#
+# explain extended select * from t1
+# where (1>2 or col0>1 or col1>1 or ...) and col99>1
+#
+$query_tbl;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 100,
+ "filtered": 99.60784149,
+ "attached_condition": "(t1.col1 > 1 or t1.col2 > 1 or t1.col3 > 1 or t1.col4 > 1 or t1.col5 > 1 or t1.col6 > 1 or t1.col7 > 1 or t1.col8 > 1 or t1.col9 > 1 or t1.col10 > 1 or t1.col11 > 1 or t1.col12 > 1 or t1.col13 > 1 or t1.col14 > 1 or t1.col15 > 1 or t1.col16 > 1 or t1.col17 > 1 or t1.col18 > 1 or t1.col19 > 1 or t1.col20 > 1 or t1.col21 > 1 or t1.col22 > 1 or t1.col23 > 1 or t1.col24 > 1 or t1.col25 > 1 or t1.col26 > 1 or t1.col27 > 1 or t1.col28 > 1 or t1.col29 > 1 or t1.col30 > 1 or t1.col31 > 1 or t1.col32 > 1 or t1.col33 > 1 or t1.col34 > 1 or t1.col35 > 1 or t1.col36 > 1 or t1.col37 > 1 or t1.col38 > 1 or t1.col39 > 1 or t1.col40 > 1 or t1.col41 > 1 or t1.col42 > 1 or t1.col43 > 1 or t1.col44 > 1 or t1.col45 > 1 or t1.col46 > 1 or t1.col47 > 1 or t1.col48 > 1 or t1.col49 > 1 or t1.col50 > 1 or t1.col51 > 1 or t1.col52 > 1 or t1.col53 > 1 or t1.col54 > 1 or t1.col55 > 1 or t1.col56 > 1 or t1.col57 > 1 or t1.col58 > 1 or t1.col59 > 1 or t1.col60 > 1 or t1.col61 > 1 or t1.col62 > 1 or t1.col63 > 1 or t1.col64 > 1 or t1.col65 > 1 or t1.col66 > 1 or t1.col67 > 1 or t1.col68 > 1 or t1.col69 > 1 or t1.col70 > 1 or t1.col71 > 1 or t1.col72 > 1 or t1.col73 > 1 or t1.col74 > 1 or t1.col75 > 1 or t1.col76 > 1 or t1.col77 > 1 or t1.col78 > 1 or t1.col79 > 1 or t1.col80 > 1 or t1.col81 > 1 or t1.col82 > 1 or t1.col83 > 1 or t1.col84 > 1 or t1.col85 > 1 or t1.col86 > 1 or t1.col87 > 1 or t1.col88 > 1 or t1.col89 > 1 or t1.col90 > 1 or t1.col91 > 1 or t1.col92 > 1 or t1.col93 > 1 or t1.col94 > 1 or t1.col95 > 1 or t1.col96 > 1 or t1.col97 > 1 or t1.col98 > 1 or t1.col99 > 1 or t1.col100 > 1 or t1.col101 > 1 or t1.col102 > 1 or t1.col103 > 1 or t1.col104 > 1 or t1.col105 > 1 or t1.col106 > 1 or t1.col107 > 1 or t1.col108 > 1 or t1.col109 > 1 or t1.col110 > 1 or t1.col111 > 1 or t1.col112 > 1 or t1.col113 > 1 or t1.col114 > 1 or t1.col115 > 1 or t1.col116 > 1 or t1.col117 > 1 or t1.col118 > 1 or t1.col119 > 1 or t1.col120 > 1 or t1.col121 > 1 or t1.col122 > 1 or t1.col123 > 1 or t1.col124 > 1 or t1.col125 > 1 or t1.col126 > 1 or t1.col127 > 1 or t1.col128 > 1 or t1.col129 > 1 or t1.col130 > 1 or t1.col131 > 1 or t1.col132 > 1 or t1.col133 > 1 or t1.col134 > 1 or t1.col135 > 1 or t1.col136 > 1 or t1.col137 > 1 or t1.col138 > 1 or t1.col139 > 1 or t1.col140 > 1 or t1.col141 > 1 or t1.col142 > 1 or t1.col143 > 1 or t1.col144 > 1 or t1.col145 > 1 or t1.col146 > 1 or t1.col147 > 1 or t1.col148 > 1 or t1.col149 > 1 or t1.col150 > 1 or t1.col151 > 1 or t1.col152 > 1 or t1.col153 > 1 or t1.col154 > 1 or t1.col155 > 1 or t1.col156 > 1 or t1.col157 > 1 or t1.col158 > 1) and t1.col159 > 1"
+ }
+ }
+ ]
+ }
+}
+select
+json_detailed(json_extract(trace,'$**.selectivity_for_columns')) as JS
+from
+information_schema.optimizer_trace;
+JS
+[
+ [
+ {
+ "column_name": "col159",
+ "ranges":
+ ["1 < col159"],
+ "selectivity_from_histogram": 0.996078431
+ }
+ ]
+]
+set optimizer_trace=@trace_tmp;
+drop table t1;
+#
# Clean up
#
+set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+set use_stat_tables= @save_use_stat_tables;
set @@global.histogram_size=@save_histogram_size;
set optimizer_switch=@save_optimizer_switch_for_selectivity_test;
SET SESSION STORAGE_ENGINE=DEFAULT;
diff --git a/mysql-test/main/selectivity_notembedded.result b/mysql-test/main/selectivity_notembedded.result
index d2e90a19..ac8922a2 100644
--- a/mysql-test/main/selectivity_notembedded.result
+++ b/mysql-test/main/selectivity_notembedded.result
@@ -83,13 +83,140 @@ sel
]
set optimizer_trace=@tmp;
drop table t0,t1,t10;
-set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
set histogram_size=@save_histogram_size;
-set use_stat_tables= @save_use_stat_tables;
#
# End of 10.4 tests
#
#
+# MDEV-33314: Crash inside calculate_cond_selectivity_for_table() with many columns
+#
+set optimizer_use_condition_selectivity= 4;
+set use_stat_tables= preferably;
+#
+# create table t1 (col0 int, col1 int, col2 int, ...);
+#
+$create_tbl;
+#
+# insert into t1 select seq, ... seq from seq_1_to_10;
+#
+$insert_cmd;
+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 @trace_tmp=@@optimizer_trace;
+set optimizer_trace=1;
+#
+# Basic testcase: don't crash for many-column selectivity
+# explain extended select * from t1 where col0>1 and col1>1 and col2>1 and ...
+#
+$query_tbl;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 100,
+ "filtered": 53.32928848,
+ "attached_condition": "t1.col0 > 1 and t1.col1 > 1 and t1.col2 > 1 and t1.col3 > 1 and t1.col4 > 1 and t1.col5 > 1 and t1.col6 > 1 and t1.col7 > 1 and t1.col8 > 1 and t1.col9 > 1 and t1.col10 > 1 and t1.col11 > 1 and t1.col12 > 1 and t1.col13 > 1 and t1.col14 > 1 and t1.col15 > 1 and t1.col16 > 1 and t1.col17 > 1 and t1.col18 > 1 and t1.col19 > 1 and t1.col20 > 1 and t1.col21 > 1 and t1.col22 > 1 and t1.col23 > 1 and t1.col24 > 1 and t1.col25 > 1 and t1.col26 > 1 and t1.col27 > 1 and t1.col28 > 1 and t1.col29 > 1 and t1.col30 > 1 and t1.col31 > 1 and t1.col32 > 1 and t1.col33 > 1 and t1.col34 > 1 and t1.col35 > 1 and t1.col36 > 1 and t1.col37 > 1 and t1.col38 > 1 and t1.col39 > 1 and t1.col40 > 1 and t1.col41 > 1 and t1.col42 > 1 and t1.col43 > 1 and t1.col44 > 1 and t1.col45 > 1 and t1.col46 > 1 and t1.col47 > 1 and t1.col48 > 1 and t1.col49 > 1 and t1.col50 > 1 and t1.col51 > 1 and t1.col52 > 1 and t1.col53 > 1 and t1.col54 > 1 and t1.col55 > 1 and t1.col56 > 1 and t1.col57 > 1 and t1.col58 > 1 and t1.col59 > 1 and t1.col60 > 1 and t1.col61 > 1 and t1.col62 > 1 and t1.col63 > 1 and t1.col64 > 1 and t1.col65 > 1 and t1.col66 > 1 and t1.col67 > 1 and t1.col68 > 1 and t1.col69 > 1 and t1.col70 > 1 and t1.col71 > 1 and t1.col72 > 1 and t1.col73 > 1 and t1.col74 > 1 and t1.col75 > 1 and t1.col76 > 1 and t1.col77 > 1 and t1.col78 > 1 and t1.col79 > 1 and t1.col80 > 1 and t1.col81 > 1 and t1.col82 > 1 and t1.col83 > 1 and t1.col84 > 1 and t1.col85 > 1 and t1.col86 > 1 and t1.col87 > 1 and t1.col88 > 1 and t1.col89 > 1 and t1.col90 > 1 and t1.col91 > 1 and t1.col92 > 1 and t1.col93 > 1 and t1.col94 > 1 and t1.col95 > 1 and t1.col96 > 1 and t1.col97 > 1 and t1.col98 > 1 and t1.col99 > 1 and t1.col100 > 1 and t1.col101 > 1 and t1.col102 > 1 and t1.col103 > 1 and t1.col104 > 1 and t1.col105 > 1 and t1.col106 > 1 and t1.col107 > 1 and t1.col108 > 1 and t1.col109 > 1 and t1.col110 > 1 and t1.col111 > 1 and t1.col112 > 1 and t1.col113 > 1 and t1.col114 > 1 and t1.col115 > 1 and t1.col116 > 1 and t1.col117 > 1 and t1.col118 > 1 and t1.col119 > 1 and t1.col120 > 1 and t1.col121 > 1 and t1.col122 > 1 and t1.col123 > 1 and t1.col124 > 1 and t1.col125 > 1 and t1.col126 > 1 and t1.col127 > 1 and t1.col128 > 1 and t1.col129 > 1 and t1.col130 > 1 and t1.col131 > 1 and t1.col132 > 1 and t1.col133 > 1 and t1.col134 > 1 and t1.col135 > 1 and t1.col136 > 1 and t1.col137 > 1 and t1.col138 > 1 and t1.col139 > 1 and t1.col140 > 1 and t1.col141 > 1 and t1.col142 > 1 and t1.col143 > 1 and t1.col144 > 1 and t1.col145 > 1 and t1.col146 > 1 and t1.col147 > 1 and t1.col148 > 1 and t1.col149 > 1 and t1.col150 > 1 and t1.col151 > 1 and t1.col152 > 1 and t1.col153 > 1 and t1.col154 > 1 and t1.col155 > 1 and t1.col156 > 1 and t1.col157 > 1 and t1.col158 > 1 and t1.col159 > 1"
+ }
+ }
+ ]
+ }
+}
+select
+json_detailed(json_extract(trace,'$**.selectivity_for_columns[0]')) as JS
+from
+information_schema.optimizer_trace;
+JS
+[
+ {
+ "column_name": "col0",
+ "ranges":
+ ["1 < col0"],
+ "selectivity_from_histogram": 0.996078431
+ }
+]
+$query_tbl;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 100,
+ "filtered": 53.32928848,
+ "attached_condition": "t1.col0 > 1 and t1.col1 > 1 and t1.col2 > 1 and t1.col3 > 1 and t1.col4 > 1 and t1.col5 > 1 and t1.col6 > 1 and t1.col7 > 1 and t1.col8 > 1 and t1.col9 > 1 and t1.col10 > 1 and t1.col11 > 1 and t1.col12 > 1 and t1.col13 > 1 and t1.col14 > 1 and t1.col15 > 1 and t1.col16 > 1 and t1.col17 > 1 and t1.col18 > 1 and t1.col19 > 1 and t1.col20 > 1 and t1.col21 > 1 and t1.col22 > 1 and t1.col23 > 1 and t1.col24 > 1 and t1.col25 > 1 and t1.col26 > 1 and t1.col27 > 1 and t1.col28 > 1 and t1.col29 > 1 and t1.col30 > 1 and t1.col31 > 1 and t1.col32 > 1 and t1.col33 > 1 and t1.col34 > 1 and t1.col35 > 1 and t1.col36 > 1 and t1.col37 > 1 and t1.col38 > 1 and t1.col39 > 1 and t1.col40 > 1 and t1.col41 > 1 and t1.col42 > 1 and t1.col43 > 1 and t1.col44 > 1 and t1.col45 > 1 and t1.col46 > 1 and t1.col47 > 1 and t1.col48 > 1 and t1.col49 > 1 and t1.col50 > 1 and t1.col51 > 1 and t1.col52 > 1 and t1.col53 > 1 and t1.col54 > 1 and t1.col55 > 1 and t1.col56 > 1 and t1.col57 > 1 and t1.col58 > 1 and t1.col59 > 1 and t1.col60 > 1 and t1.col61 > 1 and t1.col62 > 1 and t1.col63 > 1 and t1.col64 > 1 and t1.col65 > 1 and t1.col66 > 1 and t1.col67 > 1 and t1.col68 > 1 and t1.col69 > 1 and t1.col70 > 1 and t1.col71 > 1 and t1.col72 > 1 and t1.col73 > 1 and t1.col74 > 1 and t1.col75 > 1 and t1.col76 > 1 and t1.col77 > 1 and t1.col78 > 1 and t1.col79 > 1 and t1.col80 > 1 and t1.col81 > 1 and t1.col82 > 1 and t1.col83 > 1 and t1.col84 > 1 and t1.col85 > 1 and t1.col86 > 1 and t1.col87 > 1 and t1.col88 > 1 and t1.col89 > 1 and t1.col90 > 1 and t1.col91 > 1 and t1.col92 > 1 and t1.col93 > 1 and t1.col94 > 1 and t1.col95 > 1 and t1.col96 > 1 and t1.col97 > 1 and t1.col98 > 1 and t1.col99 > 1 and t1.col100 > 1 and t1.col101 > 1 and t1.col102 > 1 and t1.col103 > 1 and t1.col104 > 1 and t1.col105 > 1 and t1.col106 > 1 and t1.col107 > 1 and t1.col108 > 1 and t1.col109 > 1 and t1.col110 > 1 and t1.col111 > 1 and t1.col112 > 1 and t1.col113 > 1 and t1.col114 > 1 and t1.col115 > 1 and t1.col116 > 1 and t1.col117 > 1 and t1.col118 > 1 and t1.col119 > 1 and t1.col120 > 1 and t1.col121 > 1 and t1.col122 > 1 and t1.col123 > 1 and t1.col124 > 1 and t1.col125 > 1 and t1.col126 > 1 and t1.col127 > 1 and t1.col128 > 1 and t1.col129 > 1 and t1.col130 > 1 and t1.col131 > 1 and t1.col132 > 1 and t1.col133 > 1 and t1.col134 > 1 and t1.col135 > 1 and t1.col136 > 1 and t1.col137 > 1 and t1.col138 > 1 and t1.col139 > 1 and t1.col140 > 1 and t1.col141 > 1 and t1.col142 > 1 and t1.col143 > 1 and t1.col144 > 1 and t1.col145 > 1 and t1.col146 > 1 and t1.col147 > 1 and t1.col148 > 1 and t1.col149 > 1 and t1.col150 > 1 and t1.col151 > 1 and t1.col152 > 1 and t1.col153 > 1 and t1.col154 > 1 and t1.col155 > 1 and t1.col156 > 1 and t1.col157 > 1 and t1.col158 > 1 and t1.col159 > 1"
+ }
+ }
+ ]
+ }
+}
+select
+json_detailed(json_extract(trace,'$**.selectivity_for_columns[159]')) as JS
+from
+information_schema.optimizer_trace;
+JS
+[
+ {
+ "column_name": "col159",
+ "ranges":
+ ["1 < col159"],
+ "selectivity_from_histogram": 0.996078431
+ }
+]
+#
+# Check if not being able to infer anything for the first MAX_KEY
+# columns doesn't prevent further inferences.
+#
+# explain extended select * from t1
+# where (1>2 or col0>1 or col1>1 or ...) and col99>1
+#
+$query_tbl;
+EXPLAIN
+{
+ "query_block": {
+ "select_id": 1,
+ "nested_loop": [
+ {
+ "table": {
+ "table_name": "t1",
+ "access_type": "ALL",
+ "rows": 100,
+ "filtered": 99.60784149,
+ "attached_condition": "(t1.col1 > 1 or t1.col2 > 1 or t1.col3 > 1 or t1.col4 > 1 or t1.col5 > 1 or t1.col6 > 1 or t1.col7 > 1 or t1.col8 > 1 or t1.col9 > 1 or t1.col10 > 1 or t1.col11 > 1 or t1.col12 > 1 or t1.col13 > 1 or t1.col14 > 1 or t1.col15 > 1 or t1.col16 > 1 or t1.col17 > 1 or t1.col18 > 1 or t1.col19 > 1 or t1.col20 > 1 or t1.col21 > 1 or t1.col22 > 1 or t1.col23 > 1 or t1.col24 > 1 or t1.col25 > 1 or t1.col26 > 1 or t1.col27 > 1 or t1.col28 > 1 or t1.col29 > 1 or t1.col30 > 1 or t1.col31 > 1 or t1.col32 > 1 or t1.col33 > 1 or t1.col34 > 1 or t1.col35 > 1 or t1.col36 > 1 or t1.col37 > 1 or t1.col38 > 1 or t1.col39 > 1 or t1.col40 > 1 or t1.col41 > 1 or t1.col42 > 1 or t1.col43 > 1 or t1.col44 > 1 or t1.col45 > 1 or t1.col46 > 1 or t1.col47 > 1 or t1.col48 > 1 or t1.col49 > 1 or t1.col50 > 1 or t1.col51 > 1 or t1.col52 > 1 or t1.col53 > 1 or t1.col54 > 1 or t1.col55 > 1 or t1.col56 > 1 or t1.col57 > 1 or t1.col58 > 1 or t1.col59 > 1 or t1.col60 > 1 or t1.col61 > 1 or t1.col62 > 1 or t1.col63 > 1 or t1.col64 > 1 or t1.col65 > 1 or t1.col66 > 1 or t1.col67 > 1 or t1.col68 > 1 or t1.col69 > 1 or t1.col70 > 1 or t1.col71 > 1 or t1.col72 > 1 or t1.col73 > 1 or t1.col74 > 1 or t1.col75 > 1 or t1.col76 > 1 or t1.col77 > 1 or t1.col78 > 1 or t1.col79 > 1 or t1.col80 > 1 or t1.col81 > 1 or t1.col82 > 1 or t1.col83 > 1 or t1.col84 > 1 or t1.col85 > 1 or t1.col86 > 1 or t1.col87 > 1 or t1.col88 > 1 or t1.col89 > 1 or t1.col90 > 1 or t1.col91 > 1 or t1.col92 > 1 or t1.col93 > 1 or t1.col94 > 1 or t1.col95 > 1 or t1.col96 > 1 or t1.col97 > 1 or t1.col98 > 1 or t1.col99 > 1 or t1.col100 > 1 or t1.col101 > 1 or t1.col102 > 1 or t1.col103 > 1 or t1.col104 > 1 or t1.col105 > 1 or t1.col106 > 1 or t1.col107 > 1 or t1.col108 > 1 or t1.col109 > 1 or t1.col110 > 1 or t1.col111 > 1 or t1.col112 > 1 or t1.col113 > 1 or t1.col114 > 1 or t1.col115 > 1 or t1.col116 > 1 or t1.col117 > 1 or t1.col118 > 1 or t1.col119 > 1 or t1.col120 > 1 or t1.col121 > 1 or t1.col122 > 1 or t1.col123 > 1 or t1.col124 > 1 or t1.col125 > 1 or t1.col126 > 1 or t1.col127 > 1 or t1.col128 > 1 or t1.col129 > 1 or t1.col130 > 1 or t1.col131 > 1 or t1.col132 > 1 or t1.col133 > 1 or t1.col134 > 1 or t1.col135 > 1 or t1.col136 > 1 or t1.col137 > 1 or t1.col138 > 1 or t1.col139 > 1 or t1.col140 > 1 or t1.col141 > 1 or t1.col142 > 1 or t1.col143 > 1 or t1.col144 > 1 or t1.col145 > 1 or t1.col146 > 1 or t1.col147 > 1 or t1.col148 > 1 or t1.col149 > 1 or t1.col150 > 1 or t1.col151 > 1 or t1.col152 > 1 or t1.col153 > 1 or t1.col154 > 1 or t1.col155 > 1 or t1.col156 > 1 or t1.col157 > 1 or t1.col158 > 1) and t1.col159 > 1"
+ }
+ }
+ ]
+ }
+}
+select
+json_detailed(json_extract(trace,'$**.selectivity_for_columns')) as JS
+from
+information_schema.optimizer_trace;
+JS
+[
+ [
+ {
+ "column_name": "col159",
+ "ranges":
+ ["1 < col159"],
+ "selectivity_from_histogram": 0.996078431
+ }
+ ]
+]
+set optimizer_trace=@trace_tmp;
+drop table t1;
+#
# Clean up
#
+set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+set use_stat_tables= @save_use_stat_tables;
set @@global.histogram_size=@save_histogram_size;
diff --git a/mysql-test/main/selectivity_notembedded.test b/mysql-test/main/selectivity_notembedded.test
index 6752bd3c..30e0b7f0 100644
--- a/mysql-test/main/selectivity_notembedded.test
+++ b/mysql-test/main/selectivity_notembedded.test
@@ -105,17 +105,113 @@ from information_schema.optimizer_trace;
set optimizer_trace=@tmp;
drop table t0,t1,t10;
-set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
set histogram_size=@save_histogram_size;
-set use_stat_tables= @save_use_stat_tables;
-
--echo #
--echo # End of 10.4 tests
--echo #
--echo #
+--echo # MDEV-33314: Crash inside calculate_cond_selectivity_for_table() with many columns
+--echo #
+set optimizer_use_condition_selectivity= 4;
+set use_stat_tables= preferably;
+
+let $N_CONDS=160;
+let $N_LAST_COND=159;
+--echo #
+--echo # create table t1 (col0 int, col1 int, col2 int, ...);
+--echo #
+let $create_tbl= create table t1 ( col0 int;
+let $i=1;
+
+while ($i < $N_CONDS) {
+ let $create_tbl= $create_tbl, col$i int;
+ let $i=`select $i + 1`;
+}
+
+let $create_tbl= $create_tbl );
+#echo $create_tbl;
+evalp $create_tbl;
+
+
+--echo #
+--echo # insert into t1 select seq, ... seq from seq_1_to_10;
+--echo #
+let $insert_cmd= insert into t1 select seq;
+let $i=1;
+
+while ($i < $N_CONDS) {
+ let $insert_cmd = $insert_cmd ,seq;
+ let $i=`select $i + 1`;
+}
+let $insert_cmd= $insert_cmd from seq_1_to_100;
+
+# echo $insert_cmd;
+evalp $insert_cmd;
+
+analyze table t1 persistent for all;
+set @trace_tmp=@@optimizer_trace;
+set optimizer_trace=1;
+
+--echo #
+--echo # Basic testcase: don't crash for many-column selectivity
+--echo # explain extended select * from t1 where col0>1 and col1>1 and col2>1 and ...
+--echo #
+let $query_tbl= explain format=json select * from t1 where col0>1;
+
+let $i=1;
+while ($i < $N_CONDS) {
+ let $query_tbl= $query_tbl and col$i>1;
+ let $i=`select $i + 1`;
+}
+
+#echo $query_tbl;
+evalp $query_tbl;
+
+select
+ json_detailed(json_extract(trace,'$**.selectivity_for_columns[0]')) as JS
+from
+ information_schema.optimizer_trace;
+
+evalp $query_tbl;
+eval select
+ json_detailed(json_extract(trace,'\$**.selectivity_for_columns[$N_LAST_COND]')) as JS
+from
+ information_schema.optimizer_trace;
+
+
+--echo #
+--echo # Check if not being able to infer anything for the first MAX_KEY
+--echo # columns doesn't prevent further inferences.
+--echo #
+--echo # explain extended select * from t1
+--echo # where (1>2 or col0>1 or col1>1 or ...) and col99>1
+--echo #
+let $query_tbl= explain format=json select * from t1 where (1>2 ;
+
+let $i=1;
+while ($i < $N_LAST_COND) {
+ let $query_tbl= $query_tbl or col$i>1;
+ let $i=`select $i + 1`;
+}
+let $query_tbl= $query_tbl) and col$N_LAST_COND>1;
+
+#echo $query_tbl;
+evalp $query_tbl;
+
+select
+ json_detailed(json_extract(trace,'$**.selectivity_for_columns')) as JS
+from
+ information_schema.optimizer_trace;
+
+set optimizer_trace=@trace_tmp;
+drop table t1;
+
+--echo #
--echo # Clean up
--echo #
--source include/restore_charset.inc
+set optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+set use_stat_tables= @save_use_stat_tables;
set @@global.histogram_size=@save_histogram_size;
diff --git a/mysql-test/main/show_analyze.result b/mysql-test/main/show_analyze.result
index 77cfbc58..cc427b45 100644
--- a/mysql-test/main/show_analyze.result
+++ b/mysql-test/main/show_analyze.result
@@ -207,9 +207,12 @@ id select_type table type possible_keys key key_len ref rows r_rows filtered r_f
SET debug_dbug=@old_debug;
# Try to do SHOW ANALYZE for a query that runs a SET command:
#
-set @show_explain_probe_select_id=2;
+create table t2 (a int);
+insert into t2 values (1),(2);
+set @show_explain_probe_select_id=3;
SET debug_dbug='+d,show_explain_probe_join_exec_start';
-set @foo= (select max(a) from t0 where sin(a) >0);
+set @foo= (select max(a) from t2
+where a + (select max(a) from t0 where t0.a>t2.a) < 10000);
connection default;
show analyze for $thr2;
ERROR HY000: Target is not executing an operation with a query plan
@@ -217,6 +220,7 @@ kill query $thr2;
connection con1;
ERROR 70100: Query execution was interrupted
SET debug_dbug=@old_debug;
+drop table t2;
#
# Attempt SHOW ANALYZE for an UPDATE
#
diff --git a/mysql-test/main/show_analyze.test b/mysql-test/main/show_analyze.test
index 58d36d7d..c55aacda 100644
--- a/mysql-test/main/show_analyze.test
+++ b/mysql-test/main/show_analyze.test
@@ -213,9 +213,15 @@ SET debug_dbug=@old_debug;
--echo # Try to do SHOW ANALYZE for a query that runs a SET command:
--echo #
-set @show_explain_probe_select_id=2; # <---
+create table t2 (a int);
+insert into t2 values (1),(2);
+set @show_explain_probe_select_id=3; # Stop in the subquery.
SET debug_dbug='+d,show_explain_probe_join_exec_start';
-send set @foo= (select max(a) from t0 where sin(a) >0);
+# t2 has 2 rows so we will stop in the subquery twice:
+# - first one to serve the SHOW ANALYZE request
+# - second one when waiting to be KILLed.
+send set @foo= (select max(a) from t2
+ where a + (select max(a) from t0 where t0.a>t2.a) < 10000);
connection default;
--source include/wait_condition.inc
--error ER_TARGET_NOT_EXPLAINABLE
@@ -225,7 +231,7 @@ connection con1;
--error ER_QUERY_INTERRUPTED
reap;
SET debug_dbug=@old_debug;
-
+drop table t2;
--echo #
--echo # Attempt SHOW ANALYZE for an UPDATE
diff --git a/mysql-test/main/show_explain_json.result b/mysql-test/main/show_explain_json.result
index a5c441af..1a816597 100644
--- a/mysql-test/main/show_explain_json.result
+++ b/mysql-test/main/show_explain_json.result
@@ -518,9 +518,12 @@ SET debug_dbug=@old_debug;
# Try to do SHOW EXPLAIN for a query that runs a SET command:
# I've found experimentally that select_id==2 here...
#
-set @show_explain_probe_select_id=2;
+create table t2 (a int);
+insert into t2 values (1),(2);
+set @show_explain_probe_select_id=3;
SET debug_dbug='+d,show_explain_probe_join_exec_start';
-set @foo= (select max(a) from t0 where sin(a) >0);
+set @foo= (select max(a) from t2
+where a + (select max(a) from t0 where t0.a>t2.a) < 10000);
connection default;
show explain format=JSON for $thr2;
ERROR HY000: Target is not executing an operation with a query plan
@@ -528,6 +531,7 @@ kill query $thr2;
connection con1;
ERROR 70100: Query execution was interrupted
SET debug_dbug=@old_debug;
+drop table t2;
#
# Attempt SHOW EXPLAIN for an UPDATE
#
diff --git a/mysql-test/main/show_explain_json.test b/mysql-test/main/show_explain_json.test
index 8d2a6aa8..2426e095 100644
--- a/mysql-test/main/show_explain_json.test
+++ b/mysql-test/main/show_explain_json.test
@@ -271,9 +271,16 @@ SET debug_dbug=@old_debug;
--echo # Try to do SHOW EXPLAIN for a query that runs a SET command:
--echo # I've found experimentally that select_id==2 here...
--echo #
-set @show_explain_probe_select_id=2;
+
+create table t2 (a int);
+insert into t2 values (1),(2);
+set @show_explain_probe_select_id=3; # Stop in the subquery.
SET debug_dbug='+d,show_explain_probe_join_exec_start';
-send set @foo= (select max(a) from t0 where sin(a) >0);
+# t2 has 2 rows so we will stop in the subquery twice:
+# - first one to serve the SHOW ANALYZE request
+# - second one when waiting to be KILLed.
+send set @foo= (select max(a) from t2
+ where a + (select max(a) from t0 where t0.a>t2.a) < 10000);
connection default;
--source include/wait_condition.inc
--error ER_TARGET_NOT_EXPLAINABLE
@@ -283,6 +290,7 @@ connection con1;
--error ER_QUERY_INTERRUPTED
reap;
SET debug_dbug=@old_debug;
+drop table t2;
--echo #
--echo # Attempt SHOW EXPLAIN for an UPDATE
diff --git a/mysql-test/main/shutdown.test b/mysql-test/main/shutdown.test
index 71f2156a..b26a6d4b 100644
--- a/mysql-test/main/shutdown.test
+++ b/mysql-test/main/shutdown.test
@@ -20,13 +20,13 @@ drop procedure try_shutdown;
--let $_expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')`
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/$_expect_file_name.expect
---exec echo "wait" > $_expect_file_name
+--write_line wait $_expect_file_name
--send shutdown
--connection default
--source include/wait_until_disconnected.inc
---exec echo "restart" > $_expect_file_name
+--write_line restart $_expect_file_name
--enable_reconnect
--source include/wait_until_connected_again.inc
diff --git a/mysql-test/main/skip_grants.test b/mysql-test/main/skip_grants.test
index b74cd41b..5af697f6 100644
--- a/mysql-test/main/skip_grants.test
+++ b/mysql-test/main/skip_grants.test
@@ -176,12 +176,12 @@ drop user baz@baz;
SELECT @@skip_grant_tables AS EXPECT_1;
# Also check when the server starts without "--skip-grant-table" option
---let $restart_parameters = "--skip-skip-grant-tables"
+--let $restart_parameters = --skip-skip-grant-tables
--source include/restart_mysqld.inc
SELECT @@skip_grant_tables AS EXPECT_0;
# Need to restart the server to restore the "--skip-grant-tables" state
---let $restart_parameters = "--skip-grant-tables"
+--let $restart_parameters = --skip-grant-tables
--source include/restart_mysqld.inc
--echo #
diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result
index 522c2ced..71268c5d 100644
--- a/mysql-test/main/sp.result
+++ b/mysql-test/main/sp.result
@@ -7179,15 +7179,14 @@ CREATE VIEW t1 AS SELECT 10 AS f1;
CALL p1(1);
ERROR HY000: The target table t1 of the INSERT is not insertable-into
CREATE TEMPORARY TABLE t1 (f1 INT);
-# t1 still refers to the view since it was inlined
CALL p1(2);
-ERROR HY000: The target table t1 of the INSERT is not insertable-into
DROP VIEW t1;
# t1 now refers to the temporary table
CALL p1(3);
# Check which values were inserted into the temp table.
SELECT * FROM t1;
f1
+2
3
DROP TEMPORARY TABLE t1;
DROP PROCEDURE p1;
diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test
index 4e9b4c78..2bc71bd1 100644
--- a/mysql-test/main/sp.test
+++ b/mysql-test/main/sp.test
@@ -8632,8 +8632,6 @@ CALL p1(1);
CREATE TEMPORARY TABLE t1 (f1 INT);
---echo # t1 still refers to the view since it was inlined
---error ER_NON_INSERTABLE_TABLE
CALL p1(2);
DROP VIEW t1;
diff --git a/mysql-test/main/ssl_and_innodb.test b/mysql-test/main/ssl_and_innodb.test
index 4966f05b..2104eb5c 100644
--- a/mysql-test/main/ssl_and_innodb.test
+++ b/mysql-test/main/ssl_and_innodb.test
@@ -1,5 +1,5 @@
-- source include/have_innodb.inc
--- source include/have_ssl_crypto_functs.inc
+-- source include/have_des.inc
CREATE TABLE t1(a int) engine=innodb;
INSERT INTO t1 VALUES (1);
diff --git a/mysql-test/main/ssl_crl.result b/mysql-test/main/ssl_crl.result
index d5603254..58e3e07f 100644
--- a/mysql-test/main/ssl_crl.result
+++ b/mysql-test/main/ssl_crl.result
@@ -2,4 +2,4 @@
Variable_name Value
Ssl_version TLS_VERSION
# try logging in with a certificate in the server's --ssl-crl : should fail
-ERROR 2026 (HY000): TLS/SSL error: sslv3 alert certificate revoked
+ERROR 2026 (HY000): TLS/SSL error: ssl/tls alert certificate revoked
diff --git a/mysql-test/main/ssl_crl.test b/mysql-test/main/ssl_crl.test
index 9b475857..a09490f2 100644
--- a/mysql-test/main/ssl_crl.test
+++ b/mysql-test/main/ssl_crl.test
@@ -7,7 +7,7 @@
--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/server-new-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/server-new-cert.pem test -e "SHOW STATUS LIKE 'Ssl_version'"
--echo # try logging in with a certificate in the server's --ssl-crl : should fail
-# OpenSSL 1.1.1a correctly rejects the certificate, but the error message is different
---replace_regex /ERROR 2013 \(HY000\): Lost connection to server at '.*', system error: [0-9]+/ERROR 2026 (HY000): TLS\/SSL error: sslv3 alert certificate revoked/
+# OpenSSL 1.1.1a and later releases correctly rejects the certificate, but the error message is different
+--replace_regex /(ERROR 2013 \(HY000\): Lost connection to server at '.*', system error: [0-9]+|ERROR 2026 \(HY000\): TLS\/SSL error: sslv3 alert certificate revoked)/ERROR 2026 (HY000): TLS\/SSL error: ssl\/tls alert certificate revoked/
--error 1
--exec $MYSQL --ssl-ca=$MYSQL_TEST_DIR/std_data/cacert.pem --ssl-key=$MYSQL_TEST_DIR/std_data/client-key.pem --ssl-cert=$MYSQL_TEST_DIR/std_data/client-cert.pem test -e "SHOW STATUS LIKE 'Ssl_version'" 2>&1
diff --git a/mysql-test/main/ssl_timeout.result b/mysql-test/main/ssl_timeout.result
index 208be527..d94cfed8 100644
--- a/mysql-test/main/ssl_timeout.result
+++ b/mysql-test/main/ssl_timeout.result
@@ -1,5 +1,5 @@
# connect with read timeout so SLEEP() should timeout
-connect ssl_con,localhost,root,,,,,SSL read_timeout=5;
+connect ssl_con,localhost,root,,,,,SSL read_timeout=5$_timeout_adjustment;
# Check ssl turned on
SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher';
have_ssl
diff --git a/mysql-test/main/ssl_timeout.test b/mysql-test/main/ssl_timeout.test
index f5965f87..d762ebc3 100644
--- a/mysql-test/main/ssl_timeout.test
+++ b/mysql-test/main/ssl_timeout.test
@@ -1,10 +1,11 @@
--source include/have_ssl_communication.inc
+--source include/slow_environ.inc
# Save the initial number of concurrent sessions
--source include/count_sessions.inc
--echo # connect with read timeout so SLEEP() should timeout
-connect (ssl_con,localhost,root,,,,,SSL read_timeout=5);
+connect (ssl_con,localhost,root,,,,,SSL read_timeout=5$_timeout_adjustment);
--echo # Check ssl turned on
SELECT (VARIABLE_VALUE <> '') AS have_ssl FROM INFORMATION_SCHEMA.SESSION_STATUS WHERE VARIABLE_NAME='Ssl_cipher';
diff --git a/mysql-test/main/stat_tables_partition.result b/mysql-test/main/stat_tables_partition.result
index 2619026b..2dd63e85 100644
--- a/mysql-test/main/stat_tables_partition.result
+++ b/mysql-test/main/stat_tables_partition.result
@@ -34,13 +34,12 @@ set session use_stat_tables='preferably';
# Must NOT show "Engine-independent statistics collected":
alter table t1 analyze partition p0;
Table Op Msg_type Msg_text
-test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
# Should not have Handler_read_rnd_next=34
show session status like 'Handler_read_rnd%';
Variable_name Value
Handler_read_rnd 0
Handler_read_rnd_deleted 0
-Handler_read_rnd_next 34
+Handler_read_rnd_next 0
drop table t1;
SET use_stat_tables = DEFAULT;
diff --git a/mysql-test/main/stat_tables_rbr.result b/mysql-test/main/stat_tables_rbr.result
index 38f77441..9d5e7f85 100644
--- a/mysql-test/main/stat_tables_rbr.result
+++ b/mysql-test/main/stat_tables_rbr.result
@@ -17,7 +17,6 @@ SET use_stat_tables = PREFERABLY;
CREATE TABLE t1 ( a INT ) ENGINE=MyISAM PARTITION BY HASH(a) PARTITIONS 2;
ALTER TABLE t1 ANALYZE PARTITION p1;
Table Op Msg_type Msg_text
-test.t1 analyze status Engine-independent statistics collected
test.t1 analyze status OK
include/show_binlog_events.inc
Log_name Pos Event_type Server_id End_log_pos Info
diff --git a/mysql-test/main/subselect4.result b/mysql-test/main/subselect4.result
index 6d1e0dac..1e65bfc8 100644
--- a/mysql-test/main/subselect4.result
+++ b/mysql-test/main/subselect4.result
@@ -3001,34 +3001,31 @@ where a >= any (select b from t2 group by (select c from t3 where c = 1));
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 SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00
+3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where <nop>(<in_optimizer>(`test`.`t1`.`a`,(/* select#2 */ select min(`test`.`t2`.`b`) from `test`.`t2`) <= <cache>(`test`.`t1`.`a`)))
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where <nop>(<in_optimizer>(`test`.`t1`.`a`,<min>(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` group by (/* select#3 */ select `test`.`t3`.`c` from `test`.`t3` where `test`.`t3`.`c` = 1)) <= <cache>(`test`.`t1`.`a`)))
select a from t1
where a >= any (select b from t2 group by (select c from t3 where c = 1));
a
-3
-2
prepare stmt from "select a from t1
where a >= any (select b from t2 group by (select c from t3 where c = 1))";
execute stmt;
a
-3
-2
execute stmt;
a
-3
-2
deallocate prepare stmt;
explain extended select a from t1
where a <= all (select b from t2 group by (select c from t3 where c = 1));
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 SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00
+3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where <not>(<in_optimizer>(`test`.`t1`.`a`,(/* select#2 */ select min(`test`.`t2`.`b`) from `test`.`t2`) < <cache>(`test`.`t1`.`a`)))
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where <not>(<in_optimizer>(`test`.`t1`.`a`,<min>(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` group by (/* select#3 */ select `test`.`t3`.`c` from `test`.`t3` where `test`.`t3`.`c` = 1)) < <cache>(`test`.`t1`.`a`)))
select a from t1
where a <= all (select b from t2 group by (select c from t3 where c = 1));
a
+3
1
2
explain extended select a from t1
@@ -3036,13 +3033,12 @@ where a >= any (select b from t2 group by 1 + (select c from t3 where c = 1));
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 SUBQUERY t2 ALL NULL NULL NULL NULL 2 100.00
+3 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where <nop>(<in_optimizer>(`test`.`t1`.`a`,(/* select#2 */ select min(`test`.`t2`.`b`) from `test`.`t2`) <= <cache>(`test`.`t1`.`a`)))
+Note 1003 /* select#1 */ select `test`.`t1`.`a` AS `a` from `test`.`t1` where <nop>(<in_optimizer>(`test`.`t1`.`a`,<min>(/* select#2 */ select `test`.`t2`.`b` from `test`.`t2` group by 1 + (/* select#3 */ select `test`.`t3`.`c` from `test`.`t3` where `test`.`t3`.`c` = 1)) <= <cache>(`test`.`t1`.`a`)))
select a from t1
where a >= any (select b from t2 group by 1 + (select c from t3 where c = 1));
a
-3
-2
drop table t1,t2,t3;
#
# MDEV-29139: Redundant IN/ALL/ANY predicand in GROUP BY clause of
@@ -3062,8 +3058,10 @@ group by (select a from t1 where a = 1) in (select d from t4));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00
2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00
+4 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where 1
+Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where <in_optimizer>(1,exists(/* select#2 */ select `test`.`t3`.`c` from `test`.`t3` group by <in_optimizer>((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1),<exists>(/* select#4 */ select `test`.`t4`.`d` from `test`.`t4` where trigcond(<cache>((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)) = `test`.`t4`.`d` or `test`.`t4`.`d` is null) having trigcond(`test`.`t4`.`d` is null))) limit 1))
select b from t2
where exists (select c from t3
group by (select a from t1 where a = 1) in (select d from t4));
@@ -3089,8 +3087,10 @@ any (select d from t4));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00
2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00
+4 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where 1
+Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where <in_optimizer>(1,exists(/* select#2 */ select `test`.`t3`.`c` from `test`.`t3` group by <nop>(<expr_cache><(/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)>(<in_optimizer>((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1),<exists>(/* select#4 */ select `test`.`t4`.`d` from `test`.`t4` where trigcond(<cache>((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)) >= `test`.`t4`.`d` or `test`.`t4`.`d` is null) having trigcond(`test`.`t4`.`d` is null))))) limit 1))
select b from t2
where exists (select c from t3
group by (select a from t1 where a = 1) >=
@@ -3105,8 +3105,10 @@ all (select d from t4));
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00
2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00
+4 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where 1
+Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where <in_optimizer>(1,exists(/* select#2 */ select `test`.`t3`.`c` from `test`.`t3` group by <not>(<expr_cache><(/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)>(<in_optimizer>((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1),<exists>(/* select#4 */ select `test`.`t4`.`d` from `test`.`t4` where trigcond(<cache>((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)) >= `test`.`t4`.`d` or `test`.`t4`.`d` is null) having trigcond(`test`.`t4`.`d` is null))))) limit 1))
select b from t2
where exists (select c from t3
group by (select a from t1 where a = 1) <
@@ -3118,16 +3120,17 @@ explain extended select b from t2
where b in (select c from t3
group by (select a from t1 where a = 1) in (select d from t4));
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00
-1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 func 1 100.00
+1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
+1 PRIMARY <subquery2> eq_ref distinct_key distinct_key 4 test.t2.b 1 100.00
2 MATERIALIZED t3 ALL NULL NULL NULL NULL 2 100.00
+4 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 select `test`.`t2`.`b` AS `b` from `test`.`t2` semi join (`test`.`t3`) where 1
+Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from <materialize> (/* select#2 */ select `test`.`t3`.`c` from `test`.`t3` group by <in_optimizer>((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1),<exists>(/* select#4 */ select `test`.`t4`.`d` from `test`.`t4` where trigcond(<cache>((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)) = `test`.`t4`.`d` or `test`.`t4`.`d` is null) having trigcond(`test`.`t4`.`d` is null)))) join `test`.`t2` where `<subquery2>`.`c` = `test`.`t2`.`b`
select b from t2
where b in (select c from t3
group by (select a from t1 where a = 1) in (select d from t4));
b
-2
explain extended select b from t2
where b >= any (select c from t3
group by (select a from t1 where a = 1) in
@@ -3135,15 +3138,15 @@ group by (select a from t1 where a = 1) in
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00
+4 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where <nop>(<in_optimizer>(`test`.`t2`.`b`,(/* select#2 */ select min(`test`.`t3`.`c`) from `test`.`t3`) <= <cache>(`test`.`t2`.`b`)))
+Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where <nop>(<in_optimizer>(`test`.`t2`.`b`,<min>(/* select#2 */ select `test`.`t3`.`c` from `test`.`t3` group by <in_optimizer>((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1),<exists>(/* select#4 */ select `test`.`t4`.`d` from `test`.`t4` where trigcond(<cache>((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)) = `test`.`t4`.`d` or `test`.`t4`.`d` is null) having trigcond(`test`.`t4`.`d` is null)))) <= <cache>(`test`.`t2`.`b`)))
select b from t2
where b >= any (select c from t3
group by (select a from t1 where a = 1) in
(select d from t4));
b
-3
-2
explain extended select b from t2
where b <= all (select c from t3
group by (select a from t1 where a = 1) in
@@ -3151,13 +3154,16 @@ group by (select a from t1 where a = 1) in
id select_type table type possible_keys key key_len ref rows filtered Extra
1 PRIMARY t2 ALL NULL NULL NULL NULL 2 100.00 Using where
2 SUBQUERY t3 ALL NULL NULL NULL NULL 2 100.00
+4 SUBQUERY t4 ALL NULL NULL NULL NULL 2 100.00 Using where
+3 SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
-Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where <not>(<in_optimizer>(`test`.`t2`.`b`,<min>(/* select#2 */ select `test`.`t3`.`c` from `test`.`t3`) < <cache>(`test`.`t2`.`b`)))
+Note 1003 /* select#1 */ select `test`.`t2`.`b` AS `b` from `test`.`t2` where <not>(<in_optimizer>(`test`.`t2`.`b`,<min>(/* select#2 */ select `test`.`t3`.`c` from `test`.`t3` group by <in_optimizer>((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1),<exists>(/* select#4 */ select `test`.`t4`.`d` from `test`.`t4` where trigcond(<cache>((/* select#3 */ select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` = 1)) = `test`.`t4`.`d` or `test`.`t4`.`d` is null) having trigcond(`test`.`t4`.`d` is null)))) < <cache>(`test`.`t2`.`b`)))
select b from t2
where b <= all (select c from t3
group by (select a from t1 where a = 1) in
(select d from t4));
b
+3
2
drop table t1,t2,t3,t4;
# End of 10.3 tests
@@ -3330,4 +3336,33 @@ a
2
DEALLOCATE PREPARE stmt;
DROP TABLE t1,t2,t3;
+#
+# MDEV-33747: Optimization of (SELECT) IN (SELECT ...) executes subquery at prepare stage
+#
+create table t1 (a int, b int);
+insert into t1 select seq, seq from seq_1_to_200;
+create table t2 as select * from t1;
+create table t3 as select * from t1;
+analyze table t1,t2,t3;
+Table Op Msg_type Msg_text
+test.t1 analyze status Engine-independent statistics collected
+test.t1 analyze status OK
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+test.t3 analyze status Engine-independent statistics collected
+test.t3 analyze status OK
+select @@expensive_subquery_limit < 200 as DEFAULTS_ARE_SUITABLE;
+DEFAULTS_ARE_SUITABLE
+1
+flush status;
+explain select * from t1 where a<3 or (select max(a) from t2) in (select b from t3);
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 200 Using where
+3 SUBQUERY t3 ALL NULL NULL NULL NULL 200 Using where
+2 SUBQUERY t2 ALL NULL NULL NULL NULL 200
+# Must show 0. If this shows 200, this means subquery was executed and you have a bug:
+show status like 'Handler_read_rnd_next%';
+Variable_name Value
+Handler_read_rnd_next 0
+drop table t1,t2,t3;
# End of 10.4 tests
diff --git a/mysql-test/main/subselect4.test b/mysql-test/main/subselect4.test
index 41fa9066..854b3736 100644
--- a/mysql-test/main/subselect4.test
+++ b/mysql-test/main/subselect4.test
@@ -2670,5 +2670,20 @@ DEALLOCATE PREPARE stmt;
DROP TABLE t1,t2,t3;
+--echo #
+--echo # MDEV-33747: Optimization of (SELECT) IN (SELECT ...) executes subquery at prepare stage
+--echo #
+create table t1 (a int, b int);
+insert into t1 select seq, seq from seq_1_to_200;
+create table t2 as select * from t1;
+create table t3 as select * from t1;
+analyze table t1,t2,t3;
+select @@expensive_subquery_limit < 200 as DEFAULTS_ARE_SUITABLE;
+flush status;
+explain select * from t1 where a<3 or (select max(a) from t2) in (select b from t3);
+--echo # Must show 0. If this shows 200, this means subquery was executed and you have a bug:
+show status like 'Handler_read_rnd_next%';
+drop table t1,t2,t3;
+
--echo # End of 10.4 tests
diff --git a/mysql-test/main/subselect_elimination.result b/mysql-test/main/subselect_elimination.result
new file mode 100644
index 00000000..17400e49
--- /dev/null
+++ b/mysql-test/main/subselect_elimination.result
@@ -0,0 +1,268 @@
+#
+# MDEV-28621 group by optimization incorrectly removing subquery where
+# subject buried in a function
+#
+CREATE TABLE t1 (i int) ;
+INSERT INTO t1 VALUES (1),(2),(3);
+SELECT 1 FROM t1
+WHERE i in
+( SELECT a+1
+FROM
+(SELECT (SELECT i FROM (SELECT 1 FROM t1) dt) AS a FROM t1) dt2
+GROUP BY a
+);
+ERROR 21000: Subquery returns more than 1 row
+DROP TABLE t1;
+create table t1 (a int, b int, c int);
+insert into t1 select seq, seq, seq from seq_1_to_10;
+create table t2 as select * from t1;
+create table t20 as select * from t1;
+create table t21 as select * from t1;
+create table t3 as select * from t1;
+select a, a in
+(
+select
+(
+select max(c) from t20 where t20.a<=t2.a
+) as SUBQ1 from t2 group by SUBQ1+1
+) as COL
+from t1;
+a COL
+1 1
+2 1
+3 1
+4 1
+5 1
+6 1
+7 1
+8 1
+9 1
+10 1
+create view v2 as
+select
+a, b,
+(select max(c) from t20 where t20.a<=t2.a) as SUBQ1,
+(select max(c) from t21 where t21.a<=t2.a) as SUBQ2
+from t2;
+# test partial elimination
+explain
+select
+a,
+a in (select a from v2 where a>3 and v2.SUBQ2>=0 group by v2.SUBQ1, v2.SUBQ2)
+from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary
+5 DEPENDENT SUBQUERY t21 ALL NULL NULL NULL NULL 10 Using where
+4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where
+# test buried subselects in group by clause
+select a, a in
+(
+select
+(
+select max(c) from t20 where t20.a<=t2.a
+)*2 as SUBQ1 from t2 group by SUBQ1+1
+) as COL
+from t1;
+a COL
+1 0
+2 1
+3 0
+4 1
+5 0
+6 1
+7 0
+8 1
+9 0
+10 1
+drop view v2;
+drop table t1, t2, t20, t21, t3;
+# Testcase from MDEV-32311
+SELECT (
+( WITH x ( x ) AS
+(SELECT ( SELECT 'x' UNION SELECT 'x' ) FROM ( SELECT ( 'x' ) ) x)
+SELECT x FROM x
+WHERE x IN ( ( SELECT 'x' AND x GROUP BY x ) )
+)
+) AS SUBQ;
+SUBQ
+x
+# MDEV-32390:
+CREATE TABLE t0 ( c43 DECIMAL ( 31 ) DEFAULT ( 45 ) ) ;
+INSERT INTO t0 VALUES ( 13 ) , ( 29 ) ;
+ALTER TABLE t0 ADD COLUMN c24 INT AFTER c43 ;
+INSERT INTO t0 VALUES ( DEFAULT , DEFAULT ) , ( DEFAULT , DEFAULT ) ;
+SELECT t1 . c22 AS c9 FROM ( SELECT ( SELECT + EXISTS ( SELECT -128 AS c29 ) <<
+LOCATE ( t0 . c43 , t0 . c24 <= t0 . c24 NOT BETWEEN 4642475734208631537 AND
+-108 , NULLIF ( 57 , -8 ) SOUNDS LIKE TRIM( TRAILING FROM 6107036197732405580 )
+) - t0 . c43 AS c57 FROM t0 LIMIT 1 ) AS c22 FROM t0 ) AS t1 HAVING TRIM( CASE
+t1 . c22 WHEN -16 THEN RAND ( ) % HEX ( t1 . c22 ) - SUBSTRING_INDEX ( t1 . c22,
+':A9SEZxtjN,fKN*zR' , 'V*vhJb}&c%Op,[T[S,j`F9NDsK;\'8 4;m"
+P,ce}1r"3ID1DN' ) >> NULLIF ( t1 . c22 , -95 ) ELSE -2 END IS TRUE
+FROM t1 . c22 >= EXISTS ( SELECT t2 . c57 AS c59 FROM ( SELECT CASE c24 WHEN
+-103 THEN 85 ELSE 22 END IS TRUE AS c57 FROM t0 ) AS t2 WHERE MOD ( 64 , 46 ) =
+CONVERT ( 73 , BINARY ) % RAND ( ) IS NOT NULL = -65 GROUP BY c57 , c22 , c22
+WINDOW w0 AS ( PARTITION BY t2 . c57 ) ) & PI ( ) ) ;
+c9
+DROP TABLE t0;
+# MDEV-32309
+SELECT
+( WITH x ( x ) AS
+(
+WITH x ( x ) AS ( SELECT 1 ) SELECT ( SELECT x ) FROM x
+)
+SELECT x FROM x WHERE x IN ( SELECT NULL GROUP BY x )
+) as col1 ;
+col1
+NULL
+# MDEV-32391
+CREATE TABLE t0 ( c15 INT , c33 INT ) engine=innodb;
+INSERT INTO t0 ( c15 ) WITH t1 AS ( SELECT SQRT ( 123 ) NOT
+REGEXP MOD ( 91 , -121 ) = ALL ( SELECT c15 AS c33 FROM t0 ) AS c49 FROM t0 )
+SELECT t1 . c49 IS UNKNOWN AS c59 FROM t1 CROSS JOIN t0 AS t2
+WHERE t1 . c49 = + EXISTS ( SELECT -5839312620871436105 AS c17 GROUP BY c49 )
+BETWEEN -109 AND CHAR_LENGTH ( 2694839150676403988 ) - - LOWER ( -13 ) ;
+DROP TABLE t0;
+# MDEV-28620
+CREATE TABLE t1 ( a int);
+INSERT INTO t1 VALUES (1),(2);
+SELECT EXISTS
+( SELECT 1 FROM t1 GROUP BY 1 IN (SELECT a FROM t1)
+ORDER BY a + (SELECT 1 FROM t1 WHERE (1,2) NOT IN (SELECT 1,0))
+) as SUBQ;
+ERROR 21000: Subquery returns more than 1 row
+DROP TABLE t1;
+# MDEV-30842 Item_subselect::get_cache_parameters and UBSAN member
+# access within null pointer
+CREATE TABLE x (x INT) ENGINE=InnoDB;
+INSERT INTO x (x) VALUES (0);
+INSERT INTO x (x) VALUES (x IN (SELECT (SELECT x FROM (SELECT x FROM
+(SELECT 0 IN (SELECT x=0 FROM (SELECT x FROM (SELECT (SELECT (SELECT (SELECT
+(SELECT 0 AS x) FROM x AS x) IN (SELECT 0 AS x) AS x) FROM x AS x) IN
+(SELECT x WHERE x=0) AS x FROM x AS x) AS x) AS x GROUP BY x) AS x FROM x) AS x)
+AS x) IN (SELECT 0 AS x) AS x FROM x));
+ERROR HY000: Table 'x' is specified twice, both as a target for 'INSERT' and as a separate source for data
+DROP TABLE x;
+# MDEV-28622: Item_subselect eliminated flag set but Item still
+# evaluated/used.
+CREATE TABLE t1 ( a int) ;
+CREATE VIEW v1 (i) AS SELECT EXISTS(SELECT 1) FROM t1;
+SELECT 1 FROM v1 WHERE i NOT IN (SELECT i = 0 FROM v1 WHERE i = -1 GROUP BY i);
+1
+DROP TABLE t1;
+DROP VIEW v1;
+CREATE TABLE t(c1 INT);
+SELECT 0
+WHERE 0 IN
+(
+SELECT 0 FROM
+(
+SELECT 0 IN
+(
+SELECT
+(
+SELECT c1 FROM t
+)
+) AS c
+FROM t
+) AS dt
+WHERE c GROUP BY c
+);
+0
+DROP TABLE t;
+create table t1 (a int, b int, c int);
+insert into t1 select seq, seq, seq from seq_1_to_10;
+create table t2 as select * from t1;
+create table t20 as select * from t1;
+create table t3 as select * from t1;
+create view v2 as
+select
+a, b, (select max(c) from t20 where t20.a<=t2.a) as SUBQ1
+from t2;
+explain
+select
+a, a in (select a from v2 where a>3 group by v2.SUBQ1)
+from t1;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary
+4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where
+prepare s from '
+explain
+select
+ a, a in (select a from v2 where a>3 group by v2.SUBQ1)
+from t1';
+execute s;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary
+4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where
+execute s;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary
+4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where
+execute s;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary
+4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where
+prepare s from '
+explain
+select
+ a, a in (select a from v2 where a>3 and SUBQ1+1 group by v2.SUBQ1)
+from t1';
+execute s;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary
+4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where
+execute s;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary
+4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where
+execute s;
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary
+4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where
+create procedure p1()
+begin
+explain
+select
+a, a in (select a from v2 where a>3 group by v2.SUBQ1)
+from t1;
+end//
+create procedure p2()
+begin
+explain
+select
+a, a in (select a from v2 where a>3 and SUBQ1+1 group by v2.SUBQ1)
+from t1;
+end//
+call p1();
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary
+4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where
+call p1();
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary
+4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where
+call p2();
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary
+4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where
+call p2();
+id select_type table type possible_keys key key_len ref rows Extra
+1 PRIMARY t1 ALL NULL NULL NULL NULL 10
+2 MATERIALIZED t2 ALL NULL NULL NULL NULL 10 Using where; Using temporary
+4 DEPENDENT SUBQUERY t20 ALL NULL NULL NULL NULL 10 Using where
+drop procedure p1;
+drop procedure p2;
+drop view v2;
+drop table t1,t2,t3,t20;
+# end of 10.4 tests
diff --git a/mysql-test/main/subselect_elimination.test b/mysql-test/main/subselect_elimination.test
new file mode 100644
index 00000000..9d973477
--- /dev/null
+++ b/mysql-test/main/subselect_elimination.test
@@ -0,0 +1,242 @@
+--source include/have_innodb.inc
+--source include/have_sequence.inc
+
+--echo #
+--echo # MDEV-28621 group by optimization incorrectly removing subquery where
+--echo # subject buried in a function
+--echo #
+
+CREATE TABLE t1 (i int) ;
+INSERT INTO t1 VALUES (1),(2),(3);
+
+--error ER_SUBQUERY_NO_1_ROW
+SELECT 1 FROM t1
+WHERE i in
+( SELECT a+1
+ FROM
+ (SELECT (SELECT i FROM (SELECT 1 FROM t1) dt) AS a FROM t1) dt2
+ GROUP BY a
+);
+
+DROP TABLE t1;
+
+create table t1 (a int, b int, c int);
+insert into t1 select seq, seq, seq from seq_1_to_10;
+create table t2 as select * from t1;
+create table t20 as select * from t1;
+create table t21 as select * from t1;
+create table t3 as select * from t1;
+select a, a in
+(
+ select
+ (
+ select max(c) from t20 where t20.a<=t2.a
+ ) as SUBQ1 from t2 group by SUBQ1+1
+) as COL
+from t1;
+
+create view v2 as
+select
+ a, b,
+ (select max(c) from t20 where t20.a<=t2.a) as SUBQ1,
+ (select max(c) from t21 where t21.a<=t2.a) as SUBQ2
+from t2;
+
+--echo # test partial elimination
+
+explain
+select
+ a,
+ a in (select a from v2 where a>3 and v2.SUBQ2>=0 group by v2.SUBQ1, v2.SUBQ2)
+from t1;
+
+--echo # test buried subselects in group by clause
+
+select a, a in
+(
+ select
+ (
+ select max(c) from t20 where t20.a<=t2.a
+ )*2 as SUBQ1 from t2 group by SUBQ1+1
+) as COL
+from t1;
+
+drop view v2;
+drop table t1, t2, t20, t21, t3;
+
+--echo # Testcase from MDEV-32311
+
+# some warning duplicated using ps-protocol
+--disable_warnings
+SELECT (
+ ( WITH x ( x ) AS
+ (SELECT ( SELECT 'x' UNION SELECT 'x' ) FROM ( SELECT ( 'x' ) ) x)
+ SELECT x FROM x
+ WHERE x IN ( ( SELECT 'x' AND x GROUP BY x ) )
+ )
+) AS SUBQ;
+--enable_warnings
+
+--echo # MDEV-32390:
+
+CREATE TABLE t0 ( c43 DECIMAL ( 31 ) DEFAULT ( 45 ) ) ;
+INSERT INTO t0 VALUES ( 13 ) , ( 29 ) ;
+ALTER TABLE t0 ADD COLUMN c24 INT AFTER c43 ;
+INSERT INTO t0 VALUES ( DEFAULT , DEFAULT ) , ( DEFAULT , DEFAULT ) ;
+SELECT t1 . c22 AS c9 FROM ( SELECT ( SELECT + EXISTS ( SELECT -128 AS c29 ) <<
+LOCATE ( t0 . c43 , t0 . c24 <= t0 . c24 NOT BETWEEN 4642475734208631537 AND
+-108 , NULLIF ( 57 , -8 ) SOUNDS LIKE TRIM( TRAILING FROM 6107036197732405580 )
+) - t0 . c43 AS c57 FROM t0 LIMIT 1 ) AS c22 FROM t0 ) AS t1 HAVING TRIM( CASE
+t1 . c22 WHEN -16 THEN RAND ( ) % HEX ( t1 . c22 ) - SUBSTRING_INDEX ( t1 . c22,
+':A9SEZxtjN,fKN*zR' , 'V*vhJb}&c%Op,[T[S,j`F9NDsK;\'8 4;m"
+P,ce}1r"3ID1DN' ) >> NULLIF ( t1 . c22 , -95 ) ELSE -2 END IS TRUE
+FROM t1 . c22 >= EXISTS ( SELECT t2 . c57 AS c59 FROM ( SELECT CASE c24 WHEN
+-103 THEN 85 ELSE 22 END IS TRUE AS c57 FROM t0 ) AS t2 WHERE MOD ( 64 , 46 ) =
+CONVERT ( 73 , BINARY ) % RAND ( ) IS NOT NULL = -65 GROUP BY c57 , c22 , c22
+WINDOW w0 AS ( PARTITION BY t2 . c57 ) ) & PI ( ) ) ;
+
+DROP TABLE t0;
+
+--echo # MDEV-32309
+
+SELECT
+ ( WITH x ( x ) AS
+ (
+ WITH x ( x ) AS ( SELECT 1 ) SELECT ( SELECT x ) FROM x
+ )
+ SELECT x FROM x WHERE x IN ( SELECT NULL GROUP BY x )
+) as col1 ;
+
+--echo # MDEV-32391
+
+CREATE TABLE t0 ( c15 INT , c33 INT ) engine=innodb;
+INSERT INTO t0 ( c15 ) WITH t1 AS ( SELECT SQRT ( 123 ) NOT
+REGEXP MOD ( 91 , -121 ) = ALL ( SELECT c15 AS c33 FROM t0 ) AS c49 FROM t0 )
+SELECT t1 . c49 IS UNKNOWN AS c59 FROM t1 CROSS JOIN t0 AS t2
+WHERE t1 . c49 = + EXISTS ( SELECT -5839312620871436105 AS c17 GROUP BY c49 )
+BETWEEN -109 AND CHAR_LENGTH ( 2694839150676403988 ) - - LOWER ( -13 ) ;
+DROP TABLE t0;
+
+--echo # MDEV-28620
+CREATE TABLE t1 ( a int);
+INSERT INTO t1 VALUES (1),(2);
+
+--error ER_SUBQUERY_NO_1_ROW
+SELECT EXISTS
+( SELECT 1 FROM t1 GROUP BY 1 IN (SELECT a FROM t1)
+ ORDER BY a + (SELECT 1 FROM t1 WHERE (1,2) NOT IN (SELECT 1,0))
+) as SUBQ;
+DROP TABLE t1;
+
+--echo # MDEV-30842 Item_subselect::get_cache_parameters and UBSAN member
+--echo # access within null pointer
+
+CREATE TABLE x (x INT) ENGINE=InnoDB;
+INSERT INTO x (x) VALUES (0);
+--error ER_UPDATE_TABLE_USED
+INSERT INTO x (x) VALUES (x IN (SELECT (SELECT x FROM (SELECT x FROM
+(SELECT 0 IN (SELECT x=0 FROM (SELECT x FROM (SELECT (SELECT (SELECT (SELECT
+(SELECT 0 AS x) FROM x AS x) IN (SELECT 0 AS x) AS x) FROM x AS x) IN
+(SELECT x WHERE x=0) AS x FROM x AS x) AS x) AS x GROUP BY x) AS x FROM x) AS x)
+AS x) IN (SELECT 0 AS x) AS x FROM x));
+DROP TABLE x;
+
+--echo # MDEV-28622: Item_subselect eliminated flag set but Item still
+--echo # evaluated/used.
+
+CREATE TABLE t1 ( a int) ;
+CREATE VIEW v1 (i) AS SELECT EXISTS(SELECT 1) FROM t1;
+
+SELECT 1 FROM v1 WHERE i NOT IN (SELECT i = 0 FROM v1 WHERE i = -1 GROUP BY i);
+DROP TABLE t1;
+DROP VIEW v1;
+
+CREATE TABLE t(c1 INT);
+
+SELECT 0
+WHERE 0 IN
+(
+ SELECT 0 FROM
+ (
+ SELECT 0 IN
+ (
+ SELECT
+ (
+ SELECT c1 FROM t
+ )
+ ) AS c
+ FROM t
+ ) AS dt
+ WHERE c GROUP BY c
+);
+
+DROP TABLE t;
+
+create table t1 (a int, b int, c int);
+insert into t1 select seq, seq, seq from seq_1_to_10;
+create table t2 as select * from t1;
+create table t20 as select * from t1;
+create table t3 as select * from t1;
+
+create view v2 as
+select
+ a, b, (select max(c) from t20 where t20.a<=t2.a) as SUBQ1
+from t2;
+
+explain
+select
+ a, a in (select a from v2 where a>3 group by v2.SUBQ1)
+from t1;
+
+prepare s from '
+explain
+select
+ a, a in (select a from v2 where a>3 group by v2.SUBQ1)
+from t1';
+
+execute s;
+execute s;
+execute s;
+
+prepare s from '
+explain
+select
+ a, a in (select a from v2 where a>3 and SUBQ1+1 group by v2.SUBQ1)
+from t1';
+
+execute s;
+execute s;
+execute s;
+
+delimiter //;
+
+create procedure p1()
+begin
+explain
+select
+ a, a in (select a from v2 where a>3 group by v2.SUBQ1)
+from t1;
+end//
+
+create procedure p2()
+begin
+explain
+select
+ a, a in (select a from v2 where a>3 and SUBQ1+1 group by v2.SUBQ1)
+from t1;
+end//
+
+delimiter ;//
+
+call p1();
+call p1();
+call p2();
+call p2();
+drop procedure p1;
+drop procedure p2;
+
+
+drop view v2;
+drop table t1,t2,t3,t20;
+
+--echo # end of 10.4 tests
diff --git a/mysql-test/main/subselect_sj_mat.test b/mysql-test/main/subselect_sj_mat.test
index 00d2e95e..0222743d 100644
--- a/mysql-test/main/subselect_sj_mat.test
+++ b/mysql-test/main/subselect_sj_mat.test
@@ -523,8 +523,6 @@ where a1 in (select substring(b1,1,512) from t2_512 where b1 > '0');
# group_concat with a blob argument - depends on
# the variable group_concat_max_len, and
# convert_blob_length == max_len*collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB
-#Check after fix MDEV-31276
---disable_ps2_protocol
explain extended select left(a1,7), left(a2,7)
from t1_512
where a1 in (select group_concat(b1) from t2_512 group by b2);
@@ -542,7 +540,6 @@ where a1 in (select group_concat(b1) from t2_512 group by b2);
select left(a1,7), left(a2,7)
from t1_512
where a1 in (select group_concat(b1) from t2_512 group by b2);
---enable_ps2_protocol
drop table t1_512, t2_512, t3_512;
@@ -608,8 +605,6 @@ where a1 in (select substring(b1,1,1024) from t2_1024 where b1 > '0');
# group_concat with a blob argument - depends on
# the variable group_concat_max_len, and
# convert_blob_length == max_len*collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB
-#Check after fix MDEV-31276
---disable_ps2_protocol
explain extended select left(a1,7), left(a2,7)
from t1_1024
where a1 in (select group_concat(b1) from t2_1024 group by b2);
@@ -627,7 +622,6 @@ where a1 in (select group_concat(b1) from t2_1024 group by b2);
select left(a1,7), left(a2,7)
from t1_1024
where a1 in (select group_concat(b1) from t2_1024 group by b2);
---enable_ps2_protocol
drop table t1_1024, t2_1024, t3_1024;
@@ -693,8 +687,6 @@ where a1 in (select substring(b1,1,1025) from t2_1025 where b1 > '0');
# group_concat with a blob argument - depends on
# the variable group_concat_max_len, and
# convert_blob_length == max_len*collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB
-#Check after fix MDEV-31276
---disable_ps2_protocol
explain extended select left(a1,7), left(a2,7)
from t1_1025
where a1 in (select group_concat(b1) from t2_1025 group by b2);
@@ -712,7 +704,6 @@ where a1 in (select group_concat(b1) from t2_1025 group by b2);
select left(a1,7), left(a2,7)
from t1_1025
where a1 in (select group_concat(b1) from t2_1025 group by b2);
---enable_ps2_protocol
drop table t1_1025, t2_1025, t3_1025;
diff --git a/mysql-test/main/system_mysql_db_fix50030.result b/mysql-test/main/system_mysql_db_fix50030.result
index 644d2b8a..10607be8 100644
--- a/mysql-test/main/system_mysql_db_fix50030.result
+++ b/mysql-test/main/system_mysql_db_fix50030.result
@@ -151,7 +151,7 @@ columns_priv CREATE TABLE `columns_priv` (
show create table procs_priv;
Table Create Table
procs_priv CREATE TABLE `procs_priv` (
- `Host` char(60) NOT NULL DEFAULT '',
+ `Host` char(255) NOT NULL DEFAULT '',
`Db` char(64) NOT NULL DEFAULT '',
`User` char(128) NOT NULL DEFAULT '',
`Routine_name` char(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '',
diff --git a/mysql-test/main/system_mysql_db_fix50117.result b/mysql-test/main/system_mysql_db_fix50117.result
index 0a7cf2a9..391c4e5b 100644
--- a/mysql-test/main/system_mysql_db_fix50117.result
+++ b/mysql-test/main/system_mysql_db_fix50117.result
@@ -131,7 +131,7 @@ columns_priv CREATE TABLE `columns_priv` (
show create table procs_priv;
Table Create Table
procs_priv CREATE TABLE `procs_priv` (
- `Host` char(60) NOT NULL DEFAULT '',
+ `Host` char(255) NOT NULL DEFAULT '',
`Db` char(64) NOT NULL DEFAULT '',
`User` char(128) NOT NULL DEFAULT '',
`Routine_name` char(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '',
diff --git a/mysql-test/main/system_mysql_db_fix50568.result b/mysql-test/main/system_mysql_db_fix50568.result
index 0598f0a5..8f3a1ff1 100644
--- a/mysql-test/main/system_mysql_db_fix50568.result
+++ b/mysql-test/main/system_mysql_db_fix50568.result
@@ -152,7 +152,7 @@ columns_priv CREATE TABLE `columns_priv` (
show create table procs_priv;
Table Create Table
procs_priv CREATE TABLE `procs_priv` (
- `Host` char(60) NOT NULL DEFAULT '',
+ `Host` char(255) NOT NULL DEFAULT '',
`Db` char(64) NOT NULL DEFAULT '',
`User` char(128) NOT NULL DEFAULT '',
`Routine_name` char(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '',
diff --git a/mysql-test/main/table_value_constr.result b/mysql-test/main/table_value_constr.result
index 1ed6953b..46bea606 100644
--- a/mysql-test/main/table_value_constr.result
+++ b/mysql-test/main/table_value_constr.result
@@ -2621,9 +2621,9 @@ ERROR HY000: 'ignore' is not allowed in this context
VALUES (DEFAULT);
ERROR HY000: 'default' is not allowed in this context
EXECUTE IMMEDIATE 'VALUES (?)' USING IGNORE;
-ERROR HY000: 'ignore' is not allowed in this context
+ERROR HY000: Default/ignore value is not supported for such parameter usage
EXECUTE IMMEDIATE 'VALUES (?)' USING DEFAULT;
-ERROR HY000: 'default' is not allowed in this context
+ERROR HY000: Default/ignore value is not supported for such parameter usage
#
# MDEV-24675: TVC using subqueries
#
diff --git a/mysql-test/main/table_value_constr.test b/mysql-test/main/table_value_constr.test
index bf660bb9..6fee71a5 100644
--- a/mysql-test/main/table_value_constr.test
+++ b/mysql-test/main/table_value_constr.test
@@ -1358,9 +1358,9 @@ DELIMITER ;$$
VALUES (IGNORE);
--error ER_NOT_ALLOWED_IN_THIS_CONTEXT
VALUES (DEFAULT);
---error ER_NOT_ALLOWED_IN_THIS_CONTEXT
+--error ER_INVALID_DEFAULT_PARAM
EXECUTE IMMEDIATE 'VALUES (?)' USING IGNORE;
---error ER_NOT_ALLOWED_IN_THIS_CONTEXT
+--error ER_INVALID_DEFAULT_PARAM
EXECUTE IMMEDIATE 'VALUES (?)' USING DEFAULT;
--echo #
diff --git a/mysql-test/main/temp_table.result b/mysql-test/main/temp_table.result
index 23052e03..61b78f96 100644
--- a/mysql-test/main/temp_table.result
+++ b/mysql-test/main/temp_table.result
@@ -614,6 +614,55 @@ Tables_in_test
# in 11.2 and above here should be listed above used temporary tables
DROP TEMPORARY TABLE t1, t2;
#
+# MDEV-33218: Assertion `active_arena->is_stmt_prepare_or_first_stmt_execute() || active_arena->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed. in st_select_lex::fix_prepare_information
+#
+CREATE VIEW v1 AS SELECT 5;
+CREATE PROCEDURE sp() SELECT * FROM v1;
+CREATE TEMPORARY TABLE v1 as SELECT 7;
+# sp() accesses the temporary table v1 that hides the view with the same name
+# Therefore expected output is the row (7)
+CALL sp();
+7
+7
+DROP TEMPORARY TABLE v1;
+# After the temporary table v1 has been dropped the next invocation of sp()
+# accesses the view v1. So, expected output is the row (5)
+CALL sp();
+5
+5
+# Clean up
+DROP VIEW v1;
+DROP PROCEDURE sp;
+# Another use case is when a temporary table hides a view is dropped
+# inside a stored routine being called.
+CREATE VIEW t1 AS SELECT 1;
+CREATE PROCEDURE p1()
+BEGIN
+DROP TEMPORARY TABLE t1;
+END
+|
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+CALL p1();
+RETURN 1;
+END
+|
+CREATE TEMPORARY TABLE t1 AS SELECT 1 AS a;
+PREPARE stmt FROM 'SELECT f1()';
+EXECUTE stmt;
+f1()
+1
+# The temporary table t1 has been dropped on first
+# execution of the prepared statement 'stmt',
+# next time this statement is run it results in issuing
+# the error ER_BAD_TABLE_ERROR
+EXECUTE stmt;
+ERROR 42S02: Unknown table 'test.t1'
+# Clean up
+DROP VIEW t1;
+DROP FUNCTION f1;
+DROP PROCEDURE p1;
+#
# End of 10.4 tests
#
create function f1() returns int
diff --git a/mysql-test/main/temp_table.test b/mysql-test/main/temp_table.test
index 11a66743..529ce4a6 100644
--- a/mysql-test/main/temp_table.test
+++ b/mysql-test/main/temp_table.test
@@ -670,6 +670,60 @@ SHOW TABLES;
DROP TEMPORARY TABLE t1, t2;
--echo #
+--echo # MDEV-33218: Assertion `active_arena->is_stmt_prepare_or_first_stmt_execute() || active_arena->state == Query_arena::STMT_SP_QUERY_ARGUMENTS' failed. in st_select_lex::fix_prepare_information
+--echo #
+CREATE VIEW v1 AS SELECT 5;
+CREATE PROCEDURE sp() SELECT * FROM v1;
+CREATE TEMPORARY TABLE v1 as SELECT 7;
+--echo # sp() accesses the temporary table v1 that hides the view with the same name
+--echo # Therefore expected output is the row (7)
+CALL sp();
+DROP TEMPORARY TABLE v1;
+--echo # After the temporary table v1 has been dropped the next invocation of sp()
+--echo # accesses the view v1. So, expected output is the row (5)
+CALL sp();
+
+--echo # Clean up
+DROP VIEW v1;
+DROP PROCEDURE sp;
+
+--echo # Another use case is when a temporary table hides a view is dropped
+--echo # inside a stored routine being called.
+
+CREATE VIEW t1 AS SELECT 1;
+
+--delimiter |
+CREATE PROCEDURE p1()
+BEGIN
+ DROP TEMPORARY TABLE t1;
+END
+|
+
+CREATE FUNCTION f1() RETURNS INT
+BEGIN
+ CALL p1();
+ RETURN 1;
+END
+|
+
+--delimiter ;
+
+CREATE TEMPORARY TABLE t1 AS SELECT 1 AS a;
+PREPARE stmt FROM 'SELECT f1()';
+EXECUTE stmt;
+--echo # The temporary table t1 has been dropped on first
+--echo # execution of the prepared statement 'stmt',
+--echo # next time this statement is run it results in issuing
+--echo # the error ER_BAD_TABLE_ERROR
+--error ER_BAD_TABLE_ERROR
+EXECUTE stmt;
+
+--echo # Clean up
+DROP VIEW t1;
+DROP FUNCTION f1;
+DROP PROCEDURE p1;
+
+--echo #
--echo # End of 10.4 tests
--echo #
diff --git a/mysql-test/main/trigger.result b/mysql-test/main/trigger.result
index 410c5a53..c824af66 100644
--- a/mysql-test/main/trigger.result
+++ b/mysql-test/main/trigger.result
@@ -1,9 +1,3 @@
-drop table if exists t1, t2, t3, t4;
-drop view if exists v1;
-drop database if exists mysqltest;
-drop function if exists f1;
-drop function if exists f2;
-drop procedure if exists p1;
connect addconroot1, localhost, root,,;
connect addconroot2, localhost, root,,;
connect addconwithoutdb, localhost, root,,*NO-ONE*;
diff --git a/mysql-test/main/trigger.test b/mysql-test/main/trigger.test
index 466e9b8f..f54a09bf 100644
--- a/mysql-test/main/trigger.test
+++ b/mysql-test/main/trigger.test
@@ -7,15 +7,6 @@
# Basic triggers test
#
---disable_warnings
-drop table if exists t1, t2, t3, t4;
-drop view if exists v1;
-drop database if exists mysqltest;
-drop function if exists f1;
-drop function if exists f2;
-drop procedure if exists p1;
---enable_warnings
-
# Create additional connections used through test
connect (addconroot1, localhost, root,,);
connect (addconroot2, localhost, root,,);
diff --git a/mysql-test/main/trigger_wl3253.result b/mysql-test/main/trigger_wl3253.result
index ed08b336..e501b264 100644
--- a/mysql-test/main/trigger_wl3253.result
+++ b/mysql-test/main/trigger_wl3253.result
@@ -310,6 +310,7 @@ CREATE TABLE t1 (a INT);
CREATE TRIGGER tr1_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a:=1;
CREATE TRIGGER tr2_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a:=2;
CREATE TRIGGER tr1_bu BEFORE UPDATE ON t1 FOR EACH ROW SET @a:=3;
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
@@ -372,6 +373,7 @@ CREATE TRIGGER tr2_bi BEFORE INSERT ON t1 FOR EACH ROW SET @a:=2;
CREATE TRIGGER tr0_bi BEFORE INSERT ON t1 FOR EACH ROW PRECEDES tr1_bi SET @a:=0;
CREATE TRIGGER tr1_1_bi BEFORE INSERT ON t1 FOR EACH ROW FOLLOWS tr1_bi SET @a:=0;
# Expected order of triggers in the dump is: tr0_bi, tr1_bi, tr1_1_bi, tr2_i.
+/*!999999\- enable the sandbox mode */
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `t1` (
diff --git a/mysql-test/main/type_decimal.result b/mysql-test/main/type_decimal.result
index b2853f18..e219124a 100644
--- a/mysql-test/main/type_decimal.result
+++ b/mysql-test/main/type_decimal.result
@@ -1323,3 +1323,176 @@ SET sql_mode=DEFAULT;
#
# End of 10.4 tests
#
+#
+# Start of 10.11 tests
+#
+#
+# MDEV-33442 REPAIR TABLE corrupts UUIDs
+#
+CREATE PROCEDURE show_table()
+BEGIN
+SHOW CREATE TABLE t1;
+SELECT VERSION FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
+SELECT * FROM t1 ORDER BY a;
+END;
+$$
+# Upgrade using REPAIR
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` decimal(10,2)/*old*/ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+9
+a
+123.45
+123.46
+123.47
+CHECK TABLE t1 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check error Upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` decimal(10,2)/*old*/ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+9
+a
+123.45
+123.46
+123.47
+CHECK TABLE t1 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check error Upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` decimal(10,2)/*old*/ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+9
+a
+123.45
+123.46
+123.47
+REPAIR TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+# Expect old decimal, as it does not implicitly upgrade to new decimal
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` decimal(10,2)/*old*/ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+10
+a
+123.45
+123.46
+123.47
+CHECK TABLE t1 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` decimal(10,2)/*old*/ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+10
+a
+123.45
+123.46
+123.47
+DROP TABLE t1;
+# Upgrade using ALTER, adding a table COMMENT
+# Upgrade a 10.11.4 table using ALTER, adding a table COMMENT
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` decimal(10,2)/*old*/ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+9
+a
+123.45
+123.46
+123.47
+# ALTER..INPLACE should fail - the FRM file is too old and needs upgrade
+ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test10';
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
+ALTER IGNORE TABLE t1 COMMENT 'test11';
+# Expect old decimal, as it does not implicitly upgrade to new decimal
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` decimal(10,2)/*old*/ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='test11'
+VERSION
+10
+a
+123.45
+123.46
+123.47
+# Now ALTER..INPLACE should work
+ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test12';
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` decimal(10,2)/*old*/ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='test12'
+VERSION
+10
+a
+123.45
+123.46
+123.47
+DROP TABLE t1;
+# Upgrade using ALTER, adding a column DEFAULT
+# Upgrade a 10.11.4 table using ALTER, adding a table COMMENT
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` decimal(10,2)/*old*/ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+9
+a
+123.45
+123.46
+123.47
+# ALTER..INPLACE should fail - the FRM file is too old and needs upgrade
+ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a DECIMAL(10,2) DEFAULT 10;
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
+ALTER IGNORE TABLE t1 MODIFY a DECIMAL(10,2) DEFAULT 11;
+# Expect new decimal, as we explicitly redefined the data type
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` decimal(10,2) DEFAULT 11.00
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+10
+a
+123.45
+123.46
+123.47
+# Now ALTER..INPLACE should work
+ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a DECIMAL(10,2) DEFAULT 12;
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` decimal(10,2) DEFAULT 12.00
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+10
+a
+123.45
+123.46
+123.47
+DROP TABLE t1;
+DROP PROCEDURE show_table;
+#
+# End of 10.11 tests
+#
diff --git a/mysql-test/main/type_decimal.test b/mysql-test/main/type_decimal.test
index 9e294410..5f02d16e 100644
--- a/mysql-test/main/type_decimal.test
+++ b/mysql-test/main/type_decimal.test
@@ -826,3 +826,93 @@ SET sql_mode=DEFAULT;
--echo #
--echo # End of 10.4 tests
--echo #
+
+--echo #
+--echo # Start of 10.11 tests
+--echo #
+
+--echo #
+--echo # MDEV-33442 REPAIR TABLE corrupts UUIDs
+--echo #
+
+DELIMITER $$;
+CREATE PROCEDURE show_table()
+BEGIN
+ SHOW CREATE TABLE t1;
+ SELECT VERSION FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
+ SELECT * FROM t1 ORDER BY a;
+END;
+$$
+DELIMITER ;$$
+
+--echo # Upgrade using REPAIR
+
+--copy_file std_data/old_decimal/t1dec102.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/old_decimal/t1dec102.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/old_decimal/t1dec102.MYI $MYSQLD_DATADIR/test/t1.MYI
+CALL show_table;
+
+CHECK TABLE t1 FOR UPGRADE;
+CALL show_table;
+
+CHECK TABLE t1 FOR UPGRADE;
+CALL show_table;
+
+REPAIR TABLE t1;
+--echo # Expect old decimal, as it does not implicitly upgrade to new decimal
+CALL show_table;
+
+CHECK TABLE t1 FOR UPGRADE;
+CALL show_table;
+DROP TABLE t1;
+
+
+--echo # Upgrade using ALTER, adding a table COMMENT
+
+--echo # Upgrade a 10.11.4 table using ALTER, adding a table COMMENT
+--copy_file std_data/old_decimal/t1dec102.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/old_decimal/t1dec102.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/old_decimal/t1dec102.MYI $MYSQLD_DATADIR/test/t1.MYI
+CALL show_table;
+
+--echo # ALTER..INPLACE should fail - the FRM file is too old and needs upgrade
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test10';
+ALTER IGNORE TABLE t1 COMMENT 'test11';
+-- echo # Expect old decimal, as it does not implicitly upgrade to new decimal
+CALL show_table;
+
+--echo # Now ALTER..INPLACE should work
+ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test12';
+CALL show_table;
+
+DROP TABLE t1;
+
+
+--echo # Upgrade using ALTER, adding a column DEFAULT
+
+--echo # Upgrade a 10.11.4 table using ALTER, adding a table COMMENT
+--copy_file std_data/old_decimal/t1dec102.frm $MYSQLD_DATADIR/test/t1.frm
+--copy_file std_data/old_decimal/t1dec102.MYD $MYSQLD_DATADIR/test/t1.MYD
+--copy_file std_data/old_decimal/t1dec102.MYI $MYSQLD_DATADIR/test/t1.MYI
+CALL show_table;
+
+--echo # ALTER..INPLACE should fail - the FRM file is too old and needs upgrade
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a DECIMAL(10,2) DEFAULT 10;
+ALTER IGNORE TABLE t1 MODIFY a DECIMAL(10,2) DEFAULT 11;
+--echo # Expect new decimal, as we explicitly redefined the data type
+CALL show_table;
+
+--echo # Now ALTER..INPLACE should work
+ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a DECIMAL(10,2) DEFAULT 12;
+CALL show_table;
+
+DROP TABLE t1;
+
+DROP PROCEDURE show_table;
+
+
+--echo #
+--echo # End of 10.11 tests
+--echo #
diff --git a/mysql-test/main/type_json.result b/mysql-test/main/type_json.result
index 431a7f13..91686704 100644
--- a/mysql-test/main/type_json.result
+++ b/mysql-test/main/type_json.result
@@ -155,7 +155,7 @@ DROP TABLE t1;
#
SELECT json_object('a', (SELECT json_objectagg(b, c) FROM (SELECT 'b','c') d)) AS j FROM DUAL;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
-def j 250 (format=json) 9437283 16 Y 0 39 33
+def j 250 (format=json) 9437310 16 Y 0 39 33
j
{"a": {"b":"c"}}
#
diff --git a/mysql-test/main/type_timestamp.result b/mysql-test/main/type_timestamp.result
index 243d223c..5ac7cd64 100644
--- a/mysql-test/main/type_timestamp.result
+++ b/mysql-test/main/type_timestamp.result
@@ -1368,6 +1368,122 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
drop table t1;
#
+# MDEV-34069 Zero datetime reinterprets as '1970-01-01 00:00:00' on field_datetime=field_timestamp
+#
+SET sql_mode='';
+SET time_zone='+00:00';
+CREATE TABLE t1 (a TIMESTAMP);
+INSERT INTO t1 VALUES ('0000-00-00 00:00:00');
+SELECT * FROM t1;
+a
+0000-00-00 00:00:00
+CREATE TABLE t2 (a DATETIME);
+INSERT INTO t2 SELECT a FROM t1;
+SELECT * FROM t2;
+a
+0000-00-00 00:00:00
+SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE';
+INSERT INTO t2 VALUES ('0000-00-00 00:00:00');
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+INSERT INTO t2 SELECT a FROM t1;
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+SELECT * FROM t2;
+a
+0000-00-00 00:00:00
+0000-00-00 00:00:00
+0000-00-00 00:00:00
+DROP TABLE t2, t1;
+SET time_zone=DEFAULT;
+SET sql_mode=DEFAULT;
+#
+# MDEV-34061 unix_timestamp(coalesce(timestamp_column)) returns NULL on '1970-01-01 00:00:00.000001'
+#
+SET time_zone='+00:00';
+CREATE TABLE t1 (a TIMESTAMP(6) NULL);
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00.000001');
+SELECT unix_timestamp(a) AS c1, unix_timestamp(coalesce(a)) AS c2 FROM t1;
+c1 c2
+0.000001 0.000001
+DROP TABLE t1;
+SET time_zone=DEFAULT;
+#
+# MDEV-34088 The TIMESTAMP value of '1970-01-01 00:00:00' can be indirectly inserted in strict mode
+#
+SET sql_mode='STRICT_TRANS_TABLES,STRICT_ALL_TABLES';
+SET time_zone='+00:00';
+CREATE TABLE t1 (a TIMESTAMP);
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00');
+ERROR 22007: Incorrect datetime value: '1970-01-01 00:00:00' for column `test`.`t1`.`a` at row 1
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1');
+ERROR 22007: Incorrect datetime value: '1970-01-01 00:00:00.1' for column `test`.`t1`.`a` at row 1
+CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1');
+INSERT INTO t1 SELECT a FROM t2;
+ERROR 22007: Incorrect datetime value: '1970-01-01 00:00:00 +00:00' for column `test`.`t1`.`a` at row 1
+DROP TABLE t2;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+SET sql_mode='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE';
+SET time_zone='+00:00';
+CREATE TABLE t1 (a TIMESTAMP);
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00');
+ERROR 22007: Incorrect datetime value: '1970-01-01 00:00:00' for column `test`.`t1`.`a` at row 1
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1');
+ERROR 22007: Incorrect datetime value: '1970-01-01 00:00:00.1' for column `test`.`t1`.`a` at row 1
+CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1');
+INSERT INTO t1 SELECT a FROM t2;
+ERROR 22007: Incorrect datetime value: '1970-01-01 00:00:00 +00:00' for column `test`.`t1`.`a` at row 1
+DROP TABLE t2;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+SET sql_mode='';
+SET time_zone='+00:00';
+CREATE TABLE t1 (a TIMESTAMP);
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00');
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1');
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1');
+INSERT INTO t1 SELECT a FROM t2;
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+DROP TABLE t2;
+SELECT * FROM t1;
+a
+0000-00-00 00:00:00
+0000-00-00 00:00:00
+0000-00-00 00:00:00
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE';
+SET time_zone='+00:00';
+CREATE TABLE t1 (a TIMESTAMP);
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00');
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1');
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1');
+INSERT INTO t1 SELECT a FROM t2;
+Warnings:
+Warning 1264 Out of range value for column 'a' at row 1
+DROP TABLE t2;
+SELECT * FROM t1;
+a
+0000-00-00 00:00:00
+0000-00-00 00:00:00
+0000-00-00 00:00:00
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+#
# End of 10.5 tests
#
#
diff --git a/mysql-test/main/type_timestamp.test b/mysql-test/main/type_timestamp.test
index b3dfa192..b8568291 100644
--- a/mysql-test/main/type_timestamp.test
+++ b/mysql-test/main/type_timestamp.test
@@ -921,6 +921,98 @@ show create table t1;
drop table t1;
--echo #
+--echo # MDEV-34069 Zero datetime reinterprets as '1970-01-01 00:00:00' on field_datetime=field_timestamp
+--echo #
+
+SET sql_mode='';
+SET time_zone='+00:00';
+CREATE TABLE t1 (a TIMESTAMP);
+INSERT INTO t1 VALUES ('0000-00-00 00:00:00');
+SELECT * FROM t1;
+CREATE TABLE t2 (a DATETIME);
+INSERT INTO t2 SELECT a FROM t1;
+SELECT * FROM t2;
+SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE';
+INSERT INTO t2 VALUES ('0000-00-00 00:00:00');
+INSERT INTO t2 SELECT a FROM t1;
+SELECT * FROM t2;
+DROP TABLE t2, t1;
+SET time_zone=DEFAULT;
+SET sql_mode=DEFAULT;
+
+--echo #
+--echo # MDEV-34061 unix_timestamp(coalesce(timestamp_column)) returns NULL on '1970-01-01 00:00:00.000001'
+--echo #
+
+SET time_zone='+00:00';
+CREATE TABLE t1 (a TIMESTAMP(6) NULL);
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00.000001');
+SELECT unix_timestamp(a) AS c1, unix_timestamp(coalesce(a)) AS c2 FROM t1;
+DROP TABLE t1;
+SET time_zone=DEFAULT;
+
+--echo #
+--echo # MDEV-34088 The TIMESTAMP value of '1970-01-01 00:00:00' can be indirectly inserted in strict mode
+--echo #
+
+SET sql_mode='STRICT_TRANS_TABLES,STRICT_ALL_TABLES';
+SET time_zone='+00:00';
+CREATE TABLE t1 (a TIMESTAMP);
+--error ER_TRUNCATED_WRONG_VALUE
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00');
+--error ER_TRUNCATED_WRONG_VALUE
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1');
+CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1');
+--error ER_TRUNCATED_WRONG_VALUE
+INSERT INTO t1 SELECT a FROM t2;
+DROP TABLE t2;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+
+SET sql_mode='STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_DATE,NO_ZERO_IN_DATE';
+SET time_zone='+00:00';
+CREATE TABLE t1 (a TIMESTAMP);
+--error ER_TRUNCATED_WRONG_VALUE
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00');
+--error ER_TRUNCATED_WRONG_VALUE
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1');
+CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1');
+--error ER_TRUNCATED_WRONG_VALUE
+INSERT INTO t1 SELECT a FROM t2;
+DROP TABLE t2;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+SET sql_mode='';
+SET time_zone='+00:00';
+CREATE TABLE t1 (a TIMESTAMP);
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00');
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1');
+CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1');
+INSERT INTO t1 SELECT a FROM t2;
+DROP TABLE t2;
+SELECT * FROM t1;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+SET sql_mode='NO_ZERO_DATE,NO_ZERO_IN_DATE';
+SET time_zone='+00:00';
+CREATE TABLE t1 (a TIMESTAMP);
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00');
+INSERT INTO t1 VALUES ('1970-01-01 00:00:00.1');
+CREATE TABLE t2 (a TIMESTAMP(1)) ENGINE=MyISAM;
+INSERT INTO t2 VALUES ('1970-01-01 00:00:00.1');
+INSERT INTO t1 SELECT a FROM t2;
+DROP TABLE t2;
+SELECT * FROM t1;
+DROP TABLE t1;
+SET sql_mode=DEFAULT;
+
+--echo #
--echo # End of 10.5 tests
--echo #
diff --git a/mysql-test/main/type_varchar_mysql41.result b/mysql-test/main/type_varchar_mysql41.result
index cc7f663d..eb8bafe0 100644
--- a/mysql-test/main/type_varchar_mysql41.result
+++ b/mysql-test/main/type_varchar_mysql41.result
@@ -111,3 +111,152 @@ t2 CREATE TABLE `t2` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
DROP TABLE t1old;
DROP PROCEDURE p1;
+#
+# Start of 10.11 tests
+#
+#
+# MDEV-33442 REPAIR TABLE corrupts UUIDs
+#
+CREATE PROCEDURE show_table()
+BEGIN
+SHOW CREATE TABLE t1;
+SELECT VERSION FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
+SELECT * FROM t1 ORDER BY a,b;
+END;
+$$
+# Upgrade using REPAIR
+TRUNCATE TABLE t1;
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varbinary(255)/*old*/ DEFAULT NULL,
+ `b` varchar(255)/*old*/ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+9
+a b
+CHECK TABLE t1 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check error Upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varbinary(255)/*old*/ DEFAULT NULL,
+ `b` varchar(255)/*old*/ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+9
+a b
+CHECK TABLE t1 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check error Upgrade required. Please do "REPAIR TABLE `t1`" or dump/reload to fix it!
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varbinary(255)/*old*/ DEFAULT NULL,
+ `b` varchar(255)/*old*/ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+9
+a b
+REPAIR TABLE t1;
+Table Op Msg_type Msg_text
+test.t1 repair status OK
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varbinary(255) DEFAULT NULL,
+ `b` varchar(255) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+10
+a b
+CHECK TABLE t1 FOR UPGRADE;
+Table Op Msg_type Msg_text
+test.t1 check status OK
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varbinary(255) DEFAULT NULL,
+ `b` varchar(255) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+10
+a b
+DROP TABLE t1;
+# Upgrade using ALTER, adding a table COMMENT
+TRUNCATE TABLE t1;
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varbinary(255)/*old*/ DEFAULT NULL,
+ `b` varchar(255)/*old*/ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+9
+a b
+# ALTER..INPLACE should fail - the old columns need upgrade
+ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test10';
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
+ALTER IGNORE TABLE t1 COMMENT 'test11';
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varbinary(255) DEFAULT NULL,
+ `b` varchar(255) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='test11'
+VERSION
+10
+a b
+# Now ALTER..INPLACE should work
+ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test12';
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varbinary(255) DEFAULT NULL,
+ `b` varchar(255) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci COMMENT='test12'
+VERSION
+10
+a b
+DROP TABLE t1;
+# Upgrade using ALTER, adding a column DEFAULT
+TRUNCATE TABLE t1;
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varbinary(255)/*old*/ DEFAULT NULL,
+ `b` varchar(255)/*old*/ DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+9
+a b
+# ALTER..INPLACE should fail - the old columns need upgrade
+ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a VARBINARY(255) DEFAULT 'a10';
+ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY
+ALTER IGNORE TABLE t1 MODIFY a VARBINARY(255) DEFAULT 'a11';
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varbinary(255) DEFAULT 'a11',
+ `b` varchar(255) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+10
+a b
+# Now ALTER..INPLACE should work
+ALTER IGNORE TABLE t1 MODIFY a VARBINARY(255) DEFAULT 'a12';
+CALL show_table;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` varbinary(255) DEFAULT 'a12',
+ `b` varchar(255) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
+VERSION
+10
+a b
+DROP TABLE t1;
+DROP PROCEDURE show_table;
+#
+# End of 10.11 tests
+#
diff --git a/mysql-test/main/type_varchar_mysql41.test b/mysql-test/main/type_varchar_mysql41.test
index 5624e9ed..c963d3a3 100644
--- a/mysql-test/main/type_varchar_mysql41.test
+++ b/mysql-test/main/type_varchar_mysql41.test
@@ -57,3 +57,88 @@ CALL p1('a');
DROP TABLE t1old;
DROP PROCEDURE p1;
+
+--echo #
+--echo # Start of 10.11 tests
+--echo #
+
+--echo #
+--echo # MDEV-33442 REPAIR TABLE corrupts UUIDs
+--echo #
+
+DELIMITER $$;
+CREATE PROCEDURE show_table()
+BEGIN
+ SHOW CREATE TABLE t1;
+ SELECT VERSION FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='t1' AND TABLE_SCHEMA='test';
+ SELECT * FROM t1 ORDER BY a,b;
+END;
+$$
+DELIMITER ;$$
+
+
+--echo # Upgrade using REPAIR
+
+--copy_file $MYSQL_TEST_DIR/std_data/bug19371.frm $MYSQLD_DATADIR/test/t1.frm
+TRUNCATE TABLE t1;
+CALL show_table;
+
+CHECK TABLE t1 FOR UPGRADE;
+CALL show_table;
+
+CHECK TABLE t1 FOR UPGRADE;
+CALL show_table;
+
+REPAIR TABLE t1;
+CALL show_table;
+
+CHECK TABLE t1 FOR UPGRADE;
+CALL show_table;
+
+DROP TABLE t1;
+
+
+--echo # Upgrade using ALTER, adding a table COMMENT
+
+--copy_file $MYSQL_TEST_DIR/std_data/bug19371.frm $MYSQLD_DATADIR/test/t1.frm
+TRUNCATE TABLE t1;
+CALL show_table;
+
+--echo # ALTER..INPLACE should fail - the old columns need upgrade
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test10';
+ALTER IGNORE TABLE t1 COMMENT 'test11';
+CALL show_table;
+
+--echo # Now ALTER..INPLACE should work
+ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, COMMENT 'test12';
+CALL show_table;
+
+DROP TABLE t1;
+
+
+--echo # Upgrade using ALTER, adding a column DEFAULT
+
+--copy_file $MYSQL_TEST_DIR/std_data/bug19371.frm $MYSQLD_DATADIR/test/t1.frm
+TRUNCATE TABLE t1;
+CALL show_table;
+
+--echo # ALTER..INPLACE should fail - the old columns need upgrade
+--error ER_ALTER_OPERATION_NOT_SUPPORTED
+ALTER IGNORE TABLE t1 ALGORITHM=INPLACE, MODIFY a VARBINARY(255) DEFAULT 'a10';
+ALTER IGNORE TABLE t1 MODIFY a VARBINARY(255) DEFAULT 'a11';
+CALL show_table;
+
+--echo # Now ALTER..INPLACE should work
+ALTER IGNORE TABLE t1 MODIFY a VARBINARY(255) DEFAULT 'a12';
+CALL show_table;
+
+DROP TABLE t1;
+
+
+DROP PROCEDURE show_table;
+
+
+--echo #
+--echo # End of 10.11 tests
+--echo #
diff --git a/mysql-test/main/udf.result b/mysql-test/main/udf.result
index 8dc24a8d..53abd9c1 100644
--- a/mysql-test/main/udf.result
+++ b/mysql-test/main/udf.result
@@ -607,4 +607,68 @@ drop table t1;
DROP FUNCTION avgcost;
DROP FUNCTION avg2;
DROP FUNCTION myfunc_double;
+#
+# MDEV-24507: Server Crash using UDF in WHERE clause of VIEW
+#
+CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "UDF_EXAMPLE_LIB";
+create table t1(pk int primary key, a varchar(20));
+create table t2(pk int primary key, a varchar(20));
+create view v1 as select pk, a from t1 union select pk, a from t2;
+insert into t1 values (1, "One"), (3, "Three"), (5, "Five");
+insert into t2 values (2, "Dos"), (4, "Quatro"), (6, "Seis");
+select pk, myfunc_int(a) from t1;
+pk myfunc_int(a)
+1 3
+3 5
+5 4
+select pk, myfunc_int(a) from t2;
+pk myfunc_int(a)
+2 3
+4 6
+6 4
+select pk, myfunc_int(a) from v1;
+pk myfunc_int(a)
+1 3
+3 5
+5 4
+2 3
+4 6
+6 4
+select pk from t1 where myfunc_int(a) > 4;
+pk
+3
+select pk from (select pk, a from t1) A where myfunc_int(A.a) > 4;
+pk
+3
+set @save_optimizer_switch = @@optimizer_switch;
+set optimizer_switch = 'derived_merge=OFF';
+select pk, myfunc_int(a) from t1;
+pk myfunc_int(a)
+1 3
+3 5
+5 4
+select pk, myfunc_int(a) from t2;
+pk myfunc_int(a)
+2 3
+4 6
+6 4
+select pk, myfunc_int(a) from v1;
+pk myfunc_int(a)
+1 3
+3 5
+5 4
+2 3
+4 6
+6 4
+select pk from t1 where myfunc_int(a) > 4;
+pk
+3
+select pk from (select pk, a from t1) A where myfunc_int(A.a) > 4;
+pk
+3
+set optimizer_switch = @save_optimizer_switch;
+drop view v1;
+drop table t2;
+drop table t1;
+drop function myfunc_int;
# End of 10.4 tests
diff --git a/mysql-test/main/udf.test b/mysql-test/main/udf.test
index e9823a31..d87d446f 100644
--- a/mysql-test/main/udf.test
+++ b/mysql-test/main/udf.test
@@ -647,4 +647,38 @@ DROP FUNCTION avgcost;
DROP FUNCTION avg2;
DROP FUNCTION myfunc_double;
+--echo #
+--echo # MDEV-24507: Server Crash using UDF in WHERE clause of VIEW
+--echo #
+
+--replace_result $UDF_EXAMPLE_SO UDF_EXAMPLE_LIB
+eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_SO";
+
+create table t1(pk int primary key, a varchar(20));
+create table t2(pk int primary key, a varchar(20));
+create view v1 as select pk, a from t1 union select pk, a from t2;
+
+insert into t1 values (1, "One"), (3, "Three"), (5, "Five");
+insert into t2 values (2, "Dos"), (4, "Quatro"), (6, "Seis");
+
+select pk, myfunc_int(a) from t1;
+select pk, myfunc_int(a) from t2;
+select pk, myfunc_int(a) from v1;
+select pk from t1 where myfunc_int(a) > 4;
+select pk from (select pk, a from t1) A where myfunc_int(A.a) > 4;
+
+set @save_optimizer_switch = @@optimizer_switch;
+set optimizer_switch = 'derived_merge=OFF';
+select pk, myfunc_int(a) from t1;
+select pk, myfunc_int(a) from t2;
+select pk, myfunc_int(a) from v1;
+select pk from t1 where myfunc_int(a) > 4;
+select pk from (select pk, a from t1) A where myfunc_int(A.a) > 4;
+
+set optimizer_switch = @save_optimizer_switch;
+drop view v1;
+drop table t2;
+drop table t1;
+drop function myfunc_int;
+
--echo # End of 10.4 tests