From: | Andres Freund <andres(at)2ndquadrant(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
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-03 12:34:15 |
Message-ID: | 20150303123415.GH2579@alap3.anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2015-03-02 16:32:53 -0500, Tom Lane wrote:
> Andres Freund <andres(at)2ndquadrant(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Shigeru Hanada | 2015-03-03 12:34:44 | Re: Join push-down support for foreign tables |
Previous Message | Shigeru Hanada | 2015-03-03 12:25:43 | Re: Custom/Foreign-Join-APIs (Re: [v9.5] Custom Plan API) |