SPI_FNUMBER(3)

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

πŸ’… SPI_FNUMBER(3) β€” the column-number bestie πŸ’…

okay so you're in the PostgreSQL 14.24 Documentation era and you need to figure out which column number matches a column name? say less, bestie. this page has you covered, no cap. ✨


🌸 NAME 🌸

SPI_fnumber β€” determine the column number for the specified column name.

πŸ¦‹ SYNOPSIS πŸ¦‹

int SPI_fnumber(TupleDesc rowdesc, const char * colname)

πŸ’– DESCRIPTION πŸ’–

SPI_fnumber returns the column number for the column with the specified name. iconic behavior, literally.

if colname refers to a system column (e.g., ctid) then the appropriate negative column number will be returned. yes, negative β€” system columns stay main-character. 🫢

⚠️ okay this part matters: the caller should be careful to test the return value for exact equality to SPI_ERROR_NOATTRIBUTE to detect an error. testing the result for less than or equal to 0 is not correct unless system columns should be rejected. do not do the lazy <= 0 check unless you mean it, bestie 😭

πŸŽ€ ARGUMENTS πŸŽ€

  • TupleDesc rowdesc β€” input row description.
  • const char * colname β€” column name.

✨ RETURN VALUE ✨

column number (count starts at 1 for user-defined columns), or SPI_ERROR_NOATTRIBUTE if the named column was not found. slay. πŸ‘‘


mwah πŸ’‹ β€” signed, sealed, and served by the PostgreSQL 14.24 docs, dated 2026, page SPI_FNUMBER(3). periodt. 🌈

πŸ“¦ where this page comes from