From: | Steve Prentice <prentice(at)cisco(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | plpgsql + named parameters |
Date: | 2009-05-19 21:59:22 |
Message-ID: | 23C802EC-965D-494E-BE2F-39D604A51785@cisco.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I followed the past discussions regarding the syntax for named
parameters and I am currently using Pavel Stehule's patch for named
and mixed notation on top of the 8.4 beta.
It seems the way plpgsql substitutes $1, $2, etc for the parameters is
going to reduce the usefulness of this feature. Consider these two
functions:
CREATE FUNCTION fun1(a INT DEFAULT 1) RETURNS INT AS 'SELECT $1'
LANGUAGE SQL;
CREATE FUNCTION fun2(a INT) RETURNS INT AS $$
DECLARE
t INT;
BEGIN
t := fun1(1 as a); -- syntax error: "SELECT fun1(1 as $1 )"
t := fun1(a as a); -- syntax error: "SELECT fun1( $1 as $1 )"
RETURN 0;
END;
$$ LANGUAGE plpgsql;
I would think this would be a very common scenario where one function
calls another similar function that has similar parameter names.
Am I missing something or are there any obvious solutions to this?
Pavel's patch:
http://archives.postgresql.org/message-id/162867790903042341o477b115dtb6b351dd8ff758cc@mail.gmail.com
Thanks,
-Steve
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2009-05-20 01:42:12 | Re: plpgsql + named parameters |
Previous Message | Adriano Lange | 2009-05-19 21:48:09 | Re: GEQO: ERX |