Thread
-
Re: [HACKERS] 6.5 cvs: views doesn't survives after pg_dump (fwd)
Keith Parks <emkxp01@mtcc.demon.co.uk> — 1999-05-24T13:21:07Z
Jan, Have you any ideas on this? We get a rule output by pg_dump like :- CREATE RULE "_RETsongs" AS ON SELECT TO "songs" WHERE DO INSTEAD SELECT "t"."artist", "t"."song", "t"."trackno", "d"."cdname" FROM "disks" "d", "tracks" "t" WHERE "d"."diskid" = "t"."diskid"; from a view defined like so:- CREATE VIEW songs AS SELECT t.artist, t.song, t.trackno, d.cdname FROM disks d, tracks t WHERE d.diskid = t.diskid; Note the WHERE keyword in line 3 of the rule define. >From "./src/backend/utils/adt/ruleutils.c" line 662 of 1814 /* If the rule has an event qualification, add it */ if (ev_qual == NULL) ev_qual = ""; if (strlen(ev_qual) > 0) { Node *qual; Query *query; QryHier qh; . . strcat(buf, " WHERE "); strcat(buf, get_rule_expr(&qh, 0, qual, TRUE)); } strcat(buf, " DO "); /* The INSTEAD keyword (if so) */ if (is_instead) strcat(buf, "INSTEAD "); We put the WHERE in if strlen(ev_qual) > 0 I've not yet followed this back any further. Keith. ------------ Begin Forwarded Message ------------- X-Authentication-Warning: hub.org: majordom set sender to owner-pgsql-hackers@postgreSQL.org using -f Date: Fri, 21 May 1999 22:34:50 +0100 (BST) From: Keith Parks <emkxp01@mtcc.demon.co.uk> Subject: Re: [HACKERS] 6.5 cvs: views doesn't survives after pg_dump (fwd) To: pgsql-hackers@postgreSQL.org, oleg@sai.msu.su MIME-Version: 1.0 Content-MD5: 34XqWKKsmVlyonlE1gsMzw== Oleg Bartunov < oleg@sai.msu.su> > After dumping (by pg_dump) and restoring views becomes a tables > The problem is that views are dumped with anm extraneous "WHERE" > ............................ > QUERY: COPY "t1" FROM stdin; > CREATE RULE "_RETv1" AS ON SELECT TO "v1" WHERE DO INSTEAD SELECT "a" FROM "t1"; > QUERY: CREATE RULE "_RETv1" AS ON SELECT TO "v1" WHERE DO INSTEAD SELECT "a" FROM "t1"; ...................................................++++++ > ERROR: parser: parse error at or near "do" > EOF Which causes this error and the rule (View) is not Created. I don't know how the where clause gets in there but if you edit the dump before restoring all is OK. Keith. ------------- End Forwarded Message ------------- -
Re: [HACKERS] 6.5 cvs: views doesn't survives after pg_dump (fwd)
Jan Wieck <jwieck@debis.com> — 1999-05-25T08:14:22Z
> > Jan, > > Have you any ideas on this? Yepp > > We get a rule output by pg_dump like :- > > CREATE RULE "_RETsongs" AS > ON SELECT TO "songs" > WHERE DO INSTEAD > SELECT "t"."artist", "t"."song", "t"."trackno", "d"."cdname" > FROM "disks" "d", "tracks" "t" > WHERE "d"."diskid" = "t"."diskid"; > > from a view defined like so:- > > CREATE VIEW songs AS > SELECT t.artist, t.song, t.trackno, d.cdname > FROM disks d, tracks t > WHERE d.diskid = t.diskid; > > Note the WHERE keyword in line 3 of the rule define. > > >From "./src/backend/utils/adt/ruleutils.c" line 662 of 1814 > > /* If the rule has an event qualification, add it */ > if (ev_qual == NULL) > ev_qual = ""; > if (strlen(ev_qual) > 0) > { > Node *qual; > Query *query; > QryHier qh; > . > . That's exactly the location AFAICS. The problem was introduced when the storage of rules changed in that the event qualification is now stored as "<>" (the output of the node print functions for NULL) instead of a NULL attribute. I'll fix it soon - thanks. > > We put the WHERE in if strlen(ev_qual) > 0 > > I've not yet followed this back any further. > > Keith. Jan -- #======================================================================# # It's easier to get forgiveness for being wrong than for being right. # # Let's break this rule - forgive me. # #======================================== jwieck@debis.com (Jan Wieck) #