diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 75d1e39a921efdff64cf4587ff9ab8c4c4b33486..115630d1a543dae2e5a55dbd0d6b0a815c322e27 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -145,8 +145,8 @@ do { \ #define GET_FLOAT_VAL(x) taos_align_get_float(x) #define GET_DOUBLE_VAL(x) taos_align_get_double(x) - #define SET_FLOAT_VAL(x, y) { float z = (float)(y); (*(int32_t*) x = *(int32_t*)z); } - #define SET_DOUBLE_VAL(x, y) { double z = (double)(y); (*(int64_t*) x = *(int64_t*)z); } + #define SET_FLOAT_VAL(x, y) { float z = (float)(y); (*(int32_t*) x = *(int32_t*)(&z)); } + #define SET_DOUBLE_VAL(x, y) { double z = (double)(y); (*(int64_t*) x = *(int64_t*)(&z)); } #define SET_FLOAT_PTR(x, y) { (*(int32_t*) x = *(int32_t*)y); } #define SET_DOUBLE_PTR(x, y) { (*(int64_t*) x = *(int64_t*)y); } #else diff --git a/src/plugins/http/src/httpGcJson.c b/src/plugins/http/src/httpGcJson.c index fde8ae2176007b1f042393d8d1fc112198c3ff64..d50a38201f8d1b6c64e4dee6a25fdf47fec48dd6 100644 --- a/src/plugins/http/src/httpGcJson.c +++ b/src/plugins/http/src/httpGcJson.c @@ -148,10 +148,10 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%" PRId64, fields[i].name, *((int64_t *)row[i])); break; case TSDB_DATA_TYPE_FLOAT: - len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%.5f", fields[i].name, *((float *)row[i])); + len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%.5f", fields[i].name, GET_FLOAT_VAL(row[i])); break; case TSDB_DATA_TYPE_DOUBLE: - len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%.9f", fields[i].name, *((double *)row[i])); + len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%.9f", fields[i].name, GET_DOUBLE_VAL(row[i])); break; case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: @@ -213,7 +213,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, httpJsonFloat(jsonBuf, *((float *)row[i])); break; case TSDB_DATA_TYPE_DOUBLE: - httpJsonDouble(jsonBuf, *((double *)row[i])); + httpJsonDouble(jsonBuf, GET_DOUBLE_VAL(row[i])); break; case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: diff --git a/src/plugins/http/src/httpRestJson.c b/src/plugins/http/src/httpRestJson.c index f8912331a367d2f5fe0e5b659bd6b4a4ad1f43ae..954678c24c8fb4597ef3184d2d65060c6d159aa1 100644 --- a/src/plugins/http/src/httpRestJson.c +++ b/src/plugins/http/src/httpRestJson.c @@ -124,10 +124,10 @@ bool restBuildSqlJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result, httpJsonInt64(jsonBuf, *((int64_t *)row[i])); break; case TSDB_DATA_TYPE_FLOAT: - httpJsonFloat(jsonBuf, *((float *)row[i])); + httpJsonFloat(jsonBuf, GET_FLOAT_VAL(row[i])); break; case TSDB_DATA_TYPE_DOUBLE: - httpJsonDouble(jsonBuf, *((double *)row[i])); + httpJsonDouble(jsonBuf, GET_DOUBLE_VAL(row[i])); break; case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: