SPI_GETARGTYPEID(3)
π 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 bySPI_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
- opensuse-leap 16.0: postgresql18-docs 18.6-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms