diff --git a/Makefile b/Makefile index 99e787d7ad..2ea7f3ecab 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ check: @echo "vet --shadow" @ go tool vet --shadow . 2>&1 | grep -vE 'Godeps' | awk '{print} END{if(NR>0) {exit 1}}' @echo "golint" - @ $(GOLINT) ./... 2>&1 | grep -vE 'LastInsertId|NewLexer' | awk '{print} END{if(NR>0) {exit 1}}' + @ $(GOLINT) ./... 2>&1 | grep -vE 'LastInsertId|NewLexer|\.pb\.go' | awk '{print} END{if(NR>0) {exit 1}}' @echo "gofmt (simplify)" @ gofmt -s -l . 2>&1 | grep -vE 'Godeps|parser/parser.go|parser/scanner.go' | awk '{print} END{if(NR>0) {exit 1}}' diff --git a/xapi/tipb/expression.pb.go b/xapi/tipb/expression.pb.go new file mode 100644 index 0000000000..0f008cec04 --- /dev/null +++ b/xapi/tipb/expression.pb.go @@ -0,0 +1,458 @@ +// Code generated by protoc-gen-go. +// source: expression.proto +// DO NOT EDIT! + +/* +Package tipb is a generated protocol buffer package. + +It is generated from these files: + expression.proto + schema.proto + select.proto + +It has these top-level messages: + Expr + TableInfo + ColumnInfo + IndexInfo + KeyRange + ByItem + SelectRequest + Row + Error + SelectResponse +*/ +package tipb + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +const _ = proto.ProtoPackageIsVersion1 + +type ExprType int32 + +const ( + // Values are encoded bytes. + ExprType_Null ExprType = 0 + ExprType_Int64 ExprType = 1 + ExprType_Uint64 ExprType = 2 + ExprType_Float32 ExprType = 3 + ExprType_Float64 ExprType = 4 + ExprType_String ExprType = 5 + ExprType_Bytes ExprType = 6 + // Mysql specific types. + ExprType_MysqlBit ExprType = 101 + ExprType_MysqlDecimal ExprType = 102 + ExprType_MysqlDuration ExprType = 103 + ExprType_MysqlEnum ExprType = 104 + ExprType_MysqlHex ExprType = 105 + ExprType_MysqlSet ExprType = 106 + ExprType_MysqlTime ExprType = 107 + // Column reference. value is int64 column ID. + ExprType_ColumnRef ExprType = 201 + // Unary operations, children count 1. + ExprType_Not ExprType = 1001 + ExprType_Neg ExprType = 1002 + ExprType_BitNeg ExprType = 1003 + // Comparison operations. + ExprType_LT ExprType = 2001 + ExprType_LE ExprType = 2002 + ExprType_EQ ExprType = 2003 + ExprType_NE ExprType = 2004 + ExprType_GE ExprType = 2005 + ExprType_GT ExprType = 2006 + ExprType_NullEQ ExprType = 2007 + // Bit operations. + ExprType_BitAnd ExprType = 2101 + ExprType_BitOr ExprType = 2102 + ExprType_BitXor ExprType = 2103 + ExprType_LeftShift ExprType = 2104 + ExprType_RighShift ExprType = 2105 + // Arithmatic. + ExprType_Plus ExprType = 2201 + ExprType_Minus ExprType = 2202 + ExprType_Mul ExprType = 2203 + ExprType_Div ExprType = 2204 + ExprType_IntDiv ExprType = 2205 + ExprType_Mod ExprType = 2206 + // Logic operations. + ExprType_And ExprType = 2301 + ExprType_Or ExprType = 2302 + ExprType_Xor ExprType = 2303 + // Aggregate functions. + ExprType_Count ExprType = 3001 + ExprType_Sum ExprType = 3002 + ExprType_Avg ExprType = 3003 + ExprType_Min ExprType = 3004 + ExprType_Max ExprType = 3005 + ExprType_First ExprType = 3006 + ExprType_GroupConcat ExprType = 3007 + // Math functions. + ExprType_Abs ExprType = 3101 + ExprType_Pow ExprType = 3102 + // String functions. + ExprType_Concat ExprType = 3201 + ExprType_ConcatWS ExprType = 3202 + ExprType_Left ExprType = 3203 + ExprType_Length ExprType = 3204 + ExprType_Lower ExprType = 3205 + ExprType_Repeat ExprType = 3206 + ExprType_Replace ExprType = 3207 + ExprType_Upper ExprType = 3208 + ExprType_Strcmp ExprType = 3209 + ExprType_Convert ExprType = 3210 + ExprType_Cast ExprType = 3211 + ExprType_Substring ExprType = 3212 + ExprType_SubstringIndex ExprType = 3213 + ExprType_Locate ExprType = 3214 + ExprType_Trim ExprType = 3215 + // Control flow functions. + ExprType_If ExprType = 3301 + ExprType_NullIf ExprType = 3302 + ExprType_IfNull ExprType = 3303 + // Time functions. + ExprType_Date ExprType = 3401 + ExprType_DateAdd ExprType = 3402 + ExprType_DateSub ExprType = 3403 + ExprType_Year ExprType = 3411 + ExprType_YearWeek ExprType = 3412 + ExprType_Month ExprType = 3421 + ExprType_Week ExprType = 3431 + ExprType_Weekday ExprType = 3432 + ExprType_WeekOfYear ExprType = 3433 + ExprType_Day ExprType = 3441 + ExprType_DayName ExprType = 3442 + ExprType_DayOfYear ExprType = 3443 + ExprType_DayOfMonth ExprType = 3444 + ExprType_DayOfWeek ExprType = 3445 + ExprType_Hour ExprType = 3451 + ExprType_Minute ExprType = 3452 + ExprType_Second ExprType = 3453 + ExprType_Microsecond ExprType = 3454 + ExprType_Extract ExprType = 3461 + // Other functions; + ExprType_Coalesce ExprType = 3501 + // Other expressions. + ExprType_In ExprType = 4001 + ExprType_IsTruth ExprType = 4002 + ExprType_IsNull ExprType = 4003 + ExprType_ExprRow ExprType = 4004 + ExprType_Like ExprType = 4005 + ExprType_RLike ExprType = 4006 + ExprType_Case ExprType = 4007 +) + +var ExprType_name = map[int32]string{ + 0: "Null", + 1: "Int64", + 2: "Uint64", + 3: "Float32", + 4: "Float64", + 5: "String", + 6: "Bytes", + 101: "MysqlBit", + 102: "MysqlDecimal", + 103: "MysqlDuration", + 104: "MysqlEnum", + 105: "MysqlHex", + 106: "MysqlSet", + 107: "MysqlTime", + 201: "ColumnRef", + 1001: "Not", + 1002: "Neg", + 1003: "BitNeg", + 2001: "LT", + 2002: "LE", + 2003: "EQ", + 2004: "NE", + 2005: "GE", + 2006: "GT", + 2007: "NullEQ", + 2101: "BitAnd", + 2102: "BitOr", + 2103: "BitXor", + 2104: "LeftShift", + 2105: "RighShift", + 2201: "Plus", + 2202: "Minus", + 2203: "Mul", + 2204: "Div", + 2205: "IntDiv", + 2206: "Mod", + 2301: "And", + 2302: "Or", + 2303: "Xor", + 3001: "Count", + 3002: "Sum", + 3003: "Avg", + 3004: "Min", + 3005: "Max", + 3006: "First", + 3007: "GroupConcat", + 3101: "Abs", + 3102: "Pow", + 3201: "Concat", + 3202: "ConcatWS", + 3203: "Left", + 3204: "Length", + 3205: "Lower", + 3206: "Repeat", + 3207: "Replace", + 3208: "Upper", + 3209: "Strcmp", + 3210: "Convert", + 3211: "Cast", + 3212: "Substring", + 3213: "SubstringIndex", + 3214: "Locate", + 3215: "Trim", + 3301: "If", + 3302: "NullIf", + 3303: "IfNull", + 3401: "Date", + 3402: "DateAdd", + 3403: "DateSub", + 3411: "Year", + 3412: "YearWeek", + 3421: "Month", + 3431: "Week", + 3432: "Weekday", + 3433: "WeekOfYear", + 3441: "Day", + 3442: "DayName", + 3443: "DayOfYear", + 3444: "DayOfMonth", + 3445: "DayOfWeek", + 3451: "Hour", + 3452: "Minute", + 3453: "Second", + 3454: "Microsecond", + 3461: "Extract", + 3501: "Coalesce", + 4001: "In", + 4002: "IsTruth", + 4003: "IsNull", + 4004: "ExprRow", + 4005: "Like", + 4006: "RLike", + 4007: "Case", +} +var ExprType_value = map[string]int32{ + "Null": 0, + "Int64": 1, + "Uint64": 2, + "Float32": 3, + "Float64": 4, + "String": 5, + "Bytes": 6, + "MysqlBit": 101, + "MysqlDecimal": 102, + "MysqlDuration": 103, + "MysqlEnum": 104, + "MysqlHex": 105, + "MysqlSet": 106, + "MysqlTime": 107, + "ColumnRef": 201, + "Not": 1001, + "Neg": 1002, + "BitNeg": 1003, + "LT": 2001, + "LE": 2002, + "EQ": 2003, + "NE": 2004, + "GE": 2005, + "GT": 2006, + "NullEQ": 2007, + "BitAnd": 2101, + "BitOr": 2102, + "BitXor": 2103, + "LeftShift": 2104, + "RighShift": 2105, + "Plus": 2201, + "Minus": 2202, + "Mul": 2203, + "Div": 2204, + "IntDiv": 2205, + "Mod": 2206, + "And": 2301, + "Or": 2302, + "Xor": 2303, + "Count": 3001, + "Sum": 3002, + "Avg": 3003, + "Min": 3004, + "Max": 3005, + "First": 3006, + "GroupConcat": 3007, + "Abs": 3101, + "Pow": 3102, + "Concat": 3201, + "ConcatWS": 3202, + "Left": 3203, + "Length": 3204, + "Lower": 3205, + "Repeat": 3206, + "Replace": 3207, + "Upper": 3208, + "Strcmp": 3209, + "Convert": 3210, + "Cast": 3211, + "Substring": 3212, + "SubstringIndex": 3213, + "Locate": 3214, + "Trim": 3215, + "If": 3301, + "NullIf": 3302, + "IfNull": 3303, + "Date": 3401, + "DateAdd": 3402, + "DateSub": 3403, + "Year": 3411, + "YearWeek": 3412, + "Month": 3421, + "Week": 3431, + "Weekday": 3432, + "WeekOfYear": 3433, + "Day": 3441, + "DayName": 3442, + "DayOfYear": 3443, + "DayOfMonth": 3444, + "DayOfWeek": 3445, + "Hour": 3451, + "Minute": 3452, + "Second": 3453, + "Microsecond": 3454, + "Extract": 3461, + "Coalesce": 3501, + "In": 4001, + "IsTruth": 4002, + "IsNull": 4003, + "ExprRow": 4004, + "Like": 4005, + "RLike": 4006, + "Case": 4007, +} + +func (x ExprType) Enum() *ExprType { + p := new(ExprType) + *p = x + return p +} +func (x ExprType) String() string { + return proto.EnumName(ExprType_name, int32(x)) +} +func (x *ExprType) UnmarshalJSON(data []byte) error { + value, err := proto.UnmarshalJSONEnum(ExprType_value, data, "ExprType") + if err != nil { + return err + } + *x = ExprType(value) + return nil +} +func (ExprType) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +// Evaluators should implement evaluation functions for every expression type. +type Expr struct { + Tp *ExprType `protobuf:"varint,1,opt,name=tp,enum=tipb.ExprType" json:"tp,omitempty"` + Val []byte `protobuf:"bytes,2,opt,name=val" json:"val,omitempty"` + Children []*Expr `protobuf:"bytes,3,rep,name=children" json:"children,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Expr) Reset() { *m = Expr{} } +func (m *Expr) String() string { return proto.CompactTextString(m) } +func (*Expr) ProtoMessage() {} +func (*Expr) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +func (m *Expr) GetTp() ExprType { + if m != nil && m.Tp != nil { + return *m.Tp + } + return ExprType_Null +} + +func (m *Expr) GetVal() []byte { + if m != nil { + return m.Val + } + return nil +} + +func (m *Expr) GetChildren() []*Expr { + if m != nil { + return m.Children + } + return nil +} + +func init() { + proto.RegisterType((*Expr)(nil), "tipb.Expr") + proto.RegisterEnum("tipb.ExprType", ExprType_name, ExprType_value) +} + +var fileDescriptor0 = []byte{ + // 865 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x44, 0x54, 0x49, 0x70, 0x1b, 0x55, + 0x10, 0x45, 0x96, 0x6c, 0xc9, 0xdf, 0x8e, 0xdd, 0x1a, 0x8a, 0xb2, 0x66, 0x42, 0x95, 0x52, 0x9c, + 0x52, 0x1c, 0x7c, 0x30, 0x14, 0x77, 0x2f, 0x4a, 0xa2, 0x2a, 0xcb, 0x31, 0x92, 0x52, 0x81, 0xe3, + 0x78, 0xe6, 0x4b, 0xfa, 0x78, 0x34, 0x7f, 0xf8, 0xf3, 0x47, 0x91, 0x8e, 0x2c, 0x61, 0x5f, 0xce, + 0x2c, 0x4e, 0x15, 0xfb, 0x89, 0x23, 0xfb, 0x76, 0x0e, 0x9c, 0x20, 0x01, 0x4e, 0x1c, 0x21, 0x04, + 0x4e, 0x6c, 0x27, 0x20, 0xd0, 0xdd, 0xa3, 0x28, 0xb7, 0xf7, 0xba, 0x5f, 0x2f, 0xbf, 0xbb, 0x67, + 0x04, 0xc8, 0x71, 0x62, 0x64, 0x9a, 0x2a, 0x1d, 0xaf, 0x27, 0x46, 0x5b, 0xed, 0x94, 0xac, 0x4a, + 0x0e, 0xee, 0x6a, 0x89, 0x52, 0x03, 0x3d, 0x8e, 0x27, 0xe6, 0x6c, 0x52, 0x2b, 0x9c, 0x28, 0x9c, + 0x5c, 0xd9, 0x58, 0x59, 0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0x7c, 0x22, 0x05, 0x00, + 0x00, +} diff --git a/xapi/tipb/expression.proto b/xapi/tipb/expression.proto new file mode 100644 index 0000000000..09f95b9dc4 --- /dev/null +++ b/xapi/tipb/expression.proto @@ -0,0 +1,147 @@ +syntax = "proto2"; + +package tipb; + +option java_multiple_files = true; +option java_package = "com.pingcap.tidb.tipb"; + +enum ExprType { + /* Children count 0. */ + // Values are encoded bytes. + Null = 0; + Int64 = 1; + Uint64 = 2; + Float32 = 3; + Float64 = 4; + String = 5; + Bytes = 6; + + // Mysql specific types. + MysqlBit = 101; + MysqlDecimal = 102; + MysqlDuration = 103; + MysqlEnum = 104; + MysqlHex = 105; + MysqlSet = 106; + MysqlTime = 107; + + // Column reference. value is int64 column ID. + ColumnRef = 201; + + /* Unary operations, children count 1. */ + Not = 1001; + Neg = 1002; + BitNeg = 1003; + + /* Binary operations, children count 2. */ + // Comparison operations. + LT = 2001; + LE = 2002; + EQ = 2003; + NE = 2004; + GE = 2005; + GT = 2006; + NullEQ = 2007; + + // Bit operations. + BitAnd = 2101; + BitOr = 2102; + BitXor = 2103; + LeftShift = 2104; + RighShift = 2105; + + // Arithmatic. + Plus = 2201; + Minus = 2202; + Mul = 2203; + Div = 2204; + IntDiv = 2205; + Mod = 2206; + + // Logic operations. + And = 2301; + Or = 2302; + Xor = 2303; + + /* Mysql functions, children count is function specific. */ + // Aggregate functions. + Count = 3001; + Sum = 3002; + Avg = 3003; + Min = 3004; + Max = 3005; + First = 3006; + GroupConcat = 3007; + + // Math functions. + Abs = 3101; + Pow = 3102; + + // String functions. + Concat = 3201; + ConcatWS = 3202; + Left = 3203; + Length = 3204; + Lower = 3205; + Repeat = 3206; + Replace = 3207; + Upper = 3208; + Strcmp = 3209; + Convert = 3210; + Cast = 3211; + Substring = 3212; + SubstringIndex = 3213; + Locate = 3214; + Trim = 3215; + + // Control flow functions. + If = 3301; + NullIf = 3302; + IfNull = 3303; + + // Time functions. + Date = 3401; + DateAdd = 3402; + DateSub = 3403; + + Year = 3411; + YearWeek = 3412; + + Month = 3421; + + Week = 3431; + Weekday = 3432; + WeekOfYear = 3433; + + Day = 3441; + DayName = 3442; + DayOfYear = 3443; + DayOfMonth = 3444; + DayOfWeek = 3445; + + Hour = 3451; + Minute = 3452; + Second = 3453; + Microsecond = 3454; + + Extract = 3461; + + // Other functions; + Coalesce = 3501; + + /* Other expressions. */ + In = 4001; + IsTruth = 4002; + IsNull = 4003; + ExprRow = 4004; + Like = 4005; + RLike = 4006; + Case = 4007; +} + +// Evaluators should implement evaluation functions for every expression type. +message Expr { + optional ExprType tp = 1; + optional bytes val = 2; + repeated Expr children = 3; +} diff --git a/xapi/tipb/schema.pb.go b/xapi/tipb/schema.pb.go new file mode 100644 index 0000000000..05afa2d0c1 --- /dev/null +++ b/xapi/tipb/schema.pb.go @@ -0,0 +1,179 @@ +// Code generated by protoc-gen-go. +// source: schema.proto +// DO NOT EDIT! + +package tipb + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +type TableInfo struct { + TableId *int64 `protobuf:"varint,1,opt,name=table_id" json:"table_id,omitempty"` + Columns []*ColumnInfo `protobuf:"bytes,2,rep,name=columns" json:"columns,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *TableInfo) Reset() { *m = TableInfo{} } +func (m *TableInfo) String() string { return proto.CompactTextString(m) } +func (*TableInfo) ProtoMessage() {} +func (*TableInfo) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{0} } + +func (m *TableInfo) GetTableId() int64 { + if m != nil && m.TableId != nil { + return *m.TableId + } + return 0 +} + +func (m *TableInfo) GetColumns() []*ColumnInfo { + if m != nil { + return m.Columns + } + return nil +} + +type ColumnInfo struct { + ColumnId *int64 `protobuf:"varint,1,opt,name=column_id" json:"column_id,omitempty"` + Tp *int32 `protobuf:"varint,2,opt,name=tp" json:"tp,omitempty"` + Collation *int32 `protobuf:"varint,3,opt,name=collation" json:"collation,omitempty"` + ColumnLen *int32 `protobuf:"varint,4,opt,name=columnLen" json:"columnLen,omitempty"` + Decimal *int32 `protobuf:"varint,5,opt,name=decimal" json:"decimal,omitempty"` + Flag *int32 `protobuf:"varint,6,opt,name=flag" json:"flag,omitempty"` + Elems []string `protobuf:"bytes,7,rep,name=elems" json:"elems,omitempty"` + PkHandle *bool `protobuf:"varint,21,opt,name=pk_handle" json:"pk_handle,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ColumnInfo) Reset() { *m = ColumnInfo{} } +func (m *ColumnInfo) String() string { return proto.CompactTextString(m) } +func (*ColumnInfo) ProtoMessage() {} +func (*ColumnInfo) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{1} } + +func (m *ColumnInfo) GetColumnId() int64 { + if m != nil && m.ColumnId != nil { + return *m.ColumnId + } + return 0 +} + +func (m *ColumnInfo) GetTp() int32 { + if m != nil && m.Tp != nil { + return *m.Tp + } + return 0 +} + +func (m *ColumnInfo) GetCollation() int32 { + if m != nil && m.Collation != nil { + return *m.Collation + } + return 0 +} + +func (m *ColumnInfo) GetColumnLen() int32 { + if m != nil && m.ColumnLen != nil { + return *m.ColumnLen + } + return 0 +} + +func (m *ColumnInfo) GetDecimal() int32 { + if m != nil && m.Decimal != nil { + return *m.Decimal + } + return 0 +} + +func (m *ColumnInfo) GetFlag() int32 { + if m != nil && m.Flag != nil { + return *m.Flag + } + return 0 +} + +func (m *ColumnInfo) GetElems() []string { + if m != nil { + return m.Elems + } + return nil +} + +func (m *ColumnInfo) GetPkHandle() bool { + if m != nil && m.PkHandle != nil { + return *m.PkHandle + } + return false +} + +type IndexInfo struct { + TableId *int64 `protobuf:"varint,1,opt,name=table_id" json:"table_id,omitempty"` + IndexId *int64 `protobuf:"varint,2,opt,name=index_id" json:"index_id,omitempty"` + Columns []*ColumnInfo `protobuf:"bytes,3,rep,name=columns" json:"columns,omitempty"` + Unique *bool `protobuf:"varint,4,opt,name=unique" json:"unique,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *IndexInfo) Reset() { *m = IndexInfo{} } +func (m *IndexInfo) String() string { return proto.CompactTextString(m) } +func (*IndexInfo) ProtoMessage() {} +func (*IndexInfo) Descriptor() ([]byte, []int) { return fileDescriptor1, []int{2} } + +func (m *IndexInfo) GetTableId() int64 { + if m != nil && m.TableId != nil { + return *m.TableId + } + return 0 +} + +func (m *IndexInfo) GetIndexId() int64 { + if m != nil && m.IndexId != nil { + return *m.IndexId + } + return 0 +} + +func (m *IndexInfo) GetColumns() []*ColumnInfo { + if m != nil { + return m.Columns + } + return nil +} + +func (m *IndexInfo) GetUnique() bool { + if m != nil && m.Unique != nil { + return *m.Unique + } + return false +} + +func init() { + proto.RegisterType((*TableInfo)(nil), "tipb.TableInfo") + proto.RegisterType((*ColumnInfo)(nil), "tipb.ColumnInfo") + proto.RegisterType((*IndexInfo)(nil), "tipb.IndexInfo") +} + +var fileDescriptor1 = []byte{ + // 249 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x74, 0x8f, 0x3d, 0x4f, 0xc3, 0x30, + 0x10, 0x86, 0x95, 0xaf, 0x26, 0x39, 0x0a, 0x14, 0x4b, 0x95, 0xcc, 0x56, 0x32, 0x65, 0xca, 0xc0, + 0x2f, 0x40, 0x30, 0x55, 0x62, 0x60, 0x60, 0xaf, 0x1c, 0xfb, 0xda, 0x5a, 0xf8, 0x0b, 0xe2, 0x48, + 0xfc, 0x0e, 0x7e, 0x31, 0xb6, 0x41, 0x2a, 0x42, 0x30, 0xbe, 0xcf, 0xdd, 0x73, 0xba, 0x17, 0x96, + 0x13, 0x3f, 0xa2, 0x66, 0x83, 0x7b, 0xb3, 0xde, 0x92, 0xd2, 0x4b, 0x37, 0x76, 0x77, 0xd0, 0x3e, + 0xb3, 0x51, 0xe1, 0xd6, 0xec, 0x2d, 0x59, 0x41, 0xe3, 0x63, 0xd8, 0x49, 0x41, 0xb3, 0x4d, 0xd6, + 0x17, 0xe4, 0x06, 0x6a, 0x6e, 0xd5, 0xac, 0xcd, 0x44, 0xf3, 0x4d, 0xd1, 0x9f, 0xdd, 0xae, 0x86, + 0xa8, 0x0d, 0x0f, 0x09, 0x46, 0xa9, 0xfb, 0xc8, 0x00, 0x4e, 0x91, 0x5c, 0x41, 0xfb, 0x65, 0x9c, + 0x8e, 0x00, 0xe4, 0xde, 0x05, 0x3f, 0xeb, 0xab, 0xef, 0xb1, 0x62, 0x5e, 0x5a, 0x43, 0x8b, 0x1f, + 0x28, 0x18, 0x8f, 0x68, 0x68, 0x99, 0xd0, 0x25, 0xd4, 0x02, 0xb9, 0xd4, 0x4c, 0xd1, 0x2a, 0x81, + 0x25, 0x94, 0x7b, 0xc5, 0x0e, 0x74, 0x91, 0xd2, 0x39, 0x54, 0xa8, 0x50, 0x4f, 0xb4, 0x0e, 0x3f, + 0xb5, 0xf1, 0x80, 0x7b, 0xd9, 0x1d, 0x99, 0x11, 0x0a, 0xe9, 0x3a, 0x6c, 0x34, 0xdd, 0x08, 0xed, + 0xd6, 0x08, 0x7c, 0xff, 0xa7, 0x56, 0x20, 0x32, 0x8e, 0x23, 0xc9, 0x7f, 0x17, 0x2d, 0xfe, 0x2e, + 0x4a, 0x2e, 0x60, 0x31, 0x1b, 0xf9, 0x3a, 0x63, 0x7a, 0xb2, 0xb9, 0xbf, 0x86, 0x35, 0xb7, 0x7a, + 0x70, 0xd2, 0x1c, 0x38, 0x73, 0x61, 0x5d, 0x8c, 0xc9, 0x79, 0xca, 0x3e, 0x03, 0x00, 0x00, 0xff, + 0xff, 0xca, 0x33, 0x46, 0xc7, 0x6a, 0x01, 0x00, 0x00, +} diff --git a/xapi/tipb/schema.proto b/xapi/tipb/schema.proto new file mode 100644 index 0000000000..9dc95135f3 --- /dev/null +++ b/xapi/tipb/schema.proto @@ -0,0 +1,29 @@ +syntax = "proto2"; + +package tipb; + +option java_multiple_files = true; +option java_package = "com.pingcap.tidb.tipb"; + +message TableInfo { + optional int64 table_id = 1; + repeated ColumnInfo columns = 2; +} + +message ColumnInfo { + optional int64 column_id = 1; + optional int32 tp = 2; // MySQL type. + optional int32 collation = 3; + optional int32 columnLen = 4; + optional int32 decimal = 5; + optional int32 flag = 6; + repeated string elems = 7; + optional bool pk_handle = 21; // PK handle column value is row handle. +} + +message IndexInfo { + optional int64 table_id = 1; + optional int64 index_id = 2; + repeated ColumnInfo columns = 3; + optional bool unique = 4; +} diff --git a/xapi/tipb/select.pb.go b/xapi/tipb/select.pb.go new file mode 100644 index 0000000000..1e66b6ed84 --- /dev/null +++ b/xapi/tipb/select.pb.go @@ -0,0 +1,302 @@ +// Code generated by protoc-gen-go. +// source: select.proto +// DO NOT EDIT! + +package tipb + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// KeyRange is the encoded index key range, low is closed, high is open. (low <= x < high) +type KeyRange struct { + Low []byte `protobuf:"bytes,1,opt,name=low" json:"low,omitempty"` + High []byte `protobuf:"bytes,2,opt,name=high" json:"high,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *KeyRange) Reset() { *m = KeyRange{} } +func (m *KeyRange) String() string { return proto.CompactTextString(m) } +func (*KeyRange) ProtoMessage() {} +func (*KeyRange) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{0} } + +func (m *KeyRange) GetLow() []byte { + if m != nil { + return m.Low + } + return nil +} + +func (m *KeyRange) GetHigh() []byte { + if m != nil { + return m.High + } + return nil +} + +// ByItem type for group by and order by. +type ByItem struct { + Expr *Expr `protobuf:"bytes,1,opt,name=expr" json:"expr,omitempty"` + Desc *bool `protobuf:"varint,2,opt,name=desc" json:"desc,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *ByItem) Reset() { *m = ByItem{} } +func (m *ByItem) String() string { return proto.CompactTextString(m) } +func (*ByItem) ProtoMessage() {} +func (*ByItem) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{1} } + +func (m *ByItem) GetExpr() *Expr { + if m != nil { + return m.Expr + } + return nil +} + +func (m *ByItem) GetDesc() bool { + if m != nil && m.Desc != nil { + return *m.Desc + } + return false +} + +// SelectRequest works like a simplified select statement. +type SelectRequest struct { + // transaction start timestamp. + StartTs *int64 `protobuf:"varint,1,opt,name=start_ts" json:"start_ts,omitempty"` + // If table_info is not null, it represents a table scan, index_info would be null. + TableInfo *TableInfo `protobuf:"bytes,2,opt,name=table_info" json:"table_info,omitempty"` + // If index_info is not null, it represents an index scan, table_info would be null. + IndexInfo *IndexInfo `protobuf:"bytes,3,opt,name=index_info" json:"index_info,omitempty"` + // fields to be selected, fields type can be column reference for simple scan. + // or aggregation function. If no fields specified, only handle will be returned. + Fields []*Expr `protobuf:"bytes,4,rep,name=fields" json:"fields,omitempty"` + // disjoint handle ranges to be scanned. + Ranges []*KeyRange `protobuf:"bytes,5,rep,name=ranges" json:"ranges,omitempty"` + // handle points to be looked up. + Points [][]byte `protobuf:"bytes,6,rep,name=points" json:"points,omitempty"` + // distinct result. + Distinct *bool `protobuf:"varint,7,opt,name=distinct" json:"distinct,omitempty"` + // where condition. + Where *Expr `protobuf:"bytes,8,opt,name=where" json:"where,omitempty"` + // group by clause. + GroupBy []*ByItem `protobuf:"bytes,9,rep,name=group_by" json:"group_by,omitempty"` + // having clause. + Having *Expr `protobuf:"bytes,10,opt,name=having" json:"having,omitempty"` + // order by clause. + OrderBy []*ByItem `protobuf:"bytes,11,rep,name=order_by" json:"order_by,omitempty"` + // limit the result to be returned; + Limit *int64 `protobuf:"varint,12,opt,name=limit" json:"limit,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SelectRequest) Reset() { *m = SelectRequest{} } +func (m *SelectRequest) String() string { return proto.CompactTextString(m) } +func (*SelectRequest) ProtoMessage() {} +func (*SelectRequest) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{2} } + +func (m *SelectRequest) GetStartTs() int64 { + if m != nil && m.StartTs != nil { + return *m.StartTs + } + return 0 +} + +func (m *SelectRequest) GetTableInfo() *TableInfo { + if m != nil { + return m.TableInfo + } + return nil +} + +func (m *SelectRequest) GetIndexInfo() *IndexInfo { + if m != nil { + return m.IndexInfo + } + return nil +} + +func (m *SelectRequest) GetFields() []*Expr { + if m != nil { + return m.Fields + } + return nil +} + +func (m *SelectRequest) GetRanges() []*KeyRange { + if m != nil { + return m.Ranges + } + return nil +} + +func (m *SelectRequest) GetPoints() [][]byte { + if m != nil { + return m.Points + } + return nil +} + +func (m *SelectRequest) GetDistinct() bool { + if m != nil && m.Distinct != nil { + return *m.Distinct + } + return false +} + +func (m *SelectRequest) GetWhere() *Expr { + if m != nil { + return m.Where + } + return nil +} + +func (m *SelectRequest) GetGroupBy() []*ByItem { + if m != nil { + return m.GroupBy + } + return nil +} + +func (m *SelectRequest) GetHaving() *Expr { + if m != nil { + return m.Having + } + return nil +} + +func (m *SelectRequest) GetOrderBy() []*ByItem { + if m != nil { + return m.OrderBy + } + return nil +} + +func (m *SelectRequest) GetLimit() int64 { + if m != nil && m.Limit != nil { + return *m.Limit + } + return 0 +} + +// values are all in text format. +type Row struct { + Handle []byte `protobuf:"bytes,1,opt,name=handle" json:"handle,omitempty"` + Data []byte `protobuf:"bytes,2,opt,name=data" json:"data,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Row) Reset() { *m = Row{} } +func (m *Row) String() string { return proto.CompactTextString(m) } +func (*Row) ProtoMessage() {} +func (*Row) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{3} } + +func (m *Row) GetHandle() []byte { + if m != nil { + return m.Handle + } + return nil +} + +func (m *Row) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +type Error struct { + Code *int32 `protobuf:"varint,1,opt,name=code" json:"code,omitempty"` + Msg *string `protobuf:"bytes,2,opt,name=msg" json:"msg,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *Error) Reset() { *m = Error{} } +func (m *Error) String() string { return proto.CompactTextString(m) } +func (*Error) ProtoMessage() {} +func (*Error) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{4} } + +func (m *Error) GetCode() int32 { + if m != nil && m.Code != nil { + return *m.Code + } + return 0 +} + +func (m *Error) GetMsg() string { + if m != nil && m.Msg != nil { + return *m.Msg + } + return "" +} + +// Response for SelectRequest. +type SelectResponse struct { + Error *Error `protobuf:"bytes,1,opt,name=error" json:"error,omitempty"` + // Result rows. + Rows []*Row `protobuf:"bytes,2,rep,name=rows" json:"rows,omitempty"` + XXX_unrecognized []byte `json:"-"` +} + +func (m *SelectResponse) Reset() { *m = SelectResponse{} } +func (m *SelectResponse) String() string { return proto.CompactTextString(m) } +func (*SelectResponse) ProtoMessage() {} +func (*SelectResponse) Descriptor() ([]byte, []int) { return fileDescriptor2, []int{5} } + +func (m *SelectResponse) GetError() *Error { + if m != nil { + return m.Error + } + return nil +} + +func (m *SelectResponse) GetRows() []*Row { + if m != nil { + return m.Rows + } + return nil +} + +func init() { + proto.RegisterType((*KeyRange)(nil), "tipb.KeyRange") + proto.RegisterType((*ByItem)(nil), "tipb.ByItem") + proto.RegisterType((*SelectRequest)(nil), "tipb.SelectRequest") + proto.RegisterType((*Row)(nil), "tipb.Row") + proto.RegisterType((*Error)(nil), "tipb.Error") + proto.RegisterType((*SelectResponse)(nil), "tipb.SelectResponse") +} + +var fileDescriptor2 = []byte{ + // 404 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x6c, 0x51, 0x5d, 0x6b, 0xdb, 0x30, + 0x14, 0x25, 0xf5, 0xc7, 0x9c, 0x6b, 0x37, 0x2b, 0x86, 0x31, 0x35, 0x0f, 0xa5, 0xb8, 0x0c, 0xf6, + 0x14, 0x46, 0x7f, 0x42, 0x21, 0x0f, 0x61, 0x2f, 0x23, 0xdb, 0x7b,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00, 0x00, +} diff --git a/xapi/tipb/select.proto b/xapi/tipb/select.proto new file mode 100644 index 0000000000..8f623fe9a4 --- /dev/null +++ b/xapi/tipb/select.proto @@ -0,0 +1,80 @@ +syntax = "proto2"; + +package tipb; + +option java_multiple_files = true; +option java_package = "com.pingcap.tidb.tipb"; + +import "expression.proto"; +import "schema.proto"; + +// KeyRange is the encoded index key range, low is closed, high is open. (low <= x < high) +message KeyRange { + optional bytes low = 1; + optional bytes high = 2; +} + +// ByItem type for group by and order by. +message ByItem { + optional Expr expr = 1; + optional bool desc = 2; +} + +// SelectRequest works like a simplified select statement. +message SelectRequest { + // transaction start timestamp. + optional int64 start_ts = 1; + + // If table_info is not null, it represents a table scan, index_info would be null. + optional TableInfo table_info = 2; + + // If index_info is not null, it represents an index scan, table_info would be null. + optional IndexInfo index_info = 3; + + // fields to be selected, fields type can be column reference for simple scan. + // or aggregation function. If no fields specified, only handle will be returned. + repeated Expr fields = 4; + + // disjoint handle ranges to be scanned. + repeated KeyRange ranges = 5; + + // handle points to be looked up. + repeated bytes points = 6; + + // distinct result. + optional bool distinct = 7; + + // where condition. + optional Expr where = 8; + + // group by clause. + repeated ByItem group_by = 9; + + // having clause. + optional Expr having = 10; + + // order by clause. + repeated ByItem order_by = 11; + + // limit the result to be returned; + optional int64 limit = 12; +} + +// values are all in text format. +message Row { + optional bytes handle = 1; + optional bytes data = 2; +} + +message Error { + optional int32 code = 1; + optional string msg = 2; +} + +// Response for SelectRequest. +message SelectResponse { + optional Error error = 1; + + // Result rows. + repeated Row rows = 2; +}