← Back to team overview

drizzle-discuss team mailing list archive

New low level events plugin API

 

Hi,

I am working on a low level events plugin. The idea is that this API can be
used to implement other plugins which are interested in observing different
database events and doing something with the information.

There are 3 type of events: "Session Events", "Schema Events", and "Table
Events". The plugins can register which events they are interested in and
then they will be notified of only the events they are interested in.

New plugin events can be added as people have need of them, currently I have
added the events I need for the PBMS daemon:

   /* Schema events: */
    PRE_DROP_TABLE,   POST_DROP_TABLE,
    PRE_RENAME_TABLE, POST_RENAME_TABLE,
    
    /* Table events: */
    PRE_WRITE_ROW,    POST_WRITE_ROW,
    PRE_UPDATE_ROW,   POST_UPDATE_ROW,
    PRE_DELETE_ROW,   POST_DELETE_ROW,
    
    /* Session events: */
    PRE_CREATE_DATABASE, POST_CREATE_DATABASE,
    PRE_DROP_DATABASE,   POST_DROP_DATABASE,

Table events are specific to a table so in he case of PBMS I can say I am
interested in table events that occur only on tables that contain BLOB
columns and I can specify exactly which events I am interested in.

Schema events are events that occur with in a specific database. So a plugin
can tell drizzle that it is only interested in schema events that occur on
database 'XYZ'.

Session events are events that occur out side of the context of a database
or table. It would be possible for example to only track session events for
specific users.

For any one event drizzle only calls the event observers that have
registered an interest in that event. So if no plugins have registered an
interest in an event nothing is done.

The event handlers are specific to each event, passing in what ever
information is relevant to that event. There is NO generic event handler.

The 'PRE' events may allow data modification depending on the type of event.
If a 'PRE' event handler fails then the action will be aborted. "POST" event
handlers are ReadOny and cannot modify the data, they are also not allowed
to fail, or if they do it will have no effect on the operation.

I have pushed up the branch "drizzle_events" containing my new plugin API.
The main points of interest are:

drizzled/plugin/event.h
drizzled/plugin/event.cc

You can look in drizzled/table_share.h and drizzled/session.h to see how the
events of interest are registered with the table, schema. or session.

You will find some example event points in:
drizzled/cursor.cc
drizzled/plugin/storage_engine.cc
drizzled/statement/create_schema.cc
drizzled/statement/drop_schema.cc

I have also created an example pluggin that observes some events and prints
them out as they occur.

plugin/hello_events

So I will just put on my flame proof suit and wait for people's comments and
suggestions. :)

Barry


-------------------------------------------------------------------------
Barry Leslie

SNAP Innovation Softwareentwicklung GmbH
Senior Software Engineer

Tel: (001) 250 884 1820
Fax: (001) 250 595 4460
Email: Barry.Leslie@xxxxxxxxxxxxx
Web: www.PrimeBase.com

SNAP Innovation Softwareentwicklung GmbH, D-22765 Hamburg,
Max-Brauer-Allee 50, Germany
Amtsgericht Hamburg HRB 61066, Geschäftsführer: Ulrich Zimmer, Paul
McCullagh
-------------------------------------------------------------------------






Follow ups