mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-31 06:54:21 +01:00
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 (9cc9577c91). 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/
15f7928551435458e2991dde3a76ce71e8a32057/vendored/sqlite3-
parser/third_party/lemon/lempar.rs#L663
This PR fixes the panic by calling `sqlite3ParserFinalize()` in the case
of error.
Closes https://github.com/tursodatabase/limbo/issues/742
-----------
`git bisect` FTW
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>
Reviewed-by: Preston Thorpe (@PThorpe92)
Closes #752
This commit is contained in:
@@ -596,7 +596,10 @@ impl Iterator for QueryRunner<'_> {
|
||||
match self.parser.next() {
|
||||
Ok(Some(cmd)) => Some(self.conn.run_cmd(cmd)),
|
||||
Ok(None) => None,
|
||||
Err(err) => Some(Err(LimboError::from(err))),
|
||||
Err(err) => {
|
||||
self.parser.finalize();
|
||||
Some(Result::Err(LimboError::from(err)))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ pub use error::Error;
|
||||
pub struct Parser<'input> {
|
||||
input: &'input [u8],
|
||||
scanner: Scanner<Tokenizer>,
|
||||
/// lemon parser
|
||||
parser: yyParser<'input>,
|
||||
}
|
||||
|
||||
@@ -62,6 +63,11 @@ impl<'input> Parser<'input> {
|
||||
pub fn offset(&self) -> usize {
|
||||
self.scanner.offset()
|
||||
}
|
||||
|
||||
/// Public API for sqlite3ParserFinalize()
|
||||
pub fn finalize(&mut self) {
|
||||
self.parser.sqlite3ParserFinalize();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user