This is a backport of core#19077 [16/26]
https://github.com/bitcoin/bitcoin/pull/19077/commits/727e6b2a4ee5abb7f2dcbc9f7778291908dc28ad
Note: the code in the original commit does not compile. I had to declare int ret in SQLiteDatabase::Verify
Depends on D10563