Re: Issue with circular references in VIEW

From: Gilles Darold <gilles(dot)darold(at)dalibo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Issue with circular references in VIEW
Date: 2017-07-24 18:43:10
Message-ID: ceaadb82-fa69-b5f1-349c-72d4ccf4c1ec@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Le 24/07/2017 à 19:19, Tom Lane a écrit :
> Gilles Darold <gilles(dot)darold(at)dalibo(dot)com> writes:
>> There is an issue with version prior to 10 when dumping views with circular
>> references. I know that these views are now exported as views in 10 but they
>> are still exported as TABLE + RULE in prior versions. This conduct to the
>> following error when columns of sub-queries doesn't have the same aliases
>> names:
> The core of this issue, I think, is that pg_get_viewdef() knows that it
> should make what it prints have output column names that match the view,
> whereas pg_get_ruledef() does not, even when it is printing an ON SELECT
> rule. This is a little bit surprising --- you'd really expect those
> functions to produce identical SELECT statements --- and I think it's
> likely to break other tools even if pg_dump has managed to skirt the
> issue. So I'm inclined to think in terms of fixing it at that level
> rather than in pg_dump. It doesn't look like it would be hard to fix:
> both functions ultimately call get_query_def(), it's just that one passes
> down a tuple descriptor for the view while the other currently doesn't.

I was thinking that this was intentional that pg_get_ruledef() returns
the raw code typed by the user. I will fix it and send a patch following
your explanation.

Thanks.

--
Gilles Darold
Consultant PostgreSQL
http://dalibo.com - http://dalibo.org

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2017-07-24 18:49:45 Re: Buildfarm failure and dubious coding in predicate.c
Previous Message Peter Eisentraut 2017-07-24 18:27:03 Re: Definitional questions for pg_sequences view