

CREATE TABLE t(a int);

CREATE FUNCTION tr() RETURNS TRIGGER AS $$ BEGIN PERFORM pg_sleep(3); RETURN NEW; END; $$ LANGUAGE plpgsql;

CREATE TRIGGER tr1 AFTER INSERT ON t FOR EACH ROW EXECUTE PROCEDURE tr();
CREATE TRIGGER tr2 AFTER INSERT ON t FOR EACH ROW EXECUTE PROCEDURE tr();

INSERT INTO t VALUES(1);

\copy t TO /tmp/test.csv;

LOAD 'auto_explain';
SET auto_explain.log_min_duration = '5s';
SET auto_explain.log_analyze = true;
SET auto_explain.log_buffers = true;
SET auto_explain.log_triggers = true;
SET auto_explain.log_nested_statements= true;
SET client_min_messages TO debug;
SET log_min_duration_statement = 0;

\copy t FROM /tmp/test.csv; --statement duration 6s, but plan not logged, becouse nested statement duration tr1 is 3s and tr2 3s

SET auto_explain.log_min_duration = '3s';

\copy t FROM /tmp/test.csv; --finnaly logged
