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-04 18:44:35 +02:00
|
|
|
class Event_scheduler_ng;
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
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-07-10 13:44:43 +02:00
|
|
|
friend class Event_queue_element;
|
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-06-08 23:07:11 +02:00
|
|
|
static ulong opt_event_scheduler;
|
|
|
|
static TYPELIB opt_typelib;
|
|
|
|
|
2006-06-28 15:14:05 +02:00
|
|
|
int
|
2006-06-28 01:28:03 +02:00
|
|
|
init();
|
|
|
|
|
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-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();
|
|
|
|
|
|
|
|
bool
|
|
|
|
stop_execution_of_events();
|
|
|
|
|
|
|
|
bool
|
|
|
|
is_started();
|
|
|
|
|
2006-06-28 01:28:03 +02:00
|
|
|
static Events*
|
|
|
|
get_instance();
|
|
|
|
|
|
|
|
int
|
2006-07-05 17:12:50 +02:00
|
|
|
create_event(THD *thd, Event_parse_data *parse_data, bool if_exists,
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
uint *rows_affected);
|
2006-06-08 23:07:11 +02:00
|
|
|
|
2006-06-28 01:28:03 +02:00
|
|
|
int
|
2006-07-11 18:28:15 +02:00
|
|
|
update_event(THD *thd, Event_parse_data *parse_data, sp_name *rename_to,
|
WL#3337 (Events new architecture)
This cut No 7 should finish the part of fixing the parsing of the events :
- Event_timed is no more used during parsing. Less problems because it has
a mutex. Event_parse_data class is used during parsing. It is suited only
for this purpose. It's pretty lightweight
- Late checking of data from parsing is being performed. This should solve
the problems of nested events in SP or other events (for the situation
of no nested bodies). Before if an ALTER EVENT was in a SP, then when the
SP was compiled, and not executed, the actual init_xxx methods of Event_timed
were called, which is wrong.
- It could be a side effect of using a specialized class, but test events_stress is
now 25% quicker.
Cut No8 will start splitting Event_scheduler into 2 parts, the QUEUE will be moved
to Event_queue.
mysql-test/r/events.result:
update result
mysql-test/t/events.test:
disabled is actually wrong, should be disable, but because of the early
checking it was never parsed.
sql/event_data_objects.cc:
move add init_xxx methods from Event_timed to Event_parse_data
Event_parse data does not need definer_user and definer_host
in Event_timed::compile() do not use lex.et, well there is no more lex.et :)
sql/event_data_objects.h:
move parsing responsibilities from Event_timed to Event_parse_data
sql/event_db_repository.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_db_repository.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/event_scheduler.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.cc:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/events.h:
No more Event_timed comes from parsing but Event_parse_data
The initialization of Item*-s from parsing is done late, and not
during the actual parsing. This is the right way to go because
if an ALTER EVENT is inside a SP or CREATE EVENT it should not be
executed (initialized) during parsing, as it was done.
sql/sql_lex.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_lex.h:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
sql/sql_parse.cc:
lex->et_compile_phase and lex->et are no more.
Use lex->event_parse_data
ACL checks were moved inside the Events subsystem.
Also ending of the transaction is performed only just
before doing disk operation. Therefore only when needed.
sql/sql_yacc.yy:
lex->et and lex->et_parse_phase are no more
Use the specialized for parsing Event_parse_data
2006-06-29 00:42:25 +02:00
|
|
|
uint *rows_affected);
|
2006-06-08 23:07:11 +02:00
|
|
|
|
2006-06-28 01:28:03 +02:00
|
|
|
int
|
2006-07-10 13:44:43 +02:00
|
|
|
drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists,
|
|
|
|
uint *rows_affected, bool only_from_disk);
|
2006-06-08 23:07:11 +02:00
|
|
|
|
2006-06-28 15:14:05 +02:00
|
|
|
int
|
|
|
|
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-06-28 01:28:03 +02:00
|
|
|
int
|
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-06-08 23:07:11 +02:00
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
bool
|
2006-06-08 23:07:11 +02:00
|
|
|
dump_internal_status(THD *thd);
|
|
|
|
|
|
|
|
private:
|
2006-06-28 01:28:03 +02:00
|
|
|
/* Singleton DP is used */
|
|
|
|
Events(){}
|
|
|
|
~Events(){}
|
|
|
|
|
|
|
|
/* Singleton instance */
|
|
|
|
static Events singleton;
|
|
|
|
|
2006-07-10 13:44:43 +02:00
|
|
|
Event_queue *event_queue;
|
|
|
|
Event_scheduler_ng *scheduler_ng;
|
|
|
|
Event_db_repository *db_repository;
|
|
|
|
|
|
|
|
pthread_mutex_t LOCK_event_metadata;
|
|
|
|
|
2006-06-08 23:07:11 +02:00
|
|
|
/* Prevent use of these */
|
|
|
|
Events(const Events &);
|
|
|
|
void operator=(Events &);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* _EVENT_H_ */
|