mirror of
https://github.com/MariaDB/server.git
synced 2026-05-08 08:04:29 +02:00
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
This commit is contained in:
parent
739ea377bd
commit
9fa9378b2e
14 changed files with 569 additions and 826 deletions
|
|
@ -3833,57 +3833,31 @@ end_with_restore_list:
|
|||
case SQLCOM_ALTER_EVENT:
|
||||
{
|
||||
uint rows_affected= 1;
|
||||
DBUG_ASSERT(lex->et);
|
||||
do {
|
||||
if (! lex->et->dbname.str ||
|
||||
(lex->sql_command == SQLCOM_ALTER_EVENT && lex->spname &&
|
||||
!lex->spname->m_db.str))
|
||||
{
|
||||
my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0));
|
||||
res= true;
|
||||
break;
|
||||
}
|
||||
DBUG_ASSERT(lex->event_parse_data);
|
||||
switch (lex->sql_command) {
|
||||
case SQLCOM_CREATE_EVENT:
|
||||
res= Events::get_instance()->create_event(thd, lex->event_parse_data,
|
||||
(uint) lex->create_info.options,
|
||||
&rows_affected);
|
||||
break;
|
||||
case SQLCOM_ALTER_EVENT:
|
||||
res= Events::get_instance()->update_event(thd, lex->event_parse_data,
|
||||
lex->spname, &rows_affected);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
DBUG_PRINT("info", ("CREATE/ALTER/DROP returned error code=%d af_rows=%d",
|
||||
res, rows_affected));
|
||||
if (!res)
|
||||
send_ok(thd, rows_affected);
|
||||
|
||||
if (check_access(thd, EVENT_ACL, lex->et->dbname.str, 0, 0, 0,
|
||||
is_schema_db(lex->et->dbname.str)) ||
|
||||
(lex->sql_command == SQLCOM_ALTER_EVENT && lex->spname &&
|
||||
(check_access(thd, EVENT_ACL, lex->spname->m_db.str, 0, 0, 0,
|
||||
is_schema_db(lex->spname->m_db.str)))))
|
||||
break;
|
||||
|
||||
if (end_active_trans(thd))
|
||||
{
|
||||
res= -1;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (lex->sql_command) {
|
||||
case SQLCOM_CREATE_EVENT:
|
||||
res= Events::get_instance()->
|
||||
create_event(thd, lex->et, lex->event_parse_data,
|
||||
(uint) lex->create_info.options, &rows_affected);
|
||||
break;
|
||||
case SQLCOM_ALTER_EVENT:
|
||||
res= Events::get_instance()->
|
||||
update_event(thd, lex->et, lex->event_parse_data,
|
||||
lex->spname, &rows_affected);
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
DBUG_PRINT("info", ("CREATE/ALTER/DROP returned error code=%d af_rows=%d",
|
||||
res, rows_affected));
|
||||
if (!res)
|
||||
send_ok(thd, rows_affected);
|
||||
|
||||
/* lex->unit.cleanup() is called outside, no need to call it here */
|
||||
} while (0);
|
||||
if (!thd->spcont)
|
||||
{
|
||||
lex->et->free_sphead_on_delete= true;
|
||||
lex->et->free_sp();
|
||||
lex->et->deinit_mutexes();
|
||||
delete lex->sphead;
|
||||
lex->sphead= NULL;
|
||||
}
|
||||
|
||||
|
||||
/* lex->unit.cleanup() is called outside, no need to call it here */
|
||||
break;
|
||||
}
|
||||
case SQLCOM_DROP_EVENT:
|
||||
|
|
@ -3912,11 +3886,6 @@ end_with_restore_list:
|
|||
else
|
||||
{
|
||||
uint rows_affected= 1;
|
||||
if (end_active_trans(thd))
|
||||
{
|
||||
res= -1;
|
||||
break;
|
||||
}
|
||||
if (!(res= Events::get_instance()->drop_event(thd, lex->spname,
|
||||
lex->drop_if_exists,
|
||||
&rows_affected)))
|
||||
|
|
@ -6020,14 +5989,6 @@ void mysql_parse(THD *thd, char *inBuf, uint length)
|
|||
{
|
||||
delete lex->sphead;
|
||||
lex->sphead= NULL;
|
||||
if (lex->et)
|
||||
{
|
||||
lex->et->free_sphead_on_delete= true;
|
||||
/* alloced on thd->mem_root so no real memory free but dtor call */
|
||||
lex->et->free_sp();
|
||||
lex->et->deinit_mutexes();
|
||||
lex->et= NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -6064,13 +6025,6 @@ void mysql_parse(THD *thd, char *inBuf, uint length)
|
|||
delete lex->sphead;
|
||||
lex->sphead= NULL;
|
||||
}
|
||||
if (lex->et)
|
||||
{
|
||||
lex->et->free_sphead_on_delete= true;
|
||||
lex->et->free_sp();
|
||||
lex->et->deinit_mutexes();
|
||||
lex->et= NULL;
|
||||
}
|
||||
}
|
||||
thd->proc_info="freeing items";
|
||||
thd->end_statement();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue