summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorMagne Mahre <magne.mahre@sun.com>2010-05-05 23:28:58 +0200
committerMagne Mahre <magne.mahre@sun.com>2010-05-05 23:28:58 +0200
commitb47e4fbf834b260924d0eb15067f318f00dfbecd (patch)
tree93403e47238694206d2f6d8c6fe21f5e0cadb8b3 /mysql-test
parentde493d92b2dcc8f1d1f39d5729675fef5571aabe (diff)
downloadmariadb-git-b47e4fbf834b260924d0eb15067f318f00dfbecd.tar.gz
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.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/create.result41
-rw-r--r--mysql-test/t/create.test41
2 files changed, 82 insertions, 0 deletions
diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result
index 49597caa027..e37f9d580ba 100644
--- a/mysql-test/r/create.result
+++ b/mysql-test/r/create.result
@@ -1992,3 +1992,44 @@ CREATE TABLE t4 AS SELECT 1;
DROP TEMPORARY TABLE t1, t2, t3, t4;
DROP TABLE t1, t3, t4;
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;
diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test
index 2e205d47c5d..383ba98ae6d 100644
--- a/mysql-test/t/create.test
+++ b/mysql-test/t/create.test
@@ -1690,3 +1690,44 @@ DROP TEMPORARY TABLE t1, t2, t3, t4;
DROP TABLE t1, t3, t4;
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;
+