Skip to content

fix: harden regular prefix index correctness - #26829

Merged
XuPeng-SH merged 11 commits into
matrixorigin:mainfrom
LeftHandCold:fix/prefix-index-correctness
Aug 9, 2026
Merged

XuPeng-SH merged 11 commits into
matrixorigin:mainfrom
LeftHandCold:fix/prefix-index-correctness

Conversation

@LeftHandCold

@LeftHandCold LeftHandCold commented Aug 9, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

Fixes #26813
Fixes #26818
Fixes #26822
Fixes #26823
Fixes #26824

What this PR does / why we need it:

Regular prefix indexes had correctness gaps across planning, metadata maintenance, DDL validation, and rolling upgrades:

  • Use the stored prefix only for equality candidate lookup, retain the full base-table residual, and reject lossy index-only reconstruction.
  • Disable prefix indexes for IN, BETWEEN, scalar/paired ranges, ORDER/GROUP reconstruction, and relational index joins until those paths have prefix-aware candidate semantics.
  • Fail closed when prefix metadata is malformed or no longer matches the logical index parts. Optional reads skip the index; INSERT, UPDATE, DELETE, and REPLACE reject the stale index with a rebuild instruction.
  • Preserve prefix lengths through RENAME COLUMN and CHANGE COLUMN, including an all-index preflight so protocol or metadata failures occur before the first TableDef mutation.
  • Keep ordinary identifiers on the legacy metadata representation, and gate lossless prefix_lengths_v2 emission for delimiter-bearing identifiers on deployment protocol version 13.
  • Reserve the internal __mo_alias_ namespace across explicit CREATE TABLE, CTAS, ADD COLUMN, CHANGE COLUMN, and RENAME COLUMN paths.

Review follow-up: actual versus theoretical

The P1 findings are real:

  • On the pre-fix PR binary after flushing hidden-index blocks, FORCE INDEX prefix IN returned no rows while IGNORE INDEX returned ids 3 and 6. Prefix BETWEEN and range also disagreed with the base-table oracle.
  • FORCE INDEX FOR ORDER BY returned truncated values (abcd) and chose the wrong LIMIT 2 rows; IGNORE INDEX returned the full values in the correct order.
  • A table created and renamed by the base binary persisted column_name=b with {"prefix_lengths":"a:4"}. The pre-fix PR still selected the index and missed the row. The updated binary returns the row through a base-table scan.
  • The base-version metadata reader was run against an actual v2 payload and returned no prefix lengths, confirming the rolling-upgrade incompatibility rather than assuming it.
  • On that same stale catalog, the updated binary rejects INSERT, UPDATE, DELETE, and REPLACE before execution and leaves the rows unchanged. Before the fix, non-unique DELETE returned success without deleting the row, while REPLACE admitted two unique-index values with the same stored prefix.

A forced relational equality JOIN did select the prefix index on the pre-fix binary, but the tested result remained correct. This PR still disables that unproven path as requested; it is not presented as a reproduced wrong-result case.

Validation

  • Rebased cleanly onto current main at 415724ff30cfb1dd96fa2eb75110402fbc4e7239.
  • Protocol boundary regressions prove v12 rejects and v13 accepts lossless prefix metadata on both CREATE and RENAME.\n- make build.
  • Controlled CGo tests: full ./pkg/sql/plan; ./pkg/catalog, ./pkg/common/runtime, ./pkg/sql/plan/function/ctl.
  • Protocol-adjacent tests: ./pkg/frontend, ./pkg/sql/compile, ./pkg/txn/rpc, and ./pkg/vm/engine/tae/db/dbutils.
  • go vet: ./pkg/catalog, ./pkg/common/runtime, ./pkg/sql/plan, and ./pkg/sql/plan/function/ctl.
  • Focused BVT on the final binary: 200/200 statements across six scripts.
  • The new 52-statement matrix covers default/FORCE/IGNORE, unique and non-unique prefixes, IN/BETWEEN/paired ranges, same-prefix neighbors, prepared values, Unicode, JOIN/ORDER hints, and reads before and after flush.
  • git diff --check.

