Skip to content

Commit

Permalink
sql/catalog: rename ObjectDescriptor to Descriptor
Browse files Browse the repository at this point in the history
We're trying to define Object as a member of a schema. Today that's not really
true because Objects are currently members of databases and not schemas but
we'll get there. Descriptor is the general term for all entities which are in
the catalog, resolvable by a name, and live in the descriptor table.

Release note: None
  • Loading branch information
ajwerner committed May 26, 2020
1 parent 0857bf6 commit 873fe5e
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pkg/sql/catalog/accessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ type Accessor interface {
// descriptor and that of its parent database. If the object is not
// found and flags.required is true, an error is returned, otherwise
// a nil reference is returned.
GetObjectDesc(ctx context.Context, txn *kv.Txn, settings *cluster.Settings, codec keys.SQLCodec, db, schema, object string, flags tree.ObjectLookupFlags) (ObjectDescriptor, error)
GetObjectDesc(ctx context.Context, txn *kv.Txn, settings *cluster.Settings, codec keys.SQLCodec, db, schema, object string, flags tree.ObjectLookupFlags) (Descriptor, error)
}
2 changes: 1 addition & 1 deletion pkg/sql/catalog/accessors/logical_schema_accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func (l *LogicalSchemaAccessor) GetObjectDesc(
codec keys.SQLCodec,
db, schema, object string,
flags tree.ObjectLookupFlags,
) (catalog.ObjectDescriptor, error) {
) (catalog.Descriptor, error) {
switch flags.DesiredObjectKind {
case tree.TypeObject:
// TODO(ajwerner): Change this function if we ever expose non-table objects
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/catalog/accessors/physical_schema_accessors.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (a *CachedPhysicalAccessor) GetObjectDesc(
codec keys.SQLCodec,
db, schema, object string,
flags tree.ObjectLookupFlags,
) (catalog.ObjectDescriptor, error) {
) (catalog.Descriptor, error) {
switch flags.DesiredObjectKind {
case tree.TypeObject:
// TypeObjects are not caches so fall through to the underlying physical
Expand Down
8 changes: 4 additions & 4 deletions pkg/sql/catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/sqlbase"
)

// ObjectDescriptor provides table information for results from a name lookup.
type ObjectDescriptor interface {
// Descriptor provides table information for results from a name lookup.
type Descriptor interface {
tree.NameResolutionResult

// DatabaseDesc returns the underlying database descriptor, or nil if the
Expand All @@ -43,15 +43,15 @@ type VirtualSchemas interface {

// VirtualSchema represents a collection of VirtualObjects.
type VirtualSchema interface {
Desc() ObjectDescriptor
Desc() Descriptor
NumTables() int
VisitTables(func(object VirtualObject))
GetObjectByName(name string) (VirtualObject, error)
}

// VirtualObject is a virtual schema object.
type VirtualObject interface {
Desc() ObjectDescriptor
Desc() Descriptor
}

// TableEntry is the value type of FkTableMetadata: An optional table
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/catalog/catalogkv/physical_accessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (a UncachedPhysicalAccessor) GetObjectDesc(
codec keys.SQLCodec,
db, schema, object string,
flags tree.ObjectLookupFlags,
) (catalog.ObjectDescriptor, error) {
) (catalog.Descriptor, error) {
// Look up the database ID.
dbID, err := GetDatabaseID(ctx, txn, codec, db, flags.Required)
if err != nil || dbID == sqlbase.InvalidID {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/catalog/resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func ResolveExistingObject(
return nil, prefix, nil
}

obj := descI.(catalog.ObjectDescriptor)
obj := descI.(catalog.Descriptor)
switch lookupFlags.DesiredObjectKind {
case tree.TypeObject:
if obj.TypeDesc() == nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/sql/virtual_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ type virtualSchemaEntry struct {
allTableNames map[string]struct{}
}

func (v virtualSchemaEntry) Desc() catalog.ObjectDescriptor {
func (v virtualSchemaEntry) Desc() catalog.Descriptor {
return v.desc
}

Expand Down Expand Up @@ -322,7 +322,7 @@ type virtualDefEntry struct {
validWithNoDatabaseContext bool
}

func (e virtualDefEntry) Desc() catalog.ObjectDescriptor {
func (e virtualDefEntry) Desc() catalog.Descriptor {
return sqlbase.NewImmutableTableDescriptor(*e.desc)
}

Expand Down

0 comments on commit 873fe5e

Please sign in to comment.