Re: BUG #4629: PL/pgSQL issue - Mailing list pgsql-bugs

From Pavel Stehule
Subject Re: BUG #4629: PL/pgSQL issue
Date
Msg-id 162867790902021143p4e89dcabpc054d9fdcdb7acad@mail.gmail.com
Whole thread Raw
In response to Re: BUG #4629: PL/pgSQL issue  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #4629: PL/pgSQL issue  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
Hello

2009/2/2 Tom Lane <tgl@sss.pgh.pa.us>:
> "Martin Blazek" <mblazek@8bc.com> writes:
>> CREATE FUNCTION test() RETURNS integer AS $$
>> BEGIN
>> CREATE RULE "rule" AS ON INSERT TO "test" DO INSTEAD INSERT INTO "test"
>> VALUES (1);
>> END;$$ LANGUAGE plpgsql;
>
> Hm, I guess nobody ever tried to do that in plpgsql before.  It's
> taking the INTO as starting a clause that returns values into plpgsql
> variables :-(.
>
> There's a special case in there to prevent INTO just after INSERT
> from being taken that way, but it only works when the INSERT is at
> the start of the statement :-(.  Guess we need to change that.
>
> In the meantime, you can probably work around this by using EXECUTE,
> ie
>

We should ignore INTO keyword when statement starts with CREATE
keyword. This patch have to simple. I'll prepare it.

Regards
Pavel Stehule

> EXECUTE 'CREATE RULE "rule" AS ON INSERT TO "test" DO INSTEAD INSERT INTO "test" VALUES (1)';
>
>                        regards, tom lane
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #4629: PL/pgSQL issue
Next
From: Tom Lane
Date:
Subject: Re: BUG #4629: PL/pgSQL issue