SPI_FNAME(3)

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

✨ SPI_FNAME ✨

okay bestie, so this is the PostgreSQL 18.6 docs page for SPI_fname, and it's literally one of those tiny little functions that does exactly one thing and does it gorgeously πŸ’…


πŸŽ€ NAME πŸŽ€

SPI_fname β€” she tells you the column name for the column number you asked about. that's it. that's the whole job. icon behavior πŸ‘‘


🌸 SYNOPSIS 🌸

char * SPI_fname(TupleDesc rowdesc, int colnumber)

πŸ’– DESCRIPTION πŸ’–

so SPI_fname gives you back a copy of the column name of the column you specified. not a pointer into the original, a whole fresh copy, she's generous like that 🫢

and because it's a copy, you can use pfree to release it once you don't need the name anymore. pls do that. don't just leave her hanging in memory forever, that's not the vibe πŸ™ˆ


πŸ¦‹ ARGUMENTS πŸ¦‹

  • TupleDesc rowdesc β€” the input row description. your little map of what's in the row πŸ—ΊοΈ
  • int colnumber β€” the column number. and heads up bestie: the count starts at 1, not 0. no zero-indexing here, we're not doing that today ✨

⭐ RETURN VALUE ⭐

you get the column name back, slay. but if colnumber is out of range, you get NULL β€” no name for you πŸ’€

and on error, SPI_result gets set to SPI_ERROR_NOATTRIBUTE. so like, always check, okay? don't just assume she came through πŸ₯Ί


🌈 reminder: it's a copy, so pfree it when you're done. main character energy means cleaning up after yourself πŸ’œ

and that's the whole page, no notes. this is from the PostgreSQL 18.6 documentation, dated 2026, and it's the SPI_FNAME(3) page β€” catch you in the next one, mwah πŸŽ€πŸ’–βœ¨

πŸ“¦ where this page comes from