Skip to content

[Compatibility]: prepared RANGE window-frame bounds reject parameter markers #28022

Closed

Description

@Ariznawlll

Actual behavior

On current main (3ec2c2524f88cb3365b9bc464d02458c9a77798a), a prepared marker in a RANGE window frame is rejected at prepare time:

PREPARE range_stmt FROM
  'SELECT id, SUM(v) OVER (ORDER BY id RANGE ? PRECEDING) FROM t';

MatrixOne returns:

not supported: prepared parameter markers in RANGE window frames

The behavior was repeated independently three times.

Controls

  • Numeric RANGE 1 PRECEDING executes correctly.
  • Prepared ROWS ? PRECEDING executes correctly and returns the expected rolling sums.

This isolates the gap to prepared markers in the RANGE frame path.

Expected behavior

Accept a positional parameter marker for a RANGE frame bound and validate its value at execute time. MySQL documents ? parameter markers as permitted for expr PRECEDING and expr FOLLOWING in both ROWS and RANGE frames: https://dev.mysql.com/doc/refman/8.4/en/window-functions-frames.html

Scope

This is distinct from #27341, which concerns the omitted-frame default of frame-sensitive value functions.

Activity

  1. Ariznawlll commented on Sep 2, 2026

    @Ariznawlll
    CollaboratorAuthor

    补充 latest main 验证(3ec2c2524f88cb3365b9bc464d02458c9a77798a):

    • RANGE ? PRECEDING 在 PREPARE 阶段连续 3 次返回同一“不支持 prepared parameter markers”错误。
    • 对照的 ROWS ? PRECEDING 三次均可执行;字面量 RANGE 1 PRECEDING 也返回正确滚动结果。
    • 每次拒绝后立即读取源表,均为 3 行、SUM(v)=60,随后字面量 RANGE 查询仍可正常执行;拒绝未改变数据或损坏会话。
  2. added
    kind/bug
    on Sep 2, 2026
  3. added theissue type on Sep 2, 2026
  4. modified the milestones: MO-202608, MO-202609 on Sep 2, 2026
  5. added
    ai-light
    on Sep 3, 2026
  6. slyunnn commented on Sep 4, 2026

    @slyunnn

    Regression and extended verification for #28022 (2026-09-04)

    Verification Environment

    • Latest refreshed origin/main: 99ed717b769e261b842c2f17345bd65865fc1470 — test(frontend): make reset cancellation deterministic (#28105).
    • Related fix: PR #28065, fix(window): support prepared RANGE frame parameters, merge commit d0ad7968561f205bc2f4020ba0c37aca886d621e; it is reachable from the validated main baseline.
    • Topology: test-owned local LOG + TN + CN; MOTR used MySQL/TCP at 127.0.0.1:26001.
    • Endpoint coverage: the local CN endpoint 127.0.0.1:26001 was covered through MySQL/TCP. Standard multi-CN endpoints 127.0.0.1:16001, 127.0.0.1:16002, and Proxy 127.0.0.1:6001 were not covered; the existing :6001 listener was a non-baseline Docker container and was deliberately not used.
    • Client protocol: MySQL/TCP through MOTR. Focused binder/window unit tests were reused from built main commit bf63172c0691e917ed2613c2d3a2d3d76a7f682e: the range to refreshed main changes only docs/rfcs/, pkg/frontend/routine_test.go, and pkg/sql/plan/shuffle*, leaving the PR fix(window): support prepared RANGE frame parameters #28065 binder/window/distributed-prepare surface unchanged.

    What Was Covered

    • OK — focused planner binder tests passed for parameterized RANGE single bounds, both bounds, numeric ORDER BY validation, and unsupported interval markers.
    • OK — focused window execution tests passed for RANGE parameter materialization, valid and invalid execute-time bounds, and aggregate consumption.
    • OK — original PREPARE ... RANGE ? PRECEDING succeeded; EXECUTE with bound 2 returned the expected value-based rolling sums.
    • OK — reusing the same prepared statement with bound 3 changed the value range at execute time, proving it did not retain the previous bound.
    • OK — literal RANGE 2 PRECEDING produced the same result as the prepared bound 2 control.
    • OK — prepared ROWS ? PRECEDING remained supported as a non-equivalent compatibility control.
    • OK — RANGE BETWEEN ? PRECEDING AND ? FOLLOWING accepted and applied both markers.
    • OK — negative prepared bound was rejected at EXECUTE with 20301, window RANGE frame bound must be a finite non-negative numeric value.
    • OK — MOTR record and replay both passed through MySQL/TCP: 25 statements, 25 successful, 0 failed.
    • Not covered — multi-CN/Proxy routing through CN1:16001, CN2:16002, and Proxy :6001; this parser/binder/execution contract has no topology-dependent branch.

    Findings

    PR #28065 restores the public contract: numeric parameter markers in RANGE frame bounds are accepted during PREPARE, materialized per EXECUTE, and validated at execution time. The negative-bound result confirms validation moved to the correct phase rather than being deferred into execution without validation.

    Large-data regression is not needed. The affected contract is bound parsing, binding, and per-execution materialization; it is independent of row count, block/batch boundaries, memory/spill, concurrency, skew, network transfer, and resource scale.

    MOTR / BVT Coverage

    • Branch: test/issue-28022-prepared-range-frame.
    • Commit: d59d5b1 — test: add MOTR regression for #28022.
    • Files: suites/14_issue_regression/t/issue_28022_prepared_range_frame.test and suites/14_issue_regression/r/issue_28022_prepared_range_frame.result.
    • Record and replay completed successfully against the test-owned latest-main-equivalent CN endpoint.
    • The branch push is pending because the Git transport did not complete during this run; no issue-specific PR was created.

    Final Conclusion

    Fixed on refreshed origin/main 99ed717b769e261b842c2f17345bd65865fc1470. No large-data regression is required because the defect is data-size independent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-lightkind/bugphase/testing

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions