Обсуждение: Broken example in PL/PgSQL documentation
Hi, Just came across a broken example in the docs: local:marko=#* select * from extended_sales(1); ERROR: column reference "quantity" is ambiguous LINE 1: SELECT quantity, quantity * price FROM sales ^ DETAIL: It could refer to either a PL/pgSQL variable or a table column. QUERY: SELECT quantity, quantity * price FROM sales WHERE itemno = p_itemno CONTEXT: PL/pgSQL function "extended_sales" line 3 at RETURN QUERY Patch to fix this attached. .marko
Вложения
>Just came across a broken example in the docs:
> local:marko=#* select * from extended_sales(1);
> ERROR: column reference "quantity" is ambiguous
> LINE 1: SELECT quantity, quantity * price FROM sales
^
> DETAIL: It could refer to either a PL/pgSQL variable or a table column.
> QUERY: SELECT quantity, quantity * price FROM sales
> WHERE itemno = p_itemno
> CONTEXT: PL/pgSQL function "extended_sales" line 3 at RETURN QUERY
> Patch to fix this attached.
Patch will surely fix the broken example, however I
SELECT s.quantity, s.quantity * s.price FROM sales s
WHERE s.itemno = p_itemno;
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
> local:marko=#* select * from extended_sales(1);
> ERROR: column reference "quantity" is ambiguous
> LINE 1: SELECT quantity, quantity * price FROM sales
^
> DETAIL: It could refer to either a PL/pgSQL variable or a table column.
> QUERY: SELECT quantity, quantity * price FROM sales
> WHERE itemno = p_itemno
> CONTEXT: PL/pgSQL function "extended_sales" line 3 at RETURN QUERY
> Patch to fix this attached.
Patch will surely fix the broken example, however I
am wondering if it is better to write the query using
alias.
..SELECT s.quantity, s.quantity * s.price FROM sales s
WHERE s.itemno = p_itemno;
Note - I have cc'ed to hackers as the review for CF patches
are posted on hackers list.
With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com
On Thu, Sep 4, 2014 at 3:06 PM, Marko Tiikkaja <marko@joh.to> wrote: > Just came across a broken example in the docs +1. New version works. I would slightly prefer adding an alias to the table: RETURN QUERY SELECT s.quantity, s.quantity * s.price FROM sales AS s WHERE s.itemno = p_itemno; Other than that, there's not much to review here, marking as "Ready for Committer" Alternative patch attached, let the committer decide. Regards, Marti
Вложения
2014-10-08 21:25 GMT+02:00 Marti Raudsepp <marti@juffo.org>:
On Thu, Sep 4, 2014 at 3:06 PM, Marko Tiikkaja <marko@joh.to> wrote:
> Just came across a broken example in the docs
+1. New version works. I would slightly prefer adding an alias to the table:
RETURN QUERY SELECT s.quantity, s.quantity * s.price FROM sales AS s
WHERE s.itemno = p_itemno;
Other than that, there's not much to review here, marking as "Ready
for Committer"
This last patch is good. I it good fix of this problem - and usage of qualified identifiers is common and recommended solution.
It is really ready for commiter.
Regards
Pavel
Pavel
Alternative patch attached, let the committer decide.
Regards,
Marti
--
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs
On Fri, Oct 10, 2014 at 2:37 AM, Pavel Stehule <pavel.stehule@gmail.com> wrote: > > > 2014-10-08 21:25 GMT+02:00 Marti Raudsepp <marti@juffo.org>: >> >> On Thu, Sep 4, 2014 at 3:06 PM, Marko Tiikkaja <marko@joh.to> wrote: >> > Just came across a broken example in the docs >> >> +1. New version works. I would slightly prefer adding an alias to the >> table: >> >> RETURN QUERY SELECT s.quantity, s.quantity * s.price FROM sales AS s >> WHERE s.itemno = p_itemno; >> >> Other than that, there's not much to review here, marking as "Ready >> for Committer" > > > This last patch is good. I it good fix of this problem - and usage of > qualified identifiers is common and recommended solution. > > It is really ready for commiter. Applied. Thanks! Regards, -- Fujii Masao