~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to sql/events.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _EVENT_H_
 
2
#define _EVENT_H_
 
3
/* Copyright (C) 2004-2006 MySQL AB
 
4
 
 
5
   This program is free software; you can redistribute it and/or modify
 
6
   it under the terms of the GNU General Public License as published by
 
7
   the Free Software Foundation; version 2 of the License.
 
8
 
 
9
   This program is distributed in the hope that it will be useful,
 
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
   GNU General Public License for more details.
 
13
 
 
14
   You should have received a copy of the GNU General Public License
 
15
   along with this program; if not, write to the Free Software
 
16
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
17
 
 
18
/**
 
19
  @defgroup Event_Scheduler Event Scheduler
 
20
  @ingroup Runtime_Environment
 
21
  @{
 
22
 
 
23
  @file events.h
 
24
 
 
25
  A public interface of Events_Scheduler module.
 
26
*/
 
27
 
 
28
class Event_parse_data;
 
29
class Event_db_repository;
 
30
class Event_queue;
 
31
class Event_scheduler;
 
32
 
 
33
/* Return codes */
 
34
enum enum_events_error_code
 
35
{
 
36
  OP_OK= 0,
 
37
  OP_NOT_RUNNING,
 
38
  OP_CANT_KILL,
 
39
  OP_CANT_INIT,
 
40
  OP_DISABLED_EVENT,
 
41
  OP_LOAD_ERROR,
 
42
  OP_ALREADY_EXISTS
 
43
};
 
44
 
 
45
 
 
46
int
 
47
sortcmp_lex_string(LEX_STRING s, LEX_STRING t, CHARSET_INFO *cs);
 
48
 
 
49
/**
 
50
  @brief A facade to the functionality of the Event Scheduler.
 
51
 
 
52
  Every public operation against the scheduler has to be executed via the
 
53
  interface provided by a static method of this class. No instance of this
 
54
  class is ever created and it has no non-static data members.
 
55
 
 
56
  The life cycle of the Events module is the following:
 
57
 
 
58
  At server start up:
 
59
     set_opt_event_scheduler() -> init_mutexes() -> init()
 
60
  When the server is running:
 
61
     create_event(), drop_event(), start_or_stop_event_scheduler(), etc
 
62
  At shutdown:
 
63
     deinit(), destroy_mutexes().
 
64
 
 
65
  The peculiar initialization and shutdown cycle is an adaptation to the
 
66
  outside server startup/shutdown framework and mimics the rest of MySQL
 
67
  subsystems (ACL, time zone tables, etc).
 
68
*/
 
69
 
 
70
class Events
 
71
{
 
72
public:
 
73
  /* The order should match the order in opt_typelib */
 
74
  enum enum_opt_event_scheduler
 
75
  {
 
76
    EVENTS_OFF= 0,
 
77
    EVENTS_ON= 1,
 
78
    EVENTS_DISABLED= 4
 
79
  };
 
80
 
 
81
  /* Possible values of @@event_scheduler variable */
 
82
  static const TYPELIB var_typelib;
 
83
 
 
84
  static bool
 
85
  set_opt_event_scheduler(char *argument);
 
86
 
 
87
  static const char *
 
88
  get_opt_event_scheduler_str();
 
89
 
 
90
  /* A hack needed for Event_queue_element */
 
91
  static Event_db_repository *
 
92
  get_db_repository() { return db_repository; }
 
93
 
 
94
  static bool
 
95
  init(my_bool opt_noacl);
 
96
 
 
97
  static void
 
98
  deinit();
 
99
 
 
100
  static void
 
101
  init_mutexes();
 
102
 
 
103
  static void
 
104
  destroy_mutexes();
 
105
 
 
106
  static bool
 
107
  switch_event_scheduler_state(enum enum_opt_event_scheduler new_state);
 
108
 
 
109
  static bool
 
110
  create_event(THD *thd, Event_parse_data *parse_data, bool if_exists);
 
111
 
 
112
  static bool
 
113
  update_event(THD *thd, Event_parse_data *parse_data,
 
114
               LEX_STRING *new_dbname, LEX_STRING *new_name);
 
115
 
 
116
  static bool
 
117
  drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists);
 
118
 
 
119
  static void
 
120
  drop_schema_events(THD *thd, char *db);
 
121
 
 
122
  static bool
 
123
  show_create_event(THD *thd, LEX_STRING dbname, LEX_STRING name);
 
124
 
 
125
  /* Needed for both SHOW CREATE EVENT and INFORMATION_SCHEMA */
 
126
  static int
 
127
  reconstruct_interval_expression(String *buf, interval_type interval,
 
128
                                  longlong expression);
 
129
 
 
130
  static int
 
131
  fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */);
 
132
 
 
133
  static void
 
134
  dump_internal_status();
 
135
 
 
136
private:
 
137
  static bool check_if_system_tables_error();
 
138
 
 
139
  static bool
 
140
  load_events_from_db(THD *thd);
 
141
 
 
142
private:
 
143
  /* Command line option names */
 
144
  static const TYPELIB opt_typelib;
 
145
  static pthread_mutex_t LOCK_event_metadata;
 
146
  static Event_queue         *event_queue;
 
147
  static Event_scheduler     *scheduler;
 
148
  static Event_db_repository *db_repository;
 
149
  /* Current state of Event Scheduler */
 
150
  static enum enum_opt_event_scheduler opt_event_scheduler;
 
151
  /* Set to TRUE if an error at start up */
 
152
  static bool check_system_tables_error;
 
153
 
 
154
private:
 
155
  /* Prevent use of these */
 
156
  Events(const Events &);
 
157
  void operator=(Events &);
 
158
};
 
159
 
 
160
/**
 
161
  @} (end of group Event Scheduler)
 
162
*/
 
163
 
 
164
#endif /* _EVENT_H_ */