Merge pull request #3710 from taosdata/develop
Merge from develop into coverity scan
This commit is contained in:
commit
4ee5b5bb37
|
@ -48,6 +48,7 @@ ENDIF ()
|
||||||
IF (TD_LINUX_64)
|
IF (TD_LINUX_64)
|
||||||
ADD_DEFINITIONS(-D_M_X64)
|
ADD_DEFINITIONS(-D_M_X64)
|
||||||
ADD_DEFINITIONS(-D_TD_LINUX_64)
|
ADD_DEFINITIONS(-D_TD_LINUX_64)
|
||||||
|
MESSAGE(STATUS "linux64 is defined")
|
||||||
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g3 -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g3 -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
||||||
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
@ -55,30 +56,35 @@ ENDIF ()
|
||||||
IF (TD_LINUX_32)
|
IF (TD_LINUX_32)
|
||||||
ADD_DEFINITIONS(-D_TD_LINUX_32)
|
ADD_DEFINITIONS(-D_TD_LINUX_32)
|
||||||
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
||||||
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -munaligned-access -fpack-struct=8 -latomic -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
MESSAGE(STATUS "linux32 is defined")
|
||||||
|
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -munaligned-access -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (TD_ARM_64)
|
IF (TD_ARM_64)
|
||||||
ADD_DEFINITIONS(-D_M_X64)
|
ADD_DEFINITIONS(-D_M_X64)
|
||||||
ADD_DEFINITIONS(-D_TD_ARM_64_)
|
ADD_DEFINITIONS(-D_TD_ARM_64)
|
||||||
ADD_DEFINITIONS(-D_TD_ARM_)
|
ADD_DEFINITIONS(-D_TD_ARM_)
|
||||||
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
||||||
|
MESSAGE(STATUS "arm64 is defined")
|
||||||
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (TD_ARM_32)
|
IF (TD_ARM_32)
|
||||||
ADD_DEFINITIONS(-D_TD_ARM_32_)
|
ADD_DEFINITIONS(-D_TD_ARM_32)
|
||||||
ADD_DEFINITIONS(-D_TD_ARM_)
|
ADD_DEFINITIONS(-D_TD_ARM_)
|
||||||
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
MESSAGE(STATUS "arm32 is defined")
|
||||||
|
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g -fsigned-char -fpack-struct=8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -Wno-incompatible-pointer-types ")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (TD_MIPS_64)
|
IF (TD_MIPS_64)
|
||||||
ADD_DEFINITIONS(-D_TD_MIPS_64_)
|
ADD_DEFINITIONS(-D_TD_MIPS_64_)
|
||||||
|
MESSAGE(STATUS "mips64 is defined")
|
||||||
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g3 -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g3 -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (TD_MIPS_32)
|
IF (TD_MIPS_32)
|
||||||
ADD_DEFINITIONS(-D_TD_MIPS_32_)
|
ADD_DEFINITIONS(-D_TD_MIPS_32_)
|
||||||
|
MESSAGE(STATUS "mips32 is defined")
|
||||||
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g3 -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -fPIC -g3 -gdwarf-2 -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
@ -86,6 +92,7 @@ IF (TD_APLHINE)
|
||||||
SET(COMMON_FLAGS "${COMMON_FLAGS} -largp")
|
SET(COMMON_FLAGS "${COMMON_FLAGS} -largp")
|
||||||
link_libraries(/usr/lib/libargp.a)
|
link_libraries(/usr/lib/libargp.a)
|
||||||
ADD_DEFINITIONS(-D_ALPINE)
|
ADD_DEFINITIONS(-D_ALPINE)
|
||||||
|
MESSAGE(STATUS "aplhine is defined")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (TD_LINUX)
|
IF (TD_LINUX)
|
||||||
|
@ -95,7 +102,7 @@ IF (TD_LINUX)
|
||||||
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
|
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
|
||||||
|
|
||||||
IF (TD_NINGSI_60)
|
IF (TD_NINGSI_60)
|
||||||
ADD_DEFINITIONS(-D_TD_NINGSI_60_)
|
ADD_DEFINITIONS(-D_TD_NINGSI_60)
|
||||||
MESSAGE(STATUS "set ningsi macro to true")
|
MESSAGE(STATUS "set ningsi macro to true")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
@ -118,6 +125,7 @@ IF (TD_DARWIN_64)
|
||||||
ADD_DEFINITIONS(-DDARWIN)
|
ADD_DEFINITIONS(-DDARWIN)
|
||||||
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
|
ADD_DEFINITIONS(-D_REENTRANT -D__USE_POSIX -D_LIBC_REENTRANT)
|
||||||
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
||||||
|
MESSAGE(STATUS "darwin64 is defined")
|
||||||
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -Wno-missing-braces -fPIC -g -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
SET(COMMON_FLAGS "-std=gnu99 -Wall -Werror -Wno-missing-braces -fPIC -g -msse4.2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILE")
|
||||||
SET(DEBUG_FLAGS "-O0 -DDEBUG")
|
SET(DEBUG_FLAGS "-O0 -DDEBUG")
|
||||||
SET(RELEASE_FLAGS "-O0")
|
SET(RELEASE_FLAGS "-O0")
|
||||||
|
@ -147,11 +155,13 @@ IF (TD_WINDOWS_64)
|
||||||
ADD_DEFINITIONS(-D_M_X64)
|
ADD_DEFINITIONS(-D_M_X64)
|
||||||
ADD_DEFINITIONS(-D_TD_WINDOWS_64)
|
ADD_DEFINITIONS(-D_TD_WINDOWS_64)
|
||||||
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
||||||
|
MESSAGE(STATUS "windows64 is defined")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
IF (TD_WINDOWS_32)
|
IF (TD_WINDOWS_32)
|
||||||
ADD_DEFINITIONS(-D_TD_WINDOWS_32)
|
ADD_DEFINITIONS(-D_TD_WINDOWS_32)
|
||||||
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
ADD_DEFINITIONS(-DUSE_LIBICONV)
|
||||||
|
MESSAGE(STATUS "windows32 is defined")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
|
INCLUDE_DIRECTORIES(${TD_COMMUNITY_DIR}/src/inc)
|
||||||
|
|
|
@ -42,6 +42,12 @@ IF (DEFINED CPUTYPE)
|
||||||
ELSE ()
|
ELSE ()
|
||||||
IF (TD_WINDOWS_32)
|
IF (TD_WINDOWS_32)
|
||||||
SET(TD_VER_CPUTYPE "x86")
|
SET(TD_VER_CPUTYPE "x86")
|
||||||
|
ELSEIF (TD_LINUX_32)
|
||||||
|
SET(TD_VER_CPUTYPE "x86")
|
||||||
|
ELSEIF (TD_ARM_32)
|
||||||
|
SET(TD_VER_CPUTYPE "x86")
|
||||||
|
ELSEIF (TD_MIPS_32)
|
||||||
|
SET(TD_VER_CPUTYPE "x86")
|
||||||
ELSE ()
|
ELSE ()
|
||||||
SET(TD_VER_CPUTYPE "x64")
|
SET(TD_VER_CPUTYPE "x64")
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
|
@ -233,6 +233,12 @@ ALTER USER <user_name> PASS <'password'>;
|
||||||
|
|
||||||
修改用户密码, 为避免被转换为小写,密码需要用单引号引用,单引号为英文半角
|
修改用户密码, 为避免被转换为小写,密码需要用单引号引用,单引号为英文半角
|
||||||
|
|
||||||
|
```
|
||||||
|
ALTER USER <user_name> PRIVILEDGE <'super'|'write'|'read'>;
|
||||||
|
```
|
||||||
|
|
||||||
|
修改用户权限为:super/write/read。 为避免被转换为小写,密码需要用单引号引用,单引号为英文半角
|
||||||
|
|
||||||
```
|
```
|
||||||
SHOW USERS;
|
SHOW USERS;
|
||||||
```
|
```
|
||||||
|
|
|
@ -149,7 +149,7 @@ JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_initImp(JNIEnv *e
|
||||||
JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setOptions(JNIEnv *env, jobject jobj, jint optionIndex,
|
JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setOptions(JNIEnv *env, jobject jobj, jint optionIndex,
|
||||||
jstring optionValue) {
|
jstring optionValue) {
|
||||||
if (optionValue == NULL) {
|
if (optionValue == NULL) {
|
||||||
jniDebug("option index:%d value is null", optionIndex);
|
jniDebug("option index:%d value is null", (int32_t)optionIndex);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_setOptions(JNIEnv
|
||||||
}
|
}
|
||||||
(*env)->ReleaseStringUTFChars(env, optionValue, tz1);
|
(*env)->ReleaseStringUTFChars(env, optionValue, tz1);
|
||||||
} else {
|
} else {
|
||||||
jniError("option index:%d is not found", optionIndex);
|
jniError("option index:%d is not found", (int32_t)optionIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
@ -227,10 +227,10 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn
|
||||||
ret = (jlong)taos_connect((char *)host, (char *)user, (char *)pass, (char *)dbname, (uint16_t)jport);
|
ret = (jlong)taos_connect((char *)host, (char *)user, (char *)pass, (char *)dbname, (uint16_t)jport);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
jniError("jobj:%p, conn:%p, connect to database failed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret,
|
jniError("jobj:%p, conn:%p, connect to database failed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret,
|
||||||
(char *)host, (char *)user, (char *)dbname, jport);
|
(char *)host, (char *)user, (char *)dbname, (int32_t)jport);
|
||||||
} else {
|
} else {
|
||||||
jniDebug("jobj:%p, conn:%p, connect to database succeed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret,
|
jniDebug("jobj:%p, conn:%p, connect to database succeed, host=%s, user=%s, dbname=%s, port=%d", jobj, (void *)ret,
|
||||||
(char *)host, (char *)user, (char *)dbname, jport);
|
(char *)host, (char *)user, (char *)dbname, (int32_t)jport);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (host != NULL) (*env)->ReleaseStringUTFChars(env, jhost, host);
|
if (host != NULL) (*env)->ReleaseStringUTFChars(env, jhost, host);
|
||||||
|
@ -385,7 +385,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_getAffectedRowsIm
|
||||||
}
|
}
|
||||||
|
|
||||||
jint ret = taos_affected_rows((SSqlObj *)res);
|
jint ret = taos_affected_rows((SSqlObj *)res);
|
||||||
jniDebug("jobj:%p, conn:%p, sql:%p, res: %p, affect rows:%d", jobj, tscon, (void *)con, (void *)res, ret);
|
jniDebug("jobj:%p, conn:%p, sql:%p, res: %p, affect rows:%d", jobj, tscon, (void *)con, (void *)res, (int32_t)ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -642,14 +642,14 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
|
||||||
|
|
||||||
size_t numOfSrcCols = taosArrayGetSize(pQueryInfo->colList);
|
size_t numOfSrcCols = taosArrayGetSize(pQueryInfo->colList);
|
||||||
if (numOfSrcCols <= 0 && !tscQueryTags(pQueryInfo)) {
|
if (numOfSrcCols <= 0 && !tscQueryTags(pQueryInfo)) {
|
||||||
tscError("%p illegal value of numOfCols in query msg: %"PRIu64", table cols:%d", pSql, numOfSrcCols,
|
tscError("%p illegal value of numOfCols in query msg: %" PRIu64 ", table cols:%d", pSql, (uint64_t)numOfSrcCols,
|
||||||
tscGetNumOfColumns(pTableMeta));
|
tscGetNumOfColumns(pTableMeta));
|
||||||
|
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pQueryInfo->interval.interval < 0) {
|
if (pQueryInfo->interval.interval < 0) {
|
||||||
tscError("%p illegal value of aggregation time interval in query msg: %ld", pSql, pQueryInfo->interval.interval);
|
tscError("%p illegal value of aggregation time interval in query msg: %" PRId64, pSql, (int64_t)pQueryInfo->interval.interval);
|
||||||
return TSDB_CODE_TSC_INVALID_SQL;
|
return TSDB_CODE_TSC_INVALID_SQL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -398,8 +398,8 @@ static void tscSetSlidingWindowInfo(SSqlObj *pSql, SSqlStream *pStream) {
|
||||||
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
SQueryInfo* pQueryInfo = tscGetQueryInfoDetail(&pSql->cmd, 0);
|
||||||
|
|
||||||
if (pQueryInfo->interval.intervalUnit != 'n' && pQueryInfo->interval.intervalUnit!= 'y' && pQueryInfo->interval.interval < minIntervalTime) {
|
if (pQueryInfo->interval.intervalUnit != 'n' && pQueryInfo->interval.intervalUnit!= 'y' && pQueryInfo->interval.interval < minIntervalTime) {
|
||||||
tscWarn("%p stream:%p, original sample interval:%ld too small, reset to:%" PRId64, pSql, pStream,
|
tscWarn("%p stream:%p, original sample interval:%" PRId64 " too small, reset to:%" PRId64, pSql, pStream,
|
||||||
pQueryInfo->interval.interval, minIntervalTime);
|
(int64_t)pQueryInfo->interval.interval, minIntervalTime);
|
||||||
pQueryInfo->interval.interval = minIntervalTime;
|
pQueryInfo->interval.interval = minIntervalTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -313,13 +313,13 @@ void dataColSetOffset(SDataCol *pCol, int nEle) {
|
||||||
SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows) {
|
SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows) {
|
||||||
SDataCols *pCols = (SDataCols *)calloc(1, sizeof(SDataCols));
|
SDataCols *pCols = (SDataCols *)calloc(1, sizeof(SDataCols));
|
||||||
if (pCols == NULL) {
|
if (pCols == NULL) {
|
||||||
uDebug("malloc failure, size:%"PRId64" failed, reason:%s", sizeof(SDataCols), strerror(errno));
|
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCols), strerror(errno));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pCols->cols = (SDataCol *)calloc(maxCols, sizeof(SDataCol));
|
pCols->cols = (SDataCol *)calloc(maxCols, sizeof(SDataCol));
|
||||||
if (pCols->cols == NULL) {
|
if (pCols->cols == NULL) {
|
||||||
uDebug("malloc failure, size:%"PRId64" failed, reason:%s", sizeof(SDataCol) * maxCols, strerror(errno));
|
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCol) * maxCols, strerror(errno));
|
||||||
tdFreeDataCols(pCols);
|
tdFreeDataCols(pCols);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -331,7 +331,7 @@ SDataCols *tdNewDataCols(int maxRowSize, int maxCols, int maxRows) {
|
||||||
|
|
||||||
pCols->buf = malloc(pCols->bufSize);
|
pCols->buf = malloc(pCols->bufSize);
|
||||||
if (pCols->buf == NULL) {
|
if (pCols->buf == NULL) {
|
||||||
uDebug("malloc failure, size:%"PRId64" failed, reason:%s", sizeof(SDataCol) * maxCols, strerror(errno));
|
uDebug("malloc failure, size:%" PRId64 " failed, reason:%s", (int64_t)sizeof(SDataCol) * maxCols, strerror(errno));
|
||||||
tdFreeDataCols(pCols);
|
tdFreeDataCols(pCols);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,7 +235,7 @@ static void getStatics_f(const TSKEY *primaryKey, const void *pData, int32_t num
|
||||||
double csum = 0;
|
double csum = 0;
|
||||||
csum = GET_DOUBLE_VAL(sum);
|
csum = GET_DOUBLE_VAL(sum);
|
||||||
csum += dsum;
|
csum += dsum;
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
SET_DOUBLE_VAL_ALIGN(sum, &csum);
|
SET_DOUBLE_VAL_ALIGN(sum, &csum);
|
||||||
SET_DOUBLE_VAL_ALIGN(max, &fmax);
|
SET_DOUBLE_VAL_ALIGN(max, &fmax);
|
||||||
SET_DOUBLE_VAL_ALIGN(min, &fmin);
|
SET_DOUBLE_VAL_ALIGN(min, &fmin);
|
||||||
|
@ -282,7 +282,7 @@ static void getStatics_d(const TSKEY *primaryKey, const void *pData, int32_t num
|
||||||
csum += dsum;
|
csum += dsum;
|
||||||
|
|
||||||
|
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
SET_DOUBLE_VAL_ALIGN(sum, &csum);
|
SET_DOUBLE_VAL_ALIGN(sum, &csum);
|
||||||
SET_DOUBLE_VAL_ALIGN(max, &dmax);
|
SET_DOUBLE_VAL_ALIGN(max, &dmax);
|
||||||
SET_DOUBLE_VAL_ALIGN(min, &dmin);
|
SET_DOUBLE_VAL_ALIGN(min, &dmin);
|
||||||
|
@ -494,7 +494,7 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_FLOAT: {
|
case TSDB_DATA_TYPE_FLOAT: {
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
float fv = GET_FLOAT_VAL(src);
|
float fv = GET_FLOAT_VAL(src);
|
||||||
SET_FLOAT_VAL_ALIGN(val, &fv);
|
SET_FLOAT_VAL_ALIGN(val, &fv);
|
||||||
#else
|
#else
|
||||||
|
@ -503,7 +503,7 @@ void assignVal(char *val, const char *src, int32_t len, int32_t type) {
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
case TSDB_DATA_TYPE_DOUBLE: {
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
double dv = GET_DOUBLE_VAL(src);
|
double dv = GET_DOUBLE_VAL(src);
|
||||||
SET_DOUBLE_VAL_ALIGN(val, &dv);
|
SET_DOUBLE_VAL_ALIGN(val, &dv);
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -709,7 +709,7 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
//memcpy(&payload, &value, sizeof(float));
|
//memcpy(&payload, &value, sizeof(float));
|
||||||
float fv = (float)value;
|
float fv = (float)value;
|
||||||
SET_FLOAT_VAL_ALIGN(payload, &fv);
|
SET_FLOAT_VAL_ALIGN(payload, &fv);
|
||||||
|
@ -718,7 +718,7 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) {
|
} else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) {
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
//memcpy(&payload, &pVariant->i64Key, sizeof(float));
|
//memcpy(&payload, &pVariant->i64Key, sizeof(float));
|
||||||
float fv = (float)pVariant->i64Key;
|
float fv = (float)pVariant->i64Key;
|
||||||
SET_FLOAT_VAL_ALIGN(payload, &fv);
|
SET_FLOAT_VAL_ALIGN(payload, &fv);
|
||||||
|
@ -726,7 +726,7 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu
|
||||||
*((float *)payload) = (float)pVariant->i64Key;
|
*((float *)payload) = (float)pVariant->i64Key;
|
||||||
#endif
|
#endif
|
||||||
} else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) {
|
} else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) {
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
//memcpy(&payload, &pVariant->dKey, sizeof(float));
|
//memcpy(&payload, &pVariant->dKey, sizeof(float));
|
||||||
float fv = (float)pVariant->dKey;
|
float fv = (float)pVariant->dKey;
|
||||||
SET_FLOAT_VAL_ALIGN(payload, &fv);
|
SET_FLOAT_VAL_ALIGN(payload, &fv);
|
||||||
|
@ -738,7 +738,7 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
float fv = GET_FLOAT_VAL(payload);
|
float fv = GET_FLOAT_VAL(payload);
|
||||||
if (isinf(fv) || isnan(fv) || fv > FLT_MAX || fv < -FLT_MAX) {
|
if (isinf(fv) || isnan(fv) || fv > FLT_MAX || fv < -FLT_MAX) {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -765,21 +765,21 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
SET_DOUBLE_VAL_ALIGN(payload, &value);
|
SET_DOUBLE_VAL_ALIGN(payload, &value);
|
||||||
#else
|
#else
|
||||||
*((double *)payload) = value;
|
*((double *)payload) = value;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) {
|
} else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) {
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
double dv = (double)(pVariant->i64Key);
|
double dv = (double)(pVariant->i64Key);
|
||||||
SET_DOUBLE_VAL_ALIGN(payload, &dv);
|
SET_DOUBLE_VAL_ALIGN(payload, &dv);
|
||||||
#else
|
#else
|
||||||
*((double *)payload) = (double)pVariant->i64Key;
|
*((double *)payload) = (double)pVariant->i64Key;
|
||||||
#endif
|
#endif
|
||||||
} else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) {
|
} else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) {
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
double dv = (double)(pVariant->dKey);
|
double dv = (double)(pVariant->dKey);
|
||||||
SET_DOUBLE_VAL_ALIGN(payload, &dv);
|
SET_DOUBLE_VAL_ALIGN(payload, &dv);
|
||||||
#else
|
#else
|
||||||
|
@ -790,7 +790,7 @@ int32_t tVariantDump(tVariant *pVariant, char *payload, int16_t type, bool inclu
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
double dv = GET_DOUBLE_VAL(payload);
|
double dv = GET_DOUBLE_VAL(payload);
|
||||||
if (isinf(dv) || isnan(dv) || dv > DBL_MAX || dv < -DBL_MAX) {
|
if (isinf(dv) || isnan(dv) || dv > DBL_MAX || dv < -DBL_MAX) {
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8d7bf743852897110cbdcc7c4322cd7a74d4167b
|
Subproject commit 06ec30a0f1762e8169bf6b9045c82bcaa52bcdf0
|
|
@ -131,7 +131,7 @@ do { \
|
||||||
#define GET_INT16_VAL(x) (*(int16_t *)(x))
|
#define GET_INT16_VAL(x) (*(int16_t *)(x))
|
||||||
#define GET_INT32_VAL(x) (*(int32_t *)(x))
|
#define GET_INT32_VAL(x) (*(int32_t *)(x))
|
||||||
#define GET_INT64_VAL(x) (*(int64_t *)(x))
|
#define GET_INT64_VAL(x) (*(int64_t *)(x))
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
#define GET_FLOAT_VAL(x) taos_align_get_float(x)
|
#define GET_FLOAT_VAL(x) taos_align_get_float(x)
|
||||||
#define GET_DOUBLE_VAL(x) taos_align_get_double(x)
|
#define GET_DOUBLE_VAL(x) taos_align_get_double(x)
|
||||||
|
|
||||||
|
|
|
@ -24,10 +24,14 @@ extern "C" {
|
||||||
#include "osDarwin.h"
|
#include "osDarwin.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _TD_ARM_64_
|
#ifdef _TD_ARM_64
|
||||||
#include "osArm64.h"
|
#include "osArm64.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef _TD_ARM_32
|
||||||
|
#include "osArm32.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _TD_LINUX_64
|
#ifdef _TD_LINUX_64
|
||||||
#include "osLinux64.h"
|
#include "osLinux64.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,7 +44,7 @@ extern "C" {
|
||||||
#include "osAlpine.h"
|
#include "osAlpine.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _TD_NINGSI_60_
|
#ifdef _TD_NINGSI_60
|
||||||
#include "osNingsi.h"
|
#include "osNingsi.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TDENGINE_OS_ARM32_H
|
||||||
|
#define TDENGINE_OS_ARM32_H
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <argp.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <endian.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <float.h>
|
||||||
|
#include <ifaddrs.h>
|
||||||
|
#include <libgen.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <math.h>
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <netinet/ip.h>
|
||||||
|
#include <netinet/tcp.h>
|
||||||
|
#include <netinet/udp.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <pwd.h>
|
||||||
|
#include <regex.h>
|
||||||
|
#include <semaphore.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <strings.h>
|
||||||
|
#include <sys/epoll.h>
|
||||||
|
#include <sys/eventfd.h>
|
||||||
|
#include <sys/file.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/sendfile.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/syscall.h>
|
||||||
|
#include <sys/statvfs.h>
|
||||||
|
#include <sys/time.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/uio.h>
|
||||||
|
#include <sys/un.h>
|
||||||
|
#include <syslog.h>
|
||||||
|
#include <termios.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
#include <wordexp.h>
|
||||||
|
#include <wctype.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
|
#include <error.h>
|
||||||
|
|
||||||
|
#define TAOS_OS_FUNC_LZ4
|
||||||
|
#define BUILDIN_CLZL(val) __builtin_clzll(val)
|
||||||
|
#define BUILDIN_CTZL(val) __builtin_ctzll(val)
|
||||||
|
#define BUILDIN_CLZ(val) __builtin_clz(val)
|
||||||
|
#define BUILDIN_CTZ(val) __builtin_ctz(val)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -129,8 +129,6 @@ void* atomic_exchange_ptr_impl( void **ptr, void *val );
|
||||||
#define atomic_fetch_xor_64(ptr, val) __sync_fetch_and_xor((ptr), (val))
|
#define atomic_fetch_xor_64(ptr, val) __sync_fetch_and_xor((ptr), (val))
|
||||||
#define atomic_fetch_xor_ptr(ptr, val) __sync_fetch_and_xor((ptr), (val))
|
#define atomic_fetch_xor_ptr(ptr, val) __sync_fetch_and_xor((ptr), (val))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -51,8 +51,6 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define TAOS_OS_FUNC_ATOMIC
|
|
||||||
|
|
||||||
#define TAOS_OS_FUNC_LZ4
|
#define TAOS_OS_FUNC_LZ4
|
||||||
int32_t BUILDIN_CLZL(uint64_t val);
|
int32_t BUILDIN_CLZL(uint64_t val);
|
||||||
int32_t BUILDIN_CLZ(uint32_t val);
|
int32_t BUILDIN_CLZ(uint32_t val);
|
||||||
|
|
|
@ -9,3 +9,7 @@ SET_SOURCE_FILES_PROPERTIES(osCoredump.c PROPERTIES COMPILE_FLAGS -w)
|
||||||
|
|
||||||
ADD_LIBRARY(osdetail ${SRC})
|
ADD_LIBRARY(osdetail ${SRC})
|
||||||
TARGET_LINK_LIBRARIES(osdetail os)
|
TARGET_LINK_LIBRARIES(osdetail os)
|
||||||
|
|
||||||
|
IF (TD_ARM_32 OR TD_LINUX_32)
|
||||||
|
TARGET_LINK_LIBRARIES(osdetail atomic)
|
||||||
|
ENDIF ()
|
||||||
|
|
|
@ -569,7 +569,6 @@ int taosSystem(const char *cmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int _sysctl(struct __sysctl_args *args );
|
|
||||||
void taosSetCoreDump() {
|
void taosSetCoreDump() {
|
||||||
if (0 == tsEnableCoreFile) {
|
if (0 == tsEnableCoreFile) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
|
||||||
#ifdef _TD_NINGSI_60_
|
#ifdef _TD_NINGSI_60
|
||||||
void* atomic_exchange_ptr_impl(void** ptr, void* val ) {
|
void* atomic_exchange_ptr_impl(void** ptr, void* val ) {
|
||||||
void *old;
|
void *old;
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -67,7 +67,7 @@ static void httpDestroyContext(void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool httpInitContexts() {
|
bool httpInitContexts() {
|
||||||
tsHttpServer.contextCache = taosCacheInit(TSDB_DATA_TYPE_BIGINT, 2, true, httpDestroyContext, "restc");
|
tsHttpServer.contextCache = taosCacheInit(TSDB_CACHE_PTR_KEY, 2, true, httpDestroyContext, "restc");
|
||||||
if (tsHttpServer.contextCache == NULL) {
|
if (tsHttpServer.contextCache == NULL) {
|
||||||
httpError("failed to init context cache");
|
httpError("failed to init context cache");
|
||||||
return false;
|
return false;
|
||||||
|
@ -117,8 +117,9 @@ HttpContext *httpCreateContext(int32_t fd) {
|
||||||
pContext->state = HTTP_CONTEXT_STATE_READY;
|
pContext->state = HTTP_CONTEXT_STATE_READY;
|
||||||
pContext->parser = httpCreateParser(pContext);
|
pContext->parser = httpCreateParser(pContext);
|
||||||
|
|
||||||
uint64_t handleVal = (uint64_t)pContext;
|
TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE)pContext;
|
||||||
HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &handleVal, sizeof(int64_t), &pContext, sizeof(int64_t), 3000);
|
HttpContext **ppContext = taosCachePut(tsHttpServer.contextCache, &handleVal, sizeof(TSDB_CACHE_PTR_TYPE), &pContext,
|
||||||
|
sizeof(TSDB_CACHE_PTR_TYPE), 3000);
|
||||||
pContext->ppContext = ppContext;
|
pContext->ppContext = ppContext;
|
||||||
httpDebug("context:%p, fd:%d, is created, data:%p", pContext, fd, ppContext);
|
httpDebug("context:%p, fd:%d, is created, data:%p", pContext, fd, ppContext);
|
||||||
|
|
||||||
|
@ -129,8 +130,8 @@ HttpContext *httpCreateContext(int32_t fd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpContext *httpGetContext(void *ptr) {
|
HttpContext *httpGetContext(void *ptr) {
|
||||||
uint64_t handleVal = (uint64_t)ptr;
|
TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE)ptr;
|
||||||
HttpContext **ppContext = taosCacheAcquireByKey(tsHttpServer.contextCache, &handleVal, sizeof(HttpContext *));
|
HttpContext **ppContext = taosCacheAcquireByKey(tsHttpServer.contextCache, &handleVal, sizeof(TSDB_CACHE_PTR_TYPE));
|
||||||
|
|
||||||
if (ppContext) {
|
if (ppContext) {
|
||||||
HttpContext *pContext = *ppContext;
|
HttpContext *pContext = *ppContext;
|
||||||
|
|
|
@ -145,7 +145,7 @@ bool gcBuildQueryJson(HttpContext *pContext, HttpSqlCmd *cmd, TAOS_RES *result,
|
||||||
len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%d,", fields[i].name, *((int32_t *)row[i]));
|
len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%d,", fields[i].name, *((int32_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_BIGINT:
|
case TSDB_DATA_TYPE_BIGINT:
|
||||||
len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%ld", fields[i].name, *((int64_t *)row[i]));
|
len += snprintf(target + len, HTTP_GC_TARGET_SIZE - len, "%s:%" PRId64, fields[i].name, *((int64_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_FLOAT:
|
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, *((float *)row[i]));
|
||||||
|
|
|
@ -113,7 +113,7 @@ int32_t httpWriteJsonBufBody(JsonBuf* buf, bool isTheLast) {
|
||||||
httpTrace("context:%p, fd:%d, no data need dump", buf->pContext, buf->pContext->fd);
|
httpTrace("context:%p, fd:%d, no data need dump", buf->pContext, buf->pContext->fd);
|
||||||
return 0; // there is no data to dump.
|
return 0; // there is no data to dump.
|
||||||
} else {
|
} else {
|
||||||
int32_t len = sprintf(sLen, "%lx\r\n", srcLen);
|
int32_t len = sprintf(sLen, "%" PRIx64 "\r\n", srcLen);
|
||||||
httpTrace("context:%p, fd:%d, write body, chunkSize:%" PRIu64 ", response:\n%s", buf->pContext, buf->pContext->fd,
|
httpTrace("context:%p, fd:%d, write body, chunkSize:%" PRIu64 ", response:\n%s", buf->pContext, buf->pContext->fd,
|
||||||
srcLen, buf->buf);
|
srcLen, buf->buf);
|
||||||
httpWriteBufNoTrace(buf->pContext, sLen, len);
|
httpWriteBufNoTrace(buf->pContext, sLen, len);
|
||||||
|
@ -267,9 +267,9 @@ void httpJsonTimestamp(JsonBuf* buf, int64_t t, bool us) {
|
||||||
ptm = localtime(&tt);
|
ptm = localtime(&tt);
|
||||||
int32_t length = (int32_t) strftime(ts, 35, "%Y-%m-%d %H:%M:%S", ptm);
|
int32_t length = (int32_t) strftime(ts, 35, "%Y-%m-%d %H:%M:%S", ptm);
|
||||||
if (us) {
|
if (us) {
|
||||||
length += snprintf(ts + length, 8, ".%06ld", t % precision);
|
length += snprintf(ts + length, 8, ".%06" PRId64, t % precision);
|
||||||
} else {
|
} else {
|
||||||
length += snprintf(ts + length, 5, ".%03ld", t % precision);
|
length += snprintf(ts + length, 5, ".%03" PRId64, t % precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
httpJsonString(buf, ts, length);
|
httpJsonString(buf, ts, length);
|
||||||
|
@ -287,9 +287,9 @@ void httpJsonUtcTimestamp(JsonBuf* buf, int64_t t, bool us) {
|
||||||
ptm = localtime(&tt);
|
ptm = localtime(&tt);
|
||||||
int32_t length = (int32_t)strftime(ts, 40, "%Y-%m-%dT%H:%M:%S", ptm);
|
int32_t length = (int32_t)strftime(ts, 40, "%Y-%m-%dT%H:%M:%S", ptm);
|
||||||
if (us) {
|
if (us) {
|
||||||
length += snprintf(ts + length, 8, ".%06ld", t % precision);
|
length += snprintf(ts + length, 8, ".%06" PRId64, t % precision);
|
||||||
} else {
|
} else {
|
||||||
length += snprintf(ts + length, 5, ".%03ld", t % precision);
|
length += snprintf(ts + length, 5, ".%03" PRId64, t % precision);
|
||||||
}
|
}
|
||||||
length += (int32_t)strftime(ts + length, 40 - length, "%z", ptm);
|
length += (int32_t)strftime(ts + length, 40 - length, "%z", ptm);
|
||||||
|
|
||||||
|
|
|
@ -5050,8 +5050,8 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug(
|
qDebug(
|
||||||
"QInfo %p numOfTables:%"PRIu64", index:%d, numOfGroups:%" PRIzu ", %"PRId64" points returned, total:%"PRId64", offset:%" PRId64,
|
"QInfo %p numOfTables:%" PRIu64 ", index:%d, numOfGroups:%" PRIzu ", %" PRId64 " points returned, total:%" PRId64 ", offset:%" PRId64,
|
||||||
pQInfo, pQInfo->tableqinfoGroupInfo.numOfTables, pQInfo->tableIndex, numOfGroups, pQuery->rec.rows, pQuery->rec.total,
|
pQInfo, (uint64_t)pQInfo->tableqinfoGroupInfo.numOfTables, pQInfo->tableIndex, numOfGroups, pQuery->rec.rows, pQuery->rec.total,
|
||||||
pQuery->limit.offset);
|
pQuery->limit.offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ void *rpcOpen(const SRpcInit *pInit) {
|
||||||
size_t size = sizeof(SRpcConn) * pRpc->sessions;
|
size_t size = sizeof(SRpcConn) * pRpc->sessions;
|
||||||
pRpc->connList = (SRpcConn *)calloc(1, size);
|
pRpc->connList = (SRpcConn *)calloc(1, size);
|
||||||
if (pRpc->connList == NULL) {
|
if (pRpc->connList == NULL) {
|
||||||
tError("%s failed to allocate memory for taos connections, size:%ld", pRpc->label, size);
|
tError("%s failed to allocate memory for taos connections, size:%" PRId64, pRpc->label, (int64_t)size);
|
||||||
rpcClose(pRpc);
|
rpcClose(pRpc);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,7 +211,7 @@ static void *taosRecvUdpData(void *param) {
|
||||||
|
|
||||||
char *tmsg = malloc(dataLen + tsRpcOverhead);
|
char *tmsg = malloc(dataLen + tsRpcOverhead);
|
||||||
if (NULL == tmsg) {
|
if (NULL == tmsg) {
|
||||||
tError("%s failed to allocate memory, size:%ld", pConn->label, dataLen);
|
tError("%s failed to allocate memory, size:%" PRId64, pConn->label, (int64_t)dataLen);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
tDebug("UDP malloc mem: %p", tmsg);
|
tDebug("UDP malloc mem: %p", tmsg);
|
||||||
|
|
|
@ -325,7 +325,7 @@ static int syncProcessLastWal(SSyncPeer *pPeer, char *wname, uint32_t index) {
|
||||||
// if all data up to fversion is read out, it is over
|
// if all data up to fversion is read out, it is over
|
||||||
if (pPeer->sversion >= fversion && fversion > 0) {
|
if (pPeer->sversion >= fversion && fversion > 0) {
|
||||||
code = 0;
|
code = 0;
|
||||||
sDebug("%s, data up to fversion:%ld has been read out, bytes:%d", pPeer->id, fversion, bytes);
|
sDebug("%s, data up to fversion:%" PRId64 " has been read out, bytes:%d", pPeer->id, fversion, bytes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -386,7 +386,7 @@ int main(int argc, char *argv[]) {
|
||||||
printf(" [-m msgSize]: message body size, default is:%d\n", msgSize);
|
printf(" [-m msgSize]: message body size, default is:%d\n", msgSize);
|
||||||
printf(" [-o compSize]: compression message size, default is:%d\n", tsCompressMsgSize);
|
printf(" [-o compSize]: compression message size, default is:%d\n", tsCompressMsgSize);
|
||||||
printf(" [-w write]: write received data to file(0, 1, 2), default is:%d\n", commit);
|
printf(" [-w write]: write received data to file(0, 1, 2), default is:%d\n", commit);
|
||||||
printf(" [-v version]: initial node version, default is:%ld\n", syncInfo.version);
|
printf(" [-v version]: initial node version, default is:%" PRId64 "\n", syncInfo.version);
|
||||||
printf(" [-r replica]: replicacation number, default is:%d\n", pCfg->replica);
|
printf(" [-r replica]: replicacation number, default is:%d\n", pCfg->replica);
|
||||||
printf(" [-q quorum]: quorum, default is:%d\n", pCfg->quorum);
|
printf(" [-q quorum]: quorum, default is:%d\n", pCfg->quorum);
|
||||||
printf(" [-d debugFlag]: debug flag, default:%d\n", rpcDebugFlag);
|
printf(" [-d debugFlag]: debug flag, default:%d\n", rpcDebugFlag);
|
||||||
|
|
|
@ -24,6 +24,14 @@ extern "C" {
|
||||||
#include "tlockfree.h"
|
#include "tlockfree.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
|
|
||||||
|
#if defined(_TD_ARM_32)
|
||||||
|
#define TSDB_CACHE_PTR_KEY TSDB_DATA_TYPE_INT
|
||||||
|
#define TSDB_CACHE_PTR_TYPE int32_t
|
||||||
|
#else
|
||||||
|
#define TSDB_CACHE_PTR_KEY TSDB_DATA_TYPE_BIGINT
|
||||||
|
#define TSDB_CACHE_PTR_TYPE int64_t
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef void (*__cache_free_fn_t)(void*);
|
typedef void (*__cache_free_fn_t)(void*);
|
||||||
|
|
||||||
typedef struct SCacheStatis {
|
typedef struct SCacheStatis {
|
||||||
|
|
|
@ -738,7 +738,7 @@ void taosHashTableResize(SHashObj *pHashObj) {
|
||||||
|
|
||||||
int64_t et = taosGetTimestampUs();
|
int64_t et = taosGetTimestampUs();
|
||||||
|
|
||||||
uDebug("hash table resize completed, new capacity:%"PRId64", load factor:%f, elapsed time:%fms", pHashObj->capacity,
|
uDebug("hash table resize completed, new capacity:%d, load factor:%f, elapsed time:%fms", (int32_t)pHashObj->capacity,
|
||||||
((double)pHashObj->size) / pHashObj->capacity, (et - st) / 1000.0);
|
((double)pHashObj->size) / pHashObj->capacity, (et - st) / 1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ int main(int argc, char *argv[]) {
|
||||||
printf(" [-t total]: total wal files, default is:%d\n", total);
|
printf(" [-t total]: total wal files, default is:%d\n", total);
|
||||||
printf(" [-r rows]: rows of records per wal file, default is:%d\n", rows);
|
printf(" [-r rows]: rows of records per wal file, default is:%d\n", rows);
|
||||||
printf(" [-k keep]: keep the wal after closing, default is:%d\n", keep);
|
printf(" [-k keep]: keep the wal after closing, default is:%d\n", keep);
|
||||||
printf(" [-v version]: initial version, default is:%ld\n", ver);
|
printf(" [-v version]: initial version, default is:%" PRId64 "\n", ver);
|
||||||
printf(" [-d debugFlag]: debug flag, default:%d\n", dDebugFlag);
|
printf(" [-d debugFlag]: debug flag, default:%d\n", dDebugFlag);
|
||||||
printf(" [-h help]: print out this help\n\n");
|
printf(" [-h help]: print out this help\n\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
@ -97,7 +97,7 @@ int main(int argc, char *argv[]) {
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("version starts from:%ld\n", ver);
|
printf("version starts from:%" PRId64 "\n", ver);
|
||||||
|
|
||||||
int contLen = sizeof(SWalHead) + size;
|
int contLen = sizeof(SWalHead) + size;
|
||||||
SWalHead *pHead = (SWalHead *) malloc(contLen);
|
SWalHead *pHead = (SWalHead *) malloc(contLen);
|
||||||
|
|
|
@ -278,7 +278,7 @@ void writeData() {
|
||||||
|
|
||||||
free(threads);
|
free(threads);
|
||||||
|
|
||||||
printf("---- Spent %f seconds to insert %ld records, speed: %f Rows/Second\n", seconds, statis.totalRows, rs);
|
printf("---- Spent %f seconds to insert %" PRId64 " records, speed: %f Rows/Second\n", seconds, statis.totalRows, rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void readDataImp(void *param)
|
void readDataImp(void *param)
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <taos.h> // TAOS header file
|
#include <taos.h> // TAOS header file
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
@ -67,7 +68,7 @@ int main(int argc, char *argv[]) {
|
||||||
// insert 10 records
|
// insert 10 records
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (i = 0; i < 10; ++i) {
|
for (i = 0; i < 10; ++i) {
|
||||||
sprintf(qstr, "insert into m1 values (%ld, %d, %d, %d, %d, %f, %lf, '%s')", 1546300800000 + i * 1000, i, i, i, i*10000000, i*1.0, i*2.0, "hello");
|
sprintf(qstr, "insert into m1 values (%" PRId64 ", %d, %d, %d, %d, %f, %lf, '%s')", 1546300800000 + i * 1000, i, i, i, i*10000000, i*1.0, i*2.0, "hello");
|
||||||
printf("qstr: %s\n", qstr);
|
printf("qstr: %s\n", qstr);
|
||||||
if (taos_query(taos, qstr)) {
|
if (taos_query(taos, qstr)) {
|
||||||
printf("insert row: %i, reason:%s\n", i, taos_errstr(taos));
|
printf("insert row: %i, reason:%s\n", i, taos_errstr(taos));
|
||||||
|
|
|
@ -1,302 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
|
||||||
*
|
|
||||||
* This program is free software: you can use, redistribute, and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3
|
|
||||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"database/sql"
|
|
||||||
"time"
|
|
||||||
"log"
|
|
||||||
"fmt"
|
|
||||||
_ "github.com/taosdata/driver-go/taosSql"
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
taosDriverName := "taosSql"
|
|
||||||
demodb := "demodb"
|
|
||||||
demot := "demot"
|
|
||||||
|
|
||||||
fmt.Printf("\n======== start demo test ========\n")
|
|
||||||
// open connect to taos server
|
|
||||||
db, err := sql.Open(taosDriverName, "root:taosdata@/tcp(127.0.0.1:0)/")
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("Open database error: %s\n", err)
|
|
||||||
}
|
|
||||||
defer db.Close()
|
|
||||||
|
|
||||||
drop_database(db, demodb)
|
|
||||||
create_database(db, demodb)
|
|
||||||
use_database(db, demodb)
|
|
||||||
create_table(db, demot)
|
|
||||||
insert_data(db, demot)
|
|
||||||
select_data(db, demot)
|
|
||||||
|
|
||||||
fmt.Printf("\n======== start stmt mode test ========\n")
|
|
||||||
|
|
||||||
demodbStmt := "demodbStmt"
|
|
||||||
demotStmt := "demotStmt"
|
|
||||||
drop_database_stmt(db, demodbStmt)
|
|
||||||
create_database_stmt(db, demodbStmt)
|
|
||||||
use_database_stmt(db, demodbStmt)
|
|
||||||
create_table_stmt(db, demotStmt)
|
|
||||||
insert_data_stmt(db, demotStmt)
|
|
||||||
select_data_stmt(db, demotStmt)
|
|
||||||
|
|
||||||
fmt.Printf("\n======== end demo test ========\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
func drop_database(db *sql.DB, demodb string) {
|
|
||||||
st := time.Now().Nanosecond()
|
|
||||||
res, err := db.Exec("drop database if exists " + demodb)
|
|
||||||
checkErr(err, "drop database if exists " + demodb)
|
|
||||||
|
|
||||||
affectd, err := res.RowsAffected()
|
|
||||||
checkErr(err, "drop db, res.RowsAffected")
|
|
||||||
|
|
||||||
et := time.Now().Nanosecond()
|
|
||||||
|
|
||||||
fmt.Printf("drop database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9)
|
|
||||||
}
|
|
||||||
|
|
||||||
func create_database(db *sql.DB, demodb string) {
|
|
||||||
st := time.Now().Nanosecond()
|
|
||||||
// create database
|
|
||||||
res, err := db.Exec("create database " + demodb)
|
|
||||||
checkErr(err, "create db, db.Exec")
|
|
||||||
|
|
||||||
affectd, err := res.RowsAffected()
|
|
||||||
checkErr(err, "create db, res.RowsAffected")
|
|
||||||
|
|
||||||
et := time.Now().Nanosecond()
|
|
||||||
|
|
||||||
fmt.Printf("create database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9)
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func use_database(db *sql.DB, demodb string) {
|
|
||||||
st := time.Now().Nanosecond()
|
|
||||||
// use database
|
|
||||||
res, err := db.Exec("use " + demodb) // notes: must no quote to db name
|
|
||||||
checkErr(err, "use db db.Exec")
|
|
||||||
|
|
||||||
affectd, err := res.RowsAffected()
|
|
||||||
checkErr(err, "use db, res.RowsAffected")
|
|
||||||
|
|
||||||
et := time.Now().Nanosecond()
|
|
||||||
|
|
||||||
fmt.Printf("use database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9)
|
|
||||||
}
|
|
||||||
|
|
||||||
func create_table(db *sql.DB, demot string) {
|
|
||||||
st := time.Now().Nanosecond()
|
|
||||||
// create table
|
|
||||||
res, err := db.Exec("create table " + demot + " (ts timestamp, id int, name binary(8), len tinyint, flag bool, notes binary(8), fv float, dv double)")
|
|
||||||
checkErr(err, "create table db.Exec")
|
|
||||||
|
|
||||||
affectd, err := res.RowsAffected()
|
|
||||||
checkErr(err, "create table res.RowsAffected")
|
|
||||||
|
|
||||||
et := time.Now().Nanosecond()
|
|
||||||
fmt.Printf("create table result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9)
|
|
||||||
}
|
|
||||||
|
|
||||||
func insert_data(db *sql.DB, demot string) {
|
|
||||||
st := time.Now().Nanosecond()
|
|
||||||
// insert data
|
|
||||||
res, err := db.Exec("insert into " + demot +
|
|
||||||
" values (now, 100, 'beijing', 10, true, 'one', 123.456, 123.456)" +
|
|
||||||
" (now+1s, 101, 'shanghai', 11, true, 'two', 789.123, 789.123)" +
|
|
||||||
" (now+2s, 102, 'shenzhen', 12, false, 'three', 456.789, 456.789)")
|
|
||||||
|
|
||||||
checkErr(err, "insert data, db.Exec")
|
|
||||||
|
|
||||||
affectd, err := res.RowsAffected()
|
|
||||||
checkErr(err, "insert data res.RowsAffected")
|
|
||||||
|
|
||||||
et := time.Now().Nanosecond()
|
|
||||||
fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9)
|
|
||||||
}
|
|
||||||
|
|
||||||
func select_data(db *sql.DB, demot string) {
|
|
||||||
st := time.Now().Nanosecond()
|
|
||||||
|
|
||||||
rows, err := db.Query("select * from ? " , demot) // go text mode
|
|
||||||
checkErr(err, "select db.Query")
|
|
||||||
|
|
||||||
fmt.Printf("%10s%s%8s %5s %9s%s %s %8s%s %7s%s %8s%s %4s%s %5s%s\n", " ","ts", " ", "id"," ", "name"," ","len", " ","flag"," ", "notes", " ", "fv", " ", " ", "dv")
|
|
||||||
var affectd int
|
|
||||||
for rows.Next() {
|
|
||||||
var ts string
|
|
||||||
var name string
|
|
||||||
var id int
|
|
||||||
var len int8
|
|
||||||
var flag bool
|
|
||||||
var notes string
|
|
||||||
var fv float32
|
|
||||||
var dv float64
|
|
||||||
|
|
||||||
err = rows.Scan(&ts, &id, &name, &len, &flag, ¬es, &fv, &dv)
|
|
||||||
checkErr(err, "select rows.Scan")
|
|
||||||
|
|
||||||
fmt.Printf("%s\t", ts)
|
|
||||||
fmt.Printf("%d\t",id)
|
|
||||||
fmt.Printf("%10s\t",name)
|
|
||||||
fmt.Printf("%d\t",len)
|
|
||||||
fmt.Printf("%t\t",flag)
|
|
||||||
fmt.Printf("%s\t",notes)
|
|
||||||
fmt.Printf("%06.3f\t",fv)
|
|
||||||
fmt.Printf("%09.6f\n",dv)
|
|
||||||
|
|
||||||
affectd++
|
|
||||||
}
|
|
||||||
|
|
||||||
et := time.Now().Nanosecond()
|
|
||||||
fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9)
|
|
||||||
fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9)
|
|
||||||
}
|
|
||||||
|
|
||||||
func drop_database_stmt(db *sql.DB,demodb string) {
|
|
||||||
st := time.Now().Nanosecond()
|
|
||||||
// drop test db
|
|
||||||
res, err := db.Exec("drop database if exists " + demodb)
|
|
||||||
checkErr(err, "drop database " + demodb)
|
|
||||||
|
|
||||||
affectd, err := res.RowsAffected()
|
|
||||||
checkErr(err, "drop db, res.RowsAffected")
|
|
||||||
|
|
||||||
et := time.Now().Nanosecond()
|
|
||||||
fmt.Printf("drop database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9)
|
|
||||||
}
|
|
||||||
|
|
||||||
func create_database_stmt(db *sql.DB,demodb string) {
|
|
||||||
st := time.Now().Nanosecond()
|
|
||||||
// create database
|
|
||||||
//var stmt interface{}
|
|
||||||
stmt, err := db.Prepare("create database ?")
|
|
||||||
checkErr(err, "create db, db.Prepare")
|
|
||||||
|
|
||||||
//var res driver.Result
|
|
||||||
res, err := stmt.Exec(demodb)
|
|
||||||
checkErr(err, "create db, stmt.Exec")
|
|
||||||
|
|
||||||
//fmt.Printf("Query OK, %d row(s) affected()", res.RowsAffected())
|
|
||||||
affectd, err := res.RowsAffected()
|
|
||||||
checkErr(err, "create db, res.RowsAffected")
|
|
||||||
|
|
||||||
et := time.Now().Nanosecond()
|
|
||||||
fmt.Printf("create database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9)
|
|
||||||
}
|
|
||||||
|
|
||||||
func use_database_stmt (db *sql.DB,demodb string) {
|
|
||||||
st := time.Now().Nanosecond()
|
|
||||||
// create database
|
|
||||||
//var stmt interface{}
|
|
||||||
stmt, err := db.Prepare("use " + demodb)
|
|
||||||
checkErr(err, "use db, db.Prepare")
|
|
||||||
|
|
||||||
res, err := stmt.Exec()
|
|
||||||
checkErr(err, "use db, stmt.Exec")
|
|
||||||
|
|
||||||
affectd, err := res.RowsAffected()
|
|
||||||
checkErr(err, "use db, res.RowsAffected")
|
|
||||||
|
|
||||||
et := time.Now().Nanosecond()
|
|
||||||
fmt.Printf("use database result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9)
|
|
||||||
}
|
|
||||||
|
|
||||||
func create_table_stmt (db *sql.DB,demot string) {
|
|
||||||
st := time.Now().Nanosecond()
|
|
||||||
// create table
|
|
||||||
// (ts timestamp, id int, name binary(8), len tinyint, flag bool, notes binary(8), fv float, dv double)
|
|
||||||
stmt, err := db.Prepare("create table ? (? timestamp, ? int, ? binary(10), ? tinyint, ? bool, ? binary(8), ? float, ? double)")
|
|
||||||
checkErr(err, "create table db.Prepare")
|
|
||||||
|
|
||||||
res, err := stmt.Exec(demot, "ts", "id", "name", "len", "flag", "notes", "fv", "dv")
|
|
||||||
checkErr(err, "create table stmt.Exec")
|
|
||||||
|
|
||||||
affectd, err := res.RowsAffected()
|
|
||||||
checkErr(err, "create table res.RowsAffected")
|
|
||||||
|
|
||||||
et := time.Now().Nanosecond()
|
|
||||||
fmt.Printf("create table result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9)
|
|
||||||
}
|
|
||||||
|
|
||||||
func insert_data_stmt(db *sql.DB,demot string) {
|
|
||||||
st := time.Now().Nanosecond()
|
|
||||||
// insert data into table
|
|
||||||
stmt, err := db.Prepare("insert into ? values(?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?) (?, ?, ?, ?, ?, ?, ?, ?)")
|
|
||||||
checkErr(err, "insert db.Prepare")
|
|
||||||
|
|
||||||
res, err := stmt.Exec(demot, "now" , 1000, "'haidian'" , 6, true, "'AI world'", 6987.654, 321.987,
|
|
||||||
"now+1s", 1001, "'changyang'" , 7, false, "'DeepMode'", 12356.456, 128634.456,
|
|
||||||
"now+2s", 1002, "'chuangping'" , 8, true, "'database'", 3879.456, 65433478.456,)
|
|
||||||
checkErr(err, "insert data, stmt.Exec")
|
|
||||||
|
|
||||||
affectd, err := res.RowsAffected()
|
|
||||||
checkErr(err, "res.RowsAffected")
|
|
||||||
|
|
||||||
et := time.Now().Nanosecond()
|
|
||||||
fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9)
|
|
||||||
}
|
|
||||||
|
|
||||||
func select_data_stmt(db *sql.DB, demot string) {
|
|
||||||
st := time.Now().Nanosecond()
|
|
||||||
|
|
||||||
stmt, err := db.Prepare("select ?, ?, ?, ?, ?, ?, ?, ? from ?" ) // go binary mode
|
|
||||||
checkErr(err, "db.Prepare")
|
|
||||||
|
|
||||||
rows, err := stmt.Query("ts", "id","name","len", "flag","notes", "fv", "dv", demot)
|
|
||||||
checkErr(err, "stmt.Query")
|
|
||||||
|
|
||||||
fmt.Printf("%10s%s%8s %5s %8s%s %s %10s%s %7s%s %8s%s %11s%s %14s%s\n", " ","ts", " ", "id"," ", "name"," ","len", " ","flag"," ", "notes", " ", "fv", " ", " ", "dv")
|
|
||||||
var affectd int
|
|
||||||
for rows.Next() {
|
|
||||||
var ts string
|
|
||||||
var name string
|
|
||||||
var id int
|
|
||||||
var len int8
|
|
||||||
var flag bool
|
|
||||||
var notes string
|
|
||||||
var fv float32
|
|
||||||
var dv float64
|
|
||||||
|
|
||||||
err = rows.Scan(&ts, &id, &name, &len, &flag, ¬es, &fv, &dv)
|
|
||||||
//fmt.Println("start scan fields from row.rs, &fv:", &fv)
|
|
||||||
//err = rows.Scan(&fv)
|
|
||||||
checkErr(err, "rows.Scan")
|
|
||||||
|
|
||||||
fmt.Printf("%s\t", ts)
|
|
||||||
fmt.Printf("%d\t",id)
|
|
||||||
fmt.Printf("%10s\t",name)
|
|
||||||
fmt.Printf("%d\t",len)
|
|
||||||
fmt.Printf("%t\t",flag)
|
|
||||||
fmt.Printf("%s\t",notes)
|
|
||||||
fmt.Printf("%06.3f\t",fv)
|
|
||||||
fmt.Printf("%09.6f\n",dv)
|
|
||||||
|
|
||||||
affectd++
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
et := time.Now().Nanosecond()
|
|
||||||
fmt.Printf("insert data result:\n %d row(s) affectd (%6.6fs)\n\n", affectd, (float32(et-st))/1E9)
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkErr(err error, prompt string) {
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("%s\n", prompt)
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,409 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
|
_ "github.com/taosdata/driver-go/taosSql"
|
||||||
|
"os"
|
||||||
|
"sync"
|
||||||
|
"runtime"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
"flag"
|
||||||
|
"math/rand"
|
||||||
|
//"golang.org/x/sys/unix"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
maxLocationSize = 32
|
||||||
|
maxSqlBufSize = 65480
|
||||||
|
)
|
||||||
|
|
||||||
|
var locations = [maxLocationSize]string {
|
||||||
|
"Beijing", "Shanghai", "Guangzhou", "Shenzhen",
|
||||||
|
"HangZhou", "Tianjin", "Wuhan", "Changsha",
|
||||||
|
"Nanjing", "Xian"}
|
||||||
|
|
||||||
|
type config struct {
|
||||||
|
hostName string
|
||||||
|
serverPort int
|
||||||
|
user string
|
||||||
|
password string
|
||||||
|
dbName string
|
||||||
|
supTblName string
|
||||||
|
tablePrefix string
|
||||||
|
numOftables int
|
||||||
|
numOfRecordsPerTable int
|
||||||
|
numOfRecordsPerReq int
|
||||||
|
numOfThreads int
|
||||||
|
startTimestamp string
|
||||||
|
startTs int64
|
||||||
|
|
||||||
|
keep int
|
||||||
|
days int
|
||||||
|
}
|
||||||
|
|
||||||
|
var configPara config
|
||||||
|
var taosDriverName = "taosSql"
|
||||||
|
var url string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
flag.StringVar(&configPara.hostName, "h", "127.0.0.1","The host to connect to TDengine server.")
|
||||||
|
flag.IntVar(&configPara.serverPort, "p", 6030, "The TCP/IP port number to use for the connection to TDengine server.")
|
||||||
|
flag.StringVar(&configPara.user, "u", "root", "The TDengine user name to use when connecting to the server.")
|
||||||
|
flag.StringVar(&configPara.password, "P", "taosdata", "The password to use when connecting to the server.")
|
||||||
|
flag.StringVar(&configPara.dbName, "d", "test", "Destination database.")
|
||||||
|
flag.StringVar(&configPara.tablePrefix, "m", "d", "Table prefix name.")
|
||||||
|
flag.IntVar(&configPara.numOftables, "t", 2, "The number of tables.")
|
||||||
|
flag.IntVar(&configPara.numOfRecordsPerTable, "n", 10, "The number of records per table.")
|
||||||
|
flag.IntVar(&configPara.numOfRecordsPerReq, "r", 3, "The number of records per request.")
|
||||||
|
flag.IntVar(&configPara.numOfThreads, "T", 1, "The number of threads.")
|
||||||
|
flag.StringVar(&configPara.startTimestamp, "s", "2020-10-01 08:00:00", "The start timestamp for one table.")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
|
configPara.keep = 365 * 20
|
||||||
|
configPara.days = 30
|
||||||
|
configPara.supTblName = "meters"
|
||||||
|
|
||||||
|
startTs, err := time.ParseInLocation("2006-01-02 15:04:05", configPara.startTimestamp, time.Local)
|
||||||
|
if err==nil {
|
||||||
|
configPara.startTs = startTs.UnixNano() / 1e6
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func printAllArgs() {
|
||||||
|
fmt.Printf("\n============= args parse result: =============\n")
|
||||||
|
fmt.Printf("dbName: %v\n", configPara.hostName)
|
||||||
|
fmt.Printf("serverPort: %v\n", configPara.serverPort)
|
||||||
|
fmt.Printf("usr: %v\n", configPara.user)
|
||||||
|
fmt.Printf("password: %v\n", configPara.password)
|
||||||
|
fmt.Printf("dbName: %v\n", configPara.dbName)
|
||||||
|
fmt.Printf("tablePrefix: %v\n", configPara.tablePrefix)
|
||||||
|
fmt.Printf("numOftables: %v\n", configPara.numOftables)
|
||||||
|
fmt.Printf("numOfRecordsPerTable: %v\n", configPara.numOfRecordsPerTable)
|
||||||
|
fmt.Printf("numOfRecordsPerReq: %v\n", configPara.numOfRecordsPerReq)
|
||||||
|
fmt.Printf("numOfThreads: %v\n", configPara.numOfThreads)
|
||||||
|
fmt.Printf("startTimestamp: %v[%v]\n", configPara.startTimestamp, configPara.startTs)
|
||||||
|
fmt.Printf("================================================\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
printAllArgs()
|
||||||
|
fmt.Printf("Please press enter key to continue....\n")
|
||||||
|
fmt.Scanln()
|
||||||
|
|
||||||
|
url = "root:taosdata@/tcp(" + configPara.hostName + ":" + strconv.Itoa(configPara.serverPort) + ")/"
|
||||||
|
//url = fmt.Sprintf("%s:%s@/tcp(%s:%d)/%s?interpolateParams=true", configPara.user, configPara.password, configPara.hostName, configPara.serverPort, configPara.dbName)
|
||||||
|
// open connect to taos server
|
||||||
|
//db, err := sql.Open(taosDriverName, url)
|
||||||
|
//if err != nil {
|
||||||
|
// fmt.Println("Open database error: %s\n", err)
|
||||||
|
// os.Exit(1)
|
||||||
|
//}
|
||||||
|
//defer db.Close()
|
||||||
|
|
||||||
|
createDatabase(configPara.dbName, configPara.supTblName)
|
||||||
|
fmt.Printf("======== create database success! ========\n\n")
|
||||||
|
|
||||||
|
//create_table(db, stblName)
|
||||||
|
multiThreadCreateTable(configPara.numOfThreads, configPara.numOftables, configPara.dbName, configPara.tablePrefix)
|
||||||
|
fmt.Printf("======== create super table and child tables success! ========\n\n")
|
||||||
|
|
||||||
|
//insert_data(db, demot)
|
||||||
|
multiThreadInsertData(configPara.numOfThreads, configPara.numOftables, configPara.dbName, configPara.tablePrefix)
|
||||||
|
fmt.Printf("======== insert data into child tables success! ========\n\n")
|
||||||
|
|
||||||
|
//select_data(db, demot)
|
||||||
|
selectTest(configPara.dbName, configPara.tablePrefix, configPara.supTblName)
|
||||||
|
fmt.Printf("======== select data success! ========\n\n")
|
||||||
|
|
||||||
|
fmt.Printf("======== end demo ========\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
func createDatabase(dbName string, supTblName string) {
|
||||||
|
db, err := sql.Open(taosDriverName, url)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Open database error: %s\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
// drop database if exists
|
||||||
|
sqlStr := "drop database if exists " + dbName
|
||||||
|
_, err = db.Exec(sqlStr)
|
||||||
|
checkErr(err, sqlStr)
|
||||||
|
|
||||||
|
time.Sleep(time.Second)
|
||||||
|
|
||||||
|
// create database
|
||||||
|
sqlStr = "create database " + dbName + " keep " + strconv.Itoa(configPara.keep) + " days " + strconv.Itoa(configPara.days)
|
||||||
|
_, err = db.Exec(sqlStr)
|
||||||
|
checkErr(err, sqlStr)
|
||||||
|
|
||||||
|
// use database
|
||||||
|
//sqlStr = "use " + dbName
|
||||||
|
//_, err = db.Exec(sqlStr)
|
||||||
|
//checkErr(err, sqlStr)
|
||||||
|
|
||||||
|
sqlStr = "create table if not exists " + dbName + "." + supTblName + " (ts timestamp, current float, voltage int, phase float) tags(location binary(64), groupId int);"
|
||||||
|
_, err = db.Exec(sqlStr)
|
||||||
|
checkErr(err, sqlStr)
|
||||||
|
}
|
||||||
|
|
||||||
|
func multiThreadCreateTable(threads int, ntables int, dbName string, tablePrefix string) {
|
||||||
|
st := time.Now().UnixNano()
|
||||||
|
|
||||||
|
if (threads < 1) {
|
||||||
|
threads = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
a := ntables / threads;
|
||||||
|
if (a < 1) {
|
||||||
|
threads = ntables;
|
||||||
|
a = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
b := ntables % threads;
|
||||||
|
|
||||||
|
last := 0;
|
||||||
|
endTblId := 0
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
for i := 0; i < threads; i++ {
|
||||||
|
startTblId := last
|
||||||
|
if (i < b ) {
|
||||||
|
endTblId = last + a
|
||||||
|
} else {
|
||||||
|
endTblId = last + a - 1
|
||||||
|
}
|
||||||
|
last = endTblId + 1
|
||||||
|
wg.Add(1)
|
||||||
|
go createTable(dbName, tablePrefix, startTblId, endTblId, &wg)
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
|
et := time.Now().UnixNano()
|
||||||
|
fmt.Printf("create tables spent duration: %6.6fs\n", (float32(et-st))/1e9)
|
||||||
|
}
|
||||||
|
|
||||||
|
func createTable(dbName string, childTblPrefix string, startTblId int, endTblId int, wg *sync.WaitGroup) {
|
||||||
|
//fmt.Printf("subThread[%d]: create table from %d to %d \n", unix.Gettid(), startTblId, endTblId)
|
||||||
|
// windows.GetCurrentThreadId()
|
||||||
|
|
||||||
|
db, err := sql.Open(taosDriverName, url)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Open database error: %s\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
for i := startTblId; i <= endTblId; i++ {
|
||||||
|
sqlStr := "create table if not exists " + dbName + "." + childTblPrefix + strconv.Itoa(i) + " using " + dbName + ".meters tags('" + locations[i%maxLocationSize] + "', " + strconv.Itoa(i) + ");"
|
||||||
|
//fmt.Printf("sqlStr: %v\n", sqlStr)
|
||||||
|
_, err = db.Exec(sqlStr)
|
||||||
|
checkErr(err, sqlStr)
|
||||||
|
}
|
||||||
|
wg.Done()
|
||||||
|
runtime.Goexit()
|
||||||
|
}
|
||||||
|
|
||||||
|
func generateRowData(ts int64) string {
|
||||||
|
voltage := rand.Int() % 1000
|
||||||
|
current := 200 + rand.Float32()
|
||||||
|
phase := rand.Float32()
|
||||||
|
values := "( " + strconv.FormatInt(ts, 10) + ", " + strconv.FormatFloat(float64(current), 'f', 6, 64) + ", " + strconv.Itoa(voltage) + ", " + strconv.FormatFloat(float64(phase), 'f', 6, 64) + " ) "
|
||||||
|
return values
|
||||||
|
}
|
||||||
|
func insertData(dbName string, childTblPrefix string, startTblId int, endTblId int, wg *sync.WaitGroup) {
|
||||||
|
//fmt.Printf("subThread[%d]: insert data to table from %d to %d \n", unix.Gettid(), startTblId, endTblId)
|
||||||
|
// windows.GetCurrentThreadId()
|
||||||
|
|
||||||
|
db, err := sql.Open(taosDriverName, url)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Open database error: %s\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
tmpTs := configPara.startTs;
|
||||||
|
//rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||||
|
for tID := startTblId; tID <= endTblId; tID++{
|
||||||
|
totalNum := 0
|
||||||
|
for {
|
||||||
|
sqlStr := "insert into " + dbName + "." + childTblPrefix + strconv.Itoa(tID) + " values "
|
||||||
|
currRowNum := 0
|
||||||
|
for {
|
||||||
|
tmpTs += 1000
|
||||||
|
valuesOfRow := generateRowData(tmpTs)
|
||||||
|
currRowNum += 1
|
||||||
|
totalNum += 1
|
||||||
|
|
||||||
|
sqlStr = fmt.Sprintf("%s %s", sqlStr, valuesOfRow)
|
||||||
|
|
||||||
|
if (currRowNum >= configPara.numOfRecordsPerReq || totalNum >= configPara.numOfRecordsPerTable) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := db.Exec(sqlStr)
|
||||||
|
checkErr(err, sqlStr)
|
||||||
|
|
||||||
|
count, err := res.RowsAffected()
|
||||||
|
checkErr(err, "rows affected")
|
||||||
|
|
||||||
|
if (count != int64(currRowNum)) {
|
||||||
|
fmt.Printf("insert data, expect affected:%d, actual:%d\n", currRowNum, count)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (totalNum >= configPara.numOfRecordsPerTable) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wg.Done()
|
||||||
|
runtime.Goexit()
|
||||||
|
}
|
||||||
|
func multiThreadInsertData(threads int, ntables int, dbName string, tablePrefix string) {
|
||||||
|
st := time.Now().UnixNano()
|
||||||
|
|
||||||
|
if (threads < 1) {
|
||||||
|
threads = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
a := ntables / threads;
|
||||||
|
if (a < 1) {
|
||||||
|
threads = ntables;
|
||||||
|
a = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
b := ntables % threads;
|
||||||
|
|
||||||
|
last := 0;
|
||||||
|
endTblId := 0
|
||||||
|
wg := sync.WaitGroup{}
|
||||||
|
for i := 0; i < threads; i++ {
|
||||||
|
startTblId := last
|
||||||
|
if (i < b ) {
|
||||||
|
endTblId = last + a
|
||||||
|
} else {
|
||||||
|
endTblId = last + a - 1
|
||||||
|
}
|
||||||
|
last = endTblId + 1
|
||||||
|
wg.Add(1)
|
||||||
|
go insertData(dbName, tablePrefix, startTblId , endTblId, &wg)
|
||||||
|
}
|
||||||
|
wg.Wait()
|
||||||
|
|
||||||
|
et := time.Now().UnixNano()
|
||||||
|
fmt.Printf("insert data spent duration: %6.6fs\n", (float32(et-st))/1e9)
|
||||||
|
}
|
||||||
|
func selectTest(dbName string, tbPrefix string, supTblName string){
|
||||||
|
db, err := sql.Open(taosDriverName, url)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Open database error: %s\n", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
defer db.Close()
|
||||||
|
|
||||||
|
// select sql 1
|
||||||
|
limit := 3
|
||||||
|
offset := 0
|
||||||
|
sqlStr := "select * from " + dbName + "." + supTblName + " limit " + strconv.Itoa(limit) + " offset " + strconv.Itoa(offset)
|
||||||
|
rows, err := db.Query(sqlStr)
|
||||||
|
checkErr(err, sqlStr)
|
||||||
|
|
||||||
|
defer rows.Close()
|
||||||
|
fmt.Printf("query sql: %s\n", sqlStr)
|
||||||
|
for rows.Next() {
|
||||||
|
var (
|
||||||
|
ts string
|
||||||
|
current float32
|
||||||
|
voltage int
|
||||||
|
phase float32
|
||||||
|
location string
|
||||||
|
groupid int
|
||||||
|
)
|
||||||
|
err := rows.Scan(&ts, ¤t, &voltage, &phase, &location, &groupid)
|
||||||
|
if err != nil {
|
||||||
|
checkErr(err, "rows scan fail")
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("ts:%s\t current:%f\t voltage:%d\t phase:%f\t location:%s\t groupid:%d\n", ts, current, voltage, phase, location, groupid)
|
||||||
|
}
|
||||||
|
// check iteration error
|
||||||
|
if rows.Err() != nil {
|
||||||
|
checkErr(err, "rows next iteration error")
|
||||||
|
}
|
||||||
|
|
||||||
|
// select sql 2
|
||||||
|
sqlStr = "select avg(voltage), min(voltage), max(voltage) from " + dbName + "." + tbPrefix + strconv.Itoa( rand.Int() % configPara.numOftables)
|
||||||
|
rows, err = db.Query(sqlStr)
|
||||||
|
checkErr(err, sqlStr)
|
||||||
|
|
||||||
|
defer rows.Close()
|
||||||
|
fmt.Printf("\nquery sql: %s\n", sqlStr)
|
||||||
|
for rows.Next() {
|
||||||
|
var (
|
||||||
|
voltageAvg float32
|
||||||
|
voltageMin int
|
||||||
|
voltageMax int
|
||||||
|
)
|
||||||
|
err := rows.Scan(&voltageAvg, &voltageMin, &voltageMax)
|
||||||
|
if err != nil {
|
||||||
|
checkErr(err, "rows scan fail")
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("avg(voltage):%f\t min(voltage):%d\t max(voltage):%d\n", voltageAvg, voltageMin, voltageMax)
|
||||||
|
}
|
||||||
|
// check iteration error
|
||||||
|
if rows.Err() != nil {
|
||||||
|
checkErr(err, "rows next iteration error")
|
||||||
|
}
|
||||||
|
|
||||||
|
// select sql 3
|
||||||
|
sqlStr = "select last(*) from " + dbName + "." + supTblName
|
||||||
|
rows, err = db.Query(sqlStr)
|
||||||
|
checkErr(err, sqlStr)
|
||||||
|
|
||||||
|
defer rows.Close()
|
||||||
|
fmt.Printf("\nquery sql: %s\n", sqlStr)
|
||||||
|
for rows.Next() {
|
||||||
|
var (
|
||||||
|
lastTs string
|
||||||
|
lastCurrent float32
|
||||||
|
lastVoltage int
|
||||||
|
lastPhase float32
|
||||||
|
)
|
||||||
|
err := rows.Scan(&lastTs, &lastCurrent, &lastVoltage, &lastPhase)
|
||||||
|
if err != nil {
|
||||||
|
checkErr(err, "rows scan fail")
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("last(ts):%s\t last(current):%f\t last(voltage):%d\t last(phase):%f\n", lastTs, lastCurrent, lastVoltage, lastPhase)
|
||||||
|
}
|
||||||
|
// check iteration error
|
||||||
|
if rows.Err() != nil {
|
||||||
|
checkErr(err, "rows next iteration error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
func checkErr(err error, prompt string) {
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("%s\n", prompt)
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -751,7 +751,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
|
||||||
sprintf(value, "%" PRId64, *((int64_t *)row[i]));
|
sprintf(value, "%" PRId64, *((int64_t *)row[i]));
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_FLOAT:{
|
case TSDB_DATA_TYPE_FLOAT:{
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
float fv = 0;
|
float fv = 0;
|
||||||
*(int32_t*)(&fv) = *(int32_t*)row[i];
|
*(int32_t*)(&fv) = *(int32_t*)row[i];
|
||||||
sprintf(value, "%.5f", fv);
|
sprintf(value, "%.5f", fv);
|
||||||
|
@ -761,7 +761,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
case TSDB_DATA_TYPE_DOUBLE: {
|
||||||
#ifdef _TD_ARM_32_
|
#ifdef _TD_ARM_32
|
||||||
double dv = 0;
|
double dv = 0;
|
||||||
*(int64_t*)(&dv) = *(int64_t*)row[i];
|
*(int64_t*)(&dv) = *(int64_t*)row[i];
|
||||||
sprintf(value, "%.9lf", dv);
|
sprintf(value, "%.9lf", dv);
|
||||||
|
|
Loading…
Reference in New Issue