SQLite User Forum

Question about sqlite version 3.31 not recoverable using recovery source?
Login

Question about sqlite version 3.31 not recoverable using recovery source?

(1) By wang12302 on 2025-06-17 11:32:50 [link] [source]

#1 Hello, I recently ran into a problem while using sqlite SQLITE_CORRUPT: sqlite3 result code 11: database disk image is malformed so I tried to recover it, so one question I have is that in that version of sqlite only started to support the use of recovered source code to recover corrupt database?

#2 And while recovering corrupt database using source code I came across some problems, I would like to ask for some advice here bro.

#3 I have to use sqlite version 3.31 now, so I did some countermeasures for all the following problems, but the last one has not been solved so far.

#4 First of all, the code provided with the documentation reports no SQLITE_FCNTL_RESET_CACHE definition, to address this, I added this macro definition to sqlite3recover.c (by looking at the macro definitions in sqlite.h on the sqlite3.42 version):

#ifndef SQLITE_FCNTL_RESET_CACHE define SQLITE_FCNTL_RESET_CACHE 42

#endif

#5 Secondly, after adding the above macro definition, there is no SQLITE_VTAB_USES_ALL_SCHEMAS definition, for this, I add this macro definition in dbdata.c (by looking at the macro definition in sqlite.h on sqlite version 3.42):

#ifndef SQLITE_VTAB_USES_ALL_SCHEMAS define SQLITE_VTAB_USES_ALL_SCHEMAS 4

#endif

#6 Then, the recovery error: no such table: sqlite_schema (1), saying that there is no sqlite_schema table, after checking the information, in the old version of sqlite is used in sqlite_master table, so in the code to do the substitution.

#7 Finally, reported error recovery error: no such table: sqlite_dbpage (1) , because I am in this table then I checked the information and found that it is a continuation table, so far there is no solution, there is a replacement program in sqlite version 3.31?

(2) By Dan Kennedy (dan) on 2025-06-17 11:50:27 in reply to 1 [link] [source]

You could try to recover the database using the latest SQLite shell tool from sqlite.org/download.html . If it works the results will still be readable by 3.31 and other versions.

I think it will be quite tricky to get the recovery module to work with an old version of SQLite.

Dan.

(3) By wang12302 on 2025-06-17 12:05:37 in reply to 2 [link] [source]

Bro, you don't know, it would be nice to use a higher version of sqlite, I am using sqlite 3.42 which is recoverable, but in this project the sqlite database is 3.31 and I can't go for upgrading the version, what I want to do is to API the source code of the recovery capability to the embedded project. So now I am in dire need of a solution to recover the corrupt database on sqlite 3.31 version.

(4) By Stephan Beal (stephan) on 2025-06-17 15:28:38 in reply to 3 [link] [source]

So now I am in dire need of a solution to recover the corrupt database on sqlite 3.31 version.

Dan was suggesting that you use a newer version only for the recovery, then copy the db back to the 3.31 installation (assuming it recovers, which is never guaranteed).

(5) By Simon Slavin (slavin) on 2025-06-18 13:05:11 in reply to 3 [source]

The underlying format of the database has not changed from version 3.31 to version 3.42. You can use the CLI or any other SQLite program based on 3.42 on it, then copy the results back to your 3.31 platform.