Check for deferrable unsupported applied to attribute too

This commit is contained in:
Daniele Varrazzo 2017-02-16 13:14:45 +00:00
parent d50ed48807
commit d7bba865f3
2 changed files with 8 additions and 7 deletions

View File

@ -1189,6 +1189,13 @@ conn_set_session(connectionObject *self, int autocommit,
PGresult *pgres = NULL; PGresult *pgres = NULL;
char *error = NULL; char *error = NULL;
if (deferrable != self->deferrable && self->server_version < 90100) {
PyErr_SetString(ProgrammingError,
"the 'deferrable' setting is only available"
" from PostgreSQL 9.1");
goto exit;
}
/* Promote an isolation level to one of the levels supported by the server */ /* Promote an isolation level to one of the levels supported by the server */
if (self->server_version < 80000) { if (self->server_version < 80000) {
if (isolevel == ISOLATION_LEVEL_READ_UNCOMMITTED) { if (isolevel == ISOLATION_LEVEL_READ_UNCOMMITTED) {
@ -1219,7 +1226,7 @@ conn_set_session(connectionObject *self, int autocommit,
goto endlock; goto endlock;
} }
} }
if (deferrable != self->deferrable && self->server_version >= 90100) { if (deferrable != self->deferrable) {
if (0 > pq_set_guc_locked(self, if (0 > pq_set_guc_locked(self,
"default_transaction_deferrable", srv_state_guc[deferrable], "default_transaction_deferrable", srv_state_guc[deferrable],
&pgres, &error, &_save)) { &pgres, &error, &_save)) {

View File

@ -588,12 +588,6 @@ psyco_conn_set_session(connectionObject *self, PyObject *args, PyObject *kwargs)
} }
} }
if (Py_None != deferrable) { if (Py_None != deferrable) {
if (self->server_version < 90100) {
PyErr_SetString(ProgrammingError,
"the 'deferrable' setting is only available"
" from PostgreSQL 9.1");
return NULL;
}
if (0 > (c_deferrable = _psyco_conn_parse_onoff(deferrable))) { if (0 > (c_deferrable = _psyco_conn_parse_onoff(deferrable))) {
return NULL; return NULL;
} }