pg_get_viewdef returns one paren too much

From: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: laurie(dot)burrow(at)powerconv(dot)alstom(dot)com, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: pg_get_viewdef returns one paren too much
Date: 2004-12-10 13:55:01
Message-ID: 41B9AAB5.4030900@pse-consulting.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support pgsql-patches

laurie(dot)burrow(at)powerconv(dot)alstom(dot)com noticed a problem with pg_get_viewdef
in prettyprint mode.

create table gnrcitm (gnrcitmid int);
create table gnrcitmothrref (idntfyrefid int, gnrcitmid int);
create table other_ref(idntfyrefid int, catnmeclssid text, actvle text);

CREATE OR REPLACE VIEW test_view AS
SELECT or0.actvle AS treename
FROM gnrcitm g
LEFT JOIN (gnrcitmothrref g0
JOIN other_ref r0 ON g0.idntfyrefid = r0.idntfyrefid AND
r0.catnmeclssid::text = 'Tree Name'::text) or0
ON g.gnrcitmid = or0.gnrcitmid;

pg_get_viewdef(viewoid, true) will return

CREATE OR REPLACE VIEW test_view AS
SELECT or0.actvle AS treename
FROM gnrcitm g
LEFT JOIN
( -- <<<
(gnrcitmothrref g0
JOIN other_ref r0 ON g0.idntfyrefid = r0.idntfyrefid AND
r0.catnmeclssid = 'Tree Name'::text) or0
) -- <<<
ON g.gnrcitmid = or0.gnrcitmid;

The attached patch corrects this, without affecting the following:

CREATE OR REPLACE VIEW test_view2 AS
SELECT r0.actvle AS treename
FROM gnrcitm g
LEFT JOIN (gnrcitmothrref g0
JOIN other_ref r0 ON g0.idntfyrefid = r0.idntfyrefid AND
r0.catnmeclssid::text = 'Tree Name'::text)
ON g.gnrcitmid = g0.gnrcitmid

Regards,
Andreas

Attachment Content-Type Size
ruleutils.diff text/x-patch 634 bytes

In response to

Responses

Browse pgadmin-support by date

  From Date Subject
Next Message Raphaël Enrici 2004-12-11 09:38:39 Re: [pgadmin-support] crash
Previous Message Andreas Pflug 2004-12-10 11:34:15 Re: Reverse engineering problem on views

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Dunstan 2004-12-11 00:57:40 Re: regression script/makefile exit failure
Previous Message Andreas Pflug 2004-12-10 11:34:15 Re: Reverse engineering problem on views