Report error when loading decimal value with scientific notation (#428)

Currently we do not support scientific notation of decimal value.
This commit is contained in:
Mingyu Chen
2018-12-17 21:04:18 +08:00
committed by ZHAO Chun
parent d291068b37
commit dc4cbab11e
3 changed files with 24 additions and 19 deletions

View File

@ -900,26 +900,27 @@ int DecimalValue::parse_from_str(const char* decimal_str, int32_t length) {
*buff = value * powers10[DIG_PER_DEC1 - index_in_powers10];
}
// Handle exponent
// TODO: we do not support decimal in scientific notation
if ((frac_ptr + 1) < end && (*frac_ptr == 'e' || *frac_ptr == 'E')) {
int64_t exponent = strtoll(frac_ptr + 1, (char**) end, 10);
if (end != frac_ptr + 1) { // If at least one digit
if (errno) { // system error number, it is thread local
set_to_zero();
return E_DEC_BAD_NUM;
}
if (exponent > (INT_MAX / 2) || (errno == 0 && exponent < 0)) {
set_to_zero();
return E_DEC_OVERFLOW;
}
if (exponent < INT_MAX / 2 && error != E_DEC_OVERFLOW) {
set_to_zero();
return E_DEC_TRUNCATED;
}
if (error != E_DEC_OVERFLOW) {
// error = shift((int32_t) exponent);
}
}
return E_DEC_BAD_NUM;
// int64_t exponent = strtoll(frac_ptr + 1, (char**) &end, 10);
// if (end != frac_ptr + 1) { // If at least one digit
// if (errno) { // system error number, it is thread local
// set_to_zero();
// return E_DEC_BAD_NUM;
// }
// if (exponent > (INT_MAX / 2) || (errno == 0 && exponent < 0)) {
// set_to_zero();
// return E_DEC_OVERFLOW;
// }
// if (exponent < INT_MAX / 2 && error != E_DEC_OVERFLOW) {
// set_to_zero();
// return E_DEC_TRUNCATED;
// }
// if (error != E_DEC_OVERFLOW) {
// // error = shift((int32_t) exponent);
// }
// }
}
if (_sign && is_zero()) {
_sign = false;

View File

@ -58,12 +58,15 @@
LARGEINT(16字节)
范围:0 ~ 2^127 - 1
FLOAT(4字节)
支持科学计数法
DOUBLE(12字节)
支持科学计数法
DECIMAL[(precision, scale)] (40字节)
保证精度的小数类型。默认是 DECIMAL(10, 0)
precision: 1 ~ 27
scale: 0 ~ 9
其中整数部分为 1 ~ 18
不支持科学计数法
DATE(3字节)
范围:1900-01-01 ~ 9999-12-31
DATETIME(8字节)

View File

@ -380,6 +380,7 @@
NOTE: 需要进行url编码,譬如
需要指定'\t'为分隔符,那么应该传入'column_separator=%09'
需要指定'\x01'为分隔符,那么应该传入'column_separator=%01'
需要指定','为分隔符,那么应该传入'column_separator=%2c'
max_filter_ratio: 用于指定允许过滤不规范数据的最大比例,默认是0,不允许过滤