Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
131965: keys,server: use TableSpan from SQLCodec r=cthumuluru-crdb a=cthumuluru-crdb

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

Co-authored-by: Chandra Thumuluru <[email protected]>
  • Loading branch information
craig[bot] and cthumuluru-crdb committed Oct 7, 2024
2 parents d22a17f + 8de3ee7 commit 67f5881
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 67f5881

Please sign in to comment.