mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-25 18:33:44 +03:00
Check the connection is really bad on exception before closing it
We end up here without a pgres sometimes (e.g. from lobject errors)
This commit is contained in:
parent
f0c38f0b37
commit
e5ab0b3987
|
@ -428,8 +428,10 @@ pq_complete_error(connectionObject *conn, PGresult **pgres, char **error)
|
|||
* instead, and the connection gets closed in the pq_raise call above
|
||||
* (see ticket #196)
|
||||
*/
|
||||
if (CONNECTION_BAD == PQstatus(conn->pgconn)) {
|
||||
conn->closed = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (*error) {
|
||||
free(*error);
|
||||
|
|
|
@ -130,6 +130,7 @@ class LargeObjectTests(LargeObjectTestCase):
|
|||
|
||||
self.assertRaises(psycopg2.OperationalError,
|
||||
self.conn.lobject, 0, "w", lo.oid)
|
||||
self.assert_(not self.conn.closed)
|
||||
|
||||
def test_import(self):
|
||||
self.tmpdir = tempfile.mkdtemp()
|
||||
|
|
Loading…
Reference in New Issue
Block a user