Skip to content

Commit 2e5ccce

Browse files
committed
Merge 'Fix parser panic when duplicate column names are given to CREATE TABLE' from Krishna Vishal
Currently, we are using the same `Parser` instance across multiple queries (9cc9577). But during this error the parser is not finalized, so parser stack is not reset, thereby triggering the assertion at https://github.com/tursodatabase/limbo/blob/ 15f7928/vendored/sqlite3- parser/third_party/lemon/lempar.rs#L663 This PR fixes the panic by calling `sqlite3ParserFinalize()` in the case of error. Closes #742 ----------- `git bisect` FTW Reviewed-by: Jussi Saurio <[email protected]> Reviewed-by: Preston Thorpe (@PThorpe92) Closes #752
2 parents 9369f06 + 04fd5a4 commit 2e5ccce

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

core/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,10 @@ impl Iterator for QueryRunner<'_> {
596596
match self.parser.next() {
597597
Ok(Some(cmd)) => Some(self.conn.run_cmd(cmd)),
598598
Ok(None) => None,
599-
Err(err) => Some(Err(LimboError::from(err))),
599+
Err(err) => {
600+
self.parser.finalize();
601+
Some(Result::Err(LimboError::from(err)))
602+
}
600603
}
601604
}
602605
}

vendored/sqlite3-parser/src/lexer/sql/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub use error::Error;
2828
pub struct Parser<'input> {
2929
input: &'input [u8],
3030
scanner: Scanner<Tokenizer>,
31+
/// lemon parser
3132
parser: yyParser<'input>,
3233
}
3334

@@ -62,6 +63,11 @@ impl<'input> Parser<'input> {
6263
pub fn offset(&self) -> usize {
6364
self.scanner.offset()
6465
}
66+
67+
/// Public API for sqlite3ParserFinalize()
68+
pub fn finalize(&mut self) {
69+
self.parser.sqlite3ParserFinalize();
70+
}
6571
}
6672

6773
/*

0 commit comments

Comments
 (0)