@@ -92,9 +92,9 @@ get_chunk_dispatch_state(PlanState *substate)
92
92
* the ModifyTableState node whenever it inserts into a new chunk.
93
93
*/
94
94
static void
95
- hypertable_modify_begin (CustomScanState * node , EState * estate , int eflags )
95
+ modify_hypertable_begin (CustomScanState * node , EState * estate , int eflags )
96
96
{
97
- HypertableModifyState * state = (HypertableModifyState * ) node ;
97
+ ModifyHypertableState * state = (ModifyHypertableState * ) node ;
98
98
ModifyTableState * mtstate ;
99
99
PlanState * ps ;
100
100
@@ -116,7 +116,7 @@ hypertable_modify_begin(CustomScanState *node, EState *estate, int eflags)
116
116
* Unfortunately that strips off the HypertableInsert node leading to
117
117
* tuple routing not working in INSERTs inside CTEs. To make INSERTs
118
118
* inside CTEs work we have to fix es_auxmodifytables and add back the
119
- * HypertableModifyState .
119
+ * ModifyHypertableState .
120
120
*/
121
121
if (estate -> es_auxmodifytables && linitial (estate -> es_auxmodifytables ) == mtstate )
122
122
linitial (estate -> es_auxmodifytables ) = node ;
@@ -140,28 +140,28 @@ hypertable_modify_begin(CustomScanState *node, EState *estate, int eflags)
140
140
}
141
141
142
142
static TupleTableSlot *
143
- hypertable_modify_exec (CustomScanState * node )
143
+ modify_hypertable_exec (CustomScanState * node )
144
144
{
145
145
ModifyTableState * mtstate = linitial_node (ModifyTableState , node -> custom_ps );
146
146
return ExecModifyTable (node , & mtstate -> ps );
147
147
}
148
148
149
149
static void
150
- hypertable_modify_end (CustomScanState * node )
150
+ modify_hypertable_end (CustomScanState * node )
151
151
{
152
152
ExecEndNode (linitial (node -> custom_ps ));
153
153
}
154
154
155
155
static void
156
- hypertable_modify_rescan (CustomScanState * node )
156
+ modify_hypertable_rescan (CustomScanState * node )
157
157
{
158
158
ExecReScan (linitial (node -> custom_ps ));
159
159
}
160
160
161
161
static void
162
- hypertable_modify_explain (CustomScanState * node , List * ancestors , ExplainState * es )
162
+ modify_hypertable_explain (CustomScanState * node , List * ancestors , ExplainState * es )
163
163
{
164
- HypertableModifyState * state = (HypertableModifyState * ) node ;
164
+ ModifyHypertableState * state = (ModifyHypertableState * ) node ;
165
165
ModifyTableState * mtstate = linitial_node (ModifyTableState , node -> custom_ps );
166
166
167
167
/*
@@ -183,13 +183,13 @@ hypertable_modify_explain(CustomScanState *node, List *ancestors, ExplainState *
183
183
}
184
184
/*
185
185
* Since we hijack the ModifyTable node, instrumentation on ModifyTable will
186
- * be missing so we set it to instrumentation of HypertableModify node.
186
+ * be missing so we set it to instrumentation of ModifyHypertable node.
187
187
*/
188
188
if (mtstate -> ps .instrument )
189
189
{
190
190
/*
191
191
* INSERT .. ON CONFLICT statements record few metrics in the ModifyTable node.
192
- * So, copy them into HypertableModify node before replacing them.
192
+ * So, copy them into ModifyHypertable node before replacing them.
193
193
*/
194
194
node -> ss .ps .instrument -> ntuples2 = mtstate -> ps .instrument -> ntuples2 ;
195
195
node -> ss .ps .instrument -> nfiltered1 = mtstate -> ps .instrument -> nfiltered1 ;
@@ -220,32 +220,32 @@ hypertable_modify_explain(CustomScanState *node, List *ancestors, ExplainState *
220
220
ExplainPropertyInteger ("Batches deleted" , NULL , state -> batches_deleted , es );
221
221
}
222
222
223
- static CustomExecMethods hypertable_modify_state_methods = {
224
- .CustomName = "HypertableModifyState " ,
225
- .BeginCustomScan = hypertable_modify_begin ,
226
- .EndCustomScan = hypertable_modify_end ,
227
- .ExecCustomScan = hypertable_modify_exec ,
228
- .ReScanCustomScan = hypertable_modify_rescan ,
229
- .ExplainCustomScan = hypertable_modify_explain ,
223
+ static CustomExecMethods modify_hypertable_state_methods = {
224
+ .CustomName = "ModifyHypertableState " ,
225
+ .BeginCustomScan = modify_hypertable_begin ,
226
+ .EndCustomScan = modify_hypertable_end ,
227
+ .ExecCustomScan = modify_hypertable_exec ,
228
+ .ReScanCustomScan = modify_hypertable_rescan ,
229
+ .ExplainCustomScan = modify_hypertable_explain ,
230
230
};
231
231
232
232
static Node *
233
- hypertable_modify_state_create (CustomScan * cscan )
233
+ modify_hypertable_state_create (CustomScan * cscan )
234
234
{
235
- HypertableModifyState * state ;
235
+ ModifyHypertableState * state ;
236
236
ModifyTable * mt = castNode (ModifyTable , linitial (cscan -> custom_plans ));
237
237
238
- state = (HypertableModifyState * ) newNode (sizeof (HypertableModifyState ), T_CustomScanState );
239
- state -> cscan_state .methods = & hypertable_modify_state_methods ;
238
+ state = (ModifyHypertableState * ) newNode (sizeof (ModifyHypertableState ), T_CustomScanState );
239
+ state -> cscan_state .methods = & modify_hypertable_state_methods ;
240
240
state -> mt = mt ;
241
241
state -> mt -> arbiterIndexes = linitial (cscan -> custom_private );
242
242
243
243
return (Node * ) state ;
244
244
}
245
245
246
- static CustomScanMethods hypertable_modify_plan_methods = {
247
- .CustomName = "HypertableModify " ,
248
- .CreateCustomScanState = hypertable_modify_state_create ,
246
+ static CustomScanMethods modify_hypertable_plan_methods = {
247
+ .CustomName = "ModifyHypertable " ,
248
+ .CreateCustomScanState = modify_hypertable_state_create ,
249
249
};
250
250
251
251
/*
@@ -290,13 +290,13 @@ make_var_targetlist(const List *tlist)
290
290
* set_plan_references().
291
291
*/
292
292
void
293
- ts_hypertable_modify_fixup_tlist (Plan * plan )
293
+ ts_modify_hypertable_fixup_tlist (Plan * plan )
294
294
{
295
295
if (IsA (plan , CustomScan ))
296
296
{
297
297
CustomScan * cscan = (CustomScan * ) plan ;
298
298
299
- if (cscan -> methods == & hypertable_modify_plan_methods )
299
+ if (cscan -> methods == & modify_hypertable_plan_methods )
300
300
{
301
301
ModifyTable * mt = linitial_node (ModifyTable , cscan -> custom_plans );
302
302
@@ -344,13 +344,13 @@ ts_replace_rowid_vars(PlannerInfo *root, List *tlist, int varno)
344
344
}
345
345
346
346
static Plan *
347
- hypertable_modify_plan_create (PlannerInfo * root , RelOptInfo * rel , CustomPath * best_path ,
347
+ modify_hypertable_plan_create (PlannerInfo * root , RelOptInfo * rel , CustomPath * best_path ,
348
348
List * tlist , List * clauses , List * custom_plans )
349
349
{
350
350
CustomScan * cscan = makeNode (CustomScan );
351
351
ModifyTable * mt = linitial_node (ModifyTable , custom_plans );
352
352
353
- cscan -> methods = & hypertable_modify_plan_methods ;
353
+ cscan -> methods = & modify_hypertable_plan_methods ;
354
354
cscan -> custom_plans = custom_plans ;
355
355
cscan -> scan .scanrelid = 0 ;
356
356
@@ -427,19 +427,19 @@ hypertable_modify_plan_create(PlannerInfo *root, RelOptInfo *rel, CustomPath *be
427
427
return & cscan -> scan .plan ;
428
428
}
429
429
430
- static CustomPathMethods hypertable_modify_path_methods = {
431
- .CustomName = "HypertableModifyPath " ,
432
- .PlanCustomPath = hypertable_modify_plan_create ,
430
+ static CustomPathMethods modify_hypertable_path_methods = {
431
+ .CustomName = "ModifyHypertablePath " ,
432
+ .PlanCustomPath = modify_hypertable_plan_create ,
433
433
};
434
434
435
435
Path *
436
- ts_hypertable_modify_path_create (PlannerInfo * root , ModifyTablePath * mtpath , Hypertable * ht ,
436
+ ts_modify_hypertable_path_create (PlannerInfo * root , ModifyTablePath * mtpath , Hypertable * ht ,
437
437
RelOptInfo * rel )
438
438
{
439
439
Path * path = & mtpath -> path ;
440
440
Path * subpath = NULL ;
441
441
Cache * hcache = ts_hypertable_cache_pin ();
442
- HypertableModifyPath * hmpath ;
442
+ ModifyHypertablePath * hmpath ;
443
443
int i = 0 ;
444
444
445
445
/* PG14 only copies child rows and width if returningLists is not
@@ -459,14 +459,14 @@ ts_hypertable_modify_path_create(PlannerInfo *root, ModifyTablePath *mtpath, Hyp
459
459
subpath = ts_chunk_dispatch_path_create (root , mtpath , rti , i );
460
460
}
461
461
462
- hmpath = palloc0 (sizeof (HypertableModifyPath ));
462
+ hmpath = palloc0 (sizeof (ModifyHypertablePath ));
463
463
464
464
/* Copy costs, etc. */
465
465
memcpy (& hmpath -> cpath .path , path , sizeof (Path ));
466
466
hmpath -> cpath .path .type = T_CustomPath ;
467
467
hmpath -> cpath .path .pathtype = T_CustomScan ;
468
468
hmpath -> cpath .custom_paths = list_make1 (mtpath );
469
- hmpath -> cpath .methods = & hypertable_modify_path_methods ;
469
+ hmpath -> cpath .methods = & modify_hypertable_path_methods ;
470
470
path = & hmpath -> cpath .path ;
471
471
if (subpath )
472
472
mtpath -> subpath = subpath ;
@@ -476,22 +476,6 @@ ts_hypertable_modify_path_create(PlannerInfo *root, ModifyTablePath *mtpath, Hyp
476
476
return path ;
477
477
}
478
478
479
- /*
480
- * Callback for ModifyTableState->GetUpdateNewTuple for use by regular UPDATE.
481
- */
482
- static TupleTableSlot *
483
- internalGetUpdateNewTuple (ResultRelInfo * relinfo , TupleTableSlot * planSlot , TupleTableSlot * oldSlot ,
484
- MergeActionState * relaction )
485
- {
486
- ProjectionInfo * newProj = relinfo -> ri_projectNew ;
487
- ExprContext * econtext ;
488
-
489
- econtext = newProj -> pi_exprContext ;
490
- econtext -> ecxt_outertuple = planSlot ;
491
- econtext -> ecxt_scantuple = oldSlot ;
492
- return ExecProject (newProj );
493
- }
494
-
495
479
/* ----------------------------------------------------------------
496
480
* ExecModifyTable
497
481
*
@@ -504,7 +488,7 @@ internalGetUpdateNewTuple(ResultRelInfo *relinfo, TupleTableSlot *planSlot, Tupl
504
488
static TupleTableSlot *
505
489
ExecModifyTable (CustomScanState * cs_node , PlanState * pstate )
506
490
{
507
- HypertableModifyState * ht_state = (HypertableModifyState * ) cs_node ;
491
+ ModifyHypertableState * ht_state = (ModifyHypertableState * ) cs_node ;
508
492
ModifyTableState * node = castNode (ModifyTableState , pstate );
509
493
ModifyTableContext context ;
510
494
EState * estate = node -> ps .state ;
@@ -893,8 +877,7 @@ ExecModifyTable(CustomScanState *cs_node, PlanState *pstate)
893
877
if (!table_tuple_fetch_row_version (relation , tupleid , SnapshotAny , oldSlot ))
894
878
elog (ERROR , "failed to fetch tuple being updated" );
895
879
}
896
- slot = internalGetUpdateNewTuple (resultRelInfo , context .planSlot , oldSlot , NULL );
897
- context .GetUpdateNewTuple = internalGetUpdateNewTuple ;
880
+ slot = ExecGetUpdateNewTuple (resultRelInfo , context .planSlot , oldSlot );
898
881
context .relaction = NULL ;
899
882
/* Now apply the update. */
900
883
slot =
@@ -1320,26 +1303,6 @@ ExecGetInsertNewTuple(ResultRelInfo *relinfo, TupleTableSlot *planSlot)
1320
1303
return ExecProject (newProj );
1321
1304
}
1322
1305
1323
- /*
1324
- * ExecGetUpdateNewTuple
1325
- * This prepares a "new" tuple by combining an UPDATE subplan's output
1326
- * tuple (which contains values of changed columns) with unchanged
1327
- * columns taken from the old tuple.
1328
- *
1329
- * The subplan tuple might also contain junk columns, which are ignored.
1330
- * Note that the projection also ensures we have a slot of the right type.
1331
- */
1332
- TupleTableSlot *
1333
- ExecGetUpdateNewTuple (ResultRelInfo * relinfo , TupleTableSlot * planSlot , TupleTableSlot * oldSlot )
1334
- {
1335
- /* Use a few extra Asserts to protect against outside callers */
1336
- Assert (relinfo -> ri_projectNewInfoValid );
1337
- Assert (planSlot != NULL && !TTS_EMPTY (planSlot ));
1338
- Assert (oldSlot != NULL && !TTS_EMPTY (oldSlot ));
1339
-
1340
- return internalGetUpdateNewTuple (relinfo , planSlot , oldSlot , NULL );
1341
- }
1342
-
1343
1306
/* ----------------------------------------------------------------
1344
1307
* ExecInsert
1345
1308
*
0 commit comments