8000 Revert: Let table AM insertion methods control index insertion · postgrespro/postgres@da841aa · GitHub
[go: up one dir, main page]

Skip to content

Commit da841aa

Browse files
committed
Revert: Let table AM insertion methods control index insertion
This commit reverts b1484a3 per review by Andres Freund. Discussion: https://postgr.es/m/20240410165236.rwyrny7ihi4ddxw4%40awork3.anarazel.de
1 parent bc1e209 commit da841aa

File tree

12 files changed

+28
-72
lines changed

12 files changed

+28
-72
lines changed

src/backend/access/heap/heapam.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2257,8 +2257,7 @@ heap_multi_insert_pages(HeapTuple *heaptuples, int done, int ntuples, Size saveF
22572257
*/
22582258
void
22592259
heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
2260-
CommandId cid, int options, BulkInsertState bistate,
2261-
bool *insert_indexes)
2260+
CommandId cid, int options, BulkInsertState bistate)
22622261
{
22632262
TransactionId xid = GetCurrentTransactionId();
22642263
HeapTuple *heaptuples;
@@ -2607,7 +2606,6 @@ heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
26072606
slots[i]->tts_tid = heaptuples[i]->t_self;
26082607

26092608
pgstat_count_heap_insert(relation, ntuples);
2610-
*insert_indexes = true;
26112609
}
26122610

26132611
/*

src/backend/access/heap/heapam_handler.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ heapam_tuple_satisfies_snapshot(Relation rel, TupleTableSlot *slot,
245245

246246
static TupleTableSlot *
247247
heapam_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid,
248-
int options, BulkInsertState bistate, bool *insert_indexes)
248+
int options, BulkInsertState bistate)
249249
{
250250
bool shouldFree = true;
251251
HeapTuple tuple = ExecFetchSlotHeapTuple(slot, true, &shouldFree);
@@ -261,8 +261,6 @@ heapam_tuple_insert(Relation relation, TupleTableSlot *slot, CommandId cid,
261261
if (shouldFree)
262262
pfree(tuple);
263263

264-
*insert_indexes = true;
265-
266264
return slot;
267265
}
268266

src/backend/access/table/tableam.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,9 @@ table_tuple_get_latest_tid(TableScanDesc scan, ItemPointer tid)
273273
* default command ID and not allowing access to the speedup options.
274274
*/
275275
void
276-
simple_table_tuple_insert(Relation rel, TupleTableSlot *slot,
277-
bool *insert_indexes)
276+
simple_table_tuple_insert(Relation rel, TupleTableSlot *slot)
278277
{
279-
table_tuple_insert(rel, slot, GetCurrentCommandId(true), 0, NULL,
280-
insert_indexes);
278+
table_tuple_insert(rel, slot, GetCurrentCommandId(true), 0, NULL);
281279
}
282280

283281
/*

src/backend/catalog/indexing.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,12 @@ void
273273
CatalogTuplesMultiInsertWithInfo(Relation heapRel, TupleTableSlot **slot,
274274
int ntuples, CatalogIndexState indstate)
275275
{
276-
bool insertIndexes;
277-
278276
/* Nothing to do */
279277
if (ntuples <= 0)
280278
return;
281279

282280
heap_multi_insert(heapRel, slot, ntuples,
283-
GetCurrentCommandId(true), 0, NULL, &insertIndexes);
281+
GetCurrentCommandId(true), 0, NULL);
284282

