提交 a6fee49f 编写于 作者: wmmhello's avatar wmmhello

[TD-6167]<fix> support unsigned type in stmt

上级 dc3e3fd7
......@@ -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:
......
......@@ -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));
......
......@@ -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
......
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册