mirror of https://github.com/citusdata/citus.git
PQclear in ReportResultError to prevent memory leaks
parent
31231ce196
commit
ef326b202a
|
@ -124,6 +124,9 @@ ReportConnectionError(MultiConnection *connection, int elevel)
|
|||
*/
|
||||
void
|
||||
ReportResultError(MultiConnection *connection, PGresult *result, int elevel)
|
||||
{
|
||||
/* we release PQresult when throwing an error because the caller can't */
|
||||
PG_TRY();
|
||||
{
|
||||
char *sqlStateString = PQresultErrorField(result, PG_DIAG_SQLSTATE);
|
||||
char *messagePrimary = PQresultErrorField(result, PG_DIAG_MESSAGE_PRIMARY);
|
||||
|
@ -137,8 +140,11 @@ ReportResultError(MultiConnection *connection, PGresult *result, int elevel)
|
|||
|
||||
if (sqlStateString != NULL)
|
||||
{
|
||||
sqlState = MAKE_SQLSTATE(sqlStateString[0], sqlStateString[1], sqlStateString[2],
|
||||
sqlStateString[3], sqlStateString[4]);
|
||||
sqlState = MAKE_SQLSTATE(sqlStateString[0],
|
||||
sqlStateString[1],
|
||||
sqlStateString[2],
|
||||
sqlStateString[3],
|
||||
sqlStateString[4]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -166,6 +172,13 @@ ReportResultError(MultiConnection *connection, PGresult *result, int elevel)
|
|||
errcontext("while executing command on %s:%d",
|
||||
nodeName, nodePort)));
|
||||
}
|
||||
PG_CATCH();
|
||||
{
|
||||
PQclear(result);
|
||||
PG_RE_THROW();
|
||||
}
|
||||
PG_END_TRY();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue