Revert default_transaction_* to default only if set

When moving from autocommit True -> False reset only the server
parameters that were actually specified by psycopg to honour the
serssion characteristics.
This commit is contained in:
Daniele Varrazzo 2017-02-16 13:15:14 +00:00
parent d7bba865f3
commit 61101888e4

View File

@ -1237,17 +1237,21 @@ conn_set_session(connectionObject *self, int autocommit,
else if (self->autocommit) { else if (self->autocommit) {
/* we are moving from autocommit to not autocommit, so revert the /* we are moving from autocommit to not autocommit, so revert the
* characteristics to defaults to let BEGIN do its work */ * characteristics to defaults to let BEGIN do its work */
if (0 > pq_set_guc_locked(self, if (self->isolevel != ISOLATION_LEVEL_DEFAULT) {
"default_transaction_isolation", "default", if (0 > pq_set_guc_locked(self,
&pgres, &error, &_save)) { "default_transaction_isolation", "default",
goto endlock; &pgres, &error, &_save)) {
goto endlock;
}
} }
if (0 > pq_set_guc_locked(self, if (self->readonly != STATE_DEFAULT) {
"default_transaction_read_only", "default", if (0 > pq_set_guc_locked(self,
&pgres, &error, &_save)) { "default_transaction_read_only", "default",
goto endlock; &pgres, &error, &_save)) {
goto endlock;
}
} }
if (self->server_version >= 90100) { if (self->deferrable != STATE_DEFAULT) {
if (0 > pq_set_guc_locked(self, if (0 > pq_set_guc_locked(self,
"default_transaction_deferrable", "default", "default_transaction_deferrable", "default",
&pgres, &error, &_save)) { &pgres, &error, &_save)) {