From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | Steve Prentice <prentice(at)cisco(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: plpgsql + named parameters |
Date: | 2009-05-20 01:42:12 |
Message-ID: | b42b73150905191842u61427ef4tdaed29389602f302@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, May 19, 2009 at 5:59 PM, Steve Prentice <prentice(at)cisco(dot)com> wrote:
> 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 )"
you have a name conflict here...is it deliberate? I've learned the
hard way to always, always prefix arguments and locals to plpgsql
functions with '_'. Or are you trying to do something fancier?
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Bailey | 2009-05-20 06:42:27 | Re: INTERVAL SECOND limited to 59 seconds? |
Previous Message | Steve Prentice | 2009-05-19 21:59:22 | plpgsql + named parameters |