postgresql-triggers

How to use variable settings in trigger functions?

蹲街弑〆低调 提交于 2019-12-05 01:35:24
I would like to record the id of a user in the session/transaction, using SET , so I could be able to access it later in a trigger function, using current_setting . Basically, I'm trying option n2 from a very similar ticket posted previously , with the difference that I'm using PG 10.1 . I've been trying 3 approaches to setting the variable: SET local myvars.user_id = 4 , thereby setting it locally in the transaction; SET myvars.user_id = 4 , thereby setting it in the session; SELECT set_config('myvars.user_id', '4', false) , which depending of the last argument, will be a shortcut for the