diff options
Diffstat (limited to 'src/backend/executor/execMain.c')
-rw-r--r-- | src/backend/executor/execMain.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index c499486f016..8c799d3c21b 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -547,7 +547,6 @@ ExecCheckRTEPerms(RangeTblEntry *rte) AclMode remainingPerms; Oid relOid; Oid userid; - Bitmapset *tmpset; int col; /* @@ -614,12 +613,13 @@ ExecCheckRTEPerms(RangeTblEntry *rte) return false; } - tmpset = bms_copy(rte->selectedCols); - while ((col = bms_first_member(tmpset)) >= 0) + col = -1; + while ((col = bms_next_member(rte->selectedCols, col)) >= 0) { - /* remove the column number offset */ - col += FirstLowInvalidHeapAttributeNumber; - if (col == InvalidAttrNumber) + /* bit #s are offset by FirstLowInvalidHeapAttributeNumber */ + AttrNumber attno = col + FirstLowInvalidHeapAttributeNumber; + + if (attno == InvalidAttrNumber) { /* Whole-row reference, must have priv on all cols */ if (pg_attribute_aclcheck_all(relOid, userid, ACL_SELECT, @@ -628,12 +628,11 @@ ExecCheckRTEPerms(RangeTblEntry *rte) } else { - if (pg_attribute_aclcheck(relOid, col, userid, + if (pg_attribute_aclcheck(relOid, attno, userid, ACL_SELECT) != ACLCHECK_OK) return false; } } - bms_free(tmpset); } /* @@ -656,24 +655,24 @@ ExecCheckRTEPerms(RangeTblEntry *rte) return false; } - tmpset = bms_copy(rte->modifiedCols); - while ((col = bms_first_member(tmpset)) >= 0) + col = -1; + while ((col = bms_next_member(rte->modifiedCols, col)) >= 0) { - /* remove the column number offset */ - col += FirstLowInvalidHeapAttributeNumber; - if (col == InvalidAttrNumber) + /* bit #s are offset by FirstLowInvalidHeapAttributeNumber */ + AttrNumber attno = col + FirstLowInvalidHeapAttributeNumber; + + if (attno == InvalidAttrNumber) { /* whole-row reference can't happen here */ elog(ERROR, "whole-row update is not implemented"); } else { - if (pg_attribute_aclcheck(relOid, col, userid, + if (pg_attribute_aclcheck(relOid, attno, userid, remainingPerms) != ACLCHECK_OK) return false; } } - bms_free(tmpset); } } return true; |