From 39afdcddd12858619b648ffaa670021356c3d0c2 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 10 Apr 2014 12:14:18 +0300 Subject: MDEV-5401: Wrong result (missing row) on a 2nd execution of PS with exists_to_in=on, MERGE view or a SELECT SQ The problem was that the view substitute its fields (on prepare) with reverting the change after execution. After prepare on optimization exists2in convertion substituted arguments of '=' with constsnt '1', but then one of the arguments of '=' was reverted to the view field reference.This lead to incorrect WHERE condition on the second execution. To fix the problem we replace whole '=' with '1' permannently. --- mysql-test/t/subselect_exists2in.test | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'mysql-test/t/subselect_exists2in.test') diff --git a/mysql-test/t/subselect_exists2in.test b/mysql-test/t/subselect_exists2in.test index 94e7109e9d2..9450ef71494 100644 --- a/mysql-test/t/subselect_exists2in.test +++ b/mysql-test/t/subselect_exists2in.test @@ -735,5 +735,30 @@ drop table t1,t2,t3; set optimizer_switch=default; set optimizer_switch='exists_to_in=on'; +--echo # +--echo #MDEV-5401: Wrong result (missing row) on a 2nd execution of PS with +--echo #exists_to_in=on, MERGE view or a SELECT SQ +--echo # +CREATE TABLE t1 (a INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1),(2); + +CREATE ALGORITHM=MERGE VIEW v1 AS SELECT * FROM t1; + +CREATE TABLE t2 (b INT) ENGINE=MyISAM; +INSERT INTO t2 VALUES (2),(3); + +SELECT * FROM v1 WHERE EXISTS ( SELECT * FROM t2 t2x, t2 t2y WHERE t2y.b = a ); + +PREPARE stmt FROM "SELECT * FROM v1 WHERE EXISTS ( SELECT * FROM t2 t2x, t2 t2y WHERE t2y.b = a )"; +EXECUTE stmt; +EXECUTE stmt; + +deallocate prepare stmt; + +drop view v1; +drop table t1,t2; + +--echo # End of 10.0 tests + #restore defaults set optimizer_switch=default; -- cgit v1.2.1