Fix bugs in pg_restore phase