diff options
Diffstat (limited to 'mysql-test/t')
377 files changed, 5228 insertions, 1083 deletions
diff --git a/mysql-test/t/alias.test b/mysql-test/t/alias.test index cfa8ec7f18a..2746409c7e5 100644 --- a/mysql-test/t/alias.test +++ b/mysql-test/t/alias.test @@ -86,3 +86,5 @@ UPDATE t1 SET t1.xstatus_vor = Greatest(t1.xstatus_vor,1) WHERE t1.aufnr = ASC LIMIT 1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/alter_table.test b/mysql-test/t/alter_table.test index c3ba2c8a7a4..5695822be6b 100644 --- a/mysql-test/t/alter_table.test +++ b/mysql-test/t/alter_table.test @@ -338,6 +338,14 @@ alter table t1 drop key a; drop table t1; # +# BUG 12207 alter table ... discard table space on MyISAM table causes ERROR 2013 (HY000) +# +CREATE TABLE T12207(a int) ENGINE=MYISAM; +--error 1031 +ALTER TABLE T12207 DISCARD TABLESPACE; +DROP TABLE T12207; + +# # Bug #6479 ALTER TABLE ... changing charset fails for TEXT columns # # The column's character set was changed but the actual data was not @@ -360,3 +368,36 @@ create table t1 ( a timestamp ); --error 1089 alter table t1 add unique ( a(1) ); drop table t1; + +# +# Bug#11493 - Alter table rename to default database does not work without +# db name qualifying +# +create database mysqltest1; +create table t1 (c1 int); +# Move table to other database. +alter table t1 rename mysqltest1.t1; +# Assure that it has moved. +--error 1051 +drop table t1; +# Move table back. +alter table mysqltest1.t1 rename t1; +# Assure that it is back. +drop table t1; +# Now test for correct message if no database is selected. +# Create t1 in 'test'. +create table t1 (c1 int); +# Change to other db. +use mysqltest1; +# Drop the current db. This de-selects any db. +drop database mysqltest1; +# Now test for correct message. +--error 1046 +alter table test.t1 rename t1; +# Check that explicit qualifying works even with no selected db. +alter table test.t1 rename test.t1; +# Go back to standard 'test' db. +use test; +drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/analyse.test b/mysql-test/t/analyse.test index f5523f83226..2003feee163 100644 --- a/mysql-test/t/analyse.test +++ b/mysql-test/t/analyse.test @@ -48,6 +48,8 @@ insert into t1 values ('abc'),('abc\'def\\hij\"klm\0opq'),('\''),('\"'),('\\'),( select * from t1 procedure analyse(); drop table t1; +# End of 4.1 tests + #decimal-related test create table t1 (df decimal(5,1)); diff --git a/mysql-test/t/analyze.test b/mysql-test/t/analyze.test index faf30279c68..3c3b3933bc3 100644 --- a/mysql-test/t/analyze.test +++ b/mysql-test/t/analyze.test @@ -1,16 +1,18 @@ # # Bug #10901 Analyze Table on new table destroys table # This is minimal test case to get error -# The problem was that analyze table wrote the shared state to the file and this -# didn't include the inserts while locked. A check was needed to ensure that -# state information was not updated when executing analyze table for a locked table. -# The analyze table had to be within locks and check table had to be after unlocking -# since then it brings the wrong state from disk rather than from the currently -# correct internal state. The insert is needed since it changes the file state, -# number of records. -# The fix is to synchronise the state of the shared state and the current state before -# calling mi_state_info_write +# The problem was that analyze table wrote the shared state to the +# file and this didn't include the inserts while locked. A check was +# needed to ensure that state information was not updated when +# executing analyze table for a locked table. The analyze table had +# to be within locks and check table had to be after unlocking since +# then it brings the wrong state from disk rather than from the +# currently correct internal state. The insert is needed since it +# changes the file state, number of records. The fix is to +# synchronise the state of the shared state and the current state +# before calling mi_state_info_write # + create table t1 (a bigint); lock tables t1 write; insert into t1 values(0); @@ -37,3 +39,4 @@ check table t1; drop table t1; +# End of 4.1 tests diff --git a/mysql-test/t/ansi.test b/mysql-test/t/ansi.test index 9d235df5b46..444bf982b8a 100644 --- a/mysql-test/t/ansi.test +++ b/mysql-test/t/ansi.test @@ -25,3 +25,5 @@ SELECT id FROM t1 GROUP BY id2; drop table t1; SET @@SQL_MODE=""; + +# End of 4.1 tests diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 51334fa62bc..4318525fe43 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1302,6 +1302,7 @@ rename table t3 to t4; select * from t4 where fld3='bonfire'; select count(*) from t4; +# End of 4.1 tests # # Test for insert after select @@ -1313,6 +1314,11 @@ INSERT INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); SELECT * FROM t2; OPTIMIZE TABLE t2; SELECT * FROM t2; +INSERT INTO t2 VALUES (2,011401,37,'breaking','dreaded','Steinberg','W'); +INSERT INTO t2 VALUES (3,011402,37,'Romans','scholastics','jarring',''); +INSERT INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); +OPTIMIZE TABLE t2 EXTENDED; +SELECT * FROM t2; REPAIR TABLE t2; SELECT * FROM t2; @@ -1321,10 +1327,25 @@ SELECT * FROM t2; INSERT INTO t2 VALUES (1,000001,00,'Omaha','teethe','neat','') , (2,011401,37,'breaking','dreaded','Steinberg','W') , (3,011402,37,'Romans','scholastics','jarring','') , (4,011403,37,'intercepted','audiology','tinily',''); SELECT * FROM t2; +# +# For bug #12836 +# Delete was allowing all rows to be removed +DELETE FROM t2; +SELECT * FROM t2; +INSERT INTO t2 VALUES (2,011401,37,'breaking','dreaded','Steinberg','W'); +INSERT INTO t2 VALUES (3,011402,37,'Romans','scholastics','jarring',''); +INSERT INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); +SELECT * FROM t2; +TRUNCATE TABLE t2; +SELECT * FROM t2; + + # Just test syntax, we will never know if the out put is right or wrong # Must be the last test INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); # # Cleanup, test is over # + + drop table t1, t2, t4; diff --git a/mysql-test/t/auto_increment.test b/mysql-test/t/auto_increment.test index afc4c722051..b20fe80303d 100644 --- a/mysql-test/t/auto_increment.test +++ b/mysql-test/t/auto_increment.test @@ -219,6 +219,8 @@ INSERT INTO t1 (b) VALUES ('bbbb'); CHECK TABLE t1; DROP TABLE IF EXISTS t1; +# End of 4.1 tests + # # Bug #11080 & #11005 Multi-row REPLACE fails on a duplicate key error # diff --git a/mysql-test/t/backup.test b/mysql-test/t/backup.test index 8b3a46724ab..3034129ad4b 100644 --- a/mysql-test/t/backup.test +++ b/mysql-test/t/backup.test @@ -52,3 +52,5 @@ unlock tables; connection con1; reap; drop table t5; + +# End of 4.1 tests diff --git a/mysql-test/t/bdb-alter-table-1.test b/mysql-test/t/bdb-alter-table-1.test index 18b6c70758f..9cb469a8df6 100644 --- a/mysql-test/t/bdb-alter-table-1.test +++ b/mysql-test/t/bdb-alter-table-1.test @@ -14,3 +14,5 @@ select * from t1; alter table t1 drop column test; # Now we do a reboot and continue with the next test + +# End of 4.1 tests diff --git a/mysql-test/t/bdb-alter-table-2.test b/mysql-test/t/bdb-alter-table-2.test index a474efe42e1..15b8938a11d 100644 --- a/mysql-test/t/bdb-alter-table-2.test +++ b/mysql-test/t/bdb-alter-table-2.test @@ -6,3 +6,5 @@ -- source include/have_bdb.inc select * from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/bdb-crash.test b/mysql-test/t/bdb-crash.test index 3cd78821000..75f4d04d5df 100644 --- a/mysql-test/t/bdb-crash.test +++ b/mysql-test/t/bdb-crash.test @@ -47,3 +47,5 @@ set autocommit=0; insert into t1 values(1); analyze table t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/bdb-deadlock.test b/mysql-test/t/bdb-deadlock.test index 5e6ca666cc2..88243cfc860 100644 --- a/mysql-test/t/bdb-deadlock.test +++ b/mysql-test/t/bdb-deadlock.test @@ -55,3 +55,5 @@ select * from t2; commit; drop table t1,t2; + +# End of 4.1 tests diff --git a/mysql-test/t/bdb-deadlock.tminus b/mysql-test/t/bdb-deadlock.tminus index d86403fcffc..3918a8ffe9d 100644 --- a/mysql-test/t/bdb-deadlock.tminus +++ b/mysql-test/t/bdb-deadlock.tminus @@ -55,3 +55,5 @@ select * from t2; commit; drop table t1,t2; + +# End of 4.1 tests diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test index f4895318818..3167682f816 100644 --- a/mysql-test/t/bdb.test +++ b/mysql-test/t/bdb.test @@ -401,6 +401,7 @@ set @a:=now(); CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=bdb; insert into t1 (a) values(1),(2),(3); select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a; +select a from t1 natural join t1 as t2 where b >= @a order by a; update t1 set a=5 where a=1; select a from t1; drop table t1; @@ -937,6 +938,8 @@ 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; +# End of 4.1 tests + # # alter temp table # diff --git a/mysql-test/t/bdb_cache.test b/mysql-test/t/bdb_cache.test index 401456711ac..85328920d71 100644 --- a/mysql-test/t/bdb_cache.test +++ b/mysql-test/t/bdb_cache.test @@ -49,3 +49,5 @@ show status like "Qcache_hits"; commit; show status like "Qcache_queries_in_cache"; drop table if exists t1, t2, t3; + +# End of 4.1 tests diff --git a/mysql-test/t/bench_count_distinct.test b/mysql-test/t/bench_count_distinct.test index 3ffb95a69c2..131208f1fa1 100644 --- a/mysql-test/t/bench_count_distinct.test +++ b/mysql-test/t/bench_count_distinct.test @@ -18,3 +18,5 @@ enable_query_log; select count(distinct n) from t1; explain extended select count(distinct n) from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/bigint.test b/mysql-test/t/bigint.test index 99c8a13d0b5..5f21d2b5813 100644 --- a/mysql-test/t/bigint.test +++ b/mysql-test/t/bigint.test @@ -14,6 +14,9 @@ select +9999999999999999999,-9999999999999999999; select cast(9223372036854775808 as unsigned)+1; select 9223372036854775808+1; select -(0-3),round(-(0-3)), round(9999999999999999999); +select 1,11,101,1001,10001,100001,1000001,10000001,100000001,1000000001,10000000001,100000000001,1000000000001,10000000000001,100000000000001,1000000000000001,10000000000000001,100000000000000001,1000000000000000001,10000000000000000001; +select -1,-11,-101,-1001,-10001,-100001,-1000001,-10000001,-100000001,-1000000001,-10000000001,-100000000001,-1000000000001,-10000000000001,-100000000000001,-1000000000000001,-10000000000000001,-100000000000000001,-1000000000000000001,-10000000000000000001; +select conv(1,10,16),conv((1<<2)-1,10,16),conv((1<<10)-2,10,16),conv((1<<16)-3,10,16),conv((1<<25)-4,10,16),conv((1<<31)-5,10,16),conv((1<<36)-6,10,16),conv((1<<47)-7,10,16),conv((1<<48)-8,10,16),conv((1<<55)-9,10,16),conv((1<<56)-10,10,16),conv((1<<63)-11,10,16); # # In 3.23 we have to disable the test of column to bigint as @@ -104,6 +107,8 @@ t2.value64=t1.value64; drop table t1, t2; +# End of 4.1 tests + # # Test of CREATE ... SELECT and unsigned integers # diff --git a/mysql-test/t/binary.test b/mysql-test/t/binary.test index 54ad8e92237..02773b32302 100644 --- a/mysql-test/t/binary.test +++ b/mysql-test/t/binary.test @@ -87,3 +87,5 @@ drop table t1; create table t1 (a binary); show create table t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/blackhole.test b/mysql-test/t/blackhole.test index d1fcfc971a9..257770d311c 100644 --- a/mysql-test/t/blackhole.test +++ b/mysql-test/t/blackhole.test @@ -125,3 +125,5 @@ let $VERSION=`select version()`; show binlog events; drop table t1,t2,t3; + +# End of 4.1 tests diff --git a/mysql-test/t/bool.test b/mysql-test/t/bool.test index 53230dd5fa3..34c51c648d3 100644 --- a/mysql-test/t/bool.test +++ b/mysql-test/t/bool.test @@ -58,3 +58,5 @@ select ifnull(A, 'N') as A, ifnull(B, 'N') as B, ifnull(not A, 'N') as nA, ifnul select ifnull(A=1, 'N') as A, ifnull(B=1, 'N') as B, ifnull(not (A=1), 'N') as nA, ifnull(not (B=1), 'N') as nB, ifnull((A=1) and (B=1), 'N') as AB, ifnull(not ((A=1) and (B=1)), 'N') as `n(AB)`, ifnull((not (A=1) or not (B=1)), 'N') as nAonB, ifnull((A=1) or (B=1), 'N') as AoB, ifnull(not((A=1) or (B=1)), 'N') as `n(AoB)`, ifnull(not (A=1) and not (B=1), 'N') as nAnB from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/bulk_replace.test b/mysql-test/t/bulk_replace.test index 755d34083f8..4e567c43104 100644 --- a/mysql-test/t/bulk_replace.test +++ b/mysql-test/t/bulk_replace.test @@ -11,3 +11,4 @@ select * from t1; check table t1; drop table t1; +# End of 4.1 tests diff --git a/mysql-test/t/case.test b/mysql-test/t/case.test index e942333d5fe..555e34d5cf2 100644 --- a/mysql-test/t/case.test +++ b/mysql-test/t/case.test @@ -122,6 +122,9 @@ SELECT 'case+union+test' UNION SELECT CASE '1' WHEN '2' THEN 'BUG' ELSE 'nobug' END; +# End of 4.1 tests + + # # Tests for bug #9939: conversion of the arguments for COALESCE and IFNULL # diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 356b69daf38..2049c17580e 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -156,6 +156,9 @@ select cast(concat('184467440','73709551615') as signed); select cast(repeat('1',20) as unsigned); select cast(repeat('1',20) as signed); +# End of 4.1 tests + + #decimal-related additions select cast('1.2' as decimal(3,2)); select 1e18 * cast('1.2' as decimal(3,2)); diff --git a/mysql-test/t/check.test b/mysql-test/t/check.test index c502655818d..8d9d70bd29a 100644 --- a/mysql-test/t/check.test +++ b/mysql-test/t/check.test @@ -22,6 +22,8 @@ connection con1; reap; drop table t1; +# End of 4.1 tests + # # Bug #9897 Views: 'Check Table' crashes MySQL, with a view and a table # in the statement diff --git a/mysql-test/t/comments.test b/mysql-test/t/comments.test index 087df60f3f5..52273ec9523 100644 --- a/mysql-test/t/comments.test +++ b/mysql-test/t/comments.test @@ -17,3 +17,5 @@ select 1 --2 select 1 # The rest of the row will be ignored ; /* line with only comment */; + +# End of 4.1 tests diff --git a/mysql-test/t/compare.test b/mysql-test/t/compare.test index bc20786227b..a42ba5ac88a 100644 --- a/mysql-test/t/compare.test +++ b/mysql-test/t/compare.test @@ -35,3 +35,5 @@ DROP TABLE t1; SELECT CHAR(31) = '', '' = CHAR(31); # Extra test SELECT CHAR(30) = '', '' = CHAR(30); + +# End of 4.1 tests diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test index 5d2d53a2a90..64b170970ca 100644 --- a/mysql-test/t/connect.test +++ b/mysql-test/t/connect.test @@ -76,3 +76,5 @@ show tables; delete from mysql.user where user=_binary"test"; flush privileges; + +# End of 4.1 tests diff --git a/mysql-test/t/consistent_snapshot.test b/mysql-test/t/consistent_snapshot.test index 7afdae36325..8da8e9ce660 100644 --- a/mysql-test/t/consistent_snapshot.test +++ b/mysql-test/t/consistent_snapshot.test @@ -39,3 +39,5 @@ select * from t1; # if consistent snapshot was not set, as expected, we commit; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/constraints.test b/mysql-test/t/constraints.test index dbc34a0dff1..ed268ab5846 100644 --- a/mysql-test/t/constraints.test +++ b/mysql-test/t/constraints.test @@ -27,3 +27,5 @@ alter table t1 add constraint unique key_1(a); alter table t1 add constraint constraint_2 unique key_2(a); show create table t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/count_distinct.test b/mysql-test/t/count_distinct.test index be67026e268..e63bdabdb95 100644 --- a/mysql-test/t/count_distinct.test +++ b/mysql-test/t/count_distinct.test @@ -55,6 +55,8 @@ create table t1 (f int); select count(distinct f) from t1; drop table t1; +# End of 4.1 tests + # # Bug #6515 # diff --git a/mysql-test/t/count_distinct2.test b/mysql-test/t/count_distinct2.test index 2b982e3e620..8dcb2a70065 100644 --- a/mysql-test/t/count_distinct2.test +++ b/mysql-test/t/count_distinct2.test @@ -79,3 +79,4 @@ select count(distinct s) from t1; show status like 'Created_tmp_disk_tables'; drop table t1; +# End of 4.1 tests diff --git a/mysql-test/t/count_distinct3.test b/mysql-test/t/count_distinct3.test index 9d2bb0d139a..52a4f271dac 100644 --- a/mysql-test/t/count_distinct3.test +++ b/mysql-test/t/count_distinct3.test @@ -56,3 +56,5 @@ SELECT COUNT(DISTINCT id) FROM t1 GROUP BY grp; DROP TABLE t1; set @@read_buffer_size=default; + +# End of 4.1 tests diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 8ffb2aa2ae7..450bcd0344a 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -39,7 +39,7 @@ drop table if exists t1; --error 1075 create table t1 (ordid int(8) not null auto_increment, ord varchar(50) not null, primary key (ord,ordid)) engine=heap; --- error 1044,1 +-- error 1049 create table not_existing_database.test (a int); --error 1103 create table `a/a` (a int); @@ -305,7 +305,7 @@ select * from t2; create table t3 like t1; --error 1050 create table t3 like mysqltest.t3; ---error ER_DBACCESS_DENIED_ERROR,1 +--error 1049 create table non_existing_database.t1 like t1; --error 1051 create table t3 like non_existing_table; @@ -504,6 +504,14 @@ create table t2(test.t2.name int); drop table t1,t2; # +# Bug #12537: UNION produces longtext instead of varchar +# +CREATE TABLE t1 (f1 VARCHAR(255) CHARACTER SET utf8); +CREATE TABLE t2 AS SELECT LEFT(f1,171) AS f2 FROM t1 UNION SELECT LEFT(f1,171) AS f2 FROM t1; +DESC t2; +DROP TABLE t1,t2; + +# # Bug#11028: Crash on create table like # create database mysqltest; @@ -514,3 +522,15 @@ create table test.t1 like x; --disable_warnings drop table if exists test.t1; --enable_warnings + +# +# Bug #6859: Bogus error message on attempt to CREATE TABLE t LIKE view +# +create database mysqltest; +use mysqltest; +create view v1 as select 'foo' from dual; +--error 1347 +create table t1 like v1; +drop view v1; +drop database mysqltest; +# End of 4.1 tests diff --git a/mysql-test/t/create_select_tmp.test b/mysql-test/t/create_select_tmp.test index 3416bd2d383..1661a115f72 100644 --- a/mysql-test/t/create_select_tmp.test +++ b/mysql-test/t/create_select_tmp.test @@ -27,3 +27,5 @@ select * from t2; CREATE TEMPORARY TABLE t2 ( PRIMARY KEY (a) ) ENGINE=MYISAM SELECT a FROM t1; --error 1146 select * from t2; + +# End of 4.1 tests diff --git a/mysql-test/t/csv.test b/mysql-test/t/csv.test index 591fab3961a..2ac46d75f9a 100644 --- a/mysql-test/t/csv.test +++ b/mysql-test/t/csv.test @@ -1313,3 +1313,5 @@ INSERT INTO t1 VALUES (9410,9412); select period from t1; drop table if exists t1,t2,t3,t4; + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_big5.test b/mysql-test/t/ctype_big5.test index b5cf610d941..73d9f06042c 100644 --- a/mysql-test/t/ctype_big5.test +++ b/mysql-test/t/ctype_big5.test @@ -14,8 +14,10 @@ SET @test_collation= 'big5_chinese_ci'; SET NAMES big5; SET collation_connection='big5_chinese_ci'; -- source include/ctype_filesort.inc +-- source include/ctype_innodb_like.inc SET collation_connection='big5_bin'; -- source include/ctype_filesort.inc +-- source include/ctype_innodb_like.inc # # Bugs#9357: TEXT columns break string with special word in BIG5 charset. @@ -25,3 +27,13 @@ CREATE TABLE t1 (a text) character set big5; INSERT INTO t1 VALUES ('ùØ'); SELECT * FROM t1; DROP TABLE t1; + +# +# BUG#12075 - FULLTEXT non-functional for big5 strings +# +CREATE TABLE t1 (a CHAR(50) CHARACTER SET big5 NOT NULL, FULLTEXT(a)); +INSERT INTO t1 VALUES(0xA741ADCCA66EB6DC20A7DAADCCABDCA66E); +SELECT HEX(a) FROM t1 WHERE MATCH(a) AGAINST (0xA741ADCCA66EB6DC IN BOOLEAN MODE); +DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_collate.test b/mysql-test/t/ctype_collate.test index b65067a36cf..e59693680bf 100644 --- a/mysql-test/t/ctype_collate.test +++ b/mysql-test/t/ctype_collate.test @@ -206,3 +206,5 @@ EXPLAIN SELECT * FROM t1 WHERE s1 LIKE 'a' COLLATE latin1_german1_ci; EXPLAIN SELECT * FROM t1 WHERE s2 LIKE 'a' COLLATE latin1_german1_ci; DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_cp1250_ch.test b/mysql-test/t/ctype_cp1250_ch.test index 814da628fb7..ea4b35a44a3 100644 --- a/mysql-test/t/ctype_cp1250_ch.test +++ b/mysql-test/t/ctype_cp1250_ch.test @@ -22,3 +22,5 @@ INSERT INTO t1 VALUES ('2005-01-1'); SELECT * FROM t1 WHERE popisek = '2005-01-1'; SELECT * FROM t1 WHERE popisek LIKE '2005-01-1'; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_cp1251.test b/mysql-test/t/ctype_cp1251.test index 76873e6fa0e..1aafe7b7266 100644 --- a/mysql-test/t/ctype_cp1251.test +++ b/mysql-test/t/ctype_cp1251.test @@ -46,3 +46,5 @@ insert into t1 (a) values ('air'), select * from t1 where a like 'we_%'; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_cp932.test b/mysql-test/t/ctype_cp932.test index fed87af3adc..3d630311b3a 100644 --- a/mysql-test/t/ctype_cp932.test +++ b/mysql-test/t/ctype_cp932.test @@ -398,6 +398,27 @@ DROP TABLE t2; DROP TABLE t3; DROP TABLE t4; +# Test prepared statement with 0x8300 sequence in parameter while +# running with cp932 client character set. +RESET MASTER; +CREATE TABLE t1(f1 blob); +PREPARE stmt1 FROM 'INSERT INTO t1 VALUES(?)'; +SET @var1= x'8300'; +# TODO: Note that this doesn't actually test the code which was added for +# bug#11338 because this syntax for prepared statements causes the PS to +# be replicated differently than if we executed the PS from C or Java. +# Using this syntax, variable names are inserted into the binlog instead +# of values. The real goal of this test is to check the code that was +# added to Item_param::query_val_str() in order to do hex encoding of +# PS parameters when the client character set is cp932; +# Bug#11338 has an example java program which can be used to verify this +# code (and I have used it to test the fix) until there is some way to +# exercise this code from mysql-test-run. +EXECUTE stmt1 USING @var1; +SHOW BINLOG EVENTS FROM 98; +SELECT HEX(f1) FROM t1; +DROP table t1; +# end test for bug#11338 SET collation_connection='cp932_japanese_ci'; -- source include/ctype_filesort.inc diff --git a/mysql-test/t/ctype_create.test b/mysql-test/t/ctype_create.test index e97017ab416..e88004bbb8c 100644 --- a/mysql-test/t/ctype_create.test +++ b/mysql-test/t/ctype_create.test @@ -98,3 +98,5 @@ show create database mysqltest2; drop database mysqltest2; --error 1046 ALTER DATABASE DEFAULT CHARACTER SET latin2; + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_eucjpms.test b/mysql-test/t/ctype_eucjpms.test index cec1e2a9861..3609407fe96 100644 --- a/mysql-test/t/ctype_eucjpms.test +++ b/mysql-test/t/ctype_eucjpms.test @@ -346,6 +346,18 @@ DROP TABLE t2; DROP TABLE t3; DROP TABLE t4; +#Test bug#11717 +CREATE TABLE t1(c1 varchar(10)) default character set = eucjpms; + +insert into t1 values(_ucs2 0x00F7); +insert into t1 values(_eucjpms 0xA1E0); +insert into t1 values(_ujis 0xA1E0); +insert into t1 values(_sjis 0x8180); +insert into t1 values(_cp932 0x8180); + +SELECT HEX(c1) FROM t1; + +DROP TABLE t1; SET collation_connection='eucjpms_japanese_ci'; -- source include/ctype_filesort.inc diff --git a/mysql-test/t/ctype_gbk.test b/mysql-test/t/ctype_gbk.test new file mode 100644 index 00000000000..2210891454e --- /dev/null +++ b/mysql-test/t/ctype_gbk.test @@ -0,0 +1,32 @@ +-- source include/have_gbk.inc + +# +# Tests with the gbk character set +# +--disable_warnings +drop table if exists t1; +--enable_warnings + +SET @test_character_set= 'gbk'; +SET @test_collation= 'gbk_chinese_ci'; +-- source include/ctype_common.inc + +SET NAMES gbk; +SET collation_connection='gbk_chinese_ci'; +-- source include/ctype_filesort.inc +-- source include/ctype_innodb_like.inc +SET collation_connection='gbk_bin'; +-- source include/ctype_filesort.inc +-- source include/ctype_innodb_like.inc + +# +# Bug#11987 mysql will truncate the text when +# the text contain GBK char:"0xA3A0" and "0xA1" +# +SET NAMES gbk; +CREATE TABLE t1 (a text) character set gbk; +INSERT INTO t1 VALUES (0xA3A0),(0xA1A1); +SELECT hex(a) FROM t1 ORDER BY a; +DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_latin1.test b/mysql-test/t/ctype_latin1.test index 6006ee4c527..1b83373da29 100644 --- a/mysql-test/t/ctype_latin1.test +++ b/mysql-test/t/ctype_latin1.test @@ -75,3 +75,5 @@ SET collation_connection='latin1_bin'; --error 1064 CREATE TABLE „a (a int); SELECT '„a' as str; + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_latin1_de.test b/mysql-test/t/ctype_latin1_de.test index 88eb840a787..d6a11a22857 100644 --- a/mysql-test/t/ctype_latin1_de.test +++ b/mysql-test/t/ctype_latin1_de.test @@ -133,6 +133,8 @@ ALTER TABLE t1 ADD KEY ifword(col1); SELECT * FROM t1 WHERE col1='ß' ORDER BY col1, BINARY col1; DROP TABLE t1; +# End of 4.1 tests + # # Bug#9509 # diff --git a/mysql-test/t/ctype_latin2.test b/mysql-test/t/ctype_latin2.test index cc232adeaec..676b472e7b8 100644 --- a/mysql-test/t/ctype_latin2.test +++ b/mysql-test/t/ctype_latin2.test @@ -48,3 +48,5 @@ a, lower(a) l, upper(a) u from t1 order by ha; # SELECT group_concat(a collate latin2_croatian_ci order by binary a) from t1 group by a collate latin2_croatian_ci; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_many.test b/mysql-test/t/ctype_many.test index 454e2c63cbb..22e844c6868 100644 --- a/mysql-test/t/ctype_many.test +++ b/mysql-test/t/ctype_many.test @@ -209,3 +209,5 @@ SET CHARACTER SET 'binary'; SELECT * FROM t1; SELECT min(comment),count(*) FROM t1 GROUP BY ucs2_f; DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_mb.test b/mysql-test/t/ctype_mb.test index b0ccab8e345..6e369e3fa0b 100644 --- a/mysql-test/t/ctype_mb.test +++ b/mysql-test/t/ctype_mb.test @@ -24,3 +24,5 @@ ALTER TABLE t1 CHANGE a a CHAR(4) CHARACTER SET utf8; SHOW CREATE TABLE t1; SHOW KEYS FROM t1; DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_recoding.test b/mysql-test/t/ctype_recoding.test index 0e5e954c720..9949ef88da4 100644 --- a/mysql-test/t/ctype_recoding.test +++ b/mysql-test/t/ctype_recoding.test @@ -179,3 +179,5 @@ select rpad(c1,3,'ö'), rpad('ö',3,c1) from t1; # TODO #select case c1 when 'ß' then 'ß' when 'ö' then 'ö' else 'c' end from t1; #select export_set(5,c1,'ö'), export_set(5,'ö',c1) from t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_sjis.test b/mysql-test/t/ctype_sjis.test index 50d286f28b9..252f0a0b6c8 100644 --- a/mysql-test/t/ctype_sjis.test +++ b/mysql-test/t/ctype_sjis.test @@ -66,8 +66,10 @@ drop table t1; SET collation_connection='sjis_japanese_ci'; -- source include/ctype_filesort.inc +-- source include/ctype_innodb_like.inc SET collation_connection='sjis_bin'; -- source include/ctype_filesort.inc +-- source include/ctype_innodb_like.inc # Check parsing of string literals in SJIS with multibyte characters that # have an embedded \ in them. (Bug #8303) @@ -75,3 +77,5 @@ SET collation_connection='sjis_bin'; --character_set sjis SET NAMES sjis; SELECT HEX('²“‘@\Œ\') FROM DUAL; + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_tis620.test b/mysql-test/t/ctype_tis620.test index 87047db9b54..d649828eda3 100644 --- a/mysql-test/t/ctype_tis620.test +++ b/mysql-test/t/ctype_tis620.test @@ -157,3 +157,5 @@ SET collation_connection='tis620_thai_ci'; -- source include/ctype_filesort.inc SET collation_connection='tis620_bin'; -- source include/ctype_filesort.inc + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_uca.test b/mysql-test/t/ctype_uca.test index e5c2acc8b4e..098ea33c6b2 100644 --- a/mysql-test/t/ctype_uca.test +++ b/mysql-test/t/ctype_uca.test @@ -456,6 +456,8 @@ drop table t1; SET collation_connection='utf8_unicode_ci'; -- source include/ctype_filesort.inc +# End of 4.1 tests + # # Check UPPER/LOWER changeing length # diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index f4327536795..668edb3fafe 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -419,6 +419,8 @@ insert into t1 values (0x005b); select hex(a) from t1; drop table t1; +# End of 4.1 tests + # # Conversion from an UCS2 string to a decimal column # @@ -427,3 +429,17 @@ INSERT INTO t1 VALUES ("1.1", 0), ("2.1", 0); update t1 set b=a; SELECT * FROM t1; DROP TABLE t1; + +# +# Bug#9442 Set parameter make query fail if column character set is UCS2 +# +create table t1 (utext varchar(20) character set ucs2); +insert into t1 values ("lily"); +insert into t1 values ("river"); +prepare stmt from 'select utext from t1 where utext like ?'; +set @param1='%%'; +execute stmt using @param1; +execute stmt using @param1; +select utext from t1 where utext like '%%'; +drop table t1; +deallocate prepare stmt; diff --git a/mysql-test/t/ctype_ucs_binlog.test b/mysql-test/t/ctype_ucs_binlog.test index 226f128c1c2..1ce55edd469 100644 --- a/mysql-test/t/ctype_ucs_binlog.test +++ b/mysql-test/t/ctype_ucs_binlog.test @@ -17,4 +17,4 @@ show binlog events from 98; --exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 drop table t2; - +# End of 4.1 tests diff --git a/mysql-test/t/ctype_ujis.test b/mysql-test/t/ctype_ujis.test index 407287be30a..88386500c9f 100644 --- a/mysql-test/t/ctype_ujis.test +++ b/mysql-test/t/ctype_ujis.test @@ -1145,5 +1145,9 @@ DROP TABLE t1; SET collation_connection='ujis_japanese_ci'; -- source include/ctype_filesort.inc +-- source include/ctype_innodb_like.inc SET collation_connection='ujis_bin'; -- source include/ctype_filesort.inc +-- source include/ctype_innodb_like.inc + +# End of 4.1 tests diff --git a/mysql-test/t/ctype_utf8.test b/mysql-test/t/ctype_utf8.test index 86de7d5d761..ce259f465d9 100644 --- a/mysql-test/t/ctype_utf8.test +++ b/mysql-test/t/ctype_utf8.test @@ -748,6 +748,15 @@ select * from t1 where city = 'Durban '; drop table t1; # +# Bug #11819 CREATE TABLE with a SET DEFAULT 0 and UTF8 crashes server. +# +--error 1067 +create table t1 (x set('A', 'B') default 0) character set utf8; +--error 1067 +create table t1 (x enum('A', 'B') default 0) character set utf8; + + +# # Test for bug #11167: join for utf8 varchar value longer than 255 bytes # @@ -776,12 +785,14 @@ 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 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=InnoDB DEFAULT CHARSET=utf8; +--enable_warnings INSERT INTO t2 VALUES ('1234567890',2,'2005-05-24 13:53:25'); @@ -790,6 +801,37 @@ SELECT content, t2.msisdn FROM t1, t2 WHERE t1.msisdn = '1234567890'; DROP TABLE t1,t2; # +# Bug#11591: CHAR column with utf8 does not work properly +# (more chars than expected) +# +create table t1 (a char(20) character set utf8); +insert into t1 values ('123456'),('андрей'); +alter table t1 modify a char(2) character set utf8; +select char_length(a), length(a), a from t1 order by a; +drop table t1; + + +# +# Bugs#11754: SET NAMES utf8 followed by SELECT "A\\" LIKE "A\\" returns 0 +# +set names utf8; +select 'a\\' like 'a\\'; +select 'aa\\' like 'a%\\'; + +create table t1 (a char(10), key(a)) character set utf8; +insert into t1 values ("a"),("abc"),("abcd"),("hello"),("test"); +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#9557 MyISAM utf8 table crash # CREATE TABLE t1 ( @@ -801,6 +843,8 @@ insert into t1 values (_utf8 0x5b); select hex(a) from t1; drop table t1; +# End of 4.1 tests + # # Test for bug #11484: wrong results for a DISTINCT varchar column in uft8. # diff --git a/mysql-test/t/date_formats.test b/mysql-test/t/date_formats.test index e8bd8965b96..f76f51fd12d 100644 --- a/mysql-test/t/date_formats.test +++ b/mysql-test/t/date_formats.test @@ -260,3 +260,5 @@ select str_to_date("2003-01-02 10:11:12.0012ABCD", "%Y-%m-%d %H:%i:%S.%f") as f1 select str_to_date("2003-04-05 g", "%Y-%m-%d") as f1, str_to_date("2003-04-05 10:11:12.101010234567", "%Y-%m-%d %H:%i:%S.%f") as f2; --enable_ps_protocol + +# End of 4.1 tests diff --git a/mysql-test/t/delayed.test b/mysql-test/t/delayed.test index 513de990165..ca34cc020f3 100644 --- a/mysql-test/t/delayed.test +++ b/mysql-test/t/delayed.test @@ -36,3 +36,14 @@ insert delayed into t1 values (3,"this will give an","error"); show status like 'not_flushed_delayed_rows'; select * from t1; drop table t1; + +# End of 4.1 tests + +# +# Bug #12226: Crash when a delayed insert fails due to a duplicate key +# +create table t1 (a int not null primary key); +insert into t1 values (1); +insert delayed into t1 values (1); +select * from t1; +drop table t1; diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index 265089adfa2..4284bd2a06d 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -153,6 +153,8 @@ DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1; SELECT * FROM t1; DROP TABLE t1; +# End of 4.1 tests + # # Test of multi-delete where we are not scanning the first table # diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 1e3ffd5160b..f52e12849e4 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -42,7 +42,7 @@ CREATE TABLE t2 (a int not null); insert into t2 values(1); select * from (select * from t1 where t1.a=(select a from t2 where t2.a=t1.a)) a; select * from (select * from t1 where t1.a=(select t2.a from t2 where t2.a=t1.a) union select t1.a, t1.b from t1) a; -explain select * from (select * from t1,t2 where t1.a=t2.a) t1; +explain select * from (select t1.*, t2.a as t2a from t1,t2 where t1.a=t2.a) t1; drop table t1, t2; create table t1(a int not null, t char(8), index(a)); disable_query_log; @@ -248,3 +248,14 @@ insert into t3 values(3),(3); select * from t1 union distinct select * from t2 union all select * from t3; select * from (select * from t1 union distinct select * from t2 union all select * from t3) X; drop table t1, t2, t3; + +# +# Bug #11864 non unique names are allowed in subquery +# +create table t1 (a int); +create table t2 (a int); +--error 1060 +select * from (select * from t1,t2) foo; +drop table t1,t2; + +# End of 4.1 tests diff --git a/mysql-test/t/dirty_close.test b/mysql-test/t/dirty_close.test index f965df8cfea..f1c2c88ae83 100644 --- a/mysql-test/t/dirty_close.test +++ b/mysql-test/t/dirty_close.test @@ -12,3 +12,5 @@ create table t1 (n int); insert into t1 values (1),(2),(3); select * from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index c5f96ec4201..fe95a543fb5 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -10,4 +10,8 @@ # ############################################################################## -sp-goto:GOTO is currently is disabled - will be fixed in the future +sp-goto : GOTO is currently is disabled - will be fixed in the future +rpl_relayrotate : Unstable test case, bug#12429 +rpl_until : Unstable test case, bug#12429 +rpl_deadlock : Unstable test case, bug#12429 +kill : Unstable test case, bug#9712 diff --git a/mysql-test/t/distinct.test b/mysql-test/t/distinct.test index 057c9bd9239..e69de29bb2d 100644 --- a/mysql-test/t/distinct.test +++ b/mysql-test/t/distinct.test @@ -1,342 +0,0 @@ -# -# Bug with distinct and INSERT INTO -# Bug with group by and not used fields -# - ---disable_warnings -drop table if exists t1,t2,t3; ---enable_warnings - -CREATE TABLE t1 (id int,facility char(20)); -CREATE TABLE t2 (facility char(20)); -INSERT INTO t1 VALUES (NULL,NULL); -INSERT INTO t1 VALUES (-1,''); -INSERT INTO t1 VALUES (0,''); -INSERT INTO t1 VALUES (1,'/L'); -INSERT INTO t1 VALUES (2,'A01'); -INSERT INTO t1 VALUES (3,'ANC'); -INSERT INTO t1 VALUES (4,'F01'); -INSERT INTO t1 VALUES (5,'FBX'); -INSERT INTO t1 VALUES (6,'MT'); -INSERT INTO t1 VALUES (7,'P'); -INSERT INTO t1 VALUES (8,'RV'); -INSERT INTO t1 VALUES (9,'SRV'); -INSERT INTO t1 VALUES (10,'VMT'); -INSERT INTO t2 SELECT DISTINCT FACILITY FROM t1; - -select id from t1 group by id; -select * from t1 order by id; -select id-5,facility from t1 order by "id-5"; -select id,concat(facility) from t1 group by id ; -select id+0 as a,max(id),concat(facility) as b from t1 group by a order by b desc,a; -select id >= 0 and id <= 5 as grp,count(*) from t1 group by grp; - -SELECT DISTINCT FACILITY FROM t1; -SELECT FACILITY FROM t2; -SELECT count(*) from t1,t2 where t1.facility=t2.facility; -select count(facility) from t1; -select count(*) from t1; -select count(*) from t1 where facility IS NULL; -select count(*) from t1 where facility = NULL; -select count(*) from t1 where facility IS NOT NULL; -select count(*) from t1 where id IS NULL; -select count(*) from t1 where id IS NOT NULL; - -drop table t1,t2; - -# -# Problem with distinct without results -# -CREATE TABLE t1 (UserId int(11) DEFAULT '0' NOT NULL); -INSERT INTO t1 VALUES (20); -INSERT INTO t1 VALUES (27); - -SELECT UserId FROM t1 WHERE Userid=22; -SELECT UserId FROM t1 WHERE UserId=22 group by Userid; -SELECT DISTINCT UserId FROM t1 WHERE UserId=22 group by Userid; -SELECT DISTINCT UserId FROM t1 WHERE UserId=22; -drop table t1; - -# -# Test of distinct -# - -CREATE TABLE t1 (a int(10) unsigned not null primary key,b int(10) unsigned); -INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1); -CREATE TABLE t2 (a int(10) unsigned not null, key (A)); -INSERT INTO t2 VALUES (1),(2); -CREATE TABLE t3 (a int(10) unsigned, key(A), b text); -INSERT INTO t3 VALUES (1,'1'),(2,'2'); -SELECT DISTINCT t3.b FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; -INSERT INTO t2 values (1),(2),(3); -INSERT INTO t3 VALUES (1,'1'),(2,'2'),(1,'1'),(2,'2'); -explain SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; -SELECT distinct t3.a FROM t3,t2,t1 WHERE t3.a=t1.b AND t1.a=t2.a; - -# Create a lot of data into t3; -create temporary table t4 select * from t3; -insert into t3 select * from t4; -insert into t4 select * from t3; -insert into t3 select * from t4; -insert into t4 select * from t3; -insert into t3 select * from t4; -insert into t4 select * from t3; -insert into t3 select * from t4; - -explain select distinct t1.a from t1,t3 where t1.a=t3.a; -#flush status; -select distinct t1.a from t1,t3 where t1.a=t3.a; -#show status like 'Handler%'; -#flush status; -select distinct 1 from t1,t3 where t1.a=t3.a; -#show status like 'Handler%'; - -explain SELECT distinct t1.a from t1; -explain SELECT distinct t1.a from t1 order by a desc; -explain SELECT t1.a from t1 group by a order by a desc; -explain SELECT distinct t1.a from t1 order by a desc limit 1; -explain SELECT distinct a from t3 order by a desc limit 2; -explain SELECT distinct a,b from t3 order by a+1; -explain SELECT distinct a,b from t3 order by a limit 10; -explain SELECT a,b from t3 group by a,b order by a+1; - -drop table t1,t2,t3,t4; - -CREATE TABLE t1 (name varchar(255)); -INSERT INTO t1 VALUES ('aa'),('ab'),('ac'),('ad'),('ae'); -SELECT DISTINCT * FROM t1 LIMIT 2; -SELECT DISTINCT name FROM t1 LIMIT 2; -SELECT DISTINCT 1 FROM t1 LIMIT 2; -drop table t1; - -CREATE TABLE t1 ( - ID int(11) NOT NULL auto_increment, - NAME varchar(75) DEFAULT '' NOT NULL, - LINK_ID int(11) DEFAULT '0' NOT NULL, - PRIMARY KEY (ID), - KEY NAME (NAME), - KEY LINK_ID (LINK_ID) -); - -INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0),(2,'Jack',0),(3,'Bill',0); - -CREATE TABLE t2 ( - ID int(11) NOT NULL auto_increment, - NAME varchar(150) DEFAULT '' NOT NULL, - PRIMARY KEY (ID), - KEY NAME (NAME) -); - -SELECT DISTINCT - t2.id AS key_link_id, - t2.name AS link -FROM t1 -LEFT JOIN t2 ON t1.link_id=t2.id -GROUP BY t1.id -ORDER BY link; -drop table t1,t2; - -# -# Problem with table dependencies -# - -create table t1 ( - id int not null, - name tinytext not null, - unique (id) -); -create table t2 ( - id int not null, - idx int not null, - unique (id, idx) -); -create table t3 ( - id int not null, - idx int not null, - unique (id, idx) -); -insert into t1 values (1,'yes'), (2,'no'); -insert into t2 values (1,1); -insert into t3 values (1,1); -EXPLAIN -SELECT DISTINCT - t1.id -from - t1 - straight_join - t2 - straight_join - t3 - straight_join - t1 as j_lj_t2 left join t2 as t2_lj - on j_lj_t2.id=t2_lj.id - straight_join - t1 as j_lj_t3 left join t3 as t3_lj - on j_lj_t3.id=t3_lj.id -WHERE - ((t1.id=j_lj_t2.id AND t2_lj.id IS NULL) OR (t1.id=t2.id AND t2.idx=2)) - AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2)); -SELECT DISTINCT - t1.id -from - t1 - straight_join - t2 - straight_join - t3 - straight_join - t1 as j_lj_t2 left join t2 as t2_lj - on j_lj_t2.id=t2_lj.id - straight_join - t1 as j_lj_t3 left join t3 as t3_lj - on j_lj_t3.id=t3_lj.id -WHERE - ((t1.id=j_lj_t2.id AND t2_lj.id IS NULL) OR (t1.id=t2.id AND t2.idx=2)) - AND ((t1.id=j_lj_t3.id AND t3_lj.id IS NULL) OR (t1.id=t3.id AND t3.idx=2)); -drop table t1,t2,t3; - -# -# Test using DISTINCT on a function that contains a group function -# This also test the case when one doesn't use all fields in GROUP BY. -# - -create table t1 (a int not null, b int not null, t time); -insert into t1 values (1,1,"00:06:15"),(1,2,"00:06:15"),(1,2,"00:30:15"),(1,3,"00:06:15"),(1,3,"00:30:15"); -select a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b; -select distinct a,sec_to_time(sum(time_to_sec(t))) from t1 group by a,b; -create table t2 (a int not null primary key, b int); -insert into t2 values (1,1),(2,2),(3,3); -select t1.a,sec_to_time(sum(time_to_sec(t))) from t1 left join t2 on (t1.b=t2.a) group by t1.a,t2.b; -select distinct t1.a,sec_to_time(sum(time_to_sec(t))) from t1 left join t2 on (t1.b=t2.a) group by t1.a,t2.b; -drop table t1,t2; - -# -# Test problem with DISTINCT and HAVING -# -create table t1 (a int not null,b char(5), c text); -insert into t1 (a) values (1),(2),(3),(4),(1),(2),(3),(4); -select distinct a from t1 group by b,a having a > 2 order by a desc; -select distinct a,c from t1 group by b,c,a having a > 2 order by a desc; -drop table t1; - -# -# Test problem with DISTINCT and ORDER BY DESC -# - -create table t1 (a char(1), key(a)) engine=myisam; -insert into t1 values('1'),('1'); -select * from t1 where a >= '1'; -select distinct a from t1 order by a desc; -select distinct a from t1 where a >= '1' order by a desc; -drop table t1; - -# -# Test when using a not previously used column in ORDER BY -# - -CREATE TABLE t1 (email varchar(50), infoID BIGINT, dateentered DATETIME); -CREATE TABLE t2 (infoID BIGINT, shipcode varchar(10)); - -INSERT INTO t1 (email, infoID, dateentered) VALUES - ('test1@testdomain.com', 1, '2002-07-30 22:56:38'), - ('test1@testdomain.com', 1, '2002-07-27 22:58:16'), - ('test2@testdomain.com', 1, '2002-06-19 15:22:19'), - ('test2@testdomain.com', 2, '2002-06-18 14:23:47'), - ('test3@testdomain.com', 1, '2002-05-19 22:17:32'); - -INSERT INTO t2(infoID, shipcode) VALUES - (1, 'Z001'), - (2, 'R002'); - -SELECT DISTINCTROW email, shipcode FROM t1, t2 WHERE t1.infoID=t2.infoID; -SELECT DISTINCTROW email FROM t1 ORDER BY dateentered DESC; -SELECT DISTINCTROW email, shipcode FROM t1, t2 WHERE t1.infoID=t2.infoID ORDER BY dateentered DESC; -drop table t1,t2; - -# -# test with table.* in DISTINCT -# - -CREATE TABLE t1 (privatemessageid int(10) unsigned NOT NULL auto_increment, folderid smallint(6) NOT NULL default '0', userid int(10) unsigned NOT NULL default '0', touserid int(10) unsigned NOT NULL default '0', fromuserid int(10) unsigned NOT NULL default '0', title varchar(250) NOT NULL default '', message mediumtext NOT NULL, dateline int(10) unsigned NOT NULL default '0', showsignature smallint(6) NOT NULL default '0', iconid smallint(5) unsigned NOT NULL default '0', messageread smallint(6) NOT NULL default '0', readtime int(10) unsigned NOT NULL default '0', receipt smallint(6) unsigned NOT NULL default '0', deleteprompt smallint(6) unsigned NOT NULL default '0', multiplerecipients smallint(6) unsigned NOT NULL default '0', PRIMARY KEY (privatemessageid), KEY userid (userid)) ENGINE=MyISAM; -INSERT INTO t1 VALUES (128,0,33,33,8,':D','',996121863,1,0,2,996122850,2,0,0); -CREATE TABLE t2 (userid int(10) unsigned NOT NULL auto_increment, usergroupid smallint(5) unsigned NOT NULL default '0', username varchar(50) NOT NULL default '', password varchar(50) NOT NULL default '', email varchar(50) NOT NULL default '', styleid smallint(5) unsigned NOT NULL default '0', parentemail varchar(50) NOT NULL default '', coppauser smallint(6) NOT NULL default '0', homepage varchar(100) NOT NULL default '', icq varchar(20) NOT NULL default '', aim varchar(20) NOT NULL default '', yahoo varchar(20) NOT NULL default '', signature mediumtext NOT NULL, adminemail smallint(6) NOT NULL default '0', showemail smallint(6) NOT NULL default '0', invisible smallint(6) NOT NULL default '0', usertitle varchar(250) NOT NULL default '', customtitle smallint(6) NOT NULL default '0', joindate int(10) unsigned NOT NULL default '0', cookieuser smallint(6) NOT NULL default '0', daysprune smallint(6) NOT NULL default '0', lastvisit int(10) unsigned NOT NULL default '0', lastactivity int(10) unsigned NOT NULL default '0', lastpost int(10) unsigned NOT NULL default '0', posts smallint(5) unsigned NOT NULL default '0', timezoneoffset varchar(4) NOT NULL default '', emailnotification smallint(6) NOT NULL default '0', buddylist mediumtext NOT NULL, ignorelist mediumtext NOT NULL, pmfolders mediumtext NOT NULL, receivepm smallint(6) NOT NULL default '0', emailonpm smallint(6) NOT NULL default '0', pmpopup smallint(6) NOT NULL default '0', avatarid smallint(6) NOT NULL default '0', avatarrevision int(6) unsigned NOT NULL default '0', options smallint(6) NOT NULL default '15', birthday date NOT NULL default '0000-00-00', maxposts smallint(6) NOT NULL default '-1', startofweek smallint(6) NOT NULL default '1', ipaddress varchar(20) NOT NULL default '', referrerid int(10) unsigned NOT NULL default '0', nosessionhash smallint(6) NOT NULL default '0', autorefresh smallint(6) NOT NULL default '-1', messagepopup tinyint(2) NOT NULL default '0', inforum smallint(5) unsigned NOT NULL default '0', ratenum smallint(5) unsigned NOT NULL default '0', ratetotal smallint(5) unsigned NOT NULL default '0', allowrate smallint(5) unsigned NOT NULL default '1', PRIMARY KEY (userid), KEY usergroupid (usergroupid), KEY username (username), KEY inforum (inforum)) ENGINE=MyISAM; -INSERT INTO t2 VALUES (33,6,'Kevin','0','kevin@stileproject.com',1,'',0,'http://www.stileproject.com','','','','',1,1,0,'Administrator',0,996120694,1,-1,1030996168,1031027028,1030599436,36,'-6',0,'','','',1,0,1,0,0,15,'0000-00-00',-1,1,'64.0.0.0',0,1,-1,0,0,4,19,1); -SELECT DISTINCT t1.*, t2.* FROM t1 LEFT JOIN t2 ON (t2.userid = t1.touserid); -DROP TABLE t1,t2; - -# -# test with const_item in ORDER BY -# - -CREATE TABLE t1 (a int primary key, b int, c int); -INSERT t1 VALUES (1,2,3); -CREATE TABLE t2 (a int primary key, b int, c int); -INSERT t2 VALUES (3,4,5); -SELECT DISTINCT t1.a, t2.b FROM t1, t2 WHERE t1.a=1 ORDER BY t2.c; -DROP TABLE t1,t2; - -# -# Test of LEFT() with distinct -# - -CREATE table t1 ( `id` int(11) NOT NULL auto_increment, `name` varchar(50) NOT NULL default '', PRIMARY KEY (`id`)) ENGINE=MyISAM AUTO_INCREMENT=3 ; -INSERT INTO t1 VALUES (1, 'aaaaa'); -INSERT INTO t1 VALUES (3, 'aaaaa'); -INSERT INTO t1 VALUES (2, 'eeeeeee'); -select distinct left(name,1) as name from t1; -drop table t1; - -# -# Test case from sel000100 -# - -CREATE TABLE t1 ( - ID int(11) NOT NULL auto_increment, - NAME varchar(75) DEFAULT '' NOT NULL, - LINK_ID int(11) DEFAULT '0' NOT NULL, - PRIMARY KEY (ID), - KEY NAME (NAME), - KEY LINK_ID (LINK_ID) -); - -INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (1,'Mike',0); -INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (2,'Jack',0); -INSERT INTO t1 (ID, NAME, LINK_ID) VALUES (3,'Bill',0); - -CREATE TABLE t2 ( - ID int(11) NOT NULL auto_increment, - NAME varchar(150) DEFAULT '' NOT NULL, - PRIMARY KEY (ID), - KEY NAME (NAME) -); - -SELECT DISTINCT - t2.id AS key_link_id, - t2.name AS link -FROM t1 -LEFT JOIN t2 ON t1.link_id=t2.id -GROUP BY t1.id -ORDER BY link; -drop table t1,t2; - -# -# test case for #674 -# - -CREATE TABLE t1 ( - html varchar(5) default NULL, - rin int(11) default '0', - rout int(11) default '0' -) ENGINE=MyISAM; - -INSERT INTO t1 VALUES ('1',1,0); -SELECT DISTINCT html,SUM(rout)/(SUM(rin)+1) as 'prod' FROM t1 GROUP BY rin; -drop table t1; - -# -# Bug 9784 DISTINCT IFNULL truncates data -# -create table t1 (id int, dsc varchar(50)); -insert into t1 values (1, "line number one"), (2, "line number two"), (3, "line number three"); -select distinct id, IFNULL(dsc, '-') from t1; -drop table t1; diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index ebd70ed063a..7cd943d46da 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -79,3 +79,5 @@ unlock tables; create table t1(n int); show tables; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/drop_temp_table.test b/mysql-test/t/drop_temp_table.test index dbe7959acb2..38c13e3e5e4 100644 --- a/mysql-test/t/drop_temp_table.test +++ b/mysql-test/t/drop_temp_table.test @@ -23,3 +23,5 @@ let $VERSION=`select version()`; --replace_column 2 # 5 # show binlog events; drop database `drop-temp+table-test`; + +# End of 4.1 tests diff --git a/mysql-test/t/empty_table.test b/mysql-test/t/empty_table.test index db0a8e6a247..e8e532832f4 100644 --- a/mysql-test/t/empty_table.test +++ b/mysql-test/t/empty_table.test @@ -11,3 +11,5 @@ select count(*) from t1; select * from t1; select * from t1 limit 0; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/endspace.test b/mysql-test/t/endspace.test index 3d27c44c3b9..c4d53450910 100644 --- a/mysql-test/t/endspace.test +++ b/mysql-test/t/endspace.test @@ -94,3 +94,5 @@ select text1, length(text1) from t1 where text1='teststring' or text1 like 'test select text1, length(text1) from t1 where text1='teststring' or text1 >= 'teststring\t'; select concat('|', text1, '|') from t1 order by text1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/errors.test b/mysql-test/t/errors.test index b558c90b0c6..f5647a293e8 100644 --- a/mysql-test/t/errors.test +++ b/mysql-test/t/errors.test @@ -14,9 +14,9 @@ update t1 set a=1; create table t1 (a int); --error 1054 select count(test.t1.b) from t1; ---error 1109 +--error 1054 select count(not_existing_database.t1) from t1; ---error 1109 +--error 1054 select count(not_existing_database.t1.a) from t1; --error 1044,1146 select count(not_existing_database.t1.a) from not_existing_database.t1; @@ -29,3 +29,16 @@ select 1 from t1 order by t1.b; --error 1054 select count(*),b from t1; drop table t1; + +# End of 4.1 tests + +# +# Bug #6080: Error message for a field with a display width that is too long +# +--error 1439 +create table t1 (a int(256)); +set sql_mode='traditional'; +--error 1074 +create table t1 (a varchar(66000)); + +# End of 5.0 tests diff --git a/mysql-test/t/exampledb.test b/mysql-test/t/exampledb.test index c60a9d7f930..946d25325dc 100644 --- a/mysql-test/t/exampledb.test +++ b/mysql-test/t/exampledb.test @@ -14,3 +14,5 @@ CREATE TABLE t1 ( ) ENGINE=example; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test index 050939e5ad2..2a3a23c5f96 100644 --- a/mysql-test/t/explain.test +++ b/mysql-test/t/explain.test @@ -41,3 +41,5 @@ insert into ÔÁ (ËÏÌ0) values (2); explain select ËÏÌ0 from ÔÁ where ËÏÌ0=1; drop table ÔÁÂ; set names latin1; + +# End of 4.1 tests diff --git a/mysql-test/t/federated.test b/mysql-test/t/federated.test index 1e33efe1c0e..255b9dc22d7 100644 --- a/mysql-test/t/federated.test +++ b/mysql-test/t/federated.test @@ -1,19 +1,7 @@ ---source include/have_federated_db.inc - -source include/master-slave.inc; - -# remote table creation +source include/federated.inc; connection slave; ---replicate-ignore-db=federated -stop slave; - ---disable_warnings -# at this point, we are connected to master -DROP DATABASE IF EXISTS federated; ---enable_warnings -CREATE DATABASE federated; - +DROP TABLE IF EXISTS federated.t1; CREATE TABLE federated.t1 ( `id` int(20) NOT NULL, `name` varchar(32) NOT NULL default '' @@ -21,14 +9,10 @@ CREATE TABLE federated.t1 ( DEFAULT CHARSET=latin1; connection master; ---disable_warnings -DROP DATABASE IF EXISTS federated; ---enable_warnings -CREATE DATABASE federated; - +DROP TABLE IF EXISTS federated.t1; # test too many items (malformed) in the comment string url ---error 1005 -eval CREATE TABLE federated.t1 ( +--error 1432 +CREATE TABLE federated.t1 ( `id` int(20) NOT NULL, `name` varchar(32) NOT NULL default '' ) @@ -36,8 +20,8 @@ eval CREATE TABLE federated.t1 ( COMMENT='mysql://root@127.0.0.1:@/too/many/items/federated/t1'; # test not enough items (malformed) in the comment string url ---error 1005 -eval CREATE TABLE federated.t1 ( +--error 1432 +CREATE TABLE federated.t1 ( `id` int(20) NOT NULL, `name` varchar(32) NOT NULL default '' ) @@ -46,7 +30,7 @@ eval CREATE TABLE federated.t1 ( # test non-existant table --replace_result $SLAVE_MYPORT SLAVE_PORT ---error 1219 +--error 1434 eval CREATE TABLE federated.t1 ( `id` int(20) NOT NULL, `name` varchar(32) NOT NULL default '' @@ -56,7 +40,7 @@ eval CREATE TABLE federated.t1 ( # test bad user/password --replace_result $SLAVE_MYPORT SLAVE_PORT ---error 1218 +--error 1429 eval CREATE TABLE federated.t1 ( `id` int(20) NOT NULL, `name` varchar(32) NOT NULL default '' @@ -150,12 +134,9 @@ CREATE TABLE federated.t1 ( `name` varchar(32) NOT NULL default '', `other` int(20) NOT NULL default '0', `created` datetime default '2004-04-04 04:04:04', - PRIMARY KEY (`id`), - KEY `name` (`name`), - KEY `other_key` (`other`)) + PRIMARY KEY (`id`)) DEFAULT CHARSET=latin1; - connection master; --replace_result $SLAVE_MYPORT SLAVE_PORT eval CREATE TABLE federated.t1 ( @@ -163,9 +144,7 @@ eval CREATE TABLE federated.t1 ( `name` varchar(32) NOT NULL default '', `other` int(20) NOT NULL default '0', `created` datetime default '2004-04-04 04:04:04', - PRIMARY KEY (`id`), - KEY `name` (`name`), - KEY `other_key` (`other`)) + PRIMARY KEY (`id`)) ENGINE="FEDERATED" DEFAULT CHARSET=latin1 COMMENT='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; @@ -184,8 +163,84 @@ INSERT INTO federated.t1 (name, other) VALUES ('Tenth Name', 101010); SELECT * FROM federated.t1; # with PRIMARY KEY index_read_idx SELECT * FROM federated.t1 WHERE id = 5; -# with regular key index_read -> index_read_idx SELECT * FROM federated.t1 WHERE name = 'Sixth Name'; +SELECT * FROM federated.t1 WHERE id = 6 and name = 'Sixth Name'; +SELECT * FROM federated.t1 WHERE name = 'Sixth Name' AND other = 44444; +SELECT * FROM federated.t1 WHERE name like '%th%'; +UPDATE federated.t1 SET name = '3rd name' WHERE id = 3; +SELECT * FROM federated.t1 WHERE name = '3rd name'; +UPDATE federated.t1 SET name = 'Third name' WHERE name = '3rd name'; +SELECT * FROM federated.t1 WHERE name = 'Third name'; +# rnd_post, ::position +SELECT * FROM federated.t1 ORDER BY id DESC; +SELECT * FROM federated.t1 ORDER BY name; +SELECT * FROM federated.t1 ORDER BY name DESC; +SELECT * FROM federated.t1 ORDER BY name ASC; +SELECT * FROM federated.t1 GROUP BY other; + +# ::delete_row +DELETE FROM federated.t1 WHERE id = 5; +SELECT * FROM federated.t1 WHERE id = 5; + +# ::delete_all_rows +DELETE FROM federated.t1; +SELECT * FROM federated.t1 WHERE id = 5; + +# previous test, but this time with indexes +connection slave; +DROP TABLE IF EXISTS federated.t1; +CREATE TABLE federated.t1 ( + `id` int(20) NOT NULL auto_increment, + `name` varchar(32) NOT NULL default '', + `other` int(20) NOT NULL default '0', + `created` datetime NOT NULL, + PRIMARY KEY (`id`), + key name(`name`), + key other(`other`), + key created(`created`)) + DEFAULT CHARSET=latin1; + +connection master; +DROP TABLE IF EXISTS federated.t1; +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval CREATE TABLE federated.t1 ( + `id` int(20) NOT NULL auto_increment, + `name` varchar(32) NOT NULL default '', + `other` int(20) NOT NULL default '0', + `created` datetime NOT NULL, + PRIMARY KEY (`id`), + key name(`name`), + key other(`other`), + key created(`created`)) + ENGINE="FEDERATED" DEFAULT CHARSET=latin1 + COMMENT='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; + +INSERT INTO federated.t1 (name, other, created) + VALUES ('First Name', 11111, '2004-01-01 01:01:01'); +INSERT INTO federated.t1 (name, other, created) + VALUES ('Second Name', 22222, '2004-01-23 02:43:00'); +INSERT INTO federated.t1 (name, other, created) + VALUES ('Third Name', 33333, '2004-02-14 02:14:00'); +INSERT INTO federated.t1 (name, other, created) + VALUES ('Fourth Name', 44444, '2003-04-05 00:00:00'); +INSERT INTO federated.t1 (name, other, created) + VALUES ('Fifth Name', 55555, '2001-02-02 02:02:02'); +INSERT INTO federated.t1 (name, other, created) + VALUES ('Sixth Name', 66666, '2005-06-06 15:30:00'); +INSERT INTO federated.t1 (name, other, created) + VALUES ('Seventh Name', 77777, '2003-12-12 18:32:00'); +INSERT INTO federated.t1 (name, other, created) + VALUES ('Eigth Name', 88888, '2005-03-12 11:00:00'); +INSERT INTO federated.t1 (name, other, created) + VALUES ('Ninth Name', 99999, '2005-03-12 11:00:01'); +INSERT INTO federated.t1 (name, other, created) + VALUES ('Tenth Name', 101010, '2005-03-12 12:00:01'); + +# basic select +SELECT * FROM federated.t1; +# with PRIMARY KEY index_read_idx +SELECT * FROM federated.t1 WHERE id = 5; +# with regular key index_read -> index_read_idx # regular and PRIMARY KEY index_read_idx SELECT * FROM federated.t1 WHERE id = 6 and name = 'Sixth Name'; # with regular key index_read -> index_read_idx @@ -211,7 +266,6 @@ SELECT * FROM federated.t1 WHERE id = 5; # ::delete_all_rows DELETE FROM federated.t1; SELECT * FROM federated.t1 WHERE id = 5; - connection slave; DROP TABLE IF EXISTS federated.t1; CREATE TABLE federated.t1 ( @@ -253,8 +307,7 @@ SET name = 'Fourth Name', other = 'four four four' WHERE name IS NULL AND other IS NULL; UPDATE federated.t1 SET other = 'two two two two' WHERE name = 'Second Name'; -UPDATE federated.t1 SET other = 'seven seven' WHERE name like 'Sec%'; -UPDATE federated.t1 SET other = 'seven seven' WHERE name = 'Seventh Name'; +UPDATE federated.t1 SET other = 'seven seven' WHERE name like 'Sev%'; UPDATE federated.t1 SET name = 'Tenth Name' WHERE other like 'fee fie%'; SELECT * FROM federated.t1 WHERE name IS NULL OR other IS NULL ; SELECT * FROM federated.t1; @@ -338,6 +391,201 @@ SELECT * FROM federated.t1 WHERE name='third'; SELECT * FROM federated.t1 WHERE other=2222; SELECT * FROM federated.t1 WHERE name='third' and other=2222; +# more multi-column indexes, in the primary key +connection slave; +DROP TABLE IF EXISTS federated.t1; +CREATE TABLE federated.t1 ( + `id` int NOT NULL auto_increment, + `col1` int(10) NOT NULL DEFAULT 0, + `col2` varchar(64) NOT NULL DEFAULT '', + `col3` int(20) NOT NULL, + `col4` int(40) NOT NULL, + primary key (`id`, `col1`, `col2`, `col3`, `col4`), + key col1(col1), + key col2(col2), + key col3(col3), + key col4(col4)); + +connection master; +DROP TABLE IF EXISTS federated.t1; +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval CREATE TABLE federated.t1 ( + `id` int NOT NULL auto_increment, + `col1` int(10) NOT NULL DEFAULT 0, + `col2` varchar(64) NOT NULL DEFAULT '', + `col3` int(20) NOT NULL, + `col4` int(40) NOT NULL, + primary key (`id`, `col1`, `col2`, `col3`, `col4`), + key col1(col1), + key col2(col2), + key col3(col3), + key col4(col4)) + ENGINE="FEDERATED" + COMMENT='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; + +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES (1, 'one One', 11, 1111); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES (2, 'Two two', 22, 2222); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES (3, 'three Three', 33, 33333); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES (4, 'fourfourfour', 444, 4444444); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES (5, 'five 5 five five 5', 5, 55555); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES (6, 'six six Sixsix', 6666, 6); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES (7, 'seven Sevenseven', 77777, 7777); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES (8, 'eight eight eight', 88888, 88); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES (9, 'nine Nine', 999999, 999999); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES (10, 'Tenth ten TEN', 1010101, 1010); + +SELECT * FROM federated.t1 WHERE col2 = 'two two'; +SELECT * FROM federated.t1 WHERE col2 = 'two Two'; +SELECT * FROM federated.t1 WHERE id = 3; +SELECT * FROM federated.t1 WHERE id = 3 AND col1 = 3; +SELECT * FROM federated.t1 WHERE id = 4 AND col1 = 4 AND col2 = 'Two two'; +SELECT * FROM federated.t1 WHERE id = 4 AND col1 = 4 AND col2 = 'fourfourfour'; +SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'five 5 five five 5' + AND col3 = 5; +SELECT * FROM federated.t1 WHERE id = 5 AND col2 = 'five 5 five five 5' + AND col3 = 5 + AND col4 = 55555; +SELECT * FROM federated.t1 WHERE id = 5 + AND col2 = 'Two two' AND col3 = 22 + AND col4 = 33; +SELECT * FROM federated.t1 WHERE id = 5 + AND col2 = 'five 5 five five 5' AND col3 = 5 + AND col4 = 55555; +SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'five 5 five five 5') + OR (col2 = 'three Three' AND col3 = 33); +SELECT * FROM federated.t1 WHERE (id = 5 AND col2 = 'Two two') + OR (col2 = 444 AND col3 = 4444444); +SELECT * FROM federated.t1 WHERE id = 1 + OR col1 = 10 + OR col2 = 'Two two' + OR col3 = 33 + OR col4 = 4444444; +SELECT * FROM federated.t1 WHERE id > 5; +SELECT * FROM federated.t1 WHERE id >= 5; +SELECT * FROM federated.t1 WHERE id < 5; +SELECT * FROM federated.t1 WHERE id <= 5; +SELECT * FROM federated.t1 WHERE id != 5; +SELECT * FROM federated.t1 WHERE id > 3 AND id < 7; +SELECT * FROM federated.t1 WHERE id > 3 AND id <= 7; +SELECT * FROM federated.t1 WHERE id >= 3 AND id <= 7; +SELECT * FROM federated.t1 WHERE id < 3 AND id <= 7; +SELECT * FROM federated.t1 WHERE id < 3 AND id > 7; +SELECT * FROM federated.t1 WHERE id < 3 OR id > 7; +SELECT * FROM federated.t1 WHERE col2 = 'three Three'; +SELECT * FROM federated.t1 WHERE col2 > 'one'; +SELECT * FROM federated.t1 WHERE col2 LIKE 's%'; +SELECT * FROM federated.t1 WHERE col2 LIKE 'si%'; +SELECT * FROM federated.t1 WHERE col2 LIKE 'se%'; +SELECT * FROM federated.t1 WHERE col2 NOT LIKE 'e%'; +SELECT * FROM federated.t1 WHERE col2 <> 'one One'; + +# more multi-column indexes, in the primary key +connection slave; +DROP TABLE IF EXISTS federated.t1; +CREATE TABLE federated.t1 ( + `col1` varchar(8) NOT NULL DEFAULT '', + `col2` varchar(128) NOT NULL DEFAULT '', + `col3` varchar(20) NOT NULL DEFAULT '', + `col4` varchar(40) NOT NULL DEFAULT '', + primary key (`col1`, `col2`, `col3`, `col4`), + key 3key(`col2`,`col3`,`col4`), + key 2key (`col3`,`col4`), + key col4(col4)); + +connection master; +DROP TABLE IF EXISTS federated.t1; +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval CREATE TABLE federated.t1 ( + `col1` varchar(8) NOT NULL DEFAULT '', + `col2` varchar(128) NOT NULL DEFAULT '', + `col3` varchar(20) NOT NULL DEFAULT '', + `col4` varchar(40) NOT NULL DEFAULT '', + primary key (`col1`, `col2`, `col3`, `col4`), + key 3key(`col2`,`col3`,`col4`), + key 2key (`col3`,`col4`), + key col4(col4)) + ENGINE="FEDERATED" + COMMENT='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; + +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES ('aaaa', 'aaaaaaaaaaaaaaaaaaa', 'ababababab', 'acacacacacacacac'); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES ('bbbb', 'bbbbbbbbbbbbbbbbbbb', 'bababababa', 'bcbcbcbcbcbcbcbc'); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES ('cccc', 'ccccccccccccccccccc', 'cacacacaca', 'cbcbcbcbcbcbcbcb'); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES ('dddd', 'ddddddddddddddddddd', 'dadadadada', 'dcdcdcdcdcdcdcdc'); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES ('eeee', 'eeeeeeeeeeeeeeeeeee', 'eaeaeaeaea', 'ecececececececec'); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES ('ffff', 'fffffffffffffffffff', 'fafafafafa', 'fcfcfcfcfcfcfcfc'); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES ('gggg', 'ggggggggggggggggggg', 'gagagagaga', 'gcgcgcgcgcgcgcgc'); +INSERT INTO federated.t1 (col1, col2, col3, col4) + VALUES ('hhhh', 'hhhhhhhhhhhhhhhhhhh', 'hahahahaha', 'hchchchchchchchc'); + +SELECT * FROM federated.t1 WHERE col1 = 'cccc'; +SELECT * FROM federated.t1 WHERE col2 = 'eeeeeeeeeeeeeeeeeee'; +SELECT * FROM federated.t1 WHERE col3 = 'bababababa'; +SELECT * FROM federated.t1 WHERE col1 = 'gggg' AND col2 = 'ggggggggggggggggggg'; +SELECT * FROM federated.t1 WHERE col1 = 'gggg' AND col3 = 'gagagagaga'; +SELECT * FROM federated.t1 WHERE col1 = 'ffff' AND col4 = 'fcfcfcfcfcfcfcfc'; +SELECT * FROM federated.t1 WHERE col1 > 'bbbb'; +SELECT * FROM federated.t1 WHERE col1 >= 'bbbb'; +SELECT * FROM federated.t1 WHERE col1 < 'bbbb'; +SELECT * FROM federated.t1 WHERE col1 <= 'bbbb'; +SELECT * FROM federated.t1 WHERE col1 <> 'bbbb'; +SELECT * FROM federated.t1 WHERE col1 LIKE 'b%'; +SELECT * FROM federated.t1 WHERE col4 LIKE '%b%'; +SELECT * FROM federated.t1 WHERE col1 NOT LIKE 'c%'; +SELECT * FROM federated.t1 WHERE col4 NOT LIKE '%c%'; +connection slave; +DROP TABLE IF EXISTS federated.t1; +CREATE TABLE federated.t1 ( + `col1` varchar(8) NOT NULL DEFAULT '', + `col2` int(8) NOT NULL DEFAULT 0, + `col3` varchar(8) NOT NULL DEFAULT '', + primary key (`col1`, `col2`, `col3`)); + +connection master; +DROP TABLE IF EXISTS federated.t1; +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval CREATE TABLE federated.t1 ( + `col1` varchar(8) NOT NULL DEFAULT '', + `col2` varchar(8) NOT NULL DEFAULT '', + `col3` varchar(8) NOT NULL DEFAULT '', + primary key (`col1`, `col2`, `col3`)) + ENGINE="FEDERATED" + DEFAULT CHARSET=latin1 + COMMENT='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; + +INSERT INTO federated.t1 VALUES ('a00', '110', 'cc0'); +INSERT INTO federated.t1 VALUES ('aaa', '111', 'ccc'); +INSERT INTO federated.t1 VALUES ('bbb', '222', 'yyy'); +INSERT INTO federated.t1 VALUES ('ccc', '111', 'zzz'); +INSERT INTO federated.t1 VALUES ('ccd', '112', 'zzzz'); + +# let's see what the foreign database says +connection slave; +SELECT col3 FROM federated.t1 WHERE ( +(col1 = 'aaa' AND col2 >= '111') OR col1 > 'aaa') AND +(col1 < 'ccc' OR ( col1 = 'ccc' AND col2 <= '111')); + +connection master; +SELECT col3 FROM federated.t1 WHERE ( +(col1 = 'aaa' AND col2 >= '111') OR col1 > 'aaa') AND +(col1 < 'ccc' OR ( col1 = 'ccc' AND col2 <= '111')); + # test NULLs connection slave; DROP TABLE IF EXISTS federated.t1; @@ -422,14 +670,6 @@ eval CREATE TABLE federated.t1 ( COMMENT='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; INSERT INTO federated.t1 VALUES (3,3,3),(1,1,1),(2,2,2),(4,4,4); -EXPLAIN SELECT * FROM federated.t1 ORDER BY a; -EXPLAIN SELECT * FROM federated.t1 ORDER BY b; -EXPLAIN SELECT * FROM federated.t1 ORDER BY c; -EXPLAIN SELECT a FROM federated.t1 ORDER BY a; -EXPLAIN SELECT b FROM federated.t1 ORDER BY b; -EXPLAIN SELECT a,b FROM federated.t1 ORDER BY b; -EXPLAIN SELECT a,b FROM federated.t1; -EXPLAIN SELECT a,b,c FROM federated.t1; connection slave; DROP TABLE IF EXISTS federated.t1; @@ -862,32 +1102,16 @@ INSERT INTO federated.t1 (name, country_id, other) VALUES ('Monty', 4, 33333); INSERT INTO federated.t1 (name, country_id, other) VALUES ('Sanja', 5, 33333); #inner join -EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, -federated.t1.other AS other, federated.countries.country AS country -FROM federated.t1, federated.countries WHERE -federated.t1.country_id = federated.countries.id; - SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1, federated.countries WHERE federated.t1.country_id = federated.countries.id; -EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, -federated.t1.other AS other, federated.countries.country AS country -FROM federated.t1 INNER JOIN federated.countries ON -federated.t1.country_id = federated.countries.id; - SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1 INNER JOIN federated.countries ON federated.t1.country_id = federated.countries.id; -EXPLAIN SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, -federated.t1.other AS other, federated.countries.country AS country -FROM federated.t1 INNER JOIN federated.countries ON -federated.t1.country_id = federated.countries.id -WHERE federated.t1.name = 'Monty'; - SELECT federated.t1.name AS name, federated.t1.country_id AS country_id, federated.t1.other AS other, federated.countries.country AS country FROM federated.t1 INNER JOIN federated.countries ON @@ -895,32 +1119,17 @@ federated.t1.country_id = federated.countries.id WHERE federated.t1.name = 'Monty'; #left join -EXPLAIN SELECT federated.t1.*, federated.countries.country -FROM federated.t1 LEFT JOIN federated.countries -ON federated.t1.country_id = federated.countries.id -ORDER BY federated.countries.id; - SELECT federated.t1.*, federated.countries.country FROM federated.t1 LEFT JOIN federated.countries ON federated.t1.country_id = federated.countries.id ORDER BY federated.countries.id; -EXPLAIN SELECT federated.t1.*, federated.countries.country -FROM federated.t1 LEFT JOIN federated.countries -ON federated.t1.country_id = federated.countries.id -ORDER BY federated.countries.country; - SELECT federated.t1.*, federated.countries.country FROM federated.t1 LEFT JOIN federated.countries ON federated.t1.country_id = federated.countries.id ORDER BY federated.countries.country; #right join -EXPLAIN SELECT federated.t1.*, federated.countries.country -FROM federated.t1 RIGHT JOIN federated.countries -ON federated.t1.country_id = federated.countries.id -ORDER BY federated.t1.country_id; - SELECT federated.t1.*, federated.countries.country FROM federated.t1 RIGHT JOIN federated.countries ON federated.t1.country_id = federated.countries.id @@ -928,14 +1137,11 @@ ORDER BY federated.t1.country_id; DROP TABLE federated.countries; -connection master; ---disable_warnings -DROP TABLE IF EXISTS federated.t1; -DROP DATABASE IF EXISTS federated; ---enable_warnings +# optimize and repair tests +OPTIMIZE TABLE federated.t1; +REPAIR TABLE federated.t1; +REPAIR TABLE federated.t1 QUICK; +REPAIR TABLE federated.t1 EXTENDED; +REPAIR TABLE federated.t1 USE_FRM; -connection slave; ---disable_warnings -DROP TABLE IF EXISTS federated.t1; -DROP DATABASE IF EXISTS federated; ---enable_warnings +source include/federated_cleanup.inc; diff --git a/mysql-test/t/flush.test b/mysql-test/t/flush.test index 62af9d4932b..f5fd9fcadf2 100644 --- a/mysql-test/t/flush.test +++ b/mysql-test/t/flush.test @@ -69,3 +69,36 @@ connection con2; insert into t1 values (345); select * from t1; drop table t1; + +# +# Bug#9459 - deadlock with flush with lock, and lock table write +# +create table t1 (c1 int); +lock table t1 write; +# Cannot get the global read lock with write locked tables. +--error 1192 +flush tables with read lock; +lock table t1 read; +# Can get the global read lock with read locked tables. +flush tables with read lock; +--error 1223 +lock table t1 write; +lock table t1 read; +--error 1223 +lock table t1 write; +# Release all table locks and the global read lock. +unlock tables; +create table t2 (c1 int); +create table t3 (c1 int); +lock table t1 read, t2 read, t3 write; +# Cannot get the global read lock with write locked tables. +--error 1192 +flush tables with read lock; +lock table t1 read, t2 read, t3 read; +# Can get the global read lock with read locked tables. +flush tables with read lock; +# Release all table locks and the global read lock. +unlock tables; +drop table t1, t2, t3; + +# End of 4.1 tests diff --git a/mysql-test/t/flush_block_commit.test b/mysql-test/t/flush_block_commit.test index 29ef7b8a0b9..ebb48242a4d 100644 --- a/mysql-test/t/flush_block_commit.test +++ b/mysql-test/t/flush_block_commit.test @@ -77,6 +77,8 @@ show create database test; drop table t1; +# End of 4.1 tests + # FLUSH TABLES WITH READ LOCK should block writes to binlog too connection con1; create table t1 (a int) engine=innodb; diff --git a/mysql-test/t/flush_table.test b/mysql-test/t/flush_table.test index afb30d21da7..e46b67ad3d0 100644 --- a/mysql-test/t/flush_table.test +++ b/mysql-test/t/flush_table.test @@ -72,3 +72,12 @@ handler t1 read next limit 1; handler t1 read next limit 1; handler t1 close; drop table t1; + +# +# Bug #11934 Two sequential FLUSH TABLES WITH READ LOCK hangs client +# +FLUSH TABLES WITH READ LOCK ; +FLUSH TABLES WITH READ LOCK ; +UNLOCK TABLES; + +# End of 4.1 tests diff --git a/mysql-test/t/foreign_key.test b/mysql-test/t/foreign_key.test index 8c35fd65f74..0a3708e6dc8 100644 --- a/mysql-test/t/foreign_key.test +++ b/mysql-test/t/foreign_key.test @@ -21,3 +21,5 @@ create table t1 ( create index a on t1 (a); create unique index b on t1 (a,b); drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 3c4d5dc93da..08648f4e0a6 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -128,14 +128,14 @@ WHERE ticket2.id = ttxt.ticket AND t1.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar'); # In the following query MySQL didn't use the fulltext index -select t1.id FROM t2 as ttxt,t1 INNER JOIN t1 as ticket2 ON -ticket2.id = ttxt.ticket -WHERE t1.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar'); +select ticket2.id FROM t2 as ttxt,t2 INNER JOIN t1 as ticket2 ON +ticket2.id = t2.ticket +WHERE ticket2.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar'); INSERT INTO t1 VALUES (3,3); -select t1.id FROM t2 as ttxt,t1 -INNER JOIN t1 as ticket2 ON ticket2.id = ttxt.ticket -WHERE t1.id = ticket2.ticket and +select ticket2.id FROM t2 as ttxt,t2 +INNER JOIN t1 as ticket2 ON ticket2.id = t2.ticket +WHERE ticket2.id = ticket2.ticket and match(ttxt.inhalt) against ('foobar'); # Check that we get 'fulltext' index in SHOW CREATE @@ -338,3 +338,16 @@ SET NAMES latin1; INSERT INTO t1 VALUES('Mit freundlichem Grüß aus Osnabrück'); SELECT COUNT(*) FROM t1 WHERE MATCH(t) AGAINST ('"osnabrück"' IN BOOLEAN MODE); DROP TABLE t1; + +# +# BUG#11684 - repair crashes mysql when table has fulltext index +# + +CREATE TABLE t1 (a VARCHAR(30), FULLTEXT(a)); +INSERT INTO t1 VALUES('bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'); +SET myisam_repair_threads=2; +REPAIR TABLE t1; +SET myisam_repair_threads=@@global.myisam_repair_threads; +DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/fulltext2.test b/mysql-test/t/fulltext2.test index 1d3a5307412..bcd39b9ea04 100644 --- a/mysql-test/t/fulltext2.test +++ b/mysql-test/t/fulltext2.test @@ -182,3 +182,4 @@ select count(*) from t1 where match a against ('aaazzz' in boolean mode); drop table t1; +# End of 4.1 tests diff --git a/mysql-test/t/fulltext_cache.test b/mysql-test/t/fulltext_cache.test index b01f0d18b76..ea05f699506 100644 --- a/mysql-test/t/fulltext_cache.test +++ b/mysql-test/t/fulltext_cache.test @@ -42,3 +42,5 @@ SELECT t1.q, t2.item, t2.id, MATCH t2.item AGAINST ('sushi' IN BOOLEAN MODE) as x FROM t2, t1 WHERE (t2.id2 = t1.id) ORDER BY x DESC,t2.id; drop table t1, t2; + +# End of 4.1 tests diff --git a/mysql-test/t/fulltext_distinct.test b/mysql-test/t/fulltext_distinct.test index 1f4cb8cd7bc..bf773c36844 100644 --- a/mysql-test/t/fulltext_distinct.test +++ b/mysql-test/t/fulltext_distinct.test @@ -42,3 +42,5 @@ WHERE MATCH (t1.value) AGAINST ('baz333' IN BOOLEAN MODE) AND t1.id = t2.id_t1; DROP TABLE t1, t2; + +# End of 4.1 tests diff --git a/mysql-test/t/fulltext_left_join.test b/mysql-test/t/fulltext_left_join.test index 96751ef8678..3bb1f0b7309 100644 --- a/mysql-test/t/fulltext_left_join.test +++ b/mysql-test/t/fulltext_left_join.test @@ -45,3 +45,4 @@ select * from t1 left join t2 on (venue_id = entity_id and match(name) against(' select * from t1 left join t2 on (venue_id = entity_id and match(name) against('aberdeen')) where dt = '2003-05-23 19:30:00'; drop table t1,t2; +# End of 4.1 tests diff --git a/mysql-test/t/fulltext_multi.test b/mysql-test/t/fulltext_multi.test index 3a622a551bc..fe64fe88599 100644 --- a/mysql-test/t/fulltext_multi.test +++ b/mysql-test/t/fulltext_multi.test @@ -21,3 +21,5 @@ SELECT a, round(MATCH b AGAINST ('lala lkjh'),5) FROM t1; SELECT a, round(MATCH c AGAINST ('lala lkjh'),5) FROM t1; SELECT a, round(MATCH b,c AGAINST ('lala lkjh'),5) FROM t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/fulltext_order_by.test b/mysql-test/t/fulltext_order_by.test index 5c1b4127d8c..074aefbf943 100644 --- a/mysql-test/t/fulltext_order_by.test +++ b/mysql-test/t/fulltext_order_by.test @@ -1,5 +1,5 @@ --disable_warnings -DROP TABLE IF EXISTS t1; +DROP TABLE IF EXISTS t1,t2,t3; --enable_warnings CREATE TABLE t1 ( @@ -54,3 +54,101 @@ SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1; SELECT a, MATCH (message) AGAINST ('t* f*' IN BOOLEAN MODE) as rel FROM t1 ORDER BY rel,a; drop table t1; +# BUG#11869 +CREATE TABLE t1 ( + id int(11) NOT NULL auto_increment, + thread int(11) NOT NULL default '0', + beitrag longtext NOT NULL, + PRIMARY KEY (id), + KEY thread (thread), + FULLTEXT KEY beitrag (beitrag) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7923 ; + +CREATE TABLE t2 ( + id int(11) NOT NULL auto_increment, + text varchar(100) NOT NULL default '', + PRIMARY KEY (id), + KEY text (text) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=63 ; + +CREATE TABLE t3 ( + id int(11) NOT NULL auto_increment, + forum int(11) NOT NULL default '0', + betreff varchar(70) NOT NULL default '', + PRIMARY KEY (id), + KEY forum (forum), + FULLTEXT KEY betreff (betreff) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=996 ; + +--error 1054 +select a.text, b.id, b.betreff +from + t2 a inner join t3 b on a.id = b.forum inner join + t1 c on b.id = c.thread +where + match(b.betreff) against ('+abc' in boolean mode) +group by a.text, b.id, b.betreff +union +select a.text, b.id, b.betreff +from + t2 a inner join t3 b on a.id = b.forum inner join + t1 c on b.id = c.thread +where + match(c.beitrag) against ('+abc' in boolean mode) +group by + a.text, b.id, b.betreff +order by + match(b.betreff) against ('+abc' in boolean mode) desc; + +--error 1054 +select a.text, b.id, b.betreff +from + t2 a inner join t3 b on a.id = b.forum inner join + t1 c on b.id = c.thread +where + match(b.betreff) against ('+abc' in boolean mode) +union +select a.text, b.id, b.betreff +from + t2 a inner join t3 b on a.id = b.forum inner join + t1 c on b.id = c.thread +where + match(c.beitrag) against ('+abc' in boolean mode) +order by + match(b.betreff) against ('+abc' in boolean mode) desc; + +select a.text, b.id, b.betreff +from + t2 a inner join t3 b on a.id = b.forum inner join + t1 c on b.id = c.thread +where + match(b.betreff) against ('+abc' in boolean mode) +union +select a.text, b.id, b.betreff +from + t2 a inner join t3 b on a.id = b.forum inner join + t1 c on b.id = c.thread +where + match(c.beitrag) against ('+abc' in boolean mode) +order by + match(betreff) against ('+abc' in boolean mode) desc; + +# BUG#11869 part2: used table type doesn't support FULLTEXT indexes error +(select b.id, b.betreff from t3 b) union +(select b.id, b.betreff from t3 b) +order by match(betreff) against ('+abc' in boolean mode) desc; + +--error 1191 +(select b.id, b.betreff from t3 b) union +(select b.id, b.betreff from t3 b) +order by match(betreff) against ('+abc') desc; + +select distinct b.id, b.betreff from t3 b +order by match(betreff) against ('+abc' in boolean mode) desc; + +select b.id, b.betreff from t3 b group by b.id+1 +order by match(betreff) against ('+abc' in boolean mode) desc; + +drop table t1,t2,t3; + +# End of 4.1 tests diff --git a/mysql-test/t/fulltext_update.test b/mysql-test/t/fulltext_update.test index a1d133ba3fe..14eb0de58a5 100644 --- a/mysql-test/t/fulltext_update.test +++ b/mysql-test/t/fulltext_update.test @@ -25,3 +25,5 @@ update test set url='test', shortdesc='ggg', longdesc='mmm', description='ddd', name='nam' where gnr=2; check table test; drop table test; + +# End of 4.1 tests diff --git a/mysql-test/t/fulltext_var.test b/mysql-test/t/fulltext_var.test index 8cc8acf60a6..6b0b8aa463b 100644 --- a/mysql-test/t/fulltext_var.test +++ b/mysql-test/t/fulltext_var.test @@ -25,3 +25,4 @@ set global ft_boolean_syntax='@ -><()~*:""@|'; set global ft_boolean_syntax='+ -><()~*:""@!|'; drop table t1; +# End of 4.1 tests diff --git a/mysql-test/t/func_compress.test b/mysql-test/t/func_compress.test index 9c32313e967..a78017ddb2f 100644 --- a/mysql-test/t/func_compress.test +++ b/mysql-test/t/func_compress.test @@ -47,3 +47,4 @@ set @@max_allowed_packet=1048576*100; --replace_result "''" XXX "'1'" XXX eval select compress(repeat('aaaaaaaaaa', IF('$LOW_MEMORY', 10, 10000000))) is null; +# End of 4.1 tests diff --git a/mysql-test/t/func_concat.test b/mysql-test/t/func_concat.test index 4f13ce7513c..37fc0e105b8 100644 --- a/mysql-test/t/func_concat.test +++ b/mysql-test/t/func_concat.test @@ -52,3 +52,4 @@ select 'a' union select concat('a', -0.0); --replace_result a-0.0000 a0.0000 select 'a' union select concat('a', -0.0000); +# End of 4.1 tests diff --git a/mysql-test/t/func_crypt.test b/mysql-test/t/func_crypt.test index f352a98e3cd..5e0283feb28 100644 --- a/mysql-test/t/func_crypt.test +++ b/mysql-test/t/func_crypt.test @@ -48,3 +48,5 @@ select old_password('idkfa'); select old_password(' i d k f a '); explain extended select password('idkfa '), old_password('idkfa'); + +# End of 4.1 tests diff --git a/mysql-test/t/func_date_add.test b/mysql-test/t/func_date_add.test index 29c13793b78..e01fce30577 100644 --- a/mysql-test/t/func_date_add.test +++ b/mysql-test/t/func_date_add.test @@ -40,3 +40,28 @@ having mts < DATE_SUB(NOW(),INTERVAL 3 MONTH); select visitor_id,max(ts) as mts from t1 group by visitor_id having DATE_ADD(mts,INTERVAL 3 MONTH) < NOW(); drop table t1; + +# +# Bug #10627: Invalid date turned to NULL from date_sub/date_add in +# traditional mode +# +set sql_mode='traditional'; +create table t1 (d date); +--error S22008 +insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR); +--error S22008 +insert into t1 (d) select date_add('2000-01-01',interval 8000 year); +# No warnings/errors from the next two +insert into t1 values (date_add(NULL, INTERVAL 1 DAY)); +insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY)); +set sql_mode=''; +# These will all work now, and we'll end up with some NULL entries in the +# table and some warnings. +insert into t1 (d) select date_sub('2000-01-01', INTERVAL 2001 YEAR); +insert into t1 (d) select date_add('2000-01-01',interval 8000 year); +insert into t1 values (date_add(NULL, INTERVAL 1 DAY)); +insert into t1 values (date_add('2000-01-04', INTERVAL NULL DAY)); +select * from t1; +drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/func_default.test b/mysql-test/t/func_default.test index af7ebcf588b..7bebd4b4b72 100644 --- a/mysql-test/t/func_default.test +++ b/mysql-test/t/func_default.test @@ -18,6 +18,8 @@ explain select * from t1 where str <> default(str); drop table t1; +# End of 4.1 tests + # # Bug #11314 (HAVING DEFAULT() hangs) # diff --git a/mysql-test/t/func_des_encrypt.test b/mysql-test/t/func_des_encrypt.test new file mode 100644 index 00000000000..5d102bd02eb --- /dev/null +++ b/mysql-test/t/func_des_encrypt.test @@ -0,0 +1,11 @@ +-- source include/have_openssl.inc + +# This test can't be in func_encrypt.test, because it requires +# --des-key-file to not be set. + +# +# Bug #11643: des_encrypt() causes server to die +# +select des_encrypt('hello'); + +# End of 4.1 tests diff --git a/mysql-test/t/func_encrypt.test b/mysql-test/t/func_encrypt.test index 52aca7f9dcb..a7364fa43da 100644 --- a/mysql-test/t/func_encrypt.test +++ b/mysql-test/t/func_encrypt.test @@ -86,3 +86,5 @@ select hex(des_decrypt(des_encrypt("hello",4),'password2')); select hex(des_decrypt(des_encrypt("hello","hidden"))); explain extended select des_decrypt(des_encrypt("hello",4),'password2'), des_decrypt(des_encrypt("hello","hidden")); + +# End of 4.1 tests diff --git a/mysql-test/t/func_encrypt_nossl.test b/mysql-test/t/func_encrypt_nossl.test index 95c104ce046..11866db1da7 100644 --- a/mysql-test/t/func_encrypt_nossl.test +++ b/mysql-test/t/func_encrypt_nossl.test @@ -35,3 +35,4 @@ select hex("hello"); select hex(des_decrypt(des_encrypt("hello",4),'password2')); select hex(des_decrypt(des_encrypt("hello","hidden"))); +# End of 4.1 tests diff --git a/mysql-test/t/func_equal.test b/mysql-test/t/func_equal.test index f446e277c92..4c88ed170a1 100644 --- a/mysql-test/t/func_equal.test +++ b/mysql-test/t/func_equal.test @@ -33,3 +33,5 @@ select * from t1 where id <=>id; select * from t1 where value <=> value; select * from t1 where id <=> value or value<=>id; drop table t1,t2; + +# End of 4.1 tests diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 96cd51f58db..fc7ce8e38a5 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -264,6 +264,24 @@ select group_concat(distinct b order by b) from t1 group by a; drop table t1; # +# Bug#10201 +# +create table t1 (a varchar(255) character set cp1250 collate cp1250_general_ci, + b varchar(255) character set koi8r); +insert into t1 values ('xxx','yyy'); +select collation(a) from t1; +select collation(group_concat(a)) from t1; +create table t2 select group_concat(a) as a from t1; +show create table t2; +select collation(group_concat(a,_koi8r'test')) from t1; +--error 1267 +select collation(group_concat(a,_koi8r 0xC1C2)) from t1; +--error 1267 +select collation(group_concat(a,b)) from t1; +drop table t1; +drop table t2; + +# # bug #7769: group_concat returning null is checked in having # CREATE TABLE t1 (id int); @@ -299,3 +317,42 @@ create table t1 (a char(3), b char(20), primary key (a, b)); insert into t1 values ('ABW', 'Dutch'), ('ABW', 'English'); select group_concat(a) from t1 group by b; drop table t1; +# +# Bug #12095: GROUP_CONCAT for one row table +# + +CREATE TABLE t1 ( + aID smallint(5) unsigned NOT NULL auto_increment, + sometitle varchar(255) NOT NULL default '', + bID smallint(5) unsigned NOT NULL, + PRIMARY KEY (aID), + UNIQUE KEY sometitle (sometitle) +); +INSERT INTO t1 SET sometitle = 'title1', bID = 1; +INSERT INTO t1 SET sometitle = 'title2', bID = 1; + +CREATE TABLE t2 ( + bID smallint(5) unsigned NOT NULL auto_increment, + somename varchar(255) NOT NULL default '', + PRIMARY KEY (bID), + UNIQUE KEY somename (somename) +); +INSERT INTO t2 SET somename = 'test'; + +SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') + FROM t1 JOIN t2 ON t1.bID = t2.bID; +INSERT INTO t2 SET somename = 'test2'; +SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') + FROM t1 JOIN t2 ON t1.bID = t2.bID; +DELETE FROM t2 WHERE somename = 'test2'; +SELECT COUNT(*), GROUP_CONCAT(DISTINCT t2.somename SEPARATOR ' |') + FROM t1 JOIN t2 ON t1.bID = t2.bID; + +DROP TABLE t1,t2; + +# +# Bug #12861 hang with group_concat insubquery FROM DUAL +# +select * from (select group_concat('c') from DUAL) t; + +# End of 4.1 tests diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test index 459a40cfe87..fb9470c16dd 100644 --- a/mysql-test/t/func_group.test +++ b/mysql-test/t/func_group.test @@ -509,7 +509,41 @@ create table t2 select f2 from (select now() f2 from t1) a; show columns from t2; drop table t2, t1; +# +# Bug 8893: wrong result for min/max optimization with 2 indexes +# + +CREATE TABLE t1( + id int PRIMARY KEY, + a int, + b int, + INDEX i_b_id(a,b,id), + INDEX i_id(a,id) +); +INSERT INTO t1 VALUES + (1,1,4), (2,2,1), (3,1,3), (4,2,1), (5,1,1); +SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6; +DROP TABLE t1; + +# change the order of the last two index definitions + +CREATE TABLE t1( + id int PRIMARY KEY, + a int, + b int, + INDEX i_id(a,id), + INDEX i_b_id(a,b,id) +); +INSERT INTO t1 VALUES + (1,1,4), (2,2,1), (3,1,3), (4,2,1), (5,1,1); +SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6; +DROP TABLE t1; + +# End of 4.1 tests + +# # decimal-related tests +# create table t2 (ff double); insert into t2 values (2.2); select cast(sum(distinct ff) as decimal(5,2)) from t2; @@ -566,36 +600,6 @@ select col1,sum(col1),max(col1),min(col1) from t1 group by col1; DROP TABLE t1; # -# Bug 8893: wrong result for min/max optimization with 2 indexes -# - -CREATE TABLE t1( - id int PRIMARY KEY, - a int, - b int, - INDEX i_b_id(a,b,id), - INDEX i_id(a,id) -); -INSERT INTO t1 VALUES - (1,1,4), (2,2,1), (3,1,3), (4,2,1), (5,1,1); -SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6; -DROP TABLE t1; - -# change the order of the last two index definitions - -CREATE TABLE t1( - id int PRIMARY KEY, - a int, - b int, - INDEX i_id(a,id), - INDEX i_b_id(a,b,id) -); -INSERT INTO t1 VALUES - (1,1,4), (2,2,1), (3,1,3), (4,2,1), (5,1,1); -SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6; -DROP TABLE t1; - -# # Test that new VARCHAR correctly works with COUNT(DISTINCT) # diff --git a/mysql-test/t/func_if.test b/mysql-test/t/func_if.test index 03590dea8d1..4e0f426c10b 100644 --- a/mysql-test/t/func_if.test +++ b/mysql-test/t/func_if.test @@ -87,3 +87,5 @@ SELECT a, NULLIF(a,'') FROM t1; SELECT a, NULLIF(a,'') FROM t1 WHERE NULLIF(a,'') IS NULL; DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 6e0883b821f..7bf737402ef 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -101,3 +101,23 @@ create table t1 (a char(20) character set binary); insert into t1 values ('aa'), ('bb'); select * from t1 where a in (NULL, 'aa'); drop table t1; + +# End of 4.1 tests + +# +# Bug #11885: WHERE condition with NOT IN (one element) +# + +CREATE TABLE t1 (a int PRIMARY KEY); +INSERT INTO t1 VALUES (44), (45), (46); + +SELECT * FROM t1 WHERE a IN (45); +SELECT * FROM t1 WHERE a NOT IN (0, 45); +SELECT * FROM t1 WHERE a NOT IN (45); + +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a NOT IN (45); +SHOW CREATE VIEW v1; +SELECT * FROM v1; + +DROP VIEW v1; +DROP TABLE t1; diff --git a/mysql-test/t/func_isnull.test b/mysql-test/t/func_isnull.test index 506efada0eb..6218efb882f 100644 --- a/mysql-test/t/func_isnull.test +++ b/mysql-test/t/func_isnull.test @@ -11,3 +11,5 @@ insert into t1 values (0,"2002-05-01"),(0,"2002-05-01"),(0,"2002-05-01"); flush tables; select * from t1 where isnull(to_days(mydate)); drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/func_like.test b/mysql-test/t/func_like.test index 4ca2f28fa6e..684d7032038 100644 --- a/mysql-test/t/func_like.test +++ b/mysql-test/t/func_like.test @@ -96,3 +96,4 @@ DROP TABLE t1; # select _cp866'aaaaaaaaa' like _cp866'%aaaa%' collate cp866_bin; +# End of 4.1 tests diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index da4b8335e07..bf692325a6a 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -68,6 +68,8 @@ explain extended select degrees(pi()),radians(360); --error 1054 select rand(rand); +# End of 4.1 tests + # # Bug #8459 (FORMAT returns incorrect result) # @@ -91,3 +93,18 @@ select round(150, 2); select ceil(0.09); select ceil(0.000000000000000009); +# +# Bug #9837: problem with round() +# + +create table t1 select round(1, 6); +show create table t1; +select * from t1; +drop table t1; + +# +# Bug #11402: abs() forces rest of calculation to unsigned +# +select abs(-2) * -2; + +# End of 4.1 tests diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 78ff0907b39..4a618a56483 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -38,11 +38,43 @@ select a from t1 where mid(a+0,6,3) = ( mid(20040106123400,6,3) ); drop table t1; +# End of 4.1 tests + +# # Test for BUG#9535 +# create table t1 as select uuid(), length(uuid()); show create table t1; drop table t1; +# Bug #6760: Add SLEEP() function +create table t1 (a timestamp default '2005-05-05 01:01:01', + b timestamp default '2005-05-05 01:01:01'); +insert into t1 set a = now(); +select sleep(3); +update t1 set b = now(); +select timediff(b, a) >= '00:00:03' from t1; +drop table t1; +# +# Bug #12689: SLEEP() gets incorrectly cached/optimized-away +# +set global query_cache_size=1355776; +create table t1 (a int); +insert into t1 values (1),(1),(1); +create table t2 (a datetime default null, b datetime default null); +insert into t2 set a = now(); +select a from t1 where sleep(1); +update t2 set b = now() where b is null; +insert into t2 set a = now(); +select a from t1 where sleep(a); +update t2 set b = now() where b is null; +insert into t2 set a = now(); +select a from t1 where sleep(1); +update t2 set b = now() where b is null; +select timediff(b, a) >= '00:00:03' from t2; +drop table t2; +drop table t1; +set global query_cache_size=default; - +# End of 5.0 tests diff --git a/mysql-test/t/func_op.test b/mysql-test/t/func_op.test index 33a2884b424..24266150e4c 100644 --- a/mysql-test/t/func_op.test +++ b/mysql-test/t/func_op.test @@ -16,3 +16,5 @@ select 1 | -1, 1 ^ -1, 1 & -1; select 0 | -1, 0 ^ -1, 0 & -1; select -1 >> 0, -1 << 0; select -1 >> 1, -1 << 1; + +# End of 4.1 tests diff --git a/mysql-test/t/func_regexp.test b/mysql-test/t/func_regexp.test index 1a771d466fa..23070c71fe9 100644 --- a/mysql-test/t/func_regexp.test +++ b/mysql-test/t/func_regexp.test @@ -73,3 +73,5 @@ set @a="^R.*"; execute stmt1 using @a; deallocate prepare stmt1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/func_sapdb.test b/mysql-test/t/func_sapdb.test index bb9159eefbe..6189712b5fe 100644 --- a/mysql-test/t/func_sapdb.test +++ b/mysql-test/t/func_sapdb.test @@ -128,3 +128,5 @@ select date_add("1997-12-31",INTERVAL "10.09" SECOND_MICROSECOND) as a; --disable_ps_protocol select str_to_date("2003-01-02 10:11:12.0012", "%Y-%m-%d %H:%i:%S.%f"); --enable_ps_protocol + +# End of 4.1 tests diff --git a/mysql-test/t/func_set.test b/mysql-test/t/func_set.test index 0c79dec7cc2..710b9b90a05 100644 --- a/mysql-test/t/func_set.test +++ b/mysql-test/t/func_set.test @@ -54,3 +54,4 @@ select find_in_set(binary 'a', 'A,B,C'); # select find_in_set('1','3,1,'); +# End of 4.1 tests diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 9dc6014ec56..4a6c98c8d7f 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -23,6 +23,45 @@ select concat('',left(right(concat('what ',concat('is ','happening')),9),4),'',s select substring_index('www.tcx.se','.',-2),substring_index('www.tcx.se','.',1); select substring_index('www.tcx.se','tcx',1),substring_index('www.tcx.se','tcx',-1); select substring_index('.tcx.se','.',-2),substring_index('.tcx.se','.tcx',-1); +select substring_index('aaaaaaaaa1','a',1); +select substring_index('aaaaaaaaa1','aa',1); +select substring_index('aaaaaaaaa1','aa',2); +select substring_index('aaaaaaaaa1','aa',3); +select substring_index('aaaaaaaaa1','aa',4); +select substring_index('aaaaaaaaa1','aa',5); +select substring_index('aaaaaaaaa1','aaa',1); +select substring_index('aaaaaaaaa1','aaa',2); +select substring_index('aaaaaaaaa1','aaa',3); +select substring_index('aaaaaaaaa1','aaa',4); +select substring_index('aaaaaaaaa1','aaaa',1); +select substring_index('aaaaaaaaa1','aaaa',2); +select substring_index('aaaaaaaaa1','1',1); +select substring_index('aaaaaaaaa1','a',-1); +select substring_index('aaaaaaaaa1','aa',-1); +select substring_index('aaaaaaaaa1','aa',-2); +select substring_index('aaaaaaaaa1','aa',-3); +select substring_index('aaaaaaaaa1','aa',-4); +select substring_index('aaaaaaaaa1','aa',-5); +select substring_index('aaaaaaaaa1','aaa',-1); +select substring_index('aaaaaaaaa1','aaa',-2); +select substring_index('aaaaaaaaa1','aaa',-3); +select substring_index('aaaaaaaaa1','aaa',-4); +select substring_index('the king of thethe hill','the',-2); +select substring_index('the king of the the hill','the',-2); +select substring_index('the king of the the hill','the',-2); +select substring_index('the king of the the hill',' the ',-1); +select substring_index('the king of the the hill',' the ',-2); +select substring_index('the king of the the hill',' ',-1); +select substring_index('the king of the the hill',' ',-2); +select substring_index('the king of the the hill',' ',-3); +select substring_index('the king of the the hill',' ',-4); +select substring_index('the king of the the hill',' ',-5); +select substring_index('the king of the.the hill','the',-2); +select substring_index('the king of thethethe.the hill','the',-3); +select substring_index('the king of thethethe.the hill','the',-1); +select substring_index('the king of the the hill','the',1); +select substring_index('the king of the the hill','the',2); +select substring_index('the king of the the hill','the',3); select concat(':',ltrim(' left '),':',rtrim(' right '),':'); select concat(':',trim(leading from ' left '),':',trim(trailing from ' right '),':'); @@ -608,3 +647,21 @@ insert t1 values ('ab'), ('abc'), ('abcd'), ('abcde'); select *,substring(b,1),substring(b,-1),substring(b,-2),substring(b,-3),substring(b,-4),substring(b,-5) from t1; select * from (select *,substring(b,1),substring(b,-1),substring(b,-2),substring(b,-3),substring(b,-4),substring(b,-5) from t1) t; drop table t1; + +# +# Bug #9854 hex() and out of range handling +# +select hex(29223372036854775809), hex(-29223372036854775809); + +# +# Bug #11311: Incorrect length returned from LPAD() and RPAD() +# +create table t1 (i int); +insert into t1 values (1000000000),(1); +--enable_metadata +select lpad(i, 7, ' ') as t from t1; +select rpad(i, 7, ' ') as t from t1; +--disable_metadata +drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/func_system.test b/mysql-test/t/func_system.test index bbfef25bcfe..4a526935491 100644 --- a/mysql-test/t/func_system.test +++ b/mysql-test/t/func_system.test @@ -32,6 +32,18 @@ drop table t1; select TRUE,FALSE,NULL; # +# Bug#12351: CONCAT with USER()/DATEBASE() and +# a constant and a column gets strange results +# +create table t1 (c1 char(5)) character set=latin1; +insert into t1 values('row 1'); +insert into t1 values('row 2'); +insert into t1 values('row 3'); +select concat(user(), '--', c1) from t1; +select concat(database(), '--', c1) from t1; +drop table t1; + +# # Bug#8291 Illegal collation mix with USER() function # create table t1 (a char(10)) character set latin1; @@ -41,3 +53,5 @@ select * from t1 where a=user(); insert into t1 values ('a'); select left(concat(a,version()),1) from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/func_test.test b/mysql-test/t/func_test.test index 732cdc12cae..f2ff47704c9 100644 --- a/mysql-test/t/func_test.test +++ b/mysql-test/t/func_test.test @@ -108,6 +108,8 @@ select 5.1 mod 3, 5.1 mod -3, -5.1 mod 3, -5.1 mod -3; select 5 mod 3, 5 mod -3, -5 mod 3, -5 mod -3; +# End of 4.1 tests + # # Bug#6726: NOT BETWEEN parse failure # @@ -116,3 +118,12 @@ insert into t1 values (1,2), (2,3), (3,4), (4,5); select * from t1 where a not between 1 and 2; select * from t1 where a not between 1 and 2 and b not between 3 and 4; drop table t1; + +# +# Test for bug #12791: one of the arguments of LEAST/GREATEST is NULL +# + +SELECT GREATEST(1,NULL) FROM DUAL; +SELECT LEAST('xxx','aaa',NULL,'yyy') FROM DUAL; +SELECT LEAST(1.1,1.2,NULL,1.0) FROM DUAL; +SELECT GREATEST(1.5E+2,1.3E+2,NULL) FROM DUAL; diff --git a/mysql-test/t/func_time.test b/mysql-test/t/func_time.test index 66ff460fc61..3dd7f7276fb 100644 --- a/mysql-test/t/func_time.test +++ b/mysql-test/t/func_time.test @@ -334,6 +334,9 @@ INSERT INTO t1 VALUES (NOW()); SELECT count(*) FROM t1 WHERE d>FROM_DAYS(TO_DAYS(@TMP)) AND d<=FROM_DAYS(TO_DAYS(@TMP)+1); DROP TABLE t1; + +# End of 4.1 tests + explain extended select timestampdiff(SQL_TSI_WEEK, '2001-02-01', '2001-05-01') as a1, timestampdiff(SQL_TSI_FRAC_SECOND, '2001-02-01 12:59:59.120000', '2001-05-01 12:58:58.119999') as a2; @@ -350,3 +353,55 @@ select last_day('2005-01-00'); # the 0-11 range # select time_format('100:00:00', '%H %k %h %I %l'); + +# +# Bug #12562: Make SYSDATE behave like it does in Oracle: always the current +# time, regardless of magic to make NOW() always the same for the +# entirety of a statement. +create table t1 (a timestamp default '2005-05-05 01:01:01', + b timestamp default '2005-05-05 01:01:01'); +delimiter //; +create function t_slow_sysdate() returns timestamp +begin + do sleep(2); + return sysdate(); +end; +// + +insert into t1 set a = sysdate(), b = t_slow_sysdate();// + +create trigger t_before before insert on t1 +for each row begin + set new.b = t_slow_sysdate(); +end +// + +delimiter ;// + +insert into t1 set a = sysdate(); + +select a != b from t1; + +drop trigger t_before; +drop function t_slow_sysdate; +drop table t1; + +create table t1 (a datetime, i int, b datetime); +insert into t1 select sysdate(), sleep(1), sysdate() from dual; +select a != b from t1; +drop table t1; + +delimiter //; +create procedure t_sysdate() +begin + select sysdate() into @a; + do sleep(2); + select sysdate() into @b; + select @a != @b; +end; +// +delimiter ;// +call t_sysdate(); +drop procedure t_sysdate; + +# End of 5.0 tests diff --git a/mysql-test/t/func_timestamp.test b/mysql-test/t/func_timestamp.test index 8583c16073d..e1bb7e878ee 100644 --- a/mysql-test/t/func_timestamp.test +++ b/mysql-test/t/func_timestamp.test @@ -13,3 +13,5 @@ SELECT CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit) AS Date, UNIX_TIMESTAMP(CONCAT(Jahr,'-',Monat,'-',Tag,' ',Zeit)) AS Unix FROM t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/gcc296.test b/mysql-test/t/gcc296.test index ebca4dbc897..bfcd56ff396 100644 --- a/mysql-test/t/gcc296.test +++ b/mysql-test/t/gcc296.test @@ -18,3 +18,5 @@ INSERT INTO t1 VALUES ('0104000000','xxx','XXX'); select * from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/gis-rtree.test b/mysql-test/t/gis-rtree.test index 522f7a6f637..02e45861706 100644 --- a/mysql-test/t/gis-rtree.test +++ b/mysql-test/t/gis-rtree.test @@ -171,3 +171,20 @@ CREATE TABLE t2 (geom GEOMETRY NOT NULL, SPATIAL KEY gk(geom)); --error 1416 INSERT INTO t2 SELECT GeomFromText(st) FROM t1; drop table t1, t2; + +CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`(32))) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +INSERT INTO t1 (geometry) VALUES +(PolygonFromText('POLYGON((-18.6086111000 -66.9327777000, -18.6055555000 +-66.8158332999, -18.7186111000 -66.8102777000, -18.7211111000 -66.9269443999, +-18.6086111000 -66.9327777000))')); + +INSERT INTO t1 (geometry) VALUES +(PolygonFromText('POLYGON((-65.7402776999 -96.6686111000, -65.7372222000 +-96.5516666000, -65.8502777000 -96.5461111000, -65.8527777000 -96.6627777000, +-65.7402776999 -96.6686111000))')); +check table t1 extended; + +drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index b7071019e9d..aba2f33833a 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -371,3 +371,27 @@ insert into t1 values ("qwerty"); insert into t1 values (pointfromtext('point(1,1)')); drop table t1; + +# End of 4.1 tests + +# +# Bug #12281 (Geometry: crash in trigger) +# + +create table t1 (s1 geometry not null,s2 char(100)); +create trigger t1_bu before update on t1 for each row set new.s1 = null; +--error 1048 +insert into t1 values (null,null); +drop table t1; + +# +# Bug #10499 (function creation with GEOMETRY datatype) +# +--disable_warnings +drop procedure if exists fn3; +--enable_warnings +create function fn3 () returns point return GeomFromText("point(1 1)"); +show create function fn3; +select astext(fn3()); +drop function fn3; + diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index bb21873a0c4..635c7a3f4e7 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -479,3 +479,12 @@ insert into tables_priv values ('','test_db','mysqltest_1','test_table','test_gr flush privileges; delete from tables_priv where host = '' and user = 'mysqltest_1'; flush privileges; + +# +# Bug #10892 user variables not auto cast for comparisons +# Check that we don't get illegal mix of collations +# +set @user123="non-existent"; +select * from mysql.db where user=@user123; + +# End of 4.1 tests diff --git a/mysql-test/t/grant2.test b/mysql-test/t/grant2.test index 07bd6d53c4e..ee9cd1924c6 100644 --- a/mysql-test/t/grant2.test +++ b/mysql-test/t/grant2.test @@ -310,5 +310,45 @@ select * from t1; disconnect n1; connection default; REVOKE ALL ON mysqltest_1.t1 FROM mysqltest_1@'127.0.0.0/255.0.0.0'; +delete from mysql.user where user like 'mysqltest\_1'; +flush privileges; drop table mysqltest_1.t1; + +# +# Bug #12302: 'SET PASSWORD = ...' didn't work if connecting hostname != +# hostname the current user is authenticated as. Note that a test for this +# was also added to the test above. +# +grant all on mysqltest_1.* to mysqltest_1@'127.0.0.1'; +connect (b12302,127.0.0.1,mysqltest_1,,mysqltest_1,$MASTER_MYPORT,); +connection b12302; +select current_user(); +set password = password('changed'); +disconnect b12302; +connection default; +select host, length(password) from mysql.user where user like 'mysqltest\_1'; +revoke all on mysqltest_1.* from mysqltest_1@'127.0.0.1'; +delete from mysql.user where user like 'mysqltest\_1'; +flush privileges; +grant all on mysqltest_1.* to mysqltest_1@'127.0.0.0/255.0.0.0'; +connect (b12302_2,127.0.0.1,mysqltest_1,,mysqltest_1,$MASTER_MYPORT,); +connection b12302_2; +select current_user(); +set password = password('changed'); +disconnect b12302_2; +connection default; +select host, length(password) from mysql.user where user like 'mysqltest\_1'; +revoke all on mysqltest_1.* from mysqltest_1@'127.0.0.0/255.0.0.0'; +delete from mysql.user where user like 'mysqltest\_1'; +flush privileges; drop database mysqltest_1; + +# But anonymous users can't change their password +connect (n5,localhost,test,,test,$MASTER_MYPORT,$MASTER_MYSOCK); +connection n5; +--error 1044 +set password = password("changed"); +disconnect n5; +connection default; + +# End of 4.1 tests diff --git a/mysql-test/t/grant_cache.test b/mysql-test/t/grant_cache.test index f4423a68717..7e17a03ec21 100644 --- a/mysql-test/t/grant_cache.test +++ b/mysql-test/t/grant_cache.test @@ -149,3 +149,5 @@ drop table test.t1,mysqltest.t1,mysqltest.t2; drop database mysqltest; set GLOBAL query_cache_size=default; + +# End of 4.1 tests diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 6f1880ae8fb..8300b502518 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -575,12 +575,22 @@ CREATE TABLE t1 (id varchar(20) NOT NULL); INSERT INTO t1 VALUES ('trans1'), ('trans2'); CREATE TABLE t2 (id varchar(20) NOT NULL, err_comment blob NOT NULL); INSERT INTO t2 VALUES ('trans1', 'a problem'); - SELECT COUNT(DISTINCT(t1.id)), LEFT(err_comment, 256) AS comment FROM t1 LEFT JOIN t2 ON t1.id=t2.id GROUP BY comment; DROP TABLE t1, t2; + +# +# Bug #12266 GROUP BY expression on DATE column produces result with +# reduced length +# +create table t1 (f1 date); +insert into t1 values('2005-06-06'); +insert into t1 values('2005-06-06'); +select date(left(f1+0,8)) from t1 group by 1; +drop table t1; + # # Test for bug #11414: crash on Windows for a simple GROUP BY query # @@ -592,6 +602,8 @@ SELECT n+1 AS n FROM t1 GROUP BY n; --enable_ps_protocol DROP TABLE t1; +# End of 4.1 tests + # # Bug#11211: Ambiguous column reference in GROUP BY. # diff --git a/mysql-test/t/group_min_max.test b/mysql-test/t/group_min_max.test index 6731be615fd..da3fdec80d2 100644 --- a/mysql-test/t/group_min_max.test +++ b/mysql-test/t/group_min_max.test @@ -651,6 +651,26 @@ select a1 from t1 where a2 = 'b' group by a1; explain select distinct a1 from t1 where a2 = 'b'; select distinct a1 from t1 where a2 = 'b'; +# +# Bug #12672: primary key implcitly included in every innodb index +# + +create table bug12672 ( + pk_col int auto_increment primary key, a1 char(64), a2 char(64), b char(16), c char(16) not null, d char(16), dummy char(64) default ' ' +) engine=innodb; + +insert into bug12672 (a1, a2, b, c, d, dummy) select * from t1; + +create index idx12672_0 on bug12672 (a1); +create index idx12672_1 on bug12672 (a1,a2,b,c); +create index idx12672_2 on bug12672 (a1,a2,b); +analyze table t1; + +--replace_column 9 # +explain select distinct a1 from bug12672 where pk_col not in (1,2,3,4); +select distinct a1 from bug12672 where pk_col not in (1,2,3,4); + +drop table bug12672; drop table t1; drop table t2; diff --git a/mysql-test/t/handler.test b/mysql-test/t/handler.test index 1ab30016512..1bb9b1d3504 100644 --- a/mysql-test/t/handler.test +++ b/mysql-test/t/handler.test @@ -346,3 +346,5 @@ drop table t2; drop table t3; drop table t4; drop table t5; + +# End of 4.1 tests diff --git a/mysql-test/t/having.test b/mysql-test/t/having.test index 3221b0d4624..fb223d2a9af 100644 --- a/mysql-test/t/having.test +++ b/mysql-test/t/having.test @@ -123,6 +123,7 @@ group by a.id, a.description having (a.description is not null) and (c=0); drop table t1,t2,t3; +# End of 4.1 tests # # Tests for WL#1972 CORRECT EVALUATION OF COLUMN REFERENCES IN THE HAVING CLAUSE @@ -233,7 +234,6 @@ where t1.col2 in group by col_t1 having col_t1 <= 20; - # # nested HAVING clauses # diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test index 75ef5a73cb0..fcaa4c41ece 100644 --- a/mysql-test/t/heap.test +++ b/mysql-test/t/heap.test @@ -435,3 +435,16 @@ insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd --error 1062 insert into t1 values ("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"); drop table t1; + +# End of 4.1 tests + +# +# Bug #3094: Row format of memory tables should always be reported as Fixed +# +create table t1 (c char(10)) engine=memory; +create table t2 (c varchar(10)) engine=memory; +--replace_column 8 # +show table status like 't_'; +drop table t1, t2; + +# End of 5.0 tests diff --git a/mysql-test/t/heap_auto_increment.test b/mysql-test/t/heap_auto_increment.test index 9d0fefa4d52..016bc946209 100644 --- a/mysql-test/t/heap_auto_increment.test +++ b/mysql-test/t/heap_auto_increment.test @@ -31,3 +31,5 @@ insert into t1 values (NULL, "hey"); select * from t1; select _rowid,t1._rowid,skey,sval from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/heap_btree.test b/mysql-test/t/heap_btree.test index 6fec2ac1703..5e493c2643b 100644 --- a/mysql-test/t/heap_btree.test +++ b/mysql-test/t/heap_btree.test @@ -163,3 +163,5 @@ INSERT into t1 values (1),(2),(3),(4),(5),(6),(7),(8),(9),(10),(11); DELETE from t1 where a < 100; SELECT * from t1; DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/heap_hash.test b/mysql-test/t/heap_hash.test index 21ac69ef3a1..28a75a5ee11 100644 --- a/mysql-test/t/heap_hash.test +++ b/mysql-test/t/heap_hash.test @@ -259,3 +259,5 @@ insert into t1 values (1),(2),(3),(4),(5); select a from t1 where a in (1,3); explain select a from t1 where a in (1,3); drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/help.test b/mysql-test/t/help.test index 3f3e99e1556..ff431fb4ebd 100644 --- a/mysql-test/t/help.test +++ b/mysql-test/t/help.test @@ -113,3 +113,5 @@ delete from mysql.help_relation where help_keyword_id=@keyword1_id and help_topi delete from mysql.help_relation where help_keyword_id=@keyword2_id and help_topic_id=@topic1_id; delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic3_id; delete from mysql.help_relation where help_keyword_id=@keyword3_id and help_topic_id=@topic4_id; + +# End of 4.1 tests diff --git a/mysql-test/t/index_merge_innodb.test b/mysql-test/t/index_merge_innodb.test index c10ce3b9688..3ed7d44981b 100644 --- a/mysql-test/t/index_merge_innodb.test +++ b/mysql-test/t/index_merge_innodb.test @@ -131,3 +131,76 @@ insert into t1 values(1,'20040101'), (2,'20040102'); select * from t1 where id1 = 1 and id2= '20040101'; drop table t1; +# Test for BUG#12720 +--disable_warnings +drop view if exists v1; +--enable_warnings +CREATE TABLE t1 ( + `oid` int(11) unsigned NOT NULL auto_increment, + `fk_bbk_niederlassung` int(11) unsigned NOT NULL, + `fk_wochentag` int(11) unsigned NOT NULL, + `uhrzeit_von` time NOT NULL COMMENT 'HH:MM', + `uhrzeit_bis` time NOT NULL COMMENT 'HH:MM', + `geloescht` tinyint(4) NOT NULL, + `version` int(5) NOT NULL, + PRIMARY KEY (`oid`), + KEY `fk_bbk_niederlassung` (`fk_bbk_niederlassung`), + KEY `fk_wochentag` (`fk_wochentag`), + KEY `ix_version` (`version`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +insert into t1 values +(1, 38, 1, '08:00:00', '13:00:00', 0, 1), +(2, 38, 2, '08:00:00', '13:00:00', 0, 1), +(3, 38, 3, '08:00:00', '13:00:00', 0, 1), +(4, 38, 4, '08:00:00', '13:00:00', 0, 1), +(5, 38, 5, '08:00:00', '13:00:00', 0, 1), +(6, 38, 5, '08:00:00', '13:00:00', 1, 2), +(7, 38, 3, '08:00:00', '13:00:00', 1, 2), +(8, 38, 1, '08:00:00', '13:00:00', 1, 2), +(9, 38, 2, '08:00:00', '13:00:00', 1, 2), +(10, 38, 4, '08:00:00', '13:00:00', 1, 2), +(11, 38, 1, '08:00:00', '13:00:00', 0, 3), +(12, 38, 2, '08:00:00', '13:00:00', 0, 3), +(13, 38, 3, '08:00:00', '13:00:00', 0, 3), +(14, 38, 4, '08:00:00', '13:00:00', 0, 3), +(15, 38, 5, '08:00:00', '13:00:00', 0, 3), +(16, 38, 4, '08:00:00', '13:00:00', 0, 4), +(17, 38, 5, '08:00:00', '13:00:00', 0, 4), +(18, 38, 1, '08:00:00', '13:00:00', 0, 4), +(19, 38, 2, '08:00:00', '13:00:00', 0, 4), +(20, 38, 3, '08:00:00', '13:00:00', 0, 4), +(21, 7, 1, '08:00:00', '13:00:00', 0, 1), +(22, 7, 2, '08:00:00', '13:00:00', 0, 1), +(23, 7, 3, '08:00:00', '13:00:00', 0, 1), +(24, 7, 4, '08:00:00', '13:00:00', 0, 1), +(25, 7, 5, '08:00:00', '13:00:00', 0, 1); + +create view v1 as +select + zeit1.oid AS oid, + zeit1.fk_bbk_niederlassung AS fk_bbk_niederlassung, + zeit1.fk_wochentag AS fk_wochentag, + zeit1.uhrzeit_von AS uhrzeit_von, + zeit1.uhrzeit_bis AS uhrzeit_bis, + zeit1.geloescht AS geloescht, + zeit1.version AS version +from + t1 zeit1 +where +(zeit1.version = + (select max(zeit2.version) AS `max(version)` + from t1 zeit2 + where + ((zeit1.fk_bbk_niederlassung = zeit2.fk_bbk_niederlassung) and + (zeit1.fk_wochentag = zeit2.fk_wochentag) and + (zeit1.uhrzeit_von = zeit2.uhrzeit_von) and + (zeit1.uhrzeit_bis = zeit2.uhrzeit_bis) + ) + ) +) +and (zeit1.geloescht = 0); + +select * from v1 where oid = 21; +drop view v1; +drop table t1; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index 7c0624b67fd..23f88b75576 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -5,7 +5,7 @@ # show databases --disable_warnings -DROP TABLE IF EXISTS t0,t1,t2; +DROP TABLE IF EXISTS t0,t1,t2,t3,t5; --enable_warnings @@ -30,6 +30,8 @@ create table mysqltest.t1(a int, b VARCHAR(30), KEY string_data (b)); create table test.t2(a int); create table t3(a int, KEY a_data (a)); create table mysqltest.t4(a int); +create table t5 (id int auto_increment primary key); +insert into t5 values (10); create view v1 (c) as select table_name from information_schema.TABLES; select * from v1; @@ -76,7 +78,7 @@ where table_schema = 'mysqltest' and table_name = 'v1'; connection default; drop view v1, mysqltest.v1; -drop tables mysqltest.t4, mysqltest.t1, t2, t3; +drop tables mysqltest.t4, mysqltest.t1, t2, t3, t5; drop database mysqltest; # Test for information_schema.CHARACTER_SETS & @@ -136,7 +138,7 @@ information_schema.SCHEMATA b where a.ROUTINE_SCHEMA = b.SCHEMA_NAME; select a.ROUTINE_NAME, b.name from information_schema.ROUTINES a, -mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8); +mysql.proc b where a.ROUTINE_NAME = convert(b.name using utf8) order by 1; select count(*) from information_schema.ROUTINES; connect (user1,localhost,mysqltest_1,,); @@ -157,6 +159,8 @@ select ROUTINE_NAME, ROUTINE_DEFINITION from information_schema.ROUTINES; show create procedure sel2; show create function sub1; show create function sub2; +--replace_column 5 # 6 # +show function status like "sub2"; connection default; disconnect user1; drop function sub2; @@ -247,25 +251,27 @@ flush privileges; # QQ This results in NULLs instead of the version numbers when # QQ a LOCK TABLES is in effect when selecting from -# QQ information_schema.tables. Until this bug has been fixed, -# QQ this test is disabled /pem -#delimiter //; -#create procedure px5 () -#begin -#declare v int; -#declare c cursor for select version from -#information_schema.tables where table_schema <> 'information_schema'; -#open c; -#fetch c into v; -#select v; -#close c; -#end;// -# -#call px5()// -#call px5()// -#delimiter ;// -#select sql_mode from information_schema.ROUTINES; -#drop procedure px5; +# QQ information_schema.tables. + +--disable_parsing until bug is fixes +delimiter //; +create procedure px5 () +begin +declare v int; +declare c cursor for select version from +information_schema.tables where table_schema <> 'information_schema'; +open c; +fetch c into v; +select v; +close c; +end;// + +call px5()// +call px5()// +delimiter ;// +select sql_mode from information_schema.ROUTINES; +drop procedure px5; +--enable_parsing create table t1 (a int not null auto_increment,b int, primary key (a)); insert into t1 values (1,1),(NULL,3),(NULL,4); @@ -407,6 +413,8 @@ show variables where variable_name like "skip_show_databas"; # # Bug #7981:SHOW GLOBAL STATUS crashes server # +# We don't actually care about the value, just that it doesn't crash. +--replace_column 2 # show global status like "Threads_running"; # @@ -505,6 +513,41 @@ flush privileges; # SELECT table_schema, count(*) FROM information_schema.TABLES GROUP BY TABLE_SCHEMA; + +# +# TRIGGERS table test +# +create table t1 (i int, j int); + +delimiter |; +create trigger trg1 before insert on t1 for each row +begin + if new.j > 10 then + set new.j := 10; + end if; +end| +create trigger trg2 before update on t1 for each row +begin + if old.i % 2 = 0 then + set new.j := -1; + end if; +end| +create trigger trg3 after update on t1 for each row +begin + if new.j = -1 then + set @fired:= "Yes"; + end if; +end| +delimiter ;| +show triggers; +select * from information_schema.triggers; + +drop trigger trg1; +drop trigger trg2; +drop trigger trg3; +drop table t1; + + # # Bug #10964 Information Schema:Authorization check on privilege tables is improper # @@ -569,3 +612,57 @@ drop procedure p2; # Bug #9434 SHOW CREATE DATABASE information_schema; # show create database information_schema; + +# +# Bug #11057 information_schema: columns table has some questionable contents +# Bug #12301 information_schema: NUMERIC_SCALE must be 0 for integer columns +# +create table t1(f1 LONGBLOB, f2 LONGTEXT); +select column_name,data_type,CHARACTER_OCTET_LENGTH, + CHARACTER_MAXIMUM_LENGTH +from information_schema.columns +where table_name='t1'; +drop table t1; +create table t1(f1 tinyint, f2 SMALLINT, f3 mediumint, f4 int, + f5 BIGINT, f6 BIT, f7 bit(64)); +select column_name, NUMERIC_PRECISION, NUMERIC_SCALE +from information_schema.columns +where table_name='t1'; +drop table t1; + +# +# Bug #12127 triggers do not show in info_schema before they are used if set to the database +# +create table t1 (f1 integer); +create trigger tr1 after insert on t1 for each row set @test_var=42; +use information_schema; +select trigger_schema, trigger_name from triggers where +trigger_name='tr1'; +use test; +drop table t1; + +# +# Bug#12518 COLUMN_DEFAULT has wrong value if NOT NULL is set +# +create table t1 (a int not null, b int); +use information_schema; +select column_name, column_default from columns + where table_schema='test' and table_name='t1'; +use test; +show columns from t1; +drop table t1; + +# +# Bug #12636: SHOW TABLE STATUS with where condition containing a subquery +# over information schema +# + +CREATE TABLE t1 (a int); +CREATE TABLE t2 (b int); + +--replace_column 8 # 12 # 13 # +SHOW TABLE STATUS FROM test + WHERE name IN ( SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES + WHERE TABLE_SCHEMA='test' AND TABLE_TYPE='BASE TABLE'); + +DROP TABLE t1,t2 diff --git a/mysql-test/t/init_connect.test b/mysql-test/t/init_connect.test index d9682eb8122..2e3c67a7d38 100644 --- a/mysql-test/t/init_connect.test +++ b/mysql-test/t/init_connect.test @@ -32,3 +32,5 @@ connection con5; select @a; connection con0; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/init_file.test b/mysql-test/t/init_file.test index 604d0a01794..de6aca455bd 100644 --- a/mysql-test/t/init_file.test +++ b/mysql-test/t/init_file.test @@ -5,3 +5,5 @@ # See mysql-test/std_data/init_file.dat and # mysql-test/t/init_file-master.opt for the actual test # + +# End of 4.1 tests diff --git a/mysql-test/t/innodb-deadlock.test b/mysql-test/t/innodb-deadlock.test index a63af1a5132..41741942963 100644 --- a/mysql-test/t/innodb-deadlock.test +++ b/mysql-test/t/innodb-deadlock.test @@ -113,3 +113,5 @@ select * from t1; commit; drop table t1, t2; + +# End of 4.1 tests diff --git a/mysql-test/t/innodb-lock.test b/mysql-test/t/innodb-lock.test index 08f4cf15cc3..55a712fef9b 100644 --- a/mysql-test/t/innodb-lock.test +++ b/mysql-test/t/innodb-lock.test @@ -100,3 +100,5 @@ reap; commit; select * from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/innodb-replace.test b/mysql-test/t/innodb-replace.test index 516f058a68e..51b70f34b65 100644 --- a/mysql-test/t/innodb-replace.test +++ b/mysql-test/t/innodb-replace.test @@ -19,3 +19,4 @@ replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text select * from t1; drop table t1; +# End of 4.1 tests diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 7cc2a301e18..0bd3d8137a3 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -441,6 +441,7 @@ set @a:=now(); CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) engine=innodb; insert into t1 (a) values(1),(2),(3); select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a; +select a from t1 natural join t1 as t2 where b >= @a order by a; update t1 set a=5 where a=1; select a from t1; drop table t1; @@ -586,7 +587,7 @@ insert into mysqltest.t3 values(1); commit; drop database mysqltest; # Don't check error message ---error 12,12 +--error 1049 show tables from mysqltest; # @@ -981,7 +982,7 @@ insert into `t3`values ( 1 ) ; delete t3,t2,t1 from t1,t2,t3 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; --error 1217 update t1,t2,t3 set t3.id=5, t2.id=6, t1.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; ---error 1109 +--error 1054 update t3 set t3.id=7 where t1.id =1 and t2.id = t1.id and t3.id = t2.id; drop table t3,t2,t1; @@ -1231,6 +1232,26 @@ DROP TABLE t2; DROP TABLE t1; # +# Bug#11816 - Truncate table doesn't work with temporary innodb tables +# This is not an innodb bug, but we test it using innodb. +# +create temporary table t1 (a int) engine=innodb; +insert into t1 values (4711); +truncate t1; +insert into t1 values (42); +select * from t1; +drop table t1; +# Show that it works with permanent tables too. +create table t1 (a int) engine=innodb; +insert into t1 values (4711); +truncate t1; +insert into t1 values (42); +select * from t1; +drop table t1; + +# End of 4.1 tests + +# # range optimizer problem # @@ -1368,7 +1389,6 @@ insert into t1 (val) values ('1'),('2'); select * from t1; drop table t1; - # # Test that update does not change internal auto-increment value # @@ -1381,3 +1401,53 @@ update t1 set a=2 where a=1; insert into t1 (val) values (1); select * from t1; drop table t1; +# +# Bug #10465 +# + +--disable_warnings +CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB; +--enable_warnings +INSERT INTO t1 (GRADE) VALUES (151),(252),(343); +SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300; +SELECT GRADE FROM t1 WHERE GRADE= 151; +DROP TABLE t1; + +# +# Bug #12340 multitable delete deletes only one record +# +create table t1 (f1 varchar(10), f2 varchar(10), primary key (f1,f2)) engine=innodb; +create table t2 (f3 varchar(10), f4 varchar(10), key (f4)) engine=innodb; +insert into t2 values ('aa','cc'); +insert into t1 values ('aa','bb'),('aa','cc'); +delete t1 from t1,t2 where f1=f3 and f4='cc'; +select * from t1; +drop table t1,t2; + +# +# Test that the slow TRUNCATE implementation resets autoincrement columns +# (bug #11946) +# + +CREATE TABLE t1 ( +id INTEGER NOT NULL AUTO_INCREMENT, PRIMARY KEY (id) +) ENGINE=InnoDB; + +CREATE TABLE t2 ( +id INTEGER NOT NULL, +FOREIGN KEY (id) REFERENCES t1 (id) +) ENGINE=InnoDB; + +INSERT INTO t1 (id) VALUES (NULL); +SELECT * FROM t1; +TRUNCATE t1; +INSERT INTO t1 (id) VALUES (NULL); +SELECT * FROM t1; + +# continued from above; test that doing a slow TRUNCATE on a table with 0 +# rows resets autoincrement columns +DELETE FROM t1; +TRUNCATE t1; +INSERT INTO t1 (id) VALUES (NULL); +SELECT * FROM t1; +DROP TABLE t2, t1; diff --git a/mysql-test/t/innodb_cache.test b/mysql-test/t/innodb_cache.test index 101dde37f89..a811d660bd7 100644 --- a/mysql-test/t/innodb_cache.test +++ b/mysql-test/t/innodb_cache.test @@ -80,3 +80,4 @@ commit; select t1.* from t1, t2, t3 where t3.state & 1 = 0 and t3.t1_id = t1.id and t3.t2_id = t2.id and t1.id = 1 order by t1.a asc; drop table t3,t2,t1; +# End of 4.1 tests diff --git a/mysql-test/t/innodb_handler.test b/mysql-test/t/innodb_handler.test index 65728519e7b..18cec97af0d 100644 --- a/mysql-test/t/innodb_handler.test +++ b/mysql-test/t/innodb_handler.test @@ -93,3 +93,4 @@ HANDLER t1 READ `primary` = (1, 1000); HANDLER t1 READ `primary` PREV; DROP TABLE t1; +# End of 4.1 tests diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index e977de94871..51d936f5b4f 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -151,6 +151,12 @@ insert into t1 values(null,@value,@value,@value,@value,@value,@value,@value,@val drop table t1; --enable_ps_protocol +# End of 4.1 tests + +# +# Test automatic result buffering with INSERT INTO t1 ... SELECT ... FROM t1 +# + create table t1(id1 int not null auto_increment primary key, t char(12)); create table t2(id2 int not null, t char(12)); create table t3(id3 int not null, t char(12), index(id3)); diff --git a/mysql-test/t/insert_select-binlog.test b/mysql-test/t/insert_select-binlog.test index 9bb1ec274ef..d4041f86ab5 100644 --- a/mysql-test/t/insert_select-binlog.test +++ b/mysql-test/t/insert_select-binlog.test @@ -32,3 +32,4 @@ let $VERSION=`select version()`; show binlog events; drop table t1; +# End of 4.1 tests diff --git a/mysql-test/t/insert_select.test b/mysql-test/t/insert_select.test index 92e8c7f1231..7116a25ff39 100644 --- a/mysql-test/t/insert_select.test +++ b/mysql-test/t/insert_select.test @@ -196,8 +196,10 @@ insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= a + #Some error cases --error 1052 insert into t1 select t2.a from t2 on duplicate key update a= a + t2.b; ---error 1109 +--error 1054 insert into t1 select t2.a from t2 on duplicate key update t2.a= a + t2.b; ---error 1109 +--error 1054 insert into t1 select t2.a from t2 group by t2.a on duplicate key update a= t1.a + t2.b; drop table t1,t2,t3; + +# End of 4.1 tests diff --git a/mysql-test/t/insert_update.test b/mysql-test/t/insert_update.test index 64a76aafa5e..eda768be1bc 100644 --- a/mysql-test/t/insert_update.test +++ b/mysql-test/t/insert_update.test @@ -100,3 +100,19 @@ insert into t1 select a from t1 on duplicate key update a=a+1 ; --error 1052 insert ignore into t1 select a from t1 on duplicate key update a=t1.a+1 ; drop table t1; + +# +# Bug#10109 - INSERT .. SELECT ... ON DUPLICATE KEY UPDATE fails +# Bogus "Duplicate columns" error message +# + +CREATE TABLE t1 ( + a BIGINT(20) NOT NULL DEFAULT 0, + PRIMARY KEY (a) +) ENGINE=MyISAM; + +INSERT INTO t1 ( a ) SELECT 0 ON DUPLICATE KEY UPDATE a = a + VALUES (a) ; + +DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/join.test b/mysql-test/t/join.test index 1d18e020543..bb82a93c6c4 100644 --- a/mysql-test/t/join.test +++ b/mysql-test/t/join.test @@ -115,6 +115,10 @@ select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using --replace_result "31 tables" "XX tables" "61 tables" "XX tables" --error 1116 select t1.a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a); +select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a); +--replace_result "31 tables" "XX tables" "61 tables" "XX tables" +--error 1116 +select a from t1 as t1 left join t1 as t2 using (a) left join t1 as t3 using (a) left join t1 as t4 using (a) left join t1 as t5 using (a) left join t1 as t6 using (a) left join t1 as t7 using (a) left join t1 as t8 using (a) left join t1 as t9 using (a) left join t1 as t10 using (a) left join t1 as t11 using (a) left join t1 as t12 using (a) left join t1 as t13 using (a) left join t1 as t14 using (a) left join t1 as t15 using (a) left join t1 as t16 using (a) left join t1 as t17 using (a) left join t1 as t18 using (a) left join t1 as t19 using (a) left join t1 as t20 using (a) left join t1 as t21 using (a) left join t1 as t22 using (a) left join t1 as t23 using (a) left join t1 as t24 using (a) left join t1 as t25 using (a) left join t1 as t26 using (a) left join t1 as t27 using (a) left join t1 as t28 using (a) left join t1 as t29 using (a) left join t1 as t30 using (a) left join t1 as t31 using (a) left join t1 as t32 using (a) left join t1 as t33 using (a) left join t1 as t34 using (a) left join t1 as t35 using (a) left join t1 as t36 using (a) left join t1 as t37 using (a) left join t1 as t38 using (a) left join t1 as t39 using (a) left join t1 as t40 using (a) left join t1 as t41 using (a) left join t1 as t42 using (a) left join t1 as t43 using (a) left join t1 as t44 using (a) left join t1 as t45 using (a) left join t1 as t46 using (a) left join t1 as t47 using (a) left join t1 as t48 using (a) left join t1 as t49 using (a) left join t1 as t50 using (a) left join t1 as t51 using (a) left join t1 as t52 using (a) left join t1 as t53 using (a) left join t1 as t54 using (a) left join t1 as t55 using (a) left join t1 as t56 using (a) left join t1 as t57 using (a) left join t1 as t58 using (a) left join t1 as t59 using (a) left join t1 as t60 using (a) left join t1 as t61 using (a) left join t1 as t62 using (a) left join t1 as t63 using (a) left join t1 as t64 using (a) left join t1 as t65 using (a); drop table t1; # @@ -145,6 +149,7 @@ CREATE TABLE t1 (d DATE NOT NULL); CREATE TABLE t2 (d DATE NOT NULL); INSERT INTO t1 (d) VALUES ('2001-08-01'),('0000-00-00'); SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE t2.d IS NULL; +SELECT * FROM t1 LEFT JOIN t2 USING (d) WHERE d IS NULL; SELECT * from t1 WHERE t1.d IS NULL; SELECT * FROM t1 WHERE 1/0 IS NULL; DROP TABLE t1,t2; @@ -268,6 +273,8 @@ CREATE TABLE t2 ( INSERT INTO t2 VALUES ('rivercats','cust',20); SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND lr.siteid = 'rivercats'; SELECT emp.rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE lr.siteid = 'rivercats' AND emp.emp_id = 'psmith'; +SELECT rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE emp.emp_id = 'psmith' AND siteid = 'rivercats'; +SELECT rate_code, lr.base_rate FROM t1 AS emp LEFT JOIN t2 AS lr USING (siteid, rate_code) WHERE siteid = 'rivercats' AND emp.emp_id = 'psmith'; drop table t1,t2; # @@ -325,3 +332,5 @@ select * from t1,t2 right join t3 on (t2.i=t3.i) order by t1.i,t2.i,t3.i; select t1.i,t2.i,t3.i from t2 natural right join t3,t1 order by t1.i,t2.i,t3.i; select t1.i,t2.i,t3.i from t2 right join t3 on (t2.i=t3.i),t1 order by t1.i,t2.i,t3.i; drop table t1,t2,t3; + +# End of 4.1 tests diff --git a/mysql-test/t/join_crash.test b/mysql-test/t/join_crash.test index 2d2222ad67a..2ec96dc2c28 100644 --- a/mysql-test/t/join_crash.test +++ b/mysql-test/t/join_crash.test @@ -92,18 +92,11 @@ select distinct t1.comments as comments, sum( t3.amount_received ) + sum( t3.adjustment ) as total_budget from - t1 , t2 as client_period , - t2 as project_period - left join - t3 - on - t3.project_ptr = t1.project_id - and t3.date_received <= '2001-03-22 14:15:09' - left join - t4 - on - t4.client_id = t1.client_ptr + t2 as project_period, + t3 left join t1 on (t3.project_ptr = t1.project_id and + t3.date_received <= '2001-03-22 14:15:09') + left join t4 on t4.client_id = t1.client_ptr where 1 and ( client_period.period_type = 'client_table' @@ -124,3 +117,5 @@ from client_name asc, project_name asc; DROP TABLE t1,t2,t3,t4; + +# End of 4.1 tests diff --git a/mysql-test/t/join_nested.test b/mysql-test/t/join_nested.test index 992217d0391..482c7f9f8b9 100644 --- a/mysql-test/t/join_nested.test +++ b/mysql-test/t/join_nested.test @@ -130,15 +130,13 @@ SELECT t8.a,t8.b EXPLAIN EXTENDED SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b - FROM t6, - t7 + FROM (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10; SELECT t6.a,t6.b,t7.a,t7.b,t8.a,t8.b - FROM t6, - t7 + FROM (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10; @@ -150,8 +148,7 @@ SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b FROM t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -162,8 +159,7 @@ SELECT t5.a,t5.b,t6.a,t6.b,t7.a,t7.b,t8.a,t8.b FROM t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -186,8 +182,7 @@ SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -203,8 +198,7 @@ SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -228,8 +222,7 @@ SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -252,8 +245,7 @@ SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -281,8 +273,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -308,8 +299,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -336,8 +326,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -375,8 +364,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -452,7 +440,7 @@ SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b WHERE t1.a <= 2; SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b - FROM t1, t3, t4 + FROM t1, (t3, t4) RIGHT JOIN t2 ON t3.a=1 AND t2.b=t4.b @@ -460,7 +448,7 @@ SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b EXPLAIN EXTENDED SELECT t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b - FROM t1, t3, t4 + FROM t1, (t3, t4) RIGHT JOIN t2 ON t3.a=1 AND t2.b=t4.b @@ -470,13 +458,13 @@ CREATE INDEX idx_b ON t2(b); EXPLAIN EXTENDED SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b - FROM t3,t4 + FROM (t3,t4) LEFT JOIN (t1,t2) ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; SELECT t2.a,t2.b,t3.a,t3.b,t4.a,t4.b - FROM t3,t4 + FROM (t3,t4) LEFT JOIN (t1,t2) ON t3.a=1 AND t3.b=t2.b AND t2.b=t4.b; @@ -494,8 +482,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -534,8 +521,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -573,8 +559,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -613,8 +598,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -649,8 +633,7 @@ SELECT t0.a,t0.b,t1.a,t1.b,t2.a,t2.b,t3.a,t3.b,t4.a,t4.b, t5 LEFT JOIN ( - t6, - t7 + (t6, t7) LEFT JOIN t8 ON t7.b=t8.b AND t6.b < 10 @@ -770,3 +753,51 @@ SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; EXPLAIN SELECT * FROM t1 LEFT JOIN (t2 LEFT JOIN t3 ON c21=c31) ON c11=c21; DROP TABLE t1,t2,t3; + +# +# Bug #12154: creation of temp table for a query with nested outer join +# + +CREATE TABLE t1 (goods int(12) NOT NULL, price varchar(128) NOT NULL); +INSERT INTO t1 VALUES (23, 2340), (26, 9900); + +CREATE TABLE t2 (goods int(12), name varchar(50), shop char(2)); +INSERT INTO t2 VALUES (23, 'as300', 'fr'), (26, 'as600', 'fr'); + +create table t3 (groupid int(12) NOT NULL, goodsid int(12) NOT NULL); +INSERT INTO t3 VALUES (3,23), (6,26); + +CREATE TABLE t4 (groupid int(12)); +INSERT INTO t4 VALUES (1), (2), (3), (4), (5), (6); + +SELECT * FROM +(SELECT DISTINCT gl.groupid, gp.price + FROM t4 gl + LEFT JOIN + (t3 g INNER JOIN t2 p ON g.goodsid = p.goods + INNER JOIN t1 gp ON p.goods = gp.goods) + ON gl.groupid = g.groupid and p.shop = 'fr') t; + +CREATE VIEW v1 AS +SELECT g.groupid groupid, p.goods goods, + p.name name, p.shop shop, + gp.price price + FROM t3 g INNER JOIN t2 p ON g.goodsid = p.goods + INNER JOIN t1 gp on p.goods = gp.goods; + +CREATE VIEW v2 AS +SELECT DISTINCT g.groupid, fr.price + FROM t4 g + LEFT JOIN + v1 fr on g.groupid = fr.groupid and fr.shop = 'fr'; + +SELECT * FROM v2; + +SELECT * FROM +(SELECT DISTINCT g.groupid, fr.price + FROM t4 g + LEFT JOIN + v1 fr on g.groupid = fr.groupid and fr.shop = 'fr') t; + +DROP VIEW v1,v2; +DROP TABLE t1,t2,t3,t4; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 7dd35f164d5..aabc32c009a 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -34,13 +34,13 @@ explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a); # The next query should rearange the left joins to get this to work ---error 1120 +--error 1054 explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); ---error 1120 +--error 1054 select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); # The next query should give an error in MySQL ---error 1120 +--error 1054 select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a); # Test of inner join @@ -292,7 +292,7 @@ insert into t3 values (1); insert into t4 values (1,1); insert into t5 values (1,1); ---error 1120 +--error 1054 explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23; drop table t1,t2,t3,t4,t5; @@ -432,6 +432,8 @@ insert into t3 values(2),(4); select * from t1 natural left join t2 natural left join t3; select * from t1 natural left join t2 where (t2.i is not null)=0; select * from t1 natural left join t2 where (t2.i is not null) is not null; +select * from t1 natural left join t2 where (i is not null)=0; +select * from t1 natural left join t2 where (i is not null) is not null; drop table t1,t2,t3; # @@ -440,7 +442,6 @@ drop table t1,t2,t3; create table t1 (f1 integer,f2 integer,f3 integer); create table t2 (f2 integer,f4 integer); create table t3 (f3 integer,f5 integer); ---error 1054 select * from t1 left outer join t2 using (f2) left outer join t3 using (f3); @@ -659,9 +660,13 @@ insert into t1 values (1,"aaaaaaaaaa"),(2,"bbbbbbbbbb"); insert into t2 values (1,"cccccccccc"),(2,"dddddddddd"); select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by t1.a; select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by t1.a; +select group_concat(t1.b,t2.c) from t1 left join t2 using(a) group by a; +select group_concat(t1.b,t2.c) from t1 inner join t2 using(a) group by a; drop table t1, t2; set group_concat_max_len=default; +# End of 4.1 tests + # # BUG#10162 - ON is merged with WHERE, left join is convered to a regular join # @@ -706,8 +711,5 @@ CREATE TABLE t1 (c11 int); CREATE TABLE t2 (c21 int); INSERT INTO t1 VALUES (30), (40), (50); INSERT INTO t2 VALUES (300), (400), (500); - SELECT * FROM t1 LEFT JOIN t2 ON (c11=c21 AND c21=30) WHERE c11=40; - DROP TABLE t1, t2; - diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test index 9db1523be51..31763b84379 100644 --- a/mysql-test/t/key.test +++ b/mysql-test/t/key.test @@ -326,6 +326,23 @@ alter table t1 add key (c1,c1,c2); drop table t1; # +# Bug#12565 - ERROR 1034 when running simple UPDATE or DELETE +# on large MyISAM table +# +create table t1 ( + c1 int, + c2 varchar(20) not null, + primary key (c1), + key (c2(10)) +) engine=myisam; +insert into t1 values (1,''); +insert into t1 values (2,' \t\tTest String'); +insert into t1 values (3,' \n\tTest String'); +update t1 set c2 = 'New Test String' where c1 = 1; +select * from t1; +drop table t1; + +# # If we use a partial field for a key that is actually the length of the # field, and we extend the field, we end up with a key that includes the # whole new length of the field. @@ -337,3 +354,21 @@ show create table t1; alter table t1 modify a varchar(20); show create table t1; drop table t1; + +# +# Bug #11227: Incorrectly reporting 'MUL' vs. 'UNI' on varchar +# +create table t1 (a int not null primary key, b varchar(20) not null unique); +desc t1; +drop table t1; +create table t1 (a int not null primary key, b int not null unique); +desc t1; +drop table t1; +create table t1 (a int not null primary key, b varchar(20) not null, unique (b(10))); +desc t1; +drop table t1; +create table t1 (a int not null primary key, b varchar(20) not null, c varchar(20) not null, unique(b(10),c(10))); +desc t1; +drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/key_cache.test b/mysql-test/t/key_cache.test index 5ff26b315e2..df584021af1 100644 --- a/mysql-test/t/key_cache.test +++ b/mysql-test/t/key_cache.test @@ -167,3 +167,12 @@ set GLOBAL key_cache_block_size=2048; check table t1; drop table t1; + +# +# Bug#10473 - Can't set 'key_buffer_size' system variable to ZERO +# (One cannot drop the default key cache.) +# +set @@global.key_buffer_size=0; +select @@global.key_buffer_size; + +# End of 4.1 tests diff --git a/mysql-test/t/key_diff.test b/mysql-test/t/key_diff.test index b4e4339ae33..b490c613c61 100644 --- a/mysql-test/t/key_diff.test +++ b/mysql-test/t/key_diff.test @@ -20,3 +20,5 @@ explain select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B; select t1.*,t2.* from t1,t1 as t2 where t1.A=t2.B order by binary t1.a,t2.a; select * from t1 where a='a'; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/key_primary.test b/mysql-test/t/key_primary.test index 816365c517c..1ca2059b871 100644 --- a/mysql-test/t/key_primary.test +++ b/mysql-test/t/key_primary.test @@ -16,3 +16,5 @@ select * from t1 where t1 like "a_\%"; describe select * from t1 where t1="ABC"; describe select * from t1 where t1="ABCD"; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/keywords.test b/mysql-test/t/keywords.test index 3392bfa1b3b..de0159a950e 100644 --- a/mysql-test/t/keywords.test +++ b/mysql-test/t/keywords.test @@ -17,3 +17,5 @@ create table events(binlog int); insert into events values(1); select events.binlog from events; drop table events; + +# End of 4.1 tests diff --git a/mysql-test/t/kill.test b/mysql-test/t/kill.test index a40aa7953fe..97842d6b4e6 100644 --- a/mysql-test/t/kill.test +++ b/mysql-test/t/kill.test @@ -15,6 +15,7 @@ connection con1; drop table if exists t1; --enable_warnings +--disable_reconnect create table t1 (kill_id int); insert into t1 values(connection_id()); @@ -25,7 +26,6 @@ kill @id; connection con1; ---disable_reconnect # this statement should fail --error 2006,2013 select 1; @@ -39,6 +39,8 @@ connection con2; select 4; drop table t1; +# End of 4.1 tests + # # test of blocking of sending ERROR after OK or EOF # diff --git a/mysql-test/t/limit.test b/mysql-test/t/limit.test index 3dc56295375..6df865278f6 100644 --- a/mysql-test/t/limit.test +++ b/mysql-test/t/limit.test @@ -59,3 +59,5 @@ insert into t1 values (1); select 1 as a from t1 union all select 1 from dual limit 1; (select 1 as a from t1) union all (select 1 from dual) limit 1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index 14ef749c802..fe6828916a3 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -31,6 +31,8 @@ load data infile '../../std_data/loaddata4.dat' into table t1 fields terminated select * from t1; drop table t1; +# End of 4.1 tests + # # Let us test extended LOAD DATA features # diff --git a/mysql-test/t/lock.test b/mysql-test/t/lock.test index 127cbb54a88..4815c1a30b7 100644 --- a/mysql-test/t/lock.test +++ b/mysql-test/t/lock.test @@ -73,3 +73,5 @@ delete from t2 using t1,t2 where t1.a=t2.a; --error 1099 delete t2 from t1,t2 where t1.a=t2.a; drop table t1,t2; + +# End of 4.1 tests diff --git a/mysql-test/t/lock_multi.test b/mysql-test/t/lock_multi.test index 43cff90332b..0d2266fc2ae 100644 --- a/mysql-test/t/lock_multi.test +++ b/mysql-test/t/lock_multi.test @@ -95,10 +95,11 @@ reap; connection locker; drop table t1; +# End of 4.1 tests # # BUG#9998 - MySQL client hangs on USE "database" - +# create table t1(a int); lock tables t1 write; connection reader; diff --git a/mysql-test/t/lock_tables_lost_commit.test b/mysql-test/t/lock_tables_lost_commit.test index 8c1ad97c0cc..d31b4b7dfb5 100644 --- a/mysql-test/t/lock_tables_lost_commit.test +++ b/mysql-test/t/lock_tables_lost_commit.test @@ -20,3 +20,5 @@ connection con2; # binlog-ignore-db select * from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/lowercase_table.test b/mysql-test/t/lowercase_table.test index 9332c47cb2f..96437bc7636 100644 --- a/mysql-test/t/lowercase_table.test +++ b/mysql-test/t/lowercase_table.test @@ -84,13 +84,4 @@ drop table t1, t2; show tables; -# -#Bug 9148: Denial of service -# ---error 1049 -use lpt1; ---error 1049 -use com1; ---error 1049 -use prn; - +# End of 4.1 tests diff --git a/mysql-test/t/lowercase_table2.test b/mysql-test/t/lowercase_table2.test index f5cf292482e..c02ae8f5073 100644 --- a/mysql-test/t/lowercase_table2.test +++ b/mysql-test/t/lowercase_table2.test @@ -137,3 +137,5 @@ create table t2aA (col1 int); create table t1Aa (col1 int); select t1Aa.col1 from t1aA,t2Aa where t1Aa.col1 = t2aA.col1; drop table t2aA, t1Aa; + +# End of 4.1 tests diff --git a/mysql-test/t/lowercase_table3.test b/mysql-test/t/lowercase_table3.test index 9841059a26b..75f6e5188c5 100644 --- a/mysql-test/t/lowercase_table3.test +++ b/mysql-test/t/lowercase_table3.test @@ -5,12 +5,8 @@ # --source include/have_innodb.inc ---require r/lowercase0.require -disable_query_log; -show variables like "lower_case_%"; ---require r/true.require -select convert(@@version_compile_os using latin1) NOT IN ("NT","WIN2000","Win95/Win98","XP") as "TRUE"; -enable_query_log; +--source include/have_lowercase0.inc +--source include/not_windows.inc --disable_warnings DROP TABLE IF EXISTS t1,T1; @@ -35,3 +31,5 @@ CREATE TABLE t1 (a int) ENGINE=INNODB; --error 1146 SELECT * from T1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/lowercase_table_grant.test b/mysql-test/t/lowercase_table_grant.test index 3d6adb477a3..7449231fca5 100644 --- a/mysql-test/t/lowercase_table_grant.test +++ b/mysql-test/t/lowercase_table_grant.test @@ -26,3 +26,5 @@ flush privileges; drop user mysqltest_1@localhost; drop database MYSQLtest; + +# End of 4.1 tests diff --git a/mysql-test/t/lowercase_table_qcache.test b/mysql-test/t/lowercase_table_qcache.test index 5077a41402a..e63ad3b2c16 100644 --- a/mysql-test/t/lowercase_table_qcache.test +++ b/mysql-test/t/lowercase_table_qcache.test @@ -27,3 +27,5 @@ enable_result_log; show status like "Qcache_queries_in_cache"; set GLOBAL query_cache_size=0; + +# End of 4.1 tests diff --git a/mysql-test/t/merge.test b/mysql-test/t/merge.test index 165c16823a2..7d708243a10 100644 --- a/mysql-test/t/merge.test +++ b/mysql-test/t/merge.test @@ -320,3 +320,4 @@ INSERT INTO t2 (b) VALUES (1) ON DUPLICATE KEY UPDATE b=3; SELECT b FROM t2; DROP TABLE t1, t2; +# End of 4.1 tests diff --git a/mysql-test/t/metadata.test b/mysql-test/t/metadata.test index ebd58ef4ebb..65338448555 100644 --- a/mysql-test/t/metadata.test +++ b/mysql-test/t/metadata.test @@ -48,3 +48,17 @@ select * from (select 1 union select 1) aaa; drop table t1; --disable_metadata + +# +# Bug #11688: Bad mysql_info() results in multi-results +# +--enable_info +delimiter //; +create table t1 (i int); +insert into t1 values (1),(2),(3); +select * from t1 where i = 2; +drop table t1;// +delimiter ;// +--disable_info + +# End of 4.1 tests diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test index 0641acb552f..2e804f4c986 100644 --- a/mysql-test/t/mix_innodb_myisam_binlog.test +++ b/mysql-test/t/mix_innodb_myisam_binlog.test @@ -229,3 +229,5 @@ select (@after-@before) >= 2; # cleanup drop table t1,t2; + +# End of 4.1 tests diff --git a/mysql-test/t/multi_statement.test b/mysql-test/t/multi_statement.test index 2abec332878..eb8d867f3f0 100644 --- a/mysql-test/t/multi_statement.test +++ b/mysql-test/t/multi_statement.test @@ -29,3 +29,5 @@ show status like 'Slow_queries'|||| drop table t1|||| delimiter ;|||| + +# End of 4.1 tests diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 0ca42e86204..5e3be6d45eb 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -452,6 +452,8 @@ insert into t2 values(1,null); delete t2, t1 from t2 left join t1 on (t2.aclid=t1.aclid) where t2.refid='1'; drop table t1, t2; +# End of 4.1 tests + # # Test for bug #1980. # diff --git a/mysql-test/t/myisam-blob.test b/mysql-test/t/myisam-blob.test index 7af8c661c02..ac1b45b8c6c 100644 --- a/mysql-test/t/myisam-blob.test +++ b/mysql-test/t/myisam-blob.test @@ -39,3 +39,5 @@ INSERT INTO t1 (data) VALUES (NULL); UPDATE t1 set data=repeat('a',18*1024*1024); select length(data) from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/myisam.test b/mysql-test/t/myisam.test index fccc7642eb0..eeac2971788 100644 --- a/mysql-test/t/myisam.test +++ b/mysql-test/t/myisam.test @@ -479,7 +479,7 @@ drop table t1,t2; # # Test RTREE index # ---error 1235 +--error 1235, 1289 CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=MyISAM; # INSERT INTO t1 VALUES (1,1),(1,1); # DELETE FROM rt WHERE a<1; @@ -563,6 +563,21 @@ update t1 set c2='A B' where c1=2; check table t1; drop table t1; + +# +# Bug#12296 - CHECKSUM TABLE reports 0 for the table +# This happened if the first record was marked as deleted. +# +create table t1 (c1 int); +insert into t1 values (1),(2),(3),(4); +checksum table t1; +delete from t1 where c1 = 1; +create table t2 as select * from t1; +# The following returns 0 with the bug in place. +checksum table t1; +# The above should give the same number as the following. +checksum table t2; +drop table t1, t2; # # Test varchar # @@ -675,3 +690,14 @@ show keys from t1; drop table t1; +# +# Bug#10056 - PACK_KEYS option take values greater than 1 while creating table +# +create table t1 (c1 int) engine=myisam pack_keys=0; +create table t2 (c1 int) engine=myisam pack_keys=1; +create table t3 (c1 int) engine=myisam pack_keys=default; +--error 1064 +create table t4 (c1 int) engine=myisam pack_keys=2; +drop table t1, t2, t3; + +# End of 4.1 tests diff --git a/mysql-test/t/mysql_client_test.test b/mysql-test/t/mysql_client_test.test index 3639fc2e262..ccf5e0bf66a 100644 --- a/mysql-test/t/mysql_client_test.test +++ b/mysql-test/t/mysql_client_test.test @@ -8,3 +8,5 @@ --disable_result_log --exec echo $MYSQL_CLIENT_TEST --exec $MYSQL_CLIENT_TEST + +# End of 4.1 tests diff --git a/mysql-test/t/mysql_delimiter.sql b/mysql-test/t/mysql_delimiter.sql index 4ea481a84e2..fa80c980b29 100644 --- a/mysql-test/t/mysql_delimiter.sql +++ b/mysql-test/t/mysql_delimiter.sql @@ -45,4 +45,7 @@ delimiter delimiter select * from t1 delimiter delimiter ; # Reset delimiter - +# +# Bug #11523: \d works differently than delimiter +# +source t/mysql_delimiter_source.sql diff --git a/mysql-test/t/mysql_delimiter_source.sql b/mysql-test/t/mysql_delimiter_source.sql new file mode 100644 index 00000000000..f645091f3d4 --- /dev/null +++ b/mysql-test/t/mysql_delimiter_source.sql @@ -0,0 +1,8 @@ +delimiter // +create table t2 (a int) // +delimiter ; +\d // +create table t3 (a int) // +\d ; +show tables; +drop table t2, t3; diff --git a/mysql-test/t/mysql_protocols.test b/mysql-test/t/mysql_protocols.test index 6e2d4f20429..0253c2b5d17 100644 --- a/mysql-test/t/mysql_protocols.test +++ b/mysql-test/t/mysql_protocols.test @@ -10,3 +10,4 @@ --exec echo "select ' ok' as 'MEMORY'" | $MYSQL --protocol=MEMORY 2>&1 || true --exec echo "select ' ok' as 'NullS'" | $MYSQL --protocol=NullS 2>&1 || true +# End of 4.1 tests diff --git a/mysql-test/t/mysqlbinlog.test b/mysql-test/t/mysqlbinlog.test index 49b8237d99f..e5bd8c554cb 100644 --- a/mysql-test/t/mysqlbinlog.test +++ b/mysql-test/t/mysqlbinlog.test @@ -110,3 +110,4 @@ select "--- reading stdin --" as ""; # clean up drop table t1, t2; +# End of 4.1 tests diff --git a/mysql-test/t/mysqlbinlog2.test b/mysql-test/t/mysqlbinlog2.test index 6e2eda07695..a2f1aba05b0 100644 --- a/mysql-test/t/mysqlbinlog2.test +++ b/mysql-test/t/mysqlbinlog2.test @@ -157,3 +157,5 @@ select "--- to-last-log --" as ""; select "--- end of test --" as ""; --enable_query_log drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/mysqldump.test b/mysql-test/t/mysqldump.test index 811875a36f5..27bea937dcf 100644 --- a/mysql-test/t/mysqldump.test +++ b/mysql-test/t/mysqldump.test @@ -4,7 +4,6 @@ --disable_warnings DROP TABLE IF EXISTS t1, `"t"1`, t1aa, t2, t2aa; drop database if exists mysqldump_test_db; -drop database if exists db1; drop view if exists v1, v2, v3; --enable_warnings @@ -135,15 +134,6 @@ insert into t1 values (1),(2),(3); drop table t1; # -# dump of view -# -create table t1(a int); -create view v1 as select * from t1; ---exec $MYSQL_DUMP --skip-comments test -drop view v1; -drop table t1; - -# # Bug #6101: create database problem # @@ -198,15 +188,6 @@ INSERT INTO `t1` VALUES (0x602010000280100005E71A); DROP TABLE t1; # -# Bug #9756 -# - -CREATE TABLE t1 (a char(10)); -INSERT INTO t1 VALUES ('\''); ---exec $MYSQL_DUMP --skip-comments test t1 -DROP TABLE t1; - -# # Test for --insert-ignore # @@ -564,29 +545,6 @@ CREATE TABLE t1 (a int); INSERT INTO t1 VALUES (1),(2),(3); --exec $MYSQL_DUMP --add-drop-database --skip-comments --databases test DROP TABLE t1; - -# -# Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X) -# - -create database db1; -use db1; - -CREATE TABLE t2 ( - a varchar(30) default NULL, - KEY a (a(5)) -); - -INSERT INTO t2 VALUES ('alfred'); -INSERT INTO t2 VALUES ('angie'); -INSERT INTO t2 VALUES ('bingo'); -INSERT INTO t2 VALUES ('waffle'); -INSERT INTO t2 VALUES ('lemon'); -create view v2 as select * from t2 where a like 'a%' with check option; ---exec $MYSQL_DUMP --skip-comments db1 -drop table t2; -drop view v2; -drop database db1; # # Bug #9558 mysqldump --no-data db t1 t2 format still dumps data # @@ -620,6 +578,7 @@ select '------ Testing with illegal table names ------' as test_sequence ; --enable_query_log --error 6 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "\d-2-1.sql" 2>&1 + --error 6 --exec $MYSQL_DUMP --compact --skip-comments mysqldump_test_db "\t1" 2>&1 @@ -678,6 +637,50 @@ insert into t2 (a, b) values (NULL, NULL),(10, NULL),(NULL, "twenty"),(30, "thir --exec $MYSQL_DUMP --skip-comments --xml --no-create-info test drop table t1, t2; +# End of 4.1 tests + +# +# dump of view +# +create table t1(a int); +create view v1 as select * from t1; +--exec $MYSQL_DUMP --skip-comments test +drop view v1; +drop table t1; + +# +# Bug #10213 mysqldump crashes when dumping VIEWs(on MacOS X) +# + +create database mysqldump_test_db; +use mysqldump_test_db; + +CREATE TABLE t2 ( + a varchar(30) default NULL, + KEY a (a(5)) +); + +INSERT INTO t2 VALUES ('alfred'); +INSERT INTO t2 VALUES ('angie'); +INSERT INTO t2 VALUES ('bingo'); +INSERT INTO t2 VALUES ('waffle'); +INSERT INTO t2 VALUES ('lemon'); +create view v2 as select * from t2 where a like 'a%' with check option; +--exec $MYSQL_DUMP --skip-comments mysqldump_test_db +drop table t2; +drop view v2; +drop database mysqldump_test_db; +use test; + +# +# Bug #9756 +# + +CREATE TABLE t1 (a char(10)); +INSERT INTO t1 VALUES ('\''); +--exec $MYSQL_DUMP --skip-comments test t1 +DROP TABLE t1; + # # Bug #10927 mysqldump: Can't reload dump with view that consist of other view # @@ -709,3 +712,52 @@ select * from v1; drop view v1, v2, v3; drop table t1; +# +# Test for dumping triggers +# + +CREATE TABLE t1 (a int, b bigint default NULL); +CREATE TABLE t2 (a int); +delimiter |; +create trigger trg1 before insert on t1 for each row +begin + if new.a > 10 then + set new.a := 10; + set new.a := 11; + end if; +end| +create trigger trg2 before update on t1 for each row begin + if old.a % 2 = 0 then set new.b := 12; end if; +end| +set sql_mode="traditional"| +create trigger trg3 after update on t1 for each row +begin + if new.a = -1 then + set @fired:= "Yes"; + end if; +end| +create trigger trg4 before insert on t2 for each row +begin + if new.a > 10 then + set @fired:= "No"; + end if; +end| +set sql_mode=default| +delimiter ;| +--replace_column 6 '0000-00-00 00:00:00' +show triggers like "t1"; +INSERT INTO t1 (a) VALUES (1),(2),(3),(22); +update t1 set a = 4 where a=3; +# Triggers should be dumped by default +--exec $MYSQL_DUMP --skip-comments --databases test +# Skip dumping triggers +--exec $MYSQL_DUMP --skip-comments --databases --skip-triggers test +# Dump and reload... +--exec $MYSQL_DUMP --skip-comments --databases test > var/tmp/mysqldump.sql +drop table t1; +--exec $MYSQL test < var/tmp/mysqldump.sql +# Check that tables have been reloaded +show tables; +--replace_column 6 # +show triggers; +DROP TABLE t1, t2; diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 5bbd8cf0dfb..1d0931c12f0 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -314,6 +314,8 @@ select 3 from t1 ; #select 3 from t1 ; # #select 3 from t1 ; + +# End of 4.1 tests --error 1 --exec echo "disable_abort_on_error; enable_abort_on_error; error 1064; select 3 from t1; select 3 from t1;" | $MYSQL_TEST 2>&1 @@ -818,8 +820,6 @@ select 1 as `a'b`, 2 as `a"b`; # Test escaping of quotes select 'aaa\\','aa''a',"aa""a"; - - # # Check of include/show_msg.inc and include/show_msg80.inc # @@ -847,3 +847,14 @@ let $message= . Here comes a very very long message that . - consists of several lines; --source include/show_msg80.inc +# +# Test --enable_parsning / disable_parsning +# +--disable_query_log +--disable_parsing +# The following will not enable query logging +--enable_query_log +select "this will not be executed"; +--enable_parsing +select "this will be executed"; +--enable_query_log diff --git a/mysql-test/t/ndb_alter_table.test b/mysql-test/t/ndb_alter_table.test index 2e5e2293b5c..0f7b0bb7edc 100644 --- a/mysql-test/t/ndb_alter_table.test +++ b/mysql-test/t/ndb_alter_table.test @@ -151,7 +151,6 @@ select * from t1 where b = 'two'; connection server1; alter table t1 drop index c; connection server2; ---error 1412 select * from t1 where b = 'two'; select * from t1 where b = 'two'; connection server1; @@ -179,3 +178,30 @@ drop table t1; #truncate table t2; #select count(*) from t2; #drop table t2; + +connection server1; +create table t3 (a int primary key) engine=ndbcluster; + +connection server2; +begin; +insert into t3 values (1); + +connection server1; +alter table t3 rename t4; + +connection server2; +# This should work as transaction is ongoing... +delete from t3; +insert into t3 values (1); +commit; + +# This should fail as its a new transaction +--error 1015 +select * from t3; +select * from t4; +drop table t4; +show tables; +connection server1; + +# End of 4.1 tests + diff --git a/mysql-test/t/ndb_autodiscover.test b/mysql-test/t/ndb_autodiscover.test index 079ebd09ae1..6bbb1c2f2f2 100644 --- a/mysql-test/t/ndb_autodiscover.test +++ b/mysql-test/t/ndb_autodiscover.test @@ -501,19 +501,20 @@ drop database test_only_ndb_tables; # a table with tha same name as a table that can't be # discovered( for example a table created via NDBAPI) ---error 1050 -CREATE TABLE sys.SYSTAB_0 (a int); ---error 1105 -select * from sys.SYSTAB_0; +# Test disabled since it doesn't work on case insensitive systems +#--error 1050 +#CREATE TABLE sys.SYSTAB_0 (a int); +#--error 1105 +#select * from sys.SYSTAB_0; -CREATE TABLE IF NOT EXISTS sys.SYSTAB_0 (a int); -show warnings; ---error 1105 -select * from sys.SYSTAB_0; +#CREATE TABLE IF NOT EXISTS sys.SYSTAB_0 (a int); +#show warnings; +#--error 1105 +#select * from sys.SYSTAB_0; ---error 1051 -drop table sys.SYSTAB_0; -drop table IF EXISTS sys.SYSTAB_0; +#--error 1051 +#drop table sys.SYSTAB_0; +#drop table IF EXISTS sys.SYSTAB_0; ###################################################### # Note! This should always be the last step in this @@ -543,3 +544,5 @@ create table t10 ( insert into t10 values (1, 'kalle'); --exec $NDB_TOOLS_DIR/ndb_drop_table --no-defaults -d test `$NDB_TOOLS_DIR/ndb_show_tables --no-defaults | grep BLOB` >> $NDB_TOOLS_OUTPUT 2>&1 || true + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_autodiscover2.test b/mysql-test/t/ndb_autodiscover2.test index 29941085df4..ebe14696cd2 100644 --- a/mysql-test/t/ndb_autodiscover2.test +++ b/mysql-test/t/ndb_autodiscover2.test @@ -18,3 +18,4 @@ drop table t9; select * from t10; drop table t10; +# End of 4.1 tests diff --git a/mysql-test/t/ndb_basic.test b/mysql-test/t/ndb_basic.test index c0d5b14c2ea..1c78a4b8744 100644 --- a/mysql-test/t/ndb_basic.test +++ b/mysql-test/t/ndb_basic.test @@ -606,6 +606,7 @@ select * from t1 order by counter; drop table t1; +# End of 4.1 tests # # Test long table name diff --git a/mysql-test/t/ndb_blob.test b/mysql-test/t/ndb_blob.test index b265809b75f..a12ebee2f0d 100644 --- a/mysql-test/t/ndb_blob.test +++ b/mysql-test/t/ndb_blob.test @@ -404,3 +404,5 @@ Proper fix: Set inline bytes to multiple of mbmaxlen and validate it (after the 8 byte length).'); select * from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_cache.test b/mysql-test/t/ndb_cache.test index b61422a58fb..9c299b61c24 100644 --- a/mysql-test/t/ndb_cache.test +++ b/mysql-test/t/ndb_cache.test @@ -119,4 +119,4 @@ show status like "Qcache_queries_in_cache"; SET GLOBAL query_cache_size=0; - +# End of 4.1 tests diff --git a/mysql-test/t/ndb_charset.test b/mysql-test/t/ndb_charset.test index becbe9a4d06..fb43e1831f3 100644 --- a/mysql-test/t/ndb_charset.test +++ b/mysql-test/t/ndb_charset.test @@ -246,3 +246,5 @@ replace into t1 values ('jonas % '); replace into t1 values ('jonas % '); select * from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_config.test b/mysql-test/t/ndb_config.test new file mode 100644 index 00000000000..ab3063af672 --- /dev/null +++ b/mysql-test/t/ndb_config.test @@ -0,0 +1,10 @@ +-- source include/have_ndb.inc +-- source include/ndb_default_cluster.inc +-- source include/not_embedded.inc + +--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=type,nodeid,host 2> /dev/null +--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid,host,DataMemory,IndexMemory --type=ndbd 2> /dev/null +--exec $NDB_TOOLS_DIR/ndb_config --no-defaults -r \\n -f " " --query=nodeid,host,DataMemory,IndexMemory --type=ndbd 2> /dev/null +--exec $NDB_TOOLS_DIR/ndb_config --no-defaults --query=nodeid --type=ndbd --host=localhost 2> /dev/null + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_database.test b/mysql-test/t/ndb_database.test index 1264c3fa73b..2e924ba2dcc 100644 --- a/mysql-test/t/ndb_database.test +++ b/mysql-test/t/ndb_database.test @@ -48,3 +48,5 @@ show tables; drop table if exists t1; drop database if exists mysqltest; --enable_warnings + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_grant.later b/mysql-test/t/ndb_grant.later index b4885d2c5fc..5431d94e1f8 100644 --- a/mysql-test/t/ndb_grant.later +++ b/mysql-test/t/ndb_grant.later @@ -381,3 +381,5 @@ alter table time_zone_transition_type engine=myisam; alter table user engine=myisam; use test; flush privileges; + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_index.test b/mysql-test/t/ndb_index.test index 93085dea587..272f30e3e6f 100644 --- a/mysql-test/t/ndb_index.test +++ b/mysql-test/t/ndb_index.test @@ -126,5 +126,6 @@ select port, accessnode, pop, accesstype from t1 where pop='pop98' and accessno select port, accessnode, pop, accesstype from t1 where pop='pop98' and accessnode='node78' and port='port67' and customer_id='kllopmn'; select port, accessnode, pop, accesstype from t1 where pop='pop98' and accessnode='node78' and port='port67' and customer_id='foo'; - drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index 9c9d5d5a84f..e6827bdbe12 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -348,3 +348,11 @@ connection con1; select a from t1 where b = 2; show tables; drop table t1; + +# mysqld 5.0.13 crash, no bug# +create table t1 (a int, c varchar(10), + primary key using hash (a), index(c)) engine=ndb; +insert into t1 (a, c) values (1,'aaa'),(3,'bbb'); +select count(*) from t1 where c<'bbb'; + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_index_unique.test b/mysql-test/t/ndb_index_unique.test index d6de013c1e2..2185276c2c6 100644 --- a/mysql-test/t/ndb_index_unique.test +++ b/mysql-test/t/ndb_index_unique.test @@ -308,3 +308,5 @@ INSERT INTO t1 (month, year, code) VALUES (5,2004,'12'); select * from t1 where code = '12' and month = 4 and year = 2004 ; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_insert.test b/mysql-test/t/ndb_insert.test index 68f3817e134..92bc51bcf4f 100644 --- a/mysql-test/t/ndb_insert.test +++ b/mysql-test/t/ndb_insert.test @@ -616,3 +616,5 @@ INSERT IGNORE INTO t1 VALUES (1); INSERT IGNORE INTO t1 VALUES (1); SELECT * FROM t1; DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_limit.test b/mysql-test/t/ndb_limit.test index 0df3b2f7566..01613606d66 100644 --- a/mysql-test/t/ndb_limit.test +++ b/mysql-test/t/ndb_limit.test @@ -81,3 +81,5 @@ SELECT DATE_FORMAT(day, '%Y%m%d') as date, DATE_FORMAT(day, '%d-%m-%Y') as date_formatted FROM t2 GROUP BY day ORDER BY day DESC LIMIT 2; drop table t2; + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_lock.test b/mysql-test/t/ndb_lock.test index b93abbd564b..6945f91ee39 100644 --- a/mysql-test/t/ndb_lock.test +++ b/mysql-test/t/ndb_lock.test @@ -69,3 +69,4 @@ insert into t1 values (1,1,1); drop table t1; +# End of 4.1 tests diff --git a/mysql-test/t/ndb_minmax.test b/mysql-test/t/ndb_minmax.test index 97ea84f98ef..a3ac677cd2a 100644 --- a/mysql-test/t/ndb_minmax.test +++ b/mysql-test/t/ndb_minmax.test @@ -62,6 +62,4 @@ select MAX(c) from t2; select * from t2 order by a; drop table t2; - - - +# End of 4.1 tests diff --git a/mysql-test/t/ndb_multi.test b/mysql-test/t/ndb_multi.test index 85950c72cf9..760150c6f6a 100644 --- a/mysql-test/t/ndb_multi.test +++ b/mysql-test/t/ndb_multi.test @@ -68,4 +68,4 @@ drop table t1, t2, t3, t4; connection server2; drop table t1, t3, t4; - +# End of 4.1 tests diff --git a/mysql-test/t/ndb_replace.test b/mysql-test/t/ndb_replace.test index 1c06a9a6633..b97a0322a6a 100644 --- a/mysql-test/t/ndb_replace.test +++ b/mysql-test/t/ndb_replace.test @@ -26,3 +26,5 @@ insert into t1 (gesuchnr,benutzer_id) values (1,1); replace into t1 (gesuchnr,benutzer_id) values (1,1); select * from t1 order by gesuchnr; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_restore.test b/mysql-test/t/ndb_restore.test index 0173fabd46f..049b07d5a8b 100644 --- a/mysql-test/t/ndb_restore.test +++ b/mysql-test/t/ndb_restore.test @@ -215,3 +215,5 @@ drop table if exists t1_c,t2_c,t3_c,t4_c,t5_c,t6_c,t7_c,t8_c,t9_c; # --exec $NDB_TOOLS_DIR/ndb_select_all --no-defaults -d sys -D , SYSTAB_0 | grep 520093696 + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_subquery.test b/mysql-test/t/ndb_subquery.test index 095fdbcfa13..93c45c521a0 100644 --- a/mysql-test/t/ndb_subquery.test +++ b/mysql-test/t/ndb_subquery.test @@ -38,8 +38,11 @@ drop table t2; # bug#5367 ########## -### +# End of 4.1 tests + +# # bug#11205 +# create table t1 (p int not null primary key, u int not null) engine=ndb; insert into t1 values (1,1),(2,2),(3,3); diff --git a/mysql-test/t/ndb_transaction.test b/mysql-test/t/ndb_transaction.test index ae02059786d..d3ebadb1a78 100644 --- a/mysql-test/t/ndb_transaction.test +++ b/mysql-test/t/ndb_transaction.test @@ -295,4 +295,4 @@ select count(*) from t2; drop table test.t1, t2; drop database mysqltest; - +# End of 4.1 tests diff --git a/mysql-test/t/ndb_truncate.test b/mysql-test/t/ndb_truncate.test index 7c0f79bcc59..73af70d0d0f 100644 --- a/mysql-test/t/ndb_truncate.test +++ b/mysql-test/t/ndb_truncate.test @@ -32,3 +32,5 @@ truncate table t2; select count(*) from t2; drop table t2; + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_types.test b/mysql-test/t/ndb_types.test index d4bf4133807..3446a409b2a 100644 --- a/mysql-test/t/ndb_types.test +++ b/mysql-test/t/ndb_types.test @@ -81,3 +81,5 @@ from t1; select time_stamp>@now from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ndb_update.test b/mysql-test/t/ndb_update.test index 5453e41f937..45e3add4639 100644 --- a/mysql-test/t/ndb_update.test +++ b/mysql-test/t/ndb_update.test @@ -32,3 +32,5 @@ select * from t1 order by pk1; --disable_warnings DROP TABLE IF EXISTS t1; --enable_warnings + +# End of 4.1 tests diff --git a/mysql-test/t/negation_elimination.test b/mysql-test/t/negation_elimination.test index c50a9678edb..0e0d8891e1f 100644 --- a/mysql-test/t/negation_elimination.test +++ b/mysql-test/t/negation_elimination.test @@ -70,3 +70,5 @@ select a, not(not(a)) from t1; explain extended select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "1"), not (a not in (1,2)), not(a != 2) from t1 where not(not(a)) having not(not(a)); drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/not_embedded_server.test b/mysql-test/t/not_embedded_server.test new file mode 100644 index 00000000000..83ec03d6706 --- /dev/null +++ b/mysql-test/t/not_embedded_server.test @@ -0,0 +1,18 @@ +# +# Here we collect tests that doesn't work with the embedded server +# + +-- source include/not_embedded.inc + +# +# Show full process list with prepare +# To not show other connections, this must be the first test and we must +# have a server restart before this one +# + +prepare stmt1 from ' show full processlist '; +--replace_column 1 number 6 time 3 localhost +execute stmt1; +deallocate prepare stmt1; + +# End of 4.1 tests diff --git a/mysql-test/t/null.test b/mysql-test/t/null.test index 4cd20979319..183308880ed 100644 --- a/mysql-test/t/null.test +++ b/mysql-test/t/null.test @@ -189,3 +189,5 @@ select # Restore charset to the default value. set names latin1; + +# End of 4.1 tests diff --git a/mysql-test/t/null_key.test b/mysql-test/t/null_key.test index d7f6a634d1e..e15aec01d2a 100644 --- a/mysql-test/t/null_key.test +++ b/mysql-test/t/null_key.test @@ -193,3 +193,50 @@ select * from t1 where id2 is null or id2 > 0; delete from t1 where id <=> NULL; select * from t1; drop table t1; + +# +# Test for bug #12144: optimizations for key access with null keys +# used for outer joins +# + +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int, b int, INDEX idx(a)); +CREATE TABLE t3 (b int, INDEX idx(b)); +CREATE TABLE t4 (b int, INDEX idx(b)); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (1, 1), (3, 1); +INSERT INTO t3 VALUES + (NULL), (NULL), (NULL), (NULL), (NULL), + (NULL), (NULL), (NULL), (NULL), (NULL); +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t4 SELECT * FROM t3; +INSERT INTO t3 SELECT * FROM t4; +INSERT INTO t3 VALUES (2), (3); + +ANALYZE table t1, t2, t3; + +SELECT COUNT(*) FROM t3; + +EXPLAIN SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a + LEFT JOIN t3 ON t2.b=t3.b; +FLUSH STATUS ; +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LEFT JOIN t2 ON t1.a=t2.a + LEFT JOIN t3 ON t2.b=t3.b; +SELECT FOUND_ROWS(); +SHOW STATUS LIKE "handler_read%"; + +DROP TABLE t1,t2,t3,t4; +# End of 4.1 tests diff --git a/mysql-test/t/odbc.test b/mysql-test/t/odbc.test index 9aac5948359..d4b6fc35e74 100644 --- a/mysql-test/t/odbc.test +++ b/mysql-test/t/odbc.test @@ -20,3 +20,5 @@ select * from t1 where a is null and b=2; select * from t1 where a is null; explain select * from t1 where b is null; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index 26fcc7463d6..2e09bc5b3a3 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -266,3 +266,15 @@ EXPLAIN SELECT type FROM v1 GROUP BY type WITH ROLLUP; DROP VIEW v1; DROP TABLE t1; +# Test for bug #11543: ROLLUP query with a repeated column in GROUP BY +# + +CREATE TABLE t1 (a INT(10) NOT NULL, b INT(10) NOT NULL); +INSERT INTO t1 VALUES (1, 1); +INSERT INTO t1 VALUES (1, 2); + +SELECT a, b, a AS c, COUNT(*) AS count FROM t1 GROUP BY a, b, c WITH ROLLUP; + +DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test index 2262395d586..96c92615430 100644 --- a/mysql-test/t/openssl_1.test +++ b/mysql-test/t/openssl_1.test @@ -43,3 +43,5 @@ delete from mysql.user where user='ssl_user%'; delete from mysql.db where user='ssl_user%'; flush privileges; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 36eee6e43b7..b1807579b20 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -158,10 +158,21 @@ LEFT JOIN t3 ON t3.c = t1.c; SELECT a,b,if(b = 1,i,if(b = 2,v,'')) FROM t1 +LEFT JOIN t2 ON t1.c = t2.c +LEFT JOIN t3 ON t3.c = t1.c; + +SELECT a,b,if(b = 1,i,if(b = 2,v,'')) +FROM t1 LEFT JOIN t2 USING(c) LEFT JOIN t3 ON t3.c = t1.c ORDER BY a; +SELECT a,b,if(b = 1,i,if(b = 2,v,'')) +FROM t1 +LEFT JOIN t2 ON t1.c = t2.c +LEFT JOIN t3 ON t3.c = t1.c +ORDER BY a; + drop table t1,t2,t3; # @@ -340,7 +351,9 @@ CREATE TABLE t2 ( INSERT INTO t1 (titre,auteur,dest) VALUES ('test','joce','bug'); INSERT INTO t2 (numeropost,pseudo) VALUES (1,'joce'),(1,'bug'); SELECT titre,t1.numeropost,auteur,icone,nbrep,0,date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; +SELECT titre,numeropost,auteur,icone,nbrep,0,date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; SELECT titre,t1.numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; +SELECT titre,numeropost,auteur,icone,nbrep,'0',date,vue,ouvert,lastauteur,dest FROM t2 LEFT JOIN t1 USING(numeropost) WHERE t2.pseudo='joce' ORDER BY date DESC LIMIT 0,30; drop table t1,t2; # @@ -549,3 +562,5 @@ INSERT INTO t1 VALUES (2), (1), (1), (2), (1); SELECT a FROM t1 ORDER BY a; (SELECT a FROM t1) ORDER BY a; DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/order_fill_sortbuf.test b/mysql-test/t/order_fill_sortbuf.test index 37620ebe331..f13cf8cf350 100644 --- a/mysql-test/t/order_fill_sortbuf.test +++ b/mysql-test/t/order_fill_sortbuf.test @@ -22,3 +22,5 @@ enable_query_log; create table t2 select id2 from t1 order by id3; select count(*) from t2; drop table t1,t2; + +# End of 4.1 tests diff --git a/mysql-test/t/outfile.test b/mysql-test/t/outfile.test index 4b12f9e4e50..a74bebe1460 100644 --- a/mysql-test/t/outfile.test +++ b/mysql-test/t/outfile.test @@ -63,3 +63,5 @@ EXPLAIN FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\r\n' FROM t1; DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/overflow.test b/mysql-test/t/overflow.test index 17e443d51f8..c930707413b 100644 --- a/mysql-test/t/overflow.test +++ b/mysql-test/t/overflow.test @@ -2,3 +2,5 @@ connect (con1,localhost,boo,,); connection con1; -- error 1064,1102,1280 drop database AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA; + +# End of 4.1 tests diff --git a/mysql-test/t/packet.test b/mysql-test/t/packet.test index c7f10d75d74..4de284b7824 100644 --- a/mysql-test/t/packet.test +++ b/mysql-test/t/packet.test @@ -1,5 +1,8 @@ # Embedded server doesn't support external clients --source include/not_embedded.inc +# Windows fails because it disconnects on too-large packets instead of just +# swallowing them and returning an error +--source include/not_windows.inc # # Check protocol handling @@ -31,3 +34,5 @@ set global net_buffer_length=default; set net_buffer_length=default; SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len; select length(repeat('a',2000)); + +# End of 4.1 tests diff --git a/mysql-test/t/preload.test b/mysql-test/t/preload.test index 7a049d06a86..1b7f3c5b9eb 100644 --- a/mysql-test/t/preload.test +++ b/mysql-test/t/preload.test @@ -98,3 +98,5 @@ load index into cache t3 key (b), t2 key (c) ; show status like "key_read%"; drop table t1, t2; + +# End of 4.1 tests diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index 913b6c645af..b4c04e4432a 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -705,3 +705,128 @@ execute stmt; execute stmt; deallocate prepare stmt; drop table t1; +# +# Bug#11458 "Prepared statement with subselects return random data": +# drop PARAM_TABLE_BIT from the list of tables used by a subquery +# +create table t1 ( + id int(11) unsigned not null primary key auto_increment, + partner_id varchar(35) not null, + t1_status_id int(10) unsigned +); + +insert into t1 values ("1", "partner1", "10"), ("2", "partner2", "10"), + ("3", "partner3", "10"), ("4", "partner4", "10"); + +create table t2 ( + id int(11) unsigned not null default '0', + t1_line_id int(11) unsigned not null default '0', + article_id varchar(20), + sequence int(11) not null default '0', + primary key (id,t1_line_id) +); + +insert into t2 values ("1", "1", "sup", "0"), ("2", "1", "sup", "1"), + ("2", "2", "sup", "2"), ("2", "3", "sup", "3"), + ("2", "4", "imp", "4"), ("3", "1", "sup", "0"), + ("4", "1", "sup", "0"); + +create table t3 ( + id int(11) not null default '0', + preceeding_id int(11) not null default '0', + primary key (id,preceeding_id) +); + +create table t4 ( + user_id varchar(50) not null, + article_id varchar(20) not null, + primary key (user_id,article_id) +); + +insert into t4 values("nicke", "imp"); + +prepare stmt from +'select distinct t1.partner_id +from t1 left join t3 on t1.id = t3.id + left join t1 pp on pp.id = t3.preceeding_id +where + exists ( + select * + from t2 as pl_inner + where pl_inner.id = t1.id + and pl_inner.sequence <= ( + select min(sequence) from t2 pl_seqnr + where pl_seqnr.id = t1.id + ) + and exists ( + select * from t4 + where t4.article_id = pl_inner.article_id + and t4.user_id = ? + ) + ) + and t1.id = ? +group by t1.id +having count(pp.id) = 0'; +set @user_id = 'nicke'; +set @id = '2'; +execute stmt using @user_id, @id; +execute stmt using @user_id, @id; +deallocate prepare stmt; +drop table t1, t2, t3, t4; +# +# Bug#9379: make sure that Item::collation is reset when one sets +# a parameter marker from a string variable. +# +prepare stmt from 'select ?=?'; +set @a='CHRISTINE '; +set @b='CHRISTINE'; +execute stmt using @a, @b; +execute stmt using @a, @b; +set @a=1, @b=2; +execute stmt using @a, @b; +set @a='CHRISTINE '; +set @b='CHRISTINE'; +execute stmt using @a, @b; +deallocate prepare stmt; +# +# Bug#11299 "prepared statement makes wrong SQL syntax in binlog which stops +# replication": check that errouneous queries with placeholders are not +# allowed +# +create table t1 (a int); +--error 1064 +prepare stmt from "select ??"; +--error 1064 +prepare stmt from "select ?FROM t1"; +--error 1064 +prepare stmt from "select FROM t1 WHERE?=1"; +--error 1064 +prepare stmt from "update t1 set a=a+?WHERE 1"; +--disable_ps_protocol +--error 1064 +select ?; +--error 1064 +select ??; +--error 1064 +select ? from t1; +--enable_ps_protocol +drop table t1; +# +# Bug#9359 "Prepared statements take snapshot of system vars at PREPARE +# time" +# +prepare stmt from "select @@time_zone"; +execute stmt; +set @@time_zone:='Japan'; +execute stmt; +prepare stmt from "select @@tx_isolation"; +execute stmt; +set transaction isolation level read committed; +execute stmt; +set transaction isolation level serializable; +execute stmt; +set @@tx_isolation=default; +execute stmt; +deallocate prepare stmt; + +# End of 4.1 tests diff --git a/mysql-test/t/ps_10nestset.test b/mysql-test/t/ps_10nestset.test index 53e84f7a47d..46a88653da3 100644 --- a/mysql-test/t/ps_10nestset.test +++ b/mysql-test/t/ps_10nestset.test @@ -69,3 +69,5 @@ execute st_round using @arg_round, @arg_round; select * from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/ps_11bugs.test b/mysql-test/t/ps_11bugs.test index 5945b140645..e214afeaaf3 100644 --- a/mysql-test/t/ps_11bugs.test +++ b/mysql-test/t/ps_11bugs.test @@ -129,3 +129,4 @@ drop table t1, t2; # end of bug#1676 +# End of 4.1 tests diff --git a/mysql-test/t/ps_1general.test b/mysql-test/t/ps_1general.test index ab133e4c347..6abfd8f28a7 100644 --- a/mysql-test/t/ps_1general.test +++ b/mysql-test/t/ps_1general.test @@ -930,3 +930,5 @@ drop table t5, t9; # Thank you for reading these rules of thumb. # # Matthias + +# End of 4.1 tests diff --git a/mysql-test/t/ps_2myisam.test b/mysql-test/t/ps_2myisam.test index 534703efc14..0a335bd02a3 100644 --- a/mysql-test/t/ps_2myisam.test +++ b/mysql-test/t/ps_2myisam.test @@ -40,3 +40,5 @@ drop table t2 ; -- source include/ps_conv.inc drop table t1, t9; + +# End of 4.1 tests diff --git a/mysql-test/t/ps_3innodb.test b/mysql-test/t/ps_3innodb.test index f83b61914a2..e25a8b1f469 100644 --- a/mysql-test/t/ps_3innodb.test +++ b/mysql-test/t/ps_3innodb.test @@ -22,3 +22,5 @@ let $type= 'InnoDB' ; -- source include/ps_conv.inc drop table t1, t9; + +# End of 4.1 tests diff --git a/mysql-test/t/ps_4heap.test b/mysql-test/t/ps_4heap.test index 3ce3bea8265..f16d4599a74 100644 --- a/mysql-test/t/ps_4heap.test +++ b/mysql-test/t/ps_4heap.test @@ -47,3 +47,5 @@ eval create table t9 -- source include/ps_conv.inc drop table t1, t9; + +# End of 4.1 tests diff --git a/mysql-test/t/ps_5merge.test b/mysql-test/t/ps_5merge.test index 7e94ede41d1..e6ce9bf42d3 100644 --- a/mysql-test/t/ps_5merge.test +++ b/mysql-test/t/ps_5merge.test @@ -82,3 +82,5 @@ INSERT_METHOD=LAST; drop table t1, t1_1, t1_2, t9_1, t9_2, t9; + +# End of 4.1 tests diff --git a/mysql-test/t/ps_6bdb.test b/mysql-test/t/ps_6bdb.test index 5db3349279e..49dd7aa924b 100644 --- a/mysql-test/t/ps_6bdb.test +++ b/mysql-test/t/ps_6bdb.test @@ -21,3 +21,5 @@ let $type= 'BDB' ; -- source include/ps_conv.inc drop table t1, t9; + +# End of 4.1 tests diff --git a/mysql-test/t/ps_7ndb.test b/mysql-test/t/ps_7ndb.test index b558f2f3c21..e3f65ec2c4e 100644 --- a/mysql-test/t/ps_7ndb.test +++ b/mysql-test/t/ps_7ndb.test @@ -21,3 +21,5 @@ let $type= 'NDB' ; -- source include/ps_conv.inc drop table t1, t9; + +# End of 4.1 tests diff --git a/mysql-test/t/ps_grant.test b/mysql-test/t/ps_grant.test index 0b33a2dadde..81c842de459 100644 --- a/mysql-test/t/ps_grant.test +++ b/mysql-test/t/ps_grant.test @@ -1,7 +1,6 @@ # Can't test grants with embedded server -- source include/not_embedded.inc - let $type= 'MYISAM' ; ################ GRANT/REVOKE/DROP affecting a parallel session ################ @@ -80,6 +79,7 @@ execute s_t1 ; ######## Question 2: The table t9 does not exist. ######## --error 1146 execute s_t9 ; +deallocate prepare s_t9; #### revoke the access rights to t1 @@ -112,8 +112,11 @@ show grants for second_user@localhost ; drop database mysqltest; +# End of 4.1 tests -## grant/revoke + drop user +# +# grant/revoke + drop user +# --error 1295 prepare stmt3 from ' grant all on test.t1 to drop_user@localhost identified by ''looser'' '; @@ -126,11 +129,3 @@ revoke all privileges on test.t1 from drop_user@localhost ; --error 1295 prepare stmt3 from ' drop user drop_user@localhost '; drop user drop_user@localhost; - -# This test must be the last one, otherwise it may produce extra -# rows in the processlist under high load. -# Tested here simply so it is not tested with embedded server -prepare stmt4 from ' show full processlist '; ---replace_column 1 number 6 time 3 localhost -execute stmt4; -deallocate prepare stmt4; diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index 3a0ac08b1ba..822c27fe40d 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -79,68 +79,6 @@ delete from t3 where a=10; show status like "Qcache_queries_in_cache"; drop table t1, t2, t3; # -# FLUSH QUERY CACHE -# -create table t1 (a int not null); -insert into t1 values (1),(2),(3); -create table t2 (a int not null); -insert into t2 values (1),(2),(3); -select * from t1; -select * from t2; -insert into t1 values (4); -show status like "Qcache_free_blocks"; -flush query cache; -show status like "Qcache_free_blocks"; -drop table t1, t2; -# With join results... -create table t1 (a text not null); -create table t11 (a text not null); -create table t2 (a text not null); -create table t21 (a text not null); -create table t3 (a text not null); -insert into t1 values("1111111111111111111111111111111111111111111111111111"); -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -# t11 and t21 must be over 4Kb (QUERY_CACHE_MIN_RESULT_DATA_SIZE) -insert into t11 select * from t1; -insert into t21 select * from t1; -insert into t1 select * from t2; -insert into t2 select * from t1; -insert into t1 select * from t2; -#results of t3 must be > 0.5Mb -insert into t3 select * from t1; -insert into t3 select * from t2; -insert into t3 select * from t1; -disable_result_log; -select * from t11; -select * from t21; -enable_result_log; -show status like "Qcache_total_blocks"; -show status like "Qcache_free_blocks"; -disable_result_log; -insert into t11 values(""); -select * from t3; -enable_result_log; -show status like "Qcache_total_blocks"; -show status like "Qcache_free_blocks"; -flush query cache; -show status like "Qcache_total_blocks"; -show status like "Qcache_free_blocks"; -drop table t1, t2, t3, t11, t21; -# # SELECT SQL_CACHE ... # set query_cache_type=demand; @@ -616,6 +554,7 @@ set character_set_results=cp1251; SELECT a,'Â','â'='Â' FROM t1; show status like "Qcache_hits"; show status like "Qcache_queries_in_cache"; +SET NAMES default; DROP TABLE t1; @@ -711,9 +650,10 @@ repair table t1; show status like 'qcache_queries_in_cache'; drop table t1; +# # Bug #9549: Make sure cached queries that span more than one cache block # are handled properly in the embedded server. - +# # We just want a small query cache, so we can fragment it easily set GLOBAL query_cache_size=64*1024; # This actually gives us a usable cache size of about 48K @@ -755,6 +695,8 @@ select a from t1; flush query cache; drop table t1, t2; +set GLOBAL query_cache_size=1355776 + # # Query with warning prohibited to query cache (BUG#9414) @@ -767,9 +709,9 @@ CREATE TABLE t1 ( INSERT INTO t1 VALUES ('20050326'); INSERT INTO t1 VALUES ('20050325'); -SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050327 0:0:0'; -SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050328 0:0:0'; -SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050327 0:0:0'; +SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050327 invalid'; +SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050328 invalid'; +SELECT COUNT(*) FROM t1 WHERE date BETWEEN '20050326' AND '20050327 invalid'; show status like "Qcache_queries_in_cache"; show status like "Qcache_inserts"; show status like "Qcache_hits"; @@ -832,4 +774,45 @@ drop procedure p1// drop table t1// delimiter ;// +# +# query in QC from normal execution and SP (BUG#6897) +# +flush query cache; +reset query cache; +flush status; +delimiter //; +create table t1 (s1 int)// +create procedure f1 () begin +select sql_cache * from t1; +select sql_cache * from t1; +end;// +delimiter ;// +call f1(); +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +call f1(); +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +call f1(); +select sql_cache * from t1; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +insert into t1 values (1); +select sql_cache * from t1; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +call f1(); +call f1(); +select sql_cache * from t1; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_inserts"; +show status like "Qcache_hits"; +drop procedure f1; +drop table t1; set GLOBAL query_cache_size=0; + +# End of 4.1 tests diff --git a/mysql-test/t/query_cache_merge.test b/mysql-test/t/query_cache_merge.test index fef3f18df60..36b8662f088 100644 --- a/mysql-test/t/query_cache_merge.test +++ b/mysql-test/t/query_cache_merge.test @@ -36,3 +36,5 @@ show status like "Qcache_queries_in_cache"; drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257,t00; SET @@global.query_cache_size=0; + +# End of 4.1 tests diff --git a/mysql-test/t/query_cache_notembedded.test b/mysql-test/t/query_cache_notembedded.test new file mode 100644 index 00000000000..fd4785ffe95 --- /dev/null +++ b/mysql-test/t/query_cache_notembedded.test @@ -0,0 +1,100 @@ +-- source include/have_query_cache.inc +-- source include/not_embedded.inc + +# +# Tests with query cache +# +set GLOBAL query_cache_size=1355776; + +# Reset query cache variables. + +flush query cache; # This crashed in some versions +flush query cache; # This crashed in some versions +reset query cache; +flush status; +--disable_warnings +drop table if exists t1, t2, t3, t11, t21; +--enable_warnings +# +# FLUSH QUERY CACHE +# +create table t1 (a int not null); +insert into t1 values (1),(2),(3); +create table t2 (a int not null); +insert into t2 values (1),(2),(3); +select * from t1; +select * from t2; +insert into t1 values (4); +show status like "Qcache_free_blocks"; +flush query cache; +show status like "Qcache_free_blocks"; +drop table t1, t2; +# With join results... +create table t1 (a text not null); +create table t11 (a text not null); +create table t2 (a text not null); +create table t21 (a text not null); +create table t3 (a text not null); +insert into t1 values("1111111111111111111111111111111111111111111111111111"); +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +# t11 and t21 must be over 4Kb (QUERY_CACHE_MIN_RESULT_DATA_SIZE) +insert into t11 select * from t1; +insert into t21 select * from t1; +insert into t1 select * from t2; +insert into t2 select * from t1; +insert into t1 select * from t2; +#results of t3 must be > 0.5Mb +insert into t3 select * from t1; +insert into t3 select * from t2; +insert into t3 select * from t1; +disable_result_log; +select * from t11; +select * from t21; +enable_result_log; +show status like "Qcache_total_blocks"; +show status like "Qcache_free_blocks"; +disable_result_log; +insert into t11 values(""); +select * from t3; +enable_result_log; +show status like "Qcache_total_blocks"; +show status like "Qcache_free_blocks"; +flush query cache; +show status like "Qcache_total_blocks"; +show status like "Qcache_free_blocks"; +drop table t1, t2, t3, t11, t21; + +# +# do not use QC if tables locked (BUG#12385) +# +connect (root,localhost,root,,test,$MASTER_MYPORT,master.sock); +connection root; +CREATE TABLE t1 ( a INT NOT NULL PRIMARY KEY AUTO_INCREMENT ) ENGINE = +MyISAM; +LOCK TABLE t1 READ LOCAL; +connect (root2,localhost,root,,test,$MASTER_MYPORT,master.sock); +connection root2; +INSERT INTO t1 VALUES (), (), (); +connection root; +SELECT * FROM t1; +connection root2; +SELECT * FROM t1; +connection root; +SELECT * FROM t1; +drop table t1; + +set GLOBAL query_cache_size=0; diff --git a/mysql-test/t/raid.test b/mysql-test/t/raid.test index 14a55db0c34..3ca5adaaaea 100644 --- a/mysql-test/t/raid.test +++ b/mysql-test/t/raid.test @@ -220,3 +220,5 @@ ALTER TABLE t1 RENAME t2; ALTER TABLE t2 CHANGE COLUMN c c VARCHAR(251) NOT NULL; select count(*) from t2; DROP TABLE t2; + +# End of 4.1 tests diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index 3d2285b1633..12dda022cb9 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -490,6 +490,8 @@ SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 1' OR ARG1 != ' 2'); SELECT count(*) FROM t1 WHERE CLIENT='000' AND (ARG1 != ' 2' OR ARG1 != ' 1'); drop table t1; +# End of 4.1 tests + # # Test for optimization request #10561: to use keys for # NOT IN (c1,...,cn) and NOT BETWEEN c1 AND c2 @@ -553,3 +555,26 @@ SELECT a,b FROM v1 WHERE a < 2 and b=3; DROP VIEW v1; DROP TABLE t1; + +# +# Bug #11853: DELETE statement with a NOT (LIKE/<=>) where condition +# for an indexed attribute +# + +CREATE TABLE t1 (name varchar(15) NOT NULL, KEY idx(name)); +INSERT INTO t1 VALUES ('Betty'), ('Anna'); + +SELECT * FROM t1; +DELETE FROM t1 WHERE name NOT LIKE 'A%a'; +SELECT * FROM t1; + +DROP TABLE t1; + +CREATE TABLE t1 (a int, KEY idx(a)); +INSERT INTO t1 VALUES (NULL), (1), (2), (3); + +SELECT * FROM t1; +DELETE FROM t1 WHERE NOT(a <=> 2); +SELECT * FROM t1; + +DROP TABLE t1; diff --git a/mysql-test/t/rename.test b/mysql-test/t/rename.test index 6fa208f37ec..5caecef176e 100644 --- a/mysql-test/t/rename.test +++ b/mysql-test/t/rename.test @@ -65,3 +65,5 @@ sleep 1; show tables; drop table t2, t4; + +# End of 4.1 tests diff --git a/mysql-test/t/repair.test b/mysql-test/t/repair.test index ef7043febbc..5e39e0b6a50 100644 --- a/mysql-test/t/repair.test +++ b/mysql-test/t/repair.test @@ -33,3 +33,5 @@ system echo 1 > $MYSQL_TEST_DIR/var/master-data/test/t1.MYI ; repair table t1; repair table t1 use_frm; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/replace.test b/mysql-test/t/replace.test index 2b3775f4f67..10703eaafb8 100644 --- a/mysql-test/t/replace.test +++ b/mysql-test/t/replace.test @@ -33,3 +33,5 @@ replace into t1 values (126,"first updated"); replace into t1 values (63,default); select * from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/rollback.test b/mysql-test/t/rollback.test index 3cb1ea3024b..3b8ad901907 100644 --- a/mysql-test/t/rollback.test +++ b/mysql-test/t/rollback.test @@ -21,3 +21,5 @@ select * from t1; select @@warning_count; show warnings; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test index afcaaef6811..6301cc0f584 100644 --- a/mysql-test/t/row.test +++ b/mysql-test/t/row.test @@ -84,3 +84,11 @@ select a, MAX(b), (1, MAX(b)) = (1, 4) from t1 group by a; drop table t1; SELECT ROW(2,10) <=> ROW(3,4); SELECT ROW(NULL,10) <=> ROW(3,NULL); + +# End of 4.1 tests + +# +# Correct NULL handling in row comporison (BUG#12509) +# +SELECT ROW(1,1,1) = ROW(1,1,1) as `1`, ROW(1,1,1) = ROW(1,2,1) as `0`, ROW(1,NULL,1) = ROW(2,2,1) as `0`, ROW(1,NULL,1) = ROW(1,2,2) as `0`, ROW(1,NULL,1) = ROW(1,2,1) as `null` ; +select row(NULL,1)=(2,0); diff --git a/mysql-test/t/rpl000001.test b/mysql-test/t/rpl000001.test index 05107684f1f..3d03823d474 100644 --- a/mysql-test/t/rpl000001.test +++ b/mysql-test/t/rpl000001.test @@ -126,3 +126,5 @@ drop table t1; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl000002.test b/mysql-test/t/rpl000002.test index 4fbb6a595a4..bafd8a30159 100644 --- a/mysql-test/t/rpl000002.test +++ b/mysql-test/t/rpl000002.test @@ -37,3 +37,5 @@ show create table t5; connection master; drop table t2,t3,t5; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl000004.test b/mysql-test/t/rpl000004.test index 8fc2977faab..f2a02bd4dd6 100644 --- a/mysql-test/t/rpl000004.test +++ b/mysql-test/t/rpl000004.test @@ -21,3 +21,5 @@ connection slave; sync_with_master; create table t1(n int); drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl000005.test b/mysql-test/t/rpl000005.test index b94695c72e1..e81ad739402 100644 --- a/mysql-test/t/rpl000005.test +++ b/mysql-test/t/rpl000005.test @@ -20,3 +20,5 @@ drop table t1; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl000006.test b/mysql-test/t/rpl000006.test index 898ef309f50..334ed575835 100644 --- a/mysql-test/t/rpl000006.test +++ b/mysql-test/t/rpl000006.test @@ -43,3 +43,5 @@ drop table t1; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl000008.test b/mysql-test/t/rpl000008.test index ea782b99d28..fe030f90411 100644 --- a/mysql-test/t/rpl000008.test +++ b/mysql-test/t/rpl000008.test @@ -34,3 +34,5 @@ save_master_pos; connection slave; sync_with_master; drop table mysqltest_foo,mysqltest_bar,t1; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl000009.test b/mysql-test/t/rpl000009.test index 59451bc888d..81e9860c186 100644 --- a/mysql-test/t/rpl000009.test +++ b/mysql-test/t/rpl000009.test @@ -167,6 +167,8 @@ drop database mysqltest2; save_master_pos; connection slave; sync_with_master; -# These has to be droped on slave as they are not replicated +# These have to be dropped on slave because they are not replicated drop database mysqltest2; drop database mysqltest3; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl000010.test b/mysql-test/t/rpl000010.test index 0725214694a..261b9148774 100644 --- a/mysql-test/t/rpl000010.test +++ b/mysql-test/t/rpl000010.test @@ -16,3 +16,4 @@ save_master_pos; connection slave; sync_with_master; +# End of 4.1 tests diff --git a/mysql-test/t/rpl000011.test b/mysql-test/t/rpl000011.test index 3b00afe10e4..32f6227f7c5 100644 --- a/mysql-test/t/rpl000011.test +++ b/mysql-test/t/rpl000011.test @@ -13,3 +13,5 @@ select * from t1; connection master; drop table t1; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl000012.test b/mysql-test/t/rpl000012.test index 7f440eaaa13..2c1c65e4202 100644 --- a/mysql-test/t/rpl000012.test +++ b/mysql-test/t/rpl000012.test @@ -41,3 +41,5 @@ drop table if exists t1,t2; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl000013.test b/mysql-test/t/rpl000013.test index 94d5feb3925..eca4803c6bc 100644 --- a/mysql-test/t/rpl000013.test +++ b/mysql-test/t/rpl000013.test @@ -39,3 +39,5 @@ drop table if exists t1,t2; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl000015.test b/mysql-test/t/rpl000015.test index da73c5f4db2..a53049386af 100644 --- a/mysql-test/t/rpl000015.test +++ b/mysql-test/t/rpl000015.test @@ -37,3 +37,5 @@ select * from t1; connection master; drop table t1; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl000017.test b/mysql-test/t/rpl000017.test index 3b39a6b49a6..3b4574e9547 100644 --- a/mysql-test/t/rpl000017.test +++ b/mysql-test/t/rpl000017.test @@ -17,3 +17,5 @@ select * from t1; connection master; drop table t1; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl000018.test b/mysql-test/t/rpl000018.test index fd2be2399a5..bc6d887cc99 100644 --- a/mysql-test/t/rpl000018.test +++ b/mysql-test/t/rpl000018.test @@ -25,3 +25,5 @@ select * from t1; connection master; drop table t1; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_EE_error.test b/mysql-test/t/rpl_EE_error.test index 05c556a6c1b..72df0c20ef8 100644 --- a/mysql-test/t/rpl_EE_error.test +++ b/mysql-test/t/rpl_EE_error.test @@ -28,3 +28,5 @@ drop table t1; save_master_pos; connection slave; wait_for_slave_to_stop; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_alter.test b/mysql-test/t/rpl_alter.test index a913f01cd81..576376a0264 100644 --- a/mysql-test/t/rpl_alter.test +++ b/mysql-test/t/rpl_alter.test @@ -20,3 +20,5 @@ drop database mysqltest; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_chain_temp_table.test b/mysql-test/t/rpl_chain_temp_table.test index 007b018e9d8..96e228a17a1 100644 --- a/mysql-test/t/rpl_chain_temp_table.test +++ b/mysql-test/t/rpl_chain_temp_table.test @@ -97,3 +97,5 @@ sync_with_master; # memory they use is freed (it should) by mysqld before it terminates). # If they wouldn't be cleaned up, you would see some "still reachable" blocks in # Valgrind. + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_change_master.test b/mysql-test/t/rpl_change_master.test index a01039b6572..6c055a81ceb 100644 --- a/mysql-test/t/rpl_change_master.test +++ b/mysql-test/t/rpl_change_master.test @@ -33,3 +33,5 @@ drop table t1; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_charset.test b/mysql-test/t/rpl_charset.test index ee54bc72a65..e5ddf084461 100644 --- a/mysql-test/t/rpl_charset.test +++ b/mysql-test/t/rpl_charset.test @@ -169,3 +169,5 @@ set @p=_latin1 'test'; update t1 set pk='test' where pk=@p; drop table t1; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_commit_after_flush.test b/mysql-test/t/rpl_commit_after_flush.test index 62c89b3aae6..6129e5485a6 100644 --- a/mysql-test/t/rpl_commit_after_flush.test +++ b/mysql-test/t/rpl_commit_after_flush.test @@ -15,3 +15,5 @@ drop table t1; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_create_database.test b/mysql-test/t/rpl_create_database.test index c63b0bc85ef..cfccc4567b5 100644 --- a/mysql-test/t/rpl_create_database.test +++ b/mysql-test/t/rpl_create_database.test @@ -69,3 +69,5 @@ DROP DATABASE IF EXISTS mysqltest_prometheus; DROP DATABASE IF EXISTS mysqltest_sisyfos; DROP DATABASE IF EXISTS mysqltest_bob; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_ddl.test b/mysql-test/t/rpl_ddl.test index d043d40d96e..9521ba3d4c1 100644 --- a/mysql-test/t/rpl_ddl.test +++ b/mysql-test/t/rpl_ddl.test @@ -348,3 +348,5 @@ DROP DATABASE IF EXISTS mysqltest1; DROP DATABASE IF EXISTS mysqltest2; DROP DATABASE IF EXISTS mysqltest3; --enable_warnings + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_deadlock.test b/mysql-test/t/rpl_deadlock.test index fa17cfe0308..d2a8fc0c844 100644 --- a/mysql-test/t/rpl_deadlock.test +++ b/mysql-test/t/rpl_deadlock.test @@ -107,5 +107,7 @@ select * from t2; show slave status; connection master; -drop table t1,t2; +drop table t1,t2,t3,t4; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_delete_all.test b/mysql-test/t/rpl_delete_all.test index ad2ce29c610..e0c0757bbc2 100644 --- a/mysql-test/t/rpl_delete_all.test +++ b/mysql-test/t/rpl_delete_all.test @@ -7,7 +7,7 @@ drop database if exists mysqltest; sync_slave_with_master; # can't read dir --replace_result "Errcode: 1" "Errcode: X" "Errcode: 2" "Errcode: X" \\ / ---error 12 +--error 1049 show tables from mysqltest; connection slave; @@ -39,3 +39,5 @@ select * from t1; connection master; drop table t1; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_do_grant.test b/mysql-test/t/rpl_do_grant.test index 27a22874497..54287a67657 100644 --- a/mysql-test/t/rpl_do_grant.test +++ b/mysql-test/t/rpl_do_grant.test @@ -44,3 +44,5 @@ sync_with_master; # no need to delete manually, as the DELETEs must have done some real job on # master (updated binlog) flush privileges; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_drop.test b/mysql-test/t/rpl_drop.test index 485d5f70e22..ebb33c92a20 100644 --- a/mysql-test/t/rpl_drop.test +++ b/mysql-test/t/rpl_drop.test @@ -10,3 +10,5 @@ drop table t1, t2; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_drop_db.test b/mysql-test/t/rpl_drop_db.test new file mode 100644 index 00000000000..61354198c83 --- /dev/null +++ b/mysql-test/t/rpl_drop_db.test @@ -0,0 +1,55 @@ +# test case for BUG#4680 -- if there are extra files in the db directory +# dropping the db on the master causes replication problems + +-- source include/master-slave.inc +connection master; + +--disable_warnings +drop database if exists mysqltest1; +--enable_warnings +create database mysqltest1; +create table mysqltest1.t1 (n int); +insert into mysqltest1.t1 values (1); +select * from mysqltest1.t1 into outfile 'mysqltest1/f1.txt'; +create table mysqltest1.t2 (n int); +create table mysqltest1.t3 (n int); +--error 1010 +drop database mysqltest1; +use mysqltest1; +show tables; + +# test the branch of the code that deals with the query buffer overflow + +--disable_query_log +let $1=50; +while ($1) +{ + eval create table mysqltest1.mysqltest_long_table_name$1 (n int); + dec $1; +} +--enable_query_log + +--error 1010 +drop database mysqltest1; +use mysqltest1; +show tables; +use test; +create table t1 (n int); +insert into t1 values (1234); +sync_slave_with_master; + +connection slave; +use mysqltest1; +show tables; +use test; +select * from t1; + +connection master; +drop table t1; +sync_slave_with_master; + +#cleanup +connection slave; +stop slave; +system rm -rf var/master-data/mysqltest1; + diff --git a/mysql-test/t/rpl_drop_temp.test b/mysql-test/t/rpl_drop_temp.test index adbe1f07765..55a4e741d7c 100644 --- a/mysql-test/t/rpl_drop_temp.test +++ b/mysql-test/t/rpl_drop_temp.test @@ -14,3 +14,4 @@ show status like 'Slave_open_temp_tables'; connection default; drop database mysqltest; +# End of 4.1 tests diff --git a/mysql-test/t/rpl_empty_master_crash.test b/mysql-test/t/rpl_empty_master_crash.test index 98a630c69ca..5f26bedc9fe 100644 --- a/mysql-test/t/rpl_empty_master_crash.test +++ b/mysql-test/t/rpl_empty_master_crash.test @@ -11,3 +11,5 @@ load table t1 from master; connection slave; --error 1188 load table t1 from master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_error_ignored_table.test b/mysql-test/t/rpl_error_ignored_table.test index 32230903029..a854c3621ab 100644 --- a/mysql-test/t/rpl_error_ignored_table.test +++ b/mysql-test/t/rpl_error_ignored_table.test @@ -55,3 +55,5 @@ connection slave; # SQL slave thread should not have stopped (because table of the killed # query is in the ignore list). sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_failed_optimize.test b/mysql-test/t/rpl_failed_optimize.test index d245d1bacbb..57afaa89e83 100644 --- a/mysql-test/t/rpl_failed_optimize.test +++ b/mysql-test/t/rpl_failed_optimize.test @@ -16,3 +16,5 @@ OPTIMIZE TABLE t1; OPTIMIZE TABLE non_existing; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_failsafe.test b/mysql-test/t/rpl_failsafe.test index ae61b061153..4336d897fc0 100644 --- a/mysql-test/t/rpl_failsafe.test +++ b/mysql-test/t/rpl_failsafe.test @@ -20,3 +20,5 @@ start slave; sync_with_master; show variables like 'rpl_recovery_rank'; show status like 'Rpl_status'; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_flush_log_loop.test b/mysql-test/t/rpl_flush_log_loop.test index 6c95a06ce50..6e45047bd30 100644 --- a/mysql-test/t/rpl_flush_log_loop.test +++ b/mysql-test/t/rpl_flush_log_loop.test @@ -20,3 +20,5 @@ sleep 5; --replace_result $SLAVE_MYPORT SLAVE_PORT --replace_column 1 # 8 # 9 # 23 # 33 # show slave status; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_flush_tables.test b/mysql-test/t/rpl_flush_tables.test index eb16ddcd8de..48fda818890 100644 --- a/mysql-test/t/rpl_flush_tables.test +++ b/mysql-test/t/rpl_flush_tables.test @@ -3,7 +3,10 @@ # RENAME TABLE work with MERGE tables on the slave. # Test of FLUSH NO_WRITE_TO_BINLOG by the way. # -source include/master-slave.inc; +--source include/master-slave.inc +# Skipped on Windows because it can't handle a table underlying an open +# merge table getting renamed. +--source include/not_windows.inc create table t1 (a int); insert into t1 values (10); @@ -35,3 +38,5 @@ sync_with_master; select * from t3; # Note that all this confusion may cause warnings 'table xx is open on rename' # in the .err files; these are not fatal and are not reported by mysql-test-run. + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_free_items.test b/mysql-test/t/rpl_free_items.test index 3228ffd9cde..043e84160b8 100644 --- a/mysql-test/t/rpl_free_items.test +++ b/mysql-test/t/rpl_free_items.test @@ -18,3 +18,5 @@ connection master; drop table t1; drop table t2; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_get_lock.test b/mysql-test/t/rpl_get_lock.test index 847e7145be6..945bd98c993 100644 --- a/mysql-test/t/rpl_get_lock.test +++ b/mysql-test/t/rpl_get_lock.test @@ -39,3 +39,5 @@ drop table t1; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_heap.test b/mysql-test/t/rpl_heap.test index 3452f3990bf..3ee335fe58d 100644 --- a/mysql-test/t/rpl_heap.test +++ b/mysql-test/t/rpl_heap.test @@ -47,3 +47,5 @@ drop table t1; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_ignore_grant.test b/mysql-test/t/rpl_ignore_grant.test index 9b012d08df3..2e6e2ce9a31 100644 --- a/mysql-test/t/rpl_ignore_grant.test +++ b/mysql-test/t/rpl_ignore_grant.test @@ -55,3 +55,5 @@ sync_with_master; delete from mysql.user where user=_binary'rpl_ignore_grant'; delete from mysql.db where user=_binary'rpl_ignore_grant'; flush privileges; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_init_slave.test b/mysql-test/t/rpl_init_slave.test index 3ea04117ced..cefb04a7b75 100644 --- a/mysql-test/t/rpl_init_slave.test +++ b/mysql-test/t/rpl_init_slave.test @@ -24,3 +24,5 @@ save_master_pos; connection slave; sync_with_master; stop slave; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_innodb.test b/mysql-test/t/rpl_innodb.test index b171dced26e..551657fd7e3 100644 --- a/mysql-test/t/rpl_innodb.test +++ b/mysql-test/t/rpl_innodb.test @@ -44,3 +44,5 @@ connection master; DROP TABLE t4; --enable_query_log sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_insert_id.test b/mysql-test/t/rpl_insert_id.test index e2aa5c9b890..49d3a03640c 100644 --- a/mysql-test/t/rpl_insert_id.test +++ b/mysql-test/t/rpl_insert_id.test @@ -74,6 +74,4 @@ SET FOREIGN_KEY_CHECKS=0; INSERT INTO t1 VALUES (1),(1); sync_slave_with_master; - - - +# End of 4.1 tests diff --git a/mysql-test/t/rpl_insert_ignore.test b/mysql-test/t/rpl_insert_ignore.test index 58eaa287817..a6cc69b1df8 100644 --- a/mysql-test/t/rpl_insert_ignore.test +++ b/mysql-test/t/rpl_insert_ignore.test @@ -69,3 +69,5 @@ SELECT * FROM t1 ORDER BY a; connection master; drop table t1, t2; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_insert_select.test b/mysql-test/t/rpl_insert_select.test new file mode 100644 index 00000000000..677be526982 --- /dev/null +++ b/mysql-test/t/rpl_insert_select.test @@ -0,0 +1,19 @@ +# Testcase for BUG#10456 - INSERT INTO ... SELECT violating a primary key +# breaks replication + +-- source include/master-slave.inc +connection master; + +create table t1 (n int not null primary key); +insert into t1 values (1); +create table t2 (n int); +insert into t2 values (1); +insert ignore into t1 select * from t2; +insert into t1 values (2); +sync_slave_with_master; +connection slave; +select * from t1; + +connection master; +drop table t1,t2; +sync_slave_with_master; diff --git a/mysql-test/t/rpl_loaddata.test b/mysql-test/t/rpl_loaddata.test index 1da41bfa913..00121092bbf 100644 --- a/mysql-test/t/rpl_loaddata.test +++ b/mysql-test/t/rpl_loaddata.test @@ -149,3 +149,5 @@ wait_for_slave_to_stop; drop table t2; connection master; drop table t2; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_loaddata_rule_m.test b/mysql-test/t/rpl_loaddata_rule_m.test index 97c984c4369..68024c340a8 100644 --- a/mysql-test/t/rpl_loaddata_rule_m.test +++ b/mysql-test/t/rpl_loaddata_rule_m.test @@ -25,3 +25,5 @@ load data infile '../../std_data/rpl_loaddata.dat' into table test.t1; --replace_column 2 # 5 # show binlog events from 98; drop database mysqltest; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_loaddata_rule_s.test b/mysql-test/t/rpl_loaddata_rule_s.test index 9802c00d35f..98fad3cc06f 100644 --- a/mysql-test/t/rpl_loaddata_rule_s.test +++ b/mysql-test/t/rpl_loaddata_rule_s.test @@ -18,3 +18,5 @@ connection slave; sync_with_master; select count(*) from t1; # check that LOAD was replicated show binlog events from 98; # should be nothing + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_loaddatalocal.test b/mysql-test/t/rpl_loaddatalocal.test index f9325b39af6..0b54de8462e 100644 --- a/mysql-test/t/rpl_loaddatalocal.test +++ b/mysql-test/t/rpl_loaddatalocal.test @@ -35,6 +35,8 @@ save_master_pos; connection slave; sync_with_master; +# End of 4.1 tests + # # Now let us test how well we replicate LOAD DATA LOCAL in situation when # we met duplicates in tables to which we are adding rows. diff --git a/mysql-test/t/rpl_log.test b/mysql-test/t/rpl_log.test index 8cb99d5432e..899f812535a 100644 --- a/mysql-test/t/rpl_log.test +++ b/mysql-test/t/rpl_log.test @@ -108,3 +108,5 @@ show slave status; --error 1220 show binlog events in 'slave-bin.000005' from 4; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_log_pos.test b/mysql-test/t/rpl_log_pos.test index 2a03497846b..979b146bb22 100644 --- a/mysql-test/t/rpl_log_pos.test +++ b/mysql-test/t/rpl_log_pos.test @@ -45,3 +45,5 @@ select * from t1; connection master; drop table t1; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_many_optimize.test b/mysql-test/t/rpl_many_optimize.test index 525e23abe15..91fab0b27a8 100644 --- a/mysql-test/t/rpl_many_optimize.test +++ b/mysql-test/t/rpl_many_optimize.test @@ -18,3 +18,5 @@ enable_query_log; drop table t1; # Bug was that slave segfaulted after ~ a hundred of OPTIMIZE (or ANALYZE) sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_master_pos_wait.test b/mysql-test/t/rpl_master_pos_wait.test index 4d4d51b04ab..893c8746efc 100644 --- a/mysql-test/t/rpl_master_pos_wait.test +++ b/mysql-test/t/rpl_master_pos_wait.test @@ -14,3 +14,5 @@ connection slave1; stop slave sql_thread; connection slave; reap; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_max_relay_size.test b/mysql-test/t/rpl_max_relay_size.test index 963a76fb959..8b54cf5ab7f 100644 --- a/mysql-test/t/rpl_max_relay_size.test +++ b/mysql-test/t/rpl_max_relay_size.test @@ -91,3 +91,5 @@ connection master; # test that the absence of relay logs does not make a master crash flush logs; show master status; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_misc_functions.test b/mysql-test/t/rpl_misc_functions.test index 12eadbb25ed..f20d0aa83e4 100644 --- a/mysql-test/t/rpl_misc_functions.test +++ b/mysql-test/t/rpl_misc_functions.test @@ -28,3 +28,5 @@ load data local infile './var/master-data/test/rpl_misc_functions.outfile' into # compare them with the replica; the SELECT below should return no row select * from t1, t2 where (t1.id=t2.id) and not(t1.i=t2.i and t1.r1=t2.r1 and t1.r2=t2.r2 and t1.p=t2.p); stop slave; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_multi_delete.test b/mysql-test/t/rpl_multi_delete.test index 299cb720b62..2fd7b820b1a 100644 --- a/mysql-test/t/rpl_multi_delete.test +++ b/mysql-test/t/rpl_multi_delete.test @@ -21,3 +21,5 @@ drop table t1,t2; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_multi_delete2.test b/mysql-test/t/rpl_multi_delete2.test index c5128833843..62d95a3a90f 100644 --- a/mysql-test/t/rpl_multi_delete2.test +++ b/mysql-test/t/rpl_multi_delete2.test @@ -21,3 +21,5 @@ select * from t2; connection master; drop table t1,t2; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_multi_query.test b/mysql-test/t/rpl_multi_query.test index 2ddd61ce7ba..fa94928e13a 100644 --- a/mysql-test/t/rpl_multi_query.test +++ b/mysql-test/t/rpl_multi_query.test @@ -27,3 +27,5 @@ connection master; show binlog events from 98; drop database mysqltest; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_multi_update.test b/mysql-test/t/rpl_multi_update.test index 88994aa66bd..dd75edb3055 100644 --- a/mysql-test/t/rpl_multi_update.test +++ b/mysql-test/t/rpl_multi_update.test @@ -22,3 +22,5 @@ UPDATE t1, t2 SET t1.b = t2.b WHERE t1.a = t2.a; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_multi_update2.test b/mysql-test/t/rpl_multi_update2.test index bba7700a88e..f92c5504f43 100644 --- a/mysql-test/t/rpl_multi_update2.test +++ b/mysql-test/t/rpl_multi_update2.test @@ -31,3 +31,5 @@ connection slave; sync_with_master; SELECT * FROM t1 ORDER BY a; SELECT * FROM t2 ORDER BY a; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_multi_update3.test b/mysql-test/t/rpl_multi_update3.test index 80b0603eb60..64e46882c16 100644 --- a/mysql-test/t/rpl_multi_update3.test +++ b/mysql-test/t/rpl_multi_update3.test @@ -157,3 +157,5 @@ SELECT * FROM t1; connection master; DROP TABLE t1, t2, t3; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_mystery22.test b/mysql-test/t/rpl_mystery22.test index d49f1a210f4..f190968a03c 100644 --- a/mysql-test/t/rpl_mystery22.test +++ b/mysql-test/t/rpl_mystery22.test @@ -37,3 +37,4 @@ connection master; drop table t1; sync_slave_with_master; +# End of 4.1 tests diff --git a/mysql-test/t/rpl_openssl.test b/mysql-test/t/rpl_openssl.test index 779ec4e84bf..3c151721d8e 100644 --- a/mysql-test/t/rpl_openssl.test +++ b/mysql-test/t/rpl_openssl.test @@ -7,7 +7,7 @@ source include/master-slave.inc; # creating replication user for whom ssl auth is required # preparing playground connection master; -grant replication slave on *.* to replssl@'%' require ssl; +grant replication slave on *.* to replssl@localhost require ssl; create table t1 (t int); save_master_pos; @@ -60,3 +60,5 @@ sync_with_master; --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR $MASTER_MYPORT MASTER_MYPORT --replace_column 1 # 8 # 9 # 23 # 33 # show slave status; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_optimize.test b/mysql-test/t/rpl_optimize.test index 9f02b715885..6858f52abab 100644 --- a/mysql-test/t/rpl_optimize.test +++ b/mysql-test/t/rpl_optimize.test @@ -41,3 +41,5 @@ sync_with_master; # If the machine is so fast that slave syncs before OPTIMIZE # starts, this test wil demonstrate nothing but will pass. + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_ps.test b/mysql-test/t/rpl_ps.test index 79f48381a4f..adf39b1e4ab 100644 --- a/mysql-test/t/rpl_ps.test +++ b/mysql-test/t/rpl_ps.test @@ -41,3 +41,4 @@ connection slave; sync_with_master; stop slave; +# End of 4.1 tests diff --git a/mysql-test/t/rpl_redirect.test b/mysql-test/t/rpl_redirect.test index d505351cc69..beb18348b40 100644 --- a/mysql-test/t/rpl_redirect.test +++ b/mysql-test/t/rpl_redirect.test @@ -41,3 +41,5 @@ select * from t1; drop table t1; connection master; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_relayrotate.test b/mysql-test/t/rpl_relayrotate.test index 2fde590356a..b66cf7a6e0d 100644 --- a/mysql-test/t/rpl_relayrotate.test +++ b/mysql-test/t/rpl_relayrotate.test @@ -75,3 +75,5 @@ drop table t1; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_relayspace.test b/mysql-test/t/rpl_relayspace.test index bb82781b511..70315c14f34 100644 --- a/mysql-test/t/rpl_relayspace.test +++ b/mysql-test/t/rpl_relayspace.test @@ -30,3 +30,5 @@ start slave; # also the slave will probably not cooperate to shutdown # (as 2 threads are locked) select master_pos_wait('master-bin.001',200,6)=-1; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_replicate_do.test b/mysql-test/t/rpl_replicate_do.test index 108dd54ce0a..ff5af71ea5b 100644 --- a/mysql-test/t/rpl_replicate_do.test +++ b/mysql-test/t/rpl_replicate_do.test @@ -36,3 +36,4 @@ sync_with_master; --replace_column 1 # 8 # 9 # 23 # 33 # show slave status; +# End of 4.1 tests diff --git a/mysql-test/t/rpl_reset_slave.test b/mysql-test/t/rpl_reset_slave.test index 1b27e059f92..aeac1b50110 100644 --- a/mysql-test/t/rpl_reset_slave.test +++ b/mysql-test/t/rpl_reset_slave.test @@ -46,3 +46,5 @@ reset slave; start slave; sync_with_master; show status like 'slave_open_temp_tables'; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_rewrite_db.test b/mysql-test/t/rpl_rewrite_db.test index b77d57294fa..1e8e5a992d8 100644 --- a/mysql-test/t/rpl_rewrite_db.test +++ b/mysql-test/t/rpl_rewrite_db.test @@ -78,3 +78,4 @@ drop database rewrite; connection master; drop table t1; +# End of 4.1 tests diff --git a/mysql-test/t/rpl_rotate_logs.test b/mysql-test/t/rpl_rotate_logs.test index 5ab47c635e0..b125408d89e 100644 --- a/mysql-test/t/rpl_rotate_logs.test +++ b/mysql-test/t/rpl_rotate_logs.test @@ -153,3 +153,4 @@ connection master; drop table if exists t1,t2,t3,t4; sync_slave_with_master; +# End of 4.1 tests diff --git a/mysql-test/t/rpl_server_id1.test b/mysql-test/t/rpl_server_id1.test index 4d504325294..3583f05284c 100644 --- a/mysql-test/t/rpl_server_id1.test +++ b/mysql-test/t/rpl_server_id1.test @@ -22,3 +22,5 @@ insert into t1 values (1); sleep 2; # enough time for the event to be replicated (it should not) show status like "slave_running"; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_server_id2.test b/mysql-test/t/rpl_server_id2.test index 7bbac358ada..0f2eb560d18 100644 --- a/mysql-test/t/rpl_server_id2.test +++ b/mysql-test/t/rpl_server_id2.test @@ -22,3 +22,5 @@ select * from t1; # check that indeed 2 were inserted # (not critical). stop slave; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_set_charset.test b/mysql-test/t/rpl_set_charset.test index 269074b1c42..c70eb2681f5 100644 --- a/mysql-test/t/rpl_set_charset.test +++ b/mysql-test/t/rpl_set_charset.test @@ -31,3 +31,5 @@ drop database mysqltest1; save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_skip_error.test b/mysql-test/t/rpl_skip_error.test index 86c89c70314..e0e569a65b7 100644 --- a/mysql-test/t/rpl_skip_error.test +++ b/mysql-test/t/rpl_skip_error.test @@ -12,3 +12,5 @@ save_master_pos; connection slave; sync_with_master; select * from t1; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_slave_status.test b/mysql-test/t/rpl_slave_status.test new file mode 100644 index 00000000000..7e16097edd0 --- /dev/null +++ b/mysql-test/t/rpl_slave_status.test @@ -0,0 +1,30 @@ +# Test case for BUG #10780 +source include/master-slave.inc +connection master; +grant replication slave on *.* to rpl@127.0.0.1 identified by 'rpl'; +connection slave; +stop slave; +change master to master_user='rpl',master_password='rpl'; +start slave; +connection master; +--disable_warnings +drop table if exists t1; +--enable_warning +create table t1 (n int); +insert into t1 values (1); +save_master_pos; +connection slave; +sync_with_master; +select * from t1; +connection master; +delete from mysql.user where user='rpl'; +flush privileges; +connection slave; +stop slave; +start slave; +--replace_result $MASTER_MYPORT MASTER_MYPORT +--replace_column 7 # 8 # 9 # 22 # 23 # +--vertical_results +show slave status; + +# end of 4.1 tests diff --git a/mysql-test/t/rpl_sp.test b/mysql-test/t/rpl_sp.test index 5557f7675d5..fa44b68bd8c 100644 --- a/mysql-test/t/rpl_sp.test +++ b/mysql-test/t/rpl_sp.test @@ -83,7 +83,7 @@ create procedure foo2() call foo2(); # verify CALL is not in binlog --replace_column 2 # 5 # -show binlog events from 605; +show binlog events from 518; --error 1418 alter procedure foo2 contains sql; @@ -147,7 +147,7 @@ show warnings; # Check that only successful CALLs are in binlog --replace_column 2 # 5 # -show binlog events from 841; +show binlog events from 990; # Note that half-failed CALLs are not in binlog, which is a known # bug. If we compare t2 on master and slave we see they differ: @@ -249,7 +249,7 @@ select * from t1; connection master; delete from t1; -drop trigger t1.trg; +drop trigger trg; insert into t1 values (1); select * from t1; --replace_column 2 # 5 # diff --git a/mysql-test/t/rpl_sp_effects-master.opt b/mysql-test/t/rpl_sp_effects-master.opt new file mode 100644 index 00000000000..61dd7a6ad0e --- /dev/null +++ b/mysql-test/t/rpl_sp_effects-master.opt @@ -0,0 +1 @@ +--log_bin_trust_routine_creators=1 diff --git a/mysql-test/t/rpl_sp_effects-slave.opt b/mysql-test/t/rpl_sp_effects-slave.opt new file mode 100644 index 00000000000..61dd7a6ad0e --- /dev/null +++ b/mysql-test/t/rpl_sp_effects-slave.opt @@ -0,0 +1 @@ +--log_bin_trust_routine_creators=1 diff --git a/mysql-test/t/rpl_sp_effects.test b/mysql-test/t/rpl_sp_effects.test new file mode 100644 index 00000000000..f8e83eabe90 --- /dev/null +++ b/mysql-test/t/rpl_sp_effects.test @@ -0,0 +1,155 @@ +# Test of replication of stored procedures (WL#2146 for MySQL 5.0) + +source include/master-slave.inc; + +# **************************************************************** +connection master; + +# cleanup +--disable_warnings +drop procedure if exists p1; +drop procedure if exists p2; +drop function if exists f1; +drop table if exists t1,t2; +drop view if exists v1; +--enable_warnings +create table t1 (a int); + +# 1. Test simple variables use. +delimiter //; +create procedure p1() +begin + declare spv int default 0; + while spv < 5 do + insert into t1 values(spv+1); + set spv=spv+1; + end while; +end// +delimiter ;// + +call p1(); + +sync_slave_with_master; +connection slave; +select * from t1; +connection master; +delete from t1; + +# 2. Test SP variable name +delimiter //; +create procedure p2() +begin + declare a int default 4; + create table t2 as select a; +end// +delimiter ;// + +call p2(); +select * from t2; +sync_slave_with_master; +connection slave; +select * from t2; + +connection master; +drop procedure p1; +drop procedure p2; +drop table t2; + +# 3. Test FUNCTIONs in various places + +delimiter //; +create function f1(x int) returns int +begin + insert into t1 values(x); + return x+1; +end// + +create procedure p1(a int, b int) +begin + declare v int default f1(5); + if (f1(6)) then + select 'yes'; + end if; + set v = f1(7); + while f1(8) < 1 do + select 'this cant be'; + end while; + +end// +delimiter ;// + +call p1(f1(1), f1(2)); +select * from t1; + +create table t2(a int); +insert into t2 values (10),(11); +select a,f1(a) from t2; + +# This shouldn't put separate 'call f1(3)' into binlog: +insert into t2 select f1(3); +select 'master:',a from t1; + +sync_slave_with_master; +connection slave; +select 'slave:',a from t1; + +connection master; +drop procedure p1; +delete from t1; +delete from t2; + +# 4. VIEWs +delete from t1; +insert into t2 values(1),(2); +create view v1 as select f1(a) from t2; +select * from v1; +select 'master:',a from t1; + +sync_slave_with_master; +connection slave; +select 'slave:',a from t1; + +connection master; +drop view v1; +delete from t1; + +# 5. Prepared statements. +prepare s1 from 'select f1(?)'; +set @xx=123; +execute s1 using @xx; +select 'master:',a from t1; + +sync_slave_with_master; +connection slave; +select 'slave:',a from t1; + +connection master; +delete from t1; + +# 5. Cursors. +# t2 has (1),(2); +delimiter //; +create procedure p1(spv int) +begin + declare c cursor for select f1(spv) from t2; + while (spv > 2) do + open c; + fetch c into spv; + close c; + set spv= spv - 10; + end while; +end// +delimiter ;// + +call p1(15); +select 'master:',a from t1; +sync_slave_with_master; +connection slave; +select 'slave:',a from t1; + +connection master; +drop procedure p1; +drop function f1; +drop table t1,t2; + +sync_slave_with_master; diff --git a/mysql-test/t/rpl_sporadic_master.test b/mysql-test/t/rpl_sporadic_master.test index b24901c62a9..26b633a1c4f 100644 --- a/mysql-test/t/rpl_sporadic_master.test +++ b/mysql-test/t/rpl_sporadic_master.test @@ -22,3 +22,5 @@ select * from t1; connection master; drop table t1,t2; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_start_stop_slave.test b/mysql-test/t/rpl_start_stop_slave.test index 903ff204194..19988cf902a 100644 --- a/mysql-test/t/rpl_start_stop_slave.test +++ b/mysql-test/t/rpl_start_stop_slave.test @@ -32,3 +32,5 @@ save_master_pos; connection slave; sync_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_temporary.test b/mysql-test/t/rpl_temporary.test index e65469de7e0..fcb2391a9d8 100644 --- a/mysql-test/t/rpl_temporary.test +++ b/mysql-test/t/rpl_temporary.test @@ -130,3 +130,5 @@ create temporary table t3 (f int); sync_with_master; # The server will now close done + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_timezone.test b/mysql-test/t/rpl_timezone.test index a7547f7afc6..2e9883141d8 100644 --- a/mysql-test/t/rpl_timezone.test +++ b/mysql-test/t/rpl_timezone.test @@ -122,3 +122,5 @@ select * from t2; connection master; drop table t1, t2; sync_slave_with_master; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_trigger.test b/mysql-test/t/rpl_trigger.test new file mode 100644 index 00000000000..715222f0314 --- /dev/null +++ b/mysql-test/t/rpl_trigger.test @@ -0,0 +1,118 @@ +# +# Test of triggers with replication +# + +source include/master-slave.inc; + +# +# #12482: Triggers has side effects with auto_increment values +# + +create table t1 (a int auto_increment, primary key (a), b int, rand_value double not null); +create table t2 (a int auto_increment, primary key (a), b int); +create table t3 (a int auto_increment, primary key (a), name varchar(64) not null, old_a int, old_b int, rand_value double not null); + +delimiter |; +create trigger t1 before insert on t1 for each row +begin + insert into t3 values (NULL, "t1", new.a, new.b, rand()); +end| + +create trigger t2 after insert on t2 for each row +begin + insert into t3 values (NULL, "t2", new.a, new.b, rand()); +end| +delimiter ;| + +insert into t3 values(100,"log",0,0,0); + +# Ensure we always have same random numbers +SET @@RAND_SEED1=658490765, @@RAND_SEED2=635893186; + +# Emulate that we have rows 2-9 deleted on the slave +insert into t1 values(1,1,rand()),(NULL,2,rand()); +insert into t2 (b) values(last_insert_id()); +insert into t2 values(3,0),(NULL,0); +insert into t2 values(NULL,0),(500,0); + +select a,b, truncate(rand_value,4) from t1; +select * from t2; +select a,name, old_a, old_b, truncate(rand_value,4) from t3; +save_master_pos; +connection slave; +sync_with_master; +--disable_query_log +select "--- On slave --" as ""; +--enable_query_log +select a,b, truncate(rand_value,4) from t1; +select * from t2; +select a,name, old_a, old_b, truncate(rand_value,4) from t3; +connection master; +drop table t1,t2,t3; + +# +# #12480: NOW() is not constant in a trigger +# #12481: Using NOW() in a stored function breaks statement based replication +# + +# Start by getting a lock on 'bug12480' to be able to use get_lock() as sleep() +connect (con2,localhost,root,,); +connection con2; +select get_lock("bug12480",2); +connection default; + +create table t1 (a datetime,b datetime, c datetime); +--ignore_warnings +drop function if exists bug12480; +--enable_warnings + +delimiter |; + +create function bug12480() returns datetime +begin + set @a=get_lock("bug12480",2); + return now(); +end| + +create trigger t1_first before insert on t1 +for each row begin + set @a=get_lock("bug12480",2); + set new.b= now(); + set new.c= bug12480(); +end +| + +delimiter ;| +insert into t1 set a = now(); +select a=b && a=c from t1; +let $time=`select a from t1`; + +save_master_pos; +connection slave; +sync_with_master; +--disable_query_log +select "--- On slave --" as ""; +--enable_query_log +select a=b && a=c from t1; +--disable_query_log +eval select a='$time' as 'test' from t1; +--enable_query_log + +connection master; +disconnect con2; + +truncate table t1; +drop trigger t1_first; + +insert into t1 values ("2003-03-03","2003-03-03","2003-03-03"),(bug12480(),bug12480(),bug12480()),(now(),now(),now()); +select a=b && a=c from t1; + +drop function bug12480; +drop table t1; + +# +# End of test +# +save_master_pos; +connection slave; +sync_with_master; diff --git a/mysql-test/t/rpl_until.test b/mysql-test/t/rpl_until.test index c1aee2cb1db..5bc7a040b1b 100644 --- a/mysql-test/t/rpl_until.test +++ b/mysql-test/t/rpl_until.test @@ -83,3 +83,5 @@ start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561; # Warning should be given for second command start slave sql_thread; start slave until master_log_file='master-bin.000001', master_log_pos=776; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_user_variables.test b/mysql-test/t/rpl_user_variables.test index 711d83219a6..e8985397703 100644 --- a/mysql-test/t/rpl_user_variables.test +++ b/mysql-test/t/rpl_user_variables.test @@ -54,3 +54,5 @@ save_master_pos; connection slave; sync_with_master; stop slave; + +# End of 4.1 tests diff --git a/mysql-test/t/rpl_variables.test b/mysql-test/t/rpl_variables.test index ea40181ecd3..57ae2b9c3c4 100644 --- a/mysql-test/t/rpl_variables.test +++ b/mysql-test/t/rpl_variables.test @@ -3,6 +3,8 @@ source include/master-slave.inc; set global slave_net_timeout=100; set global sql_slave_skip_counter=100; +# End of 4.1 tests + # BUG #7800: Add various-slave related variables to SHOW VARIABLES show variables like 'slave_compressed_protocol'; --replace_column 2 SLAVE_LOAD_TMPDIR diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 2e4bb3e13ad..fad01ac9acf 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1542,6 +1542,11 @@ select t2.companynr,companyname from t2 left join t4 using (companynr) where t4. select count(*) from t2 left join t4 using (companynr) where t4.companynr is not null; explain select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr is null; + +select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +select count(*) from t2 left join t4 using (companynr) where companynr is not null; +explain select companynr,companyname from t2 left join t4 using (companynr) where companynr is null; +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr is null; delete from t2 where fld1=999999; # @@ -1550,11 +1555,19 @@ delete from t2 where fld1=999999; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 and t4.companynr > 0; + +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0; +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0; +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 and companynr > 0; # Following can't be optimized explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr is null; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where t2.companynr > 0 or t2.companynr < 0 or t4.companynr > 0; explain select t2.companynr,companyname from t4 left join t2 using (companynr) where ifnull(t2.companynr,1)>0; +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr is null; +explain select companynr,companyname from t4 left join t2 using (companynr) where companynr > 0 or companynr < 0 or companynr > 0; +explain select companynr,companyname from t4 left join t2 using (companynr) where ifnull(companynr,1)>0; + # # Joins with forms. # @@ -2080,6 +2093,96 @@ select * from t3 left join t1 on t3.id = t1.uid, t2 where t2.ident in (0, t1.gid drop table t1,t2,t3; +# Test for BUG#11700 +CREATE TABLE t1 ( + acct_id int(11) NOT NULL default '0', + profile_id smallint(6) default NULL, + UNIQUE KEY t1$acct_id (acct_id), + KEY t1$profile_id (profile_id) +); +INSERT INTO t1 VALUES (132,17),(133,18); + +CREATE TABLE t2 ( + profile_id smallint(6) default NULL, + queue_id int(11) default NULL, + seq int(11) default NULL, + KEY t2$queue_id (queue_id) +); +INSERT INTO t2 VALUES (17,31,4),(17,30,3),(17,36,2),(17,37,1); + +CREATE TABLE t3 ( + id int(11) NOT NULL default '0', + qtype int(11) default NULL, + seq int(11) default NULL, + warn_lvl int(11) default NULL, + crit_lvl int(11) default NULL, + rr1 tinyint(4) NOT NULL default '0', + rr2 int(11) default NULL, + default_queue tinyint(4) NOT NULL default '0', + KEY t3$qtype (qtype), + KEY t3$id (id) +); + +INSERT INTO t3 VALUES (30,1,29,NULL,NULL,0,NULL,0),(31,1,28,NULL,NULL,0,NULL,0), + (36,1,34,NULL,NULL,0,NULL,0),(37,1,35,NULL,NULL,0,121,0); + +SELECT COUNT(*) FROM t1 a STRAIGHT_JOIN t2 pq STRAIGHT_JOIN t3 q +WHERE + (pq.profile_id = a.profile_id) AND (a.acct_id = 132) AND + (pq.queue_id = q.id) AND (q.rr1 <> 1); + +drop table t1,t2,t3; + +# +# Bug #11482 Wrongly applied optimization was erroneously rejecting valid +# rows +create table t1 (f1 int); +insert into t1 values (1),(NULL); +create table t2 (f2 int, f3 int, f4 int); +create index idx1 on t2 (f4); +insert into t2 values (1,2,3),(2,4,6); +select A.f2 from t1 left join t2 A on A.f2 = f1 where A.f3=(select min(f3) +from t2 C where A.f4 = C.f4) or A.f3 IS NULL; +drop table t1,t2; + +# +# Bug #11521 Negative integer keys incorrectly substituted for 0 during +# range analysis. + +create table t2 (a tinyint unsigned); +create index t2i on t2(a); +insert into t2 values (0), (254), (255); +explain select * from t2 where a > -1; +select * from t2 where a > -1; +drop table t2; + +# +# Bug #11745: SELECT ... FROM DUAL with WHERE condition +# + +CREATE TABLE t1 (a int, b int, c int); +INSERT INTO t1 + SELECT 50, 3, 3 FROM DUAL + WHERE NOT EXISTS + (SELECT * FROM t1 WHERE a = 50 AND b = 3); +SELECT * FROM t1; +INSERT INTO t1 + SELECT 50, 3, 3 FROM DUAL + WHERE NOT EXISTS + (SELECT * FROM t1 WHERE a = 50 AND b = 3); +select found_rows(); +SELECT * FROM t1; +select count(*) from t1; +select found_rows(); +select count(*) from t1 limit 2,3; +select found_rows(); +select SQL_CALC_FOUND_ROWS count(*) from t1 limit 2,3; +select found_rows(); + +DROP TABLE t1; + +# End of 4.1 tests + # # Test case for bug 7098: substitution of a constant for a string field # @@ -2152,10 +2255,8 @@ INSERT INTO t1 VALUES SELECT K2C4, K4N4, F2I4 FROM t1 WHERE K2C4 = 'WART' AND (F2I4 = 2 AND K2C4 = 'WART' OR (F2I4 = 2 OR K4N4 = '0200')); - SELECT K2C4, K4N4, F2I4 FROM t1 WHERE K2C4 = 'WART' AND (K2C4 = 'WART' OR K4N4 = '0200'); - DROP TABLE t1; # @@ -2173,36 +2274,6 @@ EXPLAIN SELECT * FROM t1 LEFT JOIN t2 FORCE INDEX (a) ON t1.a=t2.a; DROP TABLE t1, t2; - -# -# Test case for bug 7098: substitution of a constant for a string field -# - -CREATE TABLE t1 ( city char(30) ); -INSERT INTO t1 VALUES ('London'); -INSERT INTO t1 VALUES ('Paris'); - -SELECT * FROM t1 WHERE city='London'; -SELECT * FROM t1 WHERE city='london'; -EXPLAIN SELECT * FROM t1 WHERE city='London' AND city='london'; -SELECT * FROM t1 WHERE city='London' AND city='london'; -EXPLAIN SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; -SELECT * FROM t1 WHERE city LIKE '%london%' AND city='London'; - -DROP TABLE t1; - -# -# Bug#7425 inconsistent sort order on unsigned columns result of substraction -# - -create table t1 (a int(11) unsigned, b int(11) unsigned); -insert into t1 values (1,0), (1,1), (1,2); -select a-b from t1 order by 1; -select a-b , (a-b < 0) from t1 order by 1; -select a-b as d, (a-b >= 0), b from t1 group by b having d >= 0; -select cast((a - b) as unsigned) from t1 order by 1; -drop table t1; - # # Bug#8670 # @@ -2290,3 +2361,107 @@ DROP TABLE t1,t2; # select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; + +# +# Bug #11398 Bug in field_conv() results in wrong result of join with index +# +create table t1 (f1 varchar(6) default NULL, f2 int(6) primary key not null); +create table t2 (f3 varchar(5) not null, f4 varchar(5) not null, UNIQUE KEY UKEY (f3,f4)); +insert into t1 values (" 2", 2); +insert into t2 values (" 2", " one "),(" 2", " two "); +select * from t1 left join t2 on f1 = f3; +drop table t1,t2; + +# +# Bug #6558 Views: CREATE VIEW fails with JOIN ... USING +# + +create table t1 (empnum smallint, grp int); +create table t2 (empnum int, name char(5)); +insert into t1 values(1,1); +insert into t2 values(1,'bob'); +create view v1 as select * from t2 inner join t1 using (empnum); +select * from v1; +drop table t1,t2; +drop view v1; + +# +# Bug #10646 Columns included in the join between two tables are ambigious +# in the select +# + +create table t1 (pk int primary key, b int); +create table t2 (pk int primary key, c int); +select pk from t1 inner join t2 using (pk); +drop table t1,t2; + +# +# Bug #10972 Natural join of view and underlying table gives wrong result +# + +create table t1 (s1 int, s2 char(5), s3 decimal(10)); +create view v1 as select s1, s2, 'x' as s3 from t1; +select * from t1 natural join v1; +insert into t1 values (1,'x',5); +select * from t1 natural join v1; +drop table t1; +drop view v1; + +# +# Bug #6276 A SELECT that does a NATURAL OUTER JOIN without common +# columns crashes server because of empty ON condition +# + +create table t1(a1 int); +create table t2(a2 int); +insert into t1 values(1),(2); +insert into t2 values(1),(2); +create view v2 (c) as select a1 from t1; + +select * from t1 natural left join t2; +select * from t1 natural right join t2; + +select * from v2 natural left join t2; +select * from v2 natural right join t2; + +drop table t1, t2; +drop view v2; + + +# +# Bug #4789 Incosistent results of more than 2-way natural joins due to +# incorrect transformation to join ... on. +# + +create table t1 (a int(10), t1_val int(10)); +create table t2 (b int(10), t2_val int(10)); +create table t3 (a int(10), b int(10)); +insert into t1 values (1,1),(2,2); +insert into t2 values (1,1),(2,2),(3,3); +insert into t3 values (1,1),(2,1),(3,1),(4,1); +# the following two queries must return the same result +select * from t1 natural join t2 natural join t3; +select * from t1 natural join t3 natural join t2; +drop table t1, t2, t3; + + +# +# Bug #12841: Server crash on DO IFNULL(NULL,NULL) +# +# (testing returning of int, decimal, real, string) +DO IFNULL(NULL, NULL); +SELECT CAST(IFNULL(NULL, NULL) AS DECIMAL); +SELECT ABS(IFNULL(NULL, NULL)); +SELECT IFNULL(NULL, NULL); + +# +# Bug #6495 Illogical requirement for column qualification in NATURAL join +# + +create table t1 (a char(1)); +create table t2 (a char(1)); +insert into t1 values ('a'),('b'),('c'); +insert into t2 values ('b'),('c'),('d'); +select a from t1 natural join t2; +select * from t1 natural join t2 where a = 'b'; +drop table t1, t2; diff --git a/mysql-test/t/select_found.test b/mysql-test/t/select_found.test index 91879015b51..e4bc54a5538 100644 --- a/mysql-test/t/select_found.test +++ b/mysql-test/t/select_found.test @@ -191,3 +191,5 @@ INSERT INTO t1 VALUES (1,2), (1,3), (1,4), (1,5); SELECT SQL_CALC_FOUND_ROWS DISTINCT 'a' FROM t1 GROUP BY b LIMIT 2; SELECT FOUND_ROWS(); DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/select_safe.test b/mysql-test/t/select_safe.test index 5b2dfb00bb7..481779e76d7 100644 --- a/mysql-test/t/select_safe.test +++ b/mysql-test/t/select_safe.test @@ -56,7 +56,6 @@ SELECT * from t1; # # Test MAX_SEEKS_FOR_KEY # -SELECT @@MAX_SEEKS_FOR_KEY; analyze table t1; insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"); explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b; @@ -79,7 +78,7 @@ select * from (select * from t1) x; set local max_join_size=1; --error 1104 -select * from (select * from t1 a, t1 b) x; +select * from (select a.a as aa, b.a as ba from t1 a, t1 b) x; set local max_join_size=1; --error 1104 @@ -87,3 +86,5 @@ select * from (select 1 union select 2 union select 3) x; drop table t1; SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT; + +# End of 4.1 tests diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index d591f90dd65..b9fc991dc80 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -385,3 +385,28 @@ create table t1 ( ); SHOW CREATE TABLE t1; DROP TABLE t1; + +# End of 4.1 tests +# +# BUG 12183 - SHOW OPEN TABLES behavior doesn't match grammar +# First we close all open tables with FLUSH tables and then we open some. +CREATE TABLE txt1(a int); +CREATE TABLE tyt2(a int); +CREATE TABLE urkunde(a int); +FLUSH TABLES; +SELECT 1 FROM mysql.db, mysql.proc, mysql.user, mysql.time_zone, mysql.time_zone_name, txt1, tyt2, urkunde LIMIT 0; +SHOW OPEN TABLES; +SHOW OPEN TABLES FROM mysql; +SHOW OPEN TABLES FROM mysql LIKE 'u%'; +SHOW OPEN TABLES LIKE 't%'; +SHOW OPEN TABLES LIKE '%o%'; +FLUSH TABLES; +SHOW OPEN TABLES; +DROP TABLE txt1; +DROP TABLE tyt2; +DROP TABLE urkunde; +# +# BUG #12591 (SHOW TABLES FROM dbname produces wrong error message) +# +--error 1049 +SHOW TABLES FROM non_existing_database; diff --git a/mysql-test/t/skip_name_resolve.test b/mysql-test/t/skip_name_resolve.test index b669579acbf..02339ca14c5 100644 --- a/mysql-test/t/skip_name_resolve.test +++ b/mysql-test/t/skip_name_resolve.test @@ -6,3 +6,5 @@ GRANT ALL ON test.* TO mysqltest_1@'127.0.0.1/255.255.255.255'; SHOW GRANTS FOR mysqltest_1@'127.0.0.1/255.255.255.255'; REVOKE ALL ON test.* FROM mysqltest_1@'127.0.0.1/255.255.255.255'; DROP USER mysqltest_1@'127.0.0.1/255.255.255.255'; + +# End of 4.1 tests diff --git a/mysql-test/t/sp-big.test b/mysql-test/t/sp-big.test new file mode 100644 index 00000000000..769d77dbef9 --- /dev/null +++ b/mysql-test/t/sp-big.test @@ -0,0 +1,33 @@ +# +# Bug #11602: SP with very large body not handled well +# + +--disable_warnings +drop procedure if exists test.longprocedure; +drop table if exists t1; +--enable_warnings + +create table t1 (a int); +insert into t1 values (1),(2),(3); + +let $body=`select repeat('select count(*) into out1 from t1;\n', 3072)`; + +delimiter //; +--disable_query_log +eval select length('$body') as length// +eval create procedure test.longprocedure (out out1 int) deterministic +begin + $body +end// +--enable_query_log + +delimiter ;// + +# this is larger than the length above, because it includes the 'begin' and +# 'end' bits and some whitespace +select length(routine_definition) from information_schema.routines where routine_schema = 'test' and routine_name = 'longprocedure'; + +call test.longprocedure(@value); select @value; + +drop procedure test.longprocedure; +drop table t1; diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index a61c082fb30..5921d59b284 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -334,7 +334,7 @@ begin end| # USE is not allowed ---error 1336 +--error ER_SP_BADSTATEMENT create procedure u() use sptmp| @@ -387,6 +387,58 @@ drop procedure p| # +# Let us test that we can access mysql.proc table for routines +# definitions lookup without locking it explicitly. +# +create procedure p() begin end| +lock table t1 read| +# This should succeed +call p()| +unlock tables| +drop procedure p| +# Let us check restrictions which this ability puts on mysql.proc locking. +--error ER_WRONG_LOCK_OF_SYSTEM_TABLE +lock tables t1 read, mysql.proc write| +--error ER_WRONG_LOCK_OF_SYSTEM_TABLE +lock tables mysql.proc write, mysql.user write| +# Locking for read should be OK +lock tables t1 read, mysql.proc read| +unlock tables| +# You also should be able lock only mysql.proc for write +lock tables mysql.proc write| +unlock tables| + + +# +# Check that in functions we don't allow to update tables which +# are used by statements which invoke these functions. +# +--disable_warnings +drop function if exists f1| +--enable_warnings +create function f1(i int) returns int +begin + insert into t1 (val) values (i); + return 0; +end| +--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG +select val, f1(val) from t1| +# Table alias should not matter +--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG +select val, f1(val) from t1 as tab| +select * from t1| +--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG +update t1 set val= f1(val)| +select * from t1| +# But this should be OK +select f1(17)| +select * from t1| +# Cleanup +delete from t1 where val= 17| +drop function f1| + + +# # BUG#1965 # create procedure bug1965() @@ -676,9 +728,7 @@ create procedure bug6600() # BUG#9566: explicit LOCK TABLE and store procedures result in illegal state # # We should not think that mysql.proc table does not exist if we are unable -# to open it under LOCK TABLE or in prelocked mode. Probably this test -# should be removed when Monty will allow access to mysql.proc without -# locking it. +# to open it under LOCK TABLE or in prelocked mode. # --disable_warnings drop procedure if exists bug9566| @@ -688,9 +738,11 @@ begin select * from t1; end| lock table t1 read| -# This should fail because we forgot to lock mysql.proc table explicitly +# This should fail since we forgot to lock mysql.proc for writing +# explicitly, and we can't open mysql.proc for _writing_ if there +# are locked tables. --error 1100 -call bug9566()| +alter procedure bug9566 comment 'Some comment'| unlock tables| # This should succeed drop procedure bug9566| @@ -788,19 +840,19 @@ end| # # Some things are caught when parsing ---error ER_SP_NO_RETSET_IN_FUNC +--error ER_SP_NO_RETSET create function bug8408() returns int begin select * from t1; return 0; end| ---error ER_SP_NO_RETSET_IN_FUNC +--error ER_SP_NO_RETSET create function bug8408() returns int begin show warnings; return 0; end| ---error ER_SP_NO_RETSET_IN_FUNC +--error ER_SP_NO_RETSET create function bug8408(a int) returns int begin declare b int; @@ -862,7 +914,7 @@ create procedure bug10537() --disable_warnings drop function if exists bug8409| --enable_warnings ---error ER_SP_BADSTATEMENT +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG create function bug8409() returns int begin @@ -874,9 +926,9 @@ end| # # BUG#9529: Stored Procedures: No Warning on truncation of procedure name # during creation. -# +# Note: When using utf8 for mysql.proc, this limit is much higher than before --error ER_TOO_LONG_IDENT -create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890() +create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123() begin end| @@ -1025,4 +1077,40 @@ end| --error 1424 call bug11394(2, 1)| drop procedure bug11394| -delimiter |; +delimiter ;| + + +# +# BUG 12490 (Packets out of order if calling HELP CONTENTS from Stored Procedure) +# +--error 1314 +CREATE PROCEDURE BUG_12490() HELP CONTENTS; +--error 1314 +CREATE FUNCTION BUG_12490() RETURNS INT HELP CONTENTS; +CREATE TABLE t_bug_12490(a int); +--error 1314 +CREATE TRIGGER BUG_12490 BEFORE UPDATE ON t_bug_12490 FOR EACH ROW HELP CONTENTS; +DROP TABLE t_bug_12490; + +# +# Bug#11834 "Re-execution of prepared statement with dropped function +# crashes server". Also tests handling of prepared stmts which use +# stored functions but does not require prelocking. +# +--disable_warnings +drop function if exists bug11834_1; +drop function if exists bug11834_2; +--enable_warnings +create function bug11834_1() returns int return 10; +create function bug11834_2() returns int return bug11834_1(); +prepare stmt from "select bug11834_2()"; +execute stmt; +# Re-execution of statement should not crash server. +execute stmt; +drop function bug11834_1; +# Attempt to execute statement should return proper error and +# should not crash server. +--error ER_SP_DOES_NOT_EXIST +execute stmt; +deallocate prepare stmt; +drop function bug11834_2; diff --git a/mysql-test/t/sp-prelocking.test b/mysql-test/t/sp-prelocking.test new file mode 100644 index 00000000000..e5f35b19fa7 --- /dev/null +++ b/mysql-test/t/sp-prelocking.test @@ -0,0 +1,242 @@ +# +# Tests of prelocking-free execution of stored procedures. +# Currently two properties of prelocking-free SP execution are checked: +# - It is possible to execute DDL statements in prelocking-free stored +# procedure +# - The same procedure can be called in prelocking-free mode and +# in prelocked mode (from within a function). + +--disable_warnings +drop database if exists mysqltest; +drop table if exists t1, t2, t3, t4; +drop procedure if exists sp1; +drop procedure if exists sp2; +drop procedure if exists sp3; +drop procedure if exists sp4; +drop function if exists f1; +drop function if exists f2; +drop function if exists f3; +--enable_warnings + +# BUG#8072 + +create database mysqltest; +delimiter //; +use mysqltest// +create procedure sp1 () +begin + drop table if exists t1; + select 1 as "my-col"; +end; +// +delimiter ;// + +select database(); +call sp1(); +select database(); + +use test; +select database(); +call mysqltest.sp1(); +select database(); + +drop procedure mysqltest.sp1; +drop database mysqltest; + +# BUG#8766 + +delimiter //; +create procedure sp1() +begin + create table t1 (a int); + insert into t1 values (10); +end// + +create procedure sp2() +begin + create table t2(a int); + insert into t2 values(1); + call sp1(); +end// + +create function f1() returns int +begin + return (select max(a) from t1); +end// + +create procedure sp3() +begin + call sp1(); + select 'func', f1(); +end// + +delimiter ;// + +call sp1(); +select 't1',a from t1; + +drop table t1; +call sp2(); +select 't1',a from t1; +select 't2',a from t2; +drop table t1, t2; + +call sp3(); +select 't1',a from t1; + +drop table t1; + +drop procedure sp1; +drop procedure sp2; +drop procedure sp3; +drop function f1; + +delimiter //; +create procedure sp1() +begin + create temporary table t2(a int); + insert into t2 select * from t1; +end// + +create procedure sp2() +begin + create temporary table t1 (a int); + insert into t1 values(1); + call sp1(); + select 't1', a from t1; + select 't2', a from t2; + drop table t1; + drop table t2; +end// + +delimiter ;// +call sp2(); + +drop procedure sp1; +drop procedure sp2; + +# Miscelaneous tests +create table t1 (a int); +insert into t1 values(1),(2); +create table t2 as select * from t1; +create table t3 as select * from t1; +create table t4 as select * from t1; +delimiter //; +create procedure sp1(a int) +begin + select a; +end // + +create function f1() returns int +begin + return (select max(a) from t1); +end // + +delimiter ;// + +CALL sp1(f1()); + +############# +delimiter //; +create procedure sp2(a int) +begin + select * from t3; + select a; +end // + +create procedure sp3() +begin + select * from t1; + call sp2(5); +end // + +create procedure sp4() +begin + select * from t2; + call sp3(); +end // + +delimiter ;// +call sp4(); + +drop procedure sp1; +drop procedure sp2; +drop procedure sp3; +drop procedure sp4; +drop function f1; + +# Test that prelocking state restoration works with cursors +--disable_warnings +drop view if exists v1; +--enable_warnings +delimiter //; + +create function f1(ab int) returns int +begin + declare i int; + set i= (select max(a) from t1 where a < ab) ; + return i; +end // + +create function f2(ab int) returns int +begin + declare i int; + set i= (select max(a) from t2 where a < ab) ; + return i; +end // + +create view v1 as + select t3.a as x, t4.a as y, f2(3) as z + from t3, t4 where t3.a = t4.a // + +create procedure sp1() +begin + declare a int; + set a= (select f1(4) + count(*) A from t1, v1); +end // + + +create function f3() returns int +begin + call sp1(); + return 1; +end // + +call sp1() // + +select f3() // +select f3() // + +call sp1() // + +--------------- +drop procedure sp1// +drop function f3// + +create procedure sp1() +begin + declare x int; + declare c cursor for select f1(3) + count(*) from v1; + open c; + fetch c into x; +end;// + +create function f3() returns int +begin + call sp1(); + return 1; +end // + +call sp1() // +call sp1() // + +select f3() // +call sp1() // + +delimiter ;// +drop table t1,t2,t3; +drop function f1; +drop function f2; +drop function f3; +drop procedure sp1; + diff --git a/mysql-test/t/sp-security.test b/mysql-test/t/sp-security.test index 3dc6b9d07ab..6f1332f80d5 100644 --- a/mysql-test/t/sp-security.test +++ b/mysql-test/t/sp-security.test @@ -341,3 +341,75 @@ REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1@localhost; drop function bug_9503; use test; drop database mysqltest; + +# +# correct value from current_user() in function run from "security definer" +# (BUG#7291) +# +connection con1root; +use test; + +select current_user(); +select user(); +create procedure bug7291_0 () sql security invoker select current_user(), user(); +create procedure bug7291_1 () sql security definer call bug7291_0(); +create procedure bug7291_2 () sql security invoker call bug7291_0(); +grant execute on procedure bug7291_0 to user1@localhost; +grant execute on procedure bug7291_1 to user1@localhost; +grant execute on procedure bug7291_2 to user1@localhost; + +connect (user1,localhost,user1,,); +connection user1; + +call bug7291_2(); +call bug7291_1(); + +connection con1root; +drop procedure bug7291_1; +drop procedure bug7291_2; +drop procedure bug7291_0; +disconnect user1; +REVOKE ALL PRIVILEGES, GRANT OPTION FROM user1@localhost; +drop user user1@localhost; + +# +# Bug #12318: Wrong error message when accessing an inaccessible stored +# procedure in another database when the current database is +# information_schema. +# + +--disable_warnings +drop database if exists mysqltest_1; +--enable_warnings + +create database mysqltest_1; +delimiter //; +create procedure mysqltest_1.p1() +begin + select 1 from dual; +end// +delimiter ;// + +grant usage on *.* to mysqltest_1@localhost; + +connect (n1,localhost,mysqltest_1,,information_schema,$MASTER_MYPORT,$MASTER_MYSOCK); +connection n1; +--error 1370 +call mysqltest_1.p1(); +disconnect n1; +# Test also without a current database +connect (n2,localhost,mysqltest_1,,*NO-ONE*,$MASTER_MYPORT,$MASTER_MYSOCK); +connection n2; +--error 1370 +call mysqltest_1.p1(); +disconnect n2; + +connection default; + +drop procedure mysqltest_1.p1; +drop database mysqltest_1; + +revoke usage on *.* from mysqltest_1@localhost; +drop user mysqltest_1@localhost; + +# End of 5.0 bugs. diff --git a/mysql-test/t/sp-threads.test b/mysql-test/t/sp-threads.test index 8fec5d14bc1..70c1efb1f0b 100644 --- a/mysql-test/t/sp-threads.test +++ b/mysql-test/t/sp-threads.test @@ -5,6 +5,7 @@ connect (con1root,localhost,root,,); connect (con2root,localhost,root,,); +connect (con3root,localhost,root,,); connection con1root; use test; @@ -75,7 +76,7 @@ send call bug9486(); connection con2root; --sleep 2 # There should be call statement in locked state. ---replace_column 1 # 6 # +--replace_column 1 # 3 localhost 6 # show processlist; unlock tables; connection con1root; @@ -112,6 +113,67 @@ drop procedure bug11158; drop table t1, t2; # +# BUG#11554: Server crashes on statement indirectly using non-cached function +# +--disable_warnings +drop function if exists bug11554; +drop view if exists v1; +--enable_warnings +create table t1 (i int); +create function bug11554 () returns int return 1; +create view v1 as select bug11554() as f; +connection con2root; +# This should not crash server +insert into t1 (select f from v1); +# Clean-up +connection con1root; +drop function bug11554; +drop table t1; +drop view v1; + + +# BUG#12228 +--disable_warnings +drop procedure if exists p1; +drop procedure if exists p2; +--enable_warnings + +connection con1root; +delimiter |; +create table t1 (s1 int)| +create procedure p1() select * from t1| +create procedure p2() +begin + insert into t1 values (1); + call p1(); + select * from t1; +end| +delimiter ;| + +connection con2root; +use test; +lock table t1 write; + +connection con1root; +send call p2(); + +connection con3root; +use test; +drop procedure p1; +create procedure p1() select * from t1; + +connection con2root; +unlock tables; + +connection con1root; +# Crash will be here if we hit BUG#12228 +reap; + +drop procedure p1; +drop procedure p2; +drop table t1; + +# # BUG#NNNN: New bug synopsis # #--disable_warnings diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index 02c560dc953..f1662a57c1b 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -22,15 +22,12 @@ use test; # t3 and up are created and dropped when needed. # --disable_warnings -drop table if exists t1; +drop table if exists t1,t2,t3,t4; --enable_warnings create table t1 ( id char(16) not null default '', data int not null ); ---disable_warnings -drop table if exists t2; ---enable_warnings create table t2 ( s char(16), i int, @@ -150,9 +147,6 @@ drop procedure setcontext| # Set things to null ---disable_warnings -drop table if exists t3| ---enable_warnings create table t3 ( d date, i int, f double, s varchar(32) )| --disable_warnings @@ -686,9 +680,6 @@ begin end| delete from t1| ---disable_warnings -drop table if exists t3| ---enable_warnings create table t3 ( s char(16), d int)| call into_test4()| select * from t3| @@ -744,14 +735,9 @@ begin insert into test.t3 values (concat(x, "2"), y+2); end| ---disable_warnings -drop table if exists t3| ---enable_warnings call create_select("cs", 90)| select * from t1, t3| ---disable_warnings -drop table if exists t3| ---enable_warnings +drop table t3| delete from t1| drop procedure create_select| @@ -925,9 +911,6 @@ drop procedure hndlr3| # Variables might be uninitialized when using handlers # (Otherwise the compiler can detect if a variable is not set, but # not in this case.) ---disable_warnings -drop table if exists t3| ---enable_warnings create table t3 ( id char(16), data int )| --disable_warnings @@ -980,9 +963,6 @@ call cur1()| select * from t1| drop procedure cur1| ---disable_warnings -drop table if exists t3| ---enable_warnings create table t3 ( s char(16), i int )| --disable_warnings @@ -1232,12 +1212,14 @@ begin end| select f5(1)| # This should generate an error about insuficient number of tables locked -# Nuw this crash server, comented until bug#11394 fix -#--error 1100 -#select f5(2)| +# Now this crash server +--disable_parsing until bug#11394 fix +--error 1100 +select f5(2)| # But now it simply miserably fails because we are trying to use the same # lex on the next iteration :/ It should generate some error too... -# select f5(3)| +select f5(3)| +--enable_parsing # OTOH this should work create function f6() returns int @@ -1283,10 +1265,13 @@ select * from v1| # views and functions ? create function f1() returns int return (select sum(data) from t1) + (select sum(data) from v1)| -# FIXME All these just exceed file limit for me :) -#select f1()| -#select * from v1| -#select * from v2| +# This queries will crash server because we can't use LEX in +# reenterable fashion yet. Patch disabling recursion will heal this. +--disable_parsing +select f1()| +select * from v1| +select * from v2| +--enable_parsing # Back to the normal cases drop function f1| create function f1() returns int @@ -1328,15 +1313,12 @@ select * from v2| select * from v1| # These should not work as we have too little instances of tables locked --error 1100 -select * from v1, v2| +select * from v1, t1| --error 1100 select f4()| unlock tables| -# TODO We also should test integration with triggers - - # Cleanup drop function f0| drop function f1| @@ -1501,54 +1483,55 @@ show procedure status like '%p%'| # # This part of test is disabled until we implement support for # recursive stored procedures. -#--disable_warnings -#drop table if exists fib| -#--enable_warnings -#create table fib ( f bigint unsigned not null )| -# -## We deliberately do it the awkward way, fetching the last two -## values from the table, in order to exercise various statements -## and table accesses at each turn. -#--disable_warnings -#drop procedure if exists fib| -#--enable_warnings -#create procedure fib(n int unsigned) -#begin -# if n > 1 then -# begin -# declare x, y bigint unsigned; -# declare c cursor for select f from fib order by f desc limit 2; -# -# open c; -# fetch c into y; -# fetch c into x; -# close c; -# insert into fib values (x+y); -# call fib(n-1); -# end; -# end if; -#end| -# -## Minimum test: recursion of 3 levels -# -#insert into fib values (0), (1)| -# -#call fib(3)| -# -#select * from fib order by f asc| -# -#delete from fib| -# -## Original test: 20 levels (may run into memory limits!) -# -#insert into fib values (0), (1)| -# -#call fib(20)| -# -#select * from fib order by f asc| -#drop table fib| -#drop procedure fib| +--disable_parsing +--disable_warnings +drop table if exists fib| +--enable_warnings +create table fib ( f bigint unsigned not null )| + +# We deliberately do it the awkward way, fetching the last two +# values from the table, in order to exercise various statements +# and table accesses at each turn. +--disable_warnings +drop procedure if exists fib| +--enable_warnings +create procedure fib(n int unsigned) +begin + if n > 1 then + begin + declare x, y bigint unsigned; + declare c cursor for select f from fib order by f desc limit 2; + + open c; + fetch c into y; + fetch c into x; + close c; + insert into fib values (x+y); + call fib(n-1); + end; + end if; +end| + +# Minimum test: recursion of 3 levels + +insert into fib values (0), (1)| + +call fib(3)| + +select * from fib order by f asc| + +delete from fib| + +# Original test: 20 levels (may run into memory limits!) +insert into fib values (0), (1)| + +call fib(20)| + +select * from fib order by f asc| +drop table fib| +drop procedure fib| +--enable_parsing # # Comment & suid @@ -1616,9 +1599,6 @@ insert into t1 values ("foo", 3), ("bar", 2), ("zip", 5), ("zap", 1)| select t1max()| drop function t1max| ---disable_warnings -drop table if exists t3| ---enable_warnings create table t3 ( v char(16) not null primary key, c int unsigned not null @@ -1752,9 +1732,6 @@ drop procedure bug1656| # # BUG#1862 # ---disable_warnings -drop table if exists t3| ---enable_warnings create table t3(a int)| --disable_warnings @@ -1832,49 +1809,51 @@ drop procedure bug2260| # FIXME: Other solution would be to use preopened proc table # instead of opening it anew. # -#--disable_warnings -#drop procedure if exists bug2267_1| -#--enable_warnings -#create procedure bug2267_1() -#begin -# show procedure status; -#end| -# -#--disable_warnings -#drop procedure if exists bug2267_2| -#--enable_warnings -#create procedure bug2267_2() -#begin -# show function status; -#end| -# -#--disable_warnings -#drop procedure if exists bug2267_3| -#--enable_warnings -#create procedure bug2267_3() -#begin -# show create procedure bug2267_1; -#end| -# -#--disable_warnings -#drop procedure if exists bug2267_4| -#--enable_warnings -#create procedure bug2267_4() -#begin -# show create function fac; -#end| -# -#--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00' -#call bug2267_1()| -#--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00' -#call bug2267_2()| -#call bug2267_3()| -#call bug2267_4()| -# -#drop procedure bug2267_1| -#drop procedure bug2267_2| -#drop procedure bug2267_3| -#drop procedure bug2267_4| +--disable_parsing +--disable_warnings +drop procedure if exists bug2267_1| +--enable_warnings +create procedure bug2267_1() +begin + show procedure status; +end| + +--disable_warnings +drop procedure if exists bug2267_2| +--enable_warnings +create procedure bug2267_2() +begin + show function status; +end| + +--disable_warnings +drop procedure if exists bug2267_3| +--enable_warnings +create procedure bug2267_3() +begin + show create procedure bug2267_1; +end| + +--disable_warnings +drop procedure if exists bug2267_4| +--enable_warnings +create procedure bug2267_4() +begin + show create function fac; +end| + +--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00' +call bug2267_1()| +--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00' +call bug2267_2()| +call bug2267_3()| +call bug2267_4()| + +drop procedure bug2267_1| +drop procedure bug2267_2| +drop procedure bug2267_3| +drop procedure bug2267_4| +--enable_parsing # # BUG#2227 @@ -1903,23 +1882,25 @@ drop procedure bug2227| # QQ For this reason we can't run this test any more (i.e., if we modify # QQ it, it's no longer a test case for the bug), but we keep it here # QQ anyway, for tracability. -#--disable_warnings -#drop procedure if exists bug2614| -#--enable_warnings -#create procedure bug2614() -#begin -# drop temporary table if exists t3; -# create temporary table t3 (id int default '0' not null); -# insert into t3 select 12; -# insert into t3 select * from t3; -#end| -# -#--disable_warnings -#call bug2614()| -#--enable_warnings -#call bug2614()| -#drop temporary table t3| -#drop procedure bug2614| +--disable_parsing +--disable_warnings +drop procedure if exists bug2614| +--enable_warnings +create procedure bug2614() +begin + drop temporary table if exists t3; + create temporary table t3 (id int default '0' not null); + insert into t3 select 12; + insert into t3 select * from t3; +end| + +--disable_warnings +call bug2614()| +--enable_warnings +call bug2614()| +drop temporary table t3| +drop procedure bug2614| +--enable_parsing # # BUG#2674 @@ -2011,9 +1992,6 @@ drop procedure bug2776_2| # # BUG#2780 # ---disable_warnings -drop table if exists t3| ---enable_warnings create table t3 (s1 smallint)| insert into t3 values (123456789012)| @@ -2087,9 +2065,6 @@ drop table t3, t4| # # BUG#2656 # ---disable_warnings -drop table if exists t3, t4| ---enable_warnings create table t3 ( OrderID int not null, @@ -2177,8 +2152,6 @@ drop procedure bug3426| # BUG#3448 # --disable_warnings -drop table if exists t3, t4| - create table t3 ( a int primary key, ach char(1) @@ -2210,9 +2183,6 @@ drop table t3, t4| # # BUG#3734 # ---disable_warnings -drop table if exists t3| ---enable_warnings create table t3 ( id int unsigned auto_increment not null primary key, title VARCHAR(200), @@ -2388,9 +2358,6 @@ drop procedure bug3843| # # BUG#3368 # ---disable_warnings -drop table if exists t3| ---enable_warnings create table t3 ( s1 char(10) )| insert into t3 values ('a'), ('b')| @@ -2410,9 +2377,6 @@ drop table t3| # # BUG#4579 # ---disable_warnings -drop table if exists t3| ---enable_warnings create table t3 (f1 int, f2 int)| insert into t3 values (1,1)| @@ -2447,7 +2411,6 @@ drop table t3| # BUG#2773: Function's data type ignored in stored procedures # --disable_warnings -drop table if exists t3| drop procedure if exists bug2773| --enable_warnings @@ -2476,10 +2439,6 @@ drop function bug3788| # # BUG#4726 # ---disable_warnings -drop table if exists t3| ---enable_warnings - create table t3 (f1 int, f2 int, f3 int)| insert into t3 values (1,1,1)| @@ -2509,28 +2468,26 @@ drop table t3| # # BUG#4318 # -#QQ Don't know if HANDLER commands can work with SPs, or at all... -#--disable_warnings -#drop table if exists t3| -#--enable_warnings -# -#create table t3 (s1 int)| -#insert into t3 values (3), (4)| -# -#--disable_warnings -#drop procedure if exists bug4318| -#--enable_warnings -#create procedure bug4318() -# handler t3 read next| -# -#handler t3 open| -## Expect no results, as tables are closed, but there shouldn't be any errors -#call bug4318()| -#call bug4318()| -#handler t3 close| -# -#drop procedure bug4318| -#drop table t3| + +--disable_parsing Don't know if HANDLER commands can work with SPs, or at all.. +create table t3 (s1 int)| +insert into t3 values (3), (4)| + +--disable_warnings +drop procedure if exists bug4318| +--enable_warnings +create procedure bug4318() + handler t3 read next| + +handler t3 open| +# Expect no results, as tables are closed, but there shouldn't be any errors +call bug4318()| +call bug4318()| +handler t3 close| + +drop procedure bug4318| +drop table t3| +--enable_parsing # # BUG#4902: Stored procedure with SHOW WARNINGS leads to packet error @@ -2565,11 +2522,13 @@ begin show variables like 'foo'; show warnings; end| -#show binlog events; -#show storage engines; -#show master status; -#show slave hosts; -#show slave status; +--disable_parsing +show binlog events; +show storage engines; +show master status; +show slave hosts; +show slave status; +--enable_parsing call bug4902()| call bug4902()| @@ -2584,9 +2543,9 @@ create procedure bug4902_2() begin show processlist; end| ---replace_column 1 # 6 # +--replace_column 1 # 6 # 3 localhost call bug4902_2()| ---replace_column 1 # 6 # +--replace_column 1 # 6 # 3 localhost call bug4902_2()| drop procedure bug4902_2| @@ -2594,10 +2553,6 @@ drop procedure bug4902_2| # BUG#4904 # --disable_warnings -drop table if exists t3| ---enable_warnings - ---disable_warnings drop procedure if exists bug4904| --enable_warnings create procedure bug4904() @@ -2850,7 +2805,6 @@ drop procedure bug3583| # BUG#4905: Stored procedure doesn't clear for "Rows affected" # --disable_warnings -drop table if exists t3| drop procedure if exists bug4905| --enable_warnings @@ -2881,26 +2835,27 @@ drop table t3| # # BUG#6022: Stored procedure shutdown problem with self-calling function. # -# This part of test is disabled until we implement support for -# recursive stored functions. -#--disable_warnings -#drop function if exists bug6022| -#--enable_warnings -# -#--disable_warnings -#drop function if exists bug6022| -#--enable_warnings -#create function bug6022(x int) returns int -#begin -# if x < 0 then -# return 0; -# else -# return bug6022(x-1); -# end if; -#end| -# -#select bug6022(5)| -#drop function bug6022| + +--disable_parsing until we implement support for recursive stored functions. +--disable_warnings +drop function if exists bug6022| +--enable_warnings + +--disable_warnings +drop function if exists bug6022| +--enable_warnings +create function bug6022(x int) returns int +begin + if x < 0 then + return 0; + else + return bug6022(x-1); + end if; +end| + +select bug6022(5)| +drop function bug6022| +--enable_parsing # # BUG#6029: Stored procedure specific handlers should have priority @@ -2950,9 +2905,6 @@ drop procedure bug8540| # # BUG#6642: Stored procedure crash if expression with set function # ---disable_warnings -drop table if exists t3| ---enable_warnings create table t3 (s1 int)| --disable_warnings @@ -3040,9 +2992,6 @@ drop table t3| # BUG#8116: calling simple stored procedure twice in a row results # in server crash # ---disable_warnings -drop table if exists t3| ---enable_warnings create table t3 ( userid bigint(20) not null default 0 )| --disable_warnings @@ -3285,7 +3234,6 @@ delete from t1| drop procedure if exists bug6900| drop procedure if exists bug9074| drop procedure if exists bug6900_9074| -drop table if exists t3| --enable_warnings create table t3 (w char unique, x char)| @@ -3379,15 +3327,16 @@ drop procedure avg| --disable_warnings drop procedure if exists bug6129| --enable_warnings -set @@sql_mode = 'traditional'| -create procedure bug6129(mode text) - select @@sql_mode = mode| - -# 1 -call bug6129(@@sql_mode)| -set @@sql_mode = ''| -# 0 -call bug6129(@@sql_mode)| +set @old_mode= @@sql_mode; +set @@sql_mode= "ERROR_FOR_DIVISION_BY_ZERO"; +create procedure bug6129() + select @@sql_mode| +call bug6129()| +set @@sql_mode= "NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO"| +call bug6129()| +set @@sql_mode= "NO_ZERO_IN_DATE"| +call bug6129()| +set @@sql_mode=@old_mode; drop procedure bug6129| @@ -3804,6 +3753,297 @@ drop procedure bug11529| # +# BUG#6063: Stored procedure labels are subject to restrictions (partial) +# BUG#7088: Stored procedures: labels won't work if character set is utf8 +# +--disable_warnings +drop procedure if exists bug6063| +drop procedure if exists bug7088_1| +drop procedure if exists bug7088_2| +--enable_warnings + +--disable_parsing temporarily disabled until Bar fixes BUG#11986 +create procedure bug6063() + lâbel: begin end| +call bug6063()| +# QQ Known bug: this will not show the label correctly. +show create procedure bug6063| + +set character set utf8| +create procedure bug7088_1() + label1: begin end label1| +create procedure bug7088_2() + läbel1: begin end| +call bug7088_1()| +call bug7088_2()| +set character set default| +show create procedure bug7088_1| +show create procedure bug7088_2| + +drop procedure bug6063| +drop procedure bug7088_1| +drop procedure bug7088_2| +--enable_parsing + +# +# BUG#9565: "Wrong locking in stored procedure if a sub-sequent procedure +# is called". +# +--disable_warnings +drop procedure if exists bug9565_sub| +drop procedure if exists bug9565| +--enable_warnings +create procedure bug9565_sub() +begin + select * from t1; +end| +create procedure bug9565() +begin + insert into t1 values ("one", 1); + call bug9565_sub(); +end| +call bug9565()| +delete from t1| +drop procedure bug9565_sub| +drop procedure bug9565| + + +# +# BUG#9538: SProc: Creation fails if we try to SET system variable +# using @@var_name in proc +# +--disable_warnings +drop procedure if exists bug9538| +--enable_warnings +create procedure bug9538() + set @@sort_buffer_size = 1000000| + +set @x = @@sort_buffer_size| +set @@sort_buffer_size = 2000000| +select @@sort_buffer_size| +call bug9538()| +select @@sort_buffer_size| +set @@sort_buffer_size = @x| + +drop procedure bug9538| + + +# +# BUG#8692: Cursor fetch of empty string +# +--disable_warnings +drop procedure if exists bug8692| +--enable_warnings +create table t3 (c1 varchar(5), c2 char(5), c3 enum('one','two'), c4 text, c5 blob, c6 char(5), c7 varchar(5))| +insert into t3 values ('', '', '', '', '', '', NULL)| + +create procedure bug8692() +begin + declare v1 VARCHAR(10); + declare v2 VARCHAR(10); + declare v3 VARCHAR(10); + declare v4 VARCHAR(10); + declare v5 VARCHAR(10); + declare v6 VARCHAR(10); + declare v7 VARCHAR(10); + declare c8692 cursor for select c1,c2,c3,c4,c5,c6,c7 from t3; + open c8692; + fetch c8692 into v1,v2,v3,v4,v5,v6,v7; + select v1, v2, v3, v4, v5, v6, v7; +end| + +call bug8692()| +drop procedure bug8692| +drop table t3| + +# +# Bug#10055 "Using stored function with information_schema causes empty +# result set" +# +--disable_warnings +drop function if exists bug10055| +--enable_warnings +create function bug10055(v char(255)) returns char(255) return lower(v)| +# This select should not crash server and should return all fields in t1 +select t.column_name, bug10055(t.column_name) +from information_schema.columns as t +where t.table_schema = 'test' and t.table_name = 't1'| +drop function bug10055| + +# +# Bug #12297 "SP crashes the server if data inserted inside a lon loop" +# The test for memleak bug, so actually there is no way to test it +# from the suite. The test below could be used to check SP memory +# consumption by passing large input parameter. +# + +# +# Note: the test is currenly disabled because of the +# Bug #12637: SP crashes the server if it has update query with user var +# & binlog is enabled. +# + +--disable_warnings +#drop procedure if exists bug12297| +--enable_warnings + +#create procedure bug12297(lim int) +#begin +# set @x = 0; +# repeat +# insert into t1(id,data) +# values('aa', @x); +# set @x = @x + 1; +# until @x >= lim +# end repeat; +#end| + +#call bug12297(10)| +#drop procedure bug12297| + +# +# Bug #11247 "Stored procedures: Function calls in long loops leak memory" +# One more memleak bug test. One could use this test to check that the memory +# isn't leaking by increasing the input value for p_bug11247. +# + +--disable_warnings +drop function if exists f_bug11247| +drop procedure if exists p_bug11247| +--enable_warnings + +create function f_bug11247(param int) + returns int +return param + 1| + +create procedure p_bug11247(lim int) +begin + declare v int default 0; + + while v < lim do + set v= f_bug11247(v); + end while; +end| + +call p_bug11247(10)| +drop function f_bug11247| +drop procedure p_bug11247| +# +# BUG#12168: "'DECLARE CONTINUE HANDLER FOR NOT FOUND ...' in conditional +# handled incorrectly" +# +--disable_warnings +drop procedure if exists bug12168| +drop table if exists t3, t4| +--enable_warnings + +create table t3 (a int)| +insert into t3 values (1),(2),(3),(4)| + +create table t4 (a int)| + +create procedure bug12168(arg1 char(1)) +begin + declare b, c integer; + if arg1 = 'a' then + begin + declare c1 cursor for select a from t3 where a % 2; + declare continue handler for not found set b = 1; + set b = 0; + open c1; + c1_repeat: repeat + fetch c1 into c; + if (b = 1) then + leave c1_repeat; + end if; + + insert into t4 values (c); + until b = 1 + end repeat; + end; + end if; + if arg1 = 'b' then + begin + declare c2 cursor for select a from t3 where not a % 2; + declare continue handler for not found set b = 1; + set b = 0; + open c2; + c2_repeat: repeat + fetch c2 into c; + if (b = 1) then + leave c2_repeat; + end if; + + insert into t4 values (c); + until b = 1 + end repeat; + end; + end if; +end| + +call bug12168('a')| +select * from t4| +truncate t4| +call bug12168('b')| +select * from t4| +truncate t4| +call bug12168('a')| +select * from t4| +truncate t4| +call bug12168('b')| +select * from t4| +truncate t4| +drop table t3, t4| +drop procedure if exists bug12168| + +# +# Bug #11333 "Stored Procedure: Memory blow up on repeated SELECT ... INTO +# query" +# One more memleak bug. Use the test to check memory consumption. +# + +--disable_warnings +drop table if exists t3| +drop procedure if exists bug11333| +--enable_warnings + +create table t3 (c1 char(128))| + +insert into t3 values + ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA')| + + +create procedure bug11333(i int) +begin + declare tmp varchar(128); + set @x = 0; + repeat + select c1 into tmp from t3 + where c1 = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'; + set @x = @x + 1; + until @x >= i + end repeat; +end| + +call bug11333(10)| + +drop procedure bug11333| +drop table t3| + +# +# BUG#9048: Creating a function with char binary IN parameter fails +# +--disable_warnings +drop function if exists bug9048| +--enable_warnings +create function bug9048(f1 char binary) returns char binary +begin + set f1= concat( 'hello', f1 ); + return f1; +end| +drop function bug9048| + +# # BUG#NNNN: New bug synopsis # #--disable_warnings @@ -3811,9 +4051,7 @@ drop procedure bug11529| #--enable_warnings #create procedure bugNNNN... - # Add bugs above this line. Use existing tables t1 and t2 when # practical, or create table t3, t4 etc temporarily (and drop them). delimiter ;| drop table t1,t2; - diff --git a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test index f8ab521e665..10db520cd12 100644 --- a/mysql-test/t/sql_mode.test +++ b/mysql-test/t/sql_mode.test @@ -86,6 +86,8 @@ drop table t1 ; --error 1231 set @@SQL_MODE=NULL; +# End of 4.1 tests + # # test for # WL 1941 "NO_C_ESCAPES sql_mode" diff --git a/mysql-test/t/status.test b/mysql-test/t/status.test index 31d9c8154d5..7fea51c9327 100644 --- a/mysql-test/t/status.test +++ b/mysql-test/t/status.test @@ -35,3 +35,5 @@ connection con1; reap; show status like 'Table_lock%'; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test index 20f0b072bfd..6af0a10d831 100644 --- a/mysql-test/t/strict.test +++ b/mysql-test/t/strict.test @@ -1093,3 +1093,53 @@ set @@sql_mode='traditional'; create table t1(a varchar(65537)); --error 1074 create table t1(a varbinary(65537)); + +# +# Bug #9881: problem with altering table +# + +set @@sql_mode='traditional'; +create table t1(a int, b date not null); +alter table t1 modify a bigint unsigned not null; +show create table t1; +drop table t1; + +# +# Bug #5906: handle invalid date due to conversion +# +set @@sql_mode='traditional'; +create table t1 (d date); +--error 1292 +insert into t1 values ('2000-10-00'); +--error 1292 +insert into t1 values (1000); +insert into t1 values ('2000-10-01'); +--error 1292 +update t1 set d = 1100; +select * from t1; +drop table t1; + +# +# Bug #11964: alter table with timestamp field +# + +set @@sql_mode='traditional'; +create table t1(a int, b timestamp); +alter table t1 add primary key(a); +show create table t1; +drop table t1; +create table t1(a int, b timestamp default 20050102030405); +alter table t1 add primary key(a); +show create table t1; +drop table t1; + +# +# BIT fields +# + +set @@sql_mode='traditional'; +create table t1(a bit(2)); +--error 1406 +insert into t1 values(b'101'); +select * from t1; +drop table t1; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 1e4930d385d..5020902009d 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -696,7 +696,7 @@ CREATE TABLE `t1` ( INSERT INTO t1 VALUES (1); UPDATE t1 SET i=i+(SELECT MAX(i) FROM (SELECT 1) t) WHERE i=(SELECT MAX(i)); UPDATE t1 SET i=i+1 WHERE i=(SELECT MAX(i)); --- error 1109 +-- error 1054 UPDATE t1 SET t.i=i+(SELECT MAX(i) FROM (SELECT 1) t); select * from t1; drop table t1; @@ -1005,7 +1005,7 @@ create table t2 (s1 int); select * from t1 where (select count(*) from t2 where t1.s2) = 1; -- error 1054 select * from t1 where (select count(*) from t2 group by t1.s2) = 1; --- error 1109 +-- error 1054 select count(*) from t2 group by t1.s2; drop table t1, t2; @@ -1133,7 +1133,9 @@ CREATE TABLE t2 (id INT); INSERT INTO t1 VALUES (1), (2); INSERT INTO t2 VALUES (1); SELECT t1.id, ( SELECT COUNT(t.id) FROM t2 AS t WHERE t.id = t1.id ) AS c FROM t1 LEFT JOIN t2 USING (id); +SELECT id, ( SELECT COUNT(t.id) FROM t2 AS t WHERE t.id = t1.id ) AS c FROM t1 LEFT JOIN t2 USING (id); SELECT t1.id, ( SELECT COUNT(t.id) FROM t2 AS t WHERE t.id = t1.id ) AS c FROM t1 LEFT JOIN t2 USING (id) ORDER BY t1.id; +SELECT id, ( SELECT COUNT(t.id) FROM t2 AS t WHERE t.id = t1.id ) AS c FROM t1 LEFT JOIN t2 USING (id) ORDER BY id; DROP TABLE t1,t2; # @@ -1726,9 +1728,102 @@ select (select a from t1) = (1,2); select (1,2,3) = (select * from t1); -- error 1241 select (select * from t1) = (1,2,3); +drop table t1 + +# +# Item_int_with_ref check (BUG#10020) +# +CREATE TABLE `t1` ( + `itemid` bigint(20) unsigned NOT NULL auto_increment, + `sessionid` bigint(20) unsigned default NULL, + `time` int(10) unsigned NOT NULL default '0', + `type` set('A','D','E','F','G','I','L','N','U') collate latin1_general_ci NOT +NULL default '', + `data` text collate latin1_general_ci NOT NULL, + PRIMARY KEY (`itemid`) +) DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; +INSERT INTO `t1` VALUES (1, 1, 1, 'D', ''); +CREATE TABLE `t2` ( + `sessionid` bigint(20) unsigned NOT NULL auto_increment, + `pid` int(10) unsigned NOT NULL default '0', + `date` int(10) unsigned NOT NULL default '0', + `ip` varchar(15) collate latin1_general_ci NOT NULL default '', + PRIMARY KEY (`sessionid`) +) DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; +INSERT INTO `t2` VALUES (1, 1, 1, '10.10.10.1'); +SELECT s.ip, count( e.itemid ) FROM `t1` e JOIN t2 s ON s.sessionid = e.sessionid WHERE e.sessionid = ( SELECT sessionid FROM t2 ORDER BY sessionid DESC LIMIT 1 ) GROUP BY s.ip HAVING count( e.itemid ) >0 LIMIT 0 , 30; +drop tables t1,t2; + +# BUG#11821 : Select from subselect using aggregate function on an enum +# segfaults: +create table t1 (fld enum('0','1')); +insert into t1 values ('1'); +select * from (select max(fld) from t1) as foo; drop table t1; # +# Bug #11867: queries with ROW(,elems>) IN (SELECT DISTINCT <cols> FROM ...) +# + +CREATE TABLE t1 (one int, two int, flag char(1)); +CREATE TABLE t2 (one int, two int, flag char(1)); +INSERT INTO t1 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); +INSERT INTO t2 VALUES(1,2,'Y'),(2,3,'Y'),(3,4,'Y'),(5,6,'N'),(7,8,'N'); + +SELECT * FROM t1 + WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t2 WHERE flag = 'N'); +SELECT * FROM t1 + WHERE ROW(one,two) IN (SELECT DISTINCT one,two FROM t1 WHERE flag = 'N'); + +insert into t2 values (null,null,'N'); +insert into t2 values (null,3,'0'); +insert into t2 values (null,5,'0'); +insert into t2 values (10,null,'0'); +insert into t1 values (10,3,'0'); +insert into t1 values (10,5,'0'); +insert into t1 values (10,10,'0'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N') as 'test' from t1; +SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N' group by one,two) as 'test' from t1; +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0') as 'test' from t1; +explain extended SELECT one,two from t1 where ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = 'N'); +explain extended SELECT one,two,ROW(one,two) IN (SELECT one,two FROM t2 WHERE flag = '0' group by one,two) as 'test' from t1; +DROP TABLE t1,t2; + +# +# Bug #12392: where cond with IN predicate for rows and NULL values in table +# + +CREATE TABLE t1 (a char(5), b char(5)); +INSERT INTO t1 VALUES (NULL,'aaa'), ('aaa','aaa'); + +SELECT * FROM t1 WHERE (a,b) IN (('aaa','aaa'), ('aaa','bbb')); + +DROP TABLE t1; + +# +# Bug #11479: subquery over left join with an empty inner table +# + +CREATE TABLE t1 (a int); +CREATE TABLE t2 (a int, b int); +CREATE TABLE t3 (b int NOT NULL); +INSERT INTO t1 VALUES (1), (2), (3), (4); +INSERT INTO t2 VALUES (1,10), (3,30); + +SELECT * FROM t2 LEFT JOIN t3 ON t2.b=t3.b + WHERE t3.b IS NOT NULL OR t2.a > 10; +SELECT * FROM t1 + WHERE t1.a NOT IN (SELECT a FROM t2 LEFT JOIN t3 ON t2.b=t3.b + WHERE t3.b IS NOT NULL OR t2.a > 10); + +DROP TABLE t1,t2,t3; + +# End of 4.1 tests + +# #decimal-related tests # create table t1 (df decimal(5,1)); @@ -1859,3 +1954,12 @@ WHERE values_id IN (SELECT values_id FROM t2 WHERE select_id = 0 OR select_id = 1); DROP TABLE t1, t2; + +# BUG#11821 : Select from subselect using aggregate function on an enum +# segfaults: +create table t1 (fld enum('0','1')); +insert into t1 values ('1'); +select * from (select max(fld) from t1) as foo; +drop table t1; + + diff --git a/mysql-test/t/subselect2.test b/mysql-test/t/subselect2.test index 2d42320334a..839e94206d0 100644 --- a/mysql-test/t/subselect2.test +++ b/mysql-test/t/subselect2.test @@ -146,4 +146,5 @@ SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON EXPLAIN SELECT t2.*, t4.DOCTYPENAME, t1.CONTENTSIZE,t1.MIMETYPE FROM t2 INNER JOIN t4 ON t2.DOCTYPEID = t4.DOCTYPEID LEFT OUTER JOIN t1 ON t2.DOCID = t1.DOCID WHERE t2.FOLDERID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID IN(SELECT t3.FOLDERID FROM t3 WHERE t3.PARENTID='2f6161e879db43c1a5b82c21ddc49089' AND t3.FOLDERNAME = 'Level1') AND t3.FOLDERNAME = 'Level2') AND t3.FOLDERNAME = 'Level3') AND t3.FOLDERNAME = 'CopiedFolder') AND t3.FOLDERNAME = 'Movie Reviews') AND t2.DOCNAME = 'Last Discussion'; -drop table t1, t2, t3, t4;
\ No newline at end of file +drop table t1, t2, t3, t4; +# End of 4.1 tests diff --git a/mysql-test/t/subselect_gis.test b/mysql-test/t/subselect_gis.test index 338051029c4..1ab139b7822 100644 --- a/mysql-test/t/subselect_gis.test +++ b/mysql-test/t/subselect_gis.test @@ -13,3 +13,5 @@ select City from t1 where (select intersects(GeomFromText(AsText(Location)),GeomFromText('Polygon((2 50, 2.5 50, 2.5 47, 2 47, 2 50))'))=0); drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/subselect_innodb.test b/mysql-test/t/subselect_innodb.test index 5d796988178..3b1d2f393c2 100644 --- a/mysql-test/t/subselect_innodb.test +++ b/mysql-test/t/subselect_innodb.test @@ -159,3 +159,5 @@ EXECUTE my_stmt; EXECUTE my_stmt; deallocate prepare my_stmt; drop table t1,t2; + +# End of 4.1 tests diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test index f477fc378c6..b7a7e83d569 100644 --- a/mysql-test/t/symlink.test +++ b/mysql-test/t/symlink.test @@ -136,3 +136,5 @@ eval create table t1 (i int) index directory = "$MYSQL_TEST_DIR/var/master-data/ enable_query_log; show create table t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/synchronization.test b/mysql-test/t/synchronization.test index 09324b32b97..c7696195ee0 100644 --- a/mysql-test/t/synchronization.test +++ b/mysql-test/t/synchronization.test @@ -36,3 +36,5 @@ while ($1) dec $1; } DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/system_mysql_db.test b/mysql-test/t/system_mysql_db.test index acd19f47728..27c17da2731 100644 --- a/mysql-test/t/system_mysql_db.test +++ b/mysql-test/t/system_mysql_db.test @@ -16,3 +16,5 @@ use test; -- enable_query_log # keep results same with system_mysql_db_fix show tables; + +# End of 4.1 tests diff --git a/mysql-test/t/system_mysql_db_fix.test b/mysql-test/t/system_mysql_db_fix.test index f47b4cba6e6..4621b2f50ef 100644 --- a/mysql-test/t/system_mysql_db_fix.test +++ b/mysql-test/t/system_mysql_db_fix.test @@ -89,5 +89,7 @@ DROP TABLE db, host, user, func, tables_priv, columns_priv, procs_priv, help_cat -- enable_query_log -# check that we droped all system tables +# check that we dropped all system tables show tables; + +# End of 4.1 tests diff --git a/mysql-test/t/system_mysql_db_refs.test b/mysql-test/t/system_mysql_db_refs.test index 9e2c5a20b54..c5146e1b043 100644 --- a/mysql-test/t/system_mysql_db_refs.test +++ b/mysql-test/t/system_mysql_db_refs.test @@ -99,3 +99,5 @@ drop table test_func; drop table test_host; drop table test_user; drop table test_db; + +# End of 4.1 tests diff --git a/mysql-test/t/tablelock.test b/mysql-test/t/tablelock.test index fbc5d685096..95533903b45 100644 --- a/mysql-test/t/tablelock.test +++ b/mysql-test/t/tablelock.test @@ -47,3 +47,5 @@ CREATE TABLE t2 (a int); lock tables t1 write,t1 as b write, t2 write, t2 as c read; drop table t2,t1; unlock tables; + +# End of 4.1 tests diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test index da7ce9b4722..9a7678ed712 100644 --- a/mysql-test/t/temp_table.test +++ b/mysql-test/t/temp_table.test @@ -112,3 +112,5 @@ insert into t1 values (3,1),(3,2); insert into t2 values (NULL, 'foo'), (NULL, 'bar'); select d, c from t1 left join t2 on b = c where a = 3 order by d; drop table t1, t2; + +# End of 4.1 tests diff --git a/mysql-test/t/timezone.test b/mysql-test/t/timezone.test index ffc2e3a3ebf..34bbb365c70 100644 --- a/mysql-test/t/timezone.test +++ b/mysql-test/t/timezone.test @@ -58,3 +58,5 @@ select unix_timestamp('1970-01-01 01:00:00'), unix_timestamp('1970-01-01 01:00:01'), unix_timestamp('2038-01-01 00:59:59'), unix_timestamp('2038-01-01 01:00:00'); + +# End of 4.1 tests diff --git a/mysql-test/t/timezone2.test b/mysql-test/t/timezone2.test index 0b5aaed5d30..069c19341e4 100644 --- a/mysql-test/t/timezone2.test +++ b/mysql-test/t/timezone2.test @@ -48,6 +48,11 @@ insert into t1 (i, ts) values (unix_timestamp('2003-03-30 01:59:59'),'2003-03-30 01:59:59'), (unix_timestamp('2003-03-30 02:30:00'),'2003-03-30 02:30:00'), (unix_timestamp('2003-03-30 03:00:00'),'2003-03-30 03:00:00'); +# Values around and in spring time-gap +insert into t1 (i, ts) values + (unix_timestamp(20030330015959),20030330015959), + (unix_timestamp(20030330023000),20030330023000), + (unix_timestamp(20030330030000),20030330030000); # Normal value with DST insert into t1 (i, ts) values (unix_timestamp('2003-05-01 00:00:00'),'2003-05-01 00:00:00'); @@ -215,3 +220,5 @@ select convert_tz('2005-01-14 17:00:00', 'UTC', custTimeZone) from (select 'UTC' create table t1 select convert_tz(NULL, NULL, NULL); select * from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/timezone3.test b/mysql-test/t/timezone3.test index 8910783cd85..0aedbafcec4 100644 --- a/mysql-test/t/timezone3.test +++ b/mysql-test/t/timezone3.test @@ -57,3 +57,5 @@ create table t1 (ts timestamp); insert into t1 values (19730101235900), (20040101235900); select * from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/timezone_grant.test b/mysql-test/t/timezone_grant.test index f586ba0c5fe..f94d86eb266 100644 --- a/mysql-test/t/timezone_grant.test +++ b/mysql-test/t/timezone_grant.test @@ -61,6 +61,18 @@ select * from mysql.time_zone_name; --error 1142 select Name, convert_tz('2004-11-30 12:00:00', Name, 'UTC') from mysql.time_zone_name; +# +# Bug #9979: Use of CONVERT_TZ in multiple-table UPDATE causes bogus +# privilege error +# +drop table t1, t2; +create table t1 (a int, b datetime); +create table t2 (a int, b varchar(40)); +update t1 set b = '2005-01-01 10:00'; +update t1 set b = convert_tz(b, 'UTC', 'UTC'); +update t1 join t2 on (t1.a = t2.a) set t1.b = '2005-01-01 10:00' where t2.b = 'foo'; +update t1 join t2 on (t1.a = t2.a) set t1.b = convert_tz('2005-01-01 10:00','UTC','UTC') where t2.b = 'foo'; + # Clean-up connection default; delete from mysql.user where user like 'mysqltest\_%'; @@ -69,3 +81,4 @@ delete from mysql.tables_priv where user like 'mysqltest\_%'; flush privileges; drop table t1, t2; +# End of 4.1 tests diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 05241772693..9920f203c94 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -3,9 +3,11 @@ # --disable_warnings -drop table if exists t1, t2; +drop table if exists t1, t2, t3; drop view if exists v1; drop database if exists mysqltest; +drop function if exists f1; +drop procedure if exists p1; --enable_warnings create table t1 (i int); @@ -16,13 +18,13 @@ set @a:=0; select @a; insert into t1 values (1); select @a; -drop trigger t1.trg; +drop trigger trg; # let us test simple trigger reading some values create trigger trg before insert on t1 for each row set @a:=new.i; insert into t1 values (123); select @a; -drop trigger t1.trg; +drop trigger trg; drop table t1; @@ -39,7 +41,7 @@ end| insert into t1 (i) values (1)| insert into t1 (i,j) values (2, 3)| select * from t1| -drop trigger t1.trg| +drop trigger trg| drop table t1| delimiter ;| @@ -51,7 +53,7 @@ create trigger trg after insert on t1 for each row set @a:=""; insert into t1 values (2),(3),(4),(5); select @a; -drop trigger t1.trg; +drop trigger trg; drop table t1; # PS doesn't work with multi-row statements @@ -74,7 +76,7 @@ set @update_failed:=""| update t1 set balance=1500| select @update_failed; select * from t1| -drop trigger t1.trg| +drop trigger trg| drop table t1| delimiter ;| --enable_ps_protocol @@ -87,7 +89,7 @@ create trigger trg after update on t1 for each row set @total_change:=0; update t1 set i=3; select @total_change; -drop trigger t1.trg; +drop trigger trg; drop table t1; # Before delete trigger @@ -99,7 +101,7 @@ create trigger trg before delete on t1 for each row set @del_sum:= 0; delete from t1 where i <= 3; select @del_sum; -drop trigger t1.trg; +drop trigger trg; drop table t1; # After delete trigger. @@ -110,7 +112,7 @@ create trigger trg after delete on t1 for each row set @del:= 1; set @del:= 0; delete from t1 where i <> 0; select @del; -drop trigger t1.trg; +drop trigger trg; drop table t1; # Several triggers on one table @@ -144,9 +146,9 @@ update t1 set j= 20; select @fired; select * from t1; -drop trigger t1.trg1; -drop trigger t1.trg2; -drop trigger t1.trg3; +drop trigger trg1; +drop trigger trg2; +drop trigger trg3; drop table t1; @@ -200,9 +202,88 @@ drop table t1; # +# Let us test triggers which access other tables. +# +# Trivial trigger which inserts data into another table +create table t1 (id int primary key, data varchar(10), fk int); +create table t2 (event varchar(100)); +create table t3 (id int primary key); +create trigger t1_ai after insert on t1 for each row + insert into t2 values (concat("INSERT INTO t1 id=", new.id, " data='", new.data, "'")); +insert into t1 (id, data) values (1, "one"), (2, "two"); +select * from t1; +select * from t2; +drop trigger t1_ai; +# Trigger which uses couple of tables (and partially emulates FK constraint) +delimiter |; +create trigger t1_bi before insert on t1 for each row +begin + if exists (select id from t3 where id=new.fk) then + insert into t2 values (concat("INSERT INTO t1 id=", new.id, " data='", new.data, "' fk=", new.fk)); + else + insert into t2 values (concat("INSERT INTO t1 FAILED id=", new.id, " data='", new.data, "' fk=", new.fk)); + set new.id= NULL; + end if; +end| +delimiter ;| +insert into t3 values (1); +--error 1048 +insert into t1 values (4, "four", 1), (5, "five", 2); +select * from t1; +select * from t2; +drop table t1, t2, t3; +# Trigger which invokes function +create table t1 (id int primary key, data varchar(10)); +create table t2 (seq int); +insert into t2 values (10); +create function f1 () returns int return (select max(seq) from t2); +delimiter |; +create trigger t1_bi before insert on t1 for each row +begin + if new.id > f1() then + set new.id:= f1(); + end if; +end| +delimiter ;| +insert into t1 values (1, "first"); +insert into t1 values (f1(), "max"); +select * from t1; +drop table t1, t2; +drop function f1; +# Trigger which forces invocation of another trigger +# (emulation of FK on delete cascade policy) +create table t1 (id int primary key, fk_t2 int); +create table t2 (id int primary key, fk_t3 int); +create table t3 (id int primary key); +insert into t1 values (1,1), (2,1), (3,2); +insert into t2 values (1,1), (2,2); +insert into t3 values (1), (2); +create trigger t3_ad after delete on t3 for each row + delete from t2 where fk_t3=old.id; +create trigger t2_ad after delete on t2 for each row + delete from t1 where fk_t2=old.id; +delete from t3 where id = 1; +select * from t1 left join (t2 left join t3 on t2.fk_t3 = t3.id) on t1.fk_t2 = t2.id; +drop table t1, t2, t3; +# Trigger which assigns value selected from table to field of row +# being inserted/updated. +create table t1 (id int primary key, copy int); +create table t2 (id int primary key, data int); +insert into t2 values (1,1), (2,2); +create trigger t1_bi before insert on t1 for each row + set new.copy= (select data from t2 where id = new.id); +create trigger t1_bu before update on t1 for each row + set new.copy= (select data from t2 where id = new.id); +insert into t1 values (1,3), (2,4), (3,3); +update t1 set copy= 1 where id = 2; +select * from t1; +drop table t1, t2; + +# # Test of wrong column specifiers in triggers # create table t1 (i int); +create table t3 (i int); --error 1363 create trigger trg before insert on t1 for each row set @a:= old.i; @@ -222,7 +303,7 @@ create trigger trg before update on t1 for each row set @a:=old.j; # # Let us test various trigger creation errors -# +# Also quickly test table namespace (bug#5892/6182) # --error 1146 create trigger trg before insert on t2 for each row set @a:=1; @@ -232,17 +313,22 @@ create trigger trg before insert on t1 for each row set @a:=1; create trigger trg after insert on t1 for each row set @a:=1; --error 1359 create trigger trg2 before insert on t1 for each row set @a:=1; -drop trigger t1.trg; +--error 1359 +create trigger trg before insert on t3 for each row set @a:=1; +create trigger trg2 before insert on t3 for each row set @a:=1; +drop trigger trg2; +drop trigger trg; --error 1360 -drop trigger t1.trg; +drop trigger trg; create view v1 as select * from t1; ---error 1361 +--error 1347 create trigger trg before insert on v1 for each row set @a:=1; drop view v1; drop table t1; +drop table t3; create temporary table t1 (i int); --error 1361 @@ -260,7 +346,7 @@ drop table t1; create table t1 (x1col char); create trigger tx1 before insert on t1 for each row set new.x1col = 'x'; insert into t1 values ('y'); -drop trigger t1.tx1; +drop trigger tx1; drop table t1; # @@ -276,8 +362,8 @@ create trigger trg2 after delete on t1 for each row set @del_after:= @del_after set @del_before:=0, @del_after:= 0; delete from t1; select @del_before, @del_after; -drop trigger t1.trg1; -drop trigger t1.trg2; +drop trigger trg1; +drop trigger trg2; drop table t1; # Test for bug #5859 "DROP TABLE does not drop triggers". Trigger should not @@ -299,6 +385,19 @@ create trigger trg1 before insert on t1 for each row set @a:= 1; drop database mysqltest; use test; +# Test for bug #8791 +# "Triggers: Allowed to create triggers on a subject table in a different DB". +create database mysqltest; +create table mysqltest.t1 (i int); +--error ER_TRG_IN_WRONG_SCHEMA +create trigger trg1 before insert on mysqltest.t1 for each row set @a:= 1; +use mysqltest; +--error ER_TRG_IN_WRONG_SCHEMA +create trigger test.trg1 before insert on t1 for each row set @a:= 1; +drop database mysqltest; +use test; + + # Test for bug #5860 "Multi-table UPDATE does not activate update triggers" # We will also test how delete triggers wor for multi-table DELETE. create table t1 (i int, j int default 10, k int not null, key (k)); @@ -480,7 +579,7 @@ select * from t1; # To test properly code-paths different from those that are used # in ordinary INSERT we need to drop "before insert" trigger. alter table t1 add primary key (i); -drop trigger t1.bi; +drop trigger bi; --error 1054 insert into t1 values (2, 4) on duplicate key update k= k + 10; select * from t1; @@ -497,6 +596,8 @@ drop table t1, t2; # Test for bug #5893 "Triggers with dropped functions cause crashes" # Appropriate error should be reported instead of crash. +# Also test for bug #11889 "Server crashes when dropping trigger +# using stored routine". --disable_warnings drop function if exists bug5893; --enable_warnings @@ -507,4 +608,160 @@ create trigger t1_bu before update on t1 for each row set new.col1= bug5893(); drop function bug5893; --error 1305 update t1 set col2 = 4; +# This should not crash server too. +drop trigger t1_bu; +drop table t1; + +# +# storing and restoring parsing modes for triggers (BUG#5891) +# +set sql_mode='ansi'; +create table t1 ("t1 column" int); +create trigger t1_bi before insert on t1 for each row set new."t1 column" = 5; +set sql_mode=""; +insert into t1 values (0); +# create trigger with different sql_mode +create trigger t1_af after insert on t1 for each row set @a=10; +insert into t1 values (0); +select * from t1; +select @a; +--replace_column 6 # +show triggers; +drop table t1; +# check that rigger preserve sql_mode during execution +set sql_mode="traditional"; +create table t1 (a date); +-- error 1292 +insert into t1 values ('2004-01-00'); +set sql_mode=""; +create trigger t1_bi before insert on t1 for each row set new.a = '2004-01-00'; +set sql_mode="traditional"; +insert into t1 values ('2004-01-01'); +select * from t1; +set sql_mode=default; +show create table t1; +--replace_column 6 # +show triggers; +drop table t1; + +# Test for bug #12280 "Triggers: crash if flush tables" +# FLUSH TABLES and FLUSH PRIVILEGES should be disallowed inside +# of functions and triggers. +create table t1 (id int); +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create trigger t1_ai after insert on t1 for each row flush tables; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +create trigger t1_ai after insert on t1 for each row flush privileges; +create procedure p1() flush tables; +create trigger t1_ai after insert on t1 for each row call p1(); +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +insert into t1 values (0); +drop procedure p1; +create procedure p1() flush privileges; +--error ER_STMT_NOT_ALLOWED_IN_SF_OR_TRG +insert into t1 values (0); +drop procedure p1; drop table t1; + +# Test for bug #11973 "SELECT .. INTO var_name; in trigger cause +# crash on update" + +create table t1 (id int, data int, username varchar(16)); +insert into t1 (id, data) values (1, 0); +delimiter |; +create trigger t1_whoupdated before update on t1 for each row +begin + declare user varchar(32); + declare i int; + select user() into user; + set NEW.username = user; + select count(*) from ((select 1) union (select 2)) as d1 into i; +end| +delimiter ;| +update t1 set data = 1; + +connect (addconroot, localhost, root,,); +connection addconroot; +update t1 set data = 2; + +connection default; +disconnect addconroot; +drop table t1; + +# +# #11587 Trigger causes lost connection error +# + +create table t1 (c1 int, c2 datetime); +delimiter |; +--error ER_SP_NO_RETSET +create trigger tr1 before insert on t1 for each row +begin + set new.c2= '2004-04-01'; + select 'hello'; +end| +delimiter ;| + +insert into t1 (c1) values (1),(2),(3); +select * from t1; + +--disable_warnings +drop procedure if exists bug11587; +--enable_warnings + +delimiter |; +create procedure bug11587(x char(16)) +begin + select "hello"; + select "hello again"; +end| + +create trigger tr1 before insert on t1 for each row +begin + call bug11587(); + set new.c2= '2004-04-02'; +end| +delimiter ;| + +--error 1312 +insert into t1 (c1) values (4),(5),(6); +select * from t1; + +drop procedure bug11587; +drop table t1; + +# Test for bug #11896 "Partial locking in case of recursive trigger +# definitions". Recursion in triggers should not be allowed. +# We also should not allow to change tables which are used in +# statements invoking this trigger. +create table t1 (f1 integer); +create table t2 (f2 integer); +create trigger t1_ai after insert on t1 + for each row insert into t2 values (new.f1+1); +create trigger t2_ai after insert on t2 + for each row insert into t1 values (new.f2+1); +--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG +insert into t1 values (1); +select * from t1; +select * from t2; +drop trigger t1_ai; +drop trigger t2_ai; +create trigger t1_bu before update on t1 + for each row insert into t1 values (2); +--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG +update t1 set f1= 10; +select * from t1; +drop trigger t1_bu; +create trigger t1_bu before update on t1 + for each row delete from t1 where f1=new.f1; +--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG +update t1 set f1= 10; +select * from t1; +drop trigger t1_bu; +# This should work tough +create trigger t1_bi before insert on t1 + for each row set new.f1=(select sum(f1) from t1); +insert into t1 values (3); +select * from t1; +drop trigger t1_bi; +drop tables t1, t2; diff --git a/mysql-test/t/truncate.test b/mysql-test/t/truncate.test index b7ec506ecf1..f806bd8ec17 100644 --- a/mysql-test/t/truncate.test +++ b/mysql-test/t/truncate.test @@ -50,3 +50,5 @@ delete from t1; insert into t1 (a) values (NULL),(NULL); SELECT * from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/type_bit.test b/mysql-test/t/type_bit.test index fd5eb49858c..6906cfc2808 100644 --- a/mysql-test/t/type_bit.test +++ b/mysql-test/t/type_bit.test @@ -16,10 +16,10 @@ select 0 + b'1111111111111111'; select 0 + b'1000000000000001'; --disable_warnings -drop table if exists t1; +drop table if exists t1,t2; --enable_warnings ---error 1074 +--error 1439 create table t1 (a bit(65)); create table t1 (a bit(0)); diff --git a/mysql-test/t/type_bit_innodb.test b/mysql-test/t/type_bit_innodb.test index 693fc169717..ec433f40a88 100644 --- a/mysql-test/t/type_bit_innodb.test +++ b/mysql-test/t/type_bit_innodb.test @@ -20,7 +20,7 @@ select 0 + b'1000000000000001'; drop table if exists t1; --enable_warnings ---error 1074 +--error 1439 create table t1 (a bit(65)) engine=innodb; create table t1 (a bit(0)) engine=innodb; diff --git a/mysql-test/t/type_blob.test b/mysql-test/t/type_blob.test index 80aabf6c5e0..1ec5c600296 100644 --- a/mysql-test/t/type_blob.test +++ b/mysql-test/t/type_blob.test @@ -394,6 +394,8 @@ INSERT t1 (i, c) VALUES (1,''),(2,''),(3,'asdfh'),(4,''); select max(i) from t1 where c = ''; drop table t1; +# End of 4.1 tests + # # Bug#11657: Creation of secondary index fails # diff --git a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test index 304ed19b971..78bdd9b8a80 100644 --- a/mysql-test/t/type_date.test +++ b/mysql-test/t/type_date.test @@ -114,3 +114,5 @@ CREATE TABLE t1 (y YEAR); INSERT INTO t1 VALUES ('abc'); SELECT * FROM t1; DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/type_datetime.test b/mysql-test/t/type_datetime.test index a7eb78cb292..4b6741b4242 100644 --- a/mysql-test/t/type_datetime.test +++ b/mysql-test/t/type_datetime.test @@ -14,6 +14,17 @@ optimize table t1; check table t1; delete from t1; insert into t1 values("000101"),("691231"),("700101"),("991231"),("00000101"),("00010101"),("99991231"),("00101000000"),("691231000000"),("700101000000"),("991231235959"),("10000101000000"),("99991231235959"),("20030100000000"),("20030000000000"); + +# Strange dates +insert into t1 values ("2003-003-03"); + +# Bug #7308: ISO-8601 date format not handled correctly +insert into t1 values ("20030102T131415"),("2001-01-01T01:01:01"), ("2001-1-1T1:01:01"); +select * from t1; + +# Test some wrong dates +truncate table t1; +insert into t1 values("2003-0303 12:13:14"); select * from t1; drop table t1; @@ -101,3 +112,5 @@ insert into t1 values ("12-00-00"), ("00-00-00 01:00:00"); insert into t1 values ("00-00-00"), ("00-00-00 00:00:00"); select * from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 2901592fd9e..44032fde46f 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -268,7 +268,11 @@ insert into t1 values ('1'),('+1'),('-1'),('0000000001'),('+0000000001'),('-0000 select * from t1; drop table t1; +# End of 4.1 tests + +# # Test for BUG#8397: decimal type in subselects (Item_cache_decimal) +# CREATE TABLE t1 (EMPNUM CHAR(3) NOT NULL, HOURS DECIMAL(5)); diff --git a/mysql-test/t/type_enum.test b/mysql-test/t/type_enum.test index 6b2183df069..0d479f312cd 100644 --- a/mysql-test/t/type_enum.test +++ b/mysql-test/t/type_enum.test @@ -126,3 +126,5 @@ create table t1 (a set('x','y') default 'x'); --error 1067 alter table t1 alter a set default 'z'; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/type_float.test b/mysql-test/t/type_float.test index a27fd4c58b4..c0f1854d5b2 100644 --- a/mysql-test/t/type_float.test +++ b/mysql-test/t/type_float.test @@ -145,3 +145,5 @@ select * from t1 where reckey=1.08E2; select * from t1 where reckey=109; select * from t1 where reckey=1.09E2; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/type_nchar.test b/mysql-test/t/type_nchar.test index e85609e3f0c..f2258830450 100644 --- a/mysql-test/t/type_nchar.test +++ b/mysql-test/t/type_nchar.test @@ -33,3 +33,4 @@ create table t1 (c nchar varying(10)); show create table t1; drop table t1; +# End of 4.1 tests diff --git a/mysql-test/t/type_newdecimal.test b/mysql-test/t/type_newdecimal.test index 39c5888a1d9..f3be64506c7 100644 --- a/mysql-test/t/type_newdecimal.test +++ b/mysql-test/t/type_newdecimal.test @@ -908,18 +908,6 @@ SELECT * FROM t1; DROP TABLE t1; # -# Bug #10465 -# - ---disable_warnings -CREATE TABLE t1 (GRADE DECIMAL(4) NOT NULL, PRIMARY KEY (GRADE)) ENGINE=INNODB; ---enable_warnings -INSERT INTO t1 (GRADE) VALUES (151),(252),(343); -SELECT GRADE FROM t1 WHERE GRADE > 160 AND GRADE < 300; -SELECT GRADE FROM t1 WHERE GRADE= 151; -DROP TABLE t1; - -# # Bug #10599: problem with NULL # @@ -998,3 +986,32 @@ create table t1 (sl decimal(0,30)); create table t1 (sl decimal(5, 5)); show create table t1; drop table t1; +# Test limits +create table t1 (sl decimal(65, 30)); +show create table t1; +drop table t1; + +# +# Bug 11557 (DEFAULT values rounded improperly +# +create table t1 ( + f1 decimal unsigned not null default 17.49, + f2 decimal unsigned not null default 17.68, + f3 decimal unsigned not null default 99.2, + f4 decimal unsigned not null default 99.7, + f5 decimal unsigned not null default 104.49, + f6 decimal unsigned not null default 199.91, + f7 decimal unsigned not null default 999.9, + f8 decimal unsigned not null default 9999.99); +insert into t1 (f1) values (1); +select * from t1; +drop table t1; + +# +# Bug 12173 (show create table fails) +# +create table t1 ( + f0 decimal (30,30) zerofill not null DEFAULT 0, + f1 decimal (0,0) zerofill not null default 0); +show create table t1; +drop table t1; diff --git a/mysql-test/t/type_ranges.test b/mysql-test/t/type_ranges.test index a2deb367e14..03ee91f14d8 100644 --- a/mysql-test/t/type_ranges.test +++ b/mysql-test/t/type_ranges.test @@ -158,10 +158,19 @@ create table t2 ( id integer unsigned not null primary key ); insert into t1 values (1), (2); insert into t2 values (1); select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id ); +select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id); create table t3 (id_A integer unsigned not null, id_B integer unsigned null ); insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id ); select * from t3; +delete from t3; +insert into t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id); +select * from t3; drop table t3; create table t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 using ( id ); select * from t3; +drop table t3; +create table t3 select t1.id as id_A, t2.id as id_B from t1 left join t2 on (t1.id = t2.id); +select * from t3; drop table t1,t2,t3; + +# End of 4.1 tests diff --git a/mysql-test/t/type_set.test b/mysql-test/t/type_set.test index b6410a9ea3d..56df3328246 100644 --- a/mysql-test/t/type_set.test +++ b/mysql-test/t/type_set.test @@ -37,3 +37,5 @@ INSERT INTO t1 VALUES ('ae,oe,ue,ss'); SELECT c FROM t1 ORDER BY c; SELECT c FROM t1 ORDER BY concat(c); DROP TABLE t1; + +# End of 4.1 tests diff --git a/mysql-test/t/type_time.test b/mysql-test/t/type_time.test index 2f342f8bf67..7ae3f65f7cc 100644 --- a/mysql-test/t/type_time.test +++ b/mysql-test/t/type_time.test @@ -20,3 +20,5 @@ insert into t1 values ('09:00:00'),('13:00:00'),('19:38:34'), ('13:00:00'),('09: select t, time_to_sec(t),sec_to_time(time_to_sec(t)) from t1; select sec_to_time(time_to_sec(t)) from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/type_timestamp.test b/mysql-test/t/type_timestamp.test index 01d18afc5af..f96beedbebc 100644 --- a/mysql-test/t/type_timestamp.test +++ b/mysql-test/t/type_timestamp.test @@ -321,3 +321,4 @@ insert into t1 (a, c) values (4, '2004-04-04 00:00:00'), select * from t1; drop table t1; +# End of 4.1 tests diff --git a/mysql-test/t/type_uint.test b/mysql-test/t/type_uint.test index b1f59242e8e..a9212183cb6 100644 --- a/mysql-test/t/type_uint.test +++ b/mysql-test/t/type_uint.test @@ -13,3 +13,5 @@ insert into t1 values (-1); insert into t1 values ('5000000000'); select * from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/type_year.test b/mysql-test/t/type_year.test index c67b8447494..9744da24c02 100644 --- a/mysql-test/t/type_year.test +++ b/mysql-test/t/type_year.test @@ -20,3 +20,5 @@ create table t1 (y year); insert into t1 values (now()); select if(y = now(), 1, 0) from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 4da19622dcb..d4b0c1746af 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -276,7 +276,7 @@ create temporary table t1 select a from t1 union select a from t2; drop temporary table t1; --error 1093 create table t1 select a from t1 union select a from t2; ---error 1109 +--error 1054 select a from t1 union select a from t2 order by t2.a; drop table t1,t2; @@ -793,3 +793,5 @@ insert into t1 (col1) values (2),(3),(4),(5),(6); select 99 union all select id from t1 order by 1; select id from t1 union all select 99 order by 1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/update.test b/mysql-test/t/update.test index 21789a550b9..dd6c36d8414 100644 --- a/mysql-test/t/update.test +++ b/mysql-test/t/update.test @@ -201,3 +201,18 @@ analyze table t1,t2; update t1, t2 set t1.a = t2.a where t2.b = t1.b; show warnings; drop table t1, t2; + +# +# Bug #11868 Update with subquery with ref built with a key from the updated +# table crashes server +# +create table t1(f1 int, f2 int); +create table t2(f3 int, f4 int); +create index idx on t2(f3); +insert into t1 values(1,0),(2,0); +insert into t2 values(1,1),(2,2); +UPDATE t1 SET t1.f2=(SELECT MAX(t2.f4) FROM t2 WHERE t2.f3=t1.f1); +select * from t1; +drop table t1,t2; + +# End of 4.1 tests diff --git a/mysql-test/t/user_var-binlog.test b/mysql-test/t/user_var-binlog.test index 916a7dfa47b..004154339b2 100644 --- a/mysql-test/t/user_var-binlog.test +++ b/mysql-test/t/user_var-binlog.test @@ -17,3 +17,5 @@ show binlog events from 98; --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --exec $MYSQL_BINLOG --short-form $MYSQL_TEST_DIR/var/log/master-bin.000001 drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/user_var.test b/mysql-test/t/user_var.test index f8c441c7564..e3b5b4ef33e 100644 --- a/mysql-test/t/user_var.test +++ b/mysql-test/t/user_var.test @@ -122,6 +122,29 @@ set session @honk=99; set one_shot @honk=99; # +# Bug #10724 @@local not preserved in column name of select +# +# The value doesn't actually matter, we just care about the column name +--replace_column 1 # +select @@local.max_allowed_packet; +--replace_column 1 # +select @@session.max_allowed_packet; +--replace_column 1 # +select @@global.max_allowed_packet; +--replace_column 1 # +select @@max_allowed_packet; +--replace_column 1 # +select @@Max_Allowed_Packet; +--replace_column 1 # +select @@version; +--replace_column 1 # +select @@global.version; +--replace_column 1 # +select @@session.VERSION; + +# End of 4.1 tests + +# # Bug #6598: problem with cast(NULL as signed integer); # diff --git a/mysql-test/t/varbinary.test b/mysql-test/t/varbinary.test index 9425bd7bd99..5fbd116d7b8 100644 --- a/mysql-test/t/varbinary.test +++ b/mysql-test/t/varbinary.test @@ -35,3 +35,5 @@ select 0xfg; create table t1 select 1 as x, 2 as xx; select x,xx from t1; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/variables.test b/mysql-test/t/variables.test index c3ffdc79c16..7ce2cf22db0 100644 --- a/mysql-test/t/variables.test +++ b/mysql-test/t/variables.test @@ -390,9 +390,12 @@ SET GLOBAL table_cache=-1; SHOW VARIABLES LIKE 'table_cache'; SET GLOBAL table_cache=DEFAULT; +# End of 4.1 tests + # # Bug#6282 Packet error with SELECT INTO # + create table t1 (a int); select a into @x from t1; show warnings; @@ -406,3 +409,21 @@ drop table t1; set @@warning_count=1; --error 1238 set @@global.error_count=1; + +# +# Bug #10351: Setting ulong variable to > MAX_ULONG fails on 32-bit platform +# + +set @@max_heap_table_size= 4294967296; +select @@max_heap_table_size > 0; +set global max_heap_table_size= 4294967296; +select @@max_heap_table_size > 0; +set @@max_heap_table_size= 4294967296; +select @@max_heap_table_size > 0; + +# +# Bug #9613: @@have_innodb +# + +--replace_column 1 # +select @@have_innodb; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 6b6b3d8a00f..d786b61c8a8 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -83,8 +83,7 @@ explain extended select c from v6; # show table/table status test show tables; show full tables; ---replace_column 12 # 13 # ---replace_result 2147483647 38654705663 +--replace_column 8 # 12 # 13 # show table status; drop view v1,v2,v3,v4,v5,v6; @@ -148,10 +147,11 @@ insert into t1 values (1), (2), (3); create view v1 (a) as select a+1 from t1; create view v2 (a) as select a-1 from t1; -# WL #2486 should enable these tests -#select * from t1 natural left join v1; -#select * from v2 natural left join t1; -#select * from v2 natural left join v1; +--disable_parsing WL #2486 should enable these tests +select * from t1 natural left join v1; +select * from v2 natural left join t1; +select * from v2 natural left join v1; +--enable_parsing drop view v1, v2; drop table t1; @@ -491,15 +491,15 @@ create view v1 (a,a) as select 'a','a'; # # SP variables inside view test # -# QQ This can't be tested with the new table locking for functions, -# QQ since views created in an SP can't be used within the same SP -# QQ (just as for tables). Instead it fails with error 1146. -#delimiter //; -#create procedure p1 () begin declare v int; create view v1 as select v; end;// -#delimiter ;// -#-- error 1351 -#call p1(); -#drop procedure p1; +--disable_warnings +drop procedure if exists p1; +--enable_warnings +delimiter //; +create procedure p1 () begin declare v int; create view v1 as select v; end;// +delimiter ;// +-- error 1351 +call p1(); +drop procedure p1; # # updatablity should be transitive @@ -1183,7 +1183,7 @@ create view v1 as select * from t1 where s1 <> 127 with check option; insert into v1 values (0); select * from v1; select * from t1; -drop trigger t1.t1_bi; +drop trigger t1_bi; drop view v1; drop table t1; @@ -1675,6 +1675,27 @@ select * from v1; drop view v1; # +# evaluation constant functions in WHERE (BUG#4663) +# +create table t1 (a timestamp default now()); +create table t2 (b timestamp default now()); +create view v1 as select a,b,t1.a < now() from t1,t2 where t1.a < now(); +SHOW CREATE VIEW v1; +drop view v1; +drop table t1, t2; +CREATE TABLE t1 ( a varchar(50) ); +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = CURRENT_USER(); +SHOW CREATE VIEW v1; +DROP VIEW v1; +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = VERSION(); +SHOW CREATE VIEW v1; +DROP VIEW v1; +CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = DATABASE(); +SHOW CREATE VIEW v1; +DROP VIEW v1; +DROP TABLE t1; + +# # checking views after some view with error (BUG#11337) # CREATE TABLE t1 (col1 time); @@ -1690,6 +1711,10 @@ CHECK TABLE v1, v2, v3, v4, v5, v6; drop view v1, v2, v3, v4, v5, v6; drop table t2; +--disable_warnings +drop function if exists f1; +drop function if exists f2; +--enable_warnings CREATE TABLE t1 (col1 time); CREATE TABLE t2 (col1 time); CREATE TABLE t3 (col1 time); @@ -1763,6 +1788,16 @@ drop view v2,v1; drop table t1; # +# Bug#11399 Use an alias in a select statement on a view +# +create table t1 (f1 int); +insert into t1 values (1); +create view v1 as select f1 from t1; +select f1 as alias from v1; +drop view v1; +drop table t1; + +# # Test for bug #6120: SP cache to be invalidated when altering a view # @@ -1774,7 +1809,198 @@ CREATE PROCEDURE p1 () SELECT * FROM v1; CALL p1(); ALTER VIEW v1 AS SELECT s1 AS s1, s2 AS s2 FROM t1; CALL p1(); +DROP VIEW v1; +CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1; +CALL p1(); DROP PROCEDURE p1; DROP VIEW v1; DROP TABLE t1; + +# +# Test for bug #11709 View was ordered by wrong column +# +create table t1 (f1 int, f2 int); +create view v1 as select f1 as f3, f2 as f1 from t1; +insert into t1 values (1,3),(2,1),(3,2); +select * from v1 order by f1; +drop view v1; +drop table t1; + +# +# Test for bug #11771: wrong query_id in SELECT * FROM <view> +# +CREATE TABLE t1 (f1 char) ENGINE = innodb; +INSERT INTO t1 VALUES ('A'); +CREATE VIEW v1 AS SELECT * FROM t1; + +INSERT INTO t1 VALUES('B'); +SELECT * FROM v1; +SELECT * FROM t1; + +DROP VIEW v1; +DROP TABLE t1; + +# +# opening table in correct locking mode (BUG#9597) +# +CREATE TABLE t1 ( bug_table_seq INTEGER NOT NULL); +CREATE OR REPLACE VIEW v1 AS SELECT * from t1; +DROP PROCEDURE IF EXISTS p1; +delimiter //; +CREATE PROCEDURE p1 ( ) +BEGIN + DO (SELECT @next := IFNULL(max(bug_table_seq),0) + 1 FROM v1); + INSERT INTO t1 VALUES (1); +END // +delimiter ;// +CALL p1(); +DROP PROCEDURE p1; +DROP VIEW v1; +DROP TABLE t1; + +# +# Bug #11335 View redefines column types +# +create table t1 (f1 tinyint(1), f2 char(1), f3 varchar(1), f4 geometry, f5 datetime); +create view v1 as select * from t1; +desc v1; +drop view v1; +drop table t1; + +# +# Bug #11760 Typo in Item_func_add_time::print() results in NULLs returned +# subtime() in view +create table t1(f1 datetime); +insert into t1 values('2005.01.01 12:0:0'); +create view v1 as select f1, subtime(f1, '1:1:1') as sb from t1; +select * from v1; +drop view v1; +drop table t1; + +# +# Test for bug #11412: query over a multitable view with GROUP_CONCAT +# +CREATE TABLE t1 ( + aid int PRIMARY KEY, + fn varchar(20) NOT NULL, + ln varchar(20) NOT NULL +); +CREATE TABLE t2 ( + aid int NOT NULL, + pid int NOT NULL +); +INSERT INTO t1 VALUES(1,'a','b'), (2,'c','d'); +INSERT INTO t2 values (1,1), (2,1), (2,2); + +CREATE VIEW v1 AS SELECT t1.*,t2.pid FROM t1,t2 WHERE t1.aid = t2.aid; + +SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM t1,t2 + WHERE t1.aid = t2.aid GROUP BY pid; +SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM v1 GROUP BY pid; + +DROP VIEW v1; +DROP TABLE t1,t2; + +# +# Test for bug #12382: SELECT * FROM view after INSERT command +# + +CREATE TABLE t1 (id int PRIMARY KEY, f varchar(255)); +CREATE VIEW v1 AS SELECT id, f FROM t1 WHERE id <= 2; +INSERT INTO t1 VALUES (2, 'foo2'); +INSERT INTO t1 VALUES (1, 'foo1'); + +SELECT * FROM v1; +SELECT * FROM v1; + +DROP VIEW v1; +DROP TABLE t1; + +# +# Test for bug #12470: crash for a simple select from a view defined +# as a join over 5 tables + +CREATE TABLE t1 (pk int PRIMARY KEY, b int); +CREATE TABLE t2 (pk int PRIMARY KEY, fk int, INDEX idx(fk)); +CREATE TABLE t3 (pk int PRIMARY KEY, fk int, INDEX idx(fk)); +CREATE TABLE t4 (pk int PRIMARY KEY, fk int, INDEX idx(fk)); +CREATE TABLE t5 (pk int PRIMARY KEY, fk int, INDEX idx(fk)); +CREATE VIEW v1 AS + SELECT t1.pk as a FROM t1,t2,t3,t4,t5 + WHERE t1.b IS NULL AND + t1.pk=t2.fk AND t2.pk=t3.fk AND t3.pk=t4.fk AND t4.pk=t5.fk; + +SELECT a FROM v1; + +DROP VIEW v1; +DROP TABLE t1,t2,t3,t4,t5; + +# +# Bug #12298 Typo in function name results in erroneous view being created. +# +create view v1 as select timestampdiff(day,'1997-01-01 00:00:00','1997-01-02 00:00:00') as f1; +select * from v1; +drop view v1; + +# +# repeatable CREATE VIEW statement BUG#12468 +# +create table t1(a int); +create procedure p1() create view v1 as select * from t1; +drop table t1; +-- error 1146 +call p1(); +-- error 1146 +call p1(); +drop procedure p1; + +# +# Bug #10624 Views with multiple UNION and UNION ALL produce incorrect results +# +create table t1 (f1 int); +create table t2 (f1 int); +insert into t1 values (1); +insert into t2 values (2); +create view v1 as select * from t1 union select * from t2 union all select * from t2; +select * from v1; +drop view v1; +drop table t1,t2; +# +# Test for bug #10970: view referring a temporary table indirectly +# + +CREATE TEMPORARY TABLE t1 (a int); +CREATE FUNCTION f1 () RETURNS int RETURN (SELECT COUNT(*) FROM t1); +-- error 1352 +CREATE VIEW v1 AS SELECT f1(); + +DROP FUNCTION f1; +DROP TABLE t1; + +# +# BUG #12533 (crash on DESCRIBE <view> after renaming base table column) +# +--disable_warnings +DROP TABLE IF EXISTS t1; +DROP VIEW IF EXISTS v1; +--enable_warnings + +CREATE TABLE t1 (f4 CHAR(5)); +CREATE VIEW v1 AS SELECT * FROM t1; +DESCRIBE v1; + +ALTER TABLE t1 CHANGE COLUMN f4 f4x CHAR(5); +--error 1356 +DESCRIBE v1; +DROP TABLE t1; +DROP VIEW v1; + +# +# Bug #12489 wrongly printed strcmp() function results in creation of broken +# view +create table t1 (f1 char); +create view v1 as select strcmp(f1,'a') from t1; +select * from v1; +drop view v1; +drop table t1; diff --git a/mysql-test/t/warnings.test b/mysql-test/t/warnings.test index 314432af83e..f6ae7cdaf30 100644 --- a/mysql-test/t/warnings.test +++ b/mysql-test/t/warnings.test @@ -151,3 +151,5 @@ select * from t1 limit 0; select * from t1 limit 1, 0; select * from t1 limit 0, 0; drop table t1; + +# End of 4.1 tests diff --git a/mysql-test/t/windows.test b/mysql-test/t/windows.test new file mode 100644 index 00000000000..d6bcfeb8cb3 --- /dev/null +++ b/mysql-test/t/windows.test @@ -0,0 +1,20 @@ +# Windows-specific tests +--source include/windows.inc + +# +# Bug 9148: Denial of service +# +--error 1049 +use lpt1; +--error 1049 +use com1; +--error 1049 +use prn; + +# +# Bug #12325: Can't create table named 'nu' +# +create table nu (a int); +drop table nu; + +# End of 4.1 tests diff --git a/mysql-test/t/xa.test b/mysql-test/t/xa.test index 321e5008035..1347fd05415 100644 --- a/mysql-test/t/xa.test +++ b/mysql-test/t/xa.test @@ -31,6 +31,9 @@ xa end 'testa','testb'; connect (con1,localhost,,,); connection con1; +--error 1440 +xa start 'testa','testb'; + # gtrid [ , bqual [ , formatID ] ] xa start 0x7465737462, 0x2030405060, 0xb; insert t1 values (40); @@ -47,6 +50,7 @@ xa prepare 'testa','testb'; xa recover; +--error 1397 xa commit 'testb',0x2030405060,11; xa rollback 'testa','testb'; |