Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: identify remaining uses of TODOSQLCodec #99774

Merged
merged 1 commit into from
Mar 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/ccl/backupccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ go_test(
"//pkg/testutils/datapathutils",
"//pkg/testutils/distsqlutils",
"//pkg/testutils/jobutils",
"//pkg/testutils/keysutils",
"//pkg/testutils/serverutils",
"//pkg/testutils/skip",
"//pkg/testutils/sqlutils",
Expand Down
3 changes: 2 additions & 1 deletion pkg/ccl/backupccl/backup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/stats"
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/jobutils"
"github.com/cockroachdb/cockroach/pkg/testutils/keysutils"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
"github.com/cockroachdb/cockroach/pkg/testutils/sqlutils"
Expand Down Expand Up @@ -6132,7 +6133,7 @@ func getMockTableDesc(
// methods.
func TestPublicIndexTableSpans(t *testing.T) {
defer leaktest.AfterTest(t)()
codec := keys.TODOSQLCodec
codec := keysutils.TestingSQLCodec
execCfg := &sql.ExecutorConfig{
Codec: codec,
}
Expand Down
1 change: 1 addition & 0 deletions pkg/ccl/streamingccl/streamingest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ go_test(
"//pkg/testutils/datapathutils",
"//pkg/testutils/distsqlutils",
"//pkg/testutils/jobutils",
"//pkg/testutils/keysutils",
"//pkg/testutils/serverutils",
"//pkg/testutils/skip",
"//pkg/testutils/sqlutils",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/storage"
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/distsqlutils"
"github.com/cockroachdb/cockroach/pkg/testutils/keysutils"
"github.com/cockroachdb/cockroach/pkg/testutils/storageutils"
"github.com/cockroachdb/cockroach/pkg/testutils/testcluster"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
Expand Down Expand Up @@ -363,7 +364,7 @@ func assertEqualKVs(
tableID int,
partitionTimestamp hlc.Timestamp,
) {
key := keys.TODOSQLCodec.TablePrefix(uint32(tableID))
key := keysutils.TestingSQLCodec.TablePrefix(uint32(tableID))

// Iterate over the store.
store := tc.GetFirstStoreFromServer(t, 0)
Expand Down
5 changes: 0 additions & 5 deletions pkg/keys/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,6 @@ func MakeSQLCodec(tenID roachpb.TenantID) SQLCodec {
// SystemSQLCodec is a SQL key codec for the system tenant.
var SystemSQLCodec = MakeSQLCodec(roachpb.SystemTenantID)

// TODOSQLCodec is a SQL key codec. It is equivalent to SystemSQLCodec, but
// should be used when it is unclear which tenant should be referenced by the
// surrounding context.
var TODOSQLCodec = MakeSQLCodec(roachpb.SystemTenantID)

// ForSystemTenant returns whether the encoder is bound to the system tenant.
func (e sqlEncoder) ForSystemTenant() bool {
return len(e.TenantPrefix()) == 0
Expand Down
5 changes: 4 additions & 1 deletion pkg/kv/kvserver/reports/reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,9 +447,12 @@ func visitAncestors(
cfg *config.SystemConfig,
visitor func(context.Context, *zonepb.ZoneConfig, ZoneKey) bool,
) (bool, error) {
// This is a bug: see https://github.com/cockroachdb/cockroach/issues/48123.
var FIXMEIDONTKNOWWHICHCODECTOUSE = keys.MakeSQLCodec(roachpb.SystemTenantID)

// Check to see if it's a table. If so, inherit from the database.
// For all other cases, inherit from the default.
descVal := cfg.GetValue(catalogkeys.MakeDescMetadataKey(keys.TODOSQLCodec, descpb.ID(id)))
descVal := cfg.GetValue(catalogkeys.MakeDescMetadataKey(FIXMEIDONTKNOWWHICHCODECTOUSE, descpb.ID(id)))
if descVal == nil {
// Couldn't find a descriptor. This is not expected to happen.
// Let's just look at the default zone config.
Expand Down
1 change: 1 addition & 0 deletions pkg/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ go_test(
"//pkg/testutils",
"//pkg/testutils/datapathutils",
"//pkg/testutils/diagutils",
"//pkg/testutils/keysutils",
"//pkg/testutils/serverutils",
"//pkg/testutils/skip",
"//pkg/testutils/sqlutils",
Expand Down
8 changes: 4 additions & 4 deletions pkg/server/decommission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import (
"testing"

"github.com/cockroachdb/cockroach/pkg/base"
"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/allocator/allocatorimpl"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/security/username"
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/keysutils"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
Expand Down Expand Up @@ -129,8 +129,8 @@ func TestDecommissionPreCheckEvaluation(t *testing.T) {
require.NoError(t, err)
tblBID, err := firstSvr.admin.queryTableID(ctx, username.RootUserName(), "test", "tblB")
require.NoError(t, err)
startKeyTblA := keys.TODOSQLCodec.TablePrefix(uint32(tblAID))
startKeyTblB := keys.TODOSQLCodec.TablePrefix(uint32(tblBID))
startKeyTblA := keysutils.TestingSQLCodec.TablePrefix(uint32(tblAID))
startKeyTblB := keysutils.TestingSQLCodec.TablePrefix(uint32(tblBID))

// Split off ranges for tblA and tblB.
_, rDescA, err := firstSvr.SplitRange(startKeyTblA)
Expand Down Expand Up @@ -234,7 +234,7 @@ func TestDecommissionPreCheckOddToEven(t *testing.T) {
runQueries(alterQueries...)
tblAID, err := firstSvr.admin.queryTableID(ctx, username.RootUserName(), "test", "tblA")
require.NoError(t, err)
startKeyTblA := keys.TODOSQLCodec.TablePrefix(uint32(tblAID))
startKeyTblA := keysutils.TestingSQLCodec.TablePrefix(uint32(tblAID))

// Split off range for tblA.
_, rDescA, err := firstSvr.SplitRange(startKeyTblA)
Expand Down
1 change: 1 addition & 0 deletions pkg/sql/row/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ go_test(
"//pkg/sql/sem/tree",
"//pkg/storage",
"//pkg/testutils",
"//pkg/testutils/keysutils",
"//pkg/testutils/serverutils",
"//pkg/testutils/sqlutils",
"//pkg/util/encoding",
Expand Down
3 changes: 2 additions & 1 deletion pkg/sql/row/expr_walker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/isql"
"github.com/cockroachdb/cockroach/pkg/sql/row"
"github.com/cockroachdb/cockroach/pkg/sql/sem/eval"
"github.com/cockroachdb/cockroach/pkg/testutils/keysutils"
"github.com/cockroachdb/cockroach/pkg/testutils/serverutils"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/log"
Expand Down Expand Up @@ -201,7 +202,7 @@ func TestJobBackedSeqChunkProvider(t *testing.T) {
}

for id, val := range test.seqIDToExpectedVal {
seqDesc := createAndIncrementSeqDescriptor(ctx, t, id, keys.TODOSQLCodec,
seqDesc := createAndIncrementSeqDescriptor(ctx, t, id, keysutils.TestingSQLCodec,
test.incrementBy, test.seqIDToOpts[id], kvDB)
seqMetadata := &row.SequenceMetadata{
SeqDesc: seqDesc,
Expand Down
7 changes: 6 additions & 1 deletion pkg/testutils/keysutils/pretty_scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func parseTableKeysAsAscendingInts(
if !ok {
panic(fmt.Sprintf("unknown table: %s", tableName))
}
output := keys.TODOSQLCodec.TablePrefix(uint32(tableID))
output := TestingSQLCodec.TablePrefix(uint32(tableID))
if remainder == "" {
return "", output
}
Expand Down Expand Up @@ -167,3 +167,8 @@ func parseAscendingIntIndexKey(input string) (string, roachpb.Key) {
}
return remainder, key
}

// TestingSQLCodec is a SQL key codec. It is equivalent to keys.SystemSQLCodec, but
// should be used when it is unclear which tenant should be referenced by the
// surrounding context.
var TestingSQLCodec = keys.MakeSQLCodec(roachpb.SystemTenantID)