hook on connection initialization
niquola opened this issue · 17 comments
Hello, is there any way to be hooked when new connection is opened.
I have to do some initialization SQL before all queries, ala SET plv8.init_proc =...
Anyway, let me know if it works for you, please. Also, the PR to update the README would be great! :)
Should this key be added to datasource-options and passed to (make-datasource opts) ?
Method not found: setConnectionInitSql
Also looks like ignoring: (.addDataSourceProperty ds "connectionInitSQL" "SET plv8.start_proc = 'plv8_init'")
(.setConnectionInitSql config "SET plv8.ustart_proc = 'plv8_init';")
does not work too
@niquola Weird: https://github.com/brettwooldridge/HikariCP/search?utf8=%E2%9C%93&q=setConnectionInitSql&type=Code
The solution would be to add custom setting like here:
hikari-cp/src/hikari_cp/core.clj
Lines 117 to 125 in fd2bf0d
Would you be so kind to prepare PR for this? :)
I will try
👍 Thanks!
Cool,
The only problem - that i'm doing this by hand - but it does not work :(
Ie (.setConnectionInitSql config "SET plv8.ustart_proc = 'plv8_init';") is called without errors, but SQL statement does not executed.
Who should execute this statement - pool? driver?
Another question: how to set pg specific connection property 'stringtype=unspecified'?
Another question: how to set pg specific connection property 'stringtype=unspecified'?
Would it work for you to set it using the configure
option? It would probably something along the lines of:
(make-datasource {:configure (fn [cfg] (.setYourProperty ...))})
Explicit support for :connection-init-sql
has been added in 7fbe6ac and released in 1.6.0. I hope this helps!
It would be nice to have a hook for on connection too. I'm experimenting with postgres notifications and I need a reliable way to set them up. Since they might vary over the course of a program run, fixed sql isn't going to cut it :/