Commit f202f3df authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-19263: Server crashes in mysql_handle_single_derived upon 2nd execution of PS

Fix case of prelocking placeholder
parent 653a56fd
......@@ -5388,3 +5388,21 @@ drop table t1;
#
# End of 10.2 tests
#
#
# MDEV-19263: Server crashes in mysql_handle_single_derived
# upon 2nd execution of PS
#
CREATE TABLE t1 (f INT);
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE TRIGGER tr BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO v1 SELECT * FROM x;
PREPARE stmt FROM "INSERT INTO v1 VALUES (1)";
EXECUTE stmt;
ERROR 42S02: Table 'test.x' doesn't exist
EXECUTE stmt;
ERROR 42S02: Table 'test.x' doesn't exist
DEALLOCATE PREPARE stmt;
DROP VIEW v1;
DROP TABLE t1;
#
# End of 10.4 tests
#
......@@ -4825,3 +4825,27 @@ drop table t1;
--echo #
--echo # End of 10.2 tests
--echo #
--echo #
--echo # MDEV-19263: Server crashes in mysql_handle_single_derived
--echo # upon 2nd execution of PS
--echo #
CREATE TABLE t1 (f INT);
CREATE VIEW v1 AS SELECT * FROM t1;
CREATE TRIGGER tr BEFORE INSERT ON t1 FOR EACH ROW INSERT INTO v1 SELECT * FROM x;
PREPARE stmt FROM "INSERT INTO v1 VALUES (1)";
--error ER_NO_SUCH_TABLE
EXECUTE stmt;
--error ER_NO_SUCH_TABLE
EXECUTE stmt;
# Cleanup
DEALLOCATE PREPARE stmt;
DROP VIEW v1;
DROP TABLE t1;
--echo #
--echo # End of 10.4 tests
--echo #
......@@ -183,7 +183,10 @@ mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases)
if (!lex->derived_tables)
DBUG_RETURN(FALSE);
derived->select_lex->changed_elements|= TOUCHED_SEL_DERIVED;
if (derived->select_lex)
derived->select_lex->changed_elements|= TOUCHED_SEL_DERIVED;
else
DBUG_ASSERT(derived->prelocking_placeholder);
lex->thd->derived_tables_processing= TRUE;
for (uint phase= 0; phase < DT_PHASES; phase++)
......
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