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, iykyk
  • int 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
  • colnumber is out of range β€” and when that happens, SPI_result is set to SPI_ERROR_NOATTRIBUTE πŸ’€
  • there's no output function available β€” and then SPI_result is set to SPI_ERROR_NOOUTFUNC 😭
so yeah, always peek at SPI_result when you get a NULL, because NULL could mean "the value is null" OR "something went wrong." two completely different girls, same NULL outfit πŸ™ˆ

πŸ’– 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!! 🧚✨