fix --without-pq-postgresql
fix test
fix possible invalid free and a leak