Skip to content

Commit 7ec280e

Browse files
committed
Be careful to get share lock on each page before computing its free space.
ITAGAKI Takahiro
1 parent 88ae1bd commit 7ec280e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

contrib/pgstattuple/pgstattuple.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.30 2007/09/20 17:56:30 tgl Exp $
2+
* $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.31 2007/10/22 17:29:35 tgl Exp $
33
*
44
* Copyright (c) 2001,2002 Tatsuo Ishii
55
*
@@ -291,8 +291,7 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
291291
buffer = ReadBuffer(rel, block);
292292
LockBuffer(buffer, BUFFER_LOCK_SHARE);
293293
stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer));
294-
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
295-
ReleaseBuffer(buffer);
294+
UnlockReleaseBuffer(buffer);
296295
block++;
297296
}
298297
}
@@ -301,8 +300,9 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
301300
while (block < nblocks)
302301
{
303302
buffer = ReadBuffer(rel, block);
303+
LockBuffer(buffer, BUFFER_LOCK_SHARE);
304304
stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer));
305-
ReleaseBuffer(buffer);
305+
UnlockReleaseBuffer(buffer);
306306
block++;
307307
}
308308

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy