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
|
2006-12-27 02:23:51 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2006-06-08 23:07:11 +02:00
|
|
|
|
|
|
|
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 */
|
|
|
|
|
2006-06-27 11:51:11 +02:00
|
|
|
class sp_name;
|
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-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);
|
|
|
|
|
2007-03-23 16:14:03 +01:00
|
|
|
/**
|
|
|
|
@class Events -- a facade to the functionality of the Event Scheduler.
|
|
|
|
|
|
|
|
*/
|
2006-06-28 01:28:03 +02:00
|
|
|
|
2006-06-08 23:07:11 +02:00
|
|
|
class Events
|
|
|
|
{
|
|
|
|
public:
|
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
|
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;
|
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
|
2007-01-29 18:46:29 +01:00
|
|
|
drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists);
|
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-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);
|
|
|
|
|
2007-01-29 18:46:29 +01:00
|
|
|
int
|
|
|
|
load_events_from_db(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_ */
|