Assert only valid flag bits are passed to visibilitymap_set()
authorAndres Freund <[email protected]>
Sun, 2 Apr 2023 00:55:33 +0000 (17:55 -0700)
committerAndres Freund <[email protected]>
Sun, 2 Apr 2023 01:00:19 +0000 (18:00 -0700)
If visibilitymap_set() is called with flags containing a higher bit than
VISIBILITYMAP_ALL_FROZEN, the state of neighboring pages is affected. While
there was an assertion that *some* valid bits were set, it did not check
that *only* valid bits were. Change that.

Discussion: https://postgr.es/m/20230331043300[email protected]

src/backend/access/heap/visibilitymap.c

index 74ff01bb1725c6e6116f62521a3cb8b26491c5ce..e193682352a44c1a98448e8801bb2d2b8de4261e 100644 (file)
@@ -259,9 +259,9 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
 
        Assert(InRecovery || XLogRecPtrIsInvalid(recptr));
        Assert(InRecovery || PageIsAllVisible((Page) BufferGetPage(heapBuf)));
+       Assert((flags & VISIBILITYMAP_VALID_BITS) == flags);
 
        /* Must never set all_frozen bit without also setting all_visible bit */
-       Assert(flags & VISIBILITYMAP_VALID_BITS);
        Assert(flags != VISIBILITYMAP_ALL_FROZEN);
 
        /* Check that we have the right heap page pinned, if present */