Skip to content

Commit

Permalink
opt: clarify the return type of Index.Ordinal()
Browse files Browse the repository at this point in the history
The return type of `Index.Ordinal()` is now the type alias
`cat.IndexOrdinal` to be consistent with other functions that use an
index ordinal, like `Table.Index(i cat.IndexOrdinal)`. It is now more
clear that `idx == Table().Index(idx.Ordinal())`

Release justification: This is a very small, low-risk change.

Release note: None
  • Loading branch information
mgartner committed Aug 18, 2022
1 parent 04c6a1a commit c863dea
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/sql/opt/cat/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ type Index interface {

// Ordinal returns the ordinal of this index within the context of its Table.
// Specifically idx = Table().Index(idx.Ordinal).
Ordinal() int
Ordinal() IndexOrdinal

// IsUnique returns true if this index is declared as UNIQUE in the schema.
IsUnique() bool
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/exec/explain/plan_gist_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ func (u *unknownIndex) Table() cat.Table {
panic(errors.AssertionFailedf("not implemented"))
}

func (u *unknownIndex) Ordinal() int {
func (u *unknownIndex) Ordinal() cat.IndexOrdinal {
return 0
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/indexrec/hypothetical_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (hi *hypotheticalIndex) Table() cat.Table {
}

// Ordinal is part of the cat.Index interface.
func (hi *hypotheticalIndex) Ordinal() int {
func (hi *hypotheticalIndex) Ordinal() cat.IndexOrdinal {
return hi.indexOrdinal
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt/testutils/testcat/test_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ func (ti *Index) Table() cat.Table {
}

// Ordinal is part of the cat.Index interface.
func (ti *Index) Ordinal() int {
func (ti *Index) Ordinal() cat.IndexOrdinal {
return ti.ordinal
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/opt_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ func (oi *optIndex) Table() cat.Table {
}

// Ordinal is part of the cat.Index interface.
func (oi *optIndex) Ordinal() int {
func (oi *optIndex) Ordinal() cat.IndexOrdinal {
return oi.indexOrdinal
}

Expand Down Expand Up @@ -2352,7 +2352,7 @@ func (oi *optVirtualIndex) Table() cat.Table {
}

// Ordinal is part of the cat.Index interface.
func (oi *optVirtualIndex) Ordinal() int {
func (oi *optVirtualIndex) Ordinal() cat.IndexOrdinal {
return oi.indexOrdinal
}

Expand Down

0 comments on commit c863dea

Please sign in to comment.