Skip to content

Commit

Permalink
Revert "Revert "fixup: lazy db.pages""
Browse files Browse the repository at this point in the history
This reverts commit 7b697c6.
  • Loading branch information
milahu committed Apr 2, 2023
1 parent cb15b1e commit 4e4bb1f
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions database/sqlite3.ksy
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,7 @@ seq:
type: database_header
instances:
pages:
type:
switch-on: '(_index == header.idx_lock_byte_page ? 0 : _index >= header.idx_first_ptrmap_page and _index <= header.idx_last_ptrmap_page ? 1 : 2)'
cases:
0: lock_byte_page(_index + 1)
1: ptrmap_page(_index + 1)
# TODO: Free pages and cell overflow pages are incorrectly interpreted as btree pages
# This is unfortunate, but unavoidable since there's no way to recognize these types at
# this point in the parser.
2: btree_page(_index + 1)
pos: 0
size: header.page_size
type: page(_index + 1, header.page_size * _index)
repeat: expr
repeat-expr: header.num_pages
doc: |
Expand All @@ -57,6 +47,27 @@ instances:
TODO how exactly? add example code
if: false
types:
page:
params:
- id: page_number
type: s4
- id: ofs_body
type: s4
instances:
page_index:
value: 'page_number - 1'
body:
pos: ofs_body
size: _root.header.page_size
type:
switch-on: '(page_index == _root.header.idx_lock_byte_page ? 0 : page_index >= _root.header.idx_first_ptrmap_page and page_index <= _root.header.idx_last_ptrmap_page ? 1 : 2)'
cases:
0: lock_byte_page(page_number)
1: ptrmap_page(page_number)
# TODO: Free pages and cell overflow pages are incorrectly interpreted as btree pages
# This is unfortunate, but unavoidable since there's no way to recognize these types at
# this point in the parser.
2: btree_page(page_number)
database_header:
seq:
- id: magic
Expand Down

0 comments on commit 4e4bb1f

Please sign in to comment.