diff options
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/mysql-test-run.sh | 8 | ||||
-rw-r--r-- | mysql-test/r/create.result | 13 | ||||
-rw-r--r-- | mysql-test/r/subselect.result | 50 | ||||
-rw-r--r-- | mysql-test/t/create.test | 16 | ||||
-rw-r--r-- | mysql-test/t/subselect.test | 25 |
5 files changed, 111 insertions, 1 deletions
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 8772e080874..0f45b8af1b0 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -428,6 +428,11 @@ if [ x$SOURCE_DIST = x1 ] ; then else MYSQL_TEST="$BASEDIR/client/mysqltest" fi + if [ -f "$BASEDIR/client/.libs/mysqldump" ] ; then + MYSQL_DUMP="$BASEDIR/client/.libs/mysqldump --no-defaults -uroot --socket=$MASTER_MYSOCK" + else + MYSQL_DUMP="$BASEDIR/client/mysqldump --no-defaults -uroot --socket=$MASTER_MYSOCK" + fi if [ -n "$STRACE_CLIENT" ]; then MYSQL_TEST="strace -o $MYSQL_TEST_DIR/var/log/mysqltest.strace $MYSQL_TEST" fi @@ -449,6 +454,7 @@ else MYSQLD="$VALGRIND $BASEDIR/bin/mysqld" fi MYSQL_TEST="$BASEDIR/bin/mysqltest" + MYSQL_DUMP="$BASEDIR/bin/mysqldump --no-defaults -uroot --socket=$MASTER_MYSOCK" MYSQLADMIN="$BASEDIR/bin/mysqladmin" WAIT_PID="$BASEDIR/bin/mysql_waitpid" MYSQL_MANAGER="$BASEDIR/bin/mysqlmanager" @@ -466,6 +472,8 @@ else fi fi +export MYSQL_DUMP + if [ -z "$MASTER_MYSQLD" ] then MASTER_MYSQLD=$MYSQLD diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 80ff8aef15b..06ddd5e2280 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -361,3 +361,16 @@ a b c d e f g h dd 1 -7 7 2000-01-01 b 2000-01-01 00:00:00 05:04:03 yet another binary data 02:00:00 2 -2 2 1825-12-14 a 2003-01-01 03:02:01 04:03:02 binary data 02:00:00 drop table t1, t2; +drop database if exists test_$1; +create database test_$1; +use test_$1; +select database(); +database() +test_$1 +drop database test_$1; +select database(); +database() +NULL +select database(); +database() +NULL diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index dd8aeba8563..2c0947346be 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -42,6 +42,9 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY <derived2> system NULL NULL NULL NULL 1 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used 2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1275 Field or reference 'a' of SELECT #3 was resolved in SELECT #1 +Note 1275 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; 1 1 @@ -207,6 +210,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t4 ALL NULL NULL NULL NULL 3 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 Using where +Warnings: +Note 1275 Field or reference 't4.a' of SELECT #3 was resolved in SELECT #1 select * from t3 where exists (select * from t2 where t2.b=t3.a); a 7 @@ -286,6 +291,9 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 Using where +Warnings: +Note 1275 Field or reference 't2.a' of SELECT #2 was resolved in SELECT #1 +Note 1275 Field or reference 't2.a' of SELECT #3 was resolved in SELECT #1 select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subselect returns more than 1 record create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); @@ -301,6 +309,8 @@ explain select * from t6 where exists (select * from t7 where uq = clinic_uq); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t6 ALL NULL NULL NULL NULL 4 Using where 2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 +Warnings: +Note 1275 Field or reference 'clinic_uq' of SELECT #2 was resolved in SELECT #1 select * from t1 where a= (select a from t2,t4 where t2.b=t4.b); ERROR 23000: Column: 'a' in field list is ambiguous drop table if exists t1,t2,t3; @@ -809,6 +819,7 @@ explain select (select a+1) from t1; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Warnings: +Note 1275 Field or reference 'a' of SELECT #2 was resolved in SELECT #1 Note 1248 Select 2 was reduced during optimisation select (select a+1) from t1; (select a+1) @@ -829,7 +840,7 @@ a t1.a in (select t2.a from t2) explain SELECT t1.a, t1.a in (select t2.a from t2) FROM t1; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 index NULL PRIMARY 4 NULL 4 Using index -2 DEPENDENT SUBQUERY t2 index_in a a 5 func 2 Using where; Using index +2 DEPENDENT SUBQUERY t2 index_in a a 5 func 2 Using index CREATE TABLE t3 (a int(11) default '0'); INSERT INTO t3 VALUES (1),(2),(3); SELECT t1.a, t1.a in (select t2.a from t2,t3 where t3.a=t2.a) FROM t1; @@ -1361,3 +1372,40 @@ userid pmtotal pmnew calc_total calc_new 1 0 0 9 3 2 0 0 4 2 drop table t1, t2; +create table t1 (s1 char(5)); +select (select 'a','b' from t1 union select 'a','b' from t1) from t1; +ERROR 21000: Cardinality error (more/less than 1 columns) +insert into t1 values ('tttt'); +select * from t1 where ('a','b')=(select 'a','b' from t1 union select 'a','b' from t1); +s1 +tttt +explain (select * from t1); +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 +(select * from t1); +s1 +tttt +drop table t1; +create table t1 (s1 char(5), index s1(s1)); +create table t2 (s1 char(5), index s1(s1)); +insert into t1 values ('a1'),('a2'),('a3'); +insert into t2 values ('a1'),('a2'); +select s1, s1 NOT IN (SELECT s1 FROM t2) from t1; +s1 s1 NOT IN (SELECT s1 FROM t2) +a1 0 +a2 0 +a3 1 +select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; +s1 s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') +a1 0 +a2 1 +a3 1 +explain select s1, s1 NOT IN (SELECT s1 FROM t2) from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 index NULL s1 6 NULL 3 Using index +2 DEPENDENT SUBQUERY t2 index_in s1 s1 6 func 2 Using index +explain select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY t1 index NULL s1 6 NULL 3 Using index +2 DEPENDENT SUBQUERY t2 index_in s1 s1 6 func 1 Using index; Using where +drop table t1,t2; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 2e21768dc0b..0b86b67fdbf 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -260,3 +260,19 @@ select * from t2; drop table t1, t2; +# +# Bug #1209 +# + +--disable_warnings +drop database if exists test_$1; +--enable_warnings +create database test_$1; +use test_$1; +select database(); +drop database test_$1; +select database(); + +# Connect without a database +connect (user4,localhost,mysqltest_1,,*NO-ONE*); +select database(); diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index c9dba498428..304e5939718 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -922,3 +922,28 @@ insert into t2 values(1,0,0),(2,0,0); insert into t1 values(1,0),(1,0),(1,0),(1,12),(1,15),(1,123),(1,12312),(1,12312),(1,123),(2,0),(2,0),(2,1),(2,2); select userid,pmtotal,pmnew, (select count(rd) from t1 where toid=t2.userid) calc_total, (select count(rd) from t1 where rd=0 and toid=t2.userid) calc_new from t2 where userid in (select distinct toid from t1); drop table t1, t2; + +# +# row union +# +create table t1 (s1 char(5)); +-- error 1240 +select (select 'a','b' from t1 union select 'a','b' from t1) from t1; +insert into t1 values ('tttt'); +select * from t1 where ('a','b')=(select 'a','b' from t1 union select 'a','b' from t1); +explain (select * from t1); +(select * from t1); +drop table t1; + +# +# IN optimisation test results +# +create table t1 (s1 char(5), index s1(s1)); +create table t2 (s1 char(5), index s1(s1)); +insert into t1 values ('a1'),('a2'),('a3'); +insert into t2 values ('a1'),('a2'); +select s1, s1 NOT IN (SELECT s1 FROM t2) from t1; +select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; +explain select s1, s1 NOT IN (SELECT s1 FROM t2) from t1; +explain select s1, s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2') from t1; +drop table t1,t2; |