SPI_KEEPPLAN(3)

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

πŸ’… SPI_KEEPPLAN(3) πŸ’…

okay so this is the SPI_KEEPPLAN(3) page from the PostgreSQL 14.24 Documentation, and it’s lowkey iconic for anyone writing C functions that need a prepared statement to stay put across calls. bestie, this is the β€œdon’t free my plan” button 🫢✨


✨ NAME ✨

SPI_keepplan β€” save a prepared statement, periodt πŸ’ΎπŸ’–

πŸ¦‹ SYNOPSIS πŸ¦‹

int SPI_keepplan(SPIPlanPtr plan)

🌸 DESCRIPTION 🌸

SPI_keepplan saves a passed statement β€” one that was prepared by SPI_prepare β€” so that it will not be freed by SPI_finish nor by the transaction manager. no cap, that’s the whole vibe πŸ”₯

This gives you the ability to reuse prepared statements in the subsequent invocations of your C function in the current session. literally the β€œkeep it for later” main character move πŸ‘‘πŸ’«

πŸŽ€ ARGUMENTS πŸŽ€

  • SPIPlanPtr plan β€” the prepared statement to be saved πŸ’–

⭐ RETURN VALUE ⭐

  • 0 on success πŸŽ‰
  • SPI_ERROR_ARGUMENT if plan is NULL or invalid 😭

πŸ’œ NOTES πŸ’œ

The passed-in statement is relocated to permanent storage by means of pointer adjustment β€” and ngl, no data copying is required 🧚✨. If you later wish to delete it, use SPI_freeplan on it. that’s the cleanup era πŸ’…


big mwah πŸ’‹ β€” this one’s from PostgreSQL 14.24, dated 2026, and it’s the SPI_KEEPPLAN(3) page, periodt 🌈🫢

πŸ“¦ where this page comes from