summaryrefslogtreecommitdiff
path: root/psycopg/connection_int.c
diff options
context:
space:
mode:
authorJan UrbaƄski <wulczer@wulczer.org>2010-03-31 01:38:46 +0200
committerFederico Di Gregorio <fog@initd.org>2010-04-05 11:37:06 +0200
commitd8ab5ac8a1f15d9f3e33ac54942b04bb52ca161f (patch)
tree5b95e889e1ee81993ac9aad69c6143377f5694e1 /psycopg/connection_int.c
parent062a9602ae97bb61aad9f0ad4b57a93b18bf1411 (diff)
downloadpsycopg2-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.
Diffstat (limited to 'psycopg/connection_int.c')
-rw-r--r--psycopg/connection_int.c20
1 files changed, 6 insertions, 14 deletions
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));