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)