Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

max_stack_depth error in postgresql

I Create trigger to store the Salary Amount but When I Fire The Query For Insert

INSERT INTO employees(
            employee_id, first_name, last_name, email, phone_number,  hire_date, 
            job_id, salary, commission_pct, manager_id, department_id)
    VALUES (2002,'poiuy','patel','bhargavgor@dfghj',9898562123,'2012-07-31 00:00:00','IT_PROG',4500.00,0.00,100,60);

Then It Will Show Me The Following Error To set the limit of the max_stack_depth So Can Any One Give Me The Idea TO Solve This Error..

I Try Also To Change The Value Of max_stack_depth in Configuration File But It IS Not Working

Error Like Following

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.
like image 892
Bhargav Gor Avatar asked Sep 13 '25 04:09

Bhargav Gor


2 Answers

I'd say you have an ON INSERT OR UPDATE trigger on employees that, directly or indirectly, does an UPDATE to the employees table without checking if it was invoked directly or via a trigger.

This is often a programming mistake, where you're doing an UPDATE on the employee table instead of having your BEFORE INSERT OR UPDATE ... FOR EACH ROW trigger modify the value of NEW.

Sometimes it's mutual recursion between two triggers, which is harder to deal with. Unfortunately I'm not aware of any way to detect whether a trigger was invoked by a direct client statement or via another stored proc or trigger. Design changes to avoid the mutual recursion are typically required.

See Prevent recursive trigger in PostgreSQL.

like image 51
Craig Ringer Avatar answered Sep 14 '25 22:09

Craig Ringer


Can you post what error message you are getting when you are changing the max_stack_depth.

" ulimit -s " in linux systems will give the stack depth. Put the max_stack_depth one or two less than your actual server limit(ulimit -s).

After setting this please do reload.

like image 36
oguri Avatar answered Sep 14 '25 20:09

oguri