pull/1334/merge
Svyatoslav 2017-04-21 14:50:12 +00:00 committed by GitHub
commit b2ea8217b5
1 changed files with 10 additions and 7 deletions

View File

@ -435,6 +435,14 @@ static void
StoreErrorMessage(PGconn *connection, StringInfo queryResultString) StoreErrorMessage(PGconn *connection, StringInfo queryResultString)
{ {
char *errorMessage = PQerrorMessage(connection); char *errorMessage = PQerrorMessage(connection);
/* put a default error message if no error message is reported */
if (errorMessage == NULL)
{
errorMessage = "An error occurred while running the query";
}
else
{
char *firstNewlineIndex = strchr(errorMessage, '\n'); char *firstNewlineIndex = strchr(errorMessage, '\n');
/* trim the error message at the line break */ /* trim the error message at the line break */
@ -442,11 +450,6 @@ StoreErrorMessage(PGconn *connection, StringInfo queryResultString)
{ {
*firstNewlineIndex = '\0'; *firstNewlineIndex = '\0';
} }
/* put a default error message if no error message is reported */
if (errorMessage == NULL)
{
errorMessage = "An error occurred while running the query";
} }
appendStringInfo(queryResultString, "%s", errorMessage); appendStringInfo(queryResultString, "%s", errorMessage);