Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nlycQ-0005H4-P3 for pgsql-bugs@arkaria.postgresql.org; Tue, 03 May 2022 19:55:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nlycP-0005Ng-2a for pgsql-bugs@arkaria.postgresql.org; Tue, 03 May 2022 19:55:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nlycO-0005NX-Qf for pgsql-bugs@lists.postgresql.org; Tue, 03 May 2022 19:55:32 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nlycH-0008WJ-Qc for pgsql-bugs@postgresql.org; Tue, 03 May 2022 19:55:32 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 243JtMm22189980; Tue, 3 May 2022 15:55:23 -0400 From: Tom Lane To: Daniele Varrazzo cc: pgsql-bugs Subject: Re: Types pollution with unknown oids and server-side parameters binding In-reply-to: References: Comments: In-reply-to Daniele Varrazzo message dated "Tue, 03 May 2022 21:10:20 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2189978.1651607722.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 03 May 2022 15:55:22 -0400 Message-ID: <2189979.1651607722@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Daniele Varrazzo writes: > A problem shown in https://github.com/psycopg/psycopg/discussions/289 > In the query: > UPDATE test289 SET num =3D $1, name =3D $2, ts =3D $3 WHERE ts::date= =3D $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