func (b *executorBuilder) columnToPBExpr(client kv.Client, column *expression.Column, tbl *model.TableInfo) *tipb.Expr { if !client.SupportRequestType(kv.ReqTypeSelect, int64(tipb.ExprType_ColumnRef)) { return nil } switch column.GetType().Tp { case mysql.TypeBit, mysql.TypeSet, mysql.TypeEnum, mysql.TypeDecimal, mysql.TypeGeometry, mysql.TypeDate, mysql.TypeNewDate, mysql.TypeDatetime, mysql.TypeTimestamp, mysql.TypeYear: return nil } id := int64(-1) for _, col := range tbl.Columns { if tbl.Name == column.TblName && col.Name == column.ColName { id = col.ID break } } // Zero Column ID is not a column from table, can not support for now. if id == 0 { return nil } // TODO:If the column ID isn't in fields, it means the column is from an outer table, // its value is available to use. if id == -1 { return nil } return &tipb.Expr{ Tp: tipb.ExprType_ColumnRef.Enum(), Val: codec.EncodeInt(nil, id)} }
func (pc pbConverter) columnToPBExpr(column *expression.Column) *tipb.Expr { if !pc.client.SupportRequestType(kv.ReqTypeSelect, int64(tipb.ExprType_ColumnRef)) { return nil } switch column.GetType().Tp { case mysql.TypeBit, mysql.TypeSet, mysql.TypeEnum, mysql.TypeGeometry, mysql.TypeDecimal: return nil } id := column.ID // Zero Column ID is not a column from table, can not support for now. if id == 0 || id == -1 { return nil } return &tipb.Expr{ Tp: tipb.ExprType_ColumnRef, Val: codec.EncodeInt(nil, id)} }