diff --git a/pkg/sql/physical_schema_accessors.go b/pkg/sql/physical_schema_accessors.go index c3cb5fce8021..7270ea4c7cc4 100644 --- a/pkg/sql/physical_schema_accessors.go +++ b/pkg/sql/physical_schema_accessors.go @@ -102,7 +102,10 @@ func (a UncachedPhysicalAccessor) GetObjectNames( flags tree.DatabaseListFlags, ) (TableNames, error) { ok, schemaID, err := a.IsValidSchema(ctx, txn, dbDesc.ID, scName) - if !ok || err != nil { + if err != nil { + return nil, err + } + if !ok { if flags.Required { tn := tree.MakeTableNameWithSchema(tree.Name(dbDesc.Name), tree.Name(scName), "") return nil, sqlbase.NewUnsupportedSchemaUsageError(tree.ErrString(&tn.TableNamePrefix))