mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Include result relation info in direct modify ForeignScan nodes.
FDWs that can perform an UPDATE/DELETE remotely using the "direct modify" set of APIs need to access the ResultRelInfo of the target table. That's currently available in EState.es_result_relation_info, but the next commit will remove that field. This commit adds a new resultRelation field in ForeignScan, to store the target relation's RT index, and the corresponding ResultRelInfo in ForeignScanState. The FDW's PlanDirectModify callback is expected to set 'resultRelation' along with 'operation'. The core code doesn't need them for anything, they are for the convenience of FDW's Begin- and IterateDirectModify callbacks. Authors: Amit Langote, Etsuro Fujita Discussion: https://www.postgresql.org/message-id/CA%2BHiwqGEmiib8FLiHMhKB%2BCH5dRgHSLc5N5wnvc4kym%2BZYpQEQ%40mail.gmail.com
This commit is contained in:
@ -861,11 +861,15 @@ PlanDirectModify(PlannerInfo *root,
|
||||
To execute the direct modification on the remote server, this function
|
||||
must rewrite the target subplan with a <structname>ForeignScan</structname> plan
|
||||
node that executes the direct modification on the remote server. The
|
||||
<structfield>operation</structfield> field of the <structname>ForeignScan</structname> must
|
||||
be set to the <literal>CmdType</literal> enumeration appropriately; that is,
|
||||
<structfield>operation</structfield> and <structfield>resultRelation</structfield> fields
|
||||
of the <structname>ForeignScan</structname> must be set appropriately.
|
||||
<structfield>operation</structfield> must be set to the <literal>CmdType</literal>
|
||||
enumeration corresponding to the statement kind (that is,
|
||||
<literal>CMD_UPDATE</literal> for <command>UPDATE</command>,
|
||||
<literal>CMD_INSERT</literal> for <command>INSERT</command>, and
|
||||
<literal>CMD_DELETE</literal> for <command>DELETE</command>.
|
||||
<literal>CMD_DELETE</literal> for <command>DELETE</command>), and the
|
||||
<literal>resultRelation</literal> argument must be copied to the
|
||||
<structfield>resultRelation</structfield> field.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@ -925,9 +929,8 @@ IterateDirectModify(ForeignScanState *node);
|
||||
needed for the <literal>RETURNING</literal> calculation, returning it in a
|
||||
tuple table slot (the node's <structfield>ScanTupleSlot</structfield> should be
|
||||
used for this purpose). The data that was actually inserted, updated
|
||||
or deleted must be stored in the
|
||||
<literal>es_result_relation_info->ri_projectReturning->pi_exprContext->ecxt_scantuple</literal>
|
||||
of the node's <structname>EState</structname>.
|
||||
or deleted must be stored in
|
||||
<literal>node->resultRelInfo->ri_projectReturning->pi_exprContext->ecxt_scantuple</literal>.
|
||||
Return NULL if no more rows are available.
|
||||
Note that this is called in a short-lived memory context that will be
|
||||
reset between invocations. Create a memory context in
|
||||
|
Reference in New Issue
Block a user