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

Commit345b2dc

Browse files
committed
Move partition_tuple_slot out of EState.
Commit2ac3ef7 added a TupleTapleSlotfor partition tuple slot to EState (es_partition_tuple_slot) but it'smore logical to have it as part of ModifyTableState(mt_partition_tuple_slot) and CopyState (partition_tuple_slot).Discussion:http://postgr.es/m/1bd459d9-4c0c-197a-346e-e5e59e217d97@lab.ntt.co.jpAmit Langote, per a gripe from me
1 parent6667d9a commit345b2dc

File tree

5 files changed

+35
-25
lines changed

5 files changed

+35
-25
lines changed

‎src/backend/commands/copy.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,14 @@ typedef struct CopyStateData
161161
ExprState**defexprs;/* array of default att expressions */
162162
boolvolatile_defexprs;/* is any of defexprs volatile? */
163163
List*range_table;
164+
164165
PartitionDispatch*partition_dispatch_info;
165-
intnum_dispatch;
166-
intnum_partitions;
167-
ResultRelInfo*partitions;
166+
intnum_dispatch;/* Number of entries in the above array */
167+
intnum_partitions;/* Number of members in the following
168+
* arrays */
169+
ResultRelInfo*partitions;/* Per partition result relation */
168170
TupleConversionMap**partition_tupconv_maps;
171+
TupleTableSlot*partition_tuple_slot;
169172

170173
/*
171174
* These variables are used to reduce overhead in textual COPY FROM.
@@ -1409,19 +1412,22 @@ BeginCopy(ParseState *pstate,
14091412
PartitionDispatch*partition_dispatch_info;
14101413
ResultRelInfo*partitions;
14111414
TupleConversionMap**partition_tupconv_maps;
1415+
TupleTableSlot*partition_tuple_slot;
14121416
intnum_parted,
14131417
num_partitions;
14141418

14151419
ExecSetupPartitionTupleRouting(rel,
14161420
&partition_dispatch_info,
14171421
&partitions,
14181422
&partition_tupconv_maps,
1423+
&partition_tuple_slot,
14191424
&num_parted,&num_partitions);
14201425
cstate->partition_dispatch_info=partition_dispatch_info;
14211426
cstate->num_dispatch=num_parted;
14221427
cstate->partitions=partitions;
14231428
cstate->num_partitions=num_partitions;
14241429
cstate->partition_tupconv_maps=partition_tupconv_maps;
1430+
cstate->partition_tuple_slot=partition_tuple_slot;
14251431
}
14261432
}
14271433
else
@@ -2435,15 +2441,6 @@ CopyFrom(CopyState cstate)
24352441
/* Triggers might need a slot as well */
24362442
estate->es_trig_tuple_slot=ExecInitExtraTupleSlot(estate);
24372443

2438-
/*
2439-
* Initialize a dedicated slot to manipulate tuples of any given
2440-
* partition's rowtype.
2441-
*/
2442-
if (cstate->partition_dispatch_info)
2443-
estate->es_partition_tuple_slot=ExecInitExtraTupleSlot(estate);
2444-
else
2445-
estate->es_partition_tuple_slot=NULL;
2446-
24472444
/*
24482445
* It's more efficient to prepare a bunch of tuples for insertion, and
24492446
* insert them in one heap_multi_insert() call, than call heap_insert()
@@ -2591,7 +2588,7 @@ CopyFrom(CopyState cstate)
25912588
* we're finished dealing with the partition.
25922589
*/
25932590
oldslot=slot;
2594-
slot=estate->es_partition_tuple_slot;
2591+
slot=cstate->partition_tuple_slot;
25952592
Assert(slot!=NULL);
25962593
ExecSetSlotDescriptor(slot,RelationGetDescr(partrel));
25972594
ExecStoreTuple(tuple,slot,InvalidBuffer, true);
@@ -2756,6 +2753,9 @@ CopyFrom(CopyState cstate)
27562753
ExecCloseIndices(resultRelInfo);
27572754
heap_close(resultRelInfo->ri_RelationDesc,NoLock);
27582755
}
2756+
2757+
/* Release the standalone partition tuple descriptor */
2758+
ExecDropSingleTupleTableSlot(cstate->partition_tuple_slot);
27592759
}
27602760

27612761
FreeExecutorState(estate);

