Skip to content

Show current SQL recursion limit in RecursionLimitExceeded error message #15644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kumarlokesh
Copy link
Contributor

@kumarlokesh kumarlokesh commented Apr 8, 2025

Which issue does this PR close?

Rationale for this change

What changes are included in this PR?

  • Added recursion_limit field to DFParser struct to track the current recursion limit
  • Updated error handling to include the current recursion limit value in error messages
  • Ensured consistent error handling for recursion limit across different parsing scenarios:
    • COPY INTO statements
    • General statement parsing
    • Native and sqlparser-rs parser paths
  • Updated error message format would be:
    sql parser error: recursion limit exceeded (current limit: {recursion_limit})

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added the sql SQL Planner label Apr 8, 2025
@kumarlokesh kumarlokesh force-pushed the improve-error-message-for-sql-parser-recursion-limit branch from 4ed10ff to 93f771e Compare April 8, 2025 20:48
Err(ParserError::RecursionLimitExceeded) => {
Err(ParserError::ParserError(format!(
"recursion limit exceeded (current limit: {})",
self.recursion_limit
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering, can we take it from config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 91da480

I tried to associate SQLParser options with DFParser struct, instead of only keeping a direct mapping between recursion_limit and DFParser. This way DFParser would've access to same recursion_limit setting that was used while building the DFParser.

Thoughts?

self.parser.parse_statement()?,
)))
match self.parser.parse_statement() {
Ok(stmt) => Ok(Statement::Statement(Box::from(stmt))),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably can do this more concise
sort of

self.parser.parse_statement().map(
    |stmt| Statement::Statement(Box::new(stmt))
).map_err(|e| match e {
    ParserError::RecursionLimitExceeded => ParserError::ParserError(format!(
        "recursion limit exceeded (current limit: {})",
        self.recursion_limit
    )),
    other => other,
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 91da480

@kumarlokesh kumarlokesh requested a review from comphead April 9, 2025 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve SQL parser recursion limit error message
2 participants