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