diff options
Diffstat (limited to 'mysql-test/include')
69 files changed, 5426 insertions, 110 deletions
diff --git a/mysql-test/include/binlog_inject_error.inc b/mysql-test/include/binlog_inject_error.inc new file mode 100644 index 00000000000..6465f7943a4 --- /dev/null +++ b/mysql-test/include/binlog_inject_error.inc @@ -0,0 +1,22 @@ +# +# === Name +# +# binlog_inject_error.inc +# +# === Description +# +# Inject binlog write error when running the query, verifies that the +# query is ended with the proper error (ER_ERROR_ON_WRITE). +# +# === Usage +# +# let query= 'CREATE TABLE t1 (a INT)'; +# source include/binlog_inject_error.inc; +# + +SET GLOBAL debug='d,injecting_fault_writing'; +--echo $query; +--replace_regex /(errno: .*)/(errno: #)/ +--error ER_ERROR_ON_WRITE +--eval $query +SET GLOBAL debug=''; diff --git a/mysql-test/include/bug38347.inc b/mysql-test/include/bug38347.inc new file mode 100644 index 00000000000..ca1dbfa1bd2 --- /dev/null +++ b/mysql-test/include/bug38347.inc @@ -0,0 +1,21 @@ + +--echo +SHOW GRANTS FOR mysqltest_u1@localhost; + +--echo +--echo # connection: con1 (mysqltest_u1@mysqltest_db1) +--connect (con1,localhost,mysqltest_u1,,mysqltest_db1) +--connection con1 + +--echo +SHOW CREATE TABLE t1; + +--echo +--echo # connection: default +--connection default + +--disconnect con1 + +--echo +REVOKE ALL PRIVILEGES, GRANT OPTION FROM mysqltest_u1@localhost; +SHOW GRANTS FOR mysqltest_u1@localhost; diff --git a/mysql-test/include/check-warnings.test b/mysql-test/include/check-warnings.test index 5295dd51a85..41b0a98e43b 100644 --- a/mysql-test/include/check-warnings.test +++ b/mysql-test/include/check-warnings.test @@ -57,5 +57,5 @@ if (`select @result = 0`){ skip OK; } --enable_query_log -echo ^ Found warnings!!; +echo ^ Found warnings in $log_error; exit; diff --git a/mysql-test/include/check_ipv6.inc b/mysql-test/include/check_ipv6.inc new file mode 100644 index 00000000000..14d04b11e83 --- /dev/null +++ b/mysql-test/include/check_ipv6.inc @@ -0,0 +1,14 @@ +# Check if ipv6 is available. If not, server is crashing (see BUG#48915). +--disable_query_log +--disable_abort_on_error +connect (checkcon123456789,::1,root,,test); +if($mysql_errno) +{ +skip wrong IP; +} +connection default; +disconnect checkcon123456789; +--enable_abort_on_error +--enable_query_log +# end check + diff --git a/mysql-test/include/check_key_reads.inc b/mysql-test/include/check_key_reads.inc new file mode 100644 index 00000000000..cfb754bccd4 --- /dev/null +++ b/mysql-test/include/check_key_reads.inc @@ -0,0 +1,6 @@ +# include file for checking if variable key_reads is zero +let $key_reads= query_get_value(SHOW STATUS LIKE 'key_reads',Value,1); +--disable_query_log +eval SELECT IF($key_reads = 0, "Yes!", "No!") as 'Zero key reads?'; +FLUSH STATUS; +--enable_query_log diff --git a/mysql-test/include/check_key_req.inc b/mysql-test/include/check_key_req.inc new file mode 100644 index 00000000000..92a81f09d91 --- /dev/null +++ b/mysql-test/include/check_key_req.inc @@ -0,0 +1,9 @@ +# include file for checking if variable key_reads = key_read_requests +let $key_reads= query_get_value(SHOW STATUS LIKE 'key_reads',Value,1); +let $key_r_req= query_get_value(SHOW STATUS LIKE 'key_read_requests',Value,1); +let $key_writes= query_get_value(SHOW STATUS LIKE 'key_writes',Value,1); +let $key_w_req= query_get_value(SHOW STATUS LIKE 'key_write_requests',Value,1); +--disable_query_log +eval SELECT IF($key_reads = $key_r_req, "reads == requests", "reads != requests") as 'reads vs requests'; +eval SELECT IF($key_writes = $key_w_req, "writes == requests", "writes != requests") as 'writes vs requests'; +--enable_query_log diff --git a/mysql-test/include/cleanup_fake_relay_log.inc b/mysql-test/include/cleanup_fake_relay_log.inc index 43aa46cb657..269cd04ca34 100644 --- a/mysql-test/include/cleanup_fake_relay_log.inc +++ b/mysql-test/include/cleanup_fake_relay_log.inc @@ -8,9 +8,10 @@ --echo Cleaning up after setup_fake_relay_log.inc -# Remove files. -remove_file $_fake_relay_log; -remove_file $_fake_relay_index; --disable_query_log +--disable_warnings +STOP SLAVE SQL_THREAD; +RESET SLAVE; eval SET @@global.relay_log_purge= $_fake_relay_log_purge; +--enable_warnings --enable_query_log diff --git a/mysql-test/include/commit.inc b/mysql-test/include/commit.inc index d91ba8291fd..59d4f6be524 100644 --- a/mysql-test/include/commit.inc +++ b/mysql-test/include/commit.inc @@ -547,9 +547,9 @@ call p_verify_status_increment(0, 0, 0, 0); --echo # the binary log. --echo # select f1(); -call p_verify_status_increment(0, 0, 1, 0); +call p_verify_status_increment(1, 0, 1, 0); commit; -call p_verify_status_increment(0, 0, 1, 0); +call p_verify_status_increment(1, 0, 1, 0); --echo # 17. Read-only statement, a function changes non-trans-table. --echo # @@ -557,15 +557,19 @@ call p_verify_status_increment(0, 0, 1, 0); --echo # non-transactional changes saved in the transaction cache to --echo # the binary log. --echo # +--disable_warnings select f1() from t1; -call p_verify_status_increment(1, 0, 2, 0); +--enable_warnings +call p_verify_status_increment(2, 0, 2, 0); commit; -call p_verify_status_increment(1, 0, 2, 0); +call p_verify_status_increment(2, 0, 2, 0); --echo # 18. Read-write statement: UPDATE, change 0 (transactional) rows. --echo # select count(*) from t2; +--disable_warnings update t1 set a=2 where a=f1()+10; +--enable_warnings select count(*) from t2; call p_verify_status_increment(2, 0, 2, 0); commit; @@ -579,7 +583,7 @@ call p_verify_status_increment(2, 0, 2, 0); drop table t2; set sql_mode=no_engine_substitution; create temporary table t2 (a int); -call p_verify_status_increment(0, 0, 0, 0); +call p_verify_status_increment(1, 0, 0, 0); set sql_mode=default; --echo # 19. A function changes temp-trans-table. --echo # @@ -636,9 +640,9 @@ call p_verify_status_increment(2, 0, 1, 0); --echo # 25. DDL: DROP TEMPORARY TABLE, does not start a transaction --echo # drop temporary table t2; -call p_verify_status_increment(0, 0, 0, 0); +call p_verify_status_increment(1, 0, 0, 0); commit; -call p_verify_status_increment(0, 0, 0, 0); +call p_verify_status_increment(1, 0, 0, 0); --echo # 26. Verify that SET AUTOCOMMIT issues an implicit commit --echo # @@ -719,21 +723,21 @@ 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(4, 4, 4, 4); +call p_verify_status_increment(2, 0, 4, 4); create table t3 select a from t2; -call p_verify_status_increment(4, 4, 4, 4); +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, 2, 2, 2); +call p_verify_status_increment(2, 0, 2, 0); rename table t4 to t3; -call p_verify_status_increment(2, 2, 2, 2); +call p_verify_status_increment(0, 0, 0, 0); truncate table t3; -call p_verify_status_increment(4, 4, 4, 4); +call p_verify_status_increment(2, 0, 2, 0); create view v1 as select * from t2; -call p_verify_status_increment(1, 0, 1, 0); +call p_verify_status_increment(2, 0, 2, 0); check table t1; -call p_verify_status_increment(3, 0, 3, 0); +call p_verify_status_increment(2, 0, 2, 0); --echo # Sic: after this bug is fixed, CHECK leaves no pending transaction commit; call p_verify_status_increment(0, 0, 0, 0); diff --git a/mysql-test/include/concurrent.inc b/mysql-test/include/concurrent.inc index 66f8a65a102..0b7299a3c34 100644 --- a/mysql-test/include/concurrent.inc +++ b/mysql-test/include/concurrent.inc @@ -25,8 +25,6 @@ # new wrapper t/concurrent_innodb_safelog.test # ---source include/not_embedded.inc - connection default; # # Show prerequisites for this test. diff --git a/mysql-test/include/ctype_datetime.inc b/mysql-test/include/ctype_datetime.inc new file mode 100644 index 00000000000..dc70f1f38a9 --- /dev/null +++ b/mysql-test/include/ctype_datetime.inc @@ -0,0 +1,11 @@ +# +# Bug#32390 Character sets: casting utf32 to/from date doesn't work +# +CREATE TABLE t1 AS SELECT repeat('a',20) AS s1 LIMIT 0; +SET timestamp=1216359724; +INSERT INTO t1 VALUES (current_date); +INSERT INTO t1 VALUES (current_time); +INSERT INTO t1 VALUES (current_timestamp); +SELECT s1, hex(s1) FROM t1; +DROP TABLE t1; +SET timestamp=0; diff --git a/mysql-test/include/ctype_like.inc b/mysql-test/include/ctype_like.inc new file mode 100644 index 00000000000..38de0bf2671 --- /dev/null +++ b/mysql-test/include/ctype_like.inc @@ -0,0 +1,50 @@ +select @@collation_connection; + +# +# Create a table with a nullable varchar(10) column +# using currect character_set_connection. +create table t1 as select repeat(' ',10) as a union select null; +alter table t1 add key(a); +show create table t1; +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +explain select * from t1 where a like 'abc%'; +explain select * from t1 where a like concat('abc','%'); +select * from t1 where a like "abc%"; +select * from t1 where a like concat("abc","%"); +select * from t1 where a like "ABC%"; +select * from t1 where a like "test%"; +select * from t1 where a like "te_t"; +select * from t1 where a like "%a%"; +select * from t1 where a like "%abcd%"; +select * from t1 where a like "%abc\d%"; +drop table t1; + +# +# Bug #2619 ucs2 LIKE comparison fails in some cases +# + +select 'AA' like 'AA'; +select 'AA' like 'A%A'; +select 'AA' like 'A%%A'; +select 'AA' like 'AA%'; +select 'AA' like '%AA%'; +select 'AA' like '%A'; +select 'AA' like '%AA'; +select 'AA' like 'A%A%'; +select 'AA' like '_%_%'; +select 'AA' like '%A%A'; +select 'AAA'like 'A%A%A'; + +select 'AZ' like 'AZ'; +select 'AZ' like 'A%Z'; +select 'AZ' like 'A%%Z'; +select 'AZ' like 'AZ%'; +select 'AZ' like '%AZ%'; +select 'AZ' like '%Z'; +select 'AZ' like '%AZ'; +select 'AZ' like 'A%Z%'; +select 'AZ' like '_%_%'; +select 'AZ' like '%A%Z'; +select 'AZ' like 'A_'; +select 'AZ' like '_Z'; +select 'AMZ'like 'A%M%Z'; diff --git a/mysql-test/include/ctype_numconv.inc b/mysql-test/include/ctype_numconv.inc new file mode 100644 index 00000000000..959ca7dfeea --- /dev/null +++ b/mysql-test/include/ctype_numconv.inc @@ -0,0 +1,1606 @@ +--echo # +--echo # Start of WL#2649 Number-to-string conversions +--echo # +# +# Basic constants +# +select hex(concat(1)); +create table t1 as select concat(1) as c1; +show create table t1; +select hex(c1) from t1; +drop table t1; + +select hex(concat(18446744073709551615)); +create table t1 as select concat(18446744073709551615) as c1; +show create table t1; +select hex(c1) from t1; +drop table t1; + +select hex(concat(1.1)); +create table t1 as select concat(1.1) as c1; +show create table t1; +select hex(c1) from t1; +drop table t1; + + +# +# Arithmetic operators +# + +select hex(concat('a', 1+2)), charset(concat(1+2)); +create table t1 as select concat(1+2) as c1; +show create table t1; +drop table t1; + +select hex(concat(1-2)); +create table t1 as select concat(1-2) as c1; +show create table t1; +drop table t1; + +select hex(concat(1*2)); +create table t1 as select concat(1*2) as c1; +show create table t1; +drop table t1; + +select hex(concat(1/2)); +create table t1 as select concat(1/2) as c1; +show create table t1; +drop table t1; + +select hex(concat(1 div 2)); +create table t1 as select concat(1 div 2) as c1; +show create table t1; +drop table t1; + +select hex(concat(1 % 2)); +create table t1 as select concat(1 % 2) as c1; +show create table t1; +drop table t1; + +select hex(concat(-1)); +create table t1 as select concat(-1) as c1; +show create table t1; +drop table t1; + +select hex(concat(-(1+2))); +create table t1 as select concat(-(1+2)) as c1; +show create table t1; +drop table t1; + + +# +# Bit functions +# + +select hex(concat(1|2)); +create table t1 as select concat(1|2) as c1; +show create table t1; +drop table t1; + +select hex(concat(1&2)); +create table t1 as select concat(1&2) as c1; +show create table t1; +drop table t1; + +select hex(concat(bit_count(12))); +create table t1 as select concat(bit_count(12)) as c1; +show create table t1; +drop table t1; + +select hex(concat(2<<1)); +create table t1 as select concat(2<<1) as c1; +show create table t1; +drop table t1; + +select hex(concat(2>>1)); +create table t1 as select concat(2>>1) as c1; +show create table t1; +drop table t1; + +select hex(concat(~0)); +create table t1 as select concat(~0) as c1; +show create table t1; +drop table t1; + +select hex(concat(3^2)); +create table t1 as select concat(3^2) as c1; +show create table t1; +drop table t1; + + + +# +# Math functions +# +# Note, some tests use LEFT(func(),1) to avoid +# non-deterministic results on various platforms. +# + +select hex(concat(abs(-2))); +create table t1 as select concat(abs(-2)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(exp(2)),1)); +create table t1 as select concat(exp(2)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(log(2)),1)); +create table t1 as select concat(log(2)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(log2(2)),1)); +create table t1 as select concat(log2(2)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(log10(2)),1)); +create table t1 as select concat(log10(2)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(sqrt(2)),1)); +create table t1 as select concat(sqrt(2)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(pow(2,2)),1)); +create table t1 as select concat(pow(2,2)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(acos(0.5)),1)); +create table t1 as select concat(acos(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(asin(0.5)),1)); +create table t1 as select concat(asin(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(atan(0.5)),1)); +create table t1 as select concat(atan(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(cos(0.5)),1)); +create table t1 as select concat(cos(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(sin(0.5)),1)); +create table t1 as select concat(sin(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(left(concat(tan(0.5)),1)); +create table t1 as select concat(tan(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(concat(degrees(0))); +create table t1 as select concat(degrees(0)) as c1; +show create table t1; +drop table t1; + +select hex(concat(radians(0))); +create table t1 as select concat(radians(0)) as c1; +show create table t1; +drop table t1; + +select hex(concat(ceiling(0.5))); +create table t1 as select concat(ceiling(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(concat(floor(0.5))); +create table t1 as select concat(floor(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(concat(round(0.5))); +create table t1 as select concat(round(0.5)) as c1; +show create table t1; +drop table t1; + +select hex(concat(sign(0.5))); +create table t1 as select concat(sign(0.5)) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(rand()) as c1; +show create table t1; +drop table t1; + + +# +# String functions +# + +select hex(concat(length('a'))); +create table t1 as select concat(length('a')) as c1; +show create table t1; +drop table t1; + +select hex(concat(char_length('a'))); +create table t1 as select concat(char_length('a')) as c1; +show create table t1; +drop table t1; + +select hex(concat(bit_length('a'))); +create table t1 as select concat(bit_length('a')) as c1; +show create table t1; +drop table t1; + +select hex(concat(coercibility('a'))); +create table t1 as select concat(coercibility('a')) as c1; +show create table t1; +drop table t1; + +select hex(concat(locate('a','a'))); +create table t1 as select concat(locate('a','a')) as c1; +show create table t1; +drop table t1; + +select hex(concat(field('c','a','b','c'))); +create table t1 as select concat(field('c','a','b','c')) as c1; +show create table t1; +drop table t1; + +select hex(concat(ascii(61))); +create table t1 as select concat(ascii(61)) as c1; +show create table t1; +drop table t1; + +select hex(concat(ord(61))); +create table t1 as select concat(ord(61)) as c1; +show create table t1; +drop table t1; + +select hex(concat(find_in_set('b','a,b,c,d'))); +create table t1 as select concat(find_in_set('b','a,b,c,d')) as c1; +show create table t1; +drop table t1; + + +# +# String hash functions +# + +select md5('a'), hex(md5('a')); +create table t1 as select md5('a') as c1; +show create table t1; +drop table t1; + +select old_password('a'), hex(old_password('a')); +create table t1 as select old_password('a') as c1; +show create table t1; +drop table t1; + +select password('a'), hex(password('a')); +create table t1 as select password('a') as c1; +show create table t1; +drop table t1; + +select sha('a'), hex(sha('a')); +create table t1 as select sha('a') as c1; +show create table t1; +drop table t1; + +select sha1('a'), hex(sha1('a')); +create table t1 as select sha1('a') as c1; +show create table t1; +drop table t1; + +#select sha2('a',224), hex(sha2('a',224)); +#create table t1 as select sha2('a',224) as c1; +#show create table t1; +#drop table t1; + + + +# +# CAST +# + +select hex(concat(cast('-1' as signed))); +create table t1 as select concat(cast('-1' as signed)) as c1; +show create table t1; +drop table t1; + +select hex(concat(cast('1' as unsigned))); +create table t1 as select concat(cast('1' as unsigned)) as c1; +show create table t1; +drop table t1; + +select hex(concat(cast(1/2 as decimal(5,5)))); +create table t1 as select concat(cast(1/2 as decimal(5,5))) as c1; +show create table t1; +drop table t1; + +select hex(concat(cast('2001-01-02 03:04:05' as date))); +create table t1 as select concat(cast('2001-01-02 03:04:05' as date)) as c1; +show create table t1; +select * from t1; +drop table t1; + +select hex(concat(cast('2001-01-02 03:04:05' as time))); +create table t1 as select concat(cast('2001-01-02 03:04:05' as time)) as c1; +show create table t1; +select * from t1; +drop table t1; + +select hex(concat(cast('2001-01-02' as datetime))); +create table t1 as select concat(cast('2001-01-02' as datetime)) as c1; +show create table t1; +select * from t1; +drop table t1; + + +# +# Aggregation: LEAST, GREATEST +# +select hex(concat(least(1,2))); +create table t1 as select concat(least(1,2)) as c1; +show create table t1; +drop table t1; + +select hex(concat(greatest(1,2))); +create table t1 as select concat(greatest(1,2)) as c1; +show create table t1; +drop table t1; + + +# +# Aggregation: CASE +# +select hex(concat(case when 11 then 22 else 33 end)); +create table t1 as select concat(case when 11 then 22 else 33 end) as c1; +show create table t1; +drop table t1; + + +# +# Aggregation: COALESCE +# +select hex(concat(coalesce(1,2))); +create table t1 as select concat(coalesce(1,2)) as c1; +show create table t1; +drop table t1; + + +# +# Aggregation: CONCAT_WS, GROUP_CONCAT +# +select hex(concat_ws(1,2,3)); +create table t1 as select concat_ws(1,2,3) as c1; +show create table t1; +drop table t1; + +select hex(group_concat(1,2,3)); +create table t1 as select group_concat(1,2,3) as c1; +show create table t1; +drop table t1; + +# +# Aggregation: UNION +# +create table t1 as select 1 as c1 union select 'a'; +show create table t1; +select hex(c1) from t1 order by c1; +drop table t1; + + +# +# Miscelaneous functions +# + +create table t1 as select concat(last_insert_id()) as c1; +show create table t1; +drop table t1; + +select hex(concat(benchmark(0,0))); +create table t1 as select concat(benchmark(0,0)) as c1; +show create table t1; +drop table t1; + +select hex(concat(sleep(0))); +create table t1 as select concat(sleep(0)) as c1; +show create table t1; +drop table t1; + +# Fails with "mtr --ps-protocol" for some reasons. +#select hex(concat(get_lock('a',0))); +#select hex(concat(release_lock('a'))); +#create table t1 as select concat(get_lock('a',0)) as c1; +#show create table t1; +#drop table t1; + +select hex(concat(is_free_lock('xxxx'))); +create table t1 as select concat(is_free_lock('xxxx')) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(is_used_lock('a')) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(release_lock('a')) as c1; +show create table t1; +drop table t1; + +select hex(concat(crc32(''))); +create table t1 as select concat(crc32('')) as c1; +show create table t1; +drop table t1; + +select hex(concat(uncompressed_length(''))); +create table t1 as select concat(uncompressed_length('')) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(connection_id()) as c1; +show create table t1; +drop table t1; + +select hex(concat(inet_aton('127.1.1.1'))); +create table t1 as select concat(inet_aton('127.1.1.1')) as c1; +show create table t1; +drop table t1; + +select hex(concat(inet_ntoa(2130772225))); +create table t1 as select concat(inet_ntoa(2130772225)) as c1; +select * from t1; +show create table t1; +drop table t1; + +select hex(concat(row_count())); +create table t1 as select concat(row_count()) as c1; +show create table t1; +drop table t1; + +select hex(concat(found_rows())); +create table t1 as select concat(found_rows()) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(uuid_short()) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(uuid()) as c1; +show create table t1; +drop table t1; + +# +# Make sure we can mix uuid() to a latin1 object +# with DERIVATION_IMPLICIT (and higher): +# (DERIVATION_COERCIBLE + MY_REPERTOIRE_ASCII allow to do so) +# +select coercibility(uuid()), coercibility(cast('a' as char character set latin1)); +select charset(concat(uuid(), cast('a' as char character set latin1))); +create table t1 as select concat(uuid(), cast('a' as char character set latin1)) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(master_pos_wait('non-existent',0,2)) as c1; +show create table t1; +drop table t1; + + +# +# User and system variable functions +# + +# User variables: INT +select hex(concat(@a1:=1)); +create table t1 as select concat(@a2:=2) as c1, @a3:=3 as c2; +select hex(c1) from t1; +show create table t1; +drop table t1; + +set @a2=1; +select hex(concat(@a2)); +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +show create table t1; +drop table t1; + +# User variables: REAL +select hex(concat(@a1:=sqrt(1))); +create table t1 as select concat(@a2:=sqrt(1)) as c1, @a3:=sqrt(1) as c2; +select hex(c1) from t1; +show create table t1; +drop table t1; + +set @a2=sqrt(1); +select hex(concat(@a2)); +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +show create table t1; +drop table t1; + +# User variables: DECIMAL +select hex(concat(@a1:=1.1)); +create table t1 as select concat(@a2:=1.1) as c1, @a3:=1.1 as c2; +select hex(c1) from t1; +show create table t1; +drop table t1; + +set @a2=1.1; +select hex(concat(@a2)); +create table t1 as select concat(@a2) as c1, @a2 as c2; +select hex(c1) from t1; +show create table t1; +drop table t1; + + +select hex(concat(@@ft_max_word_len)); +create table t1 as select concat(@@ft_max_word_len) as c1; +select hex(c1) from t1; +show create table t1; +drop table t1; + +# +# Comparison functions +# + +select hex(concat('a'='a' IS TRUE)); +create table t1 as select concat('a'='a' IS TRUE) as c1; +show create table t1; +drop table t1; + +select hex(concat('a'='a' IS NOT TRUE)); +create table t1 as select concat('a'='a' IS NOT TRUE) as c1; +show create table t1; +drop table t1; + +select hex(concat(NOT 'a'='a')); +create table t1 as select concat(NOT 'a'='a') as c1; +show create table t1; +drop table t1; + +select hex(concat('a' IS NULL)); +create table t1 as select concat('a' IS NULL) as c1; +show create table t1; +drop table t1; + +select hex(concat('a' IS NOT NULL)); +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +drop table t1; + +select hex(concat('a' rlike 'a')); +create table t1 as select concat('a' IS NOT NULL) as c1; +show create table t1; +drop table t1; + +select hex(concat(strcmp('a','b'))); +create table t1 as select concat(strcmp('a','b')) as c1; +show create table t1; +drop table t1; + +select hex(concat('a' like 'a')); +create table t1 as select concat('a' like 'b') as c1; +show create table t1; +drop table t1; + +select hex(concat('a' between 'b' and 'c')); +create table t1 as select concat('a' between 'b' and 'c') as c1; +show create table t1; +drop table t1; + +select hex(concat('a' in ('a','b'))); +create table t1 as select concat('a' in ('a','b')) as c1; +show create table t1; +drop table t1; + +select hex(concat(interval(23, 1, 15, 17, 30, 44, 200))); +create table t1 as select concat(interval(23, 1, 15, 17, 30, 44, 200)) as c1; +show create table t1; +drop table t1; + +create table t1 (a varchar(10), fulltext key(a)); +insert into t1 values ('a'); +select hex(concat(match (a) against ('a'))) from t1; +create table t2 as select concat(match (a) against ('a')) as a from t1; +show create table t2; +drop table t1, t2; + +select hex(ifnull(1,'a')); +create table t1 as select ifnull(1,'a') as c1; +show create table t1; +drop table t1; + +select hex(concat(ifnull(1,1))); +create table t1 as select concat(ifnull(1,1)) as c1; +show create table t1; +drop table t1; + +select hex(concat(ifnull(1.1,1.1))); +create table t1 as select concat(ifnull(1.1,1.1)) as c1; +show create table t1; +drop table t1; + +select hex(if(1,'b',1)); +create table t1 as select if(1,'b',1) as c1; +show create table t1; +drop table t1; + +select hex(if(1,1,'b')); +create table t1 as select if(1,1,'b') as c1; +show create table t1; +drop table t1; + +select hex(concat(if(1,1,1))); +create table t1 as select concat(if(1,1,1)) as c1; +show create table t1; +drop table t1; + +select hex(concat(nullif(1,2))); +create table t1 as select concat(nullif(1,2)) as c1; +show create table t1; +drop table t1; + +# +# GIS functions +# + +select hex(concat(Dimension(GeomFromText('LINESTRING(0 0,10 10)')))); +create table t1 as select concat(Dimension(GeomFromText('LINSTRING(0 0,10 10)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +create table t1 as select concat(NumGeometries(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)')))); +create table t1 as select concat(NumPoints(MultiPointFromText('LINESTRING(0 0,10 10)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)')))); +create table t1 as select concat(SRID(MultiPointFromText('MULTIPOINT(0 0,10 10)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')))); +create table t1 as select concat(NumInteriorRings(PolygonFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(IsEmpty(GeomFromText('POINT(1 1)')))); +create table t1 as select concat(IsEmpty(GeomFromText('Point(1 1)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(IsSimple(GeomFromText('POINT(1 1)')))); +create table t1 as select concat(IsSimple(GeomFromText('Point(1 1)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(IsClosed(GeomFromText('LineString(1 1,2 2)')))); +create table t1 as select concat(IsClosed(GeomFromText('LineString(1 1,2 2)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)')))); +create table t1 as select concat(Equals(GeomFromText('Point(1 1)'),GeomFromText('Point(1 1)'))) as c1; +drop table t1; + +select hex(concat(x(GeomFromText('Point(1 2)')))); +create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(y(GeomFromText('Point(1 2)')))); +create table t1 as select concat(x(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(GLength(GeomFromText('LineString(1 2,2 2)')))); +create table t1 as select concat(GLength(GeomFromText('LineString(1 2, 2 2)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))')))); +create table t1 as select concat(Area(GeomFromText('Polygon((0 0,1 0,1 1,0 1,0 0))'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(GeometryType(GeomFromText('Point(1 2)')))); +create table t1 as select concat(GeometryType(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +drop table t1; + +select hex(concat(AsText(GeomFromText('Point(1 2)')))); +create table t1 as select concat(AsText(GeomFromText('Point(1 2)'))) as c1; +show create table t1; +drop table t1; + + + +# +# Date/Time functions +# + +select hex(concat(period_add(200902, 2))); +create table t1 as select concat(period_add(200902, 2)) as c1; +show create table t1; +drop table t1; + +select hex(concat(period_diff(200902, 200802))); +create table t1 as select concat(period_add(200902, 200802)) as c1; +show create table t1; +drop table t1; + +select hex(concat(to_days(20090224))); +create table t1 as select concat(to_days(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(dayofmonth(20090224))); +create table t1 as select concat(dayofmonth(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(dayofyear(20090224))); +create table t1 as select concat(dayofyear(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(hour('10:11:12'))); +create table t1 as select concat(hour('10:11:12')) as c1; +show create table t1; +drop table t1; + +select hex(concat(minute('10:11:12'))); +create table t1 as select concat(minute('10:11:12')) as c1; +show create table t1; +drop table t1; + +select hex(concat(second('10:11:12'))); +create table t1 as select concat(second('10:11:12')) as c1; +show create table t1; +drop table t1; + +select hex(concat(quarter(20090224))); +create table t1 as select concat(quarter(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(week(20090224))); +create table t1 as select concat(week(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(yearweek(20090224))); +create table t1 as select concat(yearweek(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(year(20090224))); +create table t1 as select concat(year(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(weekday(20090224))); +create table t1 as select concat(weekday(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(dayofweek(20090224))); +create table t1 as select concat(dayofweek(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(unix_timestamp(20090224))); +create table t1 as select concat(unix_timestamp(20090224)) as c1; +show create table t1; +drop table t1; + +select hex(concat(time_to_sec('10:11:12'))); +create table t1 as select concat(time_to_sec('10:11:12')) as c1; +show create table t1; +drop table t1; + +select hex(concat(extract(year from 20090702))); +create table t1 as select concat(extract(year from 20090702)) as c1; +show create table t1; +drop table t1; + +select hex(concat(microsecond('12:00:00.123456'))); +create table t1 as select concat(microsecond('12:00:00.123456')) as c1; +show create table t1; +drop table t1; + +select hex(concat(month(20090224))); +create table t1 as select concat(month(20090224)) as c1; +show create table t1; +drop table t1; + + +create table t1 as select concat(last_day('2003-02-05')) as c1; +show create table t1; +select c1, hex(c1) from t1; +drop table t1; + +create table t1 as select concat(from_days(730669)) as c1; +show create table t1; +select c1, hex(c1) from t1; +drop table t1; + +create table t1 as select concat(curdate()) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(utc_date()) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(curtime()) as c1; +show create table t1; +drop table t1; + +create table t1 as select repeat('a',20) as c1 limit 0; +set timestamp=1216359724; +insert into t1 values (current_date); +insert into t1 values (current_time); +select c1, hex(c1) from t1; +drop table t1; + +create table t1 as select concat(utc_time()) as c1; +show create table t1; +drop table t1; + +select hex(concat(sec_to_time(2378))); +create table t1 as select concat(sec_to_time(2378)) as c1; +show create table t1; +drop table t1; + +select hex(concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00'))); +create table t1 as select concat(timediff('2001-01-02 00:00:00', '2001-01-01 00:00:00')) as c1; +show create table t1; +drop table t1; + +select hex(concat(maketime(10,11,12))); +create table t1 as select concat(maketime(10,11,12)) as c1; +show create table t1; +drop table t1; + +select hex(get_format(DATE,'USA')); +create table t1 as select get_format(DATE,'USA') as c1; +show create table t1; +drop table t1; + +select hex(left(concat(from_unixtime(1111885200)),4)); +create table t1 as select concat(from_unixtime(1111885200)) as c1; +show create table t1; +drop table t1; + +select hex(concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00'))); +create table t1 as select concat(convert_tz('2004-01-01 12:00:00','+10:00','-6:00')) as c1; +show create table t1; +drop table t1; + +select hex(concat(date_add('2004-01-01 12:00:00', interval 1 day))); +create table t1 as select concat(date_add('2004-01-01 12:00:00', interval 1 day)) as c1; +show create table t1; +select * from t1; +drop table t1; + +select hex(concat(makedate(2009,1))); +create table t1 as select concat(makedate(2009,1)) as c1; +show create table t1; +select * from t1; +drop table t1; + +create table t1 as select concat(now()) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(utc_timestamp()) as c1; +show create table t1; +drop table t1; + +create table t1 as select concat(sysdate()) as c1; +show create table t1; +drop table t1; + +select hex(concat(addtime('00:00:00','11:22:33'))); +create table t1 as select concat(addtime('00:00:00','11:22:33')) as c1; +show create table t1; +drop table t1; + +select hex(concat(subtime('23:59:59','11:22:33'))); +create table t1 as select concat(subtime('23:59:59','11:22:33')) as c1; +show create table t1; +drop table t1; + + +# +# Other string functions with numeric input +# +select hex(elt(1,2,3)); +create table t1 as select elt(1,2,3) as c1; +show create table t1; +drop table t1; + +select hex(export_set(1,2,3,4,2)); +create table t1 as select export_set(1,2,3,4,2) as c1; +show create table t1; +drop table t1; + +select hex(insert(1133,3,0,22)); +create table t1 as select insert(1133,3,0,22) as c1; +show create table t1; +drop table t1; + +select hex(lcase(123)); +create table t1 as select lcase(123) as c1; +show create table t1; +drop table t1; + +select hex(left(123,1)); +create table t1 as select left(123,1) as c1; +show create table t1; +drop table t1; + +select hex(lower(123)); +create table t1 as select lower(123) as c1; +show create table t1; +drop table t1; + +select hex(lpad(1,2,0)); +create table t1 as select lpad(1,2,0) as c1; +show create table t1; +drop table t1; + +select hex(ltrim(1)); +create table t1 as select ltrim(1) as c1; +show create table t1; +drop table t1; + +select hex(mid(1,1,1)); +create table t1 as select mid(1,1,1) as c1; +show create table t1; +drop table t1; + +select hex(repeat(1,2)); +create table t1 as select repeat(1,2) as c1; +show create table t1; +drop table t1; + +select hex(replace(1,1,2)); +create table t1 as select replace(1,1,2) as c1; +show create table t1; +drop table t1; + +select hex(reverse(12)); +create table t1 as select reverse(12) as c1; +show create table t1; +drop table t1; + +select hex(right(123,1)); +create table t1 as select right(123,1) as c1; +show create table t1; +drop table t1; + +select hex(rpad(1,2,0)); +create table t1 as select rpad(1,2,0) as c1; +show create table t1; +drop table t1; + +select hex(rtrim(1)); +create table t1 as select rtrim(1) as c1; +show create table t1; +drop table t1; + +select hex(soundex(1)); +create table t1 as select soundex(1) as c1; +show create table t1; +drop table t1; + +select hex(substring(1,1,1)); +create table t1 as select substring(1,1,1) as c1; +show create table t1; +drop table t1; + +select hex(trim(1)); +create table t1 as select trim(1) as c1; +show create table t1; +drop table t1; + +select hex(ucase(1)); +create table t1 as select ucase(1) as c1; +show create table t1; +drop table t1; + +select hex(upper(1)); +create table t1 as select upper(1) as c1; +show create table t1; +drop table t1; + + +# +# Bug#8204 +# +create table t1 as select repeat(' ', 64) as a limit 0; +show create table t1; +insert into t1 values ("1.1"), ("2.1"); +select a, hex(a) from t1; +update t1 set a= a + 0.1; +select a, hex(a) from t1; +drop table t1; + + +# +# Columns +# +create table t1 (a tinyint); +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a tinyint zerofill); +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a tinyint(4) zerofill); +insert into t1 values (1), (10), (100); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a smallint); +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a smallint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a mediumint); +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a mediumint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a int); +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a int zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a bigint); +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a bigint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a float); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +select concat(a) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a float zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a double); +insert into t1 values (123.456); +select hex(concat(a)) from t1; +select concat(a) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a double zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +select hex(concat(a)), a from t1; +drop table t1; + +create table t1 (a year(2)); +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a year); +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a bit(64)); +# BIT is always BINARY +insert into t1 values (1); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a timestamp); +insert into t1 values (0); +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +select hex(concat(a)) from t1; +select concat(a) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +select hex(concat(a)) from t1; +select concat(a) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +select hex(concat(a)) from t1; +create table t2 as select concat(a) from t1; +show create table t2; +drop table t1, t2; + + +# +# create view with string functions with numeric input +# +# Switched off in ucs tests due to bug#50716 +if ($not_ucs) +{ +create view v1 as select concat(1,2,3) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select concat_ws(',',1,2,3) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select elt(1,2,3) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select export_set(1,2,3,4,2) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select insert(1133,3,0,22) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select lcase(123) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select left(123,1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select lower(123) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select lpad(1,2,0) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select ltrim(1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select mid(1,1,1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select repeat(1,2) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select replace(1,1,2) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select reverse(12) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select right(123,1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select rpad(1,2,0) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select rtrim(1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select soundex(1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select substring(1,1,1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select trim(1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select ucase(1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; + +create view v1 as select upper(1) as c1; +show columns from v1; +select hex(c1) from v1; +drop view v1; +} + + +# +# Views from tables with numeric columns +# +create table t1 (a tinyint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a tinyint zerofill); +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a tinyint(30) zerofill); +insert into t1 values (1), (10), (100); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a decimal(10,2)); +insert into t1 values (123.45); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a smallint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a smallint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a mediumint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a mediumint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a int); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a int zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a bigint); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a bigint zerofill); +insert into t1 values (1), (10), (100), (1000), (10000); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a float); +insert into t1 values (123.456); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a float zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a double); +insert into t1 values (123.456); +select concat(a) from t1; +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a double zerofill); +insert into t1 values (1.1), (10.1), (100.1), (1000.1), (10000.1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a year(2)); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a year); +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a bit(64)); +# BIT is always BINARY +insert into t1 values (1); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a timestamp); +insert into t1 values (0); +insert into t1 values (20010203040506); +insert into t1 values (19800203040506); +insert into t1 values ('2001-02-03 04:05:06'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a date); +insert into t1 values ('2001-02-03'); +insert into t1 values (20010203); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a time); +insert into t1 values (1); +insert into t1 values ('01:02:03'); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +create table t1 (a datetime); +insert into t1 values ('2001-02-03 04:05:06'); +insert into t1 values (20010203040506); +create view v1(a) as select concat(a) from t1; +show columns from v1; +select hex(a) from v1; +drop table t1; +drop view v1; + +# +# User defined function returning numeric result +# +delimiter |; +create function f1 (par1 int) returns int +begin +return concat(par1); +end| +delimiter ;| + +set @a= f1(1); +select hex(@a); +select hex(concat(f1(1))); +create table t1 as select f1(1) as c1; +show create table t1; +drop table t1; +create table t1 as select concat(f1(1)) as c1; +show create table t1; +create view v1 as select concat(f1(1)) as c1; +show columns from v1; +drop table t1; +drop view v1; +drop function f1; + +delimiter |; +create function f1 (par1 decimal(18,2)) returns decimal(18,2) +begin +return concat(par1); +end| +delimiter ;| + +set @a= f1(123.45); +select hex(@a); +select hex(concat(f1(123.45))); +create table t1 as select f1(123.45) as c1; +show create table t1; +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +drop table t1; +drop view v1; +drop function f1; + +delimiter |; +create function f1 (par1 float) returns float +begin +return concat(par1); +end| +delimiter ;| + +set @a= f1(123.45); +select hex(@a); +select hex(concat(f1(123.45))); +create table t1 as select f1(123.45) as c1; +show create table t1; +drop table t1; +create table t1 as select concat(f1(123.45)) as c1; +show create table t1; +create view v1 as select concat(f1(123.45)) as c1; +show columns from v1; +drop table t1; +drop view v1; +drop function f1; + +delimiter |; +create function f1 (par1 date) returns date +begin +return concat(par1); +end| +delimiter ;| + +set @a= f1(cast('2001-01-02' as date)); +select hex(@a); +select hex(concat(f1(cast('2001-01-02' as date)))); +create table t1 as select f1(cast('2001-01-02' as date)) as c1; +show create table t1; +drop table t1; +create table t1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show create table t1; +create view v1 as select concat(f1(cast('2001-01-02' as date))) as c1; +show columns from v1; +drop table t1; +drop view v1; +drop function f1; + + +--echo # +--echo # End of WL#2649 Number-to-string conversions +--echo # + diff --git a/mysql-test/include/ctype_utf8_table.inc b/mysql-test/include/ctype_utf8_table.inc new file mode 100644 index 00000000000..28db21c06d2 --- /dev/null +++ b/mysql-test/include/ctype_utf8_table.inc @@ -0,0 +1,44 @@ +CREATE TABLE t1 (a CHAR(1)) CHARACTER SET utf8; +INSERT INTO t1 VALUES ('0'),('1'),('2'),('3'),('4'),('5'),('6'),('7'); +INSERT INTO t1 VALUES ('8'),('9'),('A'),('B'),('C'),('D'),('E'),('F'); +# +# Populate tables head and tail with values '00'-'FF' +# +CREATE TEMPORARY TABLE head AS SELECT concat(b1.a, b2.a) AS head FROM t1 b1, t1 b2; +CREATE TEMPORARY TABLE tail AS SELECT concat(b1.a, b2.a) AS tail FROM t1 b1, t1 b2; +CREATE TEMPORARY TABLE middle AS SELECT concat(b1.a, b2.a) AS middle FROM t1 b1, t1 b2; +DROP TABLE t1; + +CREATE TABLE t1 (a varchar(1)) CHARACTER SET utf8; + +# +# Populate single byte characters +# + +INSERT INTO t1 SELECT UNHEX(head) +FROM head WHERE (head BETWEEN '00' AND '7F') ORDER BY head; + +# +# Populate 2-byte byte characters: U+80..U+7FF: [C2-DF][80-BF] +# +INSERT INTO t1 +SELECT UNHEX(CONCAT(head,tail)) +FROM head, tail +WHERE (head BETWEEN 'C2' AND 'DF') AND (tail BETWEEN '80' AND 'BF') +ORDER BY head, tail; + + +# +# Populate 3-byte characters: U+800..U+FFFF: [E0-EF][80-BF][80-BF] +# excluding overlong [E0][80-9F][80-BF] +# +INSERT INTO t1 +SELECT UNHEX(CONCAT(head, middle, tail)) +FROM head, middle, tail +WHERE (head BETWEEN 'E0' AND 'EF') +AND (middle BETWEEN '80' AND 'BF') +AND (tail BETWEEN '80' AND 'BF') +AND NOT (head='E0' AND middle BETWEEN '80' AND '9F') +ORDER BY head, middle, tail; + +SELECT count(*) FROM t1; diff --git a/mysql-test/include/ctype_utf8mb4.inc b/mysql-test/include/ctype_utf8mb4.inc new file mode 100644 index 00000000000..d1cb64705cd --- /dev/null +++ b/mysql-test/include/ctype_utf8mb4.inc @@ -0,0 +1,1858 @@ +# +# Tests with the utf8mb4 character set +# +--disable_warnings +drop table if exists t1,t2; +--enable_warnings + +--echo # +--echo # Start of 5.5 tests +--echo # + +set names utf8mb4; + +select left(_utf8mb4 0xD0B0D0B1D0B2,1); +select right(_utf8mb4 0xD0B0D0B2D0B2,1); + +select locate('he','hello'); +select locate('he','hello',2); +select locate('lo','hello',2); +select locate('HE','hello'); +select locate('HE','hello',2); +select locate('LO','hello',2); +select locate('HE','hello' collate utf8mb4_bin); +select locate('HE','hello' collate utf8mb4_bin,2); +select locate('LO','hello' collate utf8mb4_bin,2); + +select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D0B1D0B2); +select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2); +select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2); +select locate(_utf8mb4 0xD091, _utf8mb4 0xD0B0D0B1D0B2 collate utf8mb4_bin); +select locate(_utf8mb4 0xD0B1, _utf8mb4 0xD0B0D091D0B2 collate utf8mb4_bin); + +select length(_utf8mb4 0xD0B1), bit_length(_utf8mb4 0xD0B1), char_length(_utf8mb4 0xD0B1); + +select 'a' like 'a'; +select 'A' like 'a'; +select 'A' like 'a' collate utf8mb4_bin; +select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD0B1,_utf8mb4 '%'); + +# Bug #6040: can't retrieve records with umlaut +# characters in case insensitive manner. +# Case insensitive search LIKE comparison +# was broken for multibyte characters: +select convert(_latin1'Günter André' using utf8mb4) like CONVERT(_latin1'GÜNTER%' USING utf8mb4); +select CONVERT(_koi8r'×ÁÓÑ' USING utf8mb4) LIKE CONVERT(_koi8r'÷áóñ' USING utf8mb4); +select CONVERT(_koi8r'÷áóñ' USING utf8mb4) LIKE CONVERT(_koi8r'×ÁÓÑ' USING utf8mb4); + +# +# Check the following: +# "a" == "a " +# "a\0" < "a" +# "a\0" < "a " + +SELECT 'a' = 'a '; +SELECT 'a\0' < 'a'; +SELECT 'a\0' < 'a '; +SELECT 'a\t' < 'a'; +SELECT 'a\t' < 'a '; + +# +# The same for binary collation +# +SELECT 'a' = 'a ' collate utf8mb4_bin; +SELECT 'a\0' < 'a' collate utf8mb4_bin; +SELECT 'a\0' < 'a ' collate utf8mb4_bin; +SELECT 'a\t' < 'a' collate utf8mb4_bin; +SELECT 'a\t' < 'a ' collate utf8mb4_bin; + +eval CREATE TABLE t1 (a char(10) character set utf8mb4 not null) ENGINE $engine; +INSERT INTO t1 VALUES ('a'),('a\0'),('a\t'),('a '); +--sorted_result +SELECT hex(a),STRCMP(a,'a'), STRCMP(a,'a ') FROM t1; +DROP TABLE t1; + +# +# Fix this, it should return 1: +# +#select _utf8mb4 0xD0B0D0B1D0B2 like concat(_utf8mb4'%',_utf8mb4 0xD091,_utf8mb4 '%'); +# + +# +# Bug 2367: INSERT() behaviour is different for different charsets. +# +select insert('txs',2,1,'hi'),insert('is ',4,0,'a'),insert('txxxxt',2,4,'es'); +select insert("aa",100,1,"b"),insert("aa",1,3,"b"); + +# +# LELF() didn't work well with utf8mb4 in some cases too. +# +select char_length(left(@a:='теÑÑ‚',5)), length(@a), @a; + + +# +# CREATE ... SELECT +# +eval create table t1 ENGINE $engine select date_format("2004-01-19 10:10:10", "%Y-%m-%d"); +show create table t1; +select * from t1; +drop table t1; + +# +# Bug#22646 LC_TIME_NAMES: Assignment to non-UTF8 target fails +# +set names utf8mb4; +set LC_TIME_NAMES='fr_FR'; +eval create table t1 (s1 char(20) character set latin1) engine $engine; +insert into t1 values (date_format('2004-02-02','%M')); +select hex(s1) from t1; +drop table t1; +eval create table t1 (s1 char(20) character set koi8r) engine $engine; +set LC_TIME_NAMES='ru_RU'; +insert into t1 values (date_format('2004-02-02','%M')); +insert into t1 values (date_format('2004-02-02','%b')); +insert into t1 values (date_format('2004-02-02','%W')); +insert into t1 values (date_format('2004-02-02','%a')); +--sorted_result +select hex(s1), s1 from t1; +drop table t1; +set LC_TIME_NAMES='en_US'; + + +# +# Bug #2366 Wrong utf8mb4 behaviour when data is truncated +# +set names koi8r; +eval create table t1 (s1 char(1) character set utf8mb4) engine $engine; +insert into t1 values (_koi8r'ÁÂ'); +select s1,hex(s1),char_length(s1),octet_length(s1) from t1; +drop table t1; + +if (!$is_heap) +{ +eval create table t1 (s1 tinytext character set utf8mb4) engine $engine; +} +if ($is_heap) +{ +eval create table t1 (s1 varchar(255) character set utf8mb4) engine $engine; +} +insert into t1 select repeat('a',300); +insert into t1 select repeat('Ñ',300); +insert into t1 select repeat('aÑ',300); +insert into t1 select repeat('Ña',300); +insert into t1 select repeat('ÑÑ',300); +--sorted_result +select hex(s1) from t1; +--sorted_result +select length(s1),char_length(s1) from t1; +drop table t1; + +if (!$is_heap) +{ +eval create table t1 (s1 text character set utf8mb4) engine $engine; +} +if ($is_heap) +{ +eval create table t1 (s1 varchar(255) character set utf8mb4) engine $engine; +} +insert into t1 select repeat('a',66000); +insert into t1 select repeat('Ñ',66000); +insert into t1 select repeat('aÑ',66000); +insert into t1 select repeat('Ña',66000); +insert into t1 select repeat('ÑÑ',66000); +--sorted_result +select length(s1),char_length(s1) from t1; +drop table t1; + +# +# Bug #2368 Multibyte charsets do not check that incoming data is well-formed +# +eval create table t1 (s1 char(10) character set utf8mb4) engine $engine; +insert into t1 values (0x41FF); +select hex(s1) from t1; +drop table t1; + +eval create table t1 (s1 varchar(10) character set utf8mb4) engine $engine; +insert into t1 values (0x41FF); +select hex(s1) from t1; +drop table t1; + +if (!$is_heap) +{ +eval create table t1 (s1 text character set utf8mb4) engine $engine; +insert into t1 values (0x41FF); +select hex(s1) from t1; +drop table t1; +} + +# +# Bug 2699 +# UTF8 breaks primary keys for cols > 333 characters +# +if(!$is_heap) +{ +if(!$is_ndb) +{ +--error ER_TOO_LONG_KEY +eval create table t1 (a text character set utf8mb4, primary key(a(371))) engine $engine; +} +if($is_ndb) +{ +--error ER_BLOB_USED_AS_KEY +eval create table t1 (a text character set utf8mb4, primary key(a(371))) engine $engine; +} +} + +# +# Bug 2959 +# UTF8 charset breaks joins with mixed column/string constant +# +eval CREATE TABLE t1 ( a varchar(10) ) CHARACTER SET utf8mb4 ENGINE $engine; +INSERT INTO t1 VALUES ( 'test' ); +SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a; +SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = 'test' and b.a = 'test'; +SELECT a.a, b.a FROM t1 a, t1 b WHERE a.a = b.a and a.a = 'test'; +DROP TABLE t1; + +eval create table t1 (a char(255) character set utf8mb4) engine $engine; +insert into t1 values('b'),('b'); +select * from t1 where a = 'b'; +select * from t1 where a = 'b' and a = 'b'; +select * from t1 where a = 'b' and a != 'b'; +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 '[[:<:]]ваÑÑ[[:>:]]'; + +# +# Bug #4555 +# ALTER TABLE crashes mysqld with enum column collated utf8mb4_unicode_ci +# +eval CREATE TABLE t1 (a enum ('Y', 'N') DEFAULT 'N' COLLATE utf8mb4_unicode_ci) ENGINE $engine; +ALTER TABLE t1 ADD COLUMN b CHAR(20); +DROP TABLE t1; + +# Customer Support Center issue # 3299 +# ENUM and SET multibyte fields computed their length wronly +# when converted into a char field +set names utf8mb4; +eval create table t1 (a enum('aaaa','проба') character set utf8mb4) engine $engine; +show create table t1; +insert into t1 values ('проба'); +select * from t1; +eval create table t2 engine $engine select ifnull(a,a) from t1; +show create table t2; +select * from t2; +drop table t1; +drop table t2; + +# +# Bug 4521: unique key prefix interacts poorly with utf8mb4 +# MYISAM: keys with prefix compression, case insensitive collation. +# +if (!$is_ndb) +{ +eval create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine $engine; +insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); +insert into t1 values ('aaaaaaaaaa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaaaaaaaaaa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaaaaaaaaaaa'); +insert into t1 values (repeat('b',20)); +select c c1 from t1 where c='1'; +select c c2 from t1 where c='2'; +select c c3 from t1 where c='3'; +select c cx from t1 where c='x'; +select c cy from t1 where c='y'; +select c cz from t1 where c='z'; +select c ca10 from t1 where c='aaaaaaaaaa'; +select c cb20 from t1 where c=repeat('b',20); +drop table t1; + +# +# Bug 4521: unique key prefix interacts poorly with utf8mb4 +# InnoDB: keys with prefix compression, case insensitive collation. +# +--disable_warnings +eval create table t1 (c varchar(30) character set utf8mb4, unique(c(10))) engine=$engine; +--enable_warnings +insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); +insert into t1 values ('aaaaaaaaaa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaaaaaaaaaa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaaaaaaaaaaa'); +insert into t1 values (repeat('b',20)); +select c c1 from t1 where c='1'; +select c c2 from t1 where c='2'; +select c c3 from t1 where c='3'; +select c cx from t1 where c='x'; +select c cy from t1 where c='y'; +select c cz from t1 where c='z'; +select c ca10 from t1 where c='aaaaaaaaaa'; +select c cb20 from t1 where c=repeat('b',20); +drop table t1; + +# +# Bug 4521: unique key prefix interacts poorly with utf8mb4 +# MYISAM: fixed length keys, case insensitive collation +# +eval create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine $engine; +insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); +insert into t1 values ('a'); +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('b'); +insert into t1 values ('bb'); +--error ER_DUP_ENTRY +insert into t1 values ('bbb'); +insert into t1 values ('а'); +insert into t1 values ('аа'); +--error ER_DUP_ENTRY +insert into t1 values ('ааа'); +insert into t1 values ('б'); +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +insert into t1 values ('ꪪ'); +insert into t1 values ('ꪪꪪ'); +--error ER_DUP_ENTRY +insert into t1 values ('ꪪꪪꪪ'); +drop table t1; +# +# Bug 4521: unique key prefix interacts poorly with utf8mb4 +# InnoDB: fixed length keys, case insensitive collation +# +--disable_warnings +eval create table t1 (c char(3) character set utf8mb4, unique (c(2))) engine=$engine; +--enable_warnings +insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); +insert into t1 values ('a'); +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('b'); +insert into t1 values ('bb'); +--error ER_DUP_ENTRY +insert into t1 values ('bbb'); +insert into t1 values ('а'); +insert into t1 values ('аа'); +--error ER_DUP_ENTRY +insert into t1 values ('ааа'); +insert into t1 values ('б'); +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +insert into t1 values ('ꪪ'); +insert into t1 values ('ꪪꪪ'); +--error ER_DUP_ENTRY +insert into t1 values ('ꪪꪪꪪ'); +drop table t1; +# +# Bug 4531: unique key prefix interacts poorly with utf8mb4 +# Check HEAP+HASH, case insensitive collation +# +eval create table t1 ( +c char(10) character set utf8mb4, +unique key a using hash (c(1)) +) engine=$engine; +show create table t1; +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +--error ER_DUP_ENTRY +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('б'); +--error ER_DUP_ENTRY +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +select c as c_all from t1 order by c; +select c as c_a from t1 where c='a'; +select c as c_a from t1 where c='б'; +drop table t1; + +# +# Bug 4531: unique key prefix interacts poorly with utf8mb4 +# Check HEAP+BTREE, case insensitive collation +# +eval create table t1 ( +c char(10) character set utf8mb4, +unique key a using btree (c(1)) +) engine=$engine; +show create table t1; +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +--error ER_DUP_ENTRY +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('б'); +--error ER_DUP_ENTRY +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +select c as c_all from t1 order by c; +select c as c_a from t1 where c='a'; +select c as c_a from t1 where c='б'; +drop table t1; + +# +# Bug 4531: unique key prefix interacts poorly with utf8mb4 +# Check BDB, case insensitive collation +# +--disable_warnings +eval create table t1 ( +c char(10) character set utf8mb4, +unique key a (c(1)) +) engine=$engine; +--enable_warnings +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +--error ER_DUP_ENTRY +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('б'); +--error ER_DUP_ENTRY +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +select c as c_all from t1 order by c; +select c as c_a from t1 where c='a'; +select c as c_a from t1 where c='б'; +drop table t1; + +# +# Bug 4521: unique key prefix interacts poorly with utf8mb4 +# MYISAM: keys with prefix compression, binary collation. +# +eval create table t1 (c varchar(30) character set utf8mb4 collate utf8mb4_bin, unique(c(10))) engine $engine; +insert into t1 values ('1'),('2'),('3'),('x'),('y'),('z'); +insert into t1 values ('aaaaaaaaaa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaaaaaaaaaa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaaaaaaaaaaa'); +insert into t1 values (repeat('b',20)); +select c c1 from t1 where c='1'; +select c c2 from t1 where c='2'; +select c c3 from t1 where c='3'; +select c cx from t1 where c='x'; +select c cy from t1 where c='y'; +select c cz from t1 where c='z'; +select c ca10 from t1 where c='aaaaaaaaaa'; +select c cb20 from t1 where c=repeat('b',20); +drop table t1; + +# +# Bug 4521: unique key prefix interacts poorly with utf8mb4 +# MYISAM: fixed length keys, binary collation +# +eval create table t1 (c char(3) character set utf8mb4 collate utf8mb4_bin, unique (c(2))) engine $engine; +insert into t1 values ('1'),('2'),('3'),('4'),('x'),('y'),('z'); +insert into t1 values ('a'); +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('b'); +insert into t1 values ('bb'); +--error ER_DUP_ENTRY +insert into t1 values ('bbb'); +insert into t1 values ('а'); +insert into t1 values ('аа'); +--error ER_DUP_ENTRY +insert into t1 values ('ааа'); +insert into t1 values ('б'); +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +insert into t1 values ('ꪪ'); +insert into t1 values ('ꪪꪪ'); +--error ER_DUP_ENTRY +insert into t1 values ('ꪪꪪꪪ'); +drop table t1; + +# +# Bug 4531: unique key prefix interacts poorly with utf8mb4 +# Check HEAP+HASH, binary collation +# +eval create table t1 ( +c char(10) character set utf8mb4 collate utf8mb4_bin, +unique key a using hash (c(1)) +) engine=$engine; +show create table t1; +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +--error ER_DUP_ENTRY +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('б'); +--error ER_DUP_ENTRY +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +select c as c_all from t1 order by c; +select c as c_a from t1 where c='a'; +select c as c_a from t1 where c='б'; +drop table t1; + +# +# Bug 4531: unique key prefix interacts poorly with utf8mb4 +# Check HEAP+BTREE, binary collation +# +eval create table t1 ( +c char(10) character set utf8mb4 collate utf8mb4_bin, +unique key a using btree (c(1)) +) engine=$engine; +show create table t1; +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +--error ER_DUP_ENTRY +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('б'); +--error ER_DUP_ENTRY +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +select c as c_all from t1 order by c; +select c as c_a from t1 where c='a'; +select c as c_a from t1 where c='б'; +drop table t1; + +# +# Bug 4531: unique key prefix interacts poorly with utf8mb4 +# Check BDB, binary collation +# +--disable_warnings +eval create table t1 ( +c char(10) character set utf8mb4 collate utf8mb4_bin, +unique key a (c(1)) +) engine=$engine; +--enable_warnings +insert into t1 values ('a'),('b'),('c'),('d'),('e'),('f'); +--error ER_DUP_ENTRY +insert into t1 values ('aa'); +--error ER_DUP_ENTRY +insert into t1 values ('aaa'); +insert into t1 values ('б'); +--error ER_DUP_ENTRY +insert into t1 values ('бб'); +--error ER_DUP_ENTRY +insert into t1 values ('ббб'); +select c as c_all from t1 order by c; +select c as c_a from t1 where c='a'; +select c as c_a from t1 where c='б'; +drop table t1; +} + + +# Bug#4594: column index make = failed for gbk, but like works +# Check MYISAM +# +eval create table t1 ( + str varchar(255) character set utf8mb4 not null, + key str (str(2)) +) engine=$engine; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +drop table t1; + +# Bug#4594: column index make = failed for gbk, but like works +# Check InnoDB +# +--disable_warnings +eval create table t1 ( + str varchar(255) character set utf8mb4 not null, + key str (str(2)) +) engine=$engine; +--enable_warnings +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +drop table t1; + +# the same for HEAP+BTREE +# + +eval create table t1 ( + str varchar(255) character set utf8mb4 not null, + key str using btree (str(2)) +) engine=$engine; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +drop table t1; + +# the same for HEAP+HASH +# + +if (!$is_ndb) +{ +eval create table t1 ( + str varchar(255) character set utf8mb4 not null, + key str using hash (str(2)) +) engine=$engine; +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +drop table t1; + +# the same for BDB +# + +#hh +--disable_warnings +eval create table t1 ( + str varchar(255) character set utf8mb4 not null, + key str (str(2)) +) engine= $engine; +--enable_warnings +INSERT INTO t1 VALUES ('str'); +INSERT INTO t1 VALUES ('str2'); +select * from t1 where str='str'; +drop table t1; +} + +# +# Bug #5397: Crash with varchar binary and LIKE +# +eval CREATE TABLE t1 (a varchar(32) BINARY) CHARACTER SET utf8mb4 ENGINE $engine; +INSERT INTO t1 VALUES ('test'); +SELECT a FROM t1 WHERE a LIKE '%te'; +DROP TABLE t1; + +# +# Bug #5723: length(<varchar utf8mb4 field>) returns varying results +# +--disable_warnings +SET NAMES utf8mb4; +--disable_warnings +eval CREATE TABLE t1 ( + subject varchar(255) character set utf8mb4 collate utf8mb4_unicode_ci, + p varchar(15) character set utf8mb4 +) ENGINE= $engine DEFAULT CHARSET=latin1; +--enable_warnings +INSERT INTO t1 VALUES ('è°·å·ä¿ŠäºŒã¨ç”³ã—ã¾ã™ãŒã€ã‚¤ãƒ³ã‚¿ãƒ¼ãƒãƒƒãƒˆäºˆç´„ã®ä¼šå“¡ç™»éŒ²ã‚’ã—ã¾ã—ãŸã¨ã“ã‚ã€ãƒ¡ãƒ¼ãƒ«ã‚¢ãƒ‰ãƒ¬ã‚¹ã‚’é–“é•ãˆã¦ã—ã¾ã„会員IDãŒå—ã‘å–ã‚‹ã“ã¨ãŒå‡ºæ¥ã¾ã›ã‚“ã§ã—ãŸã€‚é–“é•ãˆã‚¢ãƒ‰ãƒ¬ã‚¹ã¯tani-shun@n.vodafone.ne.jpを書ãè¾¼ã¿ã¾ã—ãŸã€‚ã©ã†ã™ã‚Œã°ã‚ˆã„ã§ã™ã‹ï¼Ÿ ãã®ä»–ã€ä½æ‰€ç‰ã¯é–“é•ãˆã‚りã¾ã›ã‚“。連絡ãã ã•ã„。よã‚ã—ããŠé¡˜ã„ã—ã¾ã™ã€‚m(__)m','040312-000057'); +INSERT INTO t1 VALUES ('aaa','bbb'); +--sorted_result +SELECT length(subject) FROM t1; +SELECT length(subject) FROM t1 ORDER BY 1; +DROP TABLE t1; + +# +# Bug #5832 SELECT doesn't return records in some cases +# +if (!$is_heap) +{ +if (!$is_ndb) +{ +eval CREATE TABLE t1 ( + id int unsigned NOT NULL auto_increment, + list_id smallint unsigned NOT NULL, + term TEXT NOT NULL, + PRIMARY KEY(id), + INDEX(list_id, term(4)) +) ENGINE=$engine CHARSET=utf8mb4; +INSERT INTO t1 SET list_id = 1, term = "letterc"; +INSERT INTO t1 SET list_id = 1, term = "letterb"; +INSERT INTO t1 SET list_id = 1, term = "lettera"; +INSERT INTO t1 SET list_id = 1, term = "letterd"; +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterc"); +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterb"); +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "lettera"); +SELECT id FROM t1 WHERE (list_id = 1) AND (term = "letterd"); +DROP TABLE t1; + +# +# Bug #6043 erratic searching for diacriticals in indexed MyISAM UTF-8 table +# +SET NAMES latin1; +eval CREATE TABLE t1 ( + id int unsigned NOT NULL auto_increment, + list_id smallint unsigned NOT NULL, + term text NOT NULL, + PRIMARY KEY(id), + INDEX(list_id, term(19)) +) ENGINE=$engine CHARSET=utf8mb4; +INSERT INTO t1 set list_id = 1, term = "testétest"; +INSERT INTO t1 set list_id = 1, term = "testetest"; +INSERT INTO t1 set list_id = 1, term = "testètest"; +SELECT id, term FROM t1 where (list_id = 1) AND (term = "testétest"); +SELECT id, term FROM t1 where (list_id = 1) AND (term = "testetest"); +SELECT id, term FROM t1 where (list_id = 1) AND (term = "testètest"); +DROP TABLE t1; +} +} + +# +# Bug #6019 SELECT tries to use too short prefix index on utf8mb4 data +# +set names utf8mb4; +--disable_warnings +eval create table t1 ( + a int primary key, + b varchar(6), + index b3(b(3)) +) engine=$engine character set=utf8mb4; +--enable_warnings +insert into t1 values(1,'foo'),(2,'foobar'); +--sorted_result +select * from t1 where b like 'foob%'; +--disable_warnings +alter table t1 engine=innodb; +--enable_warnings +--sorted_result +select * from t1 where b like 'foob%'; +drop table t1; + +# +# Test for calculate_interval_lengths() function +# +eval create table t1 ( + a enum('петÑ','ваÑÑ','анюта') character set utf8mb4 not null default 'анюта', + b set('петÑ','ваÑÑ','анюта') character set utf8mb4 not null default 'анюта' +) engine $engine; +eval create table t2 engine $engine select concat(a,_utf8mb4'') as a, concat(b,_utf8mb4'')as b from t1; +show create table t2; +drop table t2; +drop table t1; + +# +# Bug #6787 LIKE not working properly with _ and utf8mb4 data +# +select 'c' like '\_' as want0; + +# +# SUBSTR with negative offset didn't work with multi-byte strings +# +SELECT SUBSTR('ваÑÑ',-2); + + +# +# Bug #7730 Server crash using soundex on an utf8mb4 table +# +eval create table t1 (id integer, a varchar(100) character set utf8mb4 collate utf8mb4_unicode_ci) engine $engine; +insert into t1 values (1, 'Test'); +select * from t1 where soundex(a) = soundex('Test'); +select * from t1 where soundex(a) = soundex('TEST'); +select * from t1 where soundex(a) = soundex('test'); +drop table t1; + +# +# Bug#22638 SOUNDEX broken for international characters +# +select soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB); +select hex(soundex(_utf8mb4 0xE99885E8A788E99A8FE697B6E69BB4E696B0E79A84E696B0E997BB)); +select soundex(_utf8mb4 0xD091D092D093); +select hex(soundex(_utf8mb4 0xD091D092D093)); + + +SET collation_connection='utf8mb4_general_ci'; +-- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc +-- source include/ctype_german.inc +SET collation_connection='utf8mb4_bin'; +-- source include/ctype_filesort.inc +-- source include/ctype_like_escape.inc + +# +# Bug #7874 CONCAT() gives wrong results mixing +# latin1 field and utf8mb4 string literals +# +eval CREATE TABLE t1 ( + user varchar(255) NOT NULL default '' +) ENGINE=$engine DEFAULT CHARSET=latin1; +INSERT INTO t1 VALUES ('one'),('two'); +SELECT CHARSET('a'); +--sorted_result +SELECT user, CONCAT('<', user, '>') AS c FROM t1; +DROP TABLE t1; + +# +# Bug#8785 +# the same problem with the above, but with nested CONCATs +# +eval create table t1 (f1 varchar(1) not null) default charset utf8mb4 engine $engine; +insert into t1 values (''), (''); +select concat(concat(_latin1'->',f1),_latin1'<-') from t1; +drop table t1; + +# +# Bug#8385: utf8mb4_general_ci treats Cyrillic letters I and SHORT I as the same +# +select convert(_koi8r'É' using utf8mb4) < convert(_koi8r'Ê' using utf8mb4); + +# +# Bugs#5980: NULL requires a characterset in a union +# +set names latin1; +eval create table t1 (a varchar(10)) character set utf8mb4 engine $engine; +insert into t1 values ('test'); +select ifnull(a,'') from t1; +drop table t1; +select repeat(_utf8mb4'+',3) as h union select NULL; +select ifnull(NULL, _utf8mb4'string'); + +# +# Bug#9509 Optimizer: wrong result after AND with comparisons +# +set names utf8mb4; +eval create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_lithuanian_ci) engine $engine; +insert into t1 values ('I'),('K'),('Y'); +--sorted_result +select * from t1 where s1 < 'K' and s1 = 'Y'; +--sorted_result +select * from t1 where 'K' > s1 and s1 = 'Y'; +drop table t1; + +eval create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_czech_ci) engine $engine; +insert into t1 values ('c'),('d'),('h'),('ch'),('CH'),('cH'),('Ch'),('i'); +--sorted_result +select * from t1 where s1 > 'd' and s1 = 'CH'; +--sorted_result +select * from t1 where 'd' < s1 and s1 = 'CH'; +--sorted_result +select * from t1 where s1 = 'cH' and s1 <> 'ch'; +--sorted_result +select * from t1 where 'cH' = s1 and s1 <> 'ch'; +drop table t1; + +# +# Bug#10714: Inserting double value into utf8mb4 column crashes server +# +eval create table t1 (a varchar(255)) default character set utf8mb4 engine $engine; +insert into t1 values (1.0); +drop table t1; + +# +# Bug#10253 compound index length and utf8mb4 char set +# produces invalid query results +# +eval create table t1 ( + id int not null, + city varchar(20) not null, + key (city(7),id) +) character set=utf8mb4 engine $engine; +insert into t1 values (1,'Durban North'); +insert into t1 values (2,'Durban'); +select * from t1 where city = 'Durban'; +select * from t1 where city = 'Durban '; +drop table t1; + +# +# Bug #11819 CREATE TABLE with a SET DEFAULT 0 and UTF8 crashes server. +# +--error 1067 +eval create table t1 (x set('A', 'B') default 0) character set utf8mb4 engine $engine; +--error 1067 +eval create table t1 (x enum('A', 'B') default 0) character set utf8mb4 engine $engine; + + +# +# Test for bug #11167: join for utf8mb4 varchar value longer than 255 bytes +# + +SET NAMES UTF8; + +eval CREATE TABLE t1 ( + `id` int(20) NOT NULL auto_increment, + `country` varchar(100) NOT NULL default '', + `shortcode` varchar(100) NOT NULL default '', + `operator` varchar(100) NOT NULL default '', + `momid` varchar(30) NOT NULL default '', + `keyword` varchar(160) NOT NULL default '', + `content` varchar(160) NOT NULL default '', + `second_token` varchar(160) default NULL, + `gateway_id` int(11) NOT NULL default '0', + `created` datetime NOT NULL default '0000-00-00 00:00:00', + `msisdn` varchar(15) NOT NULL default '', + PRIMARY KEY (`id`), + UNIQUE KEY `MSCCSPK_20030521130957121` (`momid`), + KEY `IX_mobile_originated_message_keyword` (`keyword`), + KEY `IX_mobile_originated_message_created` (`created`), + KEY `IX_mobile_originated_message_support` (`msisdn`,`momid`,`keyword`,`gateway_id`,`created`) +) ENGINE=$engine DEFAULT CHARSET=utf8mb4; + +INSERT INTO t1 VALUES +(1,'blah','464','aaa','fkc1c9ilc20x0hgae7lx6j09','ERR','ERR Имри.Ðфимим.Ðеимимримдмримрмрирор имримримримр имридм ирбднримрфмририримрфмфмим.Ðд.Д имдимримрад.Ðдимримримрмдиримримримр м.Дадимфшьмримд им.Ðдимимрн имадми','ИМРИ.ÐФИМИМ.ÐЕИМИМРИМДМРИМРМРИРОР',3,'2005-06-01 17:30:43','1234567890'), +(2,'blah','464','aaa','haxpl2ilc20x00bj4tt2m5ti','11','11 g','G',3,'2005-06-02 22:43:10','1234567890'); + +--disable_warnings +eval CREATE TABLE t2 ( + `msisdn` varchar(15) NOT NULL default '', + `operator_id` int(11) NOT NULL default '0', + `created` datetime NOT NULL default '0000-00-00 00:00:00', + UNIQUE KEY `PK_user` (`msisdn`) +) ENGINE=$engine DEFAULT CHARSET=utf8mb4; +--enable_warnings + +INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25'); + +SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890'; + +DROP TABLE t1,t2; + +# +# Bug#11591: CHAR column with utf8mb4 does not work properly +# (more chars than expected) +# +eval create table t1 (a char(20) character set utf8mb4) engine $engine; +insert into t1 values ('123456'),('андрей'); +alter table t1 modify a char(2) character set utf8mb4; +select char_length(a), length(a), a from t1 order by a; +drop table t1; + +# +# Bugs#12611 +# ESCAPE + LIKE do not work when the escape char is a multibyte one +# +set names utf8mb4; +select 'andre%' like 'andreñ%' escape 'ñ'; + +# +# Bugs#11754: SET NAMES utf8mb4 followed by SELECT "A\\" LIKE "A\\" returns 0 +# +set names utf8mb4; +select 'a\\' like 'a\\'; +select 'aa\\' like 'a%\\'; + +eval create table t1 (a char(10), key(a)) character set utf8mb4 engine $engine; +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +--sorted_result +select * from t1 where a like "abc%"; +--sorted_result +select * from t1 where a like concat("abc","%"); +--sorted_result +select * from t1 where a like "ABC%"; +select * from t1 where a like "test%"; +select * from t1 where a like "te_t"; +--sorted_result +select * from t1 where a like "%a%"; +--sorted_result +select * from t1 where a like "%abcd%"; +select * from t1 where a like "%abc\d%"; +drop table t1; + + +# +# Bug#9557 MyISAM utf8mb4 table crash +# +eval CREATE TABLE t1 ( + a varchar(255) NOT NULL default '', + KEY a (a) +) ENGINE=$engine DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_general_ci; +insert into t1 values (_utf8mb4 0xe880bd); +insert into t1 values (_utf8mb4 0x5b); +--sorted_result +select hex(a) from t1; +drop table t1; + +# +# Bug#13751 find_in_set: Illegal mix of collations +# +set names 'latin1'; +eval create table t1 (a varchar(255)) default charset=utf8mb4 engine $engine; +select * from t1 where find_in_set('-1', a); +drop table t1; + +# +# Bug#13233: select distinct char(column) fails with utf8mb4 +# +eval create table t1 (a int) engine $engine; +insert into t1 values (48),(49),(50); +set names utf8mb4; +--sorted_result +select distinct char(a) from t1; +drop table t1; + +if (!$is_heap) +{ +# +# Bug#15581: COALESCE function truncates mutli-byte TINYTEXT values +# +eval CREATE TABLE t1 (t TINYTEXT CHARACTER SET utf8mb4) ENGINE $engine; +INSERT INTO t1 VALUES(REPEAT('a', 100)); +if (!$is_ndb) +{ +eval CREATE TEMPORARY TABLE t2 ENGINE $engine SELECT COALESCE(t) AS bug FROM t1; +} +if ($is_ndb) +{ +eval CREATE TABLE t2 ENGINE $engine SELECT COALESCE(t) AS bug FROM t1; +} +SELECT LENGTH(bug) FROM t2; +DROP TABLE t2; +DROP TABLE t1; +} + +# +# Bug#17313: N'xxx' and _utf8mb4'xxx' are not equivalent +# +eval CREATE TABLE t1 (item varchar(255)) default character set utf8mb4 ENGINE $engine; +INSERT INTO t1 VALUES (N'\\'); +INSERT INTO t1 VALUES (_utf8mb4'\\'); +INSERT INTO t1 VALUES (N'Cote d\'Ivoire'); +INSERT INTO t1 VALUES (_utf8mb4'Cote d\'Ivoire'); +SELECT item FROM t1 ORDER BY item; +DROP TABLE t1; + +# +# Bug#17705: Corruption of compressed index when index length changes between +# 254 and 256 +# + +SET NAMES utf8mb4; +DROP TABLE IF EXISTS t1; +eval CREATE TABLE t1(a VARCHAR(255), KEY(a)) ENGINE=$engine DEFAULT CHARSET=utf8mb4; +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +INSERT INTO t1 VALUES('uu'); +check table t1; +INSERT INTO t1 VALUES('uU'); +check table t1; +INSERT INTO t1 VALUES('uu'); +check table t1; +INSERT INTO t1 VALUES('uuABC'); +check table t1; +INSERT INTO t1 VALUES('UuABC'); +check table t1; +INSERT INTO t1 VALUES('uuABC'); +check table t1; +alter table t1 add b int; +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1); +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',2); +delete from t1 where b=1; +INSERT INTO t1 VALUES('UUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',1); +check table t1; +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3); +INSERT INTO t1 VALUES('uuABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',4); +delete from t1 where b=3; +INSERT INTO t1 VALUES('uUABCDEFGHIGKLMNOPRSTUVWXYZ̈bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',3); +check table t1; +drop table t1; + +# +# Bug#20471 LIKE search fails with indexed utf8mb4 char column +# +set names utf8mb4; +eval create table t1 (s1 char(5) character set utf8mb4) engine $engine; +insert into t1 values +('a'),('b'),(null),('ペテルグル'),('ü'),('Y'); +create index it1 on t1 (s1); +select s1 as before_delete_general_ci from t1 where s1 like 'ペテ%'; +delete from t1 where s1 = 'Y'; +select s1 as after_delete_general_ci from t1 where s1 like 'ペテ%'; +drop table t1; + +set names utf8mb4; +eval create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_unicode_ci) engine $engine; +insert into t1 values +('a'),('b'),(null),('ペテルグル'),('ü'),('Y'); +create index it1 on t1 (s1); +select s1 as before_delete_unicode_ci from t1 where s1 like 'ペテ%'; +delete from t1 where s1 = 'Y'; +select s1 as after_delete_unicode_ci from t1 where s1 like 'ペテ%'; +drop table t1; + +set names utf8mb4; +eval create table t1 (s1 char(5) character set utf8mb4 collate utf8mb4_bin) engine $engine; +insert into t1 values +('a'),('b'),(null),('ペテルグル'),('ü'),('Y'); +create index it1 on t1 (s1); +select s1 as before_delete_bin from t1 where s1 like 'ペテ%'; +delete from t1 where s1 = 'Y'; +select s1 as after_delete_bin from t1 where s1 like 'ペテ%'; +drop table t1; + +# additional tests from duplicate bug#20744 MySQL return no result + +set names utf8mb4; +--disable_warnings +eval create table t1 (a varchar(30) not null primary key) +engine=$engine default character set utf8mb4 collate utf8mb4_general_ci; +--enable_warnings +insert into t1 values ('ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã'); +insert into t1 values ('ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ'); +select a as gci1 from t1 where a like 'ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ%'; +select a as gci2 from t1 where a like 'ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã'; +drop table t1; + +set names utf8mb4; +--disable_warnings +eval create table t1 (a varchar(30) not null primary key) +engine=$engine default character set utf8mb4 collate utf8mb4_unicode_ci; +--enable_warnings +insert into t1 values ('ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã'); +insert into t1 values ('ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ'); +select a as uci1 from t1 where a like 'ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ%'; +select a as uci2 from t1 where a like 'ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã'; +drop table t1; + +set names utf8mb4; +--disable_warnings +eval create table t1 (a varchar(30) not null primary key) +engine=$engine default character set utf8mb4 collate utf8mb4_bin; +--enable_warnings +insert into t1 values ('ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã'); +insert into t1 values ('ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ'); +select a as bin1 from t1 where a like 'ã•ã—ã™ã›ãã‹ããã‘ã“ã‚ã„ã†ãˆãŠ%'; +select a as bin2 from t1 where a like 'ã‚ã„ã†ãˆãŠã‹ããã‘ã“ã•ã—ã™ã›ã'; +drop table t1; + + + +# +# Bug#14896: Comparison with a key in a partial index over mb chararacter field +# + +SET NAMES utf8mb4; +eval CREATE TABLE t1 (id int PRIMARY KEY, + a varchar(16) collate utf8mb4_unicode_ci NOT NULL default '', + b int, + f varchar(128) default 'XXX', + INDEX (a(4)) +) ENGINE=$engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +INSERT INTO t1(id, a, b) VALUES + (1, 'cccc', 50), (2, 'cccc', 70), (3, 'cccc', 30), + (4, 'cccc', 30), (5, 'cccc', 20), (6, 'bbbbbb', 40), + (7, 'dddd', 30), (8, 'aaaa', 10), (9, 'aaaa', 50), + (10, 'eeeee', 40), (11, 'bbbbbb', 60); + +--sorted_result +SELECT id, a, b FROM t1; + +--sorted_result +SELECT id, a, b FROM t1 WHERE a BETWEEN 'aaaa' AND 'bbbbbb'; + +--sorted_result +SELECT id, a FROM t1 WHERE a='bbbbbb'; +SELECT id, a FROM t1 WHERE a='bbbbbb' ORDER BY b; + +DROP TABLE t1; + +# +# Bug#16674: LIKE predicate for a utf8mb4 character set column +# + +SET NAMES utf8mb4; + +eval CREATE TABLE t1 ( + a CHAR(13) DEFAULT '', + INDEX(a) +) ENGINE=$engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +INSERT INTO t1 VALUES + ('Käli Käli 2-4'), ('Käli Käli 2-4'), + ('Käli Käli 2+4'), ('Käli Käli 2+4'), + ('Käli Käli 2-6'), ('Käli Käli 2-6'); +INSERT INTO t1 SELECT * FROM t1; + +eval CREATE TABLE t2 ( + a CHAR(13) DEFAULT '', + INDEX(a) +) ENGINE=$engine DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; + +INSERT INTO t2 VALUES + ('Kali Kali 2-4'), ('Kali Kali 2-4'), + ('Kali Kali 2+4'), ('Kali Kali 2+4'), + ('Kali Kali 2-6'), ('Kali Kali 2-6'); +INSERT INTO t2 SELECT * FROM t2; + +SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4'; +SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4'; + +EXPLAIN SELECT a FROM t1 WHERE a LIKE 'Käli Käli 2+4'; +EXPLAIN SELECT a FROM t1 WHERE a = 'Käli Käli 2+4'; +EXPLAIN SELECT a FROM t2 WHERE a LIKE 'Kali Kali 2+4'; +EXPLAIN SELECT a FROM t2 WHERE a = 'Kali Kali 2+4'; + +DROP TABLE t1,t2; + +eval CREATE TABLE t1 ( + a char(255) DEFAULT '', + KEY(a(10)) +) ENGINE=$engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +DROP TABLE t1; + +eval CREATE TABLE t1 ( + a char(255) DEFAULT '' +) ENGINE=$engine DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +INSERT INTO t1 VALUES ('Käli Käli 2-4'); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +ALTER TABLE t1 ADD KEY (a(10)); +SELECT * FROM t1 WHERE a LIKE 'Käli Käli 2%'; +DROP TABLE t1; + +# +# Bug#18359: LIKE predicate for a 'utf8mb4' text column with a partial index +# (see bug #16674 as well) +# + +SET NAMES latin2; + +if (!$is_heap) +{ +if (!$is_ndb) +{ +eval CREATE TABLE t1 ( + id int(11) NOT NULL default '0', + tid int(11) NOT NULL default '0', + val text NOT NULL, + INDEX idx(tid, val(10)) +) ENGINE=$engine DEFAULT CHARSET=utf8mb4; + +INSERT INTO t1 VALUES + (40988,72,'VOLNÝ ADSL'),(41009,72,'VOLNÝ ADSL'), + (41032,72,'VOLNÝ ADSL'),(41038,72,'VOLNÝ ADSL'), + (41063,72,'VOLNÝ ADSL'),(41537,72,'VOLNÝ ADSL Office'), + (42141,72,'VOLNÝ ADSL'),(42565,72,'VOLNÝ ADSL Combi'), + (42749,72,'VOLNÝ ADSL'),(44205,72,'VOLNÝ ADSL'); + +SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNY ADSL'; +SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNÝ ADSL'; +SELECT * FROM t1 WHERE tid=72 and val LIKE '%VOLNÝ ADSL'; + +ALTER TABLE t1 DROP KEY idx; +ALTER TABLE t1 ADD KEY idx (tid,val(11)); + +SELECT * FROM t1 WHERE tid=72 and val LIKE 'VOLNÝ ADSL'; + +DROP TABLE t1; +} +} + +# +# Bug 20709: problem with utf8mb4 fields in temporary tables +# + +eval create table t1(a char(200) collate utf8mb4_unicode_ci NOT NULL default '') + default charset=utf8mb4 collate=utf8mb4_unicode_ci engine $engine; +insert into t1 values (unhex('65')), (unhex('C3A9')), (unhex('65')); +explain select distinct a from t1; +SELECT COUNT(*) FROM (SELECT DISTINCT a FROM t1) AS t2; +explain select a from t1 group by a; +SELECT COUNT(*) FROM (SELECT a FROM t1 GROUP BY a) AS t2; +drop table t1; + +# +# Bug #20204: "order by" changes the results returned +# + +eval create table t1(a char(10)) default charset utf8mb4 engine $engine; +insert into t1 values ('123'), ('456'); +explain + select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1; +select substr(Z.a,-1), Z.a from t1 as Y join t1 as Z on Y.a=Z.a order by 1; +drop table t1; + +# +# Bug #34349: Passing invalid parameter to CHAR() in an ORDER BY causes +# MySQL to hang +# + +SET CHARACTER SET utf8mb4; +SHOW VARIABLES LIKE 'character\_set\_%'; +CREATE DATABASE crashtest DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin; +USE crashtest; +eval CREATE TABLE crashtest (crash char(10)) DEFAULT CHARSET=utf8mb4 ENGINE $engine; +INSERT INTO crashtest VALUES ('35'), ('36'), ('37'); +SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4); +INSERT INTO crashtest VALUES ('-1000'); +EXPLAIN SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4); +SELECT * FROM crashtest ORDER BY CHAR(crash USING utf8mb4); +DROP TABLE crashtest; +DROP DATABASE crashtest; +USE test; +SET CHARACTER SET default; + +# End of 4.1 tests + +# +# Test for bug #11484: wrong results for a DISTINCT varchar column in uft8. +# + +eval CREATE TABLE t1(id varchar(20) NOT NULL) DEFAULT CHARSET=utf8mb4 ENGINE $engine; +INSERT INTO t1 VALUES ('xxx'), ('aa'), ('yyy'), ('aa'); + +--sorted_result +SELECT id FROM t1; +--sorted_result +SELECT DISTINCT id FROM t1; +SELECT DISTINCT id FROM t1 ORDER BY id; + +DROP TABLE t1; + +# +# Bug#20095 Changing length of VARCHAR field with UTF8 +# collation does not truncate values +# +eval create table t1 ( + a varchar(26) not null +) default character set utf8mb4 ENGINE $engine; +insert into t1 (a) values ('abcdefghijklmnopqrstuvwxyz'); +select * from t1; +# varchar to varchar +alter table t1 change a a varchar(20) character set utf8mb4 not null; +select * from t1; +# varchar to char +alter table t1 change a a char(15) character set utf8mb4 not null; +select * from t1; +# char to char +alter table t1 change a a char(10) character set utf8mb4 not null; +select * from t1; +# char to varchar +alter table t1 change a a varchar(5) character set utf8mb4 not null; +select * from t1; +drop table t1; + +# +# Check that do_varstring2_mb produces a warning +# +if (!$is_ndb) +{ +eval create table t1 ( + a varchar(4000) not null +) default character set utf8mb4 engine $engine; +insert into t1 values (repeat('a',4000)); +alter table t1 change a a varchar(3000) character set utf8mb4 not null; +select length(a) from t1; +drop table t1; +} + +# +# Bug#10504: Character set does not support traditional mode +# Bug#14146: CHAR(...USING ...) and CONVERT(CHAR(...) USING...) +# produce different results +# +set names utf8mb4; +# correct value +select hex(char(1 using utf8mb4)); +select char(0xd1,0x8f using utf8mb4); +select char(0xd18f using utf8mb4); +select char(53647 using utf8mb4); +# incorrect value: return with warning +select char(0xff,0x8f using utf8mb4); +select convert(char(0xff,0x8f) using utf8mb4); +# incorrect value in strict mode: return NULL with "Error" level warning +set sql_mode=traditional; +select char(0xff,0x8f using utf8mb4); +select char(195 using utf8mb4); +select char(196 using utf8mb4); +select char(2557 using utf8mb4); +select convert(char(0xff,0x8f) using utf8mb4); + +# +# Check convert + char + using +# +select hex(convert(char(2557 using latin1) using utf8mb4)); + +# +# char() without USING returns "binary" by default, any argument is ok +# +select hex(char(195)); +select hex(char(196)); +select hex(char(2557)); + + + +# +# Bug#12891: UNION doesn't return DISTINCT result for multi-byte characters +# +set names utf8mb4; +eval create table t1 (a char(1)) default character set utf8mb4 engine $engine; +eval create table t2 (a char(1)) default character set utf8mb4 engine $engine; +insert into t1 values('a'),('a'),(0xE38182),(0xE38182); +insert into t1 values('i'),('i'),(0xE38184),(0xE38184); +--sorted_result +select * from t1 union distinct select * from t2; +drop table t1,t2; + + +# +# Bug#12371: executing prepared statement fails (illegal mix of collations) +# +set names utf8mb4; +eval create table t1 (a char(10), b varchar(10)) engine $engine; +insert into t1 values ('bar','kostja'); +insert into t1 values ('kostja','bar'); +prepare my_stmt from "select * from t1 where a=?"; +set @a:='bar'; +execute my_stmt using @a; +set @a:='kostja'; +execute my_stmt using @a; +set @a:=null; +execute my_stmt using @a; +drop table if exists t1; + + +# +# Bug#21505 Create view - illegal mix of collation for operation 'UNION' +# +--disable_warnings +drop table if exists t1; +drop view if exists v1, v2; +--enable_warnings +set names utf8mb4; +eval create table t1(col1 varchar(12) character set utf8mb4 collate utf8mb4_unicode_ci) engine $engine; +insert into t1 values('t1_val'); +create view v1 as select 'v1_val' as col1; +select coercibility(col1), collation(col1) from v1; +create view v2 as select col1 from v1 union select col1 from t1; +select coercibility(col1), collation(col1)from v2; +drop view v1, v2; +create view v1 as select 'v1_val' collate utf8mb4_swedish_ci as col1; +select coercibility(col1), collation(col1) from v1; +create view v2 as select col1 from v1 union select col1 from t1; +select coercibility(col1), collation(col1) from v2; +drop view v1, v2; +drop table t1; + +# +# Check conversion of NCHAR strings to subset (e.g. latin1). +# Conversion is possible if string repertoire is ASCII. +# Conversion is not possible if the string have extended characters +# +set names utf8mb4; +eval create table t1 (a varchar(10) character set latin1, b int) engine $engine; +insert into t1 values ('a',1); +select concat(a, if(b>10, N'x', N'y')) from t1; +--error 1267 +select concat(a, if(b>10, N'æ', N'ß')) from t1; +drop table t1; + +# Conversion tests for character set introducers +set names utf8mb4; +eval create table t1 (a varchar(10) character set latin1, b int) engine $engine; +insert into t1 values ('a',1); +select concat(a, if(b>10, _utf8mb4'x', _utf8mb4'y')) from t1; +--error 1267 +select concat(a, if(b>10, _utf8mb4'æ', _utf8mb4'ß')) from t1; +drop table t1; + +# Conversion tests for introducer + HEX string +set names utf8mb4; +eval create table t1 (a varchar(10) character set latin1, b int) engine $engine; +insert into t1 values ('a',1); +select concat(a, if(b>10, _utf8mb4 0x78, _utf8mb4 0x79)) from t1; +--error 1267 +select concat(a, if(b>10, _utf8mb4 0xC3A6, _utf8mb4 0xC3AF)) from t1; +drop table t1; + +# Conversion tests for "text_literal TEXT_STRING_literal" syntax structure +set names utf8mb4; +eval create table t1 (a varchar(10) character set latin1, b int) engine $engine; +insert into t1 values ('a',1); +select concat(a, if(b>10, 'x' 'x', 'y' 'y')) from t1; +--error 1267 +select concat(a, if(b>10, 'x' 'æ', 'y' 'ß')) from t1; +drop table t1; + + +# +# Bug#19960: Inconsistent results when joining +# InnoDB tables using partial UTF8 indexes +# +--disable_warnings +eval CREATE TABLE t1 ( + colA int(11) NOT NULL, + colB varchar(255) character set utf8mb4 NOT NULL, + PRIMARY KEY (colA) +) ENGINE=$engine DEFAULT CHARSET=latin1; +--enable_warnings +INSERT INTO t1 (colA, colB) VALUES (1, 'foo'), (2, 'foo bar'); +--disable_warnings +eval CREATE TABLE t2 ( + colA int(11) NOT NULL, + colB varchar(255) character set utf8mb4 NOT NULL, + KEY bad (colA,colB(3)) +) ENGINE=$engine DEFAULT CHARSET=latin1; +--enable_warnings +INSERT INTO t2 (colA, colB) VALUES (1, 'foo'),(2, 'foo bar'); +SELECT * FROM t1 JOIN t2 ON t1.colA=t2.colA AND t1.colB=t2.colB +WHERE t1.colA < 3; +DROP TABLE t1, t2; + +# +# Bug#29205: truncation of UTF8 values when the UNION statement +# forces collation to the binary charset +# + +SELECT 'н1234567890' UNION SELECT _binary '1'; +SELECT 'н1234567890' UNION SELECT 1; + +SELECT '1' UNION SELECT 'н1234567890'; +SELECT 1 UNION SELECT 'н1234567890'; + +eval CREATE TABLE t1 (c VARCHAR(11)) CHARACTER SET utf8mb4 ENGINE $engine; +eval CREATE TABLE t2 (b CHAR(1) CHARACTER SET binary, i INT) ENGINE $engine; + +INSERT INTO t1 (c) VALUES ('н1234567890'); +INSERT INTO t2 (b, i) VALUES ('1', 1); + +SELECT c FROM t1 UNION SELECT b FROM t2; +SELECT c FROM t1 UNION SELECT i FROM t2; + +SELECT b FROM t2 UNION SELECT c FROM t1; +SELECT i FROM t2 UNION SELECT c FROM t1; + +DROP TABLE t1, t2; + +# +# Bug#30982: CHAR(..USING..) can return a not-well-formed string +# Bug #30986: Character set introducer followed by a HEX string can return bad result +# +set sql_mode=traditional; +select hex(char(0xFF using utf8mb4)); +select hex(convert(0xFF using utf8mb4)); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8mb4 0x616263FF); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8mb4 X'616263FF'); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8mb4 B'001111111111'); +--error ER_INVALID_CHARACTER_STRING +select (_utf8mb4 X'616263FF'); +set sql_mode=default; +select hex(char(0xFF using utf8mb4)); +select hex(convert(0xFF using utf8mb4)); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8mb4 0x616263FF); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8mb4 X'616263FF'); +--error ER_INVALID_CHARACTER_STRING +select hex(_utf8mb4 B'001111111111'); +--error ER_INVALID_CHARACTER_STRING +select (_utf8mb4 X'616263FF'); + +# +# Bug #36772: When using UTF8, CONVERT with GROUP BY returns truncated results +# +eval CREATE TABLE t1 (a INT NOT NULL, b INT NOT NULL) ENGINE $engine; +INSERT INTO t1 VALUES (70000, 1092), (70001, 1085), (70002, 1065); +--sorted_result +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +--sorted_result +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1; +ALTER TABLE t1 ADD UNIQUE (b); +--sorted_result +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +DROP INDEX b ON t1; +--sorted_result +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) FROM t1 GROUP BY b; +ALTER TABLE t1 ADD INDEX (b); +--sorted_result +SELECT CONVERT(a, CHAR), CONVERT(b, CHAR) from t1 GROUP BY b; +DROP TABLE t1; + +--echo # +--echo # Bug#26474: Add Sinhala script (Sri Lanka) collation to MySQL +--echo # +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +eval CREATE TABLE t1 ( + predicted_order int NOT NULL, + utf8mb4_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8mb4 ENGINE $engine; +INSERT INTO t1 VALUES (19, x'E0B696'), (30, x'E0B69AE0B798'), (61, x'E0B6AF'), (93, x'E0B799'), (52, x'E0B6A6'), (73, x'E0B6BBE0B78AE2808D'), (3, x'E0B686'), (56, x'E0B6AA'), (55, x'E0B6A9'), (70, x'E0B6B9'), (94, x'E0B79A'), (80, x'E0B785'), (25, x'E0B69AE0B791'), (48, x'E0B6A2'), (13, x'E0B690'), (86, x'E0B793'), (91, x'E0B79F'), (81, x'E0B786'), (79, x'E0B784'), (14, x'E0B691'), (99, x'E0B78A'), (8, x'E0B68B'), (68, x'E0B6B7'), (22, x'E0B69A'), (16, x'E0B693'), (33, x'E0B69AE0B7B3'), (38, x'E0B69AE0B79D'), (21, x'E0B683'), (11, x'E0B68E'), (77, x'E0B782'), (40, x'E0B69AE0B78A'), (101, x'E0B78AE2808DE0B6BB'), (35, x'E0B69AE0B79A'), (1, x'E0B7B4'), (9, x'E0B68C'), (96, x'E0B79C'), (6, x'E0B689'), (95, x'E0B79B'), (88, x'E0B796'), (64, x'E0B6B3'), (26, x'E0B69AE0B792'), (82, x'E0B78F'), (28, x'E0B69AE0B794'), (39, x'E0B69AE0B79E'), (97, x'E0B79D'), (2, x'E0B685'), (75, x'E0B780'), (34, x'E0B69AE0B799'), (69, x'E0B6B8'), (83, x'E0B790'), (18, x'E0B695'), (90, x'E0B7B2'), (17, x'E0B694'), (72, x'E0B6BB'), (66, x'E0B6B5'), (59, x'E0B6AD'), (44, x'E0B69E'), (15, x'E0B692'), (23, x'E0B69AE0B78F'), (65, x'E0B6B4'), (42, x'E0B69C'), (63, x'E0B6B1'), (85, x'E0B792'), (47, x'E0B6A1'), (49, x'E0B6A3'), (92, x'E0B7B3'), (78, x'E0B783'), (36, x'E0B69AE0B79B'), (4, x'E0B687'), (24, x'E0B69AE0B790'), (87, x'E0B794'), (37, x'E0B69AE0B79C'), (32, x'E0B69AE0B79F'), (29, x'E0B69AE0B796'), (43, x'E0B69D'), (62, x'E0B6B0'), (100, x'E0B78AE2808DE0B6BA'), (60, x'E0B6AE'), (45, x'E0B69F'), (12, x'E0B68F'), (46, x'E0B6A0'), (50, x'E0B6A5'), (51, x'E0B6A4'), (5, x'E0B688'), (76, x'E0B781'), (89, x'E0B798'), (74, x'E0B6BD'), (10, x'E0B68D'), (57, x'E0B6AB'), (71, x'E0B6BA'), (58, x'E0B6AC'), (27, x'E0B69AE0B793'), (54, x'E0B6A8'), (84, x'E0B791'), (31, x'E0B69AE0B7B2'), (98, x'E0B79E'), (53, x'E0B6A7'), (41, x'E0B69B'), (67, x'E0B6B6'), (7, x'E0B68A'), (20, x'E0B682'); +SELECT predicted_order, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_sinhala_ci; +DROP TABLE t1; + +--echo # +--echo # Bug#32914 Character sets: illegal characters in utf8mb4 and utf32 columns +--echo # +eval create table t1 (utf8mb4 char(1) character set utf8mb4) engine $engine; +--echo Testing [F0][90..BF][80..BF][80..BF] +insert into t1 values (0xF0908080); +insert into t1 values (0xF0BFBFBF); +insert into t1 values (0xF08F8080); +--sorted_result +select hex(utf8mb4) from t1; +delete from t1; + +--echo Testing [F2..F3][80..BF][80..BF][80..BF] +insert into t1 values (0xF2808080); +insert into t1 values (0xF2BFBFBF); +--sorted_result +select hex(utf8mb4) from t1; +delete from t1; + +--echo Testing [F4][80..8F][80..BF][80..BF] +insert into t1 values (0xF4808080); +insert into t1 values (0xF48F8080); +insert into t1 values (0xF4908080); +--sorted_result +select hex(utf8mb4) from t1; +drop table t1; + + +--echo # +--echo # Check strnxfrm() with odd length +--echo # +set max_sort_length=5; +select @@max_sort_length; +eval create table t1 (a varchar(128) character set utf8mb4 collate utf8mb4_general_ci) engine $engine; +insert into t1 values ('a'),('b'),('c'); +select * from t1 order by a; +alter table t1 modify a varchar(128) character set utf8mb4 collate utf8mb4_bin; +select * from t1 order by a; +drop table t1; +set max_sort_length=default; + +--echo # +--echo # Bug#26180: Can't add columns to tables created with utf8mb4 text indexes +--echo # +if (!$is_heap) +{ +if (!$is_ndb) +{ +eval CREATE TABLE t1 ( + clipid INT NOT NULL, + Tape TINYTEXT, + PRIMARY KEY (clipid), + KEY tape(Tape(255)) +) CHARACTER SET=utf8mb4 ENGINE $engine; +ALTER TABLE t1 ADD mos TINYINT DEFAULT 0 AFTER clipid; +SHOW CREATE TABLE t1; +DROP TABLE t1; +} +} + +#--echo # +#--echo # Check that supplementary characters are not allowed in identifiers +#--echo # +# TODO: activate this when system_charset_info is changed to utf8mb4 +#--error 1300 +#CREATE DATABASE `ð€€`; +#--error 1300 +#CREATE TABLE `ð€€` (a int); +#--error 1166 +#CREATE TABLE test.t1 SELECT 'ð€€'; +#--error 1300 +#CREATE USER `ð€€`; + +--echo # +--echo # Testing 4-byte values. +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings +eval CREATE TABLE t1 ( + u_decimal int NOT NULL, + utf8mb4_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8mb4 ENGINE $engine; +# Source of the following values: http://www.fileformat.info/info/unicode/block/index.htm +# SINGLE BARLINE +INSERT INTO t1 VALUES (119040, x'f09d8480'), +# G CLEF + (119070, x'f09d849e'), +# HALF NOTE + (119134, x'f09d859e'), +# MUSICAL SYMBOL CROIX + (119247, x'f09d878f'), +# MATHEMATICAL BOLD ITALIC CAPITAL DELTA + (120607, x'f09d9c9f'), +# SANS-SERIF BOLD ITALIC CAPITAL PI + (120735, x'f09d9e9f'), +# <Plane 16 Private Use, Last> (last 4 byte character) + (1114111, x'f48fbfbf'), +# VARIATION SELECTOR-256 + (917999, x'f3a087af'); +# All from musical chars +INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480'); +# Mix of 3-byte and 4-byte chars +INSERT INTO t1 VALUES (65131, x'efb9abf09d849ef09d859ef09d859ef09d8480f09d859fefb9abefb9abf09d85a0efb9ab'); +# All from musical chars, but 11 instead of 10 chars. truncated +INSERT INTO t1 VALUES (119070, x'f09d849ef09d859ef09d859ef09d8480f09d859ff09d859ff09d859ff09d85a0f09d85a0f09d8480f09d85a0'); + +--sorted_result +SELECT u_decimal, hex(utf8mb4_encoding) FROM t1 ORDER BY utf8mb4_encoding COLLATE utf8mb4_general_ci, BINARY utf8mb4_encoding; + +# First invalid 4 byte value +INSERT INTO t1 VALUES (1114111, x'f5808080'); + +--sorted_result +SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE + table_name= 't1' AND column_name= 'utf8mb4_encoding'; + +--disable_warnings +DROP TABLE IF EXISTS t2; +--enable_warnings +eval CREATE TABLE t2 ( + u_decimal int NOT NULL, + utf8mb3_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8mb3 ENGINE $engine; +# LATIN CAPITAL LETTER VEND +INSERT INTO t2 VALUES (42856, x'ea9da8'); +# SMALL COMMERCIAL AT +INSERT INTO t2 VALUES (65131, x'efb9ab'); +# <Plane 16 Private Use, Last> (last 4 byte character) +INSERT INTO t2 VALUES (1114111, x'f48fbfbf'); + +--sorted_result +SELECT character_maximum_length, character_octet_length FROM information_schema.columns WHERE + table_name= 't2' AND column_name= 'utf8mb3_encoding'; + +# Update a 3-byte char col with a 4-byte char, error +UPDATE t2 SET utf8mb3_encoding= x'f48fbfbd' where u_decimal= 42856; + +# Update to a 3-byte char casted to 4-byte, error? +UPDATE t2 SET utf8mb3_encoding= _utf8mb4 x'ea9da8' where u_decimal= 42856; + +# Returns utfmb4 +--sorted_result +SELECT HEX(CONCAT(utf8mb4_encoding, _utf8 x'ea9da8')) FROM t1; +--sorted_result +SELECT HEX(CONCAT(utf8mb4_encoding, utf8mb3_encoding)) FROM t1,t2; + +#--error ER_INVALID_CHARACTER_STRING +#SELECT CONCAT(_utf8 utf8mb4_encoding, _utf8 '|') FROM t1; +#--error ER_INVALID_CHARACTER_STRING +#SELECT CONCAT(_utf8mb3 utf8mb4_encoding, _utf8 '|') FROM t1; + +SELECT count(*) FROM t1, t2 + WHERE t1.utf8mb4_encoding > t2.utf8mb3_encoding; + +# Alter from 4-byte charset to 3-byte charset, error +--disable_warnings +ALTER TABLE t1 CONVERT TO CHARACTER SET utf8; +--enable_warnings +SHOW CREATE TABLE t1; +--sorted_result +SELECT u_decimal,hex(utf8mb4_encoding),utf8mb4_encoding FROM t1; + +# Alter table from utf8 to utf8mb4 +ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb4; +SHOW CREATE TABLE t2; +--sorted_result +SELECT u_decimal,hex(utf8mb3_encoding) FROM t2; + +# Alter table back from utf8mb4 to utf8 +ALTER TABLE t2 CONVERT TO CHARACTER SET utf8mb3; +SHOW CREATE TABLE t2; +--sorted_result +SELECT u_decimal,hex(utf8mb3_encoding) FROM t2; + +# ALter of utf8mb4 column to utf8 +--disable_warnings +ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb3; +--enable_warnings +SHOW CREATE TABLE t1; +--sorted_result +SELECT u_decimal,hex(utf8mb4_encoding) FROM t1; + +# ALter of utf8 column to utf8mb4 +ALTER TABLE t1 MODIFY utf8mb4_encoding VARCHAR(10) CHARACTER SET utf8mb4; +SHOW CREATE TABLE t1; +--sorted_result +SELECT u_decimal,hex(utf8mb4_encoding) FROM t1; + +# ALter of utf8 column to utf8mb4 +ALTER TABLE t2 MODIFY utf8mb3_encoding VARCHAR(10) CHARACTER SET utf8mb4; +SHOW CREATE TABLE t2; +--sorted_result +SELECT u_decimal,hex(utf8mb3_encoding) FROM t2; + +--disable_warnings +DROP TABLE IF EXISTS t3; +--enable_warnings +eval CREATE TABLE t3 ( + u_decimal int NOT NULL, + utf8mb3_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8 ENGINE $engine; + +# Insert select utf8mb4 (4-byte) into utf8 (3-byte), error +#--error ER_INVALID_CHARACTER_STRING +INSERT INTO t3 SELECT * FROM t1; + +--disable_warnings +DROP TABLE IF EXISTS t4; +--enable_warnings +eval CREATE TABLE t4 ( + u_decimal int NOT NULL, + utf8mb4_encoding VARCHAR(10) NOT NULL +) CHARACTER SET utf8mb4 ENGINE $engine; + +# Insert select utf8 (3-byte) into utf8mb4 (4-byte) +INSERT INTO t3 SELECT * FROM t2; + +DROP TABLE t1; +DROP TABLE t2; +DROP TABLE t3; +DROP TABLE t4; + +--echo # +--echo # Testing that mixing utf8 and utf8mb4 collations returns utf8mb4 +--echo # +SELECT CHARSET(CONCAT(_utf8mb4'a',_utf8'b')); + +eval CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4 NOT NULL) ENGINE $engine; +INSERT INTO t1 VALUES (x'ea9da8'),(x'f48fbfbf'); +SELECT CONCAT(utf8mb4, _utf8 x'ea9da8') FROM t1 LIMIT 0; + +eval CREATE TABLE t2 (utf8mb3 VARCHAR(10) CHARACTER SET utf8mb3 NOT NULL) ENGINE $engine; +INSERT INTO t2 VALUES (x'ea9da8'); + +SELECT HEX(CONCAT(utf8mb4, utf8mb3)) FROM t1,t2 ORDER BY 1; +SELECT CHARSET(CONCAT(utf8mb4, utf8mb3)) FROM t1, t2 LIMIT 1; + +if (!$is_ndb) +{ +eval CREATE TEMPORARY TABLE t3 ENGINE $engine AS SELECT *, concat(utf8mb4,utf8mb3) FROM t1, t2; +SHOW CREATE TABLE t3; +DROP TEMPORARY TABLE t3; +} + +SELECT * FROM t1, t2 WHERE t1.utf8mb4 > t2.utf8mb3; +SELECT * FROM t1, t2 WHERE t1.utf8mb4 = t2.utf8mb3; +SELECT * FROM t1, t2 WHERE t1.utf8mb4 < t2.utf8mb3; + +DROP TABLE t1; +DROP TABLE t2; + +--echo # +--echo # Check that mixing utf8mb4 with an invalid utf8 constant returns error +--echo # +# This should perhaps be changed to return ER_INVALID_CHARACTER_STRING +eval CREATE TABLE t1 (utf8mb4 VARCHAR(10) CHARACTER SET utf8mb4) ENGINE $engine; +INSERT INTO t1 VALUES (x'f48fbfbf'); +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CONCAT(utf8mb4, _utf8 '¿') FROM t1; +--error ER_CANT_AGGREGATE_2COLLATIONS +SELECT CONCAT('a', _utf8 '¿') FROM t1; +DROP TABLE t1; + +--echo # +--echo # End of 5.5 tests +--echo # + +--echo # +--echo # End of tests +--echo # diff --git a/mysql-test/include/ddl_i18n.check_sp.inc b/mysql-test/include/ddl_i18n.check_sp.inc index bb1657d7072..c182f797847 100644 --- a/mysql-test/include/ddl_i18n.check_sp.inc +++ b/mysql-test/include/ddl_i18n.check_sp.inc @@ -36,19 +36,19 @@ SHOW PROCEDURE STATUS LIKE 'p4'| --echo --echo ---replace_column 16 CREATED 17 ALTERED +--replace_column 23 CREATED 24 ALTERED SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p1'| --echo ---replace_column 16 CREATED 17 ALTERED +--replace_column 23 CREATED 24 ALTERED SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p2'| --echo ---replace_column 16 CREATED 17 ALTERED +--replace_column 23 CREATED 24 ALTERED SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p3'| --echo ---replace_column 16 CREATED 17 ALTERED +--replace_column 23 CREATED 24 ALTERED SELECT * FROM INFORMATION_SCHEMA.ROUTINES WHERE routine_name = 'p4'| # - Initialize the used variables (actual values don't matter); diff --git a/mysql-test/include/default_client.cnf b/mysql-test/include/default_client.cnf new file mode 100644 index 00000000000..38f0d39127a --- /dev/null +++ b/mysql-test/include/default_client.cnf @@ -0,0 +1,19 @@ +# +# We use default-character-set=latin1 to avoid character set auto-detection +# when running tests - not to depend on the current machine localization. +# + +[mysql] +default-character-set=latin1 + +[mysqlshow] +default-character-set=latin1 + +[mysqlimport] +default-character-set=latin1 + +[mysqlcheck] +default-character-set=latin1 + +[mysql_upgrade] +default-character-set=latin1 diff --git a/mysql-test/include/default_my.cnf b/mysql-test/include/default_my.cnf index fc2bd5d1140..83c67638d4e 100644 --- a/mysql-test/include/default_my.cnf +++ b/mysql-test/include/default_my.cnf @@ -1,5 +1,21 @@ +# Copyright (C) 2009 Sun Microsystems, Inc +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + # Use default setting for mysqld processes !include default_mysqld.cnf +!include default_client.cnf [mysqld.1] @@ -8,6 +24,8 @@ log-bin= master-bin +# Run tests with the performance schema instrumentation +loose-enable-performance-schema [mysqlbinlog] disable-force-if-open diff --git a/mysql-test/include/default_mysqld.cnf b/mysql-test/include/default_mysqld.cnf index 6116b20d8bb..46fdda7df84 100644 --- a/mysql-test/include/default_mysqld.cnf +++ b/mysql-test/include/default_mysqld.cnf @@ -1,8 +1,23 @@ +# Copyright (C) 2009 Sun Microsystems, Inc +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + # Default values that applies to all MySQL Servers [mysqld] open-files-limit= 1024 local-infile -default-character-set= latin1 +character-set-server= latin1 # Increase default connect_timeout to avoid intermittent # disconnects when test servers are put under load see BUG#28359 @@ -26,3 +41,7 @@ slave-net-timeout=120 log-bin=mysqld-bin +# Run tests with the performance schema instrumentation +loose-enable-performance-schema + +binlog-direct-non-transactional-updates diff --git a/mysql-test/include/diff_tables.inc b/mysql-test/include/diff_tables.inc index d15dd56b35d..ad42615511a 100644 --- a/mysql-test/include/diff_tables.inc +++ b/mysql-test/include/diff_tables.inc @@ -60,6 +60,7 @@ disable_query_log; --error 0,1 --remove_file $MYSQLTEST_VARDIR/tmp/diff_table_2 + let $_diff_table=$diff_table_2; let $_diff_i=2; while ($_diff_i) { diff --git a/mysql-test/include/handler.inc b/mysql-test/include/handler.inc index 6e7f53ba9b2..0031cb68647 100644 --- a/mysql-test/include/handler.inc +++ b/mysql-test/include/handler.inc @@ -518,12 +518,15 @@ connect (flush,localhost,root,,); connection flush; --echo connection: flush --send flush tables; -connection default; ---echo connection: default +connect (waiter,localhost,root,,); +connection waiter; +--echo connection: waiter let $wait_condition= select count(*) = 1 from information_schema.processlist where state = "Flushing tables"; --source include/wait_condition.inc +connection default; +--echo connection: default handler t2 open; handler t2 read first; handler t1 read next; @@ -540,7 +543,7 @@ disconnect flush; # --disable_warnings -drop table if exists t1,t2; +drop table if exists t1, t0; --enable_warnings create table t1 (c1 int); --echo connection: default @@ -549,24 +552,47 @@ handler t1 read first; connect (flush,localhost,root,,); connection flush; --echo connection: flush ---send rename table t1 to t2; -connection default; ---echo connection: default +--send rename table t1 to t0; +connection waiter; +--echo connection: waiter let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "Waiting for table" and info = "rename table t1 to t2"; + where state = "Waiting for table" and info = "rename table t1 to t0"; --source include/wait_condition.inc -handler t2 open; -handler t2 read first; ---error ER_NO_SUCH_TABLE -handler t1 read next; -handler t1 close; -handler t2 close; +connection default; +--echo connection: default +--echo # +--echo # RENAME placed two pending locks and waits. +--echo # When HANDLER t0 OPEN does open_tables(), it calls +--echo # mysql_ha_flush(), which in turn closes the open HANDLER for t1. +--echo # RENAME TABLE gets unblocked. If it gets scheduled quickly +--echo # and manages to complete before open_tables() +--echo # of HANDLER t0 OPEN, open_tables() and therefore the whole +--echo # HANDLER t0 OPEN succeeds. Otherwise open_tables() +--echo # notices a pending or active exclusive metadata lock on t2 +--echo # and the whole HANDLER t0 OPEN fails with ER_LOCK_DEADLOCK +--echo # error. +--echo # +--error 0, ER_LOCK_DEADLOCK +handler t0 open; +--error 0, ER_UNKNOWN_TABLE +handler t0 close; +--echo connection: flush connection flush; reap; +--error ER_UNKNOWN_TABLE +handler t1 read next; +--error ER_UNKNOWN_TABLE +handler t1 close; connection default; -drop table t2; +drop table t0; +connection flush; disconnect flush; +--source include/wait_until_disconnected.inc +connection waiter; +disconnect waiter; +--source include/wait_until_disconnected.inc +connection default; # # Bug#30882 Dropping a temporary table inside a stored function may cause a server crash @@ -699,27 +725,62 @@ handler t1 read a next; # Bug#41112: crash in mysql_ha_close_table/get_lock_data with alter table # +connect(con1,localhost,root,,); +connect(con2,localhost,root,,); + +connection default; --disable_warnings drop table if exists t1; --enable_warnings +--echo # First test case which is supposed trigger the execution +--echo # path on which problem was discovered. create table t1 (a int); insert into t1 values (1); handler t1 open; -connect(con1,localhost,root,,); +connection con1; +lock table t1 write; send alter table t1 engine=memory; -connection default; +connection con2; let $wait_condition= select count(*) = 1 from information_schema.processlist - where state = "rename result table" and info = "alter table t1 engine=memory"; + where state = "Waiting for table" and info = "alter table t1 engine=memory"; --source include/wait_condition.inc +connection default; --error ER_ILLEGAL_HA handler t1 read a next; handler t1 close; connection con1; --reap +unlock tables; +drop table t1; +--echo # Now test case which was reported originally but which no longer +--echo # triggers execution path which has caused the problem. +connection default; +create table t1 (a int, key(a)); +insert into t1 values (1); +handler t1 open; +connection con1; +send alter table t1 engine=memory; +connection con2; +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table" and info = "alter table t1 engine=memory"; +--source include/wait_condition.inc +connection default; +--echo # Since S metadata lock was already acquired at HANDLER OPEN time +--echo # and TL_READ lock requested by HANDLER READ is compatible with +--echo # ALTER's TL_WRITE_ALLOW_READ the below statement should succeed +--echo # without waiting. The old version of table should be used in it. +handler t1 read a next; +handler t1 close; +connection con1; +--reap # Since last in this connection was a send drop table t1; disconnect con1; --source include/wait_until_disconnected.inc +connection con2; +disconnect con2; +--source include/wait_until_disconnected.inc connection default; # @@ -729,3 +790,970 @@ USE information_schema; --error ER_WRONG_USAGE HANDLER COLUMNS OPEN; USE test; + +--echo # +--echo # Add test coverage for HANDLER and LOCK TABLES, HANDLER and DDL. +--echo # +--disable_warnings +drop table if exists t1, t2, t3; +--enable_warnings +create table t1 (a int, key a (a)); +insert into t1 (a) values (1), (2), (3), (4), (5); +create table t2 (a int, key a (a)) select * from t1; +create temporary table t3 (a int, key a (a)) select * from t2; +handler t1 open; +handler t2 open; +handler t3 open; +--echo # +--echo # No HANDLER sql is allowed under LOCK TABLES. +--echo # But it does not implicitly closes all handlers. +--echo # +lock table t1 read; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +handler t1 open; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +handler t1 read next; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +handler t2 close; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +handler t3 open; +--echo # After UNLOCK TABLES handlers should be around and +--echo # we should be able to continue reading through them. +unlock tables; +handler t1 read next; +handler t1 close; +handler t2 read next; +handler t2 close; +handler t3 read next; +handler t3 close; +drop temporary table t3; +--echo # +--echo # Other operations that implicitly close handler: +--echo # +--echo # TRUNCATE +--echo # +handler t1 open; +truncate table t1; +--error ER_UNKNOWN_TABLE +handler t1 read next; +handler t1 open; +--echo # +--echo # CREATE TRIGGER +--echo # +create trigger t1_ai after insert on t1 for each row set @a=1; +--error ER_UNKNOWN_TABLE +handler t1 read next; +--echo # +--echo # DROP TRIGGER +--echo # +handler t1 open; +drop trigger t1_ai; +--error ER_UNKNOWN_TABLE +handler t1 read next; +--echo # +--echo # ALTER TABLE +--echo # +handler t1 open; +alter table t1 add column b int; +--error ER_UNKNOWN_TABLE +handler t1 read next; +--echo # +--echo # ANALYZE TABLE +--echo # +handler t1 open; +analyze table t1; +--error ER_UNKNOWN_TABLE +handler t1 read next; +--echo # +--echo # OPTIMIZE TABLE +--echo # +handler t1 open; +optimize table t1; +--error ER_UNKNOWN_TABLE +handler t1 read next; +--echo # +--echo # REPAIR TABLE +--echo # +handler t1 open; +repair table t1; +--error ER_UNKNOWN_TABLE +handler t1 read next; +--echo # +--echo # DROP TABLE, naturally. +--echo # +handler t1 open; +drop table t1; +--error ER_UNKNOWN_TABLE +handler t1 read next; +create table t1 (a int, b int, key a (a)) select a from t2; +--echo # +--echo # RENAME TABLE, naturally +--echo # +handler t1 open; +rename table t1 to t3; +--error ER_UNKNOWN_TABLE +handler t1 read next; +--echo # +--echo # CREATE TABLE (even with IF NOT EXISTS clause, +--echo # and the table exists). +--echo # +handler t2 open; +create table if not exists t2 (a int); +--error ER_UNKNOWN_TABLE +handler t2 read next; +rename table t3 to t1; +drop table t2; +--echo # +--echo # FLUSH TABLE doesn't close the table but loses the position +--echo # +handler t1 open; +handler t1 read a prev; +flush table t1; +handler t1 read a prev; +handler t1 close; +--echo # +--echo # FLUSH TABLES WITH READ LOCK behaves like FLUSH TABLE. +--echo # +handler t1 open; +handler t1 read a prev; +flush tables with read lock; +handler t1 read a prev; +handler t1 close; +unlock tables; +--echo # +--echo # Let us also check that these operations behave in similar +--echo # way under LOCK TABLES. +--echo # +--echo # TRUNCATE under LOCK TABLES. +--echo # +handler t1 open; +lock tables t1 write; +truncate table t1; +unlock tables; +--error ER_UNKNOWN_TABLE +handler t1 read next; +handler t1 open; +--echo # +--echo # CREATE TRIGGER under LOCK TABLES. +--echo # +lock tables t1 write; +create trigger t1_ai after insert on t1 for each row set @a=1; +unlock tables; +--error ER_UNKNOWN_TABLE +handler t1 read next; +--echo # +--echo # DROP TRIGGER under LOCK TABLES. +--echo # +handler t1 open; +lock tables t1 write; +drop trigger t1_ai; +unlock tables; +--error ER_UNKNOWN_TABLE +handler t1 read next; +--echo # +--echo # ALTER TABLE under LOCK TABLES. +--echo # +handler t1 open; +lock tables t1 write; +alter table t1 drop column b; +unlock tables; +--error ER_UNKNOWN_TABLE +handler t1 read next; +--echo # +--echo # ANALYZE TABLE under LOCK TABLES. +--echo # +handler t1 open; +lock tables t1 write; +analyze table t1; +unlock tables; +--error ER_UNKNOWN_TABLE +handler t1 read next; +--echo # +--echo # OPTIMIZE TABLE under LOCK TABLES. +--echo # +handler t1 open; +lock tables t1 write; +optimize table t1; +unlock tables; +--error ER_UNKNOWN_TABLE +handler t1 read next; +--echo # +--echo # REPAIR TABLE under LOCK TABLES. +--echo # +handler t1 open; +lock tables t1 write; +repair table t1; +unlock tables; +--error ER_UNKNOWN_TABLE +handler t1 read next; +--echo # +--echo # DROP TABLE under LOCK TABLES, naturally. +--echo # +handler t1 open; +lock tables t1 write; +drop table t1; +unlock tables; +--error ER_UNKNOWN_TABLE +handler t1 read next; +create table t1 (a int, b int, key a (a)); +insert into t1 (a) values (1), (2), (3), (4), (5); +--echo # +--echo # FLUSH TABLE doesn't close the table but loses the position +--echo # +handler t1 open; +handler t1 read a prev; +lock tables t1 write; +flush table t1; +unlock tables; +handler t1 read a prev; +handler t1 close; +--echo # +--echo # Explore the effect of HANDLER locks on concurrent DDL +--echo # +handler t1 open; +--echo # Establishing auxiliary connections con1, con2, con3 +connect(con1, localhost, root,,); +connect(con2, localhost, root,,); +connect(con3, localhost, root,,); +--echo # --> connection con1; +connection con1; +--echo # Sending: +--send drop table t1 +--echo # We can't use connection 'default' as wait_condition will +--echo # autoclose handlers. +--echo # --> connection con2 +connection con2; +--echo # Waitng for 'drop table t1' to get blocked... +let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1'; +--source include/wait_condition.inc +--echo # --> connection default +connection default; +handler t1 read a prev; +handler t1 read a prev; +handler t1 close; +--echo # --> connection con1 +connection con1; +--echo # Reaping 'drop table t1'... +--reap +--echo # --> connection default +connection default; +--echo # +--echo # Explore the effect of HANDLER locks in parallel with SELECT +--echo # +create table t1 (a int, key a (a)); +insert into t1 (a) values (1), (2), (3), (4), (5); +begin; +select * from t1; +handler t1 open; +handler t1 read a prev; +handler t1 read a prev; +handler t1 close; +--echo # --> connection con1; +connection con1; +--echo # Sending: +--send drop table t1 +--echo # --> connection con2 +connection con2; +--echo # Waiting for 'drop table t1' to get blocked... +let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1'; +--source include/wait_condition.inc +--echo # --> connection default +connection default; +--echo # We can still use the table, it's part of the transaction +select * from t1; +--echo # Such are the circumstances that t1 is a part of transaction, +--echo # thus we can reopen it in the handler +handler t1 open; +--echo # We can commit the transaction, it doesn't close the handler +--echo # and doesn't let DROP to proceed. +commit; +handler t1 read a prev; +handler t1 read a prev; +handler t1 read a prev; +handler t1 close; +--echo # --> connection con1 +connection con1; +--echo # Now drop can proceed +--echo # Reaping 'drop table t1'... +--reap +--echo # --> connection default +connection default; +--echo # +--echo # Demonstrate that HANDLER locks and transaction locks +--echo # reside in the same context, and we don't back-off +--echo # when have transaction or handler locks. +--echo # +create table t1 (a int, key a (a)); +insert into t1 (a) values (1), (2), (3), (4), (5); +create table t0 (a int, key a (a)); +insert into t0 (a) values (1), (2), (3), (4), (5); +begin; +select * from t1; +--echo # --> connection con2 +connection con2; +--echo # Sending: +send rename table t0 to t3, t1 to t0, t3 to t1; +--echo # --> connection con1 +connection con1; +--echo # Waiting for 'rename table ...' to get blocked... +let $wait_condition=select count(*)=1 from information_schema.processlist +where state='Waiting for table' and info='rename table t0 to t3, t1 to t0, t3 to t1'; +--source include/wait_condition.inc +--echo # --> connection default +connection default; +--error ER_LOCK_DEADLOCK +handler t0 open; +--error ER_LOCK_DEADLOCK +select * from t0; +handler t1 open; +commit; +handler t1 close; +--echo # --> connection con2 +connection con2; +--echo # Reaping 'rename table ...'... +--reap +--echo # --> connection default +connection default; +handler t1 open; +handler t1 read a prev; +handler t1 close; +drop table t0; +--echo # +--echo # Originally there was a deadlock error in this test. +--echo # With implementation of deadlock detector +--echo # we no longer deadlock, but block and wait on a lock. +--echo # The HANDLER is auto-closed as soon as the connection +--echo # sees a pending conflicting lock against it. +--echo # +create table t2 (a int, key a (a)); +handler t1 open; +--echo # --> connection con1 +connection con1; +lock tables t2 read; +--echo # --> connection con2 +connection con2; +--echo # Sending 'drop table t2'... +--send drop table t2 +--echo # --> connection con1 +connection con1; +--echo # Waiting for 'drop table t2' to get blocked... +let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2'; +--source include/wait_condition.inc +--echo # --> connection default +connection default; +--echo # Sending 'select * from t2' +send select * from t2; +--echo # --> connection con1 +connection con1; +--echo # Waiting for 'select * from t2' to get blocked... +let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='select * from t2'; +unlock tables; +--echo # --> connection con2 +connection con2; +--echo # Reaping 'drop table t2'... +--reap +--echo # --> connection default +connection default; +--echo # Reaping 'select * from t2' +--error ER_NO_SUCH_TABLE +reap; +handler t1 close; + +--echo # +--echo # ROLLBACK TO SAVEPOINT releases transactional locks, +--echo # but has no effect on open HANDLERs +--echo # +create table t2 like t1; +create table t3 like t1; +begin; +--echo # Have something before the savepoint +select * from t3; +savepoint sv; +handler t1 open; +handler t1 read a first; +handler t1 read a next; +select * from t2; +--echo # --> connection con1 +connection con1; +--echo # Sending: +--send drop table t1 +--echo # --> connection con2 +connection con2; +--echo # Sending: +--send drop table t2 +--echo # --> connection default +connection default; +--echo # Let DROP TABLE statements sync in. We must use +--echo # a separate connection for that, because otherwise SELECT +--echo # will auto-close the HANDLERs, becaues there are pending +--echo # exclusive locks against them. +--echo # --> connection con3 +connection con3; +--echo # Waiting for 'drop table t1' to get blocked... +let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1'; +--source include/wait_condition.inc +--echo # Waiting for 'drop table t2' to get blocked... +let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2'; +--source include/wait_condition.inc +--echo # Demonstrate that t2 lock was released and t2 was dropped +--echo # after ROLLBACK TO SAVEPOINT +--echo # --> connection default +connection default; +rollback to savepoint sv; +--echo # --> connection con2 +connection con2; +--echo # Reaping 'drop table t2'... +--reap +--echo # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler +--echo # lock. +--echo # --> connection default +connection default; +handler t1 read a next; +handler t1 read a next; +--echo # Demonstrate that the drop will go through as soon as we close the +--echo # HANDLER +handler t1 close; +--echo # connection con1 +connection con1; +--echo # Reaping 'drop table t1'... +--reap +--echo # --> connection default +connection default; +commit; +drop table t3; +--echo # +--echo # A few special cases when using SAVEPOINT/ROLLBACK TO +--echo # SAVEPOINT and HANDLER. +--echo # +--echo # Show that rollback to the savepoint taken in the beginning +--echo # of the transaction doesn't release mdl lock on +--echo # the HANDLER that was opened later. +--echo # +create table t1 (a int, key a(a)); +insert into t1 (a) values (1), (2), (3), (4), (5); +create table t2 like t1; +begin; +savepoint sv; +handler t1 open; +handler t1 read a first; +handler t1 read a next; +select * from t2; +--echo # --> connection con1 +connection con1; +--echo # Sending: +--send drop table t1 +--echo # --> connection con2 +connection con2; +--echo # Sending: +--send drop table t2 +--echo # --> connection default +connection default; +--echo # Let DROP TABLE statements sync in. We must use +--echo # a separate connection for that, because otherwise SELECT +--echo # will auto-close the HANDLERs, becaues there are pending +--echo # exclusive locks against them. +--echo # --> connection con3 +connection con3; +--echo # Waiting for 'drop table t1' to get blocked... +let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t1'; +--source include/wait_condition.inc +--echo # Waiting for 'drop table t2' to get blocked... +let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2'; +--source include/wait_condition.inc +--echo # Demonstrate that t2 lock was released and t2 was dropped +--echo # after ROLLBACK TO SAVEPOINT +--echo # --> connection default +connection default; +rollback to savepoint sv; +--echo # --> connection con2 +connection con2; +--echo # Reaping 'drop table t2'... +--reap +--echo # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler +--echo # lock. +--echo # --> connection default +connection default; +handler t1 read a next; +handler t1 read a next; +--echo # Demonstrate that the drop will go through as soon as we close the +--echo # HANDLER +handler t1 close; +--echo # connection con1 +connection con1; +--echo # Reaping 'drop table t1'... +--reap +--echo # --> connection default +connection default; +commit; +--echo # +--echo # Show that rollback to the savepoint taken in the beginning +--echo # of the transaction works properly (no valgrind warnins, etc), +--echo # even though it's done after the HANDLER mdl lock that was there +--echo # at the beginning is released and added again. +--echo # +create table t1 (a int, key a(a)); +insert into t1 (a) values (1), (2), (3), (4), (5); +create table t2 like t1; +create table t3 like t1; +insert into t3 (a) select a from t1; +begin; +handler t1 open; +savepoint sv; +handler t1 read a first; +select * from t2; +handler t1 close; +handler t3 open; +handler t3 read a first; +rollback to savepoint sv; +--echo # --> connection con1 +connection con1; +drop table t1, t2; +--echo # Sending: +--send drop table t3 +--echo # Let DROP TABLE statement sync in. +--echo # --> connection con2 +connection con2; +--echo # Waiting for 'drop table t3' to get blocked... +let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t3'; +--source include/wait_condition.inc +--echo # Demonstrate that ROLLBACK TO SAVEPOINT didn't release the handler +--echo # lock. +--echo # --> connection default +connection default; +handler t3 read a next; +--echo # Demonstrate that the drop will go through as soon as we close the +--echo # HANDLER +handler t3 close; +--echo # connection con1 +connection con1; +--echo # Reaping 'drop table t3'... +--reap +--echo # --> connection default +connection default; +commit; + +--echo # +--echo # If we have to wait on an exclusive locks while having +--echo # an open HANDLER, ER_LOCK_DEADLOCK is reported. +--echo # +create table t1 (a int, key a(a)); +create table t2 like t1; +handler t1 open; +--echo # --> connection con1 +connection con1; +lock table t1 write, t2 write; +--echo # --> connection default +connection default; +send drop table t2; +--echo # --> connection con2 +connection con2; +--echo # Waiting for 'drop table t2' to get blocked... +let $wait_condition=select count(*)=1 from information_schema.processlist where state='Waiting for table' and info='drop table t2'; +--source include/wait_condition.inc +--echo # --> connection con1 +connection con1; +--error ER_LOCK_DEADLOCK +drop table t1; +unlock tables; +--echo # --> connection default +connection default; +reap; + +--echo # Demonstrate that there is no deadlock with FLUSH TABLE, +--echo # even though it is waiting for the other table to go away +create table t2 like t1; +--echo # Sending: +--send flush table t2 +--echo # --> connection con2 +connection con2; +drop table t1; +--echo # --> connection con1 +connection con1; +unlock tables; +--echo # --> connection default +connection default; +--echo # Reaping 'flush table t2'... +--reap +drop table t2; + +--echo # +--echo # Bug #46224 HANDLER statements within a transaction might +--echo # lead to deadlocks +--echo # +create table t1 (a int, key a(a)); +insert into t1 values (1), (2); + +--echo # --> connection default +connection default; +begin; +select * from t1; +handler t1 open; + +--echo # --> connection con1 +connection con1; +--echo # Sending: +--send lock tables t1 write + +--echo # --> connection con2 +connection con2; +--echo # Check that 'lock tables t1 write' waits until transaction which +--echo # has read from the table commits. +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Waiting for table" and info = "lock tables t1 write"; +--source include/wait_condition.inc + +--echo # --> connection default +connection default; +--echo # The below 'handler t1 read ...' should not be blocked as +--echo # 'lock tables t1 write' has not succeeded yet. +handler t1 read a next; + +--echo # Unblock 'lock tables t1 write'. +commit; + +--echo # --> connection con1 +connection con1; +--echo # Reap 'lock tables t1 write'. +--reap + +--echo # --> connection default +connection default; +--echo # Sending: +--send handler t1 read a next + +--echo # --> connection con1 +connection con1; +--echo # Waiting for 'handler t1 read a next' to get blocked... +let $wait_condition= + select count(*) = 1 from information_schema.processlist + where state = "Table lock" and info = "handler t1 read a next"; +--source include/wait_condition.inc + +--echo # The below 'drop table t1' should be able to proceed without +--echo # waiting as it will force HANDLER to be closed. +drop table t1; +unlock tables; + +--echo # --> connection default +connection default; +--echo # Reaping 'handler t1 read a next'... +--error ER_NO_SUCH_TABLE +--reap +handler t1 close; + +--echo # --> connection con1 +connection con1; +disconnect con1; +--source include/wait_until_disconnected.inc +--echo # --> connection con2 +connection con2; +disconnect con2; +--source include/wait_until_disconnected.inc +--echo # --> connection con3 +connection con3; +disconnect con3; +--source include/wait_until_disconnected.inc +connection default; + +--echo # +--echo # A temporary table test. +--echo # Check that we don't loose positions of HANDLER opened +--echo # against a temporary table. +--echo # +create table t1 (a int, b int, key a (a)); +insert into t1 (a) values (1), (2), (3), (4), (5); +create temporary table t2 (a int, b int, key a (a)); +insert into t2 (a) select a from t1; +handler t1 open; +handler t1 read a next; +handler t2 open; +handler t2 read a next; +flush table t1; +handler t2 read a next; +--echo # Sic: the position is lost +handler t1 read a next; +select * from t1; +--echo # Sic: the position is not lost +handler t2 read a next; +--error ER_CANT_REOPEN_TABLE +select * from t2; +handler t2 read a next; +drop table t1; +drop temporary table t2; + +--echo # +--echo # A test for lock_table_names()/unlock_table_names() function. +--echo # It should work properly in presence of open HANDLER. +--echo # +create table t1 (a int, b int, key a (a)); +create table t2 like t1; +create table t3 like t1; +create table t4 like t1; +handler t1 open; +handler t2 open; +rename table t4 to t5, t3 to t4, t5 to t3; +handler t1 read first; +handler t2 read first; +drop table t1, t2, t3, t4; + +--echo # +--echo # A test for FLUSH TABLES WITH READ LOCK and HANDLER statements. +--echo # +set autocommit=0; +create table t1 (a int, b int, key a (a)); +insert into t1 (a, b) values (1, 1), (2, 1), (3, 2), (4, 2), (5, 5); +create table t2 like t1; +insert into t2 (a, b) select a, b from t1; +create table t3 like t1; +insert into t3 (a, b) select a, b from t1; +commit; +flush tables with read lock; +handler t1 open; +lock table t1 read; +--error ER_LOCK_OR_ACTIVE_TRANSACTION +handler t1 read next; +--echo # This implicitly leaves LOCK TABLES but doesn't drop the GLR +--error ER_NO_SUCH_TABLE +lock table not_exists_write read; +--echo # We still have the read lock. +--error ER_CANT_UPDATE_WITH_READLOCK +drop table t1; +handler t1 read next; +handler t1 close; +handler t1 open; +select a from t2; +handler t1 read next; +flush tables with read lock; +handler t2 open; +flush tables with read lock; +handler t1 read next; +select a from t3; +handler t2 read next; +handler t1 close; +rollback; +handler t2 close; +--error ER_CANT_UPDATE_WITH_READLOCK +drop table t1; +commit; +flush tables; +--error ER_CANT_UPDATE_WITH_READLOCK +drop table t1; +unlock tables; +drop table t1; +set autocommit=default; +drop table t2, t3; + +--echo # +--echo # HANDLER statement and operation-type aware metadata locks. +--echo # Check that when we clone a ticket for HANDLER we downrade +--echo # the lock. +--echo # +--echo # Establish an auxiliary connection con1. +connect (con1,localhost,root,,); +--echo # -> connection default +connection default; +create table t1 (a int, b int, key a (a)); +insert into t1 (a, b) values (1, 1), (2, 1), (3, 2), (4, 2), (5, 5); +begin; +insert into t1 (a, b) values (6, 6); +handler t1 open; +handler t1 read a last; +insert into t1 (a, b) values (7, 7); +handler t1 read a last; +commit; +--echo # -> connection con1 +connection con1; +--echo # Demonstrate that the HANDLER doesn't hold MDL_SHARED_WRITE. +lock table t1 write; +unlock tables; +--echo # -> connection default +connection default; +handler t1 read a prev; +handler t1 close; +--echo # Cleanup. +drop table t1; +--echo # -> connection con1 +connection con1; +disconnect con1; +--source include/wait_until_disconnected.inc +--echo # -> connection default +connection default; + +--echo # +--echo # A test for Bug#50555 "handler commands crash server in +--echo # my_hash_first()". +--echo # +--error ER_UNKNOWN_TABLE +handler no_such_table read no_such_index first; +--error ER_UNKNOWN_TABLE +handler no_such_table close; + + +--echo # +--echo # Bug#50907 Assertion `hash_tables->table->next == __null' on +--echo # HANDLER OPEN +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1, t2; +--enable_warnings + +CREATE TEMPORARY TABLE t1 (i INT); +CREATE TEMPORARY TABLE t2 (i INT); + +# This used to trigger the assert +HANDLER t2 OPEN; + +# This also used to trigger the assert +HANDLER t2 READ FIRST; + +HANDLER t2 CLOSE; +DROP TABLE t1, t2; + + +--echo # +--echo # Bug#50912 Assertion `ticket->m_type >= mdl_request->type' +--echo # failed on HANDLER + I_S +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (id INT); +HANDLER t1 OPEN; + +# This used to trigger the assert. +SELECT table_name, table_comment FROM information_schema.tables + WHERE table_schema= 'test' AND table_name= 't1'; + +HANDLER t1 CLOSE; +DROP TABLE t1; + + +--echo # +--echo # Test for bug #50908 "Assertion `handler_tables_hash.records == 0' +--echo # failed in enter_locked_tables_mode". +--echo # +--disable_warnings +drop tables if exists t1, t2; +drop function if exists f1; +--enable_warnings +create table t1 (i int); +insert into t1 values (1), (2); +create table t2 (j int); +insert into t2 values (1); +create function f1() returns int return (select count(*) from t2); +--echo # Check that open HANDLER survives statement executed in +--echo # prelocked mode. +handler t1 open; +handler t1 read next; +--echo # The below statement were aborted due to an assertion failure. +select f1() from t2; +handler t1 read next; +handler t1 close; +--echo # Check that the same happens under GLOBAL READ LOCK. +flush tables with read lock; +handler t1 open; +handler t1 read next; +select f1() from t2; +handler t1 read next; +unlock tables; +handler t1 close; +--echo # Now, check that the same happens if LOCK TABLES is executed. +handler t1 open; +handler t1 read next; +lock table t2 read; +select * from t2; +unlock tables; +handler t1 read next; +handler t1 close; +--echo # Finally, check scenario with GRL and LOCK TABLES. +flush tables with read lock; +handler t1 open; +handler t1 read next; +lock table t2 read; +select * from t2; +--echo # This unlocks both tables and GRL. +unlock tables; +handler t1 read next; +handler t1 close; +--echo # Clean-up. +drop function f1; +drop tables t1, t2; + + +--echo # +--echo # Test for bug #51136 "Crash in pthread_rwlock_rdlock on TEMPORARY + +--echo # HANDLER + LOCK + SP". +--echo # Also see additional coverage for this bug in flush.test. +--echo # +--disable_warnings +drop tables if exists t1, t2; +--enable_warnings +create table t1 (i int); +create temporary table t2 (j int); +handler t1 open; +lock table t2 read; +--echo # This commit should not release any MDL locks. +commit; +unlock tables; +--echo # The below statement crashed before the bug fix as it +--echo # has attempted to release metadata lock which was +--echo # already released by commit. +handler t1 close; +drop tables t1, t2; + + +--echo # +--echo # Bug#51355 handler stmt cause assertion in +--echo # bool MDL_context::try_acquire_lock(MDL_request*) +--echo # + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +connect(con51355, localhost, root); + +--echo # Connection default +connection default; +CREATE TABLE t1(id INT, KEY id(id)); +HANDLER t1 OPEN; + +--echo # Connection con51355 +connection con51355; +--echo # Sending: +--send DROP TABLE t1 + +--echo # Connection default +connection default; +--echo # This I_S query will cause the handler table to be closed and +--echo # the metadata lock to be released. This will allow DROP TABLE +--echo # to proceed. Waiting for the table to be removed. +let $wait_condition= + SELECT COUNT(*) = 0 FROM information_schema.tables WHERE table_name = "t1"; +--source include/wait_condition.inc + +--echo # Connection con51355 +connection con51355; +--echo # Reaping: DROP TABLE t1 +--reap + +--echo # Connection default +connection default; +--error ER_NO_SUCH_TABLE +HANDLER t1 READ id NEXT; +# This caused an assertion +--error ER_NO_SUCH_TABLE +HANDLER t1 READ id NEXT; + +HANDLER t1 CLOSE; +--echo # Connection con51355 +connection con51355; +disconnect con51355; +--source include/wait_until_disconnected.inc +--echo # Connection default +connection default; + diff --git a/mysql-test/include/have_case_insensitive_fs.inc b/mysql-test/include/have_case_insensitive_fs.inc new file mode 100644 index 00000000000..de4ad73d780 --- /dev/null +++ b/mysql-test/include/have_case_insensitive_fs.inc @@ -0,0 +1,4 @@ +--require r/case_insensitive_fs.require +--disable_query_log +show variables like 'lower_case_file_system'; +--enable_query_log diff --git a/mysql-test/include/have_community_features.inc b/mysql-test/include/have_community_features.inc deleted file mode 100644 index 66697d8dd00..00000000000 --- a/mysql-test/include/have_community_features.inc +++ /dev/null @@ -1,4 +0,0 @@ ---require r/have_community_features.require ---disable_query_log -show variables like 'have_community_features'; ---enable_query_log diff --git a/mysql-test/include/have_debug_sync.inc b/mysql-test/include/have_debug_sync.inc new file mode 100644 index 00000000000..7aa5baf3342 --- /dev/null +++ b/mysql-test/include/have_debug_sync.inc @@ -0,0 +1,5 @@ +--require r/have_debug_sync.require +disable_query_log; +let $value= query_get_value(SHOW VARIABLES LIKE 'debug_sync', Value, 1); +eval SELECT ('$value' LIKE 'ON %') AS debug_sync; +enable_query_log; diff --git a/mysql-test/include/have_dynamic_loading.inc b/mysql-test/include/have_dynamic_loading.inc index 1b2c85b3904..3ce9641d87c 100644 --- a/mysql-test/include/have_dynamic_loading.inc +++ b/mysql-test/include/have_dynamic_loading.inc @@ -1,7 +1,9 @@ # # Whether server supports dynamic loading. # ---require r/have_dynamic_loading.require +if (`SELECT @@have_dynamic_loading != 'YES'`) { + --skip The test requires dynamic loading +} disable_query_log; show variables like 'have_dynamic_loading'; enable_query_log; diff --git a/mysql-test/include/have_example_plugin.inc b/mysql-test/include/have_example_plugin.inc index a2fffc17b97..3a667d2e21a 100644 --- a/mysql-test/include/have_example_plugin.inc +++ b/mysql-test/include/have_example_plugin.inc @@ -1,13 +1,21 @@ # -# Check if server has support for loading udf's -# i.e it will support dlopen +# Check if server has support for loading plugins # ---source include/have_dynamic_loading.inc +if (`SELECT @@have_dynamic_loading != 'YES'`) { + --skip Example plugin requires dynamic loading +} # # Check if the variable EXAMPLE_PLUGIN is set # ---require r/have_example_plugin.require -disable_query_log; -eval select LENGTH('$EXAMPLE_PLUGIN') > 0 as 'have_example_plugin'; +if (`SELECT LENGTH('$EXAMPLE_PLUGIN') = 0`) { + --skip Example plugin requires the environment variable \$EXAMPLE_PLUGIN to be set (normally done by mtr) +} + +# +# Check if --plugin-dir was setup for exampledb +# +if (`SELECT CONCAT('--plugin-dir=', @@plugin_dir) != '$EXAMPLE_PLUGIN_OPT'`) { + --skip Example plugin requires that --plugin-dir is set to the example plugin dir (either the .opt file does not contain \$EXAMPLE_PLUGIN_OPT or another plugin is in use) +} enable_query_log; diff --git a/mysql-test/include/have_ipv4_mapped.inc b/mysql-test/include/have_ipv4_mapped.inc new file mode 100644 index 00000000000..d85580405cd --- /dev/null +++ b/mysql-test/include/have_ipv4_mapped.inc @@ -0,0 +1,14 @@ +# Check if ipv4 mapped to ipv6 is available. +--disable_query_log +--disable_abort_on_error +connect (checkcon123456789,::FFFF:127.0.0.1,root,,test); +if($mysql_errno) +{ +skip wrong IP; +} +connection default; +disconnect checkcon123456789; +--enable_abort_on_error +--enable_query_log +# end check + diff --git a/mysql-test/include/have_mysql_upgrade.inc b/mysql-test/include/have_mysql_upgrade.inc new file mode 100644 index 00000000000..8f486176018 --- /dev/null +++ b/mysql-test/include/have_mysql_upgrade.inc @@ -0,0 +1,4 @@ +--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_nodebug.inc b/mysql-test/include/have_nodebug.inc new file mode 100644 index 00000000000..3a5b073cd2e --- /dev/null +++ b/mysql-test/include/have_nodebug.inc @@ -0,0 +1,4 @@ +-- require r/have_nodebug.require +disable_query_log; +select (version() like '%debug%') as debug; +enable_query_log; diff --git a/mysql-test/include/have_not_innodb_plugin.inc b/mysql-test/include/have_not_innodb_plugin.inc new file mode 100644 index 00000000000..aaefbaf661c --- /dev/null +++ b/mysql-test/include/have_not_innodb_plugin.inc @@ -0,0 +1,4 @@ +disable_query_log; +--require r/not_true.require +select (PLUGIN_LIBRARY LIKE 'ha_innodb_plugin%') as `TRUE` from information_schema.plugins where PLUGIN_NAME='InnoDB'; +enable_query_log; diff --git a/mysql-test/include/have_perfschema.inc b/mysql-test/include/have_perfschema.inc new file mode 100644 index 00000000000..6d52a53b6b1 --- /dev/null +++ b/mysql-test/include/have_perfschema.inc @@ -0,0 +1,20 @@ +# Copyright (C) 2010 Sun Microsystems, Inc. +# +# 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +if (!`SELECT count(*) FROM information_schema.engines WHERE + (support = 'YES' OR support = 'DEFAULT') AND + engine = 'PERFORMANCE_SCHEMA'`){ + skip Need performance schema compiled in; +} diff --git a/mysql-test/include/have_profiling.inc b/mysql-test/include/have_profiling.inc new file mode 100644 index 00000000000..48f6668ff92 --- /dev/null +++ b/mysql-test/include/have_profiling.inc @@ -0,0 +1,4 @@ +--require r/have_profiling.require +--disable_query_log +show variables like 'have_profiling'; +--enable_query_log diff --git a/mysql-test/include/have_semisync_plugin.inc b/mysql-test/include/have_semisync_plugin.inc new file mode 100644 index 00000000000..d3b42dbf5fb --- /dev/null +++ b/mysql-test/include/have_semisync_plugin.inc @@ -0,0 +1,21 @@ +# +# Check if server has support for loading plugins +# +if (`SELECT @@have_dynamic_loading != 'YES'`) { + --skip Requires dynamic loading +} + +# +# Check if the variable SEMISYNC_MASTER_PLUGIN is set +# +if (`select LENGTH('$SEMISYNC_MASTER_PLUGIN') = 0`) +{ + skip Need semisync plugins; +} + +# +# Check if --plugin-dir was setup for semisync +# +if (`SELECT CONCAT('--plugin-dir=', @@plugin_dir) != '$SEMISYNC_PLUGIN_OPT'`) { + --skip SEMISYNC plugin requires that --plugin-dir is set to the semisync plugin dir (either the .opt file does not contain \$SEMISYNC_PLUGIN_OPT or another plugin is in use) +} diff --git a/mysql-test/include/have_simple_parser.inc b/mysql-test/include/have_simple_parser.inc index 5a4dc93ec81..745f68603fe 100644 --- a/mysql-test/include/have_simple_parser.inc +++ b/mysql-test/include/have_simple_parser.inc @@ -1,13 +1,20 @@ # -# Check if server has support for loading udf's -# i.e it will support dlopen +# Check if server has support for loading plugins # ---source include/have_dynamic_loading.inc +if (`SELECT @@have_dynamic_loading != 'YES'`) { + --skip simple parser requires dynamic loading +} # # Check if the variable SIMPLE_PARSER is set # ---require r/have_simple_parser.require -disable_query_log; -eval select LENGTH('$SIMPLE_PARSER') > 0 as 'have_simple_parser'; -enable_query_log; +if (`SELECT LENGTH('$SIMPLE_PARSER') = 0`) { + --skip simple parser requires the environment variable \$SIMPLE_PARSER to be set (normally done by mtr) +} + +# +# Check if --plugin-dir was setup for simple parser +# +if (`SELECT CONCAT('--plugin-dir=', @@plugin_dir) != '$SIMPLE_PARSER_OPT'`) { + --skip simple parser requires that --plugin-dir is set to the udf plugin dir (either the .opt file does not contain \$UDF_EXAMPLE_LIB_OPT or another plugin is in use) +} diff --git a/mysql-test/include/have_ssl_communication.inc b/mysql-test/include/have_ssl_communication.inc new file mode 100644 index 00000000000..6f2d5587a75 --- /dev/null +++ b/mysql-test/include/have_ssl_communication.inc @@ -0,0 +1,4 @@ +-- require r/have_ssl.require +disable_query_log; +show variables like 'have_ssl'; +enable_query_log; diff --git a/mysql-test/include/have_thread_concurrency.inc b/mysql-test/include/have_thread_concurrency.inc new file mode 100644 index 00000000000..730edbf4895 --- /dev/null +++ b/mysql-test/include/have_thread_concurrency.inc @@ -0,0 +1,10 @@ +disable_query_log; +disable_result_log; +set @have_thread_concurrency=0; +select @have_thread_concurrency:=1 from information_schema.global_variables where variable_name='thread_concurrency'; +if (`select @have_thread_concurrency = 0`) +{ + skip Need @@thread_concurrency; +} +enable_result_log; +enable_query_log; diff --git a/mysql-test/include/have_udf.inc b/mysql-test/include/have_udf.inc index 7be57bbb7a9..d9ca1450043 100644 --- a/mysql-test/include/have_udf.inc +++ b/mysql-test/include/have_udf.inc @@ -1,13 +1,20 @@ # -# Check if server has support for loading udf's -# i.e it will support dlopen +# Check if server has support for loading plugins # ---source include/have_dynamic_loading.inc +if (`SELECT @@have_dynamic_loading != 'YES'`) { + --skip UDF requires dynamic loading +} # # Check if the variable UDF_EXAMPLE_LIB is set # ---require r/have_udf_example.require -disable_query_log; -eval select LENGTH('$UDF_EXAMPLE_LIB') > 0 as 'have_udf_example_lib'; -enable_query_log; +if (`SELECT LENGTH('$UDF_EXAMPLE_LIB') = 0`) { + --skip UDF requires the environment variable \$UDF_EXAMPLE_LIB to be set (normally done by mtr) +} + +# +# Check if --plugin-dir was setup for udf +# +if (`SELECT CONCAT('--plugin-dir=', @@plugin_dir) != '$UDF_EXAMPLE_LIB_OPT'`) { + --skip UDF requires that --plugin-dir is set to the udf plugin dir (either the .opt file does not contain \$UDF_EXAMPLE_LIB_OPT or another plugin is in use) +} diff --git a/mysql-test/include/have_utf16.inc b/mysql-test/include/have_utf16.inc new file mode 100644 index 00000000000..ab22c255c88 --- /dev/null +++ b/mysql-test/include/have_utf16.inc @@ -0,0 +1,4 @@ +-- require r/have_utf16.require +disable_query_log; +show collation like 'utf16_general_ci'; +enable_query_log; diff --git a/mysql-test/include/have_utf32.inc b/mysql-test/include/have_utf32.inc new file mode 100644 index 00000000000..f5b5353c9fd --- /dev/null +++ b/mysql-test/include/have_utf32.inc @@ -0,0 +1,4 @@ +-- require r/have_utf32.require +disable_query_log; +show collation like 'utf32_general_ci'; +enable_query_log; diff --git a/mysql-test/include/have_utf8mb4.inc b/mysql-test/include/have_utf8mb4.inc new file mode 100644 index 00000000000..6eb91b1c23c --- /dev/null +++ b/mysql-test/include/have_utf8mb4.inc @@ -0,0 +1,7 @@ +--require r/have_utf8mb4.require + +--disable_query_log + +SHOW COLLATION LIKE 'utf8mb4_general_ci'; + +--enable_query_log diff --git a/mysql-test/include/implicit_commit_helper.inc b/mysql-test/include/implicit_commit_helper.inc new file mode 100644 index 00000000000..5e87b2db079 --- /dev/null +++ b/mysql-test/include/implicit_commit_helper.inc @@ -0,0 +1,5 @@ +INSERT INTO db1.trans (a) VALUES (1); +--disable_result_log +eval $statement; +--enable_result_log +CALL db1.test_if_commit(); diff --git a/mysql-test/include/index_merge1.inc b/mysql-test/include/index_merge1.inc index d137b0957c0..ef116c5addc 100644 --- a/mysql-test/include/index_merge1.inc +++ b/mysql-test/include/index_merge1.inc @@ -303,7 +303,7 @@ drop table t4; create table t4 (a int); insert into t4 values (1),(4),(3); set @save_join_buffer_size=@@join_buffer_size; -set join_buffer_size= 4000; +set join_buffer_size= 4096; explain select max(A.key1 + B.key1 + A.key2 + B.key2 + A.key3 + B.key3 + A.key4 + B.key4 + A.key5 + B.key5) from t0 as A force index(i1,i2), t0 as B force index (i1,i2) where (A.key1 < 500000 or A.key2 < 3) diff --git a/mysql-test/include/ipv6.inc b/mysql-test/include/ipv6.inc new file mode 100644 index 00000000000..3d8fdcfbc3c --- /dev/null +++ b/mysql-test/include/ipv6.inc @@ -0,0 +1,25 @@ +eval CREATE USER testuser@'$IPv6' identified by '1234'; +eval GRANT ALL ON test.* TO testuser@'$IPv6'; +eval SHOW GRANTS FOR testuser@'$IPv6'; +# deliver NULL instead of a valid number, see bug#34037 +eval SET @nip= inet_aton('$IPv6'); +SELECT @nip; +SELECT inet_ntoa(@nip); +# delivers a wrong value, see bug#34037 +--replace_result ::1 localhost +SELECT USER(); +--replace_result ::1 localhost +SELECT current_user(); +--disable_result_log +SHOW PROCESSLIST; +--enable_result_log +connect (con1, $IPv6, root, , test, $MASTER_MYPORT); +connection default; +disconnect con1; +eval REVOKE ALL ON test.* FROM testuser@'$IPv6'; +eval RENAME USER testuser@'$IPv6' to testuser1@'$IPv6'; +eval SET PASSWORD FOR testuser1@'$IPv6' = PASSWORD ('9876'); +--replace_result ::1 localhost +SELECT USER(); +eval DROP USER testuser1@'$IPv6'; + diff --git a/mysql-test/include/ipv6_clients.inc b/mysql-test/include/ipv6_clients.inc new file mode 100644 index 00000000000..3f2b35d811a --- /dev/null +++ b/mysql-test/include/ipv6_clients.inc @@ -0,0 +1,7 @@ +--exec $MYSQLADMIN --no-defaults --default-character-set=latin1 -h $IPv6 -P $MASTER_MYPORT -u root ping +--disable_result_log +--exec $MYSQL_CHECK -h $IPv6 -P $MASTER_MYPORT -u root test +--exec $MYSQL_DUMP -h $IPv6 -P $MASTER_MYPORT -u root test +--exec $MYSQL_SHOW -h $IPv6 -P $MASTER_MYPORT -u root +--exec $MYSQL --host=$IPv6 --port=$MASTER_MYPORT --user=root test -e "SELECT current_user();SELECT user();" +--enable_result_log diff --git a/mysql-test/include/kill_query.inc b/mysql-test/include/kill_query.inc index 341c3b93535..b303ed0ec39 100644 --- a/mysql-test/include/kill_query.inc +++ b/mysql-test/include/kill_query.inc @@ -52,7 +52,7 @@ if (`SELECT '$debug_lock' != ''`) # reap the result of the waiting query connection $connection_name; -error 0, 1317, 1307, 1306, 1334, 1305; +error 0, 1317, 1307, 1306, 1334, 1305, 1034; reap; connection master; diff --git a/mysql-test/include/master-slave-reset.inc b/mysql-test/include/master-slave-reset.inc index 938eb2c074a..f54f5b83eb5 100644 --- a/mysql-test/include/master-slave-reset.inc +++ b/mysql-test/include/master-slave-reset.inc @@ -6,12 +6,29 @@ # Since we expect STOP SLAVE to produce a warning as the slave is # stopped (the server was started with skip-slave-start), we disable # warnings when doing STOP SLAVE. +# +# $no_change_master If true, no change master will be done nor any reset slave. +# This is to avoid touching the relay-log.info file allowing +# the test to create one itself. +# $skip_slave_start If true, the slave will not be started connection slave; + +#we expect STOP SLAVE to produce a warning as the slave is stopped +#(the server was started with skip-slave-start) --disable_warnings stop slave; +--disable_query_log +if (!$no_change_master) { + eval CHANGE MASTER TO MASTER_USER='root', + MASTER_CONNECT_RETRY=1, + MASTER_HOST='127.0.0.1', + MASTER_PORT=$MASTER_MYPORT; +} +--enable_query_log source include/wait_for_slave_to_stop.inc; --enable_warnings + connection master; --disable_warnings --disable_query_log @@ -20,17 +37,39 @@ use test; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; --enable_warnings reset master; + --disable_query_log -reset slave; +if (!$no_change_master) { + reset slave; +} --enable_query_log connection slave; -reset slave; + +--disable_warnings +# the first RESET SLAVE may produce a warning about non-existent +# 'ndb_apply_status' table, because this table is created +# asynchronously at the server startup and may not exist yet +# if RESET SLAVE comes too soon after the server startup +if (!$no_change_master) { + reset slave; +} +--enable_warnings + # Clean up old test tables --disable_warnings drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; --enable_warnings + --disable_query_log +#eval CHANGE MASTER TO MASTER_USER='root', +# MASTER_CONNECT_RETRY=1, +# MASTER_HOST='127.0.0.1', +# MASTER_PORT=$MASTER_MYPORT; reset master; --enable_query_log -start slave; -source include/wait_for_slave_to_start.inc; + +if (!$skip_slave_start) { + start slave; + source include/wait_for_slave_to_start.inc; +} + diff --git a/mysql-test/include/master-slave.inc b/mysql-test/include/master-slave.inc index e0eb87f02f7..134bb61ddab 100644 --- a/mysql-test/include/master-slave.inc +++ b/mysql-test/include/master-slave.inc @@ -1,4 +1,6 @@ # Replication tests need binlog +# +# $skip_slave_start If true, the slave will not be started source include/have_log_bin.inc; connect (master,127.0.0.1,root,,test,$MASTER_MYPORT,); @@ -8,5 +10,10 @@ connect (slave1,127.0.0.1,root,,test,$SLAVE_MYPORT,); -- source include/master-slave-reset.inc +if (!$skip_slave_start) { + connection master; + sync_slave_with_master; +} + # Set the default connection to 'master' connection master; diff --git a/mysql-test/include/mix1.inc b/mysql-test/include/mix1.inc index 6dabe4864a9..66648aaf1bf 100644 --- a/mysql-test/include/mix1.inc +++ b/mysql-test/include/mix1.inc @@ -442,6 +442,8 @@ INSERT INTO t1(id, dept, age, name) VALUES EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; DELETE FROM t1; +--echo # Masking (#) number in "rows" column of the following EXPLAIN output, as it may vary (bug#47746). +--replace_column 9 # EXPLAIN SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; SELECT DISTINCT t1.name, t1.dept FROM t1 WHERE t1.name='rs5'; @@ -897,6 +899,8 @@ CREATE PROCEDURE p1 () BEGIN DECLARE i INT DEFAULT 50; DECLARE cnt INT; + # Continue even in the presence of ER_LOCK_DEADLOCK. + DECLARE CONTINUE HANDLER FOR 1213 BEGIN END; START TRANSACTION; ALTER TABLE t1 ENGINE=InnoDB; COMMIT; @@ -1390,6 +1394,7 @@ SELECT * FROM t1; connection con2; --reap SELECT * FROM t1; +COMMIT; --echo # Switch to connection con1 connection con1; diff --git a/mysql-test/include/mix2.inc b/mysql-test/include/mix2.inc index b4c4a9b8836..001d4cf44d4 100644 --- a/mysql-test/include/mix2.inc +++ b/mysql-test/include/mix2.inc @@ -1994,6 +1994,7 @@ commit; connection b; set autocommit = 0; update t1 set b = 5 where a = 2; +commit; connection a; delimiter |; create trigger t1t before insert on t1 for each row begin set NEW.b = NEW.a * 10 + 5, NEW.c = NEW.a / 10; end | @@ -2056,6 +2057,7 @@ update t2 set b = b + 5 where a = 1; update t3 set b = b + 5 where a = 1; update t4 set b = b + 5 where a = 1; insert into t5(a) values(20); +commit; connection b; set autocommit = 0; insert into t1(a) values(7); diff --git a/mysql-test/include/mtr_warnings.sql b/mysql-test/include/mtr_warnings.sql index 52bf4cd51ef..bf0a58788d6 100644 --- a/mysql-test/include/mtr_warnings.sql +++ b/mysql-test/include/mtr_warnings.sql @@ -173,6 +173,7 @@ INSERT INTO global_suppressions VALUES this error message. */ ("Can't find file: '.\\\\test\\\\\\?{8}.frm'"), + ("Slave: Unknown table 't1' Error_code: 1051"), /* Added 2009-08-XX after fixing Bug #42408 */ @@ -185,6 +186,37 @@ INSERT INTO global_suppressions VALUES (": 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"), + /* Messages from valgrind */ + ("==[0-9]*== Memcheck,"), + ("==[0-9]*== Copyright"), + ("==[0-9]*== Using"), + ("==[0-9]*== For more details"), + /* This comes with innodb plugin tests */ + ("==[0-9]*== Warning: set address range perms: large range"), + /* valgrind-3.5.0 dumps this */ + ("==[0-9]*== Command: "), + + /* valgrind warnings: invalid file descriptor -1 in syscall + write()/read(). Bug #50414 */ + ("==[0-9]*== Warning: invalid file descriptor -1 in syscall write()"), + ("==[0-9]*== Warning: invalid file descriptor -1 in syscall read()"), + + /* + Transient network failures that cause warnings on reconnect. + BUG#47743 and BUG#47983. + */ + ("Slave I/O: Get master SERVER_ID failed with error:.*"), + ("Slave I/O: Get master clock failed with error:.*"), + ("Slave I/O: Get master COLLATION_SERVER failed with error:.*"), + ("Slave I/O: Get master TIME_ZONE failed with error:.*"), + /* + BUG#42147 - Concurrent DML and LOCK TABLE ... READ for InnoDB + table cause warnings in errlog + Note: This is a temporary suppression until Bug#42147 can be + fixed properly. See bug page for more information. + */ + ("Found lock of type 6 that is write and read locked"), + ("THE_LAST_SUPPRESSION")|| @@ -220,7 +252,7 @@ BEGIN WHERE suspicious=1; IF @num_warnings > 0 THEN - SELECT file_name, line + SELECT line FROM error_log WHERE suspicious=1; --SELECT * FROM test_suppressions; -- Return 2 -> check failed diff --git a/mysql-test/include/mysqld--help.inc b/mysql-test/include/mysqld--help.inc new file mode 100644 index 00000000000..e318823d8af --- /dev/null +++ b/mysql-test/include/mysqld--help.inc @@ -0,0 +1,45 @@ +# +# mysqld --help +# +--source include/not_embedded.inc + +# +# force lower-case-table-names=1 (linux/macosx have different defaults) +# force symbolic-links=0 (valgrind build has a different default) +# +exec $MYSQLD_BOOTSTRAP_CMD --symbolic-links=0 --lower-case-table-names=1 --help --verbose > $MYSQL_TMP_DIR/mysqld--help.txt 2>&1; + +perl; + @skipvars=qw/basedir open-files-limit general-log-file log plugin-dir + log-slow-queries pid-file slow-query-log-file + datadir slave-load-tmpdir tmpdir/; + @plugins=qw/innodb ndb archive blackhole federated partition ndbcluster safemalloc debug temp-pool ssl des-key-file + thread-concurrency super-large-pages mutex-deadlock-detector null-audit/; + @env=qw/MYSQLTEST_VARDIR MYSQL_TEST_DIR MYSQL_LIBDIR MYSQL_CHARSETSDIR MYSQL_SHAREDIR /; + $re1=join('|', @skipvars, @plugins); + $re2=join('|', @plugins); + $skip=0; + open(F, '<', "$ENV{MYSQL_TMP_DIR}/mysqld--help.txt") or die; + while (<F>) { + next if 1../The following groups are read/; + # formatting, skip line consisting entirely of dashes and blanks + next if /^[\- ]+$/; + next if /Value \(after reading options\)/; # skip table header + next if /^($re1) /; + next if /^($re2)-/; + $skip=0 if /^ -/; + $skip=1 if / --($re2)\b/; + y!\\!/!; + s/[ ]+/ /; # squeeze spaces to remove table formatting + # fixes for 32-bit + s/\b4294967295\b/18446744073709551615/; + s/\b2146435072\b/9223372036853727232/; + s/\b196608\b/262144/; + foreach $var (@env) { s/$ENV{$var}/$var/ } + next if /use --skip-(use-)?symbolic-links to disable/; # for valgrind, again + next if $skip; + print; + } + close F; +EOF + diff --git a/mysql-test/include/not_binlog_format_row.inc b/mysql-test/include/not_binlog_format_row.inc new file mode 100644 index 00000000000..f9354e7cd33 --- /dev/null +++ b/mysql-test/include/not_binlog_format_row.inc @@ -0,0 +1,4 @@ +if (`SELECT @@binlog_format = 'ROW'`) +{ + skip Test cannot run with binlog_format row; +} diff --git a/mysql-test/include/not_ndb_default.inc b/mysql-test/include/not_ndb_default.inc index ca3c57a671a..682a2944171 100644 --- a/mysql-test/include/not_ndb_default.inc +++ b/mysql-test/include/not_ndb_default.inc @@ -1,4 +1,4 @@ --require r/not_ndb_default.require disable_query_log; -select convert(@@table_type using latin1) NOT IN ("ndbcluster","NDBCLUSTER") as "TRUE"; +select convert(@@storage_engine using latin1) NOT IN ("ndbcluster","NDBCLUSTER") as "TRUE"; enable_query_log; diff --git a/mysql-test/include/not_windows_embedded.inc b/mysql-test/include/not_windows_embedded.inc new file mode 100644 index 00000000000..46f5e0ccfce --- /dev/null +++ b/mysql-test/include/not_windows_embedded.inc @@ -0,0 +1,11 @@ +let $is_win = `select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows")`; +let $is_embedded = `select version() like '%embedded%'`; +#echo is_win: $is_win; +#echo is_embedded: $is_embedded; +if ($is_win) +{ + if ($is_embedded) + { + skip Not supported with embedded on windows; + } +} diff --git a/mysql-test/include/query_cache.inc b/mysql-test/include/query_cache.inc index 7ce97b42158..0cc1ebb21d6 100644 --- a/mysql-test/include/query_cache.inc +++ b/mysql-test/include/query_cache.inc @@ -114,7 +114,7 @@ connection default; # This should be 'YES'. SHOW VARIABLES LIKE 'have_query_cache'; -SET GLOBAL query_cache_size = 200000; +SET GLOBAL query_cache_size = 204800; flush status; SET @@autocommit=1; eval SET SESSION STORAGE_ENGINE = $engine_type; diff --git a/mysql-test/include/query_cache_sql_prepare.inc b/mysql-test/include/query_cache_sql_prepare.inc index 1842d5412bb..769cd535f37 100644 --- a/mysql-test/include/query_cache_sql_prepare.inc +++ b/mysql-test/include/query_cache_sql_prepare.inc @@ -1,11 +1,13 @@ ############### include/query_cache_sql_prepare.inc ################ # # This is to see how statements prepared via the PREPARE SQL command -# go into the query cache: if using parameters they cannot; if not -# using parameters they can. +# go into the query cache. # Query cache is abbreviated as "QC" # # Last update: +# 2008-05-26 Kostja +# - Add test coverage for automatic statement reprepare +# # 2007-05-03 ML - Move t/query_cache_sql_prepare.test # to include/query_cache_sql_prepare.inc # - Create two toplevel tests sourcing this routine @@ -25,7 +27,7 @@ connect (con1,localhost,root,,test,$MASTER_MYPORT,); connection default; set @initial_query_cache_size = @@global.query_cache_size; -set @@global.query_cache_size=100000; +set @@global.query_cache_size=102400; flush status; --disable_warnings drop table if exists t1; @@ -176,7 +178,7 @@ show status like 'Qcache_hits'; # then QC is re-enabled for more EXECUTE. --echo ---- switch to connection default ---- connection default; -set global query_cache_size=100000; +set global query_cache_size=102400; # Expect to see additional Qcache_hits. # The fact that the QC was temporary disabled should have no affect # except that the first execute will not hit results from the @@ -233,7 +235,7 @@ prepare stmt3 from "select * from t1 where c1=10"; --echo ---- switch to connection default ---- connection default; # then QC is enabled at EXECUTE -set global query_cache_size=100000; +set global query_cache_size=102400; show status like 'Qcache_hits'; execute stmt1; show status like 'Qcache_hits'; @@ -258,7 +260,7 @@ connection default; set global query_cache_size=0; prepare stmt1 from "select * from t1 where c1=?"; # then QC is enabled at EXECUTE -set global query_cache_size=100000; +set global query_cache_size=102400; show status like 'Qcache_hits'; set @a=1; execute stmt1 using @a; @@ -490,6 +492,37 @@ use test; --echo --echo ######################################################################## +--echo # +--echo # Bug#27430 Crash in subquery code when in PS and table DDL changed +--echo # after PREPARE +--echo # Check the effect of automatic reprepare on query cache +--echo # +--echo ######################################################################## +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (a varchar(255)); +insert into t1 (a) values ("Pack my box with five dozen liquor jugs."); +flush status; +prepare stmt from "select a from t1"; +execute stmt; +set @@global.query_cache_size=0; +alter table t1 add column b int; +execute stmt; +set @@global.query_cache_size=102400; +execute stmt; +execute stmt; +--echo # +--echo # Sic: ALTER TABLE caused an automatic reprepare +--echo # of the prepared statement. Since the query cache was disabled +--echo # at the time of reprepare, the new prepared statement doesn't +--echo # work with it. +--echo # +show status like 'Qcache_hits'; +show status like 'Qcache_queries_in_cache'; +--echo # Cleanup +deallocate prepare stmt; +drop table t1; ############################################################################### diff --git a/mysql-test/include/rpl_ip_mix.inc b/mysql-test/include/rpl_ip_mix.inc new file mode 100644 index 00000000000..96766e7dbdd --- /dev/null +++ b/mysql-test/include/rpl_ip_mix.inc @@ -0,0 +1,24 @@ +--echo connect (master,$IPv6,root,,test,MASTER_MYPORT); +connect (master,$IPv6,root,,test,$MASTER_MYPORT); +--echo connect (slave,127.0.0.1,root,,test,SLAVE_MYPORT); +connect (slave,127.0.0.1,root,,test,$SLAVE_MYPORT); +--echo connection master; +connection master; +reset master; +source include/show_master_status.inc; +save_master_pos; +--echo connection slave; +connection slave; +reset slave; +let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1); +--echo Master-Host: $master_host +eval change master to master_host='$IPv6'; +let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1); +--echo Master-Host: $master_host +--echo disconnect slave; +disconnect slave; +--echo disconnect master; +disconnect master; +--echo connection default; +connection default; + diff --git a/mysql-test/include/rpl_ip_mix2.inc b/mysql-test/include/rpl_ip_mix2.inc new file mode 100644 index 00000000000..390c788a461 --- /dev/null +++ b/mysql-test/include/rpl_ip_mix2.inc @@ -0,0 +1,24 @@ +--echo connect (master,127.0.0.1,root,,test,MASTER_MYPORT); +connect (master,127.0.0.1,root,,test,$MASTER_MYPORT); +--echo connect (slave,$IPv6,root,,test,SLAVE_MYPORT); +connect (slave,$IPv6,root,,test,$SLAVE_MYPORT); +--echo connection master; +connection master; +reset master; +source include/show_master_status.inc; +save_master_pos; +--echo connection slave; +connection slave; +reset slave; +let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1); +--echo Master-Host: $master_host +eval change master to master_host='$IPv6'; +let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1); +--echo Master-Host: $master_host +--echo disconnect slave; +disconnect slave; +--echo disconnect master; +disconnect master; +--echo connection default; +connection default; + diff --git a/mysql-test/include/rpl_ipv6.inc b/mysql-test/include/rpl_ipv6.inc new file mode 100644 index 00000000000..d2d53a4841a --- /dev/null +++ b/mysql-test/include/rpl_ipv6.inc @@ -0,0 +1,22 @@ +--echo connect (master,$IPv6,root,,test,MASTER_MYPORT); +connect (master,$IPv6,root,,test,$MASTER_MYPORT); +--echo connect (slave,$IPv6,root,,test,SLAVE_MYPORT); +connect (slave,$IPv6,root,,test,$SLAVE_MYPORT); +--echo connection master; +connection master; +reset master; +source include/show_master_status.inc; +save_master_pos; +--echo connection slave; +connection slave; +reset slave; +eval change master to master_host='$IPv6'; +let $master_host= query_get_value(SHOW SLAVE STATUS, Master_Host, 1); +--echo Master-Host: $master_host +--echo disconnect slave; +disconnect slave; +--echo disconnect master; +disconnect master; +--echo connection default; +connection default; + diff --git a/mysql-test/include/rpl_udf.inc b/mysql-test/include/rpl_udf.inc index 30f39d79d49..8be866613cb 100644 --- a/mysql-test/include/rpl_udf.inc +++ b/mysql-test/include/rpl_udf.inc @@ -55,11 +55,13 @@ connection master; --echo "Running on the master" --enable_info eval CREATE TABLE t1(sum INT, price FLOAT(24)) ENGINE=$engine_type; +--disable_warnings INSERT INTO t1 VALUES(myfunc_int(100), myfunc_double(50.00)); INSERT INTO t1 VALUES(myfunc_int(10), myfunc_double(5.00)); INSERT INTO t1 VALUES(myfunc_int(200), myfunc_double(25.00)); INSERT INTO t1 VALUES(myfunc_int(1), myfunc_double(500.00)); SELECT * FROM t1 ORDER BY sum; +--enable_warnings --disable_info sync_slave_with_master; diff --git a/mysql-test/include/setup_fake_relay_log.inc b/mysql-test/include/setup_fake_relay_log.inc index f88806e1079..86a5da328af 100644 --- a/mysql-test/include/setup_fake_relay_log.inc +++ b/mysql-test/include/setup_fake_relay_log.inc @@ -66,10 +66,32 @@ let $_fake_relay_index= $MYSQLD_DATADIR/$_fake_filename.index; # CHANGE MASTER modifies it (see the manual for CHANGE MASTER). let $_fake_relay_log_purge= `SELECT @@global.relay_log_purge`; +# Reset slave and remove relay log and index files if they exist +RESET SLAVE; +error 0,1; +remove_file $MYSQLD_DATADIR/$_fake_filename.000001; +error 0,1; +remove_file $MYSQLD_DATADIR/$_fake_filename.index; + # Create relay log file. copy_file $fake_relay_log $_fake_relay_log; + # Create relay log index. ---exec echo $_fake_filename-fake.000001 > $_fake_relay_index + +# After patch for BUG#12190, the filename used in CHANGE MASTER +# RELAY_LOG_FILE will be automatically added the directory of the +# relay log before comparison, thus we need to added the directory +# part (./ on unix .\ on windows) when faking the relay-log-bin.index. + +if (`select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows") = 0`) +{ + eval select './$_fake_filename-fake.000001\n' into dumpfile '$_fake_relay_index'; +} + +if (`select convert(@@version_compile_os using latin1) IN ("Win32","Win64","Windows") != 0`) +{ + eval select '.\\\\$_fake_filename-fake.000001\n' into dumpfile '$_fake_relay_index'; +} # 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; diff --git a/mysql-test/include/show_binlog_events.inc b/mysql-test/include/show_binlog_events.inc index 68f913a16a3..fcdc52eaf14 100644 --- a/mysql-test/include/show_binlog_events.inc +++ b/mysql-test/include/show_binlog_events.inc @@ -1,10 +1,35 @@ # $binlog_start can be set by caller or take a default value +# $binary_log_file the name of the log file show +# $binary_log_limit_row - sets the number of binlog rows to be returned +# $binary_log_limit_offset - sets the offset where to start returning events + +let $show_binlog_events= show binlog events; if (!$binlog_start) { - let $binlog_start=106; + # defaults to chop the first event in the binary log + let $binlog_start=107; } + +if (!`SELECT '$binary_log_file' = ''`) +{ + let $show_binlog_events= $show_binlog_events in '$binary_log_file'; +} +let $show_binlog_events= $show_binlog_events from $binlog_start; + +if ($binary_log_limit_row) +{ + let $limit= limit; + if ($binary_log_limit_offset) + { + let $limit= $limit $binary_log_limit_offset, ; + } + + let $limit= $limit $binary_log_limit_row; + let $show_binlog_events= $show_binlog_events $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=#/ ---eval show binlog events from $binlog_start +--eval $show_binlog_events diff --git a/mysql-test/include/show_binlog_events2.inc b/mysql-test/include/show_binlog_events2.inc index 5dd272c562d..0e1a889bacc 100644 --- a/mysql-test/include/show_binlog_events2.inc +++ b/mysql-test/include/show_binlog_events2.inc @@ -1,4 +1,4 @@ ---let $binlog_start=106 +--let $binlog_start=107 --replace_result $binlog_start <binlog_start> --replace_column 2 # 5 # --replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ diff --git a/mysql-test/include/show_relaylog_events.inc b/mysql-test/include/show_relaylog_events.inc new file mode 100644 index 00000000000..6f63b055d58 --- /dev/null +++ b/mysql-test/include/show_relaylog_events.inc @@ -0,0 +1,35 @@ +# $binlog_start can be set by caller or take a default value +# $binary_log_file the name of the log file show +# $binary_log_limit_row - sets the number of binlog rows to be returned +# $binary_log_limit_offset - sets the offset where to start returning events + +let $show_binlog_events= show relaylog events; + +if (!$binlog_start) +{ + # defaults to chop the first event in the binary log + let $binlog_start=106; +} + +if (!`SELECT '$binary_log_file' = ''`) +{ + let $show_binlog_events= $show_binlog_events in '$binary_log_file'; +} +let $show_binlog_events= $show_binlog_events from $binlog_start; + +if ($binary_log_limit_row) +{ + let $limit= limit; + if ($binary_log_limit_offset) + { + let $limit= $limit $binary_log_limit_offset, ; + } + + let $limit= $limit $binary_log_limit_row; + let $show_binlog_events= $show_binlog_events $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 $show_binlog_events diff --git a/mysql-test/include/show_slave_status2.inc b/mysql-test/include/show_slave_status2.inc index 9c4e14c62c2..7e970b31d8e 100644 --- a/mysql-test/include/show_slave_status2.inc +++ b/mysql-test/include/show_slave_status2.inc @@ -3,6 +3,6 @@ # masked out log positions ---replace_result $MASTER_MYPORT MASTER_PORT +--replace_result $MASTER_MYPORT MASTER_PORT $DEFAULT_MASTER_PORT 3306 --replace_column 1 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 # query_vertical SHOW SLAVE STATUS; diff --git a/mysql-test/include/test_fieldsize.inc b/mysql-test/include/test_fieldsize.inc index cbe63e26318..606bc63779d 100644 --- a/mysql-test/include/test_fieldsize.inc +++ b/mysql-test/include/test_fieldsize.inc @@ -22,7 +22,7 @@ eval $test_insert; connection slave; START SLAVE; -wait_for_slave_to_stop; +--source include/wait_for_slave_sql_to_stop.inc --replace_result $MASTER_MYPORT MASTER_PORT --replace_column 1 # 4 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 # --query_vertical SHOW SLAVE STATUS diff --git a/mysql-test/include/truncate_file.inc b/mysql-test/include/truncate_file.inc new file mode 100644 index 00000000000..c82108681bd --- /dev/null +++ b/mysql-test/include/truncate_file.inc @@ -0,0 +1,16 @@ +# truncate a giving file, all contents of the file are be cleared + +if (`SELECT 'x$file' = 'x'`) +{ + --echo Please assign a file name to $file!! + exit; +} + +let TRUNCATE_FILE= $file; + +perl; +use Env; +Env::import('TRUNCATE_FILE'); +open FILE, '>', $TRUNCATE_FILE || die "Can not open file $file"; +close FILE; +EOF diff --git a/mysql-test/include/wait_for_ndb_to_binlog.inc b/mysql-test/include/wait_for_ndb_to_binlog.inc new file mode 100644 index 00000000000..77da6d62154 --- /dev/null +++ b/mysql-test/include/wait_for_ndb_to_binlog.inc @@ -0,0 +1,41 @@ +# ==== Purpose ==== +# +# Several test primitives from mysql-test/extra/rpl_tests +# shared for test cases for MyISAM, InnoDB, NDB and other +# engines. But for NDB all events will be added by NDB +# injector and now there are no way to detect the state of +# NDB injector therefore this primitive waits 5 sec +# if engine type is NDB. +# In future that should be fixed by waiting of proper +# state of NDB injector. +# +# ==== Usage ==== +# +# let $engine_type= NDB; +# --source include/wait_for_ndb_to_binlog.inc +# +# ==== Parameters ===== +# +# $engine_type +# Type of engine. If type is NDB then it waits $wait_time sec +# +# $wait_time +# Test will wait $wait_time seconds + +let $_wait_time= 5; + +if (!$wait_time) { + let $_wait_time= $wait_time; +} + +if (`SELECT UPPER(LEFT('$engine_type',3)) = 'NDB'`) { + while (!$_wait_time) { + let $_wait_time_internal= 10; + while (!$_wait_time_internal) { + sleep 0.1; + dec $_wait_time_internal; + } + dec $_wait_time; + } +} + diff --git a/mysql-test/include/wait_show_condition.inc b/mysql-test/include/wait_show_condition.inc index 253101d1e07..f683ca7b47b 100644 --- a/mysql-test/include/wait_show_condition.inc +++ b/mysql-test/include/wait_show_condition.inc @@ -2,13 +2,16 @@ # # SUMMARY # -# Waits until the show statement ($show_statement) has at least within one of -# the rows of the result set for the field ($field) a value which fulfils +# Waits until the show statement ($show_statement) has one or all of the +# rows of the result set for the field ($field) a value which fulfils # a condition ($condition), or the operation times out. # # # USAGE # +# All rows of the result must fulfil the condition if $all_rows_fulfil is 1 +# else at least one of the result must fulfil the condition. +# let $wait_for_all= 1; # let $show_statement= SHOW PROCESSLIST; # let $field= State; # let $condition= = 'Updating'; @@ -46,27 +49,56 @@ inc $max_run_time; let $found= 0; let $max_end_time= `SELECT UNIX_TIMESTAMP() + $max_run_time`; -while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`) + +if (`SELECT '$wait_for_all' != '1'`) { - # Sleep a bit to avoid too heavy load. - real_sleep 0.2; - let $rowno= 1; - let $process_result= 1; - while (`SELECT $process_result = 1 AND $found = 0`) - { - let $field_value= query_get_value($show_statement, $field, $rowno); - if (`SELECT '$field_value' $condition`) - { - let $found= 1; - } - if (`SELECT '$field_value' = 'No such row'`) - { - # We are behind the last row of the result set. - let $process_result= 0; - } - inc $rowno; - } + while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`) + { + # Sleep a bit to avoid too heavy load. + real_sleep 0.2; + let $rowno= 1; + let $process_result= 1; + while (`SELECT $process_result = 1 AND $found = 0`) + { + let $field_value= query_get_value($show_statement, $field, $rowno); + if (`SELECT '$field_value' $condition`) + { + let $found= 1; + } + if (`SELECT '$field_value' = 'No such row'`) + { + # We are behind the last row of the result set. + let $process_result= 0; + } + inc $rowno; + } + } } + +if (`SELECT '$wait_for_all' = '1'`) +{ + while (`SELECT UNIX_TIMESTAMP() <= $max_end_time AND $found = 0`) + { + # Sleep a bit to avoid too heavy load. + real_sleep 0.2; + let $rowno= 1; + let $process_result= 1; + while (`SELECT $process_result = 1 AND $found = 0`) + { + let $field_value= query_get_value($show_statement, $field, $rowno); + if (`SELECT '$field_value' = 'No such row'`) + { + let $found= 1; + } + if (`SELECT $found = 0 AND NOT '$field_value' $condition`) + { + let process_result= 0; + } + inc $rowno; + } + } +} + if (!$found) { echo # Timeout in include/wait_show_condition.inc for $wait_condition; diff --git a/mysql-test/include/wait_until_disconnected.inc b/mysql-test/include/wait_until_disconnected.inc index a4362e52d01..8a989becc18 100644 --- a/mysql-test/include/wait_until_disconnected.inc +++ b/mysql-test/include/wait_until_disconnected.inc @@ -7,7 +7,7 @@ let $counter= 500; let $mysql_errno= 0; while (!$mysql_errno) { - --error 0,1053,2002,2006,2013 + --error 0,1040,1053,2002,2003,2006,2013 show status; dec $counter; |