Patch for cursor calling with named parameters

Lists: pgsql-hackers
From: Yeb Havinga <yebhavinga(at)gmail(dot)com>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Patch for cursor calling with named parameters
Date: 2011-09-15 08:18:12
Message-ID: 4E71B4C4.3010004@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello list,

The following patch implements cursor calling with named parameters in
addition to the standard positional argument lists.

c1 cursor (param1 int, param2 int) for select * from rc_test where a >
param1 and b > param2;
open c1($1, $2); -- this is currently possible
open c1(param2 := $2, param1 := $1); -- this is the new feature

Especially for cursors with a lot of arguments, this increases
readability of code. This was discussed previously in
http://archives.postgresql.org/pgsql-hackers/2010-09/msg01433.php. We
actually made two patches: one with => and then one with := notation.
Attached is the patch with := notation.

Is it ok to add it to the next commitfest?

regards,
Yeb Havinga, Willem Dijkstra

--
Yeb Havinga
http://www.mgrid.net/
Mastering Medical Data

Attachment Content-Type Size
cursornamedparameter-v1.patch text/x-patch 14.0 KB

From: Cédric Villemain <cedric(dot)villemain(dot)debian(at)gmail(dot)com>
To: Yeb Havinga <yebhavinga(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Patch for cursor calling with named parameters
Date: 2011-09-15 14:31:53
Message-ID: CAF6yO=066NxvXn40+5jUwY_wPHkQuY0fFfbjbYfRrdhCY4_dZw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2011/9/15 Yeb Havinga <yebhavinga(at)gmail(dot)com>:
> Hello list,
>
> The following patch implements cursor calling with named parameters in
> addition to the standard positional argument lists.
>
> c1 cursor (param1 int, param2 int) for select * from rc_test where a >
> param1 and b > param2;
> open c1($1, $2);                     -- this is currently possible
> open c1(param2 := $2, param1 := $1); -- this is the new feature
>
> Especially for cursors with a lot of arguments, this increases readability
> of code. This was discussed previously in
> http://archives.postgresql.org/pgsql-hackers/2010-09/msg01433.php. We
> actually made two patches: one with => and then one with := notation.
> Attached is the patch with := notation.
>
> Is it ok to add it to the next commitfest?

I think it is, as you have provided a patch.

There exist also a mecanism to order the parameters of 'EXECUTE ...
USING ...' (it's using a cursor), can the current work benefit to
EXECUTE USING to use named parameters ?

> regards,
> Yeb Havinga, Willem Dijkstra
>
> --
> Yeb Havinga
> http://www.mgrid.net/
> Mastering Medical Data
>
>
>
> --
> Sent via pgsql-hackers mailing list (pgsql-hackers(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-hackers
>
>

--
Cédric Villemain +33 (0)6 20 30 22 52
http://2ndQuadrant.fr/
PostgreSQL: Support 24x7 - Développement, Expertise et Formation


From: Yeb Havinga <yebhavinga(at)gmail(dot)com>
To: Cédric Villemain <cedric(dot)villemain(dot)debian(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Patch for cursor calling with named parameters
Date: 2011-09-15 15:30:56
Message-ID: 4E721A30.1040404@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2011-09-15 16:31, Cédric Villemain wrote:
> There exist also a mecanism to order the parameters of 'EXECUTE ...
> USING ...' (it's using a cursor), can the current work benefit to
> EXECUTE USING to use named parameters ?

I looked at it a bit but it seems there is no benefit, since the dynamic
sql handling vs the cursor declaration and opening touch different code
paths in both the plpgsql grammar and the SPI functions that are called.

regards,
Yeb