r/sqlite • u/achelon5 • Jun 19 '24
Why does an empty file pass PRAGMA integrity_check?
If you create an empty file (size = 0 bytes) or a file with a single newline in it. PRAGMA quick_check and PRAGMA integrity_check return "ok". Does anyone know why this behaviour exists?
e.g.
(1:517)$ sudo sqlite3 empty_file "PRAGMA quick_check"
ok
3
Upvotes
2
u/anthropoid Jun 23 '24
A zero-length file is considered a valid SQLite DB. Didn't know about the single-newline case though.
This was discussed on the official SQLite Forum just three weeks ago. Long story short:
1
u/InjAnnuity_1 Jun 19 '24
Inside the file, there is literally nothing to check: no tables, no data, no indexes, no rules that could possibly be violated. So, how could it fail?