Skip to content

Commit aaecc96

Browse files
committed
opt: assign table ID to hypothetical inverted index columns
This commit fixes a minor bug in index recommendations where hypothetical inverted index columns were not assigned table IDs in the hypothetical table's metadata. In theory this could cause internal errors, however, there are no known reproductions of errors. Release note: None
1 parent 8b03864 commit aaecc96

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

pkg/sql/opt/indexrec/testdata/geospatial

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,7 +1792,7 @@ select
17921792
│ ├── cost: 142.706667
17931793
│ ├── key: (3)
17941794
│ └── scan t2@inverted_idx,inverted
1795-
│ ├── columns: rowid:3!null t2.geom1_inverted_key:6!null
1795+
│ ├── columns: rowid:3!null geom1_inverted_key:6!null
17961796
│ ├── inverted constraint: /6/3
17971797
│ │ └── spans
17981798
│ │ ├── ["B\xfd\x10\x00\x00\x00\x00\x00\x00\x00", "B\xfd\x10\x00\x00\x00\x00\x00\x00\x00"]
@@ -1935,7 +1935,7 @@ select
19351935
│ ├── cost: 142.706667
19361936
│ ├── key: (3)
19371937
│ └── scan t2@inverted_idx_visible,inverted
1938-
│ ├── columns: rowid:3!null t2.geom1_inverted_key:8!null
1938+
│ ├── columns: rowid:3!null geom1_inverted_key:8!null
19391939
│ ├── inverted constraint: /8/3
19401940
│ │ └── spans
19411941
│ │ ├── ["B\xfd\x10\x00\x00\x00\x00\x00\x00\x00", "B\xfd\x10\x00\x00\x00\x00\x00\x00\x00"]

pkg/sql/opt/metadata.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,8 @@ func (md *Metadata) UpdateTableMeta(
10151015
// will have extra inverted columns added. Add any new inverted columns to
10161016
// the metadata.
10171017
for j, n := oldTable.ColumnCount(), newTable.ColumnCount(); j < n; j++ {
1018-
md.AddColumn(string(newTable.Column(j).ColName()), types.Bytes)
1018+
colID := md.AddColumn(string(newTable.Column(j).ColName()), types.Bytes)
1019+
md.ColumnMeta(colID).Table = md.tables[i].MetaID
10191020
}
10201021
if newTable.ColumnCount() > oldTable.ColumnCount() {
10211022
// If we added any new columns, we need to recalculate the not null

0 commit comments

Comments
 (0)