From de493d92b2dcc8f1d1f39d5729675fef5571aabe Mon Sep 17 00:00:00 2001 From: Magne Mahre Date: Wed, 5 May 2010 12:17:07 +0200 Subject: [PATCH] Bug#48800 CREATE TABLE t...SELECT fails if t is a temporary table If a temporary table A exists, and a (permanent) table with the same name is attempted created with "CREATE TABLE ... AS SELECT", the create would fail with an error. 1050: Table 'A' already exists The error occured in MySQL 5.1 releases, but is not present in MySQL 5.5. This patch adds a regression test to ensure that the problem does not reoccur. --- mysql-test/r/create.result | 15 +++++++++++++++ mysql-test/t/create.test | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index eb1437414e7..49597caa027 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -1977,3 +1977,18 @@ CREATE TABLE t1 LIKE t2; ERROR 42S01: Table 't1' already exists DROP TABLE t2; DROP TABLE t1; +# +# Bug #48800 CREATE TABLE t...SELECT fails if t is a +# temporary table +# +CREATE TEMPORARY TABLE t1 (a INT); +CREATE TABLE t1 (a INT); +CREATE TEMPORARY TABLE t2 (a INT); +CREATE VIEW t2 AS SELECT 1; +CREATE TABLE t3 (a INT); +CREATE TEMPORARY TABLE t3 SELECT 1; +CREATE TEMPORARY TABLE t4 (a INT); +CREATE TABLE t4 AS SELECT 1; +DROP TEMPORARY TABLE t1, t2, t3, t4; +DROP TABLE t1, t3, t4; +DROP VIEW t2; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index e0a6fde1381..2e205d47c5d 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -1668,3 +1668,25 @@ CREATE TABLE t1 LIKE t2; DROP TABLE t2; DROP TABLE t1; + +--echo # +--echo # Bug #48800 CREATE TABLE t...SELECT fails if t is a +--echo # temporary table +--echo # + +CREATE TEMPORARY TABLE t1 (a INT); +CREATE TABLE t1 (a INT); + +CREATE TEMPORARY TABLE t2 (a INT); +CREATE VIEW t2 AS SELECT 1; + +CREATE TABLE t3 (a INT); +CREATE TEMPORARY TABLE t3 SELECT 1; + +CREATE TEMPORARY TABLE t4 (a INT); +CREATE TABLE t4 AS SELECT 1; + +DROP TEMPORARY TABLE t1, t2, t3, t4; +DROP TABLE t1, t3, t4; +DROP VIEW t2; +