@LeftHandCold
LeftHandCold requested a review from a user August 9, 2026 05:07
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@matrix-meow matrix-meow added the size/XL Denotes a PR that changes [1000, 1999] lines label Aug 9, 2026
@mergify mergify Bot added the kind/bug Something isn't working label Aug 9, 2026

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

Requesting changes for two P1 prefix-index correctness blockers.

  1. [P1] Gate prefix_lengths_v2 on the cluster protocol version.

    For delimiter-bearing names, SetIndexPrefixLengthsInParamMap deletes prefix_lengths and emits only prefix_lengths_v2 (code). A base-version CN reads only prefix_lengths (base reader), so during a rolling upgrade old and new CNs interpret the same index differently. They can write full and truncated keys into the same hidden table, violating unique-prefix semantics and making lookups miss rows. Since the legacy format cannot encode these names losslessly, please reject the affected CREATE/ALTER operations until all CNs advertise v2 support, and add a mixed-version test.

  2. [P1] Apply prefix-index safety to non-equality predicates.

    Prefix transformation is applied only by replaceEqualCondition (code). getIndexForNonEquiCond can still select the prefix index for IN, BETWEEN, and range predicates, while replaceNonEqualCondition compares full constants against truncated stored keys (code). For index i(a(4)), a stored value abcdx has key abcd, so WHERE a IN ('abcdx') can discard the row before residual evaluation. Please conservatively disable these index joins for prefix indexes until each predicate is safely widened, and add forced-index versus ignore-index coverage.

Independent verification passed: focused regression tests, go test ./pkg/catalog ./pkg/sql/plan, go vet ./pkg/catalog ./pkg/sql/plan, and git diff --check.

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

I found two correctness gaps that still allow silent false negatives in the prefix-index access path.

  1. [P1] Apply prefix-key candidate semantics to non-equality lookups as well (pkg/sql/plan/apply_indices.go:1854-1904)

    This PR truncates equality RHS values through makeIndexLookupPartExpr, but getIndexForNonEquiCond can still select the same prefix index for IN, BETWEEN, in_range, and scalar ranges, while replaceNonEqualCondition and replaceRangePairCondition compare the truncated hidden key with the original full value. A concrete witness is UNIQUE INDEX uq_a(a(4)) with row a='abcdx': ... FORCE INDEX(uq_a) WHERE a IN ('abcdx') probes stored abcd with full abcdx and can return no row. Range boundaries have the same problem; e.g. values sharing abcd can be dropped around a strict bound.

    Please either disable prefix indexes for these predicate classes, or transform every lookup value to its persisted prefix and conservatively widen strict hidden-key bounds (> -> >=, < -> <=) while retaining the original base-table residual. Add default/FORCE/IGNORE coverage for IN and range boundaries, same-prefix neighbors, prepared values, Unicode, and post-flush reads.

  2. [P1] Do not fail open to a full-value probe when prefix metadata is invalid or stale (pkg/sql/plan/apply_indices.go:1809-1819)

    On metadata parse or expression-binding failure, makeIndexLookupPartExpr returns the unmodified full input and the caller still builds the index scan. If the hidden table physically contains a prefix, probing abcd with abcdx loses the candidate before the correct base residual can run. This is particularly relevant to persisted stale metadata from the pre-fix RENAME bug: a valid prefix entry whose key no longer appears in IndexDef.Parts also silently takes this path. tryIndexOnlyScan already fails closed on parse errors; the index-join path needs the same invariant. Please propagate eligibility/error and skip or reject the index, and validate metadata keys against the logical parts.

The focused new tests, full pkg/catalog and pkg/sql/plan suites, and go vet for both owning packages passed locally.

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

Reviewed current head 76a524e against the latest main merge state. No correctness, performance, or unhappy-path blockers found. The prior P1 findings are resolved and owning-package tests, vet, and CI checks pass.

@XuPeng-SH
XuPeng-SH merged commit ac33944 into matrixorigin:main Aug 9, 2026
25 checks passed
XuPeng-SH added a commit that referenced this pull request Aug 10, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR covers:

Regression coverage for #26841. The production correction merged
independently in #26829 while this PR was under review.

## What this PR does / why we need it:

