Merge branch '3.0' of https://github.com/taosdata/TDengine into feat/tsdb_snapshot

This commit is contained in:
Hongze Cheng 2022-07-06 08:07:27 +00:00
commit 418aacf4cd
24 changed files with 967 additions and 3417 deletions

View File

@ -488,6 +488,8 @@ typedef struct SAggOperatorInfo {
uint64_t groupId; uint64_t groupId;
SGroupResInfo groupResInfo; SGroupResInfo groupResInfo;
SExprSupp scalarExprSup; SExprSupp scalarExprSup;
SNode *pCondition;
} SAggOperatorInfo; } SAggOperatorInfo;
typedef struct SProjectOperatorInfo { typedef struct SProjectOperatorInfo {
@ -689,6 +691,8 @@ typedef struct SSortOperatorInfo {
int64_t startTs; // sort start time int64_t startTs; // sort start time
uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included. uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included.
SNode* pCondition;
} SSortOperatorInfo; } SSortOperatorInfo;
typedef struct STagFilterOperatorInfo { typedef struct STagFilterOperatorInfo {
@ -767,7 +771,7 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo); STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo);
SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode *pScanPhyNode, const char* pUser, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode *pScanPhyNode, const char* pUser, SExecTaskInfo* pTaskInfo);
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExprInfo* pScalarExprInfo, SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SNode* pCondition, SExprInfo* pScalarExprInfo,
int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo); int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo);
SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhysiNode *pNode, SExecTaskInfo* pTaskInfo); SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhysiNode *pNode, SExecTaskInfo* pTaskInfo);

View File

@ -3012,11 +3012,19 @@ static SSDataBlock* getAggregateResult(SOperatorInfo* pOperator) {
} }
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity); blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
doBuildResultDatablock(pOperator, pInfo, &pAggInfo->groupResInfo, pAggInfo->aggSup.pResultBuf); while (1) {
if (pInfo->pRes->info.rows == 0 || !hasDataInGroupInfo(&pAggInfo->groupResInfo)) { doBuildResultDatablock(pOperator, pInfo, &pAggInfo->groupResInfo, pAggInfo->aggSup.pResultBuf);
doSetOperatorCompleted(pOperator); doFilter(pAggInfo->pCondition, pInfo->pRes);
}
if (!hasDataInGroupInfo(&pAggInfo->groupResInfo)) {
doSetOperatorCompleted(pOperator);
break;
}
if (pInfo->pRes->info.rows > 0) {
break;
}
}
size_t rows = blockDataGetNumOfRows(pInfo->pRes); size_t rows = blockDataGetNumOfRows(pInfo->pRes);
pOperator->resultInfo.totalRows += rows; pOperator->resultInfo.totalRows += rows;
@ -3557,7 +3565,7 @@ int32_t initExprSupp(SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfExpr) {
} }
SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
SSDataBlock* pResultBlock, SExprInfo* pScalarExprInfo, SSDataBlock* pResultBlock, SNode* pCondition, SExprInfo* pScalarExprInfo,
int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo) { int32_t numOfScalarExpr, SExecTaskInfo* pTaskInfo) {
SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo)); SAggOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SAggOperatorInfo));
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo)); SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
@ -3581,6 +3589,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
} }
pInfo->groupId = INT32_MIN; pInfo->groupId = INT32_MIN;
pInfo->pCondition = pCondition;
pOperator->name = "TableAggregate"; pOperator->name = "TableAggregate";
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_HASH_AGG; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_HASH_AGG;
pOperator->blocking = true; pOperator->blocking = true;
@ -4362,7 +4371,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
pScalarExprInfo, numOfScalarExpr, pTaskInfo); pScalarExprInfo, numOfScalarExpr, pTaskInfo);
} else { } else {
pOptr = pOptr =
createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pScalarExprInfo, numOfScalarExpr, pTaskInfo); createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pAggNode->node.pConditions, pScalarExprInfo, numOfScalarExpr, pTaskInfo);
} }
} else if (QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL == type || QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL == type) { } else if (QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL == type || QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL == type) {
SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode; SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode;

View File

@ -46,7 +46,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
initResultSizeInfo(pOperator, 1024); initResultSizeInfo(pOperator, 1024);
pInfo->pSortInfo = createSortInfo(pSortPhyNode->pSortKeys); pInfo->pSortInfo = createSortInfo(pSortPhyNode->pSortKeys);
; pInfo->pCondition = pSortPhyNode->node.pConditions;
pInfo->pColMatchInfo = pColMatchColInfo; pInfo->pColMatchInfo = pColMatchColInfo;
pOperator->name = "SortOperator"; pOperator->name = "SortOperator";
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_SORT; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_SORT;
@ -205,14 +205,27 @@ SSDataBlock* doSort(SOperatorInfo* pOperator) {
longjmp(pTaskInfo->env, code); longjmp(pTaskInfo->env, code);
} }
SSDataBlock* pBlock = getSortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity, SSDataBlock* pBlock = NULL;
pInfo->pColMatchInfo, pInfo); while (1) {
pBlock = getSortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity,
pInfo->pColMatchInfo, pInfo);
if (pBlock != NULL) {
doFilter(pInfo->pCondition, pBlock);
}
if (pBlock == NULL) {
doSetOperatorCompleted(pOperator);
break;
}
if (blockDataGetNumOfRows(pBlock) > 0) {
break;
}
}
if (pBlock != NULL) { if (pBlock != NULL) {
pOperator->resultInfo.totalRows += pBlock->info.rows; pOperator->resultInfo.totalRows += pBlock->info.rows;
} else {
doSetOperatorCompleted(pOperator);
} }
return pBlock; return pBlock;
} }

View File

@ -1615,26 +1615,27 @@ static int32_t translateSubstr(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
} }
SExprNode* pPara0 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0); SExprNode* pPara0 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 0);
SExprNode* p1 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 1); SExprNode* pPara1 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 1);
uint8_t para1Type = p1->resType.type; uint8_t para0Type = pPara0->resType.type;
if (!IS_VAR_DATA_TYPE(pPara0->resType.type) || !IS_INTEGER_TYPE(para1Type)) { uint8_t para1Type = pPara1->resType.type;
if (!IS_VAR_DATA_TYPE(para0Type) || !IS_INTEGER_TYPE(para1Type)) {
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
} }
if (((SValueNode*)p1)->datum.i < 1) { if (((SValueNode*)pPara1)->datum.i == 0) {
return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName); return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName);
} }
if (3 == numOfParams) { if (3 == numOfParams) {
SExprNode* p2 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 2); SExprNode* pPara2 = (SExprNode*)nodesListGetNode(pFunc->pParameterList, 2);
uint8_t para2Type = p2->resType.type; uint8_t para2Type = pPara2->resType.type;
if (!IS_INTEGER_TYPE(para2Type)) { if (!IS_INTEGER_TYPE(para2Type)) {
return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName);
} }
int64_t v = ((SValueNode*)p1)->datum.i; int64_t v = ((SValueNode*)pPara2)->datum.i;
if (v < 0 || v > INT16_MAX) { if (v < 0) {
return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName); return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName);
} }
} }

View File

@ -376,8 +376,6 @@ int32_t parseJsontoTagData(const char* json, SArray* pTagVals, STag** ppTag, voi
char* jsonKey = item->string; char* jsonKey = item->string;
if (!isValidateTag(jsonKey)) { if (!isValidateTag(jsonKey)) {
fprintf(stdout, "%s(%d) %s %08" PRId64 "\n", __FILE__, __LINE__, __func__, taosGetSelfPthreadId());
fflush(stdout);
retCode = buildSyntaxErrMsg(pMsgBuf, "json key not validate", jsonKey); retCode = buildSyntaxErrMsg(pMsgBuf, "json key not validate", jsonKey);
goto end; goto end;
} }

View File

@ -40,7 +40,7 @@ int32_t schSwitchJobStatus(SSchJob* pJob, int32_t status, void* param) {
SCH_RET(schProcessOnJobFailure(pJob, (param ? *(int32_t*)param : 0))); SCH_RET(schProcessOnJobFailure(pJob, (param ? *(int32_t*)param : 0)));
break; break;
case JOB_TASK_STATUS_DROP: case JOB_TASK_STATUS_DROP:
SCH_ERR_JRET(schProcessOnJobDropped(pJob, *(int32_t*)param)); schProcessOnJobDropped(pJob, *(int32_t*)param);
if (taosRemoveRef(schMgmt.jobRef, pJob->refId)) { if (taosRemoveRef(schMgmt.jobRef, pJob->refId)) {
SCH_JOB_ELOG("remove job from job list failed, refId:0x%" PRIx64, pJob->refId); SCH_JOB_ELOG("remove job from job list failed, refId:0x%" PRIx64, pJob->refId);

View File

@ -144,11 +144,9 @@ void schedulerFreeJob(int64_t* jobId, int32_t errCode) {
return; return;
} }
if (schJobDone(pJob)) {
return;
}
schSwitchJobStatus(pJob, JOB_TASK_STATUS_DROP, (void*)&errCode); schSwitchJobStatus(pJob, JOB_TASK_STATUS_DROP, (void*)&errCode);
schReleaseJob(*jobId);
*jobId = 0; *jobId = 0;
} }

View File

@ -707,13 +707,36 @@ int32_t syncNodeProposeBatch(SSyncNode* pSyncNode, SRpcMsg* pMsgArr, bool* pIsWe
syncClientRequestBatch2RpcMsg(pSyncMsg, &rpcMsg); syncClientRequestBatch2RpcMsg(pSyncMsg, &rpcMsg);
taosMemoryFree(pSyncMsg); // only free msg body, do not free rpc msg content taosMemoryFree(pSyncMsg); // only free msg body, do not free rpc msg content
if (pSyncNode->FpEqMsg != NULL && (*pSyncNode->FpEqMsg)(pSyncNode->msgcb, &rpcMsg) == 0) { if (pSyncNode->replicaNum == 1 && pSyncNode->vgId != 1) {
// enqueue msg ok int32_t code = syncNodeOnClientRequestBatchCb(pSyncNode, pSyncMsg);
if (code == 0) {
// update rpc msg applyIndex
SRpcMsg* msgArr = syncClientRequestBatchRpcMsgArr(pSyncMsg);
ASSERT(arrSize == pSyncMsg->dataCount);
for (int i = 0; i < arrSize; ++i) {
pMsgArr[i].info.conn.applyIndex = msgArr[i].info.conn.applyIndex;
syncRespMgrDel(pSyncNode->pSyncRespMgr, raftArr[i].seqNum);
}
rpcFreeCont(rpcMsg.pCont);
terrno = 0;
return 1;
} else {
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
return -1;
}
} else { } else {
sError("vgId:%d, enqueue msg error, FpEqMsg is NULL", pSyncNode->vgId); if (pSyncNode->FpEqMsg != NULL && (*pSyncNode->FpEqMsg)(pSyncNode->msgcb, &rpcMsg) == 0) {
terrno = TSDB_CODE_SYN_INTERNAL_ERROR; // enqueue msg ok
return -1; return 0;
} else {
sError("vgId:%d, enqueue msg error, FpEqMsg is NULL", pSyncNode->vgId);
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
return -1;
}
} }
return 0; return 0;
@ -2490,6 +2513,9 @@ int32_t syncNodeOnClientRequestBatchCb(SSyncNode* ths, SyncClientRequestBatch* p
ASSERT(0); ASSERT(0);
return -1; return -1;
} }
// update rpc msg conn apply.index
msgArr[i].info.conn.applyIndex = pEntry->index;
} }
// fsync once // fsync once
@ -2498,7 +2524,7 @@ int32_t syncNodeOnClientRequestBatchCb(SSyncNode* ths, SyncClientRequestBatch* p
walFsync(pWal, true); walFsync(pWal, true);
if (ths->replicaNum > 1) { if (ths->replicaNum > 1) {
// if mulit replica, start replicate right now // if multi replica, start replicate right now
syncNodeReplicate(ths); syncNodeReplicate(ths);
} else if (ths->replicaNum == 1) { } else if (ths->replicaNum == 1) {

View File

@ -260,6 +260,14 @@ char *taosDirName(char *name) {
name[0] = 0; name[0] = 0;
} }
return name; return name;
#elif defined(_TD_DARWIN_64)
char *end = strrchr(name, '/');
if (end != NULL) {
*end = '\0';
} else {
name[0] = 0;
}
return name;
#else #else
return dirname(name); return dirname(name);
#endif #endif

View File

@ -947,9 +947,9 @@ int32_t taosGetFqdn(char *fqdn) {
hostname[1023] = '\0'; hostname[1023] = '\0';
if (gethostname(hostname, 1023) == -1) { if (gethostname(hostname, 1023) == -1) {
#ifdef WINDOWS #ifdef WINDOWS
printf("failed to get hostname, reason:%s", strerror(WSAGetLastError())); printf("failed to get hostname, reason:%s\n", strerror(WSAGetLastError()));
#else #else
printf("failed to get hostname, reason:%s", strerror(errno)); printf("failed to get hostname, reason:%s\n", strerror(errno));
#endif #endif
assert(0); assert(0);
return -1; return -1;
@ -968,7 +968,7 @@ int32_t taosGetFqdn(char *fqdn) {
#endif // __APPLE__ #endif // __APPLE__
int32_t ret = getaddrinfo(hostname, NULL, &hints, &result); int32_t ret = getaddrinfo(hostname, NULL, &hints, &result);
if (!result) { if (!result) {
fprintf(stderr, "failed to get fqdn, code:%d, reason:%s", ret, gai_strerror(ret)); fprintf(stderr, "failed to get fqdn, code:%d, reason:%s\n", ret, gai_strerror(ret));
return -1; return -1;
} }

View File

@ -759,9 +759,11 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen) {
return 0; return 0;
#elif defined(_TD_DARWIN_64) #elif defined(_TD_DARWIN_64)
uuid_t uuid = {0}; uuid_t uuid = {0};
char buf[37] = {0};
uuid_generate(uuid); uuid_generate(uuid);
// it's caller's responsibility to make enough space for `uid`, that's 36-char + 1-null // it's caller's responsibility to make enough space for `uid`, that's 36-char + 1-null
uuid_unparse_lower(uuid, uid); uuid_unparse_lower(uuid, buf);
memcpy(uid, buf, uidlen);
return 0; return 0;
#else #else
int len = 0; int len = 0;

View File

@ -93,7 +93,7 @@ TS_FUNC = [
"CSUM", "DERIVATIVE", "DIFF", "IRATE", "MAVG", "SAMPLE", "STATECOUNT", "STATEDURATION", "TWA" "CSUM", "DERIVATIVE", "DIFF", "IRATE", "MAVG", "SAMPLE", "STATECOUNT", "STATEDURATION", "TWA"
] ]
SYSINFO_FUCN = [ SYSINFO_FUNC = [
"DATABASE", "CLIENT_VERSION", "SERVER_VERSION", "SERVER_STATUS", "CURRENT_USER", "USER" "DATABASE", "CLIENT_VERSION", "SERVER_VERSION", "SERVER_STATUS", "CURRENT_USER", "USER"
] ]

View File

@ -87,29 +87,29 @@ class TDTestCase:
@property @property
def create_stable_sql_err(self): def create_stable_sql_err(self):
return [ return [
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(ceil) watermark 1s max_delay 1m", f"create stable stb11 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(ceil) watermark 1s max_delay 1m",
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(count) watermark 1min", f"create stable stb12 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(count) watermark 1min",
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay -1s", f"create stable stb13 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay -1s",
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark -1m", f"create stable stb14 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark -1m",
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 1m ", f"create stable stb15 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 1m ",
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) max_delay 1m ", f"create stable stb16 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) max_delay 1m ",
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} binary(16)) tags (tag1 int) rollup(avg) watermark 1s", f"create stable stb21 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} binary(16)) tags (tag1 int) rollup(avg) watermark 1s",
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {NCHAR_COL} nchar(16)) tags (tag1 int) rollup(avg) max_delay 1m", f"create stable stb22 ({PRIMARY_COL} timestamp, {INT_COL} int, {NCHAR_COL} nchar(16)) tags (tag1 int) rollup(avg) max_delay 1m",
# f"create table ntb_1 ({PRIMARY_COL} timestamp, {INT_COL} int, {NCHAR_COL} nchar(16)) rollup(avg) watermark 1s max_delay 1s", f"create table ntb_1 ({PRIMARY_COL} timestamp, {INT_COL} int, {NCHAR_COL} nchar(16)) rollup(avg) watermark 1s max_delay 1s",
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {NCHAR_COL} nchar(16)) tags (tag1 int) " , f"create stable stb23 ({PRIMARY_COL} timestamp, {INT_COL} int, {NCHAR_COL} nchar(16)) tags (tag1 int) " ,
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) " , f"create stable stb24 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) " ,
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int) " , f"create stable stb25 ({PRIMARY_COL} timestamp, {INT_COL} int) " ,
f"create stable stb2 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) " , f"create stable stb26 ({PRIMARY_COL} timestamp, {INT_COL} int, {BINARY_COL} nchar(16)) " ,
# watermark, max_delay: [0, 900000], [ms, s, m, ?] # watermark, max_delay: [0, 900000], [ms, s, m, ?]
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 1u", f"create stable stb17 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 1u",
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 1b", f"create stable stb18 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 1b",
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 900001ms", f"create stable stb19 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 900001ms",
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 16m", f"create stable stb20 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 16m",
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 901s", f"create stable stb27 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 901s",
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 1h", f"create stable stb28 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 1h",
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 0.2h", f"create stable stb29 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) max_delay 0.2h",
f"create stable stb1 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 0.002d", f"create stable stb30 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(min) watermark 0.002d",
] ]
@ -125,8 +125,8 @@ class TDTestCase:
f"create stable stb7 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m sma({INT_COL})", f"create stable stb7 ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) rollup(first) watermark 5s max_delay 1m sma({INT_COL})",
] ]
def test_create_stb(self): def test_create_stb(self, db="db2"):
tdSql.execute("use db2") tdSql.execute(f"use {db}")
for err_sql in self.create_stable_sql_err: for err_sql in self.create_stable_sql_err:
tdSql.error(err_sql) tdSql.error(err_sql)
for cur_sql in self.create_stable_sql_current: for cur_sql in self.create_stable_sql_current:
@ -136,7 +136,7 @@ class TDTestCase:
tdSql.checkRows(len(self.create_stable_sql_current)) tdSql.checkRows(len(self.create_stable_sql_current))
tdSql.execute("use db") # because db is a noraml database, not a rollup database, should not be able to create a rollup stable tdSql.execute("use db") # because db is a noraml database, not a rollup database, should not be able to create a rollup stable
# tdSql.error(f"create stable nor_db_rollup_stb ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 5s max_delay 1m") tdSql.error(f"create stable nor_db_rollup_stb ({PRIMARY_COL} timestamp, {INT_COL} int) tags (tag1 int) watermark 5s max_delay 1m")
def test_create_databases(self): def test_create_databases(self):
@ -255,6 +255,7 @@ class TDTestCase:
tdSql.execute("drop database if exists db2 ") tdSql.execute("drop database if exists db2 ")
tdSql.execute("use db3") tdSql.execute("use db3")
self.test_create_stb(db="db3")
# self.__create_tb() # self.__create_tb()
# self.__insert_data() # self.__insert_data()
self.all_test() self.all_test()

View File

@ -218,13 +218,13 @@ class TDTestCase:
tdLog.debug("assert 8th case %s"%rows) tdLog.debug("assert 8th case %s"%rows)
assert rows[0][0] == 3, ' 8th case is failed' assert rows[0][0] == 3, ' 8th case is failed'
# #query: selector Functions 9 #query: selector Functions 9
# queryparam=new_bind_params(1) queryparam=new_bind_params(1)
# queryparam[0].int(2) queryparam[0].int(2)
# rows=self.stmtExe(conn,"select bottom(bu,?) from log group by bu ; ",queryparam) rows=self.stmtExe(conn,"select bottom(bu,?) from log group by bu order by bu desc ; ",queryparam)
# tdLog.debug("assert 9th case %s"%rows) tdLog.debug("assert 9th case %s"%rows)
# assert rows[0][0] == 4, ' 9 case is failed' assert rows[1][0] == 4, ' 9 case is failed'
# assert rows[1][0] == 3, ' 9 case is failed' assert rows[2][0] == 3, ' 9 case is failed'
# #query: time-series specific Functions 10 # #query: time-series specific Functions 10

View File

@ -123,10 +123,10 @@ class TDTestCase:
elif unit.lower() == '1u': elif unit.lower() == '1u':
for i in range(len(self.ts_str)): for i in range(len(self.ts_str)):
tdSql.checkEqual(tdSql.queryResult[i][0],int(((date_time[i]/1000)-self.subtractor*1000000))) tdSql.checkEqual(tdSql.queryResult[i][0],int(((date_time[i]/1000)-self.subtractor*1000000)))
# self.check_tbtype(tb_type) self.check_tbtype(tb_type)
# tdSql.checkRows(len(self.ts_str)) tdSql.checkRows(len(self.ts_str))
# for i in range(len(self.ts_str)): for i in range(len(self.ts_str)):
# tdSql.checkEqual(tdSql.queryResult[i][0],int(((date_time[i]/1000000)-self.subtractor*1000000000))) tdSql.checkEqual(tdSql.queryResult[i][0],int(((date_time[i])-self.subtractor*1000000000)))
for unit in self.error_unit: for unit in self.error_unit:
if tb_type.lower() == 'ntb': if tb_type.lower() == 'ntb':
tdSql.error(f'select timediff(ts,{self.subtractor},{unit}) from {self.ntbname}') tdSql.error(f'select timediff(ts,{self.subtractor},{unit}) from {self.ntbname}')

File diff suppressed because it is too large Load Diff

View File

@ -478,6 +478,9 @@ class TDTestCase:
self.test_case3() self.test_case3()
# tdLog.debug(" LIMIT test_case3 ............ [OK]") # tdLog.debug(" LIMIT test_case3 ............ [OK]")
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")
return return
# #

View File

@ -21,7 +21,6 @@ class TDTestCase:
self.db_param_precision = ['ms','us','ns'] self.db_param_precision = ['ms','us','ns']
self.time_unit = ['1w','1d','1h','1m','1s','1a','1u','1b'] self.time_unit = ['1w','1d','1h','1m','1s','1a','1u','1b']
self.error_unit = ['2w','2d','2h','2m','2s','2a','2u','1c','#1'] self.error_unit = ['2w','2d','2h','2m','2s','2a','2u','1c','#1']
self.error_unit = ['2w','2d','2h','2m','2s','2a','2u','1c','#1']
self.ntbname = 'ntb' self.ntbname = 'ntb'
self.stbname = 'stb' self.stbname = 'stb'
self.ctbname = 'ctb' self.ctbname = 'ctb'

View File

@ -29,6 +29,7 @@ python3 ./test.py -f 1-insert/block_wise.py
python3 ./test.py -f 1-insert/create_retentions.py python3 ./test.py -f 1-insert/create_retentions.py
#python3 ./test.py -f 1-insert/table_param_ttl.py #python3 ./test.py -f 1-insert/table_param_ttl.py
python3 ./test.py -f 2-query/between.py python3 ./test.py -f 2-query/between.py
python3 ./test.py -f 2-query/distinct.py python3 ./test.py -f 2-query/distinct.py
python3 ./test.py -f 2-query/varchar.py python3 ./test.py -f 2-query/varchar.py
@ -53,6 +54,7 @@ python3 ./test.py -f 2-query/spread.py
python3 ./test.py -f 2-query/hyperloglog.py python3 ./test.py -f 2-query/hyperloglog.py
python3 ./test.py -f 2-query/explain.py python3 ./test.py -f 2-query/explain.py
python3 ./test.py -f 2-query/leastsquares.py python3 ./test.py -f 2-query/leastsquares.py
python3 ./test.py -f 2-query/histogram.py
python3 ./test.py -f 2-query/timezone.py python3 ./test.py -f 2-query/timezone.py
@ -118,7 +120,7 @@ python3 ./test.py -f 2-query/twa.py
python3 ./test.py -f 2-query/irate.py python3 ./test.py -f 2-query/irate.py
python3 ./test.py -f 2-query/function_null.py python3 ./test.py -f 2-query/function_null.py
#python3 ./test.py -f 2-query/queryQnode.py python3 ./test.py -f 2-query/queryQnode.py
#python3 ./test.py -f 6-cluster/5dnode1mnode.py #python3 ./test.py -f 6-cluster/5dnode1mnode.py
#python3 ./test.py -f 6-cluster/5dnode2mnode.py -N 5 -M 3 #python3 ./test.py -f 6-cluster/5dnode2mnode.py -N 5 -M 3
@ -172,3 +174,176 @@ python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-1ctb-funcNFilter.py
python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb-funcNFilter.py
python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py python3 ./test.py -f 7-tmq/tmqConsFromTsdb1-mutilVg-mutilCtb.py
#------------querPolicy 2-----------
python3 ./test.py -f 2-query/between.py -Q 2
python3 ./test.py -f 2-query/distinct.py -Q 2
python3 ./test.py -f 2-query/varchar.py -Q 2
python3 ./test.py -f 2-query/ltrim.py -Q 2
python3 ./test.py -f 2-query/rtrim.py -Q 2
python3 ./test.py -f 2-query/length.py -Q 2
python3 ./test.py -f 2-query/char_length.py -Q 2
python3 ./test.py -f 2-query/upper.py -Q 2
python3 ./test.py -f 2-query/lower.py -Q 2
python3 ./test.py -f 2-query/join.py -Q 2
python3 ./test.py -f 2-query/join2.py -Q 2
python3 ./test.py -f 2-query/cast.py -Q 2
python3 ./test.py -f 2-query/substr.py -Q 2
python3 ./test.py -f 2-query/union.py -Q 2
python3 ./test.py -f 2-query/union1.py -Q 2
python3 ./test.py -f 2-query/concat.py -Q 2
python3 ./test.py -f 2-query/concat2.py -Q 2
python3 ./test.py -f 2-query/concat_ws.py -Q 2
python3 ./test.py -f 2-query/concat_ws2.py -Q 2
python3 ./test.py -f 2-query/check_tsdb.py -Q 2
python3 ./test.py -f 2-query/spread.py -Q 2
python3 ./test.py -f 2-query/hyperloglog.py -Q 2
python3 ./test.py -f 2-query/explain.py -Q 2
python3 ./test.py -f 2-query/leastsquares.py -Q 2
python3 ./test.py -f 2-query/timezone.py -Q 2
python3 ./test.py -f 2-query/Now.py -Q 2
python3 ./test.py -f 2-query/Today.py -Q 2
python3 ./test.py -f 2-query/max.py -Q 2
python3 ./test.py -f 2-query/min.py -Q 2
python3 ./test.py -f 2-query/count.py -Q 2
python3 ./test.py -f 2-query/last.py -Q 2
python3 ./test.py -f 2-query/first.py -Q 2
python3 ./test.py -f 2-query/To_iso8601.py -Q 2
python3 ./test.py -f 2-query/To_unixtimestamp.py -Q 2
python3 ./test.py -f 2-query/timetruncate.py -Q 2
python3 ./test.py -f 2-query/diff.py -Q 2
python3 ./test.py -f 2-query/Timediff.py -Q 2
python3 ./test.py -f 2-query/json_tag.py -Q 2
python3 ./test.py -f 2-query/top.py -Q 2
python3 ./test.py -f 2-query/bottom.py -Q 2
python3 ./test.py -f 2-query/percentile.py -Q 2
python3 ./test.py -f 2-query/apercentile.py -Q 2
python3 ./test.py -f 2-query/abs.py -Q 2
python3 ./test.py -f 2-query/ceil.py -Q 2
python3 ./test.py -f 2-query/floor.py -Q 2
python3 ./test.py -f 2-query/round.py -Q 2
python3 ./test.py -f 2-query/log.py -Q 2
python3 ./test.py -f 2-query/pow.py -Q 2
python3 ./test.py -f 2-query/sqrt.py -Q 2
python3 ./test.py -f 2-query/sin.py -Q 2
python3 ./test.py -f 2-query/cos.py -Q 2
python3 ./test.py -f 2-query/tan.py -Q 2
python3 ./test.py -f 2-query/arcsin.py -Q 2
python3 ./test.py -f 2-query/arccos.py -Q 2
python3 ./test.py -f 2-query/arctan.py -Q 2
python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 2
# python3 ./test.py -f 2-query/nestedQuery.py -Q 2
# python3 ./test.py -f 2-query/nestedQuery_str.py -Q 2
python3 ./test.py -f 2-query/avg.py -Q 2
# python3 ./test.py -f 2-query/elapsed.py -Q 2
python3 ./test.py -f 2-query/csum.py -Q 2
python3 ./test.py -f 2-query/mavg.py -Q 2
python3 ./test.py -f 2-query/diff.py -Q 2
python3 ./test.py -f 2-query/sample.py -Q 2
python3 ./test.py -f 2-query/function_diff.py -Q 2
python3 ./test.py -f 2-query/unique.py -Q 2
python3 ./test.py -f 2-query/stateduration.py -Q 2
python3 ./test.py -f 2-query/function_stateduration.py -Q 2
python3 ./test.py -f 2-query/statecount.py -Q 2
python3 ./test.py -f 2-query/tail.py -Q 2
python3 ./test.py -f 2-query/ttl_comment.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_count.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_max.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_min.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_sum.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_spread.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_apercentile.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_avg.py -Q 2
python3 ./test.py -f 2-query/distribute_agg_stddev.py -Q 2
python3 ./test.py -f 2-query/twa.py -Q 2
python3 ./test.py -f 2-query/irate.py -Q 2
python3 ./test.py -f 2-query/function_null.py -Q 2
#------------querPolicy 3-----------
python3 ./test.py -f 2-query/between.py -Q 3
python3 ./test.py -f 2-query/distinct.py -Q 3
python3 ./test.py -f 2-query/varchar.py -Q 3
python3 ./test.py -f 2-query/ltrim.py -Q 3
python3 ./test.py -f 2-query/rtrim.py -Q 3
python3 ./test.py -f 2-query/length.py -Q 3
python3 ./test.py -f 2-query/char_length.py -Q 3
python3 ./test.py -f 2-query/upper.py -Q 3
python3 ./test.py -f 2-query/lower.py -Q 3
python3 ./test.py -f 2-query/join.py -Q 3
python3 ./test.py -f 2-query/join2.py -Q 3
python3 ./test.py -f 2-query/cast.py -Q 3
python3 ./test.py -f 2-query/substr.py -Q 3
python3 ./test.py -f 2-query/union.py -Q 3
python3 ./test.py -f 2-query/union1.py -Q 3
python3 ./test.py -f 2-query/concat.py -Q 3
python3 ./test.py -f 2-query/concat2.py -Q 3
python3 ./test.py -f 2-query/concat_ws.py -Q 3
python3 ./test.py -f 2-query/concat_ws2.py -Q 3
python3 ./test.py -f 2-query/check_tsdb.py -Q 3
python3 ./test.py -f 2-query/spread.py -Q 3
python3 ./test.py -f 2-query/hyperloglog.py -Q 3
python3 ./test.py -f 2-query/explain.py -Q 3
python3 ./test.py -f 2-query/leastsquares.py -Q 3
python3 ./test.py -f 2-query/timezone.py -Q 3
python3 ./test.py -f 2-query/Now.py -Q 3
python3 ./test.py -f 2-query/Today.py -Q 3
python3 ./test.py -f 2-query/max.py -Q 3
python3 ./test.py -f 2-query/min.py -Q 3
python3 ./test.py -f 2-query/count.py -Q 3
python3 ./test.py -f 2-query/last.py -Q 3
python3 ./test.py -f 2-query/first.py -Q 3
python3 ./test.py -f 2-query/To_iso8601.py -Q 3
python3 ./test.py -f 2-query/To_unixtimestamp.py -Q 3
python3 ./test.py -f 2-query/timetruncate.py -Q 3
python3 ./test.py -f 2-query/diff.py -Q 3
python3 ./test.py -f 2-query/Timediff.py -Q 3
python3 ./test.py -f 2-query/json_tag.py -Q 3
python3 ./test.py -f 2-query/top.py -Q 3
python3 ./test.py -f 2-query/bottom.py -Q 3
python3 ./test.py -f 2-query/percentile.py -Q 3
python3 ./test.py -f 2-query/apercentile.py -Q 3
python3 ./test.py -f 2-query/abs.py -Q 3
python3 ./test.py -f 2-query/ceil.py -Q 3
python3 ./test.py -f 2-query/floor.py -Q 3
python3 ./test.py -f 2-query/round.py -Q 3
python3 ./test.py -f 2-query/log.py -Q 3
python3 ./test.py -f 2-query/pow.py -Q 3
python3 ./test.py -f 2-query/sqrt.py -Q 3
python3 ./test.py -f 2-query/sin.py -Q 3
python3 ./test.py -f 2-query/cos.py -Q 3
python3 ./test.py -f 2-query/tan.py -Q 3
python3 ./test.py -f 2-query/arcsin.py -Q 3
python3 ./test.py -f 2-query/arccos.py -Q 3
python3 ./test.py -f 2-query/arctan.py -Q 3
python3 ./test.py -f 2-query/query_cols_tags_and_or.py -Q 3
# python3 ./test.py -f 2-query/nestedQuery.py -Q 3
# python3 ./test.py -f 2-query/nestedQuery_str.py -Q 3
# python3 ./test.py -f 2-query/avg.py -Q 3
# python3 ./test.py -f 2-query/elapsed.py -Q 3
python3 ./test.py -f 2-query/csum.py -Q 3
python3 ./test.py -f 2-query/mavg.py -Q 3
python3 ./test.py -f 2-query/diff.py -Q 3
python3 ./test.py -f 2-query/sample.py -Q 3
python3 ./test.py -f 2-query/function_diff.py -Q 3
python3 ./test.py -f 2-query/unique.py -Q 3
python3 ./test.py -f 2-query/stateduration.py -Q 3
python3 ./test.py -f 2-query/function_stateduration.py -Q 3
python3 ./test.py -f 2-query/statecount.py -Q 3
python3 ./test.py -f 2-query/tail.py -Q 3
python3 ./test.py -f 2-query/ttl_comment.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_count.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_max.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_min.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_sum.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_spread.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_apercentile.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_avg.py -Q 3
python3 ./test.py -f 2-query/distribute_agg_stddev.py -Q 3
python3 ./test.py -f 2-query/twa.py -Q 3
python3 ./test.py -f 2-query/irate.py -Q 3
python3 ./test.py -f 2-query/function_null.py -Q 3

View File

@ -44,27 +44,27 @@ static int32_t shellParseSingleOpt(int32_t key, char *arg);
void shellPrintHelp() { void shellPrintHelp() {
char indent[] = " "; char indent[] = " ";
printf("Usage: taos [OPTION...] \n\n"); printf("Usage: taos [OPTION...] \r\n\r\n");
printf("%s%s%s%s\n", indent, "-a,", indent, SHELL_AUTH); printf("%s%s%s%s\r\n", indent, "-a,", indent, SHELL_AUTH);
printf("%s%s%s%s\n", indent, "-A,", indent, SHELL_GEN_AUTH); printf("%s%s%s%s\r\n", indent, "-A,", indent, SHELL_GEN_AUTH);
printf("%s%s%s%s\n", indent, "-c,", indent, SHELL_CFG_DIR); printf("%s%s%s%s\r\n", indent, "-c,", indent, SHELL_CFG_DIR);
printf("%s%s%s%s\n", indent, "-C,", indent, SHELL_DMP_CFG); printf("%s%s%s%s\r\n", indent, "-C,", indent, SHELL_DMP_CFG);
printf("%s%s%s%s\n", indent, "-d,", indent, SHELL_DB); printf("%s%s%s%s\r\n", indent, "-d,", indent, SHELL_DB);
printf("%s%s%s%s\n", indent, "-f,", indent, SHELL_FILE); printf("%s%s%s%s\r\n", indent, "-f,", indent, SHELL_FILE);
printf("%s%s%s%s\n", indent, "-h,", indent, SHELL_HOST); printf("%s%s%s%s\r\n", indent, "-h,", indent, SHELL_HOST);
printf("%s%s%s%s\n", indent, "-k,", indent, SHELL_CHECK); printf("%s%s%s%s\r\n", indent, "-k,", indent, SHELL_CHECK);
printf("%s%s%s%s\n", indent, "-l,", indent, SHELL_PKG_LEN); printf("%s%s%s%s\r\n", indent, "-l,", indent, SHELL_PKG_LEN);
printf("%s%s%s%s\n", indent, "-n,", indent, SHELL_NET_ROLE); printf("%s%s%s%s\r\n", indent, "-n,", indent, SHELL_NET_ROLE);
printf("%s%s%s%s\n", indent, "-N,", indent, SHELL_PKT_NUM); printf("%s%s%s%s\r\n", indent, "-N,", indent, SHELL_PKT_NUM);
printf("%s%s%s%s\n", indent, "-p,", indent, SHELL_PASSWORD); printf("%s%s%s%s\r\n", indent, "-p,", indent, SHELL_PASSWORD);
printf("%s%s%s%s\n", indent, "-P,", indent, SHELL_PORT); printf("%s%s%s%s\r\n", indent, "-P,", indent, SHELL_PORT);
printf("%s%s%s%s\n", indent, "-r,", indent, SHELL_RAW_TIME); printf("%s%s%s%s\r\n", indent, "-r,", indent, SHELL_RAW_TIME);
printf("%s%s%s%s\n", indent, "-s,", indent, SHELL_CMD); printf("%s%s%s%s\r\n", indent, "-s,", indent, SHELL_CMD);
printf("%s%s%s%s\n", indent, "-t,", indent, SHELL_STARTUP); printf("%s%s%s%s\r\n", indent, "-t,", indent, SHELL_STARTUP);
printf("%s%s%s%s\n", indent, "-u,", indent, SHELL_USER); printf("%s%s%s%s\r\n", indent, "-u,", indent, SHELL_USER);
printf("%s%s%s%s\n", indent, "-w,", indent, SHELL_WIDTH); printf("%s%s%s%s\r\n", indent, "-w,", indent, SHELL_WIDTH);
printf("%s%s%s%s\n", indent, "-V,", indent, SHELL_VERSION); printf("%s%s%s%s\r\n", indent, "-V,", indent, SHELL_VERSION);
printf("\n\nReport bugs to %s.\n", SHELL_EMAIL); printf("\r\n\r\nReport bugs to %s.\r\n", SHELL_EMAIL);
} }
#ifdef LINUX #ifdef LINUX
@ -196,23 +196,23 @@ int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) {
char *key = argv[i]; char *key = argv[i];
int32_t keyLen = strlen(key); int32_t keyLen = strlen(key);
if (keyLen != 2) { if (keyLen != 2) {
fprintf(stderr, "invalid option %s\n", key); fprintf(stderr, "invalid option %s\r\n", key);
return -1; return -1;
} }
if (key[0] != '-') { if (key[0] != '-') {
fprintf(stderr, "invalid option %s\n", key); fprintf(stderr, "invalid option %s\r\n", key);
return -1; return -1;
} }
if (key[1] == 'h' || key[1] == 'P' || key[1] == 'u' || key[1] == 'a' || key[1] == 'c' || key[1] == 's' || if (key[1] == 'h' || key[1] == 'P' || key[1] == 'u' || key[1] == 'a' || key[1] == 'c' || key[1] == 's' ||
key[1] == 'f' || key[1] == 'd' || key[1] == 'w' || key[1] == 'n' || key[1] == 'l' || key[1] == 'N') { key[1] == 'f' || key[1] == 'd' || key[1] == 'w' || key[1] == 'n' || key[1] == 'l' || key[1] == 'N') {
if (i + 1 >= argc) { if (i + 1 >= argc) {
fprintf(stderr, "option %s requires an argument\n", key); fprintf(stderr, "option %s requires an argument\r\n", key);
return -1; return -1;
} }
char *val = argv[i + 1]; char *val = argv[i + 1];
if (val[0] == '-') { if (val[0] == '-') {
fprintf(stderr, "option %s requires an argument\n", key); fprintf(stderr, "option %s requires an argument\r\n", key);
return -1; return -1;
} }
shellParseSingleOpt(key[1], val); shellParseSingleOpt(key[1], val);
@ -221,7 +221,7 @@ int32_t shellParseArgsWithoutArgp(int argc, char *argv[]) {
key[1] == 't' || key[1] == 'V' || key[1] == '?' || key[1] == 1) { key[1] == 't' || key[1] == 'V' || key[1] == '?' || key[1] == 1) {
shellParseSingleOpt(key[1], NULL); shellParseSingleOpt(key[1], NULL);
} else { } else {
fprintf(stderr, "invalid option %s\n", key); fprintf(stderr, "invalid option %s\r\n", key);
return -1; return -1;
} }
} }
@ -241,7 +241,7 @@ static void shellInitArgs(int argc, char *argv[]) {
} }
taosSetConsoleEcho(true); taosSetConsoleEcho(true);
if (EOF == getchar()) { if (EOF == getchar()) {
fprintf(stderr, "getchar() return EOF\n"); fprintf(stderr, "getchar() return EOF\r\n");
} }
} else { } else {
tstrncpy(shell.args.password, (char *)(argv[i] + 2), sizeof(shell.args.password)); tstrncpy(shell.args.password, (char *)(argv[i] + 2), sizeof(shell.args.password));
@ -263,22 +263,22 @@ static void shellInitArgs(int argc, char *argv[]) {
static int32_t shellCheckArgs() { static int32_t shellCheckArgs() {
SShellArgs *pArgs = &shell.args; SShellArgs *pArgs = &shell.args;
if (pArgs->host != NULL && (strlen(pArgs->host) <= 0 || strlen(pArgs->host) > TSDB_FQDN_LEN)) { if (pArgs->host != NULL && (strlen(pArgs->host) <= 0 || strlen(pArgs->host) > TSDB_FQDN_LEN)) {
printf("Invalid host:%s\n", pArgs->host); printf("Invalid host:%s\r\n", pArgs->host);
return -1; return -1;
} }
if (pArgs->user != NULL && (strlen(pArgs->user) <= 0 || strlen(pArgs->user) > TSDB_USER_LEN)) { if (pArgs->user != NULL && (strlen(pArgs->user) <= 0 || strlen(pArgs->user) > TSDB_USER_LEN)) {
printf("Invalid user:%s\n", pArgs->user); printf("Invalid user:%s\r\n", pArgs->user);
return -1; return -1;
} }
if (pArgs->auth != NULL && (strlen(pArgs->auth) <= 0 || strlen(pArgs->auth) > TSDB_PASSWORD_LEN)) { if (pArgs->auth != NULL && (strlen(pArgs->auth) <= 0 || strlen(pArgs->auth) > TSDB_PASSWORD_LEN)) {
printf("Invalid auth:%s\n", pArgs->auth); printf("Invalid auth:%s\r\n", pArgs->auth);
return -1; return -1;
} }
if (pArgs->database != NULL && (strlen(pArgs->database) <= 0 || strlen(pArgs->database) > TSDB_DB_NAME_LEN)) { if (pArgs->database != NULL && (strlen(pArgs->database) <= 0 || strlen(pArgs->database) > TSDB_DB_NAME_LEN)) {
printf("Invalid database:%s\n", pArgs->database); printf("Invalid database:%s\r\n", pArgs->database);
return -1; return -1;
} }
@ -291,7 +291,7 @@ static int32_t shellCheckArgs() {
if (pArgs->cfgdir != NULL) { if (pArgs->cfgdir != NULL) {
if (strlen(pArgs->cfgdir) <= 0 || strlen(pArgs->cfgdir) >= PATH_MAX) { if (strlen(pArgs->cfgdir) <= 0 || strlen(pArgs->cfgdir) >= PATH_MAX) {
printf("Invalid cfgdir:%s\n", pArgs->cfgdir); printf("Invalid cfgdir:%s\r\n", pArgs->cfgdir);
return -1; return -1;
} else { } else {
if (taosExpandDir(pArgs->cfgdir, configDir, PATH_MAX) != 0) { if (taosExpandDir(pArgs->cfgdir, configDir, PATH_MAX) != 0) {
@ -301,37 +301,37 @@ static int32_t shellCheckArgs() {
} }
if (pArgs->commands != NULL && (strlen(pArgs->commands) <= 0)) { if (pArgs->commands != NULL && (strlen(pArgs->commands) <= 0)) {
printf("Invalid commands:%s\n", pArgs->commands); printf("Invalid commands:%s\r\n", pArgs->commands);
return -1; return -1;
} }
if (pArgs->netrole != NULL && !(strcmp(pArgs->netrole, "client") == 0 || strcmp(pArgs->netrole, "server") == 0)) { if (pArgs->netrole != NULL && !(strcmp(pArgs->netrole, "client") == 0 || strcmp(pArgs->netrole, "server") == 0)) {
printf("Invalid netrole:%s\n", pArgs->netrole); printf("Invalid netrole:%s\r\n", pArgs->netrole);
return -1; return -1;
} }
if (pArgs->password != NULL && (strlen(pArgs->password) <= 0)) { if (pArgs->password != NULL && (strlen(pArgs->password) <= 0)) {
printf("Invalid password\n"); printf("Invalid password\r\n");
return -1; return -1;
} }
if (pArgs->port < 0 || pArgs->port > 65535) { if (pArgs->port < 0 || pArgs->port > 65535) {
printf("Invalid port\n"); printf("Invalid port\r\n");
return -1; return -1;
} }
if (pArgs->pktLen < SHELL_MIN_PKG_LEN || pArgs->pktLen > SHELL_MAX_PKG_LEN) { if (pArgs->pktLen < SHELL_MIN_PKG_LEN || pArgs->pktLen > SHELL_MAX_PKG_LEN) {
printf("Invalid pktLen:%d, range:[%d, %d]\n", pArgs->pktLen, SHELL_MIN_PKG_LEN, SHELL_MAX_PKG_LEN); printf("Invalid pktLen:%d, range:[%d, %d]\r\n", pArgs->pktLen, SHELL_MIN_PKG_LEN, SHELL_MAX_PKG_LEN);
return -1; return -1;
} }
if (pArgs->pktNum < SHELL_MIN_PKG_NUM || pArgs->pktNum > SHELL_MAX_PKG_NUM) { if (pArgs->pktNum < SHELL_MIN_PKG_NUM || pArgs->pktNum > SHELL_MAX_PKG_NUM) {
printf("Invalid pktNum:%d, range:[%d, %d]\n", pArgs->pktNum, SHELL_MIN_PKG_NUM, SHELL_MAX_PKG_NUM); printf("Invalid pktNum:%d, range:[%d, %d]\r\n", pArgs->pktNum, SHELL_MIN_PKG_NUM, SHELL_MAX_PKG_NUM);
return -1; return -1;
} }
if (pArgs->displayWidth <= 0 || pArgs->displayWidth > 10 * 1024) { if (pArgs->displayWidth <= 0 || pArgs->displayWidth > 10 * 1024) {
printf("Invalid displayWidth:%d, range:[1, 10 * 1024]\n", pArgs->displayWidth); printf("Invalid displayWidth:%d, range:[1, 10 * 1024]\r\n", pArgs->displayWidth);
return -1; return -1;
} }
@ -341,8 +341,8 @@ static int32_t shellCheckArgs() {
int32_t shellParseArgs(int32_t argc, char *argv[]) { int32_t shellParseArgs(int32_t argc, char *argv[]) {
shellInitArgs(argc, argv); shellInitArgs(argc, argv);
shell.info.clientVersion = shell.info.clientVersion =
"Welcome to the TDengine shell from %s, Client Version:%s\n" "Welcome to the TDengine shell from %s, Client Version:%s\r\n"
"Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.\n\n"; "Copyright (c) 2022 by TAOS Data, Inc. All rights reserved.\r\n\r\n";
shell.info.promptHeader = TAOS_CONSOLE_PROMPT_HEADER; shell.info.promptHeader = TAOS_CONSOLE_PROMPT_HEADER;
shell.info.promptContinue = TAOS_CONSOLE_PROMPT_CONTINUE; shell.info.promptContinue = TAOS_CONSOLE_PROMPT_CONTINUE;
shell.info.promptSize = 6; shell.info.promptSize = 6;

View File

@ -314,7 +314,7 @@ void shellGetScreenSize(int32_t *ws_col, int32_t *ws_row) {
#else #else
struct winsize w; struct winsize w;
if (ioctl(0, TIOCGWINSZ, &w) < 0 || w.ws_col == 0 || w.ws_row == 0) { if (ioctl(0, TIOCGWINSZ, &w) < 0 || w.ws_col == 0 || w.ws_row == 0) {
// fprintf(stderr, "No stream device, and use default value(col 120, row 30)\n"); // fprintf(stderr, "No stream device, and use default value(col 120, row 30)\r\n");
if (ws_col != NULL) *ws_col = 120; if (ws_col != NULL) *ws_col = 120;
if (ws_row != NULL) *ws_row = 30; if (ws_row != NULL) *ws_row = 30;
} else { } else {
@ -473,7 +473,7 @@ int32_t shellReadCommand(char *command) {
shellPositionCursorHome(&cmd); shellPositionCursorHome(&cmd);
break; break;
case 3: case 3:
printf("\n"); printf("\r\n");
shellResetCommand(&cmd, ""); shellResetCommand(&cmd, "");
#ifdef WINDOWS #ifdef WINDOWS
raise(SIGINT); raise(SIGINT);
@ -483,7 +483,7 @@ int32_t shellReadCommand(char *command) {
break; break;
case 4: // EOF or Ctrl+D case 4: // EOF or Ctrl+D
taosResetTerminalMode(); taosResetTerminalMode();
printf("\n"); printf("\r\n");
return -1; return -1;
case 5: // ctrl E case 5: // ctrl E
shellPositionCursorEnd(&cmd); shellPositionCursorEnd(&cmd);
@ -495,7 +495,7 @@ int32_t shellReadCommand(char *command) {
case '\r': case '\r':
#ifdef WINDOWS #ifdef WINDOWS
#else #else
printf("\n"); printf("\r\n");
#endif #endif
if (shellIsReadyGo(&cmd)) { if (shellIsReadyGo(&cmd)) {
sprintf(command, "%s%s", cmd.buffer, cmd.command); sprintf(command, "%s%s", cmd.buffer, cmd.command);

View File

@ -180,7 +180,7 @@ void shellRunSingleCommandImp(char *command) {
} }
if (shellRegexMatch(command, "^\\s*use\\s+[a-zA-Z0-9_]+\\s*;\\s*$", REG_EXTENDED | REG_ICASE)) { if (shellRegexMatch(command, "^\\s*use\\s+[a-zA-Z0-9_]+\\s*;\\s*$", REG_EXTENDED | REG_ICASE)) {
fprintf(stdout, "Database changed.\n\n"); fprintf(stdout, "Database changed.\r\n\r\n");
fflush(stdout); fflush(stdout);
taos_free_result(pSql); taos_free_result(pSql);
@ -197,19 +197,19 @@ void shellRunSingleCommandImp(char *command) {
et = taosGetTimestampUs(); et = taosGetTimestampUs();
if (error_no == 0) { if (error_no == 0) {
printf("Query OK, %d rows affected (%.6fs)\n", numOfRows, (et - st) / 1E6); printf("Query OK, %d rows affected (%.6fs)\r\n", numOfRows, (et - st) / 1E6);
} else { } else {
printf("Query interrupted (%s), %d rows affected (%.6fs)\n", taos_errstr(pSql), numOfRows, (et - st) / 1E6); printf("Query interrupted (%s), %d rows affected (%.6fs)\r\n", taos_errstr(pSql), numOfRows, (et - st) / 1E6);
} }
taos_free_result(pSql); taos_free_result(pSql);
} else { } else {
int32_t num_rows_affacted = taos_affected_rows(pSql); int32_t num_rows_affacted = taos_affected_rows(pSql);
taos_free_result(pSql); taos_free_result(pSql);
et = taosGetTimestampUs(); et = taosGetTimestampUs();
printf("Query OK, %d of %d rows affected (%.6fs)\n", num_rows_affacted, num_rows_affacted, (et - st) / 1E6); printf("Query OK, %d of %d rows affected (%.6fs)\r\n", num_rows_affacted, num_rows_affacted, (et - st) / 1E6);
} }
printf("\n"); printf("\r\n");
} }
char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) { char *shellFormatTimestamp(char *buf, int64_t val, int32_t precision) {
@ -344,7 +344,7 @@ int32_t shellDumpResultToFile(const char *fname, TAOS_RES *tres) {
TdFilePtr pFile = taosOpenFile(fullname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM); TdFilePtr pFile = taosOpenFile(fullname, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC | TD_FILE_STREAM);
if (pFile == NULL) { if (pFile == NULL) {
fprintf(stderr, "failed to open file: %s\n", fullname); fprintf(stderr, "failed to open file: %s\r\n", fullname);
return -1; return -1;
} }
@ -358,7 +358,7 @@ int32_t shellDumpResultToFile(const char *fname, TAOS_RES *tres) {
} }
taosFprintfFile(pFile, "%s", fields[col].name); taosFprintfFile(pFile, "%s", fields[col].name);
} }
taosFprintfFile(pFile, "\n"); taosFprintfFile(pFile, "\r\n");
int32_t numOfRows = 0; int32_t numOfRows = 0;
do { do {
@ -369,7 +369,7 @@ int32_t shellDumpResultToFile(const char *fname, TAOS_RES *tres) {
} }
shellDumpFieldToFile(pFile, (const char *)row[i], fields + i, length[i], precision); shellDumpFieldToFile(pFile, (const char *)row[i], fields + i, length[i], precision);
} }
taosFprintfFile(pFile, "\n"); taosFprintfFile(pFile, "\r\n");
numOfRows++; numOfRows++;
row = taos_fetch_row(tres); row = taos_fetch_row(tres);
@ -559,7 +559,7 @@ int32_t shellVerticalPrintResult(TAOS_RES *tres, const char *sql) {
int32_t showMore = 1; int32_t showMore = 1;
do { do {
if (numOfRows < resShowMaxNum) { if (numOfRows < resShowMaxNum) {
printf("*************************** %d.row ***************************\n", numOfRows + 1); printf("*************************** %d.row ***************************\r\n", numOfRows + 1);
int32_t *length = taos_fetch_lengths(tres); int32_t *length = taos_fetch_lengths(tres);
@ -570,16 +570,17 @@ int32_t shellVerticalPrintResult(TAOS_RES *tres, const char *sql) {
printf("%*.s%s: ", padding, " ", field->name); printf("%*.s%s: ", padding, " ", field->name);
shellPrintField((const char *)row[i], field, 0, length[i], precision); shellPrintField((const char *)row[i], field, 0, length[i], precision);
putchar('\r');
putchar('\n'); putchar('\n');
} }
} else if (showMore) { } else if (showMore) {
printf("\n"); printf("\r\n");
printf(" Notice: The result shows only the first %d rows.\n", SHELL_DEFAULT_RES_SHOW_NUM); printf(" Notice: The result shows only the first %d rows.\r\n", SHELL_DEFAULT_RES_SHOW_NUM);
printf(" You can use the `LIMIT` clause to get fewer result to show.\n"); printf(" You can use the `LIMIT` clause to get fewer result to show.\r\n");
printf(" Or use '>>' to redirect the whole set of the result to a specified file.\n"); printf(" Or use '>>' to redirect the whole set of the result to a specified file.\r\n");
printf("\n"); printf("\r\n");
printf(" You can use Ctrl+C to stop the underway fetching.\n"); printf(" You can use Ctrl+C to stop the underway fetching.\r\n");
printf("\n"); printf("\r\n");
showMore = 0; showMore = 0;
} }
@ -667,10 +668,12 @@ void shellPrintHeader(TAOS_FIELD *fields, int32_t *width, int32_t num_fields) {
rowWidth += width[col] + 3; rowWidth += width[col] + 3;
} }
putchar('\r');
putchar('\n'); putchar('\n');
for (int32_t i = 0; i < rowWidth; i++) { for (int32_t i = 0; i < rowWidth; i++) {
putchar('='); putchar('=');
} }
putchar('\r');
putchar('\n'); putchar('\n');
} }
@ -709,15 +712,16 @@ int32_t shellHorizontalPrintResult(TAOS_RES *tres, const char *sql) {
putchar(' '); putchar(' ');
putchar('|'); putchar('|');
} }
putchar('\r');
putchar('\n'); putchar('\n');
} else if (showMore) { } else if (showMore) {
printf("\n"); printf("\r\n");
printf(" Notice: The result shows only the first %d rows.\n", SHELL_DEFAULT_RES_SHOW_NUM); printf(" Notice: The result shows only the first %d rows.\r\n", SHELL_DEFAULT_RES_SHOW_NUM);
printf(" You can use the `LIMIT` clause to get fewer result to show.\n"); printf(" You can use the `LIMIT` clause to get fewer result to show.\r\n");
printf(" Or use '>>' to redirect the whole set of the result to a specified file.\n"); printf(" Or use '>>' to redirect the whole set of the result to a specified file.\r\n");
printf("\n"); printf("\r\n");
printf(" You can use Ctrl+C to stop the underway fetching.\n"); printf(" You can use Ctrl+C to stop the underway fetching.\r\n");
printf("\n"); printf("\r\n");
showMore = 0; showMore = 0;
} }
@ -794,7 +798,7 @@ void shellCleanupHistory() {
void shellPrintError(TAOS_RES *tres, int64_t st) { void shellPrintError(TAOS_RES *tres, int64_t st) {
int64_t et = taosGetTimestampUs(); int64_t et = taosGetTimestampUs();
fprintf(stderr, "\nDB error: %s (%.6fs)\n", taos_errstr(tres), (et - st) / 1E6); fprintf(stderr, "\r\nDB error: %s (%.6fs)\r\n", taos_errstr(tres), (et - st) / 1E6);
taos_free_result(tres); taos_free_result(tres);
} }
@ -816,7 +820,7 @@ void shellSourceFile(const char *file) {
TdFilePtr pFile = taosOpenFile(fullname, TD_FILE_READ | TD_FILE_STREAM); TdFilePtr pFile = taosOpenFile(fullname, TD_FILE_READ | TD_FILE_STREAM);
if (pFile == NULL) { if (pFile == NULL) {
fprintf(stderr, "failed to open file %s\n", fullname); fprintf(stderr, "failed to open file %s\r\n", fullname);
taosMemoryFree(cmd); taosMemoryFree(cmd);
return; return;
} }
@ -837,7 +841,7 @@ void shellSourceFile(const char *file) {
} }
memcpy(cmd + cmd_len, line, read_len); memcpy(cmd + cmd_len, line, read_len);
printf("%s%s\n", shell.info.promptHeader, cmd); printf("%s%s\r\n", shell.info.promptHeader, cmd);
shellRunCommand(cmd); shellRunCommand(cmd);
memset(cmd, 0, TSDB_MAX_ALLOWED_SQL_LEN); memset(cmd, 0, TSDB_MAX_ALLOWED_SQL_LEN);
cmd_len = 0; cmd_len = 0;
@ -851,7 +855,7 @@ void shellSourceFile(const char *file) {
void shellGetGrantInfo() { void shellGetGrantInfo() {
char sinfo[1024] = {0}; char sinfo[1024] = {0};
tstrncpy(sinfo, taos_get_server_info(shell.conn), sizeof(sinfo)); tstrncpy(sinfo, taos_get_server_info(shell.conn), sizeof(sinfo));
strtok(sinfo, "\n"); strtok(sinfo, "\r\n");
char sql[] = "show grants"; char sql[] = "show grants";
@ -860,25 +864,25 @@ void shellGetGrantInfo() {
int32_t code = taos_errno(tres); int32_t code = taos_errno(tres);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
if (code != TSDB_CODE_OPS_NOT_SUPPORT && code != TSDB_CODE_MND_NO_RIGHTS) { if (code != TSDB_CODE_OPS_NOT_SUPPORT && code != TSDB_CODE_MND_NO_RIGHTS) {
fprintf(stderr, "Failed to check Server Edition, Reason:0x%04x:%s\n\n", code, taos_errstr(tres)); fprintf(stderr, "Failed to check Server Edition, Reason:0x%04x:%s\r\n\r\n", code, taos_errstr(tres));
} }
return; return;
} }
int32_t num_fields = taos_field_count(tres); int32_t num_fields = taos_field_count(tres);
if (num_fields == 0) { if (num_fields == 0) {
fprintf(stderr, "\nInvalid grant information.\n"); fprintf(stderr, "\r\nInvalid grant information.\r\n");
exit(0); exit(0);
} else { } else {
if (tres == NULL) { if (tres == NULL) {
fprintf(stderr, "\nGrant information is null.\n"); fprintf(stderr, "\r\nGrant information is null.\r\n");
exit(0); exit(0);
} }
TAOS_FIELD *fields = taos_fetch_fields(tres); TAOS_FIELD *fields = taos_fetch_fields(tres);
TAOS_ROW row = taos_fetch_row(tres); TAOS_ROW row = taos_fetch_row(tres);
if (row == NULL) { if (row == NULL) {
fprintf(stderr, "\nFailed to get grant information from server. Abort.\n"); fprintf(stderr, "\r\nFailed to get grant information from server. Abort.\r\n");
exit(0); exit(0);
} }
@ -891,17 +895,17 @@ void shellGetGrantInfo() {
memcpy(expired, row[2], fields[2].bytes); memcpy(expired, row[2], fields[2].bytes);
if (strcmp(serverVersion, "community") == 0) { if (strcmp(serverVersion, "community") == 0) {
fprintf(stdout, "Server is Community Edition.\n"); fprintf(stdout, "Server is Community Edition.\r\n");
} else if (strcmp(expiretime, "unlimited") == 0) { } else if (strcmp(expiretime, "unlimited") == 0) {
fprintf(stdout, "Server is Enterprise %s Edition, %s and will never expire.\n", serverVersion, sinfo); fprintf(stdout, "Server is Enterprise %s Edition, %s and will never expire.\r\n", serverVersion, sinfo);
} else { } else {
fprintf(stdout, "Server is Enterprise %s Edition, %s and will expire at %s.\n", serverVersion, sinfo, expiretime); fprintf(stdout, "Server is Enterprise %s Edition, %s and will expire at %s.\r\n", serverVersion, sinfo, expiretime);
} }
taos_free_result(tres); taos_free_result(tres);
} }
fprintf(stdout, "\n"); fprintf(stdout, "\r\n");
} }
void shellQueryInterruptHandler(int32_t signum, void *sigInfo, void *context) { tsem_post(&shell.cancelSem); } void shellQueryInterruptHandler(int32_t signum, void *sigInfo, void *context) { tsem_post(&shell.cancelSem); }
@ -921,7 +925,7 @@ void *shellCancelHandler(void *arg) {
} }
taosResetTerminalMode(); taosResetTerminalMode();
printf("\nReceive SIGTERM or other signal, quit shell.\n"); printf("\r\nReceive SIGTERM or other signal, quit shell.\r\n");
shellWriteHistory(); shellWriteHistory();
shellExit(); shellExit();
} }
@ -936,7 +940,7 @@ void *shellThreadLoop(void *arg) {
char *command = taosMemoryMalloc(SHELL_MAX_COMMAND_SIZE); char *command = taosMemoryMalloc(SHELL_MAX_COMMAND_SIZE);
if (command == NULL) { if (command == NULL) {
printf("failed to malloc command\n"); printf("failed to malloc command\r\n");
return NULL; return NULL;
} }
@ -979,7 +983,7 @@ int32_t shellExecute() {
if (pArgs->commands != NULL || pArgs->file[0] != 0) { if (pArgs->commands != NULL || pArgs->file[0] != 0) {
if (pArgs->commands != NULL) { if (pArgs->commands != NULL) {
printf("%s%s\n", shell.info.promptHeader, pArgs->commands); printf("%s%s\r\n", shell.info.promptHeader, pArgs->commands);
char *cmd = strdup(pArgs->commands); char *cmd = strdup(pArgs->commands);
shellRunCommand(cmd); shellRunCommand(cmd);
taosMemoryFree(cmd); taosMemoryFree(cmd);
@ -996,7 +1000,7 @@ int32_t shellExecute() {
} }
if (tsem_init(&shell.cancelSem, 0, 0) != 0) { if (tsem_init(&shell.cancelSem, 0, 0) != 0) {
printf("failed to create cancel semphore\n"); printf("failed to create cancel semphore\r\n");
return -1; return -1;
} }

View File

@ -34,7 +34,7 @@ static void shellWorkAsClient() {
clientRpc = rpcOpen(&rpcInit); clientRpc = rpcOpen(&rpcInit);
if (clientRpc == NULL) { if (clientRpc == NULL) {
printf("failed to init net test client since %s\n", terrstr()); printf("failed to init net test client since %s\r\n", terrstr());
goto _OVER; goto _OVER;
} }
@ -49,7 +49,7 @@ static void shellWorkAsClient() {
pArgs->port = tsServerPort; pArgs->port = tsServerPort;
} }
printf("network test client is initialized, the server is %s:%u\n", fqdn, pArgs->port); printf("network test client is initialized, the server is %s:%u\r\n", fqdn, pArgs->port);
tstrncpy(epSet.eps[0].fqdn, fqdn, TSDB_FQDN_LEN); tstrncpy(epSet.eps[0].fqdn, fqdn, TSDB_FQDN_LEN);
epSet.eps[0].port = (uint16_t)pArgs->port; epSet.eps[0].port = (uint16_t)pArgs->port;
@ -62,13 +62,13 @@ static void shellWorkAsClient() {
rpcMsg.pCont = rpcMallocCont(pArgs->pktLen); rpcMsg.pCont = rpcMallocCont(pArgs->pktLen);
rpcMsg.contLen = pArgs->pktLen; rpcMsg.contLen = pArgs->pktLen;
printf("request is sent, size:%d\n", rpcMsg.contLen); printf("request is sent, size:%d\r\n", rpcMsg.contLen);
rpcSendRecv(clientRpc, &epSet, &rpcMsg, &rpcRsp); rpcSendRecv(clientRpc, &epSet, &rpcMsg, &rpcRsp);
if (rpcRsp.code == 0 && rpcRsp.contLen == rpcMsg.contLen) { if (rpcRsp.code == 0 && rpcRsp.contLen == rpcMsg.contLen) {
printf("response is received, size:%d\n", rpcMsg.contLen); printf("response is received, size:%d\r\n", rpcMsg.contLen);
if (rpcRsp.code == 0) totalSucc++; if (rpcRsp.code == 0) totalSucc++;
} else { } else {
printf("response not received since %s\n", tstrerror(rpcRsp.code)); printf("response not received since %s\r\n", tstrerror(rpcRsp.code));
} }
rpcFreeCont(rpcRsp.pCont); rpcFreeCont(rpcRsp.pCont);
@ -78,7 +78,7 @@ static void shellWorkAsClient() {
uint64_t endTime = taosGetTimestampUs(); uint64_t endTime = taosGetTimestampUs();
uint64_t elT = endTime - startTime; uint64_t elT = endTime - startTime;
printf("\ntotal succ:%5d/%d\tcost:%8.2lf ms\tspeed:%8.2lf MB/s\n", totalSucc, pArgs->pktNum, elT / 1000.0, printf("\r\ntotal succ:%5d/%d\tcost:%8.2lf ms\tspeed:%8.2lf MB/s\r\n", totalSucc, pArgs->pktNum, elT / 1000.0,
pArgs->pktLen / (elT / 1000000.0) / 1024.0 / 1024.0 * totalSucc); pArgs->pktLen / (elT / 1000000.0) / 1024.0 / 1024.0 * totalSucc);
_OVER: _OVER:
@ -91,7 +91,7 @@ _OVER:
} }
static void shellProcessMsg(void *p, SRpcMsg *pRpc, SEpSet *pEpSet) { static void shellProcessMsg(void *p, SRpcMsg *pRpc, SEpSet *pEpSet) {
printf("request is received, size:%d\n", pRpc->contLen); printf("request is received, size:%d\r\n", pRpc->contLen);
fflush(stdout); fflush(stdout);
SRpcMsg rsp = {.info = pRpc->info, .code = 0}; SRpcMsg rsp = {.info = pRpc->info, .code = 0};
rsp.pCont = rpcMallocCont(pRpc->contLen); rsp.pCont = rpcMallocCont(pRpc->contLen);
@ -124,9 +124,9 @@ static void shellWorkAsServer() {
void *serverRpc = rpcOpen(&rpcInit); void *serverRpc = rpcOpen(&rpcInit);
if (serverRpc == NULL) { if (serverRpc == NULL) {
printf("failed to init net test server since %s\n", terrstr()); printf("failed to init net test server since %s\r\n", terrstr());
} else { } else {
printf("network test server is initialized, port:%u\n", pArgs->port); printf("network test server is initialized, port:%u\r\n", pArgs->port);
taosSetSignal(SIGTERM, shellNettestHandler); taosSetSignal(SIGTERM, shellNettestHandler);
while (1) taosMsleep(10); while (1) taosMsleep(10);
} }

View File

@ -40,7 +40,7 @@ bool shellRegexMatch(const char *s, const char *reg, int32_t cflags) {
return false; return false;
} else { } else {
regerror(reti, &regex, msgbuf, sizeof(msgbuf)); regerror(reti, &regex, msgbuf, sizeof(msgbuf));
fprintf(stderr, "Regex match failed: %s\n", msgbuf); fprintf(stderr, "Regex match failed: %s\r\n", msgbuf);
regfree(&regex); regfree(&regex);
shellExit(); shellExit();
} }
@ -68,19 +68,19 @@ int32_t shellCheckIntSize() {
return 0; return 0;
} }
void shellPrintVersion() { printf("version: %s\n", version); } void shellPrintVersion() { printf("version: %s\r\n", version); }
void shellGenerateAuth() { void shellGenerateAuth() {
char secretEncrypt[TSDB_PASSWORD_LEN + 1] = {0}; char secretEncrypt[TSDB_PASSWORD_LEN + 1] = {0};
taosEncryptPass_c((uint8_t *)shell.args.password, strlen(shell.args.password), secretEncrypt); taosEncryptPass_c((uint8_t *)shell.args.password, strlen(shell.args.password), secretEncrypt);
printf("%s\n", secretEncrypt); printf("%s\r\n", secretEncrypt);
fflush(stdout); fflush(stdout);
} }
void shellDumpConfig() { void shellDumpConfig() {
SConfig *pCfg = taosGetCfg(); SConfig *pCfg = taosGetCfg();
if (pCfg == NULL) { if (pCfg == NULL) {
printf("TDengine read global config failed!\n"); printf("TDengine read global config failed!\r\n");
} else { } else {
cfgDumpCfg(pCfg, 1, true); cfgDumpCfg(pCfg, 1, true);
} }
@ -95,23 +95,23 @@ void shellCheckServerStatus() {
code = taos_check_server_status(shell.args.host, shell.args.port, details, 1024); code = taos_check_server_status(shell.args.host, shell.args.port, details, 1024);
switch (code) { switch (code) {
case TSDB_SRV_STATUS_UNAVAILABLE: case TSDB_SRV_STATUS_UNAVAILABLE:
printf("0: unavailable\n"); printf("0: unavailable\r\n");
break; break;
case TSDB_SRV_STATUS_NETWORK_OK: case TSDB_SRV_STATUS_NETWORK_OK:
printf("1: network ok\n"); printf("1: network ok\r\n");
break; break;
case TSDB_SRV_STATUS_SERVICE_OK: case TSDB_SRV_STATUS_SERVICE_OK:
printf("2: service ok\n"); printf("2: service ok\r\n");
break; break;
case TSDB_SRV_STATUS_SERVICE_DEGRADED: case TSDB_SRV_STATUS_SERVICE_DEGRADED:
printf("3: service degraded\n"); printf("3: service degraded\r\n");
break; break;
case TSDB_SRV_STATUS_EXTING: case TSDB_SRV_STATUS_EXTING:
printf("4: exiting\n"); printf("4: exiting\r\n");
break; break;
} }
if (strlen(details) != 0) { if (strlen(details) != 0) {
printf("%s\n\n", details); printf("%s\r\n\r\n", details);
} }
fflush(stdout); fflush(stdout);
if (code == TSDB_SRV_STATUS_NETWORK_OK && shell.args.is_startup) { if (code == TSDB_SRV_STATUS_NETWORK_OK && shell.args.is_startup) {