postgresql/contrib/postgres_fdw
Tom Lane 55a1954da1 Fix EXPLAIN's column alias output for mismatched child tables.
If an inheritance/partitioning parent table is assigned some column
alias names in the query, EXPLAIN mapped those aliases onto the
child tables' columns by physical position, resulting in bogus output
if a child table's columns aren't one-for-one with the parent's.

To fix, make expand_single_inheritance_child() generate a correctly
re-mapped column alias list, rather than just copying the parent
RTE's alias node.  (We have to fill the alias field, not just
adjust the eref field, because ruleutils.c will ignore eref in
favor of looking at the real column names.)

This means that child tables will now always have alias fields in
plan rtables, where before they might not have.  That results in
a rather substantial set of regression test output changes:
EXPLAIN will now always show child tables with aliases that match
the parent table (usually with "_N" appended for uniqueness).
But that seems like a net positive for understandability, since
the parent alias corresponds to something that actually appeared
in the original query, while the child table names didn't.
(Note that this does not change anything for cases where an explicit
table alias was written in the query for the parent table; it
just makes cases without such aliases behave similarly to that.)
Hence, while we could avoid these subsidiary changes if we made
inherit.c more complicated, we choose not to.

Discussion: https://postgr.es/m/12424.1575168015@sss.pgh.pa.us
2019-12-02 19:08:10 -05:00
..
expected Fix EXPLAIN's column alias output for mismatched child tables. 2019-12-02 19:08:10 -05:00
sql Add regression test for two-phase transaction in postgres_fdw 2019-11-13 13:30:14 +09:00
.gitignore Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
Makefile Split all OBJS style lines in makefiles into one-line-per-entry style. 2019-11-05 14:41:07 -08:00
connection.c postgres_fdw: Fix error message for PREPARE TRANSACTION. 2019-11-08 17:00:30 +09:00
deparse.c Make the order of the header file includes consistent in contrib modules. 2019-10-24 08:05:34 +05:30
option.c Make the order of the header file includes consistent in contrib modules. 2019-10-24 08:05:34 +05:30
postgres_fdw--1.0.sql Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
postgres_fdw.c Make postgres_fdw's "Relations" output agree with the rest of EXPLAIN. 2019-12-02 16:31:03 -05:00
postgres_fdw.control Add postgres_fdw contrib module. 2013-02-21 05:27:16 -05:00
postgres_fdw.h Make postgres_fdw's "Relations" output agree with the rest of EXPLAIN. 2019-12-02 16:31:03 -05:00
shippable.c Make the order of the header file includes consistent in contrib modules. 2019-10-24 08:05:34 +05:30