SPI_REGI...GGER_DATA(3)
β¨ SPI_REGI...GGER_DATA(3) β¨
okay so bestie, we're in the PostgreSQL 14.24 Documentation today and this page is literally about letting your trigger's lil' ephemeral relations slide into your SPI queries π«Ά it's giving backstage pass energy, iykyk π
πΈ NAME πΈ
SPI_register_trigger_data β make ephemeral trigger data available in SPI queries β¨
π¦ SYNOPSIS π¦
int SPI_register_trigger_data(TriggerData *tdata)
π DESCRIPTION π
okay so SPI_register_trigger_data makes any ephemeral relations captured by a trigger available to queries planned and executed through the current SPI connection π
for now, "ephemeral relations" means the transition tables captured by an AFTER trigger that was defined with a REFERENCING OLD/NEW TABLE AS ... clause π« that's the whole vibe.
the way this works: a PL trigger handler function should call this function after connecting π like, connect first, register second, no cap.
π ARGUMENTS π
TriggerData *tdataβ theTriggerDataobject that got passed to a trigger handler function asfcinfo->contextπ§ it's the lil' bundle of trigger context, hand it over as-is.
π RETURN VALUE π
if the execution of the command was successful then the following (nonnegative) value will be returned, slay:
SPI_OK_TD_REGISTERβ if the captured trigger data (if any) has been successfully registered π note the "(if any)" bestie, sometimes there's just nothing to register and that's fine.
on error, one of the following negative values is returned π:
SPI_ERROR_ARGUMENTβ iftdataisNULLπ like, you can't just pass nothing, that's not the move.SPI_ERROR_UNCONNECTEDβ if called from an unconnected C function π connect first, ask questions later.SPI_ERROR_REL_DUPLICATEβ if the name of any trigger data transient relation is already registered for this connection π₯ that name is taken, bestie, pick another one.
fr fr check the return value, don't just vibe past it β a negative number means something went sideways π
β SEE ALSO β
hmm, the original doesn't list any SEE ALSO references here, so nothing to link β go look at the rest of the SPI docs if you're nosy π¦
and that's the whole page, periodt π
this was brought to you by PostgreSQL 14.24, dated 2026 β same SPI_REGI...GGER_DATA(3) energy, mwah πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql14-docs 14.24-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms