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

Tatsuhito Kasahara

contrib/pgstattuple/pgstattuple.c

index 52018df8a51e3233a047ed6f9cffc96d3679dcf9..03bc0f6497ef46fef739fce43c26b7caf7841eca 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.20.2.1 2009/03/31 22:56:05 tgl Exp $
+ * $PostgreSQL: pgsql/contrib/pgstattuple/pgstattuple.c,v 1.20.2.2 2010/04/02 16:17:18 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"
 
 
@@ -145,6 +146,8 @@ pgstattuple_real(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);
 
@@ -171,6 +174,8 @@ pgstattuple_real(Relation rel, FunctionCallInfo fcinfo)
 
        while (block <= tupblock)
        {
+           CHECK_FOR_INTERRUPTS();
+
            buffer = ReadBuffer(rel, block);
            LockBuffer(buffer, BUFFER_LOCK_SHARE);
            free_space += PageGetFreeSpace((Page) BufferGetPage(buffer));
@@ -183,6 +188,8 @@ pgstattuple_real(Relation rel, FunctionCallInfo fcinfo)
 
    while (block < nblocks)
    {
+       CHECK_FOR_INTERRUPTS();
+
        buffer = ReadBuffer(rel, block);
        free_space += PageGetFreeSpace((Page) BufferGetPage(buffer));
        ReleaseBuffer(buffer);