pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: farmernick-pg@varteg.nz
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15289: Type inference of parameters in prepared statements can sometimes fail or succeed, depending...
Date: Sat, 21 Jul 2018 11:23:36 -0400
Message-ID: <3988.1532186616@sss.pgh.pa.us> (raw)
In-Reply-To: <153217363212.1404.494341354166053594@wrigleys.postgresql.org>
References: <153217363212.1404.494341354166053594@wrigleys.postgresql.org>

=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> Type inference of parameters in prepared statements can sometimes fail even
> though all the information is present and can be obtained if the statement
> is altered in a way that really shouldn't make any functional difference.

This is not a bug.  If you don't specify a type for a parameter, the
parser attempts to infer it on first use.  If the first use is
"v = $1", it will guess that $1 is meant to be the same type as v
(whose type is already known from having processed the FROM clause).
If the first use is "$1 IS NULL", there's no basis to infer a type.

One could imagine some complicated parse-time processing that tries
to defer resolving the parameter's type in hopes that some other use
will be seen later; but there is no such thing in PG, and I doubt
it will appear soon.

			regards, tom lane




view thread (4+ messages)  latest in thread

Message-ID: <3988.1532186616@sss.pgh.pa.us>
Permalink:  ../3988.1532186616@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3988.1532186616@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 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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, farmernick-pg@varteg.nz
  Subject: Re: BUG #15289: Type inference of parameters in prepared statements can sometimes fail or succeed, depending...
  In-Reply-To: <3988.1532186616@sss.pgh.pa.us>
  References: <153217363212.1404.494341354166053594@wrigleys.postgresql.org> <3988.1532186616@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