diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-05-16 01:27:06 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-05-16 01:27:06 +0000 |
commit | 8282d6fc7029e28c7a8c716dfe1df61bc2d61372 (patch) | |
tree | 7130202a3da04f1486baf057119d815994a097f2 | |
parent | b62f246fb0c9897fe5ac294c6f6e75ac2651307f (diff) | |
download | postgresql-8282d6fc7029e28c7a8c716dfe1df61bc2d61372.tar.gz postgresql-8282d6fc7029e28c7a8c716dfe1df61bc2d61372.zip |
Persuade GIN to react to control-C in a reasonable amount of time
while building a GIN index.
-rw-r--r-- | src/backend/access/gin/gininsert.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c index 4449928caee..654bf137e23 100644 --- a/src/backend/access/gin/gininsert.c +++ b/src/backend/access/gin/gininsert.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/access/gin/gininsert.c,v 1.12 2008/05/12 00:00:44 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/access/gin/gininsert.c,v 1.13 2008/05/16 01:27:06 tgl Exp $ *------------------------------------------------------------------------- */ @@ -246,7 +246,11 @@ ginBuildCallback(Relation index, HeapTuple htup, Datum *values, uint32 nlist; while ((list = ginGetEntry(&buildstate->accum, &entry, &nlist)) != NULL) + { + /* there could be many entries, so be willing to abort here */ + CHECK_FOR_INTERRUPTS(); ginEntryInsert(index, &buildstate->ginstate, entry, list, nlist, TRUE); + } MemoryContextReset(buildstate->tmpCtx); ginInitBA(&buildstate->accum); @@ -331,9 +335,14 @@ ginbuild(PG_FUNCTION_ARGS) reltuples = IndexBuildHeapScan(heap, index, indexInfo, ginBuildCallback, (void *) &buildstate); + /* dump remaining entries to the index */ oldCtx = MemoryContextSwitchTo(buildstate.tmpCtx); while ((list = ginGetEntry(&buildstate.accum, &entry, &nlist)) != NULL) + { + /* there could be many entries, so be willing to abort here */ + CHECK_FOR_INTERRUPTS(); ginEntryInsert(index, &buildstate.ginstate, entry, list, nlist, TRUE); + } MemoryContextSwitchTo(oldCtx); MemoryContextDelete(buildstate.tmpCtx); |