diff options
author | unknown <stewart@mysql.com> | 2005-08-19 00:39:56 +1000 |
---|---|---|
committer | unknown <stewart@mysql.com> | 2005-08-19 00:39:56 +1000 |
commit | b0dee441164b751c6393f08319c063a1a70d0e32 (patch) | |
tree | 00418d060ffeeaebd17a35fa1eb91f2e29961cc6 /mysql-test/t/select.test | |
parent | f2727ff26a160f981d300edd6cba79e49867db58 (diff) | |
parent | 749f599efa81de151401d0af33c4b31292727b15 (diff) | |
download | mariadb-git-b0dee441164b751c6393f08319c063a1a70d0e32.tar.gz |
merge fix
ndb/src/mgmapi/mgmapi.cpp:
merge
Diffstat (limited to 'mysql-test/t/select.test')
-rw-r--r-- | mysql-test/t/select.test | 233 |
1 files changed, 108 insertions, 125 deletions
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index ef26712af06..390c4372f16 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -1538,22 +1538,22 @@ select t2.fld1,t22.fld1 from t2,t2 t22 where t2.fld1 >= 250501 and t2.fld1 <= 25 # insert into t2 (fld1, companynr) values (999999,99); -select t2.companynr,companyname from t2 left join t4 using (companynr) where t4.companynr is null; -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; # # Test left join optimization -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 +2080,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 # @@ -2154,15 +2244,6 @@ SELECT K2C4, K4N4, F2I4 FROM t1 (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'); - -select found_rows(); -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; # @@ -2180,36 +2261,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 # @@ -2297,82 +2348,14 @@ DROP TABLE t1,t2; # select x'10' + 0, X'10' + 0, b'10' + 0, B'10' + 0; -# 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 #12595 # -# 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 * FROM t1; - -DROP TABLE t1; +CREATE TABLE BUG_12595(a varchar(100)); +INSERT INTO BUG_12595 VALUES ('hakan%'), ('hakank'), ("ha%an"); +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan*%' ESCAPE '*'; +-- error 1210 +SELECT * FROM BUG_12595 WHERE a LIKE 'hakan**%' ESCAPE '**'; +SELECT * FROM BUG_12595 WHERE a LIKE 'ha%%an' ESCAPE '%'; +DROP TABLE BUG_12595; |