Commit 91558620 authored by venu@myvenu.com's avatar venu@myvenu.com

Return a warning for DROP DATABASE/TABLE IF EXISTS <non_existing_db/table(s)>

parent ed8cc2a8
......@@ -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 */
......
......@@ -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)
else
{
store_warning(thd,ER_DB_DROP_EXISTS,db);
if (!silent)
send_ok(thd,0);
}
goto exit;
}
pthread_mutex_lock(&LOCK_open);
......
......@@ -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
......
......@@ -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
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment