erleans / pgo

Erlang Postgres client and connection pool
Apache License 2.0
71 stars 15 forks source link

How to run a query outside of the transaction while in a transaction #81

Open lpil opened 1 week ago

lpil commented 1 week ago

Hello!

There's a check that prevents a process from intentionally using another pool in a transaction or with a different connection from the same transaction, even if one is explicitly passed in by the programmer.

https://github.com/erleans/pgo/blob/d1989c44f41ccf1b4e670ccafe46d43f71cb6dfc/src/pgo.erl#L95-L98

Is there an intended way around this? I would like full control over which pool is used, even if one of them is in a transaction state.

Thank you, Louis

tsloughter commented 1 week ago

Maybe exposing query/4 will do it. It accepts a Conn. So to get around this you'd have to checkout a connection and pass it directly, to be explicit you are going around the transaction.

lpil commented 5 days ago

That would work! Sounds good