pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Vik Fearing <vik@postgresfriends.org>
Cc: Marek Malevič <marek@malevicovi.net>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Broken type checking for empty subqueries
Date: Thu, 28 Sep 2023 10:57:39 -0400
Message-ID: <960060.1695913059@sss.pgh.pa.us> (raw)
In-Reply-To: <CAApHDvppXNM1etHZZ_8=t2jmqv-LyddtR8P5bUYkjiWwJZbeng@mail.gmail.com>
References: <7e55db68-7169-4e43-363e-947c79ba7922@malevicovi.net>
	<42808eee-9a68-cfbd-924c-db895d13f9c0@postgresfriends.org>
	<CAApHDvppXNM1etHZZ_8=t2jmqv-LyddtR8P5bUYkjiWwJZbeng@mail.gmail.com>

David Rowley <dgrowleyml@gmail.com> writes:
> I've not looked at the code to see if this would be practical or not,
> but I wonder if we could reduce these bug reports by using the new
> soft error reporting that's now done in the input functions to have
> constant folding just silently not do any folding for the expression
> if a cast fails.

Sadly, I doubt that would cover enough of the problem space to make
much difference to people who try to do this sort of thing.

> ... I imagine most people who
> have had them fail during constant folding have just redesigned or
> found some hack to prevent the folding from taking place anyway.

Yeah.  The given query looks like it was already hacked to avoid
constant-folding, though I wonder if whoever wrote it really understood
that.  Otherwise it'd be a lot more natural to use something like CASE.
Anyway, adding OFFSET 0 to suppress sub-select folding is probably
the best answer here.

			regards, tom lane





view thread (8+ messages)  latest in thread

Message-ID: <960060.1695913059@sss.pgh.pa.us>
Permalink:  ../960060.1695913059@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/960060.1695913059@sss.pgh.pa.us

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, dgrowleyml@gmail.com, vik@postgresfriends.org, marek@malevicovi.net, pgsql-bugs@lists.postgresql.org
  Subject: Re: Broken type checking for empty subqueries
  In-Reply-To: <960060.1695913059@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