diff options
author | unknown <gluh@eagle.intranet.mysql.r18.ru> | 2005-09-12 17:09:19 +0500 |
---|---|---|
committer | unknown <gluh@eagle.intranet.mysql.r18.ru> | 2005-09-12 17:09:19 +0500 |
commit | 63080dc200d8b497500422aa484f72e712b04d5f (patch) | |
tree | a57b033bb2eff45734871677eb2e7d04cfea7c43 /sql | |
parent | e98e15db9b05da3b4c1ad5d788f2c6e5a3b78a15 (diff) | |
download | mariadb-git-63080dc200d8b497500422aa484f72e712b04d5f.tar.gz |
Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
produce warning for 'create database if not exists' if database exists
do not update database options in this case
produce warning for 'create table if not exists' if table exists
mysql-test/r/create.result:
Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
updated test case result
mysql-test/r/temp_table.result:
Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
updated test case result
mysql-test/r/warnings.result:
Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
updated test case result
mysql-test/t/create.test:
Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
test case
sql/sql_db.cc:
Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
produce warning for 'create database if not exists' if database exists
do not update database options in this case
sql/sql_table.cc:
Fix for bug #6008: MySQL does not create warnings when creating database and using IF NOT EXISTS
produce warning for 'create table if not exists' if table exists
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_db.cc | 6 | ||||
-rw-r--r-- | sql/sql_table.cc | 28 |
2 files changed, 21 insertions, 13 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc index 7635774e3ac..7c834c91183 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -427,7 +427,11 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info, error= -1; goto exit; } - result= 0; + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_DB_CREATE_EXISTS, ER(ER_DB_CREATE_EXISTS), db); + error= 0; + send_ok(thd); + goto exit; } else { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 92db0143980..01126043764 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1360,6 +1360,9 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS) { create_info->table_existed= 1; // Mark that table existed + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), + alias); DBUG_RETURN(0); } my_error(ER_TABLE_EXISTS_ERROR, MYF(0), alias); @@ -1373,12 +1376,8 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, if (!access(path,F_OK)) { if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS) - { - create_info->table_existed= 1; // Mark that table existed - error= 0; - } - else - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); + goto warn; + my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); goto end; } } @@ -1401,12 +1400,8 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, DBUG_PRINT("info", ("Table with same name already existed in handler")); if (create_if_not_exists) - { - create_info->table_existed= 1; // Mark that table existed - error= 0; - } - else - my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); + goto warn; + my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name); goto end; } } @@ -1447,6 +1442,15 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, } } error=0; + goto end; + +warn: + error= 0; + push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_TABLE_EXISTS_ERROR, ER(ER_TABLE_EXISTS_ERROR), + alias); + create_info->table_existed= 1; // Mark that table existed + end: VOID(pthread_mutex_unlock(&LOCK_open)); start_waiting_global_read_lock(thd); |