Commit 8754fce8 authored by Dmitry Shulga's avatar Dmitry Shulga Committed by Sergei Golubchik

MDEV-16708: Unsupported commands for prepared statements

Fixed test failures caused by missing output of warnings that
got on prepare phase
parent aeca826c
...@@ -475,8 +475,10 @@ CREATE TABLE t1 (a INT) ENGINE=MyISAM; ...@@ -475,8 +475,10 @@ CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (8); INSERT INTO t1 VALUES (8);
CREATE TABLE t2 (b INT) ENGINE=MyISAM; CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (1),(7); INSERT INTO t2 VALUES (1),(7);
--enable_prepare_warnings
EXPLAIN SELECT * FROM (SELECT * FROM t1) AS table1, EXPLAIN SELECT * FROM (SELECT * FROM t1) AS table1,
(SELECT DISTINCT * FROM t2) AS table2 WHERE b = a AND a <> ANY (SELECT 9); (SELECT DISTINCT * FROM t2) AS table2 WHERE b = a AND a <> ANY (SELECT 9);
--disable_prepare_warnings
DROP TABLE t1, t2; DROP TABLE t1, t2;
set optimizer_switch=@save_derived_optimizer_switch_bug; set optimizer_switch=@save_derived_optimizer_switch_bug;
......
...@@ -1064,9 +1064,10 @@ DROP TABLE t1,t2; ...@@ -1064,9 +1064,10 @@ DROP TABLE t1,t2;
CREATE TABLE t1 (i INT); CREATE TABLE t1 (i INT);
CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1; CREATE OR REPLACE ALGORITHM=TEMPTABLE VIEW v1 AS SELECT * FROM t1;
INSERT INTO t1 VALUES (1),(2); INSERT INTO t1 VALUES (1),(2);
--enable_prepare_warnings
EXPLAIN FORMAT=JSON EXPLAIN FORMAT=JSON
SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 ); SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
--disable_prepare_warnings
SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 ); SELECT * FROM v1 WHERE i <= ANY ( SELECT 3 );
......
...@@ -73,14 +73,18 @@ GROUP BY t1.a ...@@ -73,14 +73,18 @@ GROUP BY t1.a
HAVING (t1.a>1) OR (a IN (SELECT 3)); HAVING (t1.a>1) OR (a IN (SELECT 3));
eval $no_pushdown $query; eval $no_pushdown $query;
eval $query; eval $query;
--enable_prepare_warnings
eval explain $query; eval explain $query;
eval explain format=json $query; eval explain format=json $query;
--disable_prepare_warnings
let $query= let $query=
SELECT t1.a,MAX(t1.b) SELECT t1.a,MAX(t1.b)
FROM t1 FROM t1
WHERE (t1.a>1) OR (a IN (SELECT 3)) WHERE (t1.a>1) OR (a IN (SELECT 3))
GROUP BY t1.a; GROUP BY t1.a;
--enable_prepare_warnings
eval $no_pushdown explain format=json $query; eval $no_pushdown explain format=json $query;
--disable_prepare_warnings
let $query= let $query=
SELECT t1.a,MAX(t1.b),MIN(t1.c) SELECT t1.a,MAX(t1.b),MIN(t1.c)
......
...@@ -30,11 +30,15 @@ SET optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on'; ...@@ -30,11 +30,15 @@ SET optimizer_switch='mrr=on,mrr_sort_keys=on,index_condition_pushdown=on';
SET optimizer_use_condition_selectivity=4; SET optimizer_use_condition_selectivity=4;
select (select 2); select (select 2);
--enable_prepare_warnings
explain extended select (select 2); explain extended select (select 2);
SELECT (SELECT 1) UNION SELECT (SELECT 2); SELECT (SELECT 1) UNION SELECT (SELECT 2);
explain extended SELECT (SELECT 1) UNION SELECT (SELECT 2); explain extended SELECT (SELECT 1) UNION SELECT (SELECT 2);
SELECT (SELECT (SELECT 0 UNION SELECT 0)); SELECT (SELECT (SELECT 0 UNION SELECT 0));
explain extended SELECT (SELECT (SELECT 0 UNION SELECT 0)); explain extended SELECT (SELECT (SELECT 0 UNION SELECT 0));
--disable_prepare_warnings
-- error ER_ILLEGAL_REFERENCE -- error ER_ILLEGAL_REFERENCE
SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a; SELECT (SELECT 1 FROM (SELECT 1) as b HAVING a=1) as a;
-- error ER_ILLEGAL_REFERENCE -- error ER_ILLEGAL_REFERENCE
...@@ -441,11 +445,15 @@ SELECT * FROM (SELECT 1) b WHERE 1 IN (SELECT *); ...@@ -441,11 +445,15 @@ SELECT * FROM (SELECT 1) b WHERE 1 IN (SELECT *);
CREATE TABLE t2 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1; CREATE TABLE t2 (id int(11) default NULL, KEY id (id)) ENGINE=MyISAM CHARSET=latin1;
INSERT INTO t2 VALUES (1),(2); INSERT INTO t2 VALUES (1),(2);
SELECT * FROM t2 WHERE id IN (SELECT 1); SELECT * FROM t2 WHERE id IN (SELECT 1);
--enable_prepare_warnings
EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1); EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1);
--disable_prepare_warnings
SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3);
SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1)); SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1));
--enable_prepare_warnings
EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1)); EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1+(select 1));
EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3); EXPLAIN EXTENDED SELECT * FROM t2 WHERE id IN (SELECT 1 UNION SELECT 3);
--disable_prepare_warnings
SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3); SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 3);
SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2); SELECT * FROM t2 WHERE id IN (SELECT 5 UNION SELECT 2);
-- error ER_UPDATE_TABLE_USED -- error ER_UPDATE_TABLE_USED
...@@ -501,7 +509,9 @@ select 1.5 > ALL (SELECT * from t1); ...@@ -501,7 +509,9 @@ select 1.5 > ALL (SELECT * from t1);
select 10.5 > ALL (SELECT * from t1); select 10.5 > ALL (SELECT * from t1);
select 1.5 > ANY (SELECT * from t1); select 1.5 > ANY (SELECT * from t1);
select 10.5 > ANY (SELECT * from t1); select 10.5 > ANY (SELECT * from t1);
--enable_prepare_warnings
explain extended select (select a+1) from t1; explain extended select (select a+1) from t1;
--disable_prepare_warnings
select (select a+1) from t1; select (select a+1) from t1;
drop table t1; drop table t1;
......
...@@ -104,8 +104,10 @@ DROP TABLE t1,t2; ...@@ -104,8 +104,10 @@ DROP TABLE t1,t2;
--echo # Bug#54568: create view cause Assertion failed: 0, --echo # Bug#54568: create view cause Assertion failed: 0,
--echo # file .\item_subselect.cc, line 836 --echo # file .\item_subselect.cc, line 836
--echo # --echo #
--enable_prepare_warnings
EXPLAIN SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); EXPLAIN SELECT 1 LIKE ( 1 IN ( SELECT 1 ) );
DESCRIBE SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); DESCRIBE SELECT 1 LIKE ( 1 IN ( SELECT 1 ) );
--disable_prepare_warnings
--echo # None of the below should crash --echo # None of the below should crash
CREATE VIEW v1 AS SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); CREATE VIEW v1 AS SELECT 1 LIKE ( 1 IN ( SELECT 1 ) );
CREATE VIEW v2 AS SELECT 1 LIKE '%' ESCAPE ( 1 IN ( SELECT 1 ) ); CREATE VIEW v2 AS SELECT 1 LIKE '%' ESCAPE ( 1 IN ( SELECT 1 ) );
......
...@@ -1471,7 +1471,9 @@ insert into t2 values (1), (2); ...@@ -1471,7 +1471,9 @@ insert into t2 values (1), (2);
let $q1= let $q1=
select (values ((select 2))) from t2; select (values ((select 2))) from t2;
eval $q1; eval $q1;
--enable_prepare_warnings
eval explain $q1; eval explain $q1;
--disable_prepare_warnings
eval prepare stmt from "$q1"; eval prepare stmt from "$q1";
execute stmt; execute stmt;
execute stmt; execute stmt;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment