Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XPVoR-0007AG-Ru for pgsql-docs@arkaria.postgresql.org; Thu, 04 Sep 2014 12:06:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XPVoR-0000M9-CH for pgsql-docs@arkaria.postgresql.org; Thu, 04 Sep 2014 12:06:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XPVoQ-0000M3-Q6 for pgsql-docs@postgresql.org; Thu, 04 Sep 2014 12:06:50 +0000 Received: from mail-la0-f50.google.com ([209.85.215.50]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XPVoJ-0002ro-53 for pgsql-docs@postgresql.org; Thu, 04 Sep 2014 12:06:49 +0000 Received: by mail-la0-f50.google.com with SMTP id mc6so11645743lab.37 for ; Thu, 04 Sep 2014 05:06:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:content-type; bh=Q5NHVgKI0xR++Upswhux4bMff4W4yXrYOvaELodgOpg=; b=A6+0lEaHAe1s9HzUmaRD+uYHSpGjcmO2eZH7zjbyf+pQosPbXCdJDqqMxFS2BmUezg JZydfmbM4kj4lFMLxNll6Se1gGVdLDBD1AIGhfnoFUBRWvkFe1G/XJ82ZLQlIL+mgxNG pTj06rz/FEdtv/g5zJq0rabaUMomnLqfVZ0zebgDEY3gOiWTvNmMbqB5eo7YzaEgJqXU t0L4S8B0hnCjpkFhtC2u/DR2JZ5TOBmWkyxxqVTzJe9LeFL6uzMudRy/kZmwv/7M0U6z EFB8ZECEUgSmuEUDgCbwnnrO5DKen08i01c0g4GNDIUKAJpK6WDBw3MwR7eeB7FTgFxr 4xaQ== X-Gm-Message-State: ALoCoQm7Dwni5G7+P37uNZWmncMkfOo35DT9VeSJOf9i8MYf4f62hcPFVnz+BJltnZc/IaGDdWWs X-Received: by 10.112.160.38 with SMTP id xh6mr3949185lbb.21.1409832401408; Thu, 04 Sep 2014 05:06:41 -0700 (PDT) Received: from Markos-MacBook-Pro.local ([46.246.117.202]) by mx.google.com with ESMTPSA id k2sm438439lbt.40.2014.09.04.05.06.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Sep 2014 05:06:40 -0700 (PDT) Message-ID: <540855D0.4020108@joh.to> Date: Thu, 04 Sep 2014 14:06:40 +0200 From: Marko Tiikkaja User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 MIME-Version: 1.0 To: PG Docs Subject: Broken example in PL/PgSQL documentation Content-Type: multipart/mixed; boundary="------------070300040209030209020507" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-docs Precedence: bulk Sender: pgsql-docs-owner@postgresql.org This is a multi-part message in MIME format. --------------070300040209030209020507 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------070300040209030209020507 Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="plpgsql_return_query.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="plpgsql_return_query.patch" *** 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; --- 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; --------------070300040209030209020507 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-docs --------------070300040209030209020507--