code: func ConvertDatumToDecimal(sc *variable.StatementContext, d Datum) (*MyDecimal, error) {
  	dec := new(MyDecimal)
  	var err error
  	switch d.Kind() {
  	case KindInt64:
  		dec.FromInt(d.GetInt64())
  	case KindUint64:
  		dec.FromUint(d.GetUint64())
  	case KindFloat32:
  		err = dec.FromFloat64(float64(d.GetFloat32()))
  	case KindFloat64:
  		err = dec.FromFloat64(d.GetFloat64())
  	case KindString:
  		err = dec.FromString(d.GetBytes())
  	case KindMysqlDecimal:
  		*dec = *d.GetMysqlDecimal()
  	case KindMysqlHex:
  		dec.FromInt(d.GetMysqlHex().Value)
  	case KindMysqlBit:
  		dec.FromUint(d.GetMysqlBit().Value)
  	case KindMysqlEnum:
  		dec.FromUint(d.GetMysqlEnum().Value)
  	case KindMysqlSet:
  		dec.FromUint(d.GetMysqlSet().Value)
  	default:
  		err = fmt.Errorf("can't convert %v to decimal", d.GetValue())
  	}
  	return dec, err
  }
docs: // ConvertDatumToDecimal converts datum to decimal.