SPI_KEEPPLAN(3)
π SPI_KEEPPLAN(3) π
okay bestie, welcome to the SPI_keepplan page, straight out of the PostgreSQL 18.6 Documentation β¨ this one's a lil C-level gem, and honestly? it's giving forever-statement energy π
πΈ NAME πΈ
SPI_keepplan β save a prepared statement π«Ά
β¨ SYNOPSIS β¨
int SPI_keepplan(SPIPlanPtr plan)
π¦ DESCRIPTION π¦
so here's the tea, bestie β 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. π€ like, it's protected. it's safe. it's untouchable.
and why do we care?? because this gives you the ability to reuse prepared statements in the subsequent invocations of your C function in the current session. π it's literally the "keep it for later" button and the way that it just... persists?? obsessed. β¨
π ARGUMENTS π
SPIPlanPtr planβ the prepared statement to be saved π₯° that's it, that's the whole argument, she's simple and she slays
π RETURN VALUE π
0on success π yay!SPI_ERROR_ARGUMENTifplanisNULLor invalid π yeah no, that one's not cute
π NOTES π
ngl this part is kinda iconic π₯ the passed-in statement is relocated to permanent storage by means of pointer adjustment β and no data copying is required. zero copying. none. the pointer just... moves. main character energy fr fr π«
and if you later wish to delete it, use SPI_freeplan on it π§Ή because everything that stays forever eventually needs a lil cleanup, iykyk
and that's the whole page, bestie!! πΈ this was PostgreSQL 18.6, dated 2026, and you just read the SPI_KEEPPLAN(3) manual page π go keep those plans, periodt π β¨
π¦ where this page comes from
- alpine 3.23: postgresql18-doc 18.6-r0 Β· PostgreSQL
- alpine 3.24: postgresql18-doc 18.6-r0 Β· PostgreSQL
- arch rolling: postgresql 18.6-4 Β· PostgreSQL
- fedora 43: postgresql-server-devel 18.6-1.fc43 Β· PostgreSQL
- fedora 43: postgresql-server-devel 18.6-1.fc43 Β· PostgreSQL
- fedora 44: postgresql-server-devel 18.6-1.fc44 Β· PostgreSQL
- fedora 44: postgresql-server-devel 18.6-1.fc44 Β· PostgreSQL
- nixos 26.05: postgresql 18.6
- ubuntu resolute: postgresql-doc-18 18.6-0ubuntu0.26.04.1 Β· PostgreSQL
- ubuntu stonking: postgresql-doc-18 18.6-3build2 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms