update pgsql test & fix some corner cases