Make dblink try harder to form useful error messages
Make dblink try harder to form useful error messages

When libpq encounters a connection-level error, e.g. runs out of memory
while forming a result, there will be no error associated with PGresult,
but a message will be placed into PGconn's error buffer. postgres_fdw
takes care to use the PGconn error message when PGresult does not have
one, but dblink has been negligent in that regard. Modify dblink to mirror
what postgres_fdw has been doing.

Back-patch to all supported branches.

Author: Joe Conway
Reviewed-By: Tom Lane
Discussion: https://postgr.es/m/02fa2d90-2efd-00bc-fefc-c23c00eb671e%40joeconway.com

greenplum-db/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,xinzweb/gpdb,50wu/gpdb,adam8157/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,xinzweb/gpdb,ashwinstar/gpdb,xinzweb/gpdb,ashwinstar/gpdb,adam8157/gpdb,ashwinstar/gpdb,xinzweb/gpdb,jmcatamney/gpdb,xinzweb/gpdb,greenplum-db/gpdb,lisakowen/gpdb,50wu/gpdb,50wu/gpdb,adam8157/gpdb,lisakowen/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,jmcatamney/gpdb,adam8157/gpdb,adam8157/gpdb,jmcatamney/gpdb,50wu/gpdb,lisakowen/gpdb,lisakowen/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,greenplum-db/gpdb,greenplum-db/gpdb,lisakowen/gpdb,lisakowen/gpdb,lisakowen/gpdb,50wu/gpdb,adam8157/gpdb,xinzweb/gpdb,greenplum-db/gpdb,lisakowen/gpdb,greenplum-db/gpdb,ashwinstar/gpdb,adam8157/gpdb,adam8157/gpdb,jmcatamney/gpdb,xinzweb/gpdb,50wu/gpdb,50wu/gpdb,50wu/gpdb,ashwinstar/gpdb,xinzweb/gpdb