|
|
@ -2020,12 +2020,11 @@ postgresBeginForeignInsert(ModifyTableState *mtstate, |
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* If the foreign table is a partition, we need to create a new RTE |
|
|
|
* If the foreign table is a partition, we need to create a new RTE |
|
|
|
* describing the foreign table for use by deparseInsertSql and |
|
|
|
* describing the foreign table for use by deparseInsertSql and |
|
|
|
* create_foreign_modify() below, after first copying the parent's |
|
|
|
* create_foreign_modify() below, after first copying the parent's RTE and |
|
|
|
* RTE and modifying some fields to describe the foreign partition to |
|
|
|
* modifying some fields to describe the foreign partition to work on. |
|
|
|
* work on. However, if this is invoked by UPDATE, the existing RTE |
|
|
|
* However, if this is invoked by UPDATE, the existing RTE may already |
|
|
|
* may already correspond to this partition if it is one of the |
|
|
|
* correspond to this partition if it is one of the UPDATE subplan target |
|
|
|
* UPDATE subplan target rels; in that case, we can just use the |
|
|
|
* rels; in that case, we can just use the existing RTE as-is. |
|
|
|
* existing RTE as-is. |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
rte = list_nth(estate->es_range_table, resultRelation - 1); |
|
|
|
rte = list_nth(estate->es_range_table, resultRelation - 1); |
|
|
|
if (rte->relid != RelationGetRelid(rel)) |
|
|
|
if (rte->relid != RelationGetRelid(rel)) |
|
|
@ -2035,10 +2034,10 @@ postgresBeginForeignInsert(ModifyTableState *mtstate, |
|
|
|
rte->relkind = RELKIND_FOREIGN_TABLE; |
|
|
|
rte->relkind = RELKIND_FOREIGN_TABLE; |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* For UPDATE, we must use the RT index of the first subplan |
|
|
|
* For UPDATE, we must use the RT index of the first subplan target |
|
|
|
* target rel's RTE, because the core code would have built |
|
|
|
* rel's RTE, because the core code would have built expressions for |
|
|
|
* expressions for the partition, such as RETURNING, using that |
|
|
|
* the partition, such as RETURNING, using that RT index as varno of |
|
|
|
* RT index as varno of Vars contained in those expressions. |
|
|
|
* Vars contained in those expressions. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
if (plan && plan->operation == CMD_UPDATE && |
|
|
|
if (plan && plan->operation == CMD_UPDATE && |
|
|
|
resultRelation == plan->nominalRelation) |
|
|
|
resultRelation == plan->nominalRelation) |
|
|
|