The following bug has been logged online:
Bug reference: 4629
Logged by: Martin Blazek
Email address: mblazek@8bc.com
PostgreSQL version: 8.3.5
Operating system: Windows XP
Description: PL/pgSQL issue
Details:
I try to create the following rule. It doesn't make much sense, but the
syntax is ok and if the table "test" exists, it is created.
CREATE RULE "rule" AS ON INSERT TO "test" DO INSTEAD INSERT INTO "test"
VALUES (1);
The next step is creating a function that contains only the following
command:
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;
Wow! Here's the result (already on function create, not during runtime):
ERROR: syntax error at ""test""
DETAIL: Expected record variable, row variable, or list of scalar variables
following INTO.
KONTEXT: compile of PL/pgSQL function "test" near line 2
It appears that only insert rules have this issue - update and delete work
as expected.