Skip to content

Commit

Permalink
catalog: properly propagate flags
Browse files Browse the repository at this point in the history
Needed for #93644.

Without this patch, it's still not possible to look up offline tables
and non-active indexes.

Release note: None
  • Loading branch information
knz committed Dec 21, 2022
1 parent 28a6abc commit 8d823f5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion pkg/sql/catalog/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,10 @@ func ResolveIndex(
) {
if tableIndexName.Table.ObjectName != "" {
lflags := tree.ObjectLookupFlags{
CommonLookupFlags: tree.CommonLookupFlags{Required: flag.Required},
CommonLookupFlags: tree.CommonLookupFlags{
Required: flag.Required,
IncludeOffline: flag.IncludeOfflineTable,
},
DesiredObjectKind: tree.TableObject,
DesiredTableDescKind: tree.ResolveRequireTableOrViewDesc,
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/sql/opt/cat/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ type Flags struct {
// which we also want to show valid ranges when a table is being imported
// (offline).
IncludeOfflineTables bool

// IncludeNonActiveIndexes considers non-active indexes (e.g. being
// added). This is useful in cases where we are running a statement
// like `SHOW RANGES` for which we also want to show valid ranges
// when a table is being imported (offline).
IncludeNonActiveIndexes bool
}

// Catalog is an interface to a database catalog, exposing only the information
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/opt_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func (oc *optCatalog) ResolveIndex(
name,
tree.IndexLookupFlags{
Required: true,
IncludeNonActiveIndex: false,
IncludeNonActiveIndex: flags.IncludeNonActiveIndexes,
IncludeOfflineTable: flags.IncludeOfflineTables,
},
)
Expand Down

0 comments on commit 8d823f5

Please sign in to comment.