Commit 6b5c0eff authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-13436 PREPARE doesn't work as expected & throws errors but MySQL is working fine

Now we allow derived in the from clause of subqueries so set
flag which prevent optimisation of subqueries during view
creation before derived processing so subquery will be
correctly printed in the view .frm.
parent 2425f2ae
......@@ -6624,5 +6624,28 @@ drop table procViewTable;
use test;
drop database bugTest;
#
# MDEV-13436: PREPARE doesn't work as expected & throws errors but
# MySQL is working fine
#
create table t1 (a int);
insert into t1 values (1),(2);
SET @sql_query = "
CREATE VIEW v1 AS
SELECT * FROM (
SELECT CASE WHEN 1 IN (SELECT a from t1 where a < 2) THEN TRUE END AS testcase
) testalias
";
PREPARE stmt FROM @sql_query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
show create view v1;
View Create View character_set_client collation_connection
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `testalias`.`testcase` AS `testcase` from (select case when 1 in (select `test`.`t1`.`a` from `test`.`t1` where `test`.`t1`.`a` < 2) then 1 end AS `testcase`) `testalias` latin1 latin1_swedish_ci
SELECT * FROM v1;
testcase
1
drop view v1;
drop table t1;
#
# End of 10.2 tests
#
......@@ -6344,6 +6344,27 @@ drop table procViewTable;
use test;
drop database bugTest;
--echo #
--echo # MDEV-13436: PREPARE doesn't work as expected & throws errors but
--echo # MySQL is working fine
--echo #
create table t1 (a int);
insert into t1 values (1),(2);
SET @sql_query = "
CREATE VIEW v1 AS
SELECT * FROM (
SELECT CASE WHEN 1 IN (SELECT a from t1 where a < 2) THEN TRUE END AS testcase
) testalias
";
PREPARE stmt FROM @sql_query;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
show create view v1;
SELECT * FROM v1;
drop view v1;
drop table t1;
--echo #
--echo # End of 10.2 tests
--echo #
......@@ -2097,11 +2097,11 @@ static bool mysql_test_create_view(Prepared_statement *stmt)
if (thd->open_temporary_tables(tables))
goto err;
lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
if (open_normal_and_derived_tables(thd, tables, MYSQL_OPEN_FORCE_SHARED_MDL,
DT_PREPARE))
goto err;
lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_VIEW;
res= select_like_stmt_test(stmt, 0, 0);
err:
......
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