Read the server version only after connection established.

This commit is contained in:
Daniele Varrazzo 2010-04-21 13:22:09 +01:00
parent 8fed0aa57d
commit d71520db9a
2 changed files with 7 additions and 3 deletions

View File

@ -374,8 +374,6 @@ conn_sync_connect(connectionObject *self)
Dprintf("conn_connect: using protocol %d", self->protocol);
self->server_version = (int)PQserverVersion(pgconn);
/* if the connection is green, wait to finish connection */
if (green) {
wait_rv = psyco_wait(self);
@ -386,6 +384,8 @@ conn_sync_connect(connectionObject *self)
}
}
self->server_version = (int)PQserverVersion(pgconn);
/* From here the connection is considered ready: with the new status,
* poll() will use PQisBusy instead of PQconnectPoll.
*/

View File

@ -45,6 +45,10 @@ class ConnectionTests(unittest.TestCase):
self.assert_(conn.notices)
conn.close()
def test_server_version(self):
conn = self.connect()
self.assert_(conn.server_version)
def test_suite():
return unittest.TestLoader().loadTestsFromName(__name__)