diff options
| author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-11-16 00:42:23 +0000 |
|---|---|---|
| committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2010-11-16 01:01:32 +0000 |
| commit | 73265e7ece3ca5e6eba1ec8b4234e5884905aafc (patch) | |
| tree | a41b7d9420bbd61acc3c58066d1a332e8432817e /psycopg/connection_int.c | |
| parent | 58079c6c9110767eda2e7ba894aaf1bffbd18ad2 (diff) | |
| download | psycopg2-73265e7ece3ca5e6eba1ec8b4234e5884905aafc.tar.gz | |
Refuse connection with server with protocol version 2.
This cuts off server whose version is older than 7.4. But enables us to
remove large portions of code rarely used and tested (e.g. p2 copy) and
will allow us to drop the query we do at each connection to establish
the client encoding and the datestyle.
Diffstat (limited to 'psycopg/connection_int.c')
| -rw-r--r-- | psycopg/connection_int.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 7f86460..e335c39 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -295,6 +295,10 @@ conn_setup(connectionObject *self, PGconn *pgconn) self->equote = conn_get_standard_conforming_strings(pgconn); self->server_version = conn_get_server_version(pgconn); self->protocol = conn_get_protocol_version(self->pgconn); + if (3 != self->protocol) { + PyErr_SetString(InterfaceError, "only protocol 3 supported"); + return -1; + } Py_BEGIN_ALLOW_THREADS; pthread_mutex_lock(&self->lock); @@ -636,6 +640,10 @@ _conn_poll_setup_async(connectionObject *self) self->equote = conn_get_standard_conforming_strings(self->pgconn); self->protocol = conn_get_protocol_version(self->pgconn); self->server_version = conn_get_server_version(self->pgconn); + if (3 != self->protocol) { + PyErr_SetString(InterfaceError, "only protocol 3 supported"); + break; + } /* asynchronous connections always use isolation level 0, the user is * expected to manage the transactions himself, by sending |
