diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index b96cc03dfab..9187504a0c8 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1841,11 +1841,6 @@ id name id pet 2 Rebecca 2 Spot 3 NULL 3 Felix drop table t1,t2; -DROP TABLE IF EXISTS t1, t2, t3; -Warnings: -Note 1051 Unknown table 't1' -Note 1051 Unknown table 't2' -Note 1051 Unknown table 't3' CREATE TABLE t1 ( a int, b int ); CREATE TABLE t2 ( c int, d int ); INSERT INTO t1 VALUES (1,2), (2,3), (3,4); @@ -1866,4 +1861,24 @@ abc b 1 2 2 3 3 4 +prepare stmt1 from "INSERT INTO t2 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);"; +execute stmt1; +deallocate prepare stmt1; +select * from t2; +c d +1 2 +2 3 +3 4 +1 2 +2 3 +3 4 +drop table t3; +prepare stmt1 from "CREATE TABLE t3 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);"; +execute stmt1; +select * from t3; +abc b +1 2 +2 3 +3 4 +deallocate prepare stmt1; DROP TABLE t1, t2, t3; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index b51f89086b4..8cbaed05e3f 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -1182,7 +1182,6 @@ drop table t1,t2; # # outer fields resolving in INSERT/REPLACE and CRETE with SELECT # -DROP TABLE IF EXISTS t1, t2, t3; CREATE TABLE t1 ( a int, b int ); CREATE TABLE t2 ( c int, d int ); INSERT INTO t1 VALUES (1,2), (2,3), (3,4); @@ -1191,4 +1190,13 @@ INSERT INTO t2 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE select * from t2; CREATE TABLE t3 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc); select * from t3; +prepare stmt1 from "INSERT INTO t2 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);"; +execute stmt1; +deallocate prepare stmt1; +select * from t2; +drop table t3; +prepare stmt1 from "CREATE TABLE t3 SELECT a AS abc, b FROM t1 WHERE b = (SELECT MIN(b) FROM t1 WHERE a=abc);"; +execute stmt1; +select * from t3; +deallocate prepare stmt1; DROP TABLE t1, t2, t3;