• Robert Haas's avatar
    Fix interaction of foreign tuple routing with remote triggers. · 37a3058b
    Robert Haas authored
    Without these fixes, changes to the inserted tuple made by remote
    triggers are ignored when building local RETURNING tuples.
    
    In the core code, call ExecInitRoutingInfo at a later point from
    within ExecInitPartitionInfo so that the FDW callback gets invoked
    after the returning list has been built.  But move CheckValidResultRel
    out of ExecInitRoutingInfo so that it can happen at an earlier stage.
    
    In postgres_fdw, refactor assorted deparsing functions to work with
    the RTE rather than the PlannerInfo, which saves us having to
    construct a fake PlannerInfo in cases where we don't have a real one.
    Then, we can pass down a constructed RTE that yields the correct
    deparse result when no real one exists.  Unfortunately, this
    necessitates a hack that understands how the core code manages RT
    indexes for update tuple routing, which is ugly, but we don't have a
    better idea right now.
    
    Original report, analysis, and patch by Etsuro Fujita.  Heavily
    refactored by me.  Then worked over some more by Amit Langote.
    
    Discussion: http://postgr.es/m/5AD4882B.10002@lab.ntt.co.jp
    37a3058b
deparse.c 90.5 KB