SPI_FNAME(3)
π SPI_FNAME π
okay so bestie, welcome to SPI_fname β straight out of the PostgreSQL 17.11 docs, and honestly? she's a little icon. this page is gonna tell you how to grab the name of a column when all you've got is its number. no cap, it's simpler than it sounds π«Ά
β¨ NAME β¨
SPI_fname β literally just: figure out the column name for the column number you asked for. that's her whole job. main character energy, minimal drama π
π SYNOPSIS π
char * SPI_fname(TupleDesc rowdesc, int colnumber)
πΈ DESCRIPTION πΈ
so SPI_fname returns a copy of the column name of whatever column you point at. a copy, bestie β not the original, so don't come for her later.
and since it's a copy, the docs are like: you can use pfree to release the copy of the name when you don't need it anymore. so go ahead and let it go when you're done, ok? releasing your stuff is self-care β¨
π¦ ARGUMENTS π¦
TupleDesc rowdescβ the input row description. this is the vibe check on the row you're snooping through πint colnumberβ the column number. and listen, the count starts at1, not0. iykyk. do not come at her with a zero, she will not know what to do with it π
π RETURN VALUE π
you get the column name back, bestie. slay.
but real talk:
it returnsNULLifcolnumberis out of range. π
and when there's an error, SPI_result set to SPI_ERROR_NOATTRIBUTE β so if things go sideways, that's where you look. not me being dramatic, that's just the facts π
π a lil sign-off π
this page is from the PostgreSQL 17.11 documentation, dated 2026 β iconic, timeless, fr fr. now go get that column name, you absolute legend πππ
π¦ 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