Re: BUG #14104: PREPARE document has a missing parameter in one of the examples

Lists: Postg토토 꽁 머니SQL : Postg토토 꽁 머니SQL 메일 링리스트 : 2016-04-21 이후 PGSQL-BUGS 21:50
From: hus787(at)gmail(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #14104: PREPARE document has a missing parameter in one of the examples
Date: 2016-04-20 13:06:28
Message-ID: 20160420130628.22913.76672@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 14104
Logged by: Hussain Parsaiyan
Email address: hus787(at)gmail(dot)com
PostgreSQL version: 9.5.2
Operating system: MacOSX
Description:

The second example here:
http://www.postgresql.org/docs/9.4/static/sql-prepare.html

```
PREPARE usrrptplan (int) AS
SELECT * FROM users u, logs l WHERE u.usrid=$1 AND u.usrid=l.usrid
AND l.date = $2;
EXECUTE usrrptplan(1, current_date);
```

`usrrptplan` should take in too arguments.


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: hus787(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14104: PREPARE document has a missing parameter in one of the examples
Date: 2016-04-21 21:50:15
Message-ID: 23196.1461275415@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: Postg토토 꽁 머니SQL : Postg토토 꽁 머니SQL 메일 링리스트 : 2016-04-21 이후 PGSQL-BUGS 21:50

hus787(at)gmail(dot)com writes:
> The second example here:
> http://www.postgresql.org/docs/9.4/static/sql-prepare.html

> ```
> PREPARE usrrptplan (int) AS
> SELECT * FROM users u, logs l WHERE u.usrid=$1 AND u.usrid=l.usrid
> AND l.date = $2;
> EXECUTE usrrptplan(1, current_date);
> ```

> `usrrptplan` should take in too arguments.

No, it's intentionally that way; the point of the example is to show
that you can let the parser infer the types of arguments if you like.
Note the subsequent para:

Note that the data type of the second parameter is not specified,
so it is inferred from the context in which $2 is used.

regards, tom lane