From 3ec4296ec413e866c3efabc8dfa94172ad5f7c04 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Thu, 12 Dec 2013 13:55:33 -0800 Subject: Fixed bug mdev-5410. The fix for bug #27937 was incomplete: it did not handle correctly the queries containing UNION with global ORDER BY in subselects. --- mysql-test/r/ps.result | 23 +++++++++++++++++++++++ mysql-test/t/ps.test | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) (limited to 'mysql-test') diff --git a/mysql-test/r/ps.result b/mysql-test/r/ps.result index 75aef40b529..e5411b2a210 100644 --- a/mysql-test/r/ps.result +++ b/mysql-test/r/ps.result @@ -3284,4 +3284,27 @@ Handler_read_rnd_deleted 0 Handler_read_rnd_next 0 deallocate prepare st; drop table t1; +# +# Bug mdev-5410: crash at the execution of PS with subselect +# formed by UNION with global ORDER BY +# +CREATE TABLE t1 (a int DEFAULT NULL); +INSERT INTO t1 VALUES (2), (4); +CREATE TABLE t2 (b int DEFAULT NULL); +INSERT INTO t2 VALUES (1), (3); +PREPARE stmt FROM " +SELECT c1 FROM (SELECT (SELECT a FROM t1 WHERE t1.a <= t2.b + UNION ALL + SELECT a FROM t1 WHERE t1.a+3<= t2.b + ORDER BY a DESC) AS c1 FROM t2) t3; +"; +EXECUTE stmt; +c1 +NULL +2 +EXECUTE stmt; +c1 +NULL +2 +DROP TABLE t1,t2; # End of 5.3 tests diff --git a/mysql-test/t/ps.test b/mysql-test/t/ps.test index f1941337874..4d7c6848da7 100644 --- a/mysql-test/t/ps.test +++ b/mysql-test/t/ps.test @@ -3308,4 +3308,26 @@ show status like '%Handler_read%'; deallocate prepare st; drop table t1; +--echo # +--echo # Bug mdev-5410: crash at the execution of PS with subselect +--echo # formed by UNION with global ORDER BY +--echo # + +CREATE TABLE t1 (a int DEFAULT NULL); +INSERT INTO t1 VALUES (2), (4); +CREATE TABLE t2 (b int DEFAULT NULL); +INSERT INTO t2 VALUES (1), (3); + +PREPARE stmt FROM " +SELECT c1 FROM (SELECT (SELECT a FROM t1 WHERE t1.a <= t2.b + UNION ALL + SELECT a FROM t1 WHERE t1.a+3<= t2.b + ORDER BY a DESC) AS c1 FROM t2) t3; +"; + +EXECUTE stmt; +EXECUTE stmt; + +DROP TABLE t1,t2; + --echo # End of 5.3 tests -- cgit v1.2.1