diff options
author | gluh@eagle.(none) <> | 2007-01-24 19:54:40 +0400 |
---|---|---|
committer | gluh@eagle.(none) <> | 2007-01-24 19:54:40 +0400 |
commit | 7b291e36cfd441dc7a719a1d1ecd6d3c1e084d5d (patch) | |
tree | f775cabca54ceb5c24dfb0a8166ff2a9d78c7644 /mysql-test/t | |
parent | 76d419137978846dd1fb5eb8bae35c26add3c938 (diff) | |
parent | 7fd3cd9e41ecab372105ec998083a79756472785 (diff) | |
download | mariadb-git-7b291e36cfd441dc7a719a1d1ecd6d3c1e084d5d.tar.gz |
Merge mysql.com:/home/gluh/MySQL/Merge/5.1
into mysql.com:/home/gluh/MySQL/Merge/5.1-opt
Diffstat (limited to 'mysql-test/t')
-rw-r--r-- | mysql-test/t/delete.test | 11 | ||||
-rw-r--r-- | mysql-test/t/func_in.test | 38 | ||||
-rw-r--r-- | mysql-test/t/func_math.test | 24 | ||||
-rw-r--r-- | mysql-test/t/func_str.test | 8 | ||||
-rw-r--r-- | mysql-test/t/gis.test | 10 | ||||
-rw-r--r-- | mysql-test/t/group_by.test | 51 | ||||
-rw-r--r-- | mysql-test/t/information_schema_inno.test | 7 | ||||
-rw-r--r-- | mysql-test/t/innodb.test | 6 | ||||
-rw-r--r-- | mysql-test/t/innodb_gis.test | 6 | ||||
-rw-r--r-- | mysql-test/t/insert.test | 17 | ||||
-rw-r--r-- | mysql-test/t/order_by.test | 13 | ||||
-rw-r--r-- | mysql-test/t/partition.test | 93 | ||||
-rw-r--r-- | mysql-test/t/range.test | 43 | ||||
-rw-r--r-- | mysql-test/t/select.test | 10 | ||||
-rw-r--r-- | mysql-test/t/subselect.test | 34 | ||||
-rw-r--r-- | mysql-test/t/trigger.test | 46 | ||||
-rw-r--r-- | mysql-test/t/udf.test | 47 | ||||
-rw-r--r-- | mysql-test/t/view.test | 60 |
18 files changed, 500 insertions, 24 deletions
diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index 865e1746fd3..306447dbd5a 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -163,6 +163,17 @@ delete `4.t1` from t1 as `4.t1` where `4.t1`.a = 5; delete FROM `4.t1` USING t1 as `4.t1` where `4.t1`.a = 5; drop table t1; +# +# Bug#17711: DELETE doesn't use index when ORDER BY, LIMIT and +# non-restricting WHERE is present. +# +create table t1(f1 int primary key); +insert into t1 values (4),(3),(1),(2); +delete from t1 where (@a:= f1) order by f1 limit 1; +select @a; +drop table t1; + +--echo End of 4.1 tests # End of 4.1 tests # diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test index 75d85065419..b5afdc122a3 100644 --- a/mysql-test/t/func_in.test +++ b/mysql-test/t/func_in.test @@ -261,6 +261,44 @@ select some_id from t1 where some_id not in('-1', '0'); drop table t1; +# TODO:Disabled until re-resolution of bug #20420 for 5.1. +# Results must be the same as in 5.0 +## +## BUG#20420: optimizer reports wrong keys on left join with IN +## +#CREATE TABLE t1 (a int, b int, PRIMARY KEY (a)); +#INSERT INTO t1 VALUES (1,1),(2,1),(3,1),(4,1),(5,1),(6,1); +# +#CREATE TABLE t2 (a int, b int, PRIMARY KEY (a)); +#INSERT INTO t2 VALUES (3,2),(4,2),(100,100),(101,201),(102,102); +# +#CREATE TABLE t3 (a int PRIMARY KEY); +#INSERT INTO t3 VALUES (1),(2),(3),(4); +# +#CREATE TABLE t4 (a int PRIMARY KEY,b int); +#INSERT INTO t4 VALUES (1,1),(2,2),(1000,1000),(1001,1001),(1002,1002),(1003,1003),(1004,1004); +# +#EXPLAIN SELECT STRAIGHT_JOIN * FROM t3 +# JOIN t1 ON t3.a=t1.a +# JOIN t2 ON t3.a=t2.a +# JOIN t4 WHERE t4.a IN (t1.b, t2.b); +# +#SELECT STRAIGHT_JOIN * FROM t3 +# JOIN t1 ON t3.a=t1.a +# JOIN t2 ON t3.a=t2.a +# JOIN t4 WHERE t4.a IN (t1.b, t2.b); +# +#EXPLAIN SELECT STRAIGHT_JOIN +# (SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +# FROM t3, t1, t2 +# WHERE t3.a=t1.a AND t3.a=t2.a; +# +#SELECT STRAIGHT_JOIN +# (SELECT SUM(t4.a) FROM t4 WHERE t4.a IN (t1.b, t2.b)) +# FROM t3, t1, t2 +# WHERE t3.a=t1.a AND t3.a=t2.a; +# +#DROP TABLE t1,t2,t3,t4; --echo End of 5.0 tests diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test index 09aa5751301..639ced6a1c0 100644 --- a/mysql-test/t/func_math.test +++ b/mysql-test/t/func_math.test @@ -115,11 +115,25 @@ select abs(-2) * -2; # # Bug #6172 RAND(a) should only accept constant values as arguments # -create table t1 (i int); -insert into t1 values (1); ---error 1210 -select rand(i) from t1; -drop table t1; +CREATE TABLE t1 (a INT); + +INSERT INTO t1 VALUES (1),(1),(1),(2); +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) + FROM t1; +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) + FROM t1 WHERE a = 1; +INSERT INTO t1 VALUES (3); +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) + FROM t1; +SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(a) * 1000 AS UNSIGNED) + FROM t1 WHERE a = 1; +PREPARE stmt FROM + "SELECT CAST(RAND(2) * 1000 AS UNSIGNED), CAST(RAND(?) * 1000 AS UNSIGNED) + FROM t1 WHERE a = 1"; +set @var=2; +EXECUTE stmt USING @var; + +DROP TABLE t1; # # Bug #14009: use of abs() on null value causes problems with filesort diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index ab072f0e692..535af6907ad 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -774,6 +774,14 @@ EXPLAIN EXTENDED SELECT s FROM t1 WHERE TRIM(BOTH 'y' FROM s) > 'ab'; DROP TABLE t1; +# +# Bug#23409: ENCODE() and DECODE() functions aren't printed correctly +# +create table t1(f1 varchar(4)); +explain extended select encode(f1,'zxcv') as 'enc' from t1; +explain extended select decode(f1,'zxcv') as 'enc' from t1; +drop table t1; + --echo End of 4.1 tests # diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 196ff5b8ff0..d1ea8dbe18f 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -428,3 +428,13 @@ drop table t1; create table t1 select GeomFromText('point(1 1)'); desc t1; 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; + diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 7f887335753..76e4af8f610 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -703,6 +703,57 @@ SELECT SQL_BIG_RESULT b, sum(1) FROM t1 GROUP BY b; DROP TABLE t1; # +# Bug #23417: Too strict checks against GROUP BY in the ONLY_FULL_GROUP_BY mode +# +CREATE TABLE t1 (a INT PRIMARY KEY, b INT); +INSERT INTO t1 VALUES (1,1),(2,1),(3,2),(4,2),(5,3),(6,3); + +SET SQL_MODE = 'ONLY_FULL_GROUP_BY'; +SELECT MAX(a)-MIN(a) FROM t1 GROUP BY b; +SELECT CEILING(MIN(a)) FROM t1 GROUP BY b; +SELECT CASE WHEN AVG(a)>=0 THEN 'Positive' ELSE 'Negative' END FROM t1 + GROUP BY b; +SELECT a + 1 FROM t1 GROUP BY a; +--error ER_WRONG_FIELD_WITH_GROUP +SELECT a + b FROM t1 GROUP BY b; +SELECT (SELECT t1_outer.a FROM t1 AS t1_inner GROUP BY b LIMIT 1) + FROM t1 AS t1_outer; +SELECT 1 FROM t1 as t1_outer GROUP BY a + HAVING (SELECT t1_outer.a FROM t1 AS t1_inner GROUP BY b LIMIT 1); +--error ER_WRONG_FIELD_WITH_GROUP +SELECT (SELECT t1_outer.a FROM t1 AS t1_inner LIMIT 1) + FROM t1 AS t1_outer GROUP BY t1_outer.b; +--error ER_BAD_FIELD_ERROR +SELECT 1 FROM t1 as t1_outer GROUP BY a + HAVING (SELECT t1_outer.b FROM t1 AS t1_inner LIMIT 1); +SELECT (SELECT SUM(t1_inner.a) FROM t1 AS t1_inner LIMIT 1) + FROM t1 AS t1_outer GROUP BY t1_outer.b; +SELECT (SELECT SUM(t1_inner.a) FROM t1 AS t1_inner GROUP BY t1_inner.b LIMIT 1) + FROM t1 AS t1_outer; +--error ER_WRONG_FIELD_WITH_GROUP +SELECT (SELECT SUM(t1_outer.a) FROM t1 AS t1_inner LIMIT 1) + FROM t1 AS t1_outer GROUP BY t1_outer.b; + +SELECT 1 FROM t1 as t1_outer + WHERE (SELECT t1_outer.b FROM t1 AS t1_inner GROUP BY t1_inner.b LIMIT 1); + +SELECT b FROM t1 GROUP BY b HAVING CEILING(b) > 0; + +SELECT 1 FROM t1 GROUP BY b HAVING b = 2 OR b = 3 OR SUM(a) > 12; +SELECT 1 FROM t1 GROUP BY b HAVING ROW (b,b) = ROW (1,1); + +--error ER_BAD_FIELD_ERROR +SELECT 1 FROM t1 GROUP BY b HAVING a = 2; +--error ER_INVALID_GROUP_FUNC_USE +SELECT 1 FROM t1 GROUP BY SUM(b); +--error ER_WRONG_FIELD_WITH_GROUP +SELECT b FROM t1 AS t1_outer GROUP BY a HAVING t1_outer.a IN + (SELECT SUM(t1_inner.b)+t1_outer.b FROM t1 AS t1_inner GROUP BY t1_inner.a + HAVING SUM(t1_inner.b)+t1_outer.b > 5); +DROP TABLE t1; +SET SQL_MODE = ''; + +# # Bug #21174: Index degrades sort performance and # optimizer does not honor IGNORE INDEX # diff --git a/mysql-test/t/information_schema_inno.test b/mysql-test/t/information_schema_inno.test index 014bdacfeea..e73f4ba2792 100644 --- a/mysql-test/t/information_schema_inno.test +++ b/mysql-test/t/information_schema_inno.test @@ -32,11 +32,11 @@ CREATE TABLE t2(b1 INT, b2 INT, INDEX (b1, b2), CONSTRAINT A1 FOREIGN KEY (b1, b2) REFERENCES t1(a1, a2) ON UPDATE CASCADE ON DELETE NO ACTION) ENGINE=INNODB; -CREATE TABLE t3(b1 INT, b2 INT, INDEX (b1, b2), +CREATE TABLE t3(b1 INT, b2 INT, INDEX t3_indx (b1, b2), CONSTRAINT A2 FOREIGN KEY (b1, b2) REFERENCES t2(b1, b2) ON UPDATE SET NULL ON DELETE RESTRICT) ENGINE=INNODB; -CREATE TABLE t4(b1 INT, b2 INT, INDEX (b1, b2), +CREATE TABLE t4(b1 INT, b2 INT, UNIQUE KEY t4_ukey (b1, b2), CONSTRAINT A3 FOREIGN KEY (b1, b2) REFERENCES t3(b1, b2) ON UPDATE NO ACTION ON DELETE SET NULL) ENGINE=INNODB; @@ -45,10 +45,9 @@ CREATE TABLE t5(b1 INT, b2 INT, INDEX (b1, b2), FOREIGN KEY (b1, b2) REFERENCES t4(b1, b2) ON UPDATE RESTRICT ON DELETE CASCADE) ENGINE=INNODB; - select a.CONSTRAINT_SCHEMA, b.TABLE_NAME, CONSTRAINT_TYPE, b.CONSTRAINT_NAME, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME, - MATCH_OPTION, UPDATE_RULE, DELETE_RULE + MATCH_OPTION, UPDATE_RULE, DELETE_RULE, b.REFERENCED_TABLE_NAME from information_schema.TABLE_CONSTRAINTS a, information_schema.REFERENTIAL_CONSTRAINTS b where a.CONSTRAINT_SCHEMA = 'test' and a.CONSTRAINT_SCHEMA = b.CONSTRAINT_SCHEMA and diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index e1e74ac8a11..bbecd787324 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -2489,12 +2489,6 @@ SELECT p0.a FROM t2 p0 WHERE BINARY p0.b = 'customer_over'; drop table t2, t1; # -# Bug #15680 (SPATIAL key in innodb) -# ---error ER_TABLE_CANT_HANDLE_SPKEYS -create table t1 (g geometry not null, spatial gk(g)) engine=innodb; - -# # Test optimize on table with open transaction # diff --git a/mysql-test/t/innodb_gis.test b/mysql-test/t/innodb_gis.test index 142b526af92..9675b6b69dc 100644 --- a/mysql-test/t/innodb_gis.test +++ b/mysql-test/t/innodb_gis.test @@ -1,3 +1,9 @@ --source include/have_innodb.inc SET storage_engine=innodb; --source include/gis_generic.inc + +# +# Bug #15680 (SPATIAL key in innodb) +# +--error ER_TABLE_CANT_HANDLE_SPKEYS +create table t1 (g geometry not null, spatial gk(g)) engine=innodb; diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test index 398b0bc89d8..0a6b081e7c3 100644 --- a/mysql-test/t/insert.test +++ b/mysql-test/t/insert.test @@ -225,6 +225,23 @@ insert into t1 values (5, 5) on duplicate key update data= data + 10; select row_count(); drop table t1; +# +# Bug#25123: ON DUPLICATE KEY clause allows fields not from the insert table +# +create table t1 (f1 int unique, f2 int); +create table t2 (f3 int, f4 int); +create view v1 as select * from t1, t2 where f1= f3; +insert into t1 values (1,11), (2,22); +insert into t2 values (1,12), (2,24); +--error 1393 +insert into v1 (f1) values (3) on duplicate key update f3= f3 + 10; +insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10; +select * from t1; +insert into v1 (f1) values (3) on duplicate key update f1= f3 + 10; +select * from t1; +drop view v1; +drop table t1,t2; + # Test of INSERT IGNORE and re-using auto_increment values create table t1 (id int primary key auto_increment, data int, unique(data)); insert ignore into t1 values(NULL,100),(NULL,110),(NULL,120); diff --git a/mysql-test/t/order_by.test b/mysql-test/t/order_by.test index 012b38ff8b7..15fb6771101 100644 --- a/mysql-test/t/order_by.test +++ b/mysql-test/t/order_by.test @@ -640,3 +640,16 @@ SELECT t2.b FROM t1 LEFT JOIN (t2, t3 LEFT JOIN t4 ON t3.a=t4.a) ON (t1.a=t2.a AND t1.b=t3.b) order by t2.b; DROP TABLE t1,t2,t3,t4; + +# +# BUG#16590: Optimized does not do right "const" table pre-read +# +CREATE TABLE t1 (a INT, b INT, PRIMARY KEY (a), UNIQUE KEY b (b)); +INSERT INTO t1 VALUES (1,1),(2,2); + +CREATE TABLE t2 (a INT, b INT, KEY a (a,b)); +INSERT INTO t2 VALUES (1,1),(1,2),(2,1),(2,2); + +EXPLAIN SELECT 1 FROM t1,t2 WHERE t1.b=2 AND t1.a=t2.a ORDER BY t2.b; + +DROP TABLE t1,t2; diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test index 02c7ca0b05c..7d7ef95626a 100644 --- a/mysql-test/t/partition.test +++ b/mysql-test/t/partition.test @@ -1370,4 +1370,97 @@ REORGANIZE PARTITION p_X INTO ( drop table t1; +# +# Bug #24186 (nested query across partitions returns fewer records) +# + +CREATE TABLE t2 ( + taken datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + id int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (id,taken), + KEY taken (taken) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +INSERT INTO t2 VALUES +('2006-09-27 21:50:01',16421), +('2006-10-02 21:50:01',16421), +('2006-09-27 21:50:01',19092), +('2006-09-28 21:50:01',19092), +('2006-09-29 21:50:01',19092), +('2006-09-30 21:50:01',19092), +('2006-10-01 21:50:01',19092), +('2006-10-02 21:50:01',19092), +('2006-09-27 21:50:01',22589), +('2006-09-29 21:50:01',22589); + +CREATE TABLE t1 ( + id int(8) NOT NULL, + PRIMARY KEY (id) +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +INSERT INTO t1 VALUES +(16421), +(19092), +(22589); + +CREATE TABLE t4 ( + taken datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + id int(11) NOT NULL DEFAULT '0', + PRIMARY KEY (id,taken), + KEY taken (taken) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +PARTITION BY RANGE (to_days(taken)) +( +PARTITION p01 VALUES LESS THAN (732920) , +PARTITION p02 VALUES LESS THAN (732950) , +PARTITION p03 VALUES LESS THAN MAXVALUE ) ; + +INSERT INTO t4 select * from t2; + +set @f_date='2006-09-28'; +set @t_date='2006-10-02'; + +SELECT t1.id AS MyISAM_part +FROM t1 +WHERE t1.id IN ( + SELECT distinct id + FROM t4 + WHERE taken BETWEEN @f_date AND date_add(@t_date, INTERVAL 1 DAY)) +ORDER BY t1.id +; + +drop table t1, t2, t4; + +CREATE TABLE t1 ( + taken datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + id int(11) NOT NULL DEFAULT '0', + status varchar(20) NOT NULL DEFAULT '', + PRIMARY KEY (id,taken) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +PARTITION BY RANGE (to_days(taken)) +( +PARTITION p15 VALUES LESS THAN (732950) , +PARTITION p16 VALUES LESS THAN MAXVALUE ) ; + + +INSERT INTO t1 VALUES +('2006-09-27 21:50:01',22589,'Open'), +('2006-09-29 21:50:01',22589,'Verified'); + +DROP TABLE IF EXISTS t2; +CREATE TABLE t2 ( + id int(8) NOT NULL, + severity tinyint(4) NOT NULL DEFAULT '0', + priority tinyint(4) NOT NULL DEFAULT '0', + status varchar(20) DEFAULT NULL, + alien tinyint(4) NOT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1; + +INSERT INTO t2 VALUES +(22589,1,1,'Need Feedback',0); + +SELECT t2.id FROM t2 WHERE t2.id IN (SELECT id FROM t1 WHERE status = 'Verified'); + +drop table t1, t2; + --echo End of 5.1 tests diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index af90b6cd4f0..b1cec049ab2 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -525,6 +525,49 @@ explain select a from t1 where a > 'x'; select a from t1 where a > 'x'; drop table t1; +# +# Bug #24776: assertion abort for 'range checked for each record' +# + +CREATE TABLE t1 ( + OXID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '', + OXPARENTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT 'oxrootid', + OXLEFT int NOT NULL DEFAULT '0', + OXRIGHT int NOT NULL DEFAULT '0', + OXROOTID varchar(32) COLLATE latin1_german2_ci NOT NULL DEFAULT '', + PRIMARY KEY (OXID), + KEY OXNID (OXID), + KEY OXLEFT (OXLEFT), + KEY OXRIGHT (OXRIGHT), + KEY OXROOTID (OXROOTID) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_german2_ci; + +INSERT INTO t1 VALUES +('d8c4177d09f8b11f5.52725521','oxrootid',1,40,'d8c4177d09f8b11f5.52725521'), +('d8c4177d151affab2.81582770','d8c4177d09f8b11f5.52725521',2,3, + 'd8c4177d09f8b11f5.52725521'), +('d8c4177d206a333d2.74422679','d8c4177d09f8b11f5.52725521',4,5, + 'd8c4177d09f8b11f5.52725521'), +('d8c4177d225791924.30714720','d8c4177d09f8b11f5.52725521',6,7, + 'd8c4177d09f8b11f5.52725521'), +('d8c4177d2380fc201.39666693','d8c4177d09f8b11f5.52725521',8,9, + 'd8c4177d09f8b11f5.52725521'), +('d8c4177d24ccef970.14957924','d8c4177d09f8b11f5.52725521',10,11, + 'd8c4177d09f8b11f5.52725521'); + +EXPLAIN +SELECT s.oxid FROM t1 v, t1 s + WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND + v.oxrootid ='d8c4177d09f8b11f5.52725521' AND + s.oxleft > v.oxleft AND s.oxleft < v.oxright; + +SELECT s.oxid FROM t1 v, t1 s + WHERE s.oxrootid = 'd8c4177d09f8b11f5.52725521' AND + v.oxrootid ='d8c4177d09f8b11f5.52725521' AND + s.oxleft > v.oxleft AND s.oxleft < v.oxright; + +DROP TABLE t1; + --echo End of 4.1 tests # diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 0e7361218aa..fbb2b4d8d3d 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3104,6 +3104,16 @@ SELECT t3.a FROM t1,t2,t3 t3.c IN ('bb','ee'); DROP TABLE t1,t2,t3; + +# +# Bug#25172: Not checked buffer size leads to a server crash +# +CREATE TABLE t1 ( f1 int primary key, f2 int, f3 int, f4 int, f5 int, f6 int, checked_out int); +CREATE TABLE t2 ( f11 int PRIMARY KEY ); +INSERT INTO t1 VALUES (1,1,1,0,0,0,0),(2,1,1,3,8,1,0),(3,1,1,4,12,1,0); +INSERT INTO t2 VALUES (62); +SELECT * FROM t1 LEFT JOIN t2 ON f11 = t1.checked_out GROUP BY f1 ORDER BY f2, f3, f4, f5 LIMIT 0, 1; +DROP TABLE t1, t2; # # Bug#6298: LIMIT #, -1 no longer works to set start with no end limit diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index eefa2528a17..98471622bc5 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2510,6 +2510,40 @@ SELECT SQL_NO_CACHE COUNT(*) DROP TABLE t1,t2; # +# Bug #25219: EXIST subquery with UNION over a mix of +# correlated and uncorrelated selects +# + +CREATE TABLE t1 (id char(4) PRIMARY KEY, c int); +CREATE TABLE t2 (c int); + +INSERT INTO t1 VALUES ('aa', 1); +INSERT INTO t2 VALUES (1); + +SELECT * FROM t1 + WHERE EXISTS (SELECT c FROM t2 WHERE c=1 + UNION + SELECT c from t2 WHERE c=t1.c); + +INSERT INTO t1 VALUES ('bb', 2), ('cc', 3), ('dd',1); + +SELECT * FROM t1 + WHERE EXISTS (SELECT c FROM t2 WHERE c=1 + UNION + SELECT c from t2 WHERE c=t1.c); + +INSERT INTO t2 VALUES (2); +CREATE TABLE t3 (c int); +INSERT INTO t3 VALUES (1); + +SELECT * FROM t1 + WHERE EXISTS (SELECT t2.c FROM t2 JOIN t3 ON t2.c=t3.c WHERE t2.c=1 + UNION + SELECT c from t2 WHERE c=t1.c); + +DROP TABLE t1,t2,t3; + +# # Bug#20835 (literal string with =any values) # CREATE TABLE t1 (s1 char(1)); diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index 56d310eec37..b40a8538e04 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -1554,4 +1554,50 @@ select * from t1; drop table t1; +# +# Bug#25398: crash when a trigger contains a SELECT with +# trigger fields in the select list under DISTINCT +# + +CREATE TABLE t1 ( + id int NOT NULL DEFAULT '0', + a varchar(10) NOT NULL, + b varchar(10), + c varchar(10), + d timestamp NOT NULL, + PRIMARY KEY (id, a) +); + +CREATE TABLE t2 ( + fubar_id int unsigned NOT NULL DEFAULT '0', + last_change_time datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (fubar_id) +); + +DELIMITER |; + +CREATE TRIGGER fubar_change + AFTER UPDATE ON t1 + FOR EACH ROW + BEGIN + INSERT INTO t2 (fubar_id, last_change_time) + SELECT DISTINCT NEW.id AS fubar_id, NOW() AS last_change_time + FROM t1 WHERE (id = NEW.id) AND (OLD.c != NEW.c) + ON DUPLICATE KEY UPDATE + last_change_time = + IF((fubar_id = NEW.id)AND(OLD.c != NEW.c),NOW(),last_change_time); + END +| + +DELIMITER ;| + +INSERT INTO t1 (id,a, b,c,d) VALUES + (1,'a','b','c',now()),(2,'a','b','c',now()); + +UPDATE t1 SET c='Bang!' WHERE id=1; + +SELECT fubar_id FROM t2; + +DROP TABLE t1,t2; + --echo End of 5.0 tests diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index 010a532f48b..7d870a86bc8 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -294,3 +294,50 @@ drop table bug18761; select is_const((1,2,3)); drop function if exists is_const; + +# +# Bug #25382: Passing NULL to an UDF called from stored procedures +# crashes server +# +--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB +eval CREATE FUNCTION metaphon RETURNS STRING SONAME "$UDF_EXAMPLE_LIB"; + +--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB +eval CREATE FUNCTION myfunc_double RETURNS REAL SONAME "$UDF_EXAMPLE_LIB"; + +--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB +eval CREATE FUNCTION myfunc_int RETURNS INTEGER SONAME "$UDF_EXAMPLE_LIB"; + +delimiter //; +create function f1(p1 varchar(255)) +returns varchar(255) +begin + return metaphon(p1); +end// + +create function f2(p1 varchar(255)) +returns double +begin + return myfunc_double(p1); +end// + +create function f3(p1 varchar(255)) +returns double +begin + return myfunc_int(p1); +end// + +delimiter ;// + +select f3(NULL); +select f2(NULL); +select f1(NULL); + +drop function f1; +drop function f2; +drop function f3; +drop function metaphon; +drop function myfunc_double; +drop function myfunc_int; + +--echo End of 5.0 tests. diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index ea429e2a0f0..2e67fc3d2d2 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1879,15 +1879,6 @@ 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); @@ -2907,6 +2898,57 @@ DROP VIEW v1; DROP TABLE t1; # +# BUG#22584: last_insert_id not updated after inserting a record +# through a updatable view +# +# We still do not update LAST_INSERT_ID if AUTO_INCREMENT column is +# not accessible through a view. However, we do not reset the value +# of LAST_INSERT_ID, but keep it unchanged. +# +--disable_warnings +DROP VIEW IF EXISTS v1, v2; +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE t1 (i INT AUTO_INCREMENT PRIMARY KEY, j INT); +CREATE VIEW v1 AS SELECT j FROM t1; +CREATE VIEW v2 AS SELECT * FROM t1; + +INSERT INTO t1 (j) VALUES (1); +SELECT LAST_INSERT_ID(); + +INSERT INTO v1 (j) VALUES (2); +--echo # LAST_INSERT_ID() should not change. +SELECT LAST_INSERT_ID(); + +INSERT INTO v2 (j) VALUES (3); +--echo # LAST_INSERT_ID() should be updated. +SELECT LAST_INSERT_ID(); + +INSERT INTO v1 (j) SELECT j FROM t1; +--echo # LAST_INSERT_ID() should not change. +SELECT LAST_INSERT_ID(); + +SELECT * FROM t1; + +DROP VIEW v1, v2; +DROP TABLE t1; + +# +# Bug #25580: !0 as an operand in a select expression of a view +# + +CREATE VIEW v AS SELECT !0 * 5 AS x FROM DUAL; +SHOW CREATE VIEW v; + +SELECT !0 * 5 AS x FROM DUAL; +SELECT * FROM v; + +DROP VIEW v; + + +--echo End of 5.0 tests. + # Bug #16813 (WITH CHECK OPTION doesn't work with UPDATE) # CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, val INT UNSIGNED NOT NULL); |