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