Ensure that contrib/pgstattuple functions respond to cancel interrupts
authorTom Lane <[email protected]>
Fri, 2 Apr 2010 16:17:24 +0000 (16:17 +0000)
committerTom Lane <[email protected]>
Fri, 2 Apr 2010 16:17:24 +0000 (16:17 +0000)
reasonably promptly, by adding CHECK_FOR_INTERRUPTS in the per-page loops.

Tatsuhito Kasahara

contrib/pgstattuple/pgstattuple.c

index 40fe4f1961c73d3cc2516af80e8c352e5f7d629e..e68a896f5254a819db9b745d65b0fde8a505cf48 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.17.4.1 2009/03/31 22:56:18 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.17.4.2 2010/04/02 16:17:24 tgl Exp $
  *
  * Copyright (c) 2001,2002     Tatsuo Ishii
  *
@@ -29,6 +29,7 @@
 #include "access/heapam.h"
 #include "access/transam.h"
 #include "catalog/namespace.h"
+#include "miscadmin.h"
 #include "utils/builtins.h"
 
 
@@ -144,6 +145,8 @@ pgstattuple_real(Relation rel)
        /* 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);
 
@@ -170,6 +173,8 @@ pgstattuple_real(Relation rel)
 
                while (block <= tupblock)
                {
+                       CHECK_FOR_INTERRUPTS();
+
                        buffer = ReadBuffer(rel, block);
                        LockBuffer(buffer, BUFFER_LOCK_SHARE);
                        free_space += PageGetFreeSpace((Page) BufferGetPage(buffer));
@@ -182,6 +187,8 @@ pgstattuple_real(Relation rel)
 
        while (block < nblocks)
        {
+               CHECK_FOR_INTERRUPTS();
+
                buffer = ReadBuffer(rel, block);
                free_space += PageGetFreeSpace((Page) BufferGetPage(buffer));
                ReleaseBuffer(buffer);