code: func (d *Datum) CompareDatum(sc *variable.StatementContext, ad Datum) (int, error) {
  	switch ad.k {
  	case KindNull:
  		if d.k == KindNull {
  			return 0, nil
  		}
  		return 1, nil
  	case KindMinNotNull:
  		if d.k == KindNull {
  			return -1, nil
  		} else if d.k == KindMinNotNull {
  			return 0, nil
  		}
  		return 1, nil
  	case KindMaxValue:
  		if d.k == KindMaxValue {
  			return 0, nil
  		}
  		return -1, nil
  	case KindInt64:
  		return d.compareInt64(sc, ad.GetInt64())
  	case KindUint64:
  		return d.compareUint64(sc, ad.GetUint64())
  	case KindFloat32, KindFloat64:
  		return d.compareFloat64(sc, ad.GetFloat64())
  	case KindString:
  		return d.compareString(sc, ad.GetString())
  	case KindBytes:
  		return d.compareBytes(sc, ad.GetBytes())
  	case KindMysqlBit:
  		return d.compareMysqlBit(sc, ad.GetMysqlBit())
  	case KindMysqlDecimal:
  		return d.compareMysqlDecimal(sc, ad.GetMysqlDecimal())
  	case KindMysqlDuration:
  		return d.compareMysqlDuration(sc, ad.GetMysqlDuration())
  	case KindMysqlEnum:
  		return d.compareMysqlEnum(sc, ad.GetMysqlEnum())
  	case KindMysqlHex:
  		return d.compareMysqlHex(sc, ad.GetMysqlHex())
  	case KindMysqlSet:
  		return d.compareMysqlSet(sc, ad.GetMysqlSet())
  	case KindMysqlTime:
  		return d.compareMysqlTime(sc, ad.GetMysqlTime())
  	case KindRow:
  		return d.compareRow(sc, ad.GetRow())
  	default:
  		return 0, nil
  	}
  }
docs: // CompareDatum compares datum to another datum.
  // TODO: return error properly.