Skip to content

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

Merged
mergify[bot] merged 4 commits intomatrixorigin:mainfrom
jiangxinmeng1:fix-interval-panic-24281-main
May 7, 2026
Merged

fix(plan): prevent panic in resetDateFunctionArgs with invalid interval expression#24284
mergify[bot] merged 4 commits intomatrixorigin:mainfrom
jiangxinmeng1:fix-interval-panic-24281-main

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.

@matrix-meow matrix-meow added the size/S Denotes a PR that changes [10,99] lines label May 6, 2026
@mergify mergify Bot added the kind/bug Something isn't working 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
@jiangxinmeng1 jiangxinmeng1 force-pushed the fix-interval-panic-24281-main branch from 62b0330 to 6adbd85 Compare May 6, 2026 09:41
@matrix-meow matrix-meow added size/XXL Denotes a PR that changes 2000+ lines and removed size/S Denotes a PR that changes [10,99] lines labels May 6, 2026
@jiangxinmeng1 jiangxinmeng1 force-pushed the fix-interval-panic-24281-main branch from 6adbd85 to 37557ab Compare May 6, 2026 09:52
jiangxinmeng1 and others added 2 commits May 7, 2026 09:35
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>
Update expected outputs from interval(expr, unit) to interval expr unit
format to match the new FuncExpr.Format() output for 2-arg interval.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 7, 2026

Merge Queue Status

  • Entered queue2026-05-07 03:30 UTC · Rule: main
  • Checks passed · in-place
  • Merged2026-05-07 04:29 UTC · at 0d7eb224138a5922fae427fd984455abec5edf69 · squash

This pull request spent 59 minutes 16 seconds in the queue, including 58 minutes 58 seconds running CI.

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

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.

[Bug]: insert panic runtime error: index out of range [1] with length 1

5 participants