Re: autogenerated column names + views are a dump hazard - Mailing list pgsql-hackers

From Tom Lane
Subject Re: autogenerated column names + views are a dump hazard
Date
Msg-id 11719.1425331973@sss.pgh.pa.us
Whole thread Raw
In response to autogenerated column names + views are a dump hazard  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: autogenerated column names + views are a dump hazard  (Andres Freund <andres@2ndquadrant.com>)
Re: autogenerated column names + views are a dump hazard  (Andres Freund <andres@2ndquadrant.com>)
List pgsql-hackers
Andres Freund <andres@2ndquadrant.com> writes:
> CREATE VIEW v_03 AS
> SELECT * FROM (SELECT '2' ORDER BY 1) s;

> View definition:
>  SELECT s."?column?"
>    FROM ( SELECT '2'::text
>           ORDER BY '2'::text) s;

> Note the added cast to determine the type of the expression and the
> generated column name.

Meh.

> The easiest way to solve this would teach ruleutils.c to simply always
> attach AS clauses for auto-generated columnnames. Won't look too pretty
> though. Does somebody have a better idea?

No, it would look awful :-(.  But I think we might have enough
infrastructure in there to notice whether the column is actually
referenced or not.  So we could label the columns only if necessary,
which would at least limit the ugliness.

Another idea would be to reconsider whether we need to force display
of the cast, though I'm a bit worried about the possible side-effects.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Why are json <=> jsonb casts marked as explicit-only?
Next
From: Robert Haas
Date:
Subject: Re: How about to have relnamespace and relrole?