Re: BUG #12789: Views defined with VALUES lose their column names when dumped

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: programble(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #12789: Views defined with VALUES lose their column names when dumped
Date: 2015-02-20 04:48:49
Message-ID: 87ioexfb91.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

>>>>> ">" == programble <programble(at)gmail(dot)com> writes:

>> The following bug has been logged on the website:
>> Bug reference: 12789
>> Logged by: Curtis McEnroe
>> Email address: programble(at)gmail(dot)com
>> PostgreSQL version: 9.4.1
>> Operating system: Mac OS X 10.10.1
>> Description:

>> A view created with explicit column names and defined as a VALUES statement
>> will lose its column names when dumped. When the dump is restored, the
>> view's columns are named "column1", "column2", etc.

>> I wrote a short repro script here:
>> https://gist.github.com/programble/a416df496bfb41259c86

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.

--
Andrew (irc:RhodiumToad)

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message lr 2015-02-20 15:08:44 BUG #12792: I can do a SELECT with no fields
Previous Message programble 2015-02-20 04:30:45 BUG #12789: Views defined with VALUES lose their column names when dumped