mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-02-07 12:50:32 +03:00
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.
This commit is contained in:
parent
58079c6c91
commit
73265e7ece
|
@ -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
|
||||
|
|
2
NEWS-2.3
2
NEWS-2.3
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user