Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
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

+4-4
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)