homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Use sqlite3 extended error codes
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Dima.Tisnek, erlendaasland, ghaering, kj, pablogsal, palaviv, r.david.murray
Priority: normal Keywords: patch

Created on 2015年05月07日 09:19 by Dima.Tisnek, last changed 2022年04月11日 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
24139.patch palaviv, 2016年08月30日 18:19 review
Pull Requests
URL Status Linked Edit
PR 1108 closed palaviv, 2017年04月13日 10:02
PR 28076 merged erlendaasland, 2021年08月30日 21:11
PR 29382 merged erlendaasland, 2021年11月03日 08:48
Messages (8)
msg242710 - (view) Author: Dima Tisnek (Dima.Tisnek) * Date: 2015年05月07日 09:19
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 
msg242714 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015年05月07日 13:41
It seems reasonable to provide as much error information as is available, one way or another. Would you like to work on a patch?
msg273949 - (view) Author: Aviv Palivoda (palaviv) * Date: 2016年08月30日 18:19
Attached is a patch to enable the extended error codes. This patch should be dependent on issue 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.
msg274008 - (view) Author: Dima Tisnek (Dima.Tisnek) * Date: 2016年08月31日 09:59
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?
msg274009 - (view) Author: Dima Tisnek (Dima.Tisnek) * Date: 2016年08月31日 10:02
I meant "the patch makes sense in itself".
msg274065 - (view) Author: Aviv Palivoda (palaviv) * Date: 2016年08月31日 20:12
> 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 issue 16379 will be resolved.
> Aviv the patch makes in itself.
I think that this issue should be dependent on issue 16379 as the behavior of the sqlite module will no be changed after this patch until issue 16379 is resolved. In addition there will be some "rebase" issues that will need to be solved.
msg405569 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2021年11月02日 23:49
New changeset 456e27ac0ac6bc1cfd6da0191bd7802d8667457b by Erlend Egeberg Aasland in branch 'main':
bpo-24139: Add support for SQLite extended result codes (GH-28076)
https://github.com/python/cpython/commit/456e27ac0ac6bc1cfd6da0191bd7802d8667457b
msg405595 - (view) Author: Ken Jin (kj) * (Python committer) Date: 2021年11月03日 09:35
New changeset 0dfb8c4afee65f9e185882efd57f7012120da74c by Erlend Egeberg Aasland in branch 'main':
bpo-24139: Fix test_sqlite3 `test_extended_error_code_on_exception()` on s390x RHEL buildbots (GH-29382)
https://github.com/python/cpython/commit/0dfb8c4afee65f9e185882efd57f7012120da74c
History
Date User Action Args
2022年04月11日 14:58:16adminsetgithub: 68327
2021年11月03日 09:35:46kjsetnosy: + kj
messages: + msg405595
2021年11月03日 08:48:45erlendaaslandsetpull_requests: + pull_request27640
2021年11月02日 23:52:46erlendaaslandsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021年11月02日 23:49:46pablogsalsetnosy: + pablogsal
messages: + msg405569
2021年08月30日 21:11:58erlendaaslandsetpull_requests: + pull_request26520
2020年12月18日 22:33:55erlendaaslandsetnosy: + erlendaasland
2019年06月07日 00:00:51terry.reedysetpull_requests: - pull_request13749
2019年06月06日 19:17:57taleinatsetstage: patch review
pull_requests: + pull_request13749
2017年04月13日 10:02:14palavivsetpull_requests: + pull_request1249
2016年08月31日 20:12:15palavivsetmessages: + msg274065
2016年08月31日 10:02:11Dima.Tisneksetmessages: + msg274009
2016年08月31日 09:59:52Dima.Tisneksetmessages: + msg274008
2016年08月30日 18:19:28palavivsetfiles: + 24139.patch

nosy: + palaviv
messages: + msg273949

keywords: + patch
2015年05月07日 18:29:14ned.deilysetnosy: + ghaering
2015年05月07日 13:41:18r.david.murraysetnosy: + r.david.murray

messages: + msg242714
versions: - Python 3.5
2015年05月07日 09:19:35Dima.Tisnekcreate

AltStyle によって変換されたページ (->オリジナル) /