From: Shigeru Hanada Date: Fri, 1 Oct 2010 07:36:59 +0000 (+0900) Subject: Fix to check the result of connection attempt. X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=69bd042692d1fd616aa3e7985590067d7ae2d250;p=users%2Fhanada%2Fpostgres.git Fix to check the result of connection attempt. --- diff --git a/contrib/postgresql_fdw/postgresql_fdw.c b/contrib/postgresql_fdw/postgresql_fdw.c index 77fc107339..fce9bcb463 100644 --- a/contrib/postgresql_fdw/postgresql_fdw.c +++ b/contrib/postgresql_fdw/postgresql_fdw.c @@ -125,6 +125,11 @@ pgConnectServer(ForeignServer *server, UserMapping *user) /* verify connection parameters and do connect */ check_conn_params(keywords, values); conn = PQconnectdbParams(keywords, values, 0); + if (!conn || PQstatus(conn) != CONNECTION_OK) + ereport(ERROR, + (errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION), + errmsg("could not connect to server"), + errdetail("%s", PQerrorMessage(conn)))); pfree(keywords); pfree(values);