rogerbinns / apsw

Another Python SQLite wrapper
https://rogerbinns.github.io/apsw/
Other
715 stars 96 forks source link

Make VFS use chained exceptions #489

Closed rogerbinns closed 9 months ago

rogerbinns commented 9 months ago

APSW has avoided chained exceptions with VFS in the past because they didn't exist under Python 2, and because it muddies the waters. For example a VFS exception could cause SQLite to take recovery actions which could then result in further completely unrelated exceptions, so the chaining didn't make semantic sense. SQLite is also running an error code system which Python exceptions hide.

But using unraiseable also results in the exceptions being cleared after printing, so it gets more difficult to tie exceptions that happened around each other together. Doing testing of pathological error conditions has shown that chaining is the better way of handling this.

It will result in observable different behaviour in the release including this, but only when exceptions happen and even then mostly when more than one exception happens during the same SQLite call. Far more exceptions that previously came through via the unraisable mechanism will now come through directly.

rogerbinns commented 9 months ago

An example of unexpected behaviour is that SQLite calls xDlOpen a second time (with slightly different parameters) if the first call returns NULL. Consequently you will the first call exception chained to the second call exception.

rogerbinns commented 9 months ago

https://github.com/rogerbinns/apsw/commit/3d117dba761fdd1ae0564de1fc883891e65a20aa is the final commit addressing this issue and it is now merged into master.