Commit 33065ef8 authored by Tom Lane's avatar Tom Lane

Ensure that contrib/pgstattuple functions respond to cancel interrupts

reasonably promptly, by adding CHECK_FOR_INTERRUPTS in the per-page loops.

Tatsuhito Kasahara
parent 4c106233
/* /*
* $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 * Copyright (c) 2001,2002 Tatsuo Ishii
* *
...@@ -276,6 +276,8 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo) ...@@ -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) ...@@ -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) ...@@ -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, ...@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment