From: Daniel Cristian Cruz <danielcristian@gmail.com>
To: pgsql-bugs@postgresql.org
Subject: BUG #6050: Dump and restore of view after a schema change: can't restore the view
Date: Fri, 3 Jun 2011 12:38:10 GMT
Message-ID: <201106031238.p53CcA8P075374@wwwmaster.postgresql.org> (raw)
The following bug has been logged online:
Bug reference: 6050
Logged by: Daniel Cristian Cruz
Email address: danielcristian@gmail.com
PostgreSQL version: 9.0.4
Operating system: Linux
Description: Dump and restore of view after a schema change: can't
restore the view
Details:
Example:
DROP VIEW IF EXISTS cba;
DROP TABLE IF EXISTS c;
DROP TABLE IF EXISTS b;
DROP TABLE IF EXISTS a;
CREATE TABLE a (
id_a serial primary key,
v text
);
CREATE TABLE b (
id_b serial primary key,
id_a integer REFERENCES a (id_a),
v text
);
CREATE TABLE c (
id_c serial primary key,
id_b integer references b (id_b),
v text
);
INSERT INTO a (id_a, v) VALUES (DEFAULT, 'A');
INSERT INTO b (id_a, v) VALUES (CURRVAL('a_id_a_seq'), 'B');
INSERT INTO c (id_b, v) VALUES (CURRVAL('b_id_b_seq'), 'C');
CREATE VIEW cba AS
SELECT c.v AS vc, b.v AS vb, a.v AS va
FROM c
JOIN b USING (id_b)
JOIN a USING (id_a);
SELECT * FROM cba;
-- RELATION a -> b-> c became a -> b and a -> c because b is optional
-- SET the value of a -> c where a -> b is defined:
ALTER TABLE c ADD id_a integer;
UPDATE c
SET id_a = b.id_a
FROM b
WHERE b.id_b = c.id_b;
-- VIEW still works!?!?!?
-- Obvious that was a modeling mistake
SELECT * FROM cba;
-- But a pg_dump and a pg_restore of this database generates an error when
restoring the view
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: danielcristian@gmail.com
Subject: Re: BUG #6050: Dump and restore of view after a schema change: can't restore the view
In-Reply-To: <201106031238.p53CcA8P075374@wwwmaster.postgresql.org>
References: <201106031238.p53CcA8P075374@wwwmaster.postgresql.org>
* 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