Permalink
Checking mergeability…
Don’t worry, you can still create the pull request.
Comparing changes
Open a pull request
- 1 commit
- 9 files changed
- 0 commit comments
- 1 contributor
Unified
Split
Showing
with
36 additions
and 22 deletions.
- +1 −1 pkg/ccl/partitionccl/partition_test.go
- +2 −1 pkg/server/admin.go
- +7 −2 pkg/sql/crdb_internal.go
- +2 −2 pkg/sql/logictest/testdata/logic_test/crdb_internal
- +4 −4 pkg/sql/logictest/testdata/logic_test/show_source
- +1 −1 pkg/sql/logictest/testdata/planner_test/explain
- +1 −1 pkg/sql/opt/exec/execbuilder/testdata/explain
- +16 −9 pkg/sql/show_zone_config.go
- +2 −1 pkg/testutils/sqlutils/zone.go
| @@ -1303,7 +1303,7 @@ func TestRepartitioning(t *testing.T) { | ||
| for _, name := range test.new.parsed.tableDesc.PartitionNames() { | ||
| newPartitionNames[name] = struct{}{} | ||
| } | ||
| rows := sqlDB.QueryStr(t, "SELECT cli_specifier FROM [SHOW ALL ZONE CONFIGURATIONS] WHERE cli_specifier IS NOT NULL") | ||
| rows := sqlDB.QueryStr(t, "SELECT zone_name FROM [SHOW ALL ZONE CONFIGURATIONS] WHERE cli_specifier IS NOT NULL") | ||
| for _, row := range rows { | ||
| zs, err := config.ParseCLIZoneSpecifier(row[0]) | ||
| if err != nil { | ||
| @@ -1516,7 +1516,8 @@ func (s *adminServer) DataDistribution( | ||
| // Get zone configs. | ||
| // TODO(vilterp): this can be done in parallel with getting table/db names and replica counts. | ||
| zoneConfigsQuery := `SHOW ALL ZONE CONFIGURATIONS` | ||
| zoneConfigsQuery := `SELECT zone_id, cli_specifier, config_sql, config_protobuf | ||
| FROM crdb_internal.zones WHERE cli_specifier IS NOT NULL` | ||
| rows2, _ /* cols */, err := s.server.internalExecutor.QueryWithUser( | ||
| ctx, "admin-replica-matrix", nil /* txn */, userName, zoneConfigsQuery, | ||
| ) | ||
| @@ -760,7 +760,9 @@ var crdbInternalClusterQueriesTable = virtualSchemaTable{ | ||
| } | ||
| func populateQueriesTable( | ||
| ctx context.Context, addRow func(...tree.Datum) error, response *serverpb.ListSessionsResponse, | ||
| ctx context.Context, | ||
| addRow func(...tree.Datum) error, | ||
| response *serverpb.ListSessionsResponse, | ||
| ) error { | ||
| for _, session := range response.Sessions { | ||
| for _, query := range session.ActiveQueries { | ||
| @@ -857,7 +859,9 @@ var crdbInternalClusterSessionsTable = virtualSchemaTable{ | ||
| } | ||
| func populateSessionsTable( | ||
| ctx context.Context, addRow func(...tree.Datum) error, response *serverpb.ListSessionsResponse, | ||
| ctx context.Context, | ||
| addRow func(...tree.Datum) error, | ||
| response *serverpb.ListSessionsResponse, | ||
| ) error { | ||
| for _, session := range response.Sessions { | ||
| // Generate active_queries and oldest_query_start | ||
| @@ -1680,6 +1684,7 @@ var crdbInternalZonesTable = virtualSchemaTable{ | ||
| schema: ` | ||
| CREATE TABLE crdb_internal.zones ( | ||
| zone_id INT NOT NULL, | ||
| zone_name STRING, | ||
| cli_specifier STRING, | ||
| config_yaml STRING NOT NULL, | ||
| config_sql STRING, -- this column can be NULL if there is no specifier syntax | ||
| @@ -195,10 +195,10 @@ SELECT * FROM crdb_internal.forward_dependencies WHERE descriptor_name = '' | ||
| ---- | ||
| descriptor_id descriptor_name index_id dependedonby_id dependedonby_type dependedonby_index_id dependedonby_name dependedonby_details | ||
| query ITTTT colnames | ||
| query ITTTTT colnames | ||
| SELECT * FROM crdb_internal.zones WHERE false | ||
| ---- | ||
| zone_id cli_specifier config_yaml config_sql config_protobuf | ||
| zone_id zone_name cli_specifier config_yaml config_sql config_protobuf | ||
| statement ok | ||
| INSERT INTO system.zones (id, config) VALUES | ||
| @@ -81,15 +81,15 @@ SELECT * FROM [SHOW DATABASE] | ||
| database | ||
| test | ||
| query ITTT colnames | ||
| query TT colnames | ||
| SELECT * FROM [SHOW ZONE CONFIGURATIONS] LIMIT 0 | ||
| ---- | ||
| zone_id cli_specifier config_sql config_protobuf | ||
| zone_name config_sql | ||
| query ITTT colnames | ||
| query TT colnames | ||
| SELECT * FROM [SHOW ZONE CONFIGURATION FOR TABLE system.users] LIMIT 0 | ||
| ---- | ||
| zone_id cli_specifier config_sql config_protobuf | ||
| zone_name config_sql | ||
| query T colnames | ||
| SELECT * FROM [SHOW DATABASES] | ||
| @@ -226,7 +226,7 @@ sort · · | ||
| ├── render · · | ||
| │ └── filter · · | ||
| │ └── values · · | ||
| │ size 20 columns, 926 rows | ||
| │ size 20 columns, 927 rows | ||
| └── render · · | ||
| └── filter · · | ||
| └── values · · | ||
| @@ -217,7 +217,7 @@ sort · · | ||
| ├── render · · | ||
| │ └── filter · · | ||
| │ └── values · · | ||
| │ size 20 columns, 926 rows | ||
| │ size 20 columns, 927 rows | ||
| └── render · · | ||
| └── filter · · | ||
| └── values · · | ||
| @@ -39,10 +39,15 @@ type showZoneConfigNode struct { | ||
| func (p *planner) ShowZoneConfig(ctx context.Context, n *tree.ShowZoneConfig) (planNode, error) { | ||
| if n.ZoneSpecifier == (tree.ZoneSpecifier{}) { | ||
| return p.delegateQuery(ctx, "SHOW ZONE CONFIGURATIONS", | ||
| `SELECT zone_id, cli_specifier, config_sql, config_protobuf | ||
| planNode, err := p.delegateQuery(ctx, "SHOW ZONE CONFIGURATIONS", | ||
| `SELECT cli_specifier as zone_name, cli_specifier, config_sql | ||
| FROM crdb_internal.zones | ||
| WHERE cli_specifier IS NOT NULL`, nil, nil) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| planNode.(*renderNode).columns[1].Hidden = true | ||
| return planNode, nil | ||
| } | ||
| return &showZoneConfigNode{ | ||
| zoneSpecifier: n.ZoneSpecifier, | ||
| @@ -51,11 +56,12 @@ func (p *planner) ShowZoneConfig(ctx context.Context, n *tree.ShowZoneConfig) (p | ||
| // These must match crdb_internal.zones. | ||
| var showZoneConfigNodeColumns = sqlbase.ResultColumns{ | ||
| {Name: "zone_id", Typ: types.Int}, | ||
| {Name: "cli_specifier", Typ: types.String}, | ||
| {Name: "zone_id", Typ: types.Int, Hidden: true}, | ||
| {Name: "zone_name", Typ: types.String}, | ||
| {Name: "cli_specifier", Typ: types.String, Hidden: true}, | ||
| {Name: "config_yaml", Typ: types.String, Hidden: true}, | ||
| {Name: "config_sql", Typ: types.String}, | ||
| {Name: "config_protobuf", Typ: types.Bytes}, | ||
| {Name: "config_protobuf", Typ: types.Bytes, Hidden: true}, | ||
| } | ||
| // showZoneConfigRun contains the run-time state of showZoneConfigNode | ||
| @@ -129,17 +135,18 @@ func generateZoneConfigIntrospectionValues( | ||
| } else { | ||
| values[1] = tree.NewDString(config.CLIZoneSpecifier(zs)) | ||
| } | ||
| values[2] = values[1] | ||
| // Populate the YAML column. | ||
| yamlConfig, err := yaml.Marshal(zone) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| values[2] = tree.NewDString(string(yamlConfig)) | ||
| values[3] = tree.NewDString(string(yamlConfig)) | ||
| // Populate the SQL column. | ||
| if zs == nil { | ||
| values[3] = tree.DNull | ||
| values[4] = tree.DNull | ||
| } else { | ||
| constraints, err := yamlMarshalFlow(config.ConstraintsList(zone.Constraints)) | ||
| if err != nil { | ||
| @@ -162,15 +169,15 @@ func generateZoneConfigIntrospectionValues( | ||
| f.Printf("\tnum_replicas = %d,\n", zone.NumReplicas) | ||
| f.Printf("\tconstraints = %s,\n", lex.EscapeSQLString(constraints)) | ||
| f.Printf("\tlease_preferences = %s", lex.EscapeSQLString(prefs)) | ||
| values[3] = tree.NewDString(f.String()) | ||
| values[4] = tree.NewDString(f.String()) | ||
| } | ||
| // Populate the protobuf column. | ||
| protoConfig, err := protoutil.Marshal(zone) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| values[4] = tree.NewDBytes(tree.DBytes(protoConfig)) | ||
| values[5] = tree.NewDBytes(tree.DBytes(protoConfig)) | ||
| return nil | ||
| } | ||
| @@ -111,7 +111,8 @@ func VerifyAllZoneConfigs(t testing.TB, sqlDB *SQLRunner, rows ...ZoneRow) { | ||
| } | ||
| sqlDB.CheckQueryResults(t, ` | ||
| SELECT zone_id, cli_specifier, config_protobuf | ||
| FROM [SHOW ALL ZONE CONFIGURATIONS]`, expected) | ||
| FROM crdb_internal.zones | ||
| WHERE cli_specifier IS NOT NULL`, expected) | ||
| } | ||
| // ZoneConfigExists returns whether a zone config with the provided cliSpecifier | ||