summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>2017-02-16 13:15:14 +0000
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>2017-02-16 13:15:14 +0000
commit61101888e43d1526b63a23aeb216a9bc2ea2e197 (patch)
tree5cb2f23676cc23dd8d4c3e69b714fb08a05eaa23
parentd7bba865f3ed3b5c9e5dde9154b6a6c091a54deb (diff)
downloadpsycopg2-session-attributes.tar.gz
Revert default_transaction_* to default only if setsession-attributes
When moving from autocommit True -> False reset only the server parameters that were actually specified by psycopg to honour the serssion characteristics.
-rw-r--r--psycopg/connection_int.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c
index e0a369e..e8081b9 100644
--- a/psycopg/connection_int.c
+++ b/psycopg/connection_int.c
@@ -1237,17 +1237,21 @@ conn_set_session(connectionObject *self, int autocommit,
else if (self->autocommit) {
/* we are moving from autocommit to not autocommit, so revert the
* characteristics to defaults to let BEGIN do its work */
- if (0 > pq_set_guc_locked(self,
- "default_transaction_isolation", "default",
- &pgres, &error, &_save)) {
- goto endlock;
+ if (self->isolevel != ISOLATION_LEVEL_DEFAULT) {
+ if (0 > pq_set_guc_locked(self,
+ "default_transaction_isolation", "default",
+ &pgres, &error, &_save)) {
+ goto endlock;
+ }
}
- if (0 > pq_set_guc_locked(self,
- "default_transaction_read_only", "default",
- &pgres, &error, &_save)) {
- goto endlock;
+ if (self->readonly != STATE_DEFAULT) {
+ if (0 > pq_set_guc_locked(self,
+ "default_transaction_read_only", "default",
+ &pgres, &error, &_save)) {
+ goto endlock;
+ }
}
- if (self->server_version >= 90100) {
+ if (self->deferrable != STATE_DEFAULT) {
if (0 > pq_set_guc_locked(self,
"default_transaction_deferrable", "default",
&pgres, &error, &_save)) {