diff options
author | Benjamin Peterson <benjamin@python.org> | 2017-09-20 14:36:18 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-20 14:36:18 (GMT) |
commit | 525269430a3f9fbb7287e4bb6b365ac216004980 (patch) | |
tree | 2d773b5d8ee8582da1b90bcbd17bb3ffc9ce25f7 /Modules/_sqlite/statement.c | |
parent | 0ad05c32cc41d4c21bfd78b9ffead519ead475a2 (diff) | |
download | cpython-525269430a3f9fbb7287e4bb6b365ac216004980.zip cpython-525269430a3f9fbb7287e4bb6b365ac216004980.tar.gz cpython-525269430a3f9fbb7287e4bb6b365ac216004980.tar.bz2 |
closes bpo-31525: require sqlite3_prepare_v2 (#3666)
This is based on
https://github.com/ghaering/pysqlite/commit/40b349cadbd87c42f70fc92e5e1aee6d02564c6d#diff-0489411409cd2934730e88bf7767790,
though we can be a bit more aggressive about deleting code.
Diffstat (limited to 'Modules/_sqlite/statement.c')
-rw-r--r-- | Modules/_sqlite/statement.c | 56 |
1 files changed, 5 insertions, 51 deletions
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c index bc0d940..3869088 100644 --- a/Modules/_sqlite/statement.c +++ b/Modules/_sqlite/statement.c @@ -93,11 +93,11 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con } Py_BEGIN_ALLOW_THREADS - rc = SQLITE3_PREPARE(connection->db, - sql_cstr, - -1, - &self->st, - &tail); + rc = sqlite3_prepare_v2(connection->db, + sql_cstr, + -1, + &self->st, + &tail); Py_END_ALLOW_THREADS self->db = connection->db; @@ -319,52 +319,6 @@ void pysqlite_statement_bind_parameters(pysqlite_Statement* self, PyObject* para } } -int pysqlite_statement_recompile(pysqlite_Statement* self, PyObject* params) -{ - const char* tail; - int rc; - const char* sql_cstr; - Py_ssize_t sql_len; - sqlite3_stmt* new_st; - - sql_cstr = PyUnicode_AsUTF8AndSize(self->sql, &sql_len); - if (sql_cstr == NULL) { - rc = PYSQLITE_SQL_WRONG_TYPE; - return rc; - } - - Py_BEGIN_ALLOW_THREADS - rc = SQLITE3_PREPARE(self->db, - sql_cstr, - -1, - &new_st, - &tail); - Py_END_ALLOW_THREADS - - if (rc == SQLITE_OK) { - /* The efficient sqlite3_transfer_bindings is only available in SQLite - * version 3.2.2 or later. For older SQLite releases, that might not - * even define SQLITE_VERSION_NUMBER, we do it the manual way. - */ - #ifdef SQLITE_VERSION_NUMBER - #if SQLITE_VERSION_NUMBER >= 3002002 - /* The check for the number of parameters is necessary to not trigger a - * bug in certain SQLite versions (experienced in 3.2.8 and 3.3.4). */ - if (sqlite3_bind_parameter_count(self->st) > 0) { - (void)sqlite3_transfer_bindings(self->st, new_st); - } - #endif - #else - statement_bind_parameters(self, params); - #endif - - (void)sqlite3_finalize(self->st); - self->st = new_st; - } - - return rc; -} - int pysqlite_statement_finalize(pysqlite_Statement* self) { int rc; |