Skip to content

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

Merged
mergify[bot] merged 5 commits into
matrixorigin:3.0-devfrom
jiangxinmeng1:fix-interval-panic-24281
May 7, 2026
Merged

mergify[bot] merged 5 commits into
matrixorigin: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 <[email protected]>
@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
@matrix-meow matrix-meow added size/S Denotes a PR that changes [10,99] lines and removed size/XXL Denotes a PR that changes 2000+ lines labels 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 <[email protected]>
Update expected outputs from `interval(expr, unit)` to `INTERVAL expr unit`
to match the new FuncExpr.Format() output for 2-arg interval expressions.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Update expected outputs from `interval(expr, unit)` / `INTERVAL(expr, unit)`
to `interval expr unit` / `INTERVAL expr unit` format to match the new
FuncExpr.Format() output for 2-arg interval expressions.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

@aunjgr aunjgr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Bounds checking fix is correct. Grammar change removing INTERVAL from name_conflict is the right approach — it prevents the parser from treating INTERVAL (expr) unit as a function call. FuncExpr.Format change to emit INTERVAL expr unit is consistent with SQL standard. BVT changes are cosmetic.

@mergify

mergify Bot commented May 7, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-05-07 07:08 UTC · Rule: release-3.0
  • ✅ Checks passed · in-place
  • ✅ Merged — 2026-05-07 08:03 UTC · at 13eec83d8f849912cede7baece53763699ed9127 · squash

This pull request spent 54 minutes 41 seconds in the queue, including 54 minutes 22 seconds running CI.

Required conditions to merge
  • #approved-reviews-by >= 1 [🛡 GitHub branch protection]
  • #changes-requested-reviews-by = 0 [🛡 GitHub branch protection]
  • branch-protection-review-decision = APPROVED [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Utils CI (3.0) / Coverage
    • check-neutral = Matrixone Utils CI (3.0) / Coverage
    • check-skipped = Matrixone Utils CI (3.0) / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI (3.0) / SCA Test on Ubuntu/x86
    • check-neutral = Matrixone CI (3.0) / SCA Test on Ubuntu/x86
    • check-skipped = Matrixone CI (3.0) / SCA Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone CI (3.0) / UT Test on Ubuntu/x86
    • check-neutral = Matrixone CI (3.0) / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI (3.0) / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI (3.0) / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-neutral = Matrixone Compose CI (3.0) / multi cn e2e bvt test docker compose(Optimistic/PUSH)
    • check-skipped = Matrixone Compose CI (3.0) / multi cn e2e bvt test docker compose(Optimistic/PUSH)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Compose CI (3.0) / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-neutral = Matrixone Compose CI (3.0) / multi cn e2e bvt test docker compose(PESSIMISTIC)
    • check-skipped = Matrixone Compose CI (3.0) / multi cn e2e bvt test docker compose(PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI (3.0) / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-neutral = Matrixone Standlone CI (3.0) / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
    • check-skipped = Matrixone Standlone CI (3.0) / Multi-CN e2e BVT Test on Linux/x64(LAUNCH, PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI (3.0) / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-neutral = Matrixone Standlone CI (3.0) / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI (3.0) / e2e BVT Test on Linux/x64(LAUNCH, PESSIMISTIC)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Standlone CI (3.0) / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-neutral = Matrixone Standlone CI (3.0) / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
    • check-skipped = Matrixone Standlone CI (3.0) / e2e BVT Test on Linux/x64(LAUNCH,Optimistic)
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone Upgrade CI (3.0) / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-neutral = Matrixone Upgrade CI (3.0) / Compatibility Test With Target on Linux/x64(LAUNCH)
    • check-skipped = Matrixone Upgrade CI (3.0) / Compatibility Test With Target on Linux/x64(LAUNCH)

This branch was previously deployed

1 inactive deployment
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.

6 participants