On 2015-03-02 16:32:53 -0500, Tom Lane wrote: > Andres Freund <and...@2ndquadrant.com> writes: > > 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 :-(.
Hm, so I looked into it, and I think the problem is actually restricted to columns where the typename that FigureColname() assigns is different from the one that will result after ger_rule_expr()/get_const_expr()'s implicit cast is added. For this case it seems easiest if we'd make get_rule_expr() (and some of its helpers) return whether an implicit cast has been added. Whenever an implicit cast is added in the target list we should add an alias - as the generated column name will be different from before. That's a bit invasive, but doesn't seem too bad. A quick hack doing so shows that there's no changes in the regression output when doing it for consts. > 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. I don't think looking for referenced columns is actually sufficient, unless you define "referenced" pretty widely at least. Before the dump CREATE VIEW ... AS SELECT '2' ORDER BY 1; will yield a '?column?' columnname. After a dump/restore it'll be 'text'. That doesn't seem desireable. Greetings, Andres Freund -- Andres Freund http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers