pgsql: Fixed reconnect behaviour, fixed textqueries, eliminated one race. All issues eliminated. I will run it in production servers as of now.