Created trigger:

CREATE TRIGGER pim_individual_doc_active_true AFTER UPDATE OR INSERT ON pim_individual_doc FOR EACH ROW EXECUTE PROCEDURE pim_individual_doc_active_true_func(); 
And trigger function:
 create or replace function pim_individual_doc_active_true_func() returns trigger AS $$ BEGIN IF ((NEW.type_id = 19 OR old.type_id = 19) AND (old.expire_dt is NULL or new.expire_dt is null)) THEN update pim_individual_doc set is_active = TRUE WHERE id = OLD.id or id = NEW.id; END IF; RETURN null; END $$ language plpgsql; 

But when updating the line, the error is:

 [54001] ERROR: stack depth limit exceeded Подсказка: Increase the configuration parameter "max_stack_depth" (currently 2048kB), after ensuring the platform's stack depth limit is adequate. Где: SQL statement "SELECT set_config('aud.when'::TEXT, to_char(cur_time, 'YYYY-MM-DD HH24:MI:SS:MS'), true)" PL/pgSQL function audit_trigger_fun() line 23 at PERFORM SQL statement "update pim_individual_doc set is_active = TRUE WHERE id = OLD.id" PL/pgSQL function pim_individual_doc_active_true_func() line 4 at SQL statement SQL statement "update pim_individual_doc set is_active = TRUE WHERE id = OLD.id" PL/pgSQL function pim_individual_doc_active_true_func() line 4 at SQL statement SQL statement "update pim_individual_doc set is_active = TRUE WHERE id = OLD.id" PL/pgSQL function pim_individual_doc_active_true_func() line 4 at SQL statement SQL statement "update pim_individual_doc set is_active = TRUE WHERE id = OLD.id" PL/pgSQL function pim_individual_doc_active_true_func() line 4 at SQL statement SQL statement " ... 

    1 answer 1

    You from the trigger perform an update of this table itself. And from a recursion, apparently, do not leave. Perhaps you wanted to check if in the trigger as well on AND NOT NEW.is_active ? Or something in this spirit to determine when it is enough to perform an update .