Re: autogenerated column names + views are a dump hazard

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: kathy(dot)forte(at)2ndquadrant(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: autogenerated column names + views are a dump hazard
Date: 2015-03-02 21:32:53
Message-ID: 11719.1425331973@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andres Freund <andres(at)2ndquadrant(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-03-02 21:42:35 Re: How about to have relnamespace and relrole?
Previous Message Tom Lane 2015-03-02 21:26:22 Why are json <=> jsonb casts marked as explicit-only?