code: func DecodeRange(b []byte, size int) ([]types.Datum, error) {
  	if len(b) < 1 {
  		return nil, errors.New("invalid encoded key: length of key is zero")
  	}
  
  	var (
  		err    error
  		values = make([]types.Datum, 0, size)
  	)
  
  	for len(b) > 1 {
  		var d types.Datum
  		b, d, err = DecodeOne(b)
  		if err != nil {
  			return nil, errors.Trace(err)
  		}
  		values = append(values, d)
  	}
  
  	if len(b) == 1 {
  		switch b[0] {
  		case NilFlag:
  			values = append(values, types.Datum{})
  		case bytesFlag:
  			values = append(values, types.MinNotNullDatum())
  		// `maxFlag + 1` for PrefixNext
  		case maxFlag, maxFlag + 1:
  			values = append(values, types.MaxValueDatum())
  		default:
  			return nil, errors.Errorf("invalid encoded key flag %v", b[0])
  		}
  	}
  	return values, nil
  }
docs: // DecodeRange decodes the range values from a byte slice that generated by EncodeKey.
  // It handles some special values like `MinNotNull` and `MaxValueDatum`.