Repository navigation
fix: validate prepared LIMIT and OFFSET parameters - #27329
Conversation
aptend
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
Merge Queue Status
This pull request spent 3 hours 15 minutes 6 seconds in the queue, with no time running CI. Waiting for
All conditions
ReasonPull 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.
Failing checks:
HintYou 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. Tick the box to put this pull request back in the merge queue (same as
|
What type of PR is this?
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/OFFSETvalidation and execution reuse.Previously, cached prepared compiles could retain pagination values from an earlier execution.
NULLtherefore produced history-dependent results, string parameters could bypass the MySQLEXECUTEcontract, and negative signed values surfaced an internal cast error instead of MySQL error 1690.This change:
NULLsources while rejecting string, floating-point, and decimal sources with error 1210;LIMIT/OFFSETvalues were materialized by an earlier execution.Validation:
mo-cgo-test ./pkg/common/moerr ./pkg/sql/plan ./pkg/frontend -count=1mo-cgo-test ./pkg/tests/issues -run '^TestIssue25408PreparedPaginationParameters$' -count=1 -timeout 5mgolangci-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.