diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2012-02-29 23:51:51 +0000 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2012-03-01 02:53:28 +0000 |
commit | a167822e2692a8372d4cbe4570a3616cbd57ff6b (patch) | |
tree | ab03725308fdb46ef5e02686320c7d2d7b94596e /psycopg/connection_int.c | |
parent | 67712e42268176894a08462006020a0a3946a6ce (diff) | |
download | psycopg2-a167822e2692a8372d4cbe4570a3616cbd57ff6b.tar.gz |
Use the newly provided attributes to validate exceptions raising
Be more consistent in using 0 for success, <0 for failure, and to check
for values < 0 instead of specific -1.
Diffstat (limited to 'psycopg/connection_int.c')
-rw-r--r-- | psycopg/connection_int.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index cb65224..4c12e1d 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -370,6 +370,7 @@ exit: } +CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION int conn_get_isolation_level(connectionObject *self) { @@ -947,6 +948,7 @@ conn_close(connectionObject *self) /* conn_commit - commit on a connection */ +CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION int conn_commit(connectionObject *self) { @@ -958,6 +960,7 @@ conn_commit(connectionObject *self) /* conn_rollback - rollback a connection */ +CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION int conn_rollback(connectionObject *self) { @@ -1040,6 +1043,7 @@ conn_set_autocommit(connectionObject *self, int value) /* conn_switch_isolation_level - switch isolation level on the connection */ +CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION int conn_switch_isolation_level(connectionObject *self, int level) { @@ -1122,12 +1126,13 @@ endlock: /* conn_set_client_encoding - switch client encoding on connection */ +CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION int conn_set_client_encoding(connectionObject *self, const char *enc) { PGresult *pgres = NULL; char *error = NULL; - int res = 1; + int res = -1; char *codec = NULL; char *clean_enc = NULL; @@ -1195,6 +1200,7 @@ exit: * in regular transactions, as PostgreSQL won't even know we are in a TPC * until PREPARE. */ +CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION int conn_tpc_begin(connectionObject *self, XidObject *xid) { @@ -1229,6 +1235,7 @@ conn_tpc_begin(connectionObject *self, XidObject *xid) * The function doesn't change the connection state as it can be used * for many commands and for recovered transactions. */ +CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION int conn_tpc_command(connectionObject *self, const char *cmd, XidObject *xid) { |