* ExecCheckRTEPermsModified * Check INSERT or UPDATE access permissions for a single RTE (these * are processed uniformly). */
| 1597 | * are processed uniformly). |
| 1598 | */ |
| 1599 | static bool |
| 1600 | ExecCheckRTEPermsModified(Oid relOid, Oid userid, Bitmapset *modifiedCols, |
| 1601 | AclMode requiredPerms) |
| 1602 | { |
| 1603 | int col = -1; |
| 1604 | |
| 1605 | /* |
| 1606 | * When the query doesn't explicitly update any columns, allow the query |
| 1607 | * if we have permission on any column of the rel. This is to handle |
| 1608 | * SELECT FOR UPDATE as well as possible corner cases in UPDATE. |
| 1609 | */ |
| 1610 | if (bms_is_empty(modifiedCols)) |
| 1611 | { |
| 1612 | if (pg_attribute_aclcheck_all(relOid, userid, requiredPerms, |
| 1613 | ACLMASK_ANY) != ACLCHECK_OK) |
| 1614 | return false; |
| 1615 | } |
| 1616 | |
| 1617 | while ((col = bms_next_member(modifiedCols, col)) >= 0) |
| 1618 | { |
| 1619 | /* bit #s are offset by FirstLowInvalidHeapAttributeNumber */ |
| 1620 | AttrNumber attno = col + FirstLowInvalidHeapAttributeNumber; |
| 1621 | |
| 1622 | if (attno == InvalidAttrNumber) |
| 1623 | { |
| 1624 | /* whole-row reference can't happen here */ |
| 1625 | elog(ERROR, "whole-row update is not implemented"); |
| 1626 | } |
| 1627 | else |
| 1628 | { |
| 1629 | if (pg_attribute_aclcheck(relOid, attno, userid, |
| 1630 | requiredPerms) != ACLCHECK_OK) |
| 1631 | return false; |
| 1632 | } |
| 1633 | } |
| 1634 | return true; |
| 1635 | } |
| 1636 | |
| 1637 | /* |
| 1638 | * Check that the query does not imply any writes to non-temp tables; |
no test coverage detected