SPI_FNAME(3)

πŸ“¦ version 17.11, in opensuse-leap 16.0

πŸ’… 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 at 1, not 0. 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 returns NULL if colnumber is 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