mirror of
https://github.com/MariaDB/server.git
synced 2026-05-07 23:54:31 +02:00
This patch introduces specialized Event data objects Event_basic as parent. Event_queue_element used for queue storage Event_timed used for SHOW EVENTS/ I_S.EVENTS / SHOW CREATE EVENT Event_job_data using during execution. Methods were moved out of Event_timed to other classes. This patch also introduces Events::LOCK_event_metadata. This patch gives new implementation of Events::dump_internal_status(). Now both the Event_scheduler and Event_queue return information during their ::dump_internal_status(). Shortened a bit the runtime for executing events test cases. mysql-test/r/events.result: update results mysql-test/r/events_bugs.result: update results mysql-test/r/events_logs_tests.result: update results mysql-test/r/events_scheduling.result: update results mysql-test/t/events.test: update test make --sleep more appropriate . saving some time could mean failure on loaded boxes though :( add tests for previously uncovered branches. mysql-test/t/events_bugs.test: update test make --sleep more appropriate . saving some time could mean failure on loaded boxes though :( add tests for previously uncovered branches. mysql-test/t/events_logs_tests.test: make the test shorter by time mysql-test/t/events_scheduling.test: when selecting always use ORDER BY mysql-test/t/events_stress.test: sleep 2.5secs for shorter stress test sql/event_data_objects.cc: Event_timed is no more used during execution. Event_timed is no more used during in the memory queue. Event_timed is only used for SHOW CREATE EVENT/ I_S.EVENTS/ SHOW EVENTS Event_basic is the parent of almost all Event data objects. Event_basic -> Event_queue_element (used for the memory queue) -> Event_timed Event_basic -> Event_job_data (the object used for execution) Sql_alloc -> Event_parse_data (used during parsing) sql/event_data_objects.h: Event_timed is no more used during execution. Event_timed is no more used during in the memory queue. Event_timed is only used for SHOW CREATE EVENT/ I_S.EVENTS/ SHOW EVENTS Event_basic is the parent of almost all Event data objects. Event_basic -> Event_queue_element (used for the memory queue) -> Event_timed Event_basic -> Event_job_data (the object used for execution) Sql_alloc -> Event_parse_data (used during parsing) sql/event_db_repository.cc: Cosmetics. load_named_event now uses Event_basic, for polymorphism find_event uses Event_basic, to be polymorphic. use Field **fields= table->field and then index fields[...] Add documentation. Fix documentation. sql/event_db_repository.h: Event_db_repository depends only on Event_basic's interface sql/event_queue.cc: Cosmetics. Don't use Event_timed for the queue and giving back object for execution. Event_queue_element is for the queue, Event_job_data is for execution. Add Event_queue::dump_internal_status() for SHOW SCHEDULER STATUS command sql/event_queue.h: Cosmetics. Don't use Event_timed for the queue and giving back object for execution. Event_queue_element is for the queue, Event_job_data is for execution. Add Event_queue::dump_internal_status() for SHOW SCHEDULER STATUS command sql/event_scheduler_ng.cc: Add back Event_scheduler::cond_wait() Add back Event_scheduler::dump_internal_status() Using Event_job_data for execution. Make the scheduler thread unkillable (thd->command= COM_DAEMON). Add a lot of documentation. sql/event_scheduler_ng.h: Add back Event_scheduler::cond_wait() Add back Event_scheduler::dump_internal_status() Using Event_job_data for execution. sql/events.cc: Documentation Add LOCK_event_metadata sql/events.h: Change the signature of Events::drop_event() not to use sp_name but LEX_STRING sql/share/errmsg.txt: Fix error message sql/sql_parse.cc: Events::drop_event() has new signature
131 lines
2.9 KiB
C++
131 lines
2.9 KiB
C++
#ifndef _EVENT_H_
|
|
#define _EVENT_H_
|
|
/* Copyright (C) 2004-2006 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
class sp_name;
|
|
class Event_parse_data;
|
|
class Event_db_repository;
|
|
class Event_queue;
|
|
class Event_queue_element;
|
|
class Event_scheduler_ng;
|
|
|
|
/* Return codes */
|
|
enum enum_events_error_code
|
|
{
|
|
OP_OK= 0,
|
|
OP_NOT_RUNNING,
|
|
OP_CANT_KILL,
|
|
OP_CANT_INIT,
|
|
OP_DISABLED_EVENT,
|
|
OP_LOAD_ERROR,
|
|
OP_ALREADY_EXISTS
|
|
};
|
|
|
|
int
|
|
sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs);
|
|
|
|
|
|
class Events
|
|
{
|
|
public:
|
|
friend class Event_queue_element;
|
|
/*
|
|
Quite NOT the best practice and will be removed once
|
|
Event_timed::drop() and Event_timed is fixed not do drop directly
|
|
or other scheme will be found.
|
|
*/
|
|
|
|
static ulong opt_event_scheduler;
|
|
static TYPELIB opt_typelib;
|
|
|
|
int
|
|
init();
|
|
|
|
void
|
|
deinit();
|
|
|
|
void
|
|
init_mutexes();
|
|
|
|
void
|
|
destroy_mutexes();
|
|
|
|
bool
|
|
start_execution_of_events();
|
|
|
|
bool
|
|
stop_execution_of_events();
|
|
|
|
bool
|
|
is_started();
|
|
|
|
static Events*
|
|
get_instance();
|
|
|
|
int
|
|
create_event(THD *thd, Event_parse_data *parse_data, bool if_exists,
|
|
uint *rows_affected);
|
|
|
|
int
|
|
update_event(THD *thd, Event_parse_data *parse_data, sp_name *new_name,
|
|
uint *rows_affected);
|
|
|
|
int
|
|
drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists,
|
|
uint *rows_affected, bool only_from_disk);
|
|
|
|
int
|
|
drop_schema_events(THD *thd, char *db);
|
|
|
|
int
|
|
open_event_table(THD *thd, enum thr_lock_type lock_type, TABLE **table);
|
|
|
|
int
|
|
show_create_event(THD *thd, sp_name *spn);
|
|
|
|
/* Needed for both SHOW CREATE EVENT and INFORMATION_SCHEMA */
|
|
static int
|
|
reconstruct_interval_expression(String *buf, interval_type interval,
|
|
longlong expression);
|
|
|
|
static int
|
|
fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */);
|
|
|
|
bool
|
|
dump_internal_status(THD *thd);
|
|
|
|
private:
|
|
/* Singleton DP is used */
|
|
Events(){}
|
|
~Events(){}
|
|
|
|
/* Singleton instance */
|
|
static Events singleton;
|
|
|
|
Event_queue *event_queue;
|
|
Event_scheduler_ng *scheduler_ng;
|
|
Event_db_repository *db_repository;
|
|
|
|
pthread_mutex_t LOCK_event_metadata;
|
|
|
|
/* Prevent use of these */
|
|
Events(const Events &);
|
|
void operator=(Events &);
|
|
};
|
|
|
|
|
|
#endif /* _EVENT_H_ */
|