Skip to content

Commit

Permalink
Merge #45521
Browse files Browse the repository at this point in the history
45521: sqlbase: test that column families are stored in sorted order r=jordanlewis a=rohany

Release note: None

Co-authored-by: Rohan Yadav <[email protected]>
  • Loading branch information
craig[bot] and rohany committed Mar 2, 2020
2 parents 003fa43 + 5ff49e6 commit a75396a
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 38 deletions.
9 changes: 9 additions & 0 deletions pkg/sql/sqlbase/structured.go
Original file line number Diff line number Diff line change
Expand Up @@ -1871,6 +1871,15 @@ func (desc *TableDescriptor) validateColumnFamilies(columnIDs map[ColumnID]strin
return err
}

if i != 0 {
prevFam := desc.Families[i-1]
if family.ID < prevFam.ID {
return errors.Newf(
"family %s at index %d has id %d less than family %s at index %d with id %d",
family.Name, i, family.ID, prevFam.Name, i-1, prevFam.ID)
}
}

if _, ok := familyNames[family.Name]; ok {
return fmt.Errorf("duplicate family name: %q", family.Name)
}
Expand Down
77 changes: 39 additions & 38 deletions pkg/sql/sqlbase/structured.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/sql/sqlbase/structured.proto
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ message TableDescriptor {
(gogoproto.customname) = "NextColumnID", (gogoproto.casttype) = "ColumnID"];
// families holds information about the column families of this table.
// This list has at least length 1, in which case all columns are stored in the same family.
// families is stored in sorted order by family ID.
repeated ColumnFamilyDescriptor families = 22 [(gogoproto.nullable) = false];
// next_family_id is used to ensure that deleted family ids are not reused.
optional uint32 next_family_id = 23 [(gogoproto.nullable) = false,
Expand Down

0 comments on commit a75396a

Please sign in to comment.