summaryrefslogtreecommitdiff
path: root/psycopg/connection_int.c
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2011-12-15 12:53:48 +0000
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2011-12-15 12:53:48 +0000
commitb5de04d2ff6fd50b7e4fd06516ac396d9c79d8b6 (patch)
treec838c6bf0d56bc6c2cb1f3739746fd2f5ede361d /psycopg/connection_int.c
parentd2d94e203f868d17d4e7ff670078a7df7afbad90 (diff)
downloadpsycopg2-b5de04d2ff6fd50b7e4fd06516ac396d9c79d8b6.tar.gz
Put back a distinct ISOLATION_LEVEL_READ_UNCOMMITTED value
Diffstat (limited to 'psycopg/connection_int.c')
-rw-r--r--psycopg/connection_int.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c
index 41b73f1..7046513 100644
--- a/psycopg/connection_int.c
+++ b/psycopg/connection_int.c
@@ -35,15 +35,16 @@
#include <string.h>
/* Mapping from isolation level name to value exposed by Python.
- * Only used for backward compatibility by the isolation_level property */
-
+ *
+ * Note: ordering matters: to get a valid pre-PG 8 level from one not valid,
+ * we increase a pointer in this list by one position. */
const IsolationLevel conn_isolevels[] = {
- {"", 0}, /* autocommit */
- {"read committed", 1},
- {"read uncommitted", 1}, /* comes after to report real level */
- {"repeatable read", 2},
- {"serializable", 3},
- {"default", -1},
+ {"", ISOLATION_LEVEL_AUTOCOMMIT},
+ {"read uncommitted", ISOLATION_LEVEL_READ_UNCOMMITTED},
+ {"read committed", ISOLATION_LEVEL_READ_COMMITTED},
+ {"repeatable read", ISOLATION_LEVEL_REPEATABLE_READ},
+ {"serializable", ISOLATION_LEVEL_SERIALIZABLE},
+ {"default", -1}, /* never to be found on the server */
{ NULL }
};
@@ -1041,8 +1042,10 @@ conn_switch_isolation_level(connectionObject *self, int level)
/* use only supported levels on older PG versions */
if (self->server_version < 80000) {
- if (level == 2)
- level = 3;
+ if (level == ISOLATION_LEVEL_READ_UNCOMMITTED)
+ level = ISOLATION_LEVEL_READ_COMMITTED;
+ else if (level == ISOLATION_LEVEL_REPEATABLE_READ)
+ level = ISOLATION_LEVEL_SERIALIZABLE;
}
if (-1 == (curr_level = conn_get_isolation_level(self))) {