From f96ca39609149fac9c8d379b0f3adbff9398dca9 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 19 Jul 2023 13:06:08 +0530 Subject: [PATCH 1/7] feat: add foreign key mode in vschema configuration on a keyspace level Signed-off-by: Manan Gupta --- go/vt/proto/vschema/vschema.pb.go | 317 +++++++++++++--------- go/vt/proto/vschema/vschema_vtproto.pb.go | 27 ++ proto/vschema.proto | 8 + web/vtadmin/src/proto/vtadmin.d.ts | 16 ++ web/vtadmin/src/proto/vtadmin.js | 63 +++++ 5 files changed, 308 insertions(+), 123 deletions(-) diff --git a/go/vt/proto/vschema/vschema.pb.go b/go/vt/proto/vschema/vschema.pb.go index 6273229a60e..1390e27d404 100644 --- a/go/vt/proto/vschema/vschema.pb.go +++ b/go/vt/proto/vschema/vschema.pb.go @@ -38,6 +38,55 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type Keyspace_ForeignKeyMode int32 + +const ( + Keyspace_Fk_unmanaged Keyspace_ForeignKeyMode = 0 + Keyspace_Fk_disallow Keyspace_ForeignKeyMode = 1 + Keyspace_Fk_managed Keyspace_ForeignKeyMode = 2 +) + +// Enum value maps for Keyspace_ForeignKeyMode. +var ( + Keyspace_ForeignKeyMode_name = map[int32]string{ + 0: "Fk_unmanaged", + 1: "Fk_disallow", + 2: "Fk_managed", + } + Keyspace_ForeignKeyMode_value = map[string]int32{ + "Fk_unmanaged": 0, + "Fk_disallow": 1, + "Fk_managed": 2, + } +) + +func (x Keyspace_ForeignKeyMode) Enum() *Keyspace_ForeignKeyMode { + p := new(Keyspace_ForeignKeyMode) + *p = x + return p +} + +func (x Keyspace_ForeignKeyMode) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Keyspace_ForeignKeyMode) Descriptor() protoreflect.EnumDescriptor { + return file_vschema_proto_enumTypes[0].Descriptor() +} + +func (Keyspace_ForeignKeyMode) Type() protoreflect.EnumType { + return &file_vschema_proto_enumTypes[0] +} + +func (x Keyspace_ForeignKeyMode) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Keyspace_ForeignKeyMode.Descriptor instead. +func (Keyspace_ForeignKeyMode) EnumDescriptor() ([]byte, []int) { + return file_vschema_proto_rawDescGZIP(), []int{2, 0} +} + // RoutingRules specify the high level routing rules for the VSchema. type RoutingRules struct { state protoimpl.MessageState @@ -157,6 +206,8 @@ type Keyspace struct { Tables map[string]*Table `protobuf:"bytes,3,rep,name=tables,proto3" json:"tables,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` // If require_explicit_routing is true, vindexes and tables are not added to global routing RequireExplicitRouting bool `protobuf:"varint,4,opt,name=require_explicit_routing,json=requireExplicitRouting,proto3" json:"require_explicit_routing,omitempty"` + // foreign_key_mode dictates how Vitess should handle foreign keys for this keyspace. + ForeignKeyMode Keyspace_ForeignKeyMode `protobuf:"varint,5,opt,name=foreign_key_mode,json=foreignKeyMode,proto3,enum=vschema.Keyspace_ForeignKeyMode" json:"foreign_key_mode,omitempty"` } func (x *Keyspace) Reset() { @@ -219,6 +270,13 @@ func (x *Keyspace) GetRequireExplicitRouting() bool { return false } +func (x *Keyspace) GetForeignKeyMode() Keyspace_ForeignKeyMode { + if x != nil { + return x.ForeignKeyMode + } + return Keyspace_Fk_unmanaged +} + // Vindex is the vindex info for a Keyspace. type Vindex struct { state protoimpl.MessageState @@ -779,7 +837,7 @@ var file_vschema_proto_rawDesc = []byte{ 0x12, 0x1d, 0x0a, 0x0a, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x66, 0x72, 0x6f, 0x6d, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x6f, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x08, 0x74, 0x6f, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x22, 0xeb, 0x02, 0x0a, + 0x28, 0x09, 0x52, 0x08, 0x74, 0x6f, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x22, 0xfc, 0x03, 0x0a, 0x08, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x68, 0x61, 0x72, 0x64, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x68, 0x61, 0x72, 0x64, 0x65, 0x64, 0x12, 0x3b, 0x0a, 0x08, 0x76, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x18, @@ -793,92 +851,101 @@ var file_vschema_proto_rawDesc = []byte{ 0x72, 0x65, 0x5f, 0x65, 0x78, 0x70, 0x6c, 0x69, 0x63, 0x69, 0x74, 0x5f, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x16, 0x72, 0x65, 0x71, 0x75, 0x69, 0x72, 0x65, 0x45, 0x78, 0x70, 0x6c, 0x69, 0x63, 0x69, 0x74, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, - 0x67, 0x1a, 0x4c, 0x0a, 0x0d, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x45, 0x6e, 0x74, - 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x03, 0x6b, 0x65, 0x79, 0x12, 0x25, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x56, 0x69, - 0x6e, 0x64, 0x65, 0x78, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, - 0x49, 0x0a, 0x0b, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, + 0x67, 0x12, 0x4a, 0x0a, 0x10, 0x66, 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x5f, 0x6b, 0x65, 0x79, + 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x20, 0x2e, 0x76, 0x73, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x2e, 0x46, + 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x4b, 0x65, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x52, 0x0e, 0x66, + 0x6f, 0x72, 0x65, 0x69, 0x67, 0x6e, 0x4b, 0x65, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x1a, 0x4c, 0x0a, + 0x0d, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, - 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0e, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, - 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0xa2, 0x01, 0x0a, 0x06, 0x56, - 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x70, 0x61, 0x72, - 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x73, 0x63, 0x68, - 0x65, 0x6d, 0x61, 0x2e, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x50, 0x61, 0x72, 0x61, 0x6d, - 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, 0x14, - 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x6f, - 0x77, 0x6e, 0x65, 0x72, 0x1a, 0x39, 0x0a, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, - 0xb1, 0x02, 0x0a, 0x05, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x3e, 0x0a, - 0x0f, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x5f, 0x76, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, - 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, - 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0e, 0x63, - 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x12, 0x3d, 0x0a, - 0x0e, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, - 0x41, 0x75, 0x74, 0x6f, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0d, 0x61, - 0x75, 0x74, 0x6f, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x29, 0x0a, 0x07, - 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, - 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, 0x07, - 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x69, 0x6e, 0x6e, 0x65, - 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, 0x12, - 0x3a, 0x0a, 0x19, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x61, - 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x61, 0x74, 0x69, 0x76, 0x65, 0x18, 0x06, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x17, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x75, - 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x61, 0x74, 0x69, 0x76, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x73, - 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, - 0x72, 0x63, 0x65, 0x22, 0x54, 0x0a, 0x0c, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x56, 0x69, 0x6e, - 0x64, 0x65, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, - 0x52, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x22, 0x43, 0x0a, 0x0d, 0x41, 0x75, 0x74, - 0x6f, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, - 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, - 0x6d, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, 0x3d, - 0x0a, 0x06, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, 0x04, - 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, 0x2e, 0x71, 0x75, 0x65, - 0x72, 0x79, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xa7, 0x02, - 0x0a, 0x0a, 0x53, 0x72, 0x76, 0x56, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x40, 0x0a, 0x09, - 0x6b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, - 0x22, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x53, 0x72, 0x76, 0x56, 0x53, 0x63, - 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x52, 0x09, 0x6b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x12, 0x3a, - 0x0a, 0x0d, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, - 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, - 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x0c, 0x72, 0x6f, - 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x4a, 0x0a, 0x13, 0x73, 0x68, - 0x61, 0x72, 0x64, 0x5f, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6c, 0x65, - 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, - 0x61, 0x2e, 0x53, 0x68, 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, - 0x6c, 0x65, 0x73, 0x52, 0x11, 0x73, 0x68, 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, - 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x1a, 0x4f, 0x0a, 0x0e, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x27, 0x0a, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x76, 0x73, 0x63, 0x68, - 0x65, 0x6d, 0x61, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x05, 0x76, 0x61, - 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x44, 0x0a, 0x11, 0x53, 0x68, 0x61, 0x72, 0x64, - 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x2f, 0x0a, 0x05, - 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x76, 0x73, - 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x53, 0x68, 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, - 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x22, 0x6e, 0x0a, - 0x10, 0x53, 0x68, 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, - 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x6b, 0x65, 0x79, 0x73, 0x70, 0x61, - 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, 0x6f, 0x6d, 0x4b, 0x65, - 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x6f, 0x5f, 0x6b, 0x65, 0x79, - 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x6f, 0x4b, - 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x68, 0x61, 0x72, 0x64, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x68, 0x61, 0x72, 0x64, 0x42, 0x26, 0x5a, - 0x24, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2e, 0x69, 0x6f, 0x2f, 0x76, 0x69, 0x74, 0x65, 0x73, - 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x76, 0x73, - 0x63, 0x68, 0x65, 0x6d, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x12, 0x25, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, + 0x0f, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, + 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x49, 0x0a, 0x0b, 0x54, + 0x61, 0x62, 0x6c, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, + 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x05, + 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x76, 0x73, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x43, 0x0a, 0x0e, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, + 0x6e, 0x4b, 0x65, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x0c, 0x46, 0x6b, 0x5f, 0x75, + 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x46, 0x6b, + 0x5f, 0x64, 0x69, 0x73, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x46, + 0x6b, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x10, 0x02, 0x22, 0xa2, 0x01, 0x0a, 0x06, + 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x70, 0x61, + 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x73, 0x63, + 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x2e, 0x50, 0x61, 0x72, 0x61, + 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, + 0x14, 0x0a, 0x05, 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x6f, 0x77, 0x6e, 0x65, 0x72, 0x1a, 0x39, 0x0a, 0x0b, 0x50, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, + 0x22, 0xb1, 0x02, 0x0a, 0x05, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, + 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x3e, + 0x0a, 0x0f, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x5f, 0x76, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, + 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, + 0x61, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x0e, + 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x12, 0x3d, + 0x0a, 0x0e, 0x61, 0x75, 0x74, 0x6f, 0x5f, 0x69, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, + 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x0d, + 0x61, 0x75, 0x74, 0x6f, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x29, 0x0a, + 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, + 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x52, + 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x70, 0x69, 0x6e, 0x6e, + 0x65, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x70, 0x69, 0x6e, 0x6e, 0x65, 0x64, + 0x12, 0x3a, 0x0a, 0x19, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x5f, 0x6c, 0x69, 0x73, 0x74, 0x5f, + 0x61, 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x61, 0x74, 0x69, 0x76, 0x65, 0x18, 0x06, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x17, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x4c, 0x69, 0x73, 0x74, 0x41, + 0x75, 0x74, 0x68, 0x6f, 0x72, 0x69, 0x74, 0x61, 0x74, 0x69, 0x76, 0x65, 0x12, 0x16, 0x0a, 0x06, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, + 0x75, 0x72, 0x63, 0x65, 0x22, 0x54, 0x0a, 0x0c, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x56, 0x69, + 0x6e, 0x64, 0x65, 0x78, 0x12, 0x16, 0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, + 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x73, 0x22, 0x43, 0x0a, 0x0d, 0x41, 0x75, + 0x74, 0x6f, 0x49, 0x6e, 0x63, 0x72, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x63, + 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x63, 0x6f, 0x6c, + 0x75, 0x6d, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x22, + 0x3d, 0x0a, 0x06, 0x43, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, + 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1f, 0x0a, + 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0b, 0x2e, 0x71, 0x75, + 0x65, 0x72, 0x79, 0x2e, 0x54, 0x79, 0x70, 0x65, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x22, 0xa7, + 0x02, 0x0a, 0x0a, 0x53, 0x72, 0x76, 0x56, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x12, 0x40, 0x0a, + 0x09, 0x6b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x22, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x53, 0x72, 0x76, 0x56, 0x53, + 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x45, + 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x6b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x73, 0x12, + 0x3a, 0x0a, 0x0d, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6c, 0x65, 0x73, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x15, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, + 0x2e, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x52, 0x0c, 0x72, + 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x4a, 0x0a, 0x13, 0x73, + 0x68, 0x61, 0x72, 0x64, 0x5f, 0x72, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6c, + 0x65, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, + 0x6d, 0x61, 0x2e, 0x53, 0x68, 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, + 0x75, 0x6c, 0x65, 0x73, 0x52, 0x11, 0x73, 0x68, 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, + 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x1a, 0x4f, 0x0a, 0x0e, 0x4b, 0x65, 0x79, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x27, 0x0a, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x11, 0x2e, 0x76, 0x73, 0x63, + 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x52, 0x05, 0x76, + 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x44, 0x0a, 0x11, 0x53, 0x68, 0x61, 0x72, + 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x73, 0x12, 0x2f, 0x0a, + 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x76, + 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x53, 0x68, 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, + 0x69, 0x6e, 0x67, 0x52, 0x75, 0x6c, 0x65, 0x52, 0x05, 0x72, 0x75, 0x6c, 0x65, 0x73, 0x22, 0x6e, + 0x0a, 0x10, 0x53, 0x68, 0x61, 0x72, 0x64, 0x52, 0x6f, 0x75, 0x74, 0x69, 0x6e, 0x67, 0x52, 0x75, + 0x6c, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x6b, 0x65, 0x79, 0x73, 0x70, + 0x61, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x66, 0x72, 0x6f, 0x6d, 0x4b, + 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x74, 0x6f, 0x5f, 0x6b, 0x65, + 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x74, 0x6f, + 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x68, 0x61, 0x72, + 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x73, 0x68, 0x61, 0x72, 0x64, 0x42, 0x26, + 0x5a, 0x24, 0x76, 0x69, 0x74, 0x65, 0x73, 0x73, 0x2e, 0x69, 0x6f, 0x2f, 0x76, 0x69, 0x74, 0x65, + 0x73, 0x73, 0x2f, 0x67, 0x6f, 0x2f, 0x76, 0x74, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x76, + 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -893,46 +960,49 @@ func file_vschema_proto_rawDescGZIP() []byte { return file_vschema_proto_rawDescData } +var file_vschema_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_vschema_proto_msgTypes = make([]protoimpl.MessageInfo, 15) var file_vschema_proto_goTypes = []interface{}{ - (*RoutingRules)(nil), // 0: vschema.RoutingRules - (*RoutingRule)(nil), // 1: vschema.RoutingRule - (*Keyspace)(nil), // 2: vschema.Keyspace - (*Vindex)(nil), // 3: vschema.Vindex - (*Table)(nil), // 4: vschema.Table - (*ColumnVindex)(nil), // 5: vschema.ColumnVindex - (*AutoIncrement)(nil), // 6: vschema.AutoIncrement - (*Column)(nil), // 7: vschema.Column - (*SrvVSchema)(nil), // 8: vschema.SrvVSchema - (*ShardRoutingRules)(nil), // 9: vschema.ShardRoutingRules - (*ShardRoutingRule)(nil), // 10: vschema.ShardRoutingRule - nil, // 11: vschema.Keyspace.VindexesEntry - nil, // 12: vschema.Keyspace.TablesEntry - nil, // 13: vschema.Vindex.ParamsEntry - nil, // 14: vschema.SrvVSchema.KeyspacesEntry - (query.Type)(0), // 15: query.Type + (Keyspace_ForeignKeyMode)(0), // 0: vschema.Keyspace.ForeignKeyMode + (*RoutingRules)(nil), // 1: vschema.RoutingRules + (*RoutingRule)(nil), // 2: vschema.RoutingRule + (*Keyspace)(nil), // 3: vschema.Keyspace + (*Vindex)(nil), // 4: vschema.Vindex + (*Table)(nil), // 5: vschema.Table + (*ColumnVindex)(nil), // 6: vschema.ColumnVindex + (*AutoIncrement)(nil), // 7: vschema.AutoIncrement + (*Column)(nil), // 8: vschema.Column + (*SrvVSchema)(nil), // 9: vschema.SrvVSchema + (*ShardRoutingRules)(nil), // 10: vschema.ShardRoutingRules + (*ShardRoutingRule)(nil), // 11: vschema.ShardRoutingRule + nil, // 12: vschema.Keyspace.VindexesEntry + nil, // 13: vschema.Keyspace.TablesEntry + nil, // 14: vschema.Vindex.ParamsEntry + nil, // 15: vschema.SrvVSchema.KeyspacesEntry + (query.Type)(0), // 16: query.Type } var file_vschema_proto_depIdxs = []int32{ - 1, // 0: vschema.RoutingRules.rules:type_name -> vschema.RoutingRule - 11, // 1: vschema.Keyspace.vindexes:type_name -> vschema.Keyspace.VindexesEntry - 12, // 2: vschema.Keyspace.tables:type_name -> vschema.Keyspace.TablesEntry - 13, // 3: vschema.Vindex.params:type_name -> vschema.Vindex.ParamsEntry - 5, // 4: vschema.Table.column_vindexes:type_name -> vschema.ColumnVindex - 6, // 5: vschema.Table.auto_increment:type_name -> vschema.AutoIncrement - 7, // 6: vschema.Table.columns:type_name -> vschema.Column - 15, // 7: vschema.Column.type:type_name -> query.Type - 14, // 8: vschema.SrvVSchema.keyspaces:type_name -> vschema.SrvVSchema.KeyspacesEntry - 0, // 9: vschema.SrvVSchema.routing_rules:type_name -> vschema.RoutingRules - 9, // 10: vschema.SrvVSchema.shard_routing_rules:type_name -> vschema.ShardRoutingRules - 10, // 11: vschema.ShardRoutingRules.rules:type_name -> vschema.ShardRoutingRule - 3, // 12: vschema.Keyspace.VindexesEntry.value:type_name -> vschema.Vindex - 4, // 13: vschema.Keyspace.TablesEntry.value:type_name -> vschema.Table - 2, // 14: vschema.SrvVSchema.KeyspacesEntry.value:type_name -> vschema.Keyspace - 15, // [15:15] is the sub-list for method output_type - 15, // [15:15] is the sub-list for method input_type - 15, // [15:15] is the sub-list for extension type_name - 15, // [15:15] is the sub-list for extension extendee - 0, // [0:15] is the sub-list for field type_name + 2, // 0: vschema.RoutingRules.rules:type_name -> vschema.RoutingRule + 12, // 1: vschema.Keyspace.vindexes:type_name -> vschema.Keyspace.VindexesEntry + 13, // 2: vschema.Keyspace.tables:type_name -> vschema.Keyspace.TablesEntry + 0, // 3: vschema.Keyspace.foreign_key_mode:type_name -> vschema.Keyspace.ForeignKeyMode + 14, // 4: vschema.Vindex.params:type_name -> vschema.Vindex.ParamsEntry + 6, // 5: vschema.Table.column_vindexes:type_name -> vschema.ColumnVindex + 7, // 6: vschema.Table.auto_increment:type_name -> vschema.AutoIncrement + 8, // 7: vschema.Table.columns:type_name -> vschema.Column + 16, // 8: vschema.Column.type:type_name -> query.Type + 15, // 9: vschema.SrvVSchema.keyspaces:type_name -> vschema.SrvVSchema.KeyspacesEntry + 1, // 10: vschema.SrvVSchema.routing_rules:type_name -> vschema.RoutingRules + 10, // 11: vschema.SrvVSchema.shard_routing_rules:type_name -> vschema.ShardRoutingRules + 11, // 12: vschema.ShardRoutingRules.rules:type_name -> vschema.ShardRoutingRule + 4, // 13: vschema.Keyspace.VindexesEntry.value:type_name -> vschema.Vindex + 5, // 14: vschema.Keyspace.TablesEntry.value:type_name -> vschema.Table + 3, // 15: vschema.SrvVSchema.KeyspacesEntry.value:type_name -> vschema.Keyspace + 16, // [16:16] is the sub-list for method output_type + 16, // [16:16] is the sub-list for method input_type + 16, // [16:16] is the sub-list for extension type_name + 16, // [16:16] is the sub-list for extension extendee + 0, // [0:16] is the sub-list for field type_name } func init() { file_vschema_proto_init() } @@ -1079,13 +1149,14 @@ func file_vschema_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_vschema_proto_rawDesc, - NumEnums: 0, + NumEnums: 1, NumMessages: 15, NumExtensions: 0, NumServices: 0, }, GoTypes: file_vschema_proto_goTypes, DependencyIndexes: file_vschema_proto_depIdxs, + EnumInfos: file_vschema_proto_enumTypes, MessageInfos: file_vschema_proto_msgTypes, }.Build() File_vschema_proto = out.File diff --git a/go/vt/proto/vschema/vschema_vtproto.pb.go b/go/vt/proto/vschema/vschema_vtproto.pb.go index 1b461eba1ff..38d7a422834 100644 --- a/go/vt/proto/vschema/vschema_vtproto.pb.go +++ b/go/vt/proto/vschema/vschema_vtproto.pb.go @@ -143,6 +143,11 @@ func (m *Keyspace) MarshalToSizedBufferVT(dAtA []byte) (int, error) { i -= len(m.unknownFields) copy(dAtA[i:], m.unknownFields) } + if m.ForeignKeyMode != 0 { + i = encodeVarint(dAtA, i, uint64(m.ForeignKeyMode)) + i-- + dAtA[i] = 0x28 + } if m.RequireExplicitRouting { i-- if m.RequireExplicitRouting { @@ -781,6 +786,9 @@ func (m *Keyspace) SizeVT() (n int) { if m.RequireExplicitRouting { n += 2 } + if m.ForeignKeyMode != 0 { + n += 1 + sov(uint64(m.ForeignKeyMode)) + } n += len(m.unknownFields) return n } @@ -1513,6 +1521,25 @@ func (m *Keyspace) UnmarshalVT(dAtA []byte) error { } } m.RequireExplicitRouting = bool(v != 0) + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ForeignKeyMode", wireType) + } + m.ForeignKeyMode = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflow + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ForeignKeyMode |= Keyspace_ForeignKeyMode(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skip(dAtA[iNdEx:]) diff --git a/proto/vschema.proto b/proto/vschema.proto index f618492693c..db1eca168b6 100644 --- a/proto/vschema.proto +++ b/proto/vschema.proto @@ -45,6 +45,14 @@ message Keyspace { map tables = 3; // If require_explicit_routing is true, vindexes and tables are not added to global routing bool require_explicit_routing = 4; + // foreign_key_mode dictates how Vitess should handle foreign keys for this keyspace. + ForeignKeyMode foreign_key_mode = 5; + + enum ForeignKeyMode { + Fk_unmanaged = 0; + Fk_disallow = 1; + Fk_managed = 2; + } } // Vindex is the vindex info for a Keyspace. diff --git a/web/vtadmin/src/proto/vtadmin.d.ts b/web/vtadmin/src/proto/vtadmin.d.ts index 6d1c9ab8f22..fb9934b2cde 100644 --- a/web/vtadmin/src/proto/vtadmin.d.ts +++ b/web/vtadmin/src/proto/vtadmin.d.ts @@ -39381,6 +39381,9 @@ export namespace vschema { /** Keyspace require_explicit_routing */ require_explicit_routing?: (boolean|null); + + /** Keyspace foreign_key_mode */ + foreign_key_mode?: (vschema.Keyspace.ForeignKeyMode|null); } /** Represents a Keyspace. */ @@ -39404,6 +39407,9 @@ export namespace vschema { /** Keyspace require_explicit_routing. */ public require_explicit_routing: boolean; + /** Keyspace foreign_key_mode. */ + public foreign_key_mode: vschema.Keyspace.ForeignKeyMode; + /** * Creates a new Keyspace instance using the specified properties. * @param [properties] Properties to set @@ -39482,6 +39488,16 @@ export namespace vschema { public static getTypeUrl(typeUrlPrefix?: string): string; } + namespace Keyspace { + + /** ForeignKeyMode enum. */ + enum ForeignKeyMode { + Fk_unmanaged = 0, + Fk_disallow = 1, + Fk_managed = 2 + } + } + /** Properties of a Vindex. */ interface IVindex { diff --git a/web/vtadmin/src/proto/vtadmin.js b/web/vtadmin/src/proto/vtadmin.js index becbedaee74..ebe21d6f6d0 100644 --- a/web/vtadmin/src/proto/vtadmin.js +++ b/web/vtadmin/src/proto/vtadmin.js @@ -94903,6 +94903,7 @@ export const vschema = $root.vschema = (() => { * @property {Object.|null} [vindexes] Keyspace vindexes * @property {Object.|null} [tables] Keyspace tables * @property {boolean|null} [require_explicit_routing] Keyspace require_explicit_routing + * @property {vschema.Keyspace.ForeignKeyMode|null} [foreign_key_mode] Keyspace foreign_key_mode */ /** @@ -94954,6 +94955,14 @@ export const vschema = $root.vschema = (() => { */ Keyspace.prototype.require_explicit_routing = false; + /** + * Keyspace foreign_key_mode. + * @member {vschema.Keyspace.ForeignKeyMode} foreign_key_mode + * @memberof vschema.Keyspace + * @instance + */ + Keyspace.prototype.foreign_key_mode = 0; + /** * Creates a new Keyspace instance using the specified properties. * @function create @@ -94992,6 +95001,8 @@ export const vschema = $root.vschema = (() => { } if (message.require_explicit_routing != null && Object.hasOwnProperty.call(message, "require_explicit_routing")) writer.uint32(/* id 4, wireType 0 =*/32).bool(message.require_explicit_routing); + if (message.foreign_key_mode != null && Object.hasOwnProperty.call(message, "foreign_key_mode")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.foreign_key_mode); return writer; }; @@ -95080,6 +95091,10 @@ export const vschema = $root.vschema = (() => { message.require_explicit_routing = reader.bool(); break; } + case 5: { + message.foreign_key_mode = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -95141,6 +95156,15 @@ export const vschema = $root.vschema = (() => { if (message.require_explicit_routing != null && message.hasOwnProperty("require_explicit_routing")) if (typeof message.require_explicit_routing !== "boolean") return "require_explicit_routing: boolean expected"; + if (message.foreign_key_mode != null && message.hasOwnProperty("foreign_key_mode")) + switch (message.foreign_key_mode) { + default: + return "foreign_key_mode: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -95180,6 +95204,26 @@ export const vschema = $root.vschema = (() => { } if (object.require_explicit_routing != null) message.require_explicit_routing = Boolean(object.require_explicit_routing); + switch (object.foreign_key_mode) { + default: + if (typeof object.foreign_key_mode === "number") { + message.foreign_key_mode = object.foreign_key_mode; + break; + } + break; + case "Fk_unmanaged": + case 0: + message.foreign_key_mode = 0; + break; + case "Fk_disallow": + case 1: + message.foreign_key_mode = 1; + break; + case "Fk_managed": + case 2: + message.foreign_key_mode = 2; + break; + } return message; }; @@ -95203,6 +95247,7 @@ export const vschema = $root.vschema = (() => { if (options.defaults) { object.sharded = false; object.require_explicit_routing = false; + object.foreign_key_mode = options.enums === String ? "Fk_unmanaged" : 0; } if (message.sharded != null && message.hasOwnProperty("sharded")) object.sharded = message.sharded; @@ -95219,6 +95264,8 @@ export const vschema = $root.vschema = (() => { } if (message.require_explicit_routing != null && message.hasOwnProperty("require_explicit_routing")) object.require_explicit_routing = message.require_explicit_routing; + if (message.foreign_key_mode != null && message.hasOwnProperty("foreign_key_mode")) + object.foreign_key_mode = options.enums === String ? $root.vschema.Keyspace.ForeignKeyMode[message.foreign_key_mode] === undefined ? message.foreign_key_mode : $root.vschema.Keyspace.ForeignKeyMode[message.foreign_key_mode] : message.foreign_key_mode; return object; }; @@ -95248,6 +95295,22 @@ export const vschema = $root.vschema = (() => { return typeUrlPrefix + "/vschema.Keyspace"; }; + /** + * ForeignKeyMode enum. + * @name vschema.Keyspace.ForeignKeyMode + * @enum {number} + * @property {number} Fk_unmanaged=0 Fk_unmanaged value + * @property {number} Fk_disallow=1 Fk_disallow value + * @property {number} Fk_managed=2 Fk_managed value + */ + Keyspace.ForeignKeyMode = (function() { + const valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "Fk_unmanaged"] = 0; + values[valuesById[1] = "Fk_disallow"] = 1; + values[valuesById[2] = "Fk_managed"] = 2; + return values; + })(); + return Keyspace; })(); From 3070c0c5444b15967fde7642698c8329780f0b21 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 19 Jul 2023 13:23:15 +0530 Subject: [PATCH 2/7] feat: added default value to the enum and stored it in the keyspace schema Signed-off-by: Manan Gupta --- go/vt/proto/vschema/vschema.pb.go | 30 ++++++++++++--------- go/vt/vtgate/vindexes/vschema.go | 24 ++++++++++++----- go/vt/vtgate/vindexes/vschema_test.go | 39 +++++++++++++++++++++++++++ proto/vschema.proto | 5 ++-- web/vtadmin/src/proto/vtadmin.d.ts | 5 ++-- web/vtadmin/src/proto/vtadmin.js | 21 ++++++++++----- 6 files changed, 93 insertions(+), 31 deletions(-) diff --git a/go/vt/proto/vschema/vschema.pb.go b/go/vt/proto/vschema/vschema.pb.go index 1390e27d404..83b90c7c7bc 100644 --- a/go/vt/proto/vschema/vschema.pb.go +++ b/go/vt/proto/vschema/vschema.pb.go @@ -41,22 +41,25 @@ const ( type Keyspace_ForeignKeyMode int32 const ( - Keyspace_Fk_unmanaged Keyspace_ForeignKeyMode = 0 + Keyspace_Fk_default Keyspace_ForeignKeyMode = 0 Keyspace_Fk_disallow Keyspace_ForeignKeyMode = 1 - Keyspace_Fk_managed Keyspace_ForeignKeyMode = 2 + Keyspace_Fk_unmanaged Keyspace_ForeignKeyMode = 2 + Keyspace_Fk_managed Keyspace_ForeignKeyMode = 3 ) // Enum value maps for Keyspace_ForeignKeyMode. var ( Keyspace_ForeignKeyMode_name = map[int32]string{ - 0: "Fk_unmanaged", + 0: "Fk_default", 1: "Fk_disallow", - 2: "Fk_managed", + 2: "Fk_unmanaged", + 3: "Fk_managed", } Keyspace_ForeignKeyMode_value = map[string]int32{ - "Fk_unmanaged": 0, + "Fk_default": 0, "Fk_disallow": 1, - "Fk_managed": 2, + "Fk_unmanaged": 2, + "Fk_managed": 3, } ) @@ -274,7 +277,7 @@ func (x *Keyspace) GetForeignKeyMode() Keyspace_ForeignKeyMode { if x != nil { return x.ForeignKeyMode } - return Keyspace_Fk_unmanaged + return Keyspace_Fk_default } // Vindex is the vindex info for a Keyspace. @@ -837,7 +840,7 @@ var file_vschema_proto_rawDesc = []byte{ 0x12, 0x1d, 0x0a, 0x0a, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x66, 0x72, 0x6f, 0x6d, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x74, 0x6f, 0x5f, 0x74, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, - 0x28, 0x09, 0x52, 0x08, 0x74, 0x6f, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x22, 0xfc, 0x03, 0x0a, + 0x28, 0x09, 0x52, 0x08, 0x74, 0x6f, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x73, 0x22, 0x8c, 0x04, 0x0a, 0x08, 0x4b, 0x65, 0x79, 0x73, 0x70, 0x61, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x68, 0x61, 0x72, 0x64, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x68, 0x61, 0x72, 0x64, 0x65, 0x64, 0x12, 0x3b, 0x0a, 0x08, 0x76, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x65, 0x73, 0x18, @@ -865,11 +868,12 @@ var file_vschema_proto_rawDesc = []byte{ 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x24, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x43, 0x0a, 0x0e, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, - 0x6e, 0x4b, 0x65, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x10, 0x0a, 0x0c, 0x46, 0x6b, 0x5f, 0x75, - 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x46, 0x6b, - 0x5f, 0x64, 0x69, 0x73, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x46, - 0x6b, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x10, 0x02, 0x22, 0xa2, 0x01, 0x0a, 0x06, + 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x53, 0x0a, 0x0e, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, + 0x6e, 0x4b, 0x65, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x6b, 0x5f, 0x64, + 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x46, 0x6b, 0x5f, 0x64, + 0x69, 0x73, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x46, 0x6b, 0x5f, + 0x75, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x46, + 0x6b, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x10, 0x03, 0x22, 0xa2, 0x01, 0x0a, 0x06, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x73, 0x63, diff --git a/go/vt/vtgate/vindexes/vschema.go b/go/vt/vtgate/vindexes/vschema.go index b62b5ce46f7..35ba85b07f0 100644 --- a/go/vt/vtgate/vindexes/vschema.go +++ b/go/vt/vtgate/vindexes/vschema.go @@ -175,11 +175,12 @@ func (col *Column) MarshalJSON() ([]byte, error) { // KeyspaceSchema contains the schema(table) for a keyspace. type KeyspaceSchema struct { - Keyspace *Keyspace - Tables map[string]*Table - Vindexes map[string]Vindex - Views map[string]sqlparser.SelectStatement - Error error + Keyspace *Keyspace + ForeignKeyMode vschemapb.Keyspace_ForeignKeyMode + Tables map[string]*Table + Vindexes map[string]Vindex + Views map[string]sqlparser.SelectStatement + Error error } type ksJSON struct { @@ -304,14 +305,23 @@ func buildKeyspaces(source *vschemapb.SrvVSchema, vschema *VSchema) { Name: ksname, Sharded: ks.Sharded, }, - Tables: make(map[string]*Table), - Vindexes: make(map[string]Vindex), + ForeignKeyMode: replaceDefaultForeignKeyMode(ks.ForeignKeyMode), + Tables: make(map[string]*Table), + Vindexes: make(map[string]Vindex), } vschema.Keyspaces[ksname] = ksvschema ksvschema.Error = buildTables(ks, vschema, ksvschema) } } +// replaceDefaultForeignKeyMode replaces the default value of the foreign key mode enum with the default we want to keep. +func replaceDefaultForeignKeyMode(fkMode vschemapb.Keyspace_ForeignKeyMode) vschemapb.Keyspace_ForeignKeyMode { + if fkMode == vschemapb.Keyspace_Fk_default { + return vschemapb.Keyspace_Fk_unmanaged + } + return fkMode +} + func (vschema *VSchema) AddView(ksname string, viewName, query string) error { ks, ok := vschema.Keyspaces[ksname] if !ok { diff --git a/go/vt/vtgate/vindexes/vschema_test.go b/go/vt/vtgate/vindexes/vschema_test.go index 9f538d20d0b..c348d8ce8d3 100644 --- a/go/vt/vtgate/vindexes/vschema_test.go +++ b/go/vt/vtgate/vindexes/vschema_test.go @@ -243,6 +243,45 @@ func TestUnshardedVSchemaValid(t *testing.T) { require.NoError(t, err) } +func TestForeignKeyMode(t *testing.T) { + tests := []struct { + name string + fkMode vschemapb.Keyspace_ForeignKeyMode + wantedFkMode vschemapb.Keyspace_ForeignKeyMode + }{ + { + name: "Default Value", + wantedFkMode: vschemapb.Keyspace_Fk_unmanaged, + }, { + name: "Managed Value", + fkMode: vschemapb.Keyspace_Fk_managed, + wantedFkMode: vschemapb.Keyspace_Fk_managed, + }, { + name: "Unmanaged Value", + fkMode: vschemapb.Keyspace_Fk_unmanaged, + wantedFkMode: vschemapb.Keyspace_Fk_unmanaged, + }, { + name: "Disallow Value", + fkMode: vschemapb.Keyspace_Fk_disallow, + wantedFkMode: vschemapb.Keyspace_Fk_disallow, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + ksSchema, err := BuildKeyspace(&vschemapb.Keyspace{ + Sharded: false, + ForeignKeyMode: test.fkMode, + Vindexes: make(map[string]*vschemapb.Vindex), + Tables: make(map[string]*vschemapb.Table), + }) + require.NoError(t, err) + require.Equal(t, test.wantedFkMode, ksSchema.ForeignKeyMode) + }) + + } +} + func TestUnshardedVSchema(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ diff --git a/proto/vschema.proto b/proto/vschema.proto index db1eca168b6..9c0355e3205 100644 --- a/proto/vschema.proto +++ b/proto/vschema.proto @@ -49,9 +49,10 @@ message Keyspace { ForeignKeyMode foreign_key_mode = 5; enum ForeignKeyMode { - Fk_unmanaged = 0; + Fk_default = 0; Fk_disallow = 1; - Fk_managed = 2; + Fk_unmanaged = 2; + Fk_managed = 3; } } diff --git a/web/vtadmin/src/proto/vtadmin.d.ts b/web/vtadmin/src/proto/vtadmin.d.ts index fb9934b2cde..b3391e8bde2 100644 --- a/web/vtadmin/src/proto/vtadmin.d.ts +++ b/web/vtadmin/src/proto/vtadmin.d.ts @@ -39492,9 +39492,10 @@ export namespace vschema { /** ForeignKeyMode enum. */ enum ForeignKeyMode { - Fk_unmanaged = 0, + Fk_default = 0, Fk_disallow = 1, - Fk_managed = 2 + Fk_unmanaged = 2, + Fk_managed = 3 } } diff --git a/web/vtadmin/src/proto/vtadmin.js b/web/vtadmin/src/proto/vtadmin.js index ebe21d6f6d0..549649ffc71 100644 --- a/web/vtadmin/src/proto/vtadmin.js +++ b/web/vtadmin/src/proto/vtadmin.js @@ -95163,6 +95163,7 @@ export const vschema = $root.vschema = (() => { case 0: case 1: case 2: + case 3: break; } return null; @@ -95211,7 +95212,7 @@ export const vschema = $root.vschema = (() => { break; } break; - case "Fk_unmanaged": + case "Fk_default": case 0: message.foreign_key_mode = 0; break; @@ -95219,10 +95220,14 @@ export const vschema = $root.vschema = (() => { case 1: message.foreign_key_mode = 1; break; - case "Fk_managed": + case "Fk_unmanaged": case 2: message.foreign_key_mode = 2; break; + case "Fk_managed": + case 3: + message.foreign_key_mode = 3; + break; } return message; }; @@ -95247,7 +95252,7 @@ export const vschema = $root.vschema = (() => { if (options.defaults) { object.sharded = false; object.require_explicit_routing = false; - object.foreign_key_mode = options.enums === String ? "Fk_unmanaged" : 0; + object.foreign_key_mode = options.enums === String ? "Fk_default" : 0; } if (message.sharded != null && message.hasOwnProperty("sharded")) object.sharded = message.sharded; @@ -95299,15 +95304,17 @@ export const vschema = $root.vschema = (() => { * ForeignKeyMode enum. * @name vschema.Keyspace.ForeignKeyMode * @enum {number} - * @property {number} Fk_unmanaged=0 Fk_unmanaged value + * @property {number} Fk_default=0 Fk_default value * @property {number} Fk_disallow=1 Fk_disallow value - * @property {number} Fk_managed=2 Fk_managed value + * @property {number} Fk_unmanaged=2 Fk_unmanaged value + * @property {number} Fk_managed=3 Fk_managed value */ Keyspace.ForeignKeyMode = (function() { const valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "Fk_unmanaged"] = 0; + values[valuesById[0] = "Fk_default"] = 0; values[valuesById[1] = "Fk_disallow"] = 1; - values[valuesById[2] = "Fk_managed"] = 2; + values[valuesById[2] = "Fk_unmanaged"] = 2; + values[valuesById[3] = "Fk_managed"] = 3; return values; })(); From cb879cc118de6e56158a4ebb04f4d2fcf6faa2e6 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Wed, 19 Jul 2023 15:54:09 +0530 Subject: [PATCH 3/7] feat: add foreign key mode to be printed in json serialization Signed-off-by: Manan Gupta --- go/vt/vtgate/vindexes/vschema.go | 18 +++---- go/vt/vtgate/vindexes/vschema_test.go | 68 +++++++++++++++++++-------- 2 files changed, 59 insertions(+), 27 deletions(-) diff --git a/go/vt/vtgate/vindexes/vschema.go b/go/vt/vtgate/vindexes/vschema.go index 35ba85b07f0..a4b4279a3b1 100644 --- a/go/vt/vtgate/vindexes/vschema.go +++ b/go/vt/vtgate/vindexes/vschema.go @@ -184,11 +184,12 @@ type KeyspaceSchema struct { } type ksJSON struct { - Sharded bool `json:"sharded,omitempty"` - Tables map[string]*Table `json:"tables,omitempty"` - Vindexes map[string]Vindex `json:"vindexes,omitempty"` - Views map[string]string `json:"views,omitempty"` - Error string `json:"error,omitempty"` + Sharded bool `json:"sharded,omitempty"` + ForeignKeyMode string `json:"foreignKeyMode,omitempty"` + Tables map[string]*Table `json:"tables,omitempty"` + Vindexes map[string]Vindex `json:"vindexes,omitempty"` + Views map[string]string `json:"views,omitempty"` + Error string `json:"error,omitempty"` } // findTable looks for the table with the requested tablename in the keyspace. @@ -217,9 +218,10 @@ func (ks *KeyspaceSchema) findTable( // MarshalJSON returns a JSON representation of KeyspaceSchema. func (ks *KeyspaceSchema) MarshalJSON() ([]byte, error) { ksJ := ksJSON{ - Sharded: ks.Keyspace.Sharded, - Tables: ks.Tables, - Vindexes: ks.Vindexes, + Sharded: ks.Keyspace.Sharded, + Tables: ks.Tables, + ForeignKeyMode: ks.ForeignKeyMode.String(), + Vindexes: ks.Vindexes, } if ks.Error != nil { ksJ.Error = ks.Error.Error() diff --git a/go/vt/vtgate/vindexes/vschema_test.go b/go/vt/vtgate/vindexes/vschema_test.go index c348d8ce8d3..5d7f055c0ce 100644 --- a/go/vt/vtgate/vindexes/vschema_test.go +++ b/go/vt/vtgate/vindexes/vschema_test.go @@ -357,6 +357,7 @@ func TestVSchemaViews(t *testing.T) { got := string(out) want := ` { + "foreignKeyMode":"Fk_unmanaged", "tables": { "t1": { "name": "t1", @@ -601,7 +602,8 @@ func TestVSchemaRoutingRules(t *testing.T) { }, Keyspaces: map[string]*vschemapb.Keyspace{ "ks1": { - Sharded: true, + Sharded: true, + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, Vindexes: map[string]*vschemapb.Vindex{ "stfu1": { Type: "stfu", @@ -619,6 +621,7 @@ func TestVSchemaRoutingRules(t *testing.T) { }, }, "ks2": { + ForeignKeyMode: vschemapb.Keyspace_Fk_managed, Tables: map[string]*vschemapb.Table{ "t2": {}, }, @@ -691,7 +694,8 @@ func TestVSchemaRoutingRules(t *testing.T) { }, Keyspaces: map[string]*KeyspaceSchema{ "ks1": { - Keyspace: ks1, + Keyspace: ks1, + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, Tables: map[string]*Table{ "t1": t1, }, @@ -700,7 +704,8 @@ func TestVSchemaRoutingRules(t *testing.T) { }, }, "ks2": { - Keyspace: ks2, + ForeignKeyMode: vschemapb.Keyspace_Fk_managed, + Keyspace: ks2, Tables: map[string]*Table{ "t2": t2, }, @@ -1019,7 +1024,8 @@ func TestShardedVSchemaMultiColumnVindex(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "sharded": { - Sharded: true, + Sharded: true, + ForeignKeyMode: vschemapb.Keyspace_Fk_disallow, Vindexes: map[string]*vschemapb.Vindex{ "stfu1": { Type: "stfu", @@ -1066,7 +1072,8 @@ func TestShardedVSchemaMultiColumnVindex(t *testing.T) { }, Keyspaces: map[string]*KeyspaceSchema{ "sharded": { - Keyspace: ks, + ForeignKeyMode: vschemapb.Keyspace_Fk_disallow, + Keyspace: ks, Tables: map[string]*Table{ "t1": t1}, Vindexes: map[string]Vindex{ @@ -1083,7 +1090,8 @@ func TestShardedVSchemaNotOwned(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "sharded": { - Sharded: true, + ForeignKeyMode: vschemapb.Keyspace_Fk_managed, + Sharded: true, Vindexes: map[string]*vschemapb.Vindex{ "stlu1": { Type: "stlu", @@ -1140,7 +1148,8 @@ func TestShardedVSchemaNotOwned(t *testing.T) { "stfu1": vindex2}, Keyspaces: map[string]*KeyspaceSchema{ "sharded": { - Keyspace: ks, + ForeignKeyMode: vschemapb.Keyspace_Fk_managed, + Keyspace: ks, Tables: map[string]*Table{ "t1": t1, }, @@ -1214,10 +1223,12 @@ func TestBuildVSchemaDupSeq(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "ksa": { + ForeignKeyMode: vschemapb.Keyspace_Fk_managed, Tables: map[string]*vschemapb.Table{ "t1": { Type: "sequence"}}}, "ksb": { + ForeignKeyMode: vschemapb.Keyspace_Fk_managed, Tables: map[string]*vschemapb.Table{ "t1": { Type: "sequence"}}}}} @@ -1242,14 +1253,16 @@ func TestBuildVSchemaDupSeq(t *testing.T) { uniqueVindexes: map[string]Vindex{}, Keyspaces: map[string]*KeyspaceSchema{ "ksa": { - Keyspace: ksa, + ForeignKeyMode: vschemapb.Keyspace_Fk_managed, + Keyspace: ksa, Tables: map[string]*Table{ "t1": t1a, }, Vindexes: map[string]Vindex{}, }, "ksb": { - Keyspace: ksb, + ForeignKeyMode: vschemapb.Keyspace_Fk_managed, + Keyspace: ksb, Tables: map[string]*Table{ "t1": t1b, }, @@ -1265,11 +1278,13 @@ func TestBuildVSchemaDupTable(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "ksa": { + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, Tables: map[string]*vschemapb.Table{ "t1": {}, }, }, "ksb": { + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, Tables: map[string]*vschemapb.Table{ "t1": {}, }, @@ -1299,14 +1314,16 @@ func TestBuildVSchemaDupTable(t *testing.T) { uniqueVindexes: map[string]Vindex{}, Keyspaces: map[string]*KeyspaceSchema{ "ksa": { - Keyspace: ksa, + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + Keyspace: ksa, Tables: map[string]*Table{ "t1": t1a, }, Vindexes: map[string]Vindex{}, }, "ksb": { - Keyspace: ksb, + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + Keyspace: ksb, Tables: map[string]*Table{ "t1": t1b, }, @@ -1325,7 +1342,8 @@ func TestBuildVSchemaDupVindex(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "ksa": { - Sharded: true, + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + Sharded: true, Vindexes: map[string]*vschemapb.Vindex{ "stlu1": { Type: "stlu", @@ -1344,7 +1362,8 @@ func TestBuildVSchemaDupVindex(t *testing.T) { }, }, "ksb": { - Sharded: true, + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + Sharded: true, Vindexes: map[string]*vschemapb.Vindex{ "stlu1": { Type: "stlu", @@ -1426,7 +1445,8 @@ func TestBuildVSchemaDupVindex(t *testing.T) { }, Keyspaces: map[string]*KeyspaceSchema{ "ksa": { - Keyspace: ksa, + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + Keyspace: ksa, Tables: map[string]*Table{ "t1": t1, }, @@ -1435,7 +1455,8 @@ func TestBuildVSchemaDupVindex(t *testing.T) { }, }, "ksb": { - Keyspace: ksb, + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + Keyspace: ksb, Tables: map[string]*Table{ "t1": t2, }, @@ -1893,6 +1914,7 @@ func TestSequence(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "unsharded": { + ForeignKeyMode: vschemapb.Keyspace_Fk_disallow, Tables: map[string]*vschemapb.Table{ "seq": { Type: "sequence", @@ -1900,7 +1922,8 @@ func TestSequence(t *testing.T) { }, }, "sharded": { - Sharded: true, + Sharded: true, + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, Vindexes: map[string]*vschemapb.Vindex{ "stfu1": { Type: "stfu", @@ -2010,14 +2033,16 @@ func TestSequence(t *testing.T) { }, Keyspaces: map[string]*KeyspaceSchema{ "unsharded": { - Keyspace: ksu, + ForeignKeyMode: vschemapb.Keyspace_Fk_disallow, + Keyspace: ksu, Tables: map[string]*Table{ "seq": seq, }, Vindexes: map[string]Vindex{}, }, "sharded": { - Keyspace: kss, + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + Keyspace: kss, Tables: map[string]*Table{ "t1": t1, "t2": t2, @@ -2446,7 +2471,8 @@ func TestBuildKeyspaceSchema(t *testing.T) { Keyspace: ks, } want := &KeyspaceSchema{ - Keyspace: ks, + Keyspace: ks, + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, Tables: map[string]*Table{ "t1": t1, "t2": t2, @@ -2568,6 +2594,7 @@ func TestVSchemaJSON(t *testing.T) { in := map[string]*KeyspaceSchema{ "unsharded": { + ForeignKeyMode: vschemapb.Keyspace_Fk_managed, Keyspace: &Keyspace{ Name: "k1", }, @@ -2588,6 +2615,7 @@ func TestVSchemaJSON(t *testing.T) { }, }, "sharded": { + ForeignKeyMode: vschemapb.Keyspace_Fk_disallow, Keyspace: &Keyspace{ Name: "k2", Sharded: true, @@ -2614,6 +2642,7 @@ func TestVSchemaJSON(t *testing.T) { want := `{ "sharded": { "sharded": true, + "foreignKeyMode": "Fk_disallow", "tables": { "t3": { "name": "n3", @@ -2638,6 +2667,7 @@ func TestVSchemaJSON(t *testing.T) { } }, "unsharded": { + "foreignKeyMode": "Fk_managed", "tables": { "t1": { "name": "n1", From 36dae7086d853b1babfe677781b45b2280f5aab0 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Thu, 20 Jul 2023 11:47:29 +0530 Subject: [PATCH 4/7] feat: fix the tests Signed-off-by: Manan Gupta --- go/vt/vtgate/vschema_manager_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/go/vt/vtgate/vschema_manager_test.go b/go/vt/vtgate/vschema_manager_test.go index 7e9a9224371..10630c385e8 100644 --- a/go/vt/vtgate/vschema_manager_test.go +++ b/go/vt/vtgate/vschema_manager_test.go @@ -222,8 +222,10 @@ func makeTestVSchema(ks string, sharded bool, tbls map[string]*vindexes.Table) * Name: ks, Sharded: sharded, }, - Tables: tbls, - Vindexes: map[string]vindexes.Vindex{}, + // Default foreign key mode + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + Tables: tbls, + Vindexes: map[string]vindexes.Vindex{}, } vs := makeTestEmptyVSchema() vs.Keyspaces[ks] = keyspaceSchema @@ -241,6 +243,8 @@ func makeTestSrvVSchema(ks string, sharded bool, tbls map[string]*vschemapb.Tabl keyspaceSchema := &vschemapb.Keyspace{ Sharded: sharded, Tables: tbls, + // Default foreign key mode + ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, } return &vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ks: keyspaceSchema}, From ccf559f638aaac192421c5ac440d9bef8d7757ac Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Thu, 20 Jul 2023 12:00:45 +0530 Subject: [PATCH 5/7] feat: rename ENUM values Signed-off-by: Manan Gupta --- go/vt/proto/vschema/vschema.pb.go | 36 +++++++------- go/vt/vtgate/vindexes/vschema.go | 4 +- go/vt/vtgate/vindexes/vschema_test.go | 68 +++++++++++++-------------- go/vt/vtgate/vschema_manager_test.go | 4 +- proto/vschema.proto | 8 ++-- web/vtadmin/src/proto/vtadmin.d.ts | 8 ++-- web/vtadmin/src/proto/vtadmin.js | 26 +++++----- 7 files changed, 77 insertions(+), 77 deletions(-) diff --git a/go/vt/proto/vschema/vschema.pb.go b/go/vt/proto/vschema/vschema.pb.go index 83b90c7c7bc..4783fa51586 100644 --- a/go/vt/proto/vschema/vschema.pb.go +++ b/go/vt/proto/vschema/vschema.pb.go @@ -41,25 +41,25 @@ const ( type Keyspace_ForeignKeyMode int32 const ( - Keyspace_Fk_default Keyspace_ForeignKeyMode = 0 - Keyspace_Fk_disallow Keyspace_ForeignKeyMode = 1 - Keyspace_Fk_unmanaged Keyspace_ForeignKeyMode = 2 - Keyspace_Fk_managed Keyspace_ForeignKeyMode = 3 + Keyspace_FK_DEFAULT Keyspace_ForeignKeyMode = 0 + Keyspace_FK_DISALLOW Keyspace_ForeignKeyMode = 1 + Keyspace_FK_UNMANAGED Keyspace_ForeignKeyMode = 2 + Keyspace_FK_MANAGED Keyspace_ForeignKeyMode = 3 ) // Enum value maps for Keyspace_ForeignKeyMode. var ( Keyspace_ForeignKeyMode_name = map[int32]string{ - 0: "Fk_default", - 1: "Fk_disallow", - 2: "Fk_unmanaged", - 3: "Fk_managed", + 0: "FK_DEFAULT", + 1: "FK_DISALLOW", + 2: "FK_UNMANAGED", + 3: "FK_MANAGED", } Keyspace_ForeignKeyMode_value = map[string]int32{ - "Fk_default": 0, - "Fk_disallow": 1, - "Fk_unmanaged": 2, - "Fk_managed": 3, + "FK_DEFAULT": 0, + "FK_DISALLOW": 1, + "FK_UNMANAGED": 2, + "FK_MANAGED": 3, } ) @@ -277,7 +277,7 @@ func (x *Keyspace) GetForeignKeyMode() Keyspace_ForeignKeyMode { if x != nil { return x.ForeignKeyMode } - return Keyspace_Fk_default + return Keyspace_FK_DEFAULT } // Vindex is the vindex info for a Keyspace. @@ -869,11 +869,11 @@ var file_vschema_proto_rawDesc = []byte{ 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x76, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x53, 0x0a, 0x0e, 0x46, 0x6f, 0x72, 0x65, 0x69, 0x67, - 0x6e, 0x4b, 0x65, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x6b, 0x5f, 0x64, - 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x46, 0x6b, 0x5f, 0x64, - 0x69, 0x73, 0x61, 0x6c, 0x6c, 0x6f, 0x77, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x46, 0x6b, 0x5f, - 0x75, 0x6e, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x46, - 0x6b, 0x5f, 0x6d, 0x61, 0x6e, 0x61, 0x67, 0x65, 0x64, 0x10, 0x03, 0x22, 0xa2, 0x01, 0x0a, 0x06, + 0x6e, 0x4b, 0x65, 0x79, 0x4d, 0x6f, 0x64, 0x65, 0x12, 0x0e, 0x0a, 0x0a, 0x46, 0x4b, 0x5f, 0x44, + 0x45, 0x46, 0x41, 0x55, 0x4c, 0x54, 0x10, 0x00, 0x12, 0x0f, 0x0a, 0x0b, 0x46, 0x4b, 0x5f, 0x44, + 0x49, 0x53, 0x41, 0x4c, 0x4c, 0x4f, 0x57, 0x10, 0x01, 0x12, 0x10, 0x0a, 0x0c, 0x46, 0x4b, 0x5f, + 0x55, 0x4e, 0x4d, 0x41, 0x4e, 0x41, 0x47, 0x45, 0x44, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x46, + 0x4b, 0x5f, 0x4d, 0x41, 0x4e, 0x41, 0x47, 0x45, 0x44, 0x10, 0x03, 0x22, 0xa2, 0x01, 0x0a, 0x06, 0x56, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79, 0x70, 0x65, 0x12, 0x33, 0x0a, 0x06, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1b, 0x2e, 0x76, 0x73, 0x63, diff --git a/go/vt/vtgate/vindexes/vschema.go b/go/vt/vtgate/vindexes/vschema.go index a4b4279a3b1..90becdf275f 100644 --- a/go/vt/vtgate/vindexes/vschema.go +++ b/go/vt/vtgate/vindexes/vschema.go @@ -318,8 +318,8 @@ func buildKeyspaces(source *vschemapb.SrvVSchema, vschema *VSchema) { // replaceDefaultForeignKeyMode replaces the default value of the foreign key mode enum with the default we want to keep. func replaceDefaultForeignKeyMode(fkMode vschemapb.Keyspace_ForeignKeyMode) vschemapb.Keyspace_ForeignKeyMode { - if fkMode == vschemapb.Keyspace_Fk_default { - return vschemapb.Keyspace_Fk_unmanaged + if fkMode == vschemapb.Keyspace_FK_DEFAULT { + return vschemapb.Keyspace_FK_UNMANAGED } return fkMode } diff --git a/go/vt/vtgate/vindexes/vschema_test.go b/go/vt/vtgate/vindexes/vschema_test.go index 5d7f055c0ce..9087a007789 100644 --- a/go/vt/vtgate/vindexes/vschema_test.go +++ b/go/vt/vtgate/vindexes/vschema_test.go @@ -251,19 +251,19 @@ func TestForeignKeyMode(t *testing.T) { }{ { name: "Default Value", - wantedFkMode: vschemapb.Keyspace_Fk_unmanaged, + wantedFkMode: vschemapb.Keyspace_FK_UNMANAGED, }, { name: "Managed Value", - fkMode: vschemapb.Keyspace_Fk_managed, - wantedFkMode: vschemapb.Keyspace_Fk_managed, + fkMode: vschemapb.Keyspace_FK_MANAGED, + wantedFkMode: vschemapb.Keyspace_FK_MANAGED, }, { name: "Unmanaged Value", - fkMode: vschemapb.Keyspace_Fk_unmanaged, - wantedFkMode: vschemapb.Keyspace_Fk_unmanaged, + fkMode: vschemapb.Keyspace_FK_UNMANAGED, + wantedFkMode: vschemapb.Keyspace_FK_UNMANAGED, }, { name: "Disallow Value", - fkMode: vschemapb.Keyspace_Fk_disallow, - wantedFkMode: vschemapb.Keyspace_Fk_disallow, + fkMode: vschemapb.Keyspace_FK_DISALLOW, + wantedFkMode: vschemapb.Keyspace_FK_DISALLOW, }, } @@ -603,7 +603,7 @@ func TestVSchemaRoutingRules(t *testing.T) { Keyspaces: map[string]*vschemapb.Keyspace{ "ks1": { Sharded: true, - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, Vindexes: map[string]*vschemapb.Vindex{ "stfu1": { Type: "stfu", @@ -621,7 +621,7 @@ func TestVSchemaRoutingRules(t *testing.T) { }, }, "ks2": { - ForeignKeyMode: vschemapb.Keyspace_Fk_managed, + ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, Tables: map[string]*vschemapb.Table{ "t2": {}, }, @@ -695,7 +695,7 @@ func TestVSchemaRoutingRules(t *testing.T) { Keyspaces: map[string]*KeyspaceSchema{ "ks1": { Keyspace: ks1, - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, Tables: map[string]*Table{ "t1": t1, }, @@ -704,7 +704,7 @@ func TestVSchemaRoutingRules(t *testing.T) { }, }, "ks2": { - ForeignKeyMode: vschemapb.Keyspace_Fk_managed, + ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, Keyspace: ks2, Tables: map[string]*Table{ "t2": t2, @@ -1025,7 +1025,7 @@ func TestShardedVSchemaMultiColumnVindex(t *testing.T) { Keyspaces: map[string]*vschemapb.Keyspace{ "sharded": { Sharded: true, - ForeignKeyMode: vschemapb.Keyspace_Fk_disallow, + ForeignKeyMode: vschemapb.Keyspace_FK_DISALLOW, Vindexes: map[string]*vschemapb.Vindex{ "stfu1": { Type: "stfu", @@ -1072,7 +1072,7 @@ func TestShardedVSchemaMultiColumnVindex(t *testing.T) { }, Keyspaces: map[string]*KeyspaceSchema{ "sharded": { - ForeignKeyMode: vschemapb.Keyspace_Fk_disallow, + ForeignKeyMode: vschemapb.Keyspace_FK_DISALLOW, Keyspace: ks, Tables: map[string]*Table{ "t1": t1}, @@ -1090,7 +1090,7 @@ func TestShardedVSchemaNotOwned(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "sharded": { - ForeignKeyMode: vschemapb.Keyspace_Fk_managed, + ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, Sharded: true, Vindexes: map[string]*vschemapb.Vindex{ "stlu1": { @@ -1148,7 +1148,7 @@ func TestShardedVSchemaNotOwned(t *testing.T) { "stfu1": vindex2}, Keyspaces: map[string]*KeyspaceSchema{ "sharded": { - ForeignKeyMode: vschemapb.Keyspace_Fk_managed, + ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, Keyspace: ks, Tables: map[string]*Table{ "t1": t1, @@ -1223,12 +1223,12 @@ func TestBuildVSchemaDupSeq(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "ksa": { - ForeignKeyMode: vschemapb.Keyspace_Fk_managed, + ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, Tables: map[string]*vschemapb.Table{ "t1": { Type: "sequence"}}}, "ksb": { - ForeignKeyMode: vschemapb.Keyspace_Fk_managed, + ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, Tables: map[string]*vschemapb.Table{ "t1": { Type: "sequence"}}}}} @@ -1253,7 +1253,7 @@ func TestBuildVSchemaDupSeq(t *testing.T) { uniqueVindexes: map[string]Vindex{}, Keyspaces: map[string]*KeyspaceSchema{ "ksa": { - ForeignKeyMode: vschemapb.Keyspace_Fk_managed, + ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, Keyspace: ksa, Tables: map[string]*Table{ "t1": t1a, @@ -1261,7 +1261,7 @@ func TestBuildVSchemaDupSeq(t *testing.T) { Vindexes: map[string]Vindex{}, }, "ksb": { - ForeignKeyMode: vschemapb.Keyspace_Fk_managed, + ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, Keyspace: ksb, Tables: map[string]*Table{ "t1": t1b, @@ -1278,13 +1278,13 @@ func TestBuildVSchemaDupTable(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "ksa": { - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, Tables: map[string]*vschemapb.Table{ "t1": {}, }, }, "ksb": { - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, Tables: map[string]*vschemapb.Table{ "t1": {}, }, @@ -1314,7 +1314,7 @@ func TestBuildVSchemaDupTable(t *testing.T) { uniqueVindexes: map[string]Vindex{}, Keyspaces: map[string]*KeyspaceSchema{ "ksa": { - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, Keyspace: ksa, Tables: map[string]*Table{ "t1": t1a, @@ -1322,7 +1322,7 @@ func TestBuildVSchemaDupTable(t *testing.T) { Vindexes: map[string]Vindex{}, }, "ksb": { - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, Keyspace: ksb, Tables: map[string]*Table{ "t1": t1b, @@ -1342,7 +1342,7 @@ func TestBuildVSchemaDupVindex(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "ksa": { - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, Sharded: true, Vindexes: map[string]*vschemapb.Vindex{ "stlu1": { @@ -1362,7 +1362,7 @@ func TestBuildVSchemaDupVindex(t *testing.T) { }, }, "ksb": { - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, Sharded: true, Vindexes: map[string]*vschemapb.Vindex{ "stlu1": { @@ -1445,7 +1445,7 @@ func TestBuildVSchemaDupVindex(t *testing.T) { }, Keyspaces: map[string]*KeyspaceSchema{ "ksa": { - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, Keyspace: ksa, Tables: map[string]*Table{ "t1": t1, @@ -1455,7 +1455,7 @@ func TestBuildVSchemaDupVindex(t *testing.T) { }, }, "ksb": { - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, Keyspace: ksb, Tables: map[string]*Table{ "t1": t2, @@ -1914,7 +1914,7 @@ func TestSequence(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ "unsharded": { - ForeignKeyMode: vschemapb.Keyspace_Fk_disallow, + ForeignKeyMode: vschemapb.Keyspace_FK_DISALLOW, Tables: map[string]*vschemapb.Table{ "seq": { Type: "sequence", @@ -1923,7 +1923,7 @@ func TestSequence(t *testing.T) { }, "sharded": { Sharded: true, - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, Vindexes: map[string]*vschemapb.Vindex{ "stfu1": { Type: "stfu", @@ -2033,7 +2033,7 @@ func TestSequence(t *testing.T) { }, Keyspaces: map[string]*KeyspaceSchema{ "unsharded": { - ForeignKeyMode: vschemapb.Keyspace_Fk_disallow, + ForeignKeyMode: vschemapb.Keyspace_FK_DISALLOW, Keyspace: ksu, Tables: map[string]*Table{ "seq": seq, @@ -2041,7 +2041,7 @@ func TestSequence(t *testing.T) { Vindexes: map[string]Vindex{}, }, "sharded": { - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, Keyspace: kss, Tables: map[string]*Table{ "t1": t1, @@ -2472,7 +2472,7 @@ func TestBuildKeyspaceSchema(t *testing.T) { } want := &KeyspaceSchema{ Keyspace: ks, - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, Tables: map[string]*Table{ "t1": t1, "t2": t2, @@ -2594,7 +2594,7 @@ func TestVSchemaJSON(t *testing.T) { in := map[string]*KeyspaceSchema{ "unsharded": { - ForeignKeyMode: vschemapb.Keyspace_Fk_managed, + ForeignKeyMode: vschemapb.Keyspace_FK_MANAGED, Keyspace: &Keyspace{ Name: "k1", }, @@ -2615,7 +2615,7 @@ func TestVSchemaJSON(t *testing.T) { }, }, "sharded": { - ForeignKeyMode: vschemapb.Keyspace_Fk_disallow, + ForeignKeyMode: vschemapb.Keyspace_FK_DISALLOW, Keyspace: &Keyspace{ Name: "k2", Sharded: true, diff --git a/go/vt/vtgate/vschema_manager_test.go b/go/vt/vtgate/vschema_manager_test.go index 10630c385e8..4aa81442f38 100644 --- a/go/vt/vtgate/vschema_manager_test.go +++ b/go/vt/vtgate/vschema_manager_test.go @@ -223,7 +223,7 @@ func makeTestVSchema(ks string, sharded bool, tbls map[string]*vindexes.Table) * Sharded: sharded, }, // Default foreign key mode - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, Tables: tbls, Vindexes: map[string]vindexes.Vindex{}, } @@ -244,7 +244,7 @@ func makeTestSrvVSchema(ks string, sharded bool, tbls map[string]*vschemapb.Tabl Sharded: sharded, Tables: tbls, // Default foreign key mode - ForeignKeyMode: vschemapb.Keyspace_Fk_unmanaged, + ForeignKeyMode: vschemapb.Keyspace_FK_UNMANAGED, } return &vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ks: keyspaceSchema}, diff --git a/proto/vschema.proto b/proto/vschema.proto index 9c0355e3205..ea6482a4825 100644 --- a/proto/vschema.proto +++ b/proto/vschema.proto @@ -49,10 +49,10 @@ message Keyspace { ForeignKeyMode foreign_key_mode = 5; enum ForeignKeyMode { - Fk_default = 0; - Fk_disallow = 1; - Fk_unmanaged = 2; - Fk_managed = 3; + FK_DEFAULT = 0; + FK_DISALLOW = 1; + FK_UNMANAGED = 2; + FK_MANAGED = 3; } } diff --git a/web/vtadmin/src/proto/vtadmin.d.ts b/web/vtadmin/src/proto/vtadmin.d.ts index b3391e8bde2..7682b62e463 100644 --- a/web/vtadmin/src/proto/vtadmin.d.ts +++ b/web/vtadmin/src/proto/vtadmin.d.ts @@ -39492,10 +39492,10 @@ export namespace vschema { /** ForeignKeyMode enum. */ enum ForeignKeyMode { - Fk_default = 0, - Fk_disallow = 1, - Fk_unmanaged = 2, - Fk_managed = 3 + FK_DEFAULT = 0, + FK_DISALLOW = 1, + FK_UNMANAGED = 2, + FK_MANAGED = 3 } } diff --git a/web/vtadmin/src/proto/vtadmin.js b/web/vtadmin/src/proto/vtadmin.js index 549649ffc71..006cef2e714 100644 --- a/web/vtadmin/src/proto/vtadmin.js +++ b/web/vtadmin/src/proto/vtadmin.js @@ -95212,19 +95212,19 @@ export const vschema = $root.vschema = (() => { break; } break; - case "Fk_default": + case "FK_DEFAULT": case 0: message.foreign_key_mode = 0; break; - case "Fk_disallow": + case "FK_DISALLOW": case 1: message.foreign_key_mode = 1; break; - case "Fk_unmanaged": + case "FK_UNMANAGED": case 2: message.foreign_key_mode = 2; break; - case "Fk_managed": + case "FK_MANAGED": case 3: message.foreign_key_mode = 3; break; @@ -95252,7 +95252,7 @@ export const vschema = $root.vschema = (() => { if (options.defaults) { object.sharded = false; object.require_explicit_routing = false; - object.foreign_key_mode = options.enums === String ? "Fk_default" : 0; + object.foreign_key_mode = options.enums === String ? "FK_DEFAULT" : 0; } if (message.sharded != null && message.hasOwnProperty("sharded")) object.sharded = message.sharded; @@ -95304,17 +95304,17 @@ export const vschema = $root.vschema = (() => { * ForeignKeyMode enum. * @name vschema.Keyspace.ForeignKeyMode * @enum {number} - * @property {number} Fk_default=0 Fk_default value - * @property {number} Fk_disallow=1 Fk_disallow value - * @property {number} Fk_unmanaged=2 Fk_unmanaged value - * @property {number} Fk_managed=3 Fk_managed value + * @property {number} FK_DEFAULT=0 FK_DEFAULT value + * @property {number} FK_DISALLOW=1 FK_DISALLOW value + * @property {number} FK_UNMANAGED=2 FK_UNMANAGED value + * @property {number} FK_MANAGED=3 FK_MANAGED value */ Keyspace.ForeignKeyMode = (function() { const valuesById = {}, values = Object.create(valuesById); - values[valuesById[0] = "Fk_default"] = 0; - values[valuesById[1] = "Fk_disallow"] = 1; - values[valuesById[2] = "Fk_unmanaged"] = 2; - values[valuesById[3] = "Fk_managed"] = 3; + values[valuesById[0] = "FK_DEFAULT"] = 0; + values[valuesById[1] = "FK_DISALLOW"] = 1; + values[valuesById[2] = "FK_UNMANAGED"] = 2; + values[valuesById[3] = "FK_MANAGED"] = 3; return values; })(); From 2a0b121644ea12fa797438c8bb450f4abdcd7315 Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Thu, 20 Jul 2023 12:27:35 +0530 Subject: [PATCH 6/7] feat: fix casing in test expectations Signed-off-by: Manan Gupta --- go/vt/vtgate/vindexes/vschema_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/go/vt/vtgate/vindexes/vschema_test.go b/go/vt/vtgate/vindexes/vschema_test.go index 9087a007789..c7257e0a633 100644 --- a/go/vt/vtgate/vindexes/vschema_test.go +++ b/go/vt/vtgate/vindexes/vschema_test.go @@ -357,7 +357,7 @@ func TestVSchemaViews(t *testing.T) { got := string(out) want := ` { - "foreignKeyMode":"Fk_unmanaged", + "foreignKeyMode":"FK_UNMANAGED", "tables": { "t1": { "name": "t1", @@ -2642,7 +2642,7 @@ func TestVSchemaJSON(t *testing.T) { want := `{ "sharded": { "sharded": true, - "foreignKeyMode": "Fk_disallow", + "foreignKeyMode": "FK_DISALLOW", "tables": { "t3": { "name": "n3", @@ -2667,7 +2667,7 @@ func TestVSchemaJSON(t *testing.T) { } }, "unsharded": { - "foreignKeyMode": "Fk_managed", + "foreignKeyMode": "FK_MANAGED", "tables": { "t1": { "name": "n1", From 8c84d7da60ea945cf12fff9e543fddaab28cb60d Mon Sep 17 00:00:00 2001 From: Manan Gupta Date: Thu, 20 Jul 2023 14:19:59 +0530 Subject: [PATCH 7/7] feat: fix TestUpdateVSchema Signed-off-by: Manan Gupta --- go/vt/vttablet/tabletserver/vstreamer/engine_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/go/vt/vttablet/tabletserver/vstreamer/engine_test.go b/go/vt/vttablet/tabletserver/vstreamer/engine_test.go index 7324e59c3b9..825d251365a 100644 --- a/go/vt/vttablet/tabletserver/vstreamer/engine_test.go +++ b/go/vt/vttablet/tabletserver/vstreamer/engine_test.go @@ -110,6 +110,7 @@ func TestUpdateVSchema(t *testing.T) { "keyspaces": { "vttest": { "sharded": true, + "foreignKeyMode": "FK_UNMANAGED", "tables": { "t1": { "name": "t1",