How to get the name of the altered table in a Postgres event trigger?

让人想犯罪 __ 提交于 2019-12-01 18:22:08
cc young

same issue addressed here: How to get SQL text from Postgres event trigger

bottom line, as of now, wait until more features are added to EVENT TRIGGER in future releases

The variables available to plpgsql in a trigger are defined here:

http://www.postgresql.org/docs/9.3/static/plpgsql-trigger.html#PLPGSQL-EVENT-TRIGGER-EXAMPLE

What I can't tell from the text is how many 'event' variables there are. Certainly there are two:

TG_EVENT
Data type text; a string representing the event the trigger is fired for.

TG_TAG
Data type text; variable that contains the command tag for which the trigger is fired.

You can print these in your function to see if they contain the table information you are looking for. The documentation shows a bunch of other variables that are for regular events. I don't know if those will help, but, perhaps TG_TABLE_NAME is set?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!