Skip to content

Commit

Permalink
sql: ensure that generator isn't used with an incomplete virtual index
Browse files Browse the repository at this point in the history
The index would never be used. This eliminates a footgun.

Release note: None
  • Loading branch information
ajwerner committed Nov 1, 2022
1 parent d0118d5 commit 5936a7e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/sql/virtual_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,18 @@ func (t virtualSchemaTable) initVirtualTableDesc(
err = errors.Wrapf(err, "initVirtualDesc problem with schema: \n%s", t.schema)
return descpb.TableDescriptor{}, err
}

if t.generator != nil {
for _, idx := range t.indexes {
if idx.incomplete {
return descpb.TableDescriptor{}, errors.AssertionFailedf(
"virtual table %s.%s contains an incomplete index and a generator will"+
" never use the index", sc.GetName(), mutDesc.GetName(),
)
}
}
}

for _, index := range mutDesc.PublicNonPrimaryIndexes() {
if index.NumKeyColumns() > 1 {
panic("we don't know how to deal with virtual composite indexes yet")
Expand Down

0 comments on commit 5936a7e

Please sign in to comment.