Neil Gaetano Lindberg
Neil Gaetano Lindberg

Reputation: 2935

How to access statement text in Postgres trigger

I'm attempting to put together what I thought would be a simple audit ability in Postgres. I intend to log session_id/user_id etc., but what I'm really after is logging the actual statement, in full. I know I can get the operation with TG_OP, but does anybody know the secret sauce to get the actual text of the current statement?

Upvotes: 2

Views: 60

Answers (1)

Bjarni Ragnarsson
Bjarni Ragnarsson

Reputation: 1781

This information can be retrieved with the current_query()function.

Upvotes: 4

Related Questions