Bhargav Gor
Bhargav Gor

Reputation: 581

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.

Upvotes: 4

Views: 26107

Answers (2)

Craig Ringer
Craig Ringer

Reputation: 324621

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.

Upvotes: 4

oguri
oguri

Reputation: 21

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.

Upvotes: 2

Related Questions