‎src/backend/executor/execMain.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3012,6 +3012,9 @@ EvalPlanQualEnd(EPQState *epqstate)
30123012
*entry for every leaf partition (required to convert input tuple based
30133013
*on the root table's rowtype to a leaf partition's rowtype after tuple
30143014
*routing is done
3015+
* 'partition_tuple_slot' receives a standalone TupleTableSlot to be used
3016+
*to manipulate any given leaf partition's rowtype after that partition
3017+
*is chosen by tuple-routing.
30153018
* 'num_parted' receives the number of partitioned tables in the partition
30163019
*tree (= the number of entries in the 'pd' output array)
30173020
* 'num_partitions' receives the number of leaf partitions in the partition
@@ -3026,6 +3029,7 @@ ExecSetupPartitionTupleRouting(Relation rel,
30263029
PartitionDispatch**pd,
30273030
ResultRelInfo**partitions,
30283031
TupleConversionMap***tup_conv_maps,
3032+
TupleTableSlot**partition_tuple_slot,
30293033
int*num_parted,int*num_partitions)
30303034
{
30313035
TupleDesctupDesc=RelationGetDescr(rel);
@@ -3043,6 +3047,14 @@ ExecSetupPartitionTupleRouting(Relation rel,
30433047
*tup_conv_maps= (TupleConversionMap**)palloc0(*num_partitions*
30443048
sizeof(TupleConversionMap*));
30453049

3050+
/*
3051+
* Initialize an empty slot that will be used to manipulate tuples of any
3052+
* given partition's rowtype. It is attached to the caller-specified node
3053+
* (such as ModifyTableState) and released when the node finishes
3054+
* processing.
3055+
*/
3056+
*partition_tuple_slot=MakeTupleTableSlot();
3057+
30463058
leaf_part_rri=*partitions;
30473059
i=0;
30483060
foreach(cell,leaf_parts)

‎src/backend/executor/nodeModifyTable.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ ExecInsert(ModifyTableState *mtstate,
329329
* Use the dedicated slot for that.
330330
*/
331331
oldslot=slot;
332-
slot=estate->es_partition_tuple_slot;
332+
slot=mtstate->mt_partition_tuple_slot;
333333
Assert(slot!=NULL);
334334
ExecSetSlotDescriptor(slot,RelationGetDescr(partrel));
335335
ExecStoreTuple(tuple,slot,InvalidBuffer, true);
@@ -1738,28 +1738,23 @@ ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags)
17381738
PartitionDispatch*partition_dispatch_info;
17391739
ResultRelInfo*partitions;
17401740
TupleConversionMap**partition_tupconv_maps;
1741+
TupleTableSlot*partition_tuple_slot;
17411742
intnum_parted,
17421743
num_partitions;
17431744

17441745
ExecSetupPartitionTupleRouting(rel,
17451746
&partition_dispatch_info,
17461747
&partitions,
17471748
&partition_tupconv_maps,
1749+
&partition_tuple_slot,
17481750
&num_parted,&num_partitions);
17491751
mtstate->mt_partition_dispatch_info=partition_dispatch_info;
17501752
mtstate->mt_num_dispatch=num_parted;
17511753
mtstate->mt_partitions=partitions;
17521754
mtstate->mt_num_partitions=num_partitions;
17531755
mtstate->mt_partition_tupconv_maps=partition_tupconv_maps;
1754-
1755-
/*
1756-
* Initialize a dedicated slot to manipulate tuples of any given
1757-
* partition's rowtype.
1758-
*/
1759-
estate->es_partition_tuple_slot=ExecInitExtraTupleSlot(estate);
1756+
mtstate->mt_partition_tuple_slot=partition_tuple_slot;
17601757
}
1761-
else
1762-
estate->es_partition_tuple_slot=NULL;
17631758

17641759
/*
17651760
* Initialize any WITH CHECK OPTION constraints if needed.
@@ -2100,6 +2095,10 @@ ExecEndModifyTable(ModifyTableState *node)
21002095
heap_close(resultRelInfo->ri_RelationDesc,NoLock);
21012096
}
21022097

2098+
/* Release the standalone partition tuple descriptor, if any */
2099+
if (node->mt_partition_tuple_slot)
2100+
ExecDropSingleTupleTableSlot(node->mt_partition_tuple_slot);
2101+
21032102
/*
21042103
* Free the exprcontext
21052104
*/

‎src/include/executor/executor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ extern void ExecSetupPartitionTupleRouting(Relation rel,
217217
PartitionDispatch**pd,
218218
ResultRelInfo**partitions,
219219
TupleConversionMap***tup_conv_maps,
220+
TupleTableSlot**partition_tuple_slot,
220221
int*num_parted,int*num_partitions);
221222
externintExecFindPartition(ResultRelInfo*resultRelInfo,
222223
PartitionDispatch*pd,

‎src/include/nodes/execnodes.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,6 @@ typedef struct EState
384384
TupleTableSlot*es_trig_oldtup_slot;/* for TriggerEnabled */
385385
TupleTableSlot*es_trig_newtup_slot;/* for TriggerEnabled */
386386

387-
/* Slot used to manipulate a tuple after it is routed to a partition */
388-
TupleTableSlot*es_partition_tuple_slot;
389-
390387
/* Parameter info: */
391388
ParamListInfoes_param_list_info;/* values of external params */
392389
ParamExecData*es_param_exec_vals;/* values of internal params */
@@ -1165,6 +1162,7 @@ typedef struct ModifyTableState
11651162
ResultRelInfo*mt_partitions;/* Per partition result relation */
11661163
TupleConversionMap**mt_partition_tupconv_maps;
11671164
/* Per partition tuple conversion map */
1165+
TupleTableSlot*mt_partition_tuple_slot;
11681166
}ModifyTableState;
11691167

11701168
/* ----------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp