From c4e7be04f849a56bdabe93d16ef1472e95fd3ae7 Mon Sep 17 00:00:00 2001 From: Diego Reis Date: Thu, 8 May 2025 16:31:14 -0300 Subject: [PATCH] core: Handles prepared statement with empty SQL --- core/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/lib.rs b/core/lib.rs index f36072e3a..6139abdcd 100644 --- a/core/lib.rs +++ b/core/lib.rs @@ -325,6 +325,10 @@ pub struct Connection { impl Connection { pub fn prepare(self: &Rc, sql: impl AsRef) -> Result { + 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(), + )) } }