76
70
virtual ~EventObserver() {}
80
BEFORE_CREATE_DATABASE, AFTER_CREATE_DATABASE,
81
BEFORE_DROP_DATABASE, AFTER_DROP_DATABASE,
88
BEFORE_DROP_TABLE, AFTER_DROP_TABLE,
89
BEFORE_RENAME_TABLE, AFTER_RENAME_TABLE,
92
BEFORE_INSERT_RECORD, AFTER_INSERT_RECORD,
93
BEFORE_UPDATE_RECORD, AFTER_UPDATE_RECORD,
94
BEFORE_DELETE_RECORD, AFTER_DELETE_RECORD,
96
/* The max event ID marker. */
74
BEFORE_CREATE_DATABASE, AFTER_CREATE_DATABASE,
75
BEFORE_DROP_DATABASE, AFTER_DROP_DATABASE,
78
BEFORE_DROP_TABLE, AFTER_DROP_TABLE,
79
BEFORE_RENAME_TABLE, AFTER_RENAME_TABLE,
82
BEFORE_INSERT_RECORD, AFTER_INSERT_RECORD,
83
BEFORE_UPDATE_RECORD, AFTER_UPDATE_RECORD,
84
BEFORE_DELETE_RECORD, AFTER_DELETE_RECORD,
86
/* The max event ID marker. */
100
90
static const char *eventName(EventType event)
192
170
* It is good practice that if the event position matters not to hard code the position
193
171
* but supply a systen variable so that it can be set at runtime so that the user can
194
172
* decide which event should be called first.
196
174
void registerEvent(EventObserverList &observers, EventType event, int32_t position= 0);
198
176
/*==========================================================*/
199
177
/* Called from drizzle to register all events for all event plugins
200
178
* interested in this table.
202
180
static void registerTableEvents(TableShare &table_share);
203
181
static void deregisterTableEvents(TableShare &table_share);
205
183
/*==========================================================*/
206
184
/* Called from drizzle to register all events for all event plugins
207
* interested in this database.
185
* interested in this database.
209
187
static void registerSchemaEvents(Session &session, const std::string &db);
210
188
static void deregisterSchemaEvents(Session &session, const std::string &db);
212
190
/*==========================================================*/
213
191
/* Called from drizzle to register all events for all event plugins
214
* interested in this session.
192
* interested in this session.
216
194
static void registerSessionEvents(Session &session);
217
195
static void deregisterSessionEvents(Session &session);
220
198
/*==========================================================*/
221
199
/* Static meathods called by drizzle to notify interested plugins
222
200
* of a schema an event,
224
static bool beforeDropTable(Session &session, const drizzled::TableIdentifier &table);
225
static bool afterDropTable(Session &session, const drizzled::TableIdentifier &table, int err);
226
static bool beforeRenameTable(Session &session, const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to);
227
static bool afterRenameTable(Session &session, const drizzled::TableIdentifier &from, const drizzled::TableIdentifier &to, int err);
228
static bool connectSession(Session &session);
229
static bool disconnectSession(Session &session);
230
static bool beforeStatement(Session &session);
231
static bool afterStatement(Session &session);
233
/*==========================================================*/
234
/* Static meathods called by drizzle to notify interested plugins
235
* of a table an event,
237
static bool beforeInsertRecord(Table &table, unsigned char *buf);
238
static bool afterInsertRecord(Table &table, const unsigned char *buf, int err);
239
static bool beforeDeleteRecord(Table &table, const unsigned char *buf);
240
static bool afterDeleteRecord(Table &table, const unsigned char *buf, int err);
241
static bool beforeUpdateRecord(Table &table, const unsigned char *old_data, unsigned char *new_data);
242
static bool afterUpdateRecord(Table &table, const unsigned char *old_data, unsigned char *new_data, int err);
244
/*==========================================================*/
245
/* Static meathods called by drizzle to notify interested plugins
246
* of a table an event,
202
static bool beforeDropTable(Session &session, TableIdentifier &table);
203
static bool afterDropTable(Session &session, TableIdentifier &table, int err);
204
static bool beforeRenameTable(Session &session, TableIdentifier &from, TableIdentifier &to);
205
static bool afterRenameTable(Session &session, TableIdentifier &from, TableIdentifier &to, int err);
207
/*==========================================================*/
208
/* Static meathods called by drizzle to notify interested plugins
209
* of a table an event,
211
static bool beforeInsertRecord(Session &session, TableShare &table_share, unsigned char *buf);
212
static bool afterInsertRecord(Session &session, TableShare &table_share, const unsigned char *buf, int err);
213
static bool beforeDeleteRecord(Session &session, TableShare &table_share, const unsigned char *buf);
214
static bool afterDeleteRecord(Session &session, TableShare &table_share, const unsigned char *buf, int err);
215
static bool beforeUpdateRecord(Session &session, TableShare &table_share, const unsigned char *old_data, unsigned char *new_data);
216
static bool afterUpdateRecord(Session &session, TableShare &table_share, const unsigned char *old_data, unsigned char *new_data, int err);
218
/*==========================================================*/
219
/* Static meathods called by drizzle to notify interested plugins
220
* of a table an event,
248
222
static bool beforeCreateDatabase(Session &session, const std::string &db);
249
223
static bool afterCreateDatabase(Session &session, const std::string &db, int err);
250
224
static bool beforeDropDatabase(Session &session, const std::string &db);
251
225
static bool afterDropDatabase(Session &session, const std::string &db, int err);
253
static const EventObserverVector &getEventObservers(void);
260
230
/* EventObserver data classes: */
261
231
//======================================
265
235
EventObserver::EventType event;
267
237
EventData(EventObserver::EventType event_arg):
268
238
event(event_arg),
269
239
observerList(NULL)
271
241
virtual ~EventData(){}
273
243
// Call all the event observers that are registered for this event.
274
244
virtual bool callEventObservers();
277
247
EventObserverList *observerList;
386
351
AfterDropDatabaseEventData(Session &session_arg, const std::string &db_arg, int err_arg):
387
SessionEventData(EventObserver::AFTER_DROP_DATABASE, session_arg),
394
class ConnectSessionEventData: public SessionEventData
398
ConnectSessionEventData(Session &session_arg):
399
SessionEventData(EventObserver::CONNECT_SESSION, session_arg)
404
class DisconnectSessionEventData: public SessionEventData
408
DisconnectSessionEventData(Session &session_arg):
409
SessionEventData(EventObserver::DISCONNECT_SESSION, session_arg)
414
class BeforeStatementEventData: public SessionEventData
418
BeforeStatementEventData(Session &session_arg):
419
SessionEventData(EventObserver::BEFORE_STATEMENT, session_arg)
424
class AfterStatementEventData: public SessionEventData
428
AfterStatementEventData(Session &session_arg):
429
SessionEventData(EventObserver::AFTER_STATEMENT, session_arg)
352
SessionEventData(EventObserver::AFTER_DROP_DATABASE, session_arg),
562
487
const unsigned char *new_row;
565
AfterUpdateRecordEventData(Session &session_arg, Table &table_arg,
566
const unsigned char *old_row_arg,
567
const unsigned char *new_row_arg,
569
TableEventData(EventObserver::AFTER_UPDATE_RECORD, session_arg, table_arg),
570
old_row(old_row_arg),
571
new_row(new_row_arg),
490
AfterUpdateRecordEventData(Session &session_arg, TableShare &table_arg,
491
const unsigned char *old_row_arg,
492
const unsigned char *new_row_arg,
494
TableEventData(EventObserver::AFTER_UPDATE_RECORD, session_arg, table_arg),
495
old_row(old_row_arg),
496
new_row(new_row_arg),
576
501
//=======================================================