Skip to content

Commit

Permalink
opt: clarify logic in Metadata.UpdateTableMeta
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
mgartner committed Jul 11, 2022
1 parent f678273 commit 41a794b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/sql/opt/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,14 +610,15 @@ func (md *Metadata) QualifiedAlias(colID ColumnID, fullyQualify bool, catalog ca
// TableMeta instance stores.
func (md *Metadata) UpdateTableMeta(tables map[cat.StableID]cat.Table) {
for i := range md.tables {
if tab, ok := tables[md.tables[i].Table.ID()]; ok {
oldTable := md.tables[i].Table
if newTable, ok := tables[oldTable.ID()]; ok {
// If there are any inverted hypothetical indexes, the hypothetical table
// will have extra inverted columns added. Add any new inverted columns to
// the metadata.
for j, n := md.tables[i].Table.ColumnCount(), tab.ColumnCount(); j < n; j++ {
md.AddColumn(string(tab.Column(j).ColName()), types.Bytes)
for j, n := oldTable.ColumnCount(), newTable.ColumnCount(); j < n; j++ {
md.AddColumn(string(newTable.Column(j).ColName()), types.Bytes)
}
md.tables[i].Table = tab
md.tables[i].Table = newTable
}
}
}
Expand Down

0 comments on commit 41a794b

Please sign in to comment.