Add CHECK_FOR_INTERRUPTS() in various strategic spots, per comments
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 6 Jan 2002 00:37:44 +0000 (00:37 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 6 Jan 2002 00:37:44 +0000 (00:37 +0000)
from Hiroshi.

src/backend/access/nbtree/nbtree.c
src/backend/catalog/index.c
src/backend/commands/analyze.c
src/backend/commands/cluster.c
src/backend/commands/vacuum.c
src/backend/commands/vacuumlazy.c
src/backend/executor/execScan.c
src/backend/utils/sort/tuplesort.c

index e11d37ac0f2ab406896f4603776e123c0544d9f2..1800d2453f1f773572291bf5c61e09dc95970705 100644 (file)
@@ -596,6 +596,8 @@ btbulkdelete(PG_FUNCTION_ARGS)
                        IndexTuple      itup;
                        ItemPointer htup;
 
+                       CHECK_FOR_INTERRUPTS();
+
                        /* current is the next index tuple */
                        blkno = ItemPointerGetBlockNumber(current);
                        offnum = ItemPointerGetOffsetNumber(current);
index d2ac0858bafcf74b02ab6c91a7c409f0cdeefc59..8666bd4351f984913ede7cd35092ca625ef3321b 100644 (file)
@@ -1679,6 +1679,8 @@ IndexBuildHeapScan(Relation heapRelation,
        {
                bool            tupleIsAlive;
 
+               CHECK_FOR_INTERRUPTS();
+
                if (snapshot == SnapshotAny)
                {
                        /* do our own time qual check */
index c825fda3d5f7dcf4391461edd9ec72a5b1a871cb..ab1a24f59e49aa58f7bd784fc18cd005175a140e 100644 (file)
@@ -516,6 +516,7 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows,
                rows[numrows++] = heap_copytuple(tuple);
                if (numrows >= targrows)
                        break;
+               CHECK_FOR_INTERRUPTS();
        }
        heap_endscan(scan);
 
@@ -584,6 +585,8 @@ acquire_sample_rows(Relation onerel, HeapTuple *rows, int targrows,
                OffsetNumber targoffset,
                                        maxoffset;
 
+               CHECK_FOR_INTERRUPTS();
+
                t = select_next_random_record(t, targrows, &rstate);
                /* Try to read the t'th record in the table */
                targpos = t / tuplesperpage;
@@ -881,6 +884,8 @@ compute_minimal_stats(VacAttrStats *stats,
                int                     firstcount1,
                                        j;
 
+               CHECK_FOR_INTERRUPTS();
+
                value = heap_getattr(tuple, stats->attnum, tupDesc, &isnull);
 
                /* Check for null/nonnull */
@@ -1158,6 +1163,8 @@ compute_scalar_stats(VacAttrStats *stats,
                Datum           value;
                bool            isnull;
 
+               CHECK_FOR_INTERRUPTS();
+
                value = heap_getattr(tuple, stats->attnum, tupDesc, &isnull);
 
                /* Check for null/nonnull */
index 3fec9bc0eee6fb51528d5518762f70a4c04ab5f0..9ac97b214aa3c6ad145bd128ad30b4bc4e8a57b7 100644 (file)
@@ -263,6 +263,8 @@ rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
                HeapTupleData LocalHeapTuple;
                Buffer          LocalBuffer;
 
+               CHECK_FOR_INTERRUPTS();
+
                LocalHeapTuple.t_self = ScanResult->heap_iptr;
                LocalHeapTuple.t_datamcxt = NULL;
                LocalHeapTuple.t_data = NULL;
index 44c4b374431a91e023cd10c739cb453a26922450..cbb4b3e8cd730449ccbbc9743eaf3ce9b49c663e 100644 (file)
@@ -992,6 +992,8 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
                bool            do_reap,
                                        do_frag;
 
+               CHECK_FOR_INTERRUPTS();
+
                buf = ReadBuffer(onerel, blkno);
                page = BufferGetPage(buf);
 
@@ -1415,6 +1417,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
                 blkno > last_move_dest_block;
                 blkno--)
        {
+               CHECK_FOR_INTERRUPTS();
+
                /*
                 * Forget fraged_pages pages at or after this one; they're no
                 * longer useful as move targets, since we only want to move down.
@@ -2127,6 +2131,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
                 i < vacuumed_pages;
                 i++, curpage++)
        {
+               CHECK_FOR_INTERRUPTS();
                Assert((*curpage)->blkno < blkno);
                if ((*curpage)->offsets_used == 0)
                {
@@ -2157,6 +2162,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel,
                 i < num_fraged_pages;
                 i++, curpage++)
        {
+               CHECK_FOR_INTERRUPTS();
                Assert((*curpage)->blkno < blkno);
                if ((*curpage)->blkno > last_move_dest_block)
                        break;                          /* no need to scan any further */
@@ -2342,6 +2348,7 @@ vacuum_heap(VRelStats *vacrelstats, Relation onerel, VacPageList vacuum_pages)
 
        for (i = 0, vacpage = vacuum_pages->pagedesc; i < nblocks; i++, vacpage++)
        {
+               CHECK_FOR_INTERRUPTS();
                if ((*vacpage)->offsets_free > 0)
                {
                        buf = ReadBuffer(onerel, (*vacpage)->blkno);
index 27b60442afd15e17d46021f3c8d1e4feb5a138ab..c878b92a2fabf6f608b6c12dc77a8da86b530bd4 100644 (file)
@@ -230,6 +230,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
                                        hastup;
                int                     prev_dead_count;
 
+               CHECK_FOR_INTERRUPTS();
+
                /*
                 * If we are close to overrunning the available space for
                 * dead-tuple TIDs, pause and do a cycle of vacuuming before we
@@ -464,6 +466,8 @@ lazy_vacuum_heap(Relation onerel, LVRelStats *vacrelstats)
                Buffer          buf;
                Page            page;
 
+               CHECK_FOR_INTERRUPTS();
+
                tblk = ItemPointerGetBlockNumber(&vacrelstats->dead_tuples[tupindex]);
                buf = ReadBuffer(onerel, tblk);
                LockBufferForCleanup(buf);
@@ -770,6 +774,8 @@ count_nondeletable_pages(Relation onerel, LVRelStats *vacrelstats)
                                        tupgone,
                                        hastup;
 
+               CHECK_FOR_INTERRUPTS();
+
                blkno--;
 
                buf = ReadBuffer(onerel, blkno);
index c2de25f53d679f0014b62c5232984bcda17e07aa..f4b94f58809d36de2b74a3ab3d1a575843069a88 100644 (file)
  *
  *-------------------------------------------------------------------------
  */
+#include "postgres.h"
 
 #include <sys/types.h>
 #include <sys/file.h>
 
-#include "postgres.h"
-
 #include "executor/executor.h"
+#include "miscadmin.h"
 #include "utils/memutils.h"
 
 
@@ -92,6 +92,8 @@ ExecScan(Scan *node,
        {
                TupleTableSlot *slot;
 
+               CHECK_FOR_INTERRUPTS();
+
                slot = (*accessMtd) (node);
 
                /*
index 63fff21b1ed060e7e173ee09635486c1e41c270d..5187efe016d8f79986521351ee16ec69c2716879 100644 (file)
@@ -1233,6 +1233,7 @@ mergeonerun(Tuplesortstate *state)
         */
        while (state->memtupcount > 0)
        {
+               CHECK_FOR_INTERRUPTS();
                /* write the tuple to destTape */
                priorAvail = state->availMem;
                srcTape = state->memtupindex[0];