From 69bd042692d1fd616aa3e7985590067d7ae2d250 Mon Sep 17 00:00:00 2001 From: Shigeru Hanada Date: Fri, 1 Oct 2010 16:36:59 +0900 Subject: [PATCH] Fix to check the result of connection attempt. --- contrib/postgresql_fdw/postgresql_fdw.c | 5 +++++ 1 file changed, 5 insertions(+) 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); -- 2.39.5