SPI_FNUMBER(3)

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

okay bestie, welcome to SPI_FNUMBER(3) from the PostgreSQL 15.19 docs β€” this is the little function that tells you which column number goes with a column name πŸ’…βœ¨

πŸŽ€ NAME πŸŽ€

SPI_fnumber β€” determine the column number for the specified column name. yes, that's literally her whole job 🫢

✨ SYNOPSIS ✨

int SPI_fnumber(TupleDesc rowdesc, const char * colname)

πŸ’– DESCRIPTION πŸ’–

okay so SPI_fnumber returns the column number for the column with the specified name. very "where is she?" but for columns πŸ‘€

if colname refers to a system column (e.g., ctid), then the appropriate negative column number will be returned. so do not freak out if the number is negative β€” that's just system-column behavior, bestie πŸ¦‹

caller tea β˜•: be careful and test the return value for exact equality to SPI_ERROR_NOATTRIBUTE when you're checking for an error. testing the result for <= 0 is not correct unless system columns should be rejected. periodt πŸ’€

🌸 ARGUMENTS 🌸

  • TupleDesc rowdesc β€” input row description. this is the row description you're handing over πŸ’Œ
  • const char * colname β€” column name. the name you're looking for πŸ”Ž

πŸ‘‘ RETURN VALUE πŸ‘‘

  • Column number (count starts at 1 for user-defined columns), or SPI_ERROR_NOATTRIBUTE if the named column was not found. iconic and straightforward πŸ’«

mwah πŸ’‹ β€” this page is from PostgreSQL 15.19, dated 2026, and it's literally called SPI_FNUMBER(3) πŸŽ€

πŸ“¦ where this page comes from