• T
    Fix inherited UPDATE/DELETE with UNION ALL subqueries. · c03ad560
    Tom Lane 提交于
    Fix an oversight in commit b3aaf908: we do
    indeed need to process the planner's append_rel_list when copying RTE
    subqueries, because if any of them were flattenable UNION ALL subqueries,
    the append_rel_list shows which subquery RTEs were pulled up out of which
    other ones.  Without this, UNION ALL subqueries aren't correctly inserted
    into the update plans for inheritance child tables after the first one,
    typically resulting in no update happening for those child table(s).
    Per report from Victor Yegorov.
    
    Experimentation with this case also exposed a fault in commit
    a7b96538: if an inherited UPDATE/DELETE
    was proven totally dummy by constraint exclusion, we might arrive at
    add_rtes_to_flat_rtable with root->simple_rel_array being NULL.  This
    should be interpreted as not having any RelOptInfos.  I chose to code
    the guard as a check against simple_rel_array_size, so as to also
    provide some protection against indexing off the end of the array.
    
    Back-patch to 9.2 where the faulty code was added.
    c03ad560
inherit.sql 18.1 KB