This branch is rebased on current `main` and intentionally retains only
coverage not already present upstream:

- white-box planner cases for declared prefix metadata across BETWEEN,
scalar and paired ranges, IN, in_range, OR, unique/non-unique, malformed
metadata, and a complete-index control;
- FORCE INDEX FOR ORDER BY and FORCE INDEX FOR GROUP BY planning checks;
- an end-to-end BVT covering same-prefix neighbors, forced versus
ignored access, runtime bounds, flush, a complete-index control, RENAME
COLUMN, and INSERT/UPDATE/DELETE after rename.

During conflict resolution, the old production implementation was
deliberately not replayed: current main contains the stronger #26829
implementation, including V2 prefix-metadata support. Reintroducing the
old code would duplicate validation and reject valid delimiter-bearing
column names.

## Validation

- focused and complete controlled-CGo `./pkg/sql/plan` tests;
- `go vet ./pkg/sql/plan` with the project CGo include paths;
- fresh `make build`;
- `prefix_index_range` BVT: 51/51;
- existing `prefix_index_non_equality` BVT: 52/52;
- `git diff --check`.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26813
Fixes matrixorigin#26818
Fixes matrixorigin#26822
Fixes matrixorigin#26823
Fixes matrixorigin#26824

## What this PR does / why we need it:

Regular prefix indexes had correctness gaps across planning, metadata
maintenance, DDL validation, and rolling upgrades:

- Use the stored prefix only for equality candidate lookup, retain the
full base-table residual, and reject lossy index-only reconstruction.
- Disable prefix indexes for IN, BETWEEN, scalar/paired ranges,
ORDER/GROUP reconstruction, and relational index joins until those paths
have prefix-aware candidate semantics.
- Fail closed when prefix metadata is malformed or no longer matches the
logical index parts. Optional reads skip the index; INSERT, UPDATE,
DELETE, and REPLACE reject the stale index with a rebuild instruction.
- Preserve prefix lengths through RENAME COLUMN and CHANGE COLUMN,
including an all-index preflight so protocol or metadata failures occur
before the first TableDef mutation.
- Keep ordinary identifiers on the legacy metadata representation, and
gate lossless `prefix_lengths_v2` emission for delimiter-bearing
identifiers on deployment protocol version 13.
- Reserve the internal `__mo_alias_` namespace across explicit CREATE
TABLE, CTAS, ADD COLUMN, CHANGE COLUMN, and RENAME COLUMN paths.

## Review follow-up: actual versus theoretical

The P1 findings are real:

- On the pre-fix PR binary after flushing hidden-index blocks, `FORCE
INDEX` prefix IN returned no rows while `IGNORE INDEX` returned ids 3
and 6. Prefix BETWEEN and range also disagreed with the base-table
oracle.
- `FORCE INDEX FOR ORDER BY` returned truncated values (`abcd`) and
chose the wrong LIMIT 2 rows; `IGNORE INDEX` returned the full values in
the correct order.
- A table created and renamed by the base binary persisted
`column_name=b` with `{"prefix_lengths":"a:4"}`. The pre-fix PR still
selected the index and missed the row. The updated binary returns the
row through a base-table scan.
- The base-version metadata reader was run against an actual v2 payload
and returned no prefix lengths, confirming the rolling-upgrade
incompatibility rather than assuming it.
- On that same stale catalog, the updated binary rejects INSERT, UPDATE,
DELETE, and REPLACE before execution and leaves the rows unchanged.
Before the fix, non-unique DELETE returned success without deleting the
row, while REPLACE admitted two unique-index values with the same stored
prefix.

A forced relational equality JOIN did select the prefix index on the
pre-fix binary, but the tested result remained correct. This PR still
disables that unproven path as requested; it is not presented as a
reproduced wrong-result case.

## Validation

