Pg pool rebased

this is the rebased PR #298 made by @aslakhellesoy + the native switch.

i was not able to setup the test environment locally but i tested this fix in our application, wich is already in production environment, it worked as expected