Any hooks for running statements before queries are run?

  • Goal:
    My database contains triggers that use custom postgres config values set using the set_config function. Ideally some hook exists where I could run set_config before each query runs (but in the same transaction as that query).

Is this possible? I can't find anything that suggests this functionality exists.

It seems like I could add this statement myself to my queries, but there are two issues:

  • For GUI mode, I can't add any SQL
  • In non-GUI mode, this is an additional statement, so I would need to turn off prepared statements.

Am I thinking about this correctly? What am I missing?

One idea is to have two queries, one to run the set_config and one to set the values, that you control with a JS query along the lines of:

await query1.trigger()