Skip to content

Commit

Permalink
keys,server: use TableSpan from SQLCodec
Browse files Browse the repository at this point in the history
Add TableSpan implementation to SQLCodec and use that to build table spans. This refactoring helps with migration experiment of default system tenant from tenantID {1} to {2}.

Informs: cockroachdb#131902
Epic: CRDB-42740
Release note: None
  • Loading branch information
cthumuluru-crdb committed Oct 7, 2024
1 parent 26d67df commit 8de3ee7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 6 additions & 0 deletions pkg/keys/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ func (e sqlEncoder) TenantSpan() roachpb.Span {
return roachpb.Span{Key: key, EndKey: endKey}
}

// TableSpan returns a span representing the table's keyspace.
func (e sqlEncoder) TableSpan(tableID uint32) roachpb.Span {
key := e.TablePrefix(tableID)
return roachpb.Span{Key: key, EndKey: key.PrefixEnd()}
}

// TablePrefix returns the key prefix used for the table's data.
func (e sqlEncoder) TablePrefix(tableID uint32) roachpb.Key {
k := e.TenantPrefix()
Expand Down
10 changes: 2 additions & 8 deletions pkg/server/systemconfigwatcher/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,8 @@ func NewWithAdditionalProvider(
c.additionalKVsSource = additional

spans := []roachpb.Span{
{
Key: append(codec.TenantPrefix(), keys.SystemDescriptorTableSpan.Key...),
EndKey: append(codec.TenantPrefix(), keys.SystemDescriptorTableSpan.EndKey...),
},
{
Key: append(codec.TenantPrefix(), keys.SystemZonesTableSpan.Key...),
EndKey: append(codec.TenantPrefix(), keys.SystemZonesTableSpan.EndKey...),
},
codec.TableSpan(keys.DescriptorTableID),
codec.TableSpan(keys.ZonesTableID),
}
c.w = rangefeedcache.NewWatcher(
"system-config-cache", clock, f,
Expand Down

0 comments on commit 8de3ee7

Please sign in to comment.