Skip to content

Commit

Permalink
Merge #64653
Browse files Browse the repository at this point in the history
64653: tabledesc: prevent panic when removing constraint from Checks slice r=postamar a=postamar

Recently, a run of the TestRandomSyntaxSchemaChangeColumn test failed
with a panic in tabledesc.MakeMutationComplete, see #63944. The panic
was triggered by removing multiple elements from the Checks slice in the
descriptor. While the underlying issue of _how_ this slice could
possibly contain two constraints sharing the same name has not yet been
resolved, deleting only the first constraint matching the target name
will prevent future panics and perhaps help diagnose the underlying
issue.

Release note: None

Co-authored-by: Marius Posta <[email protected]>
  • Loading branch information
craig[bot] and Marius Posta committed May 4, 2021
2 parents f9dca40 + f97cf8a commit 3761b5c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions pkg/sql/catalog/tabledesc/structured.go
Original file line number Diff line number Diff line change
Expand Up @@ -1572,6 +1572,7 @@ func (desc *Mutable) MakeMutationComplete(m descpb.DescriptorMutation) error {
for i, c := range desc.Checks {
if c.Name == t.Constraint.Check.Name {
desc.Checks = append(desc.Checks[:i], desc.Checks[i+1:]...)
break
}
}
col, err := desc.FindColumnWithID(t.Constraint.NotNullColumn)
Expand Down

0 comments on commit 3761b5c

Please sign in to comment.