mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +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
ddf97a0cdc
commit
cdb206d3e7
|
@ -401,7 +401,9 @@ pq_complete_error(connectionObject *conn, PGresult **pgres, char **error)
|
|||
* instead, and the connection gets closed in the pq_raise call above
|
||||
* (see ticket #196)
|
||||
*/
|
||||
conn->closed = 2;
|
||||
if (CONNECTION_BAD == PQstatus(conn->pgconn)) {
|
||||
conn->closed = 2;
|
||||
}
|
||||
}
|
||||
IFCLEARPGRES(*pgres);
|
||||
if (*error) {
|
||||
|
|
|
@ -138,6 +138,7 @@ class LargeObjectTests(LargeObjectMixin, unittest.TestCase):
|
|||
|
||||
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