pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #13870: couldn't restore dump with mat view
6+ messages / 3 participants
[nested] [flat]
* BUG #13870: couldn't restore dump with mat view
@ 2016-01-15 17:55 kardash.a.v@yandex.ru
2016-01-16 01:58 ` Re: BUG #13870: couldn't restore dump with mat view Tom Lane <tgl@sss.pgh.pa.us>
2016-01-16 05:57 ` Re: BUG #13870: couldn't restore dump with mat view Michael Paquier <michael.paquier@gmail.com>
0 siblings, 2 replies; 6+ messages in thread
From: kardash.a.v@yandex.ru @ 2016-01-15 17:55 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 13870
Logged by: Arthur Kardash
Email address: kardash.a.v@yandex.ru
PostgreSQL version: 9.5.0
Operating system: windows 7 x32
Description:
Try to feed sql-commands below, then do dump and you will see errors while
restore!
d:/pgsql/bin/pg_dump.exe -h 127.0.0.1 -U postgres -F c -f d:/backUp/test4
test
d:/pgsql/bin/pg_restore.exe -h 127.0.0.1 -U postgres -d t -F c
d:/backUp/test4
-----------------
SQL - commands
-----------------
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.5.0
-- Dumped by pg_dump version 9.5.0
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner:
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner:
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
SET search_path = public, pg_catalog;
--
-- Name: distance(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION distance(line integer) RETURNS numeric
LANGUAGE sql
AS $$
SELECT line * 4.5;
$$;
ALTER FUNCTION public.distance(line integer) OWNER TO postgres;
--
-- Name: point(integer); Type: FUNCTION; Schema: public; Owner: postgres
--
CREATE FUNCTION point(line integer) RETURNS numeric
LANGUAGE sql
AS $$
WITH t(line) AS (
SELECT line
FROM stend
)
SELECT distance (line) FROM t
$$;
ALTER FUNCTION public.point(line integer) OWNER TO postgres;
SET default_tablespace = '';
--
-- Name: conjunct_dynamic1; Type: MATERIALIZED VIEW; Schema: public; Owner:
postgres
--
CREATE MATERIALIZED VIEW conjunct_dynamic1 AS
SELECT point.point
FROM point(1) point(point)
WITH NO DATA;
ALTER TABLE conjunct_dynamic1 OWNER TO postgres;
SET default_with_oids = false;
--
-- Name: stend; Type: TABLE; Schema: public; Owner: postgres
--
CREATE TABLE stend (
line integer
);
ALTER TABLE stend OWNER TO postgres;
--
-- Data for Name: stend; Type: TABLE DATA; Schema: public; Owner: postgres
--
COPY stend (line) FROM stdin;
\.
--
-- Name: conjunct_dynamic1; Type: MATERIALIZED VIEW DATA; Schema: public;
Owner: postgres
--
REFRESH MATERIALIZED VIEW conjunct_dynamic1;
--
-- Name: public; Type: ACL; Schema: -; Owner: postgres
--
REVOKE ALL ON SCHEMA public FROM PUBLIC;
REVOKE ALL ON SCHEMA public FROM postgres;
GRANT ALL ON SCHEMA public TO postgres;
GRANT ALL ON SCHEMA public TO PUBLIC;
--
-- PostgreSQL database dump complete
--
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #13870: couldn't restore dump with mat view
2016-01-15 17:55 BUG #13870: couldn't restore dump with mat view kardash.a.v@yandex.ru
@ 2016-01-16 01:58 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-01-16 06:01 ` Re: BUG #13870: couldn't restore dump with mat view Michael Paquier <michael.paquier@gmail.com>
1 sibling, 1 reply; 6+ messages in thread
From: Tom Lane @ 2016-01-16 01:58 UTC (permalink / raw)
To: kardash.a.v@yandex.ru; +Cc: pgsql-bugs@postgresql.org, Kevin Grittner <kgrittn@gmail.com>
kardash.a.v@yandex.ru writes:
> Try to feed sql-commands below, then do dump and you will see errors while
> restore!
Well, this example doesn't work as-is because the command order is already
wrong. But the issue is that CREATE MATERIALIZED VIEW ... WITH NO DATA
tries to plan and execute the query, not just store it, which entirely
defeats pg_dump's attempt to avoid hidden dependencies. We need a less
chintzy solution to handling this variant of CREATE MATERIALIZED VIEW.
(I seem to recall complaining about this before.)
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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #13870: couldn't restore dump with mat view
2016-01-15 17:55 BUG #13870: couldn't restore dump with mat view kardash.a.v@yandex.ru
2016-01-16 01:58 ` Re: BUG #13870: couldn't restore dump with mat view Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-01-16 06:01 ` Michael Paquier <michael.paquier@gmail.com>
2016-01-16 15:27 ` Re: BUG #13870: couldn't restore dump with mat view Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 6+ messages in thread
From: Michael Paquier @ 2016-01-16 06:01 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs; Kevin Grittner <kgrittn@gmail.com>
On Sat, Jan 16, 2016 at 10:58 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> kardash.a.v@yandex.ru writes:
>> Try to feed sql-commands below, then do dump and you will see errors while
>> restore!
>
> Well, this example doesn't work as-is because the command order is already
> wrong. But the issue is that CREATE MATERIALIZED VIEW ... WITH NO DATA
> tries to plan and execute the query, not just store it, which entirely
> defeats pg_dump's attempt to avoid hidden dependencies. We need a less
> chintzy solution to handling this variant of CREATE MATERIALIZED VIEW.
>
> (I seem to recall complaining about this before.)
The first issue in the dump is the creation of point(), which depends
on relation stend.
--
Michael
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #13870: couldn't restore dump with mat view
2016-01-15 17:55 BUG #13870: couldn't restore dump with mat view kardash.a.v@yandex.ru
2016-01-16 01:58 ` Re: BUG #13870: couldn't restore dump with mat view Tom Lane <tgl@sss.pgh.pa.us>
2016-01-16 06:01 ` Re: BUG #13870: couldn't restore dump with mat view Michael Paquier <michael.paquier@gmail.com>
@ 2016-01-16 15:27 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-01-22 12:37 ` Re: BUG #13870: couldn't restore dump with mat view Michael Paquier <michael.paquier@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Tom Lane @ 2016-01-16 15:27 UTC (permalink / raw)
To: Michael Paquier <michael.paquier@gmail.com>; +Cc: pgsql-bugs; Kevin Grittner <kgrittn@gmail.com>
Michael Paquier <michael.paquier@gmail.com> writes:
> On Sat, Jan 16, 2016 at 10:58 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> Well, this example doesn't work as-is because the command order is already
>> wrong. But the issue is that CREATE MATERIALIZED VIEW ... WITH NO DATA
>> tries to plan and execute the query, not just store it, which entirely
>> defeats pg_dump's attempt to avoid hidden dependencies. We need a less
>> chintzy solution to handling this variant of CREATE MATERIALIZED VIEW.
>>
>> (I seem to recall complaining about this before.)
> The first issue in the dump is the creation of point(), which depends
> on relation stend.
point() is just fine, because check_relation_bodies is turned off.
pg_dump does that specifically because it can't see into the function
body to know what dependencies might be there.
The reason for separating dump/reload of matviews into two steps,
CREATE ... WITH NO DATA followed by REFRESH, is again to guard against
hidden dependencies. If the view were planned/executed only at the
REFRESH stage, this dump script would be fine as-is. It's the attempt
to avoid having two code paths in ExecCreateTableAs() that is causing
this failure.
(Having said that, it would still be possible to break it I think,
though much harder. Hiding relation dependencies inside functions
is not a good design technique.)
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
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #13870: couldn't restore dump with mat view
2016-01-15 17:55 BUG #13870: couldn't restore dump with mat view kardash.a.v@yandex.ru
2016-01-16 01:58 ` Re: BUG #13870: couldn't restore dump with mat view Tom Lane <tgl@sss.pgh.pa.us>
2016-01-16 06:01 ` Re: BUG #13870: couldn't restore dump with mat view Michael Paquier <michael.paquier@gmail.com>
2016-01-16 15:27 ` Re: BUG #13870: couldn't restore dump with mat view Tom Lane <tgl@sss.pgh.pa.us>
@ 2016-01-22 12:37 ` Michael Paquier <michael.paquier@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: Michael Paquier @ 2016-01-22 12:37 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs; Kevin Grittner <kgrittn@gmail.com>
On Sun, Jan 17, 2016 at 12:27 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> point() is just fine, because check_relation_bodies is turned off.
> pg_dump does that specifically because it can't see into the function
> body to know what dependencies might be there.
Thanks. Missed that.
> The reason for separating dump/reload of matviews into two steps,
> CREATE ... WITH NO DATA followed by REFRESH, is again to guard against
> hidden dependencies. If the view were planned/executed only at the
> REFRESH stage, this dump script would be fine as-is. It's the attempt
> to avoid having two code paths in ExecCreateTableAs() that is causing
> this failure.
My brain is a bit fried now... But do you think that we could have
some additional logic in ExecCreateTableAs() using
check_relation_bodies?
--
Michael
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #13870: couldn't restore dump with mat view
2016-01-15 17:55 BUG #13870: couldn't restore dump with mat view kardash.a.v@yandex.ru
@ 2016-01-16 05:57 ` Michael Paquier <michael.paquier@gmail.com>
1 sibling, 0 replies; 6+ messages in thread
From: Michael Paquier @ 2016-01-16 05:57 UTC (permalink / raw)
To: kardash.a.v@yandex.ru; +Cc: pgsql-bugs
On Sat, Jan 16, 2016 at 2:55 AM, <kardash.a.v@yandex.ru> wrote:
> Try to feed sql-commands below, then do dump and you will see errors while
> restore!
Here is a shorter sequence of commands to reproduce the failure:
CREATE TABLE stend (line integer);
CREATE FUNCTION point(line integer) RETURNS numeric
LANGUAGE sql
AS $$
WITH t(line) AS (
SELECT line
FROM stend
) SELECT (4 * line)::numeric FROM t $$;
pg_dump is usually quite smart at detecting dependencies and dumping
objects in the right order, but even if in this case pg_dump is
obviously wrong, there is no way for it to know that the function it
creates depends on this relation.
--
Michael
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2016-01-22 12:37 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-01-15 17:55 BUG #13870: couldn't restore dump with mat view kardash.a.v@yandex.ru
2016-01-16 01:58 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-01-16 06:01 ` Michael Paquier <michael.paquier@gmail.com>
2016-01-16 15:27 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-01-22 12:37 ` Michael Paquier <michael.paquier@gmail.com>
2016-01-16 05:57 ` Michael Paquier <michael.paquier@gmail.com>
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