postgresql/src
Tom Lane 6bceacfe87 Fix ruleutils issues with dropped cols in functions-returning-composite.
Due to lack of concern for the case in the dependency code, it's
possible to drop a column of a composite type even though stored
queries have references to the dropped column via functions-in-FROM
that return the composite type.  There are "soft" references,
namely FROM-clause aliases for such columns, and "hard" references,
that is actual Vars referring to them.  The right fix for hard
references is to add dependencies preventing the drop; something
we've known for many years and not done (and this commit still doesn't
address it).  A "soft" reference shouldn't prevent a drop though.
We've been around on this before (cf. 9b35ddce9, 2c4debbd0), but
nobody had noticed that the current behavior can result in dump/reload
failures, because ruleutils.c can print more column aliases than the
underlying composite type now has.  So we need to rejigger the
column-alias-handling code to treat such columns as dropped and not
print aliases for them.

Rather than writing new code for this, I used expandRTE() which already
knows how to figure out which function result columns are dropped.
I'd initially thought maybe we could use expandRTE() in all cases, but
that fails for EXPLAIN's purposes, because the planner strips a lot of
RTE infrastructure that expandRTE() needs.  So this patch just uses it
for unplanned function RTEs and otherwise does things the old way.

If there is a hard reference (Var), then removing the column alias
causes us to fail to print the Var, since there's no longer a name
to print.  Failing seems less desirable than printing a made-up
name, so I made it print "?dropped?column?" instead.

Per report from Timo Stolz.  Back-patch to all supported branches.

Discussion: https://postgr.es/m/5c91267e-3b6d-5795-189c-d15a55d61dbb@nullachtvierzehn.de
2022-07-21 13:56:02 -04:00
..
backend Fix ruleutils issues with dropped cols in functions-returning-composite. 2022-07-21 13:56:02 -04:00
bin Fix \watch's interaction with libedit on ^C. 2022-07-10 16:57:04 +12:00
common Inhibit mingw CRT's auto-globbing of command line arguments 2022-04-25 15:51:58 -04:00
fe_utils Clean up assorted failures under clang's -fsanitize=undefined checks. 2022-03-03 18:13:24 -05:00
include Fix the logical replication timeout during large transactions. 2022-05-11 10:01:35 +05:30
interfaces Fix previous commit's ecpg_clocale for ppc Darwin. 2022-07-02 21:03:24 -07:00
makefiles Select CFLAGS_SL at configure time, not in platform-specific Makefiles. 2019-10-21 12:32:36 -04:00
pl Fix pl/perl test case so it will still work under Perl 5.36. 2022-06-01 16:15:47 -04:00
port Stamp 10.21. 2022-05-09 17:21:58 -04:00
template Further tweaking of PG_SYSROOT heuristics for macOS. 2021-01-20 12:07:46 -05:00
test Fix ruleutils issues with dropped cols in functions-returning-composite. 2022-07-21 13:56:02 -04:00
timezone Update time zone data files to tzdata release 2022a. 2022-05-05 14:55:30 -04:00
tools Improve setup of environment values for commands in MSVC's vcregress.pl 2022-05-11 10:22:44 +09:00
tutorial tutorial: land height is "elevation", not "altitude" 2021-03-10 20:25:18 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
DEVELOPERS
Makefile Build src/test/isolation during "make" and "make install". 2017-11-22 20:18:52 -08:00
Makefile.global.in Fix prove_installcheck to use correct paths when used with PGXS 2021-07-01 08:48:24 -04:00
Makefile.shlib makefile: use proper linker flags for C++ compiles 2020-03-31 22:26:11 -04:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00