postgresql/src
Tom Lane 80e79718d0 Fix crash when columns have been added to the end of a view.
expandRTE() supposed that an RTE_SUBQUERY subquery must have exactly
as many non-junk tlist items as the RTE has column aliases for it.
This was true at the time the code was written, and is still true so
far as parse analysis is concerned --- but when the function is used
during planning, the subquery might have appeared through insertion
of a view that now has more columns than it did when the outer query
was parsed.  This results in a core dump if, for instance, we have
to expand a whole-row Var that references the subquery.

To avoid crashing, we can either stop expanding the RTE when we run
out of aliases, or invent new aliases for the added columns.  While
the latter might be more useful, the former is consistent with what
expandRTE() does for composite-returning functions in the RTE_FUNCTION
case, so it seems like we'd better do it that way.

Per bug #14876 from Samuel Horwitz.  This has been busted since commit
ff1ea2173 allowed views to acquire more columns, so back-patch to all
supported branches.

Discussion: https://postgr.es/m/20171026184035.1471.82810@wrigleys.postgresql.org
2017-10-27 17:10:21 -04:00
..
backend Fix crash when columns have been added to the end of a view. 2017-10-27 17:10:21 -04:00
bin Translation updates 2017-08-28 10:07:56 -04:00
include Fix low-probability loss of NOTIFY messages due to XID wraparound. 2017-10-11 14:28:34 -04:00
interfaces Fix libpq to not require user's home directory to exist. 2017-10-25 19:32:25 -04:00
makefiles Always use -fPIC, not -fpic, when building shared libraries with gcc. 2017-06-01 13:32:56 -04:00
pl Translation updates 2017-08-28 10:07:56 -04:00
port Stamp 9.2.23. 2017-08-28 17:30:10 -04:00
template AIX: Test the -qlonglong option before use. 2015-07-17 03:02:18 -04:00
test Fix crash when columns have been added to the end of a view. 2017-10-27 17:10:21 -04:00
timezone Update time zone data files to tzdata release 2017c. 2017-10-23 18:16:04 -04:00
tools Improve gendef.pl diagnostic on failure to open sym file 2017-10-26 10:17:18 -04:00
tutorial Remove tabs after spaces in C comments 2014-05-06 11:26:27 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
bcc32.mak Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Fix some oversights in distprep and maintainer-clean targets. 2011-03-10 00:04:05 -05:00
Makefile.global.in PL/Perl portability fix: absorb relevant -D switches from Perl. 2017-07-31 12:38:35 -04:00
Makefile.shlib Fix typos in comments. 2017-02-06 11:34:32 +02:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00
win32.mak Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00