max_stack_depth error in postgresql
Presumably your trigger firing on UPDATE executes an UPDATE on the same table, which itself fires the triggers, and so on recursively until the stack is full and the stack depth limit exceeded error is raised.

Here's a bare bones example demonstrating the problem:

create table tst(id int primary key, col int, trigger boolean);

create function trg() returns trigger  as $$
 begin update tst set trigger=true where tst.id=NEW.id; return NEW; END
$$ language plpgsql;

create trigger t before update on tst for each row execute procedure trg();

insert into tst(id) values(1),(2);

update tst set col=1 where id=1;
ERROR:  stack depth limit exceeded
HINT:  Increase the configuration parameter "max_stack_depth" (currently 2048kB), after ensuring the platform's stack depth limit is adequate.
CONTEXT:  SQL statement "update tst set trigger=false where tst.id=NEW.id"
PL/pgSQL function trg() line 1 at SQL statement
SQL statement "update tst set trigger=false where tst.id=NEW.id"


The mistake in the above case is to issue an UPDATE of the table already being updated, inside the trigger. The correct way is to assign directly NEW.trigger, as in:

create function trg() returns trigger  as
$$
 begin NEW.trigger=true; return NEW; END
$$ language plpgsql;