diff options
Diffstat (limited to 'mysql-test/t/select.test')
-rw-r--r-- | mysql-test/t/select.test | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test index 51f0cd73374..95c16849633 100644 --- a/mysql-test/t/select.test +++ b/mysql-test/t/select.test @@ -3767,9 +3767,14 @@ INSERT INTO t1 VALUES (2),(3); --echo # Should not crash --error ER_SUBQUERY_NO_1_ROW SELECT 1 FROM t1 WHERE a <> 1 AND NOT -ROW(a,a) <=> ROW((SELECT 1 FROM t1 WHERE 1=2),(SELECT 1 FROM t1)) +ROW(1,a) <=> ROW(1,(SELECT 1 FROM t1)) INTO @var0; +# Query correctly return 2 rows since comparison a <=> fisrt_subquery is +# always false, thus the second query is never executed. +SELECT 1 FROM t1 WHERE a <> 1 AND NOT +ROW(a,a) <=> ROW((SELECT 1 FROM t1 WHERE 1=2),(SELECT 1 FROM t1)); + DROP TABLE t1; @@ -3918,4 +3923,38 @@ SELECT table1 .`time_key` field2 FROM B table1 LEFT JOIN BB JOIN A table5 ON drop table A,AA,B,BB; --echo #end of test for bug#45266 + +--echo # +--echo # Bug#33546: Slowdown on re-evaluation of constant expressions. +--echo # +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1), (2), (3), (4), (5), (6), (7), (8), (9), (10); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (2); +SELECT * FROM t1 WHERE a = 1 + 1; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a = 1 + 1; +SELECT * FROM t1 HAVING a = 1 + 1; +EXPLAIN EXTENDED SELECT * FROM t1 HAVING a = 1 + 1; +SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +EXPLAIN EXTENDED SELECT * FROM t1, t2 WHERE a = b + (1 + 1); +SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +EXPLAIN EXTENDED SELECT * FROM t2 LEFT JOIN t1 ON a = b + 1; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a > UNIX_TIMESTAMP('2009-03-10 00:00:00'); + +delimiter |; +CREATE FUNCTION f1() RETURNS INT DETERMINISTIC +BEGIN + SET @cnt := @cnt + 1; + RETURN 1; +END;| +delimiter ;| + +SET @cnt := 0; +SELECT * FROM t1 WHERE a = f1(); +SELECT @cnt; +EXPLAIN EXTENDED SELECT * FROM t1 WHERE a = f1(); +DROP TABLE t1, t2; +DROP FUNCTION f1; +--echo # End of bug#33546 + --echo End of 5.1 tests |