diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2017-02-07 00:40:08 +0000 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2017-02-07 00:58:29 +0000 |
commit | 7485fabe4fb460fdab33296cc86fc33e17aaef47 (patch) | |
tree | e8b90480d37c69911506af6a6c6c43fd03658a3a | |
parent | c54a614c6e479e64d1819e2122a5b8972adc7a40 (diff) | |
download | psycopg2-7485fabe4fb460fdab33296cc86fc33e17aaef47.tar.gz |
Fixed BEGIN; SET TRANSACTION with PG 7.4no-set-default-session
-rw-r--r-- | psycopg/pqpath.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index c686402..50bd520 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -493,14 +493,22 @@ pq_begin_locked(connectionObject *conn, PGresult **pgres, char **error, return 0; } - snprintf(buf, bufsize, "BEGIN%s%s%s%s%s", - conn->server_version < 80000 ? ";SET TRANSACTION" : "", - (conn->isolevel >= 1 && conn->isolevel <= 4) - ? " ISOLATION LEVEL " : "", - (conn->isolevel >= 1 && conn->isolevel <= 4) - ? srv_isolevels[conn->isolevel] : "", - srv_readonly[conn->readonly], - srv_deferrable[conn->deferrable]); + if (conn->isolevel == ISOLATION_LEVEL_DEFAULT + && conn->readonly == STATE_DEFAULT + && conn->deferrable == STATE_DEFAULT) { + strcpy(buf, "BEGIN"); + } + else { + snprintf(buf, bufsize, + conn->server_version >= 80000 ? + "BEGIN%s%s%s%s" : "BEGIN;SET TRANSACTION%s%s%s%s", + (conn->isolevel >= 1 && conn->isolevel <= 4) + ? " ISOLATION LEVEL " : "", + (conn->isolevel >= 1 && conn->isolevel <= 4) + ? srv_isolevels[conn->isolevel] : "", + srv_readonly[conn->readonly], + srv_deferrable[conn->deferrable]); + } result = pq_execute_command_locked(conn, buf, pgres, error, tstate); if (result == 0) |