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
b0a3d7e47c
commit
0926c76c8e
@ -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.38.2.1 2010/04/02 16:16:57 tgl Exp $
|
||||||
*
|
*
|
||||||
* Copyright (c) 2001,2002 Tatsuo Ishii
|
* Copyright (c) 2001,2002 Tatsuo Ishii
|
||||||
*
|
*
|
||||||
@ -276,6 +276,8 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
|
|||||||
/* scan the relation */
|
/* scan the relation */
|
||||||
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
|
||||||
{
|
{
|
||||||
|
CHECK_FOR_INTERRUPTS();
|
||||||
|
|
||||||
/* must hold a buffer lock to call HeapTupleSatisfiesVisibility */
|
/* must hold a buffer lock to call HeapTupleSatisfiesVisibility */
|
||||||
LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE);
|
LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE);
|
||||||
|
|
||||||
@ -302,6 +304,8 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
|
|||||||
|
|
||||||
while (block <= tupblock)
|
while (block <= tupblock)
|
||||||
{
|
{
|
||||||
|
CHECK_FOR_INTERRUPTS();
|
||||||
|
|
||||||
buffer = ReadBuffer(rel, block);
|
buffer = ReadBuffer(rel, block);
|
||||||
LockBuffer(buffer, BUFFER_LOCK_SHARE);
|
LockBuffer(buffer, BUFFER_LOCK_SHARE);
|
||||||
stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer));
|
stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer));
|
||||||
@ -313,6 +317,8 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
|
|||||||
|
|
||||||
while (block < nblocks)
|
while (block < nblocks)
|
||||||
{
|
{
|
||||||
|
CHECK_FOR_INTERRUPTS();
|
||||||
|
|
||||||
buffer = ReadBuffer(rel, block);
|
buffer = ReadBuffer(rel, block);
|
||||||
LockBuffer(buffer, BUFFER_LOCK_SHARE);
|
LockBuffer(buffer, BUFFER_LOCK_SHARE);
|
||||||
stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer));
|
stat.free_space += PageGetHeapFreeSpace((Page) BufferGetPage(buffer));
|
||||||
@ -468,7 +474,11 @@ pgstat_index(Relation rel, BlockNumber start, pgstat_page pagefn,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (; blkno < nblocks; blkno++)
|
for (; blkno < nblocks; blkno++)
|
||||||
|
{
|
||||||
|
CHECK_FOR_INTERRUPTS();
|
||||||
|
|
||||||
pagefn(&stat, rel, blkno);
|
pagefn(&stat, rel, blkno);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
relation_close(rel, AccessShareLock);
|
relation_close(rel, AccessShareLock);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user