Restore - disable triggers - when they fired?

From: Durumdara <durumdara(at)gmail(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Restore - disable triggers - when they fired?
Date: 2018-03-20 14:31:51
Message-ID: CAEcMXhnt9P=4E7syOurQPgZgnH9XKUU+EoWkx+Vf0W_Q=7-W+g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-03-20 14:47:59 Re: Restore - disable triggers - when they fired?
Previous Message Jimmy Augustine 2018-03-20 14:28:30 Re: PostgreSQL 9.6 Temporary files