Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3368,7 +3368,10 @@ impl<'a> Parser<'a> {
/// ```
///
/// Note that we do not currently attempt to parse the quoted value.
#[cfg_attr(feature = "recursive-protection", recursive::recursive)]
pub fn parse_interval(&mut self) -> Result<Expr, ParserError> {
let _guard = self.recursion_counter.try_decrease()?;

// The SQL standard allows an optional sign before the value string, but
// it is not clear if any implementations support that syntax, so we
// don't currently try to parse it. (The sign can instead be included
Expand Down
14 changes: 14 additions & 0 deletions tests/sqlparser_common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11419,6 +11419,20 @@ fn parse_deeply_nested_subquery_expr_hits_recursion_limits() {
assert_eq!(res, Err(ParserError::RecursionLimitExceeded));
}

#[test]
fn parse_deeply_nested_interval_hits_recursion_limits() {
let dialect = GenericDialect {};

let sql = format!("SELECT {}1", "INTERVAL ".repeat(1000));

let res = Parser::new(&dialect)
.try_with_sql(&sql)
.expect("tokenize to work")
.parse_statements();

assert_eq!(res, Err(ParserError::RecursionLimitExceeded));
}

#[test]
fn parse_with_recursion_limit() {
let dialect = GenericDialect {};
Expand Down
Loading