* errtablecol --- stores schema_name, table_name and column_name * of a table column within the current errordata. * * The column is specified by attribute number --- for most callers, this is * easier and less error-prone than getting the column name for themselves. */
| 6020 | * easier and less error-prone than getting the column name for themselves. |
| 6021 | */ |
| 6022 | int |
| 6023 | errtablecol(Relation rel, int attnum) |
| 6024 | { |
| 6025 | TupleDesc reldesc = RelationGetDescr(rel); |
| 6026 | const char *colname; |
| 6027 | |
| 6028 | /* Use reldesc if it's a user attribute, else consult the catalogs */ |
| 6029 | if (attnum > 0 && attnum <= reldesc->natts) |
| 6030 | colname = NameStr(TupleDescAttr(reldesc, attnum - 1)->attname); |
| 6031 | else |
| 6032 | colname = get_attname(RelationGetRelid(rel), attnum, false); |
| 6033 | |
| 6034 | return errtablecolname(rel, colname); |
| 6035 | } |
| 6036 | |
| 6037 | /* |
| 6038 | * errtablecolname --- stores schema_name, table_name and column_name |
no test coverage detected