Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fnSCZ-0000w8-Kj for pgsql-docs@arkaria.postgresql.org; Wed, 08 Aug 2018 17:24:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fnSCX-0004xc-Km for pgsql-docs@arkaria.postgresql.org; Wed, 08 Aug 2018 17:24:49 +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.89) (envelope-from ) id 1fnSCX-0004xV-Bi for pgsql-docs@lists.postgresql.org; Wed, 08 Aug 2018 17:24:49 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fnSCU-0000O7-Kz for pgsql-docs@lists.postgresql.org; Wed, 08 Aug 2018 17:24:48 +0000 Received: from bruce by momjian.us with local (Exim 4.84_2) (envelope-from ) id 1fnSCS-0006Cc-E7; Wed, 08 Aug 2018 13:24:44 -0400 Date: Wed, 8 Aug 2018 13:24:44 -0400 From: Bruce Momjian To: farmernick-pg@varteg.nz, pgsql-docs@lists.postgresql.org Subject: Re: Parameter types are inferred from context of first use only. Message-ID: <20180808172444.GC2611@momjian.us> References: <153233728858.1404.15268121695358514937@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="cNdxnHkX5QqsyA0e" Content-Disposition: inline In-Reply-To: <153233728858.1404.15268121695358514937@wrigleys.postgresql.org> User-Agent: Mutt/1.5.23 (2014-03-12) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --cNdxnHkX5QqsyA0e Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Jul 23, 2018 at 09:14:48AM +0000, PG Doc comments form wrote: > The following documentation comment has been logged on the website: > > Page: https://www.postgresql.org/docs/10/static/sql-prepare.html > Description: > > Background can be found on the bugs list (pgsql-bug #15289). It was > explained that when a prepared statement parameter needs to have its type > inferred then, should the parameter be used more than once, only the first > use is considered. (The example in that report is that the type of $1 can be > inferred from "($1 = col) or ($1 is null)" but not from "($1 is null) or ($1 > = col)".) > > The documentation as it stands says only that the parameter's type is > inferred from the context in which it is used. The "first use only" proviso > is not mentioned (hence "context" isn't so broad as to consist of all of the > expressions in which the parameter appears). I have developed the attached patch to cover what you found. -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription + --cNdxnHkX5QqsyA0e Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="prepare.diff" diff --git a/doc/src/sgml/ref/prepare.sgml b/doc/src/sgml/ref/prepare.sgml index 704fb5e..4fe9ab7 100644 --- a/doc/src/sgml/ref/prepare.sgml +++ b/doc/src/sgml/ref/prepare.sgml @@ -52,7 +52,7 @@ PREPARE name [ ( unknown, the type is inferred from the context - in which the parameter is used (if possible). When executing the + in which the parameter is first used (if possible). When executing the statement, specify the actual values for these parameters in the EXECUTE statement. Refer to for more @@ -104,7 +104,7 @@ PREPARE name [ ( unknown, it will be inferred - from the context in which the parameter is used. To refer to the + from the context in which the parameter is first used. To refer to the parameters in the prepared statement itself, use $1, $2, etc. --cNdxnHkX5QqsyA0e--