2006-06-08 23:07:11 +02:00
|
|
|
#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 */
|
|
|
|
|
WL#3337 (Event scheduler new architecture)
Third cut to simplify parsing phase. Now DROP EVENT works.
Overloaded few functions to be able to use either sp_name or pass two LEX_STRINGs
instead of a Event_timed pointer. This is transitional and eventually the old
functions will be removed. For now DROP EVENT also works, does not need anymore
a parsing object (Event_timed) and definer initialization because everyone who
has EVENT_ACL can drop events, and this is checked on execution time in sql_parse.cc
from the security context, as it should be.
sql/event_data_objects.cc:
overload few functions
sql/event_scheduler.cc:
Event_scheduler::drop_event() actually does not need Event_timed object
but just an identifier, hence pass only sp_name.
Overloaded Event_scheduler::find_event() to work with sp_name object. Eventually
the old version will be removed. This is being done as transitional step to
be able to test frequently code.
sql/event_scheduler.h:
Event_scheduler::drop_event() actually does not need Event_timed object
but just an identifier, hence pass only sp_name.
Overloaded Event_scheduler::find_event() to work with sp_name object. Eventually
the old version will be removed. This is being done as transitional step to
be able to test frequently code.
sql/events.cc:
Change db_drop_event() not to use Event_timed, either coming from parsing
or from Event_timed::drop, but use LEX_STRINGs. sp_name is not convinient
because in Event_timed::drop a temporary object has to be created. Hence,
dereference the sp_name in Events::drop_event() and pass the LEX_STRINGs.
sql/events.h:
Change db_drop_event() not to use Event_timed, either coming from parsing
or from Event_timed::drop, but use LEX_STRINGs. sp_name is not convinient
because in Event_timed::drop a temporary object has to be created. Hence,
dereference the sp_name in Events::drop_event() and pass the LEX_STRINGs.
sql/events_priv.h:
Change db_drop_event() not to use Event_timed, either coming from parsing
or from Event_timed::drop, but use LEX_STRINGs. sp_name is not convinient
because in Event_timed::drop a temporary object has to be created. Hence,
dereference the sp_name in Events::drop_event() and pass the LEX_STRINGs.
sql/sql_parse.cc:
SQLCOM_DROP_EVENT does not need lex->event_parse_data object and
is more like SQLCOM_SHOW_CREATE_EVENT. Therefore, move it to the block that
handles the latter.
sql/sql_yacc.yy:
DROP EVENT does not need a parsing object, just a name.
Store it as lex->spname. Pretty similar handling to the one of
SHOW CREATE EVENT.
2006-06-27 11:51:11 +02:00
|
|
|
class sp_name;
|
WL#3337 (Events new infrasctructure)
Second cut of separating parsing phase from execution phase
Separate Event_timed from parsing phase and introducing Event_parse_data.
sql/event_data_objects.cc:
second cut,
copy Event_timed::init_body() to Event_parse_data::init_body()
Init the body during parsing, everything else keep as a pointer to
Item or some other pointer to use for later initialization.
sql/event_data_objects.h:
get the identifier as sp_name*, later will initialize our structures
sql/events.cc:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
sql/events.h:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
BitKeeper/etc/ignore:
Added libmysql/viosocket.o.6WmSJk libmysqld/event_data_objects.cc libmysqld/event_db_repository.cc libmysqld/event_queue.cc server-tools/instance-manager/net_serv.cc to the ignore list
sql/share/errmsg.txt:
remove this message, not used and needed for now
sql/sql_lex.h:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
sql/sql_parse.cc:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
sql/sql_yacc.yy:
for easy transition add temporarily parse_data, later Event_timed *et will be removed.
Do slow transition because Event_timed is so tightly integrated that a front-attack
by removing things from this class was unsuccessful. Do things step by step by eliminating
dependencies. Hence, the code could be checked with the current test suite too
(early testing)
2006-06-27 10:53:26 +02:00
|
|
|
class Event_parse_data;
|
2006-06-28 15:14:05 +02:00
|
|
|
class Event_db_repository;
|
2006-07-04 18:44:35 +02:00
|
|
|
class Event_queue;
|
2006-07-10 13:44:43 +02:00
|
|
|
class Event_queue_element;
|
2006-07-12 10:37:30 +02:00
|
|
|
class Event_scheduler;
|
2006-06-28 01:28:03 +02:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
};
|
|
|
|
|
2006-09-12 17:48:26 +02:00
|
|
|
|
2006-06-28 01:28:03 +02:00
|
|
|
int
|
|
|
|
sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs);
|
|
|
|
|
|
|
|
|
2006-06-08 23:07:11 +02:00
|
|
|
class Events
|
|
|
|
{
|
|
|
|
public:
|
2006-06-28 01:28:03 +02:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
2006-08-17 14:22:59 +02:00
|
|
|
friend class Event_queue_element;
|
WL#3337 (Event scheduler new architecture)
This is a post-review patch.
Fixes the typelib implementation, available only in 5.1.11.
--event-scheduler cmdline : DISABLED | ON | OFF | 0 | 1
DISABLED - makes the scheduler unavailable during the server run
(ON|1)- When the server is started the scheduler will be started. It can
be stopped and restarted by setting appropriate values to
GLOBAL event_scheduler
(OFF|0)- When the server is started, the scheduler won't be started. It
can be started and again stopped by setting appropriate values to
GLOBAL event_scheduler. _DEFAULT_ value
The GLOBAL variable event_scheduler can have the following values:
OFF | ON | 0 | 1
DISABLED is not possible and every attempt will end with an error that
it's not a valid value for the variable.
OFF | 0 - This is the pre-5.1.11 behavior - The scheduler stops, if not
already stopped, and can be started again by setting
the value of the variable to ON|1.
ON | 1 - This is the pre-5.1.11 behavior - The scheduler starts, if not
already started, and can be stopped again by setting the value
of the variable to OFF|0.
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_restart_phase1.result:
update result
mysql-test/r/events_restart_phase3.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/events.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_bugs.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_logs_tests.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_restart_phase1.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_restart_phase2-master.opt:
update master file : 1 => on
mysql-test/t/events_scheduling.test:
update test:
2 -> off
1 -> on
add tests for event_scheduler global variable representation from
SHOW VARIABLES.
mysql-test/t/events_stress.test:
update test:
2 -> off
1 -> on
sql/events.cc:
Implement two different TYPELIBs for --event-scheduler cmd line
option and for GLOBAL variable event_scheduler
--event-scheduler cmdline : DISABLED | ON | OFF | 0 | 1
DISABLED - makes the scheduler unavailable during the server run
(ON|1)- When the server is started the scheduler will be started. It can
be stopped and restarted by setting appropriate values to
GLOBAL event_scheduler
(OFF|0)- When the server is started, the scheduler won't be started. It
can be started and again stopped by setting appropriate values to
GLOBAL event_scheduler. _DEFAULT_ value
The GLOBAL variable event_scheduler can have the following values:
OFF | ON | 0 | 1
DISABLED is not possible and every attempt will end with an error that
it's not a valid value for the variable.
OFF | 0 - This is the pre-5.1.11 behavior - The scheduler stops, if not
already stopped, and can be started again by setting
the value of the variable to ON|1.
ON | 1 - This is the pre-5.1.11 behavior - The scheduler starts, if not
already started, and can be stopped again by setting the value
of the variable to OFF|0.
sql/events.h:
additional TYPELIB for GLOBAL event_scheduler
sql/mysqld.cc:
--event-scheduler should be checked against a TYPELIB and
therefore should be GET_STR, as well as we make the parameter optional.
When not provided OFF|0 is used.
sql/set_var.cc:
Implement typelib for event_scheduler variable.
If allows both INT_RESULT -> 0 | 1
and STRING_RESULT -> OFF | ON
The variable is shown as DISABLED | ON | OFF
sql/set_var.h:
Implement typelib, which expects both STRING and INT,
for event_scheduler.
2006-09-01 13:08:44 +02:00
|
|
|
|
|
|
|
/* The order should match the order in opt_typelib */
|
|
|
|
enum enum_opt_event_scheduler
|
|
|
|
{
|
|
|
|
EVENTS_OFF= 0,
|
|
|
|
EVENTS_ON= 1,
|
2006-09-25 17:22:23 +02:00
|
|
|
EVENTS_DISABLED= 4
|
WL#3337 (Event scheduler new architecture)
This is a post-review patch.
Fixes the typelib implementation, available only in 5.1.11.
--event-scheduler cmdline : DISABLED | ON | OFF | 0 | 1
DISABLED - makes the scheduler unavailable during the server run
(ON|1)- When the server is started the scheduler will be started. It can
be stopped and restarted by setting appropriate values to
GLOBAL event_scheduler
(OFF|0)- When the server is started, the scheduler won't be started. It
can be started and again stopped by setting appropriate values to
GLOBAL event_scheduler. _DEFAULT_ value
The GLOBAL variable event_scheduler can have the following values:
OFF | ON | 0 | 1
DISABLED is not possible and every attempt will end with an error that
it's not a valid value for the variable.
OFF | 0 - This is the pre-5.1.11 behavior - The scheduler stops, if not
already stopped, and can be started again by setting
the value of the variable to ON|1.
ON | 1 - This is the pre-5.1.11 behavior - The scheduler starts, if not
already started, and can be stopped again by setting the value
of the variable to OFF|0.
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_restart_phase1.result:
update result
mysql-test/r/events_restart_phase3.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/events.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_bugs.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_logs_tests.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_restart_phase1.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_restart_phase2-master.opt:
update master file : 1 => on
mysql-test/t/events_scheduling.test:
update test:
2 -> off
1 -> on
add tests for event_scheduler global variable representation from
SHOW VARIABLES.
mysql-test/t/events_stress.test:
update test:
2 -> off
1 -> on
sql/events.cc:
Implement two different TYPELIBs for --event-scheduler cmd line
option and for GLOBAL variable event_scheduler
--event-scheduler cmdline : DISABLED | ON | OFF | 0 | 1
DISABLED - makes the scheduler unavailable during the server run
(ON|1)- When the server is started the scheduler will be started. It can
be stopped and restarted by setting appropriate values to
GLOBAL event_scheduler
(OFF|0)- When the server is started, the scheduler won't be started. It
can be started and again stopped by setting appropriate values to
GLOBAL event_scheduler. _DEFAULT_ value
The GLOBAL variable event_scheduler can have the following values:
OFF | ON | 0 | 1
DISABLED is not possible and every attempt will end with an error that
it's not a valid value for the variable.
OFF | 0 - This is the pre-5.1.11 behavior - The scheduler stops, if not
already stopped, and can be started again by setting
the value of the variable to ON|1.
ON | 1 - This is the pre-5.1.11 behavior - The scheduler starts, if not
already started, and can be stopped again by setting the value
of the variable to OFF|0.
sql/events.h:
additional TYPELIB for GLOBAL event_scheduler
sql/mysqld.cc:
--event-scheduler should be checked against a TYPELIB and
therefore should be GET_STR, as well as we make the parameter optional.
When not provided OFF|0 is used.
sql/set_var.cc:
Implement typelib for event_scheduler variable.
If allows both INT_RESULT -> 0 | 1
and STRING_RESULT -> OFF | ON
The variable is shown as DISABLED | ON | OFF
sql/set_var.h:
Implement typelib, which expects both STRING and INT,
for event_scheduler.
2006-09-01 13:08:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static enum_opt_event_scheduler opt_event_scheduler;
|
2006-06-08 23:07:11 +02:00
|
|
|
static TYPELIB opt_typelib;
|
WL#3337 (Event scheduler new architecture)
This is a post-review patch.
Fixes the typelib implementation, available only in 5.1.11.
--event-scheduler cmdline : DISABLED | ON | OFF | 0 | 1
DISABLED - makes the scheduler unavailable during the server run
(ON|1)- When the server is started the scheduler will be started. It can
be stopped and restarted by setting appropriate values to
GLOBAL event_scheduler
(OFF|0)- When the server is started, the scheduler won't be started. It
can be started and again stopped by setting appropriate values to
GLOBAL event_scheduler. _DEFAULT_ value
The GLOBAL variable event_scheduler can have the following values:
OFF | ON | 0 | 1
DISABLED is not possible and every attempt will end with an error that
it's not a valid value for the variable.
OFF | 0 - This is the pre-5.1.11 behavior - The scheduler stops, if not
already stopped, and can be started again by setting
the value of the variable to ON|1.
ON | 1 - This is the pre-5.1.11 behavior - The scheduler starts, if not
already started, and can be stopped again by setting the value
of the variable to OFF|0.
mysql-test/r/events.result:
update result
mysql-test/r/events_bugs.result:
update result
mysql-test/r/events_logs_tests.result:
update result
mysql-test/r/events_restart_phase1.result:
update result
mysql-test/r/events_restart_phase3.result:
update result
mysql-test/r/events_scheduling.result:
update result
mysql-test/r/events_stress.result:
update result
mysql-test/t/events.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_bugs.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_logs_tests.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_restart_phase1.test:
update test:
2 -> off
1 -> on
mysql-test/t/events_restart_phase2-master.opt:
update master file : 1 => on
mysql-test/t/events_scheduling.test:
update test:
2 -> off
1 -> on
add tests for event_scheduler global variable representation from
SHOW VARIABLES.
mysql-test/t/events_stress.test:
update test:
2 -> off
1 -> on
sql/events.cc:
Implement two different TYPELIBs for --event-scheduler cmd line
option and for GLOBAL variable event_scheduler
--event-scheduler cmdline : DISABLED | ON | OFF | 0 | 1
DISABLED - makes the scheduler unavailable during the server run
(ON|1)- When the server is started the scheduler will be started. It can
be stopped and restarted by setting appropriate values to
GLOBAL event_scheduler
(OFF|0)- When the server is started, the scheduler won't be started. It
can be started and again stopped by setting appropriate values to
GLOBAL event_scheduler. _DEFAULT_ value
The GLOBAL variable event_scheduler can have the following values:
OFF | ON | 0 | 1
DISABLED is not possible and every attempt will end with an error that
it's not a valid value for the variable.
OFF | 0 - This is the pre-5.1.11 behavior - The scheduler stops, if not
already stopped, and can be started again by setting
the value of the variable to ON|1.
ON | 1 - This is the pre-5.1.11 behavior - The scheduler starts, if not
already started, and can be stopped again by setting the value
of the variable to OFF|0.
sql/events.h:
additional TYPELIB for GLOBAL event_scheduler
sql/mysqld.cc:
--event-scheduler should be checked against a TYPELIB and
therefore should be GET_STR, as well as we make the parameter optional.
When not provided OFF|0 is used.
sql/set_var.cc:
Implement typelib for event_scheduler variable.
If allows both INT_RESULT -> 0 | 1
and STRING_RESULT -> OFF | ON
The variable is shown as DISABLED | ON | OFF
sql/set_var.h:
Implement typelib, which expects both STRING and INT,
for event_scheduler.
2006-09-01 13:08:44 +02:00
|
|
|
static TYPELIB var_typelib;
|
2006-06-08 23:07:11 +02:00
|
|
|
|
2006-07-13 10:59:58 +02:00
|
|
|
bool
|
2006-06-28 01:28:03 +02:00
|
|
|
init();
|
2006-08-17 14:22:59 +02:00
|
|
|
|
2006-06-28 15:14:05 +02:00
|
|
|
void
|
2006-06-28 01:28:03 +02:00
|
|
|
deinit();
|
|
|
|
|
2006-06-28 15:14:05 +02:00
|
|
|
void
|
2006-06-28 01:28:03 +02:00
|
|
|
init_mutexes();
|
2006-08-17 14:22:59 +02:00
|
|
|
|
2006-06-28 15:14:05 +02:00
|
|
|
void
|
2006-06-28 01:28:03 +02:00
|
|
|
destroy_mutexes();
|
|
|
|
|
2006-07-04 18:44:35 +02:00
|
|
|
bool
|
|
|
|
start_execution_of_events();
|
2006-08-17 14:22:59 +02:00
|
|
|
|
2006-07-04 18:44:35 +02:00
|
|
|
bool
|
|
|
|
stop_execution_of_events();
|
2006-08-17 14:22:59 +02:00
|
|
|
|
2006-07-04 18:44:35 +02:00
|
|
|
bool
|
2006-08-17 14:22:59 +02:00
|
|
|
is_execution_of_events_started();
|
2006-07-04 18:44:35 +02:00
|
|
|
|
2006-08-17 14:22:59 +02:00
|
|
|
static Events *
|
2006-06-28 01:28:03 +02:00
|
|
|
get_instance();
|
|
|
|
|
2006-08-17 14:22:59 +02:00
|
|
|
bool
|
2006-08-28 10:27:42 +02:00
|
|
|
create_event(THD *thd, Event_parse_data *parse_data, bool if_exists);
|
2006-06-08 23:07:11 +02:00
|
|
|
|
2006-08-17 14:22:59 +02:00
|
|
|
bool
|
2006-08-28 10:27:42 +02:00
|
|
|
update_event(THD *thd, Event_parse_data *parse_data, sp_name *rename_to);
|
2006-06-08 23:07:11 +02:00
|
|
|
|
2006-08-17 14:22:59 +02:00
|
|
|
bool
|
2006-07-10 13:44:43 +02:00
|
|
|
drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists,
|
2006-08-28 10:27:42 +02:00
|
|
|
bool only_from_disk);
|
2006-06-08 23:07:11 +02:00
|
|
|
|
2006-08-17 14:22:59 +02:00
|
|
|
void
|
2006-06-28 15:14:05 +02:00
|
|
|
drop_schema_events(THD *thd, char *db);
|
|
|
|
|
2006-06-28 01:28:03 +02:00
|
|
|
int
|
2006-06-08 23:07:11 +02:00
|
|
|
open_event_table(THD *thd, enum thr_lock_type lock_type, TABLE **table);
|
|
|
|
|
2006-08-17 14:22:59 +02:00
|
|
|
bool
|
2006-07-11 18:28:15 +02:00
|
|
|
show_create_event(THD *thd, LEX_STRING dbname, LEX_STRING name);
|
2006-06-08 23:07:11 +02:00
|
|
|
|
2006-06-28 01:28:03 +02:00
|
|
|
/* Needed for both SHOW CREATE EVENT and INFORMATION_SCHEMA */
|
2006-06-08 23:07:11 +02:00
|
|
|
static int
|
|
|
|
reconstruct_interval_expression(String *buf, interval_type interval,
|
|
|
|
longlong expression);
|
|
|
|
|
2006-06-28 14:22:14 +02:00
|
|
|
static int
|
|
|
|
fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */);
|
2006-08-17 14:22:59 +02:00
|
|
|
|
2006-09-12 12:26:12 +02:00
|
|
|
void
|
|
|
|
dump_internal_status();
|
2006-06-08 23:07:11 +02:00
|
|
|
|
|
|
|
private:
|
2006-08-17 14:22:59 +02:00
|
|
|
bool
|
|
|
|
check_system_tables(THD *thd);
|
|
|
|
|
2006-06-28 01:28:03 +02:00
|
|
|
/* Singleton DP is used */
|
2006-08-17 14:22:59 +02:00
|
|
|
Events();
|
2006-06-28 01:28:03 +02:00
|
|
|
~Events(){}
|
|
|
|
|
|
|
|
/* Singleton instance */
|
|
|
|
static Events singleton;
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_queue *event_queue;
|
2006-08-17 14:22:59 +02:00
|
|
|
Event_scheduler *scheduler;
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_db_repository *db_repository;
|
|
|
|
|
2006-08-17 14:22:59 +02:00
|
|
|
pthread_mutex_t LOCK_event_metadata;
|
|
|
|
|
|
|
|
bool check_system_tables_error;
|
2006-07-10 13:44:43 +02:00
|
|
|
|
2006-06-08 23:07:11 +02:00
|
|
|
/* Prevent use of these */
|
|
|
|
Events(const Events &);
|
|
|
|
void operator=(Events &);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* _EVENT_H_ */
|