- Rebased cleanly onto current `main` at
`415724ff30cfb1dd96fa2eb75110402fbc4e7239`.
- Protocol boundary regressions prove v12 rejects and v13 accepts
lossless prefix metadata on both CREATE and RENAME.\n- `make build`.
- Controlled CGo tests: full `./pkg/sql/plan`; `./pkg/catalog`,
`./pkg/common/runtime`, `./pkg/sql/plan/function/ctl`.
- Protocol-adjacent tests: `./pkg/frontend`, `./pkg/sql/compile`,
`./pkg/txn/rpc`, and `./pkg/vm/engine/tae/db/dbutils`.
- `go vet`: `./pkg/catalog`, `./pkg/common/runtime`, `./pkg/sql/plan`,
and `./pkg/sql/plan/function/ctl`.
- Focused BVT on the final binary: 200/200 statements across six
scripts.
- The new 52-statement matrix covers default/FORCE/IGNORE, unique and
non-unique prefixes, IN/BETWEEN/paired ranges, same-prefix neighbors,
prepared values, Unicode, JOIN/ORDER hints, and reads before and after
flush.
- `git diff --check`.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR covers:

Regression coverage for matrixorigin#26841. The production correction merged
independently in matrixorigin#26829 while this PR was under review.

## What this PR does / why we need it:

This branch is rebased on current `main` and intentionally retains only
coverage not already present upstream:

- white-box planner cases for declared prefix metadata across BETWEEN,
scalar and paired ranges, IN, in_range, OR, unique/non-unique, malformed
metadata, and a complete-index control;
- FORCE INDEX FOR ORDER BY and FORCE INDEX FOR GROUP BY planning checks;
- an end-to-end BVT covering same-prefix neighbors, forced versus
ignored access, runtime bounds, flush, a complete-index control, RENAME
COLUMN, and INSERT/UPDATE/DELETE after rename.

During conflict resolution, the old production implementation was
deliberately not replayed: current main contains the stronger matrixorigin#26829
implementation, including V2 prefix-metadata support. Reintroducing the
old code would duplicate validation and reject valid delimiter-bearing
column names.

## Validation

- focused and complete controlled-CGo `./pkg/sql/plan` tests;
- `go vet ./pkg/sql/plan` with the project CGo include paths;
- fresh `make build`;
- `prefix_index_range` BVT: 51/51;
- existing `prefix_index_non_equality` BVT: 52/52;
- `git diff --check`.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26813
Fixes matrixorigin#26818
Fixes matrixorigin#26822
Fixes matrixorigin#26823
Fixes matrixorigin#26824

## What this PR does / why we need it:

Regular prefix indexes had correctness gaps across planning, metadata
maintenance, DDL validation, and rolling upgrades:

- Use the stored prefix only for equality candidate lookup, retain the
full base-table residual, and reject lossy index-only reconstruction.
- Disable prefix indexes for IN, BETWEEN, scalar/paired ranges,
ORDER/GROUP reconstruction, and relational index joins until those paths
have prefix-aware candidate semantics.
- Fail closed when prefix metadata is malformed or no longer matches the
logical index parts. Optional reads skip the index; INSERT, UPDATE,
DELETE, and REPLACE reject the stale index with a rebuild instruction.
- Preserve prefix lengths through RENAME COLUMN and CHANGE COLUMN,
including an all-index preflight so protocol or metadata failures occur
before the first TableDef mutation.
- Keep ordinary identifiers on the legacy metadata representation, and
gate lossless `prefix_lengths_v2` emission for delimiter-bearing
identifiers on deployment protocol version 13.
- Reserve the internal `__mo_alias_` namespace across explicit CREATE
TABLE, CTAS, ADD COLUMN, CHANGE COLUMN, and RENAME COLUMN paths.

## Review follow-up: actual versus theoretical

The P1 findings are real:

- On the pre-fix PR binary after flushing hidden-index blocks, `FORCE
INDEX` prefix IN returned no rows while `IGNORE INDEX` returned ids 3
and 6. Prefix BETWEEN and range also disagreed with the base-table
oracle.
- `FORCE INDEX FOR ORDER BY` returned truncated values (`abcd`) and
chose the wrong LIMIT 2 rows; `IGNORE INDEX` returned the full values in
the correct order.
- A table created and renamed by the base binary persisted
`column_name=b` with `{"prefix_lengths":"a:4"}`. The pre-fix PR still
selected the index and missed the row. The updated binary returns the
row through a base-table scan.
- The base-version metadata reader was run against an actual v2 payload
and returned no prefix lengths, confirming the rolling-upgrade
incompatibility rather than assuming it.
- On that same stale catalog, the updated binary rejects INSERT, UPDATE,
DELETE, and REPLACE before execution and leaves the rows unchanged.
Before the fix, non-unique DELETE returned success without deleting the
row, while REPLACE admitted two unique-index values with the same stored
prefix.

