Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34k
bpo-44165: optimise sqlite3 statement preparation by passing string size#26206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
5 commits Select commit Hold shift + click to select a range
f901fd5 bpo-44165: optimise sqlite3 statement preparation by passing string size
9febd15 Pass -1 if size >= INT_MAX
081de33 Raise OverflowError if SQL string is too long
d981be6 Raise DataError iso. OverflowError to keep current behaviour
d0d0618 sqlite3_limit is cheap; use it directly iso. caching it in the connec…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -66,6 +66,12 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con | ||
| rc = PYSQLITE_SQL_WRONG_TYPE; | ||
| return rc; | ||
| } | ||
| int max_length = sqlite3_limit(connection->db, SQLITE_LIMIT_LENGTH, -1); | ||
| if (sql_cstr_len >= max_length){ | ||
| PyErr_SetString(pysqlite_DataError, "query string is too large"); | ||
erlend-aasland marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| return PYSQLITE_TOO_MUCH_SQL; | ||
| } | ||
| if (strlen(sql_cstr) != (size_t)sql_cstr_len){ | ||
| PyErr_SetString(PyExc_ValueError, "the query contains a null character"); | ||
| return PYSQLITE_SQL_WRONG_TYPE; | ||
| @@ -96,7 +102,7 @@ int pysqlite_statement_create(pysqlite_Statement* self, pysqlite_Connection* con | ||
| Py_BEGIN_ALLOW_THREADS | ||
| rc = sqlite3_prepare_v2(connection->db, | ||
| sql_cstr, | ||
| -1, | ||
| (int)sql_cstr_len + 1, | ||
| &self->st, | ||
| &tail); | ||
| Py_END_ALLOW_THREADS | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.