Skip site navigation (1) Skip section navigation (2)

mixed, named notation support

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL-development Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: mixed, named notation support
Date: 2009-03-05 07:41:28
Message-ID: 162867790903042341o477b115dtb6b351dd8ff758cc@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
Hello

I did some cleaning on this feature, and I hope so I solve some Tom's objections

features:
 * PostgreSQL's specific syntax for named parameter: value AS name,
 * Doesn't change rules for defaults,
 * Get defaults for named, mixed notation in planner time.

ToDo: enhance documentation (any volunteer?)

regards
Pavel Stehule

CREATE FUNCTION fx(a int, b int, m int = 1, o int = 0) RETURNS int AS $$
    SELECT ($1 + $2) * $3 + $4
$$ LANGUAGE SQL;

-- positional notation
SELECT fx(10,20);
 fx
----
 30
(1 row)

SELECT fx(10,20,2,50);
  fx
-----
 110
(1 row)

-- named notation
SELECT fx(20 as b, 10 as a);
 fx
----
 30
(1 row)

SELECT fx(20 as b, 10 as a, 50 as o);
 fx
----
 80
(1 row)

-- mixed notation
SELECT fx(10,20, 10 as m);
 fx
-----
 300
(1 row)

SELECT fx(10,20, 50 as o, 2 as m);
 fx
-----
 110
(1 row)

Attachment: named_notation_20090305.01.diff
Description: text/x-patch (48.8 KB)

Responses

pgsql-hackers by date

Next:From: Heikki LinnakangasDate: 2009-03-05 07:57:35
Subject: Re: Use array in a dynamic statement
Previous:From: Xavier BugaudDate: 2009-03-05 07:39:33
Subject: Re: Patch for the MUST time zone (Mauritius Summer Time)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group