@@ -319,7 +319,7 @@ static uint64 CopyTo(CopyState cstate);
319
319
static void CopyOneRowTo (CopyState cstate ,
320
320
Datum * values , bool * nulls );
321
321
static void CopyFromInsertBatch (CopyState cstate , EState * estate ,
322
- CommandId mycid , int hi_options ,
322
+ CommandId mycid , int ti_options ,
323
323
ResultRelInfo * resultRelInfo , TupleTableSlot * myslot ,
324
324
BulkInsertState bistate ,
325
325
int nBufferedTuples , HeapTuple * bufferedTuples ,
@@ -2328,7 +2328,7 @@ CopyFrom(CopyState cstate)
2328
2328
PartitionTupleRouting * proute = NULL ;
2329
2329
ErrorContextCallback errcallback ;
2330
2330
CommandId mycid = GetCurrentCommandId (true);
2331
- int hi_options = 0 ; /* start with default heap_insert options */
2331
+ int ti_options = 0 ; /* start with default table_insert options */
2332
2332
BulkInsertState bistate ;
2333
2333
CopyInsertMethod insertMethod ;
2334
2334
uint64 processed = 0 ;
@@ -2392,8 +2392,8 @@ CopyFrom(CopyState cstate)
2392
2392
* - data is being written to relfilenode created in this transaction
2393
2393
* then we can skip writing WAL. It's safe because if the transaction
2394
2394
* doesn't commit, we'll discard the table (or the new relfilenode file).
2395
- * If it does commit, we'll have done the heap_sync at the bottom of this
2396
- * routine first.
2395
+ * If it does commit, we'll have done the table_finish_bulk_insert() at
2396
+ * the bottom of this routine first.
2397
2397
*
2398
2398
* As mentioned in comments in utils/rel.h, the in-same-transaction test
2399
2399
* is not always set correctly, since in rare cases rd_newRelfilenodeSubid
@@ -2437,9 +2437,9 @@ CopyFrom(CopyState cstate)
2437
2437
(cstate -> rel -> rd_createSubid != InvalidSubTransactionId ||
2438
2438
cstate -> rel -> rd_newRelfilenodeSubid != InvalidSubTransactionId ))
2439
2439
{
2440
- hi_options |= HEAP_INSERT_SKIP_FSM ;
2440
+ ti_options |= TABLE_INSERT_SKIP_FSM ;
2441
2441
if (!XLogIsNeeded ())
2442
- hi_options |= HEAP_INSERT_SKIP_WAL ;
2442
+ ti_options |= TABLE_INSERT_SKIP_WAL ;
2443
2443
}
2444
2444
2445
2445
/*
@@ -2491,7 +2491,7 @@ CopyFrom(CopyState cstate)
2491
2491
(errcode (ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE ),
2492
2492
errmsg ("cannot perform FREEZE because the table was not created or truncated in the current subtransaction" )));
2493
2493
2494
- hi_options |= HEAP_INSERT_FROZEN ;
2494
+ ti_options |= TABLE_INSERT_FROZEN ;
2495
2495
}
2496
2496
2497
2497
/*
@@ -2755,7 +2755,7 @@ CopyFrom(CopyState cstate)
2755
2755
{
2756
2756
MemoryContext oldcontext ;
2757
2757
2758
- CopyFromInsertBatch (cstate , estate , mycid , hi_options ,
2758
+ CopyFromInsertBatch (cstate , estate , mycid , ti_options ,
2759
2759
prevResultRelInfo , myslot , bistate ,
2760
2760
nBufferedTuples , bufferedTuples ,
2761
2761
firstBufferedLineNo );
@@ -2978,7 +2978,7 @@ CopyFrom(CopyState cstate)
2978
2978
if (nBufferedTuples == MAX_BUFFERED_TUPLES ||
2979
2979
bufferedTuplesSize > 65535 )
2980
2980
{
2981
- CopyFromInsertBatch (cstate , estate , mycid , hi_options ,
2981
+ CopyFromInsertBatch (cstate , estate , mycid , ti_options ,
2982
2982
resultRelInfo , myslot , bistate ,
2983
2983
nBufferedTuples , bufferedTuples ,
2984
2984
firstBufferedLineNo );
@@ -3015,7 +3015,7 @@ CopyFrom(CopyState cstate)
3015
3015
{
3016
3016
tuple = ExecFetchSlotHeapTuple (slot , true, NULL );
3017
3017
heap_insert (resultRelInfo -> ri_RelationDesc , tuple ,
3018
- mycid , hi_options , bistate );
3018
+ mycid , ti_options , bistate );
3019
3019
ItemPointerCopy (& tuple -> t_self , & slot -> tts_tid );
3020
3020
slot -> tts_tableOid = RelationGetRelid (resultRelInfo -> ri_RelationDesc );
3021
3021
}
@@ -3050,13 +3050,13 @@ CopyFrom(CopyState cstate)
3050
3050
{
3051
3051
if (insertMethod == CIM_MULTI_CONDITIONAL )
3052
3052
{
3053
- CopyFromInsertBatch (cstate , estate , mycid , hi_options ,
3053
+ CopyFromInsertBatch (cstate , estate , mycid , ti_options ,
3054
3054
prevResultRelInfo , myslot , bistate ,
3055
3055
nBufferedTuples , bufferedTuples ,
3056
3056
firstBufferedLineNo );
3057
3057
}
3058
3058
else
3059
- CopyFromInsertBatch (cstate , estate , mycid , hi_options ,
3059
+ CopyFromInsertBatch (cstate , estate , mycid , ti_options ,
3060
3060
resultRelInfo , myslot , bistate ,
3061
3061
nBufferedTuples , bufferedTuples ,
3062
3062
firstBufferedLineNo );
@@ -3106,12 +3106,7 @@ CopyFrom(CopyState cstate)
3106
3106
3107
3107
FreeExecutorState (estate );
3108
3108
3109
- /*
3110
- * If we skipped writing WAL, then we need to sync the heap (but not
3111
- * indexes since those use WAL anyway)
3112
- */
3113
- if (hi_options & HEAP_INSERT_SKIP_WAL )
3114
- heap_sync (cstate -> rel );
3109
+ table_finish_bulk_insert (cstate -> rel , ti_options );
3115
3110
3116
3111
return processed ;
3117
3112
}
@@ -3123,7 +3118,7 @@ CopyFrom(CopyState cstate)
3123
3118
*/
3124
3119
static void
3125
3120
CopyFromInsertBatch (CopyState cstate , EState * estate , CommandId mycid ,
3126
- int hi_options , ResultRelInfo * resultRelInfo ,
3121
+ int ti_options , ResultRelInfo * resultRelInfo ,
3127
3122
TupleTableSlot * myslot , BulkInsertState bistate ,
3128
3123
int nBufferedTuples , HeapTuple * bufferedTuples ,
3129
3124
uint64 firstBufferedLineNo )
@@ -3149,7 +3144,7 @@ CopyFromInsertBatch(CopyState cstate, EState *estate, CommandId mycid,
3149
3144
bufferedTuples ,
3150
3145
nBufferedTuples ,
3151
3146
mycid ,
3152
- hi_options ,
3147
+ ti_options ,
3153
3148
bistate );
3154
3149
MemoryContextSwitchTo (oldcontext );
3155
3150
0 commit comments