SPI_EXECUTE_PLAN(3)
β¨ SPI_EXECUTE_PLAN β¨
okay so bestie, this is the SPI_EXECUTE_PLAN(3) page from the PostgreSQL 17.11 docs, and we're literally about to make prepared-statement execution make Sense π
buckle up.
π NAME π
SPI_execute_plan β the one that runs a statement you already prepped with SPI_prepare. it's giving "reusing your fave fit instead of building a new one" π
πΈ SYNOPSIS πΈ
int SPI_execute_plan(SPIPlanPtr plan, Datum * values, const char * nulls,
bool read_only, long count)
five args, no cap. count them. π«Ά
π¦ DESCRIPTION π¦
k so SPI_execute_plan executes a statement that was prepared by SPI_prepare or one of its siblings (yes, it has siblings, it's a whole family situation π―). the read_only and count params mean exactly the same thing they mean in SPI_execute β same interpretation, no plot twist, no extra lore. periodt. β
π ARGUMENTS π
SPIPlanPtr planβ your prepared statement, aka the thingSPI_preparehanded you back. main character energy right here πDatum * valuesβ an array of the actual parameter values. it must be the same length as the statement's number of arguments β no short-changing, no extras, it's a vibe check and it has to match πconst char * nullsβ an array that says which parameters are null. also must be the same length as the statement's number of arguments.
here's the tea β if nulls is NULL, then SPI_execute_plan assumes no parameters are null. otherwise, each entry of the nulls array should be ' ' when the matching parameter value is non-null, or 'n' when the matching parameter value is null. (and in that null case, whatever you stuffed in the corresponding values entry literally doesn't matter β it's irrelevant, it's not the moment π.) also important: nulls is not a text string, it's just an array β so it does not need a '\0' terminator, bestie, don't add one π
bool read_onlyβ passtruefor read-only execution. simple as that β¨long countβ maximum number of rows to return, or0for no limit. zero means "all of them, idc, bring the whole menu" π
π₯ RETURN VALUE π₯
the return value is the same as for SPI_execute β same deal, same energy β with these additional possible error (negative) results:
SPI_ERROR_ARGUMENTβ ifplanisNULLor invalid, or ifcountis less than0πSPI_ERROR_PARAMβ ifvaluesisNULLandplanwas prepared with some parameters
and if it all goes well, SPI_processed and SPI_tuptable are set just like in SPI_execute ππ
ngl, if you're getting negative returns, check your plan first. it's almost always the plan. π§
okay that's the whole page, you ate it up fr fr π«Ά this was SPI_EXECUTE_PLAN(3) from the PostgreSQL 17.11 Documentation, dated 2026 β go forth and execute your plans, icon π
π
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17-docs 17.11-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