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 | |
| 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.
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | NEWS-2.3 | 2 | ||||
| -rw-r--r-- | doc/src/connection.rst | 4 | ||||
| -rw-r--r-- | psycopg/connection_int.c | 8 |
4 files changed, 17 insertions, 1 deletions
@@ -1,3 +1,7 @@ +2010-11-16 Daniele Varrazzo <daniele.varrazzo@gmail.com> + + * psycopg/connection_int.c: abort connection to protocol 2 server. + 2010-11-11 Daniele Varrazzo <daniele.varrazzo@gmail.com> * lib/extras.py: build the namedtuple only once per execution, not once @@ -13,6 +13,8 @@ psycopg 2.3 aims to expose some new features introduced in PostgreSQL 9.0. * Other features and changes: + - Dropped support for protocol 2: Psycopg 2.3 can only connect to PostgreSQL + servers with version at least 7.4. - `mogrify()` now supports unicode queries. - subclasses of a type that can be adapted are adapted as the superclass. - `errorcodes` knows a couple of new codes introduced in PostgreSQL 9.0. diff --git a/doc/src/connection.rst b/doc/src/connection.rst index 624fcba..22241fe 100644 --- a/doc/src/connection.rst +++ b/doc/src/connection.rst @@ -428,7 +428,9 @@ The ``connection`` class .. attribute:: protocol_version A read-only integer representing frontend/backend protocol being used. - It can be 2 or 3. + Currently Psycopg supports only protocol 3, which allows connection + to PostgreSQL server from version 7.4. Psycopg versions previous than + 2.3 support both protocols 2 and 3. .. seealso:: libpq docs for `PQprotocolVersion()`__ for details. 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 |
