@@ -731,7 +731,7 @@ Event_timed::~Event_timed()
731731*/
732732
733733Event_job_data::Event_job_data ():
734- thd(NULL ), sphead(0 ), sql_mode(0 )
734+ thd(NULL ), sphead(NULL ), sql_mode(0 )
735735{
736736}
737737
@@ -745,7 +745,10 @@ Event_job_data::Event_job_data():
745745
746746Event_job_data::~Event_job_data ()
747747{
748- free_sp ();
748+ DBUG_ENTER (" Event_job_data::~Event_job_data" );
749+ delete sphead;
750+ sphead= NULL ;
751+ DBUG_VOID_RETURN;
749752}
750753
751754
@@ -1605,20 +1608,6 @@ Event_job_data::get_fake_create_event(THD *thd, String *buf)
16051608}
16061609
16071610
1608- /*
1609- Frees the memory of the sp_head object we hold
1610- SYNOPSIS
1611- Event_job_data::free_sp()
1612- */
1613-
1614- void
1615- Event_job_data::free_sp ()
1616- {
1617- delete sphead;
1618- sphead= NULL ;
1619- }
1620-
1621-
16221611/*
16231612 Compiles an event before it's execution. Compiles the anonymous
16241613 sp_head object held by the event
@@ -1651,9 +1640,7 @@ Event_job_data::compile(THD *thd, MEM_ROOT *mem_root)
16511640 CHARSET_INFO *old_character_set_client,
16521641 *old_collation_connection,
16531642 *old_character_set_results;
1654- Security_context *save_ctx;
1655- /* this one is local and not needed after exec */
1656- Security_context security_ctx;
1643+ Security_context save_ctx;
16571644
16581645 DBUG_ENTER (" Event_job_data::compile" );
16591646
@@ -1699,10 +1686,9 @@ Event_job_data::compile(THD *thd, MEM_ROOT *mem_root)
16991686 thd->query_length = show_create.length ();
17001687 DBUG_PRINT (" info" , (" query:%s" ,thd->query ));
17011688
1702- thd->change_security_context (definer_user, definer_host, dbname,
1703- &security_ctx, &save_ctx);
1689+ thd->change_security_context (definer_user, definer_host, dbname, &save_ctx);
17041690 thd->lex = &lex;
1705- lex_start (thd, (uchar*)thd->query , thd->query_length );
1691+ mysql_init_query (thd, (uchar*) thd->query , thd->query_length );
17061692 if (MYSQLparse ((void *)thd) || thd->is_fatal_error )
17071693 {
17081694 DBUG_PRINT (" error" , (" error during compile or thd->is_fatal_error=%d" ,
@@ -1713,13 +1699,10 @@ Event_job_data::compile(THD *thd, MEM_ROOT *mem_root)
17131699 */
17141700 sql_print_error (" error during compile of %s.%s or thd->is_fatal_error=%d" ,
17151701 dbname.str , name.str , thd->is_fatal_error );
1716- if (lex.sphead )
1717- {
1718- if (&lex != thd->lex )
1719- thd->lex ->sphead ->restore_lex (thd);
1720- delete lex.sphead ;
1721- lex.sphead = 0 ;
1722- }
1702+
1703+ lex.unit .cleanup ();
1704+ delete lex.sphead ;
1705+ sphead= lex.sphead = NULL ;
17231706 ret= EVEX_COMPILE_ERROR;
17241707 goto done;
17251708 }
@@ -1734,7 +1717,7 @@ Event_job_data::compile(THD *thd, MEM_ROOT *mem_root)
17341717done:
17351718
17361719 lex_end (&lex);
1737- thd->restore_security_context (save_ctx);
1720+ thd->restore_security_context (& save_ctx);
17381721 DBUG_PRINT (" note" , (" return old data on its place. set back NAMES" ));
17391722
17401723 thd->lex = old_lex;
@@ -1772,20 +1755,17 @@ Event_job_data::compile(THD *thd, MEM_ROOT *mem_root)
17721755int
17731756Event_job_data::execute (THD *thd)
17741757{
1775- Security_context * save_ctx;
1758+ Security_context save_ctx;
17761759 /* this one is local and not needed after exec */
1777- Security_context security_ctx;
17781760 int ret= 0 ;
17791761
17801762 DBUG_ENTER (" Event_job_data::execute" );
17811763 DBUG_PRINT (" info" , (" EXECUTING %s.%s" , dbname.str , name.str ));
17821764
1783-
17841765 if ((ret= compile (thd, NULL )))
17851766 goto done;
17861767
1787- thd->change_security_context (definer_user, definer_host, dbname,
1788- &security_ctx, &save_ctx);
1768+ thd->change_security_context (definer_user, definer_host, dbname, &save_ctx);
17891769 /*
17901770 THD::~THD will clean this or if there is DROP DATABASE in the SP then
17911771 it will be free there. It should not point to our buffer which is allocated
@@ -1810,9 +1790,10 @@ Event_job_data::execute(THD *thd)
18101790 ret= -99 ;
18111791 }
18121792
1813- thd->restore_security_context (save_ctx);
1793+ thd->restore_security_context (& save_ctx);
18141794done:
1815- free_sp ();
1795+ thd->end_statement ();
1796+ thd->cleanup_after_query ();
18161797
18171798 DBUG_PRINT (" info" , (" EXECUTED %s.%s ret=%d" , dbname.str , name.str , ret));
18181799
0 commit comments