Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1e4ADG-0001Uw-I4 for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Oct 2017 18:34:06 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1e4ADF-00034s-VC for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Oct 2017 18:34:06 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e4ADF-00034i-DU for pgsql-bugs@postgresql.org; Mon, 16 Oct 2017 18:34:05 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1e4AD8-0003Mz-Ao for pgsql-bugs@postgresql.org; Mon, 16 Oct 2017 18:34:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v9GIXu1O018576; Mon, 16 Oct 2017 14:33:56 -0400 From: Tom Lane To: Tomas Vondra cc: =?UTF-8?Q?Eduardo_P=c3=a9rez_Ureta?= , "David G. Johnston" , pgsql-bugs@postgresql.org Subject: Re: BUG #14853: Parameter type is required even when the query does not need to know the type In-reply-to: <22d2db6e-d458-3893-f8a9-52a0f129fc10@2ndquadrant.com> References: <20171013140350.8210.40918@wrigleys.postgresql.org> <22d2db6e-d458-3893-f8a9-52a0f129fc10@2ndquadrant.com> Comments: In-reply-to Tomas Vondra message dated "Mon, 16 Oct 2017 20:09:21 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <18574.1508178836.1@sss.pgh.pa.us> Date: Mon, 16 Oct 2017 14:33:56 -0400 Message-ID: <18575.1508178836@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Tomas Vondra writes: > In other words, the fact that "make check" passes may easily be just due > to an omission in the regression tests. Apparently there's no test that > we actually produce the error when the type can't be inferred. > That being said, I don't know if this is a correct change or not. The patch as presented (ie, just remove the check that all types got determined) has no chance whatsoever of being accepted. The reason that check exists is that client-side code isn't necessarily going to cope with being told that a parameter it is supposed to supply is of type "unknown". psql doesn't really care (in fact I don't think it uses parameters at all), which is why the core regression tests pass. But other clients such as JDBC have considerably more logic that depends on the types of parameters. We're not going to risk breaking them for this sort of dubious-in-any-case feature. It's possible that we'd accept a patch that resolves the parameter as type text if it's in a context where the type doesn't matter. (Are there any such contexts other than IS [NOT] NULL?) Arguably that's more consistent with the fact that we now resolve "select $1" as being type text. But I'm not sure if that breaks any cases that work today. The obvious counterexample is something like prepare foo as select $1 is not null and $1 > 42; where the parameter would need to be resolved as some other type later. But that presently fails with "could not determine data type", so I don't see a very good reason why "operator does not exist: text > integer" is a worse outcome. The sticking point would be whether there are related cases that succeed but such a patch would cause them to fail (or silently change behavior, which is likely worse). > You'll need to submit it to pgsql-hackers though. Yes, this is certainly not a bug but a RFE. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs