Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix performance regression in :mod:`sqlite3` when a DML statement appeared
in a different line than the rest of the SQL query.
8 changes: 4 additions & 4 deletions Modules/_sqlite/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con
continue;
}

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);
self->is_dml = (PyOS_strnicmp(p, "insert", 6) == 0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there commands that start with "update", "delete", etc? Can a user function that starts with such prefix (for example "replacewhitespaces()") be used in this context?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can a user function that starts with such prefix (for example "replacewhitespaces()") be used in this context?

Yes, they can. The original intent of the old version was to make that check more robust and avoid cases like you've mentioned. I don't think there is a way to achieve this without relying on SQLite APIs, but then relying on newer APIs usually results seeing "I can't compile the sqlite3 module on my system" issues on the tracker :)

|| (PyOS_strnicmp(p, "update", 6) == 0)
|| (PyOS_strnicmp(p, "delete", 6) == 0)
|| (PyOS_strnicmp(p, "replace", 7) == 0);
break;
}

Expand Down