Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 34763B62186 for ; Fri, 3 Jun 2011 09:38:11 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 15940-03 for ; Fri, 3 Jun 2011 12:38:11 +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 A55D8B62144 for ; Fri, 3 Jun 2011 09:38:10 -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 p53CcAEm075375 for ; Fri, 3 Jun 2011 12:38:10 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p53CcA8P075374; Fri, 3 Jun 2011 12:38:10 GMT (envelope-from www) Date: Fri, 3 Jun 2011 12:38:10 GMT Message-Id: <201106031238.p53CcA8P075374@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6050: Dump and restore of view after a schema change: can't restore the view From: "Daniel Cristian Cruz" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201106/31 X-Sequence-Number: 30410 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