A forced relational equality JOIN did select the prefix index on the
pre-fix binary, but the tested result remained correct. This PR still
disables that unproven path as requested; it is not presented as a
reproduced wrong-result case.

## Validation

- Rebased cleanly onto current `main` at
`415724ff30cfb1dd96fa2eb75110402fbc4e7239`.
- Protocol boundary regressions prove v12 rejects and v13 accepts
lossless prefix metadata on both CREATE and RENAME.\n- `make build`.
- Controlled CGo tests: full `./pkg/sql/plan`; `./pkg/catalog`,
`./pkg/common/runtime`, `./pkg/sql/plan/function/ctl`.
- Protocol-adjacent tests: `./pkg/frontend`, `./pkg/sql/compile`,
`./pkg/txn/rpc`, and `./pkg/vm/engine/tae/db/dbutils`.
- `go vet`: `./pkg/catalog`, `./pkg/common/runtime`, `./pkg/sql/plan`,
and `./pkg/sql/plan/function/ctl`.
- Focused BVT on the final binary: 200/200 statements across six
scripts.
- The new 52-statement matrix covers default/FORCE/IGNORE, unique and
non-unique prefixes, IN/BETWEEN/paired ranges, same-prefix neighbors,
prepared values, Unicode, JOIN/ORDER hints, and reads before and after
flush.
- `git diff --check`.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR covers:

Regression coverage for matrixorigin#26841. The production correction merged
independently in matrixorigin#26829 while this PR was under review.

## What this PR does / why we need it:

This branch is rebased on current `main` and intentionally retains only
coverage not already present upstream:

- white-box planner cases for declared prefix metadata across BETWEEN,
scalar and paired ranges, IN, in_range, OR, unique/non-unique, malformed
metadata, and a complete-index control;
- FORCE INDEX FOR ORDER BY and FORCE INDEX FOR GROUP BY planning checks;
- an end-to-end BVT covering same-prefix neighbors, forced versus
ignored access, runtime bounds, flush, a complete-index control, RENAME
COLUMN, and INSERT/UPDATE/DELETE after rename.

During conflict resolution, the old production implementation was
deliberately not replayed: current main contains the stronger matrixorigin#26829
implementation, including V2 prefix-metadata support. Reintroducing the
old code would duplicate validation and reject valid delimiter-bearing
column names.

## Validation

- focused and complete controlled-CGo `./pkg/sql/plan` tests;
- `go vet ./pkg/sql/plan` with the project CGo include paths;
- fresh `make build`;
- `prefix_index_range` BVT: 51/51;
- existing `prefix_index_non_equality` BVT: 52/52;
- `git diff --check`.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes matrixorigin#26813
Fixes matrixorigin#26818
Fixes matrixorigin#26822
Fixes matrixorigin#26823
Fixes matrixorigin#26824

## What this PR does / why we need it:

Regular prefix indexes had correctness gaps across planning, metadata
maintenance, DDL validation, and rolling upgrades:

- Use the stored prefix only for equality candidate lookup, retain the
full base-table residual, and reject lossy index-only reconstruction.
- Disable prefix indexes for IN, BETWEEN, scalar/paired ranges,
ORDER/GROUP reconstruction, and relational index joins until those paths
have prefix-aware candidate semantics.
- Fail closed when prefix metadata is malformed or no longer matches the
logical index parts. Optional reads skip the index; INSERT, UPDATE,
DELETE, and REPLACE reject the stale index with a rebuild instruction.
- Preserve prefix lengths through RENAME COLUMN and CHANGE COLUMN,
including an all-index preflight so protocol or metadata failures occur
before the first TableDef mutation.
- Keep ordinary identifiers on the legacy metadata representation, and
gate lossless `prefix_lengths_v2` emission for delimiter-bearing
identifiers on deployment protocol version 13.
- Reserve the internal `__mo_alias_` namespace across explicit CREATE
TABLE, CTAS, ADD COLUMN, CHANGE COLUMN, and RENAME COLUMN paths.

