mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-18 18:44:06 +08:00
Be careful to get share lock on each page before computing its free space.
ITAGAKI Takahiro
This commit is contained in:
parent
88ae1bd3f2
commit
7ec280e117
@ -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++;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user