SPI_FNUMBER(3)
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 toSPI_ERROR_NOATTRIBUTEwhen you're checking for an error. testing the result for<= 0is 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
1for user-defined columns), orSPI_ERROR_NOATTRIBUTEif 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
- opensuse-leap 16.0: postgresql15-docs 15.19-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