I understand now why Oracle use => symbol for named params. This isn't
used so operator - so implementation is trivial.
postgres=# create function x(a boolean) returns bool as $$select $1$$
language sql;
CREATE FUNCTION
Time: 5,549 ms
postgres=# select x(a => true);
x
---
t
(1 row)
Time: 0,566 ms
postgres=# select x(a => 0 >= 1);
x
---
f
(1 row)
Time: 0,772 ms
postgres=# select x(a => 0 <= 1);
x
---
t
(1 row)
Time: 0,633 ms
postgres=# select x(a => 0 <= 1);
it could live together with labels
postgres=# select x(a => 0 <= 1 as boo);
x
---
t
(1 row)
there are not any conflict. nice (operator => is never used).
I dislike to use AS for named params - it has some unhappy consequences:
a) it merge two features together (named params, labels),
b) when we disable @a, then we should implement only one feature - named params
c) @b isn't compatible with SQL/XML that is implemented now
I don't found any notice about db2 default parameters.
Named params needs different algorithm of searching in pg_proc. There
should be some new problems - like
create function foo(a integer, b integer);
select foo(10,10); -- ok
select foo(a => 10, b =>20); -- ok
select foo(b=>20, a =>20); -- ok
select foo(c=>20, 20); -- unknown fce !!!
Regards
Pavel Stehule
real gram implemenation:
param_list: param
{
$$ = list_make1($1);
}
| param_list ',' param
{
$$ = lappend($1, $3);
}
;
param:
a_expr
{
$$ = $1;
}
| param_name POINTER a_expr
{
$$ = $3;
}
| a_expr AS ColLabel
{
$$ = $1;
}
| param_name POINTER a_expr AS ColLabel
{
$$ = $3;
}
;
lexer
identifier {ident_start}{ident_cont}*
typecast "::"
pointer "=>"
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
No comments:
Post a Comment