summaryrefslogtreecommitdiff
path: root/psycopg
diff options
context:
space:
mode:
authorFederico Di Gregorio <fog@initd.org>2011-12-15 12:22:52 +0100
committerFederico Di Gregorio <fog@initd.org>2011-12-15 12:25:19 +0100
commitd2d94e203f868d17d4e7ff670078a7df7afbad90 (patch)
treedc94e3441eb93a3f95a9cddc2a8b3af837419b5d /psycopg
parent8473209d240bad964630b9b77da7fcc664f61b41 (diff)
downloadpsycopg2-d2d94e203f868d17d4e7ff670078a7df7afbad90.tar.gz
Reverted isolation level values to backward compatible values
This basically removes the READ UNCOMMITED level (that internally PostgreSQL maps to READ COMMITED anyway) to keep the numeric values compattible with old psycopg versions. For full details and discussion see this thread: http://archives.postgresql.org/psycopg/2011-12/msg00008.php
Diffstat (limited to 'psycopg')
-rw-r--r--psycopg/connection_int.c13
-rw-r--r--psycopg/connection_type.c8
2 files changed, 11 insertions, 10 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c
index 441d362..41b73f1 100644
--- a/psycopg/connection_int.c
+++ b/psycopg/connection_int.c
@@ -39,10 +39,10 @@
const IsolationLevel conn_isolevels[] = {
{"", 0}, /* autocommit */
- {"read uncommitted", 1},
- {"read committed", 2},
- {"repeatable read", 3},
- {"serializable", 4},
+ {"read committed", 1},
+ {"read uncommitted", 1}, /* comes after to report real level */
+ {"repeatable read", 2},
+ {"serializable", 3},
{"default", -1},
{ NULL }
};
@@ -1041,9 +1041,8 @@ conn_switch_isolation_level(connectionObject *self, int level)
/* use only supported levels on older PG versions */
if (self->server_version < 80000) {
- if (level == 1 || level == 3) {
- ++level;
- }
+ if (level == 2)
+ level = 3;
}
if (-1 == (curr_level = conn_get_isolation_level(self))) {
diff --git a/psycopg/connection_type.c b/psycopg/connection_type.c
index 2bb0e70..02bc4da 100644
--- a/psycopg/connection_type.c
+++ b/psycopg/connection_type.c
@@ -405,13 +405,15 @@ _psyco_conn_parse_isolevel(connectionObject *self, PyObject *pyval)
if (PyInt_Check(pyval)) {
long level = PyInt_AsLong(pyval);
if (level == -1 && PyErr_Occurred()) { goto exit; }
- if (level < 1 || level > 4) {
+ if (level < 1 || level > 3) {
PyErr_SetString(PyExc_ValueError,
- "isolation_level must be between 1 and 4");
+ "isolation_level must be between 1 and 3");
goto exit;
}
- isolevel = conn_isolevels + level;
+ isolevel = conn_isolevels;
+ while ((++isolevel)->value != level)
+ ; /* continue */
}
/* parse from the string -- this includes "default" */