diff -r 3f9f13077ca8 Lib/sqlite3/test/transactions.py --- a/Lib/sqlite3/test/transactions.py Thu Nov 24 17:21:47 2016 +0900 +++ b/Lib/sqlite3/test/transactions.py Fri Nov 25 21:37:21 2016 +0200 @@ -179,6 +179,15 @@ class TransactionalDDL(unittest.TestCase result = self.con.execute("select * from test").fetchall() self.assertEqual(result, []) + def CheckImmediateTransactionalDDL(self): + # You can achieve transactional DDL by issuing a BEGIN + # statement manually. + self.con.execute("begin immediate") + self.con.execute("create table test(i)") + self.con.rollback() + with self.assertRaises(sqlite.OperationalError): + self.con.execute("select * from test") + def CheckTransactionalDDL(self): # You can achieve transactional DDL by issuing a BEGIN # statement manually. diff -r 3f9f13077ca8 Modules/_sqlite/statement.c --- a/Modules/_sqlite/statement.c Thu Nov 24 17:21:47 2016 +0900 +++ b/Modules/_sqlite/statement.c Fri Nov 25 21:37:21 2016 +0200 @@ -86,7 +86,9 @@ int pysqlite_statement_create(pysqlite_S self->is_ddl = (PyOS_strnicmp(p, "create ", 7) == 0) || (PyOS_strnicmp(p, "drop ", 5) == 0) - || (PyOS_strnicmp(p, "reindex ", 8) == 0); + || (PyOS_strnicmp(p, "reindex ", 8) == 0) + || (PyOS_strnicmp(p, "begin", 5) == 0 && + (p[5] == '\0' || p[5] == ' ')); break; }