Skip to content

fix(sql): preserve inherited indexes across column replacement - #30671

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/issue-30270
Oct 20, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
XuPeng-SH:codex/issue-30270

Conversation

@XuPeng-SH

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 #30270

What this PR does / why we need it:

A COPY ALTER that drops and re-adds an indexed column currently discards its inherited index, or shortens a composite key. This can silently remove uniqueness enforcement. Preserve the complete index binding when the statement supplies a fresh replacement column, while keeping the replacement's data identity separate from the old column.

Share ordered column-binding analysis between COPY and generic constraint resolution. Genuine removals still use the existing cleanup owner; plugin dependencies, including legacy INCLUDE metadata, follow the same binding identities. Existing target CREATE, COPY INSERT, dedup and index-rebuild paths validate and publish the result. No new catalog format, per-row work, background state or algorithm dispatch is introduced; extra analysis is bounded by the schema and ALTER clauses, and index-only ALTERs bypass it.

Regression coverage exercises ordinary/prefix, UNIQUE/composite NULL, classic FULLTEXT, vector INCLUDE metadata, renamed/repeated replacements, genuine removal and constraint-name reuse. Frontend tests check indexed reads against scan results, view values, subsequent uniqueness, token updates, unsupported replacement types, and atomic rollback without temporary relations. MySQL 8.4.8 independently confirms the core UNIQUE/composite/FULLTEXT behavior. Existing unsupported combined nonfunctional COPY DROP INDEX admission is unchanged; general prefix-width compatibility is outside this fix.

Validation on macOS arm64 / Go 1.27.1 with matching native artifacts:

  • Full planner normal: 17,809 passed test nodes; two existing skipped tests remain unchanged.
  • Affected planner ALTER/index/constraint/functional/INCLUDE/dedup race selection: 450 passed nodes, -race -count=1.
  • New frontend regression plus related index-access and ALTER foreign-key tests: 16 passed nodes in both normal and race modes, -count=1.
  • Configured incremental SCA for pkg/sql/plan and pkg/tests/sqlintegration: molint and all 12 configured golangci linters passed; formatting and diff checks clean.
  • gpt-6.1-sol / xhigh design and overall review, including corrections for merged bindings and legacy INCLUDE naming.

Full CI has not been claimed as passed.

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

@XuPeng-SH

XuPeng-SH commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-xupeng · superseded

Commit: 08be1304c09ab9b6843c3950d62220f39a956bf9

"interrupted"

@XuPeng-SH

XuPeng-SH commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: 08be1304c09ab9b6843c3950d62220f39a956bf9

Review completed. Read the assessment.

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mo-bot review · mo-bot-local · review

Commit: 08be1304c09ab9b6843c3950d62220f39a956bf9

Assessment: approve

Reviewed the complete six-file delta and its planner, index, COPY execution, and cleanup consumers. No actionable defects remain. Shared ordered binding analysis correctly separates inherited index identity from replacement data and replaces the resolver’s separate simulation. Existing validation, deduplication, rebuild, and rollback owners remain authoritative. Added work is confined to ALTER planning and necessary index rebuilding; ordinary SELECT/DML paths are unchanged.

Model: gpt-6-astra / xhigh

Session: 01a13dcf-1517-7f90-b3f9-c5f9f9e7031b · slot 0 · generation 1

Validation:

  • Evidence and source audit passed; checkout remains unchanged at the assigned head. Commands, source fingerprints, exits, script hashes, and retained logs are reconciled in /home/xupeng/.local/state/mo-bot/jobs/40702ed50205c03ffc54b543/attempt-1/validation-audit.json.

  • Isolation preflight passed. Rebuilt native prerequisites through the frozen repository build owner; verified 192 input files against HEAD and 46 artifact hashes. The earlier missing-native setup failure ran no product tests.

  • Targeted planner and SQL integration checks passed: 124 test nodes, including all eight frontend scenarios covering uniqueness, composite NULLs, replacement values, index rebuilding, constraint naming, rejection, rollback, and retry. Log: targeted-checks.log; receipt: checks/1792499586436404947-6.json.

  • Full planner suite passed: 17,809 test nodes, two unchanged skips, 66.298 seconds. Log: full-planner.log; receipt: checks/1792499779417744459-4.json.

  • Incremental formatting, diff checks, go vet, molint, and all 12 configured golangci linters passed for both changed packages. Log: static-checks.log; receipt: checks/1792500007817119582-4.json.

Limitations:

  • The frozen CI snapshot remains in progress. Author-reported macOS, race, and MySQL comparison results lack retained execution artifacts and were not counted as independently verified passes.

  • Issue #30270’s body was not supplied; review used the frozen PR’s stated behavioral contract. Supplied comments contain no substantive unresolved review concerns.

  • Vector INCLUDE coverage verifies planner metadata and naming. No GPU, multi-CN, or race rerun was required by the unchanged device, distributed, and concurrency contracts. Performance effects were traced through source; no benchmark improvement is claimed.

This branch was previously deployed

1 inactive deployment
ci — a9fcdcaf Deployed Oct 20, 2026 by XuPeng-SH
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/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: same-statement DROP/ADD of an indexed column silently removes its index

2 participants