]> granicus.if.org Git - postgresql/commitdiff
Ensure that contrib/pgstattuple functions respond to cancel interrupts
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 2 Apr 2010 16:16:51 +0000 (16:16 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 2 Apr 2010 16:16:51 +0000 (16:16 +0000)
reasonably promptly, by adding CHECK_FOR_INTERRUPTS in the per-page loops.

Tatsuhito Kasahara

contrib/pgstattuple/pgstattuple.c

index 5d6168f77d63c33e6555b67c71cc9ed5a366cf31..994773a9d7d01044166450de743898cf56378157 100644 (file)
@@ -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);