diff --git a/src/client/src/tscPrepare.c b/src/client/src/tscPrepare.c index 099ee77bc5d94d6542068f96af380462d358aa8f..36dd60c4feeb3691e27164e309e43586374da13a 100644 --- a/src/client/src/tscPrepare.c +++ b/src/client/src/tscPrepare.c @@ -289,7 +289,7 @@ static char* normalStmtBuildSql(STscStmt* stmt) { case TSDB_DATA_TYPE_USMALLINT: case TSDB_DATA_TYPE_UINT: case TSDB_DATA_TYPE_UBIGINT: - taosStringBuilderAppendInteger(&sb, var->u64); // maybe overflow if u64 is too big + taosStringBuilderAppendUnsignedInteger(&sb, var->u64); break; case TSDB_DATA_TYPE_FLOAT: diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 2be11a406a3b193147bbe33a8f49f62d3eda108d..ff4d0e43e6a12c7f92e301d19f8688e48ff88283 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -60,6 +60,21 @@ int32_t converToStr(char *str, int type, void *buf, int32_t bufSize, int32_t *le case TSDB_DATA_TYPE_TIMESTAMP: n = sprintf(str, "%" PRId64, *(int64_t*)buf); break; + case TSDB_DATA_TYPE_UTINYINT: + n = sprintf(str, "%d", *(uint8_t*)buf); + break; + + case TSDB_DATA_TYPE_USMALLINT: + n = sprintf(str, "%d", *(uint16_t*)buf); + break; + + case TSDB_DATA_TYPE_UINT: + n = sprintf(str, "%d", *(uint32_t*)buf); + break; + + case TSDB_DATA_TYPE_UBIGINT: + n = sprintf(str, "%" PRId64, *(uint64_t*)buf); + break; case TSDB_DATA_TYPE_FLOAT: n = sprintf(str, "%f", GET_FLOAT_VAL(buf)); diff --git a/src/util/inc/tstrbuild.h b/src/util/inc/tstrbuild.h index 68d1914be3c216a05a03fe6b80490ca1ee7bea4f..1bfa077e80164ef671bd939420e4da5385758ed3 100644 --- a/src/util/inc/tstrbuild.h +++ b/src/util/inc/tstrbuild.h @@ -43,6 +43,7 @@ void taosStringBuilderAppendStringLen(SStringBuilder* sb, const char* str, size_ void taosStringBuilderAppendString(SStringBuilder* sb, const char* str); void taosStringBuilderAppendNull(SStringBuilder* sb); void taosStringBuilderAppendInteger(SStringBuilder* sb, int64_t v); +void taosStringBuilderAppendUnsignedInteger(SStringBuilder* sb, uint64_t v) void taosStringBuilderAppendDouble(SStringBuilder* sb, double v); #ifdef __cplusplus diff --git a/src/util/src/tstrbuild.c b/src/util/src/tstrbuild.c index eec21d18354a4141be92530cda1a953e5efd89a8..e3d31595355351c7c4861166201ca65659f09a3a 100644 --- a/src/util/src/tstrbuild.c +++ b/src/util/src/tstrbuild.c @@ -73,6 +73,12 @@ void taosStringBuilderAppendInteger(SStringBuilder* sb, int64_t v) { taosStringBuilderAppendStringLen(sb, buf, MIN(len, sizeof(buf))); } +void taosStringBuilderAppendUnsignedInteger(SStringBuilder* sb, uint64_t v) { + char buf[64]; + size_t len = snprintf(buf, sizeof(buf), "%" PRId64, v); + taosStringBuilderAppendStringLen(sb, buf, MIN(len, sizeof(buf))); +} + void taosStringBuilderAppendDouble(SStringBuilder* sb, double v) { char buf[512]; size_t len = snprintf(buf, sizeof(buf), "%.9lf", v);