Re: partition routing layering in nodeModifyTable.c

Etsuro Fujita <etsuro.fujita@gmail.com>

From: Etsuro Fujita <etsuro.fujita@gmail.com>
To: Amit Langote <amitlangote09@gmail.com>
Cc: Andres Freund <andres@anarazel.de>, Thomas Munro <thomas.munro@gmail.com>, David Rowley <david.rowley@2ndquadrant.com>, Robert Haas <robertmhaas@gmail.com>, Alvaro Herrera <alvherre@2ndquadrant.com>, Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp>, PostgreSQL-development <pgsql-hackers@postgresql.org>, amitdkhan.pg@gmail.com
Date: 2019-08-07T09:00:04Z
Lists: pgsql-hackers
Amit-san,

On Wed, Aug 7, 2019 at 4:28 PM Amit Langote <amitlangote09@gmail.com> wrote:
> On Wed, Aug 7, 2019 at 12:00 PM Etsuro Fujita <etsuro.fujita@gmail.com> wrote:
> > IIUC, I think we reached a consensus at least on the 0001 patch.
> > Andres, would you mind if I commit that patch?
>
> I just noticed obsolete references to es_result_relation_info that
> 0002 failed to remove.  One of them is in fdwhandler.sgml:
>
> <programlisting>
> TupleTableSlot *
> IterateDirectModify(ForeignScanState *node);
> </programlisting>
>
>     ... The data that was actually inserted, updated
>      or deleted must be stored in the
>      <literal>es_result_relation_info-&gt;ri_projectReturning-&gt;pi_exprContext-&gt;ecxt_scantuple</literal>
>      of the node's <structname>EState</structname>.
>
> We will need to rewrite this without mentioning
> es_result_relation_info.  How about as follows:
>
> -     <literal>es_result_relation_info-&gt;ri_projectReturning-&gt;pi_exprContext-&gt;ecxt_scantuple</literal>
> -     of the node's <structname>EState</structname>.
> +     <literal>ri_projectReturning-&gt;pi_exprContext-&gt;ecxt_scantuple</literal>
> +     of the result relation's<structname>ResultRelInfo</structname> that has
> +     been made available via node.
>
> I've updated 0001 with the above change.

Good catch!

This would be nitpicking, but:

* IIUC, we don't use the term "result relation" in fdwhandler.sgml.
For consistency with your change to the doc for BeginDirectModify, how
about using the term "target foreign table" instead of "result
relation"?

* ISTM that "<structname>ResultRelInfo</structname> that has been made
available via node" would be a bit fuzzy to FDW authors.  To be more
specific, how about changing it to
"<structname>ResultRelInfo</structname> passed to
<function>BeginDirectModify</function>" or something like that?

Best regards,
Etsuro Fujita



Commits

  1. Fix initialization of es_result_relations in EvalPlanQualStart().

  2. Remove PartitionRoutingInfo struct.

  3. Revise child-to-root tuple conversion map management.

  4. Clean up code to resolve the "root target relation" in nodeModifyTable.c

  5. Refactor code for cross-partition updates to a separate function.

  6. Remove es_result_relation_info from EState.

  7. Include result relation info in direct modify ForeignScan nodes.

  8. Create ResultRelInfos later in InitPlan, index them by RT index.