summaryrefslogtreecommitdiff
path: root/sql/event_data_objects.cc
diff options
context:
space:
mode:
authorkostja@vajra.(none) <>2007-04-05 15:24:34 +0400
committerkostja@vajra.(none) <>2007-04-05 15:24:34 +0400
commit98db2300865004a4bb573caebc82b25fb5b08911 (patch)
tree0b971c23e8972589634666ba0253a19e298ee0bf /sql/event_data_objects.cc
parentc392623bf9fd24193673737902c9751a0bea3e3b (diff)
downloadmariadb-git-98db2300865004a4bb573caebc82b25fb5b08911.tar.gz
A set of changes aiming to make the Event Scheduler more user-friendly
when there are no up-to-date system tables to support it: - initialize the scheduler before reporting "Ready for connections". This ensures that warnings, if any, are printed before "Ready for connections", and this message is not mangled. - do not abort the scheduler if there are no system tables - check the tables once at start up, remember the status and disable the scheduler if the tables are not up to date. If one attempts to use the scheduler with bad tables, issue an error message. - clean up the behaviour of the module under LOCK TABLES and pre-locking mode - make sure implicit commit of Events DDL works as expected. - add more tests Collateral clean ups in the events code. This patch fixes Bug#23631 Events: SHOW VARIABLES doesn't work when mysql.event is damaged
Diffstat (limited to 'sql/event_data_objects.cc')
-rw-r--r--sql/event_data_objects.cc94
1 files changed, 36 insertions, 58 deletions
diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc
index e87a78a5e37..95bfba548de 100644
--- a/sql/event_data_objects.cc
+++ b/sql/event_data_objects.cc
@@ -20,8 +20,6 @@
#include "event_db_repository.h"
#include "sp_head.h"
-/* That's a provisional solution */
-extern Event_db_repository events_event_db_repository;
#define EVEX_MAX_INTERVAL_VALUE 1000000000L
@@ -215,7 +213,7 @@ Event_parse_data::init_body(THD *thd)
++body_begin;
--body.length;
}
- body.str= thd->strmake((char *)body_begin, body.length);
+ body.str= thd->strmake(body_begin, body.length);
DBUG_VOID_RETURN;
}
@@ -694,7 +692,7 @@ Event_basic::load_string_fields(Field **fields, ...)
va_start(args, fields);
field_name= (enum enum_events_table_field) va_arg(args, int);
- while (field_name != ET_FIELD_COUNT)
+ while (field_name < ET_FIELD_COUNT)
{
field_value= va_arg(args, LEX_STRING *);
if ((field_value->str= get_field(&mem_root, fields[field_name])) == NullS)
@@ -858,13 +856,19 @@ Event_job_data::load_from_row(THD *thd, TABLE *table)
if (!table)
goto error;
- if (table->s->fields != ET_FIELD_COUNT)
+ if (table->s->fields < ET_FIELD_COUNT)
goto error;
LEX_STRING tz_name;
- load_string_fields(table->field, ET_FIELD_DB, &dbname, ET_FIELD_NAME, &name,
- ET_FIELD_BODY, &body, ET_FIELD_DEFINER, &definer,
- ET_FIELD_TIME_ZONE, &tz_name, ET_FIELD_COUNT);
+ if (load_string_fields(table->field,
+ ET_FIELD_DB, &dbname,
+ ET_FIELD_NAME, &name,
+ ET_FIELD_BODY, &body,
+ ET_FIELD_DEFINER, &definer,
+ ET_FIELD_TIME_ZONE, &tz_name,
+ ET_FIELD_COUNT))
+ goto error;
+
if (load_time_zone(thd, tz_name))
goto error;
@@ -910,19 +914,24 @@ Event_queue_element::load_from_row(THD *thd, TABLE *table)
{
char *ptr;
TIME time;
+ LEX_STRING tz_name;
DBUG_ENTER("Event_queue_element::load_from_row");
if (!table)
goto error;
- if (table->s->fields != ET_FIELD_COUNT)
+ if (table->s->fields < ET_FIELD_COUNT)
+ goto error;
+
+ if (load_string_fields(table->field,
+ ET_FIELD_DB, &dbname,
+ ET_FIELD_NAME, &name,
+ ET_FIELD_DEFINER, &definer,
+ ET_FIELD_TIME_ZONE, &tz_name,
+ ET_FIELD_COUNT))
goto error;
- LEX_STRING tz_name;
- load_string_fields(table->field, ET_FIELD_DB, &dbname, ET_FIELD_NAME, &name,
- ET_FIELD_DEFINER, &definer,
- ET_FIELD_TIME_ZONE, &tz_name, ET_FIELD_COUNT);
if (load_time_zone(thd, tz_name))
goto error;
@@ -1039,7 +1048,11 @@ Event_timed::load_from_row(THD *thd, TABLE *table)
if (Event_queue_element::load_from_row(thd, table))
goto error;
- load_string_fields(table->field, ET_FIELD_BODY, &body, ET_FIELD_COUNT);
+ if (load_string_fields(table->field,
+ ET_FIELD_BODY, &body,
+ ET_FIELD_COUNT))
+ goto error;
+
ptr= strchr(definer.str, '@');
@@ -1594,10 +1607,8 @@ Event_queue_element::mark_last_executed(THD *thd)
bool
Event_queue_element::update_timing_fields(THD *thd)
{
- TABLE *table;
- Field **fields;
- Open_tables_state backup;
- int ret= FALSE;
+ Event_db_repository *db_repository= Events::get_db_repository();
+ int ret;
DBUG_ENTER("Event_queue_element::update_timing_fields");
@@ -1607,46 +1618,13 @@ Event_queue_element::update_timing_fields(THD *thd)
if (!(status_changed || last_executed_changed))
DBUG_RETURN(0);
- thd->reset_n_backup_open_tables_state(&backup);
-
- if (events_event_db_repository.open_event_table(thd, TL_WRITE, &table))
- {
- ret= TRUE;
- goto done;
- }
- fields= table->field;
- if ((ret= events_event_db_repository.
- find_named_event(thd, dbname, name, table)))
- goto done;
-
- store_record(table,record[1]);
- /* Don't update create on row update. */
- table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET;
-
- if (last_executed_changed)
- {
- TIME time;
- my_tz_UTC->gmt_sec_to_TIME(&time, last_executed);
-
- fields[ET_FIELD_LAST_EXECUTED]->set_notnull();
- fields[ET_FIELD_LAST_EXECUTED]->store_time(&time,
- MYSQL_TIMESTAMP_DATETIME);
- last_executed_changed= FALSE;
- }
- if (status_changed)
- {
- fields[ET_FIELD_STATUS]->set_notnull();
- fields[ET_FIELD_STATUS]->store((longlong)status, TRUE);
- status_changed= FALSE;
- }
-
- if ((table->file->ha_update_row(table->record[1], table->record[0])))
- ret= TRUE;
-
-done:
- close_thread_tables(thd);
- thd->restore_backup_open_tables_state(&backup);
-
+ ret= db_repository->update_timing_fields_for_event(thd,
+ dbname, name,
+ last_executed_changed,
+ last_executed,
+ status_changed,
+ (ulonglong) status);
+ last_executed_changed= status_changed= FALSE;
DBUG_RETURN(ret);
}