SPI_SAVEPLAN(3)
π SPI_SAVEPLAN(3) π
okay so bestie, this is the SPI_saveplan page from the PostgreSQL 15.19 Documentation, and it's giving βsave your prepared statement so future-you can use it againβ energy. No cap, let's get into it. π
β¨ NAME β¨
SPI_saveplan β save a prepared statement. Literally the whole gig. π
πΈ SYNOPSIS πΈ
SPIPlanPtr SPI_saveplan(SPIPlanPtr plan)
π¦ DESCRIPTION π¦
Okay so SPI_saveplan copies a statement you passed in β one that was prepared by SPI_prepare β into memory that will not be freed by SPI_finish nor by the transaction manager, and then it returns a pointer to the copied statement. The way this is lowkey iconic? It gives you the ability to reuse prepared statements in the subsequent invocations of your C function in the current session. Reuse era fr fr. β¨
π ARGUMENTS π
SPIPlanPtr planβ the prepared statement to be saved. That's the one, bestie. π«Ά
π₯ RETURN VALUE π₯
A pointer to the copied statement; or NULL if unsuccessful. On error, SPI_result is set thus:
SPI_ERROR_ARGUMENTβ ifplanisNULLor invalid. Not valid? Not today. πSPI_ERROR_UNCONNECTEDβ if called from an unconnected C function. Ma'am, connect first. π
π NOTES π
- The originally passed-in statement is not freed, so you might wish to do
SPI_freeplanon it to avoid leaking memory untilSPI_finish. Memory leak vibes? We don't claim them. π - In most cases,
SPI_keepplanis preferred to this function, since it accomplishes largely the same result without needing to physically copy the prepared statement's data structures. So like, check that one first, iykyk. π
and that's the whole page, bestie β cute sign-off time: this was from PostgreSQL 15.19, dated 2026. Mwah, go save those plans responsibly. π§ββοΈπ
π¦ where this page comes from
- opensuse-leap 16.0: postgresql15-docs 15.19-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