~michaeleguo/ubuntu/trusty/percona-xtradb-cluster-5.5/arm64fix

« back to all changes in this revision

Viewing changes to sql/events.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-10 14:44:23 UTC
  • Revision ID: package-import@ubuntu.com-20140210144423-f2134l2gxuvq2m6l
Tags: upstream-5.5.34-25.9+dfsg
ImportĀ upstreamĀ versionĀ 5.5.34-25.9+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _EVENT_H_
 
2
#define _EVENT_H_
 
3
/* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
 
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  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
#ifdef HAVE_PSI_INTERFACE
 
29
extern PSI_mutex_key key_event_scheduler_LOCK_scheduler_state;
 
30
extern PSI_cond_key key_event_scheduler_COND_state;
 
31
extern PSI_thread_key key_thread_event_scheduler, key_thread_event_worker;
 
32
#endif /* HAVE_PSI_INTERFACE */
 
33
 
 
34
#include "sql_string.h"                         /* LEX_STRING */
 
35
#include "my_time.h"                            /* interval_type */
 
36
 
 
37
class Event_db_repository;
 
38
class Event_parse_data;
 
39
class Event_queue;
 
40
class Event_scheduler;
 
41
struct TABLE_LIST;
 
42
class THD;
 
43
typedef class Item COND;
 
44
typedef struct charset_info_st CHARSET_INFO;
 
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
     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
  /*
 
74
    the following block is to support --event-scheduler command line option
 
75
    and the @@global.event_scheduler SQL variable.
 
76
    See sys_var.cc
 
77
  */
 
78
  enum enum_opt_event_scheduler { EVENTS_OFF, EVENTS_ON, EVENTS_DISABLED };
 
79
  /* Protected using LOCK_global_system_variables only. */
 
80
  static ulong opt_event_scheduler;
 
81
  static bool check_if_system_tables_error();
 
82
  static bool start(int *err_no);
 
83
  static bool stop();
 
84
 
 
85
public:
 
86
  /* A hack needed for Event_queue_element */
 
87
  static Event_db_repository *
 
88
  get_db_repository() { return db_repository; }
 
89
 
 
90
  static bool
 
91
  init(my_bool opt_noacl);
 
92
 
 
93
  static void
 
94
  deinit();
 
95
 
 
96
  static void
 
97
  init_mutexes();
 
98
 
 
99
  static void
 
100
  destroy_mutexes();
 
101
 
 
102
  static bool
 
103
  create_event(THD *thd, Event_parse_data *parse_data, bool if_exists);
 
104
 
 
105
  static bool
 
106
  update_event(THD *thd, Event_parse_data *parse_data,
 
107
               LEX_STRING *new_dbname, LEX_STRING *new_name);
 
108
 
 
109
  static bool
 
110
  drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name, bool if_exists);
 
111
 
 
112
  static void
 
113
  drop_schema_events(THD *thd, char *db);
 
114
 
 
115
  static bool
 
116
  show_create_event(THD *thd, LEX_STRING dbname, LEX_STRING name);
 
117
 
 
118
  /* Needed for both SHOW CREATE EVENT and INFORMATION_SCHEMA */
 
119
  static int
 
120
  reconstruct_interval_expression(String *buf, interval_type interval,
 
121
                                  longlong expression);
 
122
 
 
123
  static int
 
124
  fill_schema_events(THD *thd, TABLE_LIST *tables, COND * /* cond */);
 
125
 
 
126
  static void
 
127
  dump_internal_status();
 
128
 
 
129
private:
 
130
 
 
131
  static bool
 
132
  load_events_from_db(THD *thd);
 
133
 
 
134
private:
 
135
  static Event_queue         *event_queue;
 
136
  static Event_scheduler     *scheduler;
 
137
  static Event_db_repository *db_repository;
 
138
  /* Set to TRUE if an error at start up */
 
139
  static bool check_system_tables_error;
 
140
 
 
141
private:
 
142
  /* Prevent use of these */
 
143
  Events(const Events &);
 
144
  void operator=(Events &);
 
145
};
 
146
 
 
147
/**
 
148
  @} (end of group Event Scheduler)
 
149
*/
 
150
 
 
151
#endif /* _EVENT_H_ */