pgsql improvements

* set pgsql->result to NULL when we freed it
* drain the connection pipe just in case in pgsql_conn_release()