File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -202,19 +202,27 @@ def raw_page(self, num: int) -> bytes:
202202 if (num < 1 or num > self .header .page_count ) and self .header .page_count > 0 :
203203 raise InvalidPageNumber ("Page number exceeds boundaries" )
204204
205- # If a specific WAL checkpoint was provided, use it instead of the on-disk page.
205+ data = None
206206 if self .checkpoint is not None and (frame := self .checkpoint .get (num )):
207- return frame .data
207+ # If a specific WAL checkpoint was provided, use it instead of the on-disk page.
208+ data = frame .data
208209
209- # Check if the latest valid instance of the page is committed (either the frame itself
210- # is the commit frame or it is included in a commit's frames). If so, return that frame's data.
211- if self . wal :
210+ elif self . wal :
211+ # Check if the latest valid instance of the page is committed (either the frame itself
212+ # is the commit frame or it is included in a commit's frames). If so, return that frame's data.
212213 for commit in reversed (self .wal .commits ):
213214 if (frame := commit .get (num )) and frame .valid :
214- return frame .data
215+ data = frame .data
216+ break
217+
218+ if data is not None :
219+ if num == 1 :
220+ # Page 1 has a database header that needs to be stripped
221+ return data [len (c_sqlite3 .header ) :]
222+ return data
215223
216224 # Else we read the page from the database file.
217- if num == 1 : # Page 1 is root
225+ if num == 1 : # Page 1 is root, skip header
218226 self .fh .seek (len (c_sqlite3 .header ))
219227 else :
220228 self .fh .seek ((num - 1 ) * self .page_size )
You can’t perform that action at this time.
0 commit comments