core: Handles prepared statement with empty SQL

This commit is contained in:
Diego Reis
2025-05-08 16:31:14 -03:00
parent 9b96e2bcc3
commit c4e7be04f8

View File

@@ -325,6 +325,10 @@ pub struct Connection {
impl Connection {
pub fn prepare(self: &Rc<Connection>, sql: impl AsRef<str>) -> Result<Statement> {
if sql.as_ref().is_empty() {
return Err(LimboError::InvalidArgument("The supplied SQL string contains no statements".to_string()));
}
let sql = sql.as_ref();
tracing::trace!("Preparing: {}", sql);
let mut parser = Parser::new(sql.as_bytes());
@@ -355,7 +359,10 @@ impl Connection {
Cmd::ExplainQueryPlan(_stmt) => todo!(),
}
} else {
todo!()
// Shouln't happen
Err(LimboError::ParseError(
"The supplied SQL string contains no statements".to_string(),
))
}
}