Re: [HACKERS] autogenerated column names + views are a dump hazard

2015-03-03 Thread Andres Freund
On 2015-03-03 11:09:29 -0500, Tom Lane wrote: > Andres Freund writes: > > On 2015-03-03 09:39:03 -0500, Tom Lane wrote: > > I think this is the way to go though. There's different extremes we can > > go to though - the easiest is to simply remove the attname = "?column?" > > assignment from get_ta

Re: [HACKERS] autogenerated column names + views are a dump hazard

2015-03-03 Thread Tom Lane
Andres Freund writes: > On 2015-03-03 09:39:03 -0500, Tom Lane wrote: >> And on the third hand ... doing that would really only be robust as long >> as you assume that the output will be read by a server using exactly the >> same FigureColname() logic as what we are using. So maybe the whole idea

Re: [HACKERS] autogenerated column names + views are a dump hazard

2015-03-03 Thread Andres Freund
On 2015-03-03 09:39:03 -0500, Tom Lane wrote: > Andres Freund writes: > > 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. > > Aside from being pretty ugly, that doesn't seem particularly > bulletproof. Right

Re: [HACKERS] autogenerated column names + views are a dump hazard

2015-03-03 Thread Tom Lane
Andres Freund writes: > 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 eas

Re: [HACKERS] autogenerated column names + views are a dump hazard

2015-03-03 Thread Andres Freund
On 2015-03-02 16:32:53 -0500, Tom Lane wrote: > Andres Freund 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 :-

Re: [HACKERS] autogenerated column names + views are a dump hazard

2015-03-02 Thread Andres Freund
On 2015-03-02 16:32:53 -0500, Tom Lane wrote: > Andres Freund 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 :-

Re: [HACKERS] autogenerated column names + views are a dump hazard

2015-03-02 Thread Tom Lane
Andres Freund 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. >

[HACKERS] autogenerated column names + views are a dump hazard

2015-03-02 Thread Andres Freund
Hi, Kathy (CCed) just found a bug in BDR that turned out to actually be a bug in postgres. CREATE VIEW v_03 AS SELECT * FROM (SELECT '2' ORDER BY 1) s; postgres[l]=# \d+ v_03 View "public.v_03" ┌──┬──┬───┬──┬─┐ │ Column │ Type │ Modifi