SPI_GETTYPEID(3)

πŸ’– NAME πŸ’–

SPI_gettypeid β€” bestie, this one hands you the data type OID of whatever column you point at. that's it, that's the whole job ✨


πŸŽ€ SYNOPSIS πŸŽ€

Oid SPI_gettypeid(TupleDesc rowdesc, int colnumber)

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so picture this: you're deep in server-side C, you've got a row description in your hands, and you just need to know what type one specific column is. not the value. not the name. the type OID.

that's literally what SPI_gettypeid is for πŸ’… it returns the OID of the data type of the column you asked about.

no cap, that's the entire vibe. small function, big main character energy. πŸ‘‘


🌸 ARGUMENTS 🌸

  • TupleDesc rowdesc β€” your input row description. the thing describing the row you're snooping through πŸ•΅οΈβ™€οΈ
  • int colnumber β€” the column number. and heads up bestie, the count starts at 1, not 0. so the first column is 1, not 0. do not come for me about it, that's just how it is πŸ™ˆ

⭐ RETURN VALUE ⭐

you get back the OID of the data type of the specified column. iconic. gorgeous. exactly what you asked for 🫢

but β€” if something goes wrong, you get InvalidOid instead. and when that happens, SPI_result gets set to SPI_ERROR_NOATTRIBUTE so you actually know why it fumbled. it's giving "sorry babe, that column doesn't exist" πŸ’€

lowkey always check your return value, bestie. InvalidOid is not a vibe you wanna miss. 😭

🌈 SEE ALSO... jk, just the sign-off 🌈

that's the whole page, bestie β€” you ate it up fr fr πŸ“ this one's from the PostgreSQL 18.6 docs, dated 2026, and it's SPI_GETTYPEID(3). go forth and OID responsibly πŸ’–βœ¨πŸŽ€