Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitda841aa

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

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(Relationrelation,TupleTableSlot**slots,intntuples,
2260-
CommandIdcid,intoptions,BulkInsertStatebistate,
2261-
bool*insert_indexes)
2260+
CommandIdcid,intoptions,BulkInsertStatebistate)
22622261
{
22632262
TransactionIdxid=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
staticTupleTableSlot*
247247
heapam_tuple_insert(Relationrelation,TupleTableSlot*slot,CommandIdcid,
248-
intoptions,BulkInsertStatebistate,bool*insert_indexes)
248+
intoptions,BulkInsertStatebistate)
249249
{
250250
boolshouldFree= true;
251251
HeapTupletuple=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
returnslot;
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(Relationrel,TupleTableSlot*slot,
277-
bool*insert_indexes)
276+
simple_table_tuple_insert(Relationrel,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(RelationheapRel,TupleTableSlot**slot,
274274
intntuples,CatalogIndexStateindstate)
275275
{
276-
boolinsertIndexes;
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
boolline_buf_valid=cstate->line_buf_valid;
396396
uint64save_cur_lineno=cstate->cur_lineno;
397397
MemoryContextoldcontext;
398-
boolinsertIndexes;
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-
boolinsertIndexes;
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-
boolinsertIndexes;
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-
boolinsertIndexes;
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-
boolinsertIndexes;
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
boolfound = false;
21040-
boolinsert_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-
boolinsert_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-
boolinsertIndexes;
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-
boolinsertIndexes;
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,

‎src/include/access/heapam.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ extern void heap_insert(Relation relation, HeapTuple tup, CommandId cid,
320320
intoptions,BulkInsertStatebistate);
321321
externvoidheap_multi_insert(Relationrelation,structTupleTableSlot**slots,
322322
intntuples,CommandIdcid,intoptions,
323-
BulkInsertStatebistate,bool*insert_indexes);
323+
BulkInsertStatebistate);
324324
externTM_Resultheap_delete(Relationrelation,ItemPointertid,
325325
CommandIdcid,Snapshotcrosscheck,intoptions,
326326
structTM_FailureData*tmfd,boolchangingPart,

‎src/include/access/tableam.h

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,7 @@ typedef struct TableAmRoutine
519519
/* see table_tuple_insert() for reference about parameters */
520520
TupleTableSlot*(*tuple_insert) (Relationrel,TupleTableSlot*slot,
521521
CommandIdcid,intoptions,
522-
structBulkInsertStateData*bistate,
523-
bool*insert_indexes);
522+
structBulkInsertStateData*bistate);
524523

525524
/* see table_tuple_insert_speculative() for reference about parameters */
526525
void(*tuple_insert_speculative) (Relationrel,
@@ -538,8 +537,7 @@ typedef struct TableAmRoutine
538537

539538
/* see table_multi_insert() for reference about parameters */
540539
void(*multi_insert) (Relationrel,TupleTableSlot**slots,intnslots,
541-
CommandIdcid,intoptions,structBulkInsertStateData*bistate,
542-
bool*insert_indexes);
540+
CommandIdcid,intoptions,structBulkInsertStateData*bistate);
543541

544542
/* see table_tuple_delete() for reference about parameters */
545543
TM_Result(*tuple_delete) (Relationrel,
@@ -1387,12 +1385,6 @@ table_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
13871385
* behavior) is also just passed through to RelationGetBufferForTuple. If
13881386
* `bistate` is provided, table_finish_bulk_insert() needs to be called.
13891387
*
1390-
* The table AM's implementation of tuple_insert should set `*insert_indexes`
1391-
* to true if it expects the caller to insert the relevant index tuples
1392-
* (as heap table AM does). It should set `*insert_indexes` to false if
1393-
* it cares about index inserts itself and doesn't want the caller to do
1394-
* index inserts.
1395-
*
13961388
* Returns the slot containing the inserted tuple, which may differ from the
13971389
* given slot. For instance, the source slot may be VirtualTupleTableSlot, but
13981390
* the result slot may correspond to the table AM. On return the slot's
@@ -1402,11 +1394,10 @@ table_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
14021394
*/
14031395
staticinlineTupleTableSlot*
14041396
table_tuple_insert(Relationrel,TupleTableSlot*slot,CommandIdcid,
1405-
intoptions,structBulkInsertStateData*bistate,
1406-
bool*insert_indexes)
1397+
intoptions,structBulkInsertStateData*bistate)
14071398
{
14081399
returnrel->rd_tableam->tuple_insert(rel,slot,cid,options,
1409-
bistate,insert_indexes);
1400+
bistate);
14101401
}
14111402

14121403
/*
@@ -1458,11 +1449,10 @@ table_tuple_complete_speculative(Relation rel, TupleTableSlot *slot,
14581449
*/
14591450
staticinlinevoid
14601451
table_multi_insert(Relationrel,TupleTableSlot**slots,intnslots,
1461-
CommandIdcid,intoptions,structBulkInsertStateData*bistate,
1462-
bool*insert_indexes)
1452+
CommandIdcid,intoptions,structBulkInsertStateData*bistate)
14631453
{
14641454
rel->rd_tableam->multi_insert(rel,slots,nslots,
1465-
cid,options,bistate,insert_indexes);
1455+
cid,options,bistate);
14661456
}
14671457

14681458
/*
@@ -2087,8 +2077,7 @@ table_scan_sample_next_tuple(TableScanDesc scan,
20872077
* ----------------------------------------------------------------------------
20882078
*/
20892079

2090-
externvoidsimple_table_tuple_insert(Relationrel,TupleTableSlot*slot,
2091-
bool*insert_indexes);
2080+
externvoidsimple_table_tuple_insert(Relationrel,TupleTableSlot*slot);
20922081
externvoidsimple_table_tuple_delete(Relationrel,ItemPointertid,
20932082
Snapshotsnapshot,
20942083
TupleTableSlot*oldSlot);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp