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

« back to all changes in this revision

Viewing changes to sql/event_data_objects.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_DATA_OBJECTS_H_
 
2
#define _EVENT_DATA_OBJECTS_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
  @addtogroup Event_Scheduler
 
20
  @{
 
21
 
 
22
  @file event_data_objects.h
 
23
*/
 
24
 
 
25
#include "event_parse_data.h"
 
26
 
 
27
class Event_queue_element_for_exec
 
28
{
 
29
public:
 
30
  Event_queue_element_for_exec(){};
 
31
  ~Event_queue_element_for_exec();
 
32
 
 
33
  bool
 
34
  init(LEX_STRING dbname, LEX_STRING name);
 
35
 
 
36
  LEX_STRING dbname;
 
37
  LEX_STRING name;
 
38
  bool dropped;
 
39
  THD *thd;
 
40
 
 
41
private:
 
42
  /* Prevent use of these */
 
43
  Event_queue_element_for_exec(const Event_queue_element_for_exec &);
 
44
  void operator=(Event_queue_element_for_exec &);
 
45
};
 
46
 
 
47
 
 
48
class Event_basic
 
49
{
 
50
protected:
 
51
  MEM_ROOT mem_root;
 
52
 
 
53
public:
 
54
 
 
55
  LEX_STRING dbname;
 
56
  LEX_STRING name;
 
57
  LEX_STRING definer;// combination of user and host
 
58
 
 
59
  Time_zone *time_zone;
 
60
 
 
61
  Event_basic();
 
62
  virtual ~Event_basic();
 
63
 
 
64
  virtual bool
 
65
  load_from_row(THD *thd, TABLE *table) = 0;
 
66
 
 
67
protected:
 
68
  bool
 
69
  load_string_fields(Field **fields, ...);
 
70
 
 
71
  bool
 
72
  load_time_zone(THD *thd, const LEX_STRING tz_name);
 
73
};
 
74
 
 
75
 
 
76
 
 
77
class Event_queue_element : public Event_basic
 
78
{
 
79
protected:
 
80
  bool status_changed;
 
81
  bool last_executed_changed;
 
82
 
 
83
public:
 
84
  int on_completion;
 
85
  int status;
 
86
  longlong originator;
 
87
 
 
88
  my_time_t last_executed;
 
89
  my_time_t execute_at;
 
90
  my_time_t starts;
 
91
  my_time_t ends;
 
92
  my_bool starts_null;
 
93
  my_bool ends_null;
 
94
  my_bool execute_at_null;
 
95
 
 
96
  longlong expression;
 
97
  interval_type interval;
 
98
 
 
99
  bool dropped;
 
100
 
 
101
  uint execution_count;
 
102
 
 
103
  Event_queue_element();
 
104
  virtual ~Event_queue_element();
 
105
 
 
106
  virtual bool
 
107
  load_from_row(THD *thd, TABLE *table);
 
108
 
 
109
  bool
 
110
  compute_next_execution_time();
 
111
 
 
112
  void
 
113
  mark_last_executed(THD *thd);
 
114
 
 
115
  bool
 
116
  update_timing_fields(THD *thd);
 
117
};
 
118
 
 
119
 
 
120
class Event_timed : public Event_queue_element
 
121
{
 
122
  Event_timed(const Event_timed &);     /* Prevent use of these */
 
123
  void operator=(Event_timed &);
 
124
 
 
125
public:
 
126
  LEX_STRING body;
 
127
 
 
128
  LEX_STRING definer_user;
 
129
  LEX_STRING definer_host;
 
130
 
 
131
  LEX_STRING comment;
 
132
 
 
133
  ulonglong created;
 
134
  ulonglong modified;
 
135
 
 
136
  ulong sql_mode;
 
137
 
 
138
  class Stored_program_creation_ctx *creation_ctx;
 
139
  LEX_STRING body_utf8;
 
140
 
 
141
  Event_timed();
 
142
  virtual ~Event_timed();
 
143
 
 
144
  void
 
145
  init();
 
146
 
 
147
  virtual bool
 
148
  load_from_row(THD *thd, TABLE *table);
 
149
 
 
150
  int
 
151
  get_create_event(THD *thd, String *buf);
 
152
};
 
153
 
 
154
 
 
155
class Event_job_data : public Event_basic
 
156
{
 
157
public:
 
158
  LEX_STRING body;
 
159
  LEX_STRING definer_user;
 
160
  LEX_STRING definer_host;
 
161
 
 
162
  ulong sql_mode;
 
163
 
 
164
  class Stored_program_creation_ctx *creation_ctx;
 
165
 
 
166
  Event_job_data();
 
167
 
 
168
  virtual bool
 
169
  load_from_row(THD *thd, TABLE *table);
 
170
 
 
171
  bool
 
172
  execute(THD *thd, bool drop);
 
173
private:
 
174
  bool
 
175
  construct_sp_sql(THD *thd, String *sp_sql);
 
176
  bool
 
177
  construct_drop_event_sql(THD *thd, String *sp_sql);
 
178
 
 
179
  Event_job_data(const Event_job_data &);       /* Prevent use of these */
 
180
  void operator=(Event_job_data &);
 
181
};
 
182
 
 
183
 
 
184
/* Compares only the schema part of the identifier */
 
185
bool
 
186
event_basic_db_equal(LEX_STRING db, Event_basic *et);
 
187
 
 
188
/* Compares the whole identifier*/
 
189
bool
 
190
event_basic_identifier_equal(LEX_STRING db, LEX_STRING name, Event_basic *b);
 
191
 
 
192
/**
 
193
  @} (End of group Event_Scheduler)
 
194
*/
 
195
 
 
196
#endif /* _EVENT_DATA_OBJECTS_H_ */