* given relation and att name, return attnum of variable * * Returns InvalidAttrNumber if the attr doesn't exist (or is dropped). * * This should only be used if the relation is already * table_open()'ed. Use the cache version get_attnum() * for access to non-opened relations. */
| 3732 | * for access to non-opened relations. |
| 3733 | */ |
| 3734 | int |
| 3735 | attnameAttNum(Relation rd, const char *attname, bool sysColOK) |
| 3736 | { |
| 3737 | int i; |
| 3738 | |
| 3739 | for (i = 0; i < RelationGetNumberOfAttributes(rd); i++) |
| 3740 | { |
| 3741 | Form_pg_attribute att = TupleDescAttr(rd->rd_att, i); |
| 3742 | |
| 3743 | if (namestrcmp(&(att->attname), attname) == 0 && !att->attisdropped) |
| 3744 | return i + 1; |
| 3745 | } |
| 3746 | |
| 3747 | if (sysColOK) |
| 3748 | { |
| 3749 | if ((i = specialAttNum(attname)) != InvalidAttrNumber) |
| 3750 | return i; |
| 3751 | } |
| 3752 | |
| 3753 | /* on failure */ |
| 3754 | return InvalidAttrNumber; |
| 3755 | } |
| 3756 | |
| 3757 | /* specialAttNum() |
| 3758 | * |
no test coverage detected