Skip to content

Commit

Permalink
sqlbase: lift interface methods from SchemaDescriptor
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
ajwerner committed Jun 8, 2020
1 parent 8b1ae3e commit bc641f9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pkg/sql/catalog/catalogkv/catalogkv.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func GetDescriptorByID(
case typ != nil:
return sqlbase.NewImmutableTypeDescriptor(typ), nil
case schema != nil:
return schema, nil
return sqlbase.NewImmutableSchemaDescriptor(desc), nil
default:
return nil, nil
}
Expand Down
21 changes: 9 additions & 12 deletions pkg/sql/sqlbase/schema_desc.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,42 +65,39 @@ func NewInitialSchemaDescriptor(id ID, name string) *ImmutableSchemaDescriptor {
}

// GetAuditMode implements the DescriptorProto interface.
func (desc *SchemaDescriptor) GetAuditMode() TableDescriptor_AuditMode {
func (desc *ImmutableSchemaDescriptor) GetAuditMode() TableDescriptor_AuditMode {
return TableDescriptor_DISABLED
}

// TypeName implements the DescriptorProto interface.
func (desc *SchemaDescriptor) TypeName() string {
func (desc *ImmutableSchemaDescriptor) TypeName() string {
return "schema"
}

// SchemaDesc implements the ObjectDescriptor interface.
func (desc *SchemaDescriptor) DatabaseDesc() *DatabaseDescriptor {
func (desc *ImmutableSchemaDescriptor) DatabaseDesc() *DatabaseDescriptor {
return nil
}

// SchemaDesc implements the ObjectDescriptor interface.
func (desc *SchemaDescriptor) SchemaDesc() *SchemaDescriptor {
return desc
func (desc *ImmutableSchemaDescriptor) SchemaDesc() *SchemaDescriptor {
return &desc.SchemaDescriptor
}

// TableDesc implements the ObjectDescriptor interface.
func (desc *SchemaDescriptor) TableDesc() *TableDescriptor {
func (desc *ImmutableSchemaDescriptor) TableDesc() *TableDescriptor {
return nil
}

// TypeDesc implements the ObjectDescriptor interface.
func (desc *SchemaDescriptor) TypeDesc() *TypeDescriptor {
func (desc *ImmutableSchemaDescriptor) TypeDesc() *TypeDescriptor {
return nil
}

// DescriptorProto wraps a SchemaDescriptor in a Descriptor.
//
// TODO(ajwerner): Lift this into the SchemaDescriptorInterface
// implementations.
func (desc *SchemaDescriptor) DescriptorProto() *Descriptor {
func (desc *ImmutableSchemaDescriptor) DescriptorProto() *Descriptor {
return wrapDescriptor(desc)
}

// NameResolutionResult implements the ObjectDescriptor interface.
func (desc *SchemaDescriptor) NameResolutionResult() {}
func (desc *ImmutableSchemaDescriptor) NameResolutionResult() {}
2 changes: 1 addition & 1 deletion pkg/sql/sqlbase/system_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestShouldSplitAtDesc(t *testing.T) {
NewImmutableTableDescriptor(TableDescriptor{ViewQuery: "SELECT"}): false,
NewInitialDatabaseDescriptor(42, "db"): false,
NewMutableCreatedTypeDescriptor(&TypeDescriptor{}): false,
&SchemaDescriptor{}: false,
NewImmutableSchemaDescriptor(SchemaDescriptor{}): false,
} {
var rawDesc roachpb.Value
require.NoError(t, rawDesc.SetProto(inner.DescriptorProto()))
Expand Down

0 comments on commit bc641f9

Please sign in to comment.