summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/statement.c
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2017-02-26 15:22:38 (GMT)
committerGitHub <noreply@github.com>2017-02-26 15:22:38 (GMT)
commit4a926caf8e5fd8af771b2c34bfb6e91c732331fe (patch)
treebddaa3a91ef435b1b18716b8385a6415c55fbd13 /Modules/_sqlite/statement.c
parent46ce7599af82a929506baeaaee5c149970440c4c (diff)
downloadcpython-4a926caf8e5fd8af771b2c34bfb6e91c732331fe.zip
cpython-4a926caf8e5fd8af771b2c34bfb6e91c732331fe.tar.gz
cpython-4a926caf8e5fd8af771b2c34bfb6e91c732331fe.tar.bz2
bpo-28518: Start a transaction implicitly before a DML statement (#245)
Patch by Aviv Palivoda.
Diffstat (limited to 'Modules/_sqlite/statement.c')
-rw-r--r--Modules/_sqlite/statement.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/Modules/_sqlite/statement.c b/Modules/_sqlite/statement.c
index 8b45a03..27b2654 100644
--- a/Modules/_sqlite/statement.c
+++ b/Modules/_sqlite/statement.c
@@ -73,8 +73,9 @@ 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;
+ /* Determine if the statement is a DML statement.
+ SELECT is the only exception. See #9924. */
+ self->is_dml = 0;
for (p = sql_cstr; *p != 0; p++) {
switch (*p) {
case ' ':
@@ -84,9 +85,10 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
continue;
}
- self->is_ddl = (PyOS_strnicmp(p, "create ", 7) == 0)
- || (PyOS_strnicmp(p, "drop ", 5) == 0)
- || (PyOS_strnicmp(p, "reindex ", 8) == 0);
+ self->is_dml = (PyOS_strnicmp(p, "insert ", 7) == 0)
+ || (PyOS_strnicmp(p, "update ", 7) == 0)
+ || (PyOS_strnicmp(p, "delete ", 7) == 0)
+ || (PyOS_strnicmp(p, "replace ", 8) == 0);
break;
}