diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-04-21 13:22:09 +0100 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-04-21 15:31:07 +0100 |
| commit | d71520db9a7fdd4739677ad066fd8a3d9b118d75 (patch) | |
| tree | 36f71ba097b1f82edafb6533836f32d39e4f07b6 | |
| parent | 8fed0aa57d588c3655423a3d25ece01662719836 (diff) | |
| download | psycopg2-d71520db9a7fdd4739677ad066fd8a3d9b118d75.tar.gz | |
Read the server version only after connection established.
| -rw-r--r-- | psycopg/connection_int.c | 4 | ||||
| -rw-r--r-- | tests/test_connection.py | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index dd80576..e564cfc 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -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. */ diff --git a/tests/test_connection.py b/tests/test_connection.py index 277616b..dbb80af 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -45,8 +45,12 @@ 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__) if __name__ == "__main__": - unittest.main()
\ No newline at end of file + unittest.main() |
