1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +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

@@ -24,6 +24,31 @@ DROP TABLE t1;
--echo # CREATE & Stored routines
--echo #
DELIMITER |;
CREATE FUNCTION f1() RETURNS INT
BEGIN
DROP TEMPORARY TABLE t1;
RETURN 1;
END|
DELIMITER ;|
--error ER_BAD_TABLE_ERROR
CREATE TEMPORARY TABLE t1 AS SELECT f1();
DROP FUNCTION f1;
DELIMITER |;
CREATE FUNCTION f2() RETURNS INT
BEGIN
CREATE TEMPORARY TABLE t2(i INT);
INSERT INTO t2 VALUES(1), (2);
RETURN 1;
END|
DELIMITER ;|
--error ER_TABLE_EXISTS_ERROR
CREATE TEMPORARY TABLE t2 AS SELECT f2();
SELECT * FROM t2;
DROP TABLE t2;
DROP FUNCTION f2;
CREATE TEMPORARY TABLE t3 AS SELECT 1 AS a;
DELIMITER |;
CREATE PROCEDURE p1()