Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YM3h0-0008ND-GD for pgsql-bugs@arkaria.postgresql.org; Fri, 13 Feb 2015 00:01:10 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YM3gz-00039Q-H9 for pgsql-bugs@arkaria.postgresql.org; Fri, 13 Feb 2015 00:01:09 +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 1YM3gx-00039H-Jj for pgsql-bugs@postgresql.org; Fri, 13 Feb 2015 00:01:07 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YM3gt-0005PR-E4 for pgsql-bugs@postgresql.org; Fri, 13 Feb 2015 00:01:06 +0000 MIME-Version: 1.0 Subject: BUG #12766: Dump/Load of Materialized View with inlined SQL function fails To: pgsql-bugs@postgresql.org From: felix.buenemann@gmail.com Date: Fri, 13 Feb 2015 00:00:55 +0000 Message-ID: <20150213000055.2584.16773@wrigleys.postgresql.org> X-Pg-Spam-Score: -0.3 (/) Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 The following bug has been logged on the website: Bug reference: 12766 Logged by: Felix Buenemann Email address: felix.buenemann@gmail.com PostgreSQL version: 9.4.1 Operating system: Mac OS X 10.10.2 Description: pg_dump dumps materialized views in the wrong order, if the view is alphabetically sorted before a table that it references indirectly through a stored procedure in sql language. The reason seems to be that pg_dump does not know about the indirect dependency of the matview, so it doesn't reorder the tables/matviews properly. This leads to errors like this on restore: psql:foo.sql:43: ERROR: relation "foo" does not exist LINE 1: SELECT label FROM foo WHERE id = value; ^ QUERY: SELECT label FROM foo WHERE id = value; CONTEXT: SQL function "foo_label" during inlining Problematic dump from error above: https://gist.github.com/056f157a200e334dc5b0 Minimal testcase (thanks to RhodiumToad on IRC): http://pgsql.privatepaste.com/cc80393e25 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs