Skip to content

workload/schemachanger: fix dependency detection for DROP COLUMN#160659

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
fqazi:fixDropColumnFK
Jan 8, 2026
Merged

workload/schemachanger: fix dependency detection for DROP COLUMN#160659
craig[bot] merged 1 commit intocockroachdb:masterfrom
fqazi:fixDropColumnFK

Conversation

@fqazi
Copy link
Copy Markdown
Collaborator

@fqazi fqazi commented Jan 7, 2026

Previously, the DROP COLUMN operation in the schema changer could fail, since it detected self referential foreign key dependencies as external ones. To address this, this patch excludes them from the detection.

Fixes: #160318
Fixes: #159952

Release note: None

@fqazi fqazi requested a review from a team January 7, 2026 21:10
@fqazi fqazi requested a review from a team as a code owner January 7, 2026 21:10
@fqazi fqazi added the backport-26.1.x Flags PRs that need to be backported to 26.1 label Jan 7, 2026
@fqazi fqazi requested review from DarrylWong and golgeek and removed request for a team January 7, 2026 21:10
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@spilchen spilchen left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this!

@spilchen reviewed all commit messages and made 2 comments.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @DarrylWong, @fqazi, and @golgeek).


pkg/workload/schemachange/error_screening.go line 153 at r1 (raw file):

func (og *operationGenerator) columnIsDependedOn(
	ctx context.Context, tx pgx.Tx, tableName *tree.TableName, columnName tree.Name, includeFKs bool,

I don't think there is a case where we pass in true for the incluedFKs parameter? Just wondering what the benefit is to have this new parm. We could simplify the function a bit if we unconditionally omitted FKs. Unless setColumnType usage was meant to pass in true?

Previously, the DROP COLUMN operation in the schema changer could fail,
since it detected self referential foreign key dependencies as external
ones. To address this, this patch excludes them from the detection.

Fixes: cockroachdb#160318
Fixes: cockroachdb#159952

Release note: None
Copy link
Copy Markdown
Collaborator Author

@fqazi fqazi left a comment

Choose a reason for hiding this comment

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

@fqazi made 1 comment.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @DarrylWong, @golgeek, and @spilchen).


pkg/workload/schemachange/error_screening.go line 153 at r1 (raw file):

Previously, spilchen wrote…

I don't think there is a case where we pass in true for the incluedFKs parameter? Just wondering what the benefit is to have this new parm. We could simplify the function a bit if we unconditionally omitted FKs. Unless setColumnType usage was meant to pass in true?

Done.

Yes, I forgot to flip setColumnType to true

@fqazi fqazi requested a review from spilchen January 8, 2026 15:11
Copy link
Copy Markdown
Contributor

@spilchen spilchen left a comment

Choose a reason for hiding this comment

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

:lgtm:

@spilchen made 1 comment and resolved 1 discussion.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @DarrylWong and @golgeek).

@fqazi
Copy link
Copy Markdown
Collaborator Author

fqazi commented Jan 8, 2026

@spilchen TFTR!

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 8, 2026

@craig craig bot merged commit 2af343b into cockroachdb:master Jan 8, 2026
25 of 26 checks passed
@fqazi
Copy link
Copy Markdown
Collaborator Author

fqazi commented Mar 3, 2026

blathers backport 25.2

@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Mar 3, 2026

Based on the specified backports for this PR, I applied new labels to the following linked issue(s). Please adjust the labels as needed to match the branches actually affected by the issue(s), including adding any known older branches.


Issue #160318: branch-release-25.2.


Issue #159952: branch-release-25.2.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

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

Labels

backport-26.1.x Flags PRs that need to be backported to 26.1 v26.2.0-prerelease

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pkg/ccl/testccl/workload/schemachange/schemachange_test: TestWorkload failed roachtest: backup-restore/online-restore failed

3 participants