SPI_GETARGTYPEID(3)

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

✨ NAME ✨

okay bestie, welcome to SPI_GETARGTYPEID(3) β€” straight out of the PostgreSQL 14.24 Documentation! This one is all about SPI_getargtypeid, aka the function that returns the data type OID for an argument of a statement prepared by SPI_prepare. πŸŽ€


✨ SYNOPSIS ✨

Oid SPI_getargtypeid(SPIPlanPtr plan, int argIndex)

✨ DESCRIPTION ✨

So SPI_getargtypeid returns the OID representing the type for the argIndex'th argument of a statement prepared by SPI_prepare. And bestie, indexing starts at zero β€” the first argument is at index zero. Periodt. πŸ’…


✨ ARGUMENTS ✨

  • SPIPlanPtr plan β€” the prepared statement, aka the one returned by SPI_prepare ✨
  • int argIndex β€” the zero based index of the argument πŸŽ€

✨ RETURN VALUE ✨

It returns the type OID of the argument at the given index. πŸ’–

but lowkey watch out: if the plan is NULL or invalid, or argIndex is less than 0 or not less than the number of arguments declared for the plan, then SPI_result is set to SPI_ERROR_ARGUMENT and InvalidOid is returned. no cap, that's the whole caveat. 😭

xoxo, from the PostgreSQL 14.24 docs, dated 2026 β€” slay and happy hacking πŸ«ΆπŸ’œ

πŸ“¦ where this page comes from