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

Tatsuhito Kasahara

contrib/pgstattuple/pgstattuple.c

index 4d001cc2a4675f63d926080c634de171fd929ae8..f4351cb19e38d227f93b45c47176593ae4ca4369 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.25.2.2 2009/03/31 22:55:41 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.25.2.3 2010/04/02 16:17:12 tgl Exp $
  *
  * Copyright (c) 2001,2002     Tatsuo Ishii
  *
@@ -277,6 +277,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 HeapTupleSatisfiesNow */
                LockBuffer(scan->rs_cbuf, BUFFER_LOCK_SHARE);
 
@@ -303,6 +305,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 += PageGetFreeSpace((Page) BufferGetPage(buffer));
@@ -315,6 +319,8 @@ pgstat_heap(Relation rel, FunctionCallInfo fcinfo)
 
        while (block < nblocks)
        {
+               CHECK_FOR_INTERRUPTS();
+
                buffer = ReadBuffer(rel, block);
                stat.free_space += PageGetFreeSpace((Page) BufferGetPage(buffer));
                ReleaseBuffer(buffer);
@@ -469,7 +475,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);