diff --git a/go/cmd/vtctldclient/internal/command/schema.go b/go/cmd/vtctldclient/internal/command/schema.go new file mode 100644 index 00000000000..da6493d156e --- /dev/null +++ b/go/cmd/vtctldclient/internal/command/schema.go @@ -0,0 +1,99 @@ +/* +Copyright 2021 The Vitess Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package command + +import ( + "errors" + "fmt" + "strings" + + "github.com/spf13/cobra" + + "vitess.io/vitess/go/cmd/vtctldclient/cli" + "vitess.io/vitess/go/vt/topo/topoproto" + + vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata" +) + +// GetSchema makes a GetSchema gRPC call to a vtctld. +var GetSchema = &cobra.Command{ + Use: "GetSchema [--tables TABLES ...] [--exclude-tables EXCLUDE_TABLES ...] [{--table-names-only | --table-sizes-only}] [--include-views] alias", + Args: cobra.ExactArgs(1), + RunE: commandGetSchema, +} + +var getSchemaOptions = struct { + Tables []string + ExcludeTables []string + IncludeViews bool + TableNamesOnly bool + TableSizesOnly bool +}{} + +func commandGetSchema(cmd *cobra.Command, args []string) error { + if getSchemaOptions.TableNamesOnly && getSchemaOptions.TableSizesOnly { + return errors.New("can only pass one of --table-names-only and --table-sizes-only") + } + + alias, err := topoproto.ParseTabletAlias(cmd.Flags().Arg(0)) + if err != nil { + return err + } + + resp, err := client.GetSchema(commandCtx, &vtctldatapb.GetSchemaRequest{ + TabletAlias: alias, + Tables: getSchemaOptions.Tables, + ExcludeTables: getSchemaOptions.ExcludeTables, + IncludeViews: getSchemaOptions.IncludeViews, + TableNamesOnly: getSchemaOptions.TableNamesOnly, + TableSizesOnly: getSchemaOptions.TableSizesOnly, + }) + if err != nil { + return err + } + + if getSchemaOptions.TableNamesOnly { + names := make([]string, len(resp.Schema.TableDefinitions)) + + for i, td := range resp.Schema.TableDefinitions { + names[i] = td.Name + } + + fmt.Printf("%s\n", strings.Join(names, "\n")) + + return nil + } + + data, err := cli.MarshalJSON(resp.Schema) + if err != nil { + return err + } + + fmt.Printf("%s\n", data) + + return nil +} + +func init() { + GetSchema.Flags().StringSliceVar(&getSchemaOptions.Tables, "tables", nil, "TODO") + GetSchema.Flags().StringSliceVar(&getSchemaOptions.ExcludeTables, "exclude-tables", nil, "TODO") + GetSchema.Flags().BoolVar(&getSchemaOptions.IncludeViews, "include-views", false, "TODO") + GetSchema.Flags().BoolVarP(&getSchemaOptions.TableNamesOnly, "table-names-only", "n", false, "TODO") + GetSchema.Flags().BoolVarP(&getSchemaOptions.TableSizesOnly, "table-sizes-only", "s", false, "TODO") + + Root.AddCommand(GetSchema) +} diff --git a/go/vt/proto/vtctldata/vtctldata.pb.go b/go/vt/proto/vtctldata/vtctldata.pb.go index 8fe25077cd4..0b7cdd5e83d 100644 --- a/go/vt/proto/vtctldata/vtctldata.pb.go +++ b/go/vt/proto/vtctldata/vtctldata.pb.go @@ -10,6 +10,7 @@ import ( proto "github.com/golang/protobuf/proto" duration "github.com/golang/protobuf/ptypes/duration" logutil "vitess.io/vitess/go/vt/proto/logutil" + tabletmanagerdata "vitess.io/vitess/go/vt/proto/tabletmanagerdata" topodata "vitess.io/vitess/go/vt/proto/topodata" vschema "vitess.io/vitess/go/vt/proto/vschema" ) @@ -480,6 +481,134 @@ func (m *GetKeyspaceResponse) GetKeyspace() *Keyspace { return nil } +type GetSchemaRequest struct { + TabletAlias *topodata.TabletAlias `protobuf:"bytes,1,opt,name=tablet_alias,json=tabletAlias,proto3" json:"tablet_alias,omitempty"` + // Tables is a list of tables for which we should gather information. Each is + // either an exact match, or a regular expression of the form /regexp/. + Tables []string `protobuf:"bytes,2,rep,name=tables,proto3" json:"tables,omitempty"` + // ExcludeTables is a list of tables to exclude from the result. Each is + // either an exact match, or a regular expression of the form /regexp/. + ExcludeTables []string `protobuf:"bytes,3,rep,name=exclude_tables,json=excludeTables,proto3" json:"exclude_tables,omitempty"` + // IncludeViews specifies whether to include views in the result. + IncludeViews bool `protobuf:"varint,4,opt,name=include_views,json=includeViews,proto3" json:"include_views,omitempty"` + // TableNamesOnly specifies whether to limit the results to just table names, + // rather than full schema information for each table. + TableNamesOnly bool `protobuf:"varint,5,opt,name=table_names_only,json=tableNamesOnly,proto3" json:"table_names_only,omitempty"` + // TableSizesOnly specifies whether to limit the results to just table sizes, + // rather than full schema information for each table. It is ignored if + // TableNamesOnly is set to true. + TableSizesOnly bool `protobuf:"varint,6,opt,name=table_sizes_only,json=tableSizesOnly,proto3" json:"table_sizes_only,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetSchemaRequest) Reset() { *m = GetSchemaRequest{} } +func (m *GetSchemaRequest) String() string { return proto.CompactTextString(m) } +func (*GetSchemaRequest) ProtoMessage() {} +func (*GetSchemaRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f41247b323a1ab2e, []int{12} +} + +func (m *GetSchemaRequest) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetSchemaRequest.Unmarshal(m, b) +} +func (m *GetSchemaRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetSchemaRequest.Marshal(b, m, deterministic) +} +func (m *GetSchemaRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetSchemaRequest.Merge(m, src) +} +func (m *GetSchemaRequest) XXX_Size() int { + return xxx_messageInfo_GetSchemaRequest.Size(m) +} +func (m *GetSchemaRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetSchemaRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetSchemaRequest proto.InternalMessageInfo + +func (m *GetSchemaRequest) GetTabletAlias() *topodata.TabletAlias { + if m != nil { + return m.TabletAlias + } + return nil +} + +func (m *GetSchemaRequest) GetTables() []string { + if m != nil { + return m.Tables + } + return nil +} + +func (m *GetSchemaRequest) GetExcludeTables() []string { + if m != nil { + return m.ExcludeTables + } + return nil +} + +func (m *GetSchemaRequest) GetIncludeViews() bool { + if m != nil { + return m.IncludeViews + } + return false +} + +func (m *GetSchemaRequest) GetTableNamesOnly() bool { + if m != nil { + return m.TableNamesOnly + } + return false +} + +func (m *GetSchemaRequest) GetTableSizesOnly() bool { + if m != nil { + return m.TableSizesOnly + } + return false +} + +type GetSchemaResponse struct { + Schema *tabletmanagerdata.SchemaDefinition `protobuf:"bytes,1,opt,name=schema,proto3" json:"schema,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func (m *GetSchemaResponse) Reset() { *m = GetSchemaResponse{} } +func (m *GetSchemaResponse) String() string { return proto.CompactTextString(m) } +func (*GetSchemaResponse) ProtoMessage() {} +func (*GetSchemaResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f41247b323a1ab2e, []int{13} +} + +func (m *GetSchemaResponse) XXX_Unmarshal(b []byte) error { + return xxx_messageInfo_GetSchemaResponse.Unmarshal(m, b) +} +func (m *GetSchemaResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + return xxx_messageInfo_GetSchemaResponse.Marshal(b, m, deterministic) +} +func (m *GetSchemaResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetSchemaResponse.Merge(m, src) +} +func (m *GetSchemaResponse) XXX_Size() int { + return xxx_messageInfo_GetSchemaResponse.Size(m) +} +func (m *GetSchemaResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetSchemaResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetSchemaResponse proto.InternalMessageInfo + +func (m *GetSchemaResponse) GetSchema() *tabletmanagerdata.SchemaDefinition { + if m != nil { + return m.Schema + } + return nil +} + type GetSrvVSchemaRequest struct { Cell string `protobuf:"bytes,1,opt,name=cell,proto3" json:"cell,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -491,7 +620,7 @@ func (m *GetSrvVSchemaRequest) Reset() { *m = GetSrvVSchemaRequest{} } func (m *GetSrvVSchemaRequest) String() string { return proto.CompactTextString(m) } func (*GetSrvVSchemaRequest) ProtoMessage() {} func (*GetSrvVSchemaRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f41247b323a1ab2e, []int{12} + return fileDescriptor_f41247b323a1ab2e, []int{14} } func (m *GetSrvVSchemaRequest) XXX_Unmarshal(b []byte) error { @@ -530,7 +659,7 @@ func (m *GetSrvVSchemaResponse) Reset() { *m = GetSrvVSchemaResponse{} } func (m *GetSrvVSchemaResponse) String() string { return proto.CompactTextString(m) } func (*GetSrvVSchemaResponse) ProtoMessage() {} func (*GetSrvVSchemaResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f41247b323a1ab2e, []int{13} + return fileDescriptor_f41247b323a1ab2e, []int{15} } func (m *GetSrvVSchemaResponse) XXX_Unmarshal(b []byte) error { @@ -569,7 +698,7 @@ func (m *GetTabletRequest) Reset() { *m = GetTabletRequest{} } func (m *GetTabletRequest) String() string { return proto.CompactTextString(m) } func (*GetTabletRequest) ProtoMessage() {} func (*GetTabletRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f41247b323a1ab2e, []int{14} + return fileDescriptor_f41247b323a1ab2e, []int{16} } func (m *GetTabletRequest) XXX_Unmarshal(b []byte) error { @@ -608,7 +737,7 @@ func (m *GetTabletResponse) Reset() { *m = GetTabletResponse{} } func (m *GetTabletResponse) String() string { return proto.CompactTextString(m) } func (*GetTabletResponse) ProtoMessage() {} func (*GetTabletResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f41247b323a1ab2e, []int{15} + return fileDescriptor_f41247b323a1ab2e, []int{17} } func (m *GetTabletResponse) XXX_Unmarshal(b []byte) error { @@ -654,7 +783,7 @@ func (m *GetTabletsRequest) Reset() { *m = GetTabletsRequest{} } func (m *GetTabletsRequest) String() string { return proto.CompactTextString(m) } func (*GetTabletsRequest) ProtoMessage() {} func (*GetTabletsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f41247b323a1ab2e, []int{16} + return fileDescriptor_f41247b323a1ab2e, []int{18} } func (m *GetTabletsRequest) XXX_Unmarshal(b []byte) error { @@ -707,7 +836,7 @@ func (m *GetTabletsResponse) Reset() { *m = GetTabletsResponse{} } func (m *GetTabletsResponse) String() string { return proto.CompactTextString(m) } func (*GetTabletsResponse) ProtoMessage() {} func (*GetTabletsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f41247b323a1ab2e, []int{17} + return fileDescriptor_f41247b323a1ab2e, []int{19} } func (m *GetTabletsResponse) XXX_Unmarshal(b []byte) error { @@ -750,7 +879,7 @@ func (m *InitShardPrimaryRequest) Reset() { *m = InitShardPrimaryRequest func (m *InitShardPrimaryRequest) String() string { return proto.CompactTextString(m) } func (*InitShardPrimaryRequest) ProtoMessage() {} func (*InitShardPrimaryRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f41247b323a1ab2e, []int{18} + return fileDescriptor_f41247b323a1ab2e, []int{20} } func (m *InitShardPrimaryRequest) XXX_Unmarshal(b []byte) error { @@ -817,7 +946,7 @@ func (m *InitShardPrimaryResponse) Reset() { *m = InitShardPrimaryRespon func (m *InitShardPrimaryResponse) String() string { return proto.CompactTextString(m) } func (*InitShardPrimaryResponse) ProtoMessage() {} func (*InitShardPrimaryResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f41247b323a1ab2e, []int{19} + return fileDescriptor_f41247b323a1ab2e, []int{21} } func (m *InitShardPrimaryResponse) XXX_Unmarshal(b []byte) error { @@ -857,7 +986,7 @@ func (m *Keyspace) Reset() { *m = Keyspace{} } func (m *Keyspace) String() string { return proto.CompactTextString(m) } func (*Keyspace) ProtoMessage() {} func (*Keyspace) Descriptor() ([]byte, []int) { - return fileDescriptor_f41247b323a1ab2e, []int{20} + return fileDescriptor_f41247b323a1ab2e, []int{22} } func (m *Keyspace) XXX_Unmarshal(b []byte) error { @@ -903,7 +1032,7 @@ func (m *FindAllShardsInKeyspaceRequest) Reset() { *m = FindAllShardsInK func (m *FindAllShardsInKeyspaceRequest) String() string { return proto.CompactTextString(m) } func (*FindAllShardsInKeyspaceRequest) ProtoMessage() {} func (*FindAllShardsInKeyspaceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f41247b323a1ab2e, []int{21} + return fileDescriptor_f41247b323a1ab2e, []int{23} } func (m *FindAllShardsInKeyspaceRequest) XXX_Unmarshal(b []byte) error { @@ -942,7 +1071,7 @@ func (m *FindAllShardsInKeyspaceResponse) Reset() { *m = FindAllShardsIn func (m *FindAllShardsInKeyspaceResponse) String() string { return proto.CompactTextString(m) } func (*FindAllShardsInKeyspaceResponse) ProtoMessage() {} func (*FindAllShardsInKeyspaceResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f41247b323a1ab2e, []int{22} + return fileDescriptor_f41247b323a1ab2e, []int{24} } func (m *FindAllShardsInKeyspaceResponse) XXX_Unmarshal(b []byte) error { @@ -983,7 +1112,7 @@ func (m *Shard) Reset() { *m = Shard{} } func (m *Shard) String() string { return proto.CompactTextString(m) } func (*Shard) ProtoMessage() {} func (*Shard) Descriptor() ([]byte, []int) { - return fileDescriptor_f41247b323a1ab2e, []int{23} + return fileDescriptor_f41247b323a1ab2e, []int{25} } func (m *Shard) XXX_Unmarshal(b []byte) error { @@ -1043,7 +1172,7 @@ func (m *TableMaterializeSettings) Reset() { *m = TableMaterializeSettin func (m *TableMaterializeSettings) String() string { return proto.CompactTextString(m) } func (*TableMaterializeSettings) ProtoMessage() {} func (*TableMaterializeSettings) Descriptor() ([]byte, []int) { - return fileDescriptor_f41247b323a1ab2e, []int{24} + return fileDescriptor_f41247b323a1ab2e, []int{26} } func (m *TableMaterializeSettings) XXX_Unmarshal(b []byte) error { @@ -1106,7 +1235,7 @@ func (m *MaterializeSettings) Reset() { *m = MaterializeSettings{} } func (m *MaterializeSettings) String() string { return proto.CompactTextString(m) } func (*MaterializeSettings) ProtoMessage() {} func (*MaterializeSettings) Descriptor() ([]byte, []int) { - return fileDescriptor_f41247b323a1ab2e, []int{25} + return fileDescriptor_f41247b323a1ab2e, []int{27} } func (m *MaterializeSettings) XXX_Unmarshal(b []byte) error { @@ -1190,6 +1319,8 @@ func init() { proto.RegisterType((*GetKeyspacesResponse)(nil), "vtctldata.GetKeyspacesResponse") proto.RegisterType((*GetKeyspaceRequest)(nil), "vtctldata.GetKeyspaceRequest") proto.RegisterType((*GetKeyspaceResponse)(nil), "vtctldata.GetKeyspaceResponse") + proto.RegisterType((*GetSchemaRequest)(nil), "vtctldata.GetSchemaRequest") + proto.RegisterType((*GetSchemaResponse)(nil), "vtctldata.GetSchemaResponse") proto.RegisterType((*GetSrvVSchemaRequest)(nil), "vtctldata.GetSrvVSchemaRequest") proto.RegisterType((*GetSrvVSchemaResponse)(nil), "vtctldata.GetSrvVSchemaResponse") proto.RegisterType((*GetTabletRequest)(nil), "vtctldata.GetTabletRequest") @@ -1210,69 +1341,77 @@ func init() { func init() { proto.RegisterFile("vtctldata.proto", fileDescriptor_f41247b323a1ab2e) } var fileDescriptor_f41247b323a1ab2e = []byte{ - // 1014 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x5b, 0x6f, 0x1b, 0x45, - 0x14, 0x96, 0x9d, 0x3a, 0xb5, 0x8f, 0xe3, 0x4b, 0x37, 0x09, 0xd9, 0x1a, 0x51, 0xc2, 0x42, 0x53, - 0x2b, 0x48, 0xeb, 0x12, 0x04, 0xaa, 0x10, 0x48, 0xa4, 0xa9, 0x5b, 0x99, 0xd2, 0xa8, 0xda, 0x44, - 0x45, 0x02, 0x89, 0xd5, 0x64, 0x3d, 0x76, 0x57, 0x19, 0xef, 0x2c, 0x3b, 0x63, 0xa7, 0xe6, 0x99, - 0x17, 0xfe, 0x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0xf7, - 0x16, 0xb1, 0xa4, 0x42, 0xf8, 0x31, 0x1f, 0x98, 0xd7, 0x60, 0xca, 0x07, 0x0b, 0x69, 0x7e, 0xe5, - 0x06, 0x79, 0x20, 0x67, 0xeb, 0x1a, 0xf8, 0xfc, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x93, 0x6a, - 0xd5, 0xb7, 0x07, 0x0a, 0x00, 0x00, + // 1144 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x56, 0x5b, 0x6f, 0x1b, 0x45, + 0x14, 0x96, 0x9d, 0xda, 0x8d, 0x8f, 0x63, 0xc7, 0xdd, 0x34, 0xcd, 0xd6, 0x88, 0x12, 0x36, 0x34, + 0xb5, 0x82, 0xb4, 0x2e, 0x41, 0xa0, 0x8a, 0x8b, 0x44, 0x9a, 0xa4, 0x55, 0x28, 0x0d, 0xd1, 0x26, + 0x0a, 0x12, 0x48, 0xac, 0x26, 0xeb, 0xb1, 0xbb, 0xca, 0x78, 0x67, 0xd9, 0x19, 0x3b, 0x71, 0x9f, + 0x79, 0xe1, 0xcf, 0xf0, 0xc8, 0x23, 0xbf, 0x0d, 0xcd, 0xcc, 0x99, 0xdd, 0x75, 0x2e, 0xe5, 0xf6, + 0xb6, 0xe7, 0x3b, 0xf7, 0x33, 0xe7, 0xb2, 0xb0, 0x3c, 0x95, 0x91, 0x64, 0x03, 0x22, 0x89, 0x9f, + 0x66, 0x5c, 0x72, 0xa7, 0x91, 0x03, 0xdd, 0x47, 0x23, 0xce, 0x47, 0x8c, 0xf6, 0x35, 0xe3, 0x6c, + 0x32, 0xec, 0x0f, 0x26, 0x19, 0x91, 0x31, 0x4f, 0x8c, 0x68, 0xb7, 0xc5, 0xf8, 0x68, 0x22, 0x63, + 0x86, 0xe4, 0x9a, 0x24, 0x67, 0x8c, 0xca, 0x31, 0x49, 0xc8, 0x88, 0x66, 0x85, 0xc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9c, 0xb9, 0x96, 0x82, 0x77, 0x14, 0xba, + 0xcb, 0xd3, 0x99, 0xf3, 0x2d, 0xb4, 0xf1, 0xae, 0x60, 0x9c, 0x6e, 0x4d, 0xb7, 0xcf, 0x46, 0xe9, + 0x39, 0x6f, 0xab, 0x6c, 0xd0, 0x32, 0xa7, 0xc7, 0x66, 0x68, 0xef, 0x41, 0xbd, 0xb8, 0x07, 0xa6, + 0xf8, 0x7a, 0x6f, 0xc8, 0x59, 0x4a, 0x85, 0x7b, 0xd7, 0x16, 0x5f, 0x61, 0x27, 0x0a, 0x7a, 0xde, + 0xfb, 0x71, 0x73, 0x1a, 0x4b, 0x2a, 0x84, 0x1f, 0xf3, 0xbe, 0xf9, 0xea, 0x8f, 0x78, 0x7f, 0x2a, + 0xcd, 0xcf, 0x73, 0x3f, 0x0f, 0xe4, 0xac, 0xae, 0x81, 0x4f, 0xff, 0x0a, 0x00, 0x00, 0xff, 0xff, + 0xde, 0x21, 0xc4, 0x18, 0x79, 0x0b, 0x00, 0x00, } diff --git a/go/vt/proto/vtctlservice/vtctlservice.pb.go b/go/vt/proto/vtctlservice/vtctlservice.pb.go index 5c69809d073..86f6bd31d38 100644 --- a/go/vt/proto/vtctlservice/vtctlservice.pb.go +++ b/go/vt/proto/vtctlservice/vtctlservice.pb.go @@ -29,31 +29,32 @@ const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package func init() { proto.RegisterFile("vtctlservice.proto", fileDescriptor_27055cdbb1148d2b) } var fileDescriptor_27055cdbb1148d2b = []byte{ - // 375 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0xdf, 0x4b, 0x02, 0x41, - 0x10, 0xc7, 0xeb, 0x21, 0xa1, 0xcd, 0x30, 0xa6, 0x87, 0xc0, 0xd2, 0xca, 0x28, 0xb0, 0xc0, 0x0b, - 0xfb, 0x0b, 0x4c, 0xca, 0x44, 0x90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0xb9, 0x9c, 0x90, 0xe0, - 0x7c, 0xbd, 0x49, 0x32, 0xe9, 0xad, 0x6c, 0x8a, 0xa4, 0x66, 0x55, 0x57, 0x9e, 0x9a, 0x35, 0x7d, - 0xcd, 0x65, 0x13, 0x56, 0xbe, 0x17, 0x96, 0xd7, 0x00, 0x81, 0xa1, 0x43, 0x4d, 0x79, 0x6a, 0xe4, - 0x4a, 0xd9, 0x67, 0xfb, 0x2d, 0x14, 0xbd, 0x28, 0x1e, 0xf4, 0xec, 0x31, 0xfa, 0x1c, 0x52, 0x3d, - 0x4b, 0x22, 0xa5, 0x67, 0xe6, 0x80, 0xb2, 0x3e, 0xb1, 0xdd, 0x16, 0x8a, 0x3e, 0x1f, 0x79, 0x28, - 0xe0, 0x78, 0xb5, 0x61, 0x51, 0x95, 0xb6, 0x93, 0x6c, 0xa8, 0x4c, 0x1d, 0xc6, 0x54, 0x99, 0x20, - 0x33, 0xad, 0xfe, 0x6e, 0xc9, 0x40, 0xf5, 0xd5, 0x6c, 0x07, 0xae, 0x48, 0x96, 0xf7, 0x39, 0x72, - 0x7d, 0x1e, 0xcd, 0x57, 0x56, 0x33, 0x0d, 0xb3, 0x56, 0x73, 0x3d, 0x23, 0xf5, 0xf7, 0x37, 0xc3, - 0x6a, 0xec, 0x0a, 0x24, 0xaa, 0xb9, 0xa1, 0xb5, 0xf8, 0x65, 0x7d, 0x84, 0x56, 0x2c, 0xac, 0xe4, - 0x2d, 0xb0, 0xf4, 0x97, 0x62, 0x94, 0x4b, 0x6a, 0x77, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x12, - 0x19, 0xd7, 0x32, 0x54, 0x04, 0x00, 0x00, + // 387 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x5f, 0x4f, 0xf2, 0x30, + 0x14, 0x87, 0xdf, 0xf7, 0x42, 0x8c, 0x15, 0x83, 0xa9,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ports to suppress errors if they are not otherwise used. @@ -182,6 +183,9 @@ type VtctldClient interface { GetKeyspace(ctx context.Context, in *vtctldata.GetKeyspaceRequest, opts ...grpc.CallOption) (*vtctldata.GetKeyspaceResponse, error) // GetKeyspaces returns the keyspace struct of all keyspaces in the topo. GetKeyspaces(ctx context.Context, in *vtctldata.GetKeyspacesRequest, opts ...grpc.CallOption) (*vtctldata.GetKeyspacesResponse, error) + // GetSchema returns the schema for a tablet, or just the schema for the + // specified tables in that tablet. + GetSchema(ctx context.Context, in *vtctldata.GetSchemaRequest, opts ...grpc.CallOption) (*vtctldata.GetSchemaResponse, error) // GetSrvVSchema returns a the SrvVSchema for a cell. GetSrvVSchema(ctx context.Context, in *vtctldata.GetSrvVSchemaRequest, opts ...grpc.CallOption) (*vtctldata.GetSrvVSchemaResponse, error) // GetTablet returns information about a tablet. @@ -259,6 +263,15 @@ func (c *vtctldClient) GetKeyspaces(ctx context.Context, in *vtctldata.GetKeyspa return out, nil } +func (c *vtctldClient) GetSchema(ctx context.Context, in *vtctldata.GetSchemaRequest, opts ...grpc.CallOption) (*vtctldata.GetSchemaResponse, error) { + out := new(vtctldata.GetSchemaResponse) + err := c.cc.Invoke(ctx, "/vtctlservice.Vtctld/GetSchema", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *vtctldClient) GetSrvVSchema(ctx context.Context, in *vtctldata.GetSrvVSchemaRequest, opts ...grpc.CallOption) (*vtctldata.GetSrvVSchemaResponse, error) { out := new(vtctldata.GetSrvVSchemaResponse) err := c.cc.Invoke(ctx, "/vtctlservice.Vtctld/GetSrvVSchema", in, out, opts...) @@ -312,6 +325,9 @@ type VtctldServer interface { GetKeyspace(context.Context, *vtctldata.GetKeyspaceRequest) (*vtctldata.GetKeyspaceResponse, error) // GetKeyspaces returns the keyspace struct of all keyspaces in the topo. GetKeyspaces(context.Context, *vtctldata.GetKeyspacesRequest) (*vtctldata.GetKeyspacesResponse, error) + // GetSchema returns the schema for a tablet, or just the schema for the + // specified tables in that tablet. + GetSchema(context.Context, *vtctldata.GetSchemaRequest) (*vtctldata.GetSchemaResponse, error) // GetSrvVSchema returns a the SrvVSchema for a cell. GetSrvVSchema(context.Context, *vtctldata.GetSrvVSchemaRequest) (*vtctldata.GetSrvVSchemaResponse, error) // GetTablet returns information about a tablet. @@ -349,6 +365,9 @@ func (*UnimplementedVtctldServer) GetKeyspace(ctx context.Context, req *vtctldat func (*UnimplementedVtctldServer) GetKeyspaces(ctx context.Context, req *vtctldata.GetKeyspacesRequest) (*vtctldata.GetKeyspacesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetKeyspaces not implemented") } +func (*UnimplementedVtctldServer) GetSchema(ctx context.Context, req *vtctldata.GetSchemaRequest) (*vtctldata.GetSchemaResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetSchema not implemented") +} func (*UnimplementedVtctldServer) GetSrvVSchema(ctx context.Context, req *vtctldata.GetSrvVSchemaRequest) (*vtctldata.GetSrvVSchemaResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetSrvVSchema not implemented") } @@ -474,6 +493,24 @@ func _Vtctld_GetKeyspaces_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +func _Vtctld_GetSchema_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(vtctldata.GetSchemaRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(VtctldServer).GetSchema(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/vtctlservice.Vtctld/GetSchema", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(VtctldServer).GetSchema(ctx, req.(*vtctldata.GetSchemaRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Vtctld_GetSrvVSchema_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(vtctldata.GetSrvVSchemaRequest) if err := dec(in); err != nil { @@ -574,6 +611,10 @@ var _Vtctld_serviceDesc = grpc.ServiceDesc{ MethodName: "GetKeyspaces", Handler: _Vtctld_GetKeyspaces_Handler, }, + { + MethodName: "GetSchema", + Handler: _Vtctld_GetSchema_Handler, + }, { MethodName: "GetSrvVSchema", Handler: _Vtctld_GetSrvVSchema_Handler, diff --git a/go/vt/vtadmin/api_test.go b/go/vt/vtadmin/api_test.go index fcd310b21b9..d2f7840d579 100644 --- a/go/vt/vtadmin/api_test.go +++ b/go/vt/vtadmin/api_test.go @@ -39,6 +39,7 @@ import ( "vitess.io/vitess/go/vt/vtctl/grpcvtctldserver" "vitess.io/vitess/go/vt/vtctl/grpcvtctldserver/testutil" "vitess.io/vitess/go/vt/vtctl/vtctldclient" + "vitess.io/vitess/go/vt/vttablet/tmclient" topodatapb "vitess.io/vitess/go/vt/proto/topodata" vtadminpb "vitess.io/vitess/go/vt/proto/vtadmin" @@ -46,6 +47,10 @@ import ( "vitess.io/vitess/go/vt/proto/vttime" ) +func init() { + *tmclient.TabletManagerProtocol = testutil.TabletManagerClientProtocol +} + func TestGetGates(t *testing.T) { fakedisco1 := fakediscovery.New() cluster1 := &cluster.Cluster{ diff --git a/go/vt/vtctl/endtoend/get_schema_test.go b/go/vt/vtctl/endtoend/get_schema_test.go index ddb0c204048..1e93ce633c3 100644 --- a/go/vt/vtctl/endtoend/get_schema_test.go +++ b/go/vt/vtctl/endtoend/get_schema_test.go @@ -2,7 +2,6 @@ package endtoend import ( "context" - "fmt" "testing" "github.com/google/uuid" @@ -14,7 +13,7 @@ import ( "vitess.io/vitess/go/vt/topo/memorytopo" "vitess.io/vitess/go/vt/topo/topoproto" "vitess.io/vitess/go/vt/vtctl" - "vitess.io/vitess/go/vt/vttablet/faketmclient" + "vitess.io/vitess/go/vt/vtctl/grpcvtctldserver/testutil" "vitess.io/vitess/go/vt/vttablet/tmclient" "vitess.io/vitess/go/vt/wrangler" @@ -23,29 +22,6 @@ import ( topodatapb "vitess.io/vitess/go/vt/proto/topodata" ) -type fakeTabletManagerClient struct { - tmclient.TabletManagerClient - schemas map[string]*tabletmanagerdatapb.SchemaDefinition -} - -func newTMClient() *fakeTabletManagerClient { - return &fakeTabletManagerClient{ - TabletManagerClient: faketmclient.NewFakeTabletManagerClient(), - schemas: map[string]*tabletmanagerdatapb.SchemaDefinition{}, - } -} - -func (c *fakeTabletManagerClient) GetSchema(ctx context.Context, tablet *topodatapb.Tablet, tablets []string, excludeTables []string, includeViews bool) (*tabletmanagerdatapb.SchemaDefinition, error) { - key := topoproto.TabletAliasString(tablet.Alias) - - schema, ok := c.schemas[key] - if !ok { - return nil, fmt.Errorf("no schemas for %s", key) - } - - return schema, nil -} - func TestGetSchema(t *testing.T) { ctx := context.Background() @@ -162,8 +138,10 @@ func TestGetSchema(t *testing.T) { }, } - tmc := newTMClient() - tmc.schemas[topoproto.TabletAliasString(tablet.Alias)] = sd + tmc := testutil.TabletManagerClient + tmc.Schemas[topoproto.TabletAliasString(tablet.Alias)] = sd + + *tmclient.TabletManagerProtocol = testutil.TabletManagerClientProtocol logger := logutil.NewMemoryLogger() diff --git a/go/vt/vtctl/grpcvtctldclient/client_gen.go b/go/vt/vtctl/grpcvtctldclient/client_gen.go index 382a6984ba1..0743ed1e3c4 100644 --- a/go/vt/vtctl/grpcvtctldclient/client_gen.go +++ b/go/vt/vtctl/grpcvtctldclient/client_gen.go @@ -82,6 +82,15 @@ func (client *gRPCVtctldClient) GetKeyspaces(ctx context.Context, in *vtctldatap return client.c.GetKeyspaces(ctx, in, opts...) } +// GetSchema is part of the vtctlservicepb.VtctldClient interface. +func (client *gRPCVtctldClient) GetSchema(ctx context.Context, in *vtctldatapb.GetSchemaRequest, opts ...grpc.CallOption) (*vtctldatapb.GetSchemaResponse, error) { + if client.c == nil { + return nil, status.Error(codes.Unavailable, connClosedMsg) + } + + return client.c.GetSchema(ctx, in, opts...) +} + // GetSrvVSchema is part of the vtctlservicepb.VtctldClient interface. func (client *gRPCVtctldClient) GetSrvVSchema(ctx context.Context, in *vtctldatapb.GetSrvVSchemaRequest, opts ...grpc.CallOption) (*vtctldatapb.GetSrvVSchemaResponse, error) { if client.c == nil { diff --git a/go/vt/vtctl/grpcvtctldserver/server.go b/go/vt/vtctl/grpcvtctldserver/server.go index 91677e7c9d7..57bd6026055 100644 --- a/go/vt/vtctl/grpcvtctldserver/server.go +++ b/go/vt/vtctl/grpcvtctldserver/server.go @@ -38,6 +38,7 @@ import ( "vitess.io/vitess/go/vt/vttablet/tmclient" logutilpb "vitess.io/vitess/go/vt/proto/logutil" + tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata" topodatapb "vitess.io/vitess/go/vt/proto/topodata" vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata" vtctlservicepb "vitess.io/vitess/go/vt/proto/vtctlservice" @@ -50,12 +51,13 @@ const ( // VtctldServer implements the Vtctld RPC service protocol. type VtctldServer struct { - ts *topo.Server + ts *topo.Server + tmc tmclient.TabletManagerClient } // NewVtctldServer returns a new VtctldServer for the given topo server. func NewVtctldServer(ts *topo.Server) *VtctldServer { - return &VtctldServer{ts: ts} + return &VtctldServer{ts: ts, tmc: tmclient.NewTabletManagerClient()} } // FindAllShardsInKeyspace is part of the vtctlservicepb.VtctldServer interface. @@ -153,6 +155,48 @@ func (s *VtctldServer) GetKeyspaces(ctx context.Context, req *vtctldatapb.GetKey return &vtctldatapb.GetKeyspacesResponse{Keyspaces: keyspaces}, nil } +// GetSchema is part of the vtctlservicepb.VtctldServer interface. +func (s *VtctldServer) GetSchema(ctx context.Context, req *vtctldatapb.GetSchemaRequest) (*vtctldatapb.GetSchemaResponse, error) { + tablet, err := s.ts.GetTablet(ctx, req.TabletAlias) + if err != nil { + return nil, fmt.Errorf("GetTablet(%v) failed: %w", req.TabletAlias, err) + } + + sd, err := s.tmc.GetSchema(ctx, tablet.Tablet, req.Tables, req.ExcludeTables, req.IncludeViews) + if err != nil { + return nil, fmt.Errorf("GetSchema(%v, %v, %v, %v) failed: %w", tablet.Tablet, req.Tables, req.ExcludeTables, req.IncludeViews, err) + } + + if req.TableNamesOnly { + nameTds := make([]*tabletmanagerdatapb.TableDefinition, len(sd.TableDefinitions)) + + for i, td := range sd.TableDefinitions { + nameTds[i] = &tabletmanagerdatapb.TableDefinition{ + Name: td.Name, + } + } + + sd.TableDefinitions = nameTds + } else if req.TableSizesOnly { + sizeTds := make([]*tabletmanagerdatapb.TableDefinition, len(sd.TableDefinitions)) + + for i, td := range sd.TableDefinitions { + sizeTds[i] = &tabletmanagerdatapb.TableDefinition{ + Name: td.Name, + Type: td.Type, + RowCount: td.RowCount, + DataLength: td.DataLength, + } + } + + sd.TableDefinitions = sizeTds + } + + return &vtctldatapb.GetSchemaResponse{ + Schema: sd, + }, nil +} + // GetSrvVSchema is part of the vtctlservicepb.VtctldServer interface. func (s *VtctldServer) GetSrvVSchema(ctx context.Context, req *vtctldatapb.GetSrvVSchemaRequest) (*vtctldatapb.GetSrvVSchemaResponse, error) { vschema, err := s.ts.GetSrvVSchema(ctx, req.Cell) diff --git a/go/vt/vtctl/grpcvtctldserver/server_test.go b/go/vt/vtctl/grpcvtctldserver/server_test.go index bb5a4f867ca..cdc6003e80c 100644 --- a/go/vt/vtctl/grpcvtctldserver/server_test.go +++ b/go/vt/vtctl/grpcvtctldserver/server_test.go @@ -28,13 +28,21 @@ import ( "vitess.io/vitess/go/vt/logutil" "vitess.io/vitess/go/vt/topo/memorytopo" + "vitess.io/vitess/go/vt/topo/topoproto" "vitess.io/vitess/go/vt/vtctl/grpcvtctldserver/testutil" + "vitess.io/vitess/go/vt/vttablet/tmclient" + querypb "vitess.io/vitess/go/vt/proto/query" + tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata" topodatapb "vitess.io/vitess/go/vt/proto/topodata" vschemapb "vitess.io/vitess/go/vt/proto/vschema" vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata" ) +func init() { + *tmclient.TabletManagerProtocol = testutil.TabletManagerClientProtocol +} + func TestFindAllShardsInKeyspace(t *testing.T) { ctx := context.Background() ts := memorytopo.NewServer("cell1") @@ -259,6 +267,185 @@ func TestGetTablet(t *testing.T) { assert.Error(t, err) } +func TestGetSchema(t *testing.T) { + ctx := context.Background() + ts := memorytopo.NewServer("zone1") + vtctld := NewVtctldServer(ts) + + validAlias := &topodatapb.TabletAlias{ + Cell: "zone1", + Uid: 100, + } + testutil.AddTablet(ctx, t, ts, &topodatapb.Tablet{ + Alias: validAlias, + }) + otherAlias := &topodatapb.TabletAlias{ + Cell: "zone1", + Uid: 101, + } + testutil.AddTablet(ctx, t, ts, &topodatapb.Tablet{ + Alias: otherAlias, + }) + + // we need to run this on each test case or they will pollute each other + setupSchema := func() { + testutil.TabletManagerClient.Schemas[topoproto.TabletAliasString(validAlias)] = &tabletmanagerdatapb.SchemaDefinition{ + DatabaseSchema: "CREATE DATABASE vt_testkeyspace", + TableDefinitions: []*tabletmanagerdatapb.TableDefinition{ + { + Name: "t1", + Schema: `CREATE TABLE t1 ( + id int(11) not null, + PRIMARY KEY (id) +);`, + Type: "BASE", + Columns: []string{"id"}, + DataLength: 100, + RowCount: 50, + Fields: []*querypb.Field{ + { + Name: "id", + Type: querypb.Type_INT32, + }, + }, + }, + }, + } + } + + tests := []*struct { + name string + req *vtctldatapb.GetSchemaRequest + expected *vtctldatapb.GetSchemaResponse + shouldErr bool + }{ + { + name: "normal path", + req: &vtctldatapb.GetSchemaRequest{ + TabletAlias: validAlias, + }, + expected: &vtctldatapb.GetSchemaResponse{ + Schema: &tabletmanagerdatapb.SchemaDefinition{ + DatabaseSchema: "CREATE DATABASE vt_testkeyspace", + TableDefinitions: []*tabletmanagerdatapb.TableDefinition{ + { + Name: "t1", + Schema: `CREATE TABLE t1 ( + id int(11) not null, + PRIMARY KEY (id) +);`, + Type: "BASE", + Columns: []string{"id"}, + DataLength: 100, + RowCount: 50, + Fields: []*querypb.Field{ + { + Name: "id", + Type: querypb.Type_INT32, + }, + }, + }, + }, + }, + }, + shouldErr: false, + }, + { + name: "table names only", + req: &vtctldatapb.GetSchemaRequest{ + TabletAlias: validAlias, + TableNamesOnly: true, + }, + expected: &vtctldatapb.GetSchemaResponse{ + Schema: &tabletmanagerdatapb.SchemaDefinition{ + DatabaseSchema: "CREATE DATABASE vt_testkeyspace", + TableDefinitions: []*tabletmanagerdatapb.TableDefinition{ + { + Name: "t1", + }, + }, + }, + }, + shouldErr: false, + }, + { + name: "table sizes only", + req: &vtctldatapb.GetSchemaRequest{ + TabletAlias: validAlias, + TableSizesOnly: true, + }, + expected: &vtctldatapb.GetSchemaResponse{ + Schema: &tabletmanagerdatapb.SchemaDefinition{ + DatabaseSchema: "CREATE DATABASE vt_testkeyspace", + TableDefinitions: []*tabletmanagerdatapb.TableDefinition{ + { + Name: "t1", + Type: "BASE", + DataLength: 100, + RowCount: 50, + }, + }, + }, + }, + shouldErr: false, + }, + { + name: "table names take precedence over table sizes", + req: &vtctldatapb.GetSchemaRequest{ + TabletAlias: validAlias, + TableNamesOnly: true, + TableSizesOnly: true, + }, + expected: &vtctldatapb.GetSchemaResponse{ + Schema: &tabletmanagerdatapb.SchemaDefinition{ + DatabaseSchema: "CREATE DATABASE vt_testkeyspace", + TableDefinitions: []*tabletmanagerdatapb.TableDefinition{ + { + Name: "t1", + }, + }, + }, + }, + shouldErr: false, + }, + // error cases + { + name: "no tablet", + req: &vtctldatapb.GetSchemaRequest{ + TabletAlias: &topodatapb.TabletAlias{ + Cell: "notfound", + Uid: 100, + }, + }, + expected: nil, + shouldErr: true, + }, + { + name: "no schema", + req: &vtctldatapb.GetSchemaRequest{ + TabletAlias: otherAlias, + }, + expected: nil, + shouldErr: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + setupSchema() + + resp, err := vtctld.GetSchema(ctx, tt.req) + if tt.shouldErr { + assert.Error(t, err) + return + } + + assert.NoError(t, err) + assert.Equal(t, tt.expected, resp) + }) + } +} + func TestGetSrvVSchema(t *testing.T) { ctx := context.Background() ts, topofactory := memorytopo.NewServerAndFactory("zone1", "zone2") diff --git a/go/vt/vtctl/grpcvtctldserver/testutil/test_tmclient.go b/go/vt/vtctl/grpcvtctldserver/testutil/test_tmclient.go new file mode 100644 index 00000000000..facaaf4f5bc --- /dev/null +++ b/go/vt/vtctl/grpcvtctldserver/testutil/test_tmclient.go @@ -0,0 +1,64 @@ +/* +Copyright 2021 The Vitess Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package testutil + +import ( + "context" + "fmt" + + "vitess.io/vitess/go/vt/topo/topoproto" + "vitess.io/vitess/go/vt/vttablet/tmclient" + + tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata" + topodatapb "vitess.io/vitess/go/vt/proto/topodata" +) + +// TestTabletManagerClient implements the tmclient.TabletManagerClient for +// testing. It allows users to mock various tmclient methods. +type TestTabletManagerClient struct { + tmclient.TabletManagerClient + Schemas map[string]*tabletmanagerdatapb.SchemaDefinition +} + +// GetSchema is part of the tmclient.TabletManagerClient interface. +func (c *TestTabletManagerClient) GetSchema(ctx context.Context, tablet *topodatapb.Tablet, tablets []string, excludeTables []string, includeViews bool) (*tabletmanagerdatapb.SchemaDefinition, error) { + key := topoproto.TabletAliasString(tablet.Alias) + + schema, ok := c.Schemas[key] + if !ok { + return nil, fmt.Errorf("no schemas for %s", key) + } + + return schema, nil +} + +// TabletManagerClientProtocol is the protocol this package registers its client +// test implementation under. Users should set *tmclient.TabletManagerProtocol +// to this value before use. +const TabletManagerClientProtocol = "grpcvtctldserver.testutil" + +// TabletManagerClient is the singleton test client instance. It is public and +// singleton to allow tests to mutate and verify its state. +var TabletManagerClient = &TestTabletManagerClient{ + Schemas: map[string]*tabletmanagerdatapb.SchemaDefinition{}, +} + +func init() { + tmclient.RegisterTabletManagerClientFactory(TabletManagerClientProtocol, func() tmclient.TabletManagerClient { + return TabletManagerClient + }) +} diff --git a/go/vt/vtctl/vtctl.go b/go/vt/vtctl/vtctl.go index 05f7a10e8b5..127f6783fcf 100644 --- a/go/vt/vtctl/vtctl.go +++ b/go/vt/vtctl/vtctl.go @@ -118,7 +118,6 @@ import ( "vitess.io/vitess/go/vt/wrangler" replicationdatapb "vitess.io/vitess/go/vt/proto/replicationdata" - tabletmanagerdatapb "vitess.io/vitess/go/vt/proto/tabletmanagerdata" topodatapb "vitess.io/vitess/go/vt/proto/topodata" vschemapb "vitess.io/vitess/go/vt/proto/vschema" vtctldatapb "vitess.io/vitess/go/vt/proto/vtctldata" @@ -2673,32 +2672,26 @@ func commandGetSchema(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag excludeTableArray = strings.Split(*excludeTables, ",") } - sd, err := wr.GetSchema(ctx, tabletAlias, tableArray, excludeTableArray, *includeViews) + resp, err := wr.VtctldServer().GetSchema(ctx, &vtctldatapb.GetSchemaRequest{ + TabletAlias: tabletAlias, + Tables: tableArray, + ExcludeTables: excludeTableArray, + IncludeViews: *includeViews, + TableNamesOnly: *tableNamesOnly, + TableSizesOnly: *tableSizesOnly, + }) if err != nil { return err } + if *tableNamesOnly { - for _, td := range sd.TableDefinitions { + for _, td := range resp.Schema.TableDefinitions { wr.Logger().Printf("%v\n", td.Name) } return nil } - if *tableSizesOnly { - sizeTds := make([]*tabletmanagerdatapb.TableDefinition, len(sd.TableDefinitions)) - for i, td := range sd.TableDefinitions { - sizeTds[i] = &tabletmanagerdatapb.TableDefinition{ - Name: td.Name, - Type: td.Type, - RowCount: td.RowCount, - DataLength: td.DataLength, - } - } - - sd.TableDefinitions = sizeTds - } - - return printJSON(wr.Logger(), sd) + return printJSON(wr.Logger(), resp.Schema) } func commandReloadSchema(ctx context.Context, wr *wrangler.Wrangler, subFlags *flag.FlagSet, args []string) error { diff --git a/proto/vtctldata.proto b/proto/vtctldata.proto index 2043891b995..1336d019130 100644 --- a/proto/vtctldata.proto +++ b/proto/vtctldata.proto @@ -25,6 +25,7 @@ package vtctldata; import "google/protobuf/duration.proto"; import "logutil.proto"; +import "tabletmanagerdata.proto"; import "topodata.proto"; import "vschema.proto"; @@ -77,6 +78,29 @@ message GetKeyspaceResponse { Keyspace keyspace = 1; } +message GetSchemaRequest { + topodata.TabletAlias tablet_alias = 1; + // Tables is a list of tables for which we should gather information. Each is + // either an exact match, or a regular expression of the form /regexp/. + repeated string tables = 2; + // ExcludeTables is a list of tables to exclude from the result. Each is + // either an exact match, or a regular expression of the form /regexp/. + repeated string exclude_tables = 3; + // IncludeViews specifies whether to include views in the result. + bool include_views = 4; + // TableNamesOnly specifies whether to limit the results to just table names, + // rather than full schema information for each table. + bool table_names_only = 5; + // TableSizesOnly specifies whether to limit the results to just table sizes, + // rather than full schema information for each table. It is ignored if + // TableNamesOnly is set to true. + bool table_sizes_only = 6; +} + +message GetSchemaResponse { + tabletmanagerdata.SchemaDefinition schema = 1; +} + message GetSrvVSchemaRequest { string cell = 1; } diff --git a/proto/vtctlservice.proto b/proto/vtctlservice.proto index 95b403df47f..6e659b922ea 100644 --- a/proto/vtctlservice.proto +++ b/proto/vtctlservice.proto @@ -46,6 +46,9 @@ service Vtctld { rpc GetKeyspace(vtctldata.GetKeyspaceRequest) returns (vtctldata.GetKeyspaceResponse) {}; // GetKeyspaces returns the keyspace struct of all keyspaces in the topo. rpc GetKeyspaces(vtctldata.GetKeyspacesRequest) returns (vtctldata.GetKeyspacesResponse) {}; + // GetSchema returns the schema for a tablet, or just the schema for the + // specified tables in that tablet. + rpc GetSchema(vtctldata.GetSchemaRequest) returns (vtctldata.GetSchemaResponse) {}; // GetSrvVSchema returns a the SrvVSchema for a cell. rpc GetSrvVSchema(vtctldata.GetSrvVSchemaRequest) returns (vtctldata.GetSrvVSchemaResponse) {}; // GetTablet returns information about a tablet.