Skip to content

fix: validate prepared LIMIT and OFFSET parameters - #27329

Merged
XuPeng-SH merged 8 commits into
matrixorigin:mainfrom
ck89119:issue-25408-pagination-main
Aug 21, 2026
Merged

XuPeng-SH merged 8 commits into
matrixorigin:mainfrom
ck89119:issue-25408-pagination-main

Conversation

@ck89119

@ck89119 ck89119 commented Aug 19, 2026

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:

issue #25408

What this PR does / why we need it:

This is the first of three scoped changes for prepared runtime parameter handling. It fixes only LIMIT/OFFSET validation and execution reuse.

Previously, cached prepared compiles could retain pagination values from an earlier execution. NULL therefore produced history-dependent results, string parameters could bypass the MySQL EXECUTE contract, and negative signed values surfaced an internal cast error instead of MySQL error 1690.

This change:

  • validates pagination parameter source types on every execution for query and CTAS plans;
  • accepts integer, boolean, and NULL sources while rejecting string, floating-point, and decimal sources with error 1210;
  • reports negative signed values as MySQL 1690 / SQLSTATE 22003;
  • normalizes boolean transport payloads only at pagination positions;
  • avoids reusing a compile whose LIMIT/OFFSET values were materialized by an earlier execution.

Validation:

  • mo-cgo-test ./pkg/common/moerr ./pkg/sql/plan ./pkg/frontend -count=1
  • mo-cgo-test ./pkg/tests/issues -run '^TestIssue25408PreparedPaginationParameters$' -count=1 -timeout 5m
  • golangci-lint run -c .golangci.yml ./pkg/common/moerr ./pkg/sql/plan ./pkg/frontend ./pkg/tests/issues (0 issues)

The runtime numeric full-rebind correctness change and its type-signature compile-cache optimization will be submitted as two follow-up PRs after this PR is merged.

@aptend aptend 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.

Deep-reviewed the complete diff and all available review/comment history at exact head 846fcc908f920a5e74583b9ea3fb314f43a1e130 against merge-base b8e8a0936825c50b213dfa1222ed756e3de100af. No inline review threads or author replies exist on this PR.

The validation is scoped to parameter markers actually reachable from query and CTAS LIMIT/OFFSET expressions and runs on every SQL PREPARE and COM_STMT execution before generic casts. It preserves integer, boolean, and NULL behavior, rejects string/float/decimal provenance with MySQL 1210, reports negative signed values as 1690 / SQLSTATE 22003, and preserves parameter-order error priority. Boolean normalization changes only pagination slots, while bypassing the materialized prepared compile prevents a prior execution's pagination value from surviving into the next generation. I found no new ownership, cleanup, wait, or unbounded-growth edge in these paths.

Exact-head validation: repository thirdparties and CGo artifacts built successfully; full tests passed for pkg/common/moerr, pkg/sql/plan, and pkg/frontend; the real TestIssue25408PreparedPaginationParameters SQL PREPARE/COM_STMT/CTAS lifecycle passed; an independent temporary counterexample confirmed boolean pagination also survives the plan-substitution path; focused go vet passed; and git diff --check is clean. The temporary test was removed and the worktree is clean.

No blocking correctness or lifecycle finding remains, so I approve this exact head. GitHub currently reports a conflict with the latest main; any conflict-resolution head needs review as a new exact SHA.

# Conflicts:
#	pkg/frontend/computation_wrapper.go

@XuPeng-SH XuPeng-SH 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.

Deep-reviewed exact head 535d0681386b5a9b6b389c494d6c491f042af3c7 against base ae01f96c4d5c02c973f5bac9e8c4ab82b5dac3a7, including the interaction with the newly merged prepared-parameter runtime-specialization path.

The four functional commits are unchanged by range-diff. Pagination validation still runs before generic casts and covers parameter markers reachable from query and CTAS LIMIT/OFFSET; integer/boolean/NULL inputs remain accepted, string/float/decimal provenance is rejected with MySQL 1210, and negative signed inputs report 1690 / SQLSTATE 22003 in deterministic parameter order. Binary-protocol BIT/integer values retain numeric provenance, boolean normalization is limited to pagination positions, and pagination executions bypass the materialized cached compile so each execution consumes its current generation of parameters. Runtime specialization either materializes the current typed literal or leaves the fresh compile on the current process parameter vector; I found no stale-value split between validation and execution.

Fresh exact-head validation passed for the full pkg/common/moerr, pkg/sql/plan, and pkg/frontend test suites; the real TestIssue25408PreparedPaginationParameters SQL PREPARE/COM_STMT/CTAS lifecycle; focused build and go vet; and git diff --check. I found no additional correctness, Q1 cleanup/ownership, Q2 wait, Q3 growth, or restart/reuse-generation blocker.

@mergify mergify Bot added the queued label Aug 21, 2026
@mergify

mergify Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-08-21 08:53 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-08-21 12:08 UTC · at fddc28c43973b93db751e176055cd26c347171c8

This pull request spent 3 hours 15 minutes 6 seconds in the queue, with no time running CI.

Waiting for
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of: [🛡 GitHub branch protection]
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
All conditions
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / UT Test on Ubuntu/x86
    • check-skipped = Matrixone CI / UT Test on Ubuntu/x86
    • check-success = Matrixone CI / UT Test on Ubuntu/x86
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone CI / SCA Test on Linux/arm64
    • check-skipped = Matrixone CI / SCA Test on Linux/arm64
    • check-success = Matrixone CI / SCA Test on Linux/arm64
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-skipped = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
    • check-success = Matrixone Compose CI / multi cn e2e bvt test docker compose(PROXY)
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Utils CI / Coverage
    • check-skipped = Matrixone Utils CI / Coverage
    • check-success = Matrixone Utils CI / Coverage
  • any of [🛡 GitHub branch protection]:
    • check-neutral = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-skipped = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
    • check-success = Matrixone Standlone CI / multi CN e2e BVT Test on Linux/x64(COMPOSE, PESSIMISTIC)
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-neutral = Matrixone UT Coverage / UT Coverage on Ubuntu/x86
    • check-skipped = Matrixone UT Coverage / UT Coverage on Ubuntu/x86

Reason

Pull request #27329 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Failing checks:

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

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 kind/test-ci size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants