diff options
-rw-r--r-- | sql/mysql_priv.h | 3 | ||||
-rw-r--r-- | sql/sql_db.cc | 8 | ||||
-rw-r--r-- | sql/sql_error.cc | 26 | ||||
-rw-r--r-- | sql/sql_table.cc | 6 |
4 files changed, 38 insertions, 5 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index f4b556248da..8dc8721f10c 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -321,7 +321,6 @@ void free_items(Item *item); bool alloc_query(THD *thd, char *packet, ulong packet_length); void mysql_init_select(LEX *lex); void mysql_init_query(THD *thd); -void mysql_reset_errors(THD *thd); bool mysql_new_select(LEX *lex, bool move_down); void create_select_for_variable(const char *var_name); void mysql_init_multi_delete(LEX *lex); @@ -526,6 +525,8 @@ int check_insert_fields(THD *thd,TABLE *table,List<Item> &fields, /* sql_error.cc */ void push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, uint code, const char *msg); +void store_warning(THD *thd, uint errcode, ...); +void mysql_reset_errors(THD *thd); my_bool mysqld_show_warnings(THD *thd, ulong levels_to_show); /* sql_handler.cc */ diff --git a/sql/sql_db.cc b/sql/sql_db.cc index c3e183de0ac..85dfb38fa48 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -331,8 +331,12 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) error= -1; my_error(ER_DB_DROP_EXISTS,MYF(0),db); } - else if (!silent) - send_ok(thd,0); + else + { + store_warning(thd,ER_DB_DROP_EXISTS,db); + if (!silent) + send_ok(thd,0); + } goto exit; } pthread_mutex_lock(&LOCK_open); diff --git a/sql/sql_error.cc b/sql/sql_error.cc index d2735073461..5c9bef15ea7 100644 --- a/sql/sql_error.cc +++ b/sql/sql_error.cc @@ -104,6 +104,32 @@ void push_warning(THD *thd, MYSQL_ERROR::enum_warning_level level, uint code, thd->total_warn_count++; } +/* + Store warning to the list +*/ + +void store_warning(THD *thd, uint errcode, ...) +{ + va_list args; + const char *format; + char warning[ERRMSGSIZE+20]; + DBUG_ENTER("store_warning"); + DBUG_PRINT("enter",("warning: %u",errcode)); + + va_start(args,errcode); + if (errcode) + format= ER(errcode); + else + { + format=va_arg(args,char*); + errcode= ER_UNKNOWN_ERROR; + } + (void) vsprintf (warning,format,args); + va_end(args); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, errcode, warning); + DBUG_VOID_RETURN; +} + /* Send all notes, errors or warnings to the client in a result set diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 00077bda39f..bd720109a4d 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -163,8 +163,10 @@ int mysql_rm_table_part2(THD *thd, TABLE_LIST *tables, bool if_exists, if (access(path,F_OK)) { - if (!if_exists) - error=1; + if (if_exists) + store_warning(thd, ER_BAD_TABLE_ERROR, table->real_name); + else + error= 1; } else { |