Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-5532

User defined events

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Open (View Workflow)
    • Priority: Minor
    • Resolution: Unresolved
    • Fix Version/s: None
    • Component/s: None
    • Labels:

      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";

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            jplindst Jan Lindström
            Votes:
            3 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated: