From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
Cc: | programble(at)gmail(dot)com, pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #12789: Views defined with VALUES lose their column names when dumped |
Date: | 2015-02-25 16:24:02 |
Message-ID: | 18995.1424881442@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> writes:
> For future reference and as a simpler testcase than the one in the
> script:
> # create view v1(a) as values (1);
> CREATE VIEW
> # select pg_get_viewdef('v1'::regclass);
> pg_get_viewdef
> ----------------
> VALUES (1);
> Notice that the column name "a" is lost. Since pg_dump and so on rely on
> pg_get_viewdef, dump and restore changes the column name back to
> "column1".
> The culprit is obviously in ruleutils.c:
> get_simple_values_rte/get_values_def, which mistakenly thinks it only
> has to deal with the result of transformValuesClause(), not considering
> that the result of transformValuesClause might have been further
> mogrified by DefineView. Treating this case as not being "simple" might
> be one approach... not sure of the best way to detect that.
Yeah --- we can check to see if the tlist resnames match what's in the
RTE. It turns out that get_from_clause_item() is also buggy: apparently
the RTE_VALUES path through that has never been exercised, or at least
nobody has pointed out to us that it prints bad syntax. I'm guessing
that up to now, get_simple_values_rte *always* succeeds for situations
involving a VALUES RTE and so we never got there. The attached seems
to fix it though.
regards, tom lane
Attachment | Content-Type | Size |
---|---|---|
view-values-fix.patch | text/x-diff | 5.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | abrashears | 2015-02-25 19:49:53 | BUG #12805: Planner estimates query at higher cost when execution can be skipped |
Previous Message | Heikki Linnakangas | 2015-02-25 13:50:05 | Re: BUG #12799: libpq - SSL pqsecure_read() doesn't clean openssl error queue before reading |