11th October 2018: PostgreSQL 11 RC 1 Released!
Supported Versions: Current (10)
Development Versions: 11 / devel


SPI_register_trigger_data — make ephemeral trigger data available in SPI queries


int SPI_register_trigger_data(TriggerData *tdata)


SPI_register_trigger_data makes any ephemeral relations captured by a trigger available to queries planned and executed through the current SPI connection. Currently, this means the transition tables captured by an AFTER trigger defined with a REFERENCING OLD/NEW TABLE AS ... clause. This function should be called by a PL trigger handler function after connecting.


TriggerData *tdata

the TriggerData object passed to a trigger handler function as fcinfo->context

Return Value

If the execution of the command was successful then the following (nonnegative) value will be returned:


if the captured trigger data (if any) has been successfully registered

On error, one of the following negative values is returned:


if tdata is NULL


if called from an unconnected C function


if the name of any trigger data transient relation is already registered for this connection