Commit af650c76 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-18460: Server crashed in strmake / tdc_create_key / THD::create_tmp_table_def_key

When there is a WITH clause we postpone check for tables without
database for later stages when tables in WITH will be defined.
But we should not try to open such tables as temporary tables because
temporary tables always belong to a some database.
parent 425748f1
...@@ -1673,3 +1673,21 @@ with columns as (select 1 as t) select * from columns; ...@@ -1673,3 +1673,21 @@ with columns as (select 1 as t) select * from columns;
t t
1 1
use test; use test;
#
# MDEV-18460: Server crashed in strmake / tdc_create_key /
# THD::create_tmp_table_def_key
#
connect con1,localhost,root,,;
CREATE TEMPORARY TABLE test.t (a INT);
WITH cte AS (SELECT 1) SELECT * FROM cte;
1
1
WITH t AS (SELECT 1) SELECT * FROM t;
1
1
WITH cte AS (SELECT 1) SELECT * FROM t;
ERROR 3D000: No database selected
DROP TABLE test.t;
connection default;
disconnect con1;
# End of 10.2 tests
...@@ -1182,3 +1182,23 @@ with t as (select 1 as t) select * from t; ...@@ -1182,3 +1182,23 @@ with t as (select 1 as t) select * from t;
with columns as (select 1 as t) select * from columns; with columns as (select 1 as t) select * from columns;
use test; use test;
--echo #
--echo # MDEV-18460: Server crashed in strmake / tdc_create_key /
--echo # THD::create_tmp_table_def_key
--echo #
--connect con1,localhost,root,,
--change_user root,,
CREATE TEMPORARY TABLE test.t (a INT);
WITH cte AS (SELECT 1) SELECT * FROM cte;
WITH t AS (SELECT 1) SELECT * FROM t;
--error ER_NO_DB_ERROR
WITH cte AS (SELECT 1) SELECT * FROM t;
DROP TABLE test.t;
--connection default
--disconnect con1
--echo # End of 10.2 tests
...@@ -338,6 +338,13 @@ bool THD::open_temporary_table(TABLE_LIST *tl) ...@@ -338,6 +338,13 @@ bool THD::open_temporary_table(TABLE_LIST *tl)
DBUG_RETURN(false); DBUG_RETURN(false);
} }
if (!tl->db)
{
DBUG_PRINT("info",
("Table reference to a temporary table must have database set"));
DBUG_RETURN(false);
}
/* /*
Temporary tables are not safe for parallel replication. They were Temporary tables are not safe for parallel replication. They were
designed to be visible to one thread only, so have no table locking. designed to be visible to one thread only, so have no table locking.
......
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