diff --git a/pkg/sql/catalog/resolver/resolver.go b/pkg/sql/catalog/resolver/resolver.go index 5700b8a03a6a..fbf201e9dca3 100644 --- a/pkg/sql/catalog/resolver/resolver.go +++ b/pkg/sql/catalog/resolver/resolver.go @@ -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, } diff --git a/pkg/sql/opt/cat/catalog.go b/pkg/sql/opt/cat/catalog.go index 3c6465392a30..8764dba68bc8 100644 --- a/pkg/sql/opt/cat/catalog.go +++ b/pkg/sql/opt/cat/catalog.go @@ -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 diff --git a/pkg/sql/opt_catalog.go b/pkg/sql/opt_catalog.go index 8505c178f512..4f072079b98e 100644 --- a/pkg/sql/opt_catalog.go +++ b/pkg/sql/opt_catalog.go @@ -264,7 +264,7 @@ func (oc *optCatalog) ResolveIndex( name, tree.IndexLookupFlags{ Required: true, - IncludeNonActiveIndex: false, + IncludeNonActiveIndex: flags.IncludeNonActiveIndexes, IncludeOfflineTable: flags.IncludeOfflineTables, }, )