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

Use sqlite3 extended error codes #68327

Closed
dimaqq mannequin opened this issue May 7, 2015 · 8 comments
Closed

Use sqlite3 extended error codes #68327

dimaqq mannequin opened this issue May 7, 2015 · 8 comments
Labels
extension-modules C modules in the Modules dir type-feature A feature request or enhancement

Comments

@dimaqq
Copy link
Mannequin

dimaqq mannequin commented May 7, 2015

BPO 24139
Nosy @bitdancer, @dimaqq, @palaviv, @pablogsal, @erlend-aasland, @Fidget-Spinner
PRs
  • bpo-16379: Expose sqlite error code  #1108
  • bpo-24139: Add support for SQLite extended result codes #28076
  • bpo-24139: Fix sqlite3 test suite on s390x RHEL buildbots #29382
  • Files
  • 24139.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-11-02.23:52:46.446>
    created_at = <Date 2015-05-07.09:19:35.400>
    labels = ['extension-modules', 'type-feature']
    title = 'Use sqlite3 extended error codes'
    updated_at = <Date 2021-11-03.09:35:46.381>
    user = 'https://github.com/dimaqq'

    bugs.python.org fields:

    activity = <Date 2021-11-03.09:35:46.381>
    actor = 'kj'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-11-02.23:52:46.446>
    closer = 'erlendaasland'
    components = ['Extension Modules']
    creation = <Date 2015-05-07.09:19:35.400>
    creator = 'Dima.Tisnek'
    dependencies = []
    files = ['44280']
    hgrepos = []
    issue_num = 24139
    keywords = ['patch']
    message_count = 8.0
    messages = ['242710', '242714', '273949', '274008', '274009', '274065', '405569', '405595']
    nosy_count = 7.0
    nosy_names = ['ghaering', 'r.david.murray', 'Dima.Tisnek', 'palaviv', 'pablogsal', 'erlendaasland', 'kj']
    pr_nums = ['1108', '28076', '29382']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue24139'
    versions = ['Python 3.6']

    @dimaqq
    Copy link
    Mannequin Author

    dimaqq mannequin commented May 7, 2015

    Let's fetch extended error codes from SQLite, information contained is not particularly interesting to the user, but may be invaluable in debugging!

    http://www.sqlite.org/rescode.html
    https://sqlite.org/c3ref/extended_result_codes.html
    http://www.sqlite.org/c3ref/errcode.html

    Current behaviour:

    For example, consider that extended error was SQLITE_READONLY_DBMOVED, it would be set in https://github.com/mackyle/sqlite/blob/1caed0ecc62583c4f8a509ff66ae99b6939fe727/src/pager.c#L4836 without explicit detail string.

    Python will call sqlite3_errcode() which will strip extended information via & errMask in https://github.com/mackyle/sqlite/blob/ebb27fe5bd5045d924d99cdd7dec9b7064c24768/src/main.c#L2176

    Python will then call sqlite3_errmsg(), and the error message will be according to truncated (simple) error per:
    https://github.com/mackyle/sqlite/blob/ebb27fe5bd5045d924d99cdd7dec9b7064c24768/src/main.c#L1318

    P.S. there are a few cases where sqlite3 internally sets both error code and message, in those cases, current Python module (presumably) reads out the error message correctly. For example https://github.com/mackyle/sqlite/blob/ebb27fe5bd5045d924d99cdd7dec9b7064c24768/src/main.c#L1584

    @dimaqq dimaqq mannequin added extension-modules C modules in the Modules dir type-feature A feature request or enhancement labels May 7, 2015
    @bitdancer
    Copy link
    Member

    It seems reasonable to provide as much error information as is available, one way or another. Would you like to work on a patch?

    @palaviv
    Copy link
    Mannequin

    palaviv mannequin commented Aug 30, 2016

    Attached is a patch to enable the extended error codes. This patch should be dependent on bpo-16379.
    Without returning the sqlite error code in the exception the extended error code does not reveal any information not currently available. As you can see in https://github.com/mackyle/sqlite/blob/ebb27fe5bd5045d924d99cdd7dec9b7064c24768/src/main.c#L1318 there are messages only for the non-extended error codes and that is what is exposed now.

    @dimaqq
    Copy link
    Mannequin Author

    dimaqq mannequin commented Aug 31, 2016

    Aviv the patch makes in itself.

    Are the changes in the other ticket needed to implement new tests?
    Or is it possible to include tests here?

    @dimaqq
    Copy link
    Mannequin Author

    dimaqq mannequin commented Aug 31, 2016

    I meant "the patch makes sense in itself".

    @palaviv
    Copy link
    Mannequin

    palaviv mannequin commented Aug 31, 2016

    Are the changes in the other ticket needed to implement new tests?
    Or is it possible to include tests here?

    It is not possible to add any tests to this issue before exposing the error code. I will implement new tests when bpo-16379 will be resolved.

    Aviv the patch makes in itself.

    I think that this issue should be dependent on bpo-16379 as the behavior of the sqlite module will no be changed after this patch until bpo-16379 is resolved. In addition there will be some "rebase" issues that will need to be solved.

    @pablogsal
    Copy link
    Member

    New changeset 456e27a by Erlend Egeberg Aasland in branch 'main':
    bpo-24139: Add support for SQLite extended result codes (GH-28076)
    456e27a

    @Fidget-Spinner
    Copy link
    Member

    New changeset 0dfb8c4 by Erlend Egeberg Aasland in branch 'main':
    bpo-24139: Fix test_sqlite3 test_extended_error_code_on_exception() on s390x RHEL buildbots (GH-29382)
    0dfb8c4

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    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 type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants