MemoryContext oldContext;
AttrNumber *part_attnos = NULL;
bool found_whole_row;
- bool equalTupdescs;
/*
* We locked all the partitions in ExecSetupPartitionTupleRouting
(node != NULL &&
node->onConflictAction != ONCONFLICT_NONE));
- /* if tuple descs are identical, we don't need to map the attrs */
- equalTupdescs = equalTupleDescs(RelationGetDescr(partrel),
- RelationGetDescr(firstResultRel));
-
/*
* Build WITH CHECK OPTION constraints for the partition. Note that we
* didn't build the withCheckOptionList for partitions within the planner,
/*
* Convert Vars in it to contain this partition's attribute numbers.
*/
- if (!equalTupdescs)
- {
- part_attnos =
- convert_tuples_by_name_map(RelationGetDescr(partrel),
- RelationGetDescr(firstResultRel),
- gettext_noop("could not convert row type"));
- wcoList = (List *)
- map_variable_attnos((Node *) wcoList,
- firstVarno, 0,
- part_attnos,
- RelationGetDescr(firstResultRel)->natts,
- RelationGetForm(partrel)->reltype,
- &found_whole_row);
- /* We ignore the value of found_whole_row. */
- }
+ part_attnos =
+ convert_tuples_by_name_map(RelationGetDescr(partrel),
+ RelationGetDescr(firstResultRel),
+ gettext_noop("could not convert row type"));
+ wcoList = (List *)
+ map_variable_attnos((Node *) wcoList,
+ firstVarno, 0,
+ part_attnos,
+ RelationGetDescr(firstResultRel)->natts,
+ RelationGetForm(partrel)->reltype,
+ &found_whole_row);
+ /* We ignore the value of found_whole_row. */
foreach(ll, wcoList)
{
*/
returningList = linitial(node->returningLists);
- if (!equalTupdescs)
- {
- /*
- * Convert Vars in it to contain this partition's attribute numbers.
- */
- if (part_attnos == NULL)
- part_attnos =
- convert_tuples_by_name_map(RelationGetDescr(partrel),
- RelationGetDescr(firstResultRel),
- gettext_noop("could not convert row type"));
- returningList = (List *)
- map_variable_attnos((Node *) returningList,
- firstVarno, 0,
- part_attnos,
- RelationGetDescr(firstResultRel)->natts,
- RelationGetForm(partrel)->reltype,
- &found_whole_row);
- /* We ignore the value of found_whole_row. */
- }
+ /*
+ * Convert Vars in it to contain this partition's attribute numbers.
+ */
+ if (part_attnos == NULL)
+ part_attnos =
+ convert_tuples_by_name_map(RelationGetDescr(partrel),
+ RelationGetDescr(firstResultRel),
+ gettext_noop("could not convert row type"));
+ returningList = (List *)
+ map_variable_attnos((Node *) returningList,
+ firstVarno, 0,
+ part_attnos,
+ RelationGetDescr(firstResultRel)->natts,
+ RelationGetForm(partrel)->reltype,
+ &found_whole_row);
+ /* We ignore the value of found_whole_row. */
leaf_part_rri->ri_returningList = returningList;
* target relation (firstVarno).
*/
onconflset = (List *) copyObject((Node *) node->onConflictSet);
- if (!equalTupdescs)
- {
- if (part_attnos == NULL)
- part_attnos =
- convert_tuples_by_name_map(RelationGetDescr(partrel),
- RelationGetDescr(firstResultRel),
- gettext_noop("could not convert row type"));
- onconflset = (List *)
- map_variable_attnos((Node *) onconflset,
- INNER_VAR, 0,
- part_attnos,
- RelationGetDescr(firstResultRel)->natts,
- RelationGetForm(partrel)->reltype,
- &found_whole_row);
- /* We ignore the value of found_whole_row. */
- onconflset = (List *)
- map_variable_attnos((Node *) onconflset,
- firstVarno, 0,
- part_attnos,
- RelationGetDescr(firstResultRel)->natts,
- RelationGetForm(partrel)->reltype,
- &found_whole_row);
- /* We ignore the value of found_whole_row. */
-
- /* Finally, adjust this tlist to match the partition. */
- onconflset = adjust_partition_tlist(onconflset, map);
- }
+ if (part_attnos == NULL)
+ part_attnos =
+ convert_tuples_by_name_map(RelationGetDescr(partrel),
+ RelationGetDescr(firstResultRel),
+ gettext_noop("could not convert row type"));
+ onconflset = (List *)
+ map_variable_attnos((Node *) onconflset,
+ INNER_VAR, 0,
+ part_attnos,
+ RelationGetDescr(firstResultRel)->natts,
+ RelationGetForm(partrel)->reltype,
+ &found_whole_row);
+ /* We ignore the value of found_whole_row. */
+ onconflset = (List *)
+ map_variable_attnos((Node *) onconflset,
+ firstVarno, 0,
+ part_attnos,
+ RelationGetDescr(firstResultRel)->natts,
+ RelationGetForm(partrel)->reltype,
+ &found_whole_row);
+ /* We ignore the value of found_whole_row. */
+
+ /* Finally, adjust this tlist to match the partition. */
+ onconflset = adjust_partition_tlist(onconflset, map);
/*
* Build UPDATE SET's projection info. The user of this
List *clause;
clause = copyObject((List *) node->onConflictWhere);
- if (!equalTupdescs)
- {
- clause = (List *)
- map_variable_attnos((Node *) clause,
- INNER_VAR, 0,
- part_attnos,
- RelationGetDescr(firstResultRel)->natts,
- RelationGetForm(partrel)->reltype,
- &found_whole_row);
- /* We ignore the value of found_whole_row. */
- clause = (List *)
- map_variable_attnos((Node *) clause,
- firstVarno, 0,
- part_attnos,
- RelationGetDescr(firstResultRel)->natts,
- RelationGetForm(partrel)->reltype,
- &found_whole_row);
- /* We ignore the value of found_whole_row. */
- }
+ clause = (List *)
+ map_variable_attnos((Node *) clause,
+ INNER_VAR, 0,
+ part_attnos,
+ RelationGetDescr(firstResultRel)->natts,
+ RelationGetForm(partrel)->reltype,
+ &found_whole_row);
+ /* We ignore the value of found_whole_row. */
+ clause = (List *)
+ map_variable_attnos((Node *) clause,
+ firstVarno, 0,
+ part_attnos,
+ RelationGetDescr(firstResultRel)->natts,
+ RelationGetForm(partrel)->reltype,
+ &found_whole_row);
+ /* We ignore the value of found_whole_row. */
leaf_part_rri->ri_onConflict->oc_WhereClause =
ExecInitQual((List *) clause, &mtstate->ps);
}