pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Daniele Varrazzo <daniele.varrazzo@gmail.com>
Cc: pgsql-bugs <pgsql-bugs@postgresql.org>
Subject: Re: Types pollution with unknown oids and server-side parameters binding
Date: Tue, 03 May 2022 15:55:22 -0400
Message-ID: <2189979.1651607722@sss.pgh.pa.us> (raw)
In-Reply-To: <CA+mi_8bQPwf8zwg7GeoqhvccNuze-hyDODACCL0Dj=x_kaE7Bw@mail.gmail.com>
References: <CA+mi_8bQPwf8zwg7GeoqhvccNuze-hyDODACCL0Dj=x_kaE7Bw@mail.gmail.com>

Daniele Varrazzo <daniele.varrazzo@gmail.com> writes:
> A problem shown in https://github.com/psycopg/psycopg/discussions/289

> In the query:
>     UPDATE test289 SET num = $1, name = $2, ts = $3 WHERE ts::date = $3::date

> passing a string with unknown oid as param $3 results in the column ts
> receiving only the date part. Looks like the cast needed on the param
> in the WHERE gets propagated to the other occurrences of the same
> parameter.

I think it's operating exactly as designed.  The parameter can only
have one type, and the cast is telling it to assume that that type
is "date".

> I see why it happens... I don't think it's the right behaviour though.

What do you think ought to happen?  The same parameter somehow having
different types in different places?

			regards, tom lane





view thread (8+ messages)  latest in thread

Message-ID: <2189979.1651607722@sss.pgh.pa.us>
Permalink:  ../2189979.1651607722@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2189979.1651607722@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, daniele.varrazzo@gmail.com
  Subject: Re: Types pollution with unknown oids and server-side parameters binding
  In-Reply-To: <2189979.1651607722@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