HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Log statements from within triggers in Postgresql

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
postgresqllogstatementswithinfromtriggers

Problem

I have several sql statements running in some of my plpgsql triggers. I've enabled logging with the log_statement = 'all'. It logs the 'triggering statement', but not the statements within the query itself.

Is there a way to display statements that were executed within trigger in standard postgres log?

Solution

The auto_explain module has auto_explain.log_nested_statements since at least 8.4, so that's one option. It's a bit heavyweight but I'm not aware of any other logging option that will record statements run inside PL/PgSQL functions and triggers.

See this similar question.

Context

StackExchange Database Administrators Q#37218, answer score: 5

Revisions (0)

No revisions yet.