11/*
2- * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.38 2009/06/11 14:48:52 momjian Exp $
2+ * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.39 2010/04/02 16:16:51 tgl Exp $
33 *
44 * Copyright (c) 2001,2002Tatsuo Ishii
55 *
@@ -276,6 +276,8 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
276276/* scan the relation */
277277while ((tuple = heap_getnext (scan ,ForwardScanDirection ))!= NULL )
278278{
279+ CHECK_FOR_INTERRUPTS ();
280+
279281/* must hold a buffer lock to call HeapTupleSatisfiesVisibility */
280282LockBuffer (scan -> rs_cbuf ,BUFFER_LOCK_SHARE );
281283
@@ -302,6 +304,8 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
302304
303305while (block <=tupblock )
304306{
307+ CHECK_FOR_INTERRUPTS ();
308+
305309buffer = ReadBuffer (rel ,block );
306310LockBuffer (buffer ,BUFFER_LOCK_SHARE );
307311stat .free_space += PageGetHeapFreeSpace ((Page )BufferGetPage (buffer ));
@@ -313,6 +317,8 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
313317
314318while (block < nblocks )
315319{
320+ CHECK_FOR_INTERRUPTS ();
321+
316322buffer = ReadBuffer (rel ,block );
317323LockBuffer (buffer ,BUFFER_LOCK_SHARE );
318324stat .free_space += PageGetHeapFreeSpace ((Page )BufferGetPage (buffer ));
@@ -468,7 +474,11 @@ pgstat_index(Relation rel, BlockNumber start, pgstat_page pagefn,
468474}
469475
470476for (;blkno < nblocks ;blkno ++ )
477+ {
478+ CHECK_FOR_INTERRUPTS ();
479+
471480pagefn (& stat ,rel ,blkno );
481+ }
472482}
473483
474484relation_close (rel ,AccessShareLock );