Merge pull request #21174 from taosdata/fix/TS-3106-MAIN1

fix: print float with 20 width limit
This commit is contained in:
Hui Li 2023-05-06 13:54:46 +08:00 committed by GitHub
commit bf1cb373e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -554,7 +554,12 @@ void shellPrintField(const char *val, TAOS_FIELD *field, int32_t width, int32_t
if (tsEnableScience) { if (tsEnableScience) {
printf("%*e", width, GET_FLOAT_VAL(val)); printf("%*e", width, GET_FLOAT_VAL(val));
} else { } else {
printf("%*.5f", width, GET_FLOAT_VAL(val)); n = snprintf(buf, TSDB_MAX_BYTES_PER_ROW, "%*.5f", width, GET_FLOAT_VAL(val));
if (n > TMAX(20, width)) {
printf("%*e", width, GET_FLOAT_VAL(val));
} else {
printf("%s", buf);
}
} }
break; break;
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE: