postgresql 中的 max_stack_depth 错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11757996/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 00:08:37  来源:igfitidea点击:

max_stack_depth error in postgresql

databasepostgresql

提问by Bhargav Gor

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_depthSo Can Any One Give Me The Idea TO Solve This Error..

然后它会告诉我以下错误来设置限制max_stack_depth所以任何人都可以给我解决这个错误的想法..

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

我也尝试更改max_stack_depth配置文件中的值但它不起作用

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.

回答by Craig Ringer

I'd say you have an ON INSERT OR UPDATEtrigger on employeesthat, directly or indirectly, does an UPDATEto the employeestable without checking if it was invoked directly or via a trigger.

我会说你有一个ON INSERT OR UPDATE触发器employees,直接或间接UPDATE地对employees表执行一个操作,而不检查它是直接调用还是通过触发器调用。

This is often a programming mistake, where you're doing an UPDATEon the employeetable instead of having your BEFORE INSERT OR UPDATE ... FOR EACH ROWtrigger modify the value of NEW.

这通常是一个编程错误,您在表UPDATE上执行 anemployee而不是让BEFORE INSERT OR UPDATE ... FOR EACH ROW触发器修改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.

请参阅防止 PostgreSQL 中的递归触发器

回答by oguri

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

您可以发布更改 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).

linux 系统中的“ulimit -s”将给出堆栈深度。将 max_stack_depth 比您的实际服务器限制 (ulimit -s) 少一两个。

After setting this please do reload.

设置后请重新加载。