Skip to content

fix(plan): prevent panic in resetDateFunctionArgs with invalid interval expression#24283

Open
jiangxinmeng1 wants to merge 2 commits intomatrixorigin:3.0-devfrom
jiangxinmeng1:fix-interval-panic-24281
Open

fix(plan): prevent panic in resetDateFunctionArgs with invalid interval expression#24283
jiangxinmeng1 wants to merge 2 commits intomatrixorigin:3.0-devfrom
jiangxinmeng1:fix-interval-panic-24281

Conversation

@jiangxinmeng1
Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

fixes #24281

What this PR does / why we need it:

  • Add bounds checking in resetDateFunctionArgs and resetIntervalFunctionArgs to prevent index-out-of-range panic when the interval expression list has fewer than 2 elements
  • This fixes a crash when using INTERVAL with non-constant expressions like column references (e.g., '2024-01-01' + INTERVAL (result % 365) DAY FROM generate_series(1, 10) g)
  • Add unit test cases for interval expressions with column references

🤖 Generated with Claude Code

…al expression (matrixorigin#24281)

Add bounds checking in resetDateFunctionArgs and resetIntervalFunctionArgs
to prevent index-out-of-range panic when the interval expression list has
fewer than 2 elements. This fixes a crash when using INTERVAL with
non-constant expressions like column references (e.g.,
`'2024-01-01' + INTERVAL (result % 365) DAY`).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@qodo-code-review
Copy link
Copy Markdown

ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

@mergify mergify Bot requested a review from XuPeng-SH May 6, 2026 08:15
@mergify mergify Bot added the kind/bug Something isn't working label May 6, 2026
@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label May 6, 2026
Two changes to fix INTERVAL with parenthesized expressions:
1. Remove INTERVAL from name_confict in the grammar so that
   `INTERVAL (expr) unit` is no longer parsed as function call
   `INTERVAL(expr)` with `unit` becoming a column alias.
2. Change FuncExpr.Format() to output `INTERVAL expr unit` instead of
   `INTERVAL(expr, unit)` so that internally generated SQL (e.g. CTAS
   column names) uses the standard interval syntax.

Fixes matrixorigin#24281

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/XXL Denotes a PR that changes 2000+ lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants