mirror of
https://github.com/MariaDB/server.git
synced 2026-05-15 03:17:20 +02:00
MDEV-7281 EVENT: CREATE OR REPLACE
This commit is contained in:
parent
77806da0da
commit
2d01907c1d
12 changed files with 211 additions and 15 deletions
|
|
@ -654,7 +654,6 @@ Event_db_repository::open_event_table(THD *thd, enum thr_lock_type lock_type,
|
|||
|
||||
bool
|
||||
Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
|
||||
bool create_if_not,
|
||||
bool *event_already_exists)
|
||||
{
|
||||
int ret= 1;
|
||||
|
|
@ -685,18 +684,29 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
|
|||
DBUG_PRINT("info", ("check existance of an event with the same name"));
|
||||
if (!find_named_event(parse_data->dbname, parse_data->name, table))
|
||||
{
|
||||
if (create_if_not)
|
||||
if (thd->lex->create_info.or_replace())
|
||||
{
|
||||
*event_already_exists= false; // Force the caller to update event_queue
|
||||
if ((ret= table->file->ha_delete_row(table->record[0])))
|
||||
{
|
||||
table->file->print_error(ret, MYF(0));
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
else if (thd->lex->create_info.if_not_exists())
|
||||
{
|
||||
*event_already_exists= true;
|
||||
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
|
||||
ER_EVENT_ALREADY_EXISTS, ER(ER_EVENT_ALREADY_EXISTS),
|
||||
parse_data->name.str);
|
||||
ret= 0;
|
||||
goto end;
|
||||
}
|
||||
else
|
||||
{
|
||||
my_error(ER_EVENT_ALREADY_EXISTS, MYF(0), parse_data->name.str);
|
||||
|
||||
goto end;
|
||||
goto end;
|
||||
}
|
||||
} else
|
||||
*event_already_exists= false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue