This patch makes a trivial improvement to IncrBufferRefCount(): rather
than asserting that BufferIsValid() and then manually asserting its pin
count is > 0, we can just assert BufferIsPinned().

I'll apply to HEAD before end of day, barring any objections.

-Neil

--- src/backend/storage/buffer/bufmgr.c
+++ src/backend/storage/buffer/bufmgr.c
@@ -1549,25 +1549,18 @@
  *		at least once.
  *
  *		This function cannot be used on a buffer we do not have pinned,
- *		because it doesn't change the shared buffer state.  Therefore the
- *		Assert checks are for refcount > 0.  Someone got this wrong once...
+ *		because it doesn't change the shared buffer state.
  */
 void
 IncrBufferRefCount(Buffer buffer)
 {
-	Assert(BufferIsValid(buffer));
+	Assert(BufferIsPinned(buffer));
 	ResourceOwnerEnlargeBuffers(CurrentResourceOwner);
 	ResourceOwnerRememberBuffer(CurrentResourceOwner, buffer);
 	if (BufferIsLocal(buffer))
-	{
-		Assert(LocalRefCount[-buffer - 1] > 0);
 		LocalRefCount[-buffer - 1]++;
-	}
 	else
-	{
-		Assert(PrivateRefCount[buffer - 1] > 0);
 		PrivateRefCount[buffer - 1]++;
-	}
 }
 
 #ifdef NOT_USED
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Reply via email to