mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
core: Simplify error handling of malformed strings for prepared statements
This commit is contained in:
parent
f7ab8b11d6
commit
07bfeadd56
1 changed files with 22 additions and 28 deletions
50
core/lib.rs
50
core/lib.rs
|
@ -336,35 +336,29 @@ impl Connection {
|
|||
let mut parser = Parser::new(sql.as_bytes());
|
||||
let cmd = parser.next()?;
|
||||
let syms = self.syms.borrow();
|
||||
if let Some(cmd) = cmd {
|
||||
match cmd {
|
||||
Cmd::Stmt(stmt) => {
|
||||
let program = Rc::new(translate::translate(
|
||||
self.schema
|
||||
.try_read()
|
||||
.ok_or(LimboError::SchemaLocked)?
|
||||
.deref(),
|
||||
stmt,
|
||||
self.header.clone(),
|
||||
self.pager.clone(),
|
||||
Rc::downgrade(self),
|
||||
&syms,
|
||||
QueryMode::Normal,
|
||||
)?);
|
||||
Ok(Statement::new(
|
||||
program,
|
||||
self._db.mv_store.clone(),
|
||||
self.pager.clone(),
|
||||
))
|
||||
}
|
||||
Cmd::Explain(_stmt) => todo!(),
|
||||
Cmd::ExplainQueryPlan(_stmt) => todo!(),
|
||||
let cmd = cmd.expect("Successful parse on nonempty input string should produce a command");
|
||||
match cmd {
|
||||
Cmd::Stmt(stmt) => {
|
||||
let program = Rc::new(translate::translate(
|
||||
self.schema
|
||||
.try_read()
|
||||
.ok_or(LimboError::SchemaLocked)?
|
||||
.deref(),
|
||||
stmt,
|
||||
self.header.clone(),
|
||||
self.pager.clone(),
|
||||
Rc::downgrade(self),
|
||||
&syms,
|
||||
QueryMode::Normal,
|
||||
)?);
|
||||
Ok(Statement::new(
|
||||
program,
|
||||
self._db.mv_store.clone(),
|
||||
self.pager.clone(),
|
||||
))
|
||||
}
|
||||
} else {
|
||||
// Shouln't happen
|
||||
Err(LimboError::ParseError(
|
||||
"The supplied SQL string contains no statements".to_string(),
|
||||
))
|
||||
Cmd::Explain(_stmt) => todo!(),
|
||||
Cmd::ExplainQueryPlan(_stmt) => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue