diff options
Diffstat (limited to 'contrib/sepgsql/dml.c')
-rw-r--r-- | contrib/sepgsql/dml.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/contrib/sepgsql/dml.c b/contrib/sepgsql/dml.c index bb82c0d6d2..36c6a37ac1 100644 --- a/contrib/sepgsql/dml.c +++ b/contrib/sepgsql/dml.c @@ -4,7 +4,7 @@ * * Routines to handle DML permission checks * - * Copyright (c) 2010-2014, PostgreSQL Global Development Group + * Copyright (c) 2010-2015, PostgreSQL Global Development Group * * ------------------------------------------------------------------------- */ @@ -93,10 +93,7 @@ fixup_whole_row_references(Oid relOid, Bitmapset *columns) static Bitmapset * fixup_inherited_columns(Oid parentId, Oid childId, Bitmapset *columns) { - AttrNumber attno; - Bitmapset *tmpset; Bitmapset *result = NULL; - char *attname; int index; /* @@ -105,10 +102,12 @@ fixup_inherited_columns(Oid parentId, Oid childId, Bitmapset *columns) if (parentId == childId) return columns; - tmpset = bms_copy(columns); - while ((index = bms_first_member(tmpset)) > 0) + index = -1; + while ((index = bms_next_member(columns, index)) >= 0) { - attno = index + FirstLowInvalidHeapAttributeNumber; + /* bit numbers are offset by FirstLowInvalidHeapAttributeNumber */ + AttrNumber attno = index + FirstLowInvalidHeapAttributeNumber; + char *attname; /* * whole-row-reference shall be fixed-up later @@ -128,12 +127,11 @@ fixup_inherited_columns(Oid parentId, Oid childId, Bitmapset *columns) elog(ERROR, "cache lookup failed for attribute %s of relation %u", attname, childId); - index = attno - FirstLowInvalidHeapAttributeNumber; - result = bms_add_member(result, index); + result = bms_add_member(result, + attno - FirstLowInvalidHeapAttributeNumber); pfree(attname); } - bms_free(tmpset); return result; } |