diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2011-06-01 09:07:02 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2011-06-01 09:07:02 +0100 |
commit | ea03ffbf76c24e7ba36cc6c94ec2b0c748700c20 (patch) | |
tree | fb442a0f4f9ffc2a28bdcebb4c8f5243bdaa67da /psycopg/connection_int.c | |
parent | a69facc7f0abf96493a2d269365f1392c0e8143c (diff) | |
download | psycopg2-ea03ffbf76c24e7ba36cc6c94ec2b0c748700c20.tar.gz |
Added partial implementation for set_transaction
autocommit to be implemented yet.
Diffstat (limited to 'psycopg/connection_int.c')
-rw-r--r-- | psycopg/connection_int.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 22c5bc5..b0ed41d 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -952,6 +952,46 @@ conn_rollback(connectionObject *self) return res; } +/* conn_set - set a guc parameter */ + +int +conn_set(connectionObject *self, const char *param, const char *value) +{ + char query[256]; + PGresult *pgres = NULL; + char *error = NULL; + int res = 1; + + Dprintf("conn_set: setting %s to %s", param, value); + + Py_BEGIN_ALLOW_THREADS; + pthread_mutex_lock(&self->lock); + + if (0 == strcmp(value, "default")) { + sprintf(query, "SET %s TO DEFAULT;", param); + } + else { + sprintf(query, "SET %s TO '%s';", param, value); + } + + res = pq_execute_command_locked(self, query, &pgres, &error, &_save); + + pthread_mutex_unlock(&self->lock); + Py_END_ALLOW_THREADS; + + if (res < 0) { + pq_complete_error(self, &pgres, &error); + } + + return res; +} + +int +conn_set_autocommit(connectionObject *self, int value) +{ + return -1; +} + /* conn_switch_isolation_level - switch isolation level on the connection */ int |