Prevent connection pointer is NULL details

pull/2123/head
Marco Slot 2018-04-22 11:12:51 +02:00 committed by Jason Petersen
parent 394732b6be
commit 88f64d22db
No known key found for this signature in database
GPG Key ID: 9F1D3510D110ABA9
1 changed files with 8 additions and 1 deletions

View File

@ -243,10 +243,17 @@ ReportConnectionError(MultiConnection *connection, int elevel)
{
char *nodeName = connection->hostname;
int nodePort = connection->port;
PGconn *pgConn = connection->pgConn;
char *messageDetail = NULL;
if (pgConn != NULL)
{
messageDetail = pchomp(PQerrorMessage(pgConn));
}
ereport(elevel, (errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("connection error: %s:%d", nodeName, nodePort),
errdetail("%s", pchomp(PQerrorMessage(connection->pgConn)))));
messageDetail != NULL ? errdetail("%s", messageDetail) : 0));
}