Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 74EAFB61CBD for ; Thu, 2 Jun 2011 17:22:42 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 97137-02 for ; Thu, 2 Jun 2011 20:22:42 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id E5F42B61BB4 for ; Thu, 2 Jun 2011 17:22:41 -0300 (ADT) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p52KMf4L044246 for ; Thu, 2 Jun 2011 20:22:41 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p52KMfFL044245; Thu, 2 Jun 2011 20:22:41 GMT (envelope-from www) Date: Thu, 2 Jun 2011 20:22:41 GMT Message-Id: <201106022022.p52KMfFL044245@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6049: Can't load dumped view with VALUES and ORDER BY From: "Dylan Adams" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201106/27 X-Sequence-Number: 30406 The following bug has been logged online: Bug reference: 6049 Logged by: Dylan Adams Email address: dadams@bybaxter.com PostgreSQL version: 8.4.4 Operating system: Linux (Fedora 12) Description: Can't load dumped view with VALUES and ORDER BY Details: If you create a view based on a VALUES statement with an ORDER BY clause, the SQL produced by pg_dump can't be loaded back into the database. $ createdb testdb $ psql -c "CREATE VIEW test_view AS VALUES (1), (2), (3) ORDER BY 1; -- or ORDER BY column1" testdb CREATE VIEW $ pg_dump -t test_view testdb > test_view.dump $ psql -c "DROP VIEW test_view;" testdb DROP VIEW $ psql -f test_view.dump testdb SET SET SET SET SET SET psql:test_view.dump:18: ERROR: invalid reference to FROM-clause entry for table "*VALUES*" LINE 2: VALUES (1), (2), (3) ORDER BY "*VALUES*".column1; ^ HINT: There is an entry for table "*VALUES*", but it cannot be referenced from this part of the query. psql:test_view.dump:21: ERROR: relation "public.test_view" does not exist Here's the definition that gets dumped: CREATE VIEW test_view AS VALUES (1), (2), (3) ORDER BY "*VALUES*".column1;