sql/schemachanger: allow ALTER COLUMN TYPE with dependent routines#170003
Draft
michae2 wants to merge 1 commit into
Draft
sql/schemachanger: allow ALTER COLUMN TYPE with dependent routines#170003michae2 wants to merge 1 commit into
michae2 wants to merge 1 commit into
Conversation
Contributor
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
Member
3690f5e to
ea68989
Compare
|
Detected infrastructure failure (matched: self-hosted runner lost communication with the server). Automatically rerunning failed jobs. (run link) |
bghal
reviewed
May 13, 2026
|
|
||
| subtest dep_function | ||
|
|
||
| # Compatible type change (INT4 → INT8) should succeed with dependent function. |
Contributor
There was a problem hiding this comment.
I see widening tests but is there coverage that unsafe narrowing is blocked?
This was referenced May 13, 2026
0c8f657 to
7232852
Compare
Previously, ALTER TABLE ... ALTER COLUMN TYPE unconditionally failed when UDFs or stored procedures referenced the column, even for compatible type changes like INT4→INT8 or VARCHAR(30)→VARCHAR(60). This was a significant limitation for users with many routines who needed to widen column types without downtime. This change makes the schema changer re-validate dependent routine bodies against the new column type before rejecting the ALTER. A synthetic table descriptor with the new type is injected into the catalog, and each dependent function/procedure body is type-checked via BuildReferenceProvider. If validation passes, the ALTER proceeds and FunctionBody elements are updated with refreshed dependency references. If any routine body would become invalid with the new type, a descriptive error is returned. Fixes: cockroachdb#160622 Release note (sql change): ALTER TABLE ... ALTER COLUMN TYPE now succeeds when dependent functions or stored procedures reference the column, as long as the type change is compatible with the routine bodies. Previously, any dependent routine would unconditionally block the type change. Incompatible changes still produce a clear error identifying which routine would become invalid. Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
7232852 to
2cfec33
Compare
|
Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, ALTER TABLE ... ALTER COLUMN TYPE unconditionally failed when UDFs or stored procedures referenced the column, even for compatible type changes like INT4→INT8 or VARCHAR(30)→VARCHAR(60). This was a significant limitation for users with many routines who needed to widen column types without downtime.
This change makes the schema changer re-validate dependent routine bodies against the new column type before rejecting the ALTER. A synthetic table descriptor with the new type is injected into the catalog, and each dependent function/procedure body is type-checked via BuildReferenceProvider. If validation passes, the ALTER proceeds and FunctionBody elements are updated with refreshed dependency references. If any routine body would become invalid with the new type, a descriptive error is returned.
Fixes: #160622
Release note (sql change): ALTER TABLE ... ALTER COLUMN TYPE now succeeds when dependent functions or stored procedures reference the column, as long as the type change is compatible with the routine bodies. Previously, any dependent routine would unconditionally block the type change. Incompatible changes still produce a clear error identifying which routine would become invalid.