285283
/*
286284
* There is no equivalent to heap_multi_insert for the catalog indexes, so

src/backend/commands/copyfrom.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ CopyMultiInsertBufferFlush(CopyMultiInsertInfo *miinfo,
395395
bool line_buf_valid = cstate->line_buf_valid;
396396
uint64 save_cur_lineno = cstate->cur_lineno;
397397
MemoryContext oldcontext;
398-
bool insertIndexes;
399398

400399
Assert(buffer->bistate != NULL);
401400

@@ -415,8 +414,7 @@ CopyMultiInsertBufferFlush(CopyMultiInsertInfo *miinfo,
415414
nused,
416415
mycid,
417416
ti_options,
418-
buffer->bistate,
419-
&insertIndexes);
417+
buffer->bistate);
420418
MemoryContextSwitchTo(oldcontext);
421419

422420
for (i = 0; i < nused; i++)
@@ -425,7 +423,7 @@ CopyMultiInsertBufferFlush(CopyMultiInsertInfo *miinfo,
425423
* If there are any indexes, update them for all the inserted
426424
* tuples, and run AFTER ROW INSERT triggers.
427425
*/
428-
if (insertIndexes && resultRelInfo->ri_NumIndices > 0)
426+
if (resultRelInfo->ri_NumIndices > 0)
429427
{
430428
List *recheckIndexes;
431429

@@ -1265,14 +1263,11 @@ CopyFrom(CopyFromState cstate)
12651263
}
12661264
else
12671265
{
1268-
bool insertIndexes;
1269-
12701266
/* OK, store the tuple and create index entries for it */
12711267
table_tuple_insert(resultRelInfo->ri_RelationDesc,
1272-
myslot, mycid, ti_options, bistate,
1273-
&insertIndexes);
1268+
myslot, mycid, ti_options, bistate);
12741269

1275-
if (insertIndexes && resultRelInfo->ri_NumIndices > 0)
1270+
if (resultRelInfo->ri_NumIndices > 0)
12761271
recheckIndexes = ExecInsertIndexTuples(resultRelInfo,
12771272
myslot,
12781273
estate,

src/backend/commands/createas.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,6 @@ static bool
578578
intorel_receive(TupleTableSlot *slot, DestReceiver *self)
579579
{
580580
DR_intorel *myState = (DR_intorel *) self;
581-
bool insertIndexes;
582581

583582
/* Nothing to insert if WITH NO DATA is specified. */
584583
if (!myState->into->skipData)
@@ -595,8 +594,7 @@ intorel_receive(TupleTableSlot *slot, DestReceiver *self)
595594
slot,
596595
myState->output_cid,
597596
myState->ti_options,
598-
myState->bistate,
599-
&insertIndexes);
597+
myState->bistate);
600598
}
601599

602600
/* We know this is a newly created relation, so there are no indexes */

src/backend/commands/matview.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,6 @@ static bool
476476
transientrel_receive(TupleTableSlot *slot, DestReceiver *self)
477477
{
478478
DR_transientrel *myState = (DR_transientrel *) self;
479-
bool insertIndexes;
480479

481480
/*
482481
* Note that the input slot might not be of the type of the target
@@ -491,8 +490,7 @@ transientrel_receive(TupleTableSlot *slot, DestReceiver *self)
491490
slot,
492491
myState->output_cid,
493492
myState->ti_options,
494-
myState->bistate,
495-
&insertIndexes);
493+
myState->bistate);
496494

497495
/* We know this is a newly created relation, so there are no indexes */
498496

src/backend/commands/tablecmds.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6391,12 +6391,8 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap, LOCKMODE lockmode)
63916391

63926392
/* Write the tuple out to the new relation */
63936393
if (newrel)
6394-
{
6395-
bool insertIndexes;
6396-
63976394
table_tuple_insert(newrel, insertslot, mycid,
6398-
ti_options, bistate, &insertIndexes);
6399-
}
6395+
ti_options, bistate);
64006396

64016397
ResetExprContext(econtext);
64026398

