cockroachdb / cockroachdb/cockroach

sql: remove legacy schema changer code from alter_column_type.go

Open
#164,735 0 comments 0 reactions 1 assignee Claimed by @spilchen View on GitHub
C-tech-debt T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Summary:**
PR #164708 pruned pre-25.4 version gates from `pkg/sql/alter_column_type.go`. As a result, `alterColumnTypeGeneral` now unconditionally returns an error directing callers to use the declarative schema changer (DSC). All of the legacy guard logic that precedes that return is now dead code and should be removed. See the `TODO` comment in the file.

**Background:**
Starting in 25.1, `ALTER COLUMN TYPE` is fully handled by the DSC. The old `alterColumnTypeGeneral` function implemented the legacy schema changer path and accumulated guards over time (owned sequences, check constraints, UNIQUE WITHOUT INDEX, foreign keys, index membership, single-statement transaction requirements, etc.). Now that the version gate has been removed, none of those checks are reachable.

**Code References:**
- [`pkg/sql/alter_column_type.go`](https://github.com/cockroachdb/cockroach/blob/4897c2cb4192c963c93ecd3b5a401537cd1ab50b/pkg/sql/alter_column_type.go) — contains the `TODO` comment and the legacy code to clean up

**Next Steps:**
- [ ] Remove the body of `alterColumnTypeGeneral` — all guard checks are dead code since the function unconditionally returns a `FeatureNotSupported` error pointing to the DSC
- [ ] Consider removing `alterColumnTypeGeneral` entirely and inlining the error return directly in the `ColumnConversionGeneral` / `ColumnConversionValidate` case of `AlterColumnType`
- [ ] Remove the now-unreachable `createOrUpdateSchemaChangeJob` call and `BufferClientNotice` call in the `ColumnConversionGeneral` case of `AlterColumnType`
- [ ] Clean up any imports that become unused after the above removals

Jira issue: CRDB-60996

Epic CRDB-44826

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.