Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
59985: sql: fail type descriptor validation if referenced descriptor is dropped r=otan a=arulajmani

Previously, when a type descriptor was validated for cross references,
we weren't checking if the referenced table descriptor was dropped.
This seems erroneous, as before a table descriptor is dropped, it
should unlink itself from type descriptors that hold a backreference
to it. This patch validates as such.

Release note: None

Co-authored-by: arulajmani <[email protected]>
  • Loading branch information
craig[bot] and arulajmani committed Feb 8, 2021
2 parents e3a3da3 + 098c5b8 commit 5b33e6d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/sql/catalog/typedesc/type_desc.go
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,14 @@ func (desc *Immutable) Validate(ctx context.Context, dg catalog.DescGetter) erro
// Validate that all of the referencing descriptors exist.
tableExists := func(id descpb.ID) func(got catalog.Descriptor) error {
return func(got catalog.Descriptor) error {
if _, isTable := got.(catalog.TableDescriptor); !isTable {
tableDesc, isTable := got.(catalog.TableDescriptor)
if !isTable {
return errors.AssertionFailedf("referencing descriptor %d does not exist", id)
}
if tableDesc.Dropped() {
return errors.AssertionFailedf(
"referencing descriptor %d was dropped without dependency unlinking", id)
}
return nil
}
}
Expand Down

0 comments on commit 5b33e6d

Please sign in to comment.