diff options
| author | Jan UrbaĆski <wulczer@wulczer.org> | 2010-03-31 01:38:46 +0200 |
|---|---|---|
| committer | Federico Di Gregorio <fog@initd.org> | 2010-04-05 11:37:06 +0200 |
| commit | d8ab5ac8a1f15d9f3e33ac54942b04bb52ca161f (patch) | |
| tree | 5b95e889e1ee81993ac9aad69c6143377f5694e1 | |
| parent | 062a9602ae97bb61aad9f0ad4b57a93b18bf1411 (diff) | |
| download | psycopg2-d8ab5ac8a1f15d9f3e33ac54942b04bb52ca161f.tar.gz | |
Make asynchronous connections always use autocommit
Clients using async connections are expected to do their own
transaction management by sending (asynchronously) BEGIN and COMMIT
statements.
As a bonus, it allows to drop one step from the async connection
building, namely getting the default isolation level from the server.
| -rw-r--r-- | psycopg/connection.h | 3 | ||||
| -rw-r--r-- | psycopg/connection_int.c | 20 | ||||
| -rw-r--r-- | psycopg/connection_type.c | 2 |
3 files changed, 6 insertions, 19 deletions
diff --git a/psycopg/connection.h b/psycopg/connection.h index 33ad30b..32aaddf 100644 --- a/psycopg/connection.h +++ b/psycopg/connection.h @@ -48,9 +48,6 @@ extern "C" { #define CONN_STATUS_SEND_CLIENT_ENCODING 8 #define CONN_STATUS_SENT_CLIENT_ENCODING 9 #define CONN_STATUS_GET_CLIENT_ENCODING 10 -#define CONN_STATUS_SEND_TRANSACTION_ISOLATION 11 -#define CONN_STATUS_SENT_TRANSACTION_ISOLATION 12 -#define CONN_STATUS_GET_TRANSACTION_ISOLATION 13 /* async query execution status */ #define ASYNC_READ 1 diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 4646eea..0fce84d 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -404,11 +404,6 @@ conn_poll_send(connectionObject *self) query = psyco_client_encoding; next_status = CONN_STATUS_SENT_CLIENT_ENCODING; break; - case CONN_STATUS_SEND_TRANSACTION_ISOLATION: - /* get the default isolevel */ - query = psyco_transaction_isolation; - next_status = CONN_STATUS_SENT_TRANSACTION_ISOLATION; - break; default: /* unexpected state, error out */ PyErr_Format(OperationalError, @@ -444,9 +439,6 @@ conn_poll_send(connectionObject *self) case CONN_STATUS_SENT_CLIENT_ENCODING: next_status = CONN_STATUS_GET_CLIENT_ENCODING; break; - case CONN_STATUS_SENT_TRANSACTION_ISOLATION: - next_status = CONN_STATUS_GET_TRANSACTION_ISOLATION; - break; } } else { @@ -526,17 +518,17 @@ conn_poll_fetch(connectionObject *self) return NULL; } Dprintf("conn_poll_fetch: got client_encoding %s", self->encoding); - next_status = CONN_STATUS_SEND_TRANSACTION_ISOLATION; - } - else if (self->status == CONN_STATUS_GET_TRANSACTION_ISOLATION) { - /* got the default isolevel */ - self->isolation_level = conn_get_isolation_level(pgres); - Dprintf("conn_poll_fetch: got isolevel %ld", self->isolation_level); /* since this is the last step, set the other instance variables now */ self->equote = conn_get_standard_conforming_strings(self->pgconn); self->protocol = conn_get_protocol_version(self->pgconn); self->server_version = (int) PQserverVersion(self->pgconn); + /* + * asynchronous connections always use isolation level 0, the user is + * expected to manage the transactions himself, by sending + * (asynchronously) BEGIN and COMMIT statements. + */ + self->isolation_level = 0; Py_BEGIN_ALLOW_THREADS; pthread_mutex_lock(&(self->lock)); diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c index 3d5629d..a4f5430 100644 --- a/psycopg/connection_type.c +++ b/psycopg/connection_type.c @@ -421,14 +421,12 @@ psyco_conn_poll(connectionObject *self) case CONN_STATUS_SEND_DATESTYLE: case CONN_STATUS_SEND_CLIENT_ENCODING: - case CONN_STATUS_SEND_TRANSACTION_ISOLATION: /* these mean that we need to wait for the socket to become writable to send the rest of our query */ return conn_poll_send(self); case CONN_STATUS_GET_DATESTYLE: case CONN_STATUS_GET_CLIENT_ENCODING: - case CONN_STATUS_GET_TRANSACTION_ISOLATION: /* these mean that we are waiting for the results of the queries */ return conn_poll_fetch(self); |
