From: | "eutm" <eutm(at)yandex(dot)ru> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Bug of PL/pgSQL parser |
Date: | 2002-07-12 10:31:18 |
Message-ID: | 3D2EAFF6.000009.21733@ariel.yandex.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Dear Sirs!:)I encounted one small problem,working with
PostgreSQL 7.3devel.It can look a
bit strange,but i have to use whitespaces in names of databases,tables,fields
and so on(like "roomno jk").It's possible to create them all and work with them
(INSERT,DELETE,UPDATE),but PL/pgSQL parser(compiler ?) can't execute such
statements.To explain the problem, I took and changed next examples from
pgsql/src/pl/plpgsql/test:
-- ************************************************************
-- * Tables for the patchfield test of PL/pgSQL
-- * $Header: /projects/cvsroot/pgsql/src/pl/plpgsql/test/tables.sql,v 1.1 1998/08/24 19:16:27 momjian Exp $
-- ************************************************************
create table Room (
"roomno jk" char(8), --- common SQL parser eats it
comment text
);
create unique index Room_rno on Room using btree ("roomno jk" bpchar_ops);
create table WSlot (
slotname char(20),
"roomno jk" char(8), --- common SQL parser eats it
slotlink char(20),
backlink char(20)
);
create unique index WSlot_name on WSlot using btree (slotname bpchar_ops);
You also can use such "roomno jk" in DECLARATION of PL/pgSQL procedures and functions :
-- ************************************************************
-- * Trigger procedures and functions for the patchfield
-- * test of PL/pgSQL
-- * $Header: /projects/cvsroot/pgsql/src/pl/plpgsql/test/triggers.sql,v 1.2 2000/10/22 23:25:11 tgl Exp $
-- ************************************************************
-- * AFTER UPDATE on Room
-- * - If room no changes let wall slots follow
-- ************************************************************
PL/pgSQL eats it,he will cry during execution.
create function tg_room_au() returns opaque as '
begin
if new."roomno jk" != old."roomno jk" then
update WSlot set "roomno jk" = new."roomno jk" where "roomno jk" = old."roomno jk";
end if;
return new;
end;
' language 'plpgsql';
create trigger tg_room_au after update
on Room for each row execute procedure tg_room_au();
-- ************************************************************
-- * BEFORE INSERT or UPDATE on WSlot
-- * - Check that room exists
-- ************************************************************
PL/pgSQL also eats it,he will cry during execution.
create function tg_wslot_biu() returns opaque as '
begin
if count(*) = 0 from Room where "roomno jk" = new."roomno jk" then
raise exception ''Room % does not exist'', new."roomno jk";
end if;
return new;
end;
' language 'plpgsql';
create trigger tg_wslot_biu before insert or update
on WSlot for each row execute procedure tg_wslot_biu();
Then do next:
insert into Room values ('001', 'Entrance'); --Everything is ok
Then do it and catch failure:
insert into WSlot values ('WS.001.1a', '001', '', '');
PostgreSQL returns :
psql:/home/eu/SQL/plt/p_test.sql:19: ERROR: parse error at or near "new"
psql:/home/eu/SQL/plt/p_test.sql:20: WARNING: plpgsql: ERROR during compile of tg_wslot_biu near line 3
As you see there's no support for "roomno jk" in PL/pgSQL parser.
To this moment i know nothing serious about flex,lex and yacc,but
a simple look at PL/pgSQL parser shows,that situations of
"roomno jk" are just undefined there.
regards,Eugene
P.S.In case you make patch,please,send me a copy.
From | Date | Subject | |
---|---|---|---|
Next Message | Luis Alberto Amigo Navarro | 2002-07-12 11:37:47 | Re: [HACKERS] please help on query |
Previous Message | Tina Messmann | 2002-07-12 09:24:08 | Re: Jan's Name (Was: Re: I am being interviewed by OReilly) |