SPI_KEEPPLAN(3)

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

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

okay so bestie, this one is from the PostgreSQL 13.23 Documentation and it’s lowkey iconic: it’s all about saving a prepared statement so it sticks around. periodt. πŸŽ€

🌸 NAME 🌸

SPI_keepplan β€” save a prepared statement. bestie, that’s literally the whole vibe of this page. ✨

πŸ¦‹ 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. 🫢

this gives you the ability to reuse prepared statements in the subsequent invocations of your C function in the current session. it’s giving β€œkeep the thing alive so future you can use it again” energy. πŸ‘‘

πŸŽ€ 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 β€” no data copying is required. the pointer gets adjusted, and that’s the whole trick. πŸ’…

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


alright, that’s the page 🫢 β€” source and version: PostgreSQL 13.23 Documentation, dated 2025. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from