summaryrefslogtreecommitdiff
path: root/mysql-test/main/ps.test
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2018-08-30 11:30:28 -0700
committerIgor Babaev <igor@askmonty.org>2018-08-30 11:30:28 -0700
commitd8b8079e421a7d19d3e0c2c4e4adf526853896cb (patch)
treefb2f11f8b97603c8f7d3fe078617a8a5d62d96e7 /mysql-test/main/ps.test
parent7aa80ba66b042bbcd6f2576522bb87a1fc83a281 (diff)
downloadmariadb-git-d8b8079e421a7d19d3e0c2c4e4adf526853896cb.tar.gz
EV-16992 Assertion `table_ref->table || table_ref->view' failed in
Field_iterator_table_ref::set_field_iterator Several functions that processed different prepare statements missed the DT_INIT flag in last parameter of the open_normal_and_derived_tables() calls. It made context analysis of derived tables dependent on the order in which the derived tables were processed by mysql_handle_derived(). This order was induced by the order of SELECTs in all_select_list. In 10.4 the order of SELECTs in all_select_list became different and lack of the DT_INIT flags in some open_normal_and_derived_tables() call became critical as some derived tables were not identified as such.
Diffstat (limited to 'mysql-test/main/ps.test')
-rw-r--r--mysql-test/main/ps.test46
1 files changed, 46 insertions, 0 deletions
diff --git a/mysql-test/main/ps.test b/mysql-test/main/ps.test
index 79c08d62290..2b8a05094a6 100644
--- a/mysql-test/main/ps.test
+++ b/mysql-test/main/ps.test
@@ -4785,5 +4785,51 @@ DROP PROCEDURE p1;
DROP ROLE testrole;
--echo #
+--echo # MDEV-16992: prepare of CREATE TABLE, CREATE VIEW, DO, SET, CALL
+--echo # statements with CTE containing materialized derived
+--echo # (the bug is reproducible on 10.4)
+--echo #
+
+--enable_result_log
+
+prepare stmt from
+"CREATE TABLE t1 AS
+ WITH cte(a) AS (SELECT * FROM (SELECT 1) AS t) SELECT * FROM cte;";
+execute stmt;
+select * from t1;
+
+prepare stmt from
+"CREATE VIEW v1 AS
+ WITH cte(a) AS (SELECT * FROM (SELECT 1) AS t) SELECT * FROM cte;";
+execute stmt;
+select * from v1;
+
+prepare stmt from
+"DO (SELECT 1
+ FROM (WITH cte AS (SELECT * FROM (SELECT 1) AS t)
+ SELECT * FROM cte) AS tt);";
+execute stmt;
+
+prepare stmt from
+"SET @a = (SELECT 1
+ FROM (WITH cte AS (SELECT * FROM (SELECT 1) AS t)
+ SELECT * FROM cte) AS t);";
+execute stmt;
+
+create procedure p (i int) insert into t1 values(i);
+
+prepare stmt from
+"CALL p
+ ((SELECT 1
+ FROM (WITH cte AS (SELECT * FROM (SELECT 1) AS t)
+ SELECT * FROM cte) AS tt));";
+execute stmt;
+select * from t1;
+
+drop procedure p;
+drop view v1;
+drop table t1;
+
+--echo #
--echo # End of 10.2 tests
--echo #