This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion-sqlparser-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 33521a53 Add recursion checks for parse_interval (#2422)
33521a53 is described below
commit 33521a534eae72188e06ce0ce4836d19c7f3458a
Author: Shuvam Kumar <[email protected]>
AuthorDate: Tue Aug 4 14:55:27 2026 +0530
Add recursion checks for parse_interval (#2422)
Co-authored-by: Claude Opus 5 <[email protected]>
---
src/parser/mod.rs | 3 +++
tests/sqlparser_common.rs | 14 ++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index 2d51d471..d2668d3b 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -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
diff --git a/tests/sqlparser_common.rs b/tests/sqlparser_common.rs
index bad08360..0800bc41 100644
--- a/tests/sqlparser_common.rs
+++ b/tests/sqlparser_common.rs
@@ -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 {};
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]