postgresql/contrib/postgres_fdw
Tom Lane 4526951d56 Make postgres_fdw's "Relations" output agree with the rest of EXPLAIN.
The relation aliases shown in the "Relations" line for a foreign scan
didn't always agree with those used in the rest of EXPLAIN's output.
The regression test result changes appearing here provide examples.

It's really impossible for postgres_fdw to duplicate EXPLAIN's alias
assignment logic during postgresGetForeignRelSize(), because of the
de-duplication that EXPLAIN does on a global basis --- and anyway,
trying to duplicate that would be unmaintainable.  Instead, just put
numeric rangetable indexes into the string, and convert those to
table names/aliases in postgresExplainForeignScan, which does have
access to the results of ruleutils.c's alias assignment logic.
Aside from being more reliable, this shifts some work from planning
to EXPLAIN, which is a good tradeoff for performance.  (I also
changed from using StringInfo to using psprintf, which makes the
code slightly simpler and reduces its memory consumption.)

A kluge required by this solution is that we have to reverse-engineer
the rtoffset applied by setrefs.c.  If that logic ever fails
(presumably because the member tables of a join got offset by
different amounts), we'll need some more cooperation with setrefs.c
to keep things straight.  But for now, there's no need for that.

Arguably this is a back-patchable bug fix, but since this is a mostly
cosmetic issue and there have been no field complaints, I'll refrain
for now.

Discussion: https://postgr.es/m/12424.1575168015@sss.pgh.pa.us
2019-12-02 16:31:03 -05:00
..
expected Make postgres_fdw's "Relations" output agree with the rest of EXPLAIN. 2019-12-02 16:31:03 -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
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
Makefile Split all OBJS style lines in makefiles into one-line-per-entry style. 2019-11-05 14:41:07 -08:00
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