SPI_EXECUTE_PLAN(3)
β¨ SPI_EXECUTE_PLAN π
okay bestie, welcome to SPI_EXECUTE_PLAN(3), straight out of the PostgreSQL 18.6 Documentation π«Ά this is the one where you finally run the statement you prepped earlier. no cap, it's iconic.
πΈ NAME πΈ
SPI_execute_plan β execute a statement prepared by SPI_prepare π
π¦ SYNOPSIS π¦
int SPI_execute_plan(SPIPlanPtr plan, Datum * values, const char * nulls,
bool read_only, long count)
π DESCRIPTION π
So SPI_execute_plan runs a statement that you already prepped with SPI_prepare β or literally any of its siblings, the whole fam β¨
And read_only and count? They mean exactly the same thing they mean in SPI_execute. same vibe, no notes π
π ARGUMENTS π
SPIPlanPtr planβ your prepared statement, aka the thingSPI_preparehanded back to you πDatum * valuesβ an array of the actual parameter values. it must be the same length as the statement's number of arguments, periodt. no skipping.const char * nullsβ an array that says which parameters are null. also must be the same length as the statement's number of arguments. twin arrays fr fr π
If nulls is NULL, then SPI_execute_plan just assumes none of the parameters are null. easy.
Otherwise, each entry in the nulls array should be ' ' if that parameter's value is non-null, or 'n' if that parameter's value is null. (and if it's null, the actual value sitting in the matching values entry literally doesn't matter, it's giving irrelevant π)
β οΈ heads up bestie:nullsis not a text string, it's just an array. so it does not need a'\0'terminator. don't add one, don't expect one.
bool read_onlyβtruefor read-only execution πΈlong countβ maximum number of rows to return, or0for no limit π₯
β RETURN VALUE β
The return value is the same as for SPI_execute π«Ά but with these extra possible error (negative) results:
SPI_ERROR_ARGUMENTβ ifplanisNULLor invalid, or ifcountis less than0πSPI_ERROR_PARAMβ ifvaluesisNULLandplanwas prepared with some parameters π
And if everything goes well? SPI_processed and SPI_tuptable get set exactly like in SPI_execute. slay π
β¨
anyway that's the whole page, mwah π this was SPI_EXECUTE_PLAN(3) from PostgreSQL 18.6, dated 2026 β love that for us, go execute something iconic π¦π
π¦ 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