Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aO8FH-0008AZ-Lg for pgsql-bugs@arkaria.postgresql.org; Tue, 26 Jan 2016 18:21:40 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aO8FH-00031e-8d for pgsql-bugs@arkaria.postgresql.org; Tue, 26 Jan 2016 18:21:39 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aO8FG-000307-Q0 for pgsql-bugs@postgresql.org; Tue, 26 Jan 2016 18:21:38 +0000 Received: from mail.neveragain.de ([217.69.77.37]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1aO8FD-0003JR-K0 for pgsql-bugs@postgresql.org; Tue, 26 Jan 2016 18:21:37 +0000 Received: from dottie.dus.openit.net (dottie.dus.openit.net [IPv6:2001:aa8:fff3::fffd]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.neveragain.de (Postfix) with ESMTPSA id 9D932239B for ; Tue, 26 Jan 2016 19:21:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=neveragain.de; s=2015-10; t=1453832492; bh=OHMjYHi4TIpd1bYZ5KJooXmEox84eDq1Nee+55LYPDE=; h=From:Subject:Date:To; b=UX5FlTKbxrswrfJy2kJbYPV3SV6upgRG8iFjxOeRbc6E0PFWrn1o5fQoudiLRLqLx u0NRKx2mrDrhZ2A//+6vbvPNSM5alGVPgtTdlLsme02MX3+ZFsRc7mc+8t7zyOvEAv dgb96GlSg+Ce0SVS7qt5UumMg51l7b8lo88SN+FX4wk/dFNYF/5F6Y2gg312F/FXQV 3d/6G2orKSHFz63cSbEiMXJs34aO+nVAcXUYZzZKDirf4OQHF3pPduPuyVONbEKKmy STlecD0A1qjyu32jee5oBo01jM+uOIWUaR8TTmRBBBhwgtQYDIRRx6+1ypkKMJ3df9 gCuj5nhDBkgbQ== From: =?utf-8?Q?Dennis_K=C3=B6gel?= Content-Type: multipart/mixed; boundary="Apple-Mail=_9D97EB5D-5733-47B9-93FB-E45B7B4DF382" Subject: Parallel pg_restore fails to import views with triggers (dependency problem?) Message-Id: <1445A624-D09F-4B51-9C41-46BA1E2D6862@neveragain.de> Date: Tue, 26 Jan 2016 19:21:31 +0100 To: pgsql-bugs@postgresql.org Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) X-Mailer: Apple Mail (2.3112) X-Pg-Spam-Score: -2.0 (--) 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 --Apple-Mail=_9D97EB5D-5733-47B9-93FB-E45B7B4DF382 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hi, as far as I currently understand it: When a view has to be dumped as table = + rule, and it has triggers, it seems that parallel pg_restore fails to und= erstand that the trigger depends on the rule (at least on 9.5.0 and before). A simple test case (see attachment): # 1) create empty DB with view + trigger && create dump $ dropdb x156353; createdb x156353 && psql -d x156353 -qf 156353.sql && pg_= dump -d x156353 -Fc -f x156353.pgdump # 2) create database from that dump, no parallelism: works fine $ dropdb x156353; pg_restore -Cdpostgres -j1 x156353.pgdump=20 # 3) create database from that dump, with -j >1: fails $ dropdb x156353; pg_restore -Cdpostgres -j2 x156353.pgdump=20 pg_restore: [archiver (db)] Error while PROCESSING TOC: pg_restore: [archiver (db)] Error from TOC entry 2852; 2620 1001120 TRIGGER= tr_staff_v postgres pg_restore: [archiver (db)] could not execute query: ERROR: "staff_v" is a= table DETAIL: Tables cannot have INSTEAD OF triggers. Command was: CREATE TRIGGER tr_staff_v INSTEAD OF INSERT ON staff_v FOR= EACH ROW EXECUTE PROCEDURE tf_staff_v(); - D. P.S.: Thanks to RhodiumToad for making sense of this. --Apple-Mail=_9D97EB5D-5733-47B9-93FB-E45B7B4DF382 Content-Disposition: attachment; filename=156353.sql Content-Type: application/octet-stream; name="156353.sql" Content-Transfer-Encoding: 7bit create table staff (id integer primary key, foo integer); insert into staff values (23, 42); -- create table staff_v (id integer, foo int); -- CREATE RULE "_RETURN" AS ON SELECT TO staff_v DO INSTEAD SELECT id, foo from staff group by id; create view staff_v as select id, foo from staff group by id; CREATE FUNCTION tf_staff_v() RETURNS trigger LANGUAGE plpgsql AS $$ begin return new; end $$; CREATE TRIGGER tr_staff_v INSTEAD OF INSERT ON staff_v FOR EACH ROW EXECUTE PROCEDURE tf_staff_v(); --Apple-Mail=_9D97EB5D-5733-47B9-93FB-E45B7B4DF382 Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs --Apple-Mail=_9D97EB5D-5733-47B9-93FB-E45B7B4DF382--