public inbox for [email protected]  
help / color / mirror / Atom feed
Parameter types are inferred from context of first use only.
5+ messages / 3 participants
[nested] [flat]

* Parameter types are inferred from context of first use only.
@ 2018-07-23 09:14  PG Doc comments form <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: PG Doc comments form @ 2018-07-23 09:14 UTC (permalink / raw)
  To: [email protected]; +Cc: [email protected]

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).


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Parameter types are inferred from context of first use only.
@ 2018-08-08 17:24  Bruce Momjian <[email protected]>
  parent: PG Doc comments form <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Bruce Momjian @ 2018-08-08 17:24 UTC (permalink / raw)
  To: [email protected]; [email protected]

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  <[email protected]>        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 +


Attachments:

  [text/x-diff] prepare.diff (1.3K, 2-prepare.diff)
  download | inline 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 <replaceable class="parameter">name</replaceable> [ ( <replaceable class
    parameter data types can optionally be specified. When a
    parameter's data type is not specified or is declared as
    <literal>unknown</literal>, 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
    <command>EXECUTE</command> statement.  Refer to <xref
    linkend="sql-execute"/> for more
@@ -104,7 +104,7 @@ PREPARE <replaceable class="parameter">name</replaceable> [ ( <replaceable class
       The data type of a parameter to the prepared statement.  If the
       data type of a particular parameter is unspecified or is
       specified as <literal>unknown</literal>, 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
       <literal>$1</literal>, <literal>$2</literal>, etc.
      </para>


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Parameter types are inferred from context of first use only.
@ 2018-08-09 00:18  Morgan Owens <[email protected]>
  parent: Bruce Momjian <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Morgan Owens @ 2018-08-09 00:18 UTC (permalink / raw)
  To: Nick Farmer <[email protected]>; [email protected]

On 2018-08-09 05:24, Bruce Momjian wrote:
> 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.
> 

That says it for me. The third mention of context doesn't need anything 
because it's referring specifically to the (single) use of $2 in the 
example. I have to presume the type inference happens before any 
structural changes that might change the meaning of "first occurrence".

Nick




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Parameter types are inferred from context of first use only.
@ 2018-08-09 14:14  Bruce Momjian <[email protected]>
  parent: Morgan Owens <[email protected]>
  0 siblings, 1 reply; 5+ messages in thread

From: Bruce Momjian @ 2018-08-09 14:14 UTC (permalink / raw)
  To: Morgan Owens <[email protected]>; +Cc: Nick Farmer <[email protected]>; [email protected]

On Thu, Aug  9, 2018 at 12:18:27PM +1200, Morgan Owens wrote:
> On 2018-08-09 05:24, Bruce Momjian wrote:
> >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.
> >
> 
> That says it for me. The third mention of context doesn't need anything
> because it's referring specifically to the (single) use of $2 in the
> example. I have to presume the type inference happens before any structural
> changes that might change the meaning of "first occurrence".

Great, patch applied through 9.3.  I also changed "used" to
"referenced":

	https://git.postgresql.org/pg/commitdiff/b284262e40424daa1c546ad76f365b31304d7944

-- 
  Bruce Momjian  <[email protected]>        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 +




^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Parameter types are inferred from context of first use only.
@ 2018-08-09 14:15  Bruce Momjian <[email protected]>
  parent: Bruce Momjian <[email protected]>
  0 siblings, 0 replies; 5+ messages in thread

From: Bruce Momjian @ 2018-08-09 14:15 UTC (permalink / raw)
  To: Morgan Owens <[email protected]>; +Cc: Nick Farmer <[email protected]>; [email protected]

On Thu, Aug  9, 2018 at 10:14:33AM -0400, Bruce Momjian wrote:
> On Thu, Aug  9, 2018 at 12:18:27PM +1200, Morgan Owens wrote:
> > On 2018-08-09 05:24, Bruce Momjian wrote:
> > >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.
> > >
> > 
> > That says it for me. The third mention of context doesn't need anything
> > because it's referring specifically to the (single) use of $2 in the
> > example. I have to presume the type inference happens before any structural
> > changes that might change the meaning of "first occurrence".
> 
> Great, patch applied through 9.3.  I also changed "used" to
> "referenced":
> 
> 	https://git.postgresql.org/pg/commitdiff/b284262e40424daa1c546ad76f365b31304d7944

Sorry, reporting credit should have gone to Nick Farmer.

-- 
  Bruce Momjian  <[email protected]>        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 +





^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2018-08-09 14:15 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-07-23 09:14 Parameter types are inferred from context of first use only. PG Doc comments form <[email protected]>
2018-08-08 17:24 ` Bruce Momjian <[email protected]>
2018-08-09 00:18   ` Morgan Owens <[email protected]>
2018-08-09 14:14     ` Bruce Momjian <[email protected]>
2018-08-09 14:15       ` Bruce Momjian <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox