From 7ec280e1173c096dc7752c4633bcc11150d4c2af Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Mon, 22 Oct 2007 17:29:35 +0000 Subject: [PATCH] Be careful to get share lock on each page before computing its free space. ITAGAKI Takahiro --- contrib/pgstattuple/pgstattuple.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/pgstattuple/pgstattuple.c b/contrib/pgstattuple/pgstattuple.c index e3dae87593..48194e3a6e 100644 --- a/contrib/pgstattuple/pgstattuple.c +++ b/contrib/pgstattuple/pgstattuple.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.30 2007/09/20 17:56:30 tgl Exp $ + * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.31 2007/10/22 17:29:35 tgl Exp $ * * Copyright (c) 2001,2002 Tatsuo Ishii * @@ -291,8 +291,7 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo) buffer = ReadBuffer(rel, block); LockBuffer(buffer, BUFFER_LOCK_SHARE); stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer)); - LockBuffer(buffer, BUFFER_LOCK_UNLOCK); - ReleaseBuffer(buffer); + UnlockReleaseBuffer(buffer); block++; } } @@ -301,8 +300,9 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo) while (block < nblocks) { buffer = ReadBuffer(rel, block); + LockBuffer(buffer, BUFFER_LOCK_SHARE); stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer)); - ReleaseBuffer(buffer); + UnlockReleaseBuffer(buffer); block++; } -- 2.40.0