]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix planner error with pulling up subquery expressions into function RTEs.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 14 Oct 2021 16:43:43 +0000 (12:43 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 14 Oct 2021 16:43:43 +0000 (12:43 -0400)
commitfdd6a4d8d90aee36d2d81f0ab29399021228183a
tree6db67f96b143ea670b5a7eeb14379ea3ba4e45c6
parent2cdf97fd1ec86301c70ccffb2414a6047c9f8dd1
Fix planner error with pulling up subquery expressions into function RTEs.

If a function-in-FROM laterally references the output of some sub-SELECT
earlier in the FROM clause, and we are able to flatten that sub-SELECT
into the outer query, the expression(s) copied into the function RTE
missed being processed by eval_const_expressions.  This'd lead to trouble
and probable crashes at execution if such expressions contained
named-argument function call syntax or functions with defaulted arguments.
The bug is masked if the query contains any explicit JOIN syntax, which
may help explain why we'd not noticed.

Per bug #17227 from Bernd Dorn.  This is an oversight in commit 7266d0997,
so back-patch to v13 where that came in.

Discussion: https://postgr.es/m/17227-5a28ed1512189fa4@postgresql.org
src/backend/optimizer/plan/planner.c
src/test/regress/expected/rangefuncs.out
src/test/regress/sql/rangefuncs.sql