From 2dbce3d0896d571c7ffd631beeac4a6a902bea17 Mon Sep 17 00:00:00 2001 From: Michael Widenius Date: Mon, 17 Dec 2012 22:34:56 +0200 Subject: Fixed the CREATE TABLE IF EXIST generates warnings instead of errors mysql-test/r/create.result: Updated test results mysql-test/t/create.test: Updated test sql/sql_base.cc: Use push_internal_handler/pop_internal_handler to avoid errors & warnings instead of clear_error Give a warnings instead of an error for CREATE TABLE IF EXISTS sql/sql_parse.cc: Check if we failed because of table exists (can only happen from create) sql/sql_table.cc: Check if we failed because of table exists (can only happen from create) --- sql/sql_parse.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'sql/sql_parse.cc') diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 5dac052b749..de35d2f3d27 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2512,7 +2512,14 @@ case SQLCOM_PREPARE: goto end_with_restore_list; } - if (!(res= open_and_lock_tables(thd, lex->query_tables, TRUE, 0))) + res= open_and_lock_tables(thd, lex->query_tables, TRUE, 0); + if (res) + { + /* Got error or warning. Set res to 1 if error */ + if (!(res= thd->is_error())) + my_ok(thd); // CREATE ... IF NOT EXISTS + } + else { /* The table already exists */ if (create_table->table) -- cgit v1.2.1