postgresql_16:5.1.14.2 Event Callback Procedure
PostgreSQL 16 > Client Interfaces > libpq — C Library > Event System > Event Callback Procedure
PGEventProc
PGEventProc is a typedef for a pointer to an event procedure, that is, the user callback function that receives events from libpq. The signature of an event procedure must be int eventproc(PGEventId evtId, void *evtInfo, void *passThrough) The evtId parameter indicates which PGEVT event occurred. The evtInfo pointer must be cast to the appropriate structure type to obtain further information about the event. The passThrough parameter is the pointer provided to (see libpq-PQregisterEventProc) when the event procedure was registered. The function should return a non-zero value if it succeeds and zero if it fails.
A particular event procedure can be registered only once in any PGconn. This is because the address of the procedure is used as a lookup key to identify the associated instance data.
Caution
On Windows, functions can have two different addresses: one visible from outside a DLL and another visible from inside the DLL. One should be careful that only one of these addresses is used with libpq's event-procedure functions, else confusion will result. The simplest rule for writing code that will work is to ensure that event procedures are declared static. If the procedure's address must be available outside its own source file, expose a separate function to return the address.