SPI_SAVEPLAN(3)
β¨ NAME β¨
SPI_saveplan β save a prepared statement πΎβ¨
Yes bestie, this is the SPI_SAVEPLAN(3) manual page, and weβre keeping every detail β no cap.
πΈ SYNOPSIS πΈ
SPIPlanPtr SPI_saveplan(SPIPlanPtr plan)
π¦ DESCRIPTION π¦
Okay so SPI_saveplan copies a passed statement (prepared by SPI_prepare) into memory that will not be freed by SPI_finish nor by the transaction manager, and returns a pointer to the copied statement π«Ά. Basically it gives you the ability to reuse prepared statements in the subsequent invocations of your C function in the current session. Slay.
π ARGUMENTS π
SPIPlanPtr planβ the prepared statement to be saved πΎ
π RETURN VALUE π
Pointer to the copied statement; or NULL if unsuccessful π. On error, SPI_result is set thus:
SPI_ERROR_ARGUMENTβ ifplanisNULLor invalidSPI_ERROR_UNCONNECTEDβ if called from an unconnected C function
π₯ NOTES π₯
The originally passed-in statement is not freed, so you might wish to do SPI_freeplan on it to avoid leaking memory until SPI_finish π«§. Not me reminding you about memory leaks β okay yes, me reminding you.
In most cases, SPI_keepplan is preferred to this function, since it accomplishes largely the same result without needing to physically copy the prepared statementβs data structures π. Lowkey the better vibe here.
mwah π β PostgreSQL 13.23, dated 2025, signing off from the SPI_SAVEPLAN(3) page π«Ά
π¦ where this page comes from
- opensuse-leap 16.0: postgresql13-docs 13.23-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