Search code examples
sqlitecompatibility

Backwards compatibility with sqlite DB


In my application I'm using an amalgamated embeded version of SQLite v3.8.4. In the past I had compatibility issues with v3.7 regarding page_size > 32768. Now I'd like to keep backwards compatibility on database files with v3.6.20 (default on RHEL6), but when I try to open my DB file on my RHEL6 machine I see the error:

Error: file is encrypted or is not a database

I can dump the database to an SQL file and then again import it to v3.7. This seems to do the trick to be readable on v3.6.20 but my DB is 3 GB in size and is not feasible for me to wait 2 hours for each dump.

What options can I set on my v3.8 to generate v3.6 compatible databases?

Databases dump

$ hexdump -C works-on-3.6.20.sqlite | head -n 8
00000000  53 51 4c 69 74 65 20 66  6f 72 6d 61 74 20 33 00  |SQLite format 3.|
00000010  04 00 01 01 00 40 20 20  00 00 00 01 00 2d 8c 51  |.....@  .....-.Q|
00000020  00 00 00 00 00 00 00 00  00 00 00 12 00 00 00 01  |................|
00000030  00 00 00 00 00 00 00 00  00 00 00 01 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 01  |................|
00000060  00 2d e2 21 05 00 00 00  02 03 f6 00 00 22 fd 07  |.-.!........."..|
00000070  03 fb 03 f6 01 8f 02 38  00 7c 01 61 81 62 07 07  |.......8.|.a.b..|
$ hexdump -C fails-on-3.6.20.sqlite | head -n 8
00000000  53 51 4c 69 74 65 20 66  6f 72 6d 61 74 20 33 00  |SQLite format 3.|
00000010  80 00 02 02 00 40 20 20  00 00 00 04 00 00 00 2b  |.....@  .......+|
00000020  00 00 00 00 00 00 00 00  00 00 00 14 00 00 00 01  |................|
00000030  00 00 00 00 00 00 00 00  00 00 00 01 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 04  |................|
00000060  00 2d e6 04 0d 7f fc 00  18 75 a4 00 7f 36 7f c9  |.-.......u...6..|
00000070  7e 6b 7f 0b 7d 8f 7e 38  7c 7e 7d 62 7b ab 7c 47  |~k..}.~8|~}b{.|G|

Solution

  • The non-working database has enabled WAL mode, which was introduced in version 3.7.0. Disable it.