]> 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:05 +0000 (16:17 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 2 Apr 2010 16:17:05 +0000 (16:17 +0000)
reasonably promptly, by adding CHECK_FOR_INTERRUPTS in the per-page loops.

Tatsuhito Kasahara

contrib/pgstattuple/pgstattuple.c

index 989911fdd88b68f548ea8203ec5f380b67681722..26e37f4df377b18da21fd3ef673a2f967c60bfd5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.32.2.1 2009/03/31 22:54:52 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.32.2.2 2010/04/02 16:17:05 tgl Exp $
  *
  * Copyright (c) 2001,2002     Tatsuo Ishii
  *
@@ -273,6 +273,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);
 
@@ -299,6 +301,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));
@@ -310,6 +314,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));
@@ -465,7 +471,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);