Merge 'Pragma page size reading' from Anton Harniakou

1) Fix a bug where cli pretty mode would not print pragma results;
2) Add ability to read page_size using PRAGMA page_size;

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #1394
This commit is contained in:
Jussi Saurio
2025-04-24 11:08:55 +03:00
4 changed files with 10 additions and 2 deletions

View File

@@ -797,7 +797,7 @@ impl<'a> Limbo<'a> {
}
}
if table.header().is_some() {
if !table.is_empty() {
let _ = self.write_fmt(format_args!("{}", table));
}
}

View File

@@ -160,6 +160,9 @@ fn update_pragma(
// getting here
unreachable!();
}
PragmaName::PageSize => {
todo!("updating page_size is not yet implemented")
}
}
}
@@ -257,6 +260,10 @@ fn query_pragma(
});
program.emit_result_row(register, 1);
}
PragmaName::PageSize => {
program.emit_int(database_header.lock().page_size.into(), register);
program.emit_result_row(register, 1);
}
}
Ok(())

View File

@@ -1448,7 +1448,6 @@ pub fn op_result_row(
values: &state.registers[*start_reg] as *const Register,
count: *count,
};
state.result_row = Some(row);
state.pc += 1;
return Ok(InsnFunctionStepResult::Row);

View File

@@ -1622,6 +1622,8 @@ pub enum PragmaName {
LegacyFileFormat,
/// Return the total number of pages in the database file.
PageCount,
/// Return the page size of the database in bytes.
PageSize,
/// returns information about the columns of a table
TableInfo,
/// Returns the user version of the database file.