## Review follow-up: actual versus theoretical

The P1 findings are real:

- On the pre-fix PR binary after flushing hidden-index blocks, `FORCE
INDEX` prefix IN returned no rows while `IGNORE INDEX` returned ids 3
and 6. Prefix BETWEEN and range also disagreed with the base-table
oracle.
- `FORCE INDEX FOR ORDER BY` returned truncated values (`abcd`) and
chose the wrong LIMIT 2 rows; `IGNORE INDEX` returned the full values in
the correct order.
- A table created and renamed by the base binary persisted
`column_name=b` with `{"prefix_lengths":"a:4"}`. The pre-fix PR still
selected the index and missed the row. The updated binary returns the
row through a base-table scan.
- The base-version metadata reader was run against an actual v2 payload
and returned no prefix lengths, confirming the rolling-upgrade
incompatibility rather than assuming it.
- On that same stale catalog, the updated binary rejects INSERT, UPDATE,
DELETE, and REPLACE before execution and leaves the rows unchanged.
Before the fix, non-unique DELETE returned success without deleting the
row, while REPLACE admitted two unique-index values with the same stored
prefix.

A forced relational equality JOIN did select the prefix index on the
pre-fix binary, but the tested result remained correct. This PR still
disables that unproven path as requested; it is not presented as a
reproduced wrong-result case.

## Validation

- Rebased cleanly onto current `main` at
`415724ff30cfb1dd96fa2eb75110402fbc4e7239`.
- Protocol boundary regressions prove v12 rejects and v13 accepts
lossless prefix metadata on both CREATE and RENAME.\n- `make build`.
- Controlled CGo tests: full `./pkg/sql/plan`; `./pkg/catalog`,
`./pkg/common/runtime`, `./pkg/sql/plan/function/ctl`.
- Protocol-adjacent tests: `./pkg/frontend`, `./pkg/sql/compile`,
`./pkg/txn/rpc`, and `./pkg/vm/engine/tae/db/dbutils`.
- `go vet`: `./pkg/catalog`, `./pkg/common/runtime`, `./pkg/sql/plan`,
and `./pkg/sql/plan/function/ctl`.
- Focused BVT on the final binary: 200/200 statements across six
scripts.
- The new 52-statement matrix covers default/FORCE/IGNORE, unique and
non-unique prefixes, IN/BETWEEN/paired ranges, same-prefix neighbors,
prepared values, Unicode, JOIN/ORDER hints, and reads before and after
flush.
- `git diff --check`.

---------

Co-authored-by: XuPeng-SH <[email protected]>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [ ] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR covers:

Regression coverage for matrixorigin#26841. The production correction merged
independently in matrixorigin#26829 while this PR was under review.

## What this PR does / why we need it:

This branch is rebased on current `main` and intentionally retains only
coverage not already present upstream:

- white-box planner cases for declared prefix metadata across BETWEEN,
scalar and paired ranges, IN, in_range, OR, unique/non-unique, malformed
metadata, and a complete-index control;
- FORCE INDEX FOR ORDER BY and FORCE INDEX FOR GROUP BY planning checks;
- an end-to-end BVT covering same-prefix neighbors, forced versus
ignored access, runtime bounds, flush, a complete-index control, RENAME
COLUMN, and INSERT/UPDATE/DELETE after rename.

During conflict resolution, the old production implementation was
deliberately not replayed: current main contains the stronger matrixorigin#26829
implementation, including V2 prefix-metadata support. Reintroducing the
old code would duplicate validation and reject valid delimiter-bearing
column names.

## Validation

- focused and complete controlled-CGo `./pkg/sql/plan` tests;
- `go vet ./pkg/sql/plan` with the project CGo include paths;
- fresh `make build`;
- `prefix_index_range` BVT: 51/51;
- existing `prefix_index_non_equality` BVT: 52/52;
- `git diff --check`.

---------

Co-authored-by: XuPeng-SH <[email protected]>

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

3 participants