Assert that buffer is pinned in LockBuffer().
authorPeter Geoghegan <pg@bowt.ie>
Mon, 20 Jul 2020 23:03:38 +0000 (16:03 -0700)
committerPeter Geoghegan <pg@bowt.ie>
Mon, 20 Jul 2020 23:03:38 +0000 (16:03 -0700)
Strengthen the LockBuffer() assertion that verifies BufferIsValid() by
making it verify BufferIsPinned() instead.  Do the same in nearby
related functions.

There is probably not much chance that anybody will try to lock a buffer
that is not already pinned, but we might as well make sure of that.

src/backend/storage/buffer/bufmgr.c

index 83d91b14fb1c24752c19e807a33732f226398a32..9b9303ff650c5e1c5cacf38ac7484d4da3f9b6b8 100644 (file)
@@ -3743,7 +3743,7 @@ LockBuffer(Buffer buffer, int mode)
 {
    BufferDesc *buf;
 
-   Assert(BufferIsValid(buffer));
+   Assert(BufferIsPinned(buffer));
    if (BufferIsLocal(buffer))
        return;                 /* local buffers need no lock */
 
@@ -3769,7 +3769,7 @@ ConditionalLockBuffer(Buffer buffer)
 {
    BufferDesc *buf;
 
-   Assert(BufferIsValid(buffer));
+   Assert(BufferIsPinned(buffer));
    if (BufferIsLocal(buffer))
        return true;            /* act as though we got it */
 
@@ -3801,7 +3801,7 @@ LockBufferForCleanup(Buffer buffer)
    BufferDesc *bufHdr;
    char       *new_status = NULL;
 
-   Assert(BufferIsValid(buffer));
+   Assert(BufferIsPinned(buffer));
    Assert(PinCountWaitBuf == NULL);
 
    if (BufferIsLocal(buffer))