[MDEV-5532] User defined events Created: 2014-01-16  Updated: 2016-02-18

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Minor
Reporter: Jan Lindström (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 4
Labels: gsoc14, gsoc16


 Description   

User defined events are supported on several other databases in different form and semantics, few examples

Events are used to signal an named event in the database. Applications can use named events instead of polling, which uses more resources.

Event is created with

CREATE EVENT event_name [parameter_list] 

The name can be any user-specified alphanumeric string. The parameter list specifies parameter names and parameter types. The parameter types are normal SQL types.

Events are dropped with

DROP EVENT event_name 

Events are sent and received inside stored procedures. Special stored procedure statements are used to send and receive events.

The event is sent with the stored procedure statement

post_statement ::= POST EVENT event_name
    [( parameters) ] 

Event parameters must be local variables, constant values, or parameters in the stored procedure from which the event is sent. All clients that are waiting for the posted event will receive the event. Each connection has its own event queue. The events to be collected in the event queue are specified with the stored procedure statement:

wait_register_statement ::= REGISTER EVENT event_name 

Events are removed from the event queue with the stored procedure statement:

wait_register_statement ::= UNREGISTER EVENT event_name 

Note that you do not need to register for every event before waiting for it. When you wait on an event, you will be registered implicitly for that event if you did not already explicitly register for it. Thus you only need to explicitly register events if you want them to start being queued now but you don't want to start WAITing for them until later.

To make a procedure wait for an event to happen, the WAIT EVENT construct is used in a stored procedure:

wait_event_statement ::=
   WAIT EVENT
      [event_specification ...]
   END WAIT
 
event_specification ::=
   WHEN event_name [(parameters)] BEGIN
      statements
   END EVENT

Each connection has its own event queue. To specify the events to be collected in the event queue, use the command REGISTER EVENT event_name. Events are removed from the event queue by the command UNREGISTER EVENT event_name.

"CREATE PROCEDURE register_event
begin
        register event test_event
end";
 
"CREATE PROCEDURE unregister_event
begin
        unregister event test_event
end";


Generated at Thu Feb 08 07:05:05 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.