SPI_KEEPPLAN(3)

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

✨ SPI_KEEPPLAN(3) ✨

okay so picture this: it's manual page SPI_KEEPPLAN from the PostgreSQL 16.15 Documentation, and it's literally here to save your prepared statement from getting yeeted πŸ’… stay with me bestie, this one's short and sweet.


🌸 SYNOPSIS 🌸

int SPI_keepplan(SPIPlanPtr plan)

πŸ’– DESCRIPTION πŸ’–

so SPI_keepplan does one iconic thing: it 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 🫢

and why do you care? because this gives you the ability to reuse prepared statements in the subsequent invocations of your C function in the current session. the way that's such a glow-up for your session πŸ”₯ it's giving main character energy for your plan, honestly.

πŸŽ€ ARGUMENTS πŸŽ€

  • SPIPlanPtr plan β€” the prepared statement to be saved πŸ’Ύ that's it, that's the arg.

⭐ RETURN VALUE ⭐

  • 0 on success πŸŽ‰ slay
  • SPI_ERROR_ARGUMENT if plan is NULL or invalid πŸ’€ (check your pointer before you come for her, bestie)

πŸ¦‹ NOTES πŸ¦‹

the passed-in statement is relocated to permanent storage by means of pointer adjustment β€” and listen, no data copying is required, so it's lowkey efficient fr fr ✨

if you later wish to delete it, use SPI_freeplan on it. clean up after yourself, queen πŸ‘‘

heads up: keep track of which plans you've kept, because SPI_finish and the transaction manager are not going to do it for you anymore πŸ™ˆ

and that's the whole page, bestie β€” no crumbs left. this gem comes to you from PostgreSQL 16.15, dated 2026, and it's the SPI_KEEPPLAN(3) manual page signing off πŸŽ€πŸ’œ go keep those plans, iykyk 🧚✨

πŸ“¦ where this page comes from