SPI_KEEPPLAN(3)
β¨ 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 β
0on success π slaySPI_ERROR_ARGUMENTifplanisNULLor 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
- opensuse-leap 16.0: postgresql16-docs 16.15-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms