mirror of
https://github.com/postgres/postgres.git
synced 2025-07-21 16:02:15 +03:00
Revert MERGE patch
This reverts commitsd204ef6377
,83454e3c2b
and a few more commits thereafter (complete list at the end) related to MERGE feature. While the feature was fully functional, with sufficient test coverage and necessary documentation, it was felt that some parts of the executor and parse-analyzer can use a different design and it wasn't possible to do that in the available time. So it was decided to revert the patch for PG11 and retry again in the future. Thanks again to all reviewers and bug reporters. List of commits reverted, in reverse chronological order:f1464c5380
Improve parse representation for MERGEddb4158579
MERGE syntax diagram correction530e69e59b
Allow cpluspluscheck to pass by renaming variable01b88b4df5
MERGE minor errata3af7b2b0d4
MERGE fix variable warning in non-assert buildsa5d86181ec
MERGE INSERT allows only one VALUES clause4b2d44031f
MERGE post-commit review4923550c20
Tab completion for MERGEaa3faa3c7a
WITH support in MERGE83454e3c2b
New files for MERGEd204ef6377
MERGE SQL Command following SQL:2016 Author: Pavan Deolasee Reviewed-by: Michael Paquier
This commit is contained in:
@ -73,8 +73,6 @@ ExecSetupPartitionTupleRouting(ModifyTableState *mtstate, Relation rel)
|
||||
ResultRelInfo *update_rri = NULL;
|
||||
int num_update_rri = 0,
|
||||
update_rri_index = 0;
|
||||
bool is_update = false;
|
||||
bool is_merge = false;
|
||||
PartitionTupleRouting *proute;
|
||||
int nparts;
|
||||
ModifyTable *node = mtstate ? (ModifyTable *) mtstate->ps.plan : NULL;
|
||||
@ -97,22 +95,13 @@ ExecSetupPartitionTupleRouting(ModifyTableState *mtstate, Relation rel)
|
||||
|
||||
/* Set up details specific to the type of tuple routing we are doing. */
|
||||
if (node && node->operation == CMD_UPDATE)
|
||||
is_update = true;
|
||||
else if (node && node->operation == CMD_MERGE)
|
||||
is_merge = true;
|
||||
|
||||
if (is_update)
|
||||
{
|
||||
update_rri = mtstate->resultRelInfo;
|
||||
num_update_rri = list_length(node->plans);
|
||||
proute->subplan_partition_offsets =
|
||||
palloc(num_update_rri * sizeof(int));
|
||||
proute->num_subplan_partition_offsets = num_update_rri;
|
||||
}
|
||||
|
||||
|
||||
if (is_update || is_merge)
|
||||
{
|
||||
/*
|
||||
* We need an additional tuple slot for storing transient tuples that
|
||||
* are converted to the root table descriptor.
|
||||
@ -295,30 +284,6 @@ ExecFindPartition(ResultRelInfo *resultRelInfo, PartitionDispatch *pd,
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Given OID of the partition leaf, return the index of the leaf in the
|
||||
* partition hierarchy.
|
||||
*
|
||||
* XXX This is an O(N) operation and further optimization would be beneficial
|
||||
*/
|
||||
int
|
||||
ExecFindPartitionByOid(PartitionTupleRouting *proute, Oid partoid)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < proute->num_partitions; i++)
|
||||
{
|
||||
if (proute->partition_oids[i] == partoid)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i >= proute->num_partitions)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INTERNAL_ERROR),
|
||||
errmsg("no partition found for OID %u", partoid)));
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
* ExecInitPartitionInfo
|
||||
* Initialize ResultRelInfo and other information for a partition if not
|
||||
@ -357,8 +322,6 @@ ExecInitPartitionInfo(ModifyTableState *mtstate,
|
||||
rootrel,
|
||||
estate->es_instrument);
|
||||
|
||||
leaf_part_rri->ri_PartitionLeafIndex = partidx;
|
||||
|
||||
/*
|
||||
* Since we've just initialized this ResultRelInfo, it's not in any list
|
||||
* attached to the estate as yet. Add it, so that it can be found later.
|
||||
@ -635,90 +598,6 @@ ExecInitPartitionInfo(ModifyTableState *mtstate,
|
||||
Assert(proute->partitions[partidx] == NULL);
|
||||
proute->partitions[partidx] = leaf_part_rri;
|
||||
|
||||
/*
|
||||
* Initialize information about this partition that's needed to handle
|
||||
* MERGE.
|
||||
*/
|
||||
if (node && node->operation == CMD_MERGE)
|
||||
{
|
||||
TupleDesc partrelDesc = RelationGetDescr(partrel);
|
||||
TupleConversionMap *map = proute->parent_child_tupconv_maps[partidx];
|
||||
int firstVarno = mtstate->resultRelInfo[0].ri_RangeTableIndex;
|
||||
Relation firstResultRel = mtstate->resultRelInfo[0].ri_RelationDesc;
|
||||
|
||||
/*
|
||||
* If the root parent and partition have the same tuple
|
||||
* descriptor, just reuse the original MERGE state for partition.
|
||||
*/
|
||||
if (map == NULL)
|
||||
{
|
||||
leaf_part_rri->ri_mergeState = resultRelInfo->ri_mergeState;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Convert expressions contain partition's attnos. */
|
||||
List *conv_tl, *conv_qual;
|
||||
ListCell *l;
|
||||
List *matchedActionStates = NIL;
|
||||
List *notMatchedActionStates = NIL;
|
||||
|
||||
foreach (l, node->mergeActionList)
|
||||
{
|
||||
MergeAction *action = lfirst_node(MergeAction, l);
|
||||
MergeActionState *action_state = makeNode(MergeActionState);
|
||||
TupleDesc tupDesc;
|
||||
ExprContext *econtext;
|
||||
|
||||
action_state->matched = action->matched;
|
||||
action_state->commandType = action->commandType;
|
||||
|
||||
conv_qual = (List *) action->qual;
|
||||
conv_qual = map_partition_varattnos(conv_qual,
|
||||
firstVarno, partrel,
|
||||
firstResultRel, NULL);
|
||||
|
||||
action_state->whenqual = ExecInitQual(conv_qual, &mtstate->ps);
|
||||
|
||||
conv_tl = (List *) action->targetList;
|
||||
conv_tl = map_partition_varattnos(conv_tl,
|
||||
firstVarno, partrel,
|
||||
firstResultRel, NULL);
|
||||
|
||||
conv_tl = adjust_partition_tlist( conv_tl, map);
|
||||
|
||||
tupDesc = ExecTypeFromTL(conv_tl, partrelDesc->tdhasoid);
|
||||
action_state->tupDesc = tupDesc;
|
||||
|
||||
/* build action projection state */
|
||||
econtext = mtstate->ps.ps_ExprContext;
|
||||
action_state->proj =
|
||||
ExecBuildProjectionInfo(conv_tl, econtext,
|
||||
mtstate->mt_mergeproj,
|
||||
&mtstate->ps,
|
||||
partrelDesc);
|
||||
|
||||
if (action_state->matched)
|
||||
matchedActionStates =
|
||||
lappend(matchedActionStates, action_state);
|
||||
else
|
||||
notMatchedActionStates =
|
||||
lappend(notMatchedActionStates, action_state);
|
||||
}
|
||||
leaf_part_rri->ri_mergeState->matchedActionStates =
|
||||
matchedActionStates;
|
||||
leaf_part_rri->ri_mergeState->notMatchedActionStates =
|
||||
notMatchedActionStates;
|
||||
}
|
||||
|
||||
/*
|
||||
* get_partition_dispatch_recurse() and expand_partitioned_rtentry()
|
||||
* fetch the leaf OIDs in the same order. So we can safely derive the
|
||||
* index of the merge target relation corresponding to this partition
|
||||
* by simply adding partidx + 1 to the root's merge target relation.
|
||||
*/
|
||||
leaf_part_rri->ri_mergeTargetRTI = node->mergeTargetRelation +
|
||||
partidx + 1;
|
||||
}
|
||||
MemoryContextSwitchTo(oldContext);
|
||||
|
||||
return leaf_part_rri;
|
||||
|
Reference in New Issue
Block a user