mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-09 10:14:21 +01:00
Fix pragma page_count
This commit is contained in:
@@ -4229,13 +4229,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)
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ do_execsql_test pragma-table-info-invalid-table {
|
||||
|
||||
do_execsql_test_on_specific_db ":memory:" pragma-page-count-empty {
|
||||
PRAGMA page_count
|
||||
} {0}
|
||||
} {1}
|
||||
|
||||
do_execsql_test_on_specific_db ":memory:" pragma-page-count-table {
|
||||
CREATE TABLE foo(bar);
|
||||
|
||||
Reference in New Issue
Block a user