Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8282d6f

Browse files
committed
Persuade GIN to react to control-C in a reasonable amount of time
while building a GIN index.
1 parent b62f246 commit 8282d6f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/backend/access/gin/gininsert.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/gin/gininsert.c,v 1.12 2008/05/12 00:00:44 alvherre Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/gin/gininsert.c,v 1.13 2008/05/16 01:27:06 tgl Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414

@@ -246,7 +246,11 @@ ginBuildCallback(Relation index, HeapTuple htup, Datum *values,
246246
uint32 nlist;
247247

248248
while ((list = ginGetEntry(&buildstate->accum, &entry, &nlist)) != NULL)
249+
{
250+
/* there could be many entries, so be willing to abort here */
251+
CHECK_FOR_INTERRUPTS();
249252
ginEntryInsert(index, &buildstate->ginstate, entry, list, nlist, TRUE);
253+
}
250254

251255
MemoryContextReset(buildstate->tmpCtx);
252256
ginInitBA(&buildstate->accum);
@@ -331,9 +335,14 @@ ginbuild(PG_FUNCTION_ARGS)
331335
reltuples = IndexBuildHeapScan(heap, index, indexInfo,
332336
ginBuildCallback, (void *) &buildstate);
333337

338+
/* dump remaining entries to the index */
334339
oldCtx = MemoryContextSwitchTo(buildstate.tmpCtx);
335340
while ((list = ginGetEntry(&buildstate.accum, &entry, &nlist)) != NULL)
341+
{
342+
/* there could be many entries, so be willing to abort here */
343+
CHECK_FOR_INTERRUPTS();
336344
ginEntryInsert(index, &buildstate.ginstate, entry, list, nlist, TRUE);
345+
}
337346
MemoryContextSwitchTo(oldCtx);
338347

339348
MemoryContextDelete(buildstate.tmpCtx);

0 commit comments

Comments
 (0)