Bug(?) in pg_get_ruledef() - Mailing list pgsql-hackers

From Zakkr
Subject Bug(?) in pg_get_ruledef()
Date
Msg-id Pine.LNX.3.96.991027123327.6743A-100000@ara.zf.jcu.cz
Whole thread Raw
Responses view vs. inheritance hierarchy (was: Bug(?) in pg_get_ruledef())  (Zakkr <zakkr@zf.jcu.cz>)
List pgsql-hackers

Hi,

I try dump (via pg_dump) my database, but if I write dumped data back to DB,
views (as select on ingerit table) not work.

The bug is in routine pg_get_ruledef(pg_rewrite.rulename), which _not_
discern between select on standard table and select on inderit table.
Select on inherit table is "SELECT * FROM table*", but pg_get_ruledef()
return this view definition without asterisk: "SELECT * FROM table".

See example:
-----------  
abil=> create table mother_tab (aaa int);
CREATE

abil=> create table son () inherits(mother_tab);
CREATE

abil=> create view v_mother as select * from mother_tab*;
CREATE

abil=> insert into son values (111);
INSERT 4946878 1

abil=> select * from v_mother;
aaa
---
111
(1 row)

abil=> SELECT pg_get_ruledef(pg_rewrite.rulename) FROM pg_rewrite WHERE
rulename ='_RETv_mother';
CREATE RULE "_RETv_mother" AS ON SELECT TO "v_mother" DO INSTEAD SELECT
"mother_tab"."aaa" FROM "mother_tab";
(1 row)                        ^^^^^^^^^^^^        right is "mother_tab*"

-----
Is it but?
(It is probably fatal bug if somebody backup batabase via pg_dump and views
from dump is unavailable.)          

                    Karel Z.


------------------------------------------------------------------------------
<zakkr@zf.jcu.cz>                                http://home.zf.jcu.cz/~zakkr/

Kim Project:  http://home.zf.jcu.cz/~zakkr/kim/              (process manager)
FTP:          ftp://ftp2.zf.jcu.cz/users/zakkr/              (C/ncurses/PgSQL)
------------------------------------------------------------------------------
       ...and cathedral dilapidate
 



pgsql-hackers by date:

Previous
From: "Hiroshi Inoue"
Date:
Subject: RE: System indexes are never unique indexes( was RE: [HACKERS] mdnblocksis
Next
From: Keith Parks
Date:
Subject: Syntax error in psqlHelp.h