Commit b47e4fbf authored by Magne Mahre's avatar Magne Mahre

Bug#49193 CREATE TABLE reacts differently depending on whether

          data is selected or not

Temporary and permanent tables should live in different 
namespaces.  In this case, resolving a permanent table
name gave the temporary table, resulting in a name
collision.
parent de493d92
...@@ -1992,3 +1992,44 @@ CREATE TABLE t4 AS SELECT 1; ...@@ -1992,3 +1992,44 @@ CREATE TABLE t4 AS SELECT 1;
DROP TEMPORARY TABLE t1, t2, t3, t4; DROP TEMPORARY TABLE t1, t2, t3, t4;
DROP TABLE t1, t3, t4; DROP TABLE t1, t3, t4;
DROP VIEW t2; DROP VIEW t2;
#
# Bug #49193 CREATE TABLE reacts differently depending
# on whether data is selected or not
#
CREATE TEMPORARY TABLE t2 (ID INT);
INSERT INTO t2 VALUES (1),(2),(3);
CREATE TEMPORARY TABLE t1 (ID INT);
CREATE TABLE IF NOT EXISTS t1 (ID INT);
INSERT INTO t1 SELECT * FROM t2;
SELECT * FROM t1;
ID
1
2
3
DROP TEMPORARY TABLE t1;
SELECT * FROM t1;
ID
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (ID INT);
CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2;
SELECT * FROM t1;
ID
DROP TEMPORARY TABLE t1;
SELECT * FROM t1;
ID
1
2
3
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (ID INT);
CREATE TABLE t1 SELECT * FROM t2;
SELECT * FROM t1;
ID
DROP TEMPORARY TABLE t1;
SELECT * FROM t1;
ID
1
2
3
DROP TABLE t1;
DROP TEMPORARY TABLE t2;
...@@ -1690,3 +1690,44 @@ DROP TEMPORARY TABLE t1, t2, t3, t4; ...@@ -1690,3 +1690,44 @@ DROP TEMPORARY TABLE t1, t2, t3, t4;
DROP TABLE t1, t3, t4; DROP TABLE t1, t3, t4;
DROP VIEW t2; DROP VIEW t2;
--echo #
--echo # Bug #49193 CREATE TABLE reacts differently depending
--echo # on whether data is selected or not
--echo #
CREATE TEMPORARY TABLE t2 (ID INT);
INSERT INTO t2 VALUES (1),(2),(3);
# Case 1 -- did not fail
CREATE TEMPORARY TABLE t1 (ID INT);
CREATE TABLE IF NOT EXISTS t1 (ID INT);
INSERT INTO t1 SELECT * FROM t2;
SELECT * FROM t1;
DROP TEMPORARY TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
# Case 2 -- The DROP TABLE t1 failed with
# Table 'test.t1' doesn't exist in the SELECT *
# as the (permanent) table was not created
CREATE TEMPORARY TABLE t1 (ID INT);
CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2;
SELECT * FROM t1;
DROP TEMPORARY TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
# Case 3 -- The CREATE TABLE failed with
# Table 't1' already exists
CREATE TEMPORARY TABLE t1 (ID INT);
CREATE TABLE t1 SELECT * FROM t2;
SELECT * FROM t1;
DROP TEMPORARY TABLE t1;
SELECT * FROM t1;
DROP TABLE t1;
DROP TEMPORARY TABLE t2;
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