Ensure that contrib/pgstattuple functions respond to cancel interrupts
reasonably promptly, by adding CHECK_FOR_INTERRUPTS in the per-page loops. Tatsuhito Kasahara
This commit is contained in:
parent
4c10623306
commit
33065ef8bc
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.38 2009/06/11 14:48:52 momjian Exp $
|
||||
* $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.39 2010/04/02 16:16:51 tgl Exp $
|
||||
*
|
||||
* Copyright (c) 2001,2002 Tatsuo Ishii
|
||||
*
|
||||
@ -276,6 +276,8 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
|
||||
/* scan the relation */
|
||||
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
||||
{
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
|
||||
/* must hold a buffer lock to call HeapTupleSatisfiesVisibility */
|
||||
LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE);
|
||||
|
||||
@ -302,6 +304,8 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
|
||||
|
||||
while (block <= tupblock)
|
||||
{
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
|
||||
buffer = ReadBuffer(rel, block);
|
||||
LockBuffer(buffer, BUFFER_LOCK_SHARE);
|
||||
stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer));
|
||||
@ -313,6 +317,8 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
|
||||
|
||||
while (block < nblocks)
|
||||
{
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
|
||||
buffer = ReadBuffer(rel, block);
|
||||
LockBuffer(buffer, BUFFER_LOCK_SHARE);
|
||||
stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer));
|
||||
@ -468,7 +474,11 @@ pgstat_index(Relation rel, BlockNumber start, pgstat_page pagefn,
|
||||
}
|
||||
|
||||
for (; blkno < nblocks; blkno++)
|
||||
{
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
|
||||
pagefn(&stat, rel, blkno);
|
||||
}
|
||||
}
|
||||
|
||||
relation_close(rel, AccessShareLock);
|
||||
|
Loading…
Reference in New Issue
Block a user