[英]How to tell if/when Postgres triggers are executing
I'm working in a legacy codebase/database.我在遗留代码库/数据库中工作。 The code previously depended on triggers but at one point stopped using them - the logic was moved into the main (Nodejs) codebase and the
CREATE TRIGGER
statements were removed.代码以前依赖于触发器,但在某一时刻停止使用它们 - 逻辑被移动到主(Nodejs)代码库中,并且
CREATE TRIGGER
语句被删除。 Nonetheless, the triggers still exist in the DB.尽管如此,触发器仍然存在于数据库中。 I can see them searching the
pg_trigger
table:我可以看到他们搜索
pg_trigger
表:
As far as I can tell they're still enabled which is weird because to my knowledge they shouldn't be doing anything.据我所知,它们仍然处于启用状态,这很奇怪,因为据我所知,它们不应该做任何事情。 If they're not being used I'd like to remove them.
如果它们没有被使用,我想删除它们。 My questions:
我的问题:
There is no way to do that, unless you modify the triggers to record the execution somewhere.没有办法做到这一点,除非您修改触发器以在某处记录执行。
Perhaps session_replication_role
is set to replica
.也许
session_replication_role
设置为replica
。 Then normal triggers ( tgenabled = 'O'
) don't fire.然后正常触发器(
tgenabled = 'O'
)不会触发。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.