From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "struct" |
|---|
| subject | "Format:SQLite database file" |
|---|
| claim | "An SQLite rollback journal segment header is 28 bytes padded to one sector: magic, u32 record count, u32 checksum nonce, u32 original database size in pages, u32 sector size, u32 page size, all big-endian; page records (u32 page number, page, u32 checksum) start at the next sector. When the journal is written without sync (no-sync, memory mode or SAFE_APPEND device) the magic is present and the count is 0xFFFFFFFF (read to end of file); otherwise both the 8 magic bytes and the count are zero until syncJournal fills them in." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:SQLite database file" |
|---|
| observed_in | |
|---|
|
|---|
| data | | name | "SQLiteJournalHeader" |
|---|
| size | "0x1C" |
|---|
| fields | | offset | "0x0" |
|---|
| size | 8 |
|---|
| type | "uint8_t[8]" |
|---|
| name | "magic" |
|---|
| notes | "D9 D5 05 F9 20 A1 63 D7" |
|---|
|
| offset | "0x8" |
|---|
| size | 4 |
|---|
| type | "int32_be" |
|---|
| name | "record_count" |
|---|
|
| offset | "0xC" |
|---|
| size | 4 |
|---|
| type | "uint32_be" |
|---|
| name | "nonce" |
|---|
| notes | "initial value of every record checksum" |
|---|
|
| offset | "0x10" |
|---|
| size | 4 |
|---|
| type | "uint32_be" |
|---|
| name | "original_page_count" |
|---|
|
| offset | "0x14" |
|---|
| size | 4 |
|---|
| type | "uint32_be" |
|---|
| name | "sector_size" |
|---|
| notes | "header padding; records start at this offset" |
|---|
|
| offset | "0x18" |
|---|
| size | 4 |
|---|
| type | "uint32_be" |
|---|
| name | "page_size" |
|---|
|
|
|---|
| notes | "Bytes 0-11 (magic and record count) are zero in a journal that has not been synced yet (the normal sync mode); the magic is only written immediately, with count 0xFFFFFFFF, in no-sync, journal_mode=memory or SQLITE_IOCAP_SAFE_APPEND cases." |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "Journal header format comment and writeJournalHdr (nRec semantics)" |
|---|
| repo | "https://github.com/sqlite/sqlite" |
|---|
| commit | "43a48f77585a88940c727f33682151418f544059" |
|---|
| path | "src/pager.c" |
|---|
| lines | "1476-1530" |
|---|
|
| type | "runtime_test" |
|---|
| detail | "SQLite 3.53.1 journal: sector size 512, page size 4096, original size 27 pages, 24 segments each with nRec 1 and its own nonce" |
|---|
|
| type | "source" |
|---|
| detail | "Read writeJournalHdr: if noSync || memory || SAFE_APPEND memcpy magic and put32bits 0xffffffff, else memset(zHeader, 0, sizeof(aJournalMagic)+4); then cksumInit, dbOrigSize, sectorSize, pageSize at +8+4.. +8+16." |
|---|
| repo | "https://github.com/sqlite/sqlite" |
|---|
| commit | "43a48f77585a88940c727f33682151418f544059" |
|---|
| path | "src/pager.c" |
|---|
| lines | "1486-1595" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "Rollback journal header" |
|---|
| topic | "Format:SQLite database file/Rollback journal and WAL" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-17T19:35:40.628Z" |
|---|
| verifications | |
|---|
| revisions | | by | "PatientStepper99" |
|---|
| date | "2026-10-19T07:41:24.520Z" |
|---|
| summary | "writeJournalHdr writes the magic and the 0xFFFFFFFF count only in no-sync, memory-journal or SAFE_APPEND mode; otherwise the first 12 bytes (magic and record count) are zero until syncJournal. So…" |
|---|
| changed | | "claim" |
| "data" |
| "evidence" |
|
|---|
|
|
|---|