From: Tom Lane <tgl@sss.pgh.pa.us>
To: David G. Johnston <david.g.johnston@gmail.com>
Cc: Elvis Pranskevichus <elprans@gmail.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #16368: Incorrect function inlining in the presence of a window function
Date: Wed, 15 Apr 2020 20:14:05 -0400
Message-ID: <2039.1586996045@sss.pgh.pa.us> (raw)
In-Reply-To: <CAKFQuwZk1focovkoLbgzWcoMnn09CrnmoHXVYKuPNnSoxwNkuQ@mail.gmail.com>
References: <16368-0dd1d5ab02a3cbc0@postgresql.org>
<CAKFQuwbBmEGw0hB6B3oMoWVaXjVHEziScqhz0d7FpiG6cBs0EQ@mail.gmail.com>
<4425563.buerPE7WCZ@hammer.magicstack.net>
<CAKFQuwZk1focovkoLbgzWcoMnn09CrnmoHXVYKuPNnSoxwNkuQ@mail.gmail.com>
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Wed, Apr 15, 2020 at 1:08 PM Elvis Pranskevichus <elprans@gmail.com>
> wrote:
>> Consider any other case where an error is guarded by a "CASE WHEN", such
>> as division by zero.
> There aren't all that many and throwing out a perfectly good optimization
> for boundary cases that will error, as opposed to returning but including
> invalid results, isn't that desirable either.
In point of fact, there are many ways in which CASE and related constructs
fail to guarantee evaluation order, as noted in
https://www.postgresql.org/docs/current/sql-expressions.html#SYNTAX-EXPRESS-EVAL
The particular case mentioned there seems to be about the same as here:
constant-folding happens even in CASE arms that will never be reached at
runtime. Problems could happen earlier than that, too. It's not hard to
imagine cases that wouldn't execute "as desired" unless we didn't even do
parse analysis (e.g, subexpression type determination) on a CASE arm until
it's reached at runtime. But we're not going to make that sort of thing
happen; it's just too much contortion and inefficiency for too little
benefit. In particular, people for whom the current implementation works
OK would be quite unhappy with the performance impact of de-optimizing
CASE that way.
regards, tom lane
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, david.g.johnston@gmail.com, elprans@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16368: Incorrect function inlining in the presence of a window function
In-Reply-To: <2039.1586996045@sss.pgh.pa.us>
* 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