Pike v8.1 release 6

Method Sql.pgsql()->set_notify_callback()


Method set_notify_callback

final void set_notify_callback(string condition, void|function(int, string, string, mixed ... :void) notify_cb, void|int selfnotify, mixed ... args)

Description

With PostgreSQL you can LISTEN to NOTIFY events. This function allows you to detect and handle such events.

Parameter condition

Name of the notification event we're listening to. A special case is the empty string, which matches all events, and can be used as fallback function which is called only when the specific condition is not handled. Another special case is "_reconnect" which gets called whenever the connection unexpectedly drops and reconnects to the database.

Parameter notify_cb

Function to be called on receiving a notification-event of condition condition. The callback function is invoked with void notify_cb(pid,condition,extrainfo, .. args); pid is the process id of the database session that originated the event. condition contains the current condition. extrainfo contains optional extra information specified by the database. The rest of the arguments to notify_cb are passed verbatim from args. The callback function must return no value.

Parameter selfnotify

Normally notify events generated by your own session are ignored. If you want to receive those as well, set selfnotify to one.

Parameter args

Extra arguments to pass to notify_cb.

Note

This function is PostgreSQL-specific, and thus it is not available through the generic SQL-interface.