summaryrefslogtreecommitdiff
path: root/sql/event_db_repository.cc
diff options
context:
space:
mode:
authorDmitry Shulga <Dmitry.Shulga@oracle.com>2011-06-10 00:03:17 +0700
committerDmitry Shulga <Dmitry.Shulga@oracle.com>2011-06-10 00:03:17 +0700
commitfa913a0b987d94164449511cf0cef5baf1fb9a6f (patch)
tree8682dccf8a8135c43ef8740a59d2f4f9ad1bfceb /sql/event_db_repository.cc
parent6348b7375a506bfe340a390ed6ac832d1e224333 (diff)
downloadmariadb-git-fa913a0b987d94164449511cf0cef5baf1fb9a6f.tar.gz
Fixed bug#11764334 (formerly bug#57156): ALTER EVENT CHANGES
THE EVENT STATUS. Any ALTER EVENT statement on a disabled event enabled it back (unless this ALTER EVENT statement explicitly disabled the event). The problem was that during processing of an ALTER EVENT statement value of status field was overwritten unconditionally even if new value was not specified explicitly. As a consequence this field was set to default value for status which corresponds to ENABLE. The solution is to check if status field was explicitly specified in ALTER EVENT statement before assigning new value to status field. mysql-test/r/events_bugs.result: test's result for Bug#11764334 was added. mysql-test/t/events_bugs.test: new test for Bug#11764334 was added. sql/event_db_repository.cc: mysql_event_fill_row() was modified: set value for status field in events tables only in case if statement CREATE EVENT is being processed or if this value was set in ALTER EVENT statement. Event_db_repository::create_event was modified: removed redundant setting of status field after return from call to mysql_event_fill_row(). sql/event_parse_data.h: Event_parse_data structure was modified: added flag status_changed that is set to true if status's value was changed in ALTER EVENT statement. sql/sql_yacc.yy: Set flag status_changed if status was set in ALTER EVENT statement.
Diffstat (limited to 'sql/event_db_repository.cc')
-rw-r--r--sql/event_db_repository.cc13
1 files changed, 9 insertions, 4 deletions
diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc
index 9efd3bca675..50339165b20 100644
--- a/sql/event_db_repository.cc
+++ b/sql/event_db_repository.cc
@@ -226,9 +226,16 @@ mysql_event_fill_row(THD *thd,
if (fields[f_num= ET_FIELD_NAME]->store(et->name.str, et->name.length, scs))
goto err_truncate;
- /* both ON_COMPLETION and STATUS are NOT NULL thus not calling set_notnull()*/
+ /* ON_COMPLETION field is NOT NULL thus not calling set_notnull()*/
rs|= fields[ET_FIELD_ON_COMPLETION]->store((longlong)et->on_completion, TRUE);
- rs|= fields[ET_FIELD_STATUS]->store((longlong)et->status, TRUE);
+
+ /*
+ Set STATUS value unconditionally in case of CREATE EVENT.
+ For ALTER EVENT set it only if value of this field was changed.
+ Since STATUS field is NOT NULL call to set_notnull() is not needed.
+ */
+ if (!is_update || et->status_changed)
+ rs|= fields[ET_FIELD_STATUS]->store((longlong)et->status, TRUE);
rs|= fields[ET_FIELD_ORIGINATOR]->store((longlong)et->originator, TRUE);
/*
@@ -694,8 +701,6 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data,
if (mysql_event_fill_row(thd, table, parse_data, sp, saved_mode, FALSE))
goto end;
- table->field[ET_FIELD_STATUS]->store((longlong)parse_data->status, TRUE);
-
if ((ret= table->file->ha_write_row(table->record[0])))
{
table->file->print_error(ret, MYF(0));