@@ -21037,7 +21033,6 @@ moveSplitTableRows(Relation rel, Relation splitRel, List *partlist, List *newPar
2103721033
while (table_scan_getnextslot(scan, ForwardScanDirection, srcslot))
2103821034
{
2103921035
bool found = false;
21040-
bool insert_indexes;
2104121036
TupleTableSlot *insertslot;
2104221037

2104321038
/* Extract data from old tuple. */
@@ -21090,12 +21085,9 @@ moveSplitTableRows(Relation rel, Relation splitRel, List *partlist, List *newPar
2109021085
ExecStoreVirtualTuple(insertslot);
2109121086
}
2109221087

21093-
/*
21094-
* Write the tuple out to the new relation. We ignore the
21095-
* 'insert_indexes' flag since newPartRel has no indexes anyway.
21096-
*/
21088+
/* Write the tuple out to the new relation. */
2109721089
(void) table_tuple_insert(pc->partRel, insertslot, mycid,
21098-
ti_options, pc->bistate, &insert_indexes);
21090+
ti_options, pc->bistate);
2109921091

2110021092
ResetExprContext(econtext);
2110121093

@@ -21364,7 +21356,6 @@ moveMergedTablesRows(Relation rel, List *mergingPartitionsList,
2136421356
while (table_scan_getnextslot(scan, ForwardScanDirection, srcslot))
2136521357
{
2136621358
TupleTableSlot *insertslot;
21367-
bool insert_indexes;
2136821359

2136921360
/* Extract data from old tuple. */
2137021361
slot_getallattrs(srcslot);
@@ -21389,12 +21380,9 @@ moveMergedTablesRows(Relation rel, List *mergingPartitionsList,
2138921380
ExecStoreVirtualTuple(insertslot);
2139021381
}
2139121382

21392-
/*
21393-
* Write the tuple out to the new relation. We ignore the
21394-
* 'insert_indexes' flag since newPartRel has no indexes anyway.
21395-
*/
21383+
/* Write the tuple out to the new relation. */
2139621384
(void) table_tuple_insert(newPartRel, insertslot, mycid,
21397-
ti_options, bistate, &insert_indexes);
21385+
ti_options, bistate);
2139821386

2139921387
CHECK_FOR_INTERRUPTS();
2140021388
}

src/backend/executor/execReplication.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ ExecSimpleRelationInsert(ResultRelInfo *resultRelInfo,
509509
if (!skip_tuple)
510510
{
511511
List *recheckIndexes = NIL;
512-
bool insertIndexes;
513512

514513
/* Compute stored generated columns */
515514
if (rel->rd_att->constr &&
@@ -524,10 +523,9 @@ ExecSimpleRelationInsert(ResultRelInfo *resultRelInfo,
524523
ExecPartitionCheck(resultRelInfo, slot, estate, true);
525524

526525
/* OK, store the tuple and create index entries for it */
527-
simple_table_tuple_insert(resultRelInfo->ri_RelationDesc, slot,
528-
&insertIndexes);
526+
simple_table_tuple_insert(resultRelInfo->ri_RelationDesc, slot);
529527

530-
if (insertIndexes && resultRelInfo->ri_NumIndices > 0)
528+
if (resultRelInfo->ri_NumIndices > 0)
531529
recheckIndexes = ExecInsertIndexTuples(resultRelInfo,
532530
slot, estate, false, false,
533531
NULL, NIL, false);

src/backend/executor/nodeModifyTable.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,15 +1135,13 @@ ExecInsert(ModifyTableContext *context,
11351135
}
11361136
else
11371137
{
1138-
bool insertIndexes;
1139-
11401138
/* insert the tuple normally */
11411139
slot = table_tuple_insert(resultRelationDesc, slot,
11421140
estate->es_output_cid,
1143-
0, NULL, &insertIndexes);
1141+
0, NULL);
11441142

11451143
/* insert index entries for tuple */
1146-
if (insertIndexes && resultRelInfo->ri_NumIndices > 0)
1144+
if (resultRelInfo->ri_NumIndices > 0)
11471145
recheckIndexes = ExecInsertIndexTuples(resultRelInfo,
11481146
slot, estate, false,
11491147
false, NULL, NIL,

0 commit comments

Comments
 (0)
0