Skip to content

Commit d1efa55

Browse files
author
Erlend E. Aasland
committed
Sync with GH-24106
1 parent 09cac6c commit d1efa55

File tree

2 files changed

+1
-26
lines changed

2 files changed

+1
-26
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
Use ``sqlite3_stmt_readonly()`` internally to determine if a SQL statement is
2-
data-modifying. Requires sqlite3 3.7.11 or newer. Patch by Charles Leifer.
2+
data-modifying. Patch by Charles Leifer.

Modules/_sqlite/statement.c

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828
#include "prepare_protocol.h"
2929
#include "util.h"
3030

31-
#if SQLITE_VERSION_NUMBER >= 3007004
32-
#define HAVE_SQLITE3_STMT_READONLY
33-
#endif
34-
3531
/* prototypes */
3632
static int pysqlite_check_remaining_sql(const char* tail);
3733

@@ -57,7 +53,6 @@ static int pysqlite_statement_is_dml(sqlite3_stmt *statement, const char *sql)
5753
const char* p;
5854
int is_dml = 0;
5955

60-
#ifdef HAVE_SQLITE3_STMT_READONLY
6156
is_dml = !sqlite3_stmt_readonly(statement);
6257
if (is_dml) {
6358
/* Retain backwards-compatibility, as sqlite3_stmt_readonly will return
@@ -81,26 +76,6 @@ static int pysqlite_statement_is_dml(sqlite3_stmt *statement, const char *sql)
8176
break;
8277
}
8378
}
84-
#else
85-
/* Determine if the statement is a DML statement. SELECT is the only
86-
* exception. This is a fallback for older versions of SQLite which do not
87-
* support the sqlite3_stmt_readonly() API. */
88-
for (p = sql; *p != 0; p++) {
89-
switch (*p) {
90-
case ' ':
91-
case '\r':
92-
case '\n':
93-
case '\t':
94-
continue;
95-
}
96-
97-
is_dml = (PyOS_strnicmp(p, "insert", 6) == 0)
98-
|| (PyOS_strnicmp(p, "update", 6) == 0)
99-
|| (PyOS_strnicmp(p, "delete", 6) == 0)
100-
|| (PyOS_strnicmp(p, "replace", 7) == 0);
101-
break;
102-
}
103-
#endif
10479
return is_dml;
10580
}
10681

0 commit comments

Comments
 (0)