Commit eedee130 authored by andrey@example.com's avatar andrey@example.com

WL#3337 (Event scheduler new architecture)

Don't send affected rows after CREATE/ALTER/DROP EVENT as this is
inconsistent with the rest of the server in terms of CREATE/ALTER/DROP
DDLs
parent 71bb7e59
...@@ -1437,11 +1437,10 @@ Event_queue_element::mark_last_executed(THD *thd) ...@@ -1437,11 +1437,10 @@ Event_queue_element::mark_last_executed(THD *thd)
int int
Event_queue_element::drop(THD *thd) Event_queue_element::drop(THD *thd)
{ {
uint tmp= 0;
DBUG_ENTER("Event_queue_element::drop"); DBUG_ENTER("Event_queue_element::drop");
DBUG_RETURN(Events::get_instance()-> DBUG_RETURN(Events::get_instance()->
drop_event(thd, dbname, name, FALSE, &tmp, TRUE)); drop_event(thd, dbname, name, FALSE, TRUE));
} }
......
...@@ -508,7 +508,6 @@ check_parse_params(THD *thd, Event_parse_data *parse_data) ...@@ -508,7 +508,6 @@ check_parse_params(THD *thd, Event_parse_data *parse_data)
thd [in] THD thd [in] THD
parse_data [in] Object containing info about the event parse_data [in] Object containing info about the event
create_if_not [in] Whether to generate anwarning in case event exists create_if_not [in] Whether to generate anwarning in case event exists
rows_affected [out] How many rows were affected
RETURN VALUE RETURN VALUE
0 OK 0 OK
...@@ -521,7 +520,7 @@ check_parse_params(THD *thd, Event_parse_data *parse_data) ...@@ -521,7 +520,7 @@ check_parse_params(THD *thd, Event_parse_data *parse_data)
bool bool
Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data, Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
my_bool create_if_not, uint *rows_affected) my_bool create_if_not)
{ {
int ret= 0; int ret= 0;
CHARSET_INFO *scs= system_charset_info; CHARSET_INFO *scs= system_charset_info;
...@@ -532,7 +531,6 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data, ...@@ -532,7 +531,6 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
DBUG_ENTER("Event_db_repository::create_event"); DBUG_ENTER("Event_db_repository::create_event");
*rows_affected= 0;
if (check_parse_params(thd, parse_data)) if (check_parse_params(thd, parse_data))
goto err; goto err;
...@@ -621,7 +619,6 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data, ...@@ -621,7 +619,6 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
goto err; goto err;
} }
*rows_affected= 1;
ok: ok:
if (dbchanged) if (dbchanged)
(void) mysql_change_db(thd, old_db.str, 1); (void) mysql_change_db(thd, old_db.str, 1);
...@@ -760,7 +757,6 @@ Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data, ...@@ -760,7 +757,6 @@ Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data,
name [in] Event's name name [in] Event's name
drop_if_exists [in] If set and the event not existing => warning drop_if_exists [in] If set and the event not existing => warning
onto the stack onto the stack
rows_affected [out] Affected number of rows is returned heres
RETURN VALUE RETURN VALUE
FALSE OK FALSE OK
...@@ -769,7 +765,7 @@ Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data, ...@@ -769,7 +765,7 @@ Event_db_repository::update_event(THD *thd, Event_parse_data *parse_data,
bool bool
Event_db_repository::drop_event(THD *thd, LEX_STRING db, LEX_STRING name, Event_db_repository::drop_event(THD *thd, LEX_STRING db, LEX_STRING name,
bool drop_if_exists, uint *rows_affected) bool drop_if_exists)
{ {
TABLE *table= NULL; TABLE *table= NULL;
Open_tables_state backup; Open_tables_state backup;
......
...@@ -56,16 +56,14 @@ class Event_db_repository ...@@ -56,16 +56,14 @@ class Event_db_repository
Event_db_repository(){} Event_db_repository(){}
bool bool
create_event(THD *thd, Event_parse_data *parse_data, my_bool create_if_not, create_event(THD *thd, Event_parse_data *parse_data, my_bool create_if_not);
uint *rows_affected);
bool bool
update_event(THD *thd, Event_parse_data *parse_data, LEX_STRING *new_dbname, update_event(THD *thd, Event_parse_data *parse_data, LEX_STRING *new_dbname,
LEX_STRING *new_name); LEX_STRING *new_name);
bool bool
drop_event(THD *thd, LEX_STRING db, LEX_STRING name, bool drop_if_exists, drop_event(THD *thd, LEX_STRING db, LEX_STRING name, bool drop_if_exists);
uint *rows_affected);
void void
drop_schema_events(THD *thd, LEX_STRING schema); drop_schema_events(THD *thd, LEX_STRING schema);
......
...@@ -304,7 +304,6 @@ Events::open_event_table(THD *thd, enum thr_lock_type lock_type, ...@@ -304,7 +304,6 @@ Events::open_event_table(THD *thd, enum thr_lock_type lock_type,
thd [in] THD thd [in] THD
parse_data [in] Event's data from parsing stage parse_data [in] Event's data from parsing stage
if_not_exists [in] Whether IF NOT EXISTS was specified in the DDL if_not_exists [in] Whether IF NOT EXISTS was specified in the DDL
rows_affected [out] How many rows were affected
RETURN VALUE RETURN VALUE
FALSE OK FALSE OK
...@@ -316,8 +315,7 @@ Events::open_event_table(THD *thd, enum thr_lock_type lock_type, ...@@ -316,8 +315,7 @@ Events::open_event_table(THD *thd, enum thr_lock_type lock_type,
*/ */
bool bool
Events::create_event(THD *thd, Event_parse_data *parse_data, bool if_not_exists, Events::create_event(THD *thd, Event_parse_data *parse_data, bool if_not_exists)
uint *rows_affected)
{ {
int ret; int ret;
DBUG_ENTER("Events::create_event"); DBUG_ENTER("Events::create_event");
...@@ -329,8 +327,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, bool if_not_exists, ...@@ -329,8 +327,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, bool if_not_exists,
pthread_mutex_lock(&LOCK_event_metadata); pthread_mutex_lock(&LOCK_event_metadata);
/* On error conditions my_error() is called so no need to handle here */ /* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->create_event(thd, parse_data, if_not_exists, if (!(ret= db_repository->create_event(thd, parse_data, if_not_exists)))
rows_affected)))
{ {
if ((ret= event_queue->create_event(thd, parse_data->dbname, if ((ret= event_queue->create_event(thd, parse_data->dbname,
parse_data->name))) parse_data->name)))
...@@ -353,7 +350,6 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, bool if_not_exists, ...@@ -353,7 +350,6 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, bool if_not_exists,
thd [in] THD thd [in] THD
parse_data [in] Event's data from parsing stage parse_data [in] Event's data from parsing stage
rename_to [in] Set in case of RENAME TO. rename_to [in] Set in case of RENAME TO.
rows_affected [out] How many rows were affected.
RETURN VALUE RETURN VALUE
FALSE OK FALSE OK
...@@ -366,8 +362,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, bool if_not_exists, ...@@ -366,8 +362,7 @@ Events::create_event(THD *thd, Event_parse_data *parse_data, bool if_not_exists,
*/ */
bool bool
Events::update_event(THD *thd, Event_parse_data *parse_data, sp_name *rename_to, Events::update_event(THD *thd, Event_parse_data *parse_data, sp_name *rename_to)
uint *rows_affected)
{ {
int ret; int ret;
DBUG_ENTER("Events::update_event"); DBUG_ENTER("Events::update_event");
...@@ -406,7 +401,6 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, sp_name *rename_to, ...@@ -406,7 +401,6 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, sp_name *rename_to,
name [in] Event's name name [in] Event's name
if_exists [in] When set and the event does not exist => if_exists [in] When set and the event does not exist =>
warning onto the stack warning onto the stack
rows_affected [out] Affected number of rows is returned here
only_from_disk [in] Whether to remove the event from the queue too. only_from_disk [in] Whether to remove the event from the queue too.
In case of Event_job_data::drop() it's needed to In case of Event_job_data::drop() it's needed to
do only disk drop because Event_queue will handle do only disk drop because Event_queue will handle
...@@ -419,7 +413,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, sp_name *rename_to, ...@@ -419,7 +413,7 @@ Events::update_event(THD *thd, Event_parse_data *parse_data, sp_name *rename_to,
bool bool
Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists, Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists,
uint *rows_affected, bool only_from_disk) bool only_from_disk)
{ {
int ret; int ret;
DBUG_ENTER("Events::drop_event"); DBUG_ENTER("Events::drop_event");
...@@ -431,8 +425,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists, ...@@ -431,8 +425,7 @@ Events::drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists,
pthread_mutex_lock(&LOCK_event_metadata); pthread_mutex_lock(&LOCK_event_metadata);
/* On error conditions my_error() is called so no need to handle here */ /* On error conditions my_error() is called so no need to handle here */
if (!(ret= db_repository->drop_event(thd, dbname, name, if_exists, if (!(ret= db_repository->drop_event(thd, dbname, name, if_exists)))
rows_affected)))
{ {
if (!only_from_disk) if (!only_from_disk)
event_queue->drop_event(thd, dbname, name); event_queue->drop_event(thd, dbname, name);
......
...@@ -77,16 +77,14 @@ class Events ...@@ -77,16 +77,14 @@ class Events
get_instance(); get_instance();
bool bool
create_event(THD *thd, Event_parse_data *parse_data, bool if_exists, create_event(THD *thd, Event_parse_data *parse_data, bool if_exists);
uint *rows_affected);
bool bool
update_event(THD *thd, Event_parse_data *parse_data, sp_name *rename_to, update_event(THD *thd, Event_parse_data *parse_data, sp_name *rename_to);
uint *rows_affected);
bool bool
drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists, drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists,
uint *rows_affected, bool only_from_disk); bool only_from_disk);
void void
drop_schema_events(THD *thd, char *db); drop_schema_events(THD *thd, char *db);
......
...@@ -3897,24 +3897,23 @@ mysql_execute_command(THD *thd) ...@@ -3897,24 +3897,23 @@ mysql_execute_command(THD *thd)
case SQLCOM_CREATE_EVENT: case SQLCOM_CREATE_EVENT:
case SQLCOM_ALTER_EVENT: case SQLCOM_ALTER_EVENT:
{ {
uint affected= 1;
DBUG_ASSERT(lex->event_parse_data); DBUG_ASSERT(lex->event_parse_data);
switch (lex->sql_command) { switch (lex->sql_command) {
case SQLCOM_CREATE_EVENT: case SQLCOM_CREATE_EVENT:
res= Events::get_instance()-> res= Events::get_instance()->
create_event(thd, lex->event_parse_data, create_event(thd, lex->event_parse_data,
lex->create_info.options & HA_LEX_CREATE_IF_NOT_EXISTS, lex->create_info.options & HA_LEX_CREATE_IF_NOT_EXISTS);
&affected);
break; break;
case SQLCOM_ALTER_EVENT: case SQLCOM_ALTER_EVENT:
res= Events::get_instance()-> res= Events::get_instance()->update_event(thd, lex->event_parse_data,
update_event(thd, lex->event_parse_data, lex->spname, &affected); lex->spname);
break; break;
default:; default:
DBUG_ASSERT(0);
} }
DBUG_PRINT("info",("DDL error code=%d affected=%d", res, affected)); DBUG_PRINT("info",("DDL error code=%d", res));
if (!res) if (!res)
send_ok(thd, affected); send_ok(thd);
/* Don't do it, if we are inside a SP */ /* Don't do it, if we are inside a SP */
if (!thd->spcont) if (!thd->spcont)
...@@ -3956,9 +3955,8 @@ mysql_execute_command(THD *thd) ...@@ -3956,9 +3955,8 @@ mysql_execute_command(THD *thd)
lex->spname->m_db, lex->spname->m_db,
lex->spname->m_name, lex->spname->m_name,
lex->drop_if_exists, lex->drop_if_exists,
&affected,
FALSE))) FALSE)))
send_ok(thd, affected); send_ok(thd);
} }
break; break;
} }
......
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