1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

MDEV-5535: Cannot reopen temporary table

Temporary table being created by outer statement
should not be visible to inner statement. And if
inner statement creates a table with same name.
The whole statement should fail with
ER_TABLE_EXISTS_ERROR.

Implemented by temporarily de-linking the TABLE_SHARE
being created by outer statement so that it remains
hidden to the inner statement.
This commit is contained in:
Nirbhay Choubey
2016-06-10 16:58:08 -04:00
parent 7305be2f7e
commit e2087c6e8d
7 changed files with 142 additions and 7 deletions

View File

@ -19,6 +19,28 @@ DROP TABLE t1;
#
# CREATE & Stored routines
#
CREATE FUNCTION f1() RETURNS INT
BEGIN
DROP TEMPORARY TABLE t1;
RETURN 1;
END|
CREATE TEMPORARY TABLE t1 AS SELECT f1();
ERROR 42S02: Unknown table 'temp_db.t1'
DROP FUNCTION f1;
CREATE FUNCTION f2() RETURNS INT
BEGIN
CREATE TEMPORARY TABLE t2(i INT);
INSERT INTO t2 VALUES(1), (2);
RETURN 1;
END|
CREATE TEMPORARY TABLE t2 AS SELECT f2();
ERROR 42S01: Table 't2' already exists
SELECT * FROM t2;
i
1
2
DROP TABLE t2;
DROP FUNCTION f2;
CREATE TEMPORARY TABLE t3 AS SELECT 1 AS a;
CREATE PROCEDURE p1()
BEGIN