1616
1717#define MYSQL_LEX 1
1818#include " mysql_priv.h"
19- #include " events_priv.h"
2019#include " events.h"
2120#include " event_data_objects.h"
21+ #include " event_db_repository.h"
2222#include " sp_head.h"
2323
2424
25+ #define EVEX_MAX_INTERVAL_VALUE 2147483647L
26+
27+
2528Event_parse_data *
2629Event_parse_data::new_instance (THD *thd)
2730{
@@ -733,29 +736,29 @@ Event_timed::load_from_row(MEM_ROOT *mem_root, TABLE *table)
733736
734737 et= this ;
735738
736- if (table->s ->fields != Events::FIELD_COUNT )
739+ if (table->s ->fields != ET_FIELD_COUNT )
737740 goto error;
738741
739742 if ((et->dbname .str = get_field (mem_root,
740- table->field [Events::FIELD_DB ])) == NULL )
743+ table->field [ET_FIELD_DB ])) == NULL )
741744 goto error;
742745
743746 et->dbname .length = strlen (et->dbname .str );
744747
745748 if ((et->name .str = get_field (mem_root,
746- table->field [Events::FIELD_NAME ])) == NULL )
749+ table->field [ET_FIELD_NAME ])) == NULL )
747750 goto error;
748751
749752 et->name .length = strlen (et->name .str );
750753
751754 if ((et->body .str = get_field (mem_root,
752- table->field [Events::FIELD_BODY ])) == NULL )
755+ table->field [ET_FIELD_BODY ])) == NULL )
753756 goto error;
754757
755758 et->body .length = strlen (et->body .str );
756759
757760 if ((et->definer .str = get_field (mem_root,
758- table->field [Events::FIELD_DEFINER ])) == NullS)
761+ table->field [ET_FIELD_DEFINER ])) == NullS)
759762 goto error;
760763 et->definer .length = strlen (et->definer .str );
761764
@@ -772,71 +775,71 @@ Event_timed::load_from_row(MEM_ROOT *mem_root, TABLE *table)
772775 et->definer_host .str = strmake_root (mem_root, ptr + 1 , len);/* 1:because of @*/
773776 et->definer_host .length = len;
774777
775- et->starts_null = table->field [Events::FIELD_STARTS ]->is_null ();
776- res1= table->field [Events::FIELD_STARTS ]->
778+ et->starts_null = table->field [ET_FIELD_STARTS ]->is_null ();
779+ res1= table->field [ET_FIELD_STARTS ]->
777780 get_date (&et->starts ,TIME_NO_ZERO_DATE);
778781
779- et->ends_null = table->field [Events::FIELD_ENDS ]->is_null ();
780- res2= table->field [Events::FIELD_ENDS ]->get_date (&et->ends , TIME_NO_ZERO_DATE);
782+ et->ends_null = table->field [ET_FIELD_ENDS ]->is_null ();
783+ res2= table->field [ET_FIELD_ENDS ]->get_date (&et->ends , TIME_NO_ZERO_DATE);
781784
782- if (!table->field [Events::FIELD_INTERVAL_EXPR ]->is_null ())
783- et->expression = table->field [Events::FIELD_INTERVAL_EXPR ]->val_int ();
785+ if (!table->field [ET_FIELD_INTERVAL_EXPR ]->is_null ())
786+ et->expression = table->field [ET_FIELD_INTERVAL_EXPR ]->val_int ();
784787 else
785788 et->expression = 0 ;
786789 /*
787790 If res1 and res2 are true then both fields are empty.
788- Hence if Events::FIELD_EXECUTE_AT is empty there is an error.
791+ Hence if ET_FIELD_EXECUTE_AT is empty there is an error.
789792 */
790793 et->execute_at_null =
791- table->field [Events::FIELD_EXECUTE_AT ]->is_null ();
794+ table->field [ET_FIELD_EXECUTE_AT ]->is_null ();
792795 DBUG_ASSERT (!(et->starts_null && et->ends_null && !et->expression &&
793796 et->execute_at_null ));
794797 if (!et->expression &&
795- table->field [Events::FIELD_EXECUTE_AT ]-> get_date (&et->execute_at ,
798+ table->field [ET_FIELD_EXECUTE_AT ]-> get_date (&et->execute_at ,
796799 TIME_NO_ZERO_DATE))
797800 goto error;
798801
799802 /*
800803 In DB the values start from 1 but enum interval_type starts
801804 from 0
802805 */
803- if (!table->field [Events::FIELD_TRANSIENT_INTERVAL ]->is_null ())
806+ if (!table->field [ET_FIELD_TRANSIENT_INTERVAL ]->is_null ())
804807 et->interval = (interval_type) ((ulonglong)
805- table->field [Events::FIELD_TRANSIENT_INTERVAL ]->val_int () - 1 );
808+ table->field [ET_FIELD_TRANSIENT_INTERVAL ]->val_int () - 1 );
806809 else
807810 et->interval = (interval_type) 0 ;
808811
809- et->created = table->field [Events::FIELD_CREATED ]->val_int ();
810- et->modified = table->field [Events::FIELD_MODIFIED ]->val_int ();
812+ et->created = table->field [ET_FIELD_CREATED ]->val_int ();
813+ et->modified = table->field [ET_FIELD_MODIFIED ]->val_int ();
811814
812- table->field [Events::FIELD_LAST_EXECUTED ]->
815+ table->field [ET_FIELD_LAST_EXECUTED ]->
813816 get_date (&et->last_executed , TIME_NO_ZERO_DATE);
814817
815818 last_executed_changed= false ;
816819
817820 /* ToDo : Andrey . Find a way not to allocate ptr on event_mem_root */
818- if ((ptr= get_field (mem_root, table->field [Events::FIELD_STATUS ])) == NullS)
821+ if ((ptr= get_field (mem_root, table->field [ET_FIELD_STATUS ])) == NullS)
819822 goto error;
820823
821824 DBUG_PRINT (" load_from_row" , (" Event [%s] is [%s]" , et->name .str , ptr));
822825 et->status = (ptr[0 ]==' E' ? Event_timed::ENABLED:Event_timed::DISABLED);
823826
824827 /* ToDo : Andrey . Find a way not to allocate ptr on event_mem_root */
825828 if ((ptr= get_field (mem_root,
826- table->field [Events::FIELD_ON_COMPLETION ])) == NullS)
829+ table->field [ET_FIELD_ON_COMPLETION ])) == NullS)
827830 goto error;
828831
829832 et->on_completion = (ptr[0 ]==' D' ? Event_timed::ON_COMPLETION_DROP:
830833 Event_timed::ON_COMPLETION_PRESERVE);
831834
832- et->comment .str = get_field (mem_root, table->field [Events::FIELD_COMMENT ]);
835+ et->comment .str = get_field (mem_root, table->field [ET_FIELD_COMMENT ]);
833836 if (et->comment .str != NullS)
834837 et->comment .length = strlen (et->comment .str );
835838 else
836839 et->comment .length = 0 ;
837840
838841
839- et->sql_mode = (ulong) table->field [Events::FIELD_SQL_MODE ]->val_int ();
842+ et->sql_mode = (ulong) table->field [ET_FIELD_SQL_MODE ]->val_int ();
840843
841844 DBUG_RETURN (0 );
842845error:
@@ -1277,6 +1280,7 @@ Event_timed::mark_last_executed(THD *thd)
12771280}
12781281
12791282
1283+
12801284/*
12811285 Drops the event
12821286
@@ -1299,7 +1303,8 @@ Event_timed::drop(THD *thd)
12991303 uint tmp= 0 ;
13001304 DBUG_ENTER (" Event_timed::drop" );
13011305
1302- DBUG_RETURN (db_drop_event (thd, dbname, name, false , &tmp));
1306+ DBUG_RETURN (Events::get_instance ()->
1307+ db_repository.drop_event (thd, dbname, name, false , &tmp));
13031308}
13041309
13051310
@@ -1336,7 +1341,7 @@ Event_timed::update_fields(THD *thd)
13361341
13371342 thd->reset_n_backup_open_tables_state (&backup);
13381343
1339- if (Events::open_event_table (thd, TL_WRITE, &table))
1344+ if (Events::get_instance ()-> open_event_table (thd, TL_WRITE, &table))
13401345 {
13411346 ret= EVEX_OPEN_TABLE_FAILED;
13421347 goto done;
@@ -1352,15 +1357,15 @@ Event_timed::update_fields(THD *thd)
13521357
13531358 if (last_executed_changed)
13541359 {
1355- table->field [Events::FIELD_LAST_EXECUTED ]->set_notnull ();
1356- table->field [Events::FIELD_LAST_EXECUTED ]->store_time (&last_executed,
1360+ table->field [ET_FIELD_LAST_EXECUTED ]->set_notnull ();
1361+ table->field [ET_FIELD_LAST_EXECUTED ]->store_time (&last_executed,
13571362 MYSQL_TIMESTAMP_DATETIME);
13581363 last_executed_changed= false ;
13591364 }
13601365 if (status_changed)
13611366 {
1362- table->field [Events::FIELD_STATUS ]->set_notnull ();
1363- table->field [Events::FIELD_STATUS ]->store ((longlong)status, true );
1367+ table->field [ET_FIELD_STATUS ]->set_notnull ();
1368+ table->field [ET_FIELD_STATUS ]->store ((longlong)status, true );
13641369 status_changed= false ;
13651370 }
13661371
@@ -1630,8 +1635,8 @@ Event_timed::compile(THD *thd, MEM_ROOT *mem_root)
16301635 thd->query_length = show_create.length ();
16311636 DBUG_PRINT (" info" , (" query:%s" ,thd->query ));
16321637
1633- change_security_context (thd, definer_user, definer_host, dbname,
1634- &security_ctx, &save_ctx);
1638+ thd-> change_security_context (definer_user, definer_host, dbname,
1639+ &security_ctx, &save_ctx);
16351640 thd->lex = &lex;
16361641 lex_start (thd, (uchar*)thd->query , thd->query_length );
16371642 lex.et_compile_phase = TRUE ;
@@ -1669,7 +1674,7 @@ Event_timed::compile(THD *thd, MEM_ROOT *mem_root)
16691674 lex.et ->deinit_mutexes ();
16701675
16711676 lex_end (&lex);
1672- restore_security_context (thd, save_ctx);
1677+ thd-> restore_security_context (save_ctx);
16731678 DBUG_PRINT (" note" , (" return old data on its place. set back NAMES" ));
16741679
16751680 thd->lex = old_lex;
@@ -1870,23 +1875,6 @@ event_timed_db_equal(Event_timed *et, LEX_STRING *db)
18701875}
18711876
18721877
1873- /*
1874- Checks whether two events have the same definer
1875-
1876- SYNOPSIS
1877- event_timed_definer_equal()
1878-
1879- Returns
1880- TRUE definers are equal
1881- FALSE definers are not equal
1882- */
1883-
1884- bool
1885- event_timed_definer_equal (Event_timed *et, LEX_STRING *definer)
1886- {
1887- return !sortcmp_lex_string (et->definer , *definer, system_charset_info);
1888- }
1889-
18901878
18911879/*
18921880 Checks whether two events are equal by identifiers
0 commit comments