Skip to content
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

Refactor sqlite3 error handler #129928

Closed
erlend-aasland opened this issue Feb 10, 2025 · 0 comments · Fixed by #129929
Closed

Refactor sqlite3 error handler #129928

erlend-aasland opened this issue Feb 10, 2025 · 0 comments · Fixed by #129929
Assignees
Labels
extension-modules C modules in the Modules dir topic-sqlite3 type-feature A feature request or enhancement

Comments

@erlend-aasland
Copy link
Contributor

erlend-aasland commented Feb 10, 2025

In most error cases, we can use the error indicator from the SQLite database pointer when we raise exceptions. However, for some SQLite C APIs, we have to use the result code directly. This is the case for some of the blob APIs, where the error indicator is not stored on the database pointer.

Currently, our "set error" handler only handles the case where the error indicator is set on the database pointer. We also need an Modules/_sqlite private API for raising exception from the SQLite C API result codes.

See also #128507 (comment)

Linked PRs

@erlend-aasland erlend-aasland added type-feature A feature request or enhancement topic-sqlite3 labels Feb 10, 2025
@erlend-aasland erlend-aasland self-assigned this Feb 10, 2025
erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue Feb 10, 2025
Add a private API for raising DB-API compatible exceptions based on the
result code of SQLite C APIs. Some APIs do not store the error indicator
on the database pointer, so we need to be able to deduce the DB-API
compatible exception directly from the error code.

- rename _pysqlite_seterror() as set_error_from_db()
- introduce set_error_from_code()
erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue Feb 10, 2025
Add a private API for raising DB-API compatible exceptions based on the
result code of SQLite C APIs. Some APIs do not store the error indicator
on the database pointer, so we need to be able to deduce the DB-API
compatible exception directly from the error code.

- rename _pysqlite_seterror() as set_error_from_db()
- introduce set_error_from_code()
erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue Feb 10, 2025
…on misuse

Consistently raise ProgrammingError if the user tries to create an UDF
with an invalid number of parameters.
erlend-aasland added a commit to erlend-aasland/cpython that referenced this issue Feb 10, 2025
…on misuse

Consistently raise ProgrammingError if the user tries to create an UDF
with an invalid number of parameters.
@picnixz picnixz added the extension-modules C modules in the Modules dir label Feb 10, 2025
erlend-aasland added a commit that referenced this issue Feb 11, 2025
…eation (#129941)

Consistently raise ProgrammingError if the user tries to create an UDF
with an invalid number of parameters.
@erlend-aasland erlend-aasland linked a pull request Feb 11, 2025 that will close this issue
erlend-aasland added a commit that referenced this issue Feb 11, 2025
Add a helper for raising DB-API compatible exceptions based on the
result code of SQLite C APIs. Some APIs do not store the error indicator
on the database pointer, so we need to be able to deduce the DB-API
compatible exception directly from the error code.

- rename _pysqlite_seterror() as set_error_from_db()
- introduce set_error_from_code()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extension-modules C modules in the Modules dir topic-sqlite3 type-feature A feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants