提交 b329c58d 编写于 作者: Z zyyang-taosdata

merge master

...@@ -263,12 +263,12 @@ pipeline { ...@@ -263,12 +263,12 @@ pipeline {
''' '''
} }
timeout(time: 60, unit: 'MINUTES'){ timeout(time: 60, unit: 'MINUTES'){
// sh ''' sh '''
// cd ${WKC}/tests/pytest cd ${WKC}/tests/pytest
// rm -rf /var/lib/taos/* rm -rf /var/lib/taos/*
// rm -rf /var/log/taos/* rm -rf /var/log/taos/*
// ./handle_crash_gen_val_log.sh ./handle_crash_gen_val_log.sh
// ''' '''
sh ''' sh '''
cd ${WKC}/tests/pytest cd ${WKC}/tests/pytest
rm -rf /var/lib/taos/* rm -rf /var/lib/taos/*
......
...@@ -6,6 +6,8 @@ IF (TD_LINUX) ...@@ -6,6 +6,8 @@ IF (TD_LINUX)
ELSEIF (TD_WINDOWS) ELSEIF (TD_WINDOWS)
IF (TD_POWER) IF (TD_POWER)
SET(CMAKE_INSTALL_PREFIX C:/PowerDB) SET(CMAKE_INSTALL_PREFIX C:/PowerDB)
ELSEIF (TD_PRO)
SET(CMAKE_INSTALL_PREFIX C:/ProDB)
ELSE () ELSE ()
SET(CMAKE_INSTALL_PREFIX C:/TDengine) SET(CMAKE_INSTALL_PREFIX C:/TDengine)
ENDIF () ENDIF ()
...@@ -24,6 +26,8 @@ ELSEIF (TD_WINDOWS) ...@@ -24,6 +26,8 @@ ELSEIF (TD_WINDOWS)
IF (TD_POWER) IF (TD_POWER)
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/power.exe DESTINATION .) INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/power.exe DESTINATION .)
ELSEIF (TD_PRO)
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/prodbc.exe DESTINATION .)
ELSE () ELSE ()
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .) INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taos.exe DESTINATION .)
INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taosdemo.exe DESTINATION .) INSTALL(FILES ${EXECUTABLE_OUTPUT_PATH}/taosdemo.exe DESTINATION .)
......
...@@ -4,7 +4,7 @@ PROJECT(TDengine) ...@@ -4,7 +4,7 @@ PROJECT(TDengine)
IF (DEFINED VERNUMBER) IF (DEFINED VERNUMBER)
SET(TD_VER_NUMBER ${VERNUMBER}) SET(TD_VER_NUMBER ${VERNUMBER})
ELSE () ELSE ()
SET(TD_VER_NUMBER "2.2.0.1") SET(TD_VER_NUMBER "2.2.0.2")
ENDIF () ENDIF ()
IF (DEFINED VERCOMPATIBLE) IF (DEFINED VERCOMPATIBLE)
......
...@@ -45,6 +45,7 @@ echo "version=${version}" ...@@ -45,6 +45,7 @@ echo "version=${version}"
#docker manifest rm tdengine/tdengine:${version} #docker manifest rm tdengine/tdengine:${version}
if [ "$verType" == "beta" ]; then if [ "$verType" == "beta" ]; then
docker manifest inspect tdengine/tdengine-beta:latest docker manifest inspect tdengine/tdengine-beta:latest
docker manifest create -a tdengine/tdengine-beta:latest tdengine/tdengine-amd64-beta:latest tdengine/tdengine-aarch64-beta:latest tdengine/tdengine-aarch32-beta:latest
docker manifest rm tdengine/tdengine-beta:latest docker manifest rm tdengine/tdengine-beta:latest
docker manifest create -a tdengine/tdengine-beta:${version} tdengine/tdengine-amd64-beta:${version} tdengine/tdengine-aarch64-beta:${version} tdengine/tdengine-aarch32-beta:${version} docker manifest create -a tdengine/tdengine-beta:${version} tdengine/tdengine-amd64-beta:${version} tdengine/tdengine-aarch64-beta:${version} tdengine/tdengine-aarch32-beta:${version}
docker manifest create -a tdengine/tdengine-beta:latest tdengine/tdengine-amd64-beta:latest tdengine/tdengine-aarch64-beta:latest tdengine/tdengine-aarch32-beta:latest docker manifest create -a tdengine/tdengine-beta:latest tdengine/tdengine-amd64-beta:latest tdengine/tdengine-aarch64-beta:latest tdengine/tdengine-aarch32-beta:latest
...@@ -54,6 +55,7 @@ if [ "$verType" == "beta" ]; then ...@@ -54,6 +55,7 @@ if [ "$verType" == "beta" ]; then
elif [ "$verType" == "stable" ]; then elif [ "$verType" == "stable" ]; then
docker manifest inspect tdengine/tdengine:latest docker manifest inspect tdengine/tdengine:latest
docker manifest create -a tdengine/tdengine:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest
docker manifest rm tdengine/tdengine:latest docker manifest rm tdengine/tdengine:latest
docker manifest create -a tdengine/tdengine:${version} tdengine/tdengine-amd64:${version} tdengine/tdengine-aarch64:${version} tdengine/tdengine-aarch32:${version} docker manifest create -a tdengine/tdengine:${version} tdengine/tdengine-amd64:${version} tdengine/tdengine-aarch64:${version} tdengine/tdengine-aarch32:${version}
docker manifest create -a tdengine/tdengine:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest docker manifest create -a tdengine/tdengine:latest tdengine/tdengine-amd64:latest tdengine/tdengine-aarch64:latest tdengine/tdengine-aarch32:latest
......
...@@ -72,11 +72,10 @@ if [ "$verMode" == "cluster" ]; then ...@@ -72,11 +72,10 @@ if [ "$verMode" == "cluster" ]; then
sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/bin/remove_pro.sh >> remove_prodb_temp.sh sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/bin/remove_pro.sh >> remove_prodb_temp.sh
mv remove_prodb_temp.sh ${install_dir}/bin/remove_pro.sh mv remove_prodb_temp.sh ${install_dir}/bin/remove_pro.sh
mkdir -p ${install_dir}/nginxd && cp -r ${nginx_dir}/* ${install_dir}/nginxd mkdir -p ${install_dir}/nginxd && cp -r ${nginx_dir}/* ${install_dir}/nginxd
cp ${nginx_dir}/png/taos.png ${install_dir}/nginxd/admin/images/taos.png cp ${nginx_dir}/png/taos.png ${install_dir}/nginxd/admin/images/taos.png
rm -rf ${install_dir}/nginxd/png rm -rf ${install_dir}/nginxd/png
# replace the OEM name, add by yangzy@2021-09-22 # replace the OEM name, add by yangzy@2021-09-22
sed -i -e 's/www.taosdata.com/www.hanatech.com.cn/g' $(grep -r 'www.taosdata.com' ${install_dir}/nginxd | sed -r "s/(.*\.html):\s*(.*)/\1/g") sed -i -e 's/www.taosdata.com/www.hanatech.com.cn/g' $(grep -r 'www.taosdata.com' ${install_dir}/nginxd | sed -r "s/(.*\.html):\s*(.*)/\1/g")
sed -i -e 's/TAOS Data/Hanatech/g' $(grep -r 'TAOS Data' ${install_dir}/nginxd | sed -r "s/(.*\.html):\s*(.*)/\1/g") sed -i -e 's/TAOS Data/Hanatech/g' $(grep -r 'TAOS Data' ${install_dir}/nginxd | sed -r "s/(.*\.html):\s*(.*)/\1/g")
......
name: tdengine name: tdengine
base: core18 base: core18
version: '2.2.0.1' version: '2.2.0.2'
icon: snap/gui/t-dengine.svg icon: snap/gui/t-dengine.svg
summary: an open-source big data platform designed and optimized for IoT. summary: an open-source big data platform designed and optimized for IoT.
description: | description: |
...@@ -72,7 +72,7 @@ parts: ...@@ -72,7 +72,7 @@ parts:
- usr/bin/taosd - usr/bin/taosd
- usr/bin/taos - usr/bin/taos
- usr/bin/taosdemo - usr/bin/taosdemo
- usr/lib/libtaos.so.2.2.0.1 - usr/lib/libtaos.so.2.2.0.2
- usr/lib/libtaos.so.1 - usr/lib/libtaos.so.1
- usr/lib/libtaos.so - usr/lib/libtaos.so
......
...@@ -52,7 +52,7 @@ int tsInsertInitialCheck(SSqlObj *pSql); ...@@ -52,7 +52,7 @@ int tsInsertInitialCheck(SSqlObj *pSql);
void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs); void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs);
void tscFreeRetrieveSup(SSqlObj *pSql); void tscFreeRetrieveSup(void **param);
......
...@@ -48,6 +48,8 @@ struct SSqlInfo; ...@@ -48,6 +48,8 @@ struct SSqlInfo;
typedef void (*__async_cb_func_t)(void *param, TAOS_RES *tres, int32_t numOfRows); typedef void (*__async_cb_func_t)(void *param, TAOS_RES *tres, int32_t numOfRows);
typedef void (*_freeSqlSupporter)(void **);
typedef struct SNewVgroupInfo { typedef struct SNewVgroupInfo {
int32_t vgId; int32_t vgId;
int8_t inUse; int8_t inUse;
...@@ -364,6 +366,7 @@ typedef struct SSqlObj { ...@@ -364,6 +366,7 @@ typedef struct SSqlObj {
__async_cb_func_t fp; __async_cb_func_t fp;
__async_cb_func_t fetchFp; __async_cb_func_t fetchFp;
void *param; void *param;
_freeSqlSupporter freeParam;
int64_t stime; int64_t stime;
uint32_t queryId; uint32_t queryId;
void * pStream; void * pStream;
......
...@@ -77,6 +77,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, __async_cb_func_t fp, void* para ...@@ -77,6 +77,7 @@ void doAsyncQuery(STscObj* pObj, SSqlObj* pSql, __async_cb_func_t fp, void* para
SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd); SQueryInfo* pQueryInfo = tscGetQueryInfo(pCmd);
executeQuery(pSql, pQueryInfo); executeQuery(pSql, pQueryInfo);
taosReleaseRef(tscObjRef, pSql->self); taosReleaseRef(tscObjRef, pSql->self);
} }
......
...@@ -4455,7 +4455,7 @@ static int32_t validateLikeExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_t ...@@ -4455,7 +4455,7 @@ static int32_t validateLikeExpr(tSqlExpr* pExpr, STableMeta* pTableMeta, int32_t
} }
static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SCondExpr* pCondExpr, static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SCondExpr* pCondExpr,
int32_t* type, int32_t parentOptr) { int32_t* type, int32_t parentOptr, int32_t* tbIdx) {
const char* msg1 = "table query cannot use tags filter"; const char* msg1 = "table query cannot use tags filter";
const char* msg2 = "illegal column name"; const char* msg2 = "illegal column name";
const char* msg3 = "only one query time range allowed"; const char* msg3 = "only one query time range allowed";
...@@ -4474,6 +4474,8 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql ...@@ -4474,6 +4474,8 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2);
} }
*tbIdx = index.tableIndex;
assert(tSqlExprIsParentOfLeaf(*pExpr)); assert(tSqlExprIsParentOfLeaf(*pExpr));
STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex); STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, index.tableIndex);
...@@ -4612,12 +4614,12 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql ...@@ -4612,12 +4614,12 @@ static int32_t handleExprInQueryCond(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSql
} }
int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SCondExpr* pCondExpr, int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SCondExpr* pCondExpr,
int32_t* type, int32_t parentOptr) { int32_t* type, int32_t parentOptr, int32_t *tbIdx) {
if (pExpr == NULL) { if (pExpr == NULL) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
const char* msg1 = "query condition between different columns must use 'AND'"; const char* msg1 = "query condition between columns/tables must use 'AND'";
if ((*pExpr)->flags & (1 << EXPR_FLAG_TS_ERROR)) { if ((*pExpr)->flags & (1 << EXPR_FLAG_TS_ERROR)) {
return TSDB_CODE_TSC_INVALID_OPERATION; return TSDB_CODE_TSC_INVALID_OPERATION;
...@@ -4632,14 +4634,16 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr ...@@ -4632,14 +4634,16 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr
int32_t leftType = -1; int32_t leftType = -1;
int32_t rightType = -1; int32_t rightType = -1;
int32_t leftTbIdx = 0;
int32_t rightTbIdx = 0;
if (!tSqlExprIsParentOfLeaf(*pExpr)) { if (!tSqlExprIsParentOfLeaf(*pExpr)) {
int32_t ret = getQueryCondExpr(pCmd, pQueryInfo, &(*pExpr)->pLeft, pCondExpr, &leftType, (*pExpr)->tokenId); int32_t ret = getQueryCondExpr(pCmd, pQueryInfo, &(*pExpr)->pLeft, pCondExpr, &leftType, (*pExpr)->tokenId, &leftTbIdx);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
return ret; return ret;
} }
ret = getQueryCondExpr(pCmd, pQueryInfo, &(*pExpr)->pRight, pCondExpr, &rightType, (*pExpr)->tokenId); ret = getQueryCondExpr(pCmd, pQueryInfo, &(*pExpr)->pRight, pCondExpr, &rightType, (*pExpr)->tokenId, &rightTbIdx);
if (ret != TSDB_CODE_SUCCESS) { if (ret != TSDB_CODE_SUCCESS) {
return ret; return ret;
} }
...@@ -4654,7 +4658,14 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr ...@@ -4654,7 +4658,14 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr
} }
} }
if (((leftTbIdx != rightTbIdx) || (leftTbIdx == -1 || rightTbIdx == -1)) && ((*pExpr)->tokenId == TK_OR)) {
return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1);
}
*type = rightType; *type = rightType;
*tbIdx = (leftTbIdx == rightTbIdx) ? leftTbIdx : -1;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
...@@ -4668,7 +4679,7 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr ...@@ -4668,7 +4679,7 @@ int32_t getQueryCondExpr(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, tSqlExpr** pExpr
return TSDB_CODE_TSC_INVALID_OPERATION; return TSDB_CODE_TSC_INVALID_OPERATION;
} }
return handleExprInQueryCond(pCmd, pQueryInfo, pExpr, pCondExpr, type, parentOptr); return handleExprInQueryCond(pCmd, pQueryInfo, pExpr, pCondExpr, type, parentOptr, tbIdx);
} }
static void doExtractExprForSTable(SSqlCmd* pCmd, tSqlExpr** pExpr, SQueryInfo* pQueryInfo, tSqlExpr** pOut, int32_t tableIndex) { static void doExtractExprForSTable(SSqlCmd* pCmd, tSqlExpr** pExpr, SQueryInfo* pQueryInfo, tSqlExpr** pOut, int32_t tableIndex) {
...@@ -5210,7 +5221,8 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq ...@@ -5210,7 +5221,8 @@ int32_t validateWhereNode(SQueryInfo* pQueryInfo, tSqlExpr** pExpr, SSqlObj* pSq
} }
int32_t type = 0; int32_t type = 0;
if ((ret = getQueryCondExpr(&pSql->cmd, pQueryInfo, pExpr, &condExpr, &type, (*pExpr)->tokenId)) != TSDB_CODE_SUCCESS) { int32_t tbIdx = 0;
if ((ret = getQueryCondExpr(&pSql->cmd, pQueryInfo, pExpr, &condExpr, &type, (*pExpr)->tokenId, &tbIdx)) != TSDB_CODE_SUCCESS) {
goto PARSE_WHERE_EXIT; goto PARSE_WHERE_EXIT;
} }
......
...@@ -2129,7 +2129,7 @@ void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs) { ...@@ -2129,7 +2129,7 @@ void doCleanupSubqueries(SSqlObj *pSql, int32_t numOfSubs) {
SSqlObj* pSub = pSql->pSubs[i]; SSqlObj* pSub = pSql->pSubs[i];
assert(pSub != NULL); assert(pSub != NULL);
tscFreeRetrieveSup(pSub); tscFreeRetrieveSup(&pSub->param);
taos_free_result(pSub); taos_free_result(pSub);
} }
...@@ -2215,10 +2215,13 @@ void doAppendData(SInterResult* pInterResult, TAOS_ROW row, int32_t numOfCols, S ...@@ -2215,10 +2215,13 @@ void doAppendData(SInterResult* pInterResult, TAOS_ROW row, int32_t numOfCols, S
} }
} }
static void destroySup(SFirstRoundQuerySup* pSup) { static void tscFreeFirstRoundSup(void **param) {
taosArrayDestroyEx(pSup->pResult, freeInterResult); if (*param) {
taosArrayDestroy(pSup->pColsInfo); SFirstRoundQuerySup* pSup = (SFirstRoundQuerySup*)*param;
tfree(pSup); taosArrayDestroyEx(pSup->pResult, freeInterResult);
taosArrayDestroy(pSup->pColsInfo);
tfree(*param);
}
} }
void tscFirstRoundRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) { void tscFirstRoundRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
...@@ -2232,8 +2235,10 @@ void tscFirstRoundRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) { ...@@ -2232,8 +2235,10 @@ void tscFirstRoundRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
int32_t code = taos_errno(pSql); int32_t code = taos_errno(pSql);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
destroySup(pSup); tscFreeFirstRoundSup(&param);
taos_free_result(pSql); taos_free_result(pSql);
pParent->subState.numOfSub = 0;
tfree(pParent->pSubs);
pParent->res.code = code; pParent->res.code = code;
tscAsyncResultOnError(pParent); tscAsyncResultOnError(pParent);
return; return;
...@@ -2325,11 +2330,11 @@ void tscFirstRoundRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) { ...@@ -2325,11 +2330,11 @@ void tscFirstRoundRetrieveCallback(void* param, TAOS_RES* tres, int numOfRows) {
tbufCloseWriter(&bw); tbufCloseWriter(&bw);
} }
taosArrayDestroyEx(pSup->pResult, freeInterResult); tscFreeFirstRoundSup(&param);
taosArrayDestroy(pSup->pColsInfo);
tfree(pSup);
taos_free_result(pSql); taos_free_result(pSql);
pParent->subState.numOfSub = 0;
tfree(pParent->pSubs);
if (resRows == 0) { if (resRows == 0) {
pParent->cmd.command = TSDB_SQL_RETRIEVE_EMPTY_RESULT; pParent->cmd.command = TSDB_SQL_RETRIEVE_EMPTY_RESULT;
...@@ -2350,8 +2355,10 @@ void tscFirstRoundCallback(void* param, TAOS_RES* tres, int code) { ...@@ -2350,8 +2355,10 @@ void tscFirstRoundCallback(void* param, TAOS_RES* tres, int code) {
if (c != TSDB_CODE_SUCCESS) { if (c != TSDB_CODE_SUCCESS) {
SSqlObj* parent = pSup->pParent; SSqlObj* parent = pSup->pParent;
destroySup(pSup); tscFreeFirstRoundSup(&param);
taos_free_result(pSql); taos_free_result(pSql);
parent->subState.numOfSub = 0;
tfree(parent->pSubs);
parent->res.code = c; parent->res.code = c;
tscAsyncResultOnError(parent); tscAsyncResultOnError(parent);
return; return;
...@@ -2374,6 +2381,10 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) { ...@@ -2374,6 +2381,10 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
SSqlObj *pNew = createSubqueryObj(pSql, 0, tscFirstRoundCallback, pSup, TSDB_SQL_SELECT, NULL); SSqlObj *pNew = createSubqueryObj(pSql, 0, tscFirstRoundCallback, pSup, TSDB_SQL_SELECT, NULL);
SSqlCmd *pCmd = &pNew->cmd; SSqlCmd *pCmd = &pNew->cmd;
pNew->freeParam = tscFreeFirstRoundSup;
tscDebug("%"PRIx64 " add first round supporter:%p", pNew->self, pSup);
SQueryInfo* pNewQueryInfo = tscGetQueryInfo(pCmd); SQueryInfo* pNewQueryInfo = tscGetQueryInfo(pCmd);
assert(pQueryInfo->numOfTables == 1); assert(pQueryInfo->numOfTables == 1);
...@@ -2502,11 +2513,21 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) { ...@@ -2502,11 +2513,21 @@ int32_t tscHandleFirstRoundStableQuery(SSqlObj *pSql) {
pSql->self, pNew->self, 0, pTableMetaInfo->vgroupIndex, pTableMetaInfo->vgroupList->numOfVgroups, pNewQueryInfo->type, pSql->self, pNew->self, 0, pTableMetaInfo->vgroupIndex, pTableMetaInfo->vgroupList->numOfVgroups, pNewQueryInfo->type,
tscNumOfExprs(pNewQueryInfo), index+1, pNewQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pTableMetaInfo->name)); tscNumOfExprs(pNewQueryInfo), index+1, pNewQueryInfo->fieldsInfo.numOfOutput, tNameGetTableName(&pTableMetaInfo->name));
pSql->pSubs = calloc(1, POINTER_BYTES);
if (pSql->pSubs == NULL) {
terrno = TSDB_CODE_TSC_OUT_OF_MEMORY;
goto _error;
}
pSql->subState.numOfSub = 1;
pSql->pSubs[0] = pNew;
tscHandleMasterSTableQuery(pNew); tscHandleMasterSTableQuery(pNew);
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
_error: _error:
destroySup(pSup); tscFreeFirstRoundSup((void**)&pSup);
taos_free_result(pNew); taos_free_result(pNew);
pSql->res.code = terrno; pSql->res.code = terrno;
tscAsyncResultOnError(pSql); tscAsyncResultOnError(pSql);
...@@ -2697,16 +2718,16 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) { ...@@ -2697,16 +2718,16 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
void tscFreeRetrieveSup(SSqlObj *pSql) { void tscFreeRetrieveSup(void **param) {
SRetrieveSupport *trsupport = pSql->param; SRetrieveSupport *trsupport = *param;
void* p = atomic_val_compare_exchange_ptr(&pSql->param, trsupport, 0); void* p = atomic_val_compare_exchange_ptr(param, trsupport, 0);
if (p == NULL) { if (p == NULL) {
tscDebug("0x%"PRIx64" retrieve supp already released", pSql->self); tscDebug("retrieve supp already released");
return; return;
} }
tscDebug("0x%"PRIx64" start to free subquery supp obj:%p", pSql->self, trsupport); tscDebug("start to free subquery restrieve supp obj:%p", trsupport);
tfree(trsupport->localBuffer); tfree(trsupport->localBuffer);
tfree(trsupport); tfree(trsupport);
} }
...@@ -2779,12 +2800,12 @@ static int32_t tscReissueSubquery(SRetrieveSupport *oriTrs, SSqlObj *pSql, int32 ...@@ -2779,12 +2800,12 @@ static int32_t tscReissueSubquery(SRetrieveSupport *oriTrs, SSqlObj *pSql, int32
// if failed to process sql, let following code handle the pSql // if failed to process sql, let following code handle the pSql
if (ret == TSDB_CODE_SUCCESS) { if (ret == TSDB_CODE_SUCCESS) {
tscFreeRetrieveSup(pSql); tscFreeRetrieveSup(&pSql->param);
taos_free_result(pSql); taos_free_result(pSql);
return ret; return ret;
} else { } else {
pParentSql->pSubs[trsupport->subqueryIndex] = pSql; pParentSql->pSubs[trsupport->subqueryIndex] = pSql;
tscFreeRetrieveSup(pNew); tscFreeRetrieveSup(&pNew->param);
taos_free_result(pNew); taos_free_result(pNew);
return ret; return ret;
} }
...@@ -2839,7 +2860,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO ...@@ -2839,7 +2860,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
tscDebug("0x%"PRIx64" sub:0x%"PRIx64",%d freed, not finished, total:%d", pParentSql->self, tscDebug("0x%"PRIx64" sub:0x%"PRIx64",%d freed, not finished, total:%d", pParentSql->self,
pSql->self, trsupport->subqueryIndex, pState->numOfSub); pSql->self, trsupport->subqueryIndex, pState->numOfSub);
tscFreeRetrieveSup(pSql); tscFreeRetrieveSup(&pSql->param);
return; return;
} }
...@@ -2849,7 +2870,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO ...@@ -2849,7 +2870,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
// release allocated resource // release allocated resource
tscDestroyGlobalMergerEnv(trsupport->pExtMemBuffer, trsupport->pOrderDescriptor, pState->numOfSub); tscDestroyGlobalMergerEnv(trsupport->pExtMemBuffer, trsupport->pOrderDescriptor, pState->numOfSub);
tscFreeRetrieveSup(pSql); tscFreeRetrieveSup(&pSql->param);
// in case of second stage join subquery, invoke its callback function instead of regular QueueAsyncRes // in case of second stage join subquery, invoke its callback function instead of regular QueueAsyncRes
SQueryInfo *pQueryInfo = tscGetQueryInfo(&pParentSql->cmd); SQueryInfo *pQueryInfo = tscGetQueryInfo(&pParentSql->cmd);
...@@ -2861,7 +2882,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO ...@@ -2861,7 +2882,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
if ((code == TSDB_CODE_TDB_INVALID_TABLE_ID || code == TSDB_CODE_VND_INVALID_VGROUP_ID) && userSql->retry < userSql->maxRetry) { if ((code == TSDB_CODE_TDB_INVALID_TABLE_ID || code == TSDB_CODE_VND_INVALID_VGROUP_ID) && userSql->retry < userSql->maxRetry) {
if (userSql != pParentSql) { if (userSql != pParentSql) {
tscFreeRetrieveSup(pParentSql); (*pParentSql->freeParam)(&pParentSql->param);
} }
tscFreeSubobj(userSql); tscFreeSubobj(userSql);
...@@ -2945,7 +2966,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p ...@@ -2945,7 +2966,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" orderOfSub:%d freed, not finished", pParentSql->self, pSql->self, tscDebug("0x%"PRIx64" sub:0x%"PRIx64" orderOfSub:%d freed, not finished", pParentSql->self, pSql->self,
trsupport->subqueryIndex); trsupport->subqueryIndex);
tscFreeRetrieveSup(pSql); tscFreeRetrieveSup(&pSql->param);
return; return;
} }
...@@ -2975,7 +2996,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p ...@@ -2975,7 +2996,7 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
pParentSql->res.row = 0; pParentSql->res.row = 0;
pParentSql->res.numOfGroups = 0; pParentSql->res.numOfGroups = 0;
tscFreeRetrieveSup(pSql); tscFreeRetrieveSup(&pSql->param);
// set the command flag must be after the semaphore been correctly set. // set the command flag must be after the semaphore been correctly set.
if (pParentSql->cmd.command != TSDB_SQL_RETRIEVE_EMPTY_RESULT) { if (pParentSql->cmd.command != TSDB_SQL_RETRIEVE_EMPTY_RESULT) {
......
...@@ -3798,7 +3798,7 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) { ...@@ -3798,7 +3798,7 @@ static void tscSubqueryCompleteCallback(void* param, TAOS_RES* tres, int code) {
int32_t index = ps->subqueryIndex; int32_t index = ps->subqueryIndex;
bool ret = subAndCheckDone(pSql, pParentSql, index); bool ret = subAndCheckDone(pSql, pParentSql, index);
tscFreeRetrieveSup(pSql); tscFreeRetrieveSup(&pSql->param);
if (!ret) { if (!ret) {
tscDebug("0x%"PRIx64" sub:0x%"PRIx64" orderOfSub:%d completed, not all subquery finished", pParentSql->self, pSql->self, index); tscDebug("0x%"PRIx64" sub:0x%"PRIx64" orderOfSub:%d completed, not all subquery finished", pParentSql->self, pSql->self, index);
......
...@@ -663,16 +663,6 @@ static void doInitGlobalConfig(void) { ...@@ -663,16 +663,6 @@ static void doInitGlobalConfig(void) {
cfg.unitType = TAOS_CFG_UTYPE_MS; cfg.unitType = TAOS_CFG_UTYPE_MS;
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
cfg.option = "rpcForceTcp";
cfg.ptr = &tsRpcForceTcp;
cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
cfg.minValue = 0;
cfg.maxValue = 1;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
cfg.option = "rpcMaxTime"; cfg.option = "rpcMaxTime";
cfg.ptr = &tsRpcMaxTime; cfg.ptr = &tsRpcMaxTime;
cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.valType = TAOS_CFG_VTYPE_INT32;
...@@ -683,6 +673,16 @@ static void doInitGlobalConfig(void) { ...@@ -683,6 +673,16 @@ static void doInitGlobalConfig(void) {
cfg.unitType = TAOS_CFG_UTYPE_SECOND; cfg.unitType = TAOS_CFG_UTYPE_SECOND;
taosInitConfigOption(cfg); taosInitConfigOption(cfg);
cfg.option = "rpcForceTcp";
cfg.ptr = &tsRpcForceTcp;
cfg.valType = TAOS_CFG_VTYPE_INT32;
cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT;
cfg.minValue = 0;
cfg.maxValue = 1;
cfg.ptrLength = 0;
cfg.unitType = TAOS_CFG_UTYPE_NONE;
taosInitConfigOption(cfg);
cfg.option = "statusInterval"; cfg.option = "statusInterval";
cfg.ptr = &tsStatusInterval; cfg.ptr = &tsStatusInterval;
cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.valType = TAOS_CFG_VTYPE_INT32;
......
...@@ -34,6 +34,8 @@ ELSEIF (TD_WINDOWS) ...@@ -34,6 +34,8 @@ ELSEIF (TD_WINDOWS)
IF (TD_POWER) IF (TD_POWER)
SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME power) SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME power)
ELSEIF (TD_PRO)
SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME prodbc)
ELSE () ELSE ()
SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos) SET_TARGET_PROPERTIES(shell PROPERTIES OUTPUT_NAME taos)
ENDIF () ENDIF ()
......
...@@ -1044,56 +1044,4 @@ void source_file(TAOS *con, char *fptr) { ...@@ -1044,56 +1044,4 @@ void source_file(TAOS *con, char *fptr) {
void shellGetGrantInfo(void *con) { void shellGetGrantInfo(void *con) {
return; return;
#if 0
char sql[] = "show grants";
TAOS_RES* tres = taos_query(con, sql);
int code = taos_errno(tres);
if (code != TSDB_CODE_SUCCESS) {
if (code == TSDB_CODE_COM_OPS_NOT_SUPPORT) {
fprintf(stdout, "Server is Community Edition, version is %s\n\n", taos_get_server_info(con));
} else {
fprintf(stderr, "Failed to check Server Edition, Reason:%d:%s\n\n", taos_errno(con), taos_errstr(con));
}
return;
}
int num_fields = taos_field_count(tres);
if (num_fields == 0) {
fprintf(stderr, "\nInvalid grant information.\n");
exit(0);
} else {
if (tres == NULL) {
fprintf(stderr, "\nGrant information is null.\n");
exit(0);
}
TAOS_FIELD *fields = taos_fetch_fields(tres);
TAOS_ROW row = taos_fetch_row(tres);
if (row == NULL) {
fprintf(stderr, "\nFailed to get grant information from server. Abort.\n");
exit(0);
}
char serverVersion[32] = {0};
char expiretime[32] = {0};
char expired[32] = {0};
memcpy(serverVersion, row[0], fields[0].bytes);
memcpy(expiretime, row[1], fields[1].bytes);
memcpy(expired, row[2], fields[2].bytes);
if (strcmp(expiretime, "unlimited") == 0) {
fprintf(stdout, "Server is Enterprise %s Edition, version is %s and will never expire.\n", serverVersion, taos_get_server_info(con));
} else {
fprintf(stdout, "Server is Enterprise %s Edition, version is %s and will expire at %s.\n", serverVersion, taos_get_server_info(con), expiretime);
}
result = NULL;
taos_free_result(tres);
}
fprintf(stdout, "\n");
#endif
} }
...@@ -210,7 +210,7 @@ static void shellSourceFile(TAOS *con, char *fptr) { ...@@ -210,7 +210,7 @@ static void shellSourceFile(TAOS *con, char *fptr) {
/* free local resouce: allocated memory/metric-meta refcnt */ /* free local resouce: allocated memory/metric-meta refcnt */
taos_free_result(pSql); taos_free_result(pSql);
memset(cmd, 0, MAX_COMMAND_SIZE); memset(cmd, 0, tsMaxSQLStringLen);
cmd_len = 0; cmd_len = 0;
} }
......
...@@ -7668,7 +7668,7 @@ UNUSED_FUNC static int32_t prepareStbStmtRand( ...@@ -7668,7 +7668,7 @@ UNUSED_FUNC static int32_t prepareStbStmtRand(
} }
#if STMT_BIND_PARAM_BATCH == 1 #if STMT_BIND_PARAM_BATCH == 1
static int execBindParamBatch( static int execStbBindParamBatch(
threadInfo *pThreadInfo, threadInfo *pThreadInfo,
char *tableName, char *tableName,
int64_t tableSeq, int64_t tableSeq,
...@@ -7682,7 +7682,9 @@ static int execBindParamBatch( ...@@ -7682,7 +7682,9 @@ static int execBindParamBatch(
TAOS_STMT *stmt = pThreadInfo->stmt; TAOS_STMT *stmt = pThreadInfo->stmt;
SSuperTable *stbInfo = pThreadInfo->stbInfo; SSuperTable *stbInfo = pThreadInfo->stbInfo;
uint32_t columnCount = (stbInfo)?pThreadInfo->stbInfo->columnCount:g_args.columnCount; assert(stbInfo);
uint32_t columnCount = pThreadInfo->stbInfo->columnCount;
uint32_t thisBatch = MAX_SAMPLES - (*pSamplePos); uint32_t thisBatch = MAX_SAMPLES - (*pSamplePos);
...@@ -7707,104 +7709,97 @@ static int execBindParamBatch( ...@@ -7707,104 +7709,97 @@ static int execBindParamBatch(
param->buffer = pThreadInfo->bind_ts_array; param->buffer = pThreadInfo->bind_ts_array;
} else { } else {
data_type = (stbInfo)?stbInfo->columns[c-1].data_type:g_args.data_type[c-1]; data_type = stbInfo->columns[c-1].data_type;
char *tmpP; char *tmpP;
switch(data_type) { switch(data_type) {
case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_BINARY:
param->buffer_length =
stbInfo->columns[c-1].dataLen;
tmpP =
(char *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray
+sizeof(char*)*(c-1)));
verbosePrint("%s() LN%d, tmpP=%p pos=%"PRId64" width=%"PRIxPTR" position=%"PRId64"\n",
__func__, __LINE__, tmpP, *pSamplePos, param->buffer_length,
(*pSamplePos) * param->buffer_length);
param->buffer = (void *)(tmpP + *pSamplePos * param->buffer_length);
break;
case TSDB_DATA_TYPE_NCHAR: case TSDB_DATA_TYPE_NCHAR:
param->buffer_length = param->buffer_length =
((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth); stbInfo->columns[c-1].dataLen;
tmpP = tmpP =
(char *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray (char *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray
+sizeof(char*)*(c-1))); +sizeof(char*)*(c-1)));
verbosePrint("%s() LN%d, tmpP=%p pos=%"PRId64" width=%d position=%"PRId64"\n", verbosePrint("%s() LN%d, tmpP=%p pos=%"PRId64" width=%"PRIxPTR" position=%"PRId64"\n",
__func__, __LINE__, tmpP, *pSamplePos, __func__, __LINE__, tmpP, *pSamplePos, param->buffer_length,
(((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth)), (*pSamplePos) * param->buffer_length);
(*pSamplePos) *
(((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth)));
param->buffer = (void *)(tmpP + *pSamplePos * param->buffer = (void *)(tmpP + *pSamplePos * param->buffer_length);
(((stbInfo)?stbInfo->columns[c-1].dataLen:g_args.binwidth))
);
break; break;
case TSDB_DATA_TYPE_INT: case TSDB_DATA_TYPE_INT:
param->buffer_length = sizeof(int32_t); param->buffer_length = sizeof(int32_t);
param->buffer = (stbInfo)? param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen * (*pSamplePos)): + stbInfo->columns[c-1].dataLen * (*pSamplePos));
(void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(int32_t)*(*pSamplePos));
break; break;
case TSDB_DATA_TYPE_TINYINT: case TSDB_DATA_TYPE_TINYINT:
param->buffer_length = sizeof(int8_t); param->buffer_length = sizeof(int8_t);
param->buffer = (stbInfo)? param->buffer =
(void *)((uintptr_t)*(uintptr_t*)( (void *)((uintptr_t)*(uintptr_t*)(
stbInfo->sampleBindBatchArray stbInfo->sampleBindBatchArray
+sizeof(char*)*(c-1)) +sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen*(*pSamplePos)): + stbInfo->columns[c-1].dataLen*(*pSamplePos));
(void *)((uintptr_t)*(uintptr_t*)(
g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(int8_t)*(*pSamplePos));
break; break;
case TSDB_DATA_TYPE_SMALLINT: case TSDB_DATA_TYPE_SMALLINT:
param->buffer_length = sizeof(int16_t); param->buffer_length = sizeof(int16_t);
param->buffer = (stbInfo)? param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen * (*pSamplePos)): + stbInfo->columns[c-1].dataLen * (*pSamplePos));
(void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(int16_t)*(*pSamplePos));
break; break;
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
param->buffer_length = sizeof(int64_t); param->buffer_length = sizeof(int64_t);
param->buffer = (stbInfo)? param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen * (*pSamplePos)): + stbInfo->columns[c-1].dataLen * (*pSamplePos));
(void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(int64_t)*(*pSamplePos));
break; break;
case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_BOOL:
param->buffer_length = sizeof(int8_t); param->buffer_length = sizeof(int8_t);
param->buffer = (stbInfo)? param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen * (*pSamplePos)): + stbInfo->columns[c-1].dataLen * (*pSamplePos));
(void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(int8_t)*(*pSamplePos));
break; break;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT:
param->buffer_length = sizeof(float); param->buffer_length = sizeof(float);
param->buffer = (stbInfo)? param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen * (*pSamplePos)): + stbInfo->columns[c-1].dataLen * (*pSamplePos));
(void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(float)*(*pSamplePos));
break; break;
case TSDB_DATA_TYPE_DOUBLE: case TSDB_DATA_TYPE_DOUBLE:
param->buffer_length = sizeof(double); param->buffer_length = sizeof(double);
param->buffer = (stbInfo)? param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen * (*pSamplePos)): + stbInfo->columns[c-1].dataLen * (*pSamplePos));
(void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(double)*(*pSamplePos));
break; break;
case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_TIMESTAMP:
param->buffer_length = sizeof(int64_t); param->buffer_length = sizeof(int64_t);
param->buffer = (stbInfo)? param->buffer =
(void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1)) (void *)((uintptr_t)*(uintptr_t*)(stbInfo->sampleBindBatchArray+sizeof(char*)*(c-1))
+ stbInfo->columns[c-1].dataLen * (*pSamplePos)): + stbInfo->columns[c-1].dataLen * (*pSamplePos));
(void *)((uintptr_t)*(uintptr_t*)(g_sampleBindBatchArray+sizeof(char*)*(c-1))
+ sizeof(int64_t)*(*pSamplePos));
break; break;
default: default:
...@@ -7825,7 +7820,7 @@ static int execBindParamBatch( ...@@ -7825,7 +7820,7 @@ static int execBindParamBatch(
if (param->buffer_type == TSDB_DATA_TYPE_NCHAR) { if (param->buffer_type == TSDB_DATA_TYPE_NCHAR) {
param->length[b] = strlen( param->length[b] = strlen(
(char *)param->buffer + b * (char *)param->buffer + b *
((stbInfo)?stbInfo->columns[c].dataLen:g_args.binwidth) stbInfo->columns[c].dataLen
); );
} else { } else {
param->length[b] = param->buffer_length; param->length[b] = param->buffer_length;
...@@ -8372,7 +8367,7 @@ static int32_t prepareStbStmt( ...@@ -8372,7 +8367,7 @@ static int32_t prepareStbStmt(
} }
#if STMT_BIND_PARAM_BATCH == 1 #if STMT_BIND_PARAM_BATCH == 1
return execBindParamBatch( return execStbBindParamBatch(
pThreadInfo, pThreadInfo,
tableName, tableName,
tableSeq, tableSeq,
...@@ -10060,15 +10055,18 @@ static void startMultiThreadInsertData(int threads, char* db_name, ...@@ -10060,15 +10055,18 @@ static void startMultiThreadInsertData(int threads, char* db_name,
} }
} }
fprintf(stderr, "insert delay, avg: %10.2fms, max: %10.2fms, min: %10.2fms\n\n", if (minDelay != UINT64_MAX) {
(double)avgDelay/1000.0, fprintf(stderr, "insert delay, avg: %10.2fms, max: %10.2fms, min: %10.2fms\n\n",
(double)maxDelay/1000.0, (double)avgDelay/1000.0,
(double)minDelay/1000.0); (double)maxDelay/1000.0,
if (g_fpOfInsertResult) { (double)minDelay/1000.0);
fprintf(g_fpOfInsertResult, "insert delay, avg:%10.2fms, max: %10.2fms, min: %10.2fms\n\n",
(double)avgDelay/1000.0, if (g_fpOfInsertResult) {
(double)maxDelay/1000.0, fprintf(g_fpOfInsertResult, "insert delay, avg:%10.2fms, max: %10.2fms, min: %10.2fms\n\n",
(double)minDelay/1000.0); (double)avgDelay/1000.0,
(double)maxDelay/1000.0,
(double)minDelay/1000.0);
}
} }
//taos_close(taos); //taos_close(taos);
......
...@@ -60,7 +60,14 @@ typedef struct { ...@@ -60,7 +60,14 @@ typedef struct {
fprintf(stderr, "VERB: "fmt, __VA_ARGS__); } while(0) fprintf(stderr, "VERB: "fmt, __VA_ARGS__); } while(0)
#define errorPrint(fmt, ...) \ #define errorPrint(fmt, ...) \
do { fprintf(stderr, "\033[31m"); fprintf(stderr, "ERROR: "fmt, __VA_ARGS__); fprintf(stderr, "\033[0m"); } while(0) do { fprintf(stderr, "\033[31m"); \
fprintf(stderr, "ERROR: "fmt, __VA_ARGS__); \
fprintf(stderr, "\033[0m"); } while(0)
#define okPrint(fmt, ...) \
do { fprintf(stderr, "\033[32m"); \
fprintf(stderr, "OK: "fmt, __VA_ARGS__); \
fprintf(stderr, "\033[0m"); } while(0)
static bool isStringNumber(char *input) static bool isStringNumber(char *input)
{ {
...@@ -126,7 +133,7 @@ enum _describe_table_index { ...@@ -126,7 +133,7 @@ enum _describe_table_index {
typedef struct { typedef struct {
char field[TSDB_COL_NAME_LEN + 1]; char field[TSDB_COL_NAME_LEN + 1];
char type[32]; char type[16];
int length; int length;
char note[COL_NOTE_LEN]; char note[COL_NOTE_LEN];
} SColDes; } SColDes;
...@@ -210,7 +217,7 @@ static char doc[] = ""; ...@@ -210,7 +217,7 @@ static char doc[] = "";
/* to force a line-break, e.g.\n<-- here."; */ /* to force a line-break, e.g.\n<-- here."; */
/* A description of the arguments we accept. */ /* A description of the arguments we accept. */
static char args_doc[] = "dbname [tbname ...]\n--databases dbname ...\n--all-databases\n-i inpath\n-o outpath"; static char args_doc[] = "dbname [tbname ...]\n--databases db1,db2,... \n--all-databases\n-i inpath\n-o outpath";
/* Keys for options without short-options. */ /* Keys for options without short-options. */
#define OPT_ABORT 1 /* –abort */ #define OPT_ABORT 1 /* –abort */
...@@ -239,7 +246,7 @@ static struct argp_option options[] = { ...@@ -239,7 +246,7 @@ static struct argp_option options[] = {
{"encode", 'e', "ENCODE", 0, "Input file encoding.", 1}, {"encode", 'e', "ENCODE", 0, "Input file encoding.", 1},
// dump unit options // dump unit options
{"all-databases", 'A', 0, 0, "Dump all databases.", 2}, {"all-databases", 'A', 0, 0, "Dump all databases.", 2},
{"databases", 'D', 0, 0, "Dump assigned databases", 2}, {"databases", 'D', "DATABASES", 0, "Dump inputed databases. Use comma to seprate databases\' name.", 2},
{"allow-sys", 'a', 0, 0, "Allow to dump sys database", 2}, {"allow-sys", 'a', 0, 0, "Allow to dump sys database", 2},
// dump format options // dump format options
{"schemaonly", 's', 0, 0, "Only dump schema.", 2}, {"schemaonly", 's', 0, 0, "Only dump schema.", 2},
...@@ -255,6 +262,8 @@ static struct argp_option options[] = { ...@@ -255,6 +262,8 @@ static struct argp_option options[] = {
{0} {0}
}; };
#define HUMAN_TIME_LEN 28
/* Used by main to communicate with parse_opt. */ /* Used by main to communicate with parse_opt. */
typedef struct arguments { typedef struct arguments {
// connection option // connection option
...@@ -272,14 +281,15 @@ typedef struct arguments { ...@@ -272,14 +281,15 @@ typedef struct arguments {
// dump unit option // dump unit option
bool all_databases; bool all_databases;
bool databases; bool databases;
char *databasesSeq;
// dump format option // dump format option
bool schemaonly; bool schemaonly;
bool with_property; bool with_property;
bool avro; bool avro;
int64_t start_time; int64_t start_time;
char humanStartTime[28]; char humanStartTime[HUMAN_TIME_LEN];
int64_t end_time; int64_t end_time;
char humanEndTime[28]; char humanEndTime[HUMAN_TIME_LEN];
char precision[8]; char precision[8];
int32_t data_batch; int32_t data_batch;
...@@ -348,10 +358,11 @@ struct arguments g_args = { ...@@ -348,10 +358,11 @@ struct arguments g_args = {
"./dump_result.txt", "./dump_result.txt",
NULL, NULL,
// dump unit option // dump unit option
false, false, // all_databases
false, false, // databases
NULL, // databasesSeq
// dump format option // dump format option
false, // schemeonly false, // schemaonly
true, // with_property true, // with_property
false, // avro format false, // avro format
-INT64_MAX + 1, // start_time -INT64_MAX + 1, // start_time
...@@ -375,13 +386,61 @@ struct arguments g_args = { ...@@ -375,13 +386,61 @@ struct arguments g_args = {
0, // dbCount 0, // dbCount
}; };
// get taosdump commit number version
#ifndef TAOSDUMP_COMMIT_SHA1
#define TAOSDUMP_COMMIT_SHA1 "unknown"
#endif
#ifndef TD_VERNUMBER
#define TD_VERNUMBER "unknown"
#endif
#ifndef TAOSDUMP_STATUS
#define TAOSDUMP_STATUS "unknown"
#endif
static void printVersion() {
char tdengine_ver[] = TD_VERNUMBER;
char taosdump_ver[] = TAOSDUMP_COMMIT_SHA1;
char taosdump_status[] = TAOSDUMP_STATUS;
if (strlen(taosdump_status) == 0) {
printf("taosdump version %s-%s\n",
tdengine_ver, taosdump_ver);
} else {
printf("taosdump version %s-%s, status:%s\n",
tdengine_ver, taosdump_ver, taosdump_status);
}
}
UNUSED_FUNC void errorWrongValue(char *program, char *wrong_arg, char *wrong_value)
{
fprintf(stderr, "%s %s: %s is an invalid value\n", program, wrong_arg, wrong_value);
fprintf(stderr, "Try `taosdemo --help' or `taosdemo --usage' for more information.\n");
}
static void errorUnrecognized(char *program, char *wrong_arg)
{
fprintf(stderr, "%s: unrecognized options '%s'\n", program, wrong_arg);
fprintf(stderr, "Try `taosdemo --help' or `taosdemo --usage' for more information.\n");
}
static void errorPrintReqArg(char *program, char *wrong_arg)
{
fprintf(stderr,
"%s: option requires an argument -- '%s'\n",
program, wrong_arg);
fprintf(stderr,
"Try `taosdemo --help' or `taosdemo --usage' for more information.\n");
}
static void errorPrintReqArg2(char *program, char *wrong_arg) static void errorPrintReqArg2(char *program, char *wrong_arg)
{ {
fprintf(stderr, fprintf(stderr,
"%s: option requires a number argument '-%s'\n", "%s: option requires a number argument '-%s'\n",
program, wrong_arg); program, wrong_arg);
fprintf(stderr, fprintf(stderr,
"Try `taosdump --help' or `taosdump --usage' for more information.\n"); "Try `taosdemo --help' or `taosdemo --usage' for more information.\n");
} }
static void errorPrintReqArg3(char *program, char *wrong_arg) static void errorPrintReqArg3(char *program, char *wrong_arg)
...@@ -390,7 +449,7 @@ static void errorPrintReqArg3(char *program, char *wrong_arg) ...@@ -390,7 +449,7 @@ static void errorPrintReqArg3(char *program, char *wrong_arg)
"%s: option '%s' requires an argument\n", "%s: option '%s' requires an argument\n",
program, wrong_arg); program, wrong_arg);
fprintf(stderr, fprintf(stderr,
"Try `taosdump --help' or `taosdump --usage' for more information.\n"); "Try `taosdemo --help' or `taosdemo --usage' for more information.\n");
} }
/* Parse a single option. */ /* Parse a single option. */
...@@ -611,8 +670,40 @@ static void parse_args( ...@@ -611,8 +670,40 @@ static void parse_args(
} else if (strcmp(argv[i], "-PP") == 0) { } else if (strcmp(argv[i], "-PP") == 0) {
arguments->performance_print = true; arguments->performance_print = true;
strcpy(argv[i], ""); strcpy(argv[i], "");
} else if (strcmp(argv[i], "-A") == 0) { } else if ((strcmp(argv[i], "-A") == 0)
|| (0 == strncmp(
argv[i], "--all-database",
strlen("--all-database")))) {
g_args.all_databases = true; g_args.all_databases = true;
} else if ((strncmp(argv[i], "-D", strlen("-D")) == 0)
|| (0 == strncmp(
argv[i], "--database",
strlen("--database")))) {
if (2 == strlen(argv[i])) {
if (argc == i+1) {
errorPrintReqArg(argv[0], "D");
exit(EXIT_FAILURE);
}
arguments->databasesSeq = argv[++i];
} else if (0 == strncmp(argv[i], "--databases=", strlen("--databases="))) {
arguments->databasesSeq = (char *)(argv[i] + strlen("--databases="));
} else if (0 == strncmp(argv[i], "-D", strlen("-D"))) {
arguments->databasesSeq = (char *)(argv[i] + strlen("-D"));
} else if (strlen("--databases") == strlen(argv[i])) {
if (argc == i+1) {
errorPrintReqArg3(argv[0], "--databases");
exit(EXIT_FAILURE);
}
arguments->databasesSeq = argv[++i];
} else {
errorUnrecognized(argv[0], argv[i]);
exit(EXIT_FAILURE);
}
g_args.databases = true;
} else if (0 == strncmp(argv[i], "--version", strlen("--version")) ||
0 == strncmp(argv[i], "-V", strlen("-V"))) {
printVersion();
exit(EXIT_SUCCESS);
} else { } else {
continue; continue;
} }
...@@ -623,9 +714,9 @@ static void parse_args( ...@@ -623,9 +714,9 @@ static void parse_args(
static void copyHumanTimeToArg(char *timeStr, bool isStartTime) static void copyHumanTimeToArg(char *timeStr, bool isStartTime)
{ {
if (isStartTime) if (isStartTime)
strcpy(g_args.humanStartTime, timeStr); tstrncpy(g_args.humanStartTime, timeStr, HUMAN_TIME_LEN);
else else
strcpy(g_args.humanEndTime, timeStr); tstrncpy(g_args.humanEndTime, timeStr, HUMAN_TIME_LEN);
} }
static void copyTimestampToArg(char *timeStr, bool isStartTime) static void copyTimestampToArg(char *timeStr, bool isStartTime)
...@@ -661,6 +752,8 @@ static void parse_timestamp( ...@@ -661,6 +752,8 @@ static void parse_timestamp(
} else { } else {
copyTimestampToArg(tmp, isStartTime); copyTimestampToArg(tmp, isStartTime);
} }
free(tmp);
} }
} }
} }
...@@ -783,6 +876,7 @@ int main(int argc, char *argv[]) { ...@@ -783,6 +876,7 @@ int main(int argc, char *argv[]) {
printf("encode: %s\n", g_args.encode); printf("encode: %s\n", g_args.encode);
printf("all_databases: %s\n", g_args.all_databases?"true":"false"); printf("all_databases: %s\n", g_args.all_databases?"true":"false");
printf("databases: %d\n", g_args.databases); printf("databases: %d\n", g_args.databases);
printf("databasesSeq: %s\n", g_args.databasesSeq);
printf("schemaonly: %s\n", g_args.schemaonly?"true":"false"); printf("schemaonly: %s\n", g_args.schemaonly?"true":"false");
printf("with_property: %s\n", g_args.with_property?"true":"false"); printf("with_property: %s\n", g_args.with_property?"true":"false");
printf("avro format: %s\n", g_args.avro?"true":"false"); printf("avro format: %s\n", g_args.avro?"true":"false");
...@@ -830,6 +924,7 @@ int main(int argc, char *argv[]) { ...@@ -830,6 +924,7 @@ int main(int argc, char *argv[]) {
fprintf(g_fpOfResult, "encode: %s\n", g_args.encode); fprintf(g_fpOfResult, "encode: %s\n", g_args.encode);
fprintf(g_fpOfResult, "all_databases: %s\n", g_args.all_databases?"true":"false"); fprintf(g_fpOfResult, "all_databases: %s\n", g_args.all_databases?"true":"false");
fprintf(g_fpOfResult, "databases: %d\n", g_args.databases); fprintf(g_fpOfResult, "databases: %d\n", g_args.databases);
fprintf(g_fpOfResult, "databasesSeq: %s\n", g_args.databasesSeq);
fprintf(g_fpOfResult, "schemaonly: %s\n", g_args.schemaonly?"true":"false"); fprintf(g_fpOfResult, "schemaonly: %s\n", g_args.schemaonly?"true":"false");
fprintf(g_fpOfResult, "with_property: %s\n", g_args.with_property?"true":"false"); fprintf(g_fpOfResult, "with_property: %s\n", g_args.with_property?"true":"false");
fprintf(g_fpOfResult, "avro format: %s\n", g_args.avro?"true":"false"); fprintf(g_fpOfResult, "avro format: %s\n", g_args.avro?"true":"false");
...@@ -1124,38 +1219,56 @@ static int32_t taosSaveTableOfMetricToTempFile( ...@@ -1124,38 +1219,56 @@ static int32_t taosSaveTableOfMetricToTempFile(
return 0; return 0;
} }
static int inDatabasesSeq(
char *name,
int len)
{
if (strstr(g_args.databasesSeq, ",") == NULL) {
if (0 == strncmp(g_args.databasesSeq, name, len)) {
return 0;
}
} else {
char *dupSeq = strdup(g_args.databasesSeq);
char *running = dupSeq;
char *dbname = strsep(&running, ",");
while (dbname) {
if (0 == strncmp(dbname, name, len)) {
tfree(dupSeq);
return 0;
}
dbname = strsep(&running, ",");
}
free(dupSeq);
}
return -1;
}
static int getDbCount() static int getDbCount()
{ {
int count; int count = 0;
TAOS *taos = NULL; TAOS *taos = NULL;
TAOS_RES *result = NULL; TAOS_RES *result = NULL;
char *command = NULL; char *command = "show databases";
TAOS_ROW row; TAOS_ROW row;
command = (char *)malloc(COMMAND_SIZE);
if (command == NULL) {
errorPrint("%s() LN%d, failed to allocate command buffer\n", __func__, __LINE__);
return 0;
}
/* Connect to server */ /* Connect to server */
taos = taos_connect(g_args.host, g_args.user, g_args.password, taos = taos_connect(g_args.host, g_args.user, g_args.password,
NULL, g_args.port); NULL, g_args.port);
if (NULL == taos) { if (NULL == taos) {
errorPrint("Failed to connect to TDengine server %s\n", g_args.host); errorPrint("Failed to connect to TDengine server %s\n", g_args.host);
free(command);
return 0; return 0;
} }
sprintf(command, "show databases");
result = taos_query(taos, command); result = taos_query(taos, command);
int32_t code = taos_errno(result); int32_t code = taos_errno(result);
if (0 != code) { if (0 != code) {
errorPrint("%s() LN%d, failed to run command: %s, reason: %s\n", errorPrint("%s() LN%d, failed to run command: %s, reason: %s\n",
__func__, __LINE__, command, taos_errstr(result)); __func__, __LINE__, command, taos_errstr(result));
free(command);
return 0; return 0;
} }
...@@ -1170,39 +1283,24 @@ static int getDbCount() ...@@ -1170,39 +1283,24 @@ static int getDbCount()
} }
if (g_args.databases) { // input multi dbs if (g_args.databases) { // input multi dbs
for (int i = 0; g_args.arg_list[i]; i++) { if (inDatabasesSeq(
if (strncasecmp(g_args.arg_list[i], (char *)row[TSDB_SHOW_DB_NAME_INDEX],
(char *)row[TSDB_SHOW_DB_NAME_INDEX], fields[TSDB_SHOW_DB_NAME_INDEX].bytes) != 0)
fields[TSDB_SHOW_DB_NAME_INDEX].bytes) == 0) continue;
goto _dump_db_point;
}
continue;
} else if (!g_args.all_databases) { // only input one db } else if (!g_args.all_databases) { // only input one db
if (strncasecmp(g_args.arg_list[0], if (strncasecmp(g_args.arg_list[0],
(char *)row[TSDB_SHOW_DB_NAME_INDEX], (char *)row[TSDB_SHOW_DB_NAME_INDEX],
fields[TSDB_SHOW_DB_NAME_INDEX].bytes) == 0) fields[TSDB_SHOW_DB_NAME_INDEX].bytes) != 0)
goto _dump_db_point;
else
continue; continue;
} }
_dump_db_point:
count++; count++;
if (g_args.databases) {
if (count > g_args.arg_list_len) break;
} else if (!g_args.all_databases) {
if (count >= 1) break;
}
} }
if (count == 0) { if (count == 0) {
errorPrint("%d databases valid to dump\n", count); errorPrint("%d databases valid to dump\n", count);
} }
free(command);
return count; return count;
} }
...@@ -1233,6 +1331,7 @@ static int taosDumpOut() { ...@@ -1233,6 +1331,7 @@ static int taosDumpOut() {
g_args.dbCount = getDbCount(); g_args.dbCount = getDbCount();
if (0 == g_args.dbCount) { if (0 == g_args.dbCount) {
fclose(fp);
errorPrint("%d databases valid to dump\n", g_args.dbCount); errorPrint("%d databases valid to dump\n", g_args.dbCount);
return -1; return -1;
} }
...@@ -1284,24 +1383,18 @@ static int taosDumpOut() { ...@@ -1284,24 +1383,18 @@ static int taosDumpOut() {
} }
if (g_args.databases) { // input multi dbs if (g_args.databases) { // input multi dbs
for (int i = 0; g_args.arg_list[i]; i++) { if (inDatabasesSeq(
if (strncasecmp(g_args.arg_list[i], (char *)row[TSDB_SHOW_DB_NAME_INDEX],
(char *)row[TSDB_SHOW_DB_NAME_INDEX], fields[TSDB_SHOW_DB_NAME_INDEX].bytes) != 0) {
fields[TSDB_SHOW_DB_NAME_INDEX].bytes) == 0) continue;
goto _dump_db_point;
} }
continue;
} else if (!g_args.all_databases) { // only input one db } else if (!g_args.all_databases) { // only input one db
if (strncasecmp(g_args.arg_list[0], if (strncasecmp(g_args.arg_list[0],
(char *)row[TSDB_SHOW_DB_NAME_INDEX], (char *)row[TSDB_SHOW_DB_NAME_INDEX],
fields[TSDB_SHOW_DB_NAME_INDEX].bytes) == 0) fields[TSDB_SHOW_DB_NAME_INDEX].bytes) != 0)
goto _dump_db_point;
else
continue; continue;
} }
_dump_db_point:
g_dbInfos[count] = (SDbInfo *)calloc(1, sizeof(SDbInfo)); g_dbInfos[count] = (SDbInfo *)calloc(1, sizeof(SDbInfo));
if (g_dbInfos[count] == NULL) { if (g_dbInfos[count] == NULL) {
errorPrint("%s() LN%d, failed to allocate %"PRIu64" memory\n", errorPrint("%s() LN%d, failed to allocate %"PRIu64" memory\n",
...@@ -1309,38 +1402,55 @@ _dump_db_point: ...@@ -1309,38 +1402,55 @@ _dump_db_point:
goto _exit_failure; goto _exit_failure;
} }
okPrint("%s exists\n", (char *)row[TSDB_SHOW_DB_NAME_INDEX]);
tstrncpy(g_dbInfos[count]->name, (char *)row[TSDB_SHOW_DB_NAME_INDEX], tstrncpy(g_dbInfos[count]->name, (char *)row[TSDB_SHOW_DB_NAME_INDEX],
min(TSDB_DB_NAME_LEN, fields[TSDB_SHOW_DB_NAME_INDEX].bytes + 1)); min(TSDB_DB_NAME_LEN,
fields[TSDB_SHOW_DB_NAME_INDEX].bytes + 1));
if (g_args.with_property) { if (g_args.with_property) {
g_dbInfos[count]->ntables = *((int32_t *)row[TSDB_SHOW_DB_NTABLES_INDEX]); g_dbInfos[count]->ntables =
g_dbInfos[count]->vgroups = *((int32_t *)row[TSDB_SHOW_DB_VGROUPS_INDEX]); *((int32_t *)row[TSDB_SHOW_DB_NTABLES_INDEX]);
g_dbInfos[count]->replica = *((int16_t *)row[TSDB_SHOW_DB_REPLICA_INDEX]); g_dbInfos[count]->vgroups =
g_dbInfos[count]->quorum = *((int16_t *)row[TSDB_SHOW_DB_QUORUM_INDEX]); *((int32_t *)row[TSDB_SHOW_DB_VGROUPS_INDEX]);
g_dbInfos[count]->days = *((int16_t *)row[TSDB_SHOW_DB_DAYS_INDEX]); g_dbInfos[count]->replica =
*((int16_t *)row[TSDB_SHOW_DB_REPLICA_INDEX]);
tstrncpy(g_dbInfos[count]->keeplist, (char *)row[TSDB_SHOW_DB_KEEP_INDEX], g_dbInfos[count]->quorum =
*((int16_t *)row[TSDB_SHOW_DB_QUORUM_INDEX]);
g_dbInfos[count]->days =
*((int16_t *)row[TSDB_SHOW_DB_DAYS_INDEX]);
tstrncpy(g_dbInfos[count]->keeplist,
(char *)row[TSDB_SHOW_DB_KEEP_INDEX],
min(32, fields[TSDB_SHOW_DB_KEEP_INDEX].bytes + 1)); min(32, fields[TSDB_SHOW_DB_KEEP_INDEX].bytes + 1));
//g_dbInfos[count]->daysToKeep = *((int16_t *)row[TSDB_SHOW_DB_KEEP_INDEX]); //g_dbInfos[count]->daysToKeep = *((int16_t *)row[TSDB_SHOW_DB_KEEP_INDEX]);
//g_dbInfos[count]->daysToKeep1; //g_dbInfos[count]->daysToKeep1;
//g_dbInfos[count]->daysToKeep2; //g_dbInfos[count]->daysToKeep2;
g_dbInfos[count]->cache = *((int32_t *)row[TSDB_SHOW_DB_CACHE_INDEX]); g_dbInfos[count]->cache =
g_dbInfos[count]->blocks = *((int32_t *)row[TSDB_SHOW_DB_BLOCKS_INDEX]); *((int32_t *)row[TSDB_SHOW_DB_CACHE_INDEX]);
g_dbInfos[count]->minrows = *((int32_t *)row[TSDB_SHOW_DB_MINROWS_INDEX]); g_dbInfos[count]->blocks =
g_dbInfos[count]->maxrows = *((int32_t *)row[TSDB_SHOW_DB_MAXROWS_INDEX]); *((int32_t *)row[TSDB_SHOW_DB_BLOCKS_INDEX]);
g_dbInfos[count]->wallevel = *((int8_t *)row[TSDB_SHOW_DB_WALLEVEL_INDEX]); g_dbInfos[count]->minrows =
g_dbInfos[count]->fsync = *((int32_t *)row[TSDB_SHOW_DB_FSYNC_INDEX]); *((int32_t *)row[TSDB_SHOW_DB_MINROWS_INDEX]);
g_dbInfos[count]->comp = (int8_t)(*((int8_t *)row[TSDB_SHOW_DB_COMP_INDEX])); g_dbInfos[count]->maxrows =
g_dbInfos[count]->cachelast = (int8_t)(*((int8_t *)row[TSDB_SHOW_DB_CACHELAST_INDEX])); *((int32_t *)row[TSDB_SHOW_DB_MAXROWS_INDEX]);
g_dbInfos[count]->wallevel =
*((int8_t *)row[TSDB_SHOW_DB_WALLEVEL_INDEX]);
g_dbInfos[count]->fsync =
*((int32_t *)row[TSDB_SHOW_DB_FSYNC_INDEX]);
g_dbInfos[count]->comp =
(int8_t)(*((int8_t *)row[TSDB_SHOW_DB_COMP_INDEX]));
g_dbInfos[count]->cachelast =
(int8_t)(*((int8_t *)row[TSDB_SHOW_DB_CACHELAST_INDEX]));
tstrncpy(g_dbInfos[count]->precision, tstrncpy(g_dbInfos[count]->precision,
(char *)row[TSDB_SHOW_DB_PRECISION_INDEX], (char *)row[TSDB_SHOW_DB_PRECISION_INDEX],
DB_PRECISION_LEN); DB_PRECISION_LEN);
g_dbInfos[count]->update = *((int8_t *)row[TSDB_SHOW_DB_UPDATE_INDEX]); g_dbInfos[count]->update =
*((int8_t *)row[TSDB_SHOW_DB_UPDATE_INDEX]);
} }
count++; count++;
if (g_args.databases) { if (g_args.databases) {
if (count > g_args.arg_list_len) break; if (count > g_args.dbCount) break;
} else if (!g_args.all_databases) { } else if (!g_args.all_databases) {
if (count >= 1) break; if (count >= 1) break;
...@@ -1357,7 +1467,7 @@ _dump_db_point: ...@@ -1357,7 +1467,7 @@ _dump_db_point:
taosDumpDb(g_dbInfos[i], fp, taos); taosDumpDb(g_dbInfos[i], fp, taos);
} }
} else { } else {
if (g_args.arg_list_len == 1) { // case: taosdump <db> if (g_args.dbCount == 1) { // case: taosdump <db>
taosDumpDb(g_dbInfos[0], fp, taos); taosDumpDb(g_dbInfos[0], fp, taos);
} else { // case: taosdump <db> tablex tabley ... } else { // case: taosdump <db> tablex tabley ...
taosDumpCreateDbClause(g_dbInfos[0], g_args.with_property, fp); taosDumpCreateDbClause(g_dbInfos[0], g_args.with_property, fp);
...@@ -1492,7 +1602,7 @@ static int taosGetTableDes( ...@@ -1492,7 +1602,7 @@ static int taosGetTableDes(
fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes + 1)); fields[TSDB_DESCRIBE_METRIC_FIELD_INDEX].bytes + 1));
tstrncpy(stableDes->cols[count].type, tstrncpy(stableDes->cols[count].type,
(char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX], (char *)row[TSDB_DESCRIBE_METRIC_TYPE_INDEX],
min(32, fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes + 1)); min(16, fields[TSDB_DESCRIBE_METRIC_TYPE_INDEX].bytes + 1));
stableDes->cols[count].length = stableDes->cols[count].length =
*((int *)row[TSDB_DESCRIBE_METRIC_LENGTH_INDEX]); *((int *)row[TSDB_DESCRIBE_METRIC_LENGTH_INDEX]);
tstrncpy(stableDes->cols[count].note, tstrncpy(stableDes->cols[count].note,
...@@ -1563,18 +1673,6 @@ static int taosGetTableDes( ...@@ -1563,18 +1673,6 @@ static int taosGetTableDes(
case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_BIGINT:
sprintf(stableDes->cols[i].note, "%" PRId64 "", *((int64_t *)row[0])); sprintf(stableDes->cols[i].note, "%" PRId64 "", *((int64_t *)row[0]));
break; break;
case TSDB_DATA_TYPE_UTINYINT:
sprintf(stableDes->cols[i].note, "%d", *((uint8_t *)row[0]));
break;
case TSDB_DATA_TYPE_USMALLINT:
sprintf(stableDes->cols[i].note, "%d", *((uint16_t *)row[0]));
break;
case TSDB_DATA_TYPE_UINT:
sprintf(stableDes->cols[i].note, "%" PRIu32 "", *((uint32_t *)row[0]));
break;
case TSDB_DATA_TYPE_UBIGINT:
sprintf(stableDes->cols[i].note, "%" PRIu64 "", *((uint64_t *)row[0]));
break;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT:
sprintf(stableDes->cols[i].note, "%f", GET_FLOAT_VAL(row[0])); sprintf(stableDes->cols[i].note, "%f", GET_FLOAT_VAL(row[0]));
break; break;
...@@ -2301,19 +2399,6 @@ static int64_t writeResultToSql(TAOS_RES *res, FILE *fp, char *dbName, char *tbN ...@@ -2301,19 +2399,6 @@ static int64_t writeResultToSql(TAOS_RES *res, FILE *fp, char *dbName, char *tbN
curr_sqlstr_len += sprintf(pstr + curr_sqlstr_len, "%" PRId64 "", curr_sqlstr_len += sprintf(pstr + curr_sqlstr_len, "%" PRId64 "",
*((int64_t *)row[col])); *((int64_t *)row[col]));
break; break;
case TSDB_DATA_TYPE_UTINYINT:
curr_sqlstr_len += sprintf(pstr + curr_sqlstr_len, "%d", *((uint8_t *)row[col]));
break;
case TSDB_DATA_TYPE_USMALLINT:
curr_sqlstr_len += sprintf(pstr + curr_sqlstr_len, "%d", *((uint16_t *)row[col]));
break;
case TSDB_DATA_TYPE_UINT:
curr_sqlstr_len += sprintf(pstr + curr_sqlstr_len, "%" PRIu32 "", *((uint32_t *)row[col]));
break;
case TSDB_DATA_TYPE_UBIGINT:
curr_sqlstr_len += sprintf(pstr + curr_sqlstr_len, "%" PRIu64 "",
*((uint64_t *)row[col]));
break;
case TSDB_DATA_TYPE_FLOAT: case TSDB_DATA_TYPE_FLOAT:
curr_sqlstr_len += sprintf(pstr + curr_sqlstr_len, "%f", GET_FLOAT_VAL(row[col])); curr_sqlstr_len += sprintf(pstr + curr_sqlstr_len, "%f", GET_FLOAT_VAL(row[col]));
break; break;
...@@ -2451,12 +2536,6 @@ static int taosCheckParam(struct arguments *arguments) { ...@@ -2451,12 +2536,6 @@ static int taosCheckParam(struct arguments *arguments) {
return -1; return -1;
} }
if (g_args.arg_list_len == 0) {
if ((!g_args.all_databases) && (!g_args.isDumpIn)) {
errorPrint("%s", "taosdump requires parameters for database and operation\n");
return -1;
}
}
/* /*
if (g_args.isDumpIn && (strcmp(g_args.outpath, DEFAULT_DUMP_FILE) != 0)) { if (g_args.isDumpIn && (strcmp(g_args.outpath, DEFAULT_DUMP_FILE) != 0)) {
fprintf(stderr, "duplicate parameter input and output file path\n"); fprintf(stderr, "duplicate parameter input and output file path\n");
......
...@@ -399,7 +399,8 @@ void rpcSendRequest(void *shandle, const SRpcEpSet *pEpSet, SRpcMsg *pMsg, int64 ...@@ -399,7 +399,8 @@ void rpcSendRequest(void *shandle, const SRpcEpSet *pEpSet, SRpcMsg *pMsg, int64
pContext->oldInUse = pEpSet->inUse; pContext->oldInUse = pEpSet->inUse;
pContext->connType = RPC_CONN_UDPC; pContext->connType = RPC_CONN_UDPC;
if (contLen > tsRpcMaxUdpSize || tsRpcForceTcp ) pContext->connType = RPC_CONN_TCPC;
if (contLen > tsRpcMaxUdpSize || tsRpcForceTcp) pContext->connType = RPC_CONN_TCPC;
// connection type is application specific. // connection type is application specific.
// for TDengine, all the query, show commands shall have TCP connection // for TDengine, all the query, show commands shall have TCP connection
......
#!/bin/bash
for N in -1 0 1 10000 10001
do
for l in 1023 1024 1073741824 1073741825
do
for S in udp tcp
do
taos -n speed -h BCC-2 -P 6030 -N $N -l $l -S $S 2>&1 | tee -a result.txt
done
done
done
...@@ -134,7 +134,8 @@ cDebugFlag 135 ...@@ -134,7 +134,8 @@ cDebugFlag 135
rpcDebugFlag 135 rpcDebugFlag 135
qDebugFlag 135 qDebugFlag 135
# httpDebugFlag 143 # httpDebugFlag 143
# asyncLog 0 asyncLog 0
debugflag 143
# tables 10 # tables 10
maxtablesPerVnode 10 maxtablesPerVnode 10
rpcMaxTime 101 rpcMaxTime 101
......
...@@ -18108,4 +18108,109 @@ ...@@ -18108,4 +18108,109 @@
fun:_PyEval_EvalFrameDefault fun:_PyEval_EvalFrameDefault
fun:_PyEval_EvalCodeWithName fun:_PyEval_EvalCodeWithName
fun:_PyFunction_Vectorcall fun:_PyFunction_Vectorcall
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:lib_build_and_cache_attr
fun:lib_getattr
fun:PyObject_GetAttr
fun:_PyEval_EvalFrameDefault
fun:_PyFunction_Vectorcall
fun:_PyEval_EvalFrameDefault
fun:_PyEval_EvalCodeWithName
fun:PyEval_EvalCode
obj:/usr/bin/python3.8
obj:/usr/bin/python3.8
fun:PyVectorcall_Call
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:lib_build_and_cache_attr
fun:lib_getattr
fun:PyObject_GetAttr
obj:/usr/bin/python3.8
obj:/usr/bin/python3.8
fun:_PyEval_EvalFrameDefault
fun:_PyFunction_Vectorcall
fun:_PyEval_EvalFrameDefault
obj:/usr/bin/python3.8
fun:_PyEval_EvalFrameDefault
obj:/usr/bin/python3.8
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_my_Py_InitModule
fun:b_init_cffi_1_0_external_module
obj:/usr/bin/python3.8
obj:/usr/bin/python3.8
fun:PyObject_CallMethod
fun:PyInit__constant_time
fun:_PyImport_LoadDynamicModuleWithSpec
obj:/usr/bin/python3.8
obj:/usr/bin/python3.8
fun:PyVectorcall_Call
fun:_PyEval_EvalFrameDefault
fun:_PyEval_EvalCodeWithName
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:lib_build_cpython_func.isra.87
fun:lib_build_and_cache_attr
fun:lib_getattr
fun:PyObject_GetAttr
obj:/usr/bin/python3.8
obj:/usr/bin/python3.8
fun:_PyEval_EvalFrameDefault
fun:_PyFunction_Vectorcall
fun:_PyEval_EvalFrameDefault
obj:/usr/bin/python3.8
fun:_PyEval_EvalFrameDefault
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_my_Py_InitModule
fun:b_init_cffi_1_0_external_module
obj:/usr/bin/python3.8
obj:/usr/bin/python3.8
fun:PyObject_CallMethod
fun:PyInit__openssl
fun:_PyImport_LoadDynamicModuleWithSpec
obj:/usr/bin/python3.8
obj:/usr/bin/python3.8
fun:PyVectorcall_Call
fun:_PyEval_EvalFrameDefault
fun:_PyEval_EvalCodeWithName
}
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: definite
fun:malloc
fun:_PyObject_GC_New
fun:ffi_internal_new
fun:b_init_cffi_1_0_external_module
obj:/usr/bin/python3.8
obj:/usr/bin/python3.8
fun:PyObject_CallMethod
fun:PyInit__constant_time
fun:_PyImport_LoadDynamicModuleWithSpec
obj:/usr/bin/python3.8
obj:/usr/bin/python3.8
fun:PyVectorcall_Call
fun:_PyEval_EvalFrameDefault
} }
\ No newline at end of file
...@@ -263,10 +263,11 @@ python3 ./test.py -f query/nestedQuery/queryInterval.py ...@@ -263,10 +263,11 @@ python3 ./test.py -f query/nestedQuery/queryInterval.py
python3 ./test.py -f query/queryStateWindow.py python3 ./test.py -f query/queryStateWindow.py
# python3 ./test.py -f query/nestedQuery/queryWithOrderLimit.py # python3 ./test.py -f query/nestedQuery/queryWithOrderLimit.py
python3 ./test.py -f query/nestquery_last_row.py python3 ./test.py -f query/nestquery_last_row.py
python3 ./test.py -f query/nestedQuery/nestedQuery.py #python3 ./test.py -f query/nestedQuery/nestedQuery.py
python3 ./test.py -f query/queryCnameDisplay.py python3 ./test.py -f query/queryCnameDisplay.py
python3 ./test.py -f query/operator_cost.py python3 ./test.py -f query/operator_cost.py
python3 test.py -f query/nestedQuery/queryWithSpread.py python3 test.py -f query/nestedQuery/queryWithSpread.py
python3 ./test.py -f query/bug6586.py
#stream #stream
python3 ./test.py -f stream/metric_1.py python3 ./test.py -f stream/metric_1.py
......
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
from util.log import *
from util.cases import *
from util.sql import *
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
def run(self):
# TD-6586 Binary type value return None with python connector
# PR: https://github.com/taosdata/TDengine/pull/7913/files
tdSql.execute("create database if not exists binary_convertion")
tdSql.execute("use binary_convertion")
tdSql.execute("create stable stb (ts timestamp,value binary(3)) tags (t0 bool,t1 tinyint,t2 smallint,t3 int,t4 bigint,t5 float,t6 double,t7 binary(3),t8 nchar(3))")
tdSql.execute("create table if not exists tb1 using stb(t0,t1,t2,t3,t4,t5,t6,t7,t8) tags (1,127,32767,2147483647,9223372036854775807,11.123450279,22.123456789,'aaa','aaa')")
tdSql.execute("insert into tb1 (ts,value) values (1600000000000, \"aaa\")")
res = tdSql.query('select * from stb', True)
expected_res = [(datetime.datetime(2020, 9, 13, 20, 26, 40), 'aaa', True, 127, 32767, 2147483647, 9223372036854775807, 11.12345027923584, 22.123456789, 'aaa', 'aaa')]
tdSql.checkEqual(res, expected_res)
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
...@@ -49,10 +49,11 @@ class TDTestCase: ...@@ -49,10 +49,11 @@ class TDTestCase:
# select as cname with cname_list # select as cname with cname_list
sql_seq = f'select count(ts) as {cname_list[0]}, sum(pi1) as {cname_list[1]}, avg(pi2) as {cname_list[2]}, count(pf1) as {cname_list[3]}, count(pf2) as {cname_list[4]}, count(ps1) as {cname_list[5]}, min(pi3) as {cname_list[6]}, max(pi4) as {cname_list[7]}, count(pb1) as {cname_list[8]}, count(ps2) as {cname_list[9]} from regular_table_cname_check' sql_seq = f'select count(ts) as {cname_list[0]}, sum(pi1) as {cname_list[1]}, avg(pi2) as {cname_list[2]}, count(pf1) as {cname_list[3]}, count(pf2) as {cname_list[4]}, count(ps1) as {cname_list[5]}, min(pi3) as {cname_list[6]}, max(pi4) as {cname_list[7]}, count(pb1) as {cname_list[8]}, count(ps2) as {cname_list[9]} from regular_table_cname_check'
sql_seq_no_as = sql_seq.replace('as ', '') sql_seq_no_as = sql_seq.replace(' as ', ' ')
print(sql_seq)
print(sql_seq_no_as)
res = tdSql.getColNameList(sql_seq) res = tdSql.getColNameList(sql_seq)
res_no_as = tdSql.getColNameList(sql_seq_no_as) res_no_as = tdSql.getColNameList(sql_seq_no_as)
# cname[1] > 64, it is expected to be equal to 64 # cname[1] > 64, it is expected to be equal to 64
cname_list_1_expected = cname_list[1][:-1] cname_list_1_expected = cname_list[1][:-1]
cname_list[1] = cname_list_1_expected cname_list[1] = cname_list_1_expected
...@@ -79,7 +80,7 @@ class TDTestCase: ...@@ -79,7 +80,7 @@ class TDTestCase:
# select as cname with cname_list # select as cname with cname_list
sql_seq = f'select count(ts) as {cname_list[0]}, sum(pi1) as {cname_list[1]}, avg(pi2) as {cname_list[2]}, count(pf1) as {cname_list[3]}, count(pf2) as {cname_list[4]}, count(ps1) as {cname_list[5]}, min(pi3) as {cname_list[6]}, max(pi4) as {cname_list[7]}, count(pb1) as {cname_list[8]}, count(ps2) as {cname_list[9]}, count(si1) as {cname_list[10]}, count(si2) as {cname_list[11]}, count(sf1) as {cname_list[12]}, count(sf2) as {cname_list[13]}, count(ss1) as {cname_list[14]}, count(si3) as {cname_list[15]}, count(si4) as {cname_list[16]}, count(sb1) as {cname_list[17]}, count(ss2) as {cname_list[18]} from super_table_cname_check' sql_seq = f'select count(ts) as {cname_list[0]}, sum(pi1) as {cname_list[1]}, avg(pi2) as {cname_list[2]}, count(pf1) as {cname_list[3]}, count(pf2) as {cname_list[4]}, count(ps1) as {cname_list[5]}, min(pi3) as {cname_list[6]}, max(pi4) as {cname_list[7]}, count(pb1) as {cname_list[8]}, count(ps2) as {cname_list[9]}, count(si1) as {cname_list[10]}, count(si2) as {cname_list[11]}, count(sf1) as {cname_list[12]}, count(sf2) as {cname_list[13]}, count(ss1) as {cname_list[14]}, count(si3) as {cname_list[15]}, count(si4) as {cname_list[16]}, count(sb1) as {cname_list[17]}, count(ss2) as {cname_list[18]} from super_table_cname_check'
sql_seq_no_as = sql_seq.replace('as ', '') sql_seq_no_as = sql_seq.replace(' as ', ' ')
res = tdSql.getColNameList(sql_seq) res = tdSql.getColNameList(sql_seq)
res_no_as = tdSql.getColNameList(sql_seq_no_as) res_no_as = tdSql.getColNameList(sql_seq_no_as)
......
###################################################################
# Copyright (c) 2016 by TAOS Technologies, Inc.
# All rights reserved.
#
# This file is proprietary and confidential to TAOS Technologies.
# No part of this file may be reproduced, stored, transmitted,
# disclosed or used in any form or by any means other than as
# expressly provided by the written permission from Jianhui Tao
#
###################################################################
# -*- coding: utf-8 -*-
import sys
import os
from util.log import *
from util.cases import *
from util.sql import *
from util.dnodes import *
class TDTestCase:
def init(self, conn, logSql):
tdLog.debug("start to execute %s" % __file__)
tdSql.init(conn.cursor(), logSql)
self.ts = 1625068800000000000 # this is timestamp "2021-07-01 00:00:00"
self.numberOfTables = 10
self.numberOfRecords = 100
def checkCommunity(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
return False
else:
return True
def getBuildPath(self):
selfPath = os.path.dirname(os.path.realpath(__file__))
if ("community" in selfPath):
projPath = selfPath[:selfPath.find("community")]
else:
projPath = selfPath[:selfPath.find("tests")]
for root, dirs, files in os.walk(projPath):
if ("taosd" in files):
rootRealPath = os.path.dirname(os.path.realpath(root))
if ("packaging" not in rootRealPath):
buildPath = root[:len(root) - len("/build/bin")]
break
return buildPath
def createdb(self, precision="ns"):
tb_nums = self.numberOfTables
per_tb_rows = self.numberOfRecords
def build_db(precision, start_time):
tdSql.execute("drop database if exists timedb1")
tdSql.execute(
"create database timedb1 days 10 keep 365 blocks 8 precision "+"\""+precision+"\"")
tdSql.execute("use timedb1")
tdSql.execute(
"create stable st(ts timestamp, c1 int, c2 nchar(10),c3 timestamp) tags(t1 int, t2 binary(10))")
for tb in range(tb_nums):
tbname = "t"+str(tb)
tdSql.execute("create table " + tbname +
" using st tags(1, 'beijing')")
sql = "insert into " + tbname + " values"
currts = start_time
if precision == "ns":
ts_seed = 1000000000
elif precision == "us":
ts_seed = 1000000
else:
ts_seed = 1000
for i in range(per_tb_rows):
sql += "(%d, %d, 'nchar%d',%d)" % (currts + i*ts_seed, i %
100, i % 100, currts + i*100) # currts +1000ms (1000000000ns)
tdSql.execute(sql)
if precision == "ns":
start_time = 1625068800000000000
build_db(precision, start_time)
elif precision == "us":
start_time = 1625068800000000
build_db(precision, start_time)
elif precision == "ms":
start_time = 1625068800000
build_db(precision, start_time)
else:
print("other time precision not valid , please check! ")
def run(self):
# clear envs
os.system("rm -rf ./taosdumptest/")
tdSql.execute("drop database if exists dumptmp1")
tdSql.execute("drop database if exists dumptmp2")
tdSql.execute("drop database if exists dumptmp3")
if not os.path.exists("./taosdumptest/tmp1"):
os.makedirs("./taosdumptest/dumptmp1")
else:
print("path exist!")
if not os.path.exists("./taosdumptest/dumptmp2"):
os.makedirs("./taosdumptest/dumptmp2")
if not os.path.exists("./taosdumptest/dumptmp3"):
os.makedirs("./taosdumptest/dumptmp3")
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosdump not found!")
else:
tdLog.info("taosdump found in %s" % buildPath)
binPath = buildPath + "/build/bin/"
# create nano second database
self.createdb(precision="ns")
# dump all data
os.system(
"%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath)
# dump part data with -S -E
os.system(
'%staosdump --databases timedb1 -S 1625068810000000000 -E 1625068860000000000 -C ns -o ./taosdumptest/dumptmp2 ' %
binPath)
os.system(
'%staosdump --databases timedb1 -S 1625068810000000000 -o ./taosdumptest/dumptmp3 ' %
binPath)
# replace strings to dump in databases
os.system(
"sed -i \"s/timedb1/dumptmp1/g\" `grep timedb1 -rl ./taosdumptest/dumptmp1`")
os.system(
"sed -i \"s/timedb1/dumptmp2/g\" `grep timedb1 -rl ./taosdumptest/dumptmp2`")
os.system(
"sed -i \"s/timedb1/dumptmp3/g\" `grep timedb1 -rl ./taosdumptest/dumptmp3`")
os.system( "%staosdump -i ./taosdumptest/dumptmp1" %binPath)
os.system( "%staosdump -i ./taosdumptest/dumptmp2" %binPath)
os.system( "%staosdump -i ./taosdumptest/dumptmp3" %binPath)
# dump data and check for taosdump
tdSql.query("select count(*) from dumptmp1.st")
tdSql.checkData(0,0,1000)
tdSql.query("select count(*) from dumptmp2.st")
tdSql.checkData(0,0,510)
tdSql.query("select count(*) from dumptmp3.st")
tdSql.checkData(0,0,900)
# check data
origin_res = tdSql.getResult("select * from timedb1.st")
dump_res = tdSql.getResult("select * from dumptmp1.st")
if origin_res == dump_res:
tdLog.info("test nano second : dump check data pass for all data!" )
else:
tdLog.info("test nano second : dump check data failed for all data!" )
origin_res = tdSql.getResult("select * from timedb1.st where ts >=1625068810000000000 and ts <= 1625068860000000000")
dump_res = tdSql.getResult("select * from dumptmp2.st")
if origin_res == dump_res:
tdLog.info(" test nano second : dump check data pass for data! " )
else:
tdLog.info(" test nano second : dump check data failed for data !" )
origin_res = tdSql.getResult("select * from timedb1.st where ts >=1625068810000000000 ")
dump_res = tdSql.getResult("select * from dumptmp3.st")
if origin_res == dump_res:
tdLog.info(" test nano second : dump check data pass for data! " )
else:
tdLog.info(" test nano second : dump check data failed for data !" )
# us second support test case
os.system("rm -rf ./taosdumptest/")
tdSql.execute("drop database if exists dumptmp1")
tdSql.execute("drop database if exists dumptmp2")
tdSql.execute("drop database if exists dumptmp3")
if not os.path.exists("./taosdumptest/tmp1"):
os.makedirs("./taosdumptest/dumptmp1")
else:
print("path exits!")
if not os.path.exists("./taosdumptest/dumptmp2"):
os.makedirs("./taosdumptest/dumptmp2")
if not os.path.exists("./taosdumptest/dumptmp3"):
os.makedirs("./taosdumptest/dumptmp3")
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosdump not found!")
else:
tdLog.info("taosdump found in %s" % buildPath)
binPath = buildPath + "/build/bin/"
self.createdb(precision="us")
os.system(
"%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath)
os.system(
'%staosdump --databases timedb1 -S 1625068810000000 -E 1625068860000000 -C us -o ./taosdumptest/dumptmp2 ' %
binPath)
os.system(
'%staosdump --databases timedb1 -S 1625068810000000 -o ./taosdumptest/dumptmp3 ' %
binPath)
os.system(
"sed -i \"s/timedb1/dumptmp1/g\" `grep timedb1 -rl ./taosdumptest/dumptmp1`")
os.system(
"sed -i \"s/timedb1/dumptmp2/g\" `grep timedb1 -rl ./taosdumptest/dumptmp2`")
os.system(
"sed -i \"s/timedb1/dumptmp3/g\" `grep timedb1 -rl ./taosdumptest/dumptmp3`")
os.system( "%staosdump -i ./taosdumptest/dumptmp1" %binPath)
os.system( "%staosdump -i ./taosdumptest/dumptmp2" %binPath)
os.system( "%staosdump -i ./taosdumptest/dumptmp3" %binPath)
tdSql.query("select count(*) from dumptmp1.st")
tdSql.checkData(0,0,1000)
tdSql.query("select count(*) from dumptmp2.st")
tdSql.checkData(0,0,510)
tdSql.query("select count(*) from dumptmp3.st")
tdSql.checkData(0,0,900)
origin_res = tdSql.getResult("select * from timedb1.st")
dump_res = tdSql.getResult("select * from dumptmp1.st")
if origin_res == dump_res:
tdLog.info("test us second : dump check data pass for all data!" )
else:
tdLog.info("test us second : dump check data failed for all data!" )
origin_res = tdSql.getResult("select * from timedb1.st where ts >=1625068810000000 and ts <= 1625068860000000")
dump_res = tdSql.getResult("select * from dumptmp2.st")
if origin_res == dump_res:
tdLog.info(" test us second : dump check data pass for data! " )
else:
tdLog.info(" test us second : dump check data failed for data!" )
origin_res = tdSql.getResult("select * from timedb1.st where ts >=1625068810000000 ")
dump_res = tdSql.getResult("select * from dumptmp3.st")
if origin_res == dump_res:
tdLog.info(" test us second : dump check data pass for data! " )
else:
tdLog.info(" test us second : dump check data failed for data! " )
# ms second support test case
os.system("rm -rf ./taosdumptest/")
tdSql.execute("drop database if exists dumptmp1")
tdSql.execute("drop database if exists dumptmp2")
tdSql.execute("drop database if exists dumptmp3")
if not os.path.exists("./taosdumptest/tmp1"):
os.makedirs("./taosdumptest/dumptmp1")
else:
print("path exits!")
if not os.path.exists("./taosdumptest/dumptmp2"):
os.makedirs("./taosdumptest/dumptmp2")
if not os.path.exists("./taosdumptest/dumptmp3"):
os.makedirs("./taosdumptest/dumptmp3")
buildPath = self.getBuildPath()
if (buildPath == ""):
tdLog.exit("taosdump not found!")
else:
tdLog.info("taosdump found in %s" % buildPath)
binPath = buildPath + "/build/bin/"
self.createdb(precision="ms")
os.system(
"%staosdump --databases timedb1 -o ./taosdumptest/dumptmp1" % binPath)
os.system(
'%staosdump --databases timedb1 -S 1625068810000 -E 1625068860000 -C ms -o ./taosdumptest/dumptmp2 ' %
binPath)
os.system(
'%staosdump --databases timedb1 -S 1625068810000 -o ./taosdumptest/dumptmp3 ' %
binPath)
os.system(
"sed -i \"s/timedb1/dumptmp1/g\" `grep timedb1 -rl ./taosdumptest/dumptmp1`")
os.system(
"sed -i \"s/timedb1/dumptmp2/g\" `grep timedb1 -rl ./taosdumptest/dumptmp2`")
os.system(
"sed -i \"s/timedb1/dumptmp3/g\" `grep timedb1 -rl ./taosdumptest/dumptmp3`")
os.system( "%staosdump -i ./taosdumptest/dumptmp1" %binPath)
os.system( "%staosdump -i ./taosdumptest/dumptmp2" %binPath)
os.system( "%staosdump -i ./taosdumptest/dumptmp3" %binPath)
tdSql.query("select count(*) from dumptmp1.st")
tdSql.checkData(0,0,1000)
tdSql.query("select count(*) from dumptmp2.st")
tdSql.checkData(0,0,510)
tdSql.query("select count(*) from dumptmp3.st")
tdSql.checkData(0,0,900)
origin_res = tdSql.getResult("select * from timedb1.st")
dump_res = tdSql.getResult("select * from dumptmp1.st")
if origin_res == dump_res:
tdLog.info("test ms second : dump check data pass for all data!" )
else:
tdLog.info("test ms second : dump check data failed for all data!" )
origin_res = tdSql.getResult("select * from timedb1.st where ts >=1625068810000 and ts <= 1625068860000")
dump_res = tdSql.getResult("select * from dumptmp2.st")
if origin_res == dump_res:
tdLog.info(" test ms second : dump check data pass for data! " )
else:
tdLog.info(" test ms second : dump check data failed for data!" )
origin_res = tdSql.getResult("select * from timedb1.st where ts >=1625068810000 ")
dump_res = tdSql.getResult("select * from dumptmp3.st")
if origin_res == dump_res:
tdLog.info(" test ms second : dump check data pass for data! " )
else:
tdLog.info(" test ms second : dump check data failed for data! " )
os.system("rm -rf ./taosdumptest/")
os.system("rm -rf ./dump_result.txt")
os.system("rm -rf *.py.sql")
def stop(self):
tdSql.close()
tdLog.success("%s successfully executed" % __file__)
tdCases.addWindows(__file__, TDTestCase())
tdCases.addLinux(__file__, TDTestCase())
...@@ -26,6 +26,9 @@ class TDTestCase: ...@@ -26,6 +26,9 @@ class TDTestCase:
tdSql.init(conn.cursor(), logSql) tdSql.init(conn.cursor(), logSql)
now = time.time() now = time.time()
print(int(round(now * 1000)))
self.ts = int(round(now * 1000)) self.ts = int(round(now * 1000))
def getBuildPath(self): def getBuildPath(self):
...@@ -54,6 +57,7 @@ class TDTestCase: ...@@ -54,6 +57,7 @@ class TDTestCase:
# insert: create one or mutiple tables per sql and insert multiple rows per sql # insert: create one or mutiple tables per sql and insert multiple rows per sql
# test case for https://jira.taosdata.com:18080/browse/TD-4985 # test case for https://jira.taosdata.com:18080/browse/TD-4985
os.system("rm -rf tools/taosdemoAllTest/TD-4985/query-limit-offset.py.sql")
os.system("%staosdemo -f tools/taosdemoAllTest/TD-4985/query-limit-offset.json -y " % binPath) os.system("%staosdemo -f tools/taosdemoAllTest/TD-4985/query-limit-offset.json -y " % binPath)
tdSql.execute("use db") tdSql.execute("use db")
tdSql.query("select count (tbname) from stb0") tdSql.query("select count (tbname) from stb0")
...@@ -82,6 +86,7 @@ class TDTestCase: ...@@ -82,6 +86,7 @@ class TDTestCase:
% (self.ts + i, i, -10000+i, i)) % (self.ts + i, i, -10000+i, i))
tdSql.query("select * from stb0 where c2 like 'test99%' ") tdSql.query("select * from stb0 where c2 like 'test99%' ")
tdSql.checkRows(1000) tdSql.checkRows(1000)
tdSql.query("select * from stb0 where tbname like 'stb00_9999' limit 10" ) tdSql.query("select * from stb0 where tbname like 'stb00_9999' limit 10" )
tdSql.checkData(0, 1, 0) tdSql.checkData(0, 1, 0)
tdSql.checkData(1, 1, 1) tdSql.checkData(1, 1, 1)
......
...@@ -55,7 +55,7 @@ class TDTestCase: ...@@ -55,7 +55,7 @@ class TDTestCase:
if not os.path.exists("./taosdumptest/tmp1"): if not os.path.exists("./taosdumptest/tmp1"):
os.makedirs("./taosdumptest/tmp1") os.makedirs("./taosdumptest/tmp1")
else: else:
print("目录存在") print("directory exists")
if not os.path.exists("./taosdumptest/tmp2"): if not os.path.exists("./taosdumptest/tmp2"):
os.makedirs("./taosdumptest/tmp2") os.makedirs("./taosdumptest/tmp2")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册