pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: daniel@sonck.nl
Subject: BUG #17166: PREPARE without types inconsistent type resolving
Date: Sun, 29 Aug 2021 18:09:17 +0000
Message-ID: <17166-c3dd634fbf6f044d@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      17166
Logged by:          Daniel Sonck
Email address:      daniel@sonck.nl
PostgreSQL version: 13.3
Operating system:   Linux (Archlinux)
Description:        

When executing the  following statement, the type of $1 could not be
deduced:

    SELECT * FROM my_table WHERE ($1 IS NULL OR col = $1);

However, when executing the following statement, the type of $1 could be
deduced:

    SELECT * FROM my_table WHERE (col = $1 OR $1 IS NULL);

While both queries end result are the same, the first is more in line with
the meaning, saying that the optional parameter $1 may be NULL, or, if it's
not, results should be filtered by col = $1. It is rather curious that a
simple order affects the type of $1. I would imagine that, as $1 IS NULL has
no type implications, the col = $1 would determine the type of $1.



view thread (2+ messages)  latest in thread

Message-ID: <17166-c3dd634fbf6f044d@postgresql.org>
Permalink:  ../17166-c3dd634fbf6f044d@postgresql.org/
Also on:    postgresql.org/message-id/17166-c3dd634fbf6f044d@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 using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, daniel@sonck.nl
  Subject: Re: BUG #17166: PREPARE without types inconsistent type resolving
  In-Reply-To: <17166-c3dd634fbf6f044d@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