diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2016-09-11 09:57:15 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2016-09-11 09:57:15 (GMT) |
commit | ab994ed8b97e1b0dac151ec827c857f5e7277565 (patch) | |
tree | d497b41e76a441931ac06430f44332497eaaa083 /Modules/_sqlite/statement.c | |
parent | bd48d27944453ad83d3ce37b2c867fa0d59a1c15 (diff) | |
download | cpython-ab994ed8b97e1b0dac151ec827c857f5e7277565.zip cpython-ab994ed8b97e1b0dac151ec827c857f5e7277565.tar.gz cpython-ab994ed8b97e1b0dac151ec827c857f5e7277565.tar.bz2 |
Issue #10740: sqlite3 no longer implicitly commit an open transaction before DDL statements
This commit contains the following commits from ghaering/pysqlite:
* https://github.com/ghaering/pysqlite/commit/f254c534948c41c0ceb8cbabf0d4a2f547754739
* https://github.com/ghaering/pysqlite/commit/796b3afe38cfdac5d7d5ec260826b0a596554631
* https://github.com/ghaering/pysqlite/commit/cae87ee68613697a5f4947b4a0941f59a28da1b6
* https://github.com/ghaering/pysqlite/commit/3567b31bb5e5b226ba006213a9c69dde3f155faf
With the following additions:
* Fixed a refcount error
* Fixed a compiler warning
* Made the string comparison a little more robust
* Added a whatsnew entry
Diffstat (limited to 'Modules/_sqlite/statement.c')
-rw-r--r-- | Modules/_sqlite/statement.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c index e870633..7b98013 100644 --- a/Modules/_sqlite/statement.c +++ b/Modules/_sqlite/statement.c @@ -54,6 +54,7 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con int rc; const char* sql_cstr; Py_ssize_t sql_cstr_len; + const char* p; self->st = NULL; self->in_use = 0; @@ -72,6 +73,23 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con Py_INCREF(sql); self->sql = sql; + /* determine if the statement is a DDL statement */ + self->is_ddl = 0; + for (p = sql_cstr; *p != 0; p++) { + switch (*p) { + case ' ': + case '\r': + case '\n': + case '\t': + continue; + } + + self->is_ddl = (PyOS_strnicmp(p, "create ", 7) == 0) + || (PyOS_strnicmp(p, "drop ", 5) == 0) + || (PyOS_strnicmp(p, "reindex ", 8) == 0); + break; + } + Py_BEGIN_ALLOW_THREADS rc = sqlite3_prepare(connection->db, sql_cstr, |