pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix planner error with pulling up subquery expressions into func
Date: Thu, 14 Oct 2021 16:44:08 +0000
Message-ID: <E1mb3pw-00039q-Sp@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4d5f651f1d651c6fa79f9188e7b9a04654c7125a

Modified Files
--------------
src/backend/optimizer/plan/planner.c     |  9 +++++----
src/test/regress/expected/rangefuncs.out | 29 +++++++++++++++++++++++++++++
src/test/regress/sql/rangefuncs.sql      | 15 +++++++++++++++
3 files changed, 49 insertions(+), 4 deletions(-)



view thread (3+ messages)  latest in thread

Message-ID: <E1mb3pw-00039q-Sp@gemulon.postgresql.org>
Permalink:  ../E1mb3pw-00039q-Sp@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1mb3pw-00039q-Sp@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix planner error with pulling up subquery expressions into func
  In-Reply-To: <E1mb3pw-00039q-Sp@gemulon.postgresql.org>
  References: <E1mb3pw-00039q-Sp@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox