Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YOfWM-0000nX-UV for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Feb 2015 04:48:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YOfWM-0007kY-64 for pgsql-bugs@arkaria.postgresql.org; Fri, 20 Feb 2015 04:48:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YOfWK-0007kP-8o for pgsql-bugs@postgresql.org; Fri, 20 Feb 2015 04:48:56 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1YOfWG-0008RU-AH for pgsql-bugs@postgresql.org; Fri, 20 Feb 2015 04:48:55 +0000 Received: from localhost ([127.0.0.1]:52871 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtp (Exim 4.84 (FreeBSD)) (envelope-from ) id 1YOfWD-000KZS-Gv; Fri, 20 Feb 2015 04:48:49 +0000 From: Andrew Gierth To: programble@gmail.com Cc: pgsql-bugs@postgresql.org Subject: Re: BUG #12789: Views defined with VALUES lose their column names when dumped In-Reply-To: <20150220043045.8730.61379@wrigleys.postgresql.org> (programble@gmail.com's message of "Fri, 20 Feb 2015 04:30:45 +0000") Message-ID: <87ioexfb91.fsf@news-spur.riddles.org.uk> References: <20150220043045.8730.61379@wrigleys.postgresql.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (berkeley-unix) Date: Fri, 20 Feb 2015 04:48:49 +0000 MIME-Version: 1.0 Content-Type: text/plain X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org >>>>> ">" == programble writes: >> The following bug has been logged on the website: >> Bug reference: 12789 >> Logged by: Curtis McEnroe >> Email address: programble@gmail.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) -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs