Skip to content
Advertisement

How do I see trigger functions in the log files

I have a table charass on this table I have a trigger

The function executed by this trigger looks like

When I look at the log file. I can see the statement executed

statement: INSERT INTO charass (charass_value, charass_target_type, charass_target_id, charass_char_id) VALUES ('123456789', 'LS', 1234, 34)

I check the heat table expecting to see a record with the heat_number as ‘123456789’ but nothing is in the heat table.

So i then open up pg admin and copy the above statement and execute it manually. Now there is a record in the heat table.

What is the difference between the manual insert and the one done by the application. Is there a way to tell? the username behind the statement is the same so it cant be a permission thing. I was wondering if there was some way to send information from the trigger function to the log file so I can review it

Advertisement

Answer

Add auto_explain to shared_preload_libraries in postgresql.conf as well as these additional parameters:

Then restart PostgreSQL.

Now you will get the statements inside the function logged, along with their execution plan.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement