本文整理汇总了Golang中github.com/pingcap/tidb/expression.Column.GetType方法的典型用法代码示例。如果您正苦于以下问题:Golang Column.GetType方法的具体用法?Golang Column.GetType怎么用?Golang Column.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pingcap/tidb/expression.Column
的用法示例。
在下文中一共展示了Column.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: columnToPBExpr
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)}
}
示例2: columnToPBExpr
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)}
}