File tree 1 file changed +15
-3
lines changed 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -106,12 +106,23 @@ new_statement_cache(pysqlite_Connection *self, int maxsize)
106
106
return res ;
107
107
}
108
108
109
+ static inline const char *
110
+ begin_stmt_to_isolation_level (const char * begin_stmt )
111
+ {
112
+ assert (begin_stmt != NULL );
113
+
114
+ // All begin statements start with "BEGIN "; add strlen("BEGIN ") to get
115
+ // the isolation level.
116
+ return begin_stmt + 6 ;
117
+ }
118
+
109
119
static const char *
110
120
get_begin_statement (const char * level )
111
121
{
112
122
assert (level != NULL );
113
123
for (int i = 0 ; begin_statements [i ] != NULL ; i ++ ) {
114
- const char * candidate = begin_statements [i ] + 6 ;
124
+ const char * stmt = begin_statements [i ];
125
+ const char * candidate = begin_stmt_to_isolation_level (stmt );
115
126
if (sqlite3_stricmp (level , candidate ) == 0 ) {
116
127
return begin_statements [i ];
117
128
}
@@ -1322,8 +1333,9 @@ static PyObject* pysqlite_connection_get_isolation_level(pysqlite_Connection* se
1322
1333
return NULL ;
1323
1334
}
1324
1335
if (self -> begin_statement != NULL ) {
1325
- // We return what's left of the statement after "BEGIN "
1326
- return PyUnicode_FromString (self -> begin_statement + 6 );
1336
+ const char * stmt = self -> begin_statement ;
1337
+ const char * iso_level = begin_stmt_to_isolation_level (stmt );
1338
+ return PyUnicode_FromString (iso_level );
1327
1339
}
1328
1340
Py_RETURN_NONE ;
1329
1341
}
You can’t perform that action at this time.
0 commit comments