pg.ddx.io pgsql-docs@postgresql.org mailing list archive
help / color / mirror / Atom feedBroken example in PL/PgSQL documentation
4+ messages / 4 participants
[nested] [flat]
* Broken example in PL/PgSQL documentation
@ 2014-09-04 12:06 Marko Tiikkaja <marko@joh.to>
0 siblings, 1 reply; 4+ messages in thread
From: Marko Tiikkaja @ 2014-09-04 12:06 UTC (permalink / raw)
To: pgsql-docs
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
--
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs
Attachments:
plpgsql_return_query.patch (text/plain, 686B) download
*** a/doc/src/sgml/plpgsql.sgml
--- b/doc/src/sgml/plpgsql.sgml
***************
*** 487,494 **** $$ LANGUAGE plpgsql;
CREATE FUNCTION extended_sales(p_itemno int)
RETURNS TABLE(quantity int, total numeric) AS $$
BEGIN
! RETURN QUERY SELECT quantity, quantity * price FROM sales
! WHERE itemno = p_itemno;
END;
$$ LANGUAGE plpgsql;
</programlisting>
--- 487,494 ----
CREATE FUNCTION extended_sales(p_itemno int)
RETURNS TABLE(quantity int, total numeric) AS $$
BEGIN
! RETURN QUERY SELECT sales.quantity, sales.quantity * sales.price FROM sales
! WHERE sales.itemno = p_itemno;
END;
$$ LANGUAGE plpgsql;
</programlisting>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Broken example in PL/PgSQL documentation
@ 2014-10-08 19:25 Marti Raudsepp <marti@juffo.org>
parent: Marko Tiikkaja <marko@joh.to>
0 siblings, 1 reply; 4+ messages in thread
From: Marti Raudsepp @ 2014-10-08 19:25 UTC (permalink / raw)
To: Marko Tiikkaja <marko@joh.to>; +Cc: pgsql-docs
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
--
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs
Attachments:
0001-Fix-PL-pgSQL-ambiguity-in-RETURNS-TABLE-example.patch (text/x-patch, 914B) download
From 1f90090a65c48bba0057b3866f454e28e3f45f55 Mon Sep 17 00:00:00 2001
From: Marti Raudsepp <marti@juffo.org>
Date: Wed, 8 Oct 2014 22:23:43 +0300
Subject: [PATCH] Fix PL/pgSQL ambiguity in RETURNS TABLE example
Author: Marko Tiikkaja
---
doc/src/sgml/plpgsql.sgml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml
index f008e93..f195495 100644
--- a/doc/src/sgml/plpgsql.sgml
+++ b/doc/src/sgml/plpgsql.sgml
@@ -487,8 +487,8 @@ $$ LANGUAGE plpgsql;
CREATE FUNCTION extended_sales(p_itemno int)
RETURNS TABLE(quantity int, total numeric) AS $$
BEGIN
- RETURN QUERY SELECT quantity, quantity * price FROM sales
- WHERE itemno = p_itemno;
+ RETURN QUERY SELECT s.quantity, s.quantity * s.price FROM sales AS s
+ WHERE s.itemno = p_itemno;
END;
$$ LANGUAGE plpgsql;
</programlisting>
--
2.1.2
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Broken example in PL/PgSQL documentation
@ 2014-10-09 17:37 Pavel Stehule <pavel.stehule@gmail.com>
parent: Marti Raudsepp <marti@juffo.org>
0 siblings, 1 reply; 4+ messages in thread
From: Pavel Stehule @ 2014-10-09 17:37 UTC (permalink / raw)
To: Marti Raudsepp <marti@juffo.org>; +Cc: Marko Tiikkaja <marko@joh.to>; pgsql-docs
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
>
> 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
>
>
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Broken example in PL/PgSQL documentation
@ 2014-10-09 18:23 Fujii Masao <masao.fujii@gmail.com>
parent: Pavel Stehule <pavel.stehule@gmail.com>
0 siblings, 0 replies; 4+ messages in thread
From: Fujii Masao @ 2014-10-09 18:23 UTC (permalink / raw)
To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: Marti Raudsepp <marti@juffo.org>; Marko Tiikkaja <marko@joh.to>; 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
--
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docs
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2014-10-09 18:23 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-09-04 12:06 Broken example in PL/PgSQL documentation Marko Tiikkaja <marko@joh.to>
2014-10-08 19:25 ` Marti Raudsepp <marti@juffo.org>
2014-10-09 17:37 ` Pavel Stehule <pavel.stehule@gmail.com>
2014-10-09 18:23 ` Fujii Masao <masao.fujii@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox