diff --git a/data/test/vtgate/schema_test.json b/data/test/vtgate/schema_test.json index 5e6ad7b1c8c..45cec310e06 100644 --- a/data/test/vtgate/schema_test.json +++ b/data/test/vtgate/schema_test.json @@ -156,6 +156,9 @@ } ] }, + "pin_test": { + "pinned": "80" + }, "weird`name": { "column_vindexes": [ { diff --git a/data/test/vtgate/select_cases.txt b/data/test/vtgate/select_cases.txt index 441bee98b92..cfc528b251e 100644 --- a/data/test/vtgate/select_cases.txt +++ b/data/test/vtgate/select_cases.txt @@ -254,6 +254,26 @@ } } +# select from pinned table +"select * from pin_test" +{ + "Original": "select * from pin_test", + "Instructions": { + "Opcode": "SelectEqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "Query": "select * from pin_test", + "FieldQuery": "select * from pin_test where 1 != 1", + "Vindex": "binary", + "Values": [ + "\ufffd" + ] + } +} + + # select from dual on sharded keyspace "select @@session.auto_increment_increment from user.dual" { diff --git a/go/vt/proto/vschema/vschema.pb.go b/go/vt/proto/vschema/vschema.pb.go index dbf7953a8c7..938a617d117 100644 --- a/go/vt/proto/vschema/vschema.pb.go +++ b/go/vt/proto/vschema/vschema.pb.go @@ -34,7 +34,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_vschema_af169a2691d671e0, []int{0} + return fileDescriptor_vschema_f0f3bc4bc6c5c748, []int{0} } func (m *Keyspace) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Keyspace.Unmarshal(m, b) @@ -99,7 +99,7 @@ func (m *Vindex) Reset() { *m = Vindex{} } func (m *Vindex) String() string { return proto.CompactTextString(m) } func (*Vindex) ProtoMessage() {} func (*Vindex) Descriptor() ([]byte, []int) { - return fileDescriptor_vschema_af169a2691d671e0, []int{1} + return fileDescriptor_vschema_f0f3bc4bc6c5c748, []int{1} } func (m *Vindex) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Vindex.Unmarshal(m, b) @@ -151,17 +151,22 @@ type Table struct { // to be associated with a sequence. AutoIncrement *AutoIncrement `protobuf:"bytes,3,opt,name=auto_increment,json=autoIncrement" json:"auto_increment,omitempty"` // columns lists the columns for the table. - Columns []*Column `protobuf:"bytes,4,rep,name=columns" json:"columns,omitempty"` - XXX_NoUnkeyedLiteral struct{} `json:"-"` - XXX_unrecognized []byte `json:"-"` - XXX_sizecache int32 `json:"-"` + Columns []*Column `protobuf:"bytes,4,rep,name=columns" json:"columns,omitempty"` + // pinned pins an unsharded table to a specific + // shard, as dictated by the keyspace id. + // The keyspace id is represened in hex form + // like in keyranges. + Pinned string `protobuf:"bytes,5,opt,name=pinned" json:"pinned,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` } func (m *Table) Reset() { *m = Table{} } func (m *Table) String() string { return proto.CompactTextString(m) } func (*Table) ProtoMessage() {} func (*Table) Descriptor() ([]byte, []int) { - return fileDescriptor_vschema_af169a2691d671e0, []int{2} + return fileDescriptor_vschema_f0f3bc4bc6c5c748, []int{2} } func (m *Table) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Table.Unmarshal(m, b) @@ -209,6 +214,13 @@ func (m *Table) GetColumns() []*Column { return nil } +func (m *Table) GetPinned() string { + if m != nil { + return m.Pinned + } + return "" +} + // ColumnVindex is used to associate a column to a vindex. type ColumnVindex struct { // Legacy implemenation, moving forward all vindexes should define a list of columns. @@ -226,7 +238,7 @@ func (m *ColumnVindex) Reset() { *m = ColumnVindex{} } func (m *ColumnVindex) String() string { return proto.CompactTextString(m) } func (*ColumnVindex) ProtoMessage() {} func (*ColumnVindex) Descriptor() ([]byte, []int) { - return fileDescriptor_vschema_af169a2691d671e0, []int{3} + return fileDescriptor_vschema_f0f3bc4bc6c5c748, []int{3} } func (m *ColumnVindex) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_ColumnVindex.Unmarshal(m, b) @@ -281,7 +293,7 @@ func (m *AutoIncrement) Reset() { *m = AutoIncrement{} } func (m *AutoIncrement) String() string { return proto.CompactTextString(m) } func (*AutoIncrement) ProtoMessage() {} func (*AutoIncrement) Descriptor() ([]byte, []int) { - return fileDescriptor_vschema_af169a2691d671e0, []int{4} + return fileDescriptor_vschema_f0f3bc4bc6c5c748, []int{4} } func (m *AutoIncrement) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_AutoIncrement.Unmarshal(m, b) @@ -328,7 +340,7 @@ func (m *Column) Reset() { *m = Column{} } func (m *Column) String() string { return proto.CompactTextString(m) } func (*Column) ProtoMessage() {} func (*Column) Descriptor() ([]byte, []int) { - return fileDescriptor_vschema_af169a2691d671e0, []int{5} + return fileDescriptor_vschema_f0f3bc4bc6c5c748, []int{5} } func (m *Column) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_Column.Unmarshal(m, b) @@ -375,7 +387,7 @@ func (m *SrvVSchema) Reset() { *m = SrvVSchema{} } func (m *SrvVSchema) String() string { return proto.CompactTextString(m) } func (*SrvVSchema) ProtoMessage() {} func (*SrvVSchema) Descriptor() ([]byte, []int) { - return fileDescriptor_vschema_af169a2691d671e0, []int{6} + return fileDescriptor_vschema_f0f3bc4bc6c5c748, []int{6} } func (m *SrvVSchema) XXX_Unmarshal(b []byte) error { return xxx_messageInfo_SrvVSchema.Unmarshal(m, b) @@ -416,41 +428,42 @@ func init() { proto.RegisterMapType((map[string]*Keyspace)(nil), "vschema.SrvVSchema.KeyspacesEntry") } -func init() { proto.RegisterFile("vschema.proto", fileDescriptor_vschema_af169a2691d671e0) } - -var fileDescriptor_vschema_af169a2691d671e0 = []byte{ - // 518 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0x5d, 0x8b, 0xd3, 0x40, - 0x14, 0x25, 0xed, 0x36, 0x6d, 0x6f, 0x6c, 0xaa, 0x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1b, 0xd7, 0x39, 0x8c, 0x5a, 0x01, 0xff, 0x6b, 0x6b, 0xc3, 0x80, 0xe1, 0x5d, 0x8e, - 0x51, 0x50, 0x5b, 0x37, 0xd8, 0x39, 0x03, 0x7d, 0xde, 0x6e, 0xae, 0x29, 0xcd, 0x8f, 0xe5, 0xd8, - 0x2b, 0x95, 0x39, 0x33, 0x5c, 0xf1, 0xea, 0x16, 0x65, 0x82, 0xe2, 0x1b, 0x38, 0xbf, 0x34, 0x80, - 0x8b, 0xb4, 0xb8, 0xbc, 0xe0, 0x17, 0x27, 0xef, 0x60, 0x78, 0x2b, 0x9f, 0x03, 0xb3, 0x34, 0x3e, - 0x15, 0xa7, 0x99, 0xca, 0xa6, 0xae, 0x79, 0x33, 0x72, 0x81, 0x36, 0x22, 0xfb, 0x0b, 0x98, 0x6d, - 0x72, 0xcf, 0xc2, 0x3c, 0x6b, 0x6f, 0xf9, 0x83, 0x9d, 0xa7, 0xa8, 0xec, 0xd0, 0x87, 0xa7, 0xdf, - 0x4e, 0x8a, 0x55, 0x86, 0x8c, 0xb9, 0xab, 0xd8, 0x13, 0x27, 0xef, 0x7b, 0xec, 0x15, 0x99, 0xc7, - 0xff, 0x3c, 0x3c, 0xa9, 0xbd, 0xd6, 0x39, 0x3c, 0xfd, 0x17, 0x00, 0x00, 0xff, 0xff, 0x7a, 0x29, - 0xa2, 0x18, 0x72, 0x04, 0x00, 0x00, +func init() { proto.RegisterFile("vschema.proto", fileDescriptor_vschema_f0f3bc4bc6c5c748) } + +var fileDescriptor_vschema_f0f3bc4bc6c5c748 = []byte{ + // 530 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x54, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0x96, 0x93, 0xc6, 0x49, 0xc6, 0x24, 0x81, 0x55, 0xa9, 0x2c, 0x23, 0xd4, 0xc8, 0x2a, 0x10, + 0x2e, 0x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 0x9a, 0xbb, + 0x84, 0x51, 0xcb, 0xf8, 0x7f, 0x65, 0x1d, 0x18, 0x70, 0xbc, 0xc9, 0x91, 0x05, 0xb5, 0x74, 0x83, + 0xdd, 0x13, 0x30, 0x97, 0xed, 0xe2, 0x86, 0x56, 0xfc, 0x50, 0x3d, 0x47, 0xc5, 0x1a, 0x2f, 0x2c, + 0x4f, 0x6e, 0xe3, 0xaa, 0x4c, 0x50, 0xbe, 0x8d, 0xfb, 0xcb, 0x00, 0x38, 0x4b, 0x8b, 0xf3, 0x33, + 0xd1, 0x10, 0xf2, 0x0e, 0x86, 0xd7, 0x6a, 0x4d, 0xb8, 0x6d, 0x88, 0x6e, 0xb9, 0x4d, 0xb7, 0x6e, + 0xf3, 0x9a, 0x5d, 0x52, 0x83, 0x75, 0x4b, 0x72, 0xbe, 0xc0, 0xb8, 0x1d, 0xdc, 0x31, 0x48, 0xcf, + 0xda, 0xd3, 0xff, 0xe0, 0xce, 0x8a, 0x6a, 0xb3, 0xf5, 0xe1, 0xe9, 0xb7, 0xa3, 0x22, 0xcc, 0x90, + 0x73, 0x2f, 0x8c, 0xe7, 0xf2, 0x34, 0xff, 0x1e, 0xcf, 0x8b, 0x6c, 0x2e, 0x7e, 0x2a, 0x73, 0xc5, + 0xbd, 0x34, 0x05, 0x3c, 0xfe, 0x17, 0x00, 0x00, 0xff, 0xff, 0x31, 0x37, 0xa1, 0xa9, 0x8a, 0x04, + 0x00, 0x00, } diff --git a/go/vt/vtgate/vindexes/vschema.go b/go/vt/vtgate/vindexes/vschema.go index bba94948cfc..7619b77d405 100644 --- a/go/vt/vtgate/vindexes/vschema.go +++ b/go/vt/vtgate/vindexes/vschema.go @@ -17,6 +17,7 @@ limitations under the License. package vindexes import ( + "encoding/hex" "encoding/json" "fmt" "io/ioutil" @@ -203,7 +204,13 @@ func buildTables(source *vschemapb.SrvVSchema, vschema *VSchema) error { if table.Type == "sequence" { t.IsSequence = true } - if keyspace.Sharded && len(table.ColumnVindexes) == 0 { + if table.Pinned != "" { + decoded, err := hex.DecodeString(table.Pinned) + if err != nil { + return fmt.Errorf("could not decode the keyspace id for pin: %v", err) + } + t.Pinned = decoded + } else if keyspace.Sharded && len(table.ColumnVindexes) == 0 { return fmt.Errorf("missing primary col vindex for table: %s", tname) } diff --git a/go/vt/vtgate/vindexes/vschema_test.go b/go/vt/vtgate/vindexes/vschema_test.go index 2d075b0733d..133922bd058 100644 --- a/go/vt/vtgate/vindexes/vschema_test.go +++ b/go/vt/vtgate/vindexes/vschema_test.go @@ -237,6 +237,61 @@ func TestVSchemaColumnsFail(t *testing.T) { } } +func TestVSchemaPinned(t *testing.T) { + good := vschemapb.SrvVSchema{ + Keyspaces: map[string]*vschemapb.Keyspace{ + "sharded": { + Sharded: true, + Tables: map[string]*vschemapb.Table{ + "t1": { + Pinned: "80", + }, + }, + }, + }, + } + got, err := BuildVSchema(&good) + if err != nil { + t.Error(err) + } + ks := &Keyspace{ + Name: "sharded", + Sharded: true, + } + t1 := &Table{ + Name: sqlparser.NewTableIdent("t1"), + Keyspace: ks, + Pinned: []byte{0x80}, + } + dual := &Table{ + Name: sqlparser.NewTableIdent("dual"), + Keyspace: ks, + Pinned: []byte{0}, + } + want := &VSchema{ + uniqueTables: map[string]*Table{ + "t1": t1, + "dual": dual, + }, + uniqueVindexes: map[string]Vindex{}, + Keyspaces: map[string]*KeyspaceSchema{ + "sharded": { + Keyspace: ks, + Tables: map[string]*Table{ + "t1": t1, + "dual": dual, + }, + Vindexes: map[string]Vindex{}, + }, + }, + } + if !reflect.DeepEqual(got, want) { + gotjson, _ := json.Marshal(got) + wantjson, _ := json.Marshal(want) + t.Errorf("BuildVSchema:\n%s, want\n%s", gotjson, wantjson) + } +} + func TestShardedVSchemaOwned(t *testing.T) { good := vschemapb.SrvVSchema{ Keyspaces: map[string]*vschemapb.Keyspace{ diff --git a/proto/vschema.proto b/proto/vschema.proto index 7dc8d3fb6db..81276a767b5 100644 --- a/proto/vschema.proto +++ b/proto/vschema.proto @@ -60,6 +60,11 @@ message Table { AutoIncrement auto_increment = 3; // columns lists the columns for the table. repeated Column columns = 4; + // pinned pins an unsharded table to a specific + // shard, as dictated by the keyspace id. + // The keyspace id is represened in hex form + // like in keyranges. + string pinned =5; } // ColumnVindex is used to associate a column to a vindex. diff --git a/py/vtproto/vschema_pb2.py b/py/vtproto/vschema_pb2.py index f516b73a840..81c5b4064e8 100644 --- a/py/vtproto/vschema_pb2.py +++ b/py/vtproto/vschema_pb2.py @@ -20,7 +20,7 @@ name='vschema.proto', package='vschema', syntax='proto3', - serialized_pb=_b('\n\rvschema.proto\x12\x07vschema\x1a\x0bquery.proto\"\xfe\x01\n\x08Keyspace\x12\x0f\n\x07sharded\x18\x01 \x01(\x08\x12\x31\n\x08vindexes\x18\x02 \x03(\x0b\x32\x1f.vschema.Keyspace.VindexesEntry\x12-\n\x06tables\x18\x03 \x03(\x0b\x32\x1d.vschema.Keyspace.TablesEntry\x1a@\n\rVindexesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1e\n\x05value\x18\x02 \x01(\x0b\x32\x0f.vschema.Vindex:\x02\x38\x01\x1a=\n\x0bTablesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1d\n\x05value\x18\x02 \x01(\x0b\x32\x0e.vschema.Table:\x02\x38\x01\"\x81\x01\n\x06Vindex\x12\x0c\n\x04type\x18\x01 \x01(\t\x12+\n\x06params\x18\x02 \x03(\x0b\x32\x1b.vschema.Vindex.ParamsEntry\x12\r\n\x05owner\x18\x03 \x01(\t\x1a-\n\x0bParamsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\x97\x01\n\x05Table\x12\x0c\n\x04type\x18\x01 \x01(\t\x12.\n\x0f\x63olumn_vindexes\x18\x02 \x03(\x0b\x32\x15.vschema.ColumnVindex\x12.\n\x0e\x61uto_increment\x18\x03 \x01(\x0b\x32\x16.vschema.AutoIncrement\x12 \n\x07\x63olumns\x18\x04 \x03(\x0b\x32\x0f.vschema.Column\"=\n\x0c\x43olumnVindex\x12\x0e\n\x06\x63olumn\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0f\n\x07\x63olumns\x18\x03 \x03(\t\"1\n\rAutoIncrement\x12\x0e\n\x06\x63olumn\x18\x01 \x01(\t\x12\x10\n\x08sequence\x18\x02 \x01(\t\"1\n\x06\x43olumn\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x19\n\x04type\x18\x02 \x01(\x0e\x32\x0b.query.Type\"\x88\x01\n\nSrvVSchema\x12\x35\n\tkeyspaces\x18\x01 \x03(\x0b\x32\".vschema.SrvVSchema.KeyspacesEntry\x1a\x43\n\x0eKeyspacesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.vschema.Keyspace:\x02\x38\x01\x42&Z$vitess.io/vitess/go/vt/proto/vschemab\x06proto3') + serialized_pb=_b('\n\rvschema.proto\x12\x07vschema\x1a\x0bquery.proto\"\xfe\x01\n\x08Keyspace\x12\x0f\n\x07sharded\x18\x01 \x01(\x08\x12\x31\n\x08vindexes\x18\x02 \x03(\x0b\x32\x1f.vschema.Keyspace.VindexesEntry\x12-\n\x06tables\x18\x03 \x03(\x0b\x32\x1d.vschema.Keyspace.TablesEntry\x1a@\n\rVindexesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1e\n\x05value\x18\x02 \x01(\x0b\x32\x0f.vschema.Vindex:\x02\x38\x01\x1a=\n\x0bTablesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x1d\n\x05value\x18\x02 \x01(\x0b\x32\x0e.vschema.Table:\x02\x38\x01\"\x81\x01\n\x06Vindex\x12\x0c\n\x04type\x18\x01 \x01(\t\x12+\n\x06params\x18\x02 \x03(\x0b\x32\x1b.vschema.Vindex.ParamsEntry\x12\r\n\x05owner\x18\x03 \x01(\t\x1a-\n\x0bParamsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"\xa7\x01\n\x05Table\x12\x0c\n\x04type\x18\x01 \x01(\t\x12.\n\x0f\x63olumn_vindexes\x18\x02 \x03(\x0b\x32\x15.vschema.ColumnVindex\x12.\n\x0e\x61uto_increment\x18\x03 \x01(\x0b\x32\x16.vschema.AutoIncrement\x12 \n\x07\x63olumns\x18\x04 \x03(\x0b\x32\x0f.vschema.Column\x12\x0e\n\x06pinned\x18\x05 \x01(\t\"=\n\x0c\x43olumnVindex\x12\x0e\n\x06\x63olumn\x18\x01 \x01(\t\x12\x0c\n\x04name\x18\x02 \x01(\t\x12\x0f\n\x07\x63olumns\x18\x03 \x03(\t\"1\n\rAutoIncrement\x12\x0e\n\x06\x63olumn\x18\x01 \x01(\t\x12\x10\n\x08sequence\x18\x02 \x01(\t\"1\n\x06\x43olumn\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x19\n\x04type\x18\x02 \x01(\x0e\x32\x0b.query.Type\"\x88\x01\n\nSrvVSchema\x12\x35\n\tkeyspaces\x18\x01 \x03(\x0b\x32\".vschema.SrvVSchema.KeyspacesEntry\x1a\x43\n\x0eKeyspacesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.vschema.Keyspace:\x02\x38\x01\x42&Z$vitess.io/vitess/go/vt/proto/vschemab\x06proto3') , dependencies=[query__pb2.DESCRIPTOR,]) @@ -263,6 +263,13 @@ message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='pinned', full_name='vschema.Table.pinned', index=4, + number=5, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=_b("").decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -276,7 +283,7 @@ oneofs=[ ], serialized_start=429, - serialized_end=580, + serialized_end=596, ) @@ -320,8 +327,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=582, - serialized_end=643, + serialized_start=598, + serialized_end=659, ) @@ -358,8 +365,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=645, - serialized_end=694, + serialized_start=661, + serialized_end=710, ) @@ -396,8 +403,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=696, - serialized_end=745, + serialized_start=712, + serialized_end=761, ) @@ -434,8 +441,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=817, - serialized_end=884, + serialized_start=833, + serialized_end=900, ) _SRVVSCHEMA = _descriptor.Descriptor( @@ -464,8 +471,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=748, - serialized_end=884, + serialized_start=764, + serialized_end=900, ) _KEYSPACE_VINDEXESENTRY.fields_by_name['value'].message_type = _VINDEX