Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eyIYa-0001xD-3A for pgsql-general@arkaria.postgresql.org; Tue, 20 Mar 2018 14:48:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eyIYZ-0001rH-1X for pgsql-general@arkaria.postgresql.org; Tue, 20 Mar 2018 14:48:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eyIYY-0001r7-DW for pgsql-general@lists.postgresql.org; Tue, 20 Mar 2018 14:48:06 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eyIYU-0008Sy-EI for pgsql-general@postgresql.org; Tue, 20 Mar 2018 14:48:05 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 2F507215F7; Tue, 20 Mar 2018 10:48:01 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute6.internal (MEProxy); Tue, 20 Mar 2018 10:48:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=+XKBGxgY69/d0ToWAeZR3nCMyqZ++ gjjvh0s/Pfiz5Q=; b=akmdEqfNp6iReFT+sxPFlRaSQOIju+v4fZplWOLKc55LI KSE05T8NcRBPYNqC29/cmeLrNhbgyZ7c9Re6YzA4hf29A7oG1rdPGXA9Bj9rzkoX ZvtGifWjEHo1OxY+jRL1s946s0N5oEhTxut2BoH3sQfUMaeNaP/+mZWOHxtZb5Va A7+6wusPkauDuEib3jKJDAcoNo7AAETOICfs1UQAxe/Ds6/wgyorjCtIBEBiGare czEwjLdXlD3b0F3uuyOe+RDbGkj8OiIsv6C9kuTRR2HLNfqjI0J81c7v/bSzEo15 QIagzKeC7RdjyXjk5gasdRYT77Orcwg4nPfeFZNug== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=+XKBGx gY69/d0ToWAeZR3nCMyqZ++gjjvh0s/Pfiz5Q=; b=EPzLZWsWFSmibJxkIZ2td9 7pOOHXzmjPed4rxuOZ8bX0xRp6OXEBlakk6LnjDfotmJaqpw8Td+fW5h/SZ+Kvud n42YvirtcWs0a2nFg+EBqgDsnndtbxpEqMmes9uu88Loq9Un7o9rdHyVxHAy4F3z JiamTJYqg5cobEggKtG7dmn9fn8AvaSj0QAtEEOz0u/VZubbPCSbPG/tIJ1I/pW0 vbbq1qxIdP03kC5GVCdJB6G8P5zpvTr2x5jxXQ9P8eXyazfa4zIJ/yzCOBwRUk9a rfUi2Rvk+Pvkw+NxS4eF0t8u8oeW5DDEI2OsN+hmTkKaBeEkTHYxcTDrBvK6bM6Q == X-ME-Sender: Received: from [192.168.1.2] (71-35-123-124.tukw.qwest.net [71.35.123.124]) by mail.messagingengine.com (Postfix) with ESMTPA id 9A0C024217; Tue, 20 Mar 2018 10:48:00 -0400 (EDT) Subject: Re: Restore - disable triggers - when they fired? To: Durumdara , Postgres General References: From: Adrian Klaver Message-ID: Date: Tue, 20 Mar 2018 07:47:59 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03/20/2018 07:31 AM, Durumdara wrote: > Dear Members! > > I saw in PGAdmin 3/4 that pg_restore have an option "disable triggers". > > Because we need to move some databases in the near future I have to know > about the meaning of this option. > > I wrote a table with an BEFORE UPDATE trigger: > > create table tr_test > ( > id integer not null primary key, > value1 varchar(100), > value2 varchar(100) > ); > > insert into tr_test values(1, 'a', 'a'); > insert into tr_test values(2, 'b', 'b'); > > CREATE OR REPLACE FUNCTION tfbu_tr_test() >   RETURNS trigger AS > $BODY$ > begin >     new.value2 = cast(current_timestamp as varchar(30)); >     RETURN NEW; > end; > $BODY$ >   LANGUAGE plpgsql VOLATILE >   COST 100; > > >  CREATE TRIGGER tbi_tr_test >   BEFORE INSERT >   ON tr_test >   FOR EACH ROW >   EXECUTE PROCEDURE public.tfbu_tr_test(); > > insert into tr_test values(3, 'c', 'c'); > select * from tr_test; > > > and I tried to dump and restore in PGAdmin IV. > > The dumped data is same as I read after restore. > > The pg_restore log shows me that triggers and indexes created after data > copy. > > At this point I confused in "disable triggers" option. > > When it would be useful? https://www.postgresql.org/docs/10/static/app-pgrestore.html "--disable-triggers This option is relevant only when performing a data-only restore. It instructs pg_restore to execute commands to temporarily disable triggers on the target tables while the data is reloaded. Use this if you have referential integrity checks or other triggers on the tables that you do not want to invoke during data reload. Presently, the commands emitted for --disable-triggers must be done as superuser. So you should also specify a superuser name with -S or, preferably, run pg_restore as a PostgreSQL superuser. > > Firstly I supposed that data copy somehow could start the triggers - but > how? > > Which triggers? Or how they fired with this order? > > Or they remains as disabled AFTER the backup for next, by hand > manipulations? > > So please light my mind a little! > > Thank you! > > Regards > dd -- Adrian Klaver adrian.klaver@aklaver.com