SPI_GETVALUE(3)
β¨ SPI_GETVALUE β¨
okay bestie, welcome to the SPI_GETVALUE(3) page from the PostgreSQL 18.6 Documentation β yes it's a C function, yes it's giving backend internals, and yes we're gonna make it make sense π
π NAME π
SPI_getvalue β bestie, it returns the string value of the specified column. that's the whole job. she's focused. she's employed. periodt π
πΈ SYNOPSIS πΈ
char * SPI_getvalue(HeapTuple row, TupleDesc rowdesc, int colnumber)
π¦ DESCRIPTION π¦
so like. SPI_getvalue returns the string representation of the value of the specified column. you hand her a column, she hands you back the vibe as text. iconic behavior honestly π
the result comes back in memory that was allocated using palloc. and no cap β you can use pfree to release that memory when you don't need it anymore. free your girl!! she's not gonna do it herself π«Ά
ngl this is the "you allocated it, you free it" situation. it's giving responsibility. it's giving main character energy for your memory management.
π ARGUMENTS π
HeapTuple rowβ the input row that's getting examined. the subject of the vibe check πTupleDesc rowdescβ the input row description. the little ID card for that row, iykykint colnumberβ the column number. and listen, the count starts at 1, not 0. I know. I KNOW. we've all been burned by this. one-based indexing, no cap π
β RETURN VALUE β
she returns the column value! slay! but she'll hand you back NULL in any of these situations, and you need to know all three fr fr:
- the column is null
colnumberis out of range β and when that happens,SPI_resultis set toSPI_ERROR_NOATTRIBUTEπ- there's no output function available β and then
SPI_resultis set toSPI_ERROR_NOOUTFUNCπ
so yeah, always peek atSPI_resultwhen you get aNULL, becauseNULLcould mean "the value is null" OR "something went wrong." two completely different girls, sameNULLoutfit π
π SEE ALSO π
no SEE ALSO refs on this page, bestie β she's standing on her own and honestly? queen behavior π
okay that's the whole page!! go forth and get those column values, remember palloc means pfree later, and remember that colnumber starts at 1 π
this lil sign-off is coming to you from PostgreSQL 18.6, dated 2026, and this manual page is SPI_GETVALUE(3). mwah π bye bestie!! π§β¨
π¦ 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