core: Kill Rows wrapper struct

It's just an useless wrapper, kill it.
This commit is contained in:
Pekka Enberg 2025-01-26 16:22:04 +02:00
parent 9f3b2dcc92
commit 7967cc5efc
12 changed files with 49 additions and 64 deletions

View file

@ -281,7 +281,7 @@ impl Connection {
}
}
pub fn query(self: &Rc<Connection>, sql: impl Into<String>) -> Result<Option<Rows>> {
pub fn query(self: &Rc<Connection>, sql: impl Into<String>) -> Result<Option<Statement>> {
let sql = sql.into();
trace!("Querying: {}", sql);
let mut parser = Parser::new(sql.as_bytes());
@ -292,7 +292,7 @@ impl Connection {
}
}
pub(crate) fn run_cmd(self: &Rc<Connection>, cmd: Cmd) -> Result<Option<Rows>> {
pub(crate) fn run_cmd(self: &Rc<Connection>, cmd: Cmd) -> Result<Option<Statement>> {
let db = self.db.clone();
let syms: &SymbolTable = &db.syms.borrow();
match cmd {
@ -306,7 +306,7 @@ impl Connection {
syms,
)?);
let stmt = Statement::new(program, self.pager.clone());
Ok(Some(Rows { stmt }))
Ok(Some(stmt))
}
Cmd::Explain(stmt) => {
let program = translate::translate(
@ -465,9 +465,9 @@ impl Statement {
}
}
pub fn query(&mut self) -> Result<Rows> {
pub fn query(&mut self) -> Result<Statement> {
let stmt = Statement::new(self.program.clone(), self.pager.clone());
Ok(Rows::new(stmt))
Ok(stmt)
}
pub fn columns(&self) -> &[String] {
@ -512,24 +512,6 @@ impl<'a> Row<'a> {
}
}
pub struct Rows {
stmt: Statement,
}
impl Rows {
pub fn new(stmt: Statement) -> Self {
Self { stmt }
}
pub fn next_row(&mut self) -> Result<StepResult<'_>> {
self.stmt.step()
}
pub fn columns(&self) -> &[String] {
self.stmt.columns()
}
}
pub(crate) struct SymbolTable {
pub functions: HashMap<String, Rc<function::ExternalFunc>>,
#[cfg(not(target_family = "wasm"))]
@ -605,7 +587,7 @@ impl<'a> QueryRunner<'a> {
}
impl Iterator for QueryRunner<'_> {
type Item = Result<Option<Rows>>;
type Item = Result<Option<Statement>>;
fn next(&mut self) -> Option<Self::Item> {
match self.parser.next() {