SPI_REGI...GGER_DATA(3)

πŸ“¦ version 14.24, in opensuse-leap 16.0

✨ 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 β€” the TriggerData object that got passed to a trigger handler function as fcinfo->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 β€” if tdata is NULL πŸ’€ 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