Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ub51k-0001xC-FS for pgsql-docs@arkaria.postgresql.org; Sat, 11 May 2013 08:19:36 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Ub51j-0002dt-Qf for pgsql-docs@arkaria.postgresql.org; Sat, 11 May 2013 08:19:35 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ub51i-0002dn-Oa for pgsql-docs@postgresql.org; Sat, 11 May 2013 08:19:35 +0000 Received: from mail-ee0-f44.google.com ([74.125.83.44]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Ub51f-0000D9-Ag for pgsql-docs@postgresql.org; Sat, 11 May 2013 08:19:34 +0000 Received: by mail-ee0-f44.google.com with SMTP id b57so545490eek.17 for ; Sat, 11 May 2013 01:19:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type:x-gm-message-state; bh=pWgQQCXAXBsE30m2mjcYAIqEHzx7ehhdxeKB5aHRrO8=; b=LsXO8n1N+mbu3KOcLhWXm+xXI67FJv2yPeJCaZIC9v0xIf4fn1BA4E5ebgTVfiOSD5 2po/F5pJhydh5hOcTSIi2ARO4TSPxtnLvwXViYN3/T8/VIhJYIkHWB64yB28il7Ae1jE AK4O3SQUPCbUU7kuIb8L36r4paSRS5cnKfan82+sORVRNyBdr4as6aWttfdNye0hvsO4 eiA2DkoYQhAvefMx22+UvMaOVOjMscuD5qP1BEV7KAnH4IQuLwkjBbs8zgqHECTu05R7 tHCy4nJ0lSBGy6IiZBHO3F5tOb513Mt9rqRaIsPTrRG4+n6jz2xn6091mNFd1NJZ0cnR pAig== X-Received: by 10.14.0.129 with SMTP id 1mr50542813eeb.43.1368260369463; Sat, 11 May 2013 01:19:29 -0700 (PDT) Received: from [192.168.2.100] (chello080109013165.10.14.univie.teleweb.at. [80.109.13.165]) by mx.google.com with ESMTPSA id m4sm8512677eeu.15.2013.05.11.01.19.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 11 May 2013 01:19:28 -0700 (PDT) Message-ID: <518DFF3E.90701@falter.at> Date: Sat, 11 May 2013 10:20:14 +0200 From: Erwin Brandstetter User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: Sian Mountbatten CC: pgsql-docs@postgresql.org Subject: Re: Reference function arguments by name References: <518C0B2B.9040909@falter.at> <518DFDAC.2060909@fastmail.co.uk> In-Reply-To: <518DFDAC.2060909@fastmail.co.uk> Content-Type: multipart/alternative; boundary="------------000608030209020503000208" X-Gm-Message-State: ALoCoQnTuUtMvrG9Awl7+ibNX133uDuEXz0bQj1FlfFQrmfTvcpTrRaPbRm7h1dDXLBG28Ac5+9h 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. --------------000608030209020503000208 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11.05.2013 10:13, Sian Mountbatten wrote: > On 2013-05-09 21:46, Erwin Brandstetter wrote: >> Hi! >> >> The manual says here: >> http://www.postgresql.org/docs/current/interactive/sql-createfunction.html >> http://www.postgresql.org/docs/devel/static/sql-createfunction.html >> >>> argname >>> >>> The name of an argument. Some languages (currently only >>> PL/pgSQL) let you use the name in the function body. For other >>> languages the name of an input argument is just extra >>> documentation, so far as the function itself is concerned; but >>> you can use input argument names when calling a function to >>> improve readability (see Section 4.3 >>> ). >>> In any case, the name of an output argument is significant, >>> because it defines the column name in the result row type. (If >>> you omit the name for an output argument, the system will choose >>> a default column name.) >>> >> >> This has changed in version 9.2. SQL functions can reference the >> name. Ergo: >> >> s /(currently only PL/pgSQL) / (currently only PL/pgSQL and SQL) >> >> >> I tested it and it's /correctly /documented here: >> http://www.postgresql.org/docs/current/interactive/xfunc-sql.html#XFUNC-SQL-FUNCTION-ARGUMENTS >> >> > Arguments of a SQL function can be referenced in the function body >> using either names or numbers. >> >> >> Regards >> Erwin > It looks strongly that you people are of the opinion that "the code > documents > itself". That is a myth produced by lazy software developers who > cannot document > their code properly. You ought to be using Cweb for C code. Have a look at > the code for SQLite to see how comments in C can be used to provide decent > documentation > > Fortunately, I do not use C. I prefer a HIGH-level language :-) This reply seems unrelated. Regards Erwin --------------000608030209020503000208 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

On 11.05.2013 10:13, Sian Mountbatten wrote:
On 2013-05-09 21:46, Erwin Brandstetter wrote:
Hi!

The manual says here:
http://www.postgresql.org/docs/current/interactive/sql-createfunction.html
http://www.postgresql.org/docs/devel/static/sql-createfunction.html

argname

The name of an argument. Some languages (currently only PL/pgSQL) let you use the name in the function body. For other languages the name of an input argument is just extra documentation, so far as the function itself is concerned; but you can use input argument names when calling a function to improve readability (see Section 4.3). In any case, the name of an output argument is significant, because it defines the column name in the result row type. (If you omit the name for an output argument, the system will choose a default column name.)


This has changed in version 9.2. SQL functions can reference the name. Ergo:

s /(currently only PL/pgSQL) / (currently only PL/pgSQL and SQL)


I tested it and it's correctly documented here:
http://www.postgresql.org/docs/current/interactive/xfunc-sql.html#XFUNC-SQL-FUNCTION-ARGUMENTS

> Arguments of a SQL function can be referenced in the function body using either names or numbers.


Regards
Erwin
It looks strongly that you people are of the opinion that "the code documents
itself". That is a myth produced by lazy software developers who cannot document
their code properly. You ought to be using Cweb for C code. Have a look at
the code for SQLite to see how comments in C can be used to provide decent
documentation

Fortunately, I do not use C. I prefer a HIGH-level language :-)

This reply seems unrelated.

Regards
Erwin
--------------000608030209020503000208--