mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 10:08:20 +00:00
Merge 'Fix page_count
pragma' from meteorgan
This issue was introduced in #819. However, I believe the solution is suboptimal because `pragma page_count` can never return 1, which is inconsistent with SQLite. <img width="442" alt="image" src="https://github.com/user- attachments/assets/c772eae7-3e9f-4687-a94a-230deb0eb034" /> To align with SQLite's behavior, we should allocate the first page when the first schema object is created, rather than immediately after creating database. And it's always preferable to return an accurate page count. Reviewed-by: Pere Diaz Bou <pere-altea@homail.com> Closes #1407
This commit is contained in:
commit
7643b7666c
2 changed files with 6 additions and 10 deletions
|
@ -4305,13 +4305,8 @@ pub fn op_page_count(
|
|||
// TODO: implement temp databases
|
||||
todo!("temp databases not implemented yet");
|
||||
}
|
||||
// SQLite returns "0" on an empty database, and 2 on the first insertion,
|
||||
// so we'll mimic that behavior.
|
||||
let mut pages = pager.db_header.lock().database_size.into();
|
||||
if pages == 1 {
|
||||
pages = 0;
|
||||
}
|
||||
state.registers[*dest] = Register::OwnedValue(OwnedValue::Integer(pages));
|
||||
let count = pager.db_header.lock().database_size.into();
|
||||
state.registers[*dest] = Register::OwnedValue(OwnedValue::Integer(count));
|
||||
state.pc += 1;
|
||||
Ok(InsnFunctionStepResult::Step)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue