diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2017-02-04 02:25:48 +0000 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2017-02-04 02:38:56 +0000 |
commit | c1e016e597e1ee2b52e5277a09793caa9401f39d (patch) | |
tree | 3719e64a5efcdbe66652e19a4e38d531ef2ba479 /psycopg/connection.h | |
parent | 9863637f309e1e89523007c40e9dcdde69f60bc0 (diff) | |
download | psycopg2-c1e016e597e1ee2b52e5277a09793caa9401f39d.tar.gz |
Don't use default_transaction_* for session characteristics
Store the state in the connection object and set the params on BEGIN
Some tests fail: a few can be fixed reading transaction_* instead of
default_transaction_*; but the behaviour of tx characteristics with
autocommit is effectively changed. It may be addressed by setting
default_transaction_* if autocommit is set.
Diffstat (limited to 'psycopg/connection.h')
-rw-r--r-- | psycopg/connection.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/psycopg/connection.h b/psycopg/connection.h index 2e2d51d..6c39263 100644 --- a/psycopg/connection.h +++ b/psycopg/connection.h @@ -38,6 +38,12 @@ extern "C" { #define ISOLATION_LEVEL_READ_COMMITTED 1 #define ISOLATION_LEVEL_REPEATABLE_READ 2 #define ISOLATION_LEVEL_SERIALIZABLE 3 +#define ISOLATION_LEVEL_DEFAULT 5 + +/* 3-state values on/off/default */ +#define STATE_OFF 0 +#define STATE_ON 1 +#define STATE_DEFAULT 2 /* connection status */ #define CONN_STATUS_SETUP 0 @@ -129,6 +135,11 @@ struct connectionObject { * codecs.getdecoder('utf8') */ PyObject *pyencoder; /* python codec encoding function */ PyObject *pydecoder; /* python codec decoding function */ + + /* Values for the transactions characteristics */ + int isolevel; + int readonly; + int deferrable; }; /* map isolation level values into a numeric const */ @@ -155,10 +166,9 @@ HIDDEN void conn_close(connectionObject *self); HIDDEN void conn_close_locked(connectionObject *self); RAISES_NEG HIDDEN int conn_commit(connectionObject *self); RAISES_NEG HIDDEN int conn_rollback(connectionObject *self); -RAISES_NEG HIDDEN int conn_set_session(connectionObject *self, const char *isolevel, - const char *readonly, const char *deferrable, - int autocommit); HIDDEN int conn_set_autocommit(connectionObject *self, int value); +RAISES_NEG HIDDEN int conn_parse_isolevel(connectionObject *self, PyObject *pyval); +RAISES_NEG HIDDEN int conn_parse_onoff(PyObject *pyval); RAISES_NEG HIDDEN int conn_switch_isolation_level(connectionObject *self, int level); RAISES_NEG HIDDEN int conn_set_client_encoding(connectionObject *self, const char *enc); HIDDEN int conn_poll(connectionObject *self); |