summaryrefslogtreecommitdiff
path: root/mysql-test/include
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test/include')
-rw-r--r--mysql-test/include/alter_table_mdev539.inc65
-rw-r--r--mysql-test/include/binlog_start_pos.inc8
-rw-r--r--mysql-test/include/bytes.inc9
-rw-r--r--mysql-test/include/bytes2.inc21
-rw-r--r--mysql-test/include/check-testcase.test11
-rw-r--r--mysql-test/include/check-warnings.test4
-rw-r--r--mysql-test/include/check_slave_param.inc2
-rw-r--r--mysql-test/include/commit.inc6
-rw-r--r--mysql-test/include/common-tests.inc8
-rw-r--r--mysql-test/include/ctype_E05C.inc111
-rw-r--r--mysql-test/include/ctype_ascii_order.inc14
-rw-r--r--mysql-test/include/ctype_datetime.inc52
-rw-r--r--mysql-test/include/ctype_filesort.inc22
-rw-r--r--mysql-test/include/ctype_german.inc31
-rw-r--r--mysql-test/include/ctype_heap.inc14
-rw-r--r--mysql-test/include/ctype_like_cond_propagation.inc39
-rw-r--r--mysql-test/include/ctype_like_cond_propagation_utf8_german.inc16
-rw-r--r--mysql-test/include/ctype_mdev13118.inc15
-rw-r--r--mysql-test/include/ctype_myanmar.inc1302
-rw-r--r--mysql-test/include/ctype_pad_space.inc5
-rw-r--r--mysql-test/include/ctype_regex_utf8.inc24
-rw-r--r--mysql-test/include/ctype_strtoll10.inc49
-rw-r--r--mysql-test/include/ctype_unescape.inc327
-rw-r--r--mysql-test/include/ctype_unicode520.inc166
-rw-r--r--mysql-test/include/ctype_unicode_latin.inc179
-rw-r--r--mysql-test/include/ctype_utf8mb4.inc20
-rw-r--r--mysql-test/include/default_mysqld.cnf46
-rw-r--r--mysql-test/include/explain_non_select.inc833
-rw-r--r--mysql-test/include/explain_utils.inc161
-rw-r--r--mysql-test/include/fail_start_mysqld.inc18
-rw-r--r--mysql-test/include/filter_file.inc145
-rw-r--r--mysql-test/include/function_defaults.inc1178
-rw-r--r--mysql-test/include/function_defaults_notembedded.inc95
-rw-r--r--mysql-test/include/gap_lock_error_all.inc27
-rw-r--r--mysql-test/include/gap_lock_error_cleanup.inc1
-rw-r--r--mysql-test/include/gap_lock_error_init.inc24
-rw-r--r--mysql-test/include/gap_lock_error_select.inc89
-rw-r--r--mysql-test/include/gap_lock_error_update.inc91
-rw-r--r--mysql-test/include/gis_debug.inc161
-rw-r--r--mysql-test/include/gis_generic.inc13
-rw-r--r--mysql-test/include/have_32bit.inc9
-rw-r--r--mysql-test/include/have_64bit.inc9
-rw-r--r--mysql-test/include/have_archive.opt2
-rw-r--r--mysql-test/include/have_blackhole.opt2
-rw-r--r--mysql-test/include/have_crypt.inc9
-rw-r--r--mysql-test/include/have_debug.inc5
-rw-r--r--mysql-test/include/have_des.inc6
-rw-r--r--mysql-test/include/have_example_plugin.inc14
-rw-r--r--mysql-test/include/have_innodb.combinations17
-rw-r--r--mysql-test/include/have_innodb.inc6
-rw-r--r--mysql-test/include/have_innodb_16k.inc4
-rw-r--r--mysql-test/include/have_metadata_lock_info.inc4
-rw-r--r--mysql-test/include/have_metadata_lock_info.opt2
-rw-r--r--mysql-test/include/have_mysql_upgrade.inc4
-rw-r--r--mysql-test/include/have_openssl.inc7
-rw-r--r--mysql-test/include/have_partition.inc8
-rw-r--r--mysql-test/include/have_partition.opt2
-rw-r--r--mysql-test/include/have_plugin_auth.opt2
-rw-r--r--mysql-test/include/have_rbr_triggers.inc5
-rw-r--r--mysql-test/include/have_semisync.inc4
-rw-r--r--mysql-test/include/have_semisync.opt4
-rw-r--r--mysql-test/include/have_ssl.inc4
-rw-r--r--mysql-test/include/have_ssl_communication.inc8
-rw-r--r--mysql-test/include/have_ssl_crypto_functs.inc12
-rw-r--r--mysql-test/include/have_stat_tables.inc5
-rw-r--r--mysql-test/include/have_stat_tables.opt1
-rw-r--r--mysql-test/include/have_xtradb.combinations4
-rw-r--r--mysql-test/include/have_xtradb.inc7
-rw-r--r--mysql-test/include/index_merge2.inc1
-rw-r--r--mysql-test/include/index_merge_ror_cpk.inc3
-rw-r--r--mysql-test/include/innodb_page_size.combinations8
-rw-r--r--mysql-test/include/innodb_page_size.inc4
-rw-r--r--mysql-test/include/innodb_page_size_small.combinations8
-rw-r--r--mysql-test/include/innodb_page_size_small.inc4
-rw-r--r--mysql-test/include/is_embedded.inc8
-rw-r--r--mysql-test/include/kill_and_restart_mysqld.inc19
-rw-r--r--mysql-test/include/kill_binlog_dump_threads.inc62
-rw-r--r--mysql-test/include/kill_mysqld.inc7
-rw-r--r--mysql-test/include/linux.inc5
-rw-r--r--mysql-test/include/maybe_debug.combinations5
-rw-r--r--mysql-test/include/maybe_debug.inc3
-rw-r--r--mysql-test/include/mix1.inc38
-rw-r--r--mysql-test/include/mtr_check.sql4
-rw-r--r--mysql-test/include/mtr_warnings.sql15
-rw-r--r--mysql-test/include/mysql_upgrade_preparation.inc7
-rw-r--r--mysql-test/include/no_protocol.inc8
-rw-r--r--mysql-test/include/not_embedded.inc7
-rw-r--r--mysql-test/include/not_openssl.inc4
-rw-r--r--mysql-test/include/not_ssl.inc4
-rw-r--r--mysql-test/include/not_windows.inc8
-rw-r--r--mysql-test/include/plugin.defs1
-rw-r--r--mysql-test/include/restart_mysqld.inc15
-rw-r--r--mysql-test/include/rpl_connect.inc2
-rw-r--r--mysql-test/include/rpl_end.inc16
-rw-r--r--mysql-test/include/rpl_init.inc1
-rw-r--r--mysql-test/include/save_master_gtid.inc28
-rw-r--r--mysql-test/include/search_pattern_in_file++.inc81
-rw-r--r--mysql-test/include/search_pattern_in_file.inc44
-rw-r--r--mysql-test/include/setup_fake_relay_log.inc4
-rw-r--r--mysql-test/include/show_binlog_events.inc48
-rw-r--r--mysql-test/include/show_binlog_events2.inc20
-rw-r--r--mysql-test/include/show_events.inc118
-rw-r--r--mysql-test/include/show_slave_status.inc52
-rw-r--r--mysql-test/include/shutdown_mysqld.inc32
-rw-r--r--mysql-test/include/start_mysqld.inc21
-rw-r--r--mysql-test/include/sync_slave_sql_with_io.inc4
-rw-r--r--mysql-test/include/sync_with_master_gtid.inc52
-rw-r--r--mysql-test/include/system_db_struct.inc3
-rw-r--r--mysql-test/include/type_hrtime.inc3
-rw-r--r--mysql-test/include/wait_for_binlog_checkpoint.inc53
-rw-r--r--mysql-test/include/wait_for_purge.inc53
-rw-r--r--mysql-test/include/wait_for_slave_param.inc6
-rw-r--r--mysql-test/include/wait_innodb_all_purged.inc59
-rw-r--r--mysql-test/include/wait_show_condition.inc1
-rw-r--r--mysql-test/include/wait_until_connected_again.inc2
-rw-r--r--mysql-test/include/wait_until_disconnected.inc2
-rw-r--r--mysql-test/include/weight_string.inc66
-rw-r--r--mysql-test/include/weight_string_8140.inc36
-rw-r--r--mysql-test/include/weight_string_8EA1.inc36
-rw-r--r--mysql-test/include/weight_string_8FA2C3.inc36
-rw-r--r--mysql-test/include/weight_string_A1A1.inc36
-rw-r--r--mysql-test/include/weight_string_chde.inc59
-rw-r--r--mysql-test/include/weight_string_euro.inc30
-rw-r--r--mysql-test/include/weight_string_l1.inc10
-rw-r--r--mysql-test/include/weight_string_l12.inc5
-rw-r--r--mysql-test/include/weight_string_l14.inc37
-rw-r--r--mysql-test/include/weight_string_l2.inc7
-rw-r--r--mysql-test/include/weight_string_l3.inc10
-rw-r--r--mysql-test/include/weight_string_l4.inc10
-rw-r--r--mysql-test/include/world_schema_utf8.inc25
-rw-r--r--mysql-test/include/write_result_to_file.inc77
131 files changed, 6784 insertions, 217 deletions
diff --git a/mysql-test/include/alter_table_mdev539.inc b/mysql-test/include/alter_table_mdev539.inc
new file mode 100644
index 00000000000..a246434b779
--- /dev/null
+++ b/mysql-test/include/alter_table_mdev539.inc
@@ -0,0 +1,65 @@
+--echo #
+--echo # mdev-539: fast build of unique/primary indexes for MyISAM/Aria
+--echo #
+
+--disable_warnings
+DROP DATABASE IF EXISTS dbt3_s001;
+--enable_warnings
+CREATE DATABASE dbt3_s001;
+
+use dbt3_s001;
+
+--disable_query_log
+--disable_result_log
+--disable_warnings
+--source include/dbt3_s001.inc
+--enable_warnings
+--enable_result_log
+--enable_query_log
+
+
+drop index `primary` on lineitem;
+show create table lineitem;
+alter table lineitem add primary key (l_orderkey, l_linenumber);
+show create table lineitem;
+drop index `primary` on lineitem;
+select * from lineitem where l_orderkey=1 and l_linenumber=2;
+insert into lineitem values
+(1,68,9,2,36,34850.16,0.07,0.06,'N','O','1996-04-12','1996-02-28','1996-04-20','TAKE BACK RETURN','MAIL','slyly bold pinto beans detect s');
+select * from lineitem where l_orderkey=1 and l_linenumber=2;
+--error ER_DUP_ENTRY
+alter table lineitem add primary key (l_orderkey, l_linenumber);
+show create table lineitem;
+select * from lineitem where l_orderkey=1 and l_linenumber=2;
+delete from lineitem where l_orderkey=1 and l_linenumber=2 and l_discount=0.07;
+alter table lineitem add primary key (l_orderkey, l_linenumber);
+show create table lineitem;
+select * from lineitem where l_orderkey=1 and l_linenumber=2;
+
+create unique index i_c_name on customer(c_name);
+show create table customer;
+select * from customer where c_name='Customer#000000003';
+drop index i_c_name on customer;
+insert into customer values
+(303,'Customer#000000003','MG9kdTD2WBHm',1,'11-719-748-3364',7498.12,'AUTOMOBILE','special packages wake. slyly reg');
+select * from customer where c_name='Customer#000000003';
+--error ER_DUP_ENTRY
+alter table customer add unique index i_c_name(c_name);
+show create table customer;
+select * from customer where c_name='Customer#000000003';
+delete from customer where c_custkey=303;
+select * from customer where c_name='Customer#000000003';
+alter table customer add unique index i_c_name(c_name);
+show create table customer;
+select * from customer where c_name='Customer#000000003';
+
+drop index `primary` on customer;
+show create table customer;
+insert into customer values
+(3,'Customer#000000303','MG9kdTD2WBHm',1,'11-719-748-3364',7498.12,'AUTOMOBILE','special packages wake. slyly reg');
+alter ignore table customer add primary key (c_custkey);
+show create table customer;
+select * from customer where c_custkey=3;
+
+DROP DATABASE dbt3_s001;
+
diff --git a/mysql-test/include/binlog_start_pos.inc b/mysql-test/include/binlog_start_pos.inc
index add5a42a426..7dac1b376ee 100644
--- a/mysql-test/include/binlog_start_pos.inc
+++ b/mysql-test/include/binlog_start_pos.inc
@@ -15,14 +15,14 @@
# 1 /* Checksum algorithm */ +
# 4 /* CRC32 length */
#
-# With current number of events = 160,
+# With current number of events = 163,
#
-# binlog_start_pos = 4 + 19 + 57 + 160 + 1 + 4 = 245.
+# binlog_start_pos = 4 + 19 + 57 + 163 + 1 + 4 = 248.
#
##############################################################################
-let $binlog_start_pos=245;
+let $binlog_start_pos=248;
--disable_query_log
-SET @binlog_start_pos=245;
+SET @binlog_start_pos=248;
--enable_query_log
diff --git a/mysql-test/include/bytes.inc b/mysql-test/include/bytes.inc
new file mode 100644
index 00000000000..71575992bcf
--- /dev/null
+++ b/mysql-test/include/bytes.inc
@@ -0,0 +1,9 @@
+#
+# Create a table with all byte values
+#
+CREATE TABLE halfs (a INT);
+INSERT INTO halfs VALUES (0x00),(0x01),(0x02),(0x03),(0x04),(0x05),(0x06),(0x07);
+INSERT INTO halfs VALUES (0x08),(0x09),(0x0A),(0x0B),(0x0C),(0x0D),(0x0E),(0x0F);
+CREATE TEMPORARY TABLE bytes (a BINARY(1), KEY(a)) ENGINE=MyISAM;
+INSERT INTO bytes SELECT CHAR((t1.a << 4) | t2.a USING BINARY) FROM halfs t1, halfs t2;
+DROP TABLE halfs;
diff --git a/mysql-test/include/bytes2.inc b/mysql-test/include/bytes2.inc
new file mode 100644
index 00000000000..c151d32a3dc
--- /dev/null
+++ b/mysql-test/include/bytes2.inc
@@ -0,0 +1,21 @@
+#
+# Create a table with all 2 byte sequence values
+#
+
+--source include/bytes.inc
+
+CREATE TABLE halfs (a BINARY(1));
+# "bytes" is a temporary table, hence is not allowed in joins
+# Create a non-temporary copy.
+INSERT INTO halfs SELECT * FROM bytes;
+CREATE TEMPORARY TABLE bytes2 (
+ a BINARY(2),
+ hi BINARY(1),
+ lo BINARY(1),
+ KEY(a),
+ KEY(lo)
+) ENGINE=MyISAM;
+INSERT INTO bytes2
+SELECT CONCAT(t1.a, t2.a), t1.a, t2.a FROM halfs t1, halfs t2
+ORDER BY t1.a, t2.a;
+DROP TABLE halfs;
diff --git a/mysql-test/include/check-testcase.test b/mysql-test/include/check-testcase.test
index 858a89f706c..3a9ec419bb1 100644
--- a/mysql-test/include/check-testcase.test
+++ b/mysql-test/include/check-testcase.test
@@ -60,14 +60,23 @@ if ($tmp)
--echo Last_SQL_Error
--echo Replicate_Ignore_Server_Ids
--echo Master_Server_Id #
+ --echo Master_SSL_Crl #
+ --echo Master_SSL_Crlpath #
+ --echo Using_Gtid No
+ --echo Gtid_IO_Pos #
}
if (!$tmp) {
# Note: after WL#5177, fields 13-18 shall not be filtered-out.
- --replace_column 4 # 5 # 6 # 7 # 8 # 9 # 10 # 13 # 14 # 15 # 16 # 17 # 18 # 22 # 23 # 24 # 25 # 26 # 40 #
+ --replace_column 4 # 5 # 6 # 7 # 8 # 9 # 10 # 13 # 14 # 15 # 16 # 17 # 18 # 22 # 23 # 24 # 25 # 26 # 40 # 41 # 42 # 44 #
query_vertical
SHOW SLAVE STATUS;
}
call mtr.check_testcase();
+
+let $datadir=`select @@datadir`;
+list_files $datadir/test #sql*;
+list_files $datadir/mysql #sql*;
+
--enable_query_log
diff --git a/mysql-test/include/check-warnings.test b/mysql-test/include/check-warnings.test
index 3a26f7eecb1..9ecf7de419a 100644
--- a/mysql-test/include/check-warnings.test
+++ b/mysql-test/include/check-warnings.test
@@ -16,8 +16,10 @@ set SQL_LOG_BIN=0;
--error 0,1193
set debug_dbug="";
-
use mtr;
+# Allow this session to read-write even if server is started
+# with --transaction-read-only
+set session transaction read write;
create temporary table error_log (
row int auto_increment primary key,
diff --git a/mysql-test/include/check_slave_param.inc b/mysql-test/include/check_slave_param.inc
index 243e87a9b65..7f9971d63ea 100644
--- a/mysql-test/include/check_slave_param.inc
+++ b/mysql-test/include/check_slave_param.inc
@@ -28,7 +28,7 @@
if ($_param_value != $slave_param_value) {
--source include/show_rpl_debug_info.inc
--echo Wrong value for $slave_param. Expected '$slave_param_value', got '$_param_value'
- --die Wrong value for slave parameter
+ --die Wrong value for slave parameter $slave_param
}
diff --git a/mysql-test/include/commit.inc b/mysql-test/include/commit.inc
index fdb9ef1f563..e72ebba8527 100644
--- a/mysql-test/include/commit.inc
+++ b/mysql-test/include/commit.inc
@@ -7,7 +7,7 @@
##
set sql_mode=no_engine_substitution;
-eval set storage_engine = $engine_type;
+eval set default_storage_engine = $engine_type;
set autocommit=1;
--disable_warnings
@@ -751,13 +751,13 @@ call p_verify_status_increment(4, 4, 4, 4);
--echo # Sic: no table is created.
create table if not exists t2 (a int) select 6 union select 7;
--echo # Sic: first commits the statement, and then the transaction.
-call p_verify_status_increment(2, 0, 2, 0);
+call p_verify_status_increment(0, 0, 0, 0);
create table t3 select a from t2;
call p_verify_status_increment(2, 0, 4, 4);
alter table t3 add column (b int);
call p_verify_status_increment(2, 0, 2, 0);
alter table t3 rename t4;
-call p_verify_status_increment(2, 0, 2, 0);
+call p_verify_status_increment(0, 0, 0, 0);
rename table t4 to t3;
call p_verify_status_increment(0, 0, 0, 0);
truncate table t3;
diff --git a/mysql-test/include/common-tests.inc b/mysql-test/include/common-tests.inc
index 4b61826c347..204b6d4dd6b 100644
--- a/mysql-test/include/common-tests.inc
+++ b/mysql-test/include/common-tests.inc
@@ -1412,9 +1412,9 @@ drop table tmp;
# big table done
-SET SQL_BIG_TABLES=1;
+SET BIG_TABLES=1;
select distinct concat(fld3," ",fld3) as namn from t2,t3 where t2.fld1=t3.t2nr order by namn limit 10;
-SET SQL_BIG_TABLES=0;
+SET BIG_TABLES=0;
select distinct concat(fld3," ",fld3) from t2,t3 where t2.fld1=t3.t2nr order by fld3 limit 10;
select distinct fld5 from t2 limit 10;
@@ -1423,9 +1423,9 @@ select distinct fld5 from t2 limit 10;
#
select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10;
-SET SQL_BIG_TABLES=1; # Force use of MyISAM
+SET BIG_TABLES=1; # Force use of MyISAM
select distinct fld3,count(*) from t2 group by companynr,fld3 limit 10;
-SET SQL_BIG_TABLES=0;
+SET BIG_TABLES=0;
select distinct fld3,repeat("a",length(fld3)),count(*) from t2 group by companynr,fld3 limit 100,10;
#
diff --git a/mysql-test/include/ctype_E05C.inc b/mysql-test/include/ctype_E05C.inc
new file mode 100644
index 00000000000..9ef35a98934
--- /dev/null
+++ b/mysql-test/include/ctype_E05C.inc
@@ -0,0 +1,111 @@
+--echo # Start of ctype_E05C.inc
+
+#
+# A shared test for character sets big5, cp932, gbk, sjis
+# They all can have 0x5C as the second byte in a multi-byte character.
+# 0xE05C is one of such characters.
+#
+
+# Checking that the character 0xE05C correctly understands 5C as the second byte
+# rather than a stand-alone backslash, including the strings that also
+# have real backslash escapes and/or separator escapes.
+
+SELECT HEX('à\'),HEX('à\t');
+SELECT HEX('\\à\'),HEX('\\à\t'),HEX('\\à\t\t');
+SELECT HEX('''à\'),HEX('à\''');
+SELECT HEX('\\''à\'),HEX('à\''\\');
+
+SELECT HEX(BINARY('à\')),HEX(BINARY('à\t'));
+SELECT HEX(BINARY('\\à\')),HEX(BINARY('\\à\t')),HEX(BINARY('\\à\t\t'));
+SELECT HEX(BINARY('''à\')),HEX(BINARY('à\'''));
+SELECT HEX(BINARY('\\''à\')),HEX(BINARY('à\''\\'));
+
+SELECT HEX(_BINARY'à\'),HEX(_BINARY'à\t');
+SELECT HEX(_BINARY'\\à\'),HEX(_BINARY'\\à\t'),HEX(_BINARY'\\à\t\t');
+SELECT HEX(_BINARY'''à\'),HEX(_BINARY'à\''');
+SELECT HEX(_BINARY'\\''à\'),HEX(_BINARY'à\''\\');
+
+CREATE TABLE t1 AS SELECT REPEAT(' ',10) AS a LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('à\'),('à\t');
+INSERT INTO t1 VALUES ('\\à\'),('\\à\t'),('\\à\t\t');
+INSERT INTO t1 VALUES ('''à\'),('à\''');
+INSERT INTO t1 VALUES ('\\''à\'),('à\''\\');
+SELECT a, HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a BLOB);
+INSERT INTO t1 VALUES ('à\'),('à\t');
+INSERT INTO t1 VALUES ('\\à\'),('\\à\t'),('\\à\t\t');
+INSERT INTO t1 VALUES ('''à\'),('à\''');
+INSERT INTO t1 VALUES ('\\''à\'),('à\''\\');
+SELECT a, HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS a LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (BINARY('à\')),(BINARY('à\t'));
+INSERT INTO t1 VALUES (BINARY('\\à\')),(BINARY('\\à\t')),(BINARY('\\à\t\t'));
+INSERT INTO t1 VALUES (BINARY('''à\')),(BINARY('à\'''));
+INSERT INTO t1 VALUES (BINARY('\\''à\')),(BINARY('à\''\\'));
+SELECT a, HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a BLOB);
+INSERT INTO t1 VALUES (BINARY('à\')),(BINARY('à\t'));
+INSERT INTO t1 VALUES (BINARY('\\à\')),(BINARY('\\à\t')),(BINARY('\\à\t\t'));
+INSERT INTO t1 VALUES (BINARY('''à\')),(BINARY('à\'''));
+INSERT INTO t1 VALUES (BINARY('\\''à\')),(BINARY('à\''\\'));
+SELECT a, HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS a LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES (_BINARY'à\'),(_BINARY'à\t');
+INSERT INTO t1 VALUES (_BINARY'\\à\'),(_BINARY'\\à\t'),(_BINARY'\\à\t\t');
+INSERT INTO t1 VALUES (_BINARY'''à\'),(_BINARY'à\''');
+INSERT INTO t1 VALUES (_BINARY'\\''à\'),(_BINARY'à\''\\');
+SELECT a, HEX(a) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (a BLOB);
+INSERT INTO t1 VALUES (_BINARY'à\'),(_BINARY'à\t');
+INSERT INTO t1 VALUES (_BINARY'\\à\'),(_BINARY'\\à\t'),(_BINARY'\\à\t\t');
+INSERT INTO t1 VALUES (_BINARY'''à\'),(_BINARY'à\''');
+INSERT INTO t1 VALUES (_BINARY'\\''à\'),(_BINARY'à\''\\');
+SELECT a, HEX(a) FROM t1;
+DROP TABLE t1;
+
+# Checking that with character_set_client=binary 0x5C in 0xE05C
+# is treated as escape rather than the second byte of a multi-byte character,
+# even if character_set_connection is big5/cp932/gbk/sjis.
+# Note, the other 0x5C which is before 0xE05C is also treated as escape.
+#
+SET character_set_client=binary, character_set_results=binary;
+SELECT @@character_set_client, @@character_set_connection, @@character_set_results;
+SELECT HEX('à\['), HEX('\à\[');
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS a LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('à\['),('\à\[');
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+#
+# Checking the other way around:
+# 0x5C in 0xE05C is treated as the second byte
+# when character_set_client=big5,cp932,gbk,sjis
+# and character_set_connection=binary
+#
+SET character_set_client=@@character_set_connection, character_set_results=@@character_set_connection;
+SET character_set_connection=binary;
+SELECT @@character_set_client, @@character_set_connection, @@character_set_results;
+SELECT HEX('à\['), HEX('\à\[');
+CREATE TABLE t1 AS SELECT REPEAT(' ', 10) AS a LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('à\['),('\à\[');
+SELECT HEX(a) FROM t1;
+DROP TABLE t1;
+
+
+--echo # Start of ctype_E05C.inc
+
diff --git a/mysql-test/include/ctype_ascii_order.inc b/mysql-test/include/ctype_ascii_order.inc
new file mode 100644
index 00000000000..93127a7195f
--- /dev/null
+++ b/mysql-test/include/ctype_ascii_order.inc
@@ -0,0 +1,14 @@
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 select repeat('a',10) as c1;
+delete from t1;
+insert into t1 values (0x20),(0x21),(0x22),(0x23),(0x24),(0x25),(0x26),(0x27),(0x28),(0x29),(0x2A),(0x2B),(0x2C),(0x2D),(0x2E),(0x2F);
+insert into t1 values (0x30),(0x31),(0x32),(0x33),(0x34),(0x35),(0x36),(0x37),(0x38),(0x39),(0x3A),(0x3B),(0x3C),(0x3D),(0x3E),(0x3F);
+insert into t1 values (0x40),(0x41),(0x42),(0x43),(0x44),(0x45),(0x46),(0x47),(0x48),(0x49),(0x4A),(0x4B),(0x4C),(0x4D),(0x4E),(0x4F);
+insert into t1 values (0x50),(0x51),(0x52),(0x53),(0x54),(0x55),(0x56),(0x57),(0x58),(0x59),(0x5A),(0x5B),(0x5C),(0x5D),(0x5E),(0x5F);
+insert into t1 values (0x60),(0x61),(0x62),(0x63),(0x64),(0x65),(0x66),(0x67),(0x68),(0x69),(0x6A),(0x6B),(0x6C),(0x6D),(0x6E),(0x6F);
+insert into t1 values (0x70),(0x71),(0x72),(0x73),(0x74),(0x75),(0x76),(0x77),(0x78),(0x79),(0x7A),(0x7B),(0x7C),(0x7D),(0x7E),(0x7F);
+SELECT GROUP_CONCAT(c1 ORDER BY binary c1 SEPARATOR ''), GROUP_CONCAT(hex(c1) ORDER BY BINARY c1) FROM t1 GROUP BY c1;
+drop table t1;
diff --git a/mysql-test/include/ctype_datetime.inc b/mysql-test/include/ctype_datetime.inc
index dc70f1f38a9..f4ec2e81ea3 100644
--- a/mysql-test/include/ctype_datetime.inc
+++ b/mysql-test/include/ctype_datetime.inc
@@ -1,7 +1,8 @@
-#
-# Bug#32390 Character sets: casting utf32 to/from date doesn't work
-#
+--echo #
+--echo # Bug#32390 Character sets: casting utf32 to/from date doesn't work
+--echo #
CREATE TABLE t1 AS SELECT repeat('a',20) AS s1 LIMIT 0;
+SET time_zone=_latin1'+03:00';
SET timestamp=1216359724;
INSERT INTO t1 VALUES (current_date);
INSERT INTO t1 VALUES (current_time);
@@ -9,3 +10,48 @@ INSERT INTO t1 VALUES (current_timestamp);
SELECT s1, hex(s1) FROM t1;
DROP TABLE t1;
SET timestamp=0;
+SET time_zone=default;
+
+--echo #
+--echo # MDEV-5298 Illegal mix of collations on timestamp
+--echo #
+
+# TODO: remove "--disable_ps_protocol" when MDEV-5444 is fixed
+--disable_ps_protocol
+SELECT CHARSET('2013-11-15 00:41:28' - INTERVAL 7 DAY);
+SELECT COERCIBILITY('2013-11-15 00:41:28' - INTERVAL 7 DAY);
+SELECT CHARSET(TIMESTAMP'2013-11-15 00:41:28' - INTERVAL 7 DAY);
+SELECT COERCIBILITY(TIMESTAMP'2013-11-15 00:41:28' - INTERVAL 7 DAY);
+SELECT CHARSET(CONCAT('2013-11-15 00:41:28' - INTERVAL 7 DAY));
+SELECT COERCIBILITY(CONCAT('2013-11-15 00:41:28' - INTERVAL 7 DAY));
+SELECT CHARSET(CONCAT(TIMESTAMP'2013-11-15 00:41:28' - INTERVAL 7 DAY));
+SELECT COERCIBILITY(CONCAT(TIMESTAMP'2013-11-15 00:41:28' - INTERVAL 7 DAY));
+
+SELECT CHARSET(CONCAT('','2001-01-08 00:00:00' - INTERVAL 7 DAY));
+SELECT COERCIBILITY(CONCAT('','2001-01-08 00:00:00' - INTERVAL 7 DAY));
+SELECT HEX(CONCAT('','2001-01-08 00:00:00' - INTERVAL 7 DAY));
+SELECT CHARSET(CONCAT('',TIMESTAMP'2001-01-08 00:00:00' - INTERVAL 7 DAY));
+SELECT COERCIBILITY(CONCAT('',TIMESTAMP'2001-01-08 00:00:00' - INTERVAL 7 DAY));
+SELECT HEX(CONCAT('',TIMESTAMP'2001-01-08 00:00:00' - INTERVAL 7 DAY));
+--enable_ps_protocol
+
+CREATE TABLE t1 AS SELECT REPEAT('a', 64) AS a LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('');
+SELECT CHARSET(CONCAT(a,'2001-01-08 00:00:00' - INTERVAL 7 DAY)) FROM t1;
+SELECT COERCIBILITY(CONCAT(a,'2001-01-08 00:00:00' - INTERVAL 7 DAY)) FROM t1;
+SELECT HEX(CONCAT(a,'2001-01-08 00:00:00' - INTERVAL 7 DAY)) FROM t1;
+SELECT CHARSET(CONCAT(a,TIMESTAMP'2001-01-08 00:00:00' - INTERVAL 7 DAY)) FROM t1;
+SELECT COERCIBILITY(CONCAT(a,TIMESTAMP'2001-01-08 00:00:00' - INTERVAL 7 DAY)) FROM t1;
+SELECT HEX(CONCAT(a,TIMESTAMP'2001-01-08 00:00:00' - INTERVAL 7 DAY)) FROM t1;
+DROP TABLE t1;
+
+CREATE TABLE t1 (t TIMESTAMP NOT NULL);
+INSERT INTO t1 VALUES ('2001-01-01 00:00:00');
+SELECT * FROM t1 WHERE t < '2013-11-15 00:41:28' - INTERVAL 7 DAY;
+SELECT * FROM t1 WHERE t = '2001-01-08 00:00:00' - INTERVAL 7 DAY;
+SELECT * FROM t1 WHERE t < CONCAT('2013-11-15 00:41:28',LEFT(RAND(),0)) - INTERVAL 7 DAY;
+SELECT * FROM t1 WHERE t = CONCAT('2001-01-08 00:00:00',LEFT(RAND(),0)) - INTERVAL 7 DAY;
+SELECT * FROM t1 WHERE t < TIMESTAMP'2013-11-15 00:41:28' - INTERVAL 7 DAY;
+SELECT * FROM t1 WHERE t = TIMESTAMP'2001-01-08 00:00:00' - INTERVAL 7 DAY;
+DROP TABLE t1;
diff --git a/mysql-test/include/ctype_filesort.inc b/mysql-test/include/ctype_filesort.inc
index b1b7f21064d..f80637e5f88 100644
--- a/mysql-test/include/ctype_filesort.inc
+++ b/mysql-test/include/ctype_filesort.inc
@@ -24,3 +24,25 @@ INSERT INTO t1 VALUES (1),(2);
SELECT * FROM t1 GROUP BY MID(CURRENT_USER,0) WITH ROLLUP;
SELECT * FROM t1 GROUP BY MID('test',0) WITH ROLLUP;
DROP TABLE t1;
+
+--echo #
+--echo # MDEV-6170 Incorrect ordering with utf8_bin and utf8mb4_bin collations
+--echo #
+SELECT @@collation_connection;
+CREATE TABLE t1 ENGINE=MEMORY AS SELECT REPEAT('a',5) AS a LIMIT 0;
+INSERT INTO t1 (a) VALUES ("a");
+INSERT INTO t1 (a) VALUES ("b");
+INSERT INTO t1 (a) VALUES ("c");
+INSERT INTO t1 (a) VALUES ("d");
+INSERT INTO t1 (a) VALUES ("e");
+INSERT INTO t1 (a) VALUES ("f");
+INSERT INTO t1 (a) VALUES ("g");
+INSERT INTO t1 (a) VALUES ("h");
+INSERT INTO t1 (a) VALUES ("i");
+INSERT INTO t1 (a) VALUES ("j");
+INSERT INTO t1 (a) VALUES ("k");
+INSERT INTO t1 (a) VALUES ("l");
+INSERT INTO t1 (a) VALUES ("m");
+SELECT * FROM t1 ORDER BY LOWER(a);
+SELECT * FROM t1 ORDER BY LOWER(a) DESC;
+DROP TABLE t1;
diff --git a/mysql-test/include/ctype_german.inc b/mysql-test/include/ctype_german.inc
index 14d09358bea..0f8c995a472 100644
--- a/mysql-test/include/ctype_german.inc
+++ b/mysql-test/include/ctype_german.inc
@@ -1,3 +1,4 @@
+--echo "BEGIN ctype_german.inc"
#
# Bug #27877 incorrect german order in utf8_general_ci
#
@@ -27,14 +28,44 @@ delete from t1;
# Populate data
#
+INSERT INTO t1 VALUES ('ud'),('uf');
+INSERT INTO t1 VALUES ('od'),('of');
+INSERT INTO t1 VALUES ('e');
+INSERT INTO t1 VALUES ('ad'),('af');
+
insert into t1 values ('a'),('ae'),(_latin1 0xE4);
insert into t1 values ('o'),('oe'),(_latin1 0xF6);
insert into t1 values ('s'),('ss'),(_latin1 0xDF);
insert into t1 values ('u'),('ue'),(_latin1 0xFC);
+# LIGATURE AE
+INSERT INTO t1 VALUES (_latin1 0xE6), (_latin1 0xC6);
+# LIGATURE OE
+INSERT INTO t1 VALUES (_latin1 0x9C), (_latin1 0x8C);
+
#
# Check order
#
select s1, hex(s1) from t1 order by s1, binary s1;
select group_concat(s1 order by binary s1) from t1 group by s1;
+
+SELECT s1, hex(s1), hex(weight_string(s1)) FROM t1 ORDER BY s1, BINARY(s1);
+SELECT s1, hex(s1) FROM t1 WHERE s1='ae' ORDER BY s1, BINARY(s1);
+
drop table t1;
+
+
+#
+# Check filesort for 'S' and "U+00DF SHARP S",
+# for field and for item.
+#
+CREATE TABLE t1 AS SELECT REPEAT('a',1) AS a, 1 AS b LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('s',0),(_latin1 0xDF,1);
+SELECT * FROM t1 ORDER BY a, b;
+SELECT * FROM t1 ORDER BY a DESC, b;
+SELECT * FROM t1 ORDER BY CONCAT(a), b;
+SELECT * FROM t1 ORDER BY CONCAT(a) DESC, b;
+DROP TABLE t1;
+
+--echo "END ctype_german.inc"
diff --git a/mysql-test/include/ctype_heap.inc b/mysql-test/include/ctype_heap.inc
new file mode 100644
index 00000000000..eafd37e104a
--- /dev/null
+++ b/mysql-test/include/ctype_heap.inc
@@ -0,0 +1,14 @@
+--echo #
+--echo # Test that cs->coll->hash_sort() ignores trailing spaces
+--echo #
+SELECT @@collation_connection;
+CREATE TABLE t1 ENGINE=HEAP AS SELECT REPEAT (' ', 10) AS a LIMIT 0;
+ALTER TABLE t1 ADD KEY (a);
+CREATE TABLE t2 (a VARCHAR(10));
+INSERT INTO t2 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7');
+INSERT INTO t2 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F');
+INSERT INTO t1 SELECT CONCAT('a',t21.a,t22.a) FROM t2 t21, t2 t22 ORDER BY 1;
+DROP TABLE t2;
+INSERT INTO t1 VALUES ('a ');
+SELECT a, HEX(a) FROM t1 WHERE a='a';
+DROP TABLE t1;
diff --git a/mysql-test/include/ctype_like_cond_propagation.inc b/mysql-test/include/ctype_like_cond_propagation.inc
new file mode 100644
index 00000000000..023cf2b1b30
--- /dev/null
+++ b/mysql-test/include/ctype_like_cond_propagation.inc
@@ -0,0 +1,39 @@
+--echo #
+--echo # MDEV-7149 Constant condition propagation erroneously applied for LIKE
+--echo #
+
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS c1 LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT * FROM t1 WHERE CONCAT(c1)='a';
+SELECT * FROM t1 WHERE CONCAT(c1) LIKE 'a ';
+SELECT * FROM t1 WHERE CONCAT(c1)='a' AND CONCAT(c1) LIKE 'a ';
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE CONCAT(c1)='a' AND CONCAT(c1) LIKE 'a ';
+DROP TABLE t1;
+
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS c1 LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('a'),('a ');
+SELECT * FROM t1 WHERE 'a'=CONCAT(c1);
+SELECT * FROM t1 WHERE 'a ' LIKE CONCAT(c1);
+SELECT * FROM t1 WHERE 'a'=CONCAT(c1) AND 'a ' LIKE CONCAT(c1);
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE 'a'=CONCAT(c1) AND 'a ' LIKE CONCAT(c1);
+DROP TABLE t1;
+
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS c1 LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('%'),('% ');
+SELECT * FROM t1 WHERE '% '=CONCAT(c1);
+SELECT * FROM t1 WHERE 'a' LIKE CONCAT(c1);
+SELECT * FROM t1 WHERE '% '=CONCAT(c1) AND 'a' LIKE CONCAT(c1);
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE '% '=CONCAT(c1) AND 'a' LIKE CONCAT(c1);
+DROP TABLE t1;
+
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS c1 LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('%'),('% ');
+SELECT * FROM t1 WHERE '%'=CONCAT(c1);
+SELECT * FROM t1 WHERE 'a' LIKE CONCAT(c1);
+SELECT * FROM t1 WHERE '%'=CONCAT(c1) AND 'a' LIKE CONCAT(c1);
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE '%'=CONCAT(c1) AND 'a' LIKE CONCAT(c1);
+DROP TABLE t1;
diff --git a/mysql-test/include/ctype_like_cond_propagation_utf8_german.inc b/mysql-test/include/ctype_like_cond_propagation_utf8_german.inc
new file mode 100644
index 00000000000..2cfa89448bc
--- /dev/null
+++ b/mysql-test/include/ctype_like_cond_propagation_utf8_german.inc
@@ -0,0 +1,16 @@
+--echo #
+--echo # MDEV-7149 Constant condition propagation erroneously applied for LIKE
+--echo #
+
+CREATE TABLE t1 AS SELECT REPEAT('a',10) AS c1 LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('ae'),('ä');
+SELECT * FROM t1 WHERE c1='ä';
+SELECT * FROM t1 WHERE c1 LIKE 'ae';
+SELECT * FROM t1 WHERE c1='ä' AND c1 LIKE 'ae';
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE c1='ä' AND c1 LIKE 'ae';
+SELECT * FROM t1 WHERE CONCAT(c1)='ä';
+SELECT * FROM t1 WHERE CONCAT(c1) LIKE 'ae';
+SELECT * FROM t1 WHERE CONCAT(c1)='ä' AND CONCAT(c1) LIKE 'ae';
+EXPLAIN EXTENDED SELECT * FROM t1 WHERE CONCAT(c1)='ä' AND CONCAT(c1) LIKE 'ae';
+DROP TABLE IF EXISTS t1;
diff --git a/mysql-test/include/ctype_mdev13118.inc b/mysql-test/include/ctype_mdev13118.inc
new file mode 100644
index 00000000000..efcb57299df
--- /dev/null
+++ b/mysql-test/include/ctype_mdev13118.inc
@@ -0,0 +1,15 @@
+--echo #
+--echo # MDEV-13118 Wrong results with LOWER and UPPER and subquery
+--echo #
+
+SET @save_optimizer_switch=@@optimizer_switch;
+SET optimizer_switch=_latin1'derived_merge=on';
+CREATE TABLE t1 AS SELECT REPEAT('a', 10) AS t LIMIT 0;
+SHOW CREATE TABLE t1;
+INSERT INTO t1 VALUES ('abcdefghi'),('ABCDEFGHI');
+--sorted_result
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT LOWER(t) t2 FROM t1) sub;
+--sorted_result
+SELECT CONCAT(t2,'-',t2) c2 FROM (SELECT UPPER(t) t2 FROM t1) sub;
+DROP TABLE t1;
+SET optimizer_switch=@save_optimizer_switch;
diff --git a/mysql-test/include/ctype_myanmar.inc b/mysql-test/include/ctype_myanmar.inc
new file mode 100644
index 00000000000..82dce1335a0
--- /dev/null
+++ b/mysql-test/include/ctype_myanmar.inc
@@ -0,0 +1,1302 @@
+--echo #
+--echo # Start of ctype_myanmar.inc
+--echo #
+
+SELECT @@collation_connection;
+
+#
+# Create a table with a varchar(x) column,
+# using current values of
+# @@character_set_connection and @@collation_connection.
+#
+
+CREATE TABLE t1 AS SELECT 100000 AS id, REPEAT(' ', 64) AS s1 LIMIT 0;
+SELECT COLLATION(s1) FROM t1;
+DELETE FROM t1;
+ALTER TABLE t1 MODIFY id INT NOT NULL AUTO_INCREMENT PRIMARY KEY;
+SHOW CREATE TABLE t1;
+
+INSERT INTO t1 (s1) VALUES
+(_ucs2 0x108C),
+(_ucs2 0x1037),
+(_ucs2 0x1038),
+(_ucs2 0x10371038),
+('--- Vowels'),
+(_ucs2 0x102C),
+(_ucs2 0x102B),
+(_ucs2 0x1032),
+(_ucs2 0x1031102C),
+(_ucs2 0x1031102B),
+(_ucs2 0x1031102C103A),
+(_ucs2 0x1031102B103A),
+(_ucs2 0x1034),
+(_ucs2 0x1036),
+(_ucs2 0x102D102F),
+('--- Vowels with finals'),
+(_ucs2 0x10001039),
+(_ucs2 0x1000103A),
+(_ucs2 0x102C10001039),
+(_ucs2 0x102C1000103A),
+(_ucs2 0x102B10001039),
+(_ucs2 0x102B1000103A),
+(_ucs2 0x102D10001039),
+(_ucs2 0x102D1000103A),
+(_ucs2 0x102F10001039),
+(_ucs2 0x102F1000103A),
+(_ucs2 0x103110001039),
+(_ucs2 0x10311000103A),
+(_ucs2 0x1031102C10001039),
+(_ucs2 0x1031102C1000103A),
+(_ucs2 0x1031102B10001039),
+(_ucs2 0x1031102B1000103A),
+(_ucs2 0x102D102F10001039),
+(_ucs2 0x102D102F1000103A),
+(_ucs2 0x10011039),
+(_ucs2 0x1001103A),
+(_ucs2 0x102C10011039),
+(_ucs2 0x102C1001103A),
+(_ucs2 0x102B10011039),
+(_ucs2 0x102B1001103A),
+(_ucs2 0x102D10011039),
+(_ucs2 0x102D1001103A),
+(_ucs2 0x102F10011039),
+(_ucs2 0x102F1001103A),
+(_ucs2 0x103110011039),
+(_ucs2 0x10311001103A),
+(_ucs2 0x1031102C10011039),
+(_ucs2 0x1031102C1001103A),
+(_ucs2 0x1031102B10011039),
+(_ucs2 0x1031102B1001103A),
+(_ucs2 0x102D102F10011039),
+(_ucs2 0x102D102F1001103A),
+(_ucs2 0x10021039),
+(_ucs2 0x1002103A),
+(_ucs2 0x102C10021039),
+(_ucs2 0x102C1002103A),
+(_ucs2 0x102B10021039),
+(_ucs2 0x102B1002103A),
+(_ucs2 0x102D10021039),
+(_ucs2 0x102D1002103A),
+(_ucs2 0x102F10021039),
+(_ucs2 0x102F1002103A),
+(_ucs2 0x103110021039),
+(_ucs2 0x10311002103A),
+(_ucs2 0x1031102C10021039),
+(_ucs2 0x1031102C1002103A),
+(_ucs2 0x1031102B10021039),
+(_ucs2 0x1031102B1002103A),
+(_ucs2 0x102D102F10021039),
+(_ucs2 0x102D102F1002103A),
+(_ucs2 0x10031039),
+(_ucs2 0x1003103A),
+(_ucs2 0x102C10031039),
+(_ucs2 0x102C1003103A),
+(_ucs2 0x102B10031039),
+(_ucs2 0x102B1003103A),
+(_ucs2 0x102D10031039),
+(_ucs2 0x102D1003103A),
+(_ucs2 0x102F10031039),
+(_ucs2 0x102F1003103A),
+(_ucs2 0x103110031039),
+(_ucs2 0x10311003103A),
+(_ucs2 0x1031102C10031039),
+(_ucs2 0x1031102C1003103A),
+(_ucs2 0x1031102B10031039),
+(_ucs2 0x1031102B1003103A),
+(_ucs2 0x102D102F10031039),
+(_ucs2 0x102D102F1003103A),
+(_ucs2 0x1004103A1039),
+(_ucs2 0x1004103A),
+(_ucs2 0x102C1004103A1039),
+(_ucs2 0x102C1004103A),
+(_ucs2 0x102B1004103A1039),
+(_ucs2 0x102B1004103A),
+(_ucs2 0x102D1004103A1039),
+(_ucs2 0x102D1004103A),
+(_ucs2 0x102F1004103A1039),
+(_ucs2 0x102F1004103A),
+(_ucs2 0x10311004103A1039),
+(_ucs2 0x10311004103A),
+(_ucs2 0x1031102C1004103A1039),
+(_ucs2 0x1031102C1004103A),
+(_ucs2 0x1031102B1004103A1039),
+(_ucs2 0x1031102B1004103A),
+(_ucs2 0x102D102F1004103A1039),
+(_ucs2 0x102D102F1004103A),
+(_ucs2 0x10051039),
+(_ucs2 0x1005103A),
+(_ucs2 0x102C10051039),
+(_ucs2 0x102C1005103A),
+(_ucs2 0x102B10051039),
+(_ucs2 0x102B1005103A),
+(_ucs2 0x102D10051039),
+(_ucs2 0x102D1005103A),
+(_ucs2 0x102F10051039),
+(_ucs2 0x102F1005103A),
+(_ucs2 0x103110051039),
+(_ucs2 0x10311005103A),
+(_ucs2 0x1031102C10051039),
+(_ucs2 0x1031102C1005103A),
+(_ucs2 0x1031102B10051039),
+(_ucs2 0x1031102B1005103A),
+(_ucs2 0x102D102F10051039),
+(_ucs2 0x102D102F1005103A),
+(_ucs2 0x10061039),
+(_ucs2 0x1006103A),
+(_ucs2 0x102C10061039),
+(_ucs2 0x102C1006103A),
+(_ucs2 0x102B10061039),
+(_ucs2 0x102B1006103A),
+(_ucs2 0x102D10061039),
+(_ucs2 0x102D1006103A),
+(_ucs2 0x102F10061039),
+(_ucs2 0x102F1006103A),
+(_ucs2 0x103110061039),
+(_ucs2 0x10311006103A),
+(_ucs2 0x1031102C10061039),
+(_ucs2 0x1031102C1006103A),
+(_ucs2 0x1031102B10061039),
+(_ucs2 0x1031102B1006103A),
+(_ucs2 0x102D102F10061039),
+(_ucs2 0x102D102F1006103A),
+(_ucs2 0x10071039),
+(_ucs2 0x1007103A),
+(_ucs2 0x102C10071039),
+(_ucs2 0x102C1007103A),
+(_ucs2 0x102B10071039),
+(_ucs2 0x102B1007103A),
+(_ucs2 0x102D10071039),
+(_ucs2 0x102D1007103A),
+(_ucs2 0x102F10071039),
+(_ucs2 0x102F1007103A),
+(_ucs2 0x103110071039),
+(_ucs2 0x10311007103A),
+(_ucs2 0x1031102C10071039),
+(_ucs2 0x1031102C1007103A),
+(_ucs2 0x1031102B10071039),
+(_ucs2 0x1031102B1007103A),
+(_ucs2 0x102D102F10071039),
+(_ucs2 0x102D102F1007103A),
+(_ucs2 0x1008103A),
+(_ucs2 0x102C1008103A),
+(_ucs2 0x102B1008103A),
+(_ucs2 0x102D1008103A),
+(_ucs2 0x102F1008103A),
+(_ucs2 0x10311008103A),
+(_ucs2 0x1031102C1008103A),
+(_ucs2 0x1031102B1008103A),
+(_ucs2 0x102D102F1008103A),
+(_ucs2 0x10091039),
+(_ucs2 0x1009103A),
+(_ucs2 0x102C10091039),
+(_ucs2 0x102C1009103A),
+(_ucs2 0x102B10091039),
+(_ucs2 0x102B1009103A),
+(_ucs2 0x102D10091039),
+(_ucs2 0x102D1009103A),
+(_ucs2 0x102F10091039),
+(_ucs2 0x102F1009103A),
+(_ucs2 0x103110091039),
+(_ucs2 0x10311009103A),
+(_ucs2 0x1031102C10091039),
+(_ucs2 0x1031102C1009103A),
+(_ucs2 0x1031102B10091039),
+(_ucs2 0x1031102B1009103A),
+(_ucs2 0x102D102F10091039),
+(_ucs2 0x102D102F1009103A),
+(_ucs2 0x100A1039),
+(_ucs2 0x100A103A),
+(_ucs2 0x102C100A1039),
+(_ucs2 0x102C100A103A),
+(_ucs2 0x102B100A1039),
+(_ucs2 0x102B100A103A),
+(_ucs2 0x102D100A1039),
+(_ucs2 0x102D100A103A),
+(_ucs2 0x102F100A1039),
+(_ucs2 0x102F100A103A),
+(_ucs2 0x1031100A1039),
+(_ucs2 0x1031100A103A),
+(_ucs2 0x1031102C100A1039),
+(_ucs2 0x1031102C100A103A),
+(_ucs2 0x1031102B100A1039),
+(_ucs2 0x1031102B100A103A),
+(_ucs2 0x102D102F100A1039),
+(_ucs2 0x102D102F100A103A),
+(_ucs2 0x100B1039),
+(_ucs2 0x100B103A),
+(_ucs2 0x102C100B1039),
+(_ucs2 0x102C100B103A),
+(_ucs2 0x102B100B1039),
+(_ucs2 0x102B100B103A),
+(_ucs2 0x102D100B1039),
+(_ucs2 0x102D100B103A),
+(_ucs2 0x102F100B1039),
+(_ucs2 0x102F100B103A),
+(_ucs2 0x1031100B1039),
+(_ucs2 0x1031100B103A),
+(_ucs2 0x1031102C100B1039),
+(_ucs2 0x1031102C100B103A),
+(_ucs2 0x1031102B100B1039),
+(_ucs2 0x1031102B100B103A),
+(_ucs2 0x102D102F100B1039),
+(_ucs2 0x102D102F100B103A),
+(_ucs2 0x100C1039),
+(_ucs2 0x100C103A),
+(_ucs2 0x102C100C1039),
+(_ucs2 0x102C100C103A),
+(_ucs2 0x102B100C1039),
+(_ucs2 0x102B100C103A),
+(_ucs2 0x102D100C1039),
+(_ucs2 0x102D100C103A),
+(_ucs2 0x102F100C1039),
+(_ucs2 0x102F100C103A),
+(_ucs2 0x1031100C1039),
+(_ucs2 0x1031100C103A),
+(_ucs2 0x1031102C100C1039),
+(_ucs2 0x1031102C100C103A),
+(_ucs2 0x1031102B100C1039),
+(_ucs2 0x1031102B100C103A),
+(_ucs2 0x102D102F100C1039),
+(_ucs2 0x102D102F100C103A),
+(_ucs2 0x100D1039),
+(_ucs2 0x100D103A),
+(_ucs2 0x102C100D1039),
+(_ucs2 0x102C100D103A),
+(_ucs2 0x102B100D1039),
+(_ucs2 0x102B100D103A),
+(_ucs2 0x102D100D1039),
+(_ucs2 0x102D100D103A),
+(_ucs2 0x102F100D1039),
+(_ucs2 0x102F100D103A),
+(_ucs2 0x1031100D1039),
+(_ucs2 0x1031100D103A),
+(_ucs2 0x1031102C100D1039),
+(_ucs2 0x1031102C100D103A),
+(_ucs2 0x1031102B100D1039),
+(_ucs2 0x1031102B100D103A),
+(_ucs2 0x102D102F100D1039),
+(_ucs2 0x102D102F100D103A),
+(_ucs2 0x100E1039),
+(_ucs2 0x100E103A),
+(_ucs2 0x102C100E1039),
+(_ucs2 0x102C100E103A),
+(_ucs2 0x102B100E1039),
+(_ucs2 0x102B100E103A),
+(_ucs2 0x102D100E1039),
+(_ucs2 0x102D100E103A),
+(_ucs2 0x102F100E1039),
+(_ucs2 0x102F100E103A),
+(_ucs2 0x1031100E1039),
+(_ucs2 0x1031100E103A),
+(_ucs2 0x1031102C100E1039),
+(_ucs2 0x1031102C100E103A),
+(_ucs2 0x1031102B100E1039),
+(_ucs2 0x1031102B100E103A),
+(_ucs2 0x102D102F100E1039),
+(_ucs2 0x102D102F100E103A),
+(_ucs2 0x100F1039),
+(_ucs2 0x100F103A),
+(_ucs2 0x102C100F1039),
+(_ucs2 0x102C100F103A),
+(_ucs2 0x102B100F1039),
+(_ucs2 0x102B100F103A),
+(_ucs2 0x102D100F1039),
+(_ucs2 0x102D100F103A),
+(_ucs2 0x102F100F1039),
+(_ucs2 0x102F100F103A),
+(_ucs2 0x1031100F1039),
+(_ucs2 0x1031100F103A),
+(_ucs2 0x1031102C100F1039),
+(_ucs2 0x1031102C100F103A),
+(_ucs2 0x1031102B100F1039),
+(_ucs2 0x1031102B100F103A),
+(_ucs2 0x102D102F100F1039),
+(_ucs2 0x102D102F100F103A),
+(_ucs2 0x10101039),
+(_ucs2 0x1010103A),
+(_ucs2 0x102C10101039),
+(_ucs2 0x102C1010103A),
+(_ucs2 0x102B10101039),
+(_ucs2 0x102B1010103A),
+(_ucs2 0x102D10101039),
+(_ucs2 0x102D1010103A),
+(_ucs2 0x102F10101039),
+(_ucs2 0x102F1010103A),
+(_ucs2 0x103110101039),
+(_ucs2 0x10311010103A),
+(_ucs2 0x1031102C10101039),
+(_ucs2 0x1031102C1010103A),
+(_ucs2 0x1031102B10101039),
+(_ucs2 0x1031102B1010103A),
+(_ucs2 0x102D102F10101039),
+(_ucs2 0x102D102F1010103A),
+(_ucs2 0x10111039),
+(_ucs2 0x1011103A),
+(_ucs2 0x102C10111039),
+(_ucs2 0x102C1011103A),
+(_ucs2 0x102B10111039),
+(_ucs2 0x102B1011103A),
+(_ucs2 0x102D10111039),
+(_ucs2 0x102D1011103A),
+(_ucs2 0x102F10111039),
+(_ucs2 0x102F1011103A),
+(_ucs2 0x103110111039),
+(_ucs2 0x10311011103A),
+(_ucs2 0x1031102C10111039),
+(_ucs2 0x1031102C1011103A),
+(_ucs2 0x1031102B10111039),
+(_ucs2 0x1031102B1011103A),
+(_ucs2 0x102D102F10111039),
+(_ucs2 0x102D102F1011103A),
+(_ucs2 0x10121039),
+(_ucs2 0x1012103A),
+(_ucs2 0x102C10121039),
+(_ucs2 0x102C1012103A),
+(_ucs2 0x102B10121039),
+(_ucs2 0x102B1012103A),
+(_ucs2 0x102D10121039),
+(_ucs2 0x102D1012103A),
+(_ucs2 0x102F10121039),
+(_ucs2 0x102F1012103A),
+(_ucs2 0x103110121039),
+(_ucs2 0x10311012103A),
+(_ucs2 0x1031102C10121039),
+(_ucs2 0x1031102C1012103A),
+(_ucs2 0x1031102B10121039),
+(_ucs2 0x1031102B1012103A),
+(_ucs2 0x102D102F10121039),
+(_ucs2 0x102D102F1012103A),
+(_ucs2 0x10131039),
+(_ucs2 0x1013103A),
+(_ucs2 0x102C10131039),
+(_ucs2 0x102C1013103A),
+(_ucs2 0x102B10131039),
+(_ucs2 0x102B1013103A),
+(_ucs2 0x102D10131039),
+(_ucs2 0x102D1013103A),
+(_ucs2 0x102F10131039),
+(_ucs2 0x102F1013103A),
+(_ucs2 0x103110131039),
+(_ucs2 0x10311013103A),
+(_ucs2 0x1031102C10131039),
+(_ucs2 0x1031102C1013103A),
+(_ucs2 0x1031102B10131039),
+(_ucs2 0x1031102B1013103A),
+(_ucs2 0x102D102F10131039),
+(_ucs2 0x102D102F1013103A),
+(_ucs2 0x10141039),
+(_ucs2 0x1014103A),
+(_ucs2 0x102C10141039),
+(_ucs2 0x102C1014103A),
+(_ucs2 0x102B10141039),
+(_ucs2 0x102B1014103A),
+(_ucs2 0x102D10141039),
+(_ucs2 0x102D1014103A),
+(_ucs2 0x102F10141039),
+(_ucs2 0x102F1014103A),
+(_ucs2 0x103110141039),
+(_ucs2 0x10311014103A),
+(_ucs2 0x1031102C10141039),
+(_ucs2 0x1031102C1014103A),
+(_ucs2 0x1031102B10141039),
+(_ucs2 0x1031102B1014103A),
+(_ucs2 0x102D102F10141039),
+(_ucs2 0x102D102F1014103A),
+(_ucs2 0x10151039),
+(_ucs2 0x1015103A),
+(_ucs2 0x102C10151039),
+(_ucs2 0x102C1015103A),
+(_ucs2 0x102B10151039),
+(_ucs2 0x102B1015103A),
+(_ucs2 0x102D10151039),
+(_ucs2 0x102D1015103A),
+(_ucs2 0x102F10151039),
+(_ucs2 0x102F1015103A),
+(_ucs2 0x103110151039),
+(_ucs2 0x10311015103A),
+(_ucs2 0x1031102C10151039),
+(_ucs2 0x1031102C1015103A),
+(_ucs2 0x1031102B10151039),
+(_ucs2 0x1031102B1015103A),
+(_ucs2 0x102D102F10151039),
+(_ucs2 0x102D102F1015103A),
+(_ucs2 0x10161039),
+(_ucs2 0x1016103A),
+(_ucs2 0x102C10161039),
+(_ucs2 0x102C1016103A),
+(_ucs2 0x102B10161039),
+(_ucs2 0x102B1016103A),
+(_ucs2 0x102D10161039),
+(_ucs2 0x102D1016103A),
+(_ucs2 0x102F10161039),
+(_ucs2 0x102F1016103A),
+(_ucs2 0x103110161039),
+(_ucs2 0x10311016103A),
+(_ucs2 0x1031102C10161039),
+(_ucs2 0x1031102C1016103A),
+(_ucs2 0x1031102B10161039),
+(_ucs2 0x1031102B1016103A),
+(_ucs2 0x102D102F10161039),
+(_ucs2 0x102D102F1016103A),
+(_ucs2 0x10171039),
+(_ucs2 0x1017103A),
+(_ucs2 0x102C10171039),
+(_ucs2 0x102C1017103A),
+(_ucs2 0x102B10171039),
+(_ucs2 0x102B1017103A),
+(_ucs2 0x102D10171039),
+(_ucs2 0x102D1017103A),
+(_ucs2 0x102F10171039),
+(_ucs2 0x102F1017103A),
+(_ucs2 0x103110171039),
+(_ucs2 0x10311017103A),
+(_ucs2 0x1031102C10171039),
+(_ucs2 0x1031102C1017103A),
+(_ucs2 0x1031102B10171039),
+(_ucs2 0x1031102B1017103A),
+(_ucs2 0x102D102F10171039),
+(_ucs2 0x102D102F1017103A),
+(_ucs2 0x10181039),
+(_ucs2 0x1018103A),
+(_ucs2 0x102C10181039),
+(_ucs2 0x102C1018103A),
+(_ucs2 0x102B10181039),
+(_ucs2 0x102B1018103A),
+(_ucs2 0x102D10181039),
+(_ucs2 0x102D1018103A),
+(_ucs2 0x102F10181039),
+(_ucs2 0x102F1018103A),
+(_ucs2 0x103110181039),
+(_ucs2 0x10311018103A),
+(_ucs2 0x1031102C10181039),
+(_ucs2 0x1031102C1018103A),
+(_ucs2 0x1031102B10181039),
+(_ucs2 0x1031102B1018103A),
+(_ucs2 0x102D102F10181039),
+(_ucs2 0x102D102F1018103A),
+(_ucs2 0x10191039),
+(_ucs2 0x1019103A),
+(_ucs2 0x102C10191039),
+(_ucs2 0x102C1019103A),
+(_ucs2 0x102B10191039),
+(_ucs2 0x102B1019103A),
+(_ucs2 0x102D10191039),
+(_ucs2 0x102D1019103A),
+(_ucs2 0x102F10191039),
+(_ucs2 0x102F1019103A),
+(_ucs2 0x103110191039),
+(_ucs2 0x10311019103A),
+(_ucs2 0x1031102C10191039),
+(_ucs2 0x1031102C1019103A),
+(_ucs2 0x1031102B10191039),
+(_ucs2 0x1031102B1019103A),
+(_ucs2 0x102D102F10191039),
+(_ucs2 0x102D102F1019103A),
+(_ucs2 0x101A1039),
+(_ucs2 0x101A103A),
+(_ucs2 0x102C101A1039),
+(_ucs2 0x102C101A103A),
+(_ucs2 0x102B101A1039),
+(_ucs2 0x102B101A103A),
+(_ucs2 0x102D101A1039),
+(_ucs2 0x102D101A103A),
+(_ucs2 0x102F101A1039),
+(_ucs2 0x102F101A103A),
+(_ucs2 0x1031101A1039),
+(_ucs2 0x1031101A103A),
+(_ucs2 0x1031102C101A1039),
+(_ucs2 0x1031102C101A103A),
+(_ucs2 0x1031102B101A1039),
+(_ucs2 0x1031102B101A103A),
+(_ucs2 0x102D102F101A1039),
+(_ucs2 0x102D102F101A103A),
+(_ucs2 0x101B1039),
+(_ucs2 0x101B103A),
+(_ucs2 0x102C101B1039),
+(_ucs2 0x102C101B103A),
+(_ucs2 0x102B101B1039),
+(_ucs2 0x102B101B103A),
+(_ucs2 0x102D101B1039),
+(_ucs2 0x102D101B103A),
+(_ucs2 0x102F101B1039),
+(_ucs2 0x102F101B103A),
+(_ucs2 0x1031101B1039),
+(_ucs2 0x1031101B103A),
+(_ucs2 0x1031102C101B1039),
+(_ucs2 0x1031102C101B103A),
+(_ucs2 0x1031102B101B1039),
+(_ucs2 0x1031102B101B103A),
+(_ucs2 0x102D102F101B1039),
+(_ucs2 0x102D102F101B103A),
+(_ucs2 0x101C1039),
+(_ucs2 0x101C103A),
+(_ucs2 0x102C101C1039),
+(_ucs2 0x102C101C103A),
+(_ucs2 0x102B101C1039),
+(_ucs2 0x102B101C103A),
+(_ucs2 0x102D101C1039),
+(_ucs2 0x102D101C103A),
+(_ucs2 0x102F101C1039),
+(_ucs2 0x102F101C103A),
+(_ucs2 0x1031101C1039),
+(_ucs2 0x1031101C103A),
+(_ucs2 0x1031102C101C1039),
+(_ucs2 0x1031102C101C103A),
+(_ucs2 0x1031102B101C1039),
+(_ucs2 0x1031102B101C103A),
+(_ucs2 0x102D102F101C1039),
+(_ucs2 0x102D102F101C103A),
+(_ucs2 0x101D103A),
+(_ucs2 0x102C101D103A),
+(_ucs2 0x102B101D103A),
+(_ucs2 0x102D101D103A),
+(_ucs2 0x102F101D103A),
+(_ucs2 0x1031101D103A),
+(_ucs2 0x1031102C101D103A),
+(_ucs2 0x1031102B101D103A),
+(_ucs2 0x102D102F101D103A),
+(_ucs2 0x101E1039),
+(_ucs2 0x101E103A),
+(_ucs2 0x102C101E1039),
+(_ucs2 0x102C101E103A),
+(_ucs2 0x102B101E1039),
+(_ucs2 0x102B101E103A),
+(_ucs2 0x102D101E1039),
+(_ucs2 0x102D101E103A),
+(_ucs2 0x102F101E1039),
+(_ucs2 0x102F101E103A),
+(_ucs2 0x1031101E1039),
+(_ucs2 0x1031101E103A),
+(_ucs2 0x1031102C101E1039),
+(_ucs2 0x1031102C101E103A),
+(_ucs2 0x1031102B101E1039),
+(_ucs2 0x1031102B101E103A),
+(_ucs2 0x102D102F101E1039),
+(_ucs2 0x102D102F101E103A),
+(_ucs2 0x101F1039),
+(_ucs2 0x101F103A),
+(_ucs2 0x102C101F1039),
+(_ucs2 0x102C101F103A),
+(_ucs2 0x102B101F1039),
+(_ucs2 0x102B101F103A),
+(_ucs2 0x102D101F1039),
+(_ucs2 0x102D101F103A),
+(_ucs2 0x102F101F1039),
+(_ucs2 0x102F101F103A),
+(_ucs2 0x1031101F1039),
+(_ucs2 0x1031101F103A),
+(_ucs2 0x1031102C101F1039),
+(_ucs2 0x1031102C101F103A),
+(_ucs2 0x1031102B101F1039),
+(_ucs2 0x1031102B101F103A),
+(_ucs2 0x102D102F101F1039),
+(_ucs2 0x102D102F101F103A),
+(_ucs2 0x1020103A),
+(_ucs2 0x102C1020103A),
+(_ucs2 0x102B1020103A),
+(_ucs2 0x102D1020103A),
+(_ucs2 0x102F1020103A),
+(_ucs2 0x10311020103A),
+(_ucs2 0x1031102C1020103A),
+(_ucs2 0x1031102B1020103A),
+(_ucs2 0x102D102F1020103A),
+(_ucs2 0x1021103A),
+(_ucs2 0x102C1021103A),
+(_ucs2 0x102B1021103A),
+(_ucs2 0x102D1021103A),
+(_ucs2 0x102F1021103A),
+(_ucs2 0x10311021103A),
+(_ucs2 0x1031102C1021103A),
+(_ucs2 0x1031102B1021103A),
+(_ucs2 0x102D102F1021103A),
+('--- Medials'),
+(_ucs2 0x105E),
+(_ucs2 0x105F),
+(_ucs2 0x103B),
+(_ucs2 0x103C),
+(_ucs2 0x1060),
+(_ucs2 0x103D),
+(_ucs2 0x1082),
+(_ucs2 0x103E),
+(_ucs2 0x103B103D),
+(_ucs2 0x103C103D),
+(_ucs2 0x103B103E),
+(_ucs2 0x103C103E),
+(_ucs2 0x103D103E),
+(_ucs2 0x103B103D103E),
+(_ucs2 0x103C103D103E),
+('--- Independent vowels'),
+(_ucs2 0x1021102D),
+(_ucs2 0x1023),
+(_ucs2 0x1021102E),
+(_ucs2 0x1024),
+(_ucs2 0x1021102F),
+(_ucs2 0x1025),
+(_ucs2 0x10211030),
+(_ucs2 0x1026),
+(_ucs2 0x10211031),
+(_ucs2 0x1027),
+(_ucs2 0x1028),
+(_ucs2 0x10211031102C),
+(_ucs2 0x1029),
+(_ucs2 0x10211031102C103A),
+(_ucs2 0x102A),
+(_ucs2 0x102D1019103A),
+(_ucs2 0x102D1036),
+(_ucs2 0x102D1019103A1037),
+(_ucs2 0x102D10361037),
+(_ucs2 0x102D1019103A1038),
+(_ucs2 0x102D10361038),
+(_ucs2 0x102F1019103A),
+(_ucs2 0x102F1036),
+(_ucs2 0x102F1019103A1037),
+(_ucs2 0x102F10361037),
+(_ucs2 0x102F1019103A1038),
+(_ucs2 0x102F10361038),
+(_ucs2 0x1021102F1036),
+(_ucs2 0x1025102F1036),
+('--- Independent vowels with finals'),
+(_ucs2 0x1021102D10001039),
+(_ucs2 0x102310001039),
+(_ucs2 0x1021102D1000103A),
+(_ucs2 0x10231000103A),
+(_ucs2 0x1021102F10001039),
+(_ucs2 0x102510001039),
+(_ucs2 0x1021102F1000103A),
+(_ucs2 0x10251000103A),
+(_ucs2 0x1021103110001039),
+(_ucs2 0x102710001039),
+(_ucs2 0x102110311000103A),
+(_ucs2 0x10271000103A),
+(_ucs2 0x10211031102C10001039),
+(_ucs2 0x102910001039),
+(_ucs2 0x10211031102C1000103A),
+(_ucs2 0x10291000103A),
+(_ucs2 0x10211031102C10001039),
+(_ucs2 0x10291031102C10001039),
+(_ucs2 0x10211031102C1000103A),
+(_ucs2 0x10291031102C1000103A),
+(_ucs2 0x1021102D10011039),
+(_ucs2 0x102310011039),
+(_ucs2 0x1021102D1001103A),
+(_ucs2 0x10231001103A),
+(_ucs2 0x1021102F10011039),
+(_ucs2 0x102510011039),
+(_ucs2 0x1021102F1001103A),
+(_ucs2 0x10251001103A),
+(_ucs2 0x1021103110011039),
+(_ucs2 0x102710011039),
+(_ucs2 0x102110311001103A),
+(_ucs2 0x10271001103A),
+(_ucs2 0x10211031102C10011039),
+(_ucs2 0x102910011039),
+(_ucs2 0x10211031102C1001103A),
+(_ucs2 0x10291001103A),
+(_ucs2 0x10211031102C10011039),
+(_ucs2 0x10291031102C10011039),
+(_ucs2 0x10211031102C1001103A),
+(_ucs2 0x10291031102C1001103A),
+(_ucs2 0x1021102D10021039),
+(_ucs2 0x102310021039),
+(_ucs2 0x1021102D1002103A),
+(_ucs2 0x10231002103A),
+(_ucs2 0x1021102F10021039),
+(_ucs2 0x102510021039),
+(_ucs2 0x1021102F1002103A),
+(_ucs2 0x10251002103A),
+(_ucs2 0x1021103110021039),
+(_ucs2 0x102710021039),
+(_ucs2 0x102110311002103A),
+(_ucs2 0x10271002103A),
+(_ucs2 0x10211031102C10021039),
+(_ucs2 0x102910021039),
+(_ucs2 0x10211031102C1002103A),
+(_ucs2 0x10291002103A),
+(_ucs2 0x10211031102C10021039),
+(_ucs2 0x10291031102C10021039),
+(_ucs2 0x10211031102C1002103A),
+(_ucs2 0x10291031102C1002103A),
+(_ucs2 0x1021102D10031039),
+(_ucs2 0x102310031039),
+(_ucs2 0x1021102D1003103A),
+(_ucs2 0x10231003103A),
+(_ucs2 0x1021102F10031039),
+(_ucs2 0x102510031039),
+(_ucs2 0x1021102F1003103A),
+(_ucs2 0x10251003103A),
+(_ucs2 0x1021103110031039),
+(_ucs2 0x102710031039),
+(_ucs2 0x102110311003103A),
+(_ucs2 0x10271003103A),
+(_ucs2 0x10211031102C10031039),
+(_ucs2 0x102910031039),
+(_ucs2 0x10211031102C1003103A),
+(_ucs2 0x10291003103A),
+(_ucs2 0x10211031102C10031039),
+(_ucs2 0x10291031102C10031039),
+(_ucs2 0x10211031102C1003103A),
+(_ucs2 0x10291031102C1003103A),
+(_ucs2 0x1021102D10041039),
+(_ucs2 0x102310041039),
+(_ucs2 0x1021102D1004103A),
+(_ucs2 0x10231004103A),
+(_ucs2 0x1021102F10041039),
+(_ucs2 0x102510041039),
+(_ucs2 0x1021102F1004103A),
+(_ucs2 0x10251004103A),
+(_ucs2 0x1021103110041039),
+(_ucs2 0x102710041039),
+(_ucs2 0x102110311004103A),
+(_ucs2 0x10271004103A),
+(_ucs2 0x10211031102C10041039),
+(_ucs2 0x102910041039),
+(_ucs2 0x10211031102C1004103A),
+(_ucs2 0x10291004103A),
+(_ucs2 0x10211031102C10041039),
+(_ucs2 0x10291031102C10041039),
+(_ucs2 0x10211031102C1004103A),
+(_ucs2 0x10291031102C1004103A),
+(_ucs2 0x1021102D10051039),
+(_ucs2 0x102310051039),
+(_ucs2 0x1021102D1005103A),
+(_ucs2 0x10231005103A),
+(_ucs2 0x1021102F10051039),
+(_ucs2 0x102510051039),
+(_ucs2 0x1021102F1005103A),
+(_ucs2 0x10251005103A),
+(_ucs2 0x1021103110051039),
+(_ucs2 0x102710051039),
+(_ucs2 0x102110311005103A),
+(_ucs2 0x10271005103A),
+(_ucs2 0x10211031102C10051039),
+(_ucs2 0x102910051039),
+(_ucs2 0x10211031102C1005103A),
+(_ucs2 0x10291005103A),
+(_ucs2 0x10211031102C10051039),
+(_ucs2 0x10291031102C10051039),
+(_ucs2 0x10211031102C1005103A),
+(_ucs2 0x10291031102C1005103A),
+(_ucs2 0x1021102D10061039),
+(_ucs2 0x102310061039),
+(_ucs2 0x1021102D1006103A),
+(_ucs2 0x10231006103A),
+(_ucs2 0x1021102F10061039),
+(_ucs2 0x102510061039),
+(_ucs2 0x1021102F1006103A),
+(_ucs2 0x10251006103A),
+(_ucs2 0x1021103110061039),
+(_ucs2 0x102710061039),
+(_ucs2 0x102110311006103A),
+(_ucs2 0x10271006103A),
+(_ucs2 0x10211031102C10061039),
+(_ucs2 0x102910061039),
+(_ucs2 0x10211031102C1006103A),
+(_ucs2 0x10291006103A),
+(_ucs2 0x10211031102C10061039),
+(_ucs2 0x10291031102C10061039),
+(_ucs2 0x10211031102C1006103A),
+(_ucs2 0x10291031102C1006103A),
+(_ucs2 0x1021102D10071039),
+(_ucs2 0x102310071039),
+(_ucs2 0x1021102D1007103A),
+(_ucs2 0x10231007103A),
+(_ucs2 0x1021102F10071039),
+(_ucs2 0x102510071039),
+(_ucs2 0x1021102F1007103A),
+(_ucs2 0x10251007103A),
+(_ucs2 0x1021103110071039),
+(_ucs2 0x102710071039),
+(_ucs2 0x102110311007103A),
+(_ucs2 0x10271007103A),
+(_ucs2 0x10211031102C10071039),
+(_ucs2 0x102910071039),
+(_ucs2 0x10211031102C1007103A),
+(_ucs2 0x10291007103A),
+(_ucs2 0x10211031102C10071039),
+(_ucs2 0x10291031102C10071039),
+(_ucs2 0x10211031102C1007103A),
+(_ucs2 0x10291031102C1007103A),
+(_ucs2 0x1021102D10091039),
+(_ucs2 0x102310091039),
+(_ucs2 0x1021102D1009103A),
+(_ucs2 0x10231009103A),
+(_ucs2 0x1021102F10091039),
+(_ucs2 0x102510091039),
+(_ucs2 0x1021102F1009103A),
+(_ucs2 0x10251009103A),
+(_ucs2 0x1021103110091039),
+(_ucs2 0x102710091039),
+(_ucs2 0x102110311009103A),
+(_ucs2 0x10271009103A),
+(_ucs2 0x10211031102C10091039),
+(_ucs2 0x102910091039),
+(_ucs2 0x10211031102C1009103A),
+(_ucs2 0x10291009103A),
+(_ucs2 0x10211031102C10091039),
+(_ucs2 0x10291031102C10091039),
+(_ucs2 0x10211031102C1009103A),
+(_ucs2 0x10291031102C1009103A),
+(_ucs2 0x1021102D100A1039),
+(_ucs2 0x1023100A1039),
+(_ucs2 0x1021102D100A103A),
+(_ucs2 0x1023100A103A),
+(_ucs2 0x1021102F100A1039),
+(_ucs2 0x1025100A1039),
+(_ucs2 0x1021102F100A103A),
+(_ucs2 0x1025100A103A),
+(_ucs2 0x10211031100A1039),
+(_ucs2 0x1027100A1039),
+(_ucs2 0x10211031100A103A),
+(_ucs2 0x1027100A103A),
+(_ucs2 0x10211031102C100A1039),
+(_ucs2 0x1029100A1039),
+(_ucs2 0x10211031102C100A103A),
+(_ucs2 0x1029100A103A),
+(_ucs2 0x10211031102C100A1039),
+(_ucs2 0x10291031102C100A1039),
+(_ucs2 0x10211031102C100A103A),
+(_ucs2 0x10291031102C100A103A),
+(_ucs2 0x1021102D100B1039),
+(_ucs2 0x1023100B1039),
+(_ucs2 0x1021102D100B103A),
+(_ucs2 0x1023100B103A),
+(_ucs2 0x1021102F100B1039),
+(_ucs2 0x1025100B1039),
+(_ucs2 0x1021102F100B103A),
+(_ucs2 0x1025100B103A),
+(_ucs2 0x10211031100B1039),
+(_ucs2 0x1027100B1039),
+(_ucs2 0x10211031100B103A),
+(_ucs2 0x1027100B103A),
+(_ucs2 0x10211031102C100B1039),
+(_ucs2 0x1029100B1039),
+(_ucs2 0x10211031102C100B103A),
+(_ucs2 0x1029100B103A),
+(_ucs2 0x10211031102C100B1039),
+(_ucs2 0x10291031102C100B1039),
+(_ucs2 0x10211031102C100B103A),
+(_ucs2 0x10291031102C100B103A),
+(_ucs2 0x1021102D100C1039),
+(_ucs2 0x1023100C1039),
+(_ucs2 0x1021102D100C103A),
+(_ucs2 0x1023100C103A),
+(_ucs2 0x1021102F100C1039),
+(_ucs2 0x1025100C1039),
+(_ucs2 0x1021102F100C103A),
+(_ucs2 0x1025100C103A),
+(_ucs2 0x10211031100C1039),
+(_ucs2 0x1027100C1039),
+(_ucs2 0x10211031100C103A),
+(_ucs2 0x1027100C103A),
+(_ucs2 0x10211031102C100C1039),
+(_ucs2 0x1029100C1039),
+(_ucs2 0x10211031102C100C103A),
+(_ucs2 0x1029100C103A),
+(_ucs2 0x10211031102C100C1039),
+(_ucs2 0x10291031102C100C1039),
+(_ucs2 0x10211031102C100C103A),
+(_ucs2 0x10291031102C100C103A),
+(_ucs2 0x1021102D100D1039),
+(_ucs2 0x1023100D1039),
+(_ucs2 0x1021102D100D103A),
+(_ucs2 0x1023100D103A),
+(_ucs2 0x1021102F100D1039),
+(_ucs2 0x1025100D1039),
+(_ucs2 0x1021102F100D103A),
+(_ucs2 0x1025100D103A),
+(_ucs2 0x10211031100D1039),
+(_ucs2 0x1027100D1039),
+(_ucs2 0x10211031100D103A),
+(_ucs2 0x1027100D103A),
+(_ucs2 0x10211031102C100D1039),
+(_ucs2 0x1029100D1039),
+(_ucs2 0x10211031102C100D103A),
+(_ucs2 0x1029100D103A),
+(_ucs2 0x10211031102C100D1039),
+(_ucs2 0x10291031102C100D1039),
+(_ucs2 0x10211031102C100D103A),
+(_ucs2 0x10291031102C100D103A),
+(_ucs2 0x1021102D100E1039),
+(_ucs2 0x1023100E1039),
+(_ucs2 0x1021102D100E103A),
+(_ucs2 0x1023100E103A),
+(_ucs2 0x1021102F100E1039),
+(_ucs2 0x1025100E1039),
+(_ucs2 0x1021102F100E103A),
+(_ucs2 0x1025100E103A),
+(_ucs2 0x10211031100E1039),
+(_ucs2 0x1027100E1039),
+(_ucs2 0x10211031100E103A),
+(_ucs2 0x1027100E103A),
+(_ucs2 0x10211031102C100E1039),
+(_ucs2 0x1029100E1039),
+(_ucs2 0x10211031102C100E103A),
+(_ucs2 0x1029100E103A),
+(_ucs2 0x10211031102C100E1039),
+(_ucs2 0x10291031102C100E1039),
+(_ucs2 0x10211031102C100E103A),
+(_ucs2 0x10291031102C100E103A),
+(_ucs2 0x1021102D100F1039),
+(_ucs2 0x1023100F1039),
+(_ucs2 0x1021102D100F103A),
+(_ucs2 0x1023100F103A),
+(_ucs2 0x1021102F100F1039),
+(_ucs2 0x1025100F1039),
+(_ucs2 0x1021102F100F103A),
+(_ucs2 0x1025100F103A),
+(_ucs2 0x10211031100F1039),
+(_ucs2 0x1027100F1039),
+(_ucs2 0x10211031100F103A),
+(_ucs2 0x1027100F103A),
+(_ucs2 0x10211031102C100F1039),
+(_ucs2 0x1029100F1039),
+(_ucs2 0x10211031102C100F103A),
+(_ucs2 0x1029100F103A),
+(_ucs2 0x10211031102C100F1039),
+(_ucs2 0x10291031102C100F1039),
+(_ucs2 0x10211031102C100F103A),
+(_ucs2 0x10291031102C100F103A),
+(_ucs2 0x1021102D10101039),
+(_ucs2 0x102310101039),
+(_ucs2 0x1021102D1010103A),
+(_ucs2 0x10231010103A),
+(_ucs2 0x1021102F10101039),
+(_ucs2 0x102510101039),
+(_ucs2 0x1021102F1010103A),
+(_ucs2 0x10251010103A),
+(_ucs2 0x1021103110101039),
+(_ucs2 0x102710101039),
+(_ucs2 0x102110311010103A),
+(_ucs2 0x10271010103A),
+(_ucs2 0x10211031102C10101039),
+(_ucs2 0x102910101039),
+(_ucs2 0x10211031102C1010103A),
+(_ucs2 0x10291010103A),
+(_ucs2 0x10211031102C10101039),
+(_ucs2 0x10291031102C10101039),
+(_ucs2 0x10211031102C1010103A),
+(_ucs2 0x10291031102C1010103A),
+(_ucs2 0x1021102D10111039),
+(_ucs2 0x102310111039),
+(_ucs2 0x1021102D1011103A),
+(_ucs2 0x10231011103A),
+(_ucs2 0x1021102F10111039),
+(_ucs2 0x102510111039),
+(_ucs2 0x1021102F1011103A),
+(_ucs2 0x10251011103A),
+(_ucs2 0x1021103110111039),
+(_ucs2 0x102710111039),
+(_ucs2 0x102110311011103A),
+(_ucs2 0x10271011103A),
+(_ucs2 0x10211031102C10111039),
+(_ucs2 0x102910111039),
+(_ucs2 0x10211031102C1011103A),
+(_ucs2 0x10291011103A),
+(_ucs2 0x10211031102C10111039),
+(_ucs2 0x10291031102C10111039),
+(_ucs2 0x10211031102C1011103A),
+(_ucs2 0x10291031102C1011103A),
+(_ucs2 0x1021102D10121039),
+(_ucs2 0x102310121039),
+(_ucs2 0x1021102D1012103A),
+(_ucs2 0x10231012103A),
+(_ucs2 0x1021102F10121039),
+(_ucs2 0x102510121039),
+(_ucs2 0x1021102F1012103A),
+(_ucs2 0x10251012103A),
+(_ucs2 0x1021103110121039),
+(_ucs2 0x102710121039),
+(_ucs2 0x102110311012103A),
+(_ucs2 0x10271012103A),
+(_ucs2 0x10211031102C10121039),
+(_ucs2 0x102910121039),
+(_ucs2 0x10211031102C1012103A),
+(_ucs2 0x10291012103A),
+(_ucs2 0x10211031102C10121039),
+(_ucs2 0x10291031102C10121039),
+(_ucs2 0x10211031102C1012103A),
+(_ucs2 0x10291031102C1012103A),
+(_ucs2 0x1021102D10131039),
+(_ucs2 0x102310131039),
+(_ucs2 0x1021102D1013103A),
+(_ucs2 0x10231013103A),
+(_ucs2 0x1021102F10131039),
+(_ucs2 0x102510131039),
+(_ucs2 0x1021102F1013103A),
+(_ucs2 0x10251013103A),
+(_ucs2 0x1021103110131039),
+(_ucs2 0x102710131039),
+(_ucs2 0x102110311013103A),
+(_ucs2 0x10271013103A),
+(_ucs2 0x10211031102C10131039),
+(_ucs2 0x102910131039),
+(_ucs2 0x10211031102C1013103A),
+(_ucs2 0x10291013103A),
+(_ucs2 0x10211031102C10131039),
+(_ucs2 0x10291031102C10131039),
+(_ucs2 0x10211031102C1013103A),
+(_ucs2 0x10291031102C1013103A),
+(_ucs2 0x1021102D10141039),
+(_ucs2 0x102310141039),
+(_ucs2 0x1021102D1014103A),
+(_ucs2 0x10231014103A),
+(_ucs2 0x1021102F10141039),
+(_ucs2 0x102510141039),
+(_ucs2 0x1021102F1014103A),
+(_ucs2 0x10251014103A),
+(_ucs2 0x1021103110141039),
+(_ucs2 0x102710141039),
+(_ucs2 0x102110311014103A),
+(_ucs2 0x10271014103A),
+(_ucs2 0x10211031102C10141039),
+(_ucs2 0x102910141039),
+(_ucs2 0x10211031102C1014103A),
+(_ucs2 0x10291014103A),
+(_ucs2 0x10211031102C10141039),
+(_ucs2 0x10291031102C10141039),
+(_ucs2 0x10211031102C1014103A),
+(_ucs2 0x10291031102C1014103A),
+(_ucs2 0x1021102D10151039),
+(_ucs2 0x102310151039),
+(_ucs2 0x1021102D1015103A),
+(_ucs2 0x10231015103A),
+(_ucs2 0x1021102F10151039),
+(_ucs2 0x102510151039),
+(_ucs2 0x1021102F1015103A),
+(_ucs2 0x10251015103A),
+(_ucs2 0x1021103110151039),
+(_ucs2 0x102710151039),
+(_ucs2 0x102110311015103A),
+(_ucs2 0x10271015103A),
+(_ucs2 0x10211031102C10151039),
+(_ucs2 0x102910151039),
+(_ucs2 0x10211031102C1015103A),
+(_ucs2 0x10291015103A),
+(_ucs2 0x10211031102C10151039),
+(_ucs2 0x10291031102C10151039),
+(_ucs2 0x10211031102C1015103A),
+(_ucs2 0x10291031102C1015103A),
+(_ucs2 0x1021102D10161039),
+(_ucs2 0x102310161039),
+(_ucs2 0x1021102D1016103A),
+(_ucs2 0x10231016103A),
+(_ucs2 0x1021102F10161039),
+(_ucs2 0x102510161039),
+(_ucs2 0x1021102F1016103A),
+(_ucs2 0x10251016103A),
+(_ucs2 0x1021103110161039),
+(_ucs2 0x102710161039),
+(_ucs2 0x102110311016103A),
+(_ucs2 0x10271016103A),
+(_ucs2 0x10211031102C10161039),
+(_ucs2 0x102910161039),
+(_ucs2 0x10211031102C1016103A),
+(_ucs2 0x10291016103A),
+(_ucs2 0x10211031102C10161039),
+(_ucs2 0x10291031102C10161039),
+(_ucs2 0x10211031102C1016103A),
+(_ucs2 0x10291031102C1016103A),
+(_ucs2 0x1021102D10171039),
+(_ucs2 0x102310171039),
+(_ucs2 0x1021102D1017103A),
+(_ucs2 0x10231017103A),
+(_ucs2 0x1021102F10171039),
+(_ucs2 0x102510171039),
+(_ucs2 0x1021102F1017103A),
+(_ucs2 0x10251017103A),
+(_ucs2 0x1021103110171039),
+(_ucs2 0x102710171039),
+(_ucs2 0x102110311017103A),
+(_ucs2 0x10271017103A),
+(_ucs2 0x10211031102C10171039),
+(_ucs2 0x102910171039),
+(_ucs2 0x10211031102C1017103A),
+(_ucs2 0x10291017103A),
+(_ucs2 0x10211031102C10171039),
+(_ucs2 0x10291031102C10171039),
+(_ucs2 0x10211031102C1017103A),
+(_ucs2 0x10291031102C1017103A),
+(_ucs2 0x1021102D10181039),
+(_ucs2 0x102310181039),
+(_ucs2 0x1021102D1018103A),
+(_ucs2 0x10231018103A),
+(_ucs2 0x1021102F10181039),
+(_ucs2 0x102510181039),
+(_ucs2 0x1021102F1018103A),
+(_ucs2 0x10251018103A),
+(_ucs2 0x1021103110181039),
+(_ucs2 0x102710181039),
+(_ucs2 0x102110311018103A),
+(_ucs2 0x10271018103A),
+(_ucs2 0x10211031102C10181039),
+(_ucs2 0x102910181039),
+(_ucs2 0x10211031102C1018103A),
+(_ucs2 0x10291018103A),
+(_ucs2 0x10211031102C10181039),
+(_ucs2 0x10291031102C10181039),
+(_ucs2 0x10211031102C1018103A),
+(_ucs2 0x10291031102C1018103A),
+(_ucs2 0x1021102D10191039),
+(_ucs2 0x102310191039),
+(_ucs2 0x1021102D1019103A),
+(_ucs2 0x10231019103A),
+(_ucs2 0x1021102F10191039),
+(_ucs2 0x102510191039),
+(_ucs2 0x1021102F1019103A),
+(_ucs2 0x10251019103A),
+(_ucs2 0x1021103110191039),
+(_ucs2 0x102710191039),
+(_ucs2 0x102110311019103A),
+(_ucs2 0x10271019103A),
+(_ucs2 0x10211031102C10191039),
+(_ucs2 0x102910191039),
+(_ucs2 0x10211031102C1019103A),
+(_ucs2 0x10291019103A),
+(_ucs2 0x10211031102C10191039),
+(_ucs2 0x10291031102C10191039),
+(_ucs2 0x10211031102C1019103A),
+(_ucs2 0x10291031102C1019103A),
+(_ucs2 0x1021102D101A1039),
+(_ucs2 0x1023101A1039),
+(_ucs2 0x1021102D101A103A),
+(_ucs2 0x1023101A103A),
+(_ucs2 0x1021102F101A1039),
+(_ucs2 0x1025101A1039),
+(_ucs2 0x1021102F101A103A),
+(_ucs2 0x1025101A103A),
+(_ucs2 0x10211031101A1039),
+(_ucs2 0x1027101A1039),
+(_ucs2 0x10211031101A103A),
+(_ucs2 0x1027101A103A),
+(_ucs2 0x10211031102C101A1039),
+(_ucs2 0x1029101A1039),
+(_ucs2 0x10211031102C101A103A),
+(_ucs2 0x1029101A103A),
+(_ucs2 0x10211031102C101A1039),
+(_ucs2 0x10291031102C101A1039),
+(_ucs2 0x10211031102C101A103A),
+(_ucs2 0x10291031102C101A103A),
+(_ucs2 0x1021102D101B1039),
+(_ucs2 0x1023101B1039),
+(_ucs2 0x1021102D101B103A),
+(_ucs2 0x1023101B103A),
+(_ucs2 0x1021102F101B1039),
+(_ucs2 0x1025101B1039),
+(_ucs2 0x1021102F101B103A),
+(_ucs2 0x1025101B103A),
+(_ucs2 0x10211031101B1039),
+(_ucs2 0x1027101B1039),
+(_ucs2 0x10211031101B103A),
+(_ucs2 0x1027101B103A),
+(_ucs2 0x10211031102C101B1039),
+(_ucs2 0x1029101B1039),
+(_ucs2 0x10211031102C101B103A),
+(_ucs2 0x1029101B103A),
+(_ucs2 0x10211031102C101B1039),
+(_ucs2 0x10291031102C101B1039),
+(_ucs2 0x10211031102C101B103A),
+(_ucs2 0x10291031102C101B103A),
+(_ucs2 0x1021102D101C1039),
+(_ucs2 0x1023101C1039),
+(_ucs2 0x1021102D101C103A),
+(_ucs2 0x1023101C103A),
+(_ucs2 0x1021102F101C1039),
+(_ucs2 0x1025101C1039),
+(_ucs2 0x1021102F101C103A),
+(_ucs2 0x1025101C103A),
+(_ucs2 0x10211031101C1039),
+(_ucs2 0x1027101C1039),
+(_ucs2 0x10211031101C103A),
+(_ucs2 0x1027101C103A),
+(_ucs2 0x10211031102C101C1039),
+(_ucs2 0x1029101C1039),
+(_ucs2 0x10211031102C101C103A),
+(_ucs2 0x1029101C103A),
+(_ucs2 0x10211031102C101C1039),
+(_ucs2 0x10291031102C101C1039),
+(_ucs2 0x10211031102C101C103A),
+(_ucs2 0x10291031102C101C103A),
+(_ucs2 0x1021102D101E1039),
+(_ucs2 0x1023101E1039),
+(_ucs2 0x1021102D101E103A),
+(_ucs2 0x1023101E103A),
+(_ucs2 0x1021102F101E1039),
+(_ucs2 0x1025101E1039),
+(_ucs2 0x1021102F101E103A),
+(_ucs2 0x1025101E103A),
+(_ucs2 0x10211031101E1039),
+(_ucs2 0x1027101E1039),
+(_ucs2 0x10211031101E103A),
+(_ucs2 0x1027101E103A),
+(_ucs2 0x10211031102C101E1039),
+(_ucs2 0x1029101E1039),
+(_ucs2 0x10211031102C101E103A),
+(_ucs2 0x1029101E103A),
+(_ucs2 0x10211031102C101E1039),
+(_ucs2 0x10291031102C101E1039),
+(_ucs2 0x10211031102C101E103A),
+(_ucs2 0x10291031102C101E103A),
+(_ucs2 0x1021102D101F1039),
+(_ucs2 0x1023101F1039),
+(_ucs2 0x1021102D101F103A),
+(_ucs2 0x1023101F103A),
+(_ucs2 0x1021102F101F1039),
+(_ucs2 0x1025101F1039),
+(_ucs2 0x1021102F101F103A),
+(_ucs2 0x1025101F103A),
+(_ucs2 0x10211031101F1039),
+(_ucs2 0x1027101F1039),
+(_ucs2 0x10211031101F103A),
+(_ucs2 0x1027101F103A),
+(_ucs2 0x10211031102C101F1039),
+(_ucs2 0x1029101F1039),
+(_ucs2 0x10211031102C101F103A),
+(_ucs2 0x1029101F103A),
+(_ucs2 0x10211031102C101F1039),
+(_ucs2 0x10291031102C101F1039),
+(_ucs2 0x10211031102C101F103A),
+(_ucs2 0x10291031102C101F103A),
+('--- Contractions'),
+(_ucs2 0x1031102C1000103A1000103B),
+(_ucs2 0x1031102C1000103A103B /* (suffix of) man */),
+(_ucs2 0x1014103A1014102F1015103A),
+(_ucs2 0x1014103A102F1015103A /* (suffix of) I */),
+('--- Great Sa'),
+(_ucs2 0x1031101E1039101E),
+(_ucs2 0x1031103F),
+(_ucs2 0x102D101E1039101E),
+(_ucs2 0x102D103F),
+(_ucs2 0x102F101E1039101E),
+(_ucs2 0x102F103F),
+(_ucs2 0x1021102D101E1039101E),
+(_ucs2 0x1023103F),
+(_ucs2 0x1021102F101E1039101E),
+(_ucs2 0x1025103F),
+(_ucs2 0x101E1039101E),
+(_ucs2 0x103F),
+('--- Symbols - collate as long form'),
+(_ucs2 0x1014103E102D102F1000103A),
+(_ucs2 0x104C),
+(_ucs2 0x101B103D10311037),
+(_ucs2 0x104D),
+(_ucs2 0x101C100A103A103810001031102C1004103A1038),
+(_ucs2 0x104E1004103A1038),
+(_ucs2 0x1021102D),
+(_ucs2 0x104F),
+('--- Short Forms may need to be added here'),
+(_ucs2 0x101C1000103A101A102C),
+(_ucs2 0x101C1000103A103B102C /* right hand side */),
+(_ucs2 0x101E1019102E),
+(_ucs2 0x101E10391019102E /* daughter */),
+(_ucs2 0x101110191004103A1038),
+(_ucs2 0x1011103910191004103A1038 /* cooked rice */),
+(_ucs2 0x101C1000103A10181000103A),
+(_ucs2 0x101C103910181000103A /* tea */);
+
+SELECT id, IF(LEFT(s1,1)='-',s1,CONCAT(HEX(WEIGHT_STRING(s1)),'\t', HEX(CONVERT(s1 USING ucs2)))) FROM t1 ORDER BY id;
+
+DROP TABLE t1;
+
+--echo #
+--echo # END of ctype_myanmar.inc
+--echo #
diff --git a/mysql-test/include/ctype_pad_space.inc b/mysql-test/include/ctype_pad_space.inc
new file mode 100644
index 00000000000..667f97de710
--- /dev/null
+++ b/mysql-test/include/ctype_pad_space.inc
@@ -0,0 +1,5 @@
+SELECT strcmp('a','a ');
+SELECT strcmp('a\0','a' );
+SELECT strcmp('a\0','a ');
+SELECT strcmp('a\t','a' );
+SELECT strcmp('a\t','a ');
diff --git a/mysql-test/include/ctype_regex_utf8.inc b/mysql-test/include/ctype_regex_utf8.inc
new file mode 100644
index 00000000000..d389cb214f7
--- /dev/null
+++ b/mysql-test/include/ctype_regex_utf8.inc
@@ -0,0 +1,24 @@
+#
+# Bug #3928 regexp [[:>:]] and UTF-8
+#
+SELECT @@character_set_client, @@collation_connection;
+
+# This should return TRUE
+select 'ваÑÑ' rlike '\\bваÑÑ\\b';
+select 'ваÑÑ ' rlike '\\bваÑÑ\\b';
+select ' ваÑÑ' rlike '\\bваÑÑ\\b';
+select ' ваÑÑ ' rlike '\\bваÑÑ\\b';
+
+select 'ваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]';
+select 'ваÑÑ ' rlike '[[:<:]]ваÑÑ[[:>:]]';
+select ' ваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]';
+select ' ваÑÑ ' rlike '[[:<:]]ваÑÑ[[:>:]]';
+
+# This should return FALSE
+select 'ваÑÑz' rlike '\\bваÑÑ\\b';
+select 'zваÑÑ' rlike '\\bваÑÑ\\b';
+select 'zваÑÑz' rlike '\\bваÑÑ\\b';
+
+select 'ваÑÑz' rlike '[[:<:]]ваÑÑ[[:>:]]';
+select 'zваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]';
+select 'zваÑÑz' rlike '[[:<:]]ваÑÑ[[:>:]]';
diff --git a/mysql-test/include/ctype_strtoll10.inc b/mysql-test/include/ctype_strtoll10.inc
new file mode 100644
index 00000000000..8bb2d29f86a
--- /dev/null
+++ b/mysql-test/include/ctype_strtoll10.inc
@@ -0,0 +1,49 @@
+--echo #
+--echo # Testing cs->cset->strtoll10()
+--echo #
+
+SELECT @@character_set_connection;
+
+SELECT CAST('1' AS UNSIGNED);
+SELECT CAST('12' AS UNSIGNED);
+SELECT CAST('123' AS UNSIGNED);
+SELECT CAST('1234' AS UNSIGNED);
+SELECT CAST('12345' AS UNSIGNED);
+SELECT CAST('123456' AS UNSIGNED);
+SELECT CAST('1234567' AS UNSIGNED);
+SELECT CAST('12345678' AS UNSIGNED);
+SELECT CAST('123456789' AS UNSIGNED);
+SELECT CAST('1234567891' AS UNSIGNED);
+SELECT CAST('12345678912' AS UNSIGNED);
+SELECT CAST('123456789123' AS UNSIGNED);
+SELECT CAST('1234567891234' AS UNSIGNED);
+SELECT CAST('12345678912345' AS UNSIGNED);
+SELECT CAST('123456789123456' AS UNSIGNED);
+SELECT CAST('1234567891234567' AS UNSIGNED);
+SELECT CAST('12345678912345678' AS UNSIGNED);
+SELECT CAST('123456789123456789' AS UNSIGNED);
+SELECT CAST('1234567891234567891' AS UNSIGNED);
+SELECT CAST('12345678912345678912' AS UNSIGNED);
+SELECT CAST('123456789123456789123' AS UNSIGNED);
+
+SELECT CAST('1x' AS UNSIGNED);
+SELECT CAST('12x' AS UNSIGNED);
+SELECT CAST('123x' AS UNSIGNED);
+SELECT CAST('1234x' AS UNSIGNED);
+SELECT CAST('12345x' AS UNSIGNED);
+SELECT CAST('123456x' AS UNSIGNED);
+SELECT CAST('1234567x' AS UNSIGNED);
+SELECT CAST('12345678x' AS UNSIGNED);
+SELECT CAST('123456789x' AS UNSIGNED);
+SELECT CAST('1234567891x' AS UNSIGNED);
+SELECT CAST('12345678912x' AS UNSIGNED);
+SELECT CAST('123456789123x' AS UNSIGNED);
+SELECT CAST('1234567891234x' AS UNSIGNED);
+SELECT CAST('12345678912345x' AS UNSIGNED);
+SELECT CAST('123456789123456x' AS UNSIGNED);
+SELECT CAST('1234567891234567x' AS UNSIGNED);
+SELECT CAST('12345678912345678x' AS UNSIGNED);
+SELECT CAST('123456789123456789x' AS UNSIGNED);
+SELECT CAST('1234567891234567891x' AS UNSIGNED);
+SELECT CAST('12345678912345678912x' AS UNSIGNED);
+SELECT CAST('123456789123456789123x' AS UNSIGNED);
diff --git a/mysql-test/include/ctype_unescape.inc b/mysql-test/include/ctype_unescape.inc
new file mode 100644
index 00000000000..5d67bf8d189
--- /dev/null
+++ b/mysql-test/include/ctype_unescape.inc
@@ -0,0 +1,327 @@
+--echo # Start of ctype_unescape.inc
+
+#
+# Testing how string literals with backslash and quote-quote are unescaped.
+# The tests assume that single quote (') is used as a delimiter.
+#
+
+#
+# Make sure that the parser really works using the character set we need.
+# We use binary strings to compose strings, to be able to test get malformed
+# sequences, which are possible as a result of mysql_real_escape_string().
+# The important thing for this test is to make the parser unescape using
+# the client character set, rather than binary. Currently it works exactly
+# that way by default, so the query below should return @@character_set_client
+#
+SET @query=_binary'SELECT CHARSET(\'test\'),@@character_set_client,@@character_set_connection';
+PREPARE stmt FROM @query;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+
+let $CHARSET=`SELECT @@character_set_connection`;
+
+CREATE TABLE allbytes (a VARBINARY(10));
+
+#
+# Create various byte sequences to test. Testing the full banch of
+# possible combinations takes about 2 minutes. So this test provides
+# variants to run with:
+# - the full set of possible combinations
+# - a reduced test of combinations for selected bytes only
+#
+
+# Create selected byte combinations
+if ($ctype_unescape_combinations == 'selected')
+{
+--echo # Using selected bytes combinations
+--source include/bytes.inc
+#
+# Populate "selected_bytes" with bytes that have a special meaning.
+# We'll use "selected_bytes" to generate byte seqeunces,
+# instead of the full possible byte combinations, to reduce test time.
+#
+CREATE TABLE selected_bytes (a VARBINARY(10));
+
+# Bytes that have a special meaning in all character sets:
+# 0x00 - mysql_real_escape_string() quotes this to '\0'
+# 0x0D - mysql_real_escape_string() quotes this to '\r'
+# 0x0A - mysql_real_escape_string() quotes this to '\n'
+# 0x1A - mysql_real_escape_string() quotes this to '\Z'
+# 0x08 - mysql_real_escape_string() does not quote this,
+# but '\b' is unescaped to 0x08.
+# 0x09 - mysql_real_escape_string() does not quote this,
+# but '\t' is unescaped to 0x09.
+# 0x30 - '0', as in '\0'
+# 0x5A - 'Z', as in '\Z'
+# 0x62 - 'b', as in '\b'
+# 0x6E - 'n', as in '\n'
+# 0x72 - 't', as in '\r'
+# 0x74 - 't', as in '\t'
+
+INSERT INTO selected_bytes (a) VALUES ('\0'),('\b'),('\t'),('\r'),('\n'),('\Z');
+INSERT INTO selected_bytes (a) VALUES ('0'),('b'),('t'),('r'),('n'),('Z');
+
+# 0x22 - double quote
+# 0x25 - percent sign, '\%' is preserved as is for LIKE.
+# 0x27 - single quote
+# 0x5C - backslash
+# 0x5F - underscore, '\_' is preserved as is for LIKE.
+INSERT INTO selected_bytes (a) VALUES ('\\'),('_'),('%'),(0x22),(0x27);
+
+# Some bytes do not have any special meaning, for example basic Latin letters.
+# Let's add, one should be enough for a good enough coverage.
+INSERT INTO selected_bytes (a) VALUES ('a');
+
+#
+# This maps summarizes bytes that have a special
+# meaning in various character sets:
+#
+# MBHEAD MBTAIL NONASCII-8BIT BAD
+# ------ ------ -------------- ----------
+# big5: [A1..F9] [40..7E,A1..FE] N/A [80..A0,FA..FF]
+# cp932: [81..9F,E0..FC] [40..7E,80..FC] [A1..DF] [FD..FF]
+# gbk: [81..FE] [40..7E,80..FE] N/A [FF]
+# sjis: [81..9F,E0..FC] [40..7E,80..FC] [A1..DF] [FD..FF]
+# swe7: N/A N/A [5B..5E,7B..7E] [80..FF]
+#
+
+INSERT INTO selected_bytes (a) VALUES
+(0x3F), # 7bit
+(0x40), # 7bit mbtail
+(0x7E), # 7bit mbtail nonascii-8bit
+(0x7F), # 7bit nonascii-8bit
+(0x80), # mbtail bad-mb
+(0x81), # mbhead mbtail
+(0x9F), # mbhead mbtail bad-mb
+(0xA0), # mbhead mbtail bad-mb
+(0xA1), # mbhead mbtail nonascii-8bit
+(0xE0), # mbhead mbtai
+(0xEF), # mbhead mbtail
+(0xF9), # mbhead mbtail
+(0xFA), # mbhead mbtail bad-mb
+(0xFC), # mbhead mbtail bad-mb
+(0xFD), # mbhead mbtail bad-mb
+(0xFE), # mbhead mbtial bad-mb
+(0xFF); # bad-mb
+
+#
+# Now populate the test table
+#
+
+# Use all single bytes, this is cheap, there are only 256 values.
+INSERT INTO allbytes (a) SELECT a FROM bytes;
+
+# Add selected bytes combinations
+INSERT INTO allbytes (a) SELECT CONCAT(t1.a,t2.a) FROM selected_bytes t1,selected_bytes t2;
+INSERT INTO allbytes (a) SELECT CONCAT(0x5C,t1.a,t2.a) FROM selected_bytes t1,selected_bytes t2;
+INSERT INTO allbytes (a) SELECT CONCAT(0x5C,t1.a,0x5C,t2.a) FROM selected_bytes t1,selected_bytes t2;
+DROP TABLE selected_bytes;
+
+# Delete all non-single byte sequences that do not have
+# backslashes or quotes at all. There is nothing special with these strings.
+DELETE FROM allbytes WHERE
+ OCTET_LENGTH(a)>1 AND
+ LOCATE(0x5C,a)=0 AND
+ a NOT LIKE '%\'%' AND
+ a NOT LIKE '%"%';
+
+}
+
+if ($ctype_unescape_combinations=='')
+{
+--echo # Using full byte combinations
+--source include/bytes2.inc
+INSERT INTO allbytes (a) SELECT a FROM bytes;
+INSERT INTO allbytes (a) SELECT CONCAT(hi,lo) FROM bytes2;
+INSERT INTO allbytes (a) SELECT CONCAT(0x5C,hi,lo) FROM bytes2;
+INSERT INTO allbytes (a) SELECT CONCAT(0x5C,hi,0x5C,lo) FROM bytes2;
+}
+
+
+DELIMITER //;
+
+#
+# A procedure that make an SQL query using 'val' as a string literal.
+# The result of the query execution is written into the table 't1'.
+# NULL in t1.b means that query failed due to syntax error,
+# typically because of mis-interpreted closing quote delimiter.
+#
+CREATE PROCEDURE p1(val VARBINARY(10))
+BEGIN
+ DECLARE EXIT HANDLER FOR SQLSTATE '42000' INSERT INTO t1 (a,b) VALUES(val,NULL);
+ SET @query=CONCAT(_binary"INSERT INTO t1 (a,b) VALUES (0x",HEX(val),",'",val,"')");
+ PREPARE stmt FROM @query;
+ EXECUTE stmt;
+ DEALLOCATE PREPARE stmt;
+END//
+
+#
+# A procedure that iterates through all records in "allbytes".
+# And runs p1() for every record.
+#
+CREATE PROCEDURE p2()
+BEGIN
+ DECLARE val VARBINARY(10);
+ DECLARE done INT DEFAULT FALSE;
+ DECLARE stmt CURSOR FOR SELECT a FROM allbytes;
+ DECLARE CONTINUE HANDLER FOR NOT FOUND SET done=TRUE;
+ OPEN stmt;
+read_loop1: LOOP
+ FETCH stmt INTO val;
+ IF done THEN
+ LEAVE read_loop1;
+ END IF;
+ CALL p1(val);
+END LOOP;
+ CLOSE stmt;
+END//
+
+
+# A function that converts the value from binary to $CHARSET
+# and check if it has changed. CONVERT() fixes malformed strings.
+# So if the string changes in CONVERT(), it means it was not wellformed.
+--eval CREATE FUNCTION iswellformed(a VARBINARY(256)) RETURNS INT RETURN a=BINARY CONVERT(a USING $CHARSET);
+
+#
+# A function that approximately reproduces how the SQL parser
+# would unescape a binary string.
+#
+CREATE FUNCTION unescape(a VARBINARY(256)) RETURNS VARBINARY(256)
+BEGIN
+ # We need to do it in a way to avoid producing new escape sequences
+ # First, enclose all known escsape sequences to '{{xx}}'
+ # - Backslash not followed by a LIKE pattern characters _ and %
+ # - Double escapes
+ # This uses PCRE Branch Reset Groups: (?|(alt1)|(alt2)|(alt3)).
+ # So '\\1' in the last argument always means the match, no matter
+ # which alternative it came from.
+ SET a=REGEXP_REPLACE(a,'(?|(\\\\[^_%])|(\\x{27}\\x{27}))','{{\\1}}');
+ # Now unescape all enclosed standard escape sequences
+ SET a=REPLACE(a,'{{\\0}}', '\0');
+ SET a=REPLACE(a,'{{\\b}}', '\b');
+ SET a=REPLACE(a,'{{\\t}}', '\t');
+ SET a=REPLACE(a,'{{\\r}}', '\r');
+ SET a=REPLACE(a,'{{\\n}}', '\n');
+ SET a=REPLACE(a,'{{\\Z}}', '\Z');
+ SET a=REPLACE(a,'{{\\\'}}', '\'');
+ # Unescape double quotes
+ SET a=REPLACE(a,'{{\'\'}}', '\'');
+ # Unescape the rest: all other \x sequences mean just 'x'
+ SET a=REGEXP_REPLACE(a, '{{\\\\(.|\\R)}}', '\\1');
+ RETURN a;
+END//
+
+
+#
+# A function that checks what happened during unescaping.
+#
+# @param a - the value before unescaping
+# @param b - the value after unescaping
+#
+# The following return values are possible:
+# - SyntErr - b IS NULL, which means syntax error happened in p1().
+# - Preserv - the value was not modified during unescaping.
+# This is possible if 0x5C was treated as mbtail.
+# Or only LIKE escape sequences were found: '\_' and '\%'.
+# - Trivial - only 0x5C were removed.
+# - Regular - the value was unescaped like a binary string.
+# Some standard escape sequences were found.
+# No special multi-byte handling happened.
+# - Special - Something else happened. Should not happen.
+#
+CREATE FUNCTION unescape_type(a VARBINARY(256),b VARBINARY(256)) RETURNS VARBINARY(256)
+BEGIN
+ RETURN CASE
+ WHEN b IS NULL THEN '[SyntErr]'
+ WHEN a=b THEN CASE
+ WHEN OCTET_LENGTH(a)=1 THEN '[Preserve]'
+ WHEN a RLIKE '\\\\[_%]' THEN '[Preserve][LIKE]'
+ WHEN a RLIKE '^[[:ascii:]]+$' THEN '[Preserve][ASCII]'
+ ELSE '[Preserv][MB]' END
+ WHEN REPLACE(a,0x5C,'')=b THEN '[Trivial]'
+ WHEN UNESCAPE(a)=b THEN '[Regular]'
+ ELSE '[Special]' END;
+END//
+
+
+#
+# Check what happened with wellformedness during unescaping
+# @param a - the value before unescaping
+# @param b - the value after unescaping
+#
+# Returned values:
+# [FIXED] - the value was malformed and become wellformed after unescaping
+# [BROKE] - the value was wellformed and become malformed after unescaping
+# [ILSEQ] - both values (before unescaping and after unescaping) are malformed
+# '' - both values are wellformed
+#
+CREATE FUNCTION wellformedness(a VARBINARY(256), b VARBINARY(256))
+ RETURNS VARBINARY(256)
+BEGIN
+ RETURN CASE
+ WHEN b IS NULL THEN ''
+ WHEN NOT iswellformed(a) AND iswellformed(b) THEN '[FIXED]'
+ WHEN iswellformed(a) AND NOT iswellformed(b) THEN '[BROKE]'
+ WHEN NOT iswellformed(a) AND NOT iswellformed(b) THEN '[ILSEQ]'
+ ELSE ''
+ END;
+END//
+
+
+#
+# Check if the value could be generated by mysql_real_escape_string(),
+# or can only come from a direct user input.
+#
+# @param a - the value before unescaping
+#
+# Returns:
+# [USER] - if the value could not be generated by mysql_real_escape_string()
+# '' - if the value was possibly generated by mysql_real_escape_string()
+#
+#
+CREATE FUNCTION mysql_real_escape_string_generated(a VARBINARY(256))
+ RETURNS VARBINARY(256)
+BEGIN
+ DECLARE a1 BINARY(1) DEFAULT SUBSTR(a,1,1);
+ DECLARE a2 BINARY(1) DEFAULT SUBSTR(a,2,1);
+ DECLARE a3 BINARY(1) DEFAULT SUBSTR(a,3,1);
+ DECLARE a4 BINARY(1) DEFAULT SUBSTR(a,4,1);
+ DECLARE a2a4 BINARY(2) DEFAULT CONCAT(a2,a4);
+ RETURN CASE
+ WHEN (a1=0x5C) AND
+ (a3=0x5C) AND
+ (a2>0x7F) AND
+ (a4 NOT IN ('_','%','0','t','r','n','Z')) AND
+ iswellformed(a2a4) THEN '[USER]'
+ ELSE ''
+ END;
+END//
+
+DELIMITER ;//
+
+
+CREATE TABLE t1 (a VARBINARY(10),b VARBINARY(10));
+CALL p2();
+# Avoid "Invalid XXX character string" warnings
+# We mark malformed strings in the output anyway
+--disable_warnings
+# All records marked with '[BAD]' mean that the string was unescaped
+# in a unexpected way, that means there is a bug in UNESCAPE() above.
+SELECT HEX(a),HEX(b),
+ CONCAT(unescape_type(a,b),
+ wellformedness(a,b),
+ mysql_real_escape_string_generated(a),
+ IF(UNESCAPE(a)<>b,CONCAT('[BAD',HEX(UNESCAPE(a)),']'),'')) AS comment
+FROM t1 ORDER BY LENGTH(a),a;
+--enable_warnings
+DROP TABLE t1;
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP FUNCTION unescape;
+DROP FUNCTION unescape_type;
+DROP FUNCTION wellformedness;
+DROP FUNCTION mysql_real_escape_string_generated;
+DROP FUNCTION iswellformed;
+DROP TABLE allbytes;
+
+--echo # End of ctype_backslash.inc
diff --git a/mysql-test/include/ctype_unicode520.inc b/mysql-test/include/ctype_unicode520.inc
new file mode 100644
index 00000000000..46c8c7d8ec9
--- /dev/null
+++ b/mysql-test/include/ctype_unicode520.inc
@@ -0,0 +1,166 @@
+#
+# WL#2673 Unicode collation algorithm new version
+#
+CREATE TABLE t1 AS SELECT repeat('a', 10) as c LIMIT 0;
+SHOW CREATE TABLE t1;
+
+#
+# Unicode-5.0.0 characters
+#
+
+# Latin Extended-B and IP extensions
+INSERT INTO t1 VALUES (_utf32 0x0180),(_utf32 0x023A);
+INSERT INTO t1 VALUES (_utf32 0x023B),(_utf32 0x023C);
+INSERT INTO t1 VALUES (_utf32 0x023D),(_utf32 0x023E);
+INSERT INTO t1 VALUES (_utf32 0x0241),(_utf32 0x0242);
+INSERT INTO t1 VALUES (_utf32 0x0243),(_utf32 0x0244);
+INSERT INTO t1 VALUES (_utf32 0x0245),(_utf32 0x0246);
+INSERT INTO t1 VALUES (_utf32 0x0247),(_utf32 0x0248);
+INSERT INTO t1 VALUES (_utf32 0x0249),(_utf32 0x024A);
+INSERT INTO t1 VALUES (_utf32 0x024B),(_utf32 0x024C);
+INSERT INTO t1 VALUES (_utf32 0x024D),(_utf32 0x024E);
+INSERT INTO t1 VALUES (_utf32 0x024F),(_utf32 0x026B);
+INSERT INTO t1 VALUES (_utf32 0x027D),(_utf32 0x0289);
+INSERT INTO t1 VALUES (_utf32 0x028C);
+
+# Greek and Coptic
+INSERT INTO t1 VALUES (_utf32 0x037B), (_utf32 0x037C);
+INSERT INTO t1 VALUES (_utf32 0x037D), (_utf32 0x03FD);
+INSERT INTO t1 VALUES (_utf32 0x03FE), (_utf32 0x03FF);
+
+# Cyrillic
+INSERT INTO t1 VALUES (_utf32 0x04C0), (_utf32 0x04CF);
+INSERT INTO t1 VALUES (_utf32 0x04F6), (_utf32 0x04F7);
+INSERT INTO t1 VALUES (_utf32 0x04FA), (_utf32 0x04FB);
+INSERT INTO t1 VALUES (_utf32 0x04FC), (_utf32 0x04FD);
+INSERT INTO t1 VALUES (_utf32 0x04FE), (_utf32 0x04FF);
+INSERT INTO t1 VALUES (_utf32 0x0510), (_utf32 0x0511);
+INSERT INTO t1 VALUES (_utf32 0x0512), (_utf32 0x0513);
+
+# Georgian, Georgian Supplement
+INSERT INTO t1 VALUES (_utf32 0x10A0), (_utf32 0x10A1);
+INSERT INTO t1 VALUES (_utf32 0x10A2), (_utf32 0x10A3);
+INSERT INTO t1 VALUES (_utf32 0x10A4), (_utf32 0x10A5);
+INSERT INTO t1 VALUES (_utf32 0x10A6), (_utf32 0x10A7);
+INSERT INTO t1 VALUES (_utf32 0x2D00), (_utf32 0x2D01);
+INSERT INTO t1 VALUES (_utf32 0x2D02), (_utf32 0x2D03);
+INSERT INTO t1 VALUES (_utf32 0x2D04), (_utf32 0x2D05);
+INSERT INTO t1 VALUES (_utf32 0x2D06), (_utf32 0x2D07);
+
+# Phonetic Extensions
+INSERT INTO t1 VALUES (_utf32 0x1D7D);
+
+# Letterlike Symbols
+INSERT INTO t1 VALUES (_utf32 0x2132),(_utf32 0x214E);
+
+# Number Forms
+INSERT INTO t1 VALUES (_utf32 0x2183),(_utf32 0x2184);
+
+# Coptic
+INSERT INTO t1 VALUES (_utf32 0x2C80), (_utf32 0x2C81);
+INSERT INTO t1 VALUES (_utf32 0x2C82), (_utf32 0x2C83);
+INSERT INTO t1 VALUES (_utf32 0x2C84), (_utf32 0x2C85);
+INSERT INTO t1 VALUES (_utf32 0x2C86), (_utf32 0x2C87);
+INSERT INTO t1 VALUES (_utf32 0x2C88), (_utf32 0x2C89);
+INSERT INTO t1 VALUES (_utf32 0x2C8A), (_utf32 0x2C8B);
+INSERT INTO t1 VALUES (_utf32 0x2C8C), (_utf32 0x2C8D);
+INSERT INTO t1 VALUES (_utf32 0x2C8E), (_utf32 0x2C8F);
+
+# Latin Extended-C
+INSERT INTO t1 VALUES (_utf32 0x2C60), (_utf32 0x2C61);
+INSERT INTO t1 VALUES (_utf32 0x2C62), (_utf32 0x2C63);
+INSERT INTO t1 VALUES (_utf32 0x2C64), (_utf32 0x2C65);
+INSERT INTO t1 VALUES (_utf32 0x2C66), (_utf32 0x2C67);
+INSERT INTO t1 VALUES (_utf32 0x2C68), (_utf32 0x2C69);
+INSERT INTO t1 VALUES (_utf32 0x2C6A), (_utf32 0x2C6B);
+INSERT INTO t1 VALUES (_utf32 0x2C6C), (_utf32 0x2C75);
+INSERT INTO t1 VALUES (_utf32 0x2C76);
+
+# Glagolitic
+INSERT INTO t1 VALUES (_utf32 0x2C00), (_utf32 0x2C01);
+INSERT INTO t1 VALUES (_utf32 0x2C02), (_utf32 0x2C03);
+INSERT INTO t1 VALUES (_utf32 0x2C04), (_utf32 0x2C05);
+INSERT INTO t1 VALUES (_utf32 0x2C06), (_utf32 0x2C07);
+INSERT INTO t1 VALUES (_utf32 0x2C30), (_utf32 0x2C31);
+INSERT INTO t1 VALUES (_utf32 0x2C32), (_utf32 0x2C33);
+INSERT INTO t1 VALUES (_utf32 0x2C34), (_utf32 0x2C35);
+INSERT INTO t1 VALUES (_utf32 0x2C36), (_utf32 0x2C37);
+
+# Deseret
+INSERT INTO t1 VALUES (_utf32 0x10400), (_utf32 0x10401);
+INSERT INTO t1 VALUES (_utf32 0x10402), (_utf32 0x10403);
+INSERT INTO t1 VALUES (_utf32 0x10404), (_utf32 0x10405);
+INSERT INTO t1 VALUES (_utf32 0x10406), (_utf32 0x10407);
+INSERT INTO t1 VALUES (_utf32 0x10428), (_utf32 0x10429);
+INSERT INTO t1 VALUES (_utf32 0x1042A), (_utf32 0x1042B);
+INSERT INTO t1 VALUES (_utf32 0x1042C), (_utf32 0x1042D);
+INSERT INTO t1 VALUES (_utf32 0x1042E), (_utf32 0x1042F);
+
+
+#
+# Unicode 5.1.0 characters
+#
+
+INSERT INTO t1 VALUES (_utf32 0x0370); # GREEK CAPITAL LETTER HETA
+INSERT INTO t1 VALUES (_utf32 0x0371); # GREEK SMALL LETTER HETA
+INSERT INTO t1 VALUES (_utf32 0x0372); # GREEK CAPITAL LETTER ARCHAIC SAMPI
+INSERT INTO t1 VALUES (_utf32 0x0373); # GREEK SMALL LETTER ARCHAIC SAMPI
+
+INSERT INTO t1 VALUES (_utf32 0x0514); # CYRILLIC CAPITAL LETTER LHA
+INSERT INTO t1 VALUES (_utf32 0x0515); # CYRILLIC SMALL LETTER LHA
+INSERT INTO t1 VALUES (_utf32 0x0516); # CYRILLIC CAPITAL LETTER RHA
+INSERT INTO t1 VALUES (_utf32 0x0517); # CYRILLIC SMALL LETTER RHA
+
+INSERT INTO t1 VALUES (_utf32 0xA640); # CYRILLIC CAPITAL LETTER ZEMLYA
+INSERT INTO t1 VALUES (_utf32 0xA641); # CYRILLIC SMALL LETTER ZEMLYA
+INSERT INTO t1 VALUES (_utf32 0xA642); # CYRILLIC CAPITAL LETTER DZELO
+INSERT INTO t1 VALUES (_utf32 0xA643); # CYRILLIC SMALL LETTER DZELO
+
+INSERT INTO t1 VALUES (_utf32 0xA722); # LATIN CAPITAL LETTER EGYPTOLOGICAL ALEF
+INSERT INTO t1 VALUES (_utf32 0xA723); # LATIN SMALL LETTER EGYPTOLOGICAL ALEF
+INSERT INTO t1 VALUES (_utf32 0xA724); # LATIN CAPITAL LETTER EGYPTOLOGICAL AIN
+INSERT INTO t1 VALUES (_utf32 0xA725); # LATIN SMALL LETTER EGYPTOLOGICAL AIN
+
+INSERT INTO t1 VALUES (_utf32 0xA726); # LATIN CAPITAL LETTER HENG
+INSERT INTO t1 VALUES (_utf32 0xA727); # LATIN SMALL LETTER HENG
+INSERT INTO t1 VALUES (_utf32 0xA728); # LATIN CAPITAL LETTER TZ
+INSERT INTO t1 VALUES (_utf32 0xA729); # LATIN SMALL LETTER TZ
+INSERT INTO t1 VALUES (_utf32 0xA72A); # LATIN CAPITAL LETTER TRESILLO
+INSERT INTO t1 VALUES (_utf32 0xA72B); # LATIN SMALL LETTER TRESILLO
+
+#
+# Unicode 5.2.0 characters
+#
+
+INSERT INTO t1 VALUES (_utf32 0x2CEB); # COPTIC CAPITAL LETTER CRYPTOGRAMMIC SHEI;Lu;0;L;;;;;N;;;;2CEC;
+INSERT INTO t1 VALUES (_utf32 0x2CEC); # COPTIC SMALL LETTER CRYPTOGRAMMIC SHEI;Ll;0;L;;;;;N;;;2CEB;;2CEB
+INSERT INTO t1 VALUES (_utf32 0x2CED); # COPTIC CAPITAL LETTER CRYPTOGRAMMIC GANGIA;Lu;0;L;;;;;N;;;;2CEE;
+INSERT INTO t1 VALUES (_utf32 0x2CEE); # COPTIC SMALL LETTER CRYPTOGRAMMIC GANGIA;Ll;0;L;;;;;N;;;2CED;;2CED
+
+#
+# Check case folding and UCA weights
+#
+SELECT hex(c), hex(lower(c)), hex(upper(c)), hex(weight_string(c)), c
+FROM t1 ORDER BY c, BINARY c;
+
+
+#
+# Check that LIKE works fine with and without index.
+# This test makes sure that cs->min_sort_char and cs->max_sort_char
+# are set properly
+# Also check that LIKE is case insensitive for supplementary characters
+#
+INSERT INTO t1 VALUES ('a');
+INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0xFFFF));
+INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10FFFF));
+INSERT INTO t1 VALUES (concat(_utf32 0x61, _utf32 0x10400));
+SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c;
+SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c;
+SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c;
+ALTER TABLE t1 ADD KEY(c);
+EXPLAIN SELECT hex(c) FROM t1 WHERE c LIKE 'a%' ORDER BY c;
+SELECT hex(c), hex(weight_string(c)) FROM t1 WHERE c LIKE 'a%' ORDER BY c;
+SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10400 ORDER BY c, BINARY c;
+SELECT hex(c), hex(weight_string(c)), c FROM t1 WHERE c LIKE _utf32 0x10428 ORDER BY c, BINARY c;
+
+DROP TABLE t1;
diff --git a/mysql-test/include/ctype_unicode_latin.inc b/mysql-test/include/ctype_unicode_latin.inc
new file mode 100644
index 00000000000..b4344a3b06f
--- /dev/null
+++ b/mysql-test/include/ctype_unicode_latin.inc
@@ -0,0 +1,179 @@
+#
+# Basic Latin
+#
+insert into t1 values ('A'),('a');
+insert into t1 values ('B'),('b');
+insert into t1 values ('C'),('c');
+insert into t1 values ('D'),('d');
+insert into t1 values ('E'),('e');
+insert into t1 values ('F'),('f');
+insert into t1 values ('G'),('g');
+insert into t1 values ('H'),('h');
+insert into t1 values ('I'),('i');
+insert into t1 values ('J'),('j');
+insert into t1 values ('K'),('k');
+insert into t1 values ('L'),('l');
+insert into t1 values ('M'),('m');
+insert into t1 values ('N'),('n');
+insert into t1 values ('O'),('o');
+insert into t1 values ('P'),('p');
+insert into t1 values ('Q'),('q');
+insert into t1 values ('R'),('r');
+insert into t1 values ('S'),('s');
+insert into t1 values ('T'),('t');
+insert into t1 values ('U'),('u');
+insert into t1 values ('V'),('v');
+insert into t1 values ('W'),('w');
+insert into t1 values ('X'),('x');
+insert into t1 values ('Y'),('y');
+insert into t1 values ('Z'),('z');
+
+#
+# Latin1 supplement
+#
+insert into t1 values (_ucs2 0x00e0),(_ucs2 0x00c0);
+insert into t1 values (_ucs2 0x00e1),(_ucs2 0x00c1);
+insert into t1 values (_ucs2 0x00e2),(_ucs2 0x00c2);
+insert into t1 values (_ucs2 0x00e3),(_ucs2 0x00c3);
+insert into t1 values (_ucs2 0x00e4),(_ucs2 0x00c4);
+insert into t1 values (_ucs2 0x00e5),(_ucs2 0x00c5);
+insert into t1 values (_ucs2 0x00e6),(_ucs2 0x00c6);
+insert into t1 values (_ucs2 0x00e7),(_ucs2 0x00c7);
+insert into t1 values (_ucs2 0x00e8),(_ucs2 0x00c8);
+insert into t1 values (_ucs2 0x00e9),(_ucs2 0x00c9);
+insert into t1 values (_ucs2 0x00ea),(_ucs2 0x00ca);
+insert into t1 values (_ucs2 0x00eb),(_ucs2 0x00cb);
+insert into t1 values (_ucs2 0x00ec),(_ucs2 0x00cc);
+insert into t1 values (_ucs2 0x00ed),(_ucs2 0x00cd);
+insert into t1 values (_ucs2 0x00ee),(_ucs2 0x00ce);
+insert into t1 values (_ucs2 0x00ef),(_ucs2 0x00cf);
+
+insert into t1 values (_ucs2 0x00f0),(_ucs2 0x00d0);
+insert into t1 values (_ucs2 0x00f1),(_ucs2 0x00d1);
+insert into t1 values (_ucs2 0x00f2),(_ucs2 0x00d2);
+insert into t1 values (_ucs2 0x00f3),(_ucs2 0x00d3);
+insert into t1 values (_ucs2 0x00f4),(_ucs2 0x00d4);
+insert into t1 values (_ucs2 0x00f5),(_ucs2 0x00d5);
+insert into t1 values (_ucs2 0x00f6),(_ucs2 0x00d6);
+insert into t1 values (_ucs2 0x00f7),(_ucs2 0x00d7);
+insert into t1 values (_ucs2 0x00f8),(_ucs2 0x00d8);
+insert into t1 values (_ucs2 0x00f9),(_ucs2 0x00d9);
+insert into t1 values (_ucs2 0x00fa),(_ucs2 0x00da);
+insert into t1 values (_ucs2 0x00fb),(_ucs2 0x00db);
+insert into t1 values (_ucs2 0x00fc),(_ucs2 0x00dc);
+insert into t1 values (_ucs2 0x00fd),(_ucs2 0x00dd);
+insert into t1 values (_ucs2 0x00fe),(_ucs2 0x00de);
+insert into t1 values (_ucs2 0x00ff),(_ucs2 0x00df);
+
+#
+# Latin extended-A, 0100-017F
+#
+insert into t1 values (_ucs2 0x0100),(_ucs2 0x0101),(_ucs2 0x0102),(_ucs2 0x0103);
+insert into t1 values (_ucs2 0x0104),(_ucs2 0x0105),(_ucs2 0x0106),(_ucs2 0x0107);
+insert into t1 values (_ucs2 0x0108),(_ucs2 0x0109),(_ucs2 0x010a),(_ucs2 0x010b);
+insert into t1 values (_ucs2 0x010c),(_ucs2 0x010d),(_ucs2 0x010e),(_ucs2 0x010f);
+insert into t1 values (_ucs2 0x0110),(_ucs2 0x0111),(_ucs2 0x0112),(_ucs2 0x0113);
+insert into t1 values (_ucs2 0x0114),(_ucs2 0x0115),(_ucs2 0x0116),(_ucs2 0x0117);
+insert into t1 values (_ucs2 0x0118),(_ucs2 0x0119),(_ucs2 0x011a),(_ucs2 0x011b);
+insert into t1 values (_ucs2 0x011c),(_ucs2 0x011d),(_ucs2 0x011e),(_ucs2 0x011f);
+insert into t1 values (_ucs2 0x0120),(_ucs2 0x0121),(_ucs2 0x0122),(_ucs2 0x0123);
+insert into t1 values (_ucs2 0x0124),(_ucs2 0x0125),(_ucs2 0x0126),(_ucs2 0x0127);
+insert into t1 values (_ucs2 0x0128),(_ucs2 0x0129),(_ucs2 0x012a),(_ucs2 0x012b);
+insert into t1 values (_ucs2 0x012c),(_ucs2 0x012d),(_ucs2 0x012e),(_ucs2 0x012f);
+insert into t1 values (_ucs2 0x0130),(_ucs2 0x0131),(_ucs2 0x0132),(_ucs2 0x0133);
+insert into t1 values (_ucs2 0x0134),(_ucs2 0x0135),(_ucs2 0x0136),(_ucs2 0x0137);
+insert into t1 values (_ucs2 0x0138),(_ucs2 0x0139),(_ucs2 0x013a),(_ucs2 0x013b);
+insert into t1 values (_ucs2 0x013c),(_ucs2 0x013d),(_ucs2 0x013e),(_ucs2 0x013f);
+insert into t1 values (_ucs2 0x0140),(_ucs2 0x0141),(_ucs2 0x0142),(_ucs2 0x0143);
+insert into t1 values (_ucs2 0x0144),(_ucs2 0x0145),(_ucs2 0x0146),(_ucs2 0x0147);
+insert into t1 values (_ucs2 0x0148),(_ucs2 0x0149),(_ucs2 0x014a),(_ucs2 0x014b);
+insert into t1 values (_ucs2 0x014c),(_ucs2 0x014d),(_ucs2 0x014e),(_ucs2 0x014f);
+insert into t1 values (_ucs2 0x0150),(_ucs2 0x0151),(_ucs2 0x0152),(_ucs2 0x0153);
+insert into t1 values (_ucs2 0x0154),(_ucs2 0x0155),(_ucs2 0x0156),(_ucs2 0x0157);
+insert into t1 values (_ucs2 0x0158),(_ucs2 0x0159),(_ucs2 0x015a),(_ucs2 0x015b);
+insert into t1 values (_ucs2 0x015c),(_ucs2 0x015d),(_ucs2 0x015e),(_ucs2 0x015f);
+insert into t1 values (_ucs2 0x0160),(_ucs2 0x0161),(_ucs2 0x0162),(_ucs2 0x0163);
+insert into t1 values (_ucs2 0x0164),(_ucs2 0x0165),(_ucs2 0x0166),(_ucs2 0x0167);
+insert into t1 values (_ucs2 0x0168),(_ucs2 0x0169),(_ucs2 0x016a),(_ucs2 0x016b);
+insert into t1 values (_ucs2 0x016c),(_ucs2 0x016d),(_ucs2 0x016e),(_ucs2 0x016f);
+insert into t1 values (_ucs2 0x0170),(_ucs2 0x0171),(_ucs2 0x0172),(_ucs2 0x0173);
+insert into t1 values (_ucs2 0x0174),(_ucs2 0x0175),(_ucs2 0x0176),(_ucs2 0x0177);
+insert into t1 values (_ucs2 0x0178),(_ucs2 0x0179),(_ucs2 0x017a),(_ucs2 0x017b);
+insert into t1 values (_ucs2 0x017c),(_ucs2 0x017d),(_ucs2 0x017e),(_ucs2 0x017f);
+
+#
+# Latin extended-B, 0180-024F
+#
+insert into t1 values (_ucs2 0x0180),(_ucs2 0x0181),(_ucs2 0x0182),(_ucs2 0x0183);
+insert into t1 values (_ucs2 0x0184),(_ucs2 0x0185),(_ucs2 0x0186),(_ucs2 0x0187);
+insert into t1 values (_ucs2 0x0188),(_ucs2 0x0189),(_ucs2 0x018a),(_ucs2 0x018b);
+insert into t1 values (_ucs2 0x018c),(_ucs2 0x018d),(_ucs2 0x018e),(_ucs2 0x018f);
+insert into t1 values (_ucs2 0x0190),(_ucs2 0x0191),(_ucs2 0x0192),(_ucs2 0x0193);
+insert into t1 values (_ucs2 0x0194),(_ucs2 0x0195),(_ucs2 0x0196),(_ucs2 0x0197);
+insert into t1 values (_ucs2 0x0198),(_ucs2 0x0199),(_ucs2 0x019a),(_ucs2 0x019b);
+insert into t1 values (_ucs2 0x019c),(_ucs2 0x019d),(_ucs2 0x019e),(_ucs2 0x019f);
+insert into t1 values (_ucs2 0x01a0),(_ucs2 0x01a1),(_ucs2 0x01a2),(_ucs2 0x01a3);
+insert into t1 values (_ucs2 0x01a4),(_ucs2 0x01a5),(_ucs2 0x01a6),(_ucs2 0x01a7);
+insert into t1 values (_ucs2 0x01a8),(_ucs2 0x01a9),(_ucs2 0x01aa),(_ucs2 0x01ab);
+insert into t1 values (_ucs2 0x01ac),(_ucs2 0x01ad),(_ucs2 0x01ae),(_ucs2 0x01af);
+insert into t1 values (_ucs2 0x01b0),(_ucs2 0x01b1),(_ucs2 0x01b2),(_ucs2 0x01b3);
+insert into t1 values (_ucs2 0x01b4),(_ucs2 0x01b5),(_ucs2 0x01b6),(_ucs2 0x01b7);
+insert into t1 values (_ucs2 0x01b8),(_ucs2 0x01b9),(_ucs2 0x01ba),(_ucs2 0x01bb);
+insert into t1 values (_ucs2 0x01bc),(_ucs2 0x01bd),(_ucs2 0x01be),(_ucs2 0x01bf);
+insert into t1 values (_ucs2 0x01c0),(_ucs2 0x01c1),(_ucs2 0x01c2),(_ucs2 0x01c3);
+insert into t1 values (_ucs2 0x01c4),(_ucs2 0x01c5),(_ucs2 0x01c6),(_ucs2 0x01c7);
+insert into t1 values (_ucs2 0x01c8),(_ucs2 0x01c9),(_ucs2 0x01ca),(_ucs2 0x01cb);
+insert into t1 values (_ucs2 0x01cc),(_ucs2 0x01cd),(_ucs2 0x01ce),(_ucs2 0x01cf);
+insert into t1 values (_ucs2 0x01d0),(_ucs2 0x01d1),(_ucs2 0x01d2),(_ucs2 0x01d3);
+insert into t1 values (_ucs2 0x01d4),(_ucs2 0x01d5),(_ucs2 0x01d6),(_ucs2 0x01d7);
+insert into t1 values (_ucs2 0x01d8),(_ucs2 0x01d9),(_ucs2 0x01da),(_ucs2 0x01db);
+insert into t1 values (_ucs2 0x01dc),(_ucs2 0x01dd),(_ucs2 0x01de),(_ucs2 0x01df);
+insert into t1 values (_ucs2 0x01e0),(_ucs2 0x01e1),(_ucs2 0x01e2),(_ucs2 0x01e3);
+insert into t1 values (_ucs2 0x01e4),(_ucs2 0x01e5),(_ucs2 0x01e6),(_ucs2 0x01e7);
+insert into t1 values (_ucs2 0x01e8),(_ucs2 0x01e9),(_ucs2 0x01ea),(_ucs2 0x01eb);
+insert into t1 values (_ucs2 0x01ec),(_ucs2 0x01ed),(_ucs2 0x01ee),(_ucs2 0x01ef);
+insert into t1 values (_ucs2 0x01f0),(_ucs2 0x01f1),(_ucs2 0x01f2),(_ucs2 0x01f3);
+insert into t1 values (_ucs2 0x01f4),(_ucs2 0x01f5),(_ucs2 0x01f6),(_ucs2 0x01f7);
+insert into t1 values (_ucs2 0x01f8),(_ucs2 0x01f9),(_ucs2 0x01fa),(_ucs2 0x01fb);
+insert into t1 values (_ucs2 0x01fc),(_ucs2 0x01fd),(_ucs2 0x01fe),(_ucs2 0x01ff);
+
+#
+# Latin Extended Additional: Latin extension for Vietnamese, 1EA0-1EF1
+#
+INSERT INTO t1 VALUES (_ucs2 0x1EA0),(_ucs2 0x1EA1),(_ucs2 0x1EA2),(_ucs2 0x1EA3);
+INSERT INTO t1 VALUES (_ucs2 0x1EA4),(_ucs2 0x1EA5),(_ucs2 0x1EA6),(_ucs2 0x1EA7);
+INSERT INTO t1 VALUES (_ucs2 0x1EA8),(_ucs2 0x1EA9),(_ucs2 0x1EAA),(_ucs2 0x1EAB);
+INSERT INTO t1 VALUES (_ucs2 0x1EAC),(_ucs2 0x1EAD),(_ucs2 0x1EAE),(_ucs2 0x1EAF);
+INSERT INTO t1 VALUES (_ucs2 0x1EB0),(_ucs2 0x1EB1),(_ucs2 0x1EB2),(_ucs2 0x1EB3);
+INSERT INTO t1 VALUES (_ucs2 0x1EB4),(_ucs2 0x1EB5),(_ucs2 0x1EB6),(_ucs2 0x1EB7);
+INSERT INTO t1 VALUES (_ucs2 0x1EB8),(_ucs2 0x1EB9),(_ucs2 0x1EBA),(_ucs2 0x1EBB);
+INSERT INTO t1 VALUES (_ucs2 0x1EBC),(_ucs2 0x1EBD),(_ucs2 0x1EBE),(_ucs2 0x1EBF);
+INSERT INTO t1 VALUES (_ucs2 0x1EC0),(_ucs2 0x1EC1),(_ucs2 0x1EC2),(_ucs2 0x1EC3);
+INSERT INTO t1 VALUES (_ucs2 0x1EC4),(_ucs2 0x1EC5),(_ucs2 0x1EC6),(_ucs2 0x1EC7);
+INSERT INTO t1 VALUES (_ucs2 0x1EC8),(_ucs2 0x1EC9),(_ucs2 0x1ECA),(_ucs2 0x1ECB);
+INSERT INTO t1 VALUES (_ucs2 0x1ECC),(_ucs2 0x1ECD),(_ucs2 0x1ECE),(_ucs2 0x1ECF);
+INSERT INTO t1 VALUES (_ucs2 0x1ED0),(_ucs2 0x1ED1),(_ucs2 0x1ED2),(_ucs2 0x1ED3);
+INSERT INTO t1 VALUES (_ucs2 0x1ED4),(_ucs2 0x1ED5),(_ucs2 0x1ED6),(_ucs2 0x1ED7);
+INSERT INTO t1 VALUES (_ucs2 0x1ED8),(_ucs2 0x1ED9),(_ucs2 0x1EDA),(_ucs2 0x1EDB);
+INSERT INTO t1 VALUES (_ucs2 0x1EDC),(_ucs2 0x1EDD),(_ucs2 0x1EDE),(_ucs2 0x1EDF);
+INSERT INTO t1 VALUES (_ucs2 0x1EE0),(_ucs2 0x1EE1),(_ucs2 0x1EE2),(_ucs2 0x1EE3);
+INSERT INTO t1 VALUES (_ucs2 0x1EE4),(_ucs2 0x1EE5),(_ucs2 0x1EE6),(_ucs2 0x1EE7);
+INSERT INTO t1 VALUES (_ucs2 0x1EE8),(_ucs2 0x1EE9),(_ucs2 0x1EEA),(_ucs2 0x1EEB);
+INSERT INTO t1 VALUES (_ucs2 0x1EEC),(_ucs2 0x1EED),(_ucs2 0x1EEE),(_ucs2 0x1EEF);
+INSERT INTO t1 VALUES (_ucs2 0x1EF0),(_ucs2 0x1EF1);
+
+#
+# Contractions used in some languages
+#
+insert into t1 values ('AA'),('Aa'),('aa'),('aA');
+insert into t1 values ('AE'),('Ae'),('ae'),('aE');
+insert into t1 values ('CH'),('Ch'),('ch'),('cH');
+insert into t1 values ('DZ'),('Dz'),('dz'),('dZ');
+insert into t1 values ('DŽ'),('Dž'),('dž'),('dŽ');
+insert into t1 values ('IJ'),('Ij'),('ij'),('iJ');
+insert into t1 values ('LJ'),('Lj'),('lj'),('lJ');
+insert into t1 values ('LL'),('Ll'),('ll'),('lL');
+insert into t1 values ('NJ'),('Nj'),('nj'),('nJ');
+insert into t1 values ('OE'),('Oe'),('oe'),('oE');
+insert into t1 values ('SS'),('Ss'),('ss'),('sS');
+insert into t1 values ('RR'),('Rr'),('rr'),('rR');
diff --git a/mysql-test/include/ctype_utf8mb4.inc b/mysql-test/include/ctype_utf8mb4.inc
index d1cb64705cd..9ee2414e142 100644
--- a/mysql-test/include/ctype_utf8mb4.inc
+++ b/mysql-test/include/ctype_utf8mb4.inc
@@ -224,25 +224,9 @@ drop table t1;
#
# Testing regexp
#
-set collation_connection=utf8mb4_general_ci;
---source include/ctype_regex.inc
-set names utf8mb4;
-
-#
-# Bug #3928 regexp [[:>:]] and UTF-8
-#
set names utf8mb4;
-
-# This should return TRUE
-select 'ваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]';
-select 'ваÑÑ ' rlike '[[:<:]]ваÑÑ[[:>:]]';
-select ' ваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]';
-select ' ваÑÑ ' rlike '[[:<:]]ваÑÑ[[:>:]]';
-
-# This should return FALSE
-select 'ваÑÑz' rlike '[[:<:]]ваÑÑ[[:>:]]';
-select 'zваÑÑ' rlike '[[:<:]]ваÑÑ[[:>:]]';
-select 'zваÑÑz' rlike '[[:<:]]ваÑÑ[[:>:]]';
+--source include/ctype_regex.inc
+--source include/ctype_regex_utf8.inc
#
# Bug #4555
diff --git a/mysql-test/include/default_mysqld.cnf b/mysql-test/include/default_mysqld.cnf
index 98be65762d1..b014d6e33f8 100644
--- a/mysql-test/include/default_mysqld.cnf
+++ b/mysql-test/include/default_mysqld.cnf
@@ -1,4 +1,5 @@
# Copyright (c) 2007, 2013, Oracle and/or its affiliates
+# Copyright (c) 2010, 2013, Monty Program Ab
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -42,26 +43,63 @@ loose-feedback-debug-startup-interval=20
loose-feedback-debug-first-interval=60
loose-feedback-debug-interval=60
-loose-innodb_data_file_path= ibdata1:10M:autoextend
+loose-innodb_data_file_path= ibdata1:12M:autoextend
loose-innodb_buffer_pool_size= 8M
+loose-innodb_lru_scan_depth= 100
loose-innodb_write_io_threads= 2
loose-innodb_read_io_threads= 2
loose-innodb_log_buffer_size= 1M
loose-innodb_log_file_size= 5M
-loose-innodb_additional_mem_pool_size= 1M
loose-innodb_log_files_in_group= 2
+loose-innodb-stats-persistent= OFF
slave-net-timeout=120
+# MAINTAINER:
+# the loose- syntax is to make sure the cnf file is also
+# valid when building without the performance schema.
+
# Run tests with the performance schema instrumentation
loose-enable-performance-schema
# Run tests with a small number of instrumented objects
# to limit memory consumption with MTR
-loose-performance-schema-max-mutex-instances=10000
-loose-performance-schema-max-rwlock-instances=10000
+loose-performance-schema-accounts-size=100
+loose-performance-schema-digests-size=200
+loose-performance-schema-hosts-size=100
+loose-performance-schema-users-size=100
+loose-performance-schema-max-mutex-instances=5000
+loose-performance-schema-max-rwlock-instances=5000
+loose-performance-schema-max-cond-instances=1000
+loose-performance-schema-max-file-instances=10000
+loose-performance-schema-max-socket-instances=1000
loose-performance-schema-max-table-instances=500
loose-performance-schema-max-table-handles=1000
+loose-performance-schema-events-waits-history-size=10
+loose-performance-schema-events-waits-history-long-size=10000
+loose-performance-schema-events-stages-history-size=10
+loose-performance-schema-events-stages-history-long-size=1000
+loose-performance-schema-events-statements-history-size=10
+loose-performance-schema-events-statements-history-long-size=1000
+loose-performance-schema-max-thread-instances=200
+loose-performance-schema-session-connect-attrs-size=2048
+
+# Enable everything, for maximun code exposure during testing
+
+loose-performance-schema-instrument='%=ON'
+
+loose-performance-schema-consumer-events-stages-current=ON
+loose-performance-schema-consumer-events-stages-history=ON
+loose-performance-schema-consumer-events-stages-history-long=ON
+loose-performance-schema-consumer-events-statements-current=ON
+loose-performance-schema-consumer-events-statements-history=ON
+loose-performance-schema-consumer-events-statements-history-long=ON
+loose-performance-schema-consumer-events-waits-current=ON
+loose-performance-schema-consumer-events-waits-history=ON
+loose-performance-schema-consumer-events-waits-history-long=ON
+loose-performance-schema-consumer-global-instrumentation=ON
+loose-performance-schema-consumer-thread-instrumentation=ON
+
binlog-direct-non-transactional-updates
default-storage-engine=myisam
diff --git a/mysql-test/include/explain_non_select.inc b/mysql-test/include/explain_non_select.inc
new file mode 100644
index 00000000000..a0f86e744b0
--- /dev/null
+++ b/mysql-test/include/explain_non_select.inc
@@ -0,0 +1,833 @@
+# This file is a collection of regression and coverage tests
+# for WL#4897: Add EXPLAIN INSERT/UPDATE/DELETE.
+
+-- disable_query_log
+-- disable_result_log
+# SET GLOBAL innodb_stats_persistent=0;
+-- enable_result_log
+-- enable_query_log
+
+# set end_markers_in_json=on;
+
+--echo #1
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+--let $query = UPDATE t1 SET a = 10 WHERE a < 10
+--let $select = SELECT * FROM t1 WHERE a < 10
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #2
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+--let $query = DELETE FROM t1 WHERE a < 10
+--let $select = SELECT * FROM t1 WHERE a < 10
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #3
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+--let $query = DELETE FROM t1 USING t1 WHERE a = 1
+--let $select = SELECT * FROM t1 WHERE a = 1
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #4
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (1), (2), (3);
+--let $query = UPDATE t1, t2 SET t1.a = 10 WHERE t1.a = 1
+--let $select = SELECT * FROM t1, t2 WHERE t1.a = 1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #5
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (1), (2), (3);
+--let $query = UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a = 1
+--let $select = SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a = 1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #6
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (1), (2), (3);
+--let $query = UPDATE t1 SET a = 10 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3)
+--let $select = SELECT * FROM t1 WHERE 1 IN (SELECT 1 FROM t2 WHERE t2.b < 3)
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #7
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (1), (2), (3);
+--let $query = UPDATE t1 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3)
+--let $select = SELECT * FROM t1 WHERE a IN (SELECT b FROM t2 WHERE t1.a < 3)
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #7
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (1), (2), (3);
+--let $query = UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3)
+--let $select = SELECT * FROM t1, t2 WHERE a IN (SELECT b FROM t2 WHERE t2.b < 3)
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #8
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (1), (2), (3);
+--let $query = UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = t11.a + 10
+--let $select = SELECT * FROM t1 t11, (SELECT * FROM t2) t12
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #9
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (1), (2), (3);
+--let $query = UPDATE t1 t11, (SELECT 1 FROM DUAL) t12 SET t11.a = t11.a + 10
+--let $select = SELECT * FROM t1 t11, (SELECT 1 FROM DUAL) t12
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #10
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (1), (2), (3);
+--let $query = UPDATE t1 t11, (SELECT * FROM t2) t12 SET t11.a = 10 WHERE t11.a > 1
+--let $select = SELECT * FROM t1 t11, (SELECT * FROM t2) t12 WHERE t11.a > 1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #11
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+--let $query = DELETE FROM t1 WHERE a > 1 LIMIT 1
+--let $select = SELECT * FROM t1 WHERE a > 1 LIMIT 1
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #12
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+--let $query = DELETE FROM t1 WHERE 0
+--let $select = SELECT * FROM t1 WHERE 0
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #13
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+--let $query = DELETE FROM t1 USING t1 WHERE 0
+--let $select = SELECT * FROM t1 WHERE 0
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #14
+CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b));
+INSERT INTO t1 VALUES (3, 3), (7, 7);
+--let $query = DELETE FROM t1 WHERE a = 3
+--let $select = SELECT * FROM t1 WHERE a = 3
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #15
+CREATE TABLE t1 (a INT, b INT, UNIQUE KEY (a), KEY (b));
+INSERT INTO t1 VALUES (3, 3), (7, 7);
+--let $query = DELETE FROM t1 WHERE a < 3
+--let $select = SELECT * FROM t1 WHERE a < 3
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #16
+CREATE TABLE t1 ( a int PRIMARY KEY );
+--let $query = DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a
+--let $select = SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a
+--source include/explain_utils.inc
+INSERT INTO t1 VALUES (1), (2), (3);
+--let $query = DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a
+--let $select = SELECT * FROM t1 WHERE t1.a > 0 ORDER BY t1.a
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #17
+CREATE TABLE t1(a INT PRIMARY KEY);
+INSERT INTO t1 VALUES (4),(3),(1),(2);
+--let $query = DELETE FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1
+--let $select = SELECT * FROM t1 WHERE (@a:= a) ORDER BY a LIMIT 1
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #18
+CREATE TABLE t1 (a DATE, b TIME, c INT, KEY c(c), KEY b(b), KEY a(a));
+INSERT INTO t1 VALUES (), (), (), (), (), (), (), (), (), ();
+UPDATE t1 SET a = c, b = c;
+--let $query = DELETE FROM t1 ORDER BY a ASC, b ASC LIMIT 1
+--let $select = SELECT * FROM t1 ORDER BY a ASC, b ASC LIMIT 1
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #19
+CREATE TABLE t1 (a1 INT NOT NULL, b1 INT NOT NULL);
+CREATE TABLE t2 (a2 INT NOT NULL, b2 INT NOT NULL, PRIMARY KEY (a2,b2));
+CREATE TABLE t3 (a3 INT NOT NULL, b3 INT NOT NULL, PRIMARY KEY (a3,b3));
+INSERT INTO t1 VALUES (1,1), (2,1), (1,3);
+INSERT INTO t2 VALUES (1,1), (2,2), (3,3);
+INSERT INTO t3 VALUES (1,1), (2,1), (1,3);
+--let $query = DELETE t1,t2,t3 FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3
+--let $select = SELECT * FROM t1,t2,t3 WHERE a1=a2 AND b2=a3 AND b1=b3
+--source include/explain_utils.inc
+DROP TABLE t1, t2, t3;
+
+--echo #20
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE TABLE t2 (a INT);
+INSERT INTO t2 VALUES (1), (2), (3);
+--let $query = UPDATE t1 SET a = 10 WHERE a IN (SELECT a FROM t2)
+--let $select = SELECT * FROM t1 WHERE a IN (SELECT a FROM t2)
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #21
+CREATE TABLE t1 (a1 INT);
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
+CREATE TABLE t2 (a2 VARCHAR(10));
+INSERT INTO t2 VALUES (1), (2), (3), (4), (5);
+SET @save_optimizer_switch= @@optimizer_switch;
+--disable_query_log
+if (`select locate('semijoin', @@optimizer_switch) > 0`)
+{
+ SET @@optimizer_switch= 'semijoin=off';
+}
+--enable_query_log
+--let $query = DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2)
+--let $select = SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2)
+--source include/explain_utils.inc
+SET @@optimizer_switch= @save_optimizer_switch;
+TRUNCATE t1;
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
+--let $query = DELETE FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2)
+--let $select = SELECT * FROM t1 WHERE a1 IN (SELECT a2 FROM t2 WHERE a2 > 2)
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #22
+CREATE TABLE t1 (i INT, j INT);
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
+--let $query = UPDATE t1 SET i = 10
+--let $select = SELECT * FROM t1
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #23
+CREATE TABLE t1 (i INT, j INT);
+INSERT INTO t1 VALUES (1, 1), (2, 2), (3, 3), (4, 4), (5, 5);
+--let $query = DELETE FROM t1
+--let $select = SELECT * FROM t1
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #24
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
+ (20),(21),(22),(23),(24),(25),(26),(27),(28),(29),
+ (30),(31),(32),(33),(34),(35);
+CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c));
+INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1;
+INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2;
+--let $query = DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5
+--let $select = SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5
+--let $no_rows = 1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #25
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE TABLE t2 (i INT);
+--let $query = INSERT INTO t2 SELECT * FROM t1
+--let $select = SELECT * FROM t1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #26
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE TABLE t2 (i INT);
+--let $query = REPLACE INTO t2 SELECT * FROM t1
+--let $select = SELECT * FROM t1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #27
+CREATE TABLE t1 (i INT);
+--let $query = INSERT INTO t1 SET i = 10
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #28
+CREATE TABLE t1 (i INT);
+--let $query = REPLACE INTO t1 SET i = 10
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #29
+CREATE TABLE t1 (a INT, i INT PRIMARY KEY);
+INSERT INTO t1 (i) VALUES (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);
+--let $query = DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5
+--let $select = SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #30
+CREATE TABLE t1(a INT, i CHAR(2), INDEX(i(1)));
+INSERT INTO t1 (i) VALUES (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);
+--let $query = DELETE FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5
+--let $select = SELECT * FROM t1 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #31
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 (i) VALUES (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);
+CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c));
+INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1;
+--let $query = DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5
+--let $select = SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #32
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 (i) VALUES (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);
+CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c));
+INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1;
+INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2;
+--let $query = DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5
+--let $select = SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5
+--let $no_rows = 1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #33
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 (i) VALUES (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);
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c));
+INSERT INTO t2 SELECT i, i, i, i FROM t1;
+--let $query = DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5
+--let $select = SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #34
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 (i) VALUES (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);
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c))
+ ENGINE=HEAP;
+INSERT INTO t2 SELECT i, i, i, i FROM t1;
+--let $query = DELETE FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5
+--let $select = SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #35
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 (i) VALUES (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);
+CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2));
+INSERT INTO t2 (key1, key2) SELECT i, i FROM t1;
+--let $query = DELETE FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1
+--let $select = SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #36
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 (i) VALUES (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);
+CREATE TABLE t2(a INT, i INT PRIMARY KEY);
+INSERT INTO t2 (i) SELECT i FROM t1;
+--let $query = DELETE FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5
+--let $select = SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #37
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 (i) VALUES (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);
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b));
+INSERT INTO t2 SELECT i, i, i FROM t1;
+--let $query = DELETE FROM t2 ORDER BY a, b DESC LIMIT 5
+--let $select = SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #38
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
+ (20),(21),(22),(23),(24),(25),(26),(27),(28),(29),
+ (30),(31),(32),(33),(34),(35);
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b));
+INSERT INTO t2 (a, b) SELECT i, i FROM t1;
+INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2;
+--let $query = DELETE FROM t2 ORDER BY a DESC, b DESC LIMIT 5
+--let $select = SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5
+--let $no_rows = 1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #39
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
+ (20),(21),(22),(23),(24),(25),(26),(27),(28),(29),
+ (30),(31),(32),(33),(34),(35);
+CREATE TABLE t2(a INT, i INT PRIMARY KEY);
+INSERT INTO t2 (i) SELECT i FROM t1;
+--let $query = UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5
+--let $select = SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5
+--let $no_rows = 1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #40
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
+ (20),(21),(22),(23),(24),(25),(26),(27),(28),(29),
+ (30),(31),(32),(33),(34),(35);
+CREATE TABLE t2(a INT, i CHAR(2), INDEX(i(1)));
+INSERT INTO t2 (i) SELECT i FROM t1;
+--let $query = UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5
+--let $select = SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i LIMIT 5
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #41
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
+ (20),(21),(22),(23),(24),(25),(26),(27),(28),(29),
+ (30),(31),(32),(33),(34),(35);
+CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c));
+INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1;
+--let $query = UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5
+--let $select = SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #42
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
+ (20),(21),(22),(23),(24),(25),(26),(27),(28),(29),
+ (30),(31),(32),(33),(34),(35);
+CREATE TABLE t2(a INT, b INT, c INT, d INT, INDEX(a, b, c));
+INSERT INTO t2 (a, b, c) SELECT i, i, i FROM t1;
+INSERT INTO t2 (a, b, c) SELECT t1.i, t1.i, t1.i FROM t1, t1 x1, t1 x2;
+--let $query = UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5
+--let $select = SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5
+--let $no_rows = 1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #43
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
+ (20),(21),(22),(23),(24),(25),(26),(27),(28),(29),
+ (30),(31),(32),(33),(34),(35);
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b(1),c));
+INSERT INTO t2 SELECT i, i, i, i FROM t1;
+--let $query = UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5
+--let $select = SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #44
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
+ (20),(21),(22),(23),(24),(25),(26),(27),(28),(29),
+ (30),(31),(32),(33),(34),(35);
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), d CHAR(2), INDEX (a,b,c))
+ ENGINE=HEAP;
+INSERT INTO t2 SELECT i, i, i, i FROM t1;
+--let $query = UPDATE t2 SET d = 10 WHERE b = 10 ORDER BY a, c LIMIT 5
+--let $select = SELECT * FROM t2 WHERE b = 10 ORDER BY a, c LIMIT 5
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #45
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
+ (20),(21),(22),(23),(24),(25),(26),(27),(28),(29),
+ (30),(31),(32),(33),(34),(35),(36),(37),(38),(39),
+ (40),(41),(42);
+CREATE TABLE t2 (i INT, key1 INT, key2 INT, INDEX (key1), INDEX (key2));
+INSERT INTO t2 (key1, key2) SELECT i, i FROM t1;
+--let $query = UPDATE t2 SET i = 123 WHERE key1 < 13 or key2 < 14 ORDER BY key1
+--let $select = SELECT * FROM t2 WHERE key1 < 13 or key2 < 14 ORDER BY key1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #46
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
+ (20),(21),(22),(23),(24),(25),(26),(27),(28),(29),
+ (30),(31),(32),(33),(34),(35);
+CREATE TABLE t2(a INT, i INT PRIMARY KEY);
+INSERT INTO t2 (i) SELECT i FROM t1;
+--let $query = UPDATE t2 SET a = 10 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5
+--let $select = SELECT * FROM t2 WHERE i > 10 AND i <= 18 ORDER BY i DESC LIMIT 5
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #47
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
+ (20),(21),(22),(23),(24),(25),(26),(27),(28),(29),
+ (30),(31),(32),(33),(34),(35);
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c CHAR(2), INDEX (a, b));
+INSERT INTO t2 SELECT i, i, i FROM t1;
+--let $query = UPDATE t2 SET c = 10 ORDER BY a, b DESC LIMIT 5
+--let $select = SELECT * FROM t2 ORDER BY a, b DESC LIMIT 5
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #48
+CREATE TABLE t1 (i INT);
+INSERT INTO t1 VALUES (10),(11),(12),(13),(14),(15),(16),(17),(18),(19),
+ (20),(21),(22),(23),(24),(25),(26),(27),(28),(29),
+ (30),(31),(32),(33),(34),(35);
+CREATE TABLE t2 (a CHAR(2), b CHAR(2), c INT, INDEX (a, b));
+INSERT INTO t2 (a, b) SELECT i, i FROM t1;
+INSERT INTO t2 (a, b) SELECT t1.i, t1.i FROM t1, t1 x1, t1 x2;
+--let $query = UPDATE t2 SET c = 10 ORDER BY a DESC, b DESC LIMIT 5
+--let $select = SELECT * FROM t2 ORDER BY a DESC, b DESC LIMIT 5
+--let $no_rows = 1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #49
+CREATE TABLE t1 (
+ pk INT NOT NULL AUTO_INCREMENT,
+ c1_idx CHAR(1) DEFAULT 'y',
+ c2 INT,
+ PRIMARY KEY (pk),
+ INDEX c1_idx (c1_idx)
+);
+INSERT INTO t1 VALUES (1,'y',1), (2,'n',2), (3,'y',3), (4,'n',4);
+--let $query = UPDATE t1 SET c2 = 0 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2
+--let $select = SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2
+--source include/explain_utils.inc
+--let $query = DELETE FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2
+--let $select = SELECT * FROM t1 WHERE c1_idx = 'y' ORDER BY pk DESC LIMIT 2
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #50
+CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY);
+INSERT INTO t1 VALUES (),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),();
+--let $query = UPDATE t1 SET a=a+10 WHERE a > 34
+--let $select = SELECT * FROM t1 WHERE a > 34
+--source include/explain_utils.inc
+DROP TABLE t1;
+
+--echo #51
+CREATE TABLE t1 (c1 INT, c2 INT, c3 INT);
+CREATE TABLE t2 (c1 INT, c2 INT);
+INSERT INTO t1 VALUES (1, 1, 10), (2, 2, 20);
+--let $query = UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10
+--let $select = SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1
+--source include/explain_utils.inc
+--let $query = UPDATE t1 LEFT JOIN t2 ON t1.c1 = t2.c1 SET t2.c2 = 10 WHERE t1.c3 = 10
+--let $select = SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1 WHERE t1.c3 = 10
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #52
+CREATE TABLE t1(f1 INT, f2 INT);
+CREATE TABLE t2(f3 INT, f4 INT);
+CREATE INDEX IDX ON t2(f3);
+INSERT INTO t1 VALUES(1,0),(2,0);
+INSERT INTO t2 VALUES(1,1),(2,2);
+--let $query = UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1)
+--let $select = SELECT (SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1) FROM t1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+
+--echo #55
+CREATE TABLE t1(a INT);
+INSERT INTO t1 VALUES (1);
+SET @a = NULL;
+EXPLAIN DELETE FROM t1 WHERE (@a:= a);
+if (`SELECT @a IS NOT NULL`) {
+ die Unexpectedly modified user variable;
+}
+DROP TABLE t1;
+
+--echo #56
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+--error ER_BAD_FIELD_ERROR
+ DELETE FROM t1 USING t1 WHERE uknown_column = 12345;
+--error ER_BAD_FIELD_ERROR
+EXPLAIN EXTENDED DELETE FROM t1 USING t1 WHERE uknown_column = 12345;
+DROP TABLE t1;
+
+--echo #57
+CREATE TABLE t1(f1 INT);
+--error ER_BAD_FIELD_ERROR
+EXPLAIN EXTENDED UPDATE t1 SET f2=1 ORDER BY f2;
+--error ER_BAD_FIELD_ERROR
+UPDATE t1 SET f2=1 ORDER BY f2;
+DROP TABLE t1;
+
+--disable_parsing
+--echo #59
+CREATE TABLE t1 ( a INT, KEY( a ) );
+INSERT INTO t1 VALUES (0), (1);
+CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12;
+SET SESSION sql_safe_updates = 1;
+--error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE
+EXPLAIN EXTENDED UPDATE IGNORE v1 SET a = 1;
+--error ER_UPDATE_WITHOUT_KEY_IN_SAFE_MODE
+UPDATE IGNORE v1 SET a = 1;
+SET SESSION sql_safe_updates = DEFAULT;
+DROP TABLE t1;
+DROP VIEW v1;
+--enable_parsing
+
+--echo #62
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (0), (1);
+CREATE VIEW v1 AS SELECT t11.a, t12.a AS b FROM t1 t11, t1 t12;
+--let $query = UPDATE v1 SET a = 1 WHERE a > 0
+--let $select = SELECT * FROM v1 WHERE a > 0
+--source include/explain_utils.inc
+--let $query = UPDATE t1, v1 SET v1.a = 1 WHERE t1.a = v1.a
+--let $select = SELECT * FROM t1, v1 WHERE t1.a = v1.a
+--source include/explain_utils.inc
+DROP TABLE t1;
+DROP VIEW v1;
+
+--echo #63
+CREATE TABLE t1 (a INT, PRIMARY KEY(a));
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
+CREATE VIEW v1 (a) AS SELECT a FROM t1;
+--let $query = DELETE FROM v1 WHERE a < 4
+--let $select = SELECT * FROM v1 WHERE a < 4
+--source include/explain_utils.inc
+DROP TABLE t1;
+DROP VIEW v1;
+
+--echo #64
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a));
+INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10);
+CREATE TABLE t2 (x INT);
+INSERT INTO t2 VALUES (1), (2), (3), (4);
+CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1;
+--let $query = DELETE v1 FROM t2, v1 WHERE t2.x = v1.a
+--let $select = SELECT * FROM t2, v1 WHERE t2.x = v1.a
+--source include/explain_utils.inc
+DROP TABLE t1,t2;
+DROP VIEW v1;
+
+--echo #65
+CREATE TABLE t1 (a INT, b INT, PRIMARY KEY(a));
+INSERT INTO t1 VALUES (1,2), (2,3), (3,4), (4,5), (5,10);
+CREATE TABLE t2 (x INT);
+INSERT INTO t2 VALUES (1), (2), (3), (4);
+CREATE VIEW v1 (a,c) AS SELECT a, b+1 FROM t1;
+--let $query = DELETE v1 FROM t2, v1 WHERE t2.x = v1.a
+--let $select = SELECT * FROM t2, v1 WHERE t2.x = v1.a
+--source include/explain_utils.inc
+DROP TABLE t1,t2;
+DROP VIEW v1;
+
+--echo #66
+CREATE TABLE t1 (a INT);
+CREATE VIEW v1 (x) AS SELECT a FROM t1;
+--let $query = INSERT INTO v1 VALUES (10)
+--let $select = SELECT NULL
+--source include/explain_utils.inc
+DROP TABLE t1;
+DROP VIEW v1;
+
+--echo #67
+CREATE TABLE t1 (a INT);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (1), (2), (3);
+CREATE VIEW v1 (x) AS SELECT b FROM t2;
+--let $query = INSERT INTO v1 SELECT * FROM t1
+--let $select = SELECT * FROM t1
+--source include/explain_utils.inc
+DROP TABLE t1, t2;
+DROP VIEW v1;
+
+--echo #68
+CREATE TABLE t1 (i INT);
+EXPLAIN INSERT DELAYED INTO t1 VALUES (1);
+DROP TABLE t1;
+
+--echo #69
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE TABLE t2 (b INT);
+INSERT INTO t2 VALUES (1), (2), (3);
+--let $query = UPDATE t1 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x)
+--let $select = SELECT * FROM t1 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x)
+--source include/explain_utils.inc
+--let $query = UPDATE t1, t2 SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x)
+--let $select = SELECT * FROM t1, t2 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x)
+--source include/explain_utils.inc
+--let $query = UPDATE t1, (SELECT * FROM t2) y SET a = 10 WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x)
+--let $select = SELECT * FROM t1, (SELECT * FROM t2) y WHERE a IN (SELECT * FROM (SELECT b FROM t2 ORDER BY b LIMIT 2,2) x)
+--source include/explain_utils.inc
+DROP TABLE t1,t2;
+
+--echo #70
+CREATE TABLE t1 (c1 INT KEY);
+CREATE TABLE t2 (c2 INT);
+CREATE TABLE t3 (c3 INT);
+EXPLAIN EXTENDED UPDATE t3 SET c3 = (
+ SELECT COUNT(d1.c1)
+ FROM (
+ SELECT a11.c1 FROM t1 AS a11
+ STRAIGHT_JOIN t2 AS a21 ON a21.c2 = a11.c1
+ JOIN t1 AS a12 ON a12.c1 = a11.c1
+ ) d1
+);
+
+DROP TABLE t1, t2, t3;
+
+--disable_parsing
+--echo #71
+#
+# Bug: after EXPLAIN bulk INSERT...SELECT and bulk INSERT...SELECT
+# to a # MyISAM table the SELECT query may fail with the
+# "1030: Got error 124 from storage engine" error message.
+#
+CREATE TABLE t1 (c1 INT NOT NULL, c2 INT NOT NULL, INDEX i1(c1));
+INSERT INTO t1 VALUES (1,0),(2,0),(3,0),(4,0),(5,0),(6,0),(7,0),(8,0);
+--disable_query_log
+let $1=7;
+SET @d=8;
+while ($1) {
+ eval INSERT INTO t1 SELECT c1 + @d, c2 + @d FROM t1;
+ eval SET @d = @d*2;
+ dec $1;
+}
+--enable_query_log
+CREATE TABLE t2 LIKE t1;
+
+# replace "rows" column for InnoDB
+--replace_column 9 X
+EXPLAIN INSERT INTO t2 SELECT * FROM t1;
+INSERT INTO t2 SELECT * FROM t1;
+--disable_result_log
+SELECT * FROM t1 LEFT JOIN t2 ON t1.c1 = t2.c1;
+--enable_result_log
+
+DROP TABLE t1, t2;
+--enable_parsing
+
+--echo #73
+
+CREATE TABLE t1 (id INT);
+CREATE TABLE t2 (id INT);
+INSERT INTO t1 VALUES (1), (2);
+
+EXPLAIN SELECT * FROM t1 LEFT JOIN t2 USING(id) GROUP BY t1.id;
+
+DROP TABLE t1,t2;
+
+--echo #74
+
+CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
+INSERT INTO t1 VALUES (1), (2), (3), (4), (5);
+
+--echo # used key is modified & Using temporary
+
+--let $query = UPDATE t1 SET a=a+1 WHERE a>10
+--let $select = SELECT a t1 FROM t1 WHERE a>10
+--source include/explain_utils.inc
+
+--echo # used key is modified & Using filesort
+
+--let $query = UPDATE t1 SET a=a+1 WHERE a>10 ORDER BY a+20
+--let $select = SELECT a t1 FROM t1 WHERE a>10 ORDER BY a+20
+--source include/explain_utils.inc
+
+DROP TABLE t1;
+
+--echo #
+--echo # Bug #12949629: CLIENT LOSES CONNECTION AFTER EXECUTING A PROCEDURE WITH
+--echo # EXPLAIN UPDATE/DEL/INS
+--echo #
+
+CREATE TABLE t1 (i INT);
+CREATE TABLE t2 (i INT);
+
+--delimiter |
+CREATE PROCEDURE p1() BEGIN EXPLAIN INSERT INTO t1 VALUES (1);END|
+CREATE PROCEDURE p2() BEGIN INSERT INTO t1 VALUES (1);END|
+CREATE PROCEDURE p3() BEGIN EXPLAIN INSERT INTO t1 SELECT 1;END|
+CREATE PROCEDURE p4() BEGIN INSERT INTO t1 SELECT 1;END|
+CREATE PROCEDURE p5() BEGIN EXPLAIN REPLACE INTO t1 VALUES (1);END|
+CREATE PROCEDURE p6() BEGIN REPLACE INTO t1 VALUES (1);END|
+CREATE PROCEDURE p7() BEGIN EXPLAIN REPLACE INTO t1 SELECT 1;END|
+CREATE PROCEDURE p8() BEGIN REPLACE INTO t1 SELECT 1;END|
+CREATE PROCEDURE p9() BEGIN EXPLAIN UPDATE t1 SET i = 10;END|
+CREATE PROCEDURE p10() BEGIN UPDATE t1 SET i = 10;END|
+CREATE PROCEDURE p11() BEGIN EXPLAIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END|
+CREATE PROCEDURE p12() BEGIN UPDATE t1,t2 SET t1.i = 10 WHERE t1.i = t2.i ;END|
+CREATE PROCEDURE p13() BEGIN EXPLAIN DELETE FROM t1;END|
+CREATE PROCEDURE p14() BEGIN DELETE FROM t1;END|
+CREATE PROCEDURE p15() BEGIN EXPLAIN DELETE FROM t1 USING t1;END|
+CREATE PROCEDURE p16() BEGIN DELETE FROM t1 USING t1;END|
+--delimiter ;
+
+let $i=16;
+while($i) {
+ eval CALL p$i();
+ eval DROP PROCEDURE p$i;
+ dec $i;
+}
+
+DROP TABLE t1, t2;
+
+--echo #
+
+-- disable_query_log
+-- disable_result_log
+# SET GLOBAL innodb_stats_persistent=default;
+-- enable_result_log
+-- enable_query_log
diff --git a/mysql-test/include/explain_utils.inc b/mysql-test/include/explain_utils.inc
new file mode 100644
index 00000000000..505798e432a
--- /dev/null
+++ b/mysql-test/include/explain_utils.inc
@@ -0,0 +1,161 @@
+# This file is a collection of utility tests
+# for WL#4897: Add EXPLAIN INSERT/UPDATE/DELETE.
+#
+# Since MTR doesn't have functions, we use this file instead
+# including it many times.
+#
+# Parameters:
+#
+# $query: INSERT/REPLACE/UPDATE/DELETE query to explain
+# NOTE: this file resets this variable
+#
+# $select: may be empty; the SELECT query similar to $query
+# We use it to compare:
+# 1) table data before and after EXPLAIN $query evaluation;
+# 2) EXPLAIN $query and EXPLAIN $select output and
+# handler/filesort statistics
+# NOTE: this file resets this variable
+# $innodb: take $no_rows parameter into account if not 0;
+# $no_rows: filter out "rows" and "filtered" columns of EXPLAIN if not 0;
+# it may be necessary for InnoDB tables since InnoDB's table row
+# counter can't return precise and repeatable values;
+# NOTE: ANALYZE TABLE doesn't help
+# NOTE: this file resets this variable
+
+--echo #
+--echo # query: $query
+--echo # select: $select
+--echo #
+
+if ($select) {
+--disable_query_log
+--eval $select INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/before_explain.txt'
+--enable_query_log
+}
+
+if ($innodb) {
+ if ($no_rows) {
+--replace_column 9 X
+ }
+}
+--eval EXPLAIN $query
+if (`SELECT ROW_COUNT() > 0`) {
+--echo # Erroneous query: EXPLAIN $query
+--die Unexpected ROW_COUNT() <> 0
+}
+
+FLUSH STATUS;
+FLUSH TABLES;
+if ($innodb) {
+ if ($no_rows) {
+--replace_column 9 X 10 X
+ }
+}
+--eval EXPLAIN EXTENDED $query
+if (`SELECT ROW_COUNT() > 0`) {
+--echo # Erroneous query: EXPLAIN EXTENDED $query
+--die Unexpected ROW_COUNT() <> 0
+}
+--echo # Status of EXPLAIN EXTENDED query
+--disable_query_log
+SHOW STATUS WHERE (Variable_name LIKE 'Sort%' OR
+ Variable_name LIKE 'Handler_read_%' OR
+ Variable_name = 'Handler_write' OR
+ Variable_name = 'Handler_update' OR
+ Variable_name = 'Handler_delete') AND Value <> 0;
+--enable_query_log
+
+if ($json) {
+if ($innodb) {
+ if ($no_rows) {
+--replace_regex /"rows": [0-9]+/"rows": "X"/ /"filtered": [0-9.]+/"filtered": "X"/
+ }
+}
+--eval EXPLAIN FORMAT=JSON $query;
+if ($validation) {
+--disable_query_log
+--replace_result $MASTER_MYSOCK MASTER_MYSOCK
+--exec $MYSQL -S $MASTER_MYSOCK -u root -r test -e "EXPLAIN FORMAT=JSON $query;" > $MYSQLTEST_VARDIR/tmp/explain.json
+--replace_regex /[-]*// /FILE.[\/\\:_\.0-9A-Za-z]*/Validation:/
+--exec python $MYSQL_TEST_DIR/suite/opt_trace/validate_json.py $MYSQLTEST_VARDIR/tmp/explain.json
+--remove_file '$MYSQLTEST_VARDIR/tmp/explain.json'
+--enable_query_log
+}
+}
+
+if ($select) {
+FLUSH STATUS;
+FLUSH TABLES;
+if ($innodb) {
+ if ($no_rows) {
+--replace_column 9 X 10 X
+ }
+}
+--eval EXPLAIN EXTENDED $select
+--echo # Status of EXPLAIN EXTENDED "equivalent" SELECT query execution
+--disable_query_log
+SHOW STATUS WHERE (Variable_name LIKE 'Sort%' OR
+ Variable_name LIKE 'Handler_read_%' OR
+ Variable_name = 'Handler_write' OR
+ Variable_name = 'Handler_update' OR
+ Variable_name = 'Handler_delete') AND Value <> 0;
+--enable_query_log
+if ($json) {
+if ($innodb) {
+ if ($no_rows) {
+--replace_regex /"rows": [0-9]+/"rows": "X"/ /"filtered": [0-9.]+/"filtered": "X"/
+ }
+}
+--eval EXPLAIN FORMAT=JSON $select;
+if ($validation) {
+--disable_query_log
+--replace_result $MASTER_MYSOCK MASTER_MYSOCK
+--exec $MYSQL -S $MASTER_MYSOCK -u root -r test -e "EXPLAIN FORMAT=JSON $select;" > $MYSQLTEST_VARDIR/tmp/explain.json
+--replace_regex /[-]*// /FILE.[\/\\:_\.0-9A-Za-z]*/Validation:/
+--exec python $MYSQL_TEST_DIR/suite/opt_trace/validate_json.py $MYSQLTEST_VARDIR/tmp/explain.json
+--remove_file '$MYSQLTEST_VARDIR/tmp/explain.json'
+--enable_query_log
+}
+}
+}
+
+--disable_query_log
+
+if ($select) {
+--eval $select INTO OUTFILE '$MYSQLTEST_VARDIR/tmp/after_explain.txt'
+--diff_files '$MYSQLTEST_VARDIR/tmp/before_explain.txt' '$MYSQLTEST_VARDIR/tmp/after_explain.txt'
+--remove_file '$MYSQLTEST_VARDIR/tmp/before_explain.txt'
+--remove_file '$MYSQLTEST_VARDIR/tmp/after_explain.txt'
+}
+
+FLUSH STATUS;
+FLUSH TABLES;
+if ($select) {
+--disable_result_log
+--eval $select
+--enable_result_log
+--echo # Status of "equivalent" SELECT query execution:
+SHOW STATUS WHERE (Variable_name LIKE 'Sort%' OR
+ Variable_name LIKE 'Handler_read_%' OR
+ Variable_name = 'Handler_write' OR
+ Variable_name = 'Handler_update' OR
+ Variable_name = 'Handler_delete') AND Value <> 0;
+}
+
+FLUSH STATUS;
+FLUSH TABLES;
+--eval $query
+--echo # Status of testing query execution:
+SHOW STATUS WHERE (Variable_name LIKE 'Sort%' OR
+ Variable_name LIKE 'Handler_read_%' OR
+ Variable_name = 'Handler_write' OR
+ Variable_name = 'Handler_update' OR
+ Variable_name = 'Handler_delete') AND Value <> 0;
+
+--let $query=
+--let $select=
+--let $no_rows=
+
+--enable_query_log
+
+--echo
diff --git a/mysql-test/include/fail_start_mysqld.inc b/mysql-test/include/fail_start_mysqld.inc
new file mode 100644
index 00000000000..bb1085b5dd7
--- /dev/null
+++ b/mysql-test/include/fail_start_mysqld.inc
@@ -0,0 +1,18 @@
+# ==== Usage ====
+#
+# [--let $restart_parameters= --innodb-force-recovery=0 --innodb-read-only=1]
+# [--let $mysqld_stub_cmd= $MYSQLD_LAST_CMD]
+# [--let $error_log= $MYSQLTEST_VARDIR/log/mysqld.1.err]
+# --source include/fail_restart_mysqld.inc
+
+# Evaluate the default of $error_log
+if (!$error_log)
+{
+ --let $error_log= $MYSQLTEST_VARDIR/log/mysqld.1.err
+}
+
+--error 1
+--exec $mysqld_stub_cmd $restart_parameters >> $error_log 2>&1
+
+# As the server is stopped
+--disable_reconnect
diff --git a/mysql-test/include/filter_file.inc b/mysql-test/include/filter_file.inc
new file mode 100644
index 00000000000..17c7c1985d7
--- /dev/null
+++ b/mysql-test/include/filter_file.inc
@@ -0,0 +1,145 @@
+# ==== Purpose ====
+#
+# Read the contents of a file, filter it through a perl script, and
+# write it back.
+#
+# This is useful in conjunction with include/write_result_to_file.inc
+# and cat_file or include/read_file_to_var.inc. See
+# e.g. include/show_events.inc for an example.
+#
+# ==== Usage ====
+#
+# --let $input_file= <FILE_NAME>
+# [--let $output_file= <FILE_NAME>]
+# --let $script= <PERL_SCRIPT>
+# [--let $select_columns= <LIST OF NUMBERS>]
+# [--let $pre_script= <PERL_SCRIPT>]
+# [--let $rpl_debug= 1]
+# --source include/filter_file.inc
+#
+# Parameters:
+#
+# $input_file
+# File to read from.
+#
+# $output_file
+# File to write to. If omitted, writes to $input_file.
+#
+# $script
+# This script will be executed once for each line in $input_file.
+#
+# When the script starts, the perl variable $_ will be set to the
+# current row (including the terminating newline). The script can
+# modify $_ in any way it likes, and the result will be appended
+# to $output_file. It is even possible to remove a row by setting
+# $_ to '', or to generate extra rows by appending "\n" to $_.
+#
+# Since mysqltest is incapable of properly escaping dollar
+# characters, you have to replace any '$' in your script by
+# 'DOLLAR' (otherwise mysqltest would try to interpolate parts of
+# your script). filter_file.inc will replace 'DOLLAR' by '$'
+# before evaluating your script.
+#
+# $select_columns
+# For convenience, if you set this to a space-separated list of
+# numbers, it will print only the numbered columns, in the given
+# order.
+#
+# $pre_script
+# This script will be evaluated before starting to iterate over
+# the lines of $input_file. It can be useful if you need some
+# sort of initialization; for example, you can define a subroutine
+# here and call it from $script.
+#
+# $rpl_debug
+# If set, verbose debug info is printed.
+
+--let $include_filename= filter_file.inc
+--source include/begin_include_file.inc
+
+if ($rpl_debug)
+{
+ --echo pre_script='$pre_script'
+ --echo script='$script'
+ --echo select_columns='$select_columns'
+ --echo input_file='$input_file' output_file='$output_file'
+}
+
+--let _FF_PRE_SCRIPT= $pre_script
+--let _FF_SCRIPT= $script
+--let _FF_INPUT_FILE= $input_file
+--let _FF_OUTPUT_FILE= $output_file
+--let _FF_SELECT_COLUMNS= $select_columns
+--let _FF_DEBUG= $rpl_debug
+if (!$output_file)
+{
+ --let _FF_OUTPUT_FILE= $input_file
+}
+perl;
+ my $pre_script = $ENV{'_FF_PRE_SCRIPT'};
+ $pre_script =~ s/DOLLAR/\$/g;
+ my $script = $ENV{'_FF_SCRIPT'};
+ $script =~ s/DOLLAR/\$/g;
+ my $input_file = $ENV{'_FF_INPUT_FILE'};
+ my $output_file = $ENV{'_FF_OUTPUT_FILE'};
+ my $select_columns = $ENV{'_FF_SELECT_COLUMNS'};
+ my $debug = $ENV{'_FF_DEBUG'};
+ if ($select_columns)
+ {
+ chomp($select_columns);
+ $select_columns =~ s/[, ]+/,/g;
+ $script = '
+ chomp;
+ my @cols = split(/\t/, $_);
+ $_ = join("\t", map { $cols[$_ - 1] } ('.$select_columns.'))."\n";
+ ' . $script;
+ }
+ unless ($keep_quotes)
+ {
+ $pre_script = 'my %unquote = ("n"=>"\n","t"=>"\t","\\\\"=>"\\\\");' . $pre_script;
+ $script .= 's{\\\\(.)}{$unquote{$1}}ge;';
+ }
+ if ($debug)
+ {
+ $script = 'print "BEFORE:\'$_\'";' . $script . 'print "AFTER:\'$_\'";'
+ }
+ # Generate a script (perl is faster if we avoid many calls to eval).
+ my $full_script =
+'
+ open FILE, "< $input_file" or die "Error opening $input_file: $!";
+ my $filtered_contents = "";
+ my %column_names = ();
+ '.$pre_script.';
+ while (<FILE>)
+ {
+ chomp;
+ s/\r//g;
+ if (!%column_names)
+ {
+ my $n = 1;
+ %column_names = map { $_ => $n++ } split(/\t/, $_);
+ }
+ else
+ {
+ ' . $script . '
+ }
+ $filtered_contents .= $_."\n";
+ }
+ close FILE or die "Error closing $input_file: $!";
+ open FILE, "> $output_file" or die "Error opening $output_file: $!";
+ binmode FILE;
+ print FILE $filtered_contents or die "Error writing filtered contents to $output_file: $!";
+ close FILE or die "Error closing $output_file: $!";
+ return 0;
+';
+ if ($debug)
+ {
+ print STDOUT "full_script=<<END_OF_SCRIPT\n${full_script}END_OF_SCRIPT\n"
+ }
+ my $eval_ret = eval($full_script);
+ defined($eval_ret) or die "Parse error or 'die' invoked when evaluating perl script '$full_script': $@";
+ $eval_ret == 0 or die "Non-zero exit value $eval_ret from script '$script'";
+EOF
+
+--let $include_filename= filter_file.inc
+--source include/end_include_file.inc
diff --git a/mysql-test/include/function_defaults.inc b/mysql-test/include/function_defaults.inc
new file mode 100644
index 00000000000..cb8e8f86f93
--- /dev/null
+++ b/mysql-test/include/function_defaults.inc
@@ -0,0 +1,1178 @@
+SET TIME_ZONE = "+00:00";
+
+--echo #
+--echo # Test of errors for column data types that dont support function
+--echo # defaults.
+--echo #
+--error ER_INVALID_DEFAULT
+eval CREATE TABLE t1( a BIT DEFAULT $current_timestamp );
+--error ER_INVALID_DEFAULT
+eval CREATE TABLE t1( a TINYINT DEFAULT $current_timestamp );
+--error ER_INVALID_DEFAULT
+eval CREATE TABLE t1( a SMALLINT DEFAULT $current_timestamp );
+--error ER_INVALID_DEFAULT
+eval CREATE TABLE t1( a MEDIUMINT DEFAULT $current_timestamp );
+--error ER_INVALID_DEFAULT
+eval CREATE TABLE t1( a INT DEFAULT $current_timestamp );
+--error ER_INVALID_DEFAULT
+eval CREATE TABLE t1( a BIGINT DEFAULT $current_timestamp );
+--error ER_INVALID_DEFAULT
+eval CREATE TABLE t1( a FLOAT DEFAULT $current_timestamp );
+--error ER_INVALID_DEFAULT
+eval CREATE TABLE t1( a DECIMAL DEFAULT $current_timestamp );
+--error ER_INVALID_DEFAULT
+eval CREATE TABLE t1( a DATE DEFAULT $current_timestamp );
+--error ER_INVALID_DEFAULT
+eval CREATE TABLE t1( a TIME DEFAULT $current_timestamp );
+--error ER_INVALID_DEFAULT
+eval CREATE TABLE t1( a YEAR DEFAULT $current_timestamp );
+
+--error ER_INVALID_ON_UPDATE
+eval CREATE TABLE t1( a BIT ON UPDATE $current_timestamp );
+--error ER_INVALID_ON_UPDATE
+eval CREATE TABLE t1( a TINYINT ON UPDATE $current_timestamp );
+--error ER_INVALID_ON_UPDATE
+eval CREATE TABLE t1( a SMALLINT ON UPDATE $current_timestamp );
+--error ER_INVALID_ON_UPDATE
+eval CREATE TABLE t1( a MEDIUMINT ON UPDATE $current_timestamp );
+--error ER_INVALID_ON_UPDATE
+eval CREATE TABLE t1( a INT ON UPDATE $current_timestamp );
+--error ER_INVALID_ON_UPDATE
+eval CREATE TABLE t1( a BIGINT ON UPDATE $current_timestamp );
+--error ER_INVALID_ON_UPDATE
+eval CREATE TABLE t1( a FLOAT ON UPDATE $current_timestamp );
+--error ER_INVALID_ON_UPDATE
+eval CREATE TABLE t1( a DECIMAL ON UPDATE $current_timestamp );
+--error ER_INVALID_ON_UPDATE
+eval CREATE TABLE t1( a DATE ON UPDATE $current_timestamp );
+--error ER_INVALID_ON_UPDATE
+eval CREATE TABLE t1( a TIME ON UPDATE $current_timestamp );
+--error ER_INVALID_ON_UPDATE
+eval CREATE TABLE t1( a YEAR ON UPDATE $current_timestamp );
+
+--echo #
+--echo # Test that the default clause behaves like NOW() regarding time zones.
+--echo #
+eval CREATE TABLE t1 (
+ a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ b $timestamp NOT NULL DEFAULT $current_timestamp,
+ c $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ d $timestamp NULL,
+ e $datetime DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ f $datetime DEFAULT $current_timestamp,
+ g $datetime ON UPDATE $current_timestamp,
+ h $datetime
+);
+
+--echo # 2011-09-27 14:11:08 UTC
+SET TIMESTAMP = 1317132668.654321;
+SET @old_time_zone = @@TIME_ZONE;
+SET TIME_ZONE = "+05:00";
+
+eval INSERT INTO t1( d, h ) VALUES ( $now, $now );
+SELECT * FROM t1;
+
+--echo # 1989-05-13 01:02:03
+SET TIMESTAMP = 611017323.543212;
+eval UPDATE t1 SET d = $now, h = $now;
+SELECT * FROM t1;
+
+SET TIME_ZONE = @old_time_zone;
+DROP TABLE t1;
+
+--echo #
+--echo # Test of several TIMESTAMP columns with different function defaults.
+--echo #
+eval CREATE TABLE t1 (
+ a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ b $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ c $timestamp NOT NULL DEFAULT $current_timestamp,
+ d $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ e $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ f INT
+);
+
+--echo # 2011-04-19 07:22:02 UTC
+SET TIMESTAMP = 1303197722.534231;
+
+INSERT INTO t1 ( f ) VALUES (1);
+SELECT * FROM t1;
+
+--echo # 2011-04-19 07:23:18 UTC
+SET TIMESTAMP = 1303197798.132435;
+
+UPDATE t1 SET f = 2;
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Test of inserted values out of order.
+--echo #
+eval CREATE TABLE t1 (
+ a INT,
+ b $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ c $timestamp NOT NULL DEFAULT $current_timestamp,
+ d $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ e $timestamp NULL,
+ f $datetime,
+ g $datetime DEFAULT $current_timestamp,
+ h $datetime ON UPDATE $current_timestamp,
+ i $datetime DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ j INT
+);
+
+--echo # 2011-04-19 07:22:02 UTC
+SET TIMESTAMP = 1303197722.534231;
+
+INSERT INTO t1 ( j, a ) VALUES ( 1, 1 );
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Test of ON DUPLICATE KEY UPDATE
+--echo #
+eval CREATE TABLE t1 (
+ a INT PRIMARY KEY,
+ b INT,
+ c $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ d $timestamp NOT NULL DEFAULT $current_timestamp,
+ e $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ f $timestamp NOT NULL DEFAULT '1986-09-27 03:00:00.098765',
+ g $timestamp NULL,
+ h $datetime DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ i $datetime DEFAULT $current_timestamp,
+ j $datetime ON UPDATE $current_timestamp,
+ k $datetime NULL,
+ l $datetime DEFAULT '1986-09-27 03:00:00.098765'
+);
+
+--echo # 1977-12-21 23:00:00 UTC
+SET TIMESTAMP = 251593200.192837;
+INSERT INTO t1(a) VALUES (1) ON DUPLICATE KEY UPDATE b = 2;
+SELECT * FROM t1;
+
+--echo # 1975-05-21 23:00:00 UTC
+SET TIMESTAMP = 169945200.918273;
+INSERT INTO t1(a) VALUES (1) ON DUPLICATE KEY UPDATE b = 2;
+SELECT * FROM t1;
+
+--echo # 1973-08-14 09:11:22 UTC
+SET TIMESTAMP = 114167482.534231;
+INSERT INTO t1(a) VALUES (2) ON DUPLICATE KEY UPDATE b = 2;
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+eval CREATE TABLE t1 ( a INT PRIMARY KEY, b INT, c $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp );
+
+--echo # 2011-04-19 07:23:18 UTC
+SET TIMESTAMP = 1303197798.945156;
+
+INSERT INTO t1 VALUES
+ (1, 0, '2001-01-01 01:01:01.111111'),
+ (2, 0, '2002-02-02 02:02:02.222222'),
+ (3, 0, '2003-03-03 03:03:03.333333');
+SELECT * FROM t1;
+
+UPDATE t1 SET b = 2, c = c WHERE a = 2;
+SELECT * FROM t1;
+
+INSERT INTO t1 (a) VALUES (4);
+SELECT * FROM t1;
+
+UPDATE t1 SET c = '2004-04-04 04:04:04.444444' WHERE a = 4;
+SELECT * FROM t1;
+
+INSERT INTO t1 ( a ) VALUES ( 3 ), ( 5 ) ON DUPLICATE KEY UPDATE b = 3, c = c;
+SELECT * FROM t1;
+
+INSERT INTO t1 (a, c) VALUES
+ (4, '2004-04-04 00:00:00.444444'),
+ (6, '2006-06-06 06:06:06.666666')
+ON DUPLICATE KEY UPDATE b = 4;
+
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+
+--echo #
+--echo # Test of REPLACE INTO executed as UPDATE.
+--echo #
+eval CREATE TABLE t1 (
+ a INT PRIMARY KEY,
+ b $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ c $datetime DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ d $timestamp NOT NULL DEFAULT $current_timestamp,
+ e $datetime DEFAULT $current_timestamp,
+ f $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ g $datetime ON UPDATE $current_timestamp,
+ h $timestamp NULL,
+ i $datetime
+);
+
+--echo # 1970-09-21 09:11:12 UTC
+SET TIMESTAMP = 22756272.163584;
+
+REPLACE INTO t1 ( a ) VALUES ( 1 );
+SELECT * FROM t1;
+
+--echo # 1970-11-10 14:16:17 UTC
+SET TIMESTAMP = 27094577.852954;
+
+
+REPLACE INTO t1 ( a ) VALUES ( 1 );
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+
+--echo #
+--echo # Test of insertion of NULL, DEFAULT and an empty row for DEFAULT
+--echo # CURRENT_TIMESTAMP.
+--echo #
+eval CREATE TABLE t1 (
+ a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ b $datetime DEFAULT $current_timestamp,
+ c INT
+);
+
+--echo # 2011-04-20 09:53:41 UTC
+SET TIMESTAMP = 1303293221.163578;
+
+INSERT INTO t1 VALUES (NULL, NULL, 1), (DEFAULT, DEFAULT, 2);
+INSERT INTO t1 ( a, b, c ) VALUES (NULL, NULL, 3), (DEFAULT, DEFAULT, 4);
+SELECT * FROM t1;
+
+SET TIME_ZONE = "+03:00";
+SELECT * FROM t1;
+SET TIME_ZONE = "+00:00";
+
+DROP TABLE t1;
+
+--echo # 2011-04-20 07:05:39 UTC
+SET TIMESTAMP = 1303283139.195624;
+eval CREATE TABLE t1 (
+ a $timestamp NOT NULL DEFAULT '2010-10-11 12:34:56' ON UPDATE $current_timestamp,
+ b $datetime DEFAULT '2010-10-11 12:34:56'
+);
+
+INSERT INTO t1 VALUES (NULL, NULL), (DEFAULT, DEFAULT);
+INSERT INTO t1 ( a, b ) VALUES (NULL, NULL), (DEFAULT, DEFAULT);
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+--echo # 2011-04-20 09:53:41 UTC
+SET TIMESTAMP = 1303293221.136952;
+
+eval CREATE TABLE t1 (
+a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+b $timestamp NOT NULL DEFAULT $current_timestamp,
+c $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+d $timestamp NOT NULL DEFAULT '1986-09-27 03:00:00.098765',
+e $timestamp NULL,
+f $datetime DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+g $datetime DEFAULT $current_timestamp,
+h $datetime ON UPDATE $current_timestamp,
+i $datetime NULL,
+j $datetime DEFAULT '1986-09-27 03:00:00.098765'
+);
+
+INSERT INTO t1 VALUES ();
+
+INSERT INTO t1 SELECT NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL;
+
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Test of multiple-table UPDATE for DEFAULT CURRENT_TIMESTAMP
+--echo #
+eval CREATE TABLE t1 (
+ a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ b $datetime DEFAULT $current_timestamp,
+ c INT
+);
+
+INSERT INTO t1 ( c ) VALUES (1);
+SELECT * FROM t1;
+
+--echo # 2011-04-20 17:06:13 UTC
+SET TIMESTAMP = 1303311973.163587;
+
+UPDATE t1 t11, t1 t12 SET t11.c = 1;
+SELECT * FROM t1;
+
+UPDATE t1 t11, t1 t12 SET t11.c = 2;
+
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+eval CREATE TABLE t1 (
+ a $timestamp NOT NULL DEFAULT $current_timestamp,
+ b $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ c $datetime DEFAULT $current_timestamp,
+ d $datetime ON UPDATE $current_timestamp,
+ e INT
+);
+
+eval CREATE TABLE t2 (
+ f INT,
+ g $datetime ON UPDATE $current_timestamp,
+ h $datetime DEFAULT $current_timestamp,
+ i $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ j $timestamp NOT NULL DEFAULT $current_timestamp
+);
+
+--echo # 1995-03-11 00:02:03 UTC
+SET TIMESTAMP = 794880123.195676;
+
+INSERT INTO t1 ( e ) VALUES ( 1 ), ( 2 );
+
+INSERT INTO t2 ( f ) VALUES ( 1 ), ( 2 );
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+--echo # 1980-12-13 02:02:01 UTC
+SET TIMESTAMP = 345520921.196755;
+
+UPDATE t1, t2 SET t1.e = 3, t2.f = 4;
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Test of multiple table update with temporary table and on the fly.
+--echo #
+eval CREATE TABLE t1 (
+ a $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ b $datetime ON UPDATE $current_timestamp,
+ c INT,
+ d INT
+);
+
+eval CREATE TABLE t2 (
+ a $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ b $datetime ON UPDATE $current_timestamp,
+ c INT KEY,
+ d INT
+);
+
+INSERT INTO t1 ( c ) VALUES (1), (2);
+INSERT INTO t2 ( c ) VALUES (1), (2);
+
+--echo # Test of multiple table update done on the fly
+--echo # 2011-04-20 15:06:13 UTC
+SET TIMESTAMP = 1303311973.194685;
+UPDATE t1 JOIN t2 USING ( c ) SET t2.d = 1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+--echo # Test of multiple table update done with temporary table.
+--echo # 1979-01-15 03:02:01
+SET TIMESTAMP = 285213721.134679;
+UPDATE t1 JOIN t2 USING ( c ) SET t1.d = 1;
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+DROP TABLE t1, t2;
+
+
+--echo #
+--echo # Test of ON UPDATE CURRENT_TIMESTAMP.
+--echo #
+eval CREATE TABLE t1 (
+ a $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ b $datetime ON UPDATE $current_timestamp,
+ c INT
+);
+
+--echo # 2011-04-20 09:53:41 UTC
+SET TIMESTAMP = 1303293221.794613;
+
+INSERT INTO t1 ( c ) VALUES ( 1 );
+SELECT * FROM t1;
+
+UPDATE t1 SET c = 1;
+SELECT * FROM t1;
+
+UPDATE t1 SET c = 2;
+SELECT * FROM t1;
+
+--echo #
+--echo # Test that ON UPDATE CURRENT_TIMESTAMP works after non-changing UPDATE.
+--echo #
+
+--echo # 2011-04-20 09:54:13 UTC
+SET TIMESTAMP = 1303293253.794613;
+
+UPDATE t1 SET c = 2, b = '2011-04-20 09:53:41.794613';
+SELECT * FROM t1;
+
+UPDATE t1 SET c = 3;
+SELECT * FROM t1;
+
+--echo #
+--echo # Test of multiple-table UPDATE for ON UPDATE CURRENT_TIMESTAMP
+--echo #
+--echo # 2011-04-20 15:06:13 UTC
+SET TIMESTAMP = 1303311973.534231;
+
+UPDATE t1 t11, t1 t12 SET t11.c = 3;
+SELECT * FROM t1;
+
+UPDATE t1 t11, t1 t12 SET t11.c = 2;
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Test of a multiple-table update where only one table is updated and
+--echo # the updated table has a primary key.
+--echo #
+eval CREATE TABLE t1 ( a INT, b INT, PRIMARY KEY (a) );
+INSERT INTO t1 VALUES (1, 1),(2, 2),(3, 3),(4, 4);
+
+eval CREATE TABLE t2 ( a INT, b INT );
+INSERT INTO t2 VALUES (1, 1),(2, 2),(3, 3),(4, 4),(5, 5);
+
+UPDATE t1, t2 SET t1.b = 100 WHERE t1.a = t2.a;
+
+SELECT * FROM t1;
+SELECT * FROM t2;
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Test of ALTER TABLE, reordering columns.
+--echo #
+eval CREATE TABLE t1 ( a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp, b INT );eval ALTER TABLE t1 MODIFY a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp AFTER b;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+eval CREATE TABLE t1 ( a INT, b $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp, c $timestamp NULL );eval ALTER TABLE t1 MODIFY b $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp FIRST;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+eval CREATE TABLE t1 ( a INT, b $timestamp NULL );eval ALTER TABLE t1 MODIFY b $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp FIRST;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+eval CREATE TABLE t1 ( a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp, b $timestamp NULL );eval ALTER TABLE t1 MODIFY a $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER b;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+eval CREATE TABLE t1 ( a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp, b $timestamp NULL );eval ALTER TABLE t1 MODIFY a $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER b;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+eval CREATE TABLE t1 ( a $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $now, b INT, c $timestamp NULL );
+SHOW CREATE TABLE t1;eval ALTER TABLE t1 MODIFY a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp AFTER b;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+eval CREATE TABLE t1 ( a $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $now, b INT, c $timestamp NULL );eval ALTER TABLE t1 MODIFY c $timestamp NULL FIRST;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+eval CREATE TABLE t1 ( a $timestamp NOT NULL DEFAULT $now ON UPDATE $current_timestamp, b INT, c $timestamp NULL );
+SHOW CREATE TABLE t1;eval ALTER TABLE t1 MODIFY a $timestamp NOT NULL DEFAULT $now ON UPDATE $current_timestamp AFTER b;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+eval CREATE TABLE t1 ( a $timestamp NOT NULL DEFAULT $now ON UPDATE $current_timestamp, b INT, c $timestamp NULL );eval ALTER TABLE t1 MODIFY c $timestamp NULL FIRST;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+
+--echo #
+--echo # Test of ALTER TABLE, adding columns.
+--echo #
+eval CREATE TABLE t1 ( a INT );
+eval ALTER TABLE t1 ADD COLUMN b $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp;
+SHOW CREATE TABLE t1;
+DROP TABLE t1;
+
+--echo #
+--echo # Test of INSERT SELECT.
+--echo #
+eval CREATE TABLE t1 (
+ a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ b $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ c $datetime DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ d $datetime DEFAULT $current_timestamp ON UPDATE $current_timestamp
+);
+
+eval CREATE TABLE t2 (
+ placeholder1 INT,
+ placeholder2 INT,
+ placeholder3 INT,
+ placeholder4 INT,
+ a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ b $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ c $datetime,
+ d $datetime
+);
+
+--echo # 1977-08-16 15:30:01 UTC
+SET TIMESTAMP = 240589801.654312;
+
+INSERT INTO t2 (a, b, c, d) VALUES (
+ '1977-08-16 15:30:01.123456',
+ '1977-08-16 15:30:01.234567',
+ '1977-08-16 15:30:01.345678',
+ '1977-08-16 15:30:01.456789'
+);
+
+--echo # 1986-09-27 01:00:00 UTC
+SET TIMESTAMP = 528166800.132435;
+
+INSERT INTO t1 ( a, c ) SELECT a, c FROM t2;
+
+SELECT * FROM t1;
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Test of CREATE TABLE SELECT.
+--echo #
+--echo # We test that the columns of the source table are not used to determine
+--echo # function defaults for the receiving table.
+--echo #
+
+--echo # 1970-04-11 20:13:57 UTC
+SET TIMESTAMP = 8712837.657898;
+eval CREATE TABLE t1 (
+ a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ b $timestamp NOT NULL DEFAULT $current_timestamp,
+ c $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ d $timestamp NOT NULL DEFAULT '1986-09-27 03:00:00.098765',
+ e $timestamp NULL,
+ f $datetime DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ g $datetime DEFAULT $current_timestamp,
+ h $datetime ON UPDATE $current_timestamp,
+ i $datetime NULL,
+ j $datetime DEFAULT '1986-09-27 03:00:00.098765'
+);
+
+INSERT INTO t1 VALUES ();
+
+--echo # 1971-01-31 21:13:57 UTC
+SET TIMESTAMP = 34200837.164937;
+
+eval CREATE TABLE t2 SELECT a FROM t1; SHOW CREATE TABLE t2; SELECT * FROM t2;
+eval CREATE TABLE t3 SELECT b FROM t1; SHOW CREATE TABLE t3; SELECT * FROM t3;
+eval CREATE TABLE t4 SELECT c FROM t1; SHOW CREATE TABLE t4; SELECT * FROM t4;
+eval CREATE TABLE t5 SELECT d FROM t1; SHOW CREATE TABLE t5; SELECT * FROM t5;
+eval CREATE TABLE t6 SELECT e FROM t1; SHOW CREATE TABLE t6; SELECT * FROM t6;
+eval CREATE TABLE t7 SELECT f FROM t1; SHOW CREATE TABLE t7; SELECT * FROM t7;
+eval CREATE TABLE t8 SELECT g FROM t1; SHOW CREATE TABLE t8; SELECT * FROM t8;
+eval CREATE TABLE t9 SELECT h FROM t1; SHOW CREATE TABLE t9; SELECT * FROM t9;
+eval CREATE TABLE t10 SELECT i FROM t1; SHOW CREATE TABLE t10; SELECT * FROM t10;
+eval CREATE TABLE t11 SELECT j FROM t1; SHOW CREATE TABLE t11; SELECT * FROM t11;
+
+eval CREATE TABLE t12 (
+ k $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ l $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ m $timestamp NOT NULL DEFAULT $current_timestamp,
+ n $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ o $timestamp NOT NULL DEFAULT '1986-09-27 03:00:00.098765',
+ p $timestamp NULL,
+ q $datetime DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ r $datetime DEFAULT $current_timestamp,
+ s $datetime ON UPDATE $current_timestamp,
+ t $datetime NULL,
+ u $datetime DEFAULT '1986-09-27 03:00:00.098765'
+)
+SELECT * FROM t1;
+
+SHOW CREATE TABLE t12;
+
+DROP TABLE t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12;
+
+--echo # 1970-04-11 20:13:57 UTC
+SET TIMESTAMP = 8712837.164953;
+eval CREATE TABLE t1 (
+ a $datetime DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ b $datetime DEFAULT $current_timestamp,
+ c $datetime ON UPDATE $current_timestamp,
+ d $datetime NULL,
+ e $datetime DEFAULT '1986-09-27 03:00:00.098765'
+);
+
+INSERT INTO t1 VALUES ();
+
+--echo # 1971-01-31 20:13:57 UTC
+SET TIMESTAMP = 34200837.915736;
+
+eval CREATE TABLE t2 SELECT a FROM t1;
+SHOW CREATE TABLE t2;
+SELECT * FROM t2;
+
+eval CREATE TABLE t3 SELECT b FROM t1;
+SHOW CREATE TABLE t3;
+SELECT * FROM t3;
+
+eval CREATE TABLE t4 SELECT c FROM t1;
+SHOW CREATE TABLE t4;
+SELECT * FROM t4;
+
+eval CREATE TABLE t5 SELECT d FROM t1;
+SHOW CREATE TABLE t5;
+SELECT * FROM t5;
+
+eval CREATE TABLE t6 SELECT e FROM t1;
+SHOW CREATE TABLE t6;
+SELECT * FROM t6;
+
+DROP TABLE t1, t2, t3, t4, t5, t6;
+
+--echo #
+--echo # Test of a CREATE TABLE SELECT that also declared columns. In this case
+--echo # the function default should be de-activated during the execution of the
+--echo # CREATE TABLE statement.
+--echo #
+--echo # 1970-01-01 03:16:40
+SET TIMESTAMP = 1000.987654;
+eval CREATE TABLE t1 ( a INT );
+INSERT INTO t1 VALUES ( 1 ), ( 2 );
+
+eval CREATE TABLE t2 ( b $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp) SELECT a FROM t1;
+
+SHOW CREATE TABLE t2;
+SET TIMESTAMP = 2000.876543;
+INSERT INTO t2( a ) VALUES ( 3 );
+SELECT * FROM t2;
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Test of updating a view.
+--echo #
+eval CREATE TABLE t1 ( a INT, b $datetime DEFAULT $current_timestamp );
+eval CREATE TABLE t2 ( a INT, b $datetime ON UPDATE $current_timestamp );
+
+eval CREATE VIEW v1 AS SELECT * FROM t1;
+SHOW CREATE VIEW v1;
+
+eval CREATE VIEW v2 AS SELECT * FROM t2;
+SHOW CREATE VIEW v2;
+
+--echo # 1971-01-31 21:13:57 UTC
+SET TIMESTAMP = 34200837.348564;
+
+INSERT INTO v1 ( a ) VALUES ( 1 );
+INSERT INTO v2 ( a ) VALUES ( 1 );
+
+SELECT * FROM t1;
+SELECT * FROM v1;
+
+SELECT * FROM t2;
+SELECT * FROM v2;
+
+--echo # 1970-04-11 20:13:57 UTC
+SET TIMESTAMP = 8712837.567332;
+UPDATE v1 SET a = 2;
+UPDATE v2 SET a = 2;
+
+SELECT * FROM t1;
+SELECT * FROM v1;
+
+SELECT * FROM t2;
+SELECT * FROM v2;
+
+DROP VIEW v1, v2;
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Test with stored procedures.
+--echo #
+eval CREATE TABLE t1 (
+ a INT,
+ b $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ c $timestamp NOT NULL DEFAULT $current_timestamp,
+ d $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ e $timestamp NULL,
+ f $datetime DEFAULT $current_timestamp,
+ g $datetime ON UPDATE $current_timestamp
+);
+CREATE PROCEDURE p1() INSERT INTO test.t1( a ) VALUES ( 1 );
+CREATE PROCEDURE p2() UPDATE t1 SET a = 2 WHERE a = 1;
+
+--echo # 1971-01-31 20:13:57 UTC
+SET TIMESTAMP = 34200837.876544;
+CALL p1();
+SELECT * FROM t1;
+
+--echo # 1970-04-11 21:13:57 UTC
+SET TIMESTAMP = 8712837.143546;
+CALL p2();
+SELECT * FROM t1;
+
+DROP PROCEDURE p1;
+DROP PROCEDURE p2;
+DROP TABLE t1;
+
+--echo #
+--echo # Test with triggers.
+--echo #
+eval CREATE TABLE t1 (
+ a INT,
+ b $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ c $timestamp NOT NULL DEFAULT $current_timestamp,
+ d $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ e $timestamp NULL,
+ f $datetime,
+ g $datetime DEFAULT $current_timestamp,
+ h $datetime ON UPDATE $current_timestamp,
+ i $datetime DEFAULT $current_timestamp ON UPDATE $current_timestamp
+);
+
+eval CREATE TABLE t2 ( a INT );
+
+DELIMITER |;
+eval CREATE TRIGGER t2_trg BEFORE INSERT ON t2 FOR EACH ROW
+BEGIN
+ INSERT INTO t1 ( a ) VALUES ( 1 );
+END|
+DELIMITER ;|
+
+--echo # 1971-01-31 21:13:57 UTC
+SET TIMESTAMP = 34200837.978675;
+
+INSERT INTO t2 ( a ) VALUES ( 1 );
+SELECT * FROM t1;
+
+DROP TRIGGER t2_trg;
+
+DELIMITER |;
+eval CREATE TRIGGER t2_trg BEFORE INSERT ON t2 FOR EACH ROW
+BEGIN
+ UPDATE t1 SET a = 2;
+END|
+DELIMITER ;|
+
+--echo # 1970-04-11 21:13:57 UTC
+SET TIMESTAMP = 8712837.456789;
+
+INSERT INTO t2 ( a ) VALUES ( 1 );
+SELECT * FROM t1;
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Test where the assignment target is not a column.
+--echo #
+eval CREATE TABLE t1 ( a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp );
+eval CREATE TABLE t2 ( a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp );
+eval CREATE TABLE t3 ( a $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp );
+eval CREATE TABLE t4 ( a $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp );
+
+eval CREATE VIEW v1 AS SELECT a COLLATE latin1_german1_ci AS b FROM t1;
+eval CREATE VIEW v2 ( b ) AS SELECT a COLLATE latin1_german1_ci FROM t2;
+eval CREATE VIEW v3 AS SELECT a COLLATE latin1_german1_ci AS b FROM t3;
+eval CREATE VIEW v4 ( b ) AS SELECT a COLLATE latin1_german1_ci FROM t4;
+
+INSERT INTO v1 ( b ) VALUES ( '2007-10-24 00:03:34.010203' );
+SELECT a FROM t1;
+
+INSERT INTO v2 ( b ) VALUES ( '2007-10-24 00:03:34.010203' );
+SELECT a FROM t2;
+
+INSERT INTO t3 VALUES ();
+UPDATE v3 SET b = '2007-10-24 00:03:34.010203';
+SELECT a FROM t3;
+
+INSERT INTO t4 VALUES ();
+UPDATE v4 SET b = '2007-10-24 00:03:34.010203';
+SELECT a FROM t4;
+
+DROP VIEW v1, v2, v3, v4;
+DROP TABLE t1, t2, t3, t4;
+
+--echo #
+--echo # Test of LOAD DATA/XML INFILE
+--echo # This tests behavior of function defaults for TIMESTAMP and DATETIME
+--echo # columns. during LOAD ... INFILE.
+--echo # As can be seen here, a TIMESTAMP column with only ON UPDATE
+--echo # CURRENT_TIMESTAMP will still have CURRENT_TIMESTAMP inserted on LOAD
+--echo # ... INFILE if the value is missing. For DATETIME columns a NULL value
+--echo # is inserted instead.
+--echo #
+
+eval CREATE TABLE t1 (
+ a INT,
+ b $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ c $timestamp NOT NULL DEFAULT $current_timestamp,
+ d $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ e $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ f $datetime,
+ g $datetime DEFAULT $current_timestamp,
+ h $datetime ON UPDATE $current_timestamp,
+ i $datetime DEFAULT $current_timestamp ON UPDATE $current_timestamp
+);
+
+eval CREATE TABLE t2 (
+ a $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ b $timestamp NOT NULL DEFAULT $current_timestamp,
+ c $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $current_timestamp,
+ d $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ e $datetime NOT NULL,
+ f $datetime NOT NULL DEFAULT '1977-01-02 12:13:14',
+ g $datetime DEFAULT $current_timestamp NOT NULL,
+ h $datetime ON UPDATE $current_timestamp NOT NULL,
+ i $datetime DEFAULT $current_timestamp ON UPDATE $current_timestamp NOT NULL
+);
+
+SELECT 1 INTO OUTFILE 't3.dat' FROM dual;
+
+SELECT NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+INTO OUTFILE 't4.dat'
+FROM dual;
+
+SELECT 1, 2 INTO OUTFILE 't5.dat' FROM dual;
+
+--echo # Mon Aug 1 15:11:19 2011 UTC
+SET TIMESTAMP = 1312211479.918273;
+
+LOAD DATA INFILE 't3.dat' INTO TABLE t1;
+--query_vertical SELECT * FROM t1
+
+LOAD DATA INFILE 't4.dat' INTO TABLE t2;
+SELECT a FROM t2;
+SELECT b FROM t2;
+SELECT c FROM t2;
+SELECT d FROM t2;
+--echo # As shown here, supplying a NULL value to a non-nullable
+--echo # column with no default value results in the zero date.
+SELECT e FROM t2;
+--echo # As shown here, supplying a NULL value to a non-nullable column with a
+--echo # default value results in the zero date.
+SELECT f FROM t2;
+--echo # As shown here, supplying a NULL value to a non-nullable column with a
+--echo # default function results in the zero date.
+SELECT g FROM t2;
+--echo # As shown here, supplying a NULL value to a non-nullable DATETIME ON
+--echo # UPDATE CURRENT_TIMESTAMP column with no default value results in the
+--echo # zero date.
+SELECT h FROM t2;
+SELECT i FROM t2;
+
+DELETE FROM t1;
+DELETE FROM t2;
+
+--echo # Read t3 file into t1
+--echo # The syntax will cause a different code path to be taken
+--echo # (read_fixed_length()) than under the LOAD ... INTO TABLE t1 command
+--echo # above. The code in this path is copy-pasted code from the path taken
+--echo # under the syntax used in the previous LOAD command.
+LOAD DATA INFILE 't3.dat' INTO TABLE t1
+FIELDS TERMINATED BY '' ENCLOSED BY '';
+
+SELECT b FROM t1;
+SELECT c FROM t1;
+SELECT d FROM t1;
+SELECT e FROM t1;
+--echo # Yes, a missing field cannot be NULL using this syntax, so it will
+--echo # zero date instead. Says a comment in read_fixed_length() : "No fields
+--echo # specified in fields_vars list can be NULL in this format."
+--echo # It appears to be by design. This is inconsistent with LOAD DATA INFILE
+--echo # syntax in previous test.
+SELECT f FROM t1;
+SELECT g FROM t1;
+--echo # See comment above "SELECT f FROM f1".
+SELECT h FROM t1;
+SELECT i FROM t1;
+DELETE FROM t1;
+
+LOAD DATA INFILE 't5.dat' INTO TABLE t1 ( a, @dummy );
+SELECT * FROM t1;
+SELECT @dummy;
+DELETE FROM t1;
+
+LOAD DATA INFILE 't3.dat' INTO TABLE t1 ( a ) SET c = '2005-06-06 08:09:10';
+SELECT * FROM t1;
+DELETE FROM t1;
+
+LOAD DATA INFILE 't3.dat' INTO TABLE t1 ( a ) SET g = '2005-06-06 08:09:10';
+SELECT * FROM t1;
+DELETE FROM t1;
+
+--echo # Load a static XML file
+LOAD XML INFILE '../../std_data/onerow.xml' INTO TABLE t1
+ROWS IDENTIFIED BY '<row>';
+
+--echo Missing tags are treated as NULL
+--query_vertical SELECT * FROM t1
+
+DROP TABLE t1, t2;
+
+let $MYSQLD_DATADIR= `select @@datadir`;
+remove_file $MYSQLD_DATADIR/test/t3.dat;
+remove_file $MYSQLD_DATADIR/test/t4.dat;
+remove_file $MYSQLD_DATADIR/test/t5.dat;
+
+
+--echo #
+--echo # Similar LOAD DATA tests in another form
+--echo #
+--echo # All of this test portion has been run on a pre-WL5874 trunk
+--echo # (except that like_b and like_c didn't exist) and all result
+--echo # differences are a bug.
+--echo # Regarding like_b its definition is the same as b's except
+--echo # that the constant default is replaced with a function
+--echo # default. Our expectation is that like_b would behave
+--echo # like b: if b is set to NULL, or set to 0000-00-00, or set to
+--echo # its default, then the same should apply to like_b. Same for
+--echo # like_c vs c.
+
+--echo # Mon Aug 1 15:11:19 2011 UTC
+SET TIMESTAMP = 1312211479.089786;
+
+SELECT 1 INTO OUTFILE "file1.dat" FROM dual;
+SELECT NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ INTO OUTFILE "file2.dat" FROM dual;
+
+--echo # Too short row
+
+eval
+CREATE TABLE t1 (
+ dummy INT,
+ a $datetime NULL DEFAULT NULL,
+ b $datetime NULL DEFAULT "2011-11-18",
+ like_b $datetime NULL DEFAULT $current_timestamp,
+ c $datetime NOT NULL DEFAULT "2011-11-18",
+ like_c $datetime NOT NULL DEFAULT $current_timestamp,
+ d $timestamp NULL DEFAULT "2011-05-03" ON UPDATE $current_timestamp,
+ e $timestamp NOT NULL DEFAULT "2011-05-03",
+ f $timestamp NOT NULL DEFAULT $current_timestamp,
+ g $timestamp NULL DEFAULT NULL,
+ h INT NULL,
+ i INT NOT NULL DEFAULT 42
+);
+
+--echo # There is no promotion
+SHOW CREATE TABLE t1;
+
+LOAD DATA INFILE "file1.dat" INTO table t1;
+
+--echo # It is strange that "like_b" gets NULL when "b" gets 0. But
+--echo # this is consistent with how "a" gets NULL when "b" gets 0,
+--echo # with how "g" gets NULL when "d" gets 0, and with how "h" gets
+--echo # NULL when "i" gets 0. Looks like "DEFAULT
+--echo # <non-NULL-constant>" is changed to 0, whereas DEFAULT NULL
+--echo # and DEFAULT NOW are changed to NULL.
+--query_vertical SELECT * FROM t1
+delete from t1;
+
+alter table t1
+modify f TIMESTAMP NULL default CURRENT_TIMESTAMP;
+
+--echo # There is no promotion
+SHOW CREATE TABLE t1;
+
+LOAD DATA INFILE "file1.dat" INTO table t1;
+
+--query_vertical SELECT * FROM t1
+delete from t1;
+
+drop table t1;
+
+--echo # Conclusion derived from trunk's results:
+--echo # DATETIME DEFAULT <non-NULL-constant> (b,c) gets 0000-00-00,
+--echo # DATETIME DEFAULT NULL (a) gets NULL,
+--echo # TIMESTAMP NULL DEFAULT <non-NULL-constant> (d) gets 0000-00-00,
+--echo # TIMESTAMP NULL DEFAULT NULL (g) gets NULL,
+--echo # TIMESTAMP NULL DEFAULT NOW (f after ALTER) gets NULL,
+--echo # TIMESTAMP NOT NULL (f before ALTER, e) gets NOW.
+
+--echo ### Loading NULL ###
+
+eval
+CREATE TABLE t1 (
+ dummy INT,
+ a $datetime NULL DEFAULT NULL,
+ b $datetime NULL DEFAULT "2011-11-18",
+ like_b $datetime NULL DEFAULT $current_timestamp,
+ c $datetime NOT NULL DEFAULT "2011-11-18",
+ like_c $datetime NOT NULL DEFAULT $current_timestamp,
+ d $timestamp NULL DEFAULT "2011-05-03" ON UPDATE $current_timestamp,
+ e $timestamp NOT NULL DEFAULT "2011-05-03",
+ f $timestamp NOT NULL DEFAULT $current_timestamp,
+ g $timestamp NULL DEFAULT NULL,
+ h INT NULL,
+ i INT NOT NULL DEFAULT 42
+);
+
+--echo # There is no promotion
+SHOW CREATE TABLE t1;
+
+LOAD DATA INFILE "file2.dat" INTO table t1;
+
+--query_vertical SELECT * FROM t1
+delete from t1;
+
+alter table t1
+modify f TIMESTAMP NULL default CURRENT_TIMESTAMP;
+
+--echo # There is no promotion
+SHOW CREATE TABLE t1;
+
+LOAD DATA INFILE "file2.dat" INTO table t1;
+
+--query_vertical SELECT * FROM t1
+delete from t1;
+
+--echo # Conclusion derived from trunk's results:
+--echo # DATETIME NULL (a,b) gets NULL,
+--echo # DATETIME NOT NULL (c) gets 0000-00-00,
+--echo # TIMESTAMP NULL (d,f,g) gets NULL,
+--echo # TIMESTAMP NOT NULL (e) gets NOW.
+
+drop table t1;
+remove_file $MYSQLD_DATADIR/test/file1.dat;
+remove_file $MYSQLD_DATADIR/test/file2.dat;
+
+--echo #
+--echo # Test of updatable views with check options. The option can be violated
+--echo # using ON UPDATE updates which is very strange as this offers a loophole
+--echo # in this integrity check.
+--echo #
+SET TIME_ZONE = "+03:00";
+--echo # 1970-01-01 03:16:40
+SET TIMESTAMP = 1000.123456;
+
+eval CREATE TABLE t1 ( a INT, b $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp);
+
+SHOW CREATE TABLE t1;
+
+INSERT INTO t1 ( a ) VALUES ( 1 );
+
+SELECT * FROM t1;
+
+eval CREATE VIEW v1 AS SELECT * FROM t1 WHERE b <= '1970-01-01 03:16:40.123456'
+WITH CHECK OPTION;
+
+SELECT * FROM v1;
+
+--echo # 1970-01-01 03:33:20
+SET TIMESTAMP = 2000.000234;
+
+--error ER_VIEW_CHECK_FAILED
+UPDATE v1 SET a = 2;
+SELECT * FROM t1;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+eval CREATE TABLE t1 (
+ a $timestamp NOT NULL DEFAULT '1973-08-14 09:11:22.089786' ON UPDATE $current_timestamp,
+ c INT KEY
+);
+--echo # 1973-08-14 09:11:22 UTC
+SET TIMESTAMP = 114167482.534231;
+INSERT INTO t1 ( c ) VALUES ( 1 );
+
+eval CREATE VIEW v1 AS
+SELECT *
+FROM t1
+WHERE a >= '1973-08-14 09:11:22'
+WITH LOCAL CHECK OPTION;
+
+SELECT * FROM v1;
+
+SET TIMESTAMP = 1.126789;
+
+--error ER_VIEW_CHECK_FAILED
+INSERT INTO v1 ( c ) VALUES ( 1 ) ON DUPLICATE KEY UPDATE c = 2;
+
+SELECT * FROM v1;
+
+DROP VIEW v1;
+DROP TABLE t1;
+
+--echo #
+--echo # Bug 13095459 - MULTI-TABLE UPDATE MODIFIES A ROW TWICE
+--echo #
+eval CREATE TABLE t1 (
+ a INT,
+ b INT,
+ ts $timestamp NOT NULL DEFAULT $current_timestamp ON UPDATE $current_timestamp,
+ PRIMARY KEY ( a, ts )
+);
+INSERT INTO t1( a, b, ts ) VALUES ( 1, 0, '2000-09-28 17:44:34' );
+
+eval CREATE TABLE t2 ( a INT );
+INSERT INTO t2 VALUES ( 1 );
+
+UPDATE t1 STRAIGHT_JOIN t2
+SET t1.b = t1.b + 1
+WHERE t1.a = 1 AND t1.ts >= '2000-09-28 00:00:00';
+
+SELECT b FROM t1;
+
+DROP TABLE t1, t2;
+
+--echo #
+--echo # Bug#11745578: 17392: ALTER TABLE ADD COLUMN TIMESTAMP DEFAULT
+--echo # CURRENT_TIMESTAMP INSERTS ZERO
+--echo #
+SET timestamp = 1000;
+
+CREATE TABLE t1 ( b INT );
+INSERT INTO t1 VALUES (1);
+
+eval ALTER TABLE t1 ADD COLUMN a6 $datetime DEFAULT $now ON UPDATE $now FIRST;
+eval ALTER TABLE t1 ADD COLUMN a5 $datetime DEFAULT $now FIRST;
+eval ALTER TABLE t1 ADD COLUMN a4 $datetime ON UPDATE $now FIRST;
+
+eval ALTER TABLE t1 ADD COLUMN a3 $timestamp NOT NULL DEFAULT $now ON UPDATE $now FIRST;
+eval ALTER TABLE t1 ADD COLUMN a2 $timestamp NOT NULL DEFAULT $now FIRST;
+eval ALTER TABLE t1 ADD COLUMN a1 $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $now FIRST;
+
+eval ALTER TABLE t1 ADD COLUMN c1 $timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE $now AFTER b;
+eval ALTER TABLE t1 ADD COLUMN c2 $timestamp NOT NULL DEFAULT $now AFTER c1;
+eval ALTER TABLE t1 ADD COLUMN c3 $timestamp NOT NULL DEFAULT $now ON UPDATE $now AFTER c2;
+
+eval ALTER TABLE t1 ADD COLUMN c4 $datetime ON UPDATE $now AFTER c3;
+eval ALTER TABLE t1 ADD COLUMN c5 $datetime DEFAULT $now AFTER c4;
+eval ALTER TABLE t1 ADD COLUMN c6 $datetime DEFAULT $now ON UPDATE $now AFTER c5;
+
+query_vertical SELECT * FROM t1;
+DROP TABLE t1;
+
+
+eval CREATE TABLE t1 ( a $timestamp NOT NULL DEFAULT $now ON UPDATE $current_timestamp, b $datetime DEFAULT $now );
+INSERT INTO t1 VALUES ();
+
+SET timestamp = 1000000000;
+
+ALTER TABLE t1 MODIFY COLUMN a TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3);
+ALTER TABLE t1 MODIFY COLUMN b DATETIME(3) DEFAULT CURRENT_TIMESTAMP(3);
+
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+
+eval CREATE TABLE t1 (
+ a $timestamp NOT NULL DEFAULT '1999-12-01 11:22:33' ON UPDATE $current_timestamp,
+ b $datetime DEFAULT '1999-12-01 11:22:33'
+);
+INSERT INTO t1 VALUES ();
+
+eval ALTER TABLE t1 MODIFY COLUMN a $timestamp DEFAULT $now;
+eval ALTER TABLE t1 MODIFY COLUMN b $datetime DEFAULT $now;
+INSERT INTO t1 VALUES ();
+
+SELECT * FROM t1;
+
+DROP TABLE t1;
diff --git a/mysql-test/include/function_defaults_notembedded.inc b/mysql-test/include/function_defaults_notembedded.inc
new file mode 100644
index 00000000000..077470125f4
--- /dev/null
+++ b/mysql-test/include/function_defaults_notembedded.inc
@@ -0,0 +1,95 @@
+SET TIME_ZONE = "+00:00";
+
+--echo #
+--echo # Test of INSERT DELAYED ... SET ...
+--echo #
+
+--echo # 2011-04-19 08:02:40 UTC
+SET TIMESTAMP = 1303200160.123456;
+
+eval CREATE TABLE t1 ( a INT, b $timestamp NOT NULL DEFAULT CURRENT_$timestamp ON UPDATE CURRENT_$timestamp);
+
+INSERT DELAYED INTO t1 SET a = 1;
+FLUSH TABLE t1;
+
+SELECT * FROM t1;
+SELECT * FROM t1 WHERE b = 0;
+
+INSERT DELAYED INTO t1 SET a = 2, b = '1980-01-02 10:20:30.405060';
+FLUSH TABLE t1;
+
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Test of INSERT DELAYED ... VALUES ...
+--echo #
+
+--echo # 2011-04-19 08:04:01 UTC
+SET TIMESTAMP = 1303200241.234567;
+
+eval CREATE TABLE t1 ( a INT, b $timestamp NOT NULL DEFAULT CURRENT_$timestamp ON UPDATE CURRENT_$timestamp);
+
+INSERT DELAYED INTO t1 ( a ) VALUES (1);
+FLUSH TABLE t1;
+SELECT * FROM t1;
+
+INSERT DELAYED INTO t1 VALUES (2, '1977-12-19 12:34:56.789123');
+FLUSH TABLE t1;
+SELECT * FROM t1;
+
+DROP TABLE t1;
+
+--echo #
+--echo # Test of a delayed insert handler servicing two insert operations
+--echo # with different sets of active defaults.
+--echo #
+eval CREATE TABLE t1 ( a INT, b $timestamp NOT NULL DEFAULT CURRENT_$timestamp ON UPDATE CURRENT_$timestamp);
+
+--connect(con1, localhost, root,,)
+--echo # 2011-04-19 08:04:01 UTC
+SET TIMESTAMP = 1303200241.345678;
+SET debug_sync = 'before_write_delayed SIGNAL parked WAIT_FOR go';
+--send INSERT DELAYED INTO t1 ( a ) VALUES (1), (2), (3)
+
+--connection default
+SET debug_sync = 'now WAIT_FOR parked';
+
+--connect(con2, localhost, root,,)
+--echo # 2011-04-19 08:04:01 UTC
+SET TIME_ZONE="+03:00";
+SET TIMESTAMP = 1303200241.456789;
+--send INSERT DELAYED INTO t1 ( a, b ) VALUES (4, '1977-12-19 12:34:56.789123'), (5, '1977-12-19 12:34:57.891234'), (6, '1977-12-19 12:34:58.912345')
+
+--connection default
+SET debug_sync = 'now SIGNAL go';
+
+--let $wait_condition= SELECT COUNT(*) = 6 FROM t1
+--source include/wait_condition.inc
+
+--sorted_result
+SELECT * FROM t1;
+
+--disconnect con1
+--disconnect con2
+
+DROP TABLE t1;
+
+--echo #
+--echo # Test of early activation of function defaults.
+--echo #
+
+eval CREATE TABLE t1 ( a INT, b $timestamp NOT NULL DEFAULT CURRENT_$timestamp ON UPDATE CURRENT_$timestamp);
+
+SET TIMESTAMP = 1317235172.987654; # 2011-09-28 18:39:32 UTC
+INSERT DELAYED INTO t1 ( a ) VALUES (1), (2), (3);
+
+SET TIMESTAMP = 385503754.876543; # 1982-03-20 20:22:34 UTC
+INSERT DELAYED INTO t1 ( a ) VALUES (4), (5), (6);
+
+FLUSH TABLE t1;
+SELECT * FROM t1;
+
+DROP TABLE t1;
+SET debug_sync = 'RESET';
diff --git a/mysql-test/include/gap_lock_error_all.inc b/mysql-test/include/gap_lock_error_all.inc
new file mode 100644
index 00000000000..fc69dfb56f0
--- /dev/null
+++ b/mysql-test/include/gap_lock_error_all.inc
@@ -0,0 +1,27 @@
+--source include/have_partition.inc
+--source include/gap_lock_error_init.inc
+
+let $select_lock=for update;
+let $autocommit = 0;
+--source include/gap_lock_error_select.inc
+let $autocommit = 1;
+--source include/gap_lock_error_select.inc
+
+let $select_lock=lock in share mode;
+let $autocommit = 0;
+--source include/gap_lock_error_select.inc
+let $autocommit = 1;
+--source include/gap_lock_error_select.inc
+
+let $select_lock=;
+let $autocommit = 0;
+--source include/gap_lock_error_select.inc
+let $autocommit = 1;
+--source include/gap_lock_error_select.inc
+
+let $autocommit = 0;
+--source include/gap_lock_error_update.inc
+let $autocommit = 1;
+--source include/gap_lock_error_update.inc
+
+--source include/gap_lock_error_cleanup.inc
diff --git a/mysql-test/include/gap_lock_error_cleanup.inc b/mysql-test/include/gap_lock_error_cleanup.inc
new file mode 100644
index 00000000000..8558b5a528f
--- /dev/null
+++ b/mysql-test/include/gap_lock_error_cleanup.inc
@@ -0,0 +1 @@
+drop table gap1, gap2, gap3, gap4;
diff --git a/mysql-test/include/gap_lock_error_init.inc b/mysql-test/include/gap_lock_error_init.inc
new file mode 100644
index 00000000000..26aa852a398
--- /dev/null
+++ b/mysql-test/include/gap_lock_error_init.inc
@@ -0,0 +1,24 @@
+eval CREATE TABLE gap1 (id1 INT, id2 INT, id3 INT, c1 INT, value INT,
+ PRIMARY KEY (id1, id2, id3),
+ INDEX i (c1)) ENGINE=$engine;
+CREATE TABLE gap2 like gap1;
+eval CREATE TABLE gap3 (id INT, value INT,
+ PRIMARY KEY (id),
+ UNIQUE KEY ui(value)) ENGINE=$engine;
+eval CREATE TABLE gap4 (id INT, value INT,
+ PRIMARY KEY (id)) ENGINE=$engine
+ PARTITION BY HASH(id) PARTITIONS 2;
+--disable_query_log
+let $max = 1000;
+let $i = 1;
+while ($i <= $max) {
+ eval INSERT INTO gap1 (id1, id2, id3, c1, value)
+ VALUES ($i div 2, $i div 10, $i, $i, $i);
+ eval INSERT INTO gap2 (id1, id2, id3, c1, value)
+ VALUES ($i div 2, $i div 10, $i, $i, $i);
+ inc $i;
+}
+--enable_query_log
+
+insert into gap3 values (1,1), (2,2),(3,3),(4,4),(5,5);
+insert into gap4 values (1,1), (2,2),(3,3),(4,4),(5,5);
diff --git a/mysql-test/include/gap_lock_error_select.inc b/mysql-test/include/gap_lock_error_select.inc
new file mode 100644
index 00000000000..91db9bed68a
--- /dev/null
+++ b/mysql-test/include/gap_lock_error_select.inc
@@ -0,0 +1,89 @@
+eval set session autocommit=$autocommit;
+let $is_gaplock_target = `SELECT @@autocommit = 0 && '$select_lock' != '' && '$expect_gap_lock_errors' = 1`;
+
+if ($is_gaplock_target)
+{
+# rnd_init
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 limit 1 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 where value != 100 limit 1 $select_lock;
+# index_read_map
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 where id1=1 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 where id1=1 and id2= 1 $select_lock;
+# read_range_first
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 where id1=1 and id2= 1 and id3 != 1 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 where id1=1 and id2= 1 and id3
+ between 1 and 3 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 where id1=1 and id2= 1 order by id3 asc
+ limit 1 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 where id1=1 and id2= 1 order by id3 desc
+ limit 1 $select_lock;
+# index_first
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 order by id1 asc limit 1 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 order by id1 asc, id2 asc, id3 asc limit 1 $select_lock;
+# index_last
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 order by id1 desc limit 1 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 order by id1 desc, id2 desc, id3 desc
+ limit 1 $select_lock;
+# secondary index lookup
+--error ER_UNKNOWN_ERROR
+eval select * from gap1 force index(i) where c1=1 $select_lock;
+# unique index lookup, ensure no gap lock errors as this is effectively a
+# single point select that does not lock ranges or gaps of keys
+eval select * from gap3 force index(ui) where value=1 $select_lock;
+# primary key lookup, ensure no gap lock errors as these are effectively
+# single point selects that do not lock ranges or gaps of keys
+eval select * from gap1 where id1=1 and id2=1 and id3=1 $select_lock;
+eval select * from gap1 where id1=1 and id2=1 and id3 in (1, 2, 3) $select_lock;
+eval select * from gap1 where id1=1 and id2=1 and id3=1 and value=1
+ order by c1 $select_lock;
+eval select * from gap3 where id=1 $select_lock;
+eval select * from gap4 where id=1 $select_lock;
+eval select * from gap4 where id in (1, 2, 3) $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap4 $select_lock;
+--error ER_UNKNOWN_ERROR
+eval select * from gap4 where id between 3 and 7 $select_lock;
+}
+
+if (!$is_gaplock_target)
+{
+eval select * from gap1 limit 1 $select_lock;
+eval select * from gap1 where value != 100 limit 1 $select_lock;
+eval select * from gap1 where id1=1 $select_lock;
+eval select * from gap1 where id1=1 and id2= 1 $select_lock;
+eval select * from gap1 where id1=1 and id2= 1 and id3 != 1 $select_lock;
+eval select * from gap1 where id1=1 and id2= 1 and id3
+ between 1 and 3 $select_lock;
+eval select * from gap1 where id1=1 and id2= 1 order by id3 asc
+ limit 1 $select_lock;
+eval select * from gap1 where id1=1 and id2= 1 order by id3 desc
+ limit 1 $select_lock;
+eval select * from gap1 order by id1 asc limit 1 $select_lock;
+eval select * from gap1 order by id1 asc, id2 asc, id3 asc limit 1 $select_lock;
+eval select * from gap1 order by id1 desc limit 1 $select_lock;
+eval select * from gap1 order by id1 desc, id2 desc, id3 desc
+ limit 1 $select_lock;
+eval select * from gap1 force index(i) where c1=1 $select_lock;
+eval select * from gap3 force index(ui) where value=1 $select_lock;
+eval select * from gap1 where id1=1 and id2=1 and id3=1 $select_lock;
+eval select * from gap1 where id1=1 and id2=1 and id3 in (1, 2, 3) $select_lock;
+eval select * from gap1 where id1=1 and id2=1 and id3=1 and value=1
+ order by c1 $select_lock;
+eval select * from gap3 where id=1 $select_lock;
+eval select * from gap4 where id=1 $select_lock;
+eval select * from gap4 where id in (1, 2, 3) $select_lock;
+eval select * from gap4 $select_lock;
+eval select * from gap4 where id between 3 and 7 $select_lock;
+}
diff --git a/mysql-test/include/gap_lock_error_update.inc b/mysql-test/include/gap_lock_error_update.inc
new file mode 100644
index 00000000000..d456cf81588
--- /dev/null
+++ b/mysql-test/include/gap_lock_error_update.inc
@@ -0,0 +1,91 @@
+eval set session autocommit=$autocommit;
+let $is_gaplock_target = `SELECT @@autocommit = 0 && '$expect_gap_lock_errors' = 1`;
+
+if ($is_gaplock_target)
+{
+## single-table insert,update,delete
+insert into gap1 (id1, id2, id3) values (-1,-1,-1);
+insert into gap1 (id1, id2, id3) values (-1,-1,-1)
+ on duplicate key update value=100;
+--error ER_UNKNOWN_ERROR
+update gap1 set value=100 where id1=1;
+update gap1 set value=100 where id1=1 and id2=1 and id3=1;
+--error ER_UNKNOWN_ERROR
+delete from gap1 where id1=2;
+delete from gap1 where id1=-1 and id2=-1 and id3=-1;
+commit;
+
+## multi-table statements (preventing all gap locks with autocommit)
+# insert into select
+--error ER_UNKNOWN_ERROR
+insert into gap2 select * from gap1;
+--error ER_UNKNOWN_ERROR
+insert into gap2 select * from gap1 where id1=1;
+insert into gap2 select * from gap1 where id1=1 and id2=1 and id3=1;
+
+# create table select
+create table t4 select * from gap1 where id1=1 and id2=1 and id3=1;
+drop table t4;
+--error ER_UNKNOWN_ERROR
+create table t4 select * from gap1;
+--error ER_UNKNOWN_ERROR
+create table t4 select * from gap1 where id1=1;
+
+# update join
+update gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 set gap1.value=100 where gap2.id1=3
+ and gap2.id2=3 and gap2.id3=3;
+--error ER_UNKNOWN_ERROR
+update gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 set gap1.value=100 where gap2.id1=3;
+--error ER_UNKNOWN_ERROR
+update gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 join gap3 on gap1.id1=gap3.id
+ set gap1.value=100 where gap2.id1=3;
+--error ER_UNKNOWN_ERROR
+update gap1 set gap1.value= (select count(*) from gap2);
+
+# delete join
+delete gap1 from gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 where gap2.id1=3
+ and gap2.id2=3 and gap2.id3=3;
+--error ER_UNKNOWN_ERROR
+delete gap1 from gap1 join gap2 on gap1.id1 and gap1.id2=gap2.id2 where gap2.id1=3;
+
+# select join / self join
+--error ER_UNKNOWN_ERROR
+select * from gap1, gap2 limit 1 for update;
+--error ER_UNKNOWN_ERROR
+select * from gap1 a, gap1 b limit 1 for update;
+
+# unique secondary key
+create table u1(
+ c1 int,
+ c2 int,
+ c3 int,
+ c4 int,
+ primary key (c1, c2, c3),
+ unique key (c3, c1)
+);
+begin;
+insert into u1 values (1,1,1,1);
+commit;
+begin;
+insert into u1 values (1,2,1,1) on duplicate key update c4=10;
+commit;
+begin;
+select * from u1 where c3=1 and c1 = 1 for update;
+--error ER_UNKNOWN_ERROR
+select * from u1 where c3=1 for update;
+commit;
+drop table u1;
+}
+
+if (!$is_gaplock_target)
+{
+# autocommit doesn't prevent single table operations
+insert into gap1 (id1, id2, id3) values (-1,-1,-1);
+insert into gap1 (id1, id2, id3) values (-1,-1,-1)
+ on duplicate key update value=100;
+update gap1 set value=100 where id1=1;
+update gap1 set value=100 where id1=1 and id2=1 and id3=1;
+delete from gap1 where id1=2;
+delete from gap1 where id1=-1 and id2=-1 and id3=-1;
+commit;
+}
diff --git a/mysql-test/include/gis_debug.inc b/mysql-test/include/gis_debug.inc
new file mode 100644
index 00000000000..c81932ef90c
--- /dev/null
+++ b/mysql-test/include/gis_debug.inc
@@ -0,0 +1,161 @@
+#
+# This is a shared file included from t/gis-precise.test and t/gis-debug.test
+#
+# - gis-precise.test is executed both in debug and production builds
+# and makes sure that the checked GIS functions return the expected results.
+#
+# - gis-debug.test is executed only in debug builds
+# (and is skipped in production builds).
+# gis-debug.test activates tracing of the internal GIS routines.
+# The trace log is printed to the client side warnings.
+# So gis-debug.test makes sure not only that the correct results are returned,
+# but also check *how* these results were generated - makes sure that
+# the internal GIS routines went through the expected data and code flow paths.
+#
+
+--disable_warnings
+DROP TABLE IF EXISTS p1;
+--enable_warnings
+
+DELIMITER |;
+CREATE PROCEDURE p1(dist DOUBLE, geom TEXT)
+BEGIN
+ DECLARE g GEOMETRY;
+ SET g=GeomFromText(geom);
+ SELECT geom AS `-----`;
+ SELECT dist, GeometryType(@buf:=ST_Buffer(g, dist)) AS `buffer`, ROUND(ST_AREA(@buf),2) AS buf_area;
+END|
+DELIMITER ;|
+
+--disable_query_log
+
+--echo #
+--echo # Testing ST_BUFFER with positive distance
+--echo #
+
+CALL p1(1, 'POINT(0 0))');
+CALL p1(1, 'LineString(0 1, 1 1))');
+CALL p1(1, 'LineString(9 9,8 1,1 5,0 0)');
+CALL p1(1, 'Polygon((2 2,2 8,8 8,8 2,2 2))');
+CALL p1(1, 'Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))');
+CALL p1(1, 'Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))');
+CALL p1(1, 'MultiPoint(9 9,8 1,1 5)');
+CALL p1(1, 'MultiLineString((0 0,2 2))');
+CALL p1(1, 'MultiLineString((0 0,2 2,0 4))');
+CALL p1(1, 'MultiLineString((0 0,2 2),(0 2,2 0))');
+CALL p1(1, 'MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))');
+CALL p1(1, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))');
+CALL p1(1, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)),((9 9,8 1,1 5,9 9)))');
+CALL p1(1, 'GeometryCollection(Point(0 0))');
+CALL p1(1, 'GeometryCollection(LineString(0 0, 2 2)))');
+CALL p1(1, 'GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))');
+CALL p1(1, 'GeometryCollection(MultiPoint(9 9,8 1,1 5))');
+CALL p1(1, 'GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))');
+CALL p1(1, 'GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))');
+CALL p1(1, 'GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))');
+
+
+--echo #
+--echo # Testing ST_BUFFER with zero distance
+--echo #
+
+CALL p1(0, 'POINT(0 0))');
+CALL p1(0, 'LineString(0 1, 1 1))');
+CALL p1(0, 'LineString(9 9,8 1,1 5,0 0)');
+CALL p1(0, 'Polygon((2 2,2 8,8 8,8 2,2 2))');
+CALL p1(0, 'Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))');
+CALL p1(0, 'Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))');
+CALL p1(0, 'MultiPoint(9 9,8 1,1 5)');
+CALL p1(0, 'MultiLineString((0 0,2 2))');
+CALL p1(0, 'MultiLineString((0 0,2 2,0 4))');
+CALL p1(0, 'MultiLineString((0 0,2 2),(0 2,2 0))');
+CALL p1(0, 'MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))');
+CALL p1(0, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))');
+CALL p1(0, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)),((9 9,8 1,1 5,9 9)))');
+CALL p1(0, 'GeometryCollection(Point(0 0))');
+CALL p1(0, 'GeometryCollection(LineString(0 0, 2 2)))');
+CALL p1(0, 'GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))');
+CALL p1(0, 'GeometryCollection(MultiPoint(9 9,8 1,1 5))');
+CALL p1(0, 'GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))');
+CALL p1(0, 'GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))');
+CALL p1(0, 'GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))');
+
+
+--echo #
+--echo # Testing ST_BUFFER with negative distance
+--echo #
+
+CALL p1(-1, 'POINT(0 0))');
+CALL p1(-1, 'LineString(0 1, 1 1))');
+CALL p1(-1, 'LineString(9 9,8 1,1 5,0 0)');
+CALL p1(-1, 'Polygon((2 2,2 8,8 8,8 2,2 2))');
+#
+# Wrong shape
+# CALL p1(-1, 'Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))');
+# Wrong shape
+# CALL p1(-1, 'Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))');
+#
+CALL p1(-1, 'MultiPoint(9 9,8 1,1 5)');
+CALL p1(-1, 'MultiLineString((0 0,2 2))');
+CALL p1(-1, 'MultiLineString((0 0,2 2,0 4))');
+CALL p1(-1, 'MultiLineString((0 0,2 2),(0 2,2 0))');
+CALL p1(-1, 'MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))');
+#
+# Wrong shape
+#CALL p1(-1, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))');
+#CALL p1(-1, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)),((9 9,8 1,1 5,9 9)))');
+#
+CALL p1(-1, 'GeometryCollection(Point(0 0))');
+CALL p1(-1, 'GeometryCollection(LineString(0 0, 2 2)))');
+CALL p1(-1, 'GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))');
+CALL p1(-1, 'GeometryCollection(MultiPoint(9 9,8 1,1 5))');
+CALL p1(-1, 'GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))');
+#
+# Wrong shape
+# CALL p1(-1, 'GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))');
+#
+CALL p1(-1, 'GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))');
+
+
+--enable_query_log
+
+SELECT ST_CONTAINS(
+ GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
+ GeomFromText('POINT(5 10)'));
+SELECT AsText(ST_UNION(
+ GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
+ GeomFromText('POINT(5 10)')));
+
+DROP PROCEDURE p1;
+
+--echo #
+--echo # Bug #13833019 ASSERTION `T1->RESULT_RANGE' FAILED IN GCALC_OPERATION_REDUCER::END_COUPLE
+--echo #
+SELECT GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,9 4,3 3,0 0)),((2 2,2 2,8 8,2 3,2 2)))'), 3));
+
+--echo #
+--echo # Bug #13832749 HANDLE_FATAL_SIGNAL IN GCALC_FUNCTION::COUNT_INTERNAL
+--echo #
+SELECT GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)), ((9 9,8 1,1 5,9 9)))'),1));
+
+
+--echo #
+--echo # Bug#13358363 - ASSERTION: N > 0 && N < SINUSES_CALCULATED*2+1 | GET_N_SINCOS/ADD_EDGE_BUFFER
+--echo #
+
+DO ST_BUFFER(ST_GEOMCOLLFROMTEXT('linestring(1 1,2 2)'),'');
+
+SELECT ST_WITHIN(
+ LINESTRINGFROMTEXT(' LINESTRING(3 8,9 2,3 8,3 3,7 6,4 7,4 7,8 1) '),
+ ST_BUFFER(MULTIPOLYGONFROMTEXT(' MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2),(4 4,4 6,6 6,6 4,4 4)),((0 5,3 5,3 2,1 2,1 1,3 1,3 0,0 0,0 3,2 3,2 4,0 4,0 5))) '),
+ ST_NUMINTERIORRINGS(POLYGONFROMTEXT('POLYGON((3 5,2 4,2 5,3 5)) '))));
+
+SELECT ST_DIMENSION(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((3 5,2 5,2 4,3 4,3 5)) '),
+ ST_NUMINTERIORRINGS(POLYGONFROMTEXT(' POLYGON((0 0,9 3,4 2,0 0))'))));
+
+SELECT ST_NUMINTERIORRINGS(
+ ST_ENVELOPE(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5))) '),
+ SRID(MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 2,4 2,1 2,2 4,2 2)) ')))));
+
+SELECT ASTEXT(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((9 9,5 2,4 5,9 9))'),
+ SRID(GEOMETRYFROMTEXT(' MULTIPOINT(8 4,5 0,7 8,6 9,3 4,7 3,5 5) '))));
diff --git a/mysql-test/include/gis_generic.inc b/mysql-test/include/gis_generic.inc
index e4fee4448c1..59acf04dfa2 100644
--- a/mysql-test/include/gis_generic.inc
+++ b/mysql-test/include/gis_generic.inc
@@ -72,6 +72,19 @@ INSERT into gis_geometry SELECT * FROM gis_multi_line;
INSERT into gis_geometry SELECT * FROM gis_multi_polygon;
INSERT into gis_geometry SELECT * FROM gis_geometrycollection;
+-- disable_query_log
+-- disable_result_log
+ANALYZE TABLE gis_point;
+ANALYZE TABLE gis_line;
+ANALYZE TABLE gis_polygon;
+ANALYZE TABLE gis_multi_point;
+ANALYZE TABLE gis_multi_line;
+ANALYZE TABLE gis_multi_polygon;
+ANALYZE TABLE gis_geometrycollection;
+ANALYZE TABLE gis_geometry;
+-- enable_result_log
+-- enable_query_log
+
SELECT fid, AsText(g) FROM gis_point ORDER by fid;
SELECT fid, AsText(g) FROM gis_line ORDER by fid;
SELECT fid, AsText(g) FROM gis_polygon ORDER by fid;
diff --git a/mysql-test/include/have_32bit.inc b/mysql-test/include/have_32bit.inc
new file mode 100644
index 00000000000..d62093d8be4
--- /dev/null
+++ b/mysql-test/include/have_32bit.inc
@@ -0,0 +1,9 @@
+disable_query_log;
+disable_warnings;
+let $VERSION_COMPILE_64BIT=
+ `SELECT IF(@@version_compile_machine like '%64%', 1, 0)`;
+enable_warnings;
+enable_query_log;
+if ($VERSION_COMPILE_64BIT) {
+ skip Need a 32 bit machine/binary;
+}
diff --git a/mysql-test/include/have_64bit.inc b/mysql-test/include/have_64bit.inc
new file mode 100644
index 00000000000..38c11156a53
--- /dev/null
+++ b/mysql-test/include/have_64bit.inc
@@ -0,0 +1,9 @@
+disable_query_log;
+disable_warnings;
+let $VERSION_COMPILE_64BIT=
+ `SELECT IF(@@version_compile_machine like '%64%', 1, 0)`;
+enable_warnings;
+enable_query_log;
+if (!$VERSION_COMPILE_64BIT) {
+ skip Need a 64 bit machine/binary;
+}
diff --git a/mysql-test/include/have_archive.opt b/mysql-test/include/have_archive.opt
index cf9309d9fb0..39da455d917 100644
--- a/mysql-test/include/have_archive.opt
+++ b/mysql-test/include/have_archive.opt
@@ -1,2 +1,2 @@
--loose-archive
---plugin-load=$HA_ARCHIVE_SO
+--plugin-load-add=$HA_ARCHIVE_SO
diff --git a/mysql-test/include/have_blackhole.opt b/mysql-test/include/have_blackhole.opt
index b600b468390..980dc27e328 100644
--- a/mysql-test/include/have_blackhole.opt
+++ b/mysql-test/include/have_blackhole.opt
@@ -1,2 +1,2 @@
--loose-blackhole
---plugin-load=$HA_BLACKHOLE_SO
+--plugin-load-add=$HA_BLACKHOLE_SO
diff --git a/mysql-test/include/have_crypt.inc b/mysql-test/include/have_crypt.inc
index cbf0a7ac876..422f8922edc 100644
--- a/mysql-test/include/have_crypt.inc
+++ b/mysql-test/include/have_crypt.inc
@@ -1,4 +1,5 @@
--- require r/have_crypt.require
-disable_query_log;
-show variables like 'have_crypt';
-enable_query_log;
+# encrypt('a') is NULL if crypt(3) is not available
+# encrypt('a') is "*0" in fips mode
+if (`select length(encrypt('a')) > 3 IS NOT TRUE`) {
+ skip No crypt(3);
+}
diff --git a/mysql-test/include/have_debug.inc b/mysql-test/include/have_debug.inc
index 5df3080a6ed..a035031e49a 100644
--- a/mysql-test/include/have_debug.inc
+++ b/mysql-test/include/have_debug.inc
@@ -2,8 +2,3 @@
# suite.pm will make sure that all tests including this file
# will be skipped unless this is a debug build.
#
-# The test below is redundant
-
-if (`select version() not like '%debug%'`) {
- --skip Needs a debug build
-}
diff --git a/mysql-test/include/have_des.inc b/mysql-test/include/have_des.inc
new file mode 100644
index 00000000000..5abdaf6e2aa
--- /dev/null
+++ b/mysql-test/include/have_des.inc
@@ -0,0 +1,6 @@
+# in the FIPS mode, OpenSSL disables DES and other weak algorithms
+source include/have_ssl_crypto_functs.inc;
+
+if (`select des_encrypt("a", "b") IS NULL`) {
+ skip DES is disabled (fips mode?);
+}
diff --git a/mysql-test/include/have_example_plugin.inc b/mysql-test/include/have_example_plugin.inc
index 5571c345850..c0da490dde0 100644
--- a/mysql-test/include/have_example_plugin.inc
+++ b/mysql-test/include/have_example_plugin.inc
@@ -1,14 +1,4 @@
#
-# Check if server has support for loading plugins
+# suite.pm will make sure that all tests including this file
+# will be skipped unless dynamic ha_example plugin is available
#
-if (`SELECT @@have_dynamic_loading != 'YES'`) {
- --skip Example plugin requires dynamic loading
-}
-
-#
-# Check if the variable EXAMPLE_PLUGIN is set
-#
-if (!$HA_EXAMPLE_SO) {
- --skip Need example plugin
-}
-
diff --git a/mysql-test/include/have_innodb.combinations b/mysql-test/include/have_innodb.combinations
index 93c39fd1a98..5b8d376d1b9 100644
--- a/mysql-test/include/have_innodb.combinations
+++ b/mysql-test/include/have_innodb.combinations
@@ -1,27 +1,40 @@
[innodb_plugin]
ignore-builtin-innodb
-plugin-load=$HA_INNODB_SO
+plugin-load-add=$HA_INNODB_SO
innodb
innodb-cmpmem
innodb-trx
innodb-buffer-pool-stats
innodb-buffer-page
innodb-buffer-page-lru
+innodb-sys-foreign
+innodb-sys-foreign-col
+innodb-sys-tables
+innodb-metrics
[xtradb_plugin]
ignore-builtin-innodb
-plugin-load=$HA_XTRADB_SO
+plugin-load-add=$HA_XTRADB_SO
innodb
innodb-cmpmem
innodb-trx
innodb-buffer-pool-stats
innodb-buffer-page
innodb-buffer-page-lru
+innodb-sys-foreign
+innodb-sys-foreign-col
+innodb-sys-tables
+innodb-metrics
[xtradb]
innodb
innodb-cmpmem
innodb-trx
+innodb-metrics
innodb-buffer-pool-stats
innodb-buffer-page
innodb-buffer-page-lru
+innodb-sys-foreign
+innodb-sys-foreign-col
+innodb-sys-tables
+innodb-metrics
diff --git a/mysql-test/include/have_innodb.inc b/mysql-test/include/have_innodb.inc
index 021970423cd..b89797d5828 100644
--- a/mysql-test/include/have_innodb.inc
+++ b/mysql-test/include/have_innodb.inc
@@ -2,9 +2,3 @@
# suite.pm will make sure that all tests including this file
# will be skipped unless innodb or xtradb is enabled
#
-# The test below is redundant
-
-if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.ENGINES WHERE engine = 'innodb' AND support IN ('YES', 'DEFAULT', 'ENABLED')`)
-{
- --skip Test requires InnoDB.
-}
diff --git a/mysql-test/include/have_innodb_16k.inc b/mysql-test/include/have_innodb_16k.inc
new file mode 100644
index 00000000000..f0198ca5ee7
--- /dev/null
+++ b/mysql-test/include/have_innodb_16k.inc
@@ -0,0 +1,4 @@
+if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE LOWER(variable_name) = 'innodb_page_size' AND variable_value = 16384`)
+{
+ --skip Test requires InnoDB with 16k Page size.
+}
diff --git a/mysql-test/include/have_metadata_lock_info.inc b/mysql-test/include/have_metadata_lock_info.inc
new file mode 100644
index 00000000000..51fae1c62f0
--- /dev/null
+++ b/mysql-test/include/have_metadata_lock_info.inc
@@ -0,0 +1,4 @@
+if (!`SELECT count(*) FROM information_schema.plugins WHERE
+ (PLUGIN_STATUS = 'ACTIVE') AND PLUGIN_NAME = 'METADATA_LOCK_INFO'`){
+ skip Need archive METADATA_LOCK_INFO plugin;
+}
diff --git a/mysql-test/include/have_metadata_lock_info.opt b/mysql-test/include/have_metadata_lock_info.opt
new file mode 100644
index 00000000000..677c4ec01be
--- /dev/null
+++ b/mysql-test/include/have_metadata_lock_info.opt
@@ -0,0 +1,2 @@
+--loose-metadata-lock-info
+--plugin-load-add=$METADATA_LOCK_INFO_SO
diff --git a/mysql-test/include/have_mysql_upgrade.inc b/mysql-test/include/have_mysql_upgrade.inc
deleted file mode 100644
index 8f486176018..00000000000
--- a/mysql-test/include/have_mysql_upgrade.inc
+++ /dev/null
@@ -1,4 +0,0 @@
---require r/have_mysql_upgrade.result
---disable_query_log
-select LENGTH("$MYSQL_UPGRADE")>0 as have_mysql_upgrade;
---enable_query_log
diff --git a/mysql-test/include/have_openssl.inc b/mysql-test/include/have_openssl.inc
new file mode 100644
index 00000000000..c9260123f9d
--- /dev/null
+++ b/mysql-test/include/have_openssl.inc
@@ -0,0 +1,7 @@
+-- source include/have_ssl_communication.inc
+let $crllen=`select length(trim(coalesce(@@ssl_crl, ''))) + length(trim(coalesce(@@ssl_crlpath, '')))`;
+if (!$crllen)
+{
+ skip Needs OpenSSL;
+}
+
diff --git a/mysql-test/include/have_partition.inc b/mysql-test/include/have_partition.inc
index b45572ad31e..50dc98ac1ed 100644
--- a/mysql-test/include/have_partition.inc
+++ b/mysql-test/include/have_partition.inc
@@ -1,4 +1,4 @@
--- require r/have_partition.require
-disable_query_log;
-show variables like 'have_partitioning';
-enable_query_log;
+if (`SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.PLUGINS WHERE PLUGIN_NAME = 'partition' AND PLUGIN_STATUS='ACTIVE'`)
+{
+ --skip Test requires partitioning
+}
diff --git a/mysql-test/include/have_partition.opt b/mysql-test/include/have_partition.opt
index efbbfda3921..9c511d27dce 100644
--- a/mysql-test/include/have_partition.opt
+++ b/mysql-test/include/have_partition.opt
@@ -1 +1 @@
---enable-partition
+--loose-enable-partition
diff --git a/mysql-test/include/have_plugin_auth.opt b/mysql-test/include/have_plugin_auth.opt
index ff91abb1bef..0204e148656 100644
--- a/mysql-test/include/have_plugin_auth.opt
+++ b/mysql-test/include/have_plugin_auth.opt
@@ -1 +1 @@
---plugin-load=$AUTH_TEST_PLUGIN_SO
+--plugin-load-add=$AUTH_TEST_PLUGIN_SO
diff --git a/mysql-test/include/have_rbr_triggers.inc b/mysql-test/include/have_rbr_triggers.inc
new file mode 100644
index 00000000000..9ccfc18bfde
--- /dev/null
+++ b/mysql-test/include/have_rbr_triggers.inc
@@ -0,0 +1,5 @@
+if (`select count(*) = 0 from information_schema.session_variables where variable_name = 'slave_run_triggers_for_rbr'`)
+{
+ skip RBR triggers are not available;
+}
+
diff --git a/mysql-test/include/have_semisync.inc b/mysql-test/include/have_semisync.inc
new file mode 100644
index 00000000000..243fad83717
--- /dev/null
+++ b/mysql-test/include/have_semisync.inc
@@ -0,0 +1,4 @@
+if (`select count(*) < 2 from information_schema.plugins where plugin_name like 'rpl_semi_sync_%'`)
+{
+ --skip Test requires semisync plugins
+}
diff --git a/mysql-test/include/have_semisync.opt b/mysql-test/include/have_semisync.opt
new file mode 100644
index 00000000000..19e29c7e4de
--- /dev/null
+++ b/mysql-test/include/have_semisync.opt
@@ -0,0 +1,4 @@
+--plugin-load-add=$SEMISYNC_MASTER_SO
+--plugin-load-add=$SEMISYNC_SLAVE_SO
+--loose-rpl-semi-sync-master
+--loose-rpl-semi-sync-slave
diff --git a/mysql-test/include/have_ssl.inc b/mysql-test/include/have_ssl.inc
deleted file mode 100644
index 6f2d5587a75..00000000000
--- a/mysql-test/include/have_ssl.inc
+++ /dev/null
@@ -1,4 +0,0 @@
--- require r/have_ssl.require
-disable_query_log;
-show variables like 'have_ssl';
-enable_query_log;
diff --git a/mysql-test/include/have_ssl_communication.inc b/mysql-test/include/have_ssl_communication.inc
index 6f2d5587a75..84278e7288a 100644
--- a/mysql-test/include/have_ssl_communication.inc
+++ b/mysql-test/include/have_ssl_communication.inc
@@ -1,4 +1,4 @@
--- require r/have_ssl.require
-disable_query_log;
-show variables like 'have_ssl';
-enable_query_log;
+if (`SELECT count(*) = 0 FROM information_schema.GLOBAL_VARIABLES WHERE
+ VARIABLE_NAME = 'have_ssl' AND VARIABLE_VALUE = 'YES'`){
+ skip Needs SSL;
+}
diff --git a/mysql-test/include/have_ssl_crypto_functs.inc b/mysql-test/include/have_ssl_crypto_functs.inc
index d32f059e4fa..2204c81db39 100644
--- a/mysql-test/include/have_ssl_crypto_functs.inc
+++ b/mysql-test/include/have_ssl_crypto_functs.inc
@@ -1,8 +1,4 @@
--- require r/have_ssl_is_yes_or_disabled_only.require
-disable_query_log;
-# "yes" means that the ssl library is found and the server can communicate using SSL.
-# "no" means that there are no SSL functions in the server.
-# "disabled" means that ssl functions exist, but communication is disabled for some reason.
-replace_regex s/(YES|DISABLED)/yesordisabled/;
-show variables like "have_ssl";
-enable_query_log;
+if (`SELECT count(*) = 0 FROM information_schema.GLOBAL_VARIABLES WHERE
+ VARIABLE_NAME = 'have_ssl' AND VARIABLE_VALUE <> 'NO'`){
+ skip Needs SSL;
+}
diff --git a/mysql-test/include/have_stat_tables.inc b/mysql-test/include/have_stat_tables.inc
new file mode 100644
index 00000000000..a52a4d5ca5c
--- /dev/null
+++ b/mysql-test/include/have_stat_tables.inc
@@ -0,0 +1,5 @@
+if (`select count(*) < 3 from information_schema.tables
+ where table_schema = 'mysql' and table_name in ('table_stats','column_stats','index_stats')`)
+{
+ --skip Needs stat tables
+}
diff --git a/mysql-test/include/have_stat_tables.opt b/mysql-test/include/have_stat_tables.opt
new file mode 100644
index 00000000000..addda71619d
--- /dev/null
+++ b/mysql-test/include/have_stat_tables.opt
@@ -0,0 +1 @@
+--use-stat-tables='complementary'
diff --git a/mysql-test/include/have_xtradb.combinations b/mysql-test/include/have_xtradb.combinations
index b42b72e5785..20e07c62635 100644
--- a/mysql-test/include/have_xtradb.combinations
+++ b/mysql-test/include/have_xtradb.combinations
@@ -1,15 +1,13 @@
[xtradb_plugin]
ignore-builtin-innodb
-plugin-load=$HA_XTRADB_SO
+plugin-load-add=$HA_XTRADB_SO
innodb
innodb-cmpmem
innodb-trx
innodb-sys-index
-xtradb-admin-command
[xtradb]
innodb
innodb-cmpmem
innodb-trx
innodb-sys-index
-xtradb-admin-command
diff --git a/mysql-test/include/have_xtradb.inc b/mysql-test/include/have_xtradb.inc
index 478b9926e21..d12802e057d 100644
--- a/mysql-test/include/have_xtradb.inc
+++ b/mysql-test/include/have_xtradb.inc
@@ -2,10 +2,3 @@
# suite.pm will make sure that all tests including this file
# will be skipped unless xtradb is enabled
#
-# The test below is redundant
-
-if (!`SELECT count(*) FROM information_schema.plugins WHERE
- plugin_name = 'innodb' AND plugin_status = 'active' AND
- plugin_description LIKE '%xtradb%'`){
- skip Needs XtraDB engine;
-}
diff --git a/mysql-test/include/index_merge2.inc b/mysql-test/include/index_merge2.inc
index c50a45a9923..03afa49d323 100644
--- a/mysql-test/include/index_merge2.inc
+++ b/mysql-test/include/index_merge2.inc
@@ -341,6 +341,7 @@ while ($1)
alter table t1 add index i2(key2);
alter table t1 add index i3(key3);
update t1 set key2=key1,key3=key1;
+analyze table t1;
# to test the bug, the following must use "sort_union":
--replace_column 9 REF
diff --git a/mysql-test/include/index_merge_ror_cpk.inc b/mysql-test/include/index_merge_ror_cpk.inc
index 3912aa34026..df42745b4fc 100644
--- a/mysql-test/include/index_merge_ror_cpk.inc
+++ b/mysql-test/include/index_merge_ror_cpk.inc
@@ -79,8 +79,11 @@ select pk1,pk2 from t1 where key1 = 10 and key2=10 and 2*pk1+1 < 2*96+1;
# Verify that CPK is always used for index intersection scans
# (this is because it is used as a filter, not for retrieval)
explain select * from t1 where badkey=1 and key1=10;
+set @tmp_index_merge_ror_cpk=@@optimizer_switch;
+set optimizer_switch='extended_keys=off';
--replace_column 9 ROWS
explain select * from t1 where pk1 < 7500 and key1 = 10;
+set optimizer_switch=@tmp_index_merge_ror_cpk;
# Verify that keys with 'tails' of PK members are ok.
explain select * from t1 where pktail1ok=1 and key1=10;
diff --git a/mysql-test/include/innodb_page_size.combinations b/mysql-test/include/innodb_page_size.combinations
new file mode 100644
index 00000000000..a9b7c7ce14d
--- /dev/null
+++ b/mysql-test/include/innodb_page_size.combinations
@@ -0,0 +1,8 @@
+[16k]
+innodb-page-size=16K
+
+[8k]
+innodb-page-size=8K
+
+[4k]
+innodb-page-size=4K
diff --git a/mysql-test/include/innodb_page_size.inc b/mysql-test/include/innodb_page_size.inc
new file mode 100644
index 00000000000..754b640da86
--- /dev/null
+++ b/mysql-test/include/innodb_page_size.inc
@@ -0,0 +1,4 @@
+# The goal of including this file is to enable innodb_page_size combinations
+# (see include/innodb_page_size.combinations)
+
+--source include/have_innodb.inc
diff --git a/mysql-test/include/innodb_page_size_small.combinations b/mysql-test/include/innodb_page_size_small.combinations
new file mode 100644
index 00000000000..a9b7c7ce14d
--- /dev/null
+++ b/mysql-test/include/innodb_page_size_small.combinations
@@ -0,0 +1,8 @@
+[16k]
+innodb-page-size=16K
+
+[8k]
+innodb-page-size=8K
+
+[4k]
+innodb-page-size=4K
diff --git a/mysql-test/include/innodb_page_size_small.inc b/mysql-test/include/innodb_page_size_small.inc
new file mode 100644
index 00000000000..754b640da86
--- /dev/null
+++ b/mysql-test/include/innodb_page_size_small.inc
@@ -0,0 +1,4 @@
+# The goal of including this file is to enable innodb_page_size combinations
+# (see include/innodb_page_size.combinations)
+
+--source include/have_innodb.inc
diff --git a/mysql-test/include/is_embedded.inc b/mysql-test/include/is_embedded.inc
index 6d95772843c..b20f21953f0 100644
--- a/mysql-test/include/is_embedded.inc
+++ b/mysql-test/include/is_embedded.inc
@@ -1,5 +1,5 @@
--- require r/is_embedded.require
-disable_query_log;
-select version() like '%embedded%' as 'have_embedded';
-enable_query_log;
+if (`SELECT VERSION() NOT LIKE '%embedded%'`)
+{
+ --skip Test requires: embedded server
+}
diff --git a/mysql-test/include/kill_and_restart_mysqld.inc b/mysql-test/include/kill_and_restart_mysqld.inc
new file mode 100644
index 00000000000..f2ac9b504d2
--- /dev/null
+++ b/mysql-test/include/kill_and_restart_mysqld.inc
@@ -0,0 +1,19 @@
+--let $_server_id= `SELECT @@server_id`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+
+if ($restart_parameters)
+{
+ --echo # Kill and restart: $restart_parameters
+ --exec echo "restart: $restart_parameters" > $_expect_file_name
+}
+if (!$restart_parameters)
+{
+ --echo # Kill and restart
+ --exec echo "restart" > $_expect_file_name
+}
+
+--shutdown_server 0
+--source include/wait_until_disconnected.inc
+--enable_reconnect
+--source include/wait_until_connected_again.inc
+--disable_reconnect
diff --git a/mysql-test/include/kill_binlog_dump_threads.inc b/mysql-test/include/kill_binlog_dump_threads.inc
new file mode 100644
index 00000000000..38e3e2a7c98
--- /dev/null
+++ b/mysql-test/include/kill_binlog_dump_threads.inc
@@ -0,0 +1,62 @@
+# ==== Purpose ====
+#
+# Terminate all binlog dump threads on a master.
+#
+# This is sometimes useful, as normally such dump threads can hang
+# around for some time before they notice that the slave has disconnected.
+#
+# Note that if there are active slave connections, they might try to
+# reconnect as their dump threads are killed, which may not lead to the
+# desired results.
+#
+#
+# ==== Usage ====
+#
+# [--let $kill_timeout= NUMBER]
+# --source include/stop_slavekill_binlog_dump_threads.inc
+#
+# Parameters:
+# $kill_timeout
+# Maximum number of seconds to wait for dump threads to disappear.
+
+
+--let $include_filename= kill_binlog_dump_threads.inc
+--source include/begin_include_file.inc
+
+--disable_query_log
+
+let $wait_counter= 300;
+if ($kill_timeout)
+{
+ let $wait_counter= `SELECT $kill_timeout * 10`;
+}
+
+let $success= 0;
+while ($wait_counter)
+{
+ dec $wait_counter;
+ let $_tid= `SELECT id FROM information_schema.processlist WHERE command = 'Binlog Dump' LIMIT 1`;
+ if ($_tid)
+ {
+ eval KILL QUERY $_tid;
+ }
+ if (!$_tid)
+ {
+ let $wait_counter= 0;
+ let $success= 1;
+ }
+ if (!$success)
+ {
+ real_sleep 0.1;
+ }
+}
+if (!$success)
+{
+ SHOW FULL PROCESSLIST;
+ --die Timeout while waiting for binlog dump threads to disappear.
+}
+
+--enable_query_log
+
+--let $include_filename= kill_binlog_dump_threads.inc
+--source include/end_include_file.inc
diff --git a/mysql-test/include/kill_mysqld.inc b/mysql-test/include/kill_mysqld.inc
new file mode 100644
index 00000000000..86ee048a0f1
--- /dev/null
+++ b/mysql-test/include/kill_mysqld.inc
@@ -0,0 +1,7 @@
+--let $_server_id= `SELECT @@server_id`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+
+--echo # Kill the server
+--exec echo "wait" > $_expect_file_name
+--shutdown_server 0
+--source include/wait_until_disconnected.inc
diff --git a/mysql-test/include/linux.inc b/mysql-test/include/linux.inc
new file mode 100644
index 00000000000..f24832ca476
--- /dev/null
+++ b/mysql-test/include/linux.inc
@@ -0,0 +1,5 @@
+if (`select convert(@@version_compile_os using latin1) LIKE 'Linux' = 0`)
+{
+ skip Need Linux;
+}
+
diff --git a/mysql-test/include/maybe_debug.combinations b/mysql-test/include/maybe_debug.combinations
new file mode 100644
index 00000000000..5ee57c0bfd8
--- /dev/null
+++ b/mysql-test/include/maybe_debug.combinations
@@ -0,0 +1,5 @@
+[debug]
+--enable-gdb
+
+[release]
+--disable-gdb
diff --git a/mysql-test/include/maybe_debug.inc b/mysql-test/include/maybe_debug.inc
new file mode 100644
index 00000000000..2f6c2848f9f
--- /dev/null
+++ b/mysql-test/include/maybe_debug.inc
@@ -0,0 +1,3 @@
+# include file for test files that can be run with and without debug
+# having debug and non-debug tests.
+let $have_debug=`select version() like '%debug%'`;
diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc
index 87d6698865a..c837eb7a7ad 100644
--- a/mysql-test/include/mix1.inc
+++ b/mysql-test/include/mix1.inc
@@ -25,7 +25,7 @@
# where just some indexes have been created must be used.
#
-eval SET SESSION STORAGE_ENGINE = $engine_type;
+eval SET SESSION DEFAULT_STORAGE_ENGINE = $engine_type;
--disable_warnings
drop table if exists t1,t2,t3,t1m,t1i,t2m,t2i,t4;
@@ -388,7 +388,7 @@ drop table t1;
# Bug #13293 Wrongly used index results in endless loop.
# (was part of group_min_max.test)
#
-create table t1 (f1 int, f2 char(1), primary key(f1,f2));
+create table t1 (f1 int, f2 char(1), primary key(f1,f2)) stats_persistent=0;
insert into t1 values ( 1,"e"),(2,"a"),( 3,"c"),(4,"d");
alter table t1 drop primary key, add primary key (f2, f1);
explain select distinct f1 a, f1 b from t1;
@@ -432,7 +432,7 @@ CREATE TABLE t1 (
age tinyint(3) unsigned NOT NULL,
PRIMARY KEY (id),
INDEX (name,dept)
-) ENGINE=InnoDB;
+) ENGINE=InnoDB STATS_PERSISTENT=0;
INSERT INTO t1(id, dept, age, name) VALUES
(3987, 'cs1', 10, 'rs1'), (3988, 'cs2', 20, 'rs1'), (3995, 'cs3', 10, 'rs2'),
(3996, 'cs4', 20, 'rs2'), (4003, 'cs5', 10, 'rs3'), (4004, 'cs6', 20, 'rs3'),
@@ -546,7 +546,7 @@ CREATE TABLE t2(
acct_id int DEFAULT NULL,
INDEX idx1 (stat_id, acct_id),
INDEX idx2 (acct_id)
-) ENGINE=InnoDB;
+) ENGINE=InnoDB STATS_PERSISTENT=0;
INSERT INTO t1(stat_id,acct_id) VALUES
(1,759), (2,831), (3,785), (4,854), (1,921),
@@ -627,16 +627,13 @@ DROP TABLE t1,t2,t3;
create table t1 (a int) engine=innodb;
let $MYSQLD_DATADIR= `select @@datadir`;
copy_file $MYSQLD_DATADIR/test/t1.frm $MYSQLD_DATADIR/test/bug29807.frm;
---error 1146
+--error ER_NO_SUCH_TABLE_IN_ENGINE
select * from bug29807;
drop table t1;
---error 1051
-drop table bug29807;
-create table bug29807 (a int);
drop table bug29807;
--disable_query_log
call mtr.add_suppression("InnoDB: Error: table .test...bug29807. does not exist in the InnoDB internal");
-call mtr.add_suppression("Cannot find or open table test\/bug29807 from");
+call mtr.add_suppression("InnoDB: Cannot open table test/bug29807 from");
--enable_query_log
@@ -1585,6 +1582,29 @@ DROP TABLE t1;
--echo End of 5.1 tests
--echo #
+--echo # Bug#43600: Incorrect type conversion caused wrong result.
+--echo #
+CREATE TABLE t1 (
+ a int NOT NULL
+) engine= innodb;
+
+CREATE TABLE t2 (
+ a int NOT NULL,
+ b int NOT NULL,
+ filler char(100) DEFAULT NULL,
+ KEY a (a,b)
+) engine= innodb;
+
+insert into t1 values (0),(1),(2),(3),(4);
+insert into t2 select A.a + 10 *B.a, 1, 'filler' from t1 A, t1 B;
+
+explain select * from t1, t2 where t2.a=t1.a and t2.b + 1;
+select * from t1, t2 where t2.a=t1.a and t2.b + 1;
+
+drop table t1,t2;
+--echo # End of test case for the bug#43600
+
+--echo #
--echo # Bug#42643: InnoDB does not support replication of TRUNCATE TABLE
--echo #
--echo # Check that a TRUNCATE TABLE statement, needing an exclusive meta
diff --git a/mysql-test/include/mtr_check.sql b/mysql-test/include/mtr_check.sql
index b3e9e7498dc..5c0908349bd 100644
--- a/mysql-test/include/mtr_check.sql
+++ b/mysql-test/include/mtr_check.sql
@@ -32,6 +32,8 @@ BEGIN
AND variable_name not like "Last_IO_Err*"
AND variable_name != 'INNODB_IBUF_MAX_SIZE'
AND variable_name != 'INNODB_USE_NATIVE_AIO'
+ AND variable_name not like 'GTID%POS'
+ AND variable_name != 'GTID_BINLOG_STATE'
ORDER BY variable_name;
-- Dump all databases, there should be none
@@ -76,8 +78,10 @@ BEGIN
mysql.help_keyword,
mysql.help_relation,
mysql.host,
+ mysql.plugin,
mysql.proc,
mysql.procs_priv,
+ mysql.roles_mapping,
mysql.tables_priv,
mysql.time_zone,
mysql.time_zone_leap_second,
diff --git a/mysql-test/include/mtr_warnings.sql b/mysql-test/include/mtr_warnings.sql
index 5cdf4453a7a..8b5ba744b21 100644
--- a/mysql-test/include/mtr_warnings.sql
+++ b/mysql-test/include/mtr_warnings.sql
@@ -108,7 +108,7 @@ INSERT INTO global_suppressions VALUES
("Incorrect definition of table"),
("Incorrect information in file"),
("InnoDB: Warning: we did not need to do crash recovery"),
- ("Invalid \\(old\\?\\) table or database name"),
+ /*("Invalid \\(old\\?\\) table or database name"),*/
("Lock wait timeout exceeded"),
("Log entry on master is longer than max_allowed_packet"),
("unknown option '--loose-"),
@@ -136,7 +136,7 @@ INSERT INTO global_suppressions VALUES
("Slave: Query caused different errors on master and slave"),
("Slave: Table .* doesn't exist"),
("Slave: Table width mismatch"),
- ("Slave: The incident LOST_EVENTS occured on the master"),
+ ("Slave: The incident LOST_EVENTS occurred on the master"),
("Slave: Unknown error.* 1105"),
("Slave: Can't drop database.* database doesn't exist"),
("Time-out in NDB"),
@@ -178,7 +178,7 @@ INSERT INTO global_suppressions VALUES
("The path specified for the variable .* is not a directory or cannot be written:"),
("Master server does not support or not configured semi-sync replication, fallback to asynchronous"),
(": The MySQL server is running with the --secure-backup-file-priv option so it cannot execute this statement"),
- ("Slave: Unknown table 't1' Error_code: 1051"),
+ ("Slave: Unknown table 't1' error.* 1051"),
/* Maria storage engine dependent tests */
@@ -225,6 +225,14 @@ INSERT INTO global_suppressions VALUES
("Slave I/O: The slave I/O thread stops because a fatal error is encountered when it tried to SET @master_binlog_checksum on master.*"),
("Slave I/O: Get master BINLOG_CHECKSUM failed with error.*"),
("Slave I/O: Notifying master by SET @master_binlog_checksum= @@global.binlog_checksum failed with error.*"),
+ ("Slave I/O: Setting master-side filtering of @@skip_replication failed with error:.*"),
+ ("Slave I/O: Setting @mariadb_slave_capability failed with error:.*"),
+ ("Slave I/O: Get master @@GLOBAL.gtid_domain_id failed with error.*"),
+ ("Slave I/O: Setting @slave_connect_state failed with error.*"),
+ ("Slave I/O: Setting @slave_gtid_strict_mode failed with error.*"),
+ ("Slave I/O: Setting @slave_gtid_ignore_duplicates failed with error.*"),
+ ("Slave I/O: Setting @slave_until_gtid failed with error.*"),
+ ("Slave I/O: Get master GTID position failed with error.*"),
("THE_LAST_SUPPRESSION")||
@@ -285,6 +293,7 @@ CREATE DEFINER=root@localhost
PROCEDURE add_suppression(pattern VARCHAR(255))
BEGIN
INSERT INTO test_suppressions (pattern) VALUES (pattern);
+ FLUSH NO_WRITE_TO_BINLOG TABLE test_suppressions;
END
*/||
diff --git a/mysql-test/include/mysql_upgrade_preparation.inc b/mysql-test/include/mysql_upgrade_preparation.inc
index a3c81c4c1e7..03019ae29ff 100644
--- a/mysql-test/include/mysql_upgrade_preparation.inc
+++ b/mysql-test/include/mysql_upgrade_preparation.inc
@@ -2,13 +2,6 @@
# Can't run test of external client with embedded server
-- source include/not_embedded.inc
-
-# Only run test if "mysql_upgrade" is found
---require r/have_mysql_upgrade.result
---disable_query_log
-select LENGTH("$MYSQL_UPGRADE")>0 as have_mysql_upgrade;
---enable_query_log
-
#
# Hack:
#
diff --git a/mysql-test/include/no_protocol.inc b/mysql-test/include/no_protocol.inc
new file mode 100644
index 00000000000..8ffd3509afc
--- /dev/null
+++ b/mysql-test/include/no_protocol.inc
@@ -0,0 +1,8 @@
+# The file with expected results fits only to a run without
+# ps-protocol/sp-protocol/cursor-protocol/view-protocol.
+if (`SELECT $PS_PROTOCOL + $SP_PROTOCOL + $CURSOR_PROTOCOL
+ + $VIEW_PROTOCOL > 0`)
+{
+ --skip Test requires: ps-protocol/sp-protocol/cursor-protocol/view-protocol disabled
+}
+
diff --git a/mysql-test/include/not_embedded.inc b/mysql-test/include/not_embedded.inc
index c3a9c3e12c8..4c168f71979 100644
--- a/mysql-test/include/not_embedded.inc
+++ b/mysql-test/include/not_embedded.inc
@@ -2,10 +2,3 @@
# suite.pm will make sure that all tests including this file
# will be skipped unless this is an embedded test run
#
-# The test below is redundant
-
--- require r/not_embedded.require
-disable_query_log;
-select version() like '%embedded%' as 'have_embedded';
-enable_query_log;
-
diff --git a/mysql-test/include/not_openssl.inc b/mysql-test/include/not_openssl.inc
deleted file mode 100644
index afe2ed37c28..00000000000
--- a/mysql-test/include/not_openssl.inc
+++ /dev/null
@@ -1,4 +0,0 @@
--- require r/not_openssl.require
-disable_query_log;
-show variables like "have_openssl";
-enable_query_log;
diff --git a/mysql-test/include/not_ssl.inc b/mysql-test/include/not_ssl.inc
new file mode 100644
index 00000000000..99866923621
--- /dev/null
+++ b/mysql-test/include/not_ssl.inc
@@ -0,0 +1,4 @@
+if (`select @@have_ssl = 'YES'`)
+{
+ skip only without SSL;
+}
diff --git a/mysql-test/include/not_windows.inc b/mysql-test/include/not_windows.inc
index 9240271077a..08373095438 100644
--- a/mysql-test/include/not_windows.inc
+++ b/mysql-test/include/not_windows.inc
@@ -1,4 +1,4 @@
---require r/not_windows.require
-disable_query_log;
-select convert(@@version_compile_os using latin1) NOT IN ("Win32","Win64","Windows") as "TRUE";
-enable_query_log;
+#
+# suite.pm will make sure that all tests including this file
+# will be skipped unless this is on Windows
+#
diff --git a/mysql-test/include/plugin.defs b/mysql-test/include/plugin.defs
index 45fdfdb9a41..f2b754eb93a 100644
--- a/mysql-test/include/plugin.defs
+++ b/mysql-test/include/plugin.defs
@@ -9,6 +9,7 @@
# PLUGVAR_DIR: name of directory where plugin was found
# PLUGVAR_OPT: mysqld option --plugin_dir=....
# PLUGVAR_LOAD: option --plugin_load=.... if the 4th element is present
+# PLUGVAR_LOAD_ADD: option --plugin_load_add=.... if the 4th element is present
#
# If a listed plugin is not found, the corresponding variables will be
# set to empty, they will not be unset.
diff --git a/mysql-test/include/restart_mysqld.inc b/mysql-test/include/restart_mysqld.inc
index ed0fe64a547..940e081c431 100644
--- a/mysql-test/include/restart_mysqld.inc
+++ b/mysql-test/include/restart_mysqld.inc
@@ -4,6 +4,8 @@
# [--let $allow_rpl_inited= 1]
# --source include/restart_mysqld.inc
+--source include/not_embedded.inc
+
if ($rpl_inited)
{
if (!$allow_rpl_inited)
@@ -12,7 +14,7 @@ if ($rpl_inited)
}
}
---let $server_shutdown_timeout= 10
+--let $server_shutdown_timeout= 60
if ($shutdown_timeout)
{
--let $server_shutdown_timeout= $shutdown_timeout
@@ -29,11 +31,18 @@ if ($shutdown_timeout == 0)
--exec echo "wait" > $_expect_file_name
# Send shutdown to the connected server and give
-# it 10 seconds to die before zapping it
+# it an opted number of seconds to die before zapping it
shutdown_server $server_shutdown_timeout;
# Write file to make mysql-test-run.pl start up the server again
---exec echo "restart" > $_expect_file_name
+if ($restart_parameters)
+{
+ --exec echo "restart: $restart_parameters" > $_expect_file_name
+}
+if (!$restart_parameters)
+{
+ --exec echo "restart" > $_expect_file_name
+}
# Turn on reconnect
--enable_reconnect
diff --git a/mysql-test/include/rpl_connect.inc b/mysql-test/include/rpl_connect.inc
index 95912d57469..11927833f53 100644
--- a/mysql-test/include/rpl_connect.inc
+++ b/mysql-test/include/rpl_connect.inc
@@ -42,7 +42,7 @@ if (!$rpl_connection_name)
--let $_rpl_port= \$SERVER_MYPORT_$rpl_server_number
if (!$_rpl_port)
{
- --echo Bug in test case: '\$SERVER_MYPORT_$rpl_server_number' not initialized. Check the test's .cfg file.
+ --echo Bug in test case: '\$SERVER_MYPORT_$rpl_server_number' not initialized. Check the test's .cnf file.
--die Not all SERVER_MYPORT_* environment variables are setup correctly.
}
diff --git a/mysql-test/include/rpl_end.inc b/mysql-test/include/rpl_end.inc
index f671c442153..3fdd91ba319 100644
--- a/mysql-test/include/rpl_end.inc
+++ b/mysql-test/include/rpl_end.inc
@@ -79,6 +79,22 @@ while ($_rpl_server)
--source include/rpl_sync.inc
--source include/rpl_stop_slaves.inc
+if (!$rpl_debug)
+{
+ --disable_query_log
+}
+--let $_rpl_server= $rpl_server_count
+while ($_rpl_server)
+{
+ --let $rpl_connection_name= server_$_rpl_server
+ --source include/rpl_connection.inc
+
+ # Clear Using_Gtid in SHOW SLAVE STATUS to keep check_testcase happy.
+ CHANGE MASTER TO master_log_file='';
+
+ --dec $_rpl_server
+}
+
# mtr configures server 2 to be a slave before it runs the test. We
# have to restore that state now, so we change topology to 1->2.
--let $rpl_topology= none
diff --git a/mysql-test/include/rpl_init.inc b/mysql-test/include/rpl_init.inc
index f8b0cb46f1a..09569fc2b57 100644
--- a/mysql-test/include/rpl_init.inc
+++ b/mysql-test/include/rpl_init.inc
@@ -176,6 +176,7 @@ while ($_rpl_server)
if (!$rpl_skip_reset_master_and_slave)
{
RESET MASTER;
+ SET GLOBAL gtid_slave_pos= "";
RESET SLAVE;
}
diff --git a/mysql-test/include/save_master_gtid.inc b/mysql-test/include/save_master_gtid.inc
new file mode 100644
index 00000000000..4fd0d3266a2
--- /dev/null
+++ b/mysql-test/include/save_master_gtid.inc
@@ -0,0 +1,28 @@
+# ==== Purpose ====
+#
+# Save the current binlog GTID position on the master, to be used
+# with include/sync_with_master_gtid.inc.
+#
+#
+# ==== Usage ====
+#
+# [--let $rpl_debug= 1]
+# --source include/save_master_gtid.inc
+#
+# Parameters:
+# $rpl_debug
+# See include/rpl_init.inc
+
+
+--let $include_filename= save_master_gtid.inc
+--source include/begin_include_file.inc
+
+--let $master_pos= `SELECT @@gtid_binlog_pos`
+
+if ($rpl_debug)
+{
+ --echo save_master_gtid saved master_pos='$master_pos'
+}
+
+--let $include_filename= save_master_gtid.inc
+--source include/end_include_file.inc
diff --git a/mysql-test/include/search_pattern_in_file++.inc b/mysql-test/include/search_pattern_in_file++.inc
new file mode 100644
index 00000000000..21192b55efb
--- /dev/null
+++ b/mysql-test/include/search_pattern_in_file++.inc
@@ -0,0 +1,81 @@
+# Purpose:
+# Simple search with Perl for a pattern in some file.
+#
+# The advantages compared to thinkable auxiliary constructs using the
+# mysqltest language and SQL are:
+# 1. We do not need a running MySQL server.
+# 2. SQL causes "noise" during debugging and increases the size of logs.
+# Perl code does not disturb at all.
+#
+# The environment variables SEARCH_FILE and SEARCH_PATTERN must be set
+# before sourcing this routine.
+#
+# Optionally, SEARCH_RANGE can be set to the max number of bytes of the file
+# to search. If negative, it will search that many bytes at the end of the
+# file. By default the search happens from the last CURRENT_TEST:
+# marker till the end of file (appropriate for searching error logs).
+#
+# Optionally, SEARCH_ABORT can be set to "FOUND" or "NOT FOUND" and this
+# will abort if the search result doesn't match the requested one.
+#
+# In case of
+# - SEARCH_FILE and/or SEARCH_PATTERN is not set
+# - SEARCH_FILE cannot be opened
+# the test will abort immediate.
+#
+# Typical use case (check invalid server startup options):
+# let $error_log= $MYSQLTEST_VARDIR/log/my_restart.err;
+# --error 0,1
+# --remove_file $error_log
+# let SEARCH_FILE= $error_log;
+# # Stop the server
+# let $restart_file= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect;
+# --exec echo "wait" > $restart_file
+# --shutdown_server 10
+# --source include/wait_until_disconnected.inc
+#
+# --error 1
+# --exec $MYSQLD_CMD <whatever wrong setting> > $error_log 2>&1
+# # The server restart aborts
+# let SEARCH_PATTERN= \[ERROR\] Aborting;
+# --source include/search_pattern_in_file.inc
+#
+# Created: 2011-11-11 mleich
+#
+
+perl;
+ use strict;
+ die "SEARCH_FILE not set" unless $ENV{SEARCH_FILE};
+ my @search_files= glob($ENV{SEARCH_FILE});
+ my $search_pattern= $ENV{SEARCH_PATTERN} or die "SEARCH_PATTERN not set";
+ my $search_range= $ENV{SEARCH_RANGE};
+ my $content;
+ foreach my $search_file (@search_files) {
+ open(FILE, '<', $search_file) || die("Can't open file $search_file: $!");
+ my $file_content;
+ if ($search_range > 0) {
+ read(FILE, $file_content, $search_range, 0);
+ } elsif ($search_range < 0) {
+ my $size= -s $search_file;
+ $search_range = -$size if $size > -$search_range;
+ seek(FILE, $search_range, 2);
+ read(FILE, $file_content, -$search_range, 0);
+ } else {
+ while(<FILE>) { # error log
+ if (/^CURRENT_TEST:/) {
+ $content='';
+ } else {
+ $content.=$_;
+ }
+ }
+ }
+ close(FILE);
+ $content.= $file_content;
+ }
+ my @matches=($content =~ m/$search_pattern/gs);
+ my $res=@matches ? "FOUND " . scalar(@matches) : "NOT FOUND";
+ $ENV{SEARCH_FILE} =~ s{^.*?([^/\\]+)$}{$1};
+ print "$res /$search_pattern/ in $ENV{SEARCH_FILE}\n";
+ die "$ENV{SEARCH_ABORT}\n"
+ if $ENV{SEARCH_ABORT} && $res =~ /^$ENV{SEARCH_ABORT}/;
+EOF
diff --git a/mysql-test/include/search_pattern_in_file.inc b/mysql-test/include/search_pattern_in_file.inc
index 0d09cdcd36e..f77a7c60916 100644
--- a/mysql-test/include/search_pattern_in_file.inc
+++ b/mysql-test/include/search_pattern_in_file.inc
@@ -60,22 +60,36 @@
perl;
use strict;
- my $search_file= $ENV{'SEARCH_FILE'} or die "SEARCH_FILE not set";
- my $search_pattern= $ENV{'SEARCH_PATTERN'} or die "SEARCH_PATTERN not set";
- my $search_range= $ENV{'SEARCH_RANGE'};
- my $file_content;
+ die "SEARCH_FILE not set" unless $ENV{'SEARCH_FILE'};
+ my @search_files= glob($ENV{'SEARCH_FILE'});
+ my $search_pattern= $ENV{'SEARCH_PATTERN'} or die "SEARCH_PATTERN not set";
+ my $search_range= $ENV{'SEARCH_RANGE'};
+ my $content;
$search_range= 50000 unless $search_range =~ /-?[0-9]+/;
- open(FILE, "$search_file") or die("Unable to open '$search_file': $!\n");
- if ($search_range >= 0) {
- read(FILE, $file_content, $search_range, 0);
- } else {
- my $size= -s $search_file;
- $search_range = -$size if $size > -$search_range;
- seek(FILE, $search_range, 2);
- read(FILE, $file_content, -$search_range, 0);
+ foreach my $search_file (@search_files) {
+ open(FILE, '<', $search_file) or die("Unable to open '$search_file': $!\n");
+ my $file_content;
+ if ($search_range >= 0) {
+ read(FILE, $file_content, $search_range, 0);
+ } else {
+ my $size= -s $search_file;
+ $search_range = -$size if $size > -$search_range;
+ seek(FILE, $search_range, 2);
+ read(FILE, $file_content, -$search_range, 0);
+ }
+ close(FILE);
+ $content.= $file_content;
}
- close(FILE);
- if ( not $file_content =~ m{$search_pattern} ) {
- die("# ERROR: The file '$search_file' does not contain the expected pattern $search_pattern\n->$file_content<-\n");
+ $ENV{'SEARCH_FILE'} =~ s{^.*?([^/\\]+)$}{$1};
+ if ($content =~ m{$search_pattern}) {
+ die "FOUND /$search_pattern/ in $ENV{'SEARCH_FILE'}\n"
+ if $ENV{SEARCH_ABORT} eq 'FOUND';
+ print "FOUND /$search_pattern/ in $ENV{'SEARCH_FILE'}\n"
+ unless defined $ENV{SEARCH_ABORT};
+ } else {
+ die "NOT FOUND /$search_pattern/ in $ENV{'SEARCH_FILE'}\n"
+ if $ENV{SEARCH_ABORT} eq 'NOT FOUND';
+ print "NOT FOUND /$search_pattern/ in $ENV{'SEARCH_FILE'}\n"
+ unless defined $ENV{SEARCH_ABORT};
}
EOF
diff --git a/mysql-test/include/setup_fake_relay_log.inc b/mysql-test/include/setup_fake_relay_log.inc
index 4f1d4f6f162..a1964572427 100644
--- a/mysql-test/include/setup_fake_relay_log.inc
+++ b/mysql-test/include/setup_fake_relay_log.inc
@@ -74,7 +74,6 @@ let $_fake_relay_index= $_fake_datadir/$_fake_filename.index;
let $_fake_relay_log_purge= `SELECT @@global.relay_log_purge`;
RESET SLAVE;
-let $_orphan_relay_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);
# Create relay log file.
--copy_file $fake_relay_log $_fake_relay_log
@@ -103,8 +102,5 @@ let $_orphan_relay_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);
# Setup replication from existing relay log.
eval CHANGE MASTER TO MASTER_HOST='dummy.localdomain', RELAY_LOG_FILE='$_fake_filename-fake.000001', RELAY_LOG_POS=4;
-# remove the orphan log file (became spurious)
--- remove_file $_fake_datadir/$_orphan_relay_file
-
--let $include_filename= setup_fake_relay_log.inc
--source include/end_include_file.inc
diff --git a/mysql-test/include/show_binlog_events.inc b/mysql-test/include/show_binlog_events.inc
index e5670c054fa..b2462e0d1b1 100644
--- a/mysql-test/include/show_binlog_events.inc
+++ b/mysql-test/include/show_binlog_events.inc
@@ -1,21 +1,43 @@
-##############################################################################
-# Show binary log events
+# ==== Purpose ====
#
-# Useage:
-# let $binlog_file= master-bin.000002;
-# let $binlog_start= 240;
-# let $binlog_limit= 1, 3;
-# source include/show_binlog_events.inc;
+# Execute SHOW BINLOG EVENTS and mask non-deterministic output.
#
-# It shows the first binary log file if $binlog_file is not given.
+# ==== Usage ====
#
-# It shows events from the end position of the description event if
-# $binlog_start is not given.
+# [--let $binlog_file= [<FILENAME> | LAST]]
+# [--let $binlog_start= <POSITION> ]
+# [--let $binlog_limit= 1, 3 ]
+# [--let $keep_gtid_events= 1]
+# --source include/show_binlog_events.inc
#
-# It shows all of the events if $binlog_limit is not given.
-# $binlog_format has the same semantic with 'LIMIT' option.
+# Parameters:
#
-##############################################################################
+# $binlog_file
+# Filename for the 'IN' clause of SHOW BINLOG EVENTS. If none
+# given, no argument is given to SHOW BINLOG EVENTS, meaning that
+# it uses the first binlog. If you set this to "LAST", it prints
+# the last binlog (according to SHOW MASTER STATUS).
+#
+# $binlog_start
+# Position for the 'FROM' clause of SHOW BINLOG EVENTS. If none
+# given, starts right after the Binlog_checkpoint_log_even.
+#
+# $binlog_limit
+# Limit for the 'LIMIT' clause of SHOW BINLOG EVENTS, i.e.:
+# $binlog_limit= 3 -- print three events
+# $binlog_limit= 4, 3 -- skip four events, print the three next events
+#
+# $keep_gtid_events
+# By default, Gtid_log_event and Previous_gtid_log_event are
+# filtered out, so that the output is independent of whether GTIDs
+# are enabled or not. If this flag is set, events are kept but
+# the actual GTID values are masked out.
+
+--let $include_filename= show_binlog_events.inc
+--source include/begin_include_file.inc
--let $is_relay_log= 0
--source include/show_events.inc
+
+--let $include_filename= show_binlog_events.inc
+--source include/end_include_file.inc
diff --git a/mysql-test/include/show_binlog_events2.inc b/mysql-test/include/show_binlog_events2.inc
index c32d12537fd..b036709b81d 100644
--- a/mysql-test/include/show_binlog_events2.inc
+++ b/mysql-test/include/show_binlog_events2.inc
@@ -1,5 +1,17 @@
---let $binlog_start=245
---replace_result $binlog_start <binlog_start>
+if ($binlog_start)
+{
+ --let $_binlog_start=$binlog_start
+}
+if (!$binlog_start)
+{
+ --let $_binlog_start=248
+}
+if ($binlog_file)
+{
+ --let $_in_binlog_file=in '$binlog_file'
+}
+--let $_from_binlog_start=from $_binlog_start
+--replace_result "$_from_binlog_start" "from <binlog_start>" $MYSQLTEST_VARDIR MYSQLTEST_VARDIR
--replace_column 2 # 5 #
---replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/
---eval show binlog events from $binlog_start
+--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /file_id=[0-9]+/file_id=#/ /GTID [0-9]+-[0-9]+-[0-9]+/GTID #-#-#/
+--eval show binlog events $_in_binlog_file from $_binlog_start
diff --git a/mysql-test/include/show_events.inc b/mysql-test/include/show_events.inc
index ff5a7105c24..7917b6740cf 100644
--- a/mysql-test/include/show_events.inc
+++ b/mysql-test/include/show_events.inc
@@ -1,38 +1,110 @@
-##############################################################################
-# It's an auxiliary file used to show binary log events or relay log events.
-# It is only called by show_binlog_events.inc and show_relaylog_events.inc.
-##############################################################################
+# ==== Purpose ====
+#
+# Auxiliary file used in include/show_binlog_events.inc and
+# include/show_relaylog_events.inc.
+#
+# ==== Usage ====
+#
+# See include/show_binlog_events.inc
-if (!$binlog_start)
-{
- # If $binlog_start is not set, we will set it as the second event's
- # position. The first event(Description Event) is always ignored. For
- # description event's length might be changed because of adding new events,
- # 'SHOW BINLOG EVENTS LIMIT 1' is used to get the right value.
- --let $binlog_start= query_get_value(SHOW BINLOG EVENTS LIMIT 1, End_log_pos, 1)
-}
+--let $include_filename= show_events.inc
+--source include/begin_include_file.inc
+
+--let $_se_old_statement= $statement
---let $_statement=show binlog events
+--let $statement=show BINLOG events
if ($is_relay_log)
{
- --let $_statement=show relaylog events
+ --let $statement=show relaylog events
}
if ($binlog_file)
{
- --let $_statement= $_statement in '$binlog_file'
+ --let $_binlog_file= $binlog_file
+ if ($binlog_file == 'LAST')
+ {
+ if ($is_relay_log)
+ {
+ --let $_binlog_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
+ }
+ if (!$is_relay_log)
+ {
+ --let $_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
+ }
+ }
+ --let $statement= $statement in '$_binlog_file'
}
---let $_statement= $_statement from $binlog_start
+# Do not modify $binlog_start - if we did, it could wrongly persist until a
+# later call of show_events.inc.
+if ($binlog_start)
+{
+ --let $_binlog_start= $binlog_start
+}
+
+if (!$binlog_start)
+{
+ # If $binlog_start is not set, we will set it as the fourth event's
+ # position (second in relay log which has not Binlog Checkpoint nor
+ # Gtid_list events).
+ # The first three events (Description Event, Gtid list, and Binlog Checkpoint
+ # event) are always ignored. For description event's length might be changed
+ # because of adding new events, 'SHOW BINLOG EVENTS LIMIT 3' is used to get
+ # the right value.
+ if ($is_relay_log)
+ {
+ --let $_binlog_start= query_get_value($statement LIMIT 1, End_log_pos, 1)
+ }
+ if (!$is_relay_log)
+ {
+ --let $_binlog_start= query_get_value($statement LIMIT 3, End_log_pos, 3)
+ }
+}
-# Cannot use if($binlog_limit) since the variable may begin with a 0
+--let $statement= $statement from $_binlog_start
-if (`SELECT '$binlog_limit' <> ''`)
+if ($binlog_limit != '')
{
- --let $_statement= $_statement limit $binlog_limit
+ --let $statement= $statement limit $binlog_limit
}
---replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $binlog_start <binlog_start>
---replace_column 2 # 4 # 5 #
---replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /file_id=[0-9]+/file_id=#/ /block_len=[0-9]+/block_len=#/ /Server ver:.*$/SERVER_VERSION, BINLOG_VERSION/
---eval $_statement
+# Execute the statement and write to $output_file
+--let $output_file= GENERATE
+--source include/write_result_to_file.inc
+
+# Filter the file through the following script.
+--delimiter ||
+let $script=
+ # todo: use select_columns instead (requires updating all result files)
+ s{([^\t]*\t)[^\t]*(\t[^\t]*\t)[^\t]*\t[^\t]*(\t[^\t]*)}{DOLLAR1#DOLLAR2#\t#DOLLAR3};
+ s{/\* xid=.* \*/}{/\* XID \*/};
+ s{table_id: [0-9]+}{table_id: #};
+ s{file_id=[0-9]+}{file_id=#};
+ s{block_len=[0-9]+}{block_len=#};
+ s{Server ver:.*DOLLAR}{SERVER_VERSION, BINLOG_VERSION};
+ s{GTID [0-9]+-[0-9]+-[0-9]+}{GTID #-#-#};
+ s{\[([0-9]-[0-9]-[0-9]+,?)+\]}{[#-#-#]};
+ s{cid=[0-9]+}{cid=#};
+ s{SQL_LOAD-[a-z,0-9,-]*.[a-z]*}{SQL_LOAD-<SERVER UUID>-<MASTER server-id>-<file-id>.<extension>};
+ s{rand_seed1=[0-9]*,rand_seed2=[0-9]*}{rand_seed1=<seed 1>,rand_seed2=<seed 2>};
+ s{((?:master|slave|slave-relay)-bin\.[0-9]{6};pos=)[0-9]+DOLLAR}{DOLLAR1POS};
+ s{SONAME ".*"}{SONAME "LIB"};
+ s{DOLLARmysqltest_vardir}{MYSQLTEST_VARDIR}g;
+||
+--let $pre_script= my DOLLARmysqltest_vardir = DOLLARENV{'MYSQLTEST_VARDIR'};
+--delimiter ;
+
+#--let $select_columns= 1 3 6
+--let $input_file= $output_file
+--source include/filter_file.inc
+
+# Write to result file
+--cat_file $output_file
+
+# Remove the file
+--remove_file $output_file
+
+--let $statement= $_se_old_statement
+
+--let $include_filename= show_events.inc
+--source include/end_include_file.inc
diff --git a/mysql-test/include/show_slave_status.inc b/mysql-test/include/show_slave_status.inc
index 41b5ee17ecd..ba2e1b0c48a 100644
--- a/mysql-test/include/show_slave_status.inc
+++ b/mysql-test/include/show_slave_status.inc
@@ -67,7 +67,21 @@
#
# --let $slave_sql_mode= NO_BACKSLASH_ESCAPES
#
-
+# $all_slaves_status
+# If set, use SHOW ALL SLAVES STATUS instead of SHOW SLAVE STATUS
+# and get the column values from all rows. Example:
+#
+# --let $all_slaves_status= 1
+#
+# $slave_name
+# If set, use SHOW SLAVE '<slave_name>' STATUS instead of SHOW SLAVE STATUS.
+# The name must be quoted (can be a quoted empty string).
+# Example:
+#
+# --let $slave_name= 'm1'
+#
+# Note: $all_slaves_status and $slave_name are mutually exclusive.
+#
--let $_show_slave_status_items=$status_items
if (!$status_items)
@@ -75,6 +89,21 @@ if (!$status_items)
--die Bug in test case: The mysqltest variable $status_items is not set.
}
+--let $_show_query=SHOW SLAVE STATUS
+
+if ($all_slaves_status)
+{
+ if ($slave_name)
+ {
+ --die Bug in test case: Both $all_slaves_status and $slave_name are set.
+ }
+ --let $_show_query=SHOW ALL SLAVES STATUS
+}
+if ($slave_name)
+{
+ --let $_show_query=SHOW SLAVE $slave_name STATUS
+}
+
--let $_slave_sql_mode= NO_BACKSLASH_ESCAPES
if ($slave_sql_mode)
@@ -86,18 +115,27 @@ if ($slave_sql_mode)
eval SET sql_mode= '$_slave_sql_mode';
--enable_query_log
+--let $_slave_field_result_replace= /[\\\\]/\// $slave_field_result_replace
while ($_show_slave_status_items)
{
--let $_show_slave_status_name= `SELECT SUBSTRING_INDEX('$_show_slave_status_items', ',', 1)`
--let $_show_slave_status_items= `SELECT LTRIM(SUBSTRING('$_show_slave_status_items', LENGTH('$_show_slave_status_name') + 2))`
- --replace_regex /\.[\\\/]master/master/
- --let $_show_slave_status_value= query_get_value(SHOW SLAVE STATUS, $_show_slave_status_name, 1)
- --let $_slave_field_result_replace= /[\\]/\// $slave_field_result_replace
- --replace_regex $_slave_field_result_replace
- --let $_show_slave_status_value= `SELECT REPLACE("$_show_slave_status_value", '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')`
- --echo $_show_slave_status_name = '$_show_slave_status_value'
+ --let $num= 1
+ --let $_show_slave_status_value=
+ while ($_show_slave_status_value != 'No such row')
+ {
+ --replace_regex /\.[\\\/]master/master/
+ --let $_show_slave_status_value= query_get_value($_show_query, $_show_slave_status_name, $num)
+ if ($_show_slave_status_value != 'No such row')
+ {
+ --replace_regex $_slave_field_result_replace
+ --let $_show_slave_status_value= `SELECT REPLACE("$_show_slave_status_value", '$MYSQL_TEST_DIR', 'MYSQL_TEST_DIR')`
+ --echo $_show_slave_status_name = '$_show_slave_status_value'
+ --inc $num
+ }
+ }
}
diff --git a/mysql-test/include/shutdown_mysqld.inc b/mysql-test/include/shutdown_mysqld.inc
new file mode 100644
index 00000000000..e28f3c244ca
--- /dev/null
+++ b/mysql-test/include/shutdown_mysqld.inc
@@ -0,0 +1,32 @@
+# ==== Usage ====
+#
+# [--let $shutdown_timeout= 30]
+# [--let $allow_rpl_inited= 1]
+# --source include/shutdown_mysqld.inc
+
+# The default value is empty
+--let $server_shutdown_timeout=
+
+if ($shutdown_timeout)
+{
+ --let $server_shutdown_timeout= $shutdown_timeout
+}
+
+# This is the first half of include/restart_mysqld.inc.
+if ($rpl_inited)
+{
+ if (!$allow_rpl_inited)
+ {
+ --die ERROR IN TEST: When using the replication test framework (master-slave.inc, rpl_init.inc etc), use rpl_restart_server.inc instead of restart_mysqld.inc. If you know what you are doing and you really have to use restart_mysqld.inc, set allow_rpl_inited=1 before you source restart_mysqld.inc
+ }
+}
+
+# Write file to make mysql-test-run.pl expect the "crash", but don't start it
+--let $_server_id= `SELECT @@server_id`
+--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.$_server_id.expect
+--exec echo "wait" > $_expect_file_name
+
+# Send shutdown to the connected server
+--shutdown_server $server_shutdown_timeout
+--source include/wait_until_disconnected.inc
+
diff --git a/mysql-test/include/start_mysqld.inc b/mysql-test/include/start_mysqld.inc
new file mode 100644
index 00000000000..e31f26aad8c
--- /dev/null
+++ b/mysql-test/include/start_mysqld.inc
@@ -0,0 +1,21 @@
+# Include this script only after using shutdown_mysqld.inc
+# where $_expect_file_name was initialized.
+# Write file to make mysql-test-run.pl start up the server again
+if ($restart_parameters)
+{
+ --exec echo "restart: $restart_parameters" > $_expect_file_name
+}
+if (!$restart_parameters)
+{
+ --exec echo "restart" > $_expect_file_name
+}
+
+# Turn on reconnect
+--enable_reconnect
+
+# Call script that will poll the server waiting for it to be back online again
+--source include/wait_until_connected_again.inc
+
+# Turn off reconnect again
+--disable_reconnect
+
diff --git a/mysql-test/include/sync_slave_sql_with_io.inc b/mysql-test/include/sync_slave_sql_with_io.inc
index 8048f7a177c..9efede9a61f 100644
--- a/mysql-test/include/sync_slave_sql_with_io.inc
+++ b/mysql-test/include/sync_slave_sql_with_io.inc
@@ -26,6 +26,10 @@ let $_slave_timeout= $slave_timeout;
if (!$_slave_timeout)
{
let $_slave_timeout= 300;
+ if ($VALGRIND_TEST)
+ {
+ let $_slave_timeout= 1500;
+ }
}
--let $_master_log_file= query_get_value(SHOW SLAVE STATUS, Master_Log_File, 1)
diff --git a/mysql-test/include/sync_with_master_gtid.inc b/mysql-test/include/sync_with_master_gtid.inc
new file mode 100644
index 00000000000..777711b979c
--- /dev/null
+++ b/mysql-test/include/sync_with_master_gtid.inc
@@ -0,0 +1,52 @@
+# ==== Purpose ====
+#
+# Wait until the slave has reached a certain GTID position.
+# Similar to --sync_with_master, but using GTID instead of old-style
+# binlog file/offset coordinates.
+#
+#
+# ==== Usage ====
+#
+# --let $master_pos= `SELECT @@GLOBAL.gtid_binlog_pos`
+# [--let $slave_timeout= NUMBER]
+# [--let $rpl_debug= 1]
+# --source include/sync_with_master_gtid.inc
+#
+# Syncs slave to the specified GTID position.
+#
+# Must be called on the slave.
+#
+# Parameters:
+# $master_pos
+# The GTID position to sync to. Typically obtained from
+# @@GLOBAL.gtid_binlog_pos on the master.
+#
+# $slave_timeout
+# Timeout in seconds. The default is 2 minutes.
+#
+# $rpl_debug
+# See include/rpl_init.inc
+
+--let $include_filename= sync_with_master_gtid.inc
+--source include/begin_include_file.inc
+
+let $_slave_timeout= $slave_timeout;
+if (!$_slave_timeout)
+{
+ let $_slave_timeout= 120;
+ if ($VALGRIND_TEST)
+ {
+ let $_slave_timeout= 1200;
+ }
+}
+
+--let $_result= `SELECT master_gtid_wait('$master_pos', $_slave_timeout)`
+if ($_result == -1)
+{
+ --let $_current_gtid_pos= `SELECT @@GLOBAL.gtid_slave_pos`
+ --echo Timeout in master_gtid_wait('$master_pos', $_slave_timeout), current slave GTID position is: $_current_gtid_pos.
+ --die Failed to sync with master
+}
+
+--let $include_filename= sync_with_master_gtid.inc
+--source include/end_include_file.inc
diff --git a/mysql-test/include/system_db_struct.inc b/mysql-test/include/system_db_struct.inc
index 123c82484b9..9467c023dba 100644
--- a/mysql-test/include/system_db_struct.inc
+++ b/mysql-test/include/system_db_struct.inc
@@ -16,3 +16,6 @@ show create table proc;
show create table event;
show create table general_log;
show create table slow_log;
+show create table table_stats;
+show create table column_stats;
+show create table index_stats;
diff --git a/mysql-test/include/type_hrtime.inc b/mysql-test/include/type_hrtime.inc
index cd631f25632..5d847d72195 100644
--- a/mysql-test/include/type_hrtime.inc
+++ b/mysql-test/include/type_hrtime.inc
@@ -1,6 +1,8 @@
--source include/have_innodb.inc
+SET timestamp=UNIX_TIMESTAMP('2001-02-03 10:20:30');
+
--disable_warnings
drop table if exists t1, t2, t3;
--enable_warnings
@@ -126,3 +128,4 @@ select * from t2;
drop view v1;
drop table t1, t2;
+SET timestamp=DEFAULT;
diff --git a/mysql-test/include/wait_for_binlog_checkpoint.inc b/mysql-test/include/wait_for_binlog_checkpoint.inc
new file mode 100644
index 00000000000..960cf4e41b1
--- /dev/null
+++ b/mysql-test/include/wait_for_binlog_checkpoint.inc
@@ -0,0 +1,53 @@
+# include/wait_for_binlog_checkpoint.inc
+#
+# SUMMARY
+#
+# Wait until binlog checkpoint has been logged for current binlog file.
+# This is useful to avoid races with output difference for binlog
+# checkpoints, as these are logged asynchronously from the binlog
+# background thread.
+#
+# USAGE:
+#
+# --source include/wait_for_binlog_checkpoint.inc
+
+let $_wait_count= 300;
+
+let $_found= 0;
+
+while ($_wait_count)
+{
+ dec $_wait_count;
+ let $_cur_binlog= query_get_value(SHOW MASTER STATUS, File, 1);
+ let $_more= 1;
+ let $_row= 1;
+ while ($_more)
+ {
+ let $_event= query_get_value(SHOW BINLOG EVENTS IN "$_cur_binlog", Event_type, $_row);
+ if ($_event == "No such row")
+ {
+ let $_more= 0;
+ }
+ if ($_event == "Binlog_checkpoint")
+ {
+ let $_info= query_get_value(SHOW BINLOG EVENTS IN "$_cur_binlog", Info, $_row);
+ if (`SELECT INSTR("$_info", "$_cur_binlog") != 0`)
+ {
+ let $_more= 0;
+ let $_wait_count= 0;
+ let $_found= 1;
+ }
+ }
+ inc $_row;
+ }
+ if ($_wait_count)
+ {
+ real_sleep 0.1;
+ }
+}
+
+if (!$_found)
+{
+ eval SHOW BINLOG EVENTS IN "$_cur_binlog";
+ --die ERROR: failed while waiting for binlog checkpoint $_cur_binlog
+}
diff --git a/mysql-test/include/wait_for_purge.inc b/mysql-test/include/wait_for_purge.inc
new file mode 100644
index 00000000000..8cd3c4394e1
--- /dev/null
+++ b/mysql-test/include/wait_for_purge.inc
@@ -0,0 +1,53 @@
+# include/wait_for_purge.inc
+#
+# SUMMARY
+#
+# Repeatedly attempt to purge binlogs up to a specific point, until
+# SHOW BINARY LOGS shows it has succeeded.
+# This can be useful to avoid races where slaves are stopped but the
+# corresponding binlog dump thread on the master has not yet terminated.
+# Async binlog checkpoints can also delay purge.
+#
+# Note that it may be necessary to inject at least one event in the binlog
+# after stopping slaves, or master may not detect stop of slave for a long
+# time (or forever), depending on details of test case, if replication
+# heartbeat is enabled, etc.
+#
+# USAGE:
+#
+# --let $purge_binlogs_to=master-bin.000003
+# --source include/wait_for_purge.inc
+#
+# SIDE EFFECTS:
+#
+# Disables --query_log while running, enables it afterwards.
+
+--echo include/wait_for_purge.inc "$purge_binlogs_to"
+
+let $_wait_count= 300;
+let $_done= 0;
+
+--disable_query_log
+while ($_wait_count)
+{
+ dec $_wait_count;
+ eval PURGE BINARY LOGS TO "$purge_binlogs_to";
+ let $_cur_binlog= query_get_value(SHOW BINARY LOGS, Log_name, 1);
+ if (`SELECT "$_cur_binlog" = "$purge_binlogs_to"`)
+ {
+ let $_done= 1;
+ let $_wait_count= 0;
+ }
+ if ($_wait_count)
+ {
+ real_sleep 0.1;
+ }
+}
+
+if (!$_done)
+{
+ SHOW FULL PROCESSLIST;
+ eval SHOW BINARY LOGS;
+ --die ERROR: failed while waiting for binlog purge to $purge_binlogs_to
+}
+--enable_query_log
diff --git a/mysql-test/include/wait_for_slave_param.inc b/mysql-test/include/wait_for_slave_param.inc
index d6cff32b398..25020d46ed9 100644
--- a/mysql-test/include/wait_for_slave_param.inc
+++ b/mysql-test/include/wait_for_slave_param.inc
@@ -12,7 +12,7 @@
# [--let $slave_timeout= NUMBER]
# [--let $slave_error_param= [Slave_SQL_Errno | Slave_IO_Errno]]
# [--let $rpl_debug= 1]
-# --source include/slave_wait_param.inc
+# --source include/wait_for_slave_param.inc
#
# Parameters:
#
@@ -50,6 +50,10 @@ let $_slave_timeout= $slave_timeout;
if (!$_slave_timeout)
{
let $_slave_timeout= 300;
+ if ($VALGRIND_TEST)
+ {
+ let $_slave_timeout= 1500;
+ }
}
if ($slave_error_param == '')
diff --git a/mysql-test/include/wait_innodb_all_purged.inc b/mysql-test/include/wait_innodb_all_purged.inc
new file mode 100644
index 00000000000..97b038acc44
--- /dev/null
+++ b/mysql-test/include/wait_innodb_all_purged.inc
@@ -0,0 +1,59 @@
+# include/wait_innodb_all_purged.inc
+#
+# SUMMARY
+#
+# Waits until purged all undo records of innodb, or operation times out.
+#
+# USAGE
+#
+# --source include/wait_innodb_all_purged.inc
+#
+--source include/have_innodb.inc
+--source include/have_debug.inc
+
+--disable_query_log
+
+let $wait_counter_init= 300;
+if ($wait_timeout)
+{
+ let $wait_counter_init= `SELECT $wait_timeout * 10`;
+}
+# Reset $wait_timeout so that its value won't be used on subsequent
+# calls, and default will be used instead.
+let $wait_timeout= 0;
+
+let $wait_counter= $wait_counter_init;
+
+# Keep track of how many times the wait condition is tested
+let $wait_condition_reps= 0;
+let $prev_trx_age= 0;
+while ($wait_counter)
+{
+ let $trx_age = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS
+WHERE VARIABLE_NAME = 'INNODB_PURGE_TRX_ID_AGE';`;
+
+ if ($trx_age != $prev_trx_age)
+ {
+ let $wait_counter= $wait_counter_init;
+ let $prev_trx_age= $trx_age;
+ }
+
+ let $success= `SELECT $trx_age < 1`;
+ inc $wait_condition_reps;
+ if ($success)
+ {
+ let $wait_counter= 0;
+ }
+ if (!$success)
+ {
+ set global innodb_purge_run_now=ON;
+ real_sleep 0.1;
+ dec $wait_counter;
+ }
+}
+if (!$success)
+{
+ echo Timeout in wait_innodb_all_purged.inc for INNODB_PURGE_TRX_ID_AGE = $trx_age;
+}
+
+--enable_query_log
diff --git a/mysql-test/include/wait_show_condition.inc b/mysql-test/include/wait_show_condition.inc
index ae1600a7e30..b8dd9bdf971 100644
--- a/mysql-test/include/wait_show_condition.inc
+++ b/mysql-test/include/wait_show_condition.inc
@@ -127,5 +127,6 @@ if (!$found)
echo # field : $field;
echo # condition : $condition;
echo # max_run_time : $max_run_time;
+ eval $show_statement;
}
diff --git a/mysql-test/include/wait_until_connected_again.inc b/mysql-test/include/wait_until_connected_again.inc
index 96240e36db7..6f64ef45440 100644
--- a/mysql-test/include/wait_until_connected_again.inc
+++ b/mysql-test/include/wait_until_connected_again.inc
@@ -14,7 +14,7 @@ while ($mysql_errno)
# Strangely enough, the server might return "Too many connections"
# while being shutdown, thus 1040 is an "allowed" error
# See BUG#36228
- --error 0,1040,1053,2002,2003,2005,2006,2013
+ --error 0,1040,1053,2002,2003,2005,2006,2013,1927
show status;
dec $counter;
diff --git a/mysql-test/include/wait_until_disconnected.inc b/mysql-test/include/wait_until_disconnected.inc
index 71361682442..658bf0be739 100644
--- a/mysql-test/include/wait_until_disconnected.inc
+++ b/mysql-test/include/wait_until_disconnected.inc
@@ -12,7 +12,7 @@ while (!$mysql_errno)
# Strangely enough, the server might return "Too many connections"
# while being shutdown, thus 1040 is an "allowed" error.
# See BUG#36228.
- --error 0,1040,1053,2002,2003,2005,2006,2013
+ --error 0,1040,1053,2002,2003,2005,2006,2013,1927
show status;
dec $counter;
diff --git a/mysql-test/include/weight_string.inc b/mysql-test/include/weight_string.inc
new file mode 100644
index 00000000000..1ae8801c560
--- /dev/null
+++ b/mysql-test/include/weight_string.inc
@@ -0,0 +1,66 @@
+select @@collation_connection;
+
+#
+# MDEV-5180 Data type for WEIGHT_STRING is too short in some cases
+#
+CREATE TABLE t1 AS SELECT 'a' AS a;
+SHOW CREATE TABLE t1;
+CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1;
+SHOW CREATE TABLE t2;
+SELECT HEX(WEIGHT_STRING(a)) FROM t1;
+SELECT HEX(ws) FROM t2;
+DROP TABLE t2;
+DROP TABLE t1;
+
+CREATE TABLE t1 AS SELECT REPEAT('a',5) AS a;
+SHOW CREATE TABLE t1;
+CREATE TABLE t2 AS SELECT WEIGHT_STRING(a) AS ws FROM t1;
+SHOW CREATE TABLE t2;
+SELECT HEX(WEIGHT_STRING(a)) FROM t1;
+SELECT HEX(ws) FROM t2;
+DROP TABLE t2;
+CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(3)) AS ws FROM t1;
+SHOW CREATE TABLE t2;
+SELECT HEX(WEIGHT_STRING(a AS CHAR(3))) FROM t1;
+SELECT HEX(ws) FROM t2;
+DROP TABLE t2;
+CREATE TABLE t2 AS SELECT WEIGHT_STRING(a AS CHAR(10)) AS ws FROM t1;
+SHOW CREATE TABLE t2;
+SELECT HEX(WEIGHT_STRING(a AS CHAR(10))) FROM t1;
+SELECT HEX(ws) FROM t2;
+DROP TABLE t2;
+DROP TABLE t1;
+#
+# End of MDEV-5180
+#
+
+select hex(weight_string('a'));
+select hex(weight_string('A'));
+select hex(weight_string('abc'));
+select hex(weight_string('abc' as char(2)));
+select hex(weight_string('abc' as char(3)));
+select hex(weight_string('abc' as char(5)));
+
+# Read 2 characters from the source string (the last character is not used).
+select hex(weight_string('abc', 1, 2, 0xC0));
+select hex(weight_string('abc', 2, 2, 0xC0));
+select hex(weight_string('abc', 3, 2, 0xC0));
+select hex(weight_string('abc', 4, 2, 0xC0));
+select hex(weight_string('abc', 5, 2, 0xC0));
+select hex(weight_string('abc',25, 2, 0xC0));
+
+# Read 3 characters from the source string (the entire string is used).
+select hex(weight_string('abc', 1, 3, 0xC0));
+select hex(weight_string('abc', 2, 3, 0xC0));
+select hex(weight_string('abc', 3, 3, 0xC0));
+select hex(weight_string('abc', 4, 3, 0xC0));
+select hex(weight_string('abc', 5, 3, 0xC0));
+select hex(weight_string('abc',25, 3, 0xC0));
+
+# Read 4 characters from the source string (extra space is added)
+select hex(weight_string('abc', 1, 4, 0xC0));
+select hex(weight_string('abc', 2, 4, 0xC0));
+select hex(weight_string('abc', 3, 4, 0xC0));
+select hex(weight_string('abc', 4, 4, 0xC0));
+select hex(weight_string('abc', 5, 4, 0xC0));
+select hex(weight_string('abc',25, 4, 0xC0));
diff --git a/mysql-test/include/weight_string_8140.inc b/mysql-test/include/weight_string_8140.inc
new file mode 100644
index 00000000000..f91d40a1381
--- /dev/null
+++ b/mysql-test/include/weight_string_8140.inc
@@ -0,0 +1,36 @@
+select collation(cast(0x8140 as char));
+select hex(weight_string(cast(0x6141 as char)));
+select hex(weight_string(cast(0x8140 as char)));
+select hex(weight_string(cast(0x8140 as char) as char(1)));
+select hex(weight_string(cast(0x81408140 as char) as char(1)));
+select hex(weight_string(cast(0x8140 as char) as char(3)));
+select hex(weight_string(cast(0x81408140 as char) as char(3)));
+select hex(weight_string(cast(0x408140 as char) as char(3)));
+select hex(weight_string(cast(0x4081408140 as char) as char(3)));
+select hex(weight_string(cast(0x40814081408140 as char) as char(3)));
+select hex(weight_string(cast(0x4040814081408140 as char) as char(3)));
+
+# Read 2 characters from the source string (the last character is not used)
+select hex(weight_string(cast(0x814081408140 as char), 1, 2, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 2, 2, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 3, 2, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 4, 2, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 5, 2, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char),25, 2, 0xC0));
+
+# Read 3 characters from the source string (the entire string is used)
+select hex(weight_string(cast(0x814081408140 as char), 1, 3, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 2, 3, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 3, 3, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 4, 3, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 5, 3, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char),25, 3, 0xC0));
+
+# Read 4 characters from the source string (extra space is added)
+select hex(weight_string(cast(0x814081408140 as char), 1, 4, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 2, 4, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 3, 4, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 4, 4, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char), 5, 4, 0xC0));
+select hex(weight_string(cast(0x814081408140 as char),25, 4, 0xC0));
+
diff --git a/mysql-test/include/weight_string_8EA1.inc b/mysql-test/include/weight_string_8EA1.inc
new file mode 100644
index 00000000000..0396fc9d808
--- /dev/null
+++ b/mysql-test/include/weight_string_8EA1.inc
@@ -0,0 +1,36 @@
+select collation(cast(0xA1A1 as char));
+select hex(weight_string(cast(0x6141 as char)));
+select hex(weight_string(cast(0x8EA1 as char)));
+select hex(weight_string(cast(0x8EA1 as char) as char(1)));
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(1)));
+select hex(weight_string(cast(0x8EA1 as char) as char(3)));
+select hex(weight_string(cast(0x8EA18EA1 as char) as char(3)));
+select hex(weight_string(cast(0x408EA1 as char) as char(3)));
+select hex(weight_string(cast(0x408EA18EA1 as char) as char(3)));
+select hex(weight_string(cast(0x408EA18EA18EA1 as char) as char(3)));
+select hex(weight_string(cast(0x40408EA18EA18EA1 as char) as char(3)));
+
+# Read 2 characters from the source string (the last character is not used)
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 2, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 2, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 2, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 2, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 2, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 2, 0xC0));
+
+# Read 3 characters from the source string (the entire string is used)
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 3, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 3, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 3, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 3, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 3, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 3, 0xC0));
+
+# Read 4 characters from the source string (extra space is added)
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 1, 4, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 2, 4, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 3, 4, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 4, 4, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char), 5, 4, 0xC0));
+select hex(weight_string(cast(0x8EA18EA18EA1 as char),25, 4, 0xC0));
+
diff --git a/mysql-test/include/weight_string_8FA2C3.inc b/mysql-test/include/weight_string_8FA2C3.inc
new file mode 100644
index 00000000000..936b2e6c5e0
--- /dev/null
+++ b/mysql-test/include/weight_string_8FA2C3.inc
@@ -0,0 +1,36 @@
+select collation(cast(0x8FA2C3 as char));
+select hex(weight_string(cast(0x6141 as char)));
+select hex(weight_string(cast(0x8FA2C3 as char)));
+select hex(weight_string(cast(0x8FA2C3 as char) as char(1)));
+select hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(1)));
+select hex(weight_string(cast(0x8FA2C3 as char) as char(3)));
+select hex(weight_string(cast(0x8FA2C38FA2C3 as char) as char(3)));
+select hex(weight_string(cast(0x408FA2C3 as char) as char(3)));
+select hex(weight_string(cast(0x408FA2C38FA2C3 as char) as char(3)));
+select hex(weight_string(cast(0x408FA2C38FA2C38FA2C3 as char) as char(3)));
+select hex(weight_string(cast(0x40408FA2C38FA2C38FA2C3 as char) as char(3)));
+
+# Read 2 characters from the source string (the last character is not used)
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 2, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 2, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 2, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 2, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 2, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 2, 0xC0));
+
+# Read 3 characters from the source string (the entire string is used)
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 3, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 3, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 3, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 3, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 3, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 3, 0xC0));
+
+# Read 4 characters from the source string (extra space is added)
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 1, 4, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 2, 4, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 3, 4, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 4, 4, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char), 5, 4, 0xC0));
+select hex(weight_string(cast(0x8FA2C38FA2C38FA2C3 as char),25, 4, 0xC0));
+
diff --git a/mysql-test/include/weight_string_A1A1.inc b/mysql-test/include/weight_string_A1A1.inc
new file mode 100644
index 00000000000..34ace06d203
--- /dev/null
+++ b/mysql-test/include/weight_string_A1A1.inc
@@ -0,0 +1,36 @@
+select collation(cast(0xA1A1 as char));
+select hex(weight_string(cast(0x6141 as char)));
+select hex(weight_string(cast(0xA1A1 as char)));
+select hex(weight_string(cast(0xA1A1 as char) as char(1)));
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(1)));
+select hex(weight_string(cast(0xA1A1 as char) as char(3)));
+select hex(weight_string(cast(0xA1A1A1A1 as char) as char(3)));
+select hex(weight_string(cast(0x40A1A1 as char) as char(3)));
+select hex(weight_string(cast(0x40A1A1A1A1 as char) as char(3)));
+select hex(weight_string(cast(0x40A1A1A1A1A1A1 as char) as char(3)));
+select hex(weight_string(cast(0x4040A1A1A1A1A1A1 as char) as char(3)));
+
+# Read 2 characters from the source string (the last character is not used)
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 2, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 2, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 2, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 2, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 2, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 2, 0xC0));
+
+# Read 3 characters from the source string (the entire string is used)
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 3, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 3, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 3, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 3, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 3, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 3, 0xC0));
+
+# Read 4 characters from the source string (extra space is added)
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 1, 4, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 2, 4, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 3, 4, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 4, 4, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char), 5, 4, 0xC0));
+select hex(weight_string(cast(0xA1A1A1A1A1A1 as char),25, 4, 0xC0));
+
diff --git a/mysql-test/include/weight_string_chde.inc b/mysql-test/include/weight_string_chde.inc
new file mode 100644
index 00000000000..97c929605f9
--- /dev/null
+++ b/mysql-test/include/weight_string_chde.inc
@@ -0,0 +1,59 @@
+select @@collation_connection;
+select collation(cast(_latin1 0xDF as char));
+select hex(weight_string('s'));
+select hex(weight_string(cast(_latin1 0xDF as char)));
+select hex(weight_string(cast(_latin1 0xDF as char) as char(1)));
+select hex(weight_string('c'));
+select hex(weight_string('h'));
+select hex(weight_string('ch'));
+select hex(weight_string('i'));
+# contraction 'ch' plus expansion 'sharp s'
+select hex(weight_string(cast(_latin1 0x6368DF as char)));
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(1)));
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(2)));
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(3)));
+select hex(weight_string(cast(_latin1 0x6368DF as char) as char(4)));
+# expansion 'sharp s' plus contraction 'ch'
+select hex(weight_string(cast(_latin1 0xDF6368 as char)));
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(1)));
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(2)));
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(3)));
+select hex(weight_string(cast(_latin1 0xDF6368 as char) as char(4)));
+
+# contraction 'ch' plus expansion 'sharp s'
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 2, 0xC0));
+
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 3, 0xC0));
+
+select hex(weight_string(cast(_latin1 0x6368DF as char), 1, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 2, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 3, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char), 4, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x6368DF as char),25, 4, 0xC0));
+
+# expansion 'sharp s' plus contraction 'ch'
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 2,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 2,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 2,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 2,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 2,0xC0));
+
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 3,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 3,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 3,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 3,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 3,0xC0));
+
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 1, 4,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 2, 4,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 3, 4,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char), 4, 4,0xC0));
+select hex(weight_string(cast(_latin1 0xDF6368 as char),25, 4,0xC0));
diff --git a/mysql-test/include/weight_string_euro.inc b/mysql-test/include/weight_string_euro.inc
new file mode 100644
index 00000000000..e888bdc3df0
--- /dev/null
+++ b/mysql-test/include/weight_string_euro.inc
@@ -0,0 +1,30 @@
+select @@collation_connection;
+select hex(weight_string(cast(_latin1 0x80 as char)));
+select hex(weight_string(cast(_latin1 0x808080 as char)));
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(2)));
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(3)));
+select hex(weight_string(cast(_latin1 0x808080 as char) as char(5)));
+
+# Read 2 characters from the source string (the last character is not used).
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 2, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 2, 0xC0));
+
+# Read 3 characters from the source string (the entire string is used).
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 3, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 3, 0xC0));
+
+# Read 4 characters from the source string (extra space is added)
+select hex(weight_string(cast(_latin1 0x808080 as char), 1, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 2, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 3, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 4, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char), 5, 4, 0xC0));
+select hex(weight_string(cast(_latin1 0x808080 as char),25, 4, 0xC0));
diff --git a/mysql-test/include/weight_string_l1.inc b/mysql-test/include/weight_string_l1.inc
new file mode 100644
index 00000000000..f5ad279e563
--- /dev/null
+++ b/mysql-test/include/weight_string_l1.inc
@@ -0,0 +1,10 @@
+select @@collation_connection;
+select hex(weight_string('a' LEVEL 1));
+select hex(weight_string('A' LEVEL 1));
+select hex(weight_string('abc' LEVEL 1));
+select hex(weight_string('abc' as char(2) LEVEL 1));
+select hex(weight_string('abc' as char(3) LEVEL 1));
+select hex(weight_string('abc' as char(5) LEVEL 1));
+select hex(weight_string('abc' as char(5) LEVEL 1 REVERSE));
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC));
+select hex(weight_string('abc' as char(5) LEVEL 1 DESC REVERSE));
diff --git a/mysql-test/include/weight_string_l12.inc b/mysql-test/include/weight_string_l12.inc
new file mode 100644
index 00000000000..4ecde8f5f5b
--- /dev/null
+++ b/mysql-test/include/weight_string_l12.inc
@@ -0,0 +1,5 @@
+select @@collation_connection;
+select hex(weight_string('a' LEVEL 1,2));
+select hex(weight_string('a' LEVEL 1-2));
+select hex(weight_string('A' LEVEL 1,2));
+select hex(weight_string('A' LEVEL 1-2));
diff --git a/mysql-test/include/weight_string_l14.inc b/mysql-test/include/weight_string_l14.inc
new file mode 100644
index 00000000000..2add64700c3
--- /dev/null
+++ b/mysql-test/include/weight_string_l14.inc
@@ -0,0 +1,37 @@
+select @@collation_connection;
+select hex(weight_string('a' LEVEL 1,3));
+select hex(weight_string('a' LEVEL 1-3));
+select hex(weight_string('A' LEVEL 1,3));
+select hex(weight_string('A' LEVEL 1-3));
+
+select hex(weight_string('a' LEVEL 1,4));
+select hex(weight_string('a' LEVEL 1-4));
+select hex(weight_string('A' LEVEL 1,4));
+select hex(weight_string('A' LEVEL 1-4));
+
+select hex(weight_string('a' LEVEL 2,3));
+select hex(weight_string('a' LEVEL 2-3));
+select hex(weight_string('A' LEVEL 2,3));
+select hex(weight_string('A' LEVEL 2-3));
+
+select hex(weight_string('a' LEVEL 2,4));
+select hex(weight_string('a' LEVEL 2-4));
+select hex(weight_string('A' LEVEL 2,4));
+select hex(weight_string('A' LEVEL 2-4));
+
+select hex(weight_string('a' LEVEL 3,4));
+select hex(weight_string('a' LEVEL 3-4));
+select hex(weight_string('A' LEVEL 3,4));
+select hex(weight_string('A' LEVEL 3-4));
+
+select hex(weight_string('a' LEVEL 1,2,3,4));
+select hex(weight_string('a' LEVEL 2,3,4));
+select hex(weight_string('a' LEVEL 1,3,4));
+select hex(weight_string('a' LEVEL 1,2,3));
+
+# If any number is less than 1, it is treated as 1.
+select hex(weight_string('a' LEVEL 0));
+
+#If any number is greater than the maximum, it is treated as the maximum.
+select hex(weight_string('a' LEVEL 8));
+select hex(weight_string('a' LEVEL 1,8));
diff --git a/mysql-test/include/weight_string_l2.inc b/mysql-test/include/weight_string_l2.inc
new file mode 100644
index 00000000000..1802fcc9c79
--- /dev/null
+++ b/mysql-test/include/weight_string_l2.inc
@@ -0,0 +1,7 @@
+select @@collation_connection;
+select hex(weight_string('a' LEVEL 2));
+select hex(weight_string('A' LEVEL 2));
+select hex(weight_string('abc' LEVEL 2));
+select hex(weight_string('abc' as char(2) LEVEL 2));
+select hex(weight_string('abc' as char(3) LEVEL 2));
+select hex(weight_string('abc' as char(5) LEVEL 2));
diff --git a/mysql-test/include/weight_string_l3.inc b/mysql-test/include/weight_string_l3.inc
new file mode 100644
index 00000000000..cae1dc3bf30
--- /dev/null
+++ b/mysql-test/include/weight_string_l3.inc
@@ -0,0 +1,10 @@
+select @@collation_connection;
+select hex(weight_string('a' LEVEL 3));
+select hex(weight_string('A' LEVEL 3));
+select hex(weight_string('abc' LEVEL 3));
+select hex(weight_string('abc' as char(2) LEVEL 3));
+select hex(weight_string('abc' as char(3) LEVEL 3));
+select hex(weight_string('Abc' as char(5) LEVEL 3));
+select hex(weight_string('Abc' as char(5) LEVEL 3 REVERSE));
+select hex(weight_string('Abc' as char(5) LEVEL 3 DESC));
+select hex(weight_string('Abc' as char(5) LEVEL 3 DESC REVERSE));
diff --git a/mysql-test/include/weight_string_l4.inc b/mysql-test/include/weight_string_l4.inc
new file mode 100644
index 00000000000..811632bfc30
--- /dev/null
+++ b/mysql-test/include/weight_string_l4.inc
@@ -0,0 +1,10 @@
+select @@collation_connection;
+select hex(weight_string('a' LEVEL 4));
+select hex(weight_string('A' LEVEL 4));
+select hex(weight_string('abc' LEVEL 4));
+select hex(weight_string('abc' as char(2) LEVEL 4));
+select hex(weight_string('abc' as char(3) LEVEL 4));
+select hex(weight_string('abc' as char(5) LEVEL 4));
+select hex(weight_string('abc' as char(5) LEVEL 4 REVERSE));
+select hex(weight_string('abc' as char(5) LEVEL 4 DESC));
+select hex(weight_string('abc' as char(5) LEVEL 4 DESC REVERSE));
diff --git a/mysql-test/include/world_schema_utf8.inc b/mysql-test/include/world_schema_utf8.inc
new file mode 100644
index 00000000000..2a09c5d32d5
--- /dev/null
+++ b/mysql-test/include/world_schema_utf8.inc
@@ -0,0 +1,25 @@
+CREATE TABLE Country (
+ Code char(3) NOT NULL default '',
+ Name char(52) NOT NULL default '',
+ SurfaceArea float(10,2) NOT NULL default '0.00',
+ Population int(11) NOT NULL default '0',
+ Capital int(11) default NULL,
+ PRIMARY KEY (Code),
+ UNIQUE INDEX (Name)
+) CHARACTER SET utf8 COLLATE utf8_bin;
+CREATE TABLE City (
+ ID int(11) NOT NULL auto_increment,
+ Name char(35) NOT NULL default '',
+ Country char(3) NOT NULL default '',
+ Population int(11) NOT NULL default '0',
+ PRIMARY KEY (ID),
+ INDEX (Population),
+ INDEX (Country)
+) CHARACTER SET utf8 COLLATE utf8_bin;
+CREATE TABLE CountryLanguage (
+ Country char(3) NOT NULL default '',
+ Language char(30) NOT NULL default '',
+ Percentage float(3,1) NOT NULL default '0.0',
+ PRIMARY KEY (Country, Language),
+ INDEX (Percentage)
+) CHARACTER SET utf8 COLLATE utf8_bin;
diff --git a/mysql-test/include/write_result_to_file.inc b/mysql-test/include/write_result_to_file.inc
new file mode 100644
index 00000000000..3e2ddf48957
--- /dev/null
+++ b/mysql-test/include/write_result_to_file.inc
@@ -0,0 +1,77 @@
+# ==== Purpose ====
+#
+# Execute a statement and write the result to a file. This is useful
+# if the output needs more advanced parsing than can be done by
+# mysqltest commands.
+#
+# ==== Usage ====
+#
+# --let $statement= <STATEMENT>
+# --let $output_file= {<FILE>|GENERATE}
+# [--let $server_number= <NUMBER>]
+# [--let $dont_print_statement= 1]
+# --source include/write_result_to_file.inc
+#
+# Parameters:
+# $statement
+# The statement to execute.
+#
+# $server_number
+# 1 for the master, 2 for the slave, 3 for next server, etc.
+# If omitted, uses current connection.
+#
+# $output_file
+# Name of file to write. If omitted, generates a new filename and
+# stores the name both in the mysqltest variable $output_file and
+# in the environment variable $OUTPUT_FILE.
+#
+# $dont_print_statement
+# By default, the statement is echoed to the result log. If the
+# statement contains non-deterministic output, set this variable
+# to suppress it.
+
+--let _WRTF_SERVER_NUMBER= $server_number
+if (!$server_number)
+{
+ --let _WRTF_SERVER_NUMBER= `SELECT 1 + @@PORT - $MASTER_MYPORT`
+}
+
+--let $_write_result_msg= [server=$_WRTF_SERVER_NUMBER]
+if (!$dont_print_statement)
+{
+ --let $_write_result_msg= [server=$_WRTF_SERVER_NUMBER statement=$statement]
+}
+
+--let $include_filename= write_result_to_file.inc $_write_result_msg
+--source include/begin_include_file.inc
+
+if ($statement == '')
+{
+ --die !!!ERROR IN TEST: mysqltest variable 'statement' not set in write_result_to_file.inc
+}
+--let _WRTF_STATEMENT= $statement
+
+if (!$output_file)
+{
+ --die !!!ERROR IN TEST: mysqltest variable 'output_file' not set in write_result_to_file.inc
+}
+if ($output_file == GENERATE)
+{
+ --let $output_file= `SELECT UUID()`
+ --let $output_file= $MYSQLTEST_VARDIR/tmp/_stmt_file_$output_file
+}
+--let _WRTF_OUTPUT_FILE= $output_file
+
+perl;
+ my $stmt= $ENV{'_WRTF_STATEMENT'};
+ my $server_number= $ENV{'_WRTF_SERVER_NUMBER'};
+ my $mysql = $ENV{'MYSQL'};
+ $mysql =~ s/( --|$)/ --defaults-group-suffix=.$server_number$1/;
+ my $outfile = $ENV{'_WRTF_OUTPUT_FILE'};
+ open MYSQL, "| $mysql > $outfile" or die "Failed to open pipe to client on server '$server_number': $!";
+ print MYSQL $stmt, ';' or die "Error printing statement to MYSQL pipe: $!";
+ close MYSQL or die "Error closing MYSQL pipe: $!";
+EOF
+
+--let $include_filename= write_result_to_file.inc [$write_result_msg]
+--source include/end_include_file.inc