Skip to content

Commit

Permalink
clusterversion,*: remove NamespaceTableWithSchemas*
Browse files Browse the repository at this point in the history
This commit removes the NamespaceTableWithSchemas and
NamespaceTableWithSchemasMigration cluster version keys
and all the version-gated code pertaining to them.

Notably, this removes all references to system.namespace2 as well as the
deprecated namespace table at descriptor ID 2.

Partially addresses cockroachdb#65200.

Release note: None
  • Loading branch information
Marius Posta committed Jun 3, 2021
1 parent 83b388d commit 2291aec
Show file tree
Hide file tree
Showing 74 changed files with 313 additions and 1,837 deletions.
106 changes: 53 additions & 53 deletions pkg/bench/ddl_analysis/testdata/benchmark_expectations
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,54 @@ exp,benchmark
5,AlterRole/alter_role_with_1_option
6,AlterRole/alter_role_with_2_options
8,AlterRole/alter_role_with_3_options
19,AlterTableAddCheckConstraint/alter_table_add_1_check_constraint
19,AlterTableAddCheckConstraint/alter_table_add_2_check_constraints
19,AlterTableAddCheckConstraint/alter_table_add_3_check_constraints
19,AlterTableAddColumn/alter_table_add_1_column
19,AlterTableAddColumn/alter_table_add_2_columns
19,AlterTableAddColumn/alter_table_add_3_columns
27,AlterTableAddForeignKey/alter_table_add_1_foreign_key
35,AlterTableAddForeignKey/alter_table_add_2_foreign_keys
43,AlterTableAddForeignKey/alter_table_add_3_foreign_keys
27,AlterTableAddForeignKey/alter_table_add_foreign_key_with_3_columns
27,AlterTableConfigureZone/alter_table_configure_zone_5_replicas
27,AlterTableConfigureZone/alter_table_configure_zone_7_replicas_
27,AlterTableConfigureZone/alter_table_configure_zone_ranges
23,AlterTableDropColumn/alter_table_drop_1_column
27,AlterTableDropColumn/alter_table_drop_2_columns
31,AlterTableDropColumn/alter_table_drop_3_columns
20,AlterTableDropConstraint/alter_table_drop_1_check_constraint
21,AlterTableDropConstraint/alter_table_drop_2_check_constraints
22,AlterTableDropConstraint/alter_table_drop_3_check_constraints
14-15,AlterTableSplit/alter_table_split_at_1_value
20-21,AlterTableSplit/alter_table_split_at_2_values
26-27,AlterTableSplit/alter_table_split_at_3_values
10,AlterTableUnsplit/alter_table_unsplit_at_1_value
12,AlterTableUnsplit/alter_table_unsplit_at_2_values
14,AlterTableUnsplit/alter_table_unsplit_at_3_values
18,AlterTableAddCheckConstraint/alter_table_add_1_check_constraint
18,AlterTableAddCheckConstraint/alter_table_add_2_check_constraints
18,AlterTableAddCheckConstraint/alter_table_add_3_check_constraints
18,AlterTableAddColumn/alter_table_add_1_column
18,AlterTableAddColumn/alter_table_add_2_columns
18,AlterTableAddColumn/alter_table_add_3_columns
25,AlterTableAddForeignKey/alter_table_add_1_foreign_key
32,AlterTableAddForeignKey/alter_table_add_2_foreign_keys
39,AlterTableAddForeignKey/alter_table_add_3_foreign_keys
25,AlterTableAddForeignKey/alter_table_add_foreign_key_with_3_columns
24,AlterTableConfigureZone/alter_table_configure_zone_5_replicas
24,AlterTableConfigureZone/alter_table_configure_zone_7_replicas_
24,AlterTableConfigureZone/alter_table_configure_zone_ranges
22,AlterTableDropColumn/alter_table_drop_1_column
26,AlterTableDropColumn/alter_table_drop_2_columns
30,AlterTableDropColumn/alter_table_drop_3_columns
19,AlterTableDropConstraint/alter_table_drop_1_check_constraint
20,AlterTableDropConstraint/alter_table_drop_2_check_constraints
21,AlterTableDropConstraint/alter_table_drop_3_check_constraints
13-14,AlterTableSplit/alter_table_split_at_1_value
19-20,AlterTableSplit/alter_table_split_at_2_values
25-26,AlterTableSplit/alter_table_split_at_3_values
9,AlterTableUnsplit/alter_table_unsplit_at_1_value
11,AlterTableUnsplit/alter_table_unsplit_at_2_values
13,AlterTableUnsplit/alter_table_unsplit_at_3_values
5,CreateRole/create_role_with_1_option
7,CreateRole/create_role_with_2_options
8,CreateRole/create_role_with_3_options
6,CreateRole/create_role_with_no_options
21,DropDatabase/drop_database_0_tables
30,DropDatabase/drop_database_1_table
39,DropDatabase/drop_database_2_tables
48,DropDatabase/drop_database_3_tables
13,DropRole/drop_1_role
21,DropRole/drop_2_roles
29,DropRole/drop_3_roles
21,DropSequence/drop_1_sequence
31,DropSequence/drop_2_sequences
41,DropSequence/drop_3_sequences
24,DropTable/drop_1_table
37,DropTable/drop_2_tables
50,DropTable/drop_3_tables
25,DropView/drop_1_view
42,DropView/drop_2_views
59,DropView/drop_3_views
21,Grant/grant_all_on_1_table
24,Grant/grant_all_on_2_tables
27,Grant/grant_all_on_3_tables
20,DropDatabase/drop_database_0_tables
29,DropDatabase/drop_database_1_table
38,DropDatabase/drop_database_2_tables
47,DropDatabase/drop_database_3_tables
12,DropRole/drop_1_role
20,DropRole/drop_2_roles
28,DropRole/drop_3_roles
20,DropSequence/drop_1_sequence
29,DropSequence/drop_2_sequences
38,DropSequence/drop_3_sequences
23,DropTable/drop_1_table
35,DropTable/drop_2_tables
47,DropTable/drop_3_tables
24,DropView/drop_1_view
40,DropView/drop_2_views
56,DropView/drop_3_views
19,Grant/grant_all_on_1_table
22,Grant/grant_all_on_2_tables
25,Grant/grant_all_on_3_tables
21,GrantRole/grant_1_role
24,GrantRole/grant_2_roles
2,ORMQueries/activerecord_type_introspection_query
Expand All @@ -60,19 +60,19 @@ exp,benchmark
2,ORMQueries/pg_class
2,ORMQueries/pg_namespace
2,ORMQueries/pg_type
21,Revoke/revoke_all_on_1_table
24,Revoke/revoke_all_on_2_tables
27,Revoke/revoke_all_on_3_tables
19,Revoke/revoke_all_on_1_table
22,Revoke/revoke_all_on_2_tables
25,Revoke/revoke_all_on_3_tables
20,RevokeRole/revoke_1_role
22,RevokeRole/revoke_2_roles
1,SystemDatabaseQueries/select_system.users_with_empty_database_name
1,SystemDatabaseQueries/select_system.users_with_schema_name
2,SystemDatabaseQueries/select_system.users_without_schema_name
26-29,Truncate/truncate_1_column_0_rows
26-29,Truncate/truncate_1_column_1_row
26-29,Truncate/truncate_1_column_2_rows
26-29,Truncate/truncate_2_column_0_rows
26-29,Truncate/truncate_2_column_1_rows
26-29,Truncate/truncate_2_column_2_rows
27,Truncate/truncate_1_column_0_rows
27,Truncate/truncate_1_column_1_row
27,Truncate/truncate_1_column_2_rows
27,Truncate/truncate_2_column_0_rows
27,Truncate/truncate_2_column_1_rows
27,Truncate/truncate_2_column_2_rows
1,VirtualTableQueries/select_crdb_internal.invalid_objects_with_1_fk
1,VirtualTableQueries/select_crdb_internal.tables_with_1_fk
12 changes: 3 additions & 9 deletions pkg/ccl/backupccl/restore_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func WriteDescriptors(
// Depending on which cluster version we are restoring to, we decide which
// namespace table to write the descriptor into. This may cause wrong
// behavior if the cluster version is bumped DURING a restore.
dKey := catalogkv.MakeDatabaseNameKey(ctx, settings, desc.GetName())
dKey := catalogkeys.NewDatabaseKey(desc.GetName())
b.CPut(dKey.Key(codec), desc.GetID(), nil)
}

Expand Down Expand Up @@ -418,13 +418,7 @@ func WriteDescriptors(
// Depending on which cluster version we are restoring to, we decide which
// namespace table to write the descriptor into. This may cause wrong
// behavior if the cluster version is bumped DURING a restore.
tkey := catalogkv.MakeObjectNameKey(
ctx,
settings,
table.GetParentID(),
table.GetParentSchemaID(),
table.GetName(),
)
tkey := catalogkv.MakeObjectNameKey(table.GetParentID(), table.GetParentSchemaID(), table.GetName())
b.CPut(tkey.Key(codec), table.GetID(), nil)
}

Expand All @@ -449,7 +443,7 @@ func WriteDescriptors(
); err != nil {
return err
}
tkey := catalogkv.MakeObjectNameKey(ctx, settings, typ.GetParentID(), typ.GetParentSchemaID(), typ.GetName())
tkey := catalogkv.MakeObjectNameKey(typ.GetParentID(), typ.GetParentSchemaID(), typ.GetName())
b.CPut(tkey.Key(codec), typ.GetID(), nil)
}

Expand Down
3 changes: 0 additions & 3 deletions pkg/ccl/backupccl/system_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,6 @@ var systemTableBackupConfiguration = map[string]systemBackupConfiguration{
systemschema.NamespaceTable.GetName(): {
shouldIncludeInClusterBackup: optOutOfClusterBackup,
},
systemschema.DeprecatedNamespaceTable.GetName(): {
shouldIncludeInClusterBackup: optOutOfClusterBackup,
},
systemschema.ProtectedTimestampsMetaTable.GetName(): {
shouldIncludeInClusterBackup: optOutOfClusterBackup,
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/kvccl/kvfollowerreadsccl/followerreads_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ func TestFollowerReadsWithStaleDescriptor(t *testing.T) {
n4.Exec(t, "SELECT * from test WHERE k=1")
// Check that the cache was indeed populated.
var tableID uint32
n1.QueryRow(t, `SELECT id from system.namespace2 WHERE name='test'`).Scan(&tableID)
n1.QueryRow(t, `SELECT id from system.namespace WHERE name='test'`).Scan(&tableID)
tablePrefix := keys.MustAddr(keys.SystemSQLCodec.TablePrefix(tableID))
n4Cache := tc.Server(3).DistSenderI().(*kvcoord.DistSender).RangeDescriptorCache()
entry := n4Cache.GetCached(ctx, tablePrefix, false /* inverted */)
Expand Down
8 changes: 7 additions & 1 deletion pkg/cli/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,13 @@ func fromZipDir(
return nil, nil, nil, err
}

namespaceFile, err := os.Open(maybePrint("system.namespace2.txt"))
// Handle old debug zips where the namespace table dump is from namespace2.
namespaceFileName := "system.namespace2.txt"
if _, err := os.Stat(namespaceFileName); err != nil {
namespaceFileName = "system.namespace.txt"
}

namespaceFile, err := os.Open(maybePrint(namespaceFileName))
if err != nil {
return nil, nil, nil, err
}
Expand Down
14 changes: 8 additions & 6 deletions pkg/cli/sql_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ SET

expectedRows := [][]string{
{`parentID`, `INT8`, `false`, `NULL`, ``, `{primary}`, `false`},
{`parentSchemaID`, `INT8`, `false`, `NULL`, ``, `{primary}`, `false`},
{`name`, `STRING`, `false`, `NULL`, ``, `{primary}`, `false`},
{`id`, `INT8`, `true`, `NULL`, ``, `{}`, `false`},
}
Expand All @@ -166,12 +167,13 @@ SET
}

expected = `
column_name | data_type | is_nullable | column_default | generation_expression | indices | is_hidden
--------------+-----------+-------------+----------------+-----------------------+-----------+------------
parentID | INT8 | false | NULL | | {primary} | false
name | STRING | false | NULL | | {primary} | false
id | INT8 | true | NULL | | {} | false
(3 rows)
column_name | data_type | is_nullable | column_default | generation_expression | indices | is_hidden
-----------------+-----------+-------------+----------------+-----------------------+-----------+------------
parentID | INT8 | false | NULL | | {primary} | false
parentSchemaID | INT8 | false | NULL | | {primary} | false
name | STRING | false | NULL | | {primary} | false
id | INT8 | true | NULL | | {} | false
(4 rows)
`

if a, e := b.String(), expected[1:]; a != e {
Expand Down
Loading

0 comments on commit 2291aec

Please sign in to comment.