Clear all the notify messages in cdbconn_discardResults()
Currently, notify messages are not used in GPDB by QE's except for sequence
nextval messages. While cleaning the connection for reuse best to remove all the
notify messages as well to be safe than sorry even later if we start using it
for more things.
@@ -572,6 +572,7 @@ cdbconn_discardResults(SegmentDatabaseDescriptor *segdbDesc,
PGresult *pRes = NULL;
ExecStatusType stat;
int i = 0;
+ bool retval = true;
/* PQstatus() is smart enough to handle NULL */
while (NULL != (pRes = PQgetResult(segdbDesc->conn)))
@@ -584,13 +585,31 @@ cdbconn_discardResults(SegmentDatabaseDescriptor *segdbDesc,
PQerrorMessage(segdbDesc->conn));
if (stat == PGRES_FATAL_ERROR || stat == PGRES_BAD_RESPONSE)
- return true;
+ {
+ retval = true;
+ break;
+ }
if (i++ > retryCount)
- return false;
+ {
+ retval = false;
+ break;
+ }
+ }
+
+ /*
+ * Clear of all the notify messages as well.
+ */
+ PGnotify *notify = segdbDesc->conn->notifyHead;
+ while (notify != NULL)
+ {
+ PGnotify *prev = notify;
+ notify = notify->next;
+ PQfreemem(prev);
}
+ segdbDesc->conn->notifyHead = segdbDesc->conn->notifyTail = NULL;
- return true;
+ return retval;
}
/* Return if it's a bad connection */
