mirror of https://github.com/citusdata/citus.git
PQclear in ReportResultError to prevent memory leaks
parent
31231ce196
commit
ef326b202a
|
@ -125,6 +125,9 @@ ReportConnectionError(MultiConnection *connection, int elevel)
|
||||||
void
|
void
|
||||||
ReportResultError(MultiConnection *connection, PGresult *result, int elevel)
|
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 *sqlStateString = PQresultErrorField(result, PG_DIAG_SQLSTATE);
|
||||||
char *messagePrimary = PQresultErrorField(result, PG_DIAG_MESSAGE_PRIMARY);
|
char *messagePrimary = PQresultErrorField(result, PG_DIAG_MESSAGE_PRIMARY);
|
||||||
char *messageDetail = PQresultErrorField(result, PG_DIAG_MESSAGE_DETAIL);
|
char *messageDetail = PQresultErrorField(result, PG_DIAG_MESSAGE_DETAIL);
|
||||||
|
@ -137,8 +140,11 @@ ReportResultError(MultiConnection *connection, PGresult *result, int elevel)
|
||||||
|
|
||||||
if (sqlStateString != NULL)
|
if (sqlStateString != NULL)
|
||||||
{
|
{
|
||||||
sqlState = MAKE_SQLSTATE(sqlStateString[0], sqlStateString[1], sqlStateString[2],
|
sqlState = MAKE_SQLSTATE(sqlStateString[0],
|
||||||
sqlStateString[3], sqlStateString[4]);
|
sqlStateString[1],
|
||||||
|
sqlStateString[2],
|
||||||
|
sqlStateString[3],
|
||||||
|
sqlStateString[4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -165,6 +171,13 @@ ReportResultError(MultiConnection *connection, PGresult *result, int elevel)
|
||||||
messageContext ? errcontext("%s", messageContext) : 0,
|
messageContext ? errcontext("%s", messageContext) : 0,
|
||||||
errcontext("while executing command on %s:%d",
|
errcontext("while executing command on %s:%d",
|
||||||
nodeName, nodePort)));
|
nodeName, nodePort)));
|
||||||
|
}
|
||||||
|
PG_CATCH();
|
||||||
|
{
|
||||||
|
PQclear(result);
|
||||||
|
PG_RE_THROW();
|
||||||
|
}
|
||||||
|
PG_END_TRY();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue