Postgresql 中文操作指南

SPI_fnumber

SPI_fnumber — 确定指定列名的列号

SPI_fnumber — determine the column number for the specified column name

Synopsis

int SPI_fnumber(TupleDesc rowdesc, const char * colname)

Description

SPI_fnumber 返回具有指定名称的列的列号。

SPI_fnumber returns the column number for the column with the specified name.

如果 colname 引用系统列(例如 ctid ),则返回相应的负列号。调用方应小心地测试返回值是否与 SPI_ERROR_NOATTRIBUTE 精确相等,以检测错误;除非应该拒绝系统列,否则测试结果是否小于或等于 0 是不正确的。

If colname refers to a system column (e.g., ctid) then the appropriate negative column number will be returned. The caller should be careful to test the return value for exact equality to SPI_ERROR_NOATTRIBUTE to detect an error; testing the result for less than or equal to 0 is not correct unless system columns should be rejected.

Arguments

  • TupleDesc _rowdesc_

    • input row description

  • const char * _colname_

    • column name

Return Value

列号(计数从用户定义列的 1 开始),或未找到指定列时的 SPI_ERROR_NOATTRIBUTE

Column number (count starts at 1 for user-defined columns), or SPI_ERROR_NOATTRIBUTE if the named column was not found.