SPI_GETARGTYPEID(3)

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

πŸ’– SPI_GETARGTYPEID πŸ’–

okay bestie, so this one's from the PostgreSQL 18.6 Documentation β€” it's SPI_GETARGTYPEID(3), section 3 of the manual, and it's genuinely one of the shorter ones so we can absolutely devour this together ✨


✨ NAME ✨

SPI_getargtypeid β€” returns the data type OID for an argument of a statement prepared by SPI_prepare πŸŽ€

like. it tells you what type one of your args is. that's the whole job. iconic of it honestly.


🌸 SYNOPSIS 🌸

Oid SPI_getargtypeid(SPIPlanPtr plan, int argIndex)

look at her. two params. no drama. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so SPI_getargtypeid returns the Oid that represents the type for the argIndex'th argument of a statement that was prepared by SPI_prepare 🫢

and watch out β€” the first argument is at index zero. zero-based indexing, no cap. that's just how she runs 😭


🌈 ARGUMENTS 🌈

  • SPIPlanPtr plan β€” the prepared statement, i.e. the thing that got handed back to you by SPI_prepare πŸŽ€
  • int argIndex β€” the zero based index of the argument πŸ‘‘ yes. zero. not one. zero. i will not be repeating myself (i will be repeating myself).

πŸ’œ RETURN VALUE πŸ’œ

you get back the type OID of the argument sitting at the index you asked for. slay ✨

but if the plan is NULL or invalid, or if argIndex is less than 0 or not less than the number of arguments declared for the plan, then SPI_result gets set to SPI_ERROR_ARGUMENT and InvalidOid is returned πŸ’€

so basically: bad index or bad plan β†’ you get the error code set and InvalidOid handed to you instead of an actual answer. check your stuff, bestie πŸ™ˆ


lowkey just always check SPI_result after this one. it's giving "trust but verify" and honestly the verify part is doing all the work πŸ’…

and that's the whole page fr fr πŸ’– that was SPI_getargtypeid from the PostgreSQL 18.6 Documentation, dated 2026, living in section SPI_GETARGTYPEID(3). go forth and index responsibly, queen πŸ‘‘πŸŒΈ

πŸ“¦ where this page comes from