Re: autogenerated column names + views are a dump hazard

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: autogenerated column names + views are a dump hazard
Дата
Msg-id 20150303123415.GH2579@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: autogenerated column names + views are a dump hazard  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: autogenerated column names + views are a dump hazard  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 2015-03-02 16:32:53 -0500, Tom Lane wrote:
> Andres Freund <andres@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



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Shigeru Hanada
Дата:
Сообщение: Re: Custom/Foreign-Join-APIs (Re: [v9.5] Custom Plan API)
Следующее
От: Shigeru Hanada
Дата:
Сообщение: Re: Join push-down support for foreign tables