Bug #9884 CREATE TABLE IF NOT EXISTS x SELECT .. still INSERTs into table if it exists

Submitted: 14 Apr 2005 0:25 Modified: 28 Apr 2005 0:12
Reporter: Lachlan Mulcahy Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.11 OS:Any (Any)
Assigned to: Paul DuBois CPU Architecture:Any

[14 Apr 2005 0:25] Lachlan Mulcahy
Description:
Doing a CRATE TABLE IF NOT EXISTS t1 SELECT * FROM t2; will still perform the INSERT SELECT if the table t1 exists.

How to repeat:
USE test;
CREATE TABLE t1 (a int);
CREATE TABLE t2 (a int);
INSERT INTO t2 VALUES (1), (2);
SELECT * FROM t1;
SELECT * FROM t2;
CREATE TABLE IF NOT EXISTS t1 SELECT * FROM t2;
SELECT * FROM t1;

Suggested fix:
If the table already exists, do not proceed with populating the table with data.
[15 Apr 2005 19:22] Brian Aker
Please document.
[28 Apr 2005 0:12] Paul DuBois
Thank you for your bug report. This issue has been addressed in the
documentation. The updated documentation will appear on our website
shortly, and will be included in the next release of the relevant
product(s).

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.