My Project
|
Classes | |
class | Event_creation_ctx |
class | Event_queue_element_for_exec |
class | Event_basic |
class | Event_queue_element |
class | Event_timed |
class | Event_job_data |
class | Event_db_intact |
class | Event_db_repository |
class | Event_queue |
struct | scheduler_param |
class | Event_worker_thread |
class | Event_scheduler |
class | Events |
A facade to the functionality of the Event Scheduler. More... | |
Files | |
file | event_data_objects.h |
file | event_db_repository.h |
file | event_queue.h |
file | event_scheduler.h |
file | events.h |
Defines | |
#define | EVENT_QUEUE_INITIAL_SIZE 30 |
#define | EVENT_QUEUE_EXTENT 30 |
#define | SCHED_FUNC "<unknown>" |
#define | LOCK_QUEUE_DATA() lock_data(SCHED_FUNC, __LINE__) |
#define | UNLOCK_QUEUE_DATA() unlock_data(SCHED_FUNC, __LINE__) |
#define | SCHED_FUNC "<unknown>" |
#define | LOCK_DATA() lock_data(SCHED_FUNC, __LINE__) |
#define | UNLOCK_DATA() unlock_data(SCHED_FUNC, __LINE__) |
#define | COND_STATE_WAIT(mythd, abstime, stage) cond_wait(mythd, abstime, stage, SCHED_FUNC, __FILE__, __LINE__) |
Typedefs | |
typedef struct charset_info_st | CHARSET_INFO |
Enumerations | |
enum | enum_events_table_field { ET_FIELD_DB = 0, ET_FIELD_NAME, ET_FIELD_BODY, ET_FIELD_DEFINER, ET_FIELD_EXECUTE_AT, ET_FIELD_INTERVAL_EXPR, ET_FIELD_TRANSIENT_INTERVAL, ET_FIELD_CREATED, ET_FIELD_MODIFIED, ET_FIELD_LAST_EXECUTED, ET_FIELD_STARTS, ET_FIELD_ENDS, ET_FIELD_STATUS, ET_FIELD_ON_COMPLETION, ET_FIELD_SQL_MODE, ET_FIELD_COMMENT, ET_FIELD_ORIGINATOR, ET_FIELD_TIME_ZONE, ET_FIELD_CHARACTER_SET_CLIENT, ET_FIELD_COLLATION_CONNECTION, ET_FIELD_DB_COLLATION, ET_FIELD_BODY_UTF8, ET_FIELD_COUNT } |
Functions | |
bool | event_basic_db_equal (LEX_STRING db, Event_basic *et) |
bool | event_basic_identifier_equal (LEX_STRING db, LEX_STRING name, Event_basic *b) |
int | events_table_index_read_for_db (THD *thd, TABLE *schema_table, TABLE *event_table) |
int | events_table_scan_all (THD *thd, TABLE *schema_table, TABLE *event_table) |
int | event_queue_element_compare_q (void *, uchar *, uchar *) |
bool | post_init_event_thread (THD *thd) |
void | deinit_event_thread (THD *thd) |
void | pre_init_event_thread (THD *thd) |
pthread_handler_t | event_scheduler_thread (void *arg) |
pthread_handler_t | event_worker_thread (void *arg) |
int | sortcmp_lex_string (LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs) |
static bool | Event_creation_ctx::load_from_db (THD *thd, MEM_ROOT *event_mem_root, const char *db_name, const char *event_name, TABLE *event_tbl, Stored_program_creation_ctx **ctx) |
bool | Event_queue_element_for_exec::init (LEX_STRING dbname, LEX_STRING name) |
bool | Event_basic::load_string_fields (Field **fields,...) |
bool | Event_basic::load_time_zone (THD *thd, const LEX_STRING tz_name) |
void | Event_timed::init () |
virtual bool | Event_job_data::load_from_row (THD *thd, TABLE *table) |
virtual bool | Event_queue_element::load_from_row (THD *thd, TABLE *table) |
virtual bool | Event_timed::load_from_row (THD *thd, TABLE *table) |
bool | Event_queue_element::compute_next_execution_time () |
void | Event_queue_element::mark_last_executed (THD *thd) |
int | Event_timed::get_create_event (THD *thd, String *buf) |
bool | Event_job_data::execute (THD *thd, bool drop) |
bool | Event_db_repository::fill_schema_events (THD *thd, TABLE_LIST *tables, const char *db) |
static bool | Event_db_repository::open_event_table (THD *thd, enum thr_lock_type lock_type, TABLE **table) |
bool | Event_db_repository::create_event (THD *thd, Event_parse_data *parse_data, bool create_if_not, bool *event_already_exists) |
bool | Event_db_repository::update_event (THD *thd, Event_parse_data *parse_data, LEX_STRING *new_dbname, LEX_STRING *new_name) |
bool | Event_db_repository::drop_event (THD *thd, LEX_STRING db, LEX_STRING name, bool drop_if_exists) |
bool | Event_db_repository::find_named_event (LEX_STRING db, LEX_STRING name, TABLE *table) |
void | Event_db_repository::drop_schema_events (THD *thd, LEX_STRING schema) |
bool | Event_db_repository::load_named_event (THD *thd, LEX_STRING dbname, LEX_STRING name, Event_basic *et) |
bool | Event_db_repository::update_timing_fields_for_event (THD *thd, LEX_STRING event_db_name, LEX_STRING event_name, my_time_t last_executed, ulonglong status) |
static bool | Event_db_repository::check_system_tables (THD *thd) |
bool | Event_queue::init_queue (THD *thd) |
bool | Event_queue::create_event (THD *thd, Event_queue_element *new_element, bool *created) |
void | Event_queue::update_event (THD *thd, LEX_STRING dbname, LEX_STRING name, Event_queue_element *new_element) |
void | Event_queue::drop_event (THD *thd, LEX_STRING dbname, LEX_STRING name) |
void | Event_queue::drop_schema_events (THD *thd, LEX_STRING schema) |
void | Event_queue::recalculate_activation_times (THD *thd) |
bool | Event_queue::get_top_for_execution_if_time (THD *thd, Event_queue_element_for_exec **event_name) |
void | Event_queue::dump_internal_status () |
void | Event_worker_thread::run (THD *thd, Event_queue_element_for_exec *event) |
Event_scheduler::Event_scheduler (Event_queue *event_queue_arg) | |
bool | Event_scheduler::start (int *err_no) |
bool | Event_scheduler::run (THD *thd) |
bool | Event_scheduler::is_running () |
bool | Event_scheduler::stop () |
void | Event_scheduler::dump_internal_status () |
static bool | Events::check_if_system_tables_error () |
static int | Events::reconstruct_interval_expression (String *buf, interval_type interval, longlong expression) |
static bool | Events::create_event (THD *thd, Event_parse_data *parse_data, bool if_exists) |
static bool | Events::update_event (THD *thd, Event_parse_data *parse_data, LEX_STRING *new_dbname, LEX_STRING *new_name) |
static bool | Events::drop_event (THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists) |
static void | Events::drop_schema_events (THD *thd, char *db) |
static bool | Events::show_create_event (THD *thd, LEX_STRING dbname, LEX_STRING name) |
static int | Events::fill_schema_events (THD *thd, TABLE_LIST *tables, Item *) |
static bool | Events::init (my_bool opt_noacl) |
static void | Events::deinit () |
static void | Events::init_mutexes () |
static void | Events::dump_internal_status () |
static bool | Events::start (int *err_no) |
static bool | Events::stop () |
Variables | |
pthread_attr_t | connection_attrib |
PSI_stage_info | stage_waiting_on_empty_queue = { 0, "Waiting on empty queue", 0} |
PSI_stage_info | stage_waiting_for_next_activation = { 0, "Waiting for next activation", 0} |
PSI_stage_info | stage_waiting_for_scheduler_to_stop = { 0, "Waiting for the scheduler to stop", 0} |
PSI_stage_info | stage_waiting_on_empty_queue |
PSI_stage_info | stage_waiting_for_next_activation |
PSI_stage_info | stage_waiting_for_scheduler_to_stop |
static ulong | Events::opt_event_scheduler = Events::EVENTS_OFF |
bool Events::check_if_system_tables_error | ( | ) | [static] |
Push an error into the error stack if the system tables are not up to date.
bool Event_db_repository::check_system_tables | ( | THD * | thd | ) | [static] |
Open mysql.db, mysql.user and mysql.event and check whether:
This function is called only when the server is started.
FALSE | OK |
TRUE | Error, an error message is output to the error log. |
bool Event_queue::create_event | ( | THD * | thd, |
Event_queue_element * | new_element, | ||
bool * | created | ||
) |
Adds an event to the queue.
Compute the next execution time for an event, and if it is still active, add it to the queue. Otherwise delete it. The object is left intact in case of an error. Otherwise the queue container assumes ownership of it.
[in] | thd | thread handle |
[in] | new_element | a new element to add to the queue |
[out] | created | set to TRUE if no error and the element is added to the queue, FALSE otherwise |
TRUE | an error occured. The value of created is undefined, the element was not deleted. |
FALSE | success |
bool Event_db_repository::create_event | ( | THD * | thd, |
Event_parse_data * | parse_data, | ||
bool | create_if_not, | ||
bool * | event_already_exists | ||
) |
Creates an event record in mysql.event table.
Creates an event. Relies on mysql_event_fill_row which is shared with ::update_event.
[in,out] | thd | THD |
[in] | parse_data | Parsed event definition |
[in] | create_if_not | TRUE if IF NOT EXISTS clause was provided to CREATE EVENT statement |
[out] | event_already_exists | When method is completed successfully set to true if event already exists else set to false |
FALSE | success |
TRUE | error |
bool Events::create_event | ( | THD * | thd, |
Event_parse_data * | parse_data, | ||
bool | if_not_exists | ||
) | [static] |
Create a new event.
[in,out] | thd | THD |
[in] | parse_data | Event's data from parsing stage |
[in] | if_not_exists | Whether IF NOT EXISTS was specified In case there is an event with the same name (db) and IF NOT EXISTS is specified, an warning is put into the stack. |
FALSE | OK |
TRUE | Error (reported) |
bool Event_db_repository::drop_event | ( | THD * | thd, |
LEX_STRING | db, | ||
LEX_STRING | name, | ||
bool | drop_if_exists | ||
) |
Delete event record from mysql.event table.
[in,out] | thd | thread handle |
[in] | db | Database name |
[in] | name | Event name |
[in] | drop_if_exists | DROP IF EXISTS clause was specified. If set, and the event does not exist, the error is downgraded to a warning. |
FALSE | success |
TRUE | error (reported) |
bool Events::drop_event | ( | THD * | thd, |
LEX_STRING | dbname, | ||
LEX_STRING | name, | ||
bool | if_exists | ||
) | [static] |
Drops an event
[in,out] | thd | THD |
[in] | dbname | Event's schema |
[in] | name | Event's name |
[in] | if_exists | When this is set and the event does not exist a warning is pushed into the warning stack. Otherwise the operation produces an error. |
FALSE | OK |
TRUE | Error (reported) |
void Events::drop_schema_events | ( | THD * | thd, |
char * | db | ||
) | [static] |
Drops all events from a schema
[in,out] | thd | Thread |
[in] | db | ASCIIZ schema name |
pthread_handler_t event_worker_thread | ( | void * | arg | ) |
Function that executes an event in a child thread. Setups the environment for the event execution and cleans after that.
SYNOPSIS event_worker_thread() arg The Event_job_data object to be processed
RETURN VALUE 0 OK
bool Event_job_data::execute | ( | THD * | thd, |
bool | drop | ||
) |
Compiles and executes the event (the underlying sp_head object)
TRUE | error (reported to the error log) |
FALSE | success |
bool Event_db_repository::fill_schema_events | ( | THD * | thd, |
TABLE_LIST * | i_s_table, | ||
const char * | db | ||
) |
Fills I_S.EVENTS with data loaded from mysql.event. Also used by SHOW EVENTS
The reason we reset and backup open tables here is that this function may be called from any query that accesses INFORMATION_SCHEMA - including a query that is issued from a pre-locked statement, one that already has open and locked tables.
FALSE | success |
TRUE | error |
int Events::fill_schema_events | ( | THD * | thd, |
TABLE_LIST * | tables, | ||
Item * | |||
) | [static] |
Check access rights and fill INFORMATION_SCHEMA.events table.
[in,out] | thd | Thread context |
[in] | tables | The temporary table to fill. |
In MySQL INFORMATION_SCHEMA tables are temporary tables that are created and filled on demand. In this function, we fill INFORMATION_SCHEMA.events. It is a callback for I_S module, invoked from sql_show.cc
0 | success |
1 | an error, pushed into the error stack |
bool Event_db_repository::find_named_event | ( | LEX_STRING | db, |
LEX_STRING | name, | ||
TABLE * | table | ||
) |
Positions the internal pointer of `table` to the place where (db, name) is stored.
In case search succeeded, the table cursor points at the found row.
[in] | db | database name |
[in] | name | event name |
[in,out] | table | mysql.event table |
FALSE | an event with such db/name key exists |
TRUE | no record found or an error occured. |
bool Events::init | ( | my_bool | opt_noacl_or_bootstrap | ) | [static] |
Initializes the scheduler's structures.
opt_noacl_or_bootstrap | TRUE if there is --skip-grant-tables or --bootstrap option. In that case we disable the event scheduler. |
FALSE | Perhaps there was an error, and the event scheduler is disabled. But the error is not fatal and the server start up can continue. |
TRUE | Fatal error. Startup must terminate (call unireg_abort()). |
void Events::init_mutexes | ( | ) | [static] |
Inits Events mutexes
SYNOPSIS Events::init_mutexes() thd Thread
bool Event_queue_element::load_from_row | ( | THD * | thd, |
TABLE * | table | ||
) | [virtual] |
Load an event's body from a row from mysql.event.
This method is silent on errors and should behave like that. Callers should handle throwing of error messages. The reason is that the class should not know about how to deal with communication.
FALSE | OK |
TRUE | Error |
Implements Event_basic.
Reimplemented in Event_timed.
bool Event_timed::load_from_row | ( | THD * | thd, |
TABLE * | table | ||
) | [virtual] |
Load an event's body from a row from mysql.event.
This method is silent on errors and should behave like that. Callers should handle throwing of error messages. The reason is that the class should not know about how to deal with communication.
FALSE | OK |
TRUE | Error |
Reimplemented from Event_queue_element.
bool Event_job_data::load_from_row | ( | THD * | thd, |
TABLE * | table | ||
) | [virtual] |
Load an event's body from a row from mysql.event.
This method is silent on errors and should behave like that. Callers should handle throwing of error messages. The reason is that the class should not know about how to deal with communication.
FALSE | OK |
TRUE | Error |
Implements Event_basic.
bool Event_db_repository::load_named_event | ( | THD * | thd, |
LEX_STRING | dbname, | ||
LEX_STRING | name, | ||
Event_basic * | etn | ||
) |
Looks for a named event in mysql.event and then loads it from the table.
FALSE | success |
TRUE | error |
bool Event_db_repository::open_event_table | ( | THD * | thd, |
enum thr_lock_type | lock_type, | ||
TABLE ** | table | ||
) | [static] |
Open mysql.event table for read.
It's assumed that the caller knows what they are doing:
Note that if the table can't be locked successfully this operation will close it. Therefore it provides guarantee that it either opens and locks table or fails without leaving any tables open.
[in] | thd | Thread context |
[in] | lock_type | How to lock the table |
[out] | table | We will store the open table here |
TRUE | open and lock failed - an error message is pushed into the stack |
FALSE | success |
int Events::reconstruct_interval_expression | ( | String * | buf, |
interval_type | interval, | ||
longlong | expression | ||
) | [static] |
Reconstructs interval expression from interval type and expression value that is in form of a value of the smalles entity: For YEAR_MONTH - expression is in months DAY_MINUTE - expression is in minutes
SYNOPSIS Events::reconstruct_interval_expression() buf Preallocated String buffer to add the value to interval The interval type (for instance YEAR_MONTH) expression The value in the lowest entity
RETURN VALUE 0 OK 1 Error
void Event_worker_thread::run | ( | THD * | thd, |
Event_queue_element_for_exec * | event | ||
) |
Function that executes an event in a child thread. Setups the environment for the event execution and cleans after that.
SYNOPSIS Event_worker_thread::run() thd Thread context event The Event_queue_element_for_exec object to be processed
bool Events::show_create_event | ( | THD * | thd, |
LEX_STRING | dbname, | ||
LEX_STRING | name | ||
) | [static] |
Implement SHOW CREATE EVENT statement
thd Thread context spn The name of the event (db, name)
FALSE | OK |
TRUE | error (reported) |
bool Event_scheduler::start | ( | int * | err_no | ) |
Starts the scheduler (again). Creates a new THD and passes it to a forked thread. Does not wait for acknowledgement from the new thread that it has started. Asynchronous starting. Most of the needed initializations are done in the current thread to minimize the chance of failure in the spawned thread.
[out] | err_no | - errno indicating type of error which caused failure to start scheduler thread. |
false | Success. |
true | Error. |
bool Event_scheduler::stop | ( | ) |
Stops the scheduler (again). Waits for acknowledgement from the scheduler that it has stopped - synchronous stopping.
Already running events will not be stopped. If the user needs them stopped manual intervention is needed.
SYNOPSIS Event_scheduler::stop()
RETURN VALUE FALSE OK TRUE Error (not reported)
bool Event_db_repository::update_event | ( | THD * | thd, |
Event_parse_data * | parse_data, | ||
LEX_STRING * | new_dbname, | ||
LEX_STRING * | new_name | ||
) |
Used to execute ALTER EVENT. Pendant to Events::update_event().
[in,out] | thd | thread handle |
[in] | parse_data | parsed event definition |
[in] | new_dbname | not NULL if ALTER EVENT RENAME points at a new database name |
[in] | new_name | not NULL if ALTER EVENT RENAME points at a new event name |
FALSE | success |
TRUE | error (reported) |
bool Events::update_event | ( | THD * | thd, |
Event_parse_data * | parse_data, | ||
LEX_STRING * | new_dbname, | ||
LEX_STRING * | new_name | ||
) | [static] |
Alter an event.
[in,out] | thd | THD |
[in] | parse_data | Event's data from parsing stage |
[in] | new_dbname | A new schema name for the event. Set in the case of ALTER EVENT RENAME, otherwise is NULL. |
[in] | new_name | A new name for the event. Set in the case of ALTER EVENT RENAME |
Parameter 'et' contains data about dbname and event name. Parameter 'new_name' is the new name of the event, if not null this means that RENAME TO was specified in the query
FALSE | OK |
TRUE | error (reported) |
bool Event_db_repository::update_timing_fields_for_event | ( | THD * | thd, |
LEX_STRING | event_db_name, | ||
LEX_STRING | event_name, | ||
my_time_t | last_executed, | ||
ulonglong | status | ||
) |
Update the event record in mysql.event table with a changed status and/or last execution time.