Ensure we capture notices raised by queries. Fixes #3027

This commit is contained in:
Murtuza Zabuawala
2018-02-02 15:23:33 +01:00
committed by Dave Page
parent 4d69764869
commit 25647c16ba
2 changed files with 23 additions and 6 deletions
@@ -1333,6 +1333,7 @@ Failed to reset the connection to the server due to following error:
)
)
is_error = False
try:
status = self._wait_timeout(self.conn)
except psycopg2.Error as pe:
@@ -1343,12 +1344,18 @@ Failed to reset the connection to the server due to following error:
self.conn_id[5:]
)
errmsg = self._formatted_exception_msg(pe, formatted_exception_msg)
return False, errmsg
is_error = True
if self.conn.notices and self.__notices is not None:
while self.conn.notices:
self.__notices.append(self.conn.notices.pop(0)[:])
# We also need to fetch notices before we return from function in case
# of any Exception, To avoid code duplication we will return after
# fetching the notices in case of any Exception
if is_error:
return False, errmsg
result = None
self.row_count = 0
self.column_info = None