SPI_KEEPPLAN(3)

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

πŸ’… SPI_KEEPPLAN(3) β€” save a prepared statement πŸ’…

okay so bestie, welcome to the PostgreSQL 17.11 Documentation page for SPI_KEEPPLAN(3). This one is short, sweet, and honestly kind of iconic: it’s all about keeping a prepared statement alive so it doesn’t get swept away. Let’s get into it ✨

✨ 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. periodt. This gives you the ability to reuse prepared statements in the subsequent invocations of your C function in the current session. literally so useful 🫢

πŸŽ€ ARGUMENTS πŸŽ€

  • SPIPlanPtr plan β€” the prepared statement to be saved. that’s the one you’re tucking into safety πŸ’–

🌈 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 β€” no data copying is required. iconic efficiency, no cap πŸ’…

If you later wish to delete it, use SPI_freeplan on it. don’t just leave it vibing forever, bestie 😭


PostgreSQL 17.11 Β· 2026 Β· SPI_KEEPPLAN(3) β€” bye bestie, mwah πŸ’‹

πŸ“¦ where this page comes from