From: Tom Lane <tgl@sss.pgh.pa.us>
To: felix.buenemann@gmail.com
Cc: pgsql-bugs@postgresql.org
Cc: Kevin Grittner <kgrittn@ymail.com>
Subject: Re: BUG #12766: Dump/Load of Materialized View with inlined SQL function fails
Date: Thu, 12 Feb 2015 19:46:46 -0500
Message-ID: <17889.1423788406@sss.pgh.pa.us> (raw)
In-Reply-To: <20150213000055.2584.16773@wrigleys.postgresql.org>
References: <20150213000055.2584.16773@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
felix.buenemann@gmail.com writes:
> 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.
It's mathematically impossible to guarantee that pg_dump could handle such
things --- maybe it could do simple cases, given enormously more knowledge
about PL functions than it actually possesses, but a full solution would
be equivalent to solving the halting problem. So we're not going to try
to fix this in pg_dump.
Having said that, I wonder why CREATE MATERIALIZED VIEW seems to insist on
running the planner and even executing the query when told WITH NO DATA.
If it were satisfied to store the view definition and quit, we'd not
be seeing a failure here.
> Problematic dump from error above:
> https://gist.github.com/056f157a200e334dc5b0
> Minimal testcase (thanks to RhodiumToad on IRC):
> http://pgsql.privatepaste.com/cc80393e25
BTW, links to pages that will probably not be there next month are
entirely inadequate documentation for bug reports. For the sake
of the archives, here's the test case:
create table t1 (a integer);
create function f1() returns integer language sql stable as
$f$ select a from t1 limit 1; $f$;
create table t2 (b integer);
create materialized view m1 as select f1(), b from t2;
Dumping and restoring this causes the reported failure, since
m1 is restored before t1.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, felix.buenemann@gmail.com, kgrittn@ymail.com
Subject: Re: BUG #12766: Dump/Load of Materialized View with inlined SQL function fails
In-Reply-To: <17889.1423788406@sss.pgh.pa.us>
References: <20150213000055.2584.16773@wrigleys.postgresql.org> <17889.1423788406@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox