From 6722b336bff582445c48abc3968b67d75ee46b63 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Fri, 12 Mar 2021 13:34:29 +0800 Subject: [PATCH 01/89] add debug log --- src/client/src/tscServer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 9e43ae674d..655113bf02 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -522,7 +522,7 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) { assert(pVgroupInfo->vgroups[vgIndex].vgId > 0 && vgIndex < pTableMetaInfo->vgroupList->numOfVgroups); pRetrieveMsg->header.vgId = htonl(pVgroupInfo->vgroups[vgIndex].vgId); - tscDebug("%p build fetch msg from vgId:%d, vgIndex:%d", pSql, pVgroupInfo->vgroups[vgIndex].vgId, vgIndex); + tscDebug("%p build fetch msg from vgId:%d, vgIndex:%d, qhandle:%" PRIX64, pSql, pVgroupInfo->vgroups[vgIndex].vgId, vgIndex, pSql->res.qhandle); } else { int32_t numOfVgroups = (int32_t)taosArrayGetSize(pTableMetaInfo->pVgroupTables); assert(vgIndex >= 0 && vgIndex < numOfVgroups); @@ -530,12 +530,12 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) { SVgroupTableInfo* pTableIdList = taosArrayGet(pTableMetaInfo->pVgroupTables, vgIndex); pRetrieveMsg->header.vgId = htonl(pTableIdList->vgInfo.vgId); - tscDebug("%p build fetch msg from vgId:%d, vgIndex:%d", pSql, pTableIdList->vgInfo.vgId, vgIndex); + tscDebug("%p build fetch msg from vgId:%d, vgIndex:%d, qhandle:%" PRIX64, pSql, pTableIdList->vgInfo.vgId, vgIndex, pSql->res.qhandle); } } else { STableMeta* pTableMeta = pTableMetaInfo->pTableMeta; pRetrieveMsg->header.vgId = htonl(pTableMeta->vgId); - tscDebug("%p build fetch msg from only one vgroup, vgId:%d", pSql, pTableMeta->vgId); + tscDebug("%p build fetch msg from only one vgroup, vgId:%d, qhandle:%" PRIX64, pSql, pTableMeta->vgId, pSql->res.qhandle); } pSql->cmd.payloadLen = sizeof(SRetrieveTableMsg); From 7502039df4e1cfb67b51c4e8c02786c95f2ebc97 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Fri, 12 Mar 2021 15:19:19 +0800 Subject: [PATCH 02/89] fix bug --- src/inc/query.h | 5 +++-- src/query/inc/qExecutor.h | 3 ++- src/query/src/qExecutor.c | 15 ++++++++++++--- src/query/src/queryMain.c | 9 ++++----- src/vnode/src/vnodeRead.c | 23 ++++++++++++----------- 5 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/inc/query.h b/src/inc/query.h index 7342221cb9..77a12ebfc5 100644 --- a/src/inc/query.h +++ b/src/inc/query.h @@ -28,7 +28,7 @@ typedef void* qinfo_t; * @param qinfo * @return */ -int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryTableMsg, qinfo_t* qinfo); +int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryTableMsg, qinfo_t* qinfo, uint64_t *qId); /** @@ -88,9 +88,10 @@ void* qOpenQueryMgmt(int32_t vgId); void qQueryMgmtNotifyClosed(void* pExecutor); void qQueryMgmtReOpen(void *pExecutor); void qCleanupQueryMgmt(void* pExecutor); -void** qRegisterQInfo(void* pMgmt, uint64_t qInfo); +void** qRegisterQInfo(void* pMgmt, uint64_t qId, uint64_t qInfo); void** qAcquireQInfo(void* pMgmt, uint64_t key); void** qReleaseQInfo(void* pMgmt, void* pQInfo, bool freeHandle); +bool checkQIdEqual(void *qHandle, uint64_t qId); #ifdef __cplusplus } diff --git a/src/query/inc/qExecutor.h b/src/query/inc/qExecutor.h index ec1261da0a..0d296b365e 100644 --- a/src/query/inc/qExecutor.h +++ b/src/query/inc/qExecutor.h @@ -262,6 +262,7 @@ enum { typedef struct SQInfo { void* signature; + uint64_t qId; int32_t code; // error code to returned to client int64_t owner; // if it is in execution void* tsdb; @@ -311,7 +312,7 @@ int32_t createQueryFuncExprFromMsg(SQueryTableMsg *pQueryMsg, int32_t numOfOutpu SColumnInfo* pTagCols); SSqlGroupbyExpr *createGroupbyExprFromMsg(SQueryTableMsg *pQueryMsg, SColIndex *pColIndex, int32_t *code); SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGroupbyExpr, SExprInfo *pExprs, - SExprInfo *pSecExprs, STableGroupInfo *pTableGroupInfo, SColumnInfo* pTagCols, bool stableQuery, char* sql); + SExprInfo *pSecExprs, STableGroupInfo *pTableGroupInfo, SColumnInfo* pTagCols, bool stableQuery, char* sql, uint64_t *qId); int32_t initQInfo(SQueryTableMsg *pQueryMsg, void *tsdb, int32_t vgId, SQInfo *pQInfo, SQueryParam* param, bool isSTable); void freeColumnFilterInfo(SColumnFilterInfo* pFilter, int32_t numOfFilters); diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index f8119b0d4a..7b0dbdc5c2 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -112,6 +112,9 @@ static UNUSED_FUNC void* u_realloc(void* p, size_t __size) { static void finalizeQueryResult(SQueryRuntimeEnv *pRuntimeEnv); +uint64_t queryHandleId = 0; + + int32_t getMaximumIdleDurationSec() { return tsShellActivityTimer * 2; } @@ -6570,8 +6573,12 @@ static void calResultBufSize(SQuery* pQuery) { } } +FORCE_INLINE bool checkQIdEqual(void *qHandle, uint64_t qId) { + return ((SQInfo *)qHandle)->qId == qId; +} + SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGroupbyExpr, SExprInfo *pExprs, - SExprInfo *pSecExprs, STableGroupInfo *pTableGroupInfo, SColumnInfo* pTagCols, bool stableQuery, char* sql) { + SExprInfo *pSecExprs, STableGroupInfo *pTableGroupInfo, SColumnInfo* pTagCols, bool stableQuery, char* sql, uint64_t *qId) { int16_t numOfCols = pQueryMsg->numOfCols; int16_t numOfOutput = pQueryMsg->numOfOutput; @@ -6749,8 +6756,10 @@ SQInfo *createQInfoImpl(SQueryTableMsg *pQueryMsg, SSqlGroupbyExpr *pGroupbyExpr // todo refactor pQInfo->runtimeEnv.queryBlockDist = (numOfOutput == 1 && pExprs[0].base.colInfo.colId == TSDB_BLOCK_DIST_COLUMN_INDEX); - - qDebug("qmsg:%p QInfo:%p created", pQueryMsg, pQInfo); + + pQInfo->qId = atomic_add_fetch_64(&queryHandleId, 1); + *qId = pQInfo->qId; + qDebug("qmsg:%p QInfo:%" PRIu64 "-%p created", pQueryMsg, pQInfo->qId, pQInfo); return pQInfo; _cleanup_qinfo: diff --git a/src/query/src/queryMain.c b/src/query/src/queryMain.c index e262a3ad38..bc4ac06a56 100644 --- a/src/query/src/queryMain.c +++ b/src/query/src/queryMain.c @@ -68,7 +68,7 @@ void freeParam(SQueryParam *param) { tfree(param->prevResult); } -int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qinfo_t* pQInfo) { +int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qinfo_t* pQInfo, uint64_t *qId) { assert(pQueryMsg != NULL && tsdb != NULL); int32_t code = TSDB_CODE_SUCCESS; @@ -158,7 +158,7 @@ int32_t qCreateQueryInfo(void* tsdb, int32_t vgId, SQueryTableMsg* pQueryMsg, qi goto _over; } - (*pQInfo) = createQInfoImpl(pQueryMsg, param.pGroupbyExpr, param.pExprs, param.pSecExprs, &tableGroupInfo, param.pTagColumnInfo, isSTableQuery, param.sql); + (*pQInfo) = createQInfoImpl(pQueryMsg, param.pGroupbyExpr, param.pExprs, param.pSecExprs, &tableGroupInfo, param.pTagColumnInfo, isSTableQuery, param.sql, qId); param.sql = NULL; param.pExprs = NULL; @@ -479,7 +479,7 @@ void qCleanupQueryMgmt(void* pQMgmt) { qDebug("vgId:%d, queryMgmt cleanup completed", vgId); } -void** qRegisterQInfo(void* pMgmt, uint64_t qInfo) { +void** qRegisterQInfo(void* pMgmt, uint64_t qId, uint64_t qInfo) { if (pMgmt == NULL) { terrno = TSDB_CODE_VND_INVALID_VGROUP_ID; return NULL; @@ -499,8 +499,7 @@ void** qRegisterQInfo(void* pMgmt, uint64_t qInfo) { terrno = TSDB_CODE_VND_INVALID_VGROUP_ID; return NULL; } else { - TSDB_CACHE_PTR_TYPE handleVal = (TSDB_CACHE_PTR_TYPE) qInfo; - void** handle = taosCachePut(pQueryMgmt->qinfoPool, &handleVal, sizeof(TSDB_CACHE_PTR_TYPE), &qInfo, sizeof(TSDB_CACHE_PTR_TYPE), + void** handle = taosCachePut(pQueryMgmt->qinfoPool, &qId, sizeof(qId), &qInfo, sizeof(TSDB_CACHE_PTR_TYPE), (getMaximumIdleDurationSec()*1000)); pthread_mutex_unlock(&pQueryMgmt->lock); diff --git a/src/vnode/src/vnodeRead.c b/src/vnode/src/vnodeRead.c index acb1fc78f6..69bcd079c0 100644 --- a/src/vnode/src/vnodeRead.c +++ b/src/vnode/src/vnodeRead.c @@ -247,7 +247,8 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) { if (contLen != 0) { qinfo_t pQInfo = NULL; - code = qCreateQueryInfo(pVnode->tsdb, pVnode->vgId, pQueryTableMsg, &pQInfo); + uint64_t qId = 0; + code = qCreateQueryInfo(pVnode->tsdb, pVnode->vgId, pQueryTableMsg, &pQInfo, &qId); SQueryTableRsp *pRsp = (SQueryTableRsp *)rpcMallocCont(sizeof(SQueryTableRsp)); pRsp->code = code; @@ -259,22 +260,22 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) { // current connect is broken if (code == TSDB_CODE_SUCCESS) { - handle = qRegisterQInfo(pVnode->qMgmt, (uint64_t)pQInfo); + handle = qRegisterQInfo(pVnode->qMgmt, qId, (uint64_t)pQInfo); if (handle == NULL) { // failed to register qhandle pRsp->code = terrno; terrno = 0; - vError("vgId:%d, QInfo:%p register qhandle failed, return to app, code:%s", pVnode->vgId, (void *)pQInfo, + vError("vgId:%d, QInfo:%"PRIu64 "-%p register qhandle failed, return to app, code:%s", pVnode->vgId, qId, (void *)pQInfo, tstrerror(pRsp->code)); qDestroyQueryInfo(pQInfo); // destroy it directly return pRsp->code; } else { assert(*handle == pQInfo); - pRsp->qhandle = htobe64((uint64_t)pQInfo); + pRsp->qhandle = htobe64(qId); } if (handle != NULL && vnodeNotifyCurrentQhandle(pRead->rpcHandle, *handle, pVnode->vgId) != TSDB_CODE_SUCCESS) { - vError("vgId:%d, QInfo:%p, query discarded since link is broken, %p", pVnode->vgId, *handle, + vError("vgId:%d, QInfo:%"PRIu64 "-%p, query discarded since link is broken, %p", pVnode->vgId, qId, *handle, pRead->rpcHandle); pRsp->code = TSDB_CODE_RPC_NETWORK_UNAVAIL; qReleaseQInfo(pVnode->qMgmt, (void **)&handle, true); @@ -285,7 +286,7 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) { } if (handle != NULL) { - vTrace("vgId:%d, QInfo:%p, dnode query msg disposed, create qhandle and returns to app", vgId, *handle); + vTrace("vgId:%d, QInfo:%"PRIu64 "-%p, dnode query msg disposed, create qhandle and returns to app", vgId, qId, *handle); code = vnodePutItemIntoReadQueue(pVnode, handle, pRead->rpcHandle); if (code != TSDB_CODE_SUCCESS) { pRsp->code = code; @@ -349,7 +350,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pRead) { pRetrieve->free = htons(pRetrieve->free); pRetrieve->qhandle = htobe64(pRetrieve->qhandle); - vTrace("vgId:%d, QInfo:%p, retrieve msg is disposed, free:%d, conn:%p", pVnode->vgId, (void *)pRetrieve->qhandle, + vTrace("vgId:%d, QInfo:%" PRIu64 ", retrieve msg is disposed, free:%d, conn:%p", pVnode->vgId, pRetrieve->qhandle, pRetrieve->free, pRead->rpcHandle); memset(pRet, 0, sizeof(SRspRet)); @@ -360,19 +361,19 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pRead) { if (handle == NULL) { code = terrno; terrno = TSDB_CODE_SUCCESS; - } else if ((*handle) != (void *)pRetrieve->qhandle) { + } else if (!checkQIdEqual(*handle, pRetrieve->qhandle)) { code = TSDB_CODE_QRY_INVALID_QHANDLE; } if (code != TSDB_CODE_SUCCESS) { - vError("vgId:%d, invalid handle in retrieving result, code:%s, QInfo:%p", pVnode->vgId, tstrerror(code), (void *)pRetrieve->qhandle); + vError("vgId:%d, invalid handle in retrieving result, code:%s, QInfo:%" PRIu64, pVnode->vgId, tstrerror(code), pRetrieve->qhandle); vnodeBuildNoResultQueryRsp(pRet); return code; } // kill current query and free corresponding resources. if (pRetrieve->free == 1) { - vWarn("vgId:%d, QInfo:%p, retrieve msg received to kill query and free qhandle", pVnode->vgId, *handle); + vWarn("vgId:%d, QInfo:%"PRIu64 "-%p, retrieve msg received to kill query and free qhandle", pVnode->vgId, pRetrieve->qhandle, *handle); qKillQuery(*handle); qReleaseQInfo(pVnode->qMgmt, (void **)&handle, true); @@ -383,7 +384,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pRead) { // register the qhandle to connect to quit query immediate if connection is broken if (vnodeNotifyCurrentQhandle(pRead->rpcHandle, *handle, pVnode->vgId) != TSDB_CODE_SUCCESS) { - vError("vgId:%d, QInfo:%p, retrieve discarded since link is broken, %p", pVnode->vgId, *handle, pRead->rpcHandle); + vError("vgId:%d, QInfo:%"PRIu64 "-%p, retrieve discarded since link is broken, %p", pVnode->vgId, pRetrieve->qhandle, *handle, pRead->rpcHandle); code = TSDB_CODE_RPC_NETWORK_UNAVAIL; qKillQuery(*handle); qReleaseQInfo(pVnode->qMgmt, (void **)&handle, true); From 2d2316eeec7d105fa38769bbf90116346729a319 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 12 Mar 2021 15:32:58 +0800 Subject: [PATCH 03/89] [td-3277]: fix the taosd crash caused by fetching the too long binary data in tags. --- src/query/src/qExecutor.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index f8119b0d4a..57efcf4b34 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -2913,7 +2913,9 @@ static void doSetTagValueInParam(void* pTable, int32_t tagColId, tVariant *tag, return; } - tVariantCreateFromBinary(tag, varDataVal(val), varDataLen(val), type); + int32_t maxLen = bytes - VARSTR_HEADER_SIZE; + int32_t len = (varDataLen(val) > maxLen)? maxLen:varDataLen(val); + tVariantCreateFromBinary(tag, varDataVal(val), len, type); } else { if (isNull(val, type)) { tag->nType = TSDB_DATA_TYPE_NULL; @@ -7070,8 +7072,15 @@ static void doSetTagValueToResultBuf(char* output, const char* val, int16_t type return; } - if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { - memcpy(output, val, varDataTLen(val)); + if (IS_VAR_DATA_TYPE(type)) { + // Binary data overflows for sort of unknown reasons. Let trim the overflow data + if (varDataTLen(val) > bytes) { + int32_t len = bytes; + memcpy(varDataVal(output), varDataVal(val), len); + varDataSetLen(output, len); + } else { + varDataCopy(output, val); + } } else { memcpy(output, val, bytes); } From 1e6cc776f83a6726188a3dcdf57b8799029f7cbf Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 12 Mar 2021 17:24:18 +0800 Subject: [PATCH 04/89] add tag value check to create table --- src/inc/taoserror.h | 1 + src/tsdb/src/tsdbMeta.c | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/inc/taoserror.h b/src/inc/taoserror.h index 3eb197868b..97749f5b78 100644 --- a/src/inc/taoserror.h +++ b/src/inc/taoserror.h @@ -235,6 +235,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TDB_IVD_CREATE_TABLE_INFO TAOS_DEF_ERROR_CODE(0, 0x0612) //"Invalid information to create table") #define TSDB_CODE_TDB_NO_AVAIL_DISK TAOS_DEF_ERROR_CODE(0, 0x0613) //"No available disk") #define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0614) //"TSDB messed message") +#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615) //"TSDB invalid tag value") // query #define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700) //"Invalid handle") diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index 5e2e0fce1d..cdde2bc91f 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -20,7 +20,7 @@ static int tsdbCompareSchemaVersion(const void *key1, const void *key2); static char * getTagIndexKey(const void *pData); static STable *tsdbNewTable(); -static STable *tsdbCreateTableFromCfg(STableCfg *pCfg, bool isSuper); +static STable *tsdbCreateTableFromCfg(STableCfg *pCfg, bool isSuper, STable *pSTable); static void tsdbFreeTable(STable *pTable); static int tsdbAddTableToMeta(STsdbRepo *pRepo, STable *pTable, bool addIdx, bool lock); static void tsdbRemoveTableFromMeta(STsdbRepo *pRepo, STable *pTable, bool rmFromIdx, bool lock); @@ -43,6 +43,7 @@ static void * tsdbInsertTableAct(STsdbRepo *pRepo, int8_t act, void *buf, STabl static int tsdbRemoveTableFromStore(STsdbRepo *pRepo, STable *pTable); static int tsdbRmTableFromMeta(STsdbRepo *pRepo, STable *pTable); static int tsdbAdjustMetaTables(STsdbRepo *pRepo, int tid); +static int tsdbCheckTableTagVal(SKVRow *pKVRow, STSchema *pSchema); // ------------------ OUTER FUNCTIONS ------------------ int tsdbCreateTable(STsdbRepo *repo, STableCfg *pCfg) { @@ -87,7 +88,7 @@ int tsdbCreateTable(STsdbRepo *repo, STableCfg *pCfg) { super = tsdbGetTableByUid(pMeta, pCfg->superUid); if (super == NULL) { // super table not exists, try to create it newSuper = true; - super = tsdbCreateTableFromCfg(pCfg, true); + super = tsdbCreateTableFromCfg(pCfg, true, NULL); if (super == NULL) goto _err; } else { if (TABLE_TYPE(super) != TSDB_SUPER_TABLE || TABLE_UID(super) != pCfg->superUid) { @@ -108,7 +109,7 @@ int tsdbCreateTable(STsdbRepo *repo, STableCfg *pCfg) { } } - table = tsdbCreateTableFromCfg(pCfg, false); + table = tsdbCreateTableFromCfg(pCfg, false, super); if (table == NULL) goto _err; // Register to meta @@ -674,7 +675,7 @@ static STable *tsdbNewTable() { return pTable; } -static STable *tsdbCreateTableFromCfg(STableCfg *pCfg, bool isSuper) { +static STable *tsdbCreateTableFromCfg(STableCfg *pCfg, bool isSuper, STable *pSTable) { STable *pTable = NULL; size_t tsize = 0; @@ -726,6 +727,9 @@ static STable *tsdbCreateTableFromCfg(STableCfg *pCfg, bool isSuper) { if (pCfg->type == TSDB_CHILD_TABLE) { TABLE_SUID(pTable) = pCfg->superUid; + if (tsdbCheckTableTagVal(pCfg->tagValues, pSTable->tagSchema) < 0) { + goto _err; + } pTable->tagVal = tdKVRowDup(pCfg->tagValues); if (pTable->tagVal == NULL) { terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; @@ -1302,3 +1306,20 @@ static int tsdbAdjustMetaTables(STsdbRepo *pRepo, int tid) { return 0; } + +static int tsdbCheckTableTagVal(SKVRow *pKVRow, STSchema *pSchema) { + for (size_t i = 0; i < kvRowNCols(pKVRow); i++) { + SColIdx * pColIdx = kvRowColIdxAt(pKVRow, i); + STColumn *pCol = tdGetColOfID(pSchema, pColIdx->colId); + + if ((pCol == NULL) || (!IS_VAR_DATA_TYPE(pCol->type))) continue; + + void *pValue = tdGetKVRowValOfCol(pKVRow, pCol->colId); + if (varDataTLen(pValue) > pCol->bytes) { + terrno = TSDB_CODE_TDB_IVLD_TAG_VAL; + return -1; + } + } + + return 0; +} \ No newline at end of file From 7879ca6ababf580525c4b1385c604d44f40039ac Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Mon, 15 Mar 2021 09:52:19 +0800 Subject: [PATCH 05/89] [TD-3223]case for stddev on the same column --- tests/pytest/functions/function_stddev.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/pytest/functions/function_stddev.py b/tests/pytest/functions/function_stddev.py index 6e4ee69422..afc59ac83d 100644 --- a/tests/pytest/functions/function_stddev.py +++ b/tests/pytest/functions/function_stddev.py @@ -113,6 +113,12 @@ class TDTestCase: for i in range(13): tdSql.query('select stddev(c4) from s group by t%s' % str(i+1) ) + #add for td-3223 + for i in range(13): + if i == 1 or i == 5 or i == 6 or i == 7 or i == 9 or i == 8 :continue + tdSql.query('select stddev(c%d),stddev(c%d) from s group by c%d' %( i+1 , i+1 , i+1 ) ) + + def stop(self): From e94cbdf532ee094521fbaa3803fb8b22917799d2 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Mon, 15 Mar 2021 15:07:24 +0800 Subject: [PATCH 06/89] [TD-1002]: add test case for double type --- tests/pytest/functions/function_percentile2.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/pytest/functions/function_percentile2.py b/tests/pytest/functions/function_percentile2.py index 8a2b280c7d..227a3cbe03 100644 --- a/tests/pytest/functions/function_percentile2.py +++ b/tests/pytest/functions/function_percentile2.py @@ -28,13 +28,13 @@ class TDTestCase: def run(self): tdSql.prepare() - tdSql.execute("create table test(ts timestamp, col1 int, col2 float)") + tdSql.execute("create table test(ts timestamp, col1 int, col2 float, col3 double)") for i in range(1000): sql = "insert into test values" batchSize = int (self.rowNum / 1000) for j in range (batchSize): currTime = self.ts + batchSize * i + j - sql += "(%d, 1, 2.37)" % currTime + sql += "(%d, 1, 2.37, 3.1415926)" % currTime tdSql.execute(sql) tdSql.query("select percentile(col1, 20) from test") @@ -43,12 +43,18 @@ class TDTestCase: tdSql.query("select percentile(col2, 20) from test") tdSql.checkData(0, 0, 2.3699998) + tdSql.query("select percentile(col3, 20) from test") + tdSql.checkData(0, 0, 3.1415926) + tdSql.query("select apercentile(col1, 20) from test") tdSql.checkData(0, 0, 1) tdSql.query("select apercentile(col2, 20) from test") tdSql.checkData(0, 0, 2.3699998) + tdSql.query("select apercentile(col3, 20) from test") + tdSql.checkData(0, 0, 3.1415926) + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) From b434b54d7713500bdf6a29ba5edd563a2db7b407 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Mon, 15 Mar 2021 16:54:10 +0800 Subject: [PATCH 07/89] [TD-3307]: fix too long string append with length >= 64 --- src/plugins/http/src/httpParser.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plugins/http/src/httpParser.c b/src/plugins/http/src/httpParser.c index 4ce54a8ee6..669b352ab6 100644 --- a/src/plugins/http/src/httpParser.c +++ b/src/plugins/http/src/httpParser.c @@ -110,7 +110,7 @@ static void httpCleanupString(HttpString *str) { static int32_t httpAppendString(HttpString *str, const char *s, int32_t len) { if (str->size == 0) { str->pos = 0; - str->size = 64; + str->size = len; str->str = malloc(str->size); } else if (str->pos + len + 1 >= str->size) { str->size += len; @@ -715,10 +715,12 @@ static int32_t httpParserOnVersion(HttpParser *parser, HTTP_PARSER_STATE state, if (parser->method) { ok = httpOnRequestLine(parser, parser->method, parser->target, parser->version); + /* if (parser->target) { free(parser->target); parser->target = NULL; } + */ } httpClearString(&parser->str); From 851975db4e74dc30d666060e3adb82e8bdfa6ce6 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 15 Mar 2021 10:37:54 +0000 Subject: [PATCH 08/89] TD-3308 --- src/inc/tsync.h | 4 + src/inc/twal.h | 1 + src/sync/inc/syncInt.h | 1 + src/sync/src/syncMain.c | 1 + src/sync/src/syncRestore.c | 1 + src/vnode/inc/vnodeSync.h | 1 + src/vnode/src/vnodeMain.c | 1 + src/vnode/src/vnodeSync.c | 16 + src/wal/src/walWrite.c | 13 + tests/script/issue/TD-3300.sim | 556 +++++++++++++++++++++++++++++++++ 10 files changed, 595 insertions(+) create mode 100644 tests/script/issue/TD-3300.sim diff --git a/src/inc/tsync.h b/src/inc/tsync.h index 379c877b26..e5aa07fe7b 100644 --- a/src/inc/tsync.h +++ b/src/inc/tsync.h @@ -79,6 +79,9 @@ typedef void (*FStopSyncFile)(int32_t vgId, uint64_t fversion); // get file version typedef int32_t (*FGetVersion)(int32_t vgId, uint64_t *fver, uint64_t *vver); +// reset version +typedef int32_t (*FResetVersion)(int32_t vgId, uint64_t fver); + typedef int32_t (*FSendFile)(void *tsdb, SOCKET socketFd); typedef int32_t (*FRecvFile)(void *tsdb, SOCKET socketFd); @@ -96,6 +99,7 @@ typedef struct { FStartSyncFile startSyncFileFp; FStopSyncFile stopSyncFileFp; FGetVersion getVersionFp; + FResetVersion resetVersionFp; FSendFile sendFileFp; FRecvFile recvFileFp; } SSyncInfo; diff --git a/src/inc/twal.h b/src/inc/twal.h index 1645de77aa..bce398d6f9 100644 --- a/src/inc/twal.h +++ b/src/inc/twal.h @@ -65,6 +65,7 @@ void walFsync(twalh, bool forceFsync); int32_t walRestore(twalh, void *pVnode, FWalWrite writeFp); int32_t walGetWalFile(twalh, char *fileName, int64_t *fileId); uint64_t walGetVersion(twalh); +void walResetVersion(twalh, uint64_t newVer); #ifdef __cplusplus } diff --git a/src/sync/inc/syncInt.h b/src/sync/inc/syncInt.h index 91613ae351..2b87938474 100644 --- a/src/sync/inc/syncInt.h +++ b/src/sync/inc/syncInt.h @@ -117,6 +117,7 @@ typedef struct SSyncNode { FStartSyncFile startSyncFileFp; FStopSyncFile stopSyncFileFp; FGetVersion getVersionFp; + FResetVersion resetVersionFp; FSendFile sendFileFp; FRecvFile recvFileFp; pthread_mutex_t mutex; diff --git a/src/sync/src/syncMain.c b/src/sync/src/syncMain.c index 956ccdc073..f018f00848 100644 --- a/src/sync/src/syncMain.c +++ b/src/sync/src/syncMain.c @@ -182,6 +182,7 @@ int64_t syncStart(const SSyncInfo *pInfo) { pNode->startSyncFileFp = pInfo->startSyncFileFp; pNode->stopSyncFileFp = pInfo->stopSyncFileFp; pNode->getVersionFp = pInfo->getVersionFp; + pNode->resetVersionFp = pInfo->resetVersionFp; pNode->sendFileFp = pInfo->sendFileFp; pNode->recvFileFp = pInfo->recvFileFp; diff --git a/src/sync/src/syncRestore.c b/src/sync/src/syncRestore.c index c0d66316cd..4c2444caa0 100644 --- a/src/sync/src/syncRestore.c +++ b/src/sync/src/syncRestore.c @@ -238,6 +238,7 @@ static int32_t syncRestoreDataStepByStep(SSyncPeer *pPeer) { (*pNode->stopSyncFileFp)(pNode->vgId, fversion); nodeVersion = fversion; + (*pNode->resetVersionFp)(pNode->vgId, fversion); sInfo("%s, start to restore wal, fver:%" PRIu64, pPeer->id, nodeVersion); uint64_t wver = 0; diff --git a/src/vnode/inc/vnodeSync.h b/src/vnode/inc/vnodeSync.h index c9ac25c227..9a7da626f8 100644 --- a/src/vnode/inc/vnodeSync.h +++ b/src/vnode/inc/vnodeSync.h @@ -30,6 +30,7 @@ void vnodeStopSyncFile(int32_t vgId, uint64_t fversion); void vnodeConfirmForard(int32_t vgId, void *wparam, int32_t code); int32_t vnodeWriteToCache(int32_t vgId, void *wparam, int32_t qtype, void *rparam); int32_t vnodeGetVersion(int32_t vgId, uint64_t *fver, uint64_t *wver); +int32_t vnodeResetVersion(int32_t vgId, uint64_t fver); void vnodeConfirmForward(void *pVnode, uint64_t version, int32_t code); diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index ac9536d243..c380b60f88 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -305,6 +305,7 @@ int32_t vnodeOpen(int32_t vgId) { syncInfo.startSyncFileFp = vnodeStartSyncFile; syncInfo.stopSyncFileFp = vnodeStopSyncFile; syncInfo.getVersionFp = vnodeGetVersion; + syncInfo.resetVersionFp = vnodeResetVersion; syncInfo.sendFileFp = tsdbSyncSend; syncInfo.recvFileFp = tsdbSyncRecv; syncInfo.pTsdb = pVnode->tsdb; diff --git a/src/vnode/src/vnodeSync.c b/src/vnode/src/vnodeSync.c index 627783c391..1f9c6c7216 100644 --- a/src/vnode/src/vnodeSync.c +++ b/src/vnode/src/vnodeSync.c @@ -158,6 +158,22 @@ int32_t vnodeGetVersion(int32_t vgId, uint64_t *fver, uint64_t *wver) { return code; } +int32_t vnodeResetVersion(int32_t vgId, uint64_t fver) { + SVnodeObj *pVnode = vnodeAcquire(vgId); + if (pVnode == NULL) { + vError("vgId:%d, vnode not found while reset version", vgId); + return -1; + } + + pVnode->fversion = fver; + pVnode->version = fver; + walResetVersion(pVnode->wal, fver); + vDebug("vgId:%d, version reset to %" PRIu64, vgId, fver); + + vnodeRelease(pVnode); + return 0; +} + void vnodeConfirmForward(void *vparam, uint64_t version, int32_t code) { SVnodeObj *pVnode = vparam; syncConfirmForward(pVnode->sync, version, code); diff --git a/src/wal/src/walWrite.c b/src/wal/src/walWrite.c index aeb4983029..51b770d346 100644 --- a/src/wal/src/walWrite.c +++ b/src/wal/src/walWrite.c @@ -446,3 +446,16 @@ uint64_t walGetVersion(twalh param) { return pWal->version; } + +// Wal version in slave (dnode1) must be reset. +// Because after the data file is recovered from peer (dnode2), the new file version in dnode1 may become smaller than origin. +// Some new wal record cannot be written to the wal file in dnode1 for wal version not reset, then fversion and the record in wal file may inconsistent, +// At this time, if dnode2 down, dnode1 switched to master. After dnode2 start and restore data from dnode1, data loss will occur + +void walResetVersion(twalh param, uint64_t newVer) { + SWal *pWal = param; + if (pWal == 0) return; + wDebug("vgId:%d, version reset from %" PRIu64 " to %" PRIu64, pWal->vgId, pWal->version, newVer); + + pWal->version = newVer; +} \ No newline at end of file diff --git a/tests/script/issue/TD-3300.sim b/tests/script/issue/TD-3300.sim new file mode 100644 index 0000000000..0745ceb849 --- /dev/null +++ b/tests/script/issue/TD-3300.sim @@ -0,0 +1,556 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/deploy.sh -n dnode2 -i 2 +system sh/deploy.sh -n dnode3 -i 3 +system sh/deploy.sh -n dnode4 -i 4 + +system sh/cfg.sh -n dnode1 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode2 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode3 -c numOfMnodes -v 1 +system sh/cfg.sh -n dnode4 -c numOfMnodes -v 1 + +system sh/cfg.sh -n dnode1 -c role -v 1 +system sh/cfg.sh -n dnode2 -c role -v 2 +system sh/cfg.sh -n dnode3 -c role -v 2 +system sh/cfg.sh -n dnode4 -c role -v 2 + +system sh/cfg.sh -n dnode1 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode2 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode3 -c arbitrator -v $arbitrator +system sh/cfg.sh -n dnode4 -c arbitrator -v $arbitrator + +print ============== step0: start tarbitrator +system sh/exec_tarbitrator.sh -s start + +print ============== step1: start dnode1, only deploy mnode +system sh/exec.sh -n dnode1 -s start +sql connect + +print ============== step2: start dnode2/dnode3 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start +sql create dnode $hostname2 +sql create dnode $hostname3 + +$x = 0 +step2: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step2 +endi +if $data4_2 != ready then + goto step2 +endi +if $data4_3 != ready then + goto step2 +endi + +sleep 1000 + +print ============== step3 +sql create database db replica 2 +sql use db + +sql create table stb (ts timestamp, c1 int, c2 int) tags(t1 int) +sql create table t1 using stb tags(1) +sql insert into t1 values(1577980800000, 1, 5) +sql insert into t1 values(1577980800001, 2, 4) +sql insert into t1 values(1577980800002, 3, 3) +sql insert into t1 values(1577980800003, 4, 2) +sql insert into t1 values(1577980800004, 5, 1) + +sql show db.vgroups +if $data04 != 3 then + return -1 +endi +if $data06 != 2 then + return -1 +endi +if $data05 != master then + return -1 +endi +if $data07 != slave then + return -1 +endi + +sql select * from t1 +if $rows != 5 then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGKILL +system sh/exec.sh -n dnode3 -s stop -x SIGKILL + +print ============== step4 +system sh/exec.sh -n dnode2 -s start +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step4: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step4 +endi +if $data4_2 != ready then + goto step4 +endi +if $data4_3 != ready then + goto step4 +endi + +sql show db.vgroups +if $data04 != 3 then + goto step4 +endi +if $data06 != 2 then + goto step4 +endi +if $data05 != master then + goto step4 +endi +if $data07 != slave then + goto step4 +endi + +sql create table t2 using stb tags(1) +sql insert into t2 values(1577980800000, 1, 5) +sql insert into t2 values(1577980800001, 2, 4) +sql insert into t2 values(1577980800002, 3, 3) +sql insert into t2 values(1577980800003, 4, 2) +sql insert into t2 values(1577980800004, 5, 1) + +sql select * from t2 +if $rows != 5 then + return -1 +endi + +print ============== step5 +system sh/exec.sh -n dnode3 -s stop -x SIGKILL + +$x = 0 +step5: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step5 +endi +if $data4_2 != ready then + goto step5 +endi +if $data4_3 != offline then + goto step5 +endi + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi + +sql show db.vgroups +if $data04 != 3 then + goto step5 +endi +if $data06 != 2 then + goto step5 +endi +if $data05 != offline then + goto step5 +endi +if $data07 != master then + goto step5 +endi + +print ============== step6 +sql create table t3 using stb tags(1) +sql insert into t3 values(1577980800000, 1, 5) +sql insert into t3 values(1577980800001, 2, 4) +sql insert into t3 values(1577980800002, 3, 3) +sql insert into t3 values(1577980800003, 4, 2) +sql insert into t3 values(1577980800004, 5, 1) +sql insert into t3 values(1577980800010, 11, 5) +sql insert into t3 values(1577980800011, 12, 4) +sql insert into t3 values(1577980800012, 13, 3) +sql insert into t3 values(1577980800013, 14, 2) +sql insert into t3 values(1577980800014, 15, 1) + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi + +system sh/exec.sh -n dnode3 -s start + +$x = 0 +step6: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step6 +endi +if $data4_2 != ready then + goto step6 +endi +if $data4_3 != ready then + goto step6 +endi + +sql show db.vgroups +if $data04 != 3 then + goto step6 +endi +if $data06 != 2 then + goto step6 +endi +if $data05 != slave then + goto step6 +endi +if $data07 != master then + goto step6 +endi + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi + +print ============== step7 +sql create table t4 using stb tags(1) +sql insert into t4 values(1577980800000, 1, 5) +sql insert into t4 values(1577980800001, 2, 4) +sql insert into t4 values(1577980800002, 3, 3) +sql insert into t4 values(1577980800003, 4, 2) +sql insert into t4 values(1577980800004, 5, 1) +sql insert into t4 values(1577980800010, 11, 5) +sql insert into t4 values(1577980800011, 12, 4) +sql insert into t4 values(1577980800012, 13, 3) +sql insert into t4 values(1577980800013, 14, 2) +sql insert into t4 values(1577980800014, 15, 1) +sql insert into t4 values(1577980800020, 21, 5) +sql insert into t4 values(1577980800021, 22, 4) +sql insert into t4 values(1577980800022, 23, 3) +sql insert into t4 values(1577980800023, 24, 2) +sql insert into t4 values(1577980800024, 25, 1) + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi +sql select * from t4 +if $rows != 15 then + return -1 +endi + +system sh/exec.sh -n dnode2 -s stop -x SIGKILL +$x = 0 +step7: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step7 +endi +if $data4_2 != offline then + goto step7 +endi +if $data4_3 != ready then + goto step7 +endi + +sql show db.vgroups +if $data04 != 3 then + goto step7 +endi +if $data06 != 2 then + goto step7 +endi +if $data05 != master then + goto step7 +endi +if $data07 != offline then + goto step7 +endi + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi +sql select * from t4 +if $rows != 15 then + return -1 +endi + +print ============== step8 +sql create table t5 using stb tags(1) +sql insert into t5 values(1577980800000, 1, 5) +sql insert into t5 values(1577980800001, 2, 4) +sql insert into t5 values(1577980800002, 3, 3) +sql insert into t5 values(1577980800003, 4, 2) +sql insert into t5 values(1577980800004, 5, 1) +sql insert into t5 values(1577980800010, 11, 5) + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi +sql select * from t4 +if $rows != 15 then + return -1 +endi +sql select * from t5 +if $rows != 6 then + return -1 +endi + +system sh/exec.sh -n dnode2 -s start +$x = 0 +step8: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step8 +endi +if $data4_2 != ready then + goto step8 +endi +if $data4_3 != ready then + goto step8 +endi + +sql show db.vgroups +if $data04 != 3 then + goto step8 +endi +if $data06 != 2 then + goto step8 +endi +if $data05 != master then + goto step8 +endi +if $data07 != slave then + goto step8 +endi + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi +sql select * from t4 +if $rows != 15 then + return -1 +endi +sql select * from t5 +if $rows != 6 then + return -1 +endi + +print ============== step9 +sql create table t6 using stb tags(1) +sql insert into t6 values(1577980800000, 1, 5) +sql insert into t6 values(1577980800001, 2, 4) +sql insert into t6 values(1577980800002, 3, 3) +sql insert into t6 values(1577980800003, 4, 2) +sql insert into t6 values(1577980800004, 5, 1) +sql insert into t6 values(1577980800010, 11, 5) +sql insert into t6 values(1577980800011, 12, 4) + +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi +sql select * from t4 +if $rows != 15 then + return -1 +endi +sql select * from t5 +if $rows != 6 then + return -1 +endi +sql select * from t6 +if $rows != 7 then + return -1 +endi + +system sh/exec.sh -n dnode3 -s stop -x SIGKILL +$x = 0 +step9: + $x = $x + 1 + sleep 1000 + if $x == 10 then + return -1 + endi + +sql show dnodes +print dnode1 $data4_1 +print dnode2 $data4_2 +print dnode3 $data4_3 + +if $data4_1 != ready then + goto step9 +endi +if $data4_2 != ready then + goto step9 +endi +if $data4_3 != offline then + goto step9 +endi + +print ============== 2 +sql show db.vgroups + +if $data04 != 3 then + goto step7 +endi +if $data06 != 2 then + goto step7 +endi +if $data05 != offline then + goto step7 +endi +if $data07 != master then + goto step7 +endi + +print ============== 3 +sql select * from t1 +if $rows != 5 then + return -1 +endi +sql select * from t2 +if $rows != 5 then + return -1 +endi +sql select * from t3 +if $rows != 10 then + return -1 +endi +sql select * from t4 +if $rows != 15 then + return -1 +endi +sql select * from t5 +if $rows != 6 then + return -1 +endi +sql select * from t6 +if $rows != 7 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop +system sh/exec.sh -n dnode2 -s stop +system sh/exec.sh -n dnode3 -s stop From 2854d6105e45492ac4f4f5b8cc9f7b8a83e7060e Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 16 Mar 2021 01:39:08 +0000 Subject: [PATCH 09/89] TD-3308 --- src/dnode/src/dnodeVWrite.c | 2 +- src/inc/tsync.h | 4 ++-- src/inc/vnode.h | 2 +- src/mnode/src/mnodeSdb.c | 6 +++--- src/sync/src/syncMain.c | 14 +++++++------- src/vnode/inc/vnodeSync.h | 2 +- src/vnode/src/vnodeSync.c | 6 +++--- src/vnode/src/vnodeWrite.c | 3 ++- 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/dnode/src/dnodeVWrite.c b/src/dnode/src/dnodeVWrite.c index a3ff459396..87b31e4604 100644 --- a/src/dnode/src/dnodeVWrite.c +++ b/src/dnode/src/dnodeVWrite.c @@ -222,7 +222,7 @@ static void *dnodeProcessVWriteQueue(void *wparam) { dnodeSendRpcVWriteRsp(pVnode, pWrite, pWrite->code); } else { if (qtype == TAOS_QTYPE_FWD) { - vnodeConfirmForward(pVnode, pWrite->pHead.version, 0); + vnodeConfirmForward(pVnode, pWrite->pHead.version, 0, pWrite->pHead.msgType != TSDB_MSG_TYPE_SUBMIT); } if (pWrite->rspRet.rsp) { rpcFreeCont(pWrite->rspRet.rsp); diff --git a/src/inc/tsync.h b/src/inc/tsync.h index e5aa07fe7b..99dfd3a6a3 100644 --- a/src/inc/tsync.h +++ b/src/inc/tsync.h @@ -112,8 +112,8 @@ void syncCleanUp(); int64_t syncStart(const SSyncInfo *); void syncStop(int64_t rid); int32_t syncReconfig(int64_t rid, const SSyncCfg *); -int32_t syncForwardToPeer(int64_t rid, void *pHead, void *mhandle, int32_t qtype); -void syncConfirmForward(int64_t rid, uint64_t version, int32_t code); +int32_t syncForwardToPeer(int64_t rid, void *pHead, void *mhandle, int32_t qtype, bool force); +void syncConfirmForward(int64_t rid, uint64_t version, int32_t code, bool force); void syncRecover(int64_t rid); // recover from other nodes: int32_t syncGetNodesRole(int64_t rid, SNodesRole *); diff --git a/src/inc/vnode.h b/src/inc/vnode.h index 7c9ebd8a0b..dddec83da8 100644 --- a/src/inc/vnode.h +++ b/src/inc/vnode.h @@ -78,7 +78,7 @@ void vnodeFreeFromWQueue(void *pVnode, SVWriteMsg *pWrite); int32_t vnodeProcessWrite(void *pVnode, void *pHead, int32_t qtype, void *pRspRet); // vnodeSync -void vnodeConfirmForward(void *pVnode, uint64_t version, int32_t code); +void vnodeConfirmForward(void *pVnode, uint64_t version, int32_t code, bool force); // vnodeRead int32_t vnodeWriteToRQueue(void *pVnode, void *pCont, int32_t contLen, int8_t qtype, void *rparam); diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index fe1f70cb50..319b16e62a 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -680,7 +680,7 @@ static int32_t sdbProcessWrite(void *wparam, void *hparam, int32_t qtype, void * if (pRow != NULL) { // forward to peers pRow->processedCount = 0; - int32_t syncCode = syncForwardToPeer(tsSdbMgmt.sync, pHead, pRow, TAOS_QTYPE_RPC); + int32_t syncCode = syncForwardToPeer(tsSdbMgmt.sync, pHead, pRow, TAOS_QTYPE_RPC, false); if (syncCode <= 0) pRow->processedCount = 1; if (syncCode < 0) { @@ -700,7 +700,7 @@ static int32_t sdbProcessWrite(void *wparam, void *hparam, int32_t qtype, void * actStr[action], sdbGetKeyStr(pTable, pHead->cont), pHead->version); // even it is WAL/FWD, it shall be called to update version in sync - syncForwardToPeer(tsSdbMgmt.sync, pHead, pRow, TAOS_QTYPE_RPC); + syncForwardToPeer(tsSdbMgmt.sync, pHead, pRow, TAOS_QTYPE_RPC, false); // from wal or forward msg, row not created, should add into hash if (action == SDB_ACTION_INSERT) { @@ -1119,7 +1119,7 @@ static void *sdbWorkerFp(void *pWorker) { sdbConfirmForward(1, pRow, pRow->code); } else { if (qtype == TAOS_QTYPE_FWD) { - syncConfirmForward(tsSdbMgmt.sync, pRow->pHead.version, pRow->code); + syncConfirmForward(tsSdbMgmt.sync, pRow->pHead.version, pRow->code, false); } sdbFreeFromQueue(pRow); } diff --git a/src/sync/src/syncMain.c b/src/sync/src/syncMain.c index f018f00848..264bbf6b92 100644 --- a/src/sync/src/syncMain.c +++ b/src/sync/src/syncMain.c @@ -56,7 +56,7 @@ static void syncMonitorNodeRole(void *param, void *tmrId); static void syncProcessFwdAck(SSyncNode *pNode, SFwdInfo *pFwdInfo, int32_t code); static int32_t syncSaveFwdInfo(SSyncNode *pNode, uint64_t version, void *mhandle); static void syncRestartPeer(SSyncPeer *pPeer); -static int32_t syncForwardToPeerImpl(SSyncNode *pNode, void *data, void *mhandle, int32_t qtyp); +static int32_t syncForwardToPeerImpl(SSyncNode *pNode, void *data, void *mhandle, int32_t qtype, bool force); static SSyncPeer *syncAddPeer(SSyncNode *pNode, const SNodeInfo *pInfo); static void syncStartCheckPeerConn(SSyncPeer *pPeer); @@ -378,24 +378,24 @@ int32_t syncReconfig(int64_t rid, const SSyncCfg *pNewCfg) { return 0; } -int32_t syncForwardToPeer(int64_t rid, void *data, void *mhandle, int32_t qtype) { +int32_t syncForwardToPeer(int64_t rid, void *data, void *mhandle, int32_t qtype, bool force) { if (rid <= 0) return 0; SSyncNode *pNode = syncAcquireNode(rid); if (pNode == NULL) return 0; - int32_t code = syncForwardToPeerImpl(pNode, data, mhandle, qtype); + int32_t code = syncForwardToPeerImpl(pNode, data, mhandle, qtype, force); syncReleaseNode(pNode); return code; } -void syncConfirmForward(int64_t rid, uint64_t version, int32_t code) { +void syncConfirmForward(int64_t rid, uint64_t version, int32_t code, bool force) { SSyncNode *pNode = syncAcquireNode(rid); if (pNode == NULL) return; SSyncPeer *pPeer = pNode->pMaster; - if (pPeer && pNode->quorum > 1) { + if (pPeer && (pNode->quorum > 1 || force)) { SFwdRsp rsp; syncBuildSyncFwdRsp(&rsp, pNode->vgId, version, code); @@ -1414,7 +1414,7 @@ static void syncMonitorFwdInfos(void *param, void *tmrId) { syncReleaseNode(pNode); } -static int32_t syncForwardToPeerImpl(SSyncNode *pNode, void *data, void *mhandle, int32_t qtype) { +static int32_t syncForwardToPeerImpl(SSyncNode *pNode, void *data, void *mhandle, int32_t qtype, bool force) { SSyncPeer *pPeer; SSyncHead *pSyncHead; SWalHead * pWalHead = data; @@ -1458,7 +1458,7 @@ static int32_t syncForwardToPeerImpl(SSyncNode *pNode, void *data, void *mhandle if (pPeer == NULL || pPeer->peerFd < 0) continue; if (pPeer->role != TAOS_SYNC_ROLE_SLAVE && pPeer->sstatus != TAOS_SYNC_STATUS_CACHE) continue; - if (pNode->quorum > 1 && code == 0) { + if ((pNode->quorum > 1 || force) && code == 0) { code = syncSaveFwdInfo(pNode, pWalHead->version, mhandle); if (code >= 0) code = 1; } diff --git a/src/vnode/inc/vnodeSync.h b/src/vnode/inc/vnodeSync.h index 9a7da626f8..75d7ffbabd 100644 --- a/src/vnode/inc/vnodeSync.h +++ b/src/vnode/inc/vnodeSync.h @@ -32,7 +32,7 @@ int32_t vnodeWriteToCache(int32_t vgId, void *wparam, int32_t qtype, void *rpar int32_t vnodeGetVersion(int32_t vgId, uint64_t *fver, uint64_t *wver); int32_t vnodeResetVersion(int32_t vgId, uint64_t fver); -void vnodeConfirmForward(void *pVnode, uint64_t version, int32_t code); +void vnodeConfirmForward(void *pVnode, uint64_t version, int32_t code, bool force); #ifdef __cplusplus } diff --git a/src/vnode/src/vnodeSync.c b/src/vnode/src/vnodeSync.c index 1f9c6c7216..a45eae9b16 100644 --- a/src/vnode/src/vnodeSync.c +++ b/src/vnode/src/vnodeSync.c @@ -174,7 +174,7 @@ int32_t vnodeResetVersion(int32_t vgId, uint64_t fver) { return 0; } -void vnodeConfirmForward(void *vparam, uint64_t version, int32_t code) { +void vnodeConfirmForward(void *vparam, uint64_t version, int32_t code, bool force) { SVnodeObj *pVnode = vparam; - syncConfirmForward(pVnode->sync, version, code); -} + syncConfirmForward(pVnode->sync, version, code, force); +} \ No newline at end of file diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 99b7e7b628..0551ff8d1f 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -88,7 +88,8 @@ int32_t vnodeProcessWrite(void *vparam, void *wparam, int32_t qtype, void *rpara // forward to peers, even it is WAL/FWD, it shall be called to update version in sync int32_t syncCode = 0; - syncCode = syncForwardToPeer(pVnode->sync, pHead, pWrite, qtype); + bool force = (pWrite == NULL ? false : pWrite->pHead.msgType != TSDB_MSG_TYPE_SUBMIT); + syncCode = syncForwardToPeer(pVnode->sync, pHead, pWrite, qtype, force); if (syncCode < 0) return syncCode; // write into WAL From 6c9f2db0c155b8d20f2f30751e8cb801bf777316 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 16 Mar 2021 01:39:17 +0000 Subject: [PATCH 10/89] TD-3309 --- src/kit/shell/inc/shell.h | 2 + src/kit/shell/src/shellCheck.c | 199 ++++++++++++++++++++++++++++++++ src/kit/shell/src/shellEngine.c | 6 + src/kit/shell/src/shellLinux.c | 4 + 4 files changed, 211 insertions(+) create mode 100644 src/kit/shell/src/shellCheck.c diff --git a/src/kit/shell/inc/shell.h b/src/kit/shell/inc/shell.h index 50bceb1a71..019f3e5d92 100644 --- a/src/kit/shell/inc/shell.h +++ b/src/kit/shell/inc/shell.h @@ -51,6 +51,7 @@ typedef struct SShellArguments { char file[TSDB_FILENAME_LEN]; char dir[TSDB_FILENAME_LEN]; int threadNum; + int check; char* commands; int abort; int port; @@ -71,6 +72,7 @@ void read_history(); void write_history(); void source_file(TAOS* con, char* fptr); void source_dir(TAOS* con, SShellArguments* args); +void shellCheck(TAOS* con, SShellArguments* args); void get_history_path(char* history); void cleanup_handler(void* arg); void exitShell(); diff --git a/src/kit/shell/src/shellCheck.c b/src/kit/shell/src/shellCheck.c new file mode 100644 index 0000000000..b88244ea01 --- /dev/null +++ b/src/kit/shell/src/shellCheck.c @@ -0,0 +1,199 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#define _GNU_SOURCE +#define _XOPEN_SOURCE +#define _DEFAULT_SOURCE + +#include "os.h" +#include "shell.h" +#include "shellCommand.h" +#include "tglobal.h" +#include "tutil.h" + +#define SHELL_SQL_LEN 1024 +static int32_t tbNum = 0; +static int32_t tbMallocNum = 0; +static char ** tbNames = NULL; +static int32_t checkedNum = 0; +static int32_t errorNum = 0; + +typedef struct { + pthread_t threadID; + int threadIndex; + int totalThreads; + void * taos; + char * db; +} ShellThreadObj; + +static int32_t shellUseDb(TAOS *con, char *db) { + if (db == NULL) { + fprintf(stdout, "no dbname input\n"); + return -1; + } + + char sql[SHELL_SQL_LEN] = {0}; + snprintf(sql, SHELL_SQL_LEN, "use %s", db); + + TAOS_RES *pSql = taos_query(con, sql); + int32_t code = taos_errno(pSql); + if (code != 0) { + fprintf(stdout, "failed to execute sql:%s since %s", sql, taos_errstr(pSql)); + } + + taos_free_result(pSql); + return code; +} + +static int32_t shellShowTables(TAOS *con, char *db) { + char sql[SHELL_SQL_LEN] = {0}; + snprintf(sql, SHELL_SQL_LEN, "show %s.tables", db); + + TAOS_RES *pSql = taos_query(con, sql); + int32_t code = taos_errno(pSql); + + if (code != 0) { + fprintf(stdout, "failed to execute sql:%s since %s\n", sql, taos_errstr(pSql)); + } else { + TAOS_ROW row; + while ((row = taos_fetch_row(pSql))) { + int32_t tbIndex = tbNum++; + if (tbMallocNum < tbNum) { + tbMallocNum = (tbMallocNum * 2 + 1); + tbNames = realloc(tbNames, tbMallocNum * sizeof(char *)); + if (tbNames == NULL) { + fprintf(stdout, "failed to malloc tablenames, num:%d\n", tbMallocNum); + code = TSDB_CODE_TSC_OUT_OF_MEMORY; + break; + } + } + + tbNames[tbIndex] = malloc(TSDB_TABLE_NAME_LEN); + strncpy(tbNames[tbIndex], (const char *)row[0], TSDB_TABLE_NAME_LEN); + if (tbIndex % 100000 == 0 && tbIndex != 0) { + fprintf(stdout, "%d tablenames fetched\n", tbIndex); + } + } + } + + taos_free_result(pSql); + + fprintf(stdout, "total %d tablenames fetched, over\n", tbNum); + return code; +} + +static void shellFreeTbnames() { + for (int32_t i = 0; i < tbNum; ++i) { + free(tbNames[i]); + } + free(tbNames); +} + +static void *shellCheckThreadFp(void *arg) { + ShellThreadObj *pThread = (ShellThreadObj *)arg; + + int32_t interval = tbNum / pThread->totalThreads + 1; + int32_t start = pThread->threadIndex * interval; + int32_t end = (pThread->threadIndex + 1) * interval; + + if (end > tbNum) end = tbNum + 1; + + char file[32] = {0}; + snprintf(file, 32, "tb%d.txt", pThread->threadIndex); + + FILE *fp = fopen(file, "w"); + if (!fp) { + fprintf(stdout, "failed to open %s, reason:%s", file, strerror(errno)); + return NULL; + } + + char sql[SHELL_SQL_LEN]; + for (int32_t t = start; t < end; ++t) { + char *tbname = tbNames[t]; + if (tbname == NULL) break; + + snprintf(sql, SHELL_SQL_LEN, "select * from %s limit 1", tbname); + + TAOS_RES *pSql = taos_query(pThread->taos, sql); + int32_t code = taos_errno(pSql); + if (code != 0) { + int32_t len = snprintf(sql, SHELL_SQL_LEN, "drop table %s.%s;\n", pThread->db, tbname); + fwrite(sql, 1, len, fp); + atomic_add_fetch_32(&errorNum, 1); + } + + int32_t cnum = atomic_add_fetch_32(&checkedNum, 1); + if (cnum % 5000 == 0 && cnum != 0) { + fprintf(stdout, "%d tables checked\n", cnum); + } + + taos_free_result(pSql); + } + + fsync(fileno(fp)); + fclose(fp); + + return NULL; +} + +static void shellRunCheckThreads(TAOS *con, SShellArguments *args) { + pthread_attr_t thattr; + ShellThreadObj *threadObj = (ShellThreadObj *)calloc(args->threadNum, sizeof(ShellThreadObj)); + for (int t = 0; t < args->threadNum; ++t) { + ShellThreadObj *pThread = threadObj + t; + pThread->threadIndex = t; + pThread->totalThreads = args->threadNum; + pThread->taos = con; + pThread->db = args->database; + + pthread_attr_init(&thattr); + pthread_attr_setdetachstate(&thattr, PTHREAD_CREATE_JOINABLE); + + if (pthread_create(&(pThread->threadID), &thattr, shellCheckThreadFp, (void *)pThread) != 0) { + fprintf(stderr, "ERROR: thread:%d failed to start\n", pThread->threadIndex); + exit(0); + } + } + + for (int t = 0; t < args->threadNum; ++t) { + pthread_join(threadObj[t].threadID, NULL); + } + + for (int t = 0; t < args->threadNum; ++t) { + taos_close(threadObj[t].taos); + } + free(threadObj); +} + +void shellCheck(TAOS *con, SShellArguments *args) { + int64_t start = taosGetTimestampMs(); + + if (shellUseDb(con, args->database) != 0) { + shellFreeTbnames(); + return; + } + + if (shellShowTables(con, args->database) != 0) { + shellFreeTbnames(); + return; + } + + fprintf(stdout, "total %d tables will be checked by %d threads\n", tbNum, args->threadNum); + shellRunCheckThreads(con, args); + + int64_t end = taosGetTimestampMs(); + fprintf(stdout, "total %d tables checked, failed:%d, time spent %.2f seconds\n", checkedNum, errorNum, + (end - start) / 1000.0); +} diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index a6f5869936..82b5fb3e00 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -121,6 +121,12 @@ TAOS *shellInit(SShellArguments *args) { taos_close(con); exit(EXIT_SUCCESS); } + + if (args->check != 0) { + shellCheck(con, args); + taos_close(con); + exit(EXIT_SUCCESS); + } #endif return con; diff --git a/src/kit/shell/src/shellLinux.c b/src/kit/shell/src/shellLinux.c index 07b21531a7..3f6b3da9bf 100644 --- a/src/kit/shell/src/shellLinux.c +++ b/src/kit/shell/src/shellLinux.c @@ -45,6 +45,7 @@ static struct argp_option options[] = { {"file", 'f', "FILE", 0, "Script to run without enter the shell."}, {"directory", 'D', "DIRECTORY", 0, "Use multi-thread to import all SQL files in the directory separately."}, {"thread", 'T', "THREADNUM", 0, "Number of threads when using multi-thread to import data."}, + {"check", 'k', "CHECK", 0, "Check tables."}, {"database", 'd', "DATABASE", 0, "Database to use when connecting to the server."}, {"timezone", 't', "TIMEZONE", 0, "Time zone of the shell, default is local."}, {"netrole", 'n', "NETROLE", 0, "Net role when network connectivity test, default is startup, options: client|server|rpc|startup|sync."}, @@ -130,6 +131,9 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) { return -1; } break; + case 'k': + arguments->check = atoi(arg); + break; case 'd': arguments->database = arg; break; From daa7b47ee7456849d6dec55c69fb97c08cd0901e Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 16 Mar 2021 10:14:03 +0800 Subject: [PATCH 11/89] [td-3313] : fix join bug --- src/query/src/qExecutor.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index ff5e9efb09..8f3c51d2a9 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -2366,13 +2366,13 @@ static int32_t doTSJoinFilter(SQueryRuntimeEnv *pRuntimeEnv, TSKEY key, bool asc } void filterRowsInDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFilterCols, - SSDataBlock* pBlock, STSBuf* pTsBuf, bool ascQuery) { + SSDataBlock* pBlock, bool ascQuery) { int32_t numOfRows = pBlock->info.rows; int8_t *p = calloc(numOfRows, sizeof(int8_t)); bool all = true; - if (pTsBuf != NULL) { + if (pRuntimeEnv->pTsBuf != NULL) { SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, 0); TSKEY* k = (TSKEY*) pColInfoData->pData; @@ -2393,6 +2393,9 @@ void filterRowsInDataBlock(SQueryRuntimeEnv* pRuntimeEnv, SSingleColumnFilterInf break; } } + + // save the cursor status + pRuntimeEnv->pQuery->current->cur = tsBufGetCursor(pRuntimeEnv->pTsBuf); } else { for (int32_t i = 0; i < numOfRows; ++i) { bool qualified = false; @@ -2653,8 +2656,7 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv* pRuntimeEnv, STableScanInfo* pTa doSetFilterColumnInfo(pQuery, pBlock); if (pQuery->numOfFilterCols > 0 || pRuntimeEnv->pTsBuf != NULL) { - filterRowsInDataBlock(pRuntimeEnv, pQuery->pFilterInfo, pQuery->numOfFilterCols, pBlock, pRuntimeEnv->pTsBuf, - ascQuery); + filterRowsInDataBlock(pRuntimeEnv, pQuery->pFilterInfo, pQuery->numOfFilterCols, pBlock, ascQuery); } } From 18c0457af25ac59ff5d70caa9fadaafc37f71275 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 16 Mar 2021 10:19:00 +0800 Subject: [PATCH 12/89] [td-225]fix null tag caused crash. --- src/query/src/qExecutor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 1b3d8ec294..c8295f27cf 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -2720,7 +2720,7 @@ static void doSetTagValueInParam(void* pTable, int32_t tagColId, tVariant *tag, val = tsdbGetTableTagVal(pTable, tagColId, type, bytes); } - if (isNull(val, type)) { + if (val == NULL || isNull(val, type)) { tag->nType = TSDB_DATA_TYPE_NULL; return; } @@ -6524,7 +6524,7 @@ static void doSetTagValueToResultBuf(char* output, const char* val, int16_t type if (IS_VAR_DATA_TYPE(type)) { // Binary data overflows for sort of unknown reasons. Let trim the overflow data if (varDataTLen(val) > bytes) { - int32_t len = bytes; + int32_t len = bytes - VARSTR_HEADER_SIZE; // remain available space memcpy(varDataVal(output), varDataVal(val), len); varDataSetLen(output, len); } else { From 9ff85c617e2e2baba70ed828472d2d72aea1296b Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 16 Mar 2021 10:26:24 +0800 Subject: [PATCH 13/89] [td-3313] add test script. --- tests/script/general/parser/join.sim | 2 +- .../script/general/parser/join_manyblocks.sim | 93 +++++++++++++++++++ 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 tests/script/general/parser/join_manyblocks.sim diff --git a/tests/script/general/parser/join.sim b/tests/script/general/parser/join.sim index 73f83f1c9e..2c14a86c3a 100644 --- a/tests/script/general/parser/join.sim +++ b/tests/script/general/parser/join.sim @@ -448,7 +448,7 @@ endi sql select first(join_tb0.c8),first(join_tb0.c9) from join_tb1 , join_tb0 where join_tb1.ts = join_tb0.ts and join_tb1.ts <= 100002 and join_tb0.c7 = true #====================group by========================================= - +print =================>"group by not supported" diff --git a/tests/script/general/parser/join_manyblocks.sim b/tests/script/general/parser/join_manyblocks.sim new file mode 100644 index 0000000000..fddd59c0a1 --- /dev/null +++ b/tests/script/general/parser/join_manyblocks.sim @@ -0,0 +1,93 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c walLevel -v 1 +system sh/cfg.sh -n dnode1 -c maxtablespervnode -v 4 + +system sh/exec.sh -n dnode1 -s start +sql connect +sleep 100 + +$dbPrefix = join_m_db +$tbPrefix = join_tb +$mtPrefix = join_mt +$tbNum = 3 +$rowNum = 20000 +$totalNum = $tbNum * $rowNum + +print =============== join_manyBlocks.sim +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +$tstart = 100000 + +sql drop database if exists $db -x step1 +step1: +sql create database if not exists $db keep 36500 + +sql use $db +sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) + +$mt1 = $mtPrefix . 1 . $i +sql create table $mt1 (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12), t3 int) + +$i = 0 +$tbPrefix1 = join_1_tb + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + $tg2 = ' . abc + $tg2 = $tg2 . ' + sql create table $tb using $mt tags( $i , $tg2 ) + + $tb1 = $tbPrefix1 . $i + $c = $i + $t3 = $i + 1 + + $binary = ' . abc + $binary = $binary . $i + $binary = $binary . ' + + print $binary + sql create table $tb1 using $mt1 tags( $i , $binary , $t3 ) + + $x = 0 + while $x < $rowNum + $ms = $x . m + $c = $x / 100 + $c = $c * 100 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + $nchar = ' . nchar + $nchar = $nchar . $c + $nchar = $nchar . ' + + sql insert into $tb values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) $tb1 values ($tstart , $c , $c , $c , $c , $c , $c , $c , $binary , $nchar ) + + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 100000 +endw + +sleep 100 + +print ===============join_manyblocks.sim +print ==============> td-3313 +sql select join_mt0.ts,join_mt0.ts,join_mt0.t1 from join_mt0, join_mt1 where join_mt0.ts=join_mt1.ts and join_mt0.t1=join_mt1.t1; + +print $row +if $row != 60000 then + print expect 60000, actual: $row + return -1 +endi + +print ======= second tags join From 497a0e3b3194335c5c0b914ad864bbe509b2b1d8 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 16 Mar 2021 10:52:48 +0800 Subject: [PATCH 14/89] [td-2859]refactor. --- src/client/src/tscSQLParser.c | 47 ++-- src/client/src/tscUtil.c | 2 +- src/query/inc/qSqlparser.h | 40 ++- src/query/inc/sql.y | 30 +-- src/query/src/qSqlParser.c | 53 +++- src/query/src/sql.c | 485 +++++++++++++++++----------------- 6 files changed, 358 insertions(+), 299 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 29eaecfea0..b58cc41f25 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6374,12 +6374,12 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } - SArray* pSrcMeterName = pInfo->pCreateTableInfo->pSelect->from; - if (pSrcMeterName == NULL || taosArrayGetSize(pSrcMeterName) == 0) { + SFromInfo* pFromInfo = pInfo->pCreateTableInfo->pSelect->from; + if (pFromInfo == NULL || taosArrayGetSize(pFromInfo->tableList) == 0) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6); } - tVariantListItem* p1 = taosArrayGet(pSrcMeterName, 0); + tVariantListItem* p1 = taosArrayGet(pFromInfo->tableList, 0); SStrToken srcToken = {.z = p1->pVar.pz, .n = p1->pVar.nLen, .type = TK_STRING}; if (tscValidateName(&srcToken) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); @@ -6498,7 +6498,7 @@ static int32_t checkQueryRangeForFill(SSqlCmd* pCmd, SQueryInfo* pQueryInfo) { } int32_t doValidateSqlNode(SSqlObj* pSql, SQuerySqlNode* pQuerySqlNode, int32_t index) { - assert(pQuerySqlNode != NULL && (pQuerySqlNode->from == NULL || taosArrayGetSize(pQuerySqlNode->from) > 0)); + assert(pQuerySqlNode != NULL && (pQuerySqlNode->from == NULL || taosArrayGetSize(pQuerySqlNode->from->tableList) > 0)); const char* msg0 = "invalid table name"; const char* msg1 = "point interpolation query needs timestamp"; @@ -6539,60 +6539,59 @@ int32_t doValidateSqlNode(SSqlObj* pSql, SQuerySqlNode* pQuerySqlNode, int32_t i return doLocalQueryProcess(pCmd, pQueryInfo, pQuerySqlNode); } - size_t fromSize = taosArrayGetSize(pQuerySqlNode->from); - if (fromSize > TSDB_MAX_JOIN_TABLE_NUM * 2) { + size_t fromSize = taosArrayGetSize(pQuerySqlNode->from->tableList); + if (fromSize > TSDB_MAX_JOIN_TABLE_NUM) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg4); } pQueryInfo->command = TSDB_SQL_SELECT; - if (fromSize > 4) { + if (fromSize > 2) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6); } // set all query tables, which are maybe more than one. for (int32_t i = 0; i < fromSize; ) { - tVariantListItem* item = taosArrayGet(pQuerySqlNode->from, i); - tVariant* pTableItem = &item->pVar; + STableNamePair* item = taosArrayGet(pQuerySqlNode->from->tableList, i); + SStrToken* pTableItem = &item->name; - if (pTableItem->nType != TSDB_DATA_TYPE_BINARY) { + if (pTableItem->type != TSDB_DATA_TYPE_BINARY) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg0); } - pTableItem->nLen = strdequote(pTableItem->pz); + pTableItem->n = strdequote(pTableItem->z); - SStrToken tableName = {.z = pTableItem->pz, .n = pTableItem->nLen, .type = TK_STRING}; + SStrToken tableName = {.z = pTableItem->z, .n = pTableItem->n, .type = TK_STRING}; if (tscValidateName(&tableName) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg0); } - if (pQueryInfo->numOfTables <= i/2) { // more than one table + if (pQueryInfo->numOfTables <= i) { // more than one table tscAddEmptyMetaInfo(pQueryInfo); } STableMetaInfo* pTableMetaInfo1 = tscGetMetaInfo(pQueryInfo, i/2); - SStrToken t = {.type = TSDB_DATA_TYPE_BINARY, .n = pTableItem->nLen, .z = pTableItem->pz}; + SStrToken t = {.type = TSDB_DATA_TYPE_BINARY, .n = pTableItem->n, .z = pTableItem->z}; code = tscSetTableFullName(pTableMetaInfo1, &t, pSql); if (code != TSDB_CODE_SUCCESS) { return code; } - tVariantListItem* p1 = taosArrayGet(pQuerySqlNode->from, i + 1); - if (p1->pVar.nType != TSDB_DATA_TYPE_BINARY) { + SStrToken* aliasName = &item->aliasName; + if (aliasName->type != TSDB_DATA_TYPE_BINARY) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7); } - SStrToken aliasName = {.z = p1->pVar.pz, .n = p1->pVar.nLen, .type = TK_STRING}; - if (tscValidateName(&aliasName) != TSDB_CODE_SUCCESS) { + if (TPARSER_HAS_TOKEN(*aliasName) && tscValidateName(aliasName) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7); } // has no table alias name - if (memcmp(pTableItem->pz, p1->pVar.pz, p1->pVar.nLen) == 0) { - strncpy(pTableMetaInfo1->aliasName, tNameGetTableName(&pTableMetaInfo1->name), tListLen(pTableMetaInfo->aliasName)); + if (!TPARSER_HAS_TOKEN(*aliasName)) { + strncpy(pTableMetaInfo1->aliasName, tNameGetTableName(&pTableMetaInfo1->name), tListLen(pTableMetaInfo1->aliasName)); } else { - tstrncpy(pTableMetaInfo1->aliasName, p1->pVar.pz, sizeof(pTableMetaInfo1->aliasName)); + tstrncpy(pTableMetaInfo1->aliasName, aliasName->z, sizeof(pTableMetaInfo1->aliasName)); } code = tscGetTableMeta(pSql, pTableMetaInfo1); @@ -6603,7 +6602,7 @@ int32_t doValidateSqlNode(SSqlObj* pSql, SQuerySqlNode* pQuerySqlNode, int32_t i i += 2; } - assert(pQueryInfo->numOfTables == taosArrayGetSize(pQuerySqlNode->from) / 2); + assert(pQueryInfo->numOfTables == taosArrayGetSize(pQuerySqlNode->from->tableList) / 2); bool isSTable = false; if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { @@ -6637,12 +6636,12 @@ int32_t doValidateSqlNode(SSqlObj* pSql, SQuerySqlNode* pQuerySqlNode, int32_t i pQueryInfo->window.ekey = pQueryInfo->window.ekey / 1000; } } else { // set the time rang - if (taosArrayGetSize(pQuerySqlNode->from) > 2) { // it is a join query, no wher clause is not allowed. + if (taosArrayGetSize(pQuerySqlNode->from->tableList) > 1) { // it is a join query, no where clause is not allowed. return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), "condition missing for join query "); } } - int32_t joinQuery = (pQuerySqlNode->from != NULL && taosArrayGetSize(pQuerySqlNode->from) > 2); + int32_t joinQuery = (pQuerySqlNode->from != NULL && taosArrayGetSize(pQuerySqlNode->from->tableList) > 1); int32_t timeWindowQuery = (TPARSER_HAS_TOKEN(pQuerySqlNode->interval.interval) || TPARSER_HAS_TOKEN(pQuerySqlNode->sessionVal.gap)); diff --git a/src/client/src/tscUtil.c b/src/client/src/tscUtil.c index 2d5e8382a4..e899450261 100644 --- a/src/client/src/tscUtil.c +++ b/src/client/src/tscUtil.c @@ -1159,7 +1159,7 @@ SSqlExpr* tscSqlExprInsert(SQueryInfo* pQueryInfo, int32_t index, int16_t functi } SSqlExpr* tscSqlExprAppend(SQueryInfo* pQueryInfo, int16_t functionId, SColumnIndex* pColIndex, int16_t type, - int16_t size, int16_t resColId, int16_t interSize, bool isTagCol) { + int16_t size, int16_t resColId, int16_t interSize, bool isTagCol) { SSqlExpr* pExpr = doCreateSqlExpr(pQueryInfo, functionId, pColIndex, type, size, resColId, interSize, isTagCol); taosArrayPush(pQueryInfo->exprList, &pExpr); return pExpr; diff --git a/src/query/inc/qSqlparser.h b/src/query/inc/qSqlparser.h index 858779c5f2..3ce81787f0 100644 --- a/src/query/inc/qSqlparser.h +++ b/src/query/inc/qSqlparser.h @@ -39,6 +39,11 @@ enum SQL_NODE_TYPE { SQL_NODE_EXPR = 4, }; +enum SQL_NODE_FROM_TYPE { + SQL_NODE_FROM_SUBQUERY = 1, + SQL_NODE_FROM_NAMELIST = 2, +}; + extern char tTokenTypeSwitcher[13]; #define toTSDBType(x) \ @@ -78,12 +83,14 @@ typedef struct SSessionWindowVal { SStrToken gap; } SSessionWindowVal; +struct SFromInfo; + typedef struct SQuerySqlNode { struct SArray *pSelectList; // select clause - SArray *from; // from clause SArray + struct SFromInfo *from; // from clause SArray struct tSqlExpr *pWhere; // where clause [optional] SArray *pGroupby; // groupby clause, only for tags[optional], SArray - SArray *pSortOrder; // orderby [optional], SArray + SArray *pSortOrder; // orderby [optional], SArray SArray *fillType; // fill type[optional], SArray SIntervalVal interval; // (interval, interval_offset) [optional] SSessionWindowVal sessionVal; // session window [optional] @@ -93,6 +100,24 @@ typedef struct SQuerySqlNode { SStrToken sqlstr; // sql string in select clause } SQuerySqlNode; +typedef struct STableNamePair { + SStrToken name; + SStrToken aliasName; +} STableNamePair; + +typedef struct SSubclauseInfo { // "UNION" multiple select sub-clause + SQuerySqlNode **pClause; + int32_t numOfClause; +} SSubclauseInfo; + +typedef struct SFromInfo { + int32_t type; // nested query|table name list + union { + SSubclauseInfo *pNode; + SArray *tableList; // SArray + }; +} SFromInfo; + typedef struct SCreatedTableInfo { SStrToken name; // table name token SStrToken stableName; // super table name token , for using clause @@ -188,11 +213,6 @@ typedef struct SMiscInfo { }; } SMiscInfo; -typedef struct SSubclauseInfo { // "UNION" multiple select sub-clause - SQuerySqlNode **pClause; - int32_t numOfClause; -} SSubclauseInfo; - typedef struct SSqlInfo { int32_t type; bool valid; @@ -233,6 +253,10 @@ SArray *tVariantListAppend(SArray *pList, tVariant *pVar, uint8_t sortOrder); SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int32_t index); SArray *tVariantListAppendToken(SArray *pList, SStrToken *pAliasToken, uint8_t sortOrder); +SFromInfo *setTableNameList(SFromInfo* pFromInfo, SStrToken *pName, SStrToken* pAlias); +SFromInfo *setSubquery(SFromInfo* pFromInfo, SQuerySqlNode *pSqlNode); +void *destroyFromInfo(SFromInfo* pFromInfo); + // sql expr leaf node tSqlExpr *tSqlExprCreateIdValue(SStrToken *pToken, int32_t optrType); tSqlExpr *tSqlExprCreateFunction(SArray *pParam, SStrToken *pFuncToken, SStrToken *endToken, int32_t optType); @@ -246,7 +270,7 @@ void tSqlExprDestroy(tSqlExpr *pExpr); SArray *tSqlExprListAppend(SArray *pList, tSqlExpr *pNode, SStrToken *pDistinct, SStrToken *pToken); void tSqlExprListDestroy(SArray *pList); -SQuerySqlNode *tSetQuerySqlNode(SStrToken *pSelectToken, SArray *pSelectList, SArray *pFrom, tSqlExpr *pWhere, +SQuerySqlNode *tSetQuerySqlNode(SStrToken *pSelectToken, SArray *pSelectList, SFromInfo *pFrom, tSqlExpr *pWhere, SArray *pGroupby, SArray *pSortOrder, SIntervalVal *pInterval, SSessionWindowVal *ps, SStrToken *pSliding, SArray *pFill, SLimitVal *pLimit, SLimitVal *pgLimit); diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 0d7f1e9755..aa9b7945a5 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -456,20 +456,20 @@ select(A) ::= SELECT(T) selcollist(W) from(X) where_opt(Y) interval_opt(K) sessi A = tSetQuerySqlNode(&T, W, X, Y, P, Z, &K, &H, &S, F, &L, &G); } +select(A) ::= LP select(B) RP. {A = B;} + %type union {SSubclauseInfo*} %destructor union {destroyAllSelectClause($$);} - union(Y) ::= select(X). { Y = setSubclause(NULL, X); } -union(Y) ::= LP union(X) RP. { Y = X; } union(Y) ::= union(Z) UNION ALL select(X). { Y = appendSelectClause(Z, X); } -union(Y) ::= union(Z) UNION ALL LP select(X) RP. { Y = appendSelectClause(Z, X); } cmd ::= union(X). { setSqlInfo(pInfo, X, NULL, TSDB_SQL_SELECT); } // Support for the SQL exprssion without from & where subclauses, e.g., -// select current_database(), -// select server_version(), select client_version(), -// select server_state(); +// select current_database() +// select server_version() +// select client_version() +// select server_state() select(A) ::= SELECT(T) selcollist(W). { A = tSetQuerySqlNode(&T, W, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } @@ -495,7 +495,6 @@ selcollist(A) ::= sclp(P) STAR. { // An option "AS " phrase that can follow one of the expressions that // define the result set, or one of the tables in the FROM clause. -// %type as {SStrToken} as(X) ::= AS ids(Y). { X = Y; } as(X) ::= ids(Y). { X = Y; } @@ -506,39 +505,36 @@ distinct(X) ::= DISTINCT(Y). { X = Y; } distinct(X) ::= . { X.n = 0;} // A complete FROM clause. -%type from {SArray*} -// current not support query from no-table +%type from {SFromInfo*} from(A) ::= FROM tablelist(X). {A = X;} +from(A) ::= FROM LP union(Y) RP. {A = Y;} %type tablelist {SArray*} tablelist(A) ::= ids(X) cpxName(Y). { toTSDBType(X.type); X.n += Y.n; - A = tVariantListAppendToken(NULL, &X, -1); - A = tVariantListAppendToken(A, &X, -1); // table alias name + A = setTableNameList(NULL, &X, NULL); } tablelist(A) ::= ids(X) cpxName(Y) ids(Z). { toTSDBType(X.type); toTSDBType(Z.type); X.n += Y.n; - A = tVariantListAppendToken(NULL, &X, -1); - A = tVariantListAppendToken(A, &Z, -1); + A = setTableNameList(NULL, &X, &Y); } tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z). { toTSDBType(X.type); X.n += Z.n; - A = tVariantListAppendToken(Y, &X, -1); - A = tVariantListAppendToken(A, &X, -1); + A = setTableNameList(Y, &X, NULL); } tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z) ids(F). { toTSDBType(X.type); toTSDBType(F.type); X.n += Z.n; - A = tVariantListAppendToken(Y, &X, -1); - A = tVariantListAppendToken(A, &F, -1); + + A = setTableNameList(Y, &X, &F); } // The value of interval should be the form of "number+[a,s,m,h,d,n,y]" or "now" diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c index 669e182be5..d7c708d9ef 100644 --- a/src/query/src/qSqlParser.c +++ b/src/query/src/qSqlParser.c @@ -443,6 +443,49 @@ SArray *tVariantListInsert(SArray *pList, tVariant *pVar, uint8_t sortOrder, int return pList; } +SFromInfo *setTableNameList(SFromInfo* pFromInfo, SStrToken *pName, SStrToken* pAlias) { + if (pFromInfo == NULL) { + pFromInfo = calloc(1, sizeof(SFromInfo)); + pFromInfo->tableList = taosArrayInit(4, sizeof(STableNamePair)); + } + + pFromInfo->type = SQL_NODE_FROM_NAMELIST; + STableNamePair p = {.name = *pName}; + if (pAlias != NULL) { + p.aliasName = *pAlias; + } else { + TPARSER_SET_NONE_TOKEN(p.aliasName); + } + + taosArrayPush(pFromInfo->tableList, &p); + + return pFromInfo; +} + +SFromInfo *setSubquery(SFromInfo* pFromInfo, SQuerySqlNode* pSqlNode) { + if (pFromInfo == NULL) { + pFromInfo = calloc(1, sizeof(SFromInfo)); + } + + pFromInfo->type = SQL_NODE_FROM_SUBQUERY; + pFromInfo->pNode->pClause[pFromInfo->pNode->numOfClause - 1] = pSqlNode; + + return pFromInfo; +} + +void* destroyFromInfo(SFromInfo* pFromInfo) { + assert(pFromInfo != NULL); + if (pFromInfo->type == SQL_NODE_FROM_NAMELIST) { + taosArrayDestroy(pFromInfo->tableList); + } else { + destroyAllSelectClause(pFromInfo->pNode); + } + + tfree(pFromInfo); + return NULL; +} + + void tSetDbName(SStrToken *pCpxName, SStrToken *pDb) { pCpxName->type = pDb->type; pCpxName->z = pDb->z; @@ -582,9 +625,10 @@ void tSetColumnType(TAOS_FIELD *pField, SStrToken *type) { /* * extract the select info out of sql string */ -SQuerySqlNode *tSetQuerySqlNode(SStrToken *pSelectToken, SArray *pSelectList, SArray *pFrom, tSqlExpr *pWhere, - SArray *pGroupby, SArray *pSortOrder, SIntervalVal *pInterval, SSessionWindowVal *pSession, - SStrToken *pSliding, SArray *pFill, SLimitVal *pLimit, SLimitVal *psLimit) { +SQuerySqlNode *tSetQuerySqlNode(SStrToken *pSelectToken, SArray *pSelectList, SFromInfo *pFrom, tSqlExpr *pWhere, + SArray *pGroupby, SArray *pSortOrder, SIntervalVal *pInterval, + SSessionWindowVal *pSession, SStrToken *pSliding, SArray *pFill, SLimitVal *pLimit, + SLimitVal *psLimit) { assert(pSelectList != NULL); SQuerySqlNode *pSqlNode = calloc(1, sizeof(SQuerySqlNode)); @@ -668,8 +712,7 @@ void destroyQuerySqlNode(SQuerySqlNode *pQuerySql) { taosArrayDestroyEx(pQuerySql->pGroupby, freeVariant); pQuerySql->pGroupby = NULL; - taosArrayDestroyEx(pQuerySql->from, freeVariant); - pQuerySql->from = NULL; + pQuerySql->from = destroyFromInfo(pQuerySql->from); taosArrayDestroyEx(pQuerySql->fillType, freeVariant); pQuerySql->fillType = NULL; diff --git a/src/query/src/sql.c b/src/query/src/sql.c index c6d6d0c931..ee2a694987 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -104,9 +104,9 @@ typedef union { int yyinit; ParseTOKENTYPE yy0; SCreatedTableInfo yy96; + SFromInfo* yy162; tSqlExpr* yy178; SCreateAcctInfo yy187; - SCreateTableSql* yy230; SArray* yy285; TAOS_FIELD yy295; SQuerySqlNode* yy342; @@ -114,6 +114,7 @@ typedef union { SIntervalVal yy376; SLimitVal yy438; int yy460; + SCreateTableSql* yy470; SSubclauseInfo* yy513; SSessionWindowVal yy523; int64_t yy525; @@ -203,76 +204,76 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (675) +#define YY_ACTTAB_COUNT (676) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 910, 549, 201, 310, 205, 138, 938, 3, 166, 550, - /* 10 */ 768, 312, 17, 47, 48, 138, 51, 52, 30, 180, + /* 0 */ 910, 549, 201, 310, 205, 139, 937, 3, 166, 550, + /* 10 */ 768, 312, 17, 47, 48, 139, 51, 52, 30, 180, /* 20 */ 213, 41, 180, 50, 260, 55, 53, 57, 54, 1016, /* 30 */ 916, 208, 1017, 46, 45, 178, 180, 44, 43, 42, /* 40 */ 47, 48, 219, 51, 52, 207, 1017, 213, 41, 549, - /* 50 */ 50, 260, 55, 53, 57, 54, 927, 550, 184, 203, - /* 60 */ 46, 45, 913, 218, 44, 43, 42, 48, 935, 51, + /* 50 */ 50, 260, 55, 53, 57, 54, 928, 550, 184, 202, + /* 60 */ 46, 45, 913, 218, 44, 43, 42, 48, 934, 51, /* 70 */ 52, 240, 968, 213, 41, 549, 50, 260, 55, 53, - /* 80 */ 57, 54, 969, 550, 255, 220, 46, 45, 82, 916, + /* 80 */ 57, 54, 969, 550, 255, 220, 46, 45, 276, 916, /* 90 */ 44, 43, 42, 503, 504, 505, 506, 507, 508, 509, - /* 100 */ 510, 511, 512, 513, 514, 515, 311, 628, 815, 230, - /* 110 */ 70, 916, 165, 47, 48, 30, 51, 52, 276, 30, - /* 120 */ 213, 41, 904, 50, 260, 55, 53, 57, 54, 44, - /* 130 */ 43, 42, 714, 46, 45, 286, 285, 44, 43, 42, - /* 140 */ 47, 49, 824, 51, 52, 224, 165, 213, 41, 24, - /* 150 */ 50, 260, 55, 53, 57, 54, 216, 36, 902, 913, + /* 100 */ 510, 511, 512, 513, 514, 515, 311, 628, 84, 230, + /* 110 */ 69, 916, 296, 47, 48, 30, 51, 52, 1013, 30, + /* 120 */ 213, 41, 549, 50, 260, 55, 53, 57, 54, 1012, + /* 130 */ 550, 306, 714, 46, 45, 286, 285, 44, 43, 42, + /* 140 */ 47, 49, 904, 51, 52, 224, 1011, 213, 41, 667, + /* 150 */ 50, 260, 55, 53, 57, 54, 216, 916, 902, 913, /* 160 */ 46, 45, 222, 912, 44, 43, 42, 23, 274, 305, /* 170 */ 304, 273, 272, 271, 303, 270, 302, 301, 300, 269, - /* 180 */ 299, 298, 876, 138, 864, 865, 866, 867, 868, 869, + /* 180 */ 299, 298, 876, 139, 864, 865, 866, 867, 868, 869, /* 190 */ 870, 871, 872, 873, 874, 875, 877, 878, 51, 52, - /* 200 */ 816, 306, 213, 41, 165, 50, 260, 55, 53, 57, - /* 210 */ 54, 296, 18, 79, 226, 46, 45, 283, 282, 44, - /* 220 */ 43, 42, 212, 727, 927, 131, 718, 916, 721, 189, - /* 230 */ 724, 223, 212, 727, 278, 190, 718, 276, 721, 202, - /* 240 */ 724, 115, 114, 188, 899, 900, 29, 903, 257, 233, - /* 250 */ 76, 309, 308, 123, 209, 210, 237, 236, 259, 138, - /* 260 */ 23, 225, 305, 304, 209, 210, 69, 303, 979, 302, - /* 270 */ 301, 300, 24, 299, 298, 884, 102, 30, 882, 883, - /* 280 */ 36, 296, 78, 885, 1013, 887, 888, 886, 245, 889, - /* 290 */ 890, 55, 53, 57, 54, 71, 914, 261, 901, 46, - /* 300 */ 45, 668, 239, 44, 43, 42, 100, 105, 30, 196, - /* 310 */ 1, 153, 94, 104, 110, 113, 103, 720, 217, 723, - /* 320 */ 129, 913, 107, 5, 155, 56, 77, 30, 36, 33, - /* 330 */ 154, 89, 84, 88, 30, 56, 173, 169, 726, 719, - /* 340 */ 30, 722, 171, 168, 118, 117, 116, 12, 726, 279, - /* 350 */ 211, 81, 913, 149, 725, 660, 46, 45, 695, 696, - /* 360 */ 44, 43, 42, 242, 725, 243, 665, 652, 280, 31, - /* 370 */ 649, 913, 650, 25, 651, 284, 680, 716, 913, 672, - /* 380 */ 133, 288, 686, 687, 913, 747, 60, 20, 728, 19, - /* 390 */ 61, 1012, 19, 730, 6, 64, 638, 263, 227, 228, - /* 400 */ 31, 31, 640, 265, 639, 1011, 60, 80, 60, 93, - /* 410 */ 92, 28, 62, 717, 266, 65, 14, 13, 67, 197, - /* 420 */ 627, 99, 98, 198, 16, 15, 656, 654, 657, 655, - /* 430 */ 112, 111, 128, 126, 182, 1026, 183, 185, 179, 186, - /* 440 */ 915, 187, 193, 194, 192, 177, 191, 181, 978, 929, - /* 450 */ 214, 975, 974, 215, 287, 130, 39, 937, 148, 944, - /* 460 */ 946, 132, 136, 36, 241, 961, 960, 150, 909, 127, - /* 470 */ 679, 246, 911, 204, 248, 140, 653, 151, 141, 926, - /* 480 */ 152, 827, 63, 253, 66, 268, 37, 175, 34, 139, - /* 490 */ 58, 258, 277, 823, 1031, 90, 1030, 1028, 156, 256, - /* 500 */ 281, 1025, 96, 1024, 142, 1022, 254, 157, 845, 35, - /* 510 */ 32, 38, 176, 812, 106, 252, 810, 108, 109, 808, - /* 520 */ 807, 229, 167, 805, 804, 803, 250, 802, 801, 800, - /* 530 */ 170, 172, 797, 795, 793, 791, 789, 174, 247, 244, - /* 540 */ 72, 73, 249, 962, 40, 297, 101, 289, 290, 291, - /* 550 */ 292, 293, 294, 199, 295, 221, 307, 267, 766, 231, - /* 560 */ 232, 765, 234, 235, 200, 85, 86, 195, 764, 752, - /* 570 */ 238, 242, 662, 74, 68, 8, 262, 806, 681, 799, - /* 580 */ 164, 846, 160, 158, 159, 162, 161, 163, 119, 2, - /* 590 */ 120, 121, 880, 798, 4, 122, 790, 134, 147, 143, - /* 600 */ 144, 145, 146, 135, 684, 75, 206, 251, 137, 892, - /* 610 */ 688, 26, 9, 10, 729, 27, 7, 11, 731, 21, - /* 620 */ 22, 264, 83, 591, 587, 81, 585, 584, 583, 580, - /* 630 */ 553, 275, 31, 87, 91, 630, 59, 629, 95, 626, - /* 640 */ 575, 573, 565, 571, 567, 569, 97, 563, 561, 594, - /* 650 */ 593, 592, 590, 589, 588, 586, 582, 581, 60, 551, - /* 660 */ 519, 517, 124, 770, 769, 769, 769, 769, 769, 769, - /* 670 */ 769, 769, 769, 769, 125, + /* 200 */ 815, 197, 213, 41, 165, 50, 260, 55, 53, 57, + /* 210 */ 54, 198, 18, 81, 226, 46, 45, 283, 282, 44, + /* 220 */ 43, 42, 212, 727, 928, 25, 718, 671, 721, 189, + /* 230 */ 724, 223, 212, 727, 278, 190, 718, 276, 721, 203, + /* 240 */ 724, 117, 116, 188, 899, 900, 29, 903, 257, 233, + /* 250 */ 77, 44, 43, 42, 209, 210, 237, 236, 259, 139, + /* 260 */ 23, 104, 305, 304, 209, 210, 296, 303, 79, 302, + /* 270 */ 301, 300, 73, 299, 298, 884, 132, 30, 882, 883, + /* 280 */ 36, 70, 225, 885, 824, 887, 888, 886, 165, 889, + /* 290 */ 890, 55, 53, 57, 54, 182, 309, 308, 125, 46, + /* 300 */ 45, 1026, 239, 44, 43, 42, 102, 107, 30, 196, + /* 310 */ 261, 73, 96, 106, 112, 115, 105, 914, 217, 36, + /* 320 */ 674, 913, 109, 5, 155, 56, 78, 30, 243, 33, + /* 330 */ 154, 91, 86, 90, 30, 56, 173, 169, 726, 245, + /* 340 */ 30, 68, 171, 168, 120, 119, 118, 12, 726, 279, + /* 350 */ 183, 83, 913, 80, 725, 28, 46, 45, 266, 816, + /* 360 */ 44, 43, 42, 165, 725, 1, 153, 652, 280, 716, + /* 370 */ 649, 913, 650, 901, 651, 284, 695, 696, 913, 664, + /* 380 */ 720, 288, 723, 241, 913, 680, 24, 31, 686, 134, + /* 390 */ 687, 747, 60, 728, 20, 19, 211, 19, 227, 228, + /* 400 */ 719, 61, 722, 185, 638, 717, 730, 64, 31, 263, + /* 410 */ 640, 265, 639, 31, 60, 82, 60, 179, 95, 94, + /* 420 */ 186, 14, 13, 62, 101, 100, 67, 65, 627, 187, + /* 430 */ 16, 15, 656, 654, 657, 655, 114, 113, 130, 128, + /* 440 */ 6, 193, 194, 192, 177, 191, 181, 915, 979, 131, + /* 450 */ 978, 214, 975, 974, 215, 287, 936, 39, 961, 944, + /* 460 */ 946, 133, 960, 929, 244, 137, 129, 150, 911, 149, + /* 470 */ 242, 909, 679, 246, 151, 204, 653, 247, 258, 256, + /* 480 */ 66, 152, 827, 268, 63, 926, 37, 140, 175, 34, + /* 490 */ 248, 253, 277, 823, 1031, 92, 58, 141, 254, 142, + /* 500 */ 1030, 1028, 156, 281, 1025, 98, 1024, 1022, 157, 845, + /* 510 */ 35, 32, 38, 176, 252, 144, 812, 108, 810, 110, + /* 520 */ 111, 808, 807, 229, 167, 805, 804, 803, 250, 802, + /* 530 */ 801, 800, 170, 172, 797, 795, 793, 791, 789, 174, + /* 540 */ 40, 71, 74, 249, 962, 297, 103, 289, 290, 291, + /* 550 */ 292, 293, 294, 295, 307, 199, 766, 221, 231, 232, + /* 560 */ 267, 765, 234, 235, 764, 752, 200, 195, 238, 87, + /* 570 */ 88, 243, 75, 8, 262, 659, 72, 806, 681, 121, + /* 580 */ 206, 135, 122, 799, 160, 123, 159, 846, 158, 161, + /* 590 */ 162, 164, 163, 798, 684, 124, 880, 790, 2, 136, + /* 600 */ 4, 145, 143, 146, 147, 76, 148, 251, 892, 688, + /* 610 */ 138, 26, 264, 729, 9, 10, 27, 7, 11, 21, + /* 620 */ 731, 22, 85, 591, 83, 587, 585, 584, 583, 580, + /* 630 */ 553, 275, 93, 89, 31, 59, 630, 97, 99, 629, + /* 640 */ 626, 575, 573, 565, 571, 567, 569, 563, 561, 594, + /* 650 */ 593, 592, 590, 589, 588, 586, 582, 581, 60, 519, + /* 660 */ 551, 517, 770, 769, 769, 769, 769, 769, 769, 769, + /* 670 */ 769, 769, 769, 769, 126, 127, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 192, 1, 191, 192, 211, 192, 192, 195, 196, 9, @@ -283,66 +284,66 @@ static const YYCODETYPE yy_lookahead[] = { /* 50 */ 23, 24, 25, 26, 27, 28, 235, 9, 253, 233, /* 60 */ 33, 34, 236, 211, 37, 38, 39, 14, 254, 16, /* 70 */ 17, 250, 259, 20, 21, 1, 23, 24, 25, 26, - /* 80 */ 27, 28, 259, 9, 261, 211, 33, 34, 198, 237, + /* 80 */ 27, 28, 259, 9, 261, 211, 33, 34, 79, 237, /* 90 */ 37, 38, 39, 45, 46, 47, 48, 49, 50, 51, - /* 100 */ 52, 53, 54, 55, 56, 57, 58, 5, 197, 61, - /* 110 */ 110, 237, 201, 13, 14, 192, 16, 17, 79, 192, - /* 120 */ 20, 21, 232, 23, 24, 25, 26, 27, 28, 37, - /* 130 */ 38, 39, 105, 33, 34, 33, 34, 37, 38, 39, - /* 140 */ 13, 14, 197, 16, 17, 67, 201, 20, 21, 104, - /* 150 */ 23, 24, 25, 26, 27, 28, 233, 112, 0, 236, + /* 100 */ 52, 53, 54, 55, 56, 57, 58, 5, 198, 61, + /* 110 */ 110, 237, 81, 13, 14, 192, 16, 17, 253, 192, + /* 120 */ 20, 21, 1, 23, 24, 25, 26, 27, 28, 253, + /* 130 */ 9, 211, 105, 33, 34, 33, 34, 37, 38, 39, + /* 140 */ 13, 14, 232, 16, 17, 67, 253, 20, 21, 37, + /* 150 */ 23, 24, 25, 26, 27, 28, 233, 237, 0, 236, /* 160 */ 33, 34, 67, 236, 37, 38, 39, 88, 89, 90, /* 170 */ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, /* 180 */ 101, 102, 210, 192, 212, 213, 214, 215, 216, 217, /* 190 */ 218, 219, 220, 221, 222, 223, 224, 225, 16, 17, - /* 200 */ 197, 211, 20, 21, 201, 23, 24, 25, 26, 27, - /* 210 */ 28, 81, 44, 198, 136, 33, 34, 139, 140, 37, - /* 220 */ 38, 39, 1, 2, 235, 192, 5, 237, 7, 61, + /* 200 */ 197, 253, 20, 21, 201, 23, 24, 25, 26, 27, + /* 210 */ 28, 253, 44, 198, 136, 33, 34, 139, 140, 37, + /* 220 */ 38, 39, 1, 2, 235, 104, 5, 115, 7, 61, /* 230 */ 9, 136, 1, 2, 139, 67, 5, 79, 7, 250, /* 240 */ 9, 73, 74, 75, 229, 230, 231, 232, 257, 135, - /* 250 */ 259, 64, 65, 66, 33, 34, 142, 143, 37, 192, - /* 260 */ 88, 192, 90, 91, 33, 34, 198, 95, 228, 97, - /* 270 */ 98, 99, 104, 101, 102, 210, 76, 192, 213, 214, - /* 280 */ 112, 81, 238, 218, 253, 220, 221, 222, 255, 224, - /* 290 */ 225, 25, 26, 27, 28, 251, 227, 15, 230, 33, - /* 300 */ 34, 37, 134, 37, 38, 39, 62, 63, 192, 141, - /* 310 */ 199, 200, 68, 69, 70, 71, 72, 5, 233, 7, - /* 320 */ 104, 236, 78, 62, 63, 104, 259, 192, 112, 68, - /* 330 */ 69, 70, 71, 72, 192, 104, 62, 63, 117, 5, - /* 340 */ 192, 7, 68, 69, 70, 71, 72, 104, 117, 233, - /* 350 */ 60, 108, 236, 110, 133, 105, 33, 34, 124, 125, - /* 360 */ 37, 38, 39, 113, 133, 105, 109, 2, 233, 109, - /* 370 */ 5, 236, 7, 116, 9, 233, 105, 1, 236, 115, - /* 380 */ 109, 233, 105, 105, 236, 105, 109, 109, 105, 109, - /* 390 */ 109, 253, 109, 111, 104, 109, 105, 105, 33, 34, - /* 400 */ 109, 109, 105, 105, 105, 253, 109, 109, 109, 137, - /* 410 */ 138, 104, 131, 37, 107, 129, 137, 138, 104, 253, - /* 420 */ 106, 137, 138, 253, 137, 138, 5, 5, 7, 7, - /* 430 */ 76, 77, 62, 63, 253, 237, 253, 253, 253, 253, - /* 440 */ 237, 253, 253, 253, 253, 253, 253, 253, 228, 235, - /* 450 */ 228, 228, 228, 228, 228, 192, 252, 192, 239, 192, - /* 460 */ 192, 192, 192, 112, 235, 260, 260, 192, 192, 60, - /* 470 */ 117, 256, 235, 256, 256, 247, 111, 192, 246, 249, - /* 480 */ 192, 192, 130, 256, 128, 192, 192, 192, 192, 248, - /* 490 */ 127, 122, 192, 192, 192, 192, 192, 192, 192, 126, - /* 500 */ 192, 192, 192, 192, 245, 192, 121, 192, 192, 192, - /* 510 */ 192, 192, 192, 192, 192, 120, 192, 192, 192, 192, - /* 520 */ 192, 192, 192, 192, 192, 192, 119, 192, 192, 192, - /* 530 */ 192, 192, 192, 192, 192, 192, 192, 192, 118, 193, - /* 540 */ 193, 193, 193, 193, 132, 103, 87, 86, 50, 83, - /* 550 */ 85, 54, 84, 193, 82, 193, 79, 193, 5, 144, - /* 560 */ 5, 5, 144, 5, 193, 198, 198, 193, 5, 89, - /* 570 */ 135, 113, 105, 109, 114, 104, 107, 193, 105, 193, - /* 580 */ 202, 209, 203, 208, 207, 204, 206, 205, 194, 199, - /* 590 */ 194, 194, 226, 193, 195, 194, 193, 104, 240, 244, - /* 600 */ 243, 242, 241, 109, 105, 104, 1, 104, 104, 226, - /* 610 */ 105, 109, 123, 123, 105, 109, 104, 104, 111, 104, - /* 620 */ 104, 107, 76, 9, 5, 108, 5, 5, 5, 5, - /* 630 */ 80, 15, 109, 76, 138, 5, 16, 5, 138, 105, - /* 640 */ 5, 5, 5, 5, 5, 5, 138, 5, 5, 5, - /* 650 */ 5, 5, 5, 5, 5, 5, 5, 5, 109, 80, - /* 660 */ 60, 59, 21, 0, 264, 264, 264, 264, 264, 264, - /* 670 */ 264, 264, 264, 264, 21, 264, 264, 264, 264, 264, + /* 250 */ 259, 37, 38, 39, 33, 34, 142, 143, 37, 192, + /* 260 */ 88, 76, 90, 91, 33, 34, 81, 95, 238, 97, + /* 270 */ 98, 99, 104, 101, 102, 210, 192, 192, 213, 214, + /* 280 */ 112, 251, 192, 218, 197, 220, 221, 222, 201, 224, + /* 290 */ 225, 25, 26, 27, 28, 253, 64, 65, 66, 33, + /* 300 */ 34, 237, 134, 37, 38, 39, 62, 63, 192, 141, + /* 310 */ 15, 104, 68, 69, 70, 71, 72, 227, 233, 112, + /* 320 */ 105, 236, 78, 62, 63, 104, 259, 192, 113, 68, + /* 330 */ 69, 70, 71, 72, 192, 104, 62, 63, 117, 255, + /* 340 */ 192, 198, 68, 69, 70, 71, 72, 104, 117, 233, + /* 350 */ 253, 108, 236, 110, 133, 104, 33, 34, 107, 197, + /* 360 */ 37, 38, 39, 201, 133, 199, 200, 2, 233, 1, + /* 370 */ 5, 236, 7, 230, 9, 233, 124, 125, 236, 109, + /* 380 */ 5, 233, 7, 105, 236, 105, 116, 109, 105, 109, + /* 390 */ 105, 105, 109, 105, 109, 109, 60, 109, 33, 34, + /* 400 */ 5, 109, 7, 253, 105, 37, 111, 109, 109, 105, + /* 410 */ 105, 105, 105, 109, 109, 109, 109, 253, 137, 138, + /* 420 */ 253, 137, 138, 131, 137, 138, 104, 129, 106, 253, + /* 430 */ 137, 138, 5, 5, 7, 7, 76, 77, 62, 63, + /* 440 */ 104, 253, 253, 253, 253, 253, 253, 237, 228, 192, + /* 450 */ 228, 228, 228, 228, 228, 228, 192, 252, 260, 192, + /* 460 */ 192, 192, 260, 235, 235, 192, 60, 192, 235, 239, + /* 470 */ 193, 192, 117, 256, 192, 256, 111, 118, 122, 126, + /* 480 */ 128, 192, 192, 192, 130, 249, 192, 248, 192, 192, + /* 490 */ 256, 256, 192, 192, 192, 192, 127, 247, 121, 246, + /* 500 */ 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, + /* 510 */ 192, 192, 192, 192, 120, 244, 192, 192, 192, 192, + /* 520 */ 192, 192, 192, 192, 192, 192, 192, 192, 119, 192, + /* 530 */ 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, + /* 540 */ 132, 193, 193, 193, 193, 103, 87, 86, 50, 83, + /* 550 */ 85, 54, 84, 82, 79, 193, 5, 193, 144, 5, + /* 560 */ 193, 5, 144, 5, 5, 89, 193, 193, 135, 198, + /* 570 */ 198, 113, 109, 104, 107, 105, 114, 193, 105, 194, + /* 580 */ 1, 104, 194, 193, 203, 194, 207, 209, 208, 206, + /* 590 */ 204, 202, 205, 193, 105, 194, 226, 193, 199, 109, + /* 600 */ 195, 243, 245, 242, 241, 104, 240, 104, 226, 105, + /* 610 */ 104, 109, 107, 105, 123, 123, 109, 104, 104, 104, + /* 620 */ 111, 104, 76, 9, 108, 5, 5, 5, 5, 5, + /* 630 */ 80, 15, 138, 76, 109, 16, 5, 138, 138, 5, + /* 640 */ 105, 5, 5, 5, 5, 5, 5, 5, 5, 5, + /* 650 */ 5, 5, 5, 5, 5, 5, 5, 5, 109, 60, + /* 660 */ 80, 59, 0, 264, 264, 264, 264, 264, 264, 264, + /* 670 */ 264, 264, 264, 264, 21, 21, 264, 264, 264, 264, /* 680 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, /* 690 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, /* 700 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, @@ -361,84 +362,84 @@ static const YYCODETYPE yy_lookahead[] = { /* 830 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, /* 840 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, /* 850 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 860 */ 264, 264, 264, + /* 860 */ 264, 264, 264, 264, }; #define YY_SHIFT_COUNT (312) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (663) +#define YY_SHIFT_MAX (662) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 168, 79, 79, 172, 172, 39, 221, 231, 74, 74, + /* 0 */ 168, 79, 79, 172, 172, 9, 221, 231, 74, 74, /* 10 */ 74, 74, 74, 74, 74, 74, 74, 0, 48, 231, - /* 20 */ 365, 365, 365, 365, 45, 74, 74, 74, 74, 158, - /* 30 */ 74, 74, 200, 39, 130, 130, 675, 675, 675, 231, + /* 20 */ 365, 365, 365, 365, 121, 207, 74, 74, 74, 158, + /* 30 */ 74, 74, 185, 9, 31, 31, 676, 676, 676, 231, /* 40 */ 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, /* 50 */ 231, 231, 231, 231, 231, 231, 231, 231, 231, 365, - /* 60 */ 365, 102, 102, 102, 102, 102, 102, 102, 216, 74, - /* 70 */ 74, 264, 74, 74, 74, 74, 234, 234, 257, 74, - /* 80 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, + /* 60 */ 365, 102, 102, 102, 102, 102, 102, 102, 74, 74, + /* 70 */ 112, 74, 207, 207, 74, 74, 74, 252, 252, 270, + /* 80 */ 207, 74, 74, 74, 74, 74, 74, 74, 74, 74, /* 90 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, /* 100 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, /* 110 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, - /* 120 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 351, - /* 130 */ 409, 409, 409, 353, 353, 353, 409, 353, 409, 356, - /* 140 */ 352, 363, 369, 373, 385, 395, 407, 420, 412, 351, - /* 150 */ 409, 409, 409, 442, 39, 39, 409, 409, 459, 461, - /* 160 */ 498, 466, 465, 497, 468, 472, 442, 409, 477, 477, - /* 170 */ 409, 477, 409, 477, 409, 675, 675, 27, 100, 127, + /* 120 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, + /* 130 */ 74, 406, 406, 406, 355, 355, 355, 406, 355, 406, + /* 140 */ 352, 354, 369, 356, 353, 377, 394, 409, 359, 408, + /* 150 */ 406, 406, 406, 442, 9, 9, 406, 406, 459, 461, + /* 160 */ 498, 466, 465, 497, 468, 471, 442, 406, 475, 475, + /* 170 */ 406, 475, 406, 475, 406, 676, 676, 27, 100, 127, /* 180 */ 100, 100, 53, 182, 266, 266, 266, 266, 244, 261, - /* 190 */ 274, 323, 323, 323, 323, 78, 114, 92, 92, 243, - /* 200 */ 95, 187, 250, 260, 271, 277, 278, 280, 283, 312, - /* 210 */ 334, 376, 290, 282, 281, 286, 291, 292, 297, 298, - /* 220 */ 299, 307, 272, 279, 284, 314, 287, 421, 422, 354, - /* 230 */ 370, 553, 415, 555, 556, 418, 558, 563, 480, 435, - /* 240 */ 458, 467, 460, 469, 471, 464, 473, 493, 499, 494, - /* 250 */ 501, 605, 503, 505, 504, 502, 489, 506, 490, 509, - /* 260 */ 512, 507, 513, 469, 515, 514, 516, 517, 546, 614, - /* 270 */ 619, 621, 622, 623, 624, 550, 616, 557, 496, 523, - /* 280 */ 523, 620, 500, 508, 523, 630, 632, 534, 523, 635, - /* 290 */ 636, 637, 638, 639, 640, 642, 643, 644, 645, 646, - /* 300 */ 647, 648, 649, 650, 651, 652, 549, 579, 641, 653, - /* 310 */ 600, 602, 663, + /* 190 */ 274, 323, 323, 323, 323, 78, 114, 214, 214, 243, + /* 200 */ 95, 232, 278, 215, 280, 283, 285, 286, 288, 375, + /* 210 */ 395, 368, 336, 295, 292, 298, 299, 304, 305, 306, + /* 220 */ 307, 251, 281, 284, 287, 322, 293, 427, 428, 360, + /* 230 */ 376, 551, 414, 554, 556, 418, 558, 559, 476, 433, + /* 240 */ 458, 467, 469, 462, 470, 463, 473, 477, 489, 490, + /* 250 */ 501, 579, 503, 504, 506, 502, 491, 507, 492, 508, + /* 260 */ 513, 509, 514, 467, 515, 505, 517, 516, 546, 614, + /* 270 */ 620, 621, 622, 623, 624, 550, 616, 557, 494, 525, + /* 280 */ 525, 619, 499, 500, 525, 631, 634, 535, 525, 636, + /* 290 */ 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, + /* 300 */ 647, 648, 649, 650, 651, 652, 549, 580, 653, 654, + /* 310 */ 599, 602, 662, }; #define YY_REDUCE_COUNT (176) #define YY_REDUCE_MIN (-241) -#define YY_REDUCE_MAX (403) +#define YY_REDUCE_MAX (405) static const short yy_reduce_ofst[] = { /* 0 */ -179, -28, -28, 65, 65, 15, -231, -217, -174, -177, /* 10 */ -9, -77, 85, 116, 135, 142, 148, -186, -189, -234, - /* 20 */ -207, -148, -126, -10, -11, 33, -187, 67, -192, -110, - /* 30 */ 69, -73, -89, 68, -55, 3, 44, 111, -188, -241, - /* 40 */ -218, -195, 31, 138, 152, 166, 170, 181, 183, 184, - /* 50 */ 185, 186, 188, 189, 190, 191, 192, 193, 194, 198, - /* 60 */ 203, 40, 220, 222, 223, 224, 225, 226, 214, 263, - /* 70 */ 265, 204, 267, 268, 269, 270, 205, 206, 219, 275, - /* 80 */ 276, 285, 288, 289, 293, 294, 295, 296, 300, 301, - /* 90 */ 302, 303, 304, 305, 306, 308, 309, 310, 311, 313, - /* 100 */ 315, 316, 317, 318, 319, 320, 321, 322, 324, 325, - /* 110 */ 326, 327, 328, 329, 330, 331, 332, 333, 335, 336, - /* 120 */ 337, 338, 339, 340, 341, 342, 343, 344, 345, 229, - /* 130 */ 346, 347, 348, 215, 217, 218, 349, 227, 350, 230, - /* 140 */ 241, 228, 232, 259, 355, 357, 359, 361, 358, 237, - /* 150 */ 360, 362, 364, 366, 367, 368, 371, 374, 372, 375, - /* 160 */ 377, 379, 380, 381, 382, 378, 383, 384, 394, 396, - /* 170 */ 386, 397, 400, 401, 403, 390, 399, + /* 20 */ -207, -148, -126, -80, 84, -11, -187, 67, -192, -90, + /* 30 */ 90, -73, 3, 143, 87, 162, 30, 166, -188, -241, + /* 40 */ -218, -195, -135, -124, -107, -52, -42, 42, 97, 150, + /* 50 */ 164, 167, 176, 188, 189, 190, 191, 192, 193, 64, + /* 60 */ 210, 220, 222, 223, 224, 225, 226, 227, 257, 264, + /* 70 */ 205, 267, 228, 229, 268, 269, 273, 198, 202, 230, + /* 80 */ 233, 275, 279, 282, 289, 290, 291, 294, 296, 297, + /* 90 */ 300, 301, 302, 303, 308, 309, 310, 311, 312, 313, + /* 100 */ 314, 315, 316, 317, 318, 319, 320, 321, 324, 325, + /* 110 */ 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, + /* 120 */ 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, + /* 130 */ 347, 277, 348, 349, 217, 219, 234, 350, 235, 351, + /* 140 */ 236, 239, 250, 253, 357, 271, 358, 361, 363, 366, + /* 150 */ 362, 364, 367, 370, 371, 372, 373, 374, 378, 380, + /* 160 */ 379, 381, 383, 386, 387, 389, 382, 384, 385, 388, + /* 170 */ 390, 391, 400, 401, 404, 399, 405, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 767, 879, 825, 891, 813, 822, 1019, 1019, 767, 767, - /* 10 */ 767, 767, 767, 767, 767, 767, 767, 939, 786, 1019, + /* 10 */ 767, 767, 767, 767, 767, 767, 767, 938, 786, 1019, /* 20 */ 767, 767, 767, 767, 767, 767, 767, 767, 767, 822, - /* 30 */ 767, 767, 828, 822, 828, 828, 934, 863, 881, 767, + /* 30 */ 767, 767, 828, 822, 828, 828, 933, 863, 881, 767, /* 40 */ 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, /* 50 */ 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, /* 60 */ 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, - /* 70 */ 767, 941, 943, 945, 767, 767, 965, 965, 932, 767, + /* 70 */ 940, 943, 767, 767, 945, 767, 767, 965, 965, 931, /* 80 */ 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, /* 90 */ 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, - /* 100 */ 767, 767, 767, 767, 767, 767, 811, 767, 809, 767, - /* 110 */ 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, - /* 120 */ 767, 767, 767, 796, 767, 767, 767, 767, 767, 767, - /* 130 */ 788, 788, 788, 767, 767, 767, 788, 767, 788, 972, - /* 140 */ 976, 970, 958, 966, 957, 953, 951, 950, 980, 767, + /* 100 */ 767, 767, 767, 767, 767, 767, 767, 767, 811, 767, + /* 110 */ 809, 767, 767, 767, 767, 767, 767, 767, 767, 767, + /* 120 */ 767, 767, 767, 767, 767, 796, 767, 767, 767, 767, + /* 130 */ 767, 788, 788, 788, 767, 767, 767, 788, 767, 788, + /* 140 */ 972, 976, 970, 958, 966, 957, 953, 951, 950, 980, /* 150 */ 788, 788, 788, 826, 822, 822, 788, 788, 844, 842, /* 160 */ 840, 832, 838, 834, 836, 830, 814, 788, 820, 820, /* 170 */ 788, 820, 788, 820, 788, 863, 881, 767, 981, 767, @@ -448,7 +449,7 @@ static const YYACTIONTYPE yy_default[] = { /* 210 */ 767, 767, 983, 767, 977, 973, 767, 767, 767, 767, /* 220 */ 767, 767, 767, 767, 767, 893, 767, 767, 767, 767, /* 230 */ 767, 767, 767, 767, 767, 767, 767, 767, 767, 767, - /* 240 */ 931, 767, 767, 767, 767, 942, 767, 767, 767, 767, + /* 240 */ 930, 767, 767, 767, 767, 941, 767, 767, 767, 767, /* 250 */ 767, 767, 767, 767, 767, 967, 767, 959, 767, 767, /* 260 */ 767, 767, 767, 905, 767, 767, 767, 767, 767, 767, /* 270 */ 767, 767, 767, 767, 767, 767, 767, 767, 767, 1029, @@ -1177,22 +1178,22 @@ static const char *const yyRuleName[] = { /* 154 */ "tagitem ::= PLUS INTEGER", /* 155 */ "tagitem ::= PLUS FLOAT", /* 156 */ "select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt", - /* 157 */ "union ::= select", - /* 158 */ "union ::= LP union RP", + /* 157 */ "select ::= LP select RP", + /* 158 */ "union ::= select", /* 159 */ "union ::= union UNION ALL select", - /* 160 */ "union ::= union UNION ALL LP select RP", - /* 161 */ "cmd ::= union", - /* 162 */ "select ::= SELECT selcollist", - /* 163 */ "sclp ::= selcollist COMMA", - /* 164 */ "sclp ::=", - /* 165 */ "selcollist ::= sclp distinct expr as", - /* 166 */ "selcollist ::= sclp STAR", - /* 167 */ "as ::= AS ids", - /* 168 */ "as ::= ids", - /* 169 */ "as ::=", - /* 170 */ "distinct ::= DISTINCT", - /* 171 */ "distinct ::=", - /* 172 */ "from ::= FROM tablelist", + /* 160 */ "cmd ::= union", + /* 161 */ "select ::= SELECT selcollist", + /* 162 */ "sclp ::= selcollist COMMA", + /* 163 */ "sclp ::=", + /* 164 */ "selcollist ::= sclp distinct expr as", + /* 165 */ "selcollist ::= sclp STAR", + /* 166 */ "as ::= AS ids", + /* 167 */ "as ::= ids", + /* 168 */ "as ::=", + /* 169 */ "distinct ::= DISTINCT", + /* 170 */ "distinct ::=", + /* 171 */ "from ::= FROM tablelist", + /* 172 */ "from ::= FROM LP union RP", /* 173 */ "tablelist ::= ids cpxName", /* 174 */ "tablelist ::= ids cpxName ids", /* 175 */ "tablelist ::= tablelist COMMA ids cpxName", @@ -1420,7 +1421,7 @@ taosArrayDestroy((yypminor->yy285)); break; case 231: /* create_table_list */ { -destroyCreateTableSql((yypminor->yy230)); +destroyCreateTableSql((yypminor->yy470)); } break; case 235: /* select */ @@ -1901,22 +1902,22 @@ static const struct { { 237, -2 }, /* (154) tagitem ::= PLUS INTEGER */ { 237, -2 }, /* (155) tagitem ::= PLUS FLOAT */ { 235, -13 }, /* (156) select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ - { 250, -1 }, /* (157) union ::= select */ - { 250, -3 }, /* (158) union ::= LP union RP */ + { 235, -3 }, /* (157) select ::= LP select RP */ + { 250, -1 }, /* (158) union ::= select */ { 250, -4 }, /* (159) union ::= union UNION ALL select */ - { 250, -6 }, /* (160) union ::= union UNION ALL LP select RP */ - { 190, -1 }, /* (161) cmd ::= union */ - { 235, -2 }, /* (162) select ::= SELECT selcollist */ - { 251, -2 }, /* (163) sclp ::= selcollist COMMA */ - { 251, 0 }, /* (164) sclp ::= */ - { 238, -4 }, /* (165) selcollist ::= sclp distinct expr as */ - { 238, -2 }, /* (166) selcollist ::= sclp STAR */ - { 254, -2 }, /* (167) as ::= AS ids */ - { 254, -1 }, /* (168) as ::= ids */ - { 254, 0 }, /* (169) as ::= */ - { 252, -1 }, /* (170) distinct ::= DISTINCT */ - { 252, 0 }, /* (171) distinct ::= */ - { 239, -2 }, /* (172) from ::= FROM tablelist */ + { 190, -1 }, /* (160) cmd ::= union */ + { 235, -2 }, /* (161) select ::= SELECT selcollist */ + { 251, -2 }, /* (162) sclp ::= selcollist COMMA */ + { 251, 0 }, /* (163) sclp ::= */ + { 238, -4 }, /* (164) selcollist ::= sclp distinct expr as */ + { 238, -2 }, /* (165) selcollist ::= sclp STAR */ + { 254, -2 }, /* (166) as ::= AS ids */ + { 254, -1 }, /* (167) as ::= ids */ + { 254, 0 }, /* (168) as ::= */ + { 252, -1 }, /* (169) distinct ::= DISTINCT */ + { 252, 0 }, /* (170) distinct ::= */ + { 239, -2 }, /* (171) from ::= FROM tablelist */ + { 239, -4 }, /* (172) from ::= FROM LP union RP */ { 255, -2 }, /* (173) tablelist ::= ids cpxName */ { 255, -3 }, /* (174) tablelist ::= ids cpxName ids */ { 255, -4 }, /* (175) tablelist ::= tablelist COMMA ids cpxName */ @@ -2273,7 +2274,7 @@ static void yy_reduce( break; case 50: /* ifexists ::= */ case 52: /* ifnotexists ::= */ yytestcase(yyruleno==52); - case 171: /* distinct ::= */ yytestcase(yyruleno==171); + case 170: /* distinct ::= */ yytestcase(yyruleno==170); { yymsp[1].minor.yy0.n = 0;} break; case 51: /* ifnotexists ::= IF NOT EXISTS */ @@ -2471,7 +2472,7 @@ static void yy_reduce( { yymsp[-1].minor.yy525 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; case 132: /* cmd ::= CREATE TABLE create_table_list */ -{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy230;} +{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy470;} break; case 133: /* create_table_list ::= create_from_stable */ { @@ -2480,36 +2481,36 @@ static void yy_reduce( taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy96); pCreateTable->type = TSQL_CREATE_TABLE_FROM_STABLE; - yylhsminor.yy230 = pCreateTable; + yylhsminor.yy470 = pCreateTable; } - yymsp[0].minor.yy230 = yylhsminor.yy230; + yymsp[0].minor.yy470 = yylhsminor.yy470; break; case 134: /* create_table_list ::= create_table_list create_from_stable */ { - taosArrayPush(yymsp[-1].minor.yy230->childTableInfo, &yymsp[0].minor.yy96); - yylhsminor.yy230 = yymsp[-1].minor.yy230; + taosArrayPush(yymsp[-1].minor.yy470->childTableInfo, &yymsp[0].minor.yy96); + yylhsminor.yy470 = yymsp[-1].minor.yy470; } - yymsp[-1].minor.yy230 = yylhsminor.yy230; + yymsp[-1].minor.yy470 = yylhsminor.yy470; break; case 135: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { - yylhsminor.yy230 = tSetCreateTableInfo(yymsp[-1].minor.yy285, NULL, NULL, TSQL_CREATE_TABLE); - setSqlInfo(pInfo, yylhsminor.yy230, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy470 = tSetCreateTableInfo(yymsp[-1].minor.yy285, NULL, NULL, TSQL_CREATE_TABLE); + setSqlInfo(pInfo, yylhsminor.yy470, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-4].minor.yy0, &yymsp[-5].minor.yy0); } - yymsp[-5].minor.yy230 = yylhsminor.yy230; + yymsp[-5].minor.yy470 = yylhsminor.yy470; break; case 136: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { - yylhsminor.yy230 = tSetCreateTableInfo(yymsp[-5].minor.yy285, yymsp[-1].minor.yy285, NULL, TSQL_CREATE_STABLE); - setSqlInfo(pInfo, yylhsminor.yy230, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy470 = tSetCreateTableInfo(yymsp[-5].minor.yy285, yymsp[-1].minor.yy285, NULL, TSQL_CREATE_STABLE); + setSqlInfo(pInfo, yylhsminor.yy470, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy230 = yylhsminor.yy230; + yymsp[-9].minor.yy470 = yylhsminor.yy470; break; case 137: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ { @@ -2537,13 +2538,13 @@ static void yy_reduce( break; case 141: /* create_table_args ::= ifnotexists ids cpxName AS select */ { - yylhsminor.yy230 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy342, TSQL_CREATE_STREAM); - setSqlInfo(pInfo, yylhsminor.yy230, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy470 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy342, TSQL_CREATE_STREAM); + setSqlInfo(pInfo, yylhsminor.yy470, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-3].minor.yy0, &yymsp[-4].minor.yy0); } - yymsp[-4].minor.yy230 = yylhsminor.yy230; + yymsp[-4].minor.yy470 = yylhsminor.yy470; break; case 142: /* columnlist ::= columnlist COMMA column */ {taosArrayPush(yymsp[-2].minor.yy285, &yymsp[0].minor.yy295); yylhsminor.yy285 = yymsp[-2].minor.yy285; } @@ -2592,78 +2593,76 @@ static void yy_reduce( break; case 156: /* select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ { - yylhsminor.yy342 = tSetQuerySqlNode(&yymsp[-12].minor.yy0, yymsp[-11].minor.yy285, yymsp[-10].minor.yy285, yymsp[-9].minor.yy178, yymsp[-4].minor.yy285, yymsp[-3].minor.yy285, &yymsp[-8].minor.yy376, &yymsp[-7].minor.yy523, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy285, &yymsp[0].minor.yy438, &yymsp[-1].minor.yy438); + yylhsminor.yy342 = tSetQuerySqlNode(&yymsp[-12].minor.yy0, yymsp[-11].minor.yy285, yymsp[-10].minor.yy162, yymsp[-9].minor.yy178, yymsp[-4].minor.yy285, yymsp[-3].minor.yy285, &yymsp[-8].minor.yy376, &yymsp[-7].minor.yy523, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy285, &yymsp[0].minor.yy438, &yymsp[-1].minor.yy438); } yymsp[-12].minor.yy342 = yylhsminor.yy342; break; - case 157: /* union ::= select */ + case 157: /* select ::= LP select RP */ +{yymsp[-2].minor.yy342 = yymsp[-1].minor.yy342;} + break; + case 158: /* union ::= select */ { yylhsminor.yy513 = setSubclause(NULL, yymsp[0].minor.yy342); } yymsp[0].minor.yy513 = yylhsminor.yy513; break; - case 158: /* union ::= LP union RP */ -{ yymsp[-2].minor.yy513 = yymsp[-1].minor.yy513; } - break; case 159: /* union ::= union UNION ALL select */ { yylhsminor.yy513 = appendSelectClause(yymsp[-3].minor.yy513, yymsp[0].minor.yy342); } yymsp[-3].minor.yy513 = yylhsminor.yy513; break; - case 160: /* union ::= union UNION ALL LP select RP */ -{ yylhsminor.yy513 = appendSelectClause(yymsp[-5].minor.yy513, yymsp[-1].minor.yy342); } - yymsp[-5].minor.yy513 = yylhsminor.yy513; - break; - case 161: /* cmd ::= union */ + case 160: /* cmd ::= union */ { setSqlInfo(pInfo, yymsp[0].minor.yy513, NULL, TSDB_SQL_SELECT); } break; - case 162: /* select ::= SELECT selcollist */ + case 161: /* select ::= SELECT selcollist */ { yylhsminor.yy342 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy285, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } yymsp[-1].minor.yy342 = yylhsminor.yy342; break; - case 163: /* sclp ::= selcollist COMMA */ + case 162: /* sclp ::= selcollist COMMA */ {yylhsminor.yy285 = yymsp[-1].minor.yy285;} yymsp[-1].minor.yy285 = yylhsminor.yy285; break; - case 164: /* sclp ::= */ + case 163: /* sclp ::= */ case 188: /* orderby_opt ::= */ yytestcase(yyruleno==188); {yymsp[1].minor.yy285 = 0;} break; - case 165: /* selcollist ::= sclp distinct expr as */ + case 164: /* selcollist ::= sclp distinct expr as */ { yylhsminor.yy285 = tSqlExprListAppend(yymsp[-3].minor.yy285, yymsp[-1].minor.yy178, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } yymsp[-3].minor.yy285 = yylhsminor.yy285; break; - case 166: /* selcollist ::= sclp STAR */ + case 165: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); yylhsminor.yy285 = tSqlExprListAppend(yymsp[-1].minor.yy285, pNode, 0, 0); } yymsp[-1].minor.yy285 = yylhsminor.yy285; break; - case 167: /* as ::= AS ids */ + case 166: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; - case 168: /* as ::= ids */ + case 167: /* as ::= ids */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 169: /* as ::= */ + case 168: /* as ::= */ { yymsp[1].minor.yy0.n = 0; } break; - case 170: /* distinct ::= DISTINCT */ + case 169: /* distinct ::= DISTINCT */ { yylhsminor.yy0 = yymsp[0].minor.yy0; } yymsp[0].minor.yy0 = yylhsminor.yy0; break; - case 172: /* from ::= FROM tablelist */ -{yymsp[-1].minor.yy285 = yymsp[0].minor.yy285;} + case 171: /* from ::= FROM tablelist */ +{yymsp[-1].minor.yy162 = yymsp[0].minor.yy285;} + break; + case 172: /* from ::= FROM LP union RP */ +{yymsp[-3].minor.yy162 = yymsp[-1].minor.yy513;} break; case 173: /* tablelist ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy285 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); - yylhsminor.yy285 = tVariantListAppendToken(yylhsminor.yy285, &yymsp[-1].minor.yy0, -1); // table alias name + yylhsminor.yy285 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } yymsp[-1].minor.yy285 = yylhsminor.yy285; break; @@ -2672,8 +2671,7 @@ static void yy_reduce( toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type); yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy285 = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - yylhsminor.yy285 = tVariantListAppendToken(yylhsminor.yy285, &yymsp[0].minor.yy0, -1); + yylhsminor.yy285 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0); } yymsp[-2].minor.yy285 = yylhsminor.yy285; break; @@ -2681,8 +2679,7 @@ static void yy_reduce( { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy285 = tVariantListAppendToken(yymsp[-3].minor.yy285, &yymsp[-1].minor.yy0, -1); - yylhsminor.yy285 = tVariantListAppendToken(yylhsminor.yy285, &yymsp[-1].minor.yy0, -1); + yylhsminor.yy285 = setTableNameList(yymsp[-3].minor.yy285, &yymsp[-1].minor.yy0, NULL); } yymsp[-3].minor.yy285 = yylhsminor.yy285; break; @@ -2691,8 +2688,8 @@ static void yy_reduce( toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type); yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy285 = tVariantListAppendToken(yymsp[-4].minor.yy285, &yymsp[-2].minor.yy0, -1); - yylhsminor.yy285 = tVariantListAppendToken(yylhsminor.yy285, &yymsp[0].minor.yy0, -1); + + yylhsminor.yy285 = setTableNameList(yymsp[-4].minor.yy285, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } yymsp[-4].minor.yy285 = yylhsminor.yy285; break; From 01962da413f2192486aaadd568b9da5da0e4876b Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 16 Mar 2021 11:26:29 +0800 Subject: [PATCH 15/89] [td-225]fix error. --- src/client/src/tscSQLParser.c | 42 ++++++++++++++++++----------------- src/query/inc/sql.y | 2 +- src/query/src/sql.c | 2 +- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index b58cc41f25..d4ab9cc1c7 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6508,6 +6508,7 @@ int32_t doValidateSqlNode(SSqlObj* pSql, SQuerySqlNode* pQuerySqlNode, int32_t i const char* msg5 = "too many columns in selection clause"; const char* msg6 = "too many tables in from clause"; const char* msg7 = "invalid table alias name"; + const char* msg8 = "alias name too long"; int32_t code = TSDB_CODE_SUCCESS; @@ -6545,13 +6546,12 @@ int32_t doValidateSqlNode(SSqlObj* pSql, SQuerySqlNode* pQuerySqlNode, int32_t i } pQueryInfo->command = TSDB_SQL_SELECT; - if (fromSize > 2) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6); } // set all query tables, which are maybe more than one. - for (int32_t i = 0; i < fromSize; ) { + for (int32_t i = 0; i < fromSize; ++i) { STableNamePair* item = taosArrayGet(pQuerySqlNode->from->tableList, i); SStrToken* pTableItem = &item->name; @@ -6559,7 +6559,7 @@ int32_t doValidateSqlNode(SSqlObj* pSql, SQuerySqlNode* pQuerySqlNode, int32_t i return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg0); } - pTableItem->n = strdequote(pTableItem->z); + tscDequoteAndTrimToken(pTableItem); SStrToken tableName = {.z = pTableItem->z, .n = pTableItem->n, .type = TK_STRING}; if (tscValidateName(&tableName) != TSDB_CODE_SUCCESS) { @@ -6570,39 +6570,41 @@ int32_t doValidateSqlNode(SSqlObj* pSql, SQuerySqlNode* pQuerySqlNode, int32_t i tscAddEmptyMetaInfo(pQueryInfo); } - STableMetaInfo* pTableMetaInfo1 = tscGetMetaInfo(pQueryInfo, i/2); - - SStrToken t = {.type = TSDB_DATA_TYPE_BINARY, .n = pTableItem->n, .z = pTableItem->z}; - code = tscSetTableFullName(pTableMetaInfo1, &t, pSql); + STableMetaInfo* pTableMetaInfo1 = tscGetMetaInfo(pQueryInfo, i); + code = tscSetTableFullName(pTableMetaInfo1, pTableItem, pSql); if (code != TSDB_CODE_SUCCESS) { return code; } SStrToken* aliasName = &item->aliasName; - if (aliasName->type != TSDB_DATA_TYPE_BINARY) { - return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7); - } + if (TPARSER_HAS_TOKEN(*aliasName)) { + if (aliasName->type != TSDB_DATA_TYPE_BINARY) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7); + } - if (TPARSER_HAS_TOKEN(*aliasName) && tscValidateName(aliasName) != TSDB_CODE_SUCCESS) { - return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7); - } + tscDequoteAndTrimToken(aliasName); - // has no table alias name - if (!TPARSER_HAS_TOKEN(*aliasName)) { - strncpy(pTableMetaInfo1->aliasName, tNameGetTableName(&pTableMetaInfo1->name), tListLen(pTableMetaInfo1->aliasName)); + SStrToken aliasName1 = {.z = aliasName->z, .n = aliasName->n, .type = TK_STRING}; + if (tscValidateName(&aliasName1) != TSDB_CODE_SUCCESS) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg7); + } + + if (aliasName1.n >= TSDB_TABLE_NAME_LEN) { + return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg8); + } + + strncpy(pTableMetaInfo1->aliasName, aliasName1.z, aliasName1.n); } else { - tstrncpy(pTableMetaInfo1->aliasName, aliasName->z, sizeof(pTableMetaInfo1->aliasName)); + strncpy(pTableMetaInfo1->aliasName, tNameGetTableName(&pTableMetaInfo1->name), tListLen(pTableMetaInfo1->aliasName)); } code = tscGetTableMeta(pSql, pTableMetaInfo1); if (code != TSDB_CODE_SUCCESS) { return code; } - - i += 2; } - assert(pQueryInfo->numOfTables == taosArrayGetSize(pQuerySqlNode->from->tableList) / 2); + assert(pQueryInfo->numOfTables == taosArrayGetSize(pQuerySqlNode->from->tableList)); bool isSTable = false; if (UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo)) { diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index aa9b7945a5..7d704e03b4 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -520,7 +520,7 @@ tablelist(A) ::= ids(X) cpxName(Y) ids(Z). { toTSDBType(X.type); toTSDBType(Z.type); X.n += Y.n; - A = setTableNameList(NULL, &X, &Y); + A = setTableNameList(NULL, &X, &Z); } tablelist(A) ::= tablelist(Y) COMMA ids(X) cpxName(Z). { diff --git a/src/query/src/sql.c b/src/query/src/sql.c index ee2a694987..1aafe75c32 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -2671,7 +2671,7 @@ static void yy_reduce( toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type); yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy285 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0); + yylhsminor.yy285 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy285 = yylhsminor.yy285; break; From 1175e8343f052b9b6f9c7cdfea49ae46a1dfd43e Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 16 Mar 2021 11:37:43 +0800 Subject: [PATCH 16/89] [td-225] add more check. --- src/query/src/qSqlParser.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/query/src/qSqlParser.c b/src/query/src/qSqlParser.c index d7c708d9ef..e76b78c523 100644 --- a/src/query/src/qSqlParser.c +++ b/src/query/src/qSqlParser.c @@ -474,7 +474,10 @@ SFromInfo *setSubquery(SFromInfo* pFromInfo, SQuerySqlNode* pSqlNode) { } void* destroyFromInfo(SFromInfo* pFromInfo) { - assert(pFromInfo != NULL); + if (pFromInfo == NULL) { + return NULL; + } + if (pFromInfo->type == SQL_NODE_FROM_NAMELIST) { taosArrayDestroy(pFromInfo->tableList); } else { From a4b97eec604a2d14cf3810c264479345803675ea Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 16 Mar 2021 13:17:10 +0800 Subject: [PATCH 17/89] fix merge issue --- src/query/src/qExecutor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 6747858f08..f37c5d08f0 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -6113,7 +6113,7 @@ FORCE_INLINE bool checkQIdEqual(void *qHandle, uint64_t qId) { SQInfo* createQInfoImpl(SQueryTableMsg* pQueryMsg, SSqlGroupbyExpr* pGroupbyExpr, SExprInfo* pExprs, SExprInfo* pSecExprs, STableGroupInfo* pTableGroupInfo, SColumnInfo* pTagCols, bool stableQuery, - char* sql) { + char* sql, uint64_t *qId) { int16_t numOfCols = pQueryMsg->numOfCols; int16_t numOfOutput = pQueryMsg->numOfOutput; From 7d232a7914c2a1b7869798ca56f648486f5666e7 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Tue, 16 Mar 2021 05:19:14 +0000 Subject: [PATCH 18/89] TD-3309 --- src/sync/src/syncRestore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sync/src/syncRestore.c b/src/sync/src/syncRestore.c index 4c2444caa0..22d0a27581 100644 --- a/src/sync/src/syncRestore.c +++ b/src/sync/src/syncRestore.c @@ -238,7 +238,7 @@ static int32_t syncRestoreDataStepByStep(SSyncPeer *pPeer) { (*pNode->stopSyncFileFp)(pNode->vgId, fversion); nodeVersion = fversion; - (*pNode->resetVersionFp)(pNode->vgId, fversion); + if (pNode->resetVersionFp) (*pNode->resetVersionFp)(pNode->vgId, fversion); sInfo("%s, start to restore wal, fver:%" PRIu64, pPeer->id, nodeVersion); uint64_t wver = 0; From ac5d5316ac943507221d34f3f71485126c2f95bc Mon Sep 17 00:00:00 2001 From: zyyang <69311263+zyyang-taosdata@users.noreply.github.com> Date: Tue, 16 Mar 2021 13:44:09 +0800 Subject: [PATCH 19/89] [TD-3082]: jdbc connector support unsigned tinyint, smallint, int, bigint (#5447) * [TD-3082]: support unsigned number in JDBC connector * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change * change version * change * change --- cmake/install.inc | 2 +- src/client/src/TSDBJNIConnector.c | 4 + src/connector/jdbc/CMakeLists.txt | 2 +- src/connector/jdbc/deploy-pom.xml | 2 +- src/connector/jdbc/pom.xml | 4 +- .../com/taosdata/jdbc/AbstractDriver.java | 7 +- .../com/taosdata/jdbc/AbstractResultSet.java | 10 +- .../taosdata/jdbc/SavedPreparedStatement.java | 7 +- .../java/com/taosdata/jdbc/TSDBConstants.java | 132 +-- .../java/com/taosdata/jdbc/TSDBDriver.java | 28 +- .../java/com/taosdata/jdbc/TSDBError.java | 26 +- .../com/taosdata/jdbc/TSDBErrorNumbers.java | 17 +- .../com/taosdata/jdbc/TSDBJNIConnector.java | 17 +- .../java/com/taosdata/jdbc/TSDBResultSet.java | 133 ++- .../taosdata/jdbc/TSDBResultSetBlockData.java | 932 +++++++++--------- .../taosdata/jdbc/TSDBResultSetMetaData.java | 26 +- .../taosdata/jdbc/TSDBResultSetRowData.java | 428 +++++--- .../java/com/taosdata/jdbc/TSDBStatement.java | 1 - .../java/com/taosdata/jdbc/TSDBSubscribe.java | 26 +- .../taosdata/jdbc/rs/RestfulConnection.java | 1 - .../com/taosdata/jdbc/rs/RestfulDriver.java | 23 +- .../taosdata/jdbc/rs/RestfulResultSet.java | 187 ++-- .../jdbc/rs/RestfulResultSetMetaData.java | 25 +- .../taosdata/jdbc/rs/RestfulStatement.java | 72 +- .../taosdata/jdbc/TSDBJNIConnectorTest.java | 12 +- .../jdbc/cases/InsertDbwithoutUseDbTest.java | 92 ++ .../jdbc/cases/UnsignedNumberJniTest.java | 191 ++++ .../jdbc/cases/UnsignedNumberRestfulTest.java | 177 ++++ .../jdbc/rs/RestfulResultSetTest.java | 7 +- 29 files changed, 1570 insertions(+), 1021 deletions(-) create mode 100644 src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java create mode 100644 src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberJniTest.java create mode 100644 src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberRestfulTest.java diff --git a/cmake/install.inc b/cmake/install.inc index 0ea79589ca..1d50ca292d 100755 --- a/cmake/install.inc +++ b/cmake/install.inc @@ -32,7 +32,7 @@ ELSEIF (TD_WINDOWS) #INSTALL(TARGETS taos RUNTIME DESTINATION driver) #INSTALL(TARGETS shell RUNTIME DESTINATION .) IF (TD_MVN_INSTALLED) - INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.21-dist.jar DESTINATION connector/jdbc) + INSTALL(FILES ${LIBRARY_OUTPUT_PATH}/taos-jdbcdriver-2.0.22-dist.jar DESTINATION connector/jdbc) ENDIF () ELSEIF (TD_DARWIN) SET(TD_MAKE_INSTALL_SH "${TD_COMMUNITY_DIR}/packaging/tools/make_install.sh") diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index a8829499a3..56e155311e 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -481,15 +481,19 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_fetchRowImp(JNIEn case TSDB_DATA_TYPE_BOOL: (*env)->CallVoidMethod(env, rowobj, g_rowdataSetBooleanFp, i, (jboolean)(*((char *)row[i]) == 1)); break; + case TSDB_DATA_TYPE_UTINYINT: case TSDB_DATA_TYPE_TINYINT: (*env)->CallVoidMethod(env, rowobj, g_rowdataSetByteFp, i, (jbyte) * ((int8_t *)row[i])); break; + case TSDB_DATA_TYPE_USMALLINT: case TSDB_DATA_TYPE_SMALLINT: (*env)->CallVoidMethod(env, rowobj, g_rowdataSetShortFp, i, (jshort) * ((int16_t *)row[i])); break; + case TSDB_DATA_TYPE_UINT: case TSDB_DATA_TYPE_INT: (*env)->CallVoidMethod(env, rowobj, g_rowdataSetIntFp, i, (jint) * (int32_t *)row[i]); break; + case TSDB_DATA_TYPE_UBIGINT: case TSDB_DATA_TYPE_BIGINT: (*env)->CallVoidMethod(env, rowobj, g_rowdataSetLongFp, i, (jlong) * ((int64_t *)row[i])); break; diff --git a/src/connector/jdbc/CMakeLists.txt b/src/connector/jdbc/CMakeLists.txt index 3c50ac566b..86ddfcb022 100644 --- a/src/connector/jdbc/CMakeLists.txt +++ b/src/connector/jdbc/CMakeLists.txt @@ -8,7 +8,7 @@ IF (TD_MVN_INSTALLED) ADD_CUSTOM_COMMAND(OUTPUT ${JDBC_CMD_NAME} POST_BUILD COMMAND mvn -Dmaven.test.skip=true install -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.21-dist.jar ${LIBRARY_OUTPUT_PATH} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/target/taos-jdbcdriver-2.0.22-dist.jar ${LIBRARY_OUTPUT_PATH} COMMAND mvn -Dmaven.test.skip=true clean -f ${CMAKE_CURRENT_SOURCE_DIR}/pom.xml COMMENT "build jdbc driver") ADD_CUSTOM_TARGET(${JDBC_TARGET_NAME} ALL WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} DEPENDS ${JDBC_CMD_NAME}) diff --git a/src/connector/jdbc/deploy-pom.xml b/src/connector/jdbc/deploy-pom.xml index 1c24b621ef..fe93e54c69 100755 --- a/src/connector/jdbc/deploy-pom.xml +++ b/src/connector/jdbc/deploy-pom.xml @@ -5,7 +5,7 @@ com.taosdata.jdbc taos-jdbcdriver - 2.0.21 + 2.0.22 jar JDBCDriver diff --git a/src/connector/jdbc/pom.xml b/src/connector/jdbc/pom.xml index f1e013e864..51cb0b3808 100755 --- a/src/connector/jdbc/pom.xml +++ b/src/connector/jdbc/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.taosdata.jdbc taos-jdbcdriver - 2.0.21 + 2.0.22 jar JDBCDriver https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc @@ -102,6 +102,8 @@ **/*Test.java + **/TSDBJNIConnectorTest.java + **/UnsignedNumberJniTest.java **/DatetimeBefore1970Test.java **/AppMemoryLeakTest.java **/AuthenticationTest.java diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDriver.java index 28b7bd6a5f..5eaac1cd3b 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDriver.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractDriver.java @@ -12,7 +12,7 @@ public abstract class AbstractDriver implements Driver { hostProp.required = false; hostProp.description = "Hostname"; - DriverPropertyInfo portProp = new DriverPropertyInfo(TSDBDriver.PROPERTY_KEY_PORT, info.getProperty(TSDBDriver.PROPERTY_KEY_PORT, TSDBConstants.DEFAULT_PORT)); + DriverPropertyInfo portProp = new DriverPropertyInfo(TSDBDriver.PROPERTY_KEY_PORT, info.getProperty(TSDBDriver.PROPERTY_KEY_PORT)); portProp.required = false; portProp.description = "Port"; @@ -40,11 +40,11 @@ public abstract class AbstractDriver implements Driver { protected Properties parseURL(String url, Properties defaults) { Properties urlProps = (defaults != null) ? defaults : new Properties(); - // parse properties + // parse properties in url int beginningOfSlashes = url.indexOf("//"); int index = url.indexOf("?"); if (index != -1) { - String paramString = url.substring(index + 1, url.length()); + String paramString = url.substring(index + 1); url = url.substring(0, index); StringTokenizer queryParams = new StringTokenizer(paramString, "&"); while (queryParams.hasMoreElements()) { @@ -68,6 +68,7 @@ public abstract class AbstractDriver implements Driver { String dbProductName = url.substring(0, beginningOfSlashes); dbProductName = dbProductName.substring(dbProductName.indexOf(":") + 1); dbProductName = dbProductName.substring(0, dbProductName.indexOf(":")); + urlProps.setProperty(TSDBDriver.PROPERTY_KEY_PRODUCT_NAME,dbProductName); // parse dbname url = url.substring(beginningOfSlashes + 2); int indexOfSlash = url.indexOf("/"); diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java index 14bd2929f1..238d18039d 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/AbstractResultSet.java @@ -29,12 +29,7 @@ public abstract class AbstractResultSet extends WrapperImpl implements ResultSet public abstract boolean getBoolean(int columnIndex) throws SQLException; @Override - public byte getByte(int columnIndex) throws SQLException { - if (isClosed()) - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED); - - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); - } + public abstract byte getByte(int columnIndex) throws SQLException; @Override public abstract short getShort(int columnIndex) throws SQLException; @@ -1205,6 +1200,7 @@ public abstract class AbstractResultSet extends WrapperImpl implements ResultSet public T getObject(String columnLabel, Class type) throws SQLException { if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_STATEMENT_CLOSED); - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); } + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNSUPPORTED_METHOD); + } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/SavedPreparedStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/SavedPreparedStatement.java index a0aa7ec584..512fcd26b8 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/SavedPreparedStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/SavedPreparedStatement.java @@ -122,8 +122,7 @@ public class SavedPreparedStatement { initPreparedParam = initDefaultParam(tableName, middleParamSize, valueListSize); } else { - // not match - throw new SQLException(TSDBConstants.WrapErrMsg("the sql is not complete!")); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_SQL); } } @@ -189,7 +188,7 @@ public class SavedPreparedStatement { String errorMsg = String.format("the parameterIndex %s out of the range [1, %s]", parameterIndex, paramSize); if (parameterIndex < 1 || parameterIndex > paramSize) { - throw new SQLException(TSDBConstants.WrapErrMsg(errorMsg)); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE,errorMsg); } this.isAddBatch = false; //set isAddBatch to false @@ -212,7 +211,7 @@ public class SavedPreparedStatement { return; } - throw new SQLException(TSDBConstants.WrapErrMsg(errorMsg)); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE,errorMsg); } public void addBatch() { diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConstants.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConstants.java index 6179b47da1..37073e243f 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConstants.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBConstants.java @@ -16,16 +16,11 @@ package com.taosdata.jdbc; import java.sql.SQLException; import java.sql.Types; -import java.util.HashMap; -import java.util.Map; public abstract class TSDBConstants { - public static final String DEFAULT_PORT = "6200"; - public static Map DATATYPE_MAP = null; - public static final long JNI_NULL_POINTER = 0L; - + // JNI_ERROR_NUMBER public static final int JNI_SUCCESS = 0; public static final int JNI_TDENGINE_ERROR = -1; public static final int JNI_CONNECTION_NULL = -2; @@ -34,8 +29,7 @@ public abstract class TSDBConstants { public static final int JNI_SQL_NULL = -5; public static final int JNI_FETCH_END = -6; public static final int JNI_OUT_OF_MEMORY = -7; - - public static final int TSDB_DATA_TYPE_NULL = 0; + // TSDB Data Types public static final int TSDB_DATA_TYPE_BOOL = 1; public static final int TSDB_DATA_TYPE_TINYINT = 2; public static final int TSDB_DATA_TYPE_SMALLINT = 3; @@ -46,46 +40,36 @@ public abstract class TSDBConstants { public static final int TSDB_DATA_TYPE_BINARY = 8; public static final int TSDB_DATA_TYPE_TIMESTAMP = 9; public static final int TSDB_DATA_TYPE_NCHAR = 10; - - // nchar field's max length + /* + 系统增加新的无符号数据类型,分别是: + unsigned tinyint, 数值范围:0-254, NULL 为255 + unsigned smallint,数值范围: 0-65534, NULL 为65535 + unsigned int,数值范围:0-4294967294,NULL 为4294967295u + unsigned bigint,数值范围:0-18446744073709551614u,NULL 为18446744073709551615u。 + example: + create table tb(ts timestamp, a tinyint unsigned, b smallint unsigned, c int unsigned, d bigint unsigned); + */ + public static final int TSDB_DATA_TYPE_UTINYINT = 11; //unsigned tinyint + public static final int TSDB_DATA_TYPE_USMALLINT = 12; //unsigned smallint + public static final int TSDB_DATA_TYPE_UINT = 13; //unsigned int + public static final int TSDB_DATA_TYPE_UBIGINT = 14; //unsigned bigint + // nchar column max length public static final int maxFieldSize = 16 * 1024; - public static String WrapErrMsg(String msg) { - return "TDengine Error: " + msg; - } - - public static String FixErrMsg(int code) { - switch (code) { - case JNI_TDENGINE_ERROR: - return WrapErrMsg("internal error of database!"); - case JNI_CONNECTION_NULL: - return WrapErrMsg("invalid tdengine connection!"); - case JNI_RESULT_SET_NULL: - return WrapErrMsg("invalid resultset pointer!"); - case JNI_NUM_OF_FIELDS_0: - return WrapErrMsg("invalid num of fields!"); - case JNI_SQL_NULL: - return WrapErrMsg("can't execute empty sql!"); - case JNI_FETCH_END: - return WrapErrMsg("fetch to the end of resultset"); - default: - break; - } - return WrapErrMsg("unkown error!"); - } - public static int taosType2JdbcType(int taosType) throws SQLException { switch (taosType) { - case TSDBConstants.TSDB_DATA_TYPE_NULL: - return Types.NULL; case TSDBConstants.TSDB_DATA_TYPE_BOOL: return Types.BOOLEAN; case TSDBConstants.TSDB_DATA_TYPE_TINYINT: + case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: return Types.TINYINT; + case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: return Types.SMALLINT; + case TSDBConstants.TSDB_DATA_TYPE_UINT: case TSDBConstants.TSDB_DATA_TYPE_INT: return Types.INTEGER; + case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return Types.BIGINT; case TSDBConstants.TSDB_DATA_TYPE_FLOAT: @@ -99,13 +83,42 @@ public abstract class TSDBConstants { case TSDBConstants.TSDB_DATA_TYPE_NCHAR: return Types.NCHAR; } - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_SQL_TYPE_IN_TDENGINE); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_TAOS_TYPE_IN_TDENGINE); + } + + public static String taosType2JdbcTypeName(int taosType) throws SQLException { + switch (taosType){ + case TSDBConstants.TSDB_DATA_TYPE_BOOL: + return "BOOL"; + case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: + return "TINYINT"; + case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: + return "SMALLINT"; + case TSDBConstants.TSDB_DATA_TYPE_UINT: + case TSDBConstants.TSDB_DATA_TYPE_INT: + return "INT"; + case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: + return "BIGINT"; + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: + return "FLOAT"; + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: + return "DOUBLE"; + case TSDBConstants.TSDB_DATA_TYPE_BINARY: + return "BINARY"; + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + return "TIMESTAMP"; + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + return "NCHAR"; + default: + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_TAOS_TYPE_IN_TDENGINE); + } } public static int jdbcType2TaosType(int jdbcType) throws SQLException { switch (jdbcType){ - case Types.NULL: - return TSDBConstants.TSDB_DATA_TYPE_NULL; case Types.BOOLEAN: return TSDBConstants.TSDB_DATA_TYPE_BOOL; case Types.TINYINT: @@ -130,22 +143,31 @@ public abstract class TSDBConstants { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_SQL_TYPE_IN_TDENGINE); } - static { - DATATYPE_MAP = new HashMap<>(); - DATATYPE_MAP.put(0, "NULL"); - DATATYPE_MAP.put(1, "BOOL"); - DATATYPE_MAP.put(2, "TINYINT"); - DATATYPE_MAP.put(3, "SMALLINT"); - DATATYPE_MAP.put(4, "INT"); - DATATYPE_MAP.put(5, "BIGINT"); - DATATYPE_MAP.put(6, "FLOAT"); - DATATYPE_MAP.put(7, "DOUBLE"); - DATATYPE_MAP.put(8, "BINARY"); - DATATYPE_MAP.put(9, "TIMESTAMP"); - DATATYPE_MAP.put(10, "NCHAR"); + public static String jdbcType2TaosTypeName(int jdbcType) throws SQLException { + switch (jdbcType){ + case Types.BOOLEAN: + return "BOOL"; + case Types.TINYINT: + return "TINYINT"; + case Types.SMALLINT: + return "SMALLINT"; + case Types.INTEGER: + return "INT"; + case Types.BIGINT: + return "BIGINT"; + case Types.FLOAT: + return "FLOAT"; + case Types.DOUBLE: + return "DOUBLE"; + case Types.BINARY: + return "BINARY"; + case Types.TIMESTAMP: + return "TIMESTAMP"; + case Types.NCHAR: + return "NCHAR"; + default: + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_UNKNOWN_SQL_TYPE_IN_TDENGINE); + } } - public static String jdbcType2TaosTypeName(int type) throws SQLException { - return DATATYPE_MAP.get(jdbcType2TaosType(type)); - } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java index 530ece6bcb..5f599df130 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBDriver.java @@ -44,6 +44,10 @@ public class TSDBDriver extends AbstractDriver { private static final String URL_PREFIX = "jdbc:TAOS://"; + /** + * PRODUCT_NAME + */ + public static final String PROPERTY_KEY_PRODUCT_NAME = "productName"; /** * Key used to retrieve the host value from the properties instance passed to * the driver. @@ -96,38 +100,34 @@ public class TSDBDriver extends AbstractDriver { static { try { java.sql.DriverManager.registerDriver(new TSDBDriver()); - } catch (SQLException E) { - throw new RuntimeException(TSDBConstants.WrapErrMsg("can't register tdengine jdbc driver!")); + } catch (SQLException e) { + throw TSDBError.createRuntimeException(TSDBErrorNumbers.ERROR_CANNOT_REGISTER_JNI_DRIVER, e); } } public Connection connect(String url, Properties info) throws SQLException { if (url == null) - throw new SQLException(TSDBConstants.WrapErrMsg("url is not set!")); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_URL_NOT_SET); if (!acceptsURL(url)) return null; - Properties props = null; - if ((props = parseURL(url, info)) == null) { + Properties props = parseURL(url, info); + if (props == null) { return null; } try { TSDBJNIConnector.init((String) props.get(PROPERTY_KEY_CONFIG_DIR), (String) props.get(PROPERTY_KEY_LOCALE), (String) props.get(PROPERTY_KEY_CHARSET), (String) props.get(PROPERTY_KEY_TIME_ZONE)); - Connection newConn = new TSDBConnection(props, this.dbMetaData); - return newConn; + return new TSDBConnection(props, this.dbMetaData); } catch (SQLWarning sqlWarning) { sqlWarning.printStackTrace(); - Connection newConn = new TSDBConnection(props, this.dbMetaData); - return newConn; + return new TSDBConnection(props, this.dbMetaData); } catch (SQLException sqlEx) { throw sqlEx; } catch (Exception ex) { - SQLException sqlEx = new SQLException("SQLException:" + ex.toString()); - sqlEx.initCause(ex); - throw sqlEx; + throw new SQLException("SQLException:" + ex.toString(), ex); } } @@ -139,8 +139,8 @@ public class TSDBDriver extends AbstractDriver { */ public boolean acceptsURL(String url) throws SQLException { if (url == null) - throw new SQLException(TSDBConstants.WrapErrMsg("url is null")); - return (url != null && url.length() > 0 && url.trim().length() > 0) && (url.startsWith(URL_PREFIX) || url.startsWith(URL_PREFIX1)); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_URL_NOT_SET); + return url.length() > 0 && url.trim().length() > 0 && (url.startsWith(URL_PREFIX) || url.startsWith(URL_PREFIX1)); } public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException { diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java index c7717e331b..90967b3620 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBError.java @@ -3,6 +3,7 @@ package com.taosdata.jdbc; import java.sql.SQLClientInfoException; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; +import java.sql.SQLWarning; import java.util.HashMap; import java.util.Map; @@ -18,18 +19,25 @@ public class TSDBError { TSDBErrorMap.put(TSDBErrorNumbers.ERROR_BATCH_IS_EMPTY, "Batch is empty!"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEQUERY, "Can not issue data manipulation statements with executeQuery()"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEUPDATE, "Can not issue SELECT via executeUpdate()"); - TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_FOR_EXECUTE_QUERY, "not a valid sql for executeQuery: (?)"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_FOR_EXECUTE_QUERY, "invalid sql for executeQuery: (?)"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_DATABASE_NOT_SPECIFIED_OR_AVAILABLE, "Database not specified or available"); - TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_FOR_EXECUTE_UPDATE, "not a valid sql for executeUpdate: (?)"); - TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_FOR_EXECUTE, "not a valid sql for execute: (?)"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_FOR_EXECUTE_UPDATE, "invalid sql for executeUpdate: (?)"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_FOR_EXECUTE, "invalid sql for execute: (?)"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE, "parameter index out of range"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED, "connection already closed"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNKNOWN_SQL_TYPE_IN_TDENGINE, "unknown sql type in tdengine"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_CANNOT_REGISTER_JNI_DRIVER, "can't register JDBC-JNI driver"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_CANNOT_REGISTER_RESTFUL_DRIVER, "can't register JDBC-RESTful driver"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_URL_NOT_SET, "url is not set"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_INVALID_SQL, "invalid sql"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE, "numeric value out of range"); + TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNKNOWN_TAOS_TYPE_IN_TDENGINE, "unknown taos type in tdengine"); + /**************************************************/ TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNKNOWN, "unknown error"); /**************************************************/ TSDBErrorMap.put(TSDBErrorNumbers.ERROR_SUBSCRIBE_FAILED, "failed to create subscription"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_UNSUPPORTED_ENCODING, "Unsupported encoding"); - TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_TDENGINE_ERROR, "internal error of database"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL, "JNI connection is NULL"); TSDBErrorMap.put(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL, "JNI result set is NULL"); @@ -65,4 +73,12 @@ public class TSDBError { return new SQLException("TDengine ERROR (" + Integer.toHexString(errorCode) + "): " + message, "", errorCode); } -} + public static RuntimeException createRuntimeException(int errorCode, Throwable t) { + String message = TSDBErrorMap.get(errorCode); + return new RuntimeException("ERROR (" + Integer.toHexString(errorCode) + "): " + message, t); + } + + public static SQLWarning createSQLWarning(String message) { + return new SQLWarning(message); + } +} \ No newline at end of file diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java index 78e7aec79c..c978bb3a2e 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBErrorNumbers.java @@ -16,15 +16,20 @@ public class TSDBErrorNumbers { public static final int ERROR_DATABASE_NOT_SPECIFIED_OR_AVAILABLE = 0x230a; //Database not specified or available public static final int ERROR_INVALID_FOR_EXECUTE_UPDATE = 0x230b; //not a valid sql for executeUpdate: (SQL) public static final int ERROR_INVALID_FOR_EXECUTE = 0x230c; //not a valid sql for execute: (SQL) - public static final int ERROR_PARAMETER_INDEX_OUT_RANGE = 0x230d; // parameter index out of range + public static final int ERROR_PARAMETER_INDEX_OUT_RANGE = 0x230d; // parameter index out of range public static final int ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED = 0x230e; // connection already closed public static final int ERROR_UNKNOWN_SQL_TYPE_IN_TDENGINE = 0x230f; //unknown sql type in tdengine + public static final int ERROR_CANNOT_REGISTER_JNI_DRIVER = 0x2310; // can't register JDBC-JNI driver + public static final int ERROR_CANNOT_REGISTER_RESTFUL_DRIVER = 0x2311; // can't register JDBC-RESTful driver + public static final int ERROR_URL_NOT_SET = 0x2312; // url is not set + public static final int ERROR_INVALID_SQL = 0x2313; // invalid sql + public static final int ERROR_NUMERIC_VALUE_OUT_OF_RANGE = 0x2314; // numeric value out of range + public static final int ERROR_UNKNOWN_TAOS_TYPE_IN_TDENGINE = 0x2315; //unknown taos type in tdengine public static final int ERROR_UNKNOWN = 0x2350; //unknown error public static final int ERROR_SUBSCRIBE_FAILED = 0x2351; // failed to create subscription public static final int ERROR_UNSUPPORTED_ENCODING = 0x2352; // Unsupported encoding - public static final int ERROR_JNI_TDENGINE_ERROR = 0x2353; // internal error of database public static final int ERROR_JNI_CONNECTION_NULL = 0x2354; // JNI connection is NULL public static final int ERROR_JNI_RESULT_SET_NULL = 0x2355; // invalid JNI result set @@ -51,11 +56,16 @@ public class TSDBErrorNumbers { errorNumbers.add(ERROR_PARAMETER_INDEX_OUT_RANGE); errorNumbers.add(ERROR_SQLCLIENT_EXCEPTION_ON_CONNECTION_CLOSED); errorNumbers.add(ERROR_UNKNOWN_SQL_TYPE_IN_TDENGINE); + errorNumbers.add(ERROR_CANNOT_REGISTER_JNI_DRIVER); + errorNumbers.add(ERROR_CANNOT_REGISTER_RESTFUL_DRIVER); + errorNumbers.add(ERROR_URL_NOT_SET); + errorNumbers.add(ERROR_INVALID_SQL); + errorNumbers.add(ERROR_NUMERIC_VALUE_OUT_OF_RANGE); + errorNumbers.add(ERROR_UNKNOWN_TAOS_TYPE_IN_TDENGINE); /*****************************************************/ errorNumbers.add(ERROR_SUBSCRIBE_FAILED); errorNumbers.add(ERROR_UNSUPPORTED_ENCODING); - errorNumbers.add(ERROR_JNI_TDENGINE_ERROR); errorNumbers.add(ERROR_JNI_CONNECTION_NULL); errorNumbers.add(ERROR_JNI_RESULT_SET_NULL); @@ -63,7 +73,6 @@ public class TSDBErrorNumbers { errorNumbers.add(ERROR_JNI_SQL_NULL); errorNumbers.add(ERROR_JNI_FETCH_END); errorNumbers.add(ERROR_JNI_OUT_OF_MEMORY); - } private TSDBErrorNumbers() { diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java index b27bc63db1..7d3741917c 100755 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBJNIConnector.java @@ -1,18 +1,19 @@ /** * ************************************************************************* * Copyright (c) 2019 TAOS Data, Inc. - * + *

* This program is free software: you can use, redistribute, and/or modify * it under the terms of the GNU Affero General Public License, version 3 * or later ("AGPL"), as published by the Free Software Foundation. - * + *

* This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. - * + *

* You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . - **************************************************************************** */ + * *************************************************************************** + */ package com.taosdata.jdbc; import com.taosdata.jdbc.utils.TaosInfo; @@ -23,7 +24,7 @@ import java.util.List; /** * JNI connector - * */ + */ public class TSDBJNIConnector { private static volatile Boolean isInitialized = false; @@ -72,13 +73,13 @@ public class TSDBJNIConnector { if (!isInitialized) { initImp(configDir); if (setOptions(0, locale) < 0) { - throw new SQLWarning(TSDBConstants.WrapErrMsg("Failed to set locale: " + locale + ". System default will be used.")); + throw TSDBError.createSQLWarning("Failed to set locale: " + locale + ". System default will be used."); } if (setOptions(1, charset) < 0) { - throw new SQLWarning(TSDBConstants.WrapErrMsg("Failed to set charset: " + charset + ". System default will be used.")); + throw TSDBError.createSQLWarning("Failed to set charset: " + charset + ". System default will be used."); } if (setOptions(2, timezone) < 0) { - throw new SQLWarning(TSDBConstants.WrapErrMsg("Failed to set timezone: " + timezone + ". System default will be used.")); + throw TSDBError.createSQLWarning("Failed to set timezone: " + timezone + ". System default will be used."); } isInitialized = true; TaosGlobalConfig.setCharset(getTsCharset()); diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java index 5d68ffad6c..7c2940fdc2 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSet.java @@ -27,8 +27,8 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { private final TSDBResultSetRowData rowData; private final TSDBResultSetBlockData blockData; - private boolean batchFetch = false; - private boolean lastWasNull = false; + private boolean batchFetch; + private boolean lastWasNull; private boolean isClosed; public void setBatchFetch(boolean batchFetch) { @@ -86,7 +86,6 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { if (rowData != null) { this.rowData.clear(); } - int code = this.jniConnector.fetchRow(this.resultSetPointer, this.rowData); if (code == TSDBConstants.JNI_CONNECTION_NULL) { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); @@ -124,30 +123,27 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { String res = null; int colIndex = getTrueColumnIndex(columnIndex); - if (!this.getBatchFetch()) { - this.lastWasNull = this.rowData.wasNull(colIndex); - if (!lastWasNull) { - res = this.rowData.getString(colIndex, this.columnMetaDataList.get(colIndex).getColType()); - } - return res; - } else { + if (this.getBatchFetch()) return this.blockData.getString(colIndex); + + this.lastWasNull = this.rowData.wasNull(colIndex); + if (!lastWasNull) { + res = this.rowData.getString(colIndex, this.columnMetaDataList.get(colIndex).getColType()); } + return res; } public boolean getBoolean(int columnIndex) throws SQLException { boolean res = false; int colIndex = getTrueColumnIndex(columnIndex); - if (!this.getBatchFetch()) { - this.lastWasNull = this.rowData.wasNull(colIndex); - if (!lastWasNull) { - res = this.rowData.getBoolean(colIndex, this.columnMetaDataList.get(colIndex).getColType()); - } - } else { + if (this.getBatchFetch()) return this.blockData.getBoolean(colIndex); - } + this.lastWasNull = this.rowData.wasNull(colIndex); + if (!lastWasNull) { + res = this.rowData.getBoolean(colIndex, this.columnMetaDataList.get(colIndex).getColType()); + } return res; } @@ -155,91 +151,84 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { byte res = 0; int colIndex = getTrueColumnIndex(columnIndex); - if (!this.getBatchFetch()) { - this.lastWasNull = this.rowData.wasNull(colIndex); - if (!lastWasNull) { - res = (byte) this.rowData.getInt(colIndex, this.columnMetaDataList.get(colIndex).getColType()); - } - return res; - } else { + if (this.getBatchFetch()) return (byte) this.blockData.getInt(colIndex); + + this.lastWasNull = this.rowData.wasNull(colIndex); + if (!lastWasNull) { + res = (byte) this.rowData.getInt(colIndex, this.columnMetaDataList.get(colIndex).getColType()); } + return res; } public short getShort(int columnIndex) throws SQLException { short res = 0; int colIndex = getTrueColumnIndex(columnIndex); - if (!this.getBatchFetch()) { - this.lastWasNull = this.rowData.wasNull(colIndex); - if (!lastWasNull) { - res = (short) this.rowData.getInt(colIndex, this.columnMetaDataList.get(colIndex).getColType()); - } - return res; - } else { + if (this.getBatchFetch()) return (short) this.blockData.getInt(colIndex); + + this.lastWasNull = this.rowData.wasNull(colIndex); + if (!lastWasNull) { + res = (short) this.rowData.getInt(colIndex, this.columnMetaDataList.get(colIndex).getColType()); } + return res; } public int getInt(int columnIndex) throws SQLException { int res = 0; int colIndex = getTrueColumnIndex(columnIndex); - if (!this.getBatchFetch()) { - this.lastWasNull = this.rowData.wasNull(colIndex); - if (!lastWasNull) { - res = this.rowData.getInt(colIndex, this.columnMetaDataList.get(colIndex).getColType()); - } - return res; - } else { + if (this.getBatchFetch()) return this.blockData.getInt(colIndex); - } + this.lastWasNull = this.rowData.wasNull(colIndex); + if (!lastWasNull) { + res = this.rowData.getInt(colIndex, this.columnMetaDataList.get(colIndex).getColType()); + } + return res; } public long getLong(int columnIndex) throws SQLException { long res = 0L; int colIndex = getTrueColumnIndex(columnIndex); - if (!this.getBatchFetch()) { - this.lastWasNull = this.rowData.wasNull(colIndex); - if (!lastWasNull) { - res = this.rowData.getLong(colIndex, this.columnMetaDataList.get(colIndex).getColType()); - } - return res; - } else { + if (this.getBatchFetch()) return this.blockData.getLong(colIndex); + + this.lastWasNull = this.rowData.wasNull(colIndex); + if (!lastWasNull) { + res = this.rowData.getLong(colIndex, this.columnMetaDataList.get(colIndex).getColType()); } + return res; } public float getFloat(int columnIndex) throws SQLException { float res = 0; int colIndex = getTrueColumnIndex(columnIndex); - if (!this.getBatchFetch()) { - this.lastWasNull = this.rowData.wasNull(colIndex); - if (!lastWasNull) { - res = this.rowData.getFloat(colIndex, this.columnMetaDataList.get(colIndex).getColType()); - } - return res; - } else { + if (this.getBatchFetch()) return (float) this.blockData.getDouble(colIndex); - } + + this.lastWasNull = this.rowData.wasNull(colIndex); + if (!lastWasNull) + res = this.rowData.getFloat(colIndex, this.columnMetaDataList.get(colIndex).getColType()); + + return res; } public double getDouble(int columnIndex) throws SQLException { double res = 0; int colIndex = getTrueColumnIndex(columnIndex); - if (!this.getBatchFetch()) { - this.lastWasNull = this.rowData.wasNull(colIndex); - if (!lastWasNull) { - res = this.rowData.getDouble(colIndex, this.columnMetaDataList.get(colIndex).getColType()); - } - return res; - } else { + if (this.getBatchFetch()) return this.blockData.getDouble(colIndex); + + this.lastWasNull = this.rowData.wasNull(colIndex); + if (!lastWasNull) { + res = this.rowData.getDouble(colIndex, this.columnMetaDataList.get(colIndex).getColType()); } + return res; } @Deprecated @@ -255,15 +244,14 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { Timestamp res = null; int colIndex = getTrueColumnIndex(columnIndex); - if (!this.getBatchFetch()) { - this.lastWasNull = this.rowData.wasNull(colIndex); - if (!lastWasNull) { - res = this.rowData.getTimestamp(colIndex); - } - return res; - } else { + if (this.getBatchFetch()) return this.blockData.getTimestamp(columnIndex); + + this.lastWasNull = this.rowData.wasNull(colIndex); + if (!lastWasNull) { + res = this.rowData.getTimestamp(colIndex); } + return res; } public ResultSetMetaData getMetaData() throws SQLException { @@ -274,12 +262,11 @@ public class TSDBResultSet extends AbstractResultSet implements ResultSet { public Object getObject(int columnIndex) throws SQLException { int colIndex = getTrueColumnIndex(columnIndex); - if (!this.getBatchFetch()) { - this.lastWasNull = this.rowData.wasNull(colIndex); - return this.rowData.get(colIndex); - } else { + if (this.getBatchFetch()) return this.blockData.get(colIndex); - } + + this.lastWasNull = this.rowData.wasNull(colIndex); + return this.rowData.get(colIndex); } @Override diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java index 9352cf5253..ce5290de66 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetBlockData.java @@ -30,468 +30,472 @@ import java.util.Collections; import java.util.List; public class TSDBResultSetBlockData { - private int numOfRows = 0; - private int rowIndex = 0; - - private List columnMetaDataList; - private ArrayList colData = null; - - public TSDBResultSetBlockData(List colMeta, int numOfCols) { - this.columnMetaDataList = colMeta; - this.colData = new ArrayList(numOfCols); - } - - public TSDBResultSetBlockData() { - this.colData = new ArrayList(); - } - - public void clear() { - int size = this.colData.size(); - if (this.colData != null) { - this.colData.clear(); - } - - setNumOfCols(size); - } - - public int getNumOfRows() { - return this.numOfRows; - } - - public void setNumOfRows(int numOfRows) { - this.numOfRows = numOfRows; - } - - public int getNumOfCols() { - return this.colData.size(); - } - - public void setNumOfCols(int numOfCols) { - this.colData = new ArrayList(numOfCols); - this.colData.addAll(Collections.nCopies(numOfCols, null)); - } - - public boolean hasMore() { - return this.rowIndex < this.numOfRows; - } - - public boolean forward() { - if (this.rowIndex > this.numOfRows) { - return false; - } - - return ((++this.rowIndex) < this.numOfRows); - } - - public void reset() { - this.rowIndex = 0; - } - - public void setBoolean(int col, boolean value) { - colData.set(col, value); - } - - public void setByteArray(int col, int length, byte[] value) { - try { - switch (this.columnMetaDataList.get(col).getColType()) { - case TSDBConstants.TSDB_DATA_TYPE_BOOL: { - ByteBuffer buf = ByteBuffer.wrap(value, 0, length); - buf.order(ByteOrder.LITTLE_ENDIAN).asCharBuffer(); - this.colData.set(col, buf); - break; - } - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: { - ByteBuffer buf = ByteBuffer.wrap(value, 0, length); - buf.order(ByteOrder.LITTLE_ENDIAN); - this.colData.set(col, buf); - break; - } - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: { - ByteBuffer buf = ByteBuffer.wrap(value, 0, length); - ShortBuffer sb = buf.order(ByteOrder.LITTLE_ENDIAN).asShortBuffer(); - this.colData.set(col, sb); - break; - } - case TSDBConstants.TSDB_DATA_TYPE_INT: { - ByteBuffer buf = ByteBuffer.wrap(value, 0, length); - IntBuffer ib = buf.order(ByteOrder.LITTLE_ENDIAN).asIntBuffer(); - this.colData.set(col, ib); - break; - } - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: { - ByteBuffer buf = ByteBuffer.wrap(value, 0, length); - LongBuffer lb = buf.order(ByteOrder.LITTLE_ENDIAN).asLongBuffer(); - this.colData.set(col, lb); - break; - } - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: { - ByteBuffer buf = ByteBuffer.wrap(value, 0, length); - FloatBuffer fb = buf.order(ByteOrder.LITTLE_ENDIAN).asFloatBuffer(); - this.colData.set(col, fb); - break; - } - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { - ByteBuffer buf = ByteBuffer.wrap(value, 0, length); - DoubleBuffer db = buf.order(ByteOrder.LITTLE_ENDIAN).asDoubleBuffer(); - this.colData.set(col, db); - break; - } - case TSDBConstants.TSDB_DATA_TYPE_BINARY: { - ByteBuffer buf = ByteBuffer.wrap(value, 0, length); - buf.order(ByteOrder.LITTLE_ENDIAN); - this.colData.set(col, buf); - break; - } - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: { - ByteBuffer buf = ByteBuffer.wrap(value, 0, length); - LongBuffer lb = buf.order(ByteOrder.LITTLE_ENDIAN).asLongBuffer(); - this.colData.set(col, lb); - break; - } - case TSDBConstants.TSDB_DATA_TYPE_NCHAR: { - ByteBuffer buf = ByteBuffer.wrap(value, 0, length); - buf.order(ByteOrder.LITTLE_ENDIAN); - this.colData.set(col, buf); - break; - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - private static class NullType { - private static final byte NULL_BOOL_VAL = 0x2; - private static final String NULL_STR = "null"; - - public String toString() { - return NullType.NULL_STR; - } - - public static boolean isBooleanNull(byte val) { - return val == NullType.NULL_BOOL_VAL; - } - - private static boolean isTinyIntNull(byte val) { - return val == Byte.MIN_VALUE; - } - - private static boolean isSmallIntNull(short val) { - return val == Short.MIN_VALUE; - } - - private static boolean isIntNull(int val) { - return val == Integer.MIN_VALUE; - } - - private static boolean isBigIntNull(long val) { - return val == Long.MIN_VALUE; - } - - private static boolean isFloatNull(float val) { - return Float.isNaN(val); - } - - private static boolean isDoubleNull(double val) { - return Double.isNaN(val); - } - - private static boolean isBinaryNull(byte[] val, int length) { - if (length != Byte.BYTES) { - return false; - } - - return val[0] == 0xFF; - } - - private static boolean isNcharNull(byte[] val, int length) { - if (length != Integer.BYTES) { - return false; - } - - return (val[0] & val[1] & val[2] & val[3]) == 0xFF; - } - - } - - /** - * The original type may not be a string type, but will be converted to by - * calling this method - * - * @param col column index - * @return - * @throws SQLException - */ - public String getString(int col) throws SQLException { - Object obj = get(col); - if (obj == null) { - return new NullType().toString(); - } - - return obj.toString(); - } - - public int getInt(int col) { - Object obj = get(col); - if (obj == null) { - return 0; - } - - int type = this.columnMetaDataList.get(col).getColType(); - switch (type) { - case TSDBConstants.TSDB_DATA_TYPE_BOOL: - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: - case TSDBConstants.TSDB_DATA_TYPE_INT: { - return (int) obj; - } - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: { - return ((Long) obj).intValue(); - } - - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { - return ((Double) obj).intValue(); - } - - case TSDBConstants.TSDB_DATA_TYPE_NCHAR: - case TSDBConstants.TSDB_DATA_TYPE_BINARY: { - return Integer.parseInt((String) obj); - } - } - - return 0; - } - - public boolean getBoolean(int col) throws SQLException { - Object obj = get(col); - if (obj == null) { - return Boolean.FALSE; - } - - int type = this.columnMetaDataList.get(col).getColType(); - switch (type) { - case TSDBConstants.TSDB_DATA_TYPE_BOOL: - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: - case TSDBConstants.TSDB_DATA_TYPE_INT: { - return ((int) obj == 0L) ? Boolean.FALSE : Boolean.TRUE; - } - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: { - return (((Long) obj) == 0L) ? Boolean.FALSE : Boolean.TRUE; - } - - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { - return (((Double) obj) == 0) ? Boolean.FALSE : Boolean.TRUE; - } - - case TSDBConstants.TSDB_DATA_TYPE_NCHAR: - case TSDBConstants.TSDB_DATA_TYPE_BINARY: { - if ("TRUE".compareToIgnoreCase((String) obj) == 0) { - return Boolean.TRUE; - } else if ("FALSE".compareToIgnoreCase((String) obj) == 0) { - return Boolean.TRUE; - } else { - throw new SQLDataException(); - } - } - } - - return Boolean.FALSE; - } - - public long getLong(int col) throws SQLException { - Object obj = get(col); - if (obj == null) { - return 0; - } - - int type = this.columnMetaDataList.get(col).getColType(); - switch (type) { - case TSDBConstants.TSDB_DATA_TYPE_BOOL: - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: - case TSDBConstants.TSDB_DATA_TYPE_INT: { - return (int) obj; - } - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: { - return (long) obj; - } - - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { - return ((Double) obj).longValue(); - } - - case TSDBConstants.TSDB_DATA_TYPE_NCHAR: - case TSDBConstants.TSDB_DATA_TYPE_BINARY: { - return Long.parseLong((String) obj); - } - } - - return 0; - } - - public Timestamp getTimestamp(int col) { - try { - return new Timestamp(getLong(col)); - } catch (SQLException e) { - e.printStackTrace(); - } - - return null; - } - - public double getDouble(int col) { - Object obj = get(col); - if (obj == null) { - return 0; - } - - int type = this.columnMetaDataList.get(col).getColType(); - switch (type) { - case TSDBConstants.TSDB_DATA_TYPE_BOOL: - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: - case TSDBConstants.TSDB_DATA_TYPE_INT: { - return (int) obj; - } - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: { - return (long) obj; - } - - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { - return (double) obj; - } - - case TSDBConstants.TSDB_DATA_TYPE_NCHAR: - case TSDBConstants.TSDB_DATA_TYPE_BINARY: { - return Double.parseDouble((String) obj); - } - } - - return 0; - } - - public Object get(int col) { - int fieldSize = this.columnMetaDataList.get(col).getColSize(); - - switch (this.columnMetaDataList.get(col).getColType()) { - case TSDBConstants.TSDB_DATA_TYPE_BOOL: { - ByteBuffer bb = (ByteBuffer) this.colData.get(col); - - byte val = bb.get(this.rowIndex); - if (NullType.isBooleanNull(val)) { - return null; - } - - return (val == 0x0) ? Boolean.FALSE : Boolean.TRUE; - } - - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: { - ByteBuffer bb = (ByteBuffer) this.colData.get(col); - - byte val = bb.get(this.rowIndex); - if (NullType.isTinyIntNull(val)) { - return null; - } - - return val; - } - - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: { - ShortBuffer sb = (ShortBuffer) this.colData.get(col); - short val = sb.get(this.rowIndex); - if (NullType.isSmallIntNull(val)) { - return null; - } - - return val; - } - - case TSDBConstants.TSDB_DATA_TYPE_INT: { - IntBuffer ib = (IntBuffer) this.colData.get(col); - int val = ib.get(this.rowIndex); - if (NullType.isIntNull(val)) { - return null; - } - - return val; - } - - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: { - LongBuffer lb = (LongBuffer) this.colData.get(col); - long val = lb.get(this.rowIndex); - if (NullType.isBigIntNull(val)) { - return null; - } - - return (long) val; - } - - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: { - FloatBuffer fb = (FloatBuffer) this.colData.get(col); - float val = fb.get(this.rowIndex); - if (NullType.isFloatNull(val)) { - return null; - } - - return val; - } - - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { - DoubleBuffer lb = (DoubleBuffer) this.colData.get(col); - double val = lb.get(this.rowIndex); - if (NullType.isDoubleNull(val)) { - return null; - } - - return val; - } - - case TSDBConstants.TSDB_DATA_TYPE_BINARY: { - ByteBuffer bb = (ByteBuffer) this.colData.get(col); - bb.position(fieldSize * this.rowIndex); - - int length = bb.getShort(); - - byte[] dest = new byte[length]; - bb.get(dest, 0, length); - if (NullType.isBinaryNull(dest, length)) { - return null; - } - - return new String(dest); - } - - case TSDBConstants.TSDB_DATA_TYPE_NCHAR: { - ByteBuffer bb = (ByteBuffer) this.colData.get(col); - bb.position(fieldSize * this.rowIndex); - - int length = bb.getShort(); - - byte[] dest = new byte[length]; - bb.get(dest, 0, length); - if (NullType.isNcharNull(dest, length)) { - return null; - } - - try { - String ss = TaosGlobalConfig.getCharset(); - return new String(dest, ss); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - } - } - - return 0; - } + private int numOfRows = 0; + private int rowIndex = 0; + + private List columnMetaDataList; + private ArrayList colData = null; + + public TSDBResultSetBlockData(List colMeta, int numOfCols) { + this.columnMetaDataList = colMeta; + this.colData = new ArrayList(numOfCols); + } + + public TSDBResultSetBlockData() { + this.colData = new ArrayList(); + } + + public void clear() { + int size = this.colData.size(); + if (this.colData != null) { + this.colData.clear(); + } + + setNumOfCols(size); + } + + public int getNumOfRows() { + return this.numOfRows; + } + + public void setNumOfRows(int numOfRows) { + this.numOfRows = numOfRows; + } + + public int getNumOfCols() { + return this.colData.size(); + } + + public void setNumOfCols(int numOfCols) { + this.colData = new ArrayList(numOfCols); + this.colData.addAll(Collections.nCopies(numOfCols, null)); + } + + public boolean hasMore() { + return this.rowIndex < this.numOfRows; + } + + public boolean forward() { + if (this.rowIndex > this.numOfRows) { + return false; + } + + return ((++this.rowIndex) < this.numOfRows); + } + + public void reset() { + this.rowIndex = 0; + } + + public void setBoolean(int col, boolean value) { + colData.set(col, value); + } + + public void setByteArray(int col, int length, byte[] value) { + try { + switch (this.columnMetaDataList.get(col).getColType()) { + case TSDBConstants.TSDB_DATA_TYPE_BOOL: { + ByteBuffer buf = ByteBuffer.wrap(value, 0, length); + buf.order(ByteOrder.LITTLE_ENDIAN).asCharBuffer(); + this.colData.set(col, buf); + break; + } + case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: { + ByteBuffer buf = ByteBuffer.wrap(value, 0, length); + buf.order(ByteOrder.LITTLE_ENDIAN); + this.colData.set(col, buf); + break; + } + case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: { + ByteBuffer buf = ByteBuffer.wrap(value, 0, length); + ShortBuffer sb = buf.order(ByteOrder.LITTLE_ENDIAN).asShortBuffer(); + this.colData.set(col, sb); + break; + } + case TSDBConstants.TSDB_DATA_TYPE_UINT: + case TSDBConstants.TSDB_DATA_TYPE_INT: { + ByteBuffer buf = ByteBuffer.wrap(value, 0, length); + IntBuffer ib = buf.order(ByteOrder.LITTLE_ENDIAN).asIntBuffer(); + this.colData.set(col, ib); + break; + } + case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: { + ByteBuffer buf = ByteBuffer.wrap(value, 0, length); + LongBuffer lb = buf.order(ByteOrder.LITTLE_ENDIAN).asLongBuffer(); + this.colData.set(col, lb); + break; + } + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: { + ByteBuffer buf = ByteBuffer.wrap(value, 0, length); + FloatBuffer fb = buf.order(ByteOrder.LITTLE_ENDIAN).asFloatBuffer(); + this.colData.set(col, fb); + break; + } + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { + ByteBuffer buf = ByteBuffer.wrap(value, 0, length); + DoubleBuffer db = buf.order(ByteOrder.LITTLE_ENDIAN).asDoubleBuffer(); + this.colData.set(col, db); + break; + } + case TSDBConstants.TSDB_DATA_TYPE_BINARY: { + ByteBuffer buf = ByteBuffer.wrap(value, 0, length); + buf.order(ByteOrder.LITTLE_ENDIAN); + this.colData.set(col, buf); + break; + } + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: { + ByteBuffer buf = ByteBuffer.wrap(value, 0, length); + LongBuffer lb = buf.order(ByteOrder.LITTLE_ENDIAN).asLongBuffer(); + this.colData.set(col, lb); + break; + } + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: { + ByteBuffer buf = ByteBuffer.wrap(value, 0, length); + buf.order(ByteOrder.LITTLE_ENDIAN); + this.colData.set(col, buf); + break; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static class NullType { + private static final byte NULL_BOOL_VAL = 0x2; + private static final String NULL_STR = "null"; + + public String toString() { + return NullType.NULL_STR; + } + + public static boolean isBooleanNull(byte val) { + return val == NullType.NULL_BOOL_VAL; + } + + private static boolean isTinyIntNull(byte val) { + return val == Byte.MIN_VALUE; + } + + private static boolean isSmallIntNull(short val) { + return val == Short.MIN_VALUE; + } + + private static boolean isIntNull(int val) { + return val == Integer.MIN_VALUE; + } + + private static boolean isBigIntNull(long val) { + return val == Long.MIN_VALUE; + } + + private static boolean isFloatNull(float val) { + return Float.isNaN(val); + } + + private static boolean isDoubleNull(double val) { + return Double.isNaN(val); + } + + private static boolean isBinaryNull(byte[] val, int length) { + if (length != Byte.BYTES) { + return false; + } + + return val[0] == 0xFF; + } + + private static boolean isNcharNull(byte[] val, int length) { + if (length != Integer.BYTES) { + return false; + } + + return (val[0] & val[1] & val[2] & val[3]) == 0xFF; + } + + } + + /** + * The original type may not be a string type, but will be converted to by + * calling this method + * + * @param col column index + * @return + * @throws SQLException + */ + public String getString(int col) throws SQLException { + Object obj = get(col); + if (obj == null) { + return new NullType().toString(); + } + + return obj.toString(); + } + + public int getInt(int col) { + Object obj = get(col); + if (obj == null) { + return 0; + } + + int type = this.columnMetaDataList.get(col).getColType(); + switch (type) { + case TSDBConstants.TSDB_DATA_TYPE_BOOL: + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: + case TSDBConstants.TSDB_DATA_TYPE_INT: { + return (int) obj; + } + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: { + return ((Long) obj).intValue(); + } + + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { + return ((Double) obj).intValue(); + } + + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: { + return Integer.parseInt((String) obj); + } + } + + return 0; + } + + public boolean getBoolean(int col) throws SQLException { + Object obj = get(col); + if (obj == null) { + return Boolean.FALSE; + } + + int type = this.columnMetaDataList.get(col).getColType(); + switch (type) { + case TSDBConstants.TSDB_DATA_TYPE_BOOL: + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: + case TSDBConstants.TSDB_DATA_TYPE_INT: { + return ((int) obj == 0L) ? Boolean.FALSE : Boolean.TRUE; + } + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: { + return (((Long) obj) == 0L) ? Boolean.FALSE : Boolean.TRUE; + } + + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { + return (((Double) obj) == 0) ? Boolean.FALSE : Boolean.TRUE; + } + + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: { + if ("TRUE".compareToIgnoreCase((String) obj) == 0) { + return Boolean.TRUE; + } else if ("FALSE".compareToIgnoreCase((String) obj) == 0) { + return Boolean.TRUE; + } else { + throw new SQLDataException(); + } + } + } + + return Boolean.FALSE; + } + + public long getLong(int col) throws SQLException { + Object obj = get(col); + if (obj == null) { + return 0; + } + + int type = this.columnMetaDataList.get(col).getColType(); + switch (type) { + case TSDBConstants.TSDB_DATA_TYPE_BOOL: + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: + case TSDBConstants.TSDB_DATA_TYPE_INT: { + return (int) obj; + } + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: { + return (long) obj; + } + + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { + return ((Double) obj).longValue(); + } + + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: { + return Long.parseLong((String) obj); + } + } + + return 0; + } + + public Timestamp getTimestamp(int col) { + try { + return new Timestamp(getLong(col)); + } catch (SQLException e) { + e.printStackTrace(); + } + + return null; + } + + public double getDouble(int col) { + Object obj = get(col); + if (obj == null) { + return 0; + } + + int type = this.columnMetaDataList.get(col).getColType(); + switch (type) { + case TSDBConstants.TSDB_DATA_TYPE_BOOL: + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: + case TSDBConstants.TSDB_DATA_TYPE_INT: { + return (int) obj; + } + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: { + return (long) obj; + } + + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { + return (double) obj; + } + + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: { + return Double.parseDouble((String) obj); + } + } + + return 0; + } + + public Object get(int col) { + int fieldSize = this.columnMetaDataList.get(col).getColSize(); + + switch (this.columnMetaDataList.get(col).getColType()) { + case TSDBConstants.TSDB_DATA_TYPE_BOOL: { + ByteBuffer bb = (ByteBuffer) this.colData.get(col); + + byte val = bb.get(this.rowIndex); + if (NullType.isBooleanNull(val)) { + return null; + } + + return (val == 0x0) ? Boolean.FALSE : Boolean.TRUE; + } + + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: { + ByteBuffer bb = (ByteBuffer) this.colData.get(col); + + byte val = bb.get(this.rowIndex); + if (NullType.isTinyIntNull(val)) { + return null; + } + + return val; + } + + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: { + ShortBuffer sb = (ShortBuffer) this.colData.get(col); + short val = sb.get(this.rowIndex); + if (NullType.isSmallIntNull(val)) { + return null; + } + + return val; + } + + case TSDBConstants.TSDB_DATA_TYPE_INT: { + IntBuffer ib = (IntBuffer) this.colData.get(col); + int val = ib.get(this.rowIndex); + if (NullType.isIntNull(val)) { + return null; + } + + return val; + } + + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: { + LongBuffer lb = (LongBuffer) this.colData.get(col); + long val = lb.get(this.rowIndex); + if (NullType.isBigIntNull(val)) { + return null; + } + + return (long) val; + } + + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: { + FloatBuffer fb = (FloatBuffer) this.colData.get(col); + float val = fb.get(this.rowIndex); + if (NullType.isFloatNull(val)) { + return null; + } + + return val; + } + + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: { + DoubleBuffer lb = (DoubleBuffer) this.colData.get(col); + double val = lb.get(this.rowIndex); + if (NullType.isDoubleNull(val)) { + return null; + } + + return val; + } + + case TSDBConstants.TSDB_DATA_TYPE_BINARY: { + ByteBuffer bb = (ByteBuffer) this.colData.get(col); + bb.position(fieldSize * this.rowIndex); + + int length = bb.getShort(); + + byte[] dest = new byte[length]; + bb.get(dest, 0, length); + if (NullType.isBinaryNull(dest, length)) { + return null; + } + + return new String(dest); + } + + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: { + ByteBuffer bb = (ByteBuffer) this.colData.get(col); + bb.position(fieldSize * this.rowIndex); + + int length = bb.getShort(); + + byte[] dest = new byte[length]; + bb.get(dest, 0, length); + if (NullType.isNcharNull(dest, length)) { + return null; + } + + try { + String ss = TaosGlobalConfig.getCharset(); + return new String(dest, ss); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + } + } + + return 0; + } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetMetaData.java index e0b1c246cb..7abd997459 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetMetaData.java @@ -126,34 +126,12 @@ public class TSDBResultSetMetaData extends WrapperImpl implements ResultSetMetaD public int getColumnType(int column) throws SQLException { ColumnMetaData meta = this.colMetaDataList.get(column - 1); - switch (meta.getColType()) { - case TSDBConstants.TSDB_DATA_TYPE_BOOL: - return Types.BOOLEAN; - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: - return java.sql.Types.TINYINT; - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: - return java.sql.Types.SMALLINT; - case TSDBConstants.TSDB_DATA_TYPE_INT: - return java.sql.Types.INTEGER; - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: - return java.sql.Types.BIGINT; - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: - return java.sql.Types.FLOAT; - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: - return java.sql.Types.DOUBLE; - case TSDBConstants.TSDB_DATA_TYPE_BINARY: - return Types.BINARY; - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: - return java.sql.Types.TIMESTAMP; - case TSDBConstants.TSDB_DATA_TYPE_NCHAR: - return Types.NCHAR; - } - throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_VARIABLE); + return TSDBConstants.taosType2JdbcType(meta.getColType()); } public String getColumnTypeName(int column) throws SQLException { ColumnMetaData meta = this.colMetaDataList.get(column - 1); - return TSDBConstants.DATATYPE_MAP.get(meta.getColType()); + return TSDBConstants.taosType2JdbcTypeName(meta.getColType()); } public boolean isReadOnly(int column) throws SQLException { diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java index 6518bf10e4..44d760897b 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBResultSetRowData.java @@ -14,208 +14,322 @@ *****************************************************************************/ package com.taosdata.jdbc; +import java.math.BigDecimal; import java.sql.SQLException; import java.sql.Timestamp; import java.util.ArrayList; import java.util.Collections; public class TSDBResultSetRowData { - private ArrayList data = null; - private int colSize = 0; + private ArrayList data = null; + private int colSize = 0; - public TSDBResultSetRowData(int colSize) { - this.setColSize(colSize); - } + public TSDBResultSetRowData(int colSize) { + this.setColSize(colSize); + } - public TSDBResultSetRowData() { - this.data = new ArrayList<>(); - this.setColSize(0); - } + public TSDBResultSetRowData() { + this.data = new ArrayList<>(); + this.setColSize(0); + } - public void clear() { - if(this.data != null) { - this.data.clear(); - } - if (this.colSize == 0) { - return; - } - this.data = new ArrayList<>(colSize); - this.data.addAll(Collections.nCopies(this.colSize, null)); - } + public void clear() { + if (this.data != null) { + this.data.clear(); + } + if (this.colSize == 0) { + return; + } + this.data = new ArrayList<>(colSize); + this.data.addAll(Collections.nCopies(this.colSize, null)); + } - public boolean wasNull(int col) { - return data.get(col) == null; - } + public boolean wasNull(int col) { + return data.get(col) == null; + } - public void setBoolean(int col, boolean value) { - data.set(col, value); - } + public void setBoolean(int col, boolean value) { + data.set(col, value); + } - public boolean getBoolean(int col, int srcType) throws SQLException { - Object obj = data.get(col); + public boolean getBoolean(int col, int srcType) throws SQLException { + Object obj = data.get(col); - switch(srcType) { - case TSDBConstants.TSDB_DATA_TYPE_BOOL: return (Boolean) obj; - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: return ((Float) obj) == 1.0? Boolean.TRUE:Boolean.FALSE; - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: return ((Double) obj) == 1.0? Boolean.TRUE:Boolean.FALSE; - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: return ((Byte) obj) == 1? Boolean.TRUE:Boolean.FALSE; - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT:return ((Short)obj) == 1? Boolean.TRUE:Boolean.FALSE; - case TSDBConstants.TSDB_DATA_TYPE_INT: return ((Integer)obj) == 1? Boolean.TRUE:Boolean.FALSE; - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return ((Long) obj) == 1L? Boolean.TRUE:Boolean.FALSE; - } + switch (srcType) { + case TSDBConstants.TSDB_DATA_TYPE_BOOL: + return (Boolean) obj; + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: + return ((Float) obj) == 1.0 ? Boolean.TRUE : Boolean.FALSE; + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: + return ((Double) obj) == 1.0 ? Boolean.TRUE : Boolean.FALSE; + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: + return ((Byte) obj) == 1 ? Boolean.TRUE : Boolean.FALSE; + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: + return ((Short) obj) == 1 ? Boolean.TRUE : Boolean.FALSE; + case TSDBConstants.TSDB_DATA_TYPE_INT: + return ((Integer) obj) == 1 ? Boolean.TRUE : Boolean.FALSE; + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: + return ((Long) obj) == 1L ? Boolean.TRUE : Boolean.FALSE; + } - return Boolean.TRUE; - } + return Boolean.TRUE; + } - public void setByte(int col, byte value) { - data.set(col, value); - } + public void setByte(int col, byte value) { + data.set(col, value); + } - public void setShort(int col, short value) { - data.set(col, value); - } + public void setShort(int col, short value) { + data.set(col, value); + } - public void setInt(int col, int value) { - data.set(col, value); - } + public void setInt(int col, int value) { + data.set(col, value); + } - public int getInt(int col, int srcType) throws SQLException { - Object obj = data.get(col); + public int getInt(int col, int srcType) throws SQLException { + Object obj = data.get(col); - switch(srcType) { - case TSDBConstants.TSDB_DATA_TYPE_BOOL: return Boolean.TRUE.equals(obj)? 1:0; - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: return ((Float) obj).intValue(); - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: return ((Double)obj).intValue(); - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: return (Byte) obj; - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT:return (Short) obj; - case TSDBConstants.TSDB_DATA_TYPE_INT: return (Integer) obj; - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return ((Long) obj).intValue(); - case TSDBConstants.TSDB_DATA_TYPE_NCHAR: - case TSDBConstants.TSDB_DATA_TYPE_BINARY: return Integer.parseInt((String) obj); - } + switch (srcType) { + case TSDBConstants.TSDB_DATA_TYPE_BOOL: + return Boolean.TRUE.equals(obj) ? 1 : 0; + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: + return ((Float) obj).intValue(); + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: + return ((Double) obj).intValue(); + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: + return (Byte) obj; + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: + return (Short) obj; + case TSDBConstants.TSDB_DATA_TYPE_INT: + return (Integer) obj; + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: + return ((Long) obj).intValue(); + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: + return Integer.parseInt((String) obj); + case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: { + Byte value = (byte) obj; + if (value < 0) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); + return value; + } + case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: { + short value = (short) obj; + if (value < 0) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); + return value; + } + case TSDBConstants.TSDB_DATA_TYPE_UINT: { + int value = (int) obj; + if (value < 0) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); + return value; + } + case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: { + long value = (long) obj; + if (value < 0) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); + return new Long(value).intValue(); + } + } - return 0; - } + return 0; + } - public void setLong(int col, long value) { - data.set(col, value); - } + public void setLong(int col, long value) { + data.set(col, value); + } - public long getLong(int col, int srcType) throws SQLException { - Object obj = data.get(col); + public long getLong(int col, int srcType) throws SQLException { + Object obj = data.get(col); - switch(srcType) { - case TSDBConstants.TSDB_DATA_TYPE_BOOL: return Boolean.TRUE.equals(obj)? 1:0; - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: return ((Float) obj).longValue(); - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: return ((Double) obj).longValue(); - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: return (Byte) obj; - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT:return (Short) obj; - case TSDBConstants.TSDB_DATA_TYPE_INT: return (Integer) obj; - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return (Long) obj; - case TSDBConstants.TSDB_DATA_TYPE_NCHAR: - case TSDBConstants.TSDB_DATA_TYPE_BINARY: return Long.parseLong((String) obj); - } + switch (srcType) { + case TSDBConstants.TSDB_DATA_TYPE_BOOL: + return Boolean.TRUE.equals(obj) ? 1 : 0; + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: + return ((Float) obj).longValue(); + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: + return ((Double) obj).longValue(); + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: + return (Byte) obj; + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: + return (Short) obj; + case TSDBConstants.TSDB_DATA_TYPE_INT: + return (Integer) obj; + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: + return (Long) obj; + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: + return Long.parseLong((String) obj); + case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: { + Byte value = (byte) obj; + if (value < 0) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); + return value; + } + case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: { + short value = (short) obj; + if (value < 0) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); + return value; + } + case TSDBConstants.TSDB_DATA_TYPE_UINT: { + int value = (int) obj; + if (value < 0) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); + return value; + } + case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: { + long value = (long) obj; + if (value < 0) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE); + return value; + } + } - return 0; - } + return 0; + } - public void setFloat(int col, float value) { - data.set(col, value); - } + public void setFloat(int col, float value) { + data.set(col, value); + } - public float getFloat(int col, int srcType) throws SQLException { - Object obj = data.get(col); + public float getFloat(int col, int srcType) throws SQLException { + Object obj = data.get(col); - switch(srcType) { - case TSDBConstants.TSDB_DATA_TYPE_BOOL: return Boolean.TRUE.equals(obj)? 1:0; - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: return (Float) obj; - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: return ((Double) obj).floatValue(); - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: return (Byte) obj; - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: return (Short) obj; - case TSDBConstants.TSDB_DATA_TYPE_INT: return (Integer) obj; - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return (Long) obj; - } + switch (srcType) { + case TSDBConstants.TSDB_DATA_TYPE_BOOL: + return Boolean.TRUE.equals(obj) ? 1 : 0; + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: + return (Float) obj; + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: + return ((Double) obj).floatValue(); + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: + return (Byte) obj; + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: + return (Short) obj; + case TSDBConstants.TSDB_DATA_TYPE_INT: + return (Integer) obj; + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: + return (Long) obj; + } - return 0; - } + return 0; + } - public void setDouble(int col, double value) { - data.set(col, value); - } + public void setDouble(int col, double value) { + data.set(col, value); + } - public double getDouble(int col, int srcType) throws SQLException { - Object obj = data.get(col); + public double getDouble(int col, int srcType) throws SQLException { + Object obj = data.get(col); - switch(srcType) { - case TSDBConstants.TSDB_DATA_TYPE_BOOL: return Boolean.TRUE.equals(obj)? 1:0; - case TSDBConstants.TSDB_DATA_TYPE_FLOAT: return (Float) obj; - case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: return (Double) obj; - case TSDBConstants.TSDB_DATA_TYPE_TINYINT: return (Byte) obj; - case TSDBConstants.TSDB_DATA_TYPE_SMALLINT:return (Short) obj; - case TSDBConstants.TSDB_DATA_TYPE_INT: return (Integer) obj; - case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: - case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return (Long) obj; - } + switch (srcType) { + case TSDBConstants.TSDB_DATA_TYPE_BOOL: + return Boolean.TRUE.equals(obj) ? 1 : 0; + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: + return (Float) obj; + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: + return (Double) obj; + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: + return (Byte) obj; + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: + return (Short) obj; + case TSDBConstants.TSDB_DATA_TYPE_INT: + return (Integer) obj; + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: + return (Long) obj; + } - return 0; - } + return 0; + } - public void setString(int col, String value) { - data.set(col, value); - } + public void setString(int col, String value) { + data.set(col, value); + } - public void setByteArray(int col, byte[] value) { + public void setByteArray(int col, byte[] value) { try { data.set(col, new String(value, TaosGlobalConfig.getCharset())); } catch (Exception e) { e.printStackTrace(); } - } + } - /** - * The original type may not be a string type, but will be converted to by calling this method - * @param col column index - * @return - * @throws SQLException - */ - public String getString(int col, int srcType) throws SQLException { - if (srcType == TSDBConstants.TSDB_DATA_TYPE_BINARY || srcType == TSDBConstants.TSDB_DATA_TYPE_NCHAR) { - return (String) data.get(col); - } else { - return String.valueOf(data.get(col)); - } - } + /** + * The original type may not be a string type, but will be converted to by calling this method + * + * @param col column index + * @return + * @throws SQLException + */ + public String getString(int col, int srcType) throws SQLException { + switch (srcType) { + case TSDBConstants.TSDB_DATA_TYPE_BINARY: + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: + return (String) data.get(col); + case TSDBConstants.TSDB_DATA_TYPE_UTINYINT: { + Byte value = new Byte(String.valueOf(data.get(col))); + if (value >= 0) + return value.toString(); + return Integer.toString(value & 0xff); + } + case TSDBConstants.TSDB_DATA_TYPE_USMALLINT: { + Short value = new Short(String.valueOf(data.get(col))); + if (value >= 0) + return value.toString(); + return Integer.toString(value & 0xffff); + } + case TSDBConstants.TSDB_DATA_TYPE_UINT: { + Integer value = new Integer(String.valueOf(data.get(col))); + if (value >= 0) + return value.toString(); + return Long.toString(value & 0xffffffffl); + } + case TSDBConstants.TSDB_DATA_TYPE_UBIGINT: { + Long value = new Long(String.valueOf(data.get(col))); + if (value >= 0) + return value.toString(); + long lowValue = value & 0x7fffffffffffffffL; + return BigDecimal.valueOf(lowValue).add(BigDecimal.valueOf(Long.MAX_VALUE)).add(BigDecimal.valueOf(1)).toString(); + } + default: + return String.valueOf(data.get(col)); + } + } - public void setTimestamp(int col, long ts) { - data.set(col, ts); - } + public void setTimestamp(int col, long ts) { + data.set(col, ts); + } - public Timestamp getTimestamp(int col) { - return new Timestamp((Long) data.get(col)); - } + public Timestamp getTimestamp(int col) { + return new Timestamp((Long) data.get(col)); + } - public Object get(int col) { - return data.get(col); - } + public Object get(int col) { + return data.get(col); + } - public int getColSize() { - return colSize; - } + public int getColSize() { + return colSize; + } - public void setColSize(int colSize) { - this.colSize = colSize; - this.clear(); - } + public void setColSize(int colSize) { + this.colSize = colSize; + this.clear(); + } - public ArrayList getData() { - return data; - } + public ArrayList getData() { + return data; + } - public void setData(ArrayList data) { - this.data = (ArrayList) data.clone(); - } + public void setData(ArrayList data) { + this.data = (ArrayList) data.clone(); + } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java index 29e849049e..fb20a621b0 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBStatement.java @@ -51,7 +51,6 @@ public class TSDBStatement extends AbstractStatement { this.connector.freeResultSet(pSql); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEQUERY); } - TSDBResultSet res = new TSDBResultSet(this, this.connector, pSql); res.setBatchFetch(this.connection.getBatchFetch()); return res; diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribe.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribe.java index dd0d0d5b7b..c5fd497ca3 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribe.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/TSDBSubscribe.java @@ -21,27 +21,23 @@ public class TSDBSubscribe { private final long id; TSDBSubscribe(TSDBJNIConnector connecter, long id) throws SQLException { - if (null != connecter) { - this.connecter = connecter; - this.id = id; - } else { - throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); - } + if (connecter == null) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); + + this.connecter = connecter; + this.id = id; } /** * consume - * */ public TSDBResultSet consume() throws SQLException { - if (this.connecter.isClosed()) { - throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); - } + if (this.connecter.isClosed()) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); long resultSetPointer = this.connecter.consume(this.id); - if (resultSetPointer == TSDBConstants.JNI_CONNECTION_NULL) { - throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); } else if (resultSetPointer == TSDBConstants.JNI_NULL_POINTER) { return null; } else { @@ -56,9 +52,9 @@ public class TSDBSubscribe { * @throws SQLException */ public void close(boolean keepProgress) throws SQLException { - if (this.connecter.isClosed()) { - throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); - } + if (this.connecter.isClosed()) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); + this.connecter.unsubscribe(this.id, keepProgress); } } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java index 0484701f68..c1834a7b80 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulConnection.java @@ -27,7 +27,6 @@ public class RestfulConnection extends AbstractConnection { public Statement createStatement() throws SQLException { if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED); - ; return new RestfulStatement(this, database); } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java index d45ca0c3a0..a94cfa6e07 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulDriver.java @@ -2,9 +2,7 @@ package com.taosdata.jdbc.rs; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; -import com.taosdata.jdbc.AbstractDriver; -import com.taosdata.jdbc.TSDBConstants; -import com.taosdata.jdbc.TSDBDriver; +import com.taosdata.jdbc.*; import com.taosdata.jdbc.utils.HttpClientPoolUtil; import java.io.UnsupportedEncodingException; @@ -21,15 +19,16 @@ public class RestfulDriver extends AbstractDriver { try { DriverManager.registerDriver(new RestfulDriver()); } catch (SQLException e) { - throw new RuntimeException(TSDBConstants.WrapErrMsg("can not register Restful JDBC driver"), e); + throw TSDBError.createRuntimeException(TSDBErrorNumbers.ERROR_URL_NOT_SET, e); } } @Override public Connection connect(String url, Properties info) throws SQLException { // throw SQLException if url is null - if (url == null) - throw new SQLException(TSDBConstants.WrapErrMsg("url is not set!")); + if (url == null || url.trim().isEmpty() || url.trim().replaceAll("\\s", "").isEmpty()) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_URL_NOT_SET); + // return null if url is not be accepted if (!acceptsURL(url)) return null; @@ -61,14 +60,20 @@ public class RestfulDriver extends AbstractDriver { throw new SQLException(jsonResult.getString("desc")); } - return new RestfulConnection(host, port, props, database, url); + RestfulConnection conn = new RestfulConnection(host, port, props, database, url); + if (database != null && !database.trim().replaceAll("\\s", "").isEmpty()) { + Statement stmt = conn.createStatement(); + stmt.execute("use " + database); + stmt.close(); + } + return conn; } @Override public boolean acceptsURL(String url) throws SQLException { if (url == null) - throw new SQLException(TSDBConstants.WrapErrMsg("url is null")); - return (url != null && url.length() > 0 && url.trim().length() > 0) && url.startsWith(URL_PREFIX); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_URL_NOT_SET); + return url.length() > 0 && url.trim().length() > 0 && url.startsWith(URL_PREFIX); } @Override diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java index 9d394b8b03..30081a63c3 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java @@ -9,7 +9,6 @@ import com.taosdata.jdbc.TSDBErrorNumbers; import java.sql.*; import java.util.ArrayList; -import java.util.List; public class RestfulResultSet extends AbstractResultSet implements ResultSet { private volatile boolean isClosed; @@ -17,8 +16,9 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { private final String database; private final Statement statement; +// private final JSONObject resultJson; // data - private ArrayList> resultSet; + private final ArrayList> resultSet; // meta private ArrayList columnNames; private ArrayList columns; @@ -32,6 +32,8 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { public RestfulResultSet(String database, Statement statement, JSONObject resultJson) throws SQLException { this.database = database; this.statement = statement; +// this.resultJson = resultJson; + // column metadata JSONArray columnMeta = resultJson.getJSONArray("column_meta"); columnNames = new ArrayList<>(); @@ -39,10 +41,11 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { for (int colIndex = 0; colIndex < columnMeta.size(); colIndex++) { JSONArray col = columnMeta.getJSONArray(colIndex); String col_name = col.getString(0); - int col_type = TSDBConstants.taosType2JdbcType(col.getInteger(1)); + int taos_type = col.getInteger(1); + int col_type = TSDBConstants.taosType2JdbcType(taos_type); int col_length = col.getInteger(2); columnNames.add(col_name); - columns.add(new Field(col_name, col_type, col_length, "")); + columns.add(new Field(col_name, col_type, col_length, "", taos_type)); } this.metaData = new RestfulResultSetMetaData(this.database, columns, this); @@ -53,105 +56,50 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { ArrayList row = new ArrayList(); JSONArray jsonRow = data.getJSONArray(rowIndex); for (int colIndex = 0; colIndex < jsonRow.size(); colIndex++) { - row.add(parseColumnData(jsonRow, colIndex, columns.get(colIndex).type)); + row.add(parseColumnData(jsonRow, colIndex, columns.get(colIndex).taos_type)); } resultSet.add(row); } - - /* - int columnIndex = 0; - for (; columnIndex < data.size(); columnIndex++) { - ArrayList oneRow = new ArrayList<>(); - JSONArray one = data.getJSONArray(columnIndex); - for (int j = 0; j < one.size(); j++) { - oneRow.add(one.getString(j)); - } - resultSet.add(oneRow); - } - - // column only names - JSONArray head = resultJson.getJSONArray("head"); - for (int i = 0; i < head.size(); i++) { - String name = head.getString(i); - columnNames.add(name); - columns.add(new Field(name, "", 0, "")); - } - this.metaData = new RestfulResultSetMetaData(this.database, columns, this); - */ } - private Object parseColumnData(JSONArray row, int colIndex, int sqlType) { - switch (sqlType) { - case Types.NULL: - return null; - case Types.BOOLEAN: + private Object parseColumnData(JSONArray row, int colIndex, int taosType) { + switch (taosType) { + case TSDBConstants.TSDB_DATA_TYPE_BOOL: return row.getBoolean(colIndex); - case Types.TINYINT: - case Types.SMALLINT: + case TSDBConstants.TSDB_DATA_TYPE_TINYINT: + return row.getByte(colIndex); + case TSDBConstants.TSDB_DATA_TYPE_SMALLINT: return row.getShort(colIndex); - case Types.INTEGER: + case TSDBConstants.TSDB_DATA_TYPE_INT: return row.getInteger(colIndex); - case Types.BIGINT: + case TSDBConstants.TSDB_DATA_TYPE_BIGINT: return row.getBigInteger(colIndex); - case Types.FLOAT: + case TSDBConstants.TSDB_DATA_TYPE_FLOAT: return row.getFloat(colIndex); - case Types.DOUBLE: + case TSDBConstants.TSDB_DATA_TYPE_DOUBLE: return row.getDouble(colIndex); - case Types.TIMESTAMP: + case TSDBConstants.TSDB_DATA_TYPE_TIMESTAMP: return new Timestamp(row.getDate(colIndex).getTime()); - case Types.BINARY: - case Types.NCHAR: + case TSDBConstants.TSDB_DATA_TYPE_BINARY: + case TSDBConstants.TSDB_DATA_TYPE_NCHAR: default: return row.getString(colIndex); } } -// /** -// * 由多个resultSet的JSON构造结果集 -// * -// * @param resultJson: 包含data信息的结果集,有sql返回的结果集 -// * @param fieldJson: 包含多个(最多2个)meta信息的结果集,有describe xxx -// **/ -// public RestfulResultSet(String database, Statement statement, JSONObject resultJson, List fieldJson) throws SQLException { -// this(database, statement, resultJson); -// ArrayList newColumns = new ArrayList<>(); -// -// for (Field column : columns) { -// Field field = findField(column.name, fieldJson); -// if (field != null) { -// newColumns.add(field); -// } else { -// newColumns.add(column); -// } -// } -// this.columns = newColumns; -// this.metaData = new RestfulResultSetMetaData(this.database, this.columns, this); -// } - -// public Field findField(String columnName, List fieldJsonList) { -// for (JSONObject fieldJSON : fieldJsonList) { -// JSONArray fieldDataJson = fieldJSON.getJSONArray("data"); -// for (int i = 0; i < fieldDataJson.size(); i++) { -// JSONArray field = fieldDataJson.getJSONArray(i); -// if (columnName.equalsIgnoreCase(field.getString(0))) { -// return new Field(field.getString(0), field.getString(1), field.getInteger(2), field.getString(3)); -// } -// } -// } -// return null; -// } - public class Field { String name; int type; int length; String note; + int taos_type; - public Field(String name, int type, int length, String note) { + public Field(String name, int type, int length, String note, int taos_type) { this.name = name; this.type = type; this.length = length; this.note = note; + this.taos_type = taos_type; } } @@ -184,10 +132,8 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { public String getString(int columnIndex) throws SQLException { if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED); - - if (columnIndex > resultSet.get(pos).size()) { - throw new SQLException(TSDBConstants.WrapErrMsg("Column Index out of range, " + columnIndex + " > " + resultSet.get(pos).size())); - } + if (columnIndex > resultSet.get(pos).size()) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE, "Column Index out of range, " + columnIndex + " > " + resultSet.get(pos).size()); columnIndex = getTrueColumnIndex(columnIndex); return resultSet.get(pos).get(columnIndex).toString(); @@ -197,40 +143,107 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { public boolean getBoolean(int columnIndex) throws SQLException { if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED); + if (columnIndex > resultSet.get(pos).size()) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE, "Column Index out of range, " + columnIndex + " > " + resultSet.get(pos).size()); columnIndex = getTrueColumnIndex(columnIndex); int result = getInt(columnIndex); return result == 0 ? false : true; } + @Override + public byte getByte(int columnIndex) throws SQLException { + if (isClosed()) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED); + if (columnIndex > resultSet.get(pos).size()) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE, "Column Index out of range, " + columnIndex + " > " + resultSet.get(pos).size()); + + columnIndex = getTrueColumnIndex(columnIndex); + Object value = resultSet.get(pos).get(columnIndex); + if (value == null) + return 0; + long valueAsLong = Long.parseLong(value.toString()); + if (valueAsLong == Byte.MIN_VALUE) + return 0; + if (valueAsLong < Byte.MIN_VALUE || valueAsLong > Byte.MAX_VALUE) + throwRangeException(value.toString(), columnIndex, Types.TINYINT); + + return (byte) valueAsLong; + } + + private void throwRangeException(String valueAsString, int columnIndex, int jdbcType) throws SQLException { + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_NUMERIC_VALUE_OUT_OF_RANGE, + "'" + valueAsString + "' in column '" + columnIndex + "' is outside valid range for the jdbcType " + TSDBConstants.jdbcType2TaosTypeName(jdbcType)); + } + @Override public short getShort(int columnIndex) throws SQLException { if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED); + if (columnIndex > resultSet.get(pos).size()) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE, "Column Index out of range, " + columnIndex + " > " + resultSet.get(pos).size()); + columnIndex = getTrueColumnIndex(columnIndex); - return Short.parseShort(resultSet.get(pos).get(columnIndex).toString()); + Object value = resultSet.get(pos).get(columnIndex); + if (value == null) + return 0; + long valueAsLong = Long.parseLong(value.toString()); + if (valueAsLong == Short.MIN_VALUE) + return 0; + if (valueAsLong < Short.MIN_VALUE || valueAsLong > Short.MAX_VALUE) + throwRangeException(value.toString(), columnIndex, Types.SMALLINT); + return (short) valueAsLong; } @Override public int getInt(int columnIndex) throws SQLException { if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED); + if (columnIndex > resultSet.get(pos).size()) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE, "Column Index out of range, " + columnIndex + " > " + resultSet.get(pos).size()); + columnIndex = getTrueColumnIndex(columnIndex); - return Integer.parseInt(resultSet.get(pos).get(columnIndex).toString()); + Object value = resultSet.get(pos).get(columnIndex); + if (value == null) + return 0; + long valueAsLong = Long.parseLong(value.toString()); + if (valueAsLong == Integer.MIN_VALUE) + return 0; + if (valueAsLong < Integer.MIN_VALUE || valueAsLong > Integer.MAX_VALUE) + throwRangeException(value.toString(), columnIndex, Types.INTEGER); + return (int) valueAsLong; } @Override public long getLong(int columnIndex) throws SQLException { if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED); + if (columnIndex > resultSet.get(pos).size()) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE, "Column Index out of range, " + columnIndex + " > " + resultSet.get(pos).size()); + columnIndex = getTrueColumnIndex(columnIndex); - return Long.parseLong(resultSet.get(pos).get(columnIndex).toString()); + Object value = resultSet.get(pos).get(columnIndex); + if (value == null) + return 0; + + long valueAsLong = 0; + try { + valueAsLong = Long.parseLong(value.toString()); + if (valueAsLong == Long.MIN_VALUE) + return 0; + } catch (NumberFormatException e) { + throwRangeException(value.toString(), columnIndex, Types.BIGINT); + } + return valueAsLong; } @Override public float getFloat(int columnIndex) throws SQLException { if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED); + if (columnIndex > resultSet.get(pos).size()) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE, "Column Index out of range, " + columnIndex + " > " + resultSet.get(pos).size()); + columnIndex = getTrueColumnIndex(columnIndex); return Float.parseFloat(resultSet.get(pos).get(columnIndex).toString()); } @@ -239,6 +252,8 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { public double getDouble(int columnIndex) throws SQLException { if (isClosed()) throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_RESULTSET_CLOSED); + if (columnIndex > resultSet.get(pos).size()) + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE, "Column Index out of range, " + columnIndex + " > " + resultSet.get(pos).size()); columnIndex = getTrueColumnIndex(columnIndex); return Double.parseDouble(resultSet.get(pos).get(columnIndex).toString()); @@ -246,12 +261,14 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { private int getTrueColumnIndex(int columnIndex) throws SQLException { if (columnIndex < 1) { - throw new SQLException("Column Index out of range, " + columnIndex + " < 1"); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE + , "Column Index out of range, " + columnIndex + " < 1"); } int numOfCols = resultSet.get(pos).size(); if (columnIndex > numOfCols) { - throw new SQLException("Column Index out of range, " + columnIndex + " > " + numOfCols); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE + , "Column Index out of range, " + columnIndex + " > " + numOfCols); } return columnIndex - 1; diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSetMetaData.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSetMetaData.java index 29ba13bec1..7ead8bd1bb 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSetMetaData.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSetMetaData.java @@ -1,6 +1,7 @@ package com.taosdata.jdbc.rs; import com.taosdata.jdbc.TSDBConstants; +import com.taosdata.jdbc.WrapperImpl; import java.sql.ResultSetMetaData; import java.sql.SQLException; @@ -8,7 +9,7 @@ import java.sql.Timestamp; import java.sql.Types; import java.util.ArrayList; -public class RestfulResultSetMetaData implements ResultSetMetaData { +public class RestfulResultSetMetaData extends WrapperImpl implements ResultSetMetaData { private final String database; private ArrayList fields; @@ -20,6 +21,10 @@ public class RestfulResultSetMetaData implements ResultSetMetaData { this.resultSet = resultSet; } + public ArrayList getFields() { + return fields; + } + @Override public int getColumnCount() throws SQLException { return fields.size(); @@ -134,8 +139,8 @@ public class RestfulResultSetMetaData implements ResultSetMetaData { @Override public String getColumnTypeName(int column) throws SQLException { - int type = fields.get(column - 1).type; - return TSDBConstants.jdbcType2TaosTypeName(type); + int taos_type = fields.get(column - 1).taos_type; + return TSDBConstants.taosType2JdbcTypeName(taos_type); } @Override @@ -180,18 +185,4 @@ public class RestfulResultSetMetaData implements ResultSetMetaData { return columnClassName; } - @Override - public T unwrap(Class iface) throws SQLException { - try { - return iface.cast(this); - } catch (ClassCastException cce) { - throw new SQLException("Unable to unwrap to " + iface.toString()); - } - } - - @Override - public boolean isWrapperFor(Class iface) throws SQLException { - return iface.isInstance(this); - } - } diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java index d60940d877..9071c04672 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulStatement.java @@ -4,17 +4,14 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.taosdata.jdbc.AbstractStatement; -import com.taosdata.jdbc.TSDBConstants; import com.taosdata.jdbc.TSDBError; import com.taosdata.jdbc.TSDBErrorNumbers; import com.taosdata.jdbc.utils.HttpClientPoolUtil; import com.taosdata.jdbc.utils.SqlSyntaxValidator; -import java.sql.*; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; +import java.sql.Connection; +import java.sql.ResultSet; +import java.sql.SQLException; public class RestfulStatement extends AbstractStatement { @@ -30,39 +27,6 @@ public class RestfulStatement extends AbstractStatement { this.database = database; } - protected String[] parseTableIdentifier(String sql) { - sql = sql.trim().toLowerCase(); - String[] ret = null; - if (sql.contains("where")) - sql = sql.substring(0, sql.indexOf("where")); - if (sql.contains("interval")) - sql = sql.substring(0, sql.indexOf("interval")); - if (sql.contains("fill")) - sql = sql.substring(0, sql.indexOf("fill")); - if (sql.contains("sliding")) - sql = sql.substring(0, sql.indexOf("sliding")); - if (sql.contains("group by")) - sql = sql.substring(0, sql.indexOf("group by")); - if (sql.contains("order by")) - sql = sql.substring(0, sql.indexOf("order by")); - if (sql.contains("slimit")) - sql = sql.substring(0, sql.indexOf("slimit")); - if (sql.contains("limit")) - sql = sql.substring(0, sql.indexOf("limit")); - // parse - if (sql.contains("from")) { - sql = sql.substring(sql.indexOf("from") + 4).trim(); - return Arrays.asList(sql.split(",")).stream() - .map(tableIdentifier -> { - tableIdentifier = tableIdentifier.trim(); - if (tableIdentifier.contains(" ")) - tableIdentifier = tableIdentifier.substring(0, tableIdentifier.indexOf(" ")); - return tableIdentifier; - }).collect(Collectors.joining(",")).split(","); - } - return ret; - } - @Override public ResultSet executeQuery(String sql) throws SQLException { if (isClosed()) @@ -75,9 +39,8 @@ public class RestfulStatement extends AbstractStatement { return executeOneQuery(url, sql); } -// if (this.database == null || this.database.isEmpty()) -// throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_DATABASE_NOT_SPECIFIED_OR_AVAILABLE); - HttpClientPoolUtil.execute(url, "use " + this.database); +// if (this.database != null && !this.database.trim().replaceAll("\\s","").isEmpty()) +// HttpClientPoolUtil.execute(url, "use " + this.database); return executeOneQuery(url, sql); } @@ -93,10 +56,8 @@ public class RestfulStatement extends AbstractStatement { return executeOneUpdate(url, sql); } -// if (this.database == null || this.database.isEmpty()) -// throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_DATABASE_NOT_SPECIFIED_OR_AVAILABLE); - - HttpClientPoolUtil.execute(url, "use " + this.database); +// if (this.database != null && !this.database.trim().replaceAll("\\s", "").isEmpty()) +// HttpClientPoolUtil.execute(url, "use " + this.database); return executeOneUpdate(url, sql); } @@ -148,24 +109,9 @@ public class RestfulStatement extends AbstractStatement { String result = HttpClientPoolUtil.execute(url, sql); JSONObject resultJson = JSON.parseObject(result); if (resultJson.getString("status").equals("error")) { - throw new SQLException(TSDBConstants.WrapErrMsg("SQL execution error: " + resultJson.getString("desc") + "\n" + "error code: " + resultJson.getString("code"))); + throw TSDBError.createSQLException(resultJson.getInteger("code"), resultJson.getString("desc")); } - // parse table name from sql -// String[] tableIdentifiers = parseTableIdentifier(sql); -// if (tableIdentifiers != null) { -// List fieldJsonList = new ArrayList<>(); -// for (String tableIdentifier : tableIdentifiers) { -// String fields = HttpClientPoolUtil.execute(url, "DESCRIBE " + tableIdentifier); -// JSONObject fieldJson = JSON.parseObject(fields); -// if (fieldJson.getString("status").equals("error")) { -// throw new SQLException(TSDBConstants.WrapErrMsg("SQL execution error: " + fieldJson.getString("desc") + "\n" + "error code: " + fieldJson.getString("code"))); -// } -// fieldJsonList.add(fieldJson); -// } -// this.resultSet = new RestfulResultSet(database, this, resultJson, fieldJsonList); -// } else { this.resultSet = new RestfulResultSet(database, this, resultJson); -// } this.affectedRows = 0; return resultSet; } @@ -177,7 +123,7 @@ public class RestfulStatement extends AbstractStatement { String result = HttpClientPoolUtil.execute(url, sql); JSONObject jsonObject = JSON.parseObject(result); if (jsonObject.getString("status").equals("error")) { - throw new SQLException(TSDBConstants.WrapErrMsg("SQL execution error: " + jsonObject.getString("desc") + "\n" + "error code: " + jsonObject.getString("code"))); + throw TSDBError.createSQLException(jsonObject.getInteger("code"), jsonObject.getString("desc")); } this.resultSet = null; this.affectedRows = checkJsonResultSet(jsonObject); diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java index aba95f65b7..161539962d 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/TSDBJNIConnectorTest.java @@ -15,12 +15,12 @@ public class TSDBJNIConnectorTest { public void test() { try { // init - TSDBJNIConnector.init(null, null, null, null); + TSDBJNIConnector.init("/etc/taos/taos.cfg", null, null, null); // connect TSDBJNIConnector connector = new TSDBJNIConnector(); - connector.connect("127.0.0.1", 6030, null, "root", "taosdata"); + connector.connect("127.0.0.1", 6030, "unsign_jni", "root", "taosdata"); // executeQuery - long pSql = connector.executeQuery("show variables"); + long pSql = connector.executeQuery("select * from unsign_jni.us_table"); if (connector.isUpdateQuery(pSql)) { connector.freeResultSet(pSql); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_INVALID_WITH_EXECUTEQUERY); @@ -29,13 +29,13 @@ public class TSDBJNIConnectorTest { List columnMetaDataList = new ArrayList<>(); int code = connector.getSchemaMetaData(pSql, columnMetaDataList); if (code == TSDBConstants.JNI_CONNECTION_NULL) { - throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_CONNECTION_NULL); } if (code == TSDBConstants.JNI_RESULT_SET_NULL) { - throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_RESULT_SET_NULL)); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_RESULT_SET_NULL); } if (code == TSDBConstants.JNI_NUM_OF_FIELDS_0) { - throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_NUM_OF_FIELDS_0)); + throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_JNI_NUM_OF_FIELDS_0); } int columnSize = columnMetaDataList.size(); // print metadata diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java new file mode 100644 index 0000000000..54ee8fd6eb --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/InsertDbwithoutUseDbTest.java @@ -0,0 +1,92 @@ +package com.taosdata.jdbc.cases; + +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +import java.sql.*; +import java.util.Properties; +import java.util.Random; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class InsertDbwithoutUseDbTest { + + private static String host = "127.0.0.1"; + // private static String host = "master"; + private static Properties properties; + private static Random random = new Random(System.currentTimeMillis()); + + @Test + public void case001() throws ClassNotFoundException, SQLException { + // prepare schema + Class.forName("com.taosdata.jdbc.TSDBDriver"); + String url = "jdbc:TAOS://127.0.0.1:6030/?user=root&password=taosdata"; + Connection conn = DriverManager.getConnection(url, properties); + try (Statement stmt = conn.createStatement()) { + stmt.execute("drop database if exists inWithoutDb"); + stmt.execute("create database if not exists inWithoutDb"); + stmt.execute("create table inWithoutDb.weather(ts timestamp, f1 int)"); + } + conn.close(); + + // execute insert + url = "jdbc:TAOS://127.0.0.1:6030/inWithoutDb?user=root&password=taosdata"; + conn = DriverManager.getConnection(url, properties); + try (Statement stmt = conn.createStatement()) { + int affectedRow = stmt.executeUpdate("insert into weather(ts, f1) values(now," + random.nextInt(100) + ")"); + Assert.assertEquals(1, affectedRow); + boolean flag = stmt.execute("insert into weather(ts, f1) values(now + 10s," + random.nextInt(100) + ")"); + Assert.assertEquals(false, flag); + ResultSet rs = stmt.executeQuery("select count(*) from weather"); + rs.next(); + int count = rs.getInt("count(*)"); + Assert.assertEquals(2, count); + + } catch (SQLException e) { + e.printStackTrace(); + } + + conn.close(); + } + + @Test + public void case002() throws ClassNotFoundException, SQLException { + // prepare the schema + Class.forName("com.taosdata.jdbc.rs.RestfulDriver"); + final String url = "jdbc:TAOS-RS://" + host + ":6041/inWithoutDb?user=root&password=taosdata"; + Connection conn = DriverManager.getConnection(url, properties); + try (Statement stmt = conn.createStatement()) { + stmt.execute("drop database if exists inWithoutDb"); + stmt.execute("create database if not exists inWithoutDb"); + stmt.execute("create table inWithoutDb.weather(ts timestamp, f1 int)"); + } + conn.close(); + + // execute + conn = DriverManager.getConnection(url, properties); + try (Statement stmt = conn.createStatement()) { + int affectedRow = stmt.executeUpdate("insert into weather(ts, f1) values(now," + random.nextInt(100) + ")"); + Assert.assertEquals(1, affectedRow); + boolean flag = stmt.execute("insert into weather(ts, f1) values(now + 10s," + random.nextInt(100) + ")"); + Assert.assertEquals(false, flag); + ResultSet rs = stmt.executeQuery("select count(*) from weather"); + rs.next(); + int count = rs.getInt("count(*)"); + Assert.assertEquals(2, count); + + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @BeforeClass + public static void beforeClass() { + properties = new Properties(); + properties.setProperty("charset", "UTF-8"); + properties.setProperty("locale", "en_US.UTF-8"); + properties.setProperty("timezone", "UTC-8"); + } + +} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberJniTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberJniTest.java new file mode 100644 index 0000000000..d1816a3e7c --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberJniTest.java @@ -0,0 +1,191 @@ +package com.taosdata.jdbc.cases; + +import com.taosdata.jdbc.TSDBDriver; +import org.junit.*; +import org.junit.runners.MethodSorters; + +import java.sql.*; +import java.util.Properties; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class UnsignedNumberJniTest { + private static final String host = "127.0.0.1"; + private static Connection conn; + + @Test + public void testCase001() { + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from us_table"); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + for (int i = 1; i <= meta.getColumnCount(); i++) { + System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t"); + } + System.out.println(); + Assert.assertEquals("127", rs.getString(2)); + Assert.assertEquals("32767", rs.getString(3)); + Assert.assertEquals("2147483647", rs.getString(4)); + Assert.assertEquals("9223372036854775807", rs.getString(5)); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Test + public void testCase002() { + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from us_table"); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + System.out.print(meta.getColumnLabel(1) + ": " + rs.getTimestamp(1) + "\t"); + System.out.print(meta.getColumnLabel(2) + ": " + rs.getByte(2) + "\t"); + System.out.print(meta.getColumnLabel(3) + ": " + rs.getShort(3) + "\t"); + System.out.print(meta.getColumnLabel(4) + ": " + rs.getInt(4) + "\t"); + System.out.print(meta.getColumnLabel(5) + ": " + rs.getLong(5) + "\t"); + System.out.println(); + Assert.assertEquals(127, rs.getByte(2)); + Assert.assertEquals(32767, rs.getShort(3)); + Assert.assertEquals(2147483647, rs.getInt(4)); + Assert.assertEquals(9223372036854775807l, rs.getLong(5)); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Test(expected = SQLException.class) + public void testCase003() throws SQLException { + try (Statement stmt = conn.createStatement()) { + long now = System.currentTimeMillis(); + stmt.executeUpdate("insert into us_table(ts,f1,f2,f3,f4) values(" + now + ", 127, 32767,2147483647, 18446744073709551614)"); + ResultSet rs = stmt.executeQuery("select * from us_table where ts = " + now); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + System.out.print(meta.getColumnLabel(1) + ": " + rs.getTimestamp(1) + "\t"); + System.out.print(meta.getColumnLabel(2) + ": " + rs.getByte(2) + "\t"); + System.out.print(meta.getColumnLabel(3) + ": " + rs.getShort(3) + "\t"); + System.out.print(meta.getColumnLabel(4) + ": " + rs.getInt(4) + "\t"); + System.out.print(meta.getColumnLabel(5) + ": " + rs.getLong(5) + "\t"); + System.out.println(); + Assert.assertEquals(127, rs.getByte(2)); + Assert.assertEquals(32767, rs.getShort(3)); + Assert.assertEquals(2147483647, rs.getInt(4)); + } + } + } + + @Test(expected = SQLException.class) + public void testCase004() throws SQLException { + try (Statement stmt = conn.createStatement()) { + long now = System.currentTimeMillis(); + stmt.executeUpdate("insert into us_table(ts,f1,f2,f3,f4) values(" + now + ", 127, 32767,4294967294, 18446744073709551614)"); + ResultSet rs = stmt.executeQuery("select * from us_table where ts = " + now); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + System.out.print(meta.getColumnLabel(1) + ": " + rs.getTimestamp(1) + "\t"); + System.out.print(meta.getColumnLabel(2) + ": " + rs.getByte(2) + "\t"); + System.out.print(meta.getColumnLabel(3) + ": " + rs.getShort(3) + "\t"); + System.out.print(meta.getColumnLabel(4) + ": " + rs.getInt(4) + "\t"); + System.out.print(meta.getColumnLabel(5) + ": " + rs.getLong(5) + "\t"); + System.out.println(); + Assert.assertEquals(127, rs.getByte(2)); + Assert.assertEquals(32767, rs.getShort(3)); + } + } + } + + @Test(expected = SQLException.class) + public void testCase005() throws SQLException { + try (Statement stmt = conn.createStatement()) { + long now = System.currentTimeMillis(); + stmt.executeUpdate("insert into us_table(ts,f1,f2,f3,f4) values(" + now + ", 127, 65534,4294967294, 18446744073709551614)"); + ResultSet rs = stmt.executeQuery("select * from us_table where ts = " + now); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + System.out.print(meta.getColumnLabel(1) + ": " + rs.getTimestamp(1) + "\t"); + System.out.print(meta.getColumnLabel(2) + ": " + rs.getByte(2) + "\t"); + System.out.print(meta.getColumnLabel(3) + ": " + rs.getShort(3) + "\t"); + System.out.print(meta.getColumnLabel(4) + ": " + rs.getInt(4) + "\t"); + System.out.print(meta.getColumnLabel(5) + ": " + rs.getLong(5) + "\t"); + System.out.println(); + + Assert.assertEquals(127, rs.getByte(2)); + } + } + } + + @Test(expected = SQLException.class) + public void testCase006() throws SQLException { + try (Statement stmt = conn.createStatement()) { + long now = System.currentTimeMillis(); + stmt.executeUpdate("insert into us_table(ts,f1,f2,f3,f4) values(" + now + ", 254, 65534,4294967294, 18446744073709551614)"); + ResultSet rs = stmt.executeQuery("select * from us_table where ts = " + now); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + System.out.print(meta.getColumnLabel(1) + ": " + rs.getTimestamp(1) + "\t"); + System.out.print(meta.getColumnLabel(2) + ": " + rs.getByte(2) + "\t"); + System.out.print(meta.getColumnLabel(3) + ": " + rs.getShort(3) + "\t"); + System.out.print(meta.getColumnLabel(4) + ": " + rs.getInt(4) + "\t"); + System.out.print(meta.getColumnLabel(5) + ": " + rs.getLong(5) + "\t"); + System.out.println(); + } + } + } + + @Test + public void testCase007() throws SQLException { + try (Statement stmt = conn.createStatement()) { + long now = System.currentTimeMillis(); + stmt.executeUpdate("insert into us_table(ts,f1,f2,f3,f4) values(" + now + ", 254, 65534,4294967294, 18446744073709551614)"); + ResultSet rs = stmt.executeQuery("select * from us_table where ts = " + now); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + for (int i = 1; i <= meta.getColumnCount(); i++) { + System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t"); + } + System.out.println(); + Assert.assertEquals("254", rs.getString(2)); + Assert.assertEquals("65534", rs.getString(3)); + Assert.assertEquals("4294967294", rs.getString(4)); + Assert.assertEquals("18446744073709551614", rs.getString(5)); + } + } + } + + + @BeforeClass + public static void beforeClass() { + Properties properties = new Properties(); + properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); + + try { + Class.forName("com.taosdata.jdbc.TSDBDriver"); + final String url = "jdbc:TAOS://" + host + ":6030/?user=root&password=taosdata"; + conn = DriverManager.getConnection(url, properties); + + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists unsign_jni"); + stmt.execute("create database if not exists unsign_jni"); + stmt.execute("use unsign_jni"); + stmt.execute("create table us_table(ts timestamp, f1 tinyint unsigned, f2 smallint unsigned, f3 int unsigned, f4 bigint unsigned)"); + stmt.executeUpdate("insert into us_table(ts,f1,f2,f3,f4) values(now, 127, 32767,2147483647, 9223372036854775807)"); + stmt.close(); + } catch (ClassNotFoundException | SQLException e) { + e.printStackTrace(); + } + } + + @AfterClass + public static void afterClass() { + try { + if (conn != null) + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberRestfulTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberRestfulTest.java new file mode 100644 index 0000000000..d0e6306704 --- /dev/null +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/cases/UnsignedNumberRestfulTest.java @@ -0,0 +1,177 @@ +package com.taosdata.jdbc.cases; + +import com.taosdata.jdbc.TSDBDriver; +import org.junit.*; +import org.junit.runners.MethodSorters; + +import java.sql.*; +import java.util.Properties; + + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class UnsignedNumberRestfulTest { + private static final String host = "127.0.0.1"; +// private static final String host = "master"; + private static Connection conn; + + @Test + public void testCase001() { + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from us_table"); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + for (int i = 1; i <= meta.getColumnCount(); i++) { + System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t"); + } + System.out.println(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Test + public void testCase002() { + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select * from us_table"); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + System.out.print(meta.getColumnLabel(1) + ": " + rs.getTimestamp(1) + "\t"); + System.out.print(meta.getColumnLabel(2) + ": " + rs.getByte(2) + "\t"); + System.out.print(meta.getColumnLabel(3) + ": " + rs.getShort(3) + "\t"); + System.out.print(meta.getColumnLabel(4) + ": " + rs.getInt(4) + "\t"); + System.out.print(meta.getColumnLabel(5) + ": " + rs.getLong(5) + "\t"); + System.out.println(); + } + } catch (SQLException e) { + e.printStackTrace(); + } + } + + @Test(expected = SQLException.class) + public void testCase003() throws SQLException { + try (Statement stmt = conn.createStatement()) { + long now = System.currentTimeMillis(); + stmt.executeUpdate("insert into us_table(ts,f1,f2,f3,f4) values(" + now + ", 127, 32767,2147483647, 18446744073709551614)"); + ResultSet rs = stmt.executeQuery("select * from us_table where ts = " + now); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + System.out.print(meta.getColumnLabel(1) + ": " + rs.getTimestamp(1) + "\t"); + System.out.print(meta.getColumnLabel(2) + ": " + rs.getByte(2) + "\t"); + System.out.print(meta.getColumnLabel(3) + ": " + rs.getShort(3) + "\t"); + System.out.print(meta.getColumnLabel(4) + ": " + rs.getInt(4) + "\t"); + System.out.print(meta.getColumnLabel(5) + ": " + rs.getLong(5) + "\t"); + System.out.println(); + } + } + } + + @Test(expected = SQLException.class) + public void testCase004() throws SQLException { + try (Statement stmt = conn.createStatement()) { + long now = System.currentTimeMillis(); + stmt.executeUpdate("insert into us_table(ts,f1,f2,f3,f4) values(" + now + ", 127, 32767,4294967294, 18446744073709551614)"); + ResultSet rs = stmt.executeQuery("select * from us_table where ts = " + now); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + System.out.print(meta.getColumnLabel(1) + ": " + rs.getTimestamp(1) + "\t"); + System.out.print(meta.getColumnLabel(2) + ": " + rs.getByte(2) + "\t"); + System.out.print(meta.getColumnLabel(3) + ": " + rs.getShort(3) + "\t"); + System.out.print(meta.getColumnLabel(4) + ": " + rs.getInt(4) + "\t"); + System.out.print(meta.getColumnLabel(5) + ": " + rs.getLong(5) + "\t"); + System.out.println(); + } + } + } + + @Test(expected = SQLException.class) + public void testCase005() throws SQLException { + try (Statement stmt = conn.createStatement()) { + long now = System.currentTimeMillis(); + stmt.executeUpdate("insert into us_table(ts,f1,f2,f3,f4) values(" + now + ", 127, 65534,4294967294, 18446744073709551614)"); + ResultSet rs = stmt.executeQuery("select * from us_table where ts = " + now); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + System.out.print(meta.getColumnLabel(1) + ": " + rs.getTimestamp(1) + "\t"); + System.out.print(meta.getColumnLabel(2) + ": " + rs.getByte(2) + "\t"); + System.out.print(meta.getColumnLabel(3) + ": " + rs.getShort(3) + "\t"); + System.out.print(meta.getColumnLabel(4) + ": " + rs.getInt(4) + "\t"); + System.out.print(meta.getColumnLabel(5) + ": " + rs.getLong(5) + "\t"); + System.out.println(); + } + } + } + + @Test(expected = SQLException.class) + public void testCase006() throws SQLException { + try (Statement stmt = conn.createStatement()) { + long now = System.currentTimeMillis(); + stmt.executeUpdate("insert into us_table(ts,f1,f2,f3,f4) values(" + now + ", 254, 65534,4294967294, 18446744073709551614)"); + ResultSet rs = stmt.executeQuery("select * from us_table where ts = " + now); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + System.out.print(meta.getColumnLabel(1) + ": " + rs.getTimestamp(1) + "\t"); + System.out.print(meta.getColumnLabel(2) + ": " + rs.getByte(2) + "\t"); + System.out.print(meta.getColumnLabel(3) + ": " + rs.getShort(3) + "\t"); + System.out.print(meta.getColumnLabel(4) + ": " + rs.getInt(4) + "\t"); + System.out.print(meta.getColumnLabel(5) + ": " + rs.getLong(5) + "\t"); + System.out.println(); + } + } + } + + @Test + public void testCase007() throws SQLException { + try (Statement stmt = conn.createStatement()) { + long now = System.currentTimeMillis(); + stmt.executeUpdate("insert into us_table(ts,f1,f2,f3,f4) values(" + now + ", 254, 65534,4294967294, 18446744073709551614)"); + ResultSet rs = stmt.executeQuery("select * from us_table where ts = " + now); + ResultSetMetaData meta = rs.getMetaData(); + while (rs.next()) { + for (int i = 1; i <= meta.getColumnCount(); i++) { + System.out.print(meta.getColumnLabel(i) + ": " + rs.getString(i) + "\t"); + } + System.out.println(); + Assert.assertEquals("254", rs.getString(2)); + Assert.assertEquals("65534", rs.getString(3)); + Assert.assertEquals("4294967294", rs.getString(4)); + Assert.assertEquals("18446744073709551614", rs.getString(5)); + } + } + } + + @BeforeClass + public static void beforeClass() { + Properties properties = new Properties(); + properties.setProperty(TSDBDriver.PROPERTY_KEY_CHARSET, "UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_LOCALE, "en_US.UTF-8"); + properties.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8"); + + try { + Class.forName("com.taosdata.jdbc.rs.RestfulDriver"); + final String url = "jdbc:TAOS-RS://" + host + ":6041/?user=root&password=taosdata"; + conn = DriverManager.getConnection(url, properties); + + Statement stmt = conn.createStatement(); + stmt.execute("drop database if exists unsign_restful"); + stmt.execute("create database if not exists unsign_restful"); + stmt.execute("use unsign_restful"); + stmt.execute("create table us_table(ts timestamp, f1 tinyint unsigned, f2 smallint unsigned, f3 int unsigned, f4 bigint unsigned)"); + stmt.executeUpdate("insert into us_table(ts,f1,f2,f3,f4) values(now, 127, 32767,2147483647, 9223372036854775807)"); + stmt.close(); + } catch (ClassNotFoundException | SQLException e) { + e.printStackTrace(); + } + } + + @AfterClass + public static void afterClass() { + try { + if (conn != null) + conn.close(); + } catch (SQLException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java index b199eff1ba..a15b1964ea 100644 --- a/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java +++ b/src/connector/jdbc/src/test/java/com/taosdata/jdbc/rs/RestfulResultSetTest.java @@ -40,9 +40,12 @@ public class RestfulResultSetTest { Assert.assertEquals(true, f9); } - @Test(expected = SQLFeatureNotSupportedException.class) + @Test public void getByte() throws SQLException { - rs.getByte(1); + byte f8 = rs.getByte("f8"); + Assert.assertEquals(10, f8); + f8 = rs.getByte(8); + Assert.assertEquals(10, f8); } @Test From befbdf8972fa5aeefcc48878722cd41d020d9dcf Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 16 Mar 2021 14:11:05 +0800 Subject: [PATCH 20/89] [td-225]update test. --- src/client/src/tscSQLParser.c | 4 ++-- tests/pytest/query/queryNormal.py | 5 +++-- tests/script/general/table/delete_writing.sim | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index d4ab9cc1c7..8b2998c0e7 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -6379,8 +6379,8 @@ int32_t doCheckForStream(SSqlObj* pSql, SSqlInfo* pInfo) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg6); } - tVariantListItem* p1 = taosArrayGet(pFromInfo->tableList, 0); - SStrToken srcToken = {.z = p1->pVar.pz, .n = p1->pVar.nLen, .type = TK_STRING}; + STableNamePair* p1 = taosArrayGet(pFromInfo->tableList, 0); + SStrToken srcToken = {.z = p1->name.z, .n = p1->name.n, .type = TK_STRING}; if (tscValidateName(&srcToken) != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg1); } diff --git a/tests/pytest/query/queryNormal.py b/tests/pytest/query/queryNormal.py index 13393117d6..4e3f9dd3bd 100644 --- a/tests/pytest/query/queryNormal.py +++ b/tests/pytest/query/queryNormal.py @@ -94,8 +94,9 @@ class TDTestCase: tdSql.query("select * from stb1 limit 2 offset 3") tdSql.checkRows(1) - # query ... alias for table ---- bug - tdSql.error("select t.ts from tb1 t") + # query ... alias for table + tdSql.query("select t.ts from tb1 t") + tdSql.checkRows(2) # query ... tbname tdSql.query("select tbname from stb1") diff --git a/tests/script/general/table/delete_writing.sim b/tests/script/general/table/delete_writing.sim index b7350f26a7..5351d13d80 100644 --- a/tests/script/general/table/delete_writing.sim +++ b/tests/script/general/table/delete_writing.sim @@ -41,7 +41,7 @@ while $x < 15 sql create table db.tb (ts timestamp, i int) - sleep 2000 + sleep 1000 $x = $x + 1 endw From d99b2bed1b170132d528c77484639b9ceea044fb Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Tue, 16 Mar 2021 14:24:31 +0800 Subject: [PATCH 21/89] http/string: append need one more byte for null --- src/plugins/http/src/httpParser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/http/src/httpParser.c b/src/plugins/http/src/httpParser.c index 669b352ab6..18cea56cfe 100644 --- a/src/plugins/http/src/httpParser.c +++ b/src/plugins/http/src/httpParser.c @@ -110,7 +110,7 @@ static void httpCleanupString(HttpString *str) { static int32_t httpAppendString(HttpString *str, const char *s, int32_t len) { if (str->size == 0) { str->pos = 0; - str->size = len; + str->size = len + 1; str->str = malloc(str->size); } else if (str->pos + len + 1 >= str->size) { str->size += len; From c5d19cbf4021a1474bb24f7e6f02337669f3af9a Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 16 Mar 2021 15:03:33 +0800 Subject: [PATCH 22/89] [td-3315]: enable insert timestamp in the format of string '1970-1-1 8:0:0' and other unix timestamp. --- src/client/src/tscParseInsert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/src/tscParseInsert.c b/src/client/src/tscParseInsert.c index 41bfe34561..2b962333d5 100644 --- a/src/client/src/tscParseInsert.c +++ b/src/client/src/tscParseInsert.c @@ -394,7 +394,7 @@ static int32_t tsCheckTimestamp(STableDataBlocks *pDataBlocks, const char *start TSKEY k = *(TSKEY *)start; - if (k == 0) { + if (k == INT64_MIN) { if (pDataBlocks->tsSource == TSDB_USE_CLI_TS) { return -1; } else if (pDataBlocks->tsSource == -1) { From 3f8e90670f3699905331336824dfc64ab63e1205 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Tue, 16 Mar 2021 16:10:54 +0800 Subject: [PATCH 23/89] [TD-3326]backup taos after taos coredump --- tests/test-all.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/test-all.sh b/tests/test-all.sh index db9d6523a0..b91440c7c6 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -24,11 +24,14 @@ function stopTaosd { function dohavecore(){ corefile=`find $corepath -mmin 1` + proc=`echo $corefile|cut -d "_" -f2` if [ -n "$corefile" ];then - echo 'taosd or taos has generated core' - if [[ $1 == 1 ]];then - exit 8 - fi + echo 'taosd or taos has generated core' + echo '\n'|gdb /usr/local/taos/bin/$proc $corepath/$corefile -ex "bt 10" -ex quit + tar zcvf $corepath/taos_`date "+%Y_%m_%d_%H:%M:%S"`.tar.gz /usr/local/taos + if [[ $1 == 1 ]];then + exit 8 + fi fi } function runSimCaseOneByOne { From 6cadb9dfa186493ae1331c70cc36fc95c78025dd Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 16 Mar 2021 16:17:42 +0800 Subject: [PATCH 24/89] [td-3331]: print timestamp format error. --- src/kit/shell/src/shellEngine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index a6f5869936..e86a1fce60 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -412,7 +412,7 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) { #ifdef WINDOWS if (tt < 0) tt = 0; #endif - if (tt < 0 && ms != 0) { + if (tt <= 0 && ms < 0) { tt--; if (precision == TSDB_TIME_PRECISION_MICRO) { ms += 1000000; From f4aa1da2351614fd75b3c6e5a32130c34404be41 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Tue, 16 Mar 2021 16:19:45 +0800 Subject: [PATCH 25/89] fix error --- tests/test-all.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test-all.sh b/tests/test-all.sh index b91440c7c6..7cd08e2510 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -24,12 +24,12 @@ function stopTaosd { function dohavecore(){ corefile=`find $corepath -mmin 1` - proc=`echo $corefile|cut -d "_" -f2` + proc=`echo $corefile|cut -d "_" -f3` if [ -n "$corefile" ];then echo 'taosd or taos has generated core' - echo '\n'|gdb /usr/local/taos/bin/$proc $corepath/$corefile -ex "bt 10" -ex quit tar zcvf $corepath/taos_`date "+%Y_%m_%d_%H:%M:%S"`.tar.gz /usr/local/taos if [[ $1 == 1 ]];then + echo '\n'|gdb /usr/local/taos/bin/$proc $corepath/$corefile -ex "bt 10" -ex quit exit 8 fi fi From 46424a67fc77d27b1a9dd196d9a7ce3e664dff2f Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 16 Mar 2021 16:27:56 +0800 Subject: [PATCH 26/89] [td-225] update the sim script. --- tests/script/general/parser/testSuite.sim | 56 +---------------------- tests/script/jenkins/basic.txt | 4 ++ 2 files changed, 5 insertions(+), 55 deletions(-) diff --git a/tests/script/general/parser/testSuite.sim b/tests/script/general/parser/testSuite.sim index c2ce5df12e..f05474d158 100644 --- a/tests/script/general/parser/testSuite.sim +++ b/tests/script/general/parser/testSuite.sim @@ -1,112 +1,58 @@ run general/parser/alter.sim -sleep 100 run general/parser/alter1.sim -sleep 100 run general/parser/alter_stable.sim -sleep 100 run general/parser/auto_create_tb.sim -sleep 100 run general/parser/auto_create_tb_drop_tb.sim -sleep 100 run general/parser/col_arithmetic_operation.sim -sleep 100 run general/parser/columnValue.sim -sleep 100 run general/parser/commit.sim -sleep 100 run general/parser/create_db.sim -sleep 100 run general/parser/create_mt.sim -sleep 100 run general/parser/create_tb.sim -sleep 100 run general/parser/dbtbnameValidate.sim -sleep 100 run general/parser/fill.sim -sleep 100 run general/parser/fill_stb.sim -sleep 100 #run general/parser/fill_us.sim # -sleep 100 run general/parser/first_last.sim -sleep 100 run general/parser/import_commit1.sim -sleep 100 run general/parser/import_commit2.sim -sleep 100 run general/parser/import_commit3.sim -sleep 100 #run general/parser/import_file.sim -sleep 100 run general/parser/insert_tb.sim -sleep 100 run general/parser/tags_dynamically_specifiy.sim -sleep 100 run general/parser/interp.sim -sleep 100 run general/parser/lastrow.sim -sleep 100 run general/parser/limit.sim -sleep 100 run general/parser/limit1.sim -sleep 100 run general/parser/limit1_tblocks100.sim -sleep 100 run general/parser/limit2.sim -sleep 100 run general/parser/mixed_blocks.sim -sleep 100 run general/parser/nchar.sim -sleep 100 run general/parser/null_char.sim -sleep 100 run general/parser/selectResNum.sim -sleep 100 run general/parser/select_across_vnodes.sim -sleep 100 run general/parser/select_from_cache_disk.sim -sleep 100 run general/parser/set_tag_vals.sim -sleep 100 run general/parser/single_row_in_tb.sim -sleep 100 run general/parser/slimit.sim -sleep 100 run general/parser/slimit1.sim -sleep 100 run general/parser/slimit_alter_tags.sim -sleep 100 run general/parser/tbnameIn.sim -sleep 100 run general/parser/slimit_alter_tags.sim # persistent failed -sleep 100 run general/parser/join.sim -sleep 100 run general/parser/join_multivnode.sim -sleep 100 +run general/parser/join_manyblocks.sim run general/parser/projection_limit_offset.sim -sleep 100 run general/parser/select_with_tags.sim -sleep 100 run general/parser/groupby.sim -sleep 100 run general/parser/tags_filter.sim -sleep 100 run general/parser/topbot.sim -sleep 100 run general/parser/union.sim -sleep 100 run general/parser/constCol.sim -sleep 100 run general/parser/where.sim -sleep 100 run general/parser/timestamp.sim -sleep 100 run general/parser/sliding.sim -sleep 100 run general/parser/function.sim -sleep 100 run general/parser/stableOp.sim -sleep 100 run general/parser/slimit_alter_tags.sim diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index fc56e34dca..f6e2267f6d 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -162,6 +162,10 @@ cd ../../../debug; make ./test.sh -f general/parser/topbot.sim ./test.sh -f general/parser/function.sim ./test.sh -f general/parser/select_distinct_tag.sim +./test.sh -f general/parser/join_manyblocks.sim +./test.sh -f general/parser/stableOp.sim +./test.sh -f general/parser/timestamp.sim +./test.sh -f general/parser/sliding.sim ./test.sh -f general/stable/disk.sim ./test.sh -f general/stable/dnode3.sim From d0254171b7e3f24f4c302847c829d105499ef89e Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Tue, 16 Mar 2021 17:26:13 +0800 Subject: [PATCH 27/89] fix error --- tests/test-all.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test-all.sh b/tests/test-all.sh index 7cd08e2510..bda03191d1 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -24,12 +24,14 @@ function stopTaosd { function dohavecore(){ corefile=`find $corepath -mmin 1` + core_file=`echo $corefile|cut -d " " -f2` + echo $core_file proc=`echo $corefile|cut -d "_" -f3` if [ -n "$corefile" ];then echo 'taosd or taos has generated core' - tar zcvf $corepath/taos_`date "+%Y_%m_%d_%H:%M:%S"`.tar.gz /usr/local/taos + tar -zcvPf $corepath'taos_'`date "+%Y_%m_%d_%H_%M_%S"`.tar.gz /usr/local/taos/ if [[ $1 == 1 ]];then - echo '\n'|gdb /usr/local/taos/bin/$proc $corepath/$corefile -ex "bt 10" -ex quit + echo '\n'|gdb /usr/local/taos/bin/$proc $core_file -ex "bt 10" -ex quit exit 8 fi fi From 6396e651b943a9a4069e107705f605dcd902ef12 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 16 Mar 2021 17:42:24 +0800 Subject: [PATCH 28/89] [td-3183] : fix unsigned number arithmetic calculation with sort option caused crash. --- src/common/src/texpr.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index f50b829baa..1008c4cf8f 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -41,41 +41,46 @@ static uint8_t UNUSED_FUNC isQueryOnPrimaryKey(const char *primaryColumnName, co static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOfRows) { switch(type) { - case TSDB_DATA_TYPE_TINYINT: { + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_UTINYINT:{ int8_t* p = (int8_t*) dest; int8_t* pSrc = (int8_t*) src; for(int32_t i = 0; i < numOfRows; ++i) { p[i] = pSrc[numOfRows - i - 1]; } - break; + return; } - case TSDB_DATA_TYPE_SMALLINT: { + + case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_USMALLINT:{ int16_t* p = (int16_t*) dest; int16_t* pSrc = (int16_t*) src; for(int32_t i = 0; i < numOfRows; ++i) { p[i] = pSrc[numOfRows - i - 1]; } - break; + return; } - case TSDB_DATA_TYPE_INT: { + case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_UINT: { int32_t* p = (int32_t*) dest; int32_t* pSrc = (int32_t*) src; for(int32_t i = 0; i < numOfRows; ++i) { p[i] = pSrc[numOfRows - i - 1]; } - break; + return; } - case TSDB_DATA_TYPE_BIGINT: { + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_UBIGINT: { int64_t* p = (int64_t*) dest; int64_t* pSrc = (int64_t*) src; for(int32_t i = 0; i < numOfRows; ++i) { p[i] = pSrc[numOfRows - i - 1]; } - break; + return; } case TSDB_DATA_TYPE_FLOAT: { float* p = (float*) dest; @@ -84,7 +89,7 @@ static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOf for(int32_t i = 0; i < numOfRows; ++i) { p[i] = pSrc[numOfRows - i - 1]; } - break; + return; } case TSDB_DATA_TYPE_DOUBLE: { double* p = (double*) dest; @@ -93,7 +98,7 @@ static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOf for(int32_t i = 0; i < numOfRows; ++i) { p[i] = pSrc[numOfRows - i - 1]; } - break; + return; } default: assert(0); } From 2307d8ef2531312c8e01cb73449a659fec209185 Mon Sep 17 00:00:00 2001 From: Wizzer Date: Tue, 16 Mar 2021 17:57:04 +0800 Subject: [PATCH 29/89] fix: jdbc connector RestfulResultSet.getString NPE --- .../src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java index 30081a63c3..0cbb40dbb6 100644 --- a/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java +++ b/src/connector/jdbc/src/main/java/com/taosdata/jdbc/rs/RestfulResultSet.java @@ -136,7 +136,8 @@ public class RestfulResultSet extends AbstractResultSet implements ResultSet { throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_PARAMETER_INDEX_OUT_RANGE, "Column Index out of range, " + columnIndex + " > " + resultSet.get(pos).size()); columnIndex = getTrueColumnIndex(columnIndex); - return resultSet.get(pos).get(columnIndex).toString(); + Object value = resultSet.get(pos).get(columnIndex); + return value == null ? null : value.toString(); } @Override From eb7a74d694867cd12b086cf94a969dfe53d8af9a Mon Sep 17 00:00:00 2001 From: slguan Date: Tue, 16 Mar 2021 18:05:07 +0800 Subject: [PATCH 30/89] TD-3309 --- src/kit/shell/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/kit/shell/CMakeLists.txt b/src/kit/shell/CMakeLists.txt index b6babc5bc5..d36c1e3fcc 100644 --- a/src/kit/shell/CMakeLists.txt +++ b/src/kit/shell/CMakeLists.txt @@ -36,6 +36,7 @@ ELSEIF (TD_DARWIN) LIST(APPEND SRC ./src/shellDarwin.c) LIST(APPEND SRC ./src/shellCommand.c) LIST(APPEND SRC ./src/shellImport.c) + LIST(APPEND SRC ./src/shellCheck.c) ADD_EXECUTABLE(shell ${SRC}) # linking with dylib TARGET_LINK_LIBRARIES(shell taos) From d422bba8ddd25dc739ae11ae431bf5900905c4c6 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 16 Mar 2021 18:24:51 +0800 Subject: [PATCH 31/89] [td-3318]: fix crash caused by empty stddev query. --- src/query/src/qExecutor.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 8f3c51d2a9..e0e18a7cc8 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -4170,8 +4170,10 @@ static SSDataBlock* doTableScan(void* param) { assert(ret); } - pResultRowInfo->curIndex = 0; - pResultRowInfo->prevSKey = pResultRowInfo->pResult[0]->win.skey; + if (pResultRowInfo->size > 0) { + pResultRowInfo->curIndex = 0; + pResultRowInfo->prevSKey = pResultRowInfo->pResult[0]->win.skey; + } qDebug("QInfo:%p start to repeat scan data blocks due to query func required, qrange:%" PRId64 "-%" PRId64, pRuntimeEnv->qinfo, cond.twindow.skey, cond.twindow.ekey); From 83543e05354ac120f0ac3e5c998cf5b93431fcb3 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 16 Mar 2021 18:39:02 +0800 Subject: [PATCH 32/89] [td-3318]update the sim --- tests/script/general/parser/where.sim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/script/general/parser/where.sim b/tests/script/general/parser/where.sim index ace1ca6f5b..157c41ce58 100644 --- a/tests/script/general/parser/where.sim +++ b/tests/script/general/parser/where.sim @@ -350,5 +350,13 @@ if $rows != 0 then return -1 endi +print ==========================>td-3318 +sql create table tu(ts timestamp, k int, b binary(12)) +sql insert into tu values(now, 1, 'abc') +sql select stddev(k) from tu where b <>'abc' interval(1s) +if $rows != 0 then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From 8e455df2976685e806a688bea521d65cb1c2a3ec Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 16 Mar 2021 18:51:11 +0800 Subject: [PATCH 33/89] Hotfix/sangshuduo/td 3327 taosdemo segfault sampledata (#5458) * [TD-3316] : add testcase for taosdemo limit and offset. check offset 0. * [TD-3316] : add testcase for taosdemo limit and offset. fix sample file import bug. * [TD-3316] : add test case for limit and offset. fix sample data issue. * [TD-3327] : fix taosdemo segfault when import data from sample data file. Co-authored-by: Shuduo Sang --- src/kit/taosdemo/insert.json | 3 +- src/kit/taosdemo/taosdemo.c | 420 ++++-------------- tests/pytest/fulltest.sh | 1 + tests/pytest/pytest_3.sh | 1 + .../pytest/tools/insert-tblimit-tboffset.json | 1 - tests/pytest/tools/sampledata.csv | 3 + tests/pytest/tools/taosdemo-sampledata.json | 39 ++ tests/pytest/tools/taosdemoTestLimitOffset.py | 9 + tests/pytest/tools/taosdemoTestSampleData.py | 68 +++ 9 files changed, 203 insertions(+), 342 deletions(-) create mode 100644 tests/pytest/tools/sampledata.csv create mode 100644 tests/pytest/tools/taosdemo-sampledata.json create mode 100644 tests/pytest/tools/taosdemoTestSampleData.py diff --git a/src/kit/taosdemo/insert.json b/src/kit/taosdemo/insert.json index 208b5fcb74..e6b1895043 100644 --- a/src/kit/taosdemo/insert.json +++ b/src/kit/taosdemo/insert.json @@ -41,8 +41,7 @@ "insert_mode": "taosc", "insert_rows": 100000, "multi_thread_write_one_tbl": "no", - "number_of_tbl_in_one_sql": 0, - "rows_per_tbl": 100, + "rows_per_tbl": 0, "max_sql_len": 1024000, "disorder_ratio": 0, "disorder_range": 1000, diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index ce88ba5bef..6b1cf5f657 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -23,7 +23,6 @@ #ifdef LINUX #include - #include #include #ifndef _ALPINE #include @@ -39,11 +38,11 @@ #include #include #else - #include #include #include #endif +#include #include #include "cJSON.h" @@ -221,7 +220,6 @@ typedef struct SSuperTable_S { int childTblOffset; int multiThreadWriteOneTbl; // 0: no, 1: yes - int numberOfTblInOneSql; // 0/1: one table, > 1: number of tbl int rowsPerTbl; // int disorderRatio; // 0: no disorder, >0: x% int disorderRange; // ms or us by database precision @@ -396,6 +394,8 @@ typedef struct SThreadInfo_S { uint64_t et; int64_t lastTs; + // sample data + int samplePos; // statistics int64_t totalInsertRows; int64_t totalAffectedRows; @@ -1126,8 +1126,6 @@ static int printfInsertMeta() { }else { printf(" multiThreadWriteOneTbl: \033[33myes\033[0m\n"); } - printf(" numberOfTblInOneSql: \033[33m%d\033[0m\n", - g_Dbs.db[i].superTbls[j].numberOfTblInOneSql); printf(" rowsPerTbl: \033[33m%d\033[0m\n", g_Dbs.db[i].superTbls[j].rowsPerTbl); printf(" disorderRange: \033[33m%d\033[0m\n", @@ -1287,7 +1285,6 @@ static void printfInsertMetaToFile(FILE* fp) { }else { fprintf(fp, " multiThreadWriteOneTbl: yes\n"); } - fprintf(fp, " numberOfTblInOneSql: %d\n", g_Dbs.db[i].superTbls[j].numberOfTblInOneSql); fprintf(fp, " rowsPerTbl: %d\n", g_Dbs.db[i].superTbls[j].rowsPerTbl); fprintf(fp, " disorderRange: %d\n", g_Dbs.db[i].superTbls[j].disorderRange); fprintf(fp, " disorderRatio: %d\n", g_Dbs.db[i].superTbls[j].disorderRatio); @@ -2335,7 +2332,8 @@ static int createDatabases() { " fsync %d", g_Dbs.db[i].dbCfg.fsync); } if ((0 == strncasecmp(g_Dbs.db[i].dbCfg.precision, "ms", strlen("ms"))) - || (0 == strncasecmp(g_Dbs.db[i].dbCfg.precision, "us", strlen("us")))) { + || (0 == strncasecmp(g_Dbs.db[i].dbCfg.precision, + "us", strlen("us")))) { dataLen += snprintf(command + dataLen, BUFFER_SIZE - dataLen, " precision \'%s\';", g_Dbs.db[i].dbCfg.precision); } @@ -2351,14 +2349,17 @@ static int createDatabases() { debugPrint("%s() %d supertbl count:%d\n", __func__, __LINE__, g_Dbs.db[i].superTblCount); for (int j = 0; j < g_Dbs.db[i].superTblCount; j++) { // describe super table, if exists - sprintf(command, "describe %s.%s;", g_Dbs.db[i].dbName, g_Dbs.db[i].superTbls[j].sTblName); + sprintf(command, "describe %s.%s;", g_Dbs.db[i].dbName, + g_Dbs.db[i].superTbls[j].sTblName); verbosePrint("%s() %d command: %s\n", __func__, __LINE__, command); if (0 != queryDbExec(taos, command, NO_INSERT_TYPE)) { g_Dbs.db[i].superTbls[j].superTblExists = TBL_NO_EXISTS; - ret = createSuperTable(taos, g_Dbs.db[i].dbName, &g_Dbs.db[i].superTbls[j], g_Dbs.use_metric); + ret = createSuperTable(taos, g_Dbs.db[i].dbName, + &g_Dbs.db[i].superTbls[j], g_Dbs.use_metric); } else { g_Dbs.db[i].superTbls[j].superTblExists = TBL_ALREADY_EXISTS; - ret = getSuperTableFromServer(taos, g_Dbs.db[i].dbName, &g_Dbs.db[i].superTbls[j]); + ret = getSuperTableFromServer(taos, g_Dbs.db[i].dbName, + &g_Dbs.db[i].superTbls[j]); } if (0 != ret) { @@ -2715,6 +2716,8 @@ static int readSampleFromCsvFileToMem( continue; } + verbosePrint("readLen=%ld stb->lenOfOneRow=%d getRows=%d\n", readLen, superTblInfo->lenOfOneRow, getRows); + memcpy(superTblInfo->sampleDataBuf + getRows * superTblInfo->lenOfOneRow, line, readLen); getRows++; @@ -3426,24 +3429,13 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { printf("ERROR: failed to read json, multiThreadWriteOneTbl not found\n"); goto PARSE_OVER; } - - cJSON* numberOfTblInOneSql = cJSON_GetObjectItem(stbInfo, "number_of_tbl_in_one_sql"); - if (numberOfTblInOneSql && numberOfTblInOneSql->type == cJSON_Number) { - g_Dbs.db[i].superTbls[j].numberOfTblInOneSql = numberOfTblInOneSql->valueint; - } else if (!numberOfTblInOneSql) { - g_Dbs.db[i].superTbls[j].numberOfTblInOneSql = 0; - } else { - printf("ERROR: failed to read json, numberOfTblInOneSql not found\n"); - goto PARSE_OVER; - } - cJSON* rowsPerTbl = cJSON_GetObjectItem(stbInfo, "rows_per_tbl"); if (rowsPerTbl && rowsPerTbl->type == cJSON_Number) { g_Dbs.db[i].superTbls[j].rowsPerTbl = rowsPerTbl->valueint; } else if (!rowsPerTbl) { - g_Dbs.db[i].superTbls[j].rowsPerTbl = 1; + g_Dbs.db[i].superTbls[j].rowsPerTbl = 0; // 0 means progressive mode, > 0 mean interlace mode. max value is less or equ num_of_records_per_req } else { - printf("ERROR: failed to read json, rowsPerTbl not found\n"); + fprintf(stderr, "ERROR: failed to read json, rowsPerTbl input mistake\n"); goto PARSE_OVER; } @@ -3901,7 +3893,7 @@ PARSE_OVER: return ret; } -void prepareSampleData() { +static void prepareSampleData() { for (int i = 0; i < g_Dbs.dbCount; i++) { for (int j = 0; j < g_Dbs.db[i].superTblCount; j++) { //if (0 == strncasecmp(g_Dbs.db[i].superTbls[j].dataSource, "sample", 6)) { @@ -3915,7 +3907,7 @@ void prepareSampleData() { } } -void postFreeResource() { +static void postFreeResource() { tmfclose(g_fpOfInsertResult); for (int i = 0; i < g_Dbs.dbCount; i++) { for (int j = 0; j < g_Dbs.db[i].superTblCount; j++) { @@ -3942,16 +3934,18 @@ void postFreeResource() { static int getRowDataFromSample(char* dataBuf, int maxLen, int64_t timestamp, SSuperTable* superTblInfo, int* sampleUsePos) { if ((*sampleUsePos) == MAX_SAMPLES_ONCE_FROM_FILE) { - int ret = readSampleFromCsvFileToMem(superTblInfo); +/* int ret = readSampleFromCsvFileToMem(superTblInfo); if (0 != ret) { tmfree(superTblInfo->sampleDataBuf); superTblInfo->sampleDataBuf = NULL; return -1; } +*/ *sampleUsePos = 0; } int dataLen = 0; + dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, "(%" PRId64 ", ", timestamp); dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, @@ -3967,12 +3961,14 @@ static int generateRowData(char* dataBuf, int maxLen, int64_t timestamp, SSuper int dataLen = 0; dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, "(%" PRId64 ", ", timestamp); for (int i = 0; i < stbInfo->columnCount; i++) { - if ((0 == strncasecmp(stbInfo->columns[i].dataType, "binary", 6)) || (0 == strncasecmp(stbInfo->columns[i].dataType, "nchar", 5))) { + if ((0 == strncasecmp(stbInfo->columns[i].dataType, "binary", 6)) + || (0 == strncasecmp(stbInfo->columns[i].dataType, "nchar", 5))) { if (stbInfo->columns[i].dataLen > TSDB_MAX_BINARY_LEN) { - printf("binary or nchar length overflow, max size:%u\n", (uint32_t)TSDB_MAX_BINARY_LEN); + printf("binary or nchar length overflow, max size:%u\n", + (uint32_t)TSDB_MAX_BINARY_LEN); return (-1); } - + char* buf = (char*)calloc(stbInfo->columns[i].dataLen+1, 1); if (NULL == buf) { printf("calloc failed! size:%d\n", stbInfo->columns[i].dataLen); @@ -3981,15 +3977,24 @@ static int generateRowData(char* dataBuf, int maxLen, int64_t timestamp, SSuper rand_string(buf, stbInfo->columns[i].dataLen); dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, "\'%s\', ", buf); tmfree(buf); - } else if (0 == strncasecmp(stbInfo->columns[i].dataType, "int", 3)) { - dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, "%d, ", rand_int()); - } else if (0 == strncasecmp(stbInfo->columns[i].dataType, "bigint", 6)) { - dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, "%"PRId64", ", rand_bigint()); - } else if (0 == strncasecmp(stbInfo->columns[i].dataType, "float", 5)) { - dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, "%f, ", rand_float()); - } else if (0 == strncasecmp(stbInfo->columns[i].dataType, "double", 6)) { - dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, "%f, ", rand_double()); - } else if (0 == strncasecmp(stbInfo->columns[i].dataType, "smallint", 8)) { + } else if (0 == strncasecmp(stbInfo->columns[i].dataType, + "int", 3)) { + dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, + "%d, ", rand_int()); + } else if (0 == strncasecmp(stbInfo->columns[i].dataType, + "bigint", 6)) { + dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, + "%"PRId64", ", rand_bigint()); + } else if (0 == strncasecmp(stbInfo->columns[i].dataType, + "float", 5)) { + dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, + "%f, ", rand_float()); + } else if (0 == strncasecmp(stbInfo->columns[i].dataType, + "double", 6)) { + dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, + "%f, ", rand_double()); + } else if (0 == strncasecmp(stbInfo->columns[i].dataType, + "smallint", 8)) { dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, "%d, ", rand_smallint()); } else if (0 == strncasecmp(stbInfo->columns[i].dataType, "tinyint", 7)) { dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, "%d, ", rand_tinyint()); @@ -4009,255 +4014,6 @@ static int generateRowData(char* dataBuf, int maxLen, int64_t timestamp, SSuper return dataLen; } -static void syncWriteForNumberOfTblInOneSql( - threadInfo *winfo, char* sampleDataBuf) { - SSuperTable* superTblInfo = winfo->superTblInfo; - - int samplePos = 0; - - //printf("========threadID[%d], table rang: %d - %d \n", winfo->threadID, winfo->start_table_id, winfo->end_table_id); - int64_t lastPrintTime = taosGetTimestampMs(); - - char* buffer = calloc(superTblInfo->maxSqlLen+1, 1); - if (NULL == buffer) { - printf("========calloc size[ %d ] fail!\n", superTblInfo->maxSqlLen); - return; - } - - int32_t numberOfTblInOneSql = superTblInfo->numberOfTblInOneSql; - int32_t tbls = winfo->end_table_id - winfo->start_table_id + 1; - if (numberOfTblInOneSql > tbls) { - numberOfTblInOneSql = tbls; - } - - uint64_t time_counter = winfo->start_time; - int sampleUsePos; - - int insert_interval = superTblInfo?superTblInfo->insertInterval:g_args.insert_interval; - int64_t st = 0; - int64_t et = 0xffffffff; - - int64_t insertRows = (superTblInfo)?superTblInfo->insertRows:g_args.num_of_DPT; - for (int i = 0; i < insertRows;) { - int32_t tbl_id = 0; - for (int tableSeq = winfo->start_table_id; tableSeq <= winfo->end_table_id; ) { - int64_t start_time = 0; - int inserted = i; - - for (int k = 0; k < g_args.num_of_RPR;) { - int len = 0; - memset(buffer, 0, superTblInfo->maxSqlLen); - char *pstr = buffer; - - int32_t end_tbl_id = tableSeq + numberOfTblInOneSql; - if (end_tbl_id > winfo->end_table_id) { - end_tbl_id = winfo->end_table_id+1; - } - - for (tbl_id = tableSeq ; tbl_id < end_tbl_id; tbl_id++) { - sampleUsePos = samplePos; - if (AUTO_CREATE_SUBTBL == superTblInfo->autoCreateTable) { - char* tagsValBuf = NULL; - if (0 == superTblInfo->tagSource) { - tagsValBuf = generateTagVaulesForStb(superTblInfo); - } else { - tagsValBuf = getTagValueFromTagSample( - superTblInfo, tbl_id % superTblInfo->tagSampleCount); - } - if (NULL == tagsValBuf) { - goto free_and_statistics; - } - - if (0 == len) { - len += snprintf(pstr + len, - superTblInfo->maxSqlLen - len, - "insert into %s.%s%d using %s.%s tags %s values ", - winfo->db_name, - superTblInfo->childTblPrefix, - tbl_id, - winfo->db_name, - superTblInfo->sTblName, - tagsValBuf); - } else { - len += snprintf(pstr + len, - superTblInfo->maxSqlLen - len, - " %s.%s%d using %s.%s tags %s values ", - winfo->db_name, - superTblInfo->childTblPrefix, - tbl_id, - winfo->db_name, - superTblInfo->sTblName, - tagsValBuf); - } - tmfree(tagsValBuf); - } else if (TBL_ALREADY_EXISTS == superTblInfo->childTblExists) { - if (0 == len) { - len += snprintf(pstr + len, - superTblInfo->maxSqlLen - len, - "insert into %s.%s values ", - winfo->db_name, - superTblInfo->childTblName + tbl_id * TSDB_TABLE_NAME_LEN); - } else { - len += snprintf(pstr + len, - superTblInfo->maxSqlLen - len, - " %s.%s values ", - winfo->db_name, - superTblInfo->childTblName + tbl_id * TSDB_TABLE_NAME_LEN); - } - } else { // pre-create child table - if (0 == len) { - len += snprintf(pstr + len, - superTblInfo->maxSqlLen - len, - "insert into %s.%s%d values ", - winfo->db_name, - superTblInfo->childTblPrefix, - tbl_id); - } else { - len += snprintf(pstr + len, - superTblInfo->maxSqlLen - len, - " %s.%s%d values ", - winfo->db_name, - superTblInfo->childTblPrefix, - tbl_id); - } - } - - start_time = time_counter; - for (int j = 0; j < superTblInfo->rowsPerTbl;) { - int retLen = 0; - if (0 == strncasecmp(superTblInfo->dataSource, - "sample", strlen("sample"))) { - retLen = getRowDataFromSample(pstr + len, - superTblInfo->maxSqlLen - len, - start_time += superTblInfo->timeStampStep, - superTblInfo, - &sampleUsePos); - if (retLen < 0) { - goto free_and_statistics; - } - } else if (0 == strncasecmp( - superTblInfo->dataSource, "rand", strlen("rand"))) { - int rand_num = rand_tinyint() % 100; - if (0 != superTblInfo->disorderRatio - && rand_num < superTblInfo->disorderRatio) { - int64_t d = start_time - taosRandom() % superTblInfo->disorderRange; - retLen = generateRowData(pstr + len, - superTblInfo->maxSqlLen - len, - d, - superTblInfo); - } else { - retLen = generateRowData(pstr + len, - superTblInfo->maxSqlLen - len, - start_time += superTblInfo->timeStampStep, - superTblInfo); - } - if (retLen < 0) { - goto free_and_statistics; - } - } - len += retLen; - //inserted++; - j++; - winfo->totalInsertRows++; - - if (inserted >= superTblInfo->insertRows || - (superTblInfo->maxSqlLen - len) < (superTblInfo->lenOfOneRow + 128)) { - tableSeq = tbl_id + 1; - printf("config rowsPerTbl and numberOfTblInOneSql not match with max_sql_lenth, please reconfig![lenOfOneRow:%d]\n", - superTblInfo->lenOfOneRow); - goto send_to_server; - } - } - } - - tableSeq = tbl_id; - inserted += superTblInfo->rowsPerTbl; - -send_to_server: - if (insert_interval) { - st = taosGetTimestampUs(); - - if (insert_interval > ((et - st)/1000)) { - int sleep_time = insert_interval - (et -st); - printf("sleep: %d ms insert interval\n", sleep_time); - taosMsleep(sleep_time); // ms - } - } - - if (0 == strncasecmp(superTblInfo->insertMode, - "taosc", - strlen("taosc"))) { - //printf("multi table===== sql: %s \n\n", buffer); - //int64_t t1 = taosGetTimestampMs(); - int64_t startTs; - int64_t endTs; - startTs = taosGetTimestampUs(); - - debugPrint("%s() LN%d buff: %s\n", __func__, __LINE__, buffer); - int affectedRows = queryDbExec( - winfo->taos, buffer, INSERT_TYPE); - - if (0 < affectedRows) { - endTs = taosGetTimestampUs(); - int64_t delay = endTs - startTs; - if (delay > winfo->maxDelay) winfo->maxDelay = delay; - if (delay < winfo->minDelay) winfo->minDelay = delay; - winfo->cntDelay++; - winfo->totalDelay += delay; - winfo->avgDelay = (double)winfo->totalDelay / winfo->cntDelay; - winfo->totalAffectedRows += affectedRows; - } else { - fprintf(stderr, "queryDbExec() buffer:\n%s\naffected rows is %d", buffer, affectedRows); - goto free_and_statistics; - } - - int64_t currentPrintTime = taosGetTimestampMs(); - if (currentPrintTime - lastPrintTime > 30*1000) { - printf("thread[%d] has currently inserted rows: %"PRId64 ", affected rows: %"PRId64 "\n", - winfo->threadID, - winfo->totalInsertRows, - winfo->totalAffectedRows); - lastPrintTime = currentPrintTime; - } - //int64_t t2 = taosGetTimestampMs(); - //printf("taosc insert sql return, Spent %.4f seconds \n", (double)(t2 - t1)/1000.0); - } else { - //int64_t t1 = taosGetTimestampMs(); - int retCode = postProceSql(g_Dbs.host, g_Dbs.port, buffer); - //int64_t t2 = taosGetTimestampMs(); - //printf("http insert sql return, Spent %ld ms \n", t2 - t1); - - if (0 != retCode) { - printf("========restful return fail, threadID[%d]\n", winfo->threadID); - goto free_and_statistics; - } - } - if (insert_interval) { - et = taosGetTimestampUs(); - } - - break; - } - - if (tableSeq > winfo->end_table_id) { - if (0 == strncasecmp(superTblInfo->dataSource, "sample", strlen("sample"))) { - samplePos = sampleUsePos; - } - i = inserted; - time_counter = start_time; - } - } - - //printf("========loop %d childTables duration:%"PRId64 "========inserted rows:%d\n", winfo->end_table_id - winfo->start_table_id, et - st, i); - } - -free_and_statistics: - tmfree(buffer); - printf("====thread[%d] completed total inserted rows: %"PRId64 ", affected rows: %"PRId64 "====\n", - winfo->threadID, winfo->totalInsertRows, winfo->totalAffectedRows); - return; -} - int32_t generateData(char *res, char **data_type, int num_of_cols, int64_t timestamp, int lenOfBinary) { memset(res, 0, MAX_DATA_SIZE); @@ -4319,26 +4075,23 @@ int32_t generateData(char *res, char **data_type, static int prepareSampleDataForSTable(SSuperTable *superTblInfo) { char* sampleDataBuf = NULL; - // each thread read sample data from csv file - if (0 == strncasecmp(superTblInfo->dataSource, - "sample", - strlen("sample"))) { - sampleDataBuf = calloc( + sampleDataBuf = calloc( superTblInfo->lenOfOneRow * MAX_SAMPLES_ONCE_FROM_FILE, 1); - if (sampleDataBuf == NULL) { + if (sampleDataBuf == NULL) { fprintf(stderr, "Failed to calloc %d Bytes, reason:%s\n", superTblInfo->lenOfOneRow * MAX_SAMPLES_ONCE_FROM_FILE, strerror(errno)); return -1; - } + } - superTblInfo->sampleDataBuf = sampleDataBuf; - int ret = readSampleFromCsvFileToMem(superTblInfo); - if (0 != ret) { + superTblInfo->sampleDataBuf = sampleDataBuf; + int ret = readSampleFromCsvFileToMem(superTblInfo); + + if (0 != ret) { + fprintf(stderr, "read sample from csv file failed.\n"); tmfree(sampleDataBuf); superTblInfo->sampleDataBuf = NULL; return -1; - } } return 0; @@ -4400,7 +4153,8 @@ static int generateDataBuffer(int32_t tableSeq, return -1; } - if (superTblInfo && (superTblInfo->childTblOffset > 0)) { + if (superTblInfo && (superTblInfo->childTblOffset >= 0) + && (superTblInfo->childTblLimit > 0)) { // select tbname from stb limit 1 offset tableSeq getChildNameOfSuperTableWithLimitAndOffset(pThreadInfo->taos, pThreadInfo->db_name, superTblInfo->sTblName, @@ -4467,7 +4221,7 @@ static int generateDataBuffer(int32_t tableSeq, verbosePrint("%s() LN%d num_of_RPR=%d\n", __func__, __LINE__, g_args.num_of_RPR); for (k = 0; k < g_args.num_of_RPR;) { if (superTblInfo) { - int retLen = 0; + int retLen = 0; if (0 == strncasecmp(superTblInfo->dataSource, "sample", strlen("sample"))) { @@ -4488,27 +4242,26 @@ static int generateDataBuffer(int32_t tableSeq, superTblInfo->maxSqlLen - len, d, superTblInfo); - //printf("disorder rows, rand_num:%d, last ts:%"PRId64" current ts:%"PRId64"\n", rand_num, start_time, d); - } else { - retLen = generateRowData( + } else { + retLen = generateRowData( pstr + len, superTblInfo->maxSqlLen - len, startTime + superTblInfo->timeStampStep * startFrom, superTblInfo); - } + } + } - if (retLen < 0) { - free(pChildTblName); - return -1; - } + if (retLen < 0) { + free(pChildTblName); + return -1; + } - len += retLen; + len += retLen; - if (len >= (superTblInfo->maxSqlLen - 256)) { // reserve for overwrite - k++; - break; - } - } + if (len >= (superTblInfo->maxSqlLen - 256)) { // reserve for overwrite + k++; + break; + } } else { int rand_num = taosRandom() % 100; char data[MAX_DATA_SIZE]; @@ -4529,14 +4282,13 @@ static int generateDataBuffer(int32_t tableSeq, } pstr += sprintf(pstr, " %s", data); - //assert(len + pstr - buffer < BUFFER_SIZE); if (len + pstr - buffer >= (g_args.max_sql_len - 256)) { // too long k++; break; } } - verbosePrint("%s() LN%d len=%d k=%d \nbuffer=%p\n", __func__, __LINE__, len, k, buffer); + verbosePrint("%s() LN%d len=%d k=%d \nbuffer=%s\n", __func__, __LINE__, len, k, buffer); k++; startFrom ++; @@ -4571,21 +4323,7 @@ static void* syncWrite(void *sarg) { strerror(errno)); return NULL; } - - if (superTblInfo) { - if (0 != prepareSampleDataForSTable(superTblInfo)) - return NULL; - - if (superTblInfo->numberOfTblInOneSql > 0) { - syncWriteForNumberOfTblInOneSql(winfo, superTblInfo->sampleDataBuf); - tmfree(superTblInfo->sampleDataBuf); - superTblInfo->sampleDataBuf = NULL; - return NULL; - } - } - int samplePos = 0; - int64_t lastPrintTime = taosGetTimestampMs(); int64_t startTs = taosGetTimestampUs(); int64_t endTs; @@ -4598,7 +4336,7 @@ static void* syncWrite(void *sarg) { winfo->totalInsertRows = 0; winfo->totalAffectedRows = 0; - int sampleUsePos; + winfo->samplePos = 0; for (uint32_t tableSeq = winfo->start_table_id; tableSeq <= winfo->end_table_id; tableSeq ++) { @@ -4612,10 +4350,8 @@ static void* syncWrite(void *sarg) { st = taosGetTimestampUs(); } - sampleUsePos = samplePos; - int generated = generateDataBuffer(tableSeq, winfo, buffer, insertRows, - i, start_time, &sampleUsePos); + i, start_time, &(winfo->samplePos)); if (generated > 0) i += generated; else @@ -4662,16 +4398,12 @@ static void* syncWrite(void *sarg) { if ((tableSeq == winfo->end_table_id) && superTblInfo && (0 == strncasecmp( superTblInfo->dataSource, "sample", strlen("sample")))) { - samplePos = sampleUsePos; + printf("%s() LN%d samplePos=%d\n", __func__, __LINE__, winfo->samplePos); } } // tableSeq free_and_statistics_2: tmfree(buffer); - if (superTblInfo) { - tmfree(superTblInfo->sampleDataBuf); - superTblInfo->sampleDataBuf = NULL; - } printf("====thread[%d] completed total inserted rows: %"PRId64 ", total affected rows: %"PRId64 "====\n", winfo->threadID, @@ -4842,6 +4574,15 @@ static void startMultiThreadInsertData(int threads, char* db_name, else last = 0; + // read sample data from file first + if ((superTblInfo) && (0 == strncasecmp(superTblInfo->dataSource, + "sample", strlen("sample")))) { + if (0 != prepareSampleDataForSTable(superTblInfo)) { + fprintf(stderr, "prepare sample data for stable failed!\n"); + exit(-1); + } + } + for (int i = 0; i < threads; i++) { threadInfo *t_info = infos + i; t_info->threadID = i; @@ -4877,6 +4618,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, t_info->start_time = t_info->start_time + rand_int() % 10000 - rand_tinyint(); } + tsem_init(&(t_info->lock_sem), 0, 0); if (SYNC == g_Dbs.queryMode) { pthread_create(pids + i, NULL, syncWrite, t_info); diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index d830d96865..a125196b69 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -249,6 +249,7 @@ python3 test.py -f tools/taosdemoTest.py python3 test.py -f tools/taosdemoTest2.py python3 test.py -f tools/taosdemoTestWithoutMetric.py python3 test.py -f tools/taosdemoTestLimitOffset.py +python3 test.py -f tools/taosdemoTestSampleData.py # subscribe python3 test.py -f subscribe/singlemeter.py diff --git a/tests/pytest/pytest_3.sh b/tests/pytest/pytest_3.sh index f2462154bc..a8ffff665d 100755 --- a/tests/pytest/pytest_3.sh +++ b/tests/pytest/pytest_3.sh @@ -82,6 +82,7 @@ python3 test.py -f tools/lowaTest.py python3 test.py -f tools/taosdemoTest.py python3 test.py -f tools/taosdemoTestWithoutMetric.py python3 test.py -f tools/taosdemoTestLimitOffset.py +python3 test.py -f tools/taosdemoTestSampleData.py python3 test.py -f tools/taosdumpTest.py #python3 test.py -f tools/taosdemoTest2.py diff --git a/tests/pytest/tools/insert-tblimit-tboffset.json b/tests/pytest/tools/insert-tblimit-tboffset.json index 5f63660347..f3d3e864ba 100644 --- a/tests/pytest/tools/insert-tblimit-tboffset.json +++ b/tests/pytest/tools/insert-tblimit-tboffset.json @@ -44,7 +44,6 @@ "childtable_offset": 33, "multi_thread_write_one_tbl": "no", "number_of_tbl_in_one_sql": 0, - "rows_per_tbl": 100, "max_sql_len": 1024000, "disorder_ratio": 0, "disorder_range": 1000, diff --git a/tests/pytest/tools/sampledata.csv b/tests/pytest/tools/sampledata.csv new file mode 100644 index 0000000000..01e79c32a8 --- /dev/null +++ b/tests/pytest/tools/sampledata.csv @@ -0,0 +1,3 @@ +1 +2 +3 diff --git a/tests/pytest/tools/taosdemo-sampledata.json b/tests/pytest/tools/taosdemo-sampledata.json new file mode 100644 index 0000000000..473c977773 --- /dev/null +++ b/tests/pytest/tools/taosdemo-sampledata.json @@ -0,0 +1,39 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 10, + "confirm_parameter_prompt": "no", + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes" + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 20, + "childtable_limit": 10, + "childtable_offset": 0, + "childtable_prefix": "t_", + "auto_create_table": "no", + "data_source": "sample", + "insert_mode": "taosc", + "insert_rate": 0, + "insert_rows": 20, + "multi_thread_write_one_tbl": "no", + "number_of_tbl_in_one_sql": 0, + "max_sql_len": 1048000, + "timestamp_step": 1000, + "start_timestamp": "2020-1-1 00:00:00", + "sample_format": "csv", + "sample_file": "./tools/sampledata.csv", + "columns": [{"type": "INT"}], + "tags": [{"type": "INT", "count":1}] + }] + }] + +} diff --git a/tests/pytest/tools/taosdemoTestLimitOffset.py b/tests/pytest/tools/taosdemoTestLimitOffset.py index 6dbe5a7028..69a81b166b 100644 --- a/tests/pytest/tools/taosdemoTestLimitOffset.py +++ b/tests/pytest/tools/taosdemoTestLimitOffset.py @@ -59,6 +59,15 @@ class TDTestCase: tdSql.query("select count(*) from db.stb") tdSql.checkData(0, 0, 33000) + os.system("%staosdemo -f tools/insert-tblimit-tboffset0.json" % binPath) + + tdSql.execute("reset query cache") + tdSql.execute("use db") + tdSql.query("select count(tbname) from db.stb") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 20000) + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/pytest/tools/taosdemoTestSampleData.py b/tests/pytest/tools/taosdemoTestSampleData.py new file mode 100644 index 0000000000..893c53984d --- /dev/null +++ b/tests/pytest/tools/taosdemoTestSampleData.py @@ -0,0 +1,68 @@ +################################################################### +# 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.numberOfTables = 10000 + self.numberOfRecords = 100 + + 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 run(self): + tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + os.system("%staosdemo -f tools/taosdemo-sampledata.json" % binPath) + + tdSql.execute("use db") + tdSql.query("select count(tbname) from db.stb") + tdSql.checkData(0, 0, 20) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 200) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) From 3cb51e980f5ab636965b8f037f2305a621a9247d Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 17 Mar 2021 00:10:45 +0800 Subject: [PATCH 34/89] Hotfix/sangshuduo/td 3316 testcase for taosdemo limit offset (#5462) * [TD-3316] : add testcase for taosdemo limit and offset. check offset 0. * [TD-3316] : add testcase for taosdemo limit and offset. fix sample file import bug. --- src/kit/taosdemo/taosdemo.c | 49 ++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 6b1cf5f657..b03f47bfaf 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -4145,7 +4145,6 @@ static int generateDataBuffer(int32_t tableSeq, assert(buffer != NULL); char *pChildTblName; - int childTblCount; pChildTblName = calloc(TSDB_TABLE_NAME_LEN, 1); if (NULL == pChildTblName) { @@ -4155,13 +4154,10 @@ static int generateDataBuffer(int32_t tableSeq, if (superTblInfo && (superTblInfo->childTblOffset >= 0) && (superTblInfo->childTblLimit > 0)) { - // select tbname from stb limit 1 offset tableSeq - getChildNameOfSuperTableWithLimitAndOffset(pThreadInfo->taos, - pThreadInfo->db_name, superTblInfo->sTblName, - &pChildTblName, &childTblCount, - 1, tableSeq); + snprintf(pChildTblName, TSDB_TABLE_NAME_LEN, "%s", + superTblInfo->childTblName + (tableSeq - superTblInfo->childTblOffset) * TSDB_TABLE_NAME_LEN); } else { - snprintf(pChildTblName, TSDB_TABLE_NAME_LEN, "%s%d", + snprintf(pChildTblName, TSDB_TABLE_NAME_LEN, "%s%d", superTblInfo?superTblInfo->childTblPrefix:g_args.tb_prefix, tableSeq); } @@ -4577,10 +4573,40 @@ static void startMultiThreadInsertData(int threads, char* db_name, // read sample data from file first if ((superTblInfo) && (0 == strncasecmp(superTblInfo->dataSource, "sample", strlen("sample")))) { - if (0 != prepareSampleDataForSTable(superTblInfo)) { - fprintf(stderr, "prepare sample data for stable failed!\n"); - exit(-1); - } + if (0 != prepareSampleDataForSTable(superTblInfo)) { + fprintf(stderr, "prepare sample data for stable failed!\n"); + exit(-1); + } + } + + if (superTblInfo && (superTblInfo->childTblOffset >= 0) + && (superTblInfo->childTblLimit > 0)) { + + TAOS* taos = taos_connect( + g_Dbs.host, g_Dbs.user, + g_Dbs.password, db_name, g_Dbs.port); + if (NULL == taos) { + fprintf(stderr, "connect to server fail , reason: %s\n", + taos_errstr(NULL)); + exit(-1); + } + + superTblInfo->childTblName = (char*)calloc(1, + superTblInfo->childTblLimit * TSDB_TABLE_NAME_LEN); + if (superTblInfo->childTblName == NULL) { + fprintf(stderr, "alloc memory failed!"); + taos_close(taos); + exit(-1); + } + int childTblCount; + + getChildNameOfSuperTableWithLimitAndOffset( + taos, + db_name, superTblInfo->sTblName, + &superTblInfo->childTblName, &childTblCount, + superTblInfo->childTblLimit, + superTblInfo->childTblOffset); + taos_close(taos); } for (int i = 0; i < threads; i++) { @@ -4618,7 +4644,6 @@ static void startMultiThreadInsertData(int threads, char* db_name, t_info->start_time = t_info->start_time + rand_int() % 10000 - rand_tinyint(); } - tsem_init(&(t_info->lock_sem), 0, 0); if (SYNC == g_Dbs.queryMode) { pthread_create(pids + i, NULL, syncWrite, t_info); From 58cfd2ccf7eb78a9c2ce7e8f9ea2cfce17547bb3 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 17 Mar 2021 01:16:04 +0000 Subject: [PATCH 35/89] TD-3323 --- src/vnode/src/vnodeMain.c | 64 ++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index c380b60f88..d81347d2f2 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -110,31 +110,64 @@ int32_t vnodeDrop(int32_t vgId) { } static int32_t vnodeAlterImp(SVnodeObj *pVnode, SCreateVnodeMsg *pVnodeCfg) { + STsdbCfg tsdbCfg = pVnode->tsdbCfg; + SSyncCfg syncCfg = pVnode->syncCfg; + int32_t dbCfgVersion = pVnode->dbCfgVersion; + int32_t vgCfgVersion = pVnode->vgCfgVersion; + int32_t code = vnodeWriteCfg(pVnodeCfg); if (code != TSDB_CODE_SUCCESS) { - return code; + pVnode->dbCfgVersion = dbCfgVersion; + pVnode->vgCfgVersion = vgCfgVersion; + return code; } code = vnodeReadCfg(pVnode); if (code != TSDB_CODE_SUCCESS) { - return code; + pVnode->dbCfgVersion = dbCfgVersion; + pVnode->vgCfgVersion = vgCfgVersion; + return code; } code = walAlter(pVnode->wal, &pVnode->walCfg); if (code != TSDB_CODE_SUCCESS) { + pVnode->dbCfgVersion = dbCfgVersion; + pVnode->vgCfgVersion = vgCfgVersion; return code; } - code = syncReconfig(pVnode->sync, &pVnode->syncCfg); - if (code != TSDB_CODE_SUCCESS) { - return code; - } + bool tsdbCfgChanged = (memcmp(&tsdbCfg, &pVnode->tsdbCfg, sizeof(STsdbCfg)) != 0); + bool syncCfgChanged = (memcmp(&syncCfg, &pVnode->syncCfg, sizeof(SSyncCfg)) != 0); - if (pVnode->tsdb) { - code = tsdbConfigRepo(pVnode->tsdb, &pVnode->tsdbCfg); + if (tsdbCfgChanged || syncCfgChanged) { + // vnode in non-ready state and still needs to return success instead of TSDB_CODE_VND_INVALID_STATUS + // dbCfgVersion can be corrected by status msg + if (!vnodeSetUpdatingStatus(pVnode)) { + vDebug("vgId:%d, vnode is not ready, do alter operation later", pVnode->vgId); + pVnode->dbCfgVersion = dbCfgVersion; + pVnode->vgCfgVersion = vgCfgVersion; + return TSDB_CODE_SUCCESS; + } + + code = syncReconfig(pVnode->sync, &pVnode->syncCfg); if (code != TSDB_CODE_SUCCESS) { + pVnode->dbCfgVersion = dbCfgVersion; + pVnode->vgCfgVersion = vgCfgVersion; + vnodeSetReadyStatus(pVnode); return code; } + + if (pVnode->tsdb) { + code = tsdbConfigRepo(pVnode->tsdb, &pVnode->tsdbCfg); + if (code != TSDB_CODE_SUCCESS) { + pVnode->dbCfgVersion = dbCfgVersion; + pVnode->vgCfgVersion = vgCfgVersion; + vnodeSetReadyStatus(pVnode); + return code; + } + } + + vnodeSetReadyStatus(pVnode); } return 0; @@ -142,21 +175,16 @@ static int32_t vnodeAlterImp(SVnodeObj *pVnode, SCreateVnodeMsg *pVnodeCfg) { int32_t vnodeAlter(void *vparam, SCreateVnodeMsg *pVnodeCfg) { SVnodeObj *pVnode = vparam; - if (pVnode->dbCfgVersion == pVnodeCfg->cfg.dbCfgVersion && pVnode->vgCfgVersion == pVnodeCfg->cfg.vgCfgVersion) { - vDebug("vgId:%d, dbCfgVersion:%d and vgCfgVersion:%d not change", pVnode->vgId, pVnode->dbCfgVersion, - pVnode->vgCfgVersion); - return TSDB_CODE_SUCCESS; - } - // vnode in non-ready state and still needs to return success instead of TSDB_CODE_VND_INVALID_STATUS - // dbCfgVersion can be corrected by status msg - if (!vnodeSetUpdatingStatus(pVnode)) { - vDebug("vgId:%d, vnode is not ready, do alter operation later", pVnode->vgId); + vDebug("vgId:%d, current dbCfgVersion:%d vgCfgVersion:%d, input dbCfgVersion:%d vgCfgVersion:%d", pVnode->vgId, + pVnode->dbCfgVersion, pVnode->vgCfgVersion, pVnodeCfg->cfg.dbCfgVersion, pVnodeCfg->cfg.vgCfgVersion); + + if (pVnode->dbCfgVersion == pVnodeCfg->cfg.dbCfgVersion && pVnode->vgCfgVersion == pVnodeCfg->cfg.vgCfgVersion) { + vDebug("vgId:%d, cfg not change", pVnode->vgId); return TSDB_CODE_SUCCESS; } int32_t code = vnodeAlterImp(pVnode, pVnodeCfg); - vnodeSetReadyStatus(pVnode); if (code != 0) { vError("vgId:%d, failed to alter vnode, code:0x%x", pVnode->vgId, code); From 6d152e198f673ef8105c3f572595f38fb037e6ba Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 17 Mar 2021 09:23:50 +0800 Subject: [PATCH 36/89] Reduce unnecessary output --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e7603b578b..45993ffe05 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -42,14 +42,14 @@ def pre_test(){ cd ${WKC} git checkout develop git reset --hard HEAD~10 >/dev/null - git pull + git pull >/dev/null git fetch origin +refs/pull/${CHANGE_ID}/merge git checkout -qf FETCH_HEAD - git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD develop)|grep -v -E '.*md|//src//connector|Jenkinsfile' || exit 0 + git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD develop)|grep -v -E '.*md|//src//connector|Jenkinsfile' find ${WKC}/tests/pytest -name \'*\'.sql -exec rm -rf {} \\; cd ${WK} git reset --hard HEAD~10 - git checkout develop + git checkout develop >/dev/null git pull cd ${WK} export TZ=Asia/Harbin From 9d52d7983f8544cbb0a62376c26925ed1e01f5ca Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 17 Mar 2021 09:52:38 +0800 Subject: [PATCH 37/89] fix --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 45993ffe05..68fe4879c1 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -49,8 +49,8 @@ def pre_test(){ find ${WKC}/tests/pytest -name \'*\'.sql -exec rm -rf {} \\; cd ${WK} git reset --hard HEAD~10 - git checkout develop >/dev/null - git pull + git checkout develop + git pull >/dev/null cd ${WK} export TZ=Asia/Harbin date From 9d024fe48634d0f4b86b1c1c9150b8fbef73a2a8 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 17 Mar 2021 10:34:13 +0800 Subject: [PATCH 38/89] TD-3334 --- src/vnode/src/vnodeMain.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index d81347d2f2..42b9c024c9 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -119,6 +119,8 @@ static int32_t vnodeAlterImp(SVnodeObj *pVnode, SCreateVnodeMsg *pVnodeCfg) { if (code != TSDB_CODE_SUCCESS) { pVnode->dbCfgVersion = dbCfgVersion; pVnode->vgCfgVersion = vgCfgVersion; + pVnode->syncCfg = syncCfg; + pVnode->tsdbCfg = tsdbCfg; return code; } @@ -126,6 +128,8 @@ static int32_t vnodeAlterImp(SVnodeObj *pVnode, SCreateVnodeMsg *pVnodeCfg) { if (code != TSDB_CODE_SUCCESS) { pVnode->dbCfgVersion = dbCfgVersion; pVnode->vgCfgVersion = vgCfgVersion; + pVnode->syncCfg = syncCfg; + pVnode->tsdbCfg = tsdbCfg; return code; } @@ -133,12 +137,16 @@ static int32_t vnodeAlterImp(SVnodeObj *pVnode, SCreateVnodeMsg *pVnodeCfg) { if (code != TSDB_CODE_SUCCESS) { pVnode->dbCfgVersion = dbCfgVersion; pVnode->vgCfgVersion = vgCfgVersion; + pVnode->syncCfg = syncCfg; + pVnode->tsdbCfg = tsdbCfg; return code; } bool tsdbCfgChanged = (memcmp(&tsdbCfg, &pVnode->tsdbCfg, sizeof(STsdbCfg)) != 0); bool syncCfgChanged = (memcmp(&syncCfg, &pVnode->syncCfg, sizeof(SSyncCfg)) != 0); + vDebug("vgId:%d, tsdbchanged:%d syncchanged:%d while alter vnode", pVnode->vgId, tsdbCfgChanged, syncCfgChanged); + if (tsdbCfgChanged || syncCfgChanged) { // vnode in non-ready state and still needs to return success instead of TSDB_CODE_VND_INVALID_STATUS // dbCfgVersion can be corrected by status msg @@ -146,6 +154,8 @@ static int32_t vnodeAlterImp(SVnodeObj *pVnode, SCreateVnodeMsg *pVnodeCfg) { vDebug("vgId:%d, vnode is not ready, do alter operation later", pVnode->vgId); pVnode->dbCfgVersion = dbCfgVersion; pVnode->vgCfgVersion = vgCfgVersion; + pVnode->syncCfg = syncCfg; + pVnode->tsdbCfg = tsdbCfg; return TSDB_CODE_SUCCESS; } @@ -153,6 +163,8 @@ static int32_t vnodeAlterImp(SVnodeObj *pVnode, SCreateVnodeMsg *pVnodeCfg) { if (code != TSDB_CODE_SUCCESS) { pVnode->dbCfgVersion = dbCfgVersion; pVnode->vgCfgVersion = vgCfgVersion; + pVnode->syncCfg = syncCfg; + pVnode->tsdbCfg = tsdbCfg; vnodeSetReadyStatus(pVnode); return code; } @@ -162,6 +174,8 @@ static int32_t vnodeAlterImp(SVnodeObj *pVnode, SCreateVnodeMsg *pVnodeCfg) { if (code != TSDB_CODE_SUCCESS) { pVnode->dbCfgVersion = dbCfgVersion; pVnode->vgCfgVersion = vgCfgVersion; + pVnode->syncCfg = syncCfg; + pVnode->tsdbCfg = tsdbCfg; vnodeSetReadyStatus(pVnode); return code; } From 583bbf26c580d68b10317971c5b9c0f5a2c2e354 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 17 Mar 2021 12:02:01 +0800 Subject: [PATCH 39/89] [td-3338]: query data before 1970-1-1 00:00:00 caused taosd crash. --- src/tsdb/src/tsdbRead.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 0bf533d027..7b7c244ba8 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -1021,6 +1021,14 @@ static int32_t doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SBlock* pBloc pBlock->numOfRows = pCols->numOfRows; + // Convert from TKEY to TSKEY for primary timestamp column if current block has timestamp before 1970-01-01T00:00:00Z + if(pBlock->keyFirst < 0 && colIds[0] == PRIMARYKEY_TIMESTAMP_COL_INDEX) { + int64_t* src = pCols->cols[0].pData; + for(int32_t i = 0; i < pBlock->numOfRows; ++i) { + src[i] = tdGetKey(src[i]); + } + } + int64_t elapsedTime = (taosGetTimestampUs() - st); pQueryHandle->cost.blockLoadTime += elapsedTime; @@ -1277,13 +1285,7 @@ int32_t doCopyRowsFromFileBlock(STsdbQueryHandle* pQueryHandle, int32_t capacity } if (pColInfo->info.colId == src->colId) { - - if (pColInfo->info.type == TSDB_DATA_TYPE_TIMESTAMP) { - for (int32_t n = 0; n < num; n++) { - TKEY tkey = *(TKEY *)((char*)src->pData + bytes * start + n * sizeof(TKEY)); - *(TSKEY *)(pData + n * sizeof(TSKEY)) = tdGetKey(tkey); - } - } else if (pColInfo->info.type != TSDB_DATA_TYPE_BINARY && pColInfo->info.type != TSDB_DATA_TYPE_NCHAR) { + if (pColInfo->info.type != TSDB_DATA_TYPE_BINARY && pColInfo->info.type != TSDB_DATA_TYPE_NCHAR) { memmove(pData, (char*)src->pData + bytes * start, bytes * num); } else { // handle the var-string char* dst = pData; From 608134c2297c62f4ad5fb60b5d5e21818874b03a Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 17 Mar 2021 12:38:43 +0800 Subject: [PATCH 40/89] [TD-3198]sync test case file --- tests/pytest/fulltest.sh | 129 +++++--- tests/pytest/pytest_1.sh | 138 -------- tests/pytest/pytest_2.sh | 16 - tests/pytest/pytest_3.sh | 92 ------ tests/pytest/pytest_4.sh | 39 --- tests/script/jenkins/basic.txt | 546 ++++++++++++++++--------------- tests/script/jenkins/basic_1.txt | 85 ----- tests/script/jenkins/basic_2.txt | 74 ----- tests/script/jenkins/basic_3.txt | 58 ---- tests/script/jenkins/basic_4.txt | 46 --- tests/script/jenkins/basic_5.txt | 19 -- tests/script/jenkins/basic_6.txt | 37 --- tests/script/jenkins/basic_7.txt | 83 ----- tests/test-all.sh | 66 ++-- 14 files changed, 400 insertions(+), 1028 deletions(-) delete mode 100755 tests/pytest/pytest_1.sh delete mode 100755 tests/pytest/pytest_2.sh delete mode 100755 tests/pytest/pytest_3.sh delete mode 100755 tests/pytest/pytest_4.sh delete mode 100644 tests/script/jenkins/basic_1.txt delete mode 100644 tests/script/jenkins/basic_2.txt delete mode 100644 tests/script/jenkins/basic_3.txt delete mode 100644 tests/script/jenkins/basic_4.txt delete mode 100644 tests/script/jenkins/basic_5.txt delete mode 100644 tests/script/jenkins/basic_6.txt delete mode 100644 tests/script/jenkins/basic_7.txt diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index d830d96865..506d469b2f 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -1,18 +1,15 @@ #!/bin/bash ulimit -c unlimited +#======================p1-start=============== python3 ./test.py -f insert/basic.py python3 ./test.py -f insert/int.py -python3 ./test.py -f insert/unsignedInt.py python3 ./test.py -f insert/float.py python3 ./test.py -f insert/bigint.py -python3 ./test.py -f insert/unsignedBigint.py python3 ./test.py -f insert/bool.py python3 ./test.py -f insert/double.py python3 ./test.py -f insert/smallint.py -python3 ./test.py -f insert/unsignedSmallint.py python3 ./test.py -f insert/tinyint.py -python3 ./test.py -f insert/unsignedTinyint.py python3 ./test.py -f insert/date.py python3 ./test.py -f insert/binary.py python3 ./test.py -f insert/nchar.py @@ -23,10 +20,8 @@ python3 ./test.py -f insert/randomNullCommit.py python3 insert/retentionpolicy.py python3 ./test.py -f insert/alterTableAndInsert.py python3 ./test.py -f insert/insertIntoTwoTables.py -#python3 ./test.py -f insert/before_1970.py -python3 ./test.py -f insert/metadataUpdate.py +python3 ./test.py -f insert/before_1970.py python3 bug2265.py -python3 ./test.py -f insert/boundary2.py #table python3 ./test.py -f table/alter_wal0.py @@ -71,7 +66,7 @@ python3 ./test.py -f tag_lite/int.py python3 ./test.py -f tag_lite/set.py python3 ./test.py -f tag_lite/smallint.py python3 ./test.py -f tag_lite/tinyint.py -python3 ./test.py -f tag_lite/alter_tag.py + #python3 ./test.py -f dbmgmt/database-name-boundary.py python3 ./test.py -f import_merge/importBlock1HO.py @@ -142,6 +137,27 @@ python3 ./test.py -f import_merge/importTPORestart.py python3 ./test.py -f import_merge/importTRestart.py python3 ./test.py -f import_merge/importInsertThenImport.py python3 ./test.py -f import_merge/importCSV.py +#======================p1-end=============== +#======================p2-start=============== +# update +python3 ./test.py -f update/allow_update.py +python3 ./test.py -f update/allow_update-0.py +python3 ./test.py -f update/append_commit_data.py +python3 ./test.py -f update/append_commit_last-0.py +python3 ./test.py -f update/append_commit_last.py +python3 ./test.py -f update/merge_commit_data.py + +python3 ./test.py -f update/merge_commit_data2.py +python3 ./test.py -f update/merge_commit_data2_update0.py +python3 ./test.py -f update/merge_commit_last-0.py +python3 ./test.py -f update/merge_commit_last.py +python3 ./test.py -f update/bug_td2279.py + +#======================p2-end=============== +#======================p3-start=============== + +python3 ./test.py -f insert/randomNullCommit.py + # user python3 ./test.py -f user/user_create.py python3 ./test.py -f user/pass_len.py @@ -155,7 +171,6 @@ python3 ./test.py -f query/filterCombo.py python3 ./test.py -f query/queryNormal.py python3 ./test.py -f query/queryError.py python3 ./test.py -f query/filterAllIntTypes.py -python3 ./test.py -f query/filterAllUnsignedIntTypes.py python3 ./test.py -f query/filterFloatAndDouble.py python3 ./test.py -f query/filterOtherTypes.py python3 ./test.py -f query/querySort.py @@ -182,8 +197,6 @@ python3 ./test.py -f query/bug2119.py python3 ./test.py -f query/isNullTest.py python3 ./test.py -f query/queryWithTaosdKilled.py python3 ./test.py -f query/floatCompare.py -python3 ./test.py -f query/queryGroupbySort.py -python3 ./test.py -f query/queryBetweenAnd.py #stream python3 ./test.py -f stream/metric_1.py @@ -199,8 +212,6 @@ python3 ./test.py -f stream/table_n.py #alter table python3 ./test.py -f alter/alter_table_crash.py -python3 ./test.py -f alter/alter_table.py -python3 ./test.py -f alter/alter_debugFlag.py # client python3 ./test.py -f client/client.py @@ -213,6 +224,36 @@ python3 testCompress.py python3 testNoCompress.py python3 testMinTablesPerVnode.py + +python3 queryCount.py +python3 ./test.py -f query/queryGroupbyWithInterval.py +python3 client/twoClients.py +python3 test.py -f query/queryInterval.py +python3 test.py -f query/queryFillTest.py + +# tools +python3 test.py -f tools/lowaTest.py +python3 test.py -f tools/taosdemoTest.py +python3 test.py -f tools/taosdemoTestWithoutMetric.py +python3 test.py -f tools/taosdemoTestLimitOffset.py +python3 test.py -f tools/taosdumpTest.py +python3 test.py -f tools/taosdemoTest2.py + +# subscribe +python3 test.py -f subscribe/singlemeter.py +#python3 test.py -f subscribe/stability.py +python3 test.py -f subscribe/supertable.py + + +#======================p3-end=============== +#======================p4-start=============== + +python3 ./test.py -f update/merge_commit_data-0.py +# wal +python3 ./test.py -f wal/addOldWalTest.py + +# function +python3 ./test.py -f functions/all_null_value.py # functions python3 ./test.py -f functions/function_avg.py -r 1 python3 ./test.py -f functions/function_bottom.py -r 1 @@ -232,46 +273,26 @@ python3 ./test.py -f functions/function_sum.py -r 1 python3 ./test.py -f functions/function_top.py -r 1 python3 ./test.py -f functions/function_twa.py -r 1 python3 ./test.py -f functions/function_twa_test2.py -python3 ./test.py -f functions/all_null_value.py -python3 ./test.py -f functions/function_percentile2.py -python3 queryCount.py -python3 ./test.py -f query/queryGroupbyWithInterval.py -python3 client/twoClients.py -python3 ./test.py -f query/queryInterval.py -python3 ./test.py -f query/queryFillTest.py -python3 ./test.py -f query/last_row_cache.py +python3 ./test.py -f functions/function_stddev_td2555.py +python3 ./test.py -f insert/metadataUpdate.py +python3 ./test.py -f tools/taosdemoTest2.py python3 ./test.py -f query/last_cache.py - -# tools -python3 test.py -f tools/taosdumpTest.py -python3 test.py -f tools/lowaTest.py -python3 test.py -f tools/taosdemoTest.py -python3 test.py -f tools/taosdemoTest2.py -python3 test.py -f tools/taosdemoTestWithoutMetric.py -python3 test.py -f tools/taosdemoTestLimitOffset.py - -# subscribe -python3 test.py -f subscribe/singlemeter.py -#python3 test.py -f subscribe/stability.py -python3 test.py -f subscribe/supertable.py - - -# update -python3 ./test.py -f update/allow_update.py -python3 ./test.py -f update/allow_update-0.py -python3 ./test.py -f update/append_commit_data.py -python3 ./test.py -f update/append_commit_last-0.py -python3 ./test.py -f update/append_commit_last.py -python3 ./test.py -f update/merge_commit_data.py -python3 ./test.py -f update/merge_commit_data-0.py -python3 ./test.py -f update/merge_commit_data2.py -python3 ./test.py -f update/merge_commit_data2_update0.py -python3 ./test.py -f update/merge_commit_last-0.py -python3 ./test.py -f update/merge_commit_last.py -python3 ./test.py -f update/bug_td2279.py - -# wal -python3 ./test.py -f wal/addOldWalTest.py - -# account +python3 ./test.py -f query/last_row_cache.py python3 ./test.py -f account/account_create.py +python3 ./test.py -f alter/alter_table.py +python3 ./test.py -f query/queryGroupbySort.py + +python3 ./test.py -f insert/unsignedInt.py +python3 ./test.py -f insert/unsignedBigint.py +python3 ./test.py -f insert/unsignedSmallint.py +python3 ./test.py -f insert/unsignedTinyint.py +python3 ./test.py -f query/filterAllUnsignedIntTypes.py + +python3 ./test.py -f functions/function_percentile2.py +python3 ./test.py -f insert/boundary2.py +python3 ./test.py -f query/queryFillTest.py +python3 ./test.py -f alter/alter_debugFlag.py +python3 ./test.py -f query/queryBetweenAnd.py +python3 ./test.py -f tag_lite/alter_tag.py + +#======================p4-end=============== \ No newline at end of file diff --git a/tests/pytest/pytest_1.sh b/tests/pytest/pytest_1.sh deleted file mode 100755 index e6638cbb17..0000000000 --- a/tests/pytest/pytest_1.sh +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/bash -ulimit -c unlimited - -python3 ./test.py -f insert/basic.py -python3 ./test.py -f insert/int.py -python3 ./test.py -f insert/float.py -python3 ./test.py -f insert/bigint.py -python3 ./test.py -f insert/bool.py -python3 ./test.py -f insert/double.py -python3 ./test.py -f insert/smallint.py -python3 ./test.py -f insert/tinyint.py -python3 ./test.py -f insert/date.py -python3 ./test.py -f insert/binary.py -python3 ./test.py -f insert/nchar.py -#python3 ./test.py -f insert/nchar-boundary.py -python3 ./test.py -f insert/nchar-unicode.py -python3 ./test.py -f insert/multi.py -python3 ./test.py -f insert/randomNullCommit.py -python3 insert/retentionpolicy.py -python3 ./test.py -f insert/alterTableAndInsert.py -python3 ./test.py -f insert/insertIntoTwoTables.py -python3 ./test.py -f insert/before_1970.py -python3 bug2265.py - -#table -python3 ./test.py -f table/alter_wal0.py -python3 ./test.py -f table/column_name.py -python3 ./test.py -f table/column_num.py -python3 ./test.py -f table/db_table.py -python3 ./test.py -f table/create_sensitive.py -#python3 ./test.py -f table/tablename-boundary.py -python3 ./test.py -f table/max_table_length.py -python3 ./test.py -f table/alter_column.py -python3 ./test.py -f table/boundary.py -python3 ./test.py -f table/create.py -python3 ./test.py -f table/del_stable.py - - -# tag -python3 ./test.py -f tag_lite/filter.py -python3 ./test.py -f tag_lite/create-tags-boundary.py -python3 ./test.py -f tag_lite/3.py -python3 ./test.py -f tag_lite/4.py -python3 ./test.py -f tag_lite/5.py -python3 ./test.py -f tag_lite/6.py -python3 ./test.py -f tag_lite/add.py -python3 ./test.py -f tag_lite/bigint.py -python3 ./test.py -f tag_lite/binary_binary.py -python3 ./test.py -f tag_lite/binary.py -python3 ./test.py -f tag_lite/bool_binary.py -python3 ./test.py -f tag_lite/bool_int.py -python3 ./test.py -f tag_lite/bool.py -python3 ./test.py -f tag_lite/change.py -python3 ./test.py -f tag_lite/column.py -python3 ./test.py -f tag_lite/commit.py -python3 ./test.py -f tag_lite/create.py -python3 ./test.py -f tag_lite/datatype.py -python3 ./test.py -f tag_lite/datatype-without-alter.py -python3 ./test.py -f tag_lite/delete.py -python3 ./test.py -f tag_lite/double.py -python3 ./test.py -f tag_lite/float.py -python3 ./test.py -f tag_lite/int_binary.py -python3 ./test.py -f tag_lite/int_float.py -python3 ./test.py -f tag_lite/int.py -python3 ./test.py -f tag_lite/set.py -python3 ./test.py -f tag_lite/smallint.py -python3 ./test.py -f tag_lite/tinyint.py - -#python3 ./test.py -f dbmgmt/database-name-boundary.py - -python3 ./test.py -f import_merge/importBlock1HO.py -python3 ./test.py -f import_merge/importBlock1HPO.py -python3 ./test.py -f import_merge/importBlock1H.py -python3 ./test.py -f import_merge/importBlock1S.py -python3 ./test.py -f import_merge/importBlock1Sub.py -python3 ./test.py -f import_merge/importBlock1TO.py -python3 ./test.py -f import_merge/importBlock1TPO.py -python3 ./test.py -f import_merge/importBlock1T.py -python3 ./test.py -f import_merge/importBlock2HO.py -python3 ./test.py -f import_merge/importBlock2HPO.py -python3 ./test.py -f import_merge/importBlock2H.py -python3 ./test.py -f import_merge/importBlock2S.py -python3 ./test.py -f import_merge/importBlock2Sub.py -python3 ./test.py -f import_merge/importBlock2TO.py -python3 ./test.py -f import_merge/importBlock2TPO.py -python3 ./test.py -f import_merge/importBlock2T.py -python3 ./test.py -f import_merge/importBlockbetween.py -python3 ./test.py -f import_merge/importCacheFileHO.py -python3 ./test.py -f import_merge/importCacheFileHPO.py -python3 ./test.py -f import_merge/importCacheFileH.py -python3 ./test.py -f import_merge/importCacheFileS.py -python3 ./test.py -f import_merge/importCacheFileSub.py -python3 ./test.py -f import_merge/importCacheFileTO.py -python3 ./test.py -f import_merge/importCacheFileTPO.py -python3 ./test.py -f import_merge/importCacheFileT.py -python3 ./test.py -f import_merge/importDataH2.py -python3 ./test.py -f import_merge/importDataHO2.py -python3 ./test.py -f import_merge/importDataHO.py -python3 ./test.py -f import_merge/importDataHPO.py -python3 ./test.py -f import_merge/importDataLastHO.py -python3 ./test.py -f import_merge/importDataLastHPO.py -python3 ./test.py -f import_merge/importDataLastH.py -python3 ./test.py -f import_merge/importDataLastS.py -python3 ./test.py -f import_merge/importDataLastSub.py -python3 ./test.py -f import_merge/importDataLastTO.py -python3 ./test.py -f import_merge/importDataLastTPO.py -python3 ./test.py -f import_merge/importDataLastT.py -python3 ./test.py -f import_merge/importDataS.py -python3 ./test.py -f import_merge/importDataSub.py -python3 ./test.py -f import_merge/importDataTO.py -python3 ./test.py -f import_merge/importDataTPO.py -python3 ./test.py -f import_merge/importDataT.py -python3 ./test.py -f import_merge/importHeadOverlap.py -python3 ./test.py -f import_merge/importHeadPartOverlap.py -python3 ./test.py -f import_merge/importHead.py -python3 ./test.py -f import_merge/importHORestart.py -python3 ./test.py -f import_merge/importHPORestart.py -python3 ./test.py -f import_merge/importHRestart.py -python3 ./test.py -f import_merge/importLastHO.py -python3 ./test.py -f import_merge/importLastHPO.py -python3 ./test.py -f import_merge/importLastH.py -python3 ./test.py -f import_merge/importLastS.py -python3 ./test.py -f import_merge/importLastSub.py -python3 ./test.py -f import_merge/importLastTO.py -python3 ./test.py -f import_merge/importLastTPO.py -python3 ./test.py -f import_merge/importLastT.py -python3 ./test.py -f import_merge/importSpan.py -python3 ./test.py -f import_merge/importSRestart.py -python3 ./test.py -f import_merge/importSubRestart.py -python3 ./test.py -f import_merge/importTailOverlap.py -python3 ./test.py -f import_merge/importTailPartOverlap.py -python3 ./test.py -f import_merge/importTail.py -python3 ./test.py -f import_merge/importToCommit.py -python3 ./test.py -f import_merge/importTORestart.py -python3 ./test.py -f import_merge/importTPORestart.py -python3 ./test.py -f import_merge/importTRestart.py -python3 ./test.py -f import_merge/importInsertThenImport.py -python3 ./test.py -f import_merge/importCSV.py \ No newline at end of file diff --git a/tests/pytest/pytest_2.sh b/tests/pytest/pytest_2.sh deleted file mode 100755 index d152ed85fb..0000000000 --- a/tests/pytest/pytest_2.sh +++ /dev/null @@ -1,16 +0,0 @@ - - -# update -python3 ./test.py -f update/allow_update.py -python3 ./test.py -f update/allow_update-0.py -python3 ./test.py -f update/append_commit_data.py -python3 ./test.py -f update/append_commit_last-0.py -python3 ./test.py -f update/append_commit_last.py -python3 ./test.py -f update/merge_commit_data.py - -python3 ./test.py -f update/merge_commit_data2.py -python3 ./test.py -f update/merge_commit_data2_update0.py -python3 ./test.py -f update/merge_commit_last-0.py -python3 ./test.py -f update/merge_commit_last.py -python3 ./test.py -f update/bug_td2279.py - diff --git a/tests/pytest/pytest_3.sh b/tests/pytest/pytest_3.sh deleted file mode 100755 index f2462154bc..0000000000 --- a/tests/pytest/pytest_3.sh +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -ulimit -c unlimited - - -python3 ./test.py -f insert/randomNullCommit.py - -# user -python3 ./test.py -f user/user_create.py -python3 ./test.py -f user/pass_len.py - -# stable -python3 ./test.py -f stable/query_after_reset.py - -#query -python3 ./test.py -f query/filter.py -python3 ./test.py -f query/filterCombo.py -python3 ./test.py -f query/queryNormal.py -python3 ./test.py -f query/queryError.py -python3 ./test.py -f query/filterAllIntTypes.py -python3 ./test.py -f query/filterFloatAndDouble.py -python3 ./test.py -f query/filterOtherTypes.py -python3 ./test.py -f query/querySort.py -python3 ./test.py -f query/queryJoin.py -python3 ./test.py -f query/select_last_crash.py -python3 ./test.py -f query/queryNullValueTest.py -python3 ./test.py -f query/queryInsertValue.py -python3 ./test.py -f query/queryConnection.py -python3 ./test.py -f query/queryCountCSVData.py -python3 ./test.py -f query/natualInterval.py -python3 ./test.py -f query/bug1471.py -#python3 ./test.py -f query/dataLossTest.py -python3 ./test.py -f query/bug1874.py -python3 ./test.py -f query/bug1875.py -python3 ./test.py -f query/bug1876.py -python3 ./test.py -f query/bug2218.py -python3 ./test.py -f query/bug2117.py -python3 ./test.py -f query/bug2118.py -python3 ./test.py -f query/bug2143.py -python3 ./test.py -f query/sliding.py -python3 ./test.py -f query/unionAllTest.py -python3 ./test.py -f query/bug2281.py -python3 ./test.py -f query/bug2119.py -python3 ./test.py -f query/isNullTest.py -python3 ./test.py -f query/queryWithTaosdKilled.py -python3 ./test.py -f query/floatCompare.py - -#stream -python3 ./test.py -f stream/metric_1.py -python3 ./test.py -f stream/metric_n.py -python3 ./test.py -f stream/new.py -python3 ./test.py -f stream/stream1.py -python3 ./test.py -f stream/stream2.py -#python3 ./test.py -f stream/parser.py -python3 ./test.py -f stream/history.py -python3 ./test.py -f stream/sys.py -python3 ./test.py -f stream/table_1.py -python3 ./test.py -f stream/table_n.py - -#alter table -python3 ./test.py -f alter/alter_table_crash.py - -# client -python3 ./test.py -f client/client.py -python3 ./test.py -f client/version.py -python3 ./test.py -f client/alterDatabase.py -python3 ./test.py -f client/noConnectionErrorTest.py - -# Misc -python3 testCompress.py -python3 testNoCompress.py -python3 testMinTablesPerVnode.py - - -python3 queryCount.py -python3 ./test.py -f query/queryGroupbyWithInterval.py -python3 client/twoClients.py -python3 test.py -f query/queryInterval.py -python3 test.py -f query/queryFillTest.py - -# tools -python3 test.py -f tools/lowaTest.py -python3 test.py -f tools/taosdemoTest.py -python3 test.py -f tools/taosdemoTestWithoutMetric.py -python3 test.py -f tools/taosdemoTestLimitOffset.py -python3 test.py -f tools/taosdumpTest.py -#python3 test.py -f tools/taosdemoTest2.py - -# subscribe -python3 test.py -f subscribe/singlemeter.py -#python3 test.py -f subscribe/stability.py -python3 test.py -f subscribe/supertable.py - diff --git a/tests/pytest/pytest_4.sh b/tests/pytest/pytest_4.sh deleted file mode 100755 index dada90c709..0000000000 --- a/tests/pytest/pytest_4.sh +++ /dev/null @@ -1,39 +0,0 @@ -python3 ./test.py -f update/merge_commit_data-0.py -# wal -python3 ./test.py -f wal/addOldWalTest.py - -# function -python3 ./test.py -f functions/all_null_value.py -# functions -python3 ./test.py -f functions/function_avg.py -r 1 -python3 ./test.py -f functions/function_bottom.py -r 1 -python3 ./test.py -f functions/function_count.py -r 1 -python3 ./test.py -f functions/function_diff.py -r 1 -python3 ./test.py -f functions/function_first.py -r 1 -python3 ./test.py -f functions/function_last.py -r 1 -python3 ./test.py -f functions/function_last_row.py -r 1 -python3 ./test.py -f functions/function_leastsquares.py -r 1 -python3 ./test.py -f functions/function_max.py -r 1 -python3 ./test.py -f functions/function_min.py -r 1 -python3 ./test.py -f functions/function_operations.py -r 1 -python3 ./test.py -f functions/function_percentile.py -r 1 -python3 ./test.py -f functions/function_spread.py -r 1 -python3 ./test.py -f functions/function_stddev.py -r 1 -python3 ./test.py -f functions/function_sum.py -r 1 -python3 ./test.py -f functions/function_top.py -r 1 -python3 ./test.py -f functions/function_twa.py -r 1 -python3 ./test.py -f functions/function_twa_test2.py -python3 ./test.py -f functions/function_stddev_td2555.py -python3 ./test.py -f insert/metadataUpdate.py -python3 ./test.py -f tools/taosdemoTest2.py -python3 ./test.py -f query/last_cache.py -python3 ./test.py -f query/last_row_cache.py -python3 ./test.py -f account/account_create.py -python3 ./test.py -f alter/alter_table.py -python3 ./test.py -f query/queryGroupbySort.py - -python3 ./test.py -f insert/unsignedInt.py -python3 ./test.py -f insert/unsignedBigint.py -python3 ./test.py -f insert/unsignedSmallint.py -python3 ./test.py -f insert/unsignedTinyint.py -python3 ./test.py -f query/filterAllUnsignedIntTypes.py \ No newline at end of file diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index fc56e34dca..d0bd7179e5 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -1,76 +1,7 @@ cd ../../../debug; cmake .. cd ../../../debug; make -./test.sh -f issue/TD-2677.sim -./test.sh -f issue/TD-2680.sim -./test.sh -f issue/TD-2713.sim - -./test.sh -f general/alter/cached_schema_after_alter.sim -./test.sh -f general/alter/count.sim -./test.sh -f general/alter/dnode.sim -./test.sh -f general/alter/import.sim -./test.sh -f general/alter/insert1.sim -./test.sh -f general/alter/insert2.sim -./test.sh -f general/alter/metrics.sim -./test.sh -f general/alter/table.sim - -./test.sh -f general/cache/new_metrics.sim -./test.sh -f general/cache/restart_metrics.sim -./test.sh -f general/cache/restart_table.sim - -./test.sh -f general/connection/connection.sim - -./test.sh -f general/column/commit.sim -./test.sh -f general/column/metrics.sim -./test.sh -f general/column/table.sim - -./test.sh -f general/compress/commitlog.sim -./test.sh -f general/compress/compress.sim -./test.sh -f general/compress/compress2.sim -./test.sh -f general/compress/uncompress.sim - -./test.sh -f general/compute/avg.sim -./test.sh -f general/compute/bottom.sim -./test.sh -f general/compute/count.sim -./test.sh -f general/compute/diff.sim -./test.sh -f general/compute/diff2.sim -./test.sh -f general/compute/first.sim -./test.sh -f general/compute/interval.sim -./test.sh -f general/compute/last.sim -./test.sh -f general/compute/leastsquare.sim -./test.sh -f general/compute/max.sim -./test.sh -f general/compute/min.sim -./test.sh -f general/compute/null.sim -./test.sh -f general/compute/percentile.sim -./test.sh -f general/compute/stddev.sim -./test.sh -f general/compute/sum.sim -./test.sh -f general/compute/top.sim - -./test.sh -f general/db/alter_option.sim -./test.sh -f general/db/alter_tables_d2.sim -./test.sh -f general/db/alter_tables_v1.sim -./test.sh -f general/db/alter_tables_v4.sim -./test.sh -f general/db/alter_vgroups.sim -./test.sh -f general/db/basic.sim -./test.sh -f general/db/basic1.sim -./test.sh -f general/db/basic2.sim -./test.sh -f general/db/basic3.sim -./test.sh -f general/db/basic4.sim -./test.sh -f general/db/basic5.sim -./test.sh -f general/db/delete_reuse1.sim -./test.sh -f general/db/delete_reuse2.sim -./test.sh -f general/db/delete_reusevnode.sim -./test.sh -f general/db/delete_reusevnode2.sim -./test.sh -f general/db/delete_writing1.sim -./test.sh -f general/db/delete_writing2.sim -./test.sh -f general/db/delete.sim -./test.sh -f general/db/len.sim -./test.sh -f general/db/repeat.sim -./test.sh -f general/db/tables.sim -./test.sh -f general/db/vnodes.sim -./test.sh -f general/db/topic1.sim -./test.sh -f general/db/topic2.sim -./test.sh -f general/db/nosuchfile.sim +#======================s1-start=============== ./test.sh -f general/field/2.sim ./test.sh -f general/field/3.sim @@ -96,11 +27,6 @@ cd ../../../debug; make ./test.sh -f general/http/grafana_bug.sim ./test.sh -f general/http/grafana.sim -./test.sh -f general/import/basic.sim -./test.sh -f general/import/commit.sim -./test.sh -f general/import/large.sim -./test.sh -f general/import/replica1.sim - ./test.sh -f general/insert/basic.sim ./test.sh -f general/insert/insert_drop.sim ./test.sh -f general/insert/query_block1_memory.sim @@ -160,8 +86,174 @@ cd ../../../debug; make ./test.sh -f general/parser/repeatAlter.sim ./test.sh -f general/parser/union.sim ./test.sh -f general/parser/topbot.sim +./test.sh -f general/db/nosuchfile.sim ./test.sh -f general/parser/function.sim -./test.sh -f general/parser/select_distinct_tag.sim + +#======================s1-end=============== +#======================s2-start=============== + +./test.sh -f general/tag/3.sim +./test.sh -f general/tag/4.sim +./test.sh -f general/tag/5.sim +./test.sh -f general/tag/6.sim +./test.sh -f general/tag/add.sim +./test.sh -f general/tag/bigint.sim +./test.sh -f general/tag/binary_binary.sim +./test.sh -f general/tag/binary.sim +./test.sh -f general/tag/bool_binary.sim +./test.sh -f general/tag/bool_int.sim +./test.sh -f general/tag/bool.sim +./test.sh -f general/tag/change.sim +./test.sh -f general/tag/column.sim +./test.sh -f general/tag/commit.sim +./test.sh -f general/tag/create.sim +./test.sh -f general/tag/delete.sim +./test.sh -f general/tag/double.sim +./test.sh -f general/tag/filter.sim +./test.sh -f general/tag/float.sim +./test.sh -f general/tag/int_binary.sim +./test.sh -f general/tag/int_float.sim +./test.sh -f general/tag/int.sim +./test.sh -f general/tag/set.sim +./test.sh -f general/tag/smallint.sim +./test.sh -f general/tag/tinyint.sim +./test.sh -f general/wal/sync.sim +./test.sh -f general/wal/kill.sim +./test.sh -f general/wal/maxtables.sim + +./test.sh -f general/user/authority.sim +./test.sh -f general/user/monitor.sim +./test.sh -f general/user/pass_alter.sim +./test.sh -f general/user/pass_len.sim +./test.sh -f general/user/user_create.sim +./test.sh -f general/user/user_len.sim + +./test.sh -f general/vector/metrics_field.sim +./test.sh -f general/vector/metrics_mix.sim +./test.sh -f general/vector/metrics_query.sim +./test.sh -f general/vector/metrics_tag.sim +./test.sh -f general/vector/metrics_time.sim +./test.sh -f general/vector/multi.sim +./test.sh -f general/vector/single.sim +./test.sh -f general/vector/table_field.sim +./test.sh -f general/vector/table_mix.sim +./test.sh -f general/vector/table_query.sim +./test.sh -f general/vector/table_time.sim + +./test.sh -f unique/account/account_create.sim +./test.sh -f unique/account/account_delete.sim +./test.sh -f unique/account/account_len.sim +./test.sh -f unique/account/authority.sim +./test.sh -f unique/account/basic.sim +./test.sh -f unique/account/paras.sim +./test.sh -f unique/account/pass_alter.sim +./test.sh -f unique/account/pass_len.sim +./test.sh -f unique/account/usage.sim +./test.sh -f unique/account/user_create.sim +./test.sh -f unique/account/user_len.sim + +./test.sh -f unique/big/balance.sim +./test.sh -f unique/big/maxvnodes.sim +./test.sh -f unique/big/tcp.sim + +./test.sh -f unique/cluster/alter.sim +./test.sh -f unique/cluster/balance1.sim +./test.sh -f unique/cluster/balance2.sim +./test.sh -f unique/cluster/balance3.sim +./test.sh -f unique/cluster/cache.sim +./test.sh -f unique/cluster/vgroup100.sim + +#======================s2-end=============== +#======================s3-start=============== + +./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim +#./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim +./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim +./test.sh -f unique/arbitrator/dn3_mn1_multiCreateDropTable.sim +#./test.sh -f unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim +#./test.sh -f unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim +./test.sh -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim +./test.sh -f unique/arbitrator/dn3_mn1_replica_change.sim +#./test.sh -f unique/arbitrator/dn3_mn1_stopDnode_timeout.sim +# lower the priority while file corruption +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_change.sim +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim +#./test.sh -f unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim +./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim +./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim +./test.sh -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim +./test.sh -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim +./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim +./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim + +./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim +./test.sh -f unique/arbitrator/offline_replica2_alterTag_online.sim +./test.sh -f unique/arbitrator/offline_replica2_createTable_online.sim +./test.sh -f unique/arbitrator/offline_replica2_dropDb_online.sim +./test.sh -f unique/arbitrator/offline_replica2_dropTable_online.sim +./test.sh -f unique/arbitrator/offline_replica3_alterTable_online.sim +./test.sh -f unique/arbitrator/offline_replica3_alterTag_online.sim +./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim +./test.sh -f unique/arbitrator/offline_replica3_dropDb_online.sim +./test.sh -f unique/arbitrator/offline_replica3_dropTable_online.sim +./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim +./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim +./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim + +./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim +./test.sh -f unique/arbitrator/sync_replica2_dropTable.sim +./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim +./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim +./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim +./test.sh -f unique/arbitrator/sync_replica3_dropTable.sim + +./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim +./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim +./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim +./test.sh -f unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim + +./test.sh -f unique/stable/balance_replica1.sim +./test.sh -f unique/stable/dnode2_stop.sim +./test.sh -f unique/stable/dnode2.sim +./test.sh -f unique/stable/dnode3.sim +./test.sh -f unique/stable/replica2_dnode4.sim +./test.sh -f unique/stable/replica2_vnode3.sim +./test.sh -f unique/stable/replica3_dnode6.sim +./test.sh -f unique/stable/replica3_vnode3.sim + +#======================s3-end=============== +#======================s4-start=============== + +./test.sh -f unique/http/admin.sim +./test.sh -f unique/http/opentsdb.sim + +./test.sh -f unique/import/replica2.sim +./test.sh -f unique/import/replica3.sim + +./test.sh -f general/alter/cached_schema_after_alter.sim +./test.sh -f general/alter/count.sim +./test.sh -f general/alter/dnode.sim +./test.sh -f general/alter/import.sim +./test.sh -f general/alter/insert1.sim +./test.sh -f general/alter/insert2.sim +./test.sh -f general/alter/metrics.sim +./test.sh -f general/alter/table.sim + +./test.sh -f general/cache/new_metrics.sim +./test.sh -f general/cache/restart_metrics.sim +./test.sh -f general/cache/restart_table.sim + +./test.sh -f general/connection/connection.sim + +./test.sh -f general/column/commit.sim +./test.sh -f general/column/metrics.sim +./test.sh -f general/column/table.sim + +./test.sh -f general/compress/commitlog.sim +./test.sh -f general/compress/compress.sim +./test.sh -f general/compress/compress2.sim +./test.sh -f general/compress/uncompress.sim ./test.sh -f general/stable/disk.sim ./test.sh -f general/stable/dnode3.sim @@ -171,6 +263,122 @@ cd ../../../debug; make ./test.sh -f general/stable/values.sim ./test.sh -f general/stable/vnode3.sim +./test.sh -f unique/column/replica3.sim +./test.sh -f issue/TD-2713.sim +./test.sh -f general/parser/select_distinct_tag.sim +./test.sh -f unique/mnode/mgmt30.sim +./test.sh -f issue/TD-2677.sim +./test.sh -f issue/TD-2680.sim +./test.sh -f unique/dnode/lossdata.sim + +#======================s4-end=============== +#======================s5-start=============== + +./test.sh -f unique/dnode/alternativeRole.sim +./test.sh -f unique/dnode/balance1.sim +./test.sh -f unique/dnode/balance2.sim +./test.sh -f unique/dnode/balance3.sim +./test.sh -f unique/dnode/balancex.sim +./test.sh -f unique/dnode/offline1.sim +./test.sh -f unique/dnode/offline2.sim + +./test.sh -f general/stream/metrics_del.sim +./test.sh -f general/stream/metrics_replica1_vnoden.sim +./test.sh -f general/stream/restart_stream.sim +./test.sh -f general/stream/stream_3.sim +./test.sh -f general/stream/stream_restart.sim +./test.sh -f general/stream/table_del.sim +./test.sh -f general/stream/table_replica1_vnoden.sim + +./test.sh -f general/connection/test_old_data.sim +./test.sh -f unique/dnode/datatrans_3node.sim +./test.sh -f unique/dnode/datatrans_3node_2.sim + +#======================s5-end=============== +#======================s6-start=============== + +./test.sh -f unique/dnode/reason.sim +./test.sh -f unique/dnode/remove1.sim +./test.sh -f unique/dnode/remove2.sim +./test.sh -f unique/dnode/vnode_clean.sim + +./test.sh -f unique/db/commit.sim +./test.sh -f unique/db/delete.sim +./test.sh -f unique/db/delete_part.sim +./test.sh -f unique/db/replica_add12.sim +./test.sh -f unique/db/replica_add13.sim +./test.sh -f unique/db/replica_add23.sim +./test.sh -f unique/db/replica_reduce21.sim +./test.sh -f unique/db/replica_reduce32.sim +./test.sh -f unique/db/replica_reduce31.sim +./test.sh -f unique/db/replica_part.sim + +./test.sh -f unique/vnode/many.sim +./test.sh -f unique/vnode/replica2_basic2.sim +./test.sh -f unique/vnode/replica2_repeat.sim +./test.sh -f unique/vnode/replica3_basic.sim +./test.sh -f unique/vnode/replica3_repeat.sim +./test.sh -f unique/vnode/replica3_vgroup.sim + +./test.sh -f unique/dnode/monitor.sim +./test.sh -f unique/dnode/monitor_bug.sim +./test.sh -f unique/dnode/simple.sim +./test.sh -f unique/dnode/data1.sim +./test.sh -f unique/dnode/m2.sim +./test.sh -f unique/dnode/m3.sim +./test.sh -f unique/dnode/offline3.sim +./test.sh -f general/wal/kill.sim +./test.sh -f general/wal/maxtables.sim + +./test.sh -f general/import/basic.sim +./test.sh -f general/import/commit.sim +./test.sh -f general/import/large.sim +./test.sh -f general/import/replica1.sim + +#======================s6-end=============== +#======================s7-start=============== + +./test.sh -f general/compute/avg.sim +./test.sh -f general/compute/bottom.sim +./test.sh -f general/compute/count.sim +./test.sh -f general/compute/diff.sim +./test.sh -f general/compute/diff2.sim +./test.sh -f general/compute/first.sim +./test.sh -f general/compute/interval.sim +./test.sh -f general/compute/last.sim +./test.sh -f general/compute/leastsquare.sim +./test.sh -f general/compute/max.sim +./test.sh -f general/compute/min.sim +./test.sh -f general/compute/null.sim +./test.sh -f general/compute/percentile.sim +./test.sh -f general/compute/stddev.sim +./test.sh -f general/compute/sum.sim +./test.sh -f general/compute/top.sim + +./test.sh -f general/db/alter_option.sim +./test.sh -f general/db/alter_tables_d2.sim +./test.sh -f general/db/alter_tables_v1.sim +./test.sh -f general/db/alter_tables_v4.sim +./test.sh -f general/db/alter_vgroups.sim +./test.sh -f general/db/basic.sim +./test.sh -f general/db/basic1.sim +./test.sh -f general/db/basic2.sim +./test.sh -f general/db/basic3.sim +./test.sh -f general/db/basic4.sim +./test.sh -f general/db/basic5.sim +./test.sh -f general/db/delete_reuse1.sim +./test.sh -f general/db/delete_reuse2.sim +./test.sh -f general/db/delete_reusevnode.sim +./test.sh -f general/db/delete_reusevnode2.sim +./test.sh -f general/db/delete_writing1.sim +./test.sh -f general/db/delete_writing2.sim +./test.sh -f general/db/delete.sim +./test.sh -f general/db/len.sim +./test.sh -f general/db/repeat.sim +./test.sh -f general/db/tables.sim +./test.sh -f general/db/vnodes.sim +./test.sh -f general/db/topic1.sim +./test.sh -f general/db/topic2.sim ./test.sh -f general/table/autocreate.sim ./test.sh -f general/table/basic1.sim ./test.sh -f general/table/basic2.sim @@ -200,126 +408,6 @@ cd ../../../debug; make ./test.sh -f general/table/vgroup.sim ./test.sh -f general/table/createmulti.sim -./test.sh -f general/tag/3.sim -./test.sh -f general/tag/4.sim -./test.sh -f general/tag/5.sim -./test.sh -f general/tag/6.sim -./test.sh -f general/tag/add.sim -./test.sh -f general/tag/bigint.sim -./test.sh -f general/tag/binary_binary.sim -./test.sh -f general/tag/binary.sim -./test.sh -f general/tag/bool_binary.sim -./test.sh -f general/tag/bool_int.sim -./test.sh -f general/tag/bool.sim -./test.sh -f general/tag/change.sim -./test.sh -f general/tag/column.sim -./test.sh -f general/tag/commit.sim -./test.sh -f general/tag/create.sim -./test.sh -f general/tag/delete.sim -./test.sh -f general/tag/double.sim -./test.sh -f general/tag/filter.sim -./test.sh -f general/tag/float.sim -./test.sh -f general/tag/int_binary.sim -./test.sh -f general/tag/int_float.sim -./test.sh -f general/tag/int.sim -./test.sh -f general/tag/set.sim -./test.sh -f general/tag/smallint.sim -./test.sh -f general/tag/tinyint.sim - -./test.sh -f general/user/authority.sim -./test.sh -f general/user/monitor.sim -./test.sh -f general/user/pass_alter.sim -./test.sh -f general/user/pass_len.sim -./test.sh -f general/user/user_create.sim -./test.sh -f general/user/user_len.sim - -./test.sh -f general/vector/metrics_field.sim -./test.sh -f general/vector/metrics_mix.sim -./test.sh -f general/vector/metrics_query.sim -./test.sh -f general/vector/metrics_tag.sim -./test.sh -f general/vector/metrics_time.sim -./test.sh -f general/vector/multi.sim -./test.sh -f general/vector/single.sim -./test.sh -f general/vector/table_field.sim -./test.sh -f general/vector/table_mix.sim -./test.sh -f general/vector/table_query.sim -./test.sh -f general/vector/table_time.sim - -./test.sh -f general/wal/sync.sim -./test.sh -f general/wal/kill.sim -./test.sh -f general/wal/maxtables.sim - -./test.sh -f unique/account/account_create.sim -./test.sh -f unique/account/account_delete.sim -./test.sh -f unique/account/account_len.sim -./test.sh -f unique/account/authority.sim -./test.sh -f unique/account/basic.sim -./test.sh -f unique/account/paras.sim -./test.sh -f unique/account/pass_alter.sim -./test.sh -f unique/account/pass_len.sim -./test.sh -f unique/account/usage.sim -./test.sh -f unique/account/user_create.sim -./test.sh -f unique/account/user_len.sim - -./test.sh -f unique/big/balance.sim -./test.sh -f unique/big/maxvnodes.sim -./test.sh -f unique/big/tcp.sim - -./test.sh -f unique/cluster/alter.sim -./test.sh -f unique/cluster/balance1.sim -./test.sh -f unique/cluster/balance2.sim -./test.sh -f unique/cluster/balance3.sim -./test.sh -f unique/cluster/cache.sim -./test.sh -f unique/cluster/vgroup100.sim - -./test.sh -f unique/column/replica3.sim - -./test.sh -f unique/db/commit.sim -./test.sh -f unique/db/delete.sim -./test.sh -f unique/db/delete_part.sim -./test.sh -f unique/db/replica_add12.sim -./test.sh -f unique/db/replica_add13.sim -./test.sh -f unique/db/replica_add23.sim -./test.sh -f unique/db/replica_reduce21.sim -./test.sh -f unique/db/replica_reduce32.sim -./test.sh -f unique/db/replica_reduce31.sim -./test.sh -f unique/db/replica_part.sim - -./test.sh -f unique/dnode/alternativeRole.sim -./test.sh -f unique/dnode/monitor.sim -./test.sh -f unique/dnode/monitor_bug.sim -./test.sh -f unique/dnode/simple.sim -./test.sh -f unique/dnode/balance1.sim -./test.sh -f unique/dnode/balance2.sim -./test.sh -f unique/dnode/balance3.sim -./test.sh -f unique/dnode/balancex.sim -./test.sh -f unique/dnode/data1.sim -./test.sh -f unique/dnode/m2.sim -./test.sh -f unique/dnode/m3.sim -./test.sh -f unique/dnode/lossdata.sim -./test.sh -f unique/dnode/offline1.sim -./test.sh -f unique/dnode/offline2.sim -./test.sh -f unique/dnode/offline3.sim -./test.sh -f unique/dnode/reason.sim -./test.sh -f unique/dnode/remove1.sim -./test.sh -f unique/dnode/remove2.sim -./test.sh -f unique/dnode/vnode_clean.sim - -./test.sh -f unique/http/admin.sim -./test.sh -f unique/http/opentsdb.sim - -./test.sh -f unique/import/replica2.sim -./test.sh -f unique/import/replica3.sim - -./test.sh -f unique/stable/balance_replica1.sim -./test.sh -f unique/stable/dnode2_stop.sim -./test.sh -f unique/stable/dnode2.sim -./test.sh -f unique/stable/dnode3.sim -./test.sh -f unique/stable/replica2_dnode4.sim -./test.sh -f unique/stable/replica2_vnode3.sim -./test.sh -f unique/stable/replica3_dnode6.sim -./test.sh -f unique/stable/replica3_vnode3.sim - ./test.sh -f unique/mnode/mgmt20.sim ./test.sh -f unique/mnode/mgmt21.sim ./test.sh -f unique/mnode/mgmt22.sim @@ -327,74 +415,10 @@ cd ../../../debug; make ./test.sh -f unique/mnode/mgmt24.sim ./test.sh -f unique/mnode/mgmt25.sim ./test.sh -f unique/mnode/mgmt26.sim -./test.sh -f unique/mnode/mgmt30.sim ./test.sh -f unique/mnode/mgmt33.sim ./test.sh -f unique/mnode/mgmt34.sim ./test.sh -f unique/mnode/mgmtr2.sim -./test.sh -f unique/vnode/many.sim -./test.sh -f unique/vnode/replica2_basic2.sim -./test.sh -f unique/vnode/replica2_repeat.sim -./test.sh -f unique/vnode/replica3_basic.sim -./test.sh -f unique/vnode/replica3_repeat.sim -./test.sh -f unique/vnode/replica3_vgroup.sim - -./test.sh -f general/stream/metrics_del.sim -./test.sh -f general/stream/metrics_replica1_vnoden.sim -./test.sh -f general/stream/restart_stream.sim -./test.sh -f general/stream/stream_3.sim -./test.sh -f general/stream/stream_restart.sim -./test.sh -f general/stream/table_del.sim -./test.sh -f general/stream/table_replica1_vnoden.sim - -./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim -#./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim -./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim -./test.sh -f unique/arbitrator/dn3_mn1_multiCreateDropTable.sim -#./test.sh -f unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim -#./test.sh -f unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim -./test.sh -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim -./test.sh -f unique/arbitrator/dn3_mn1_replica_change.sim -#./test.sh -f unique/arbitrator/dn3_mn1_stopDnode_timeout.sim -# lower the priority while file corruption -#./test.sh -f unique/arbitrator/dn3_mn1_vnode_change.sim -#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim -#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim -#./test.sh -f unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim -./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim -./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim -./test.sh -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim -./test.sh -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim -./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim -./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim ./test.sh -f unique/arbitrator/insert_duplicationTs.sim -./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim -./test.sh -f unique/arbitrator/offline_replica2_alterTag_online.sim -./test.sh -f unique/arbitrator/offline_replica2_createTable_online.sim -./test.sh -f unique/arbitrator/offline_replica2_dropDb_online.sim -./test.sh -f unique/arbitrator/offline_replica2_dropTable_online.sim -./test.sh -f unique/arbitrator/offline_replica3_alterTable_online.sim -./test.sh -f unique/arbitrator/offline_replica3_alterTag_online.sim -./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim -./test.sh -f unique/arbitrator/offline_replica3_dropDb_online.sim -./test.sh -f unique/arbitrator/offline_replica3_dropTable_online.sim -./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim -./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim -./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim - -./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim -./test.sh -f unique/arbitrator/sync_replica2_dropTable.sim -./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim -./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim -./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim -./test.sh -f unique/arbitrator/sync_replica3_dropTable.sim - -./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim -./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim -./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim -./test.sh -f unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim - -./test.sh -f general/connection/test_old_data.sim -./test.sh -f unique/dnode/datatrans_3node.sim -./test.sh -f unique/dnode/datatrans_3node_2.sim +#======================s7-end=============== diff --git a/tests/script/jenkins/basic_1.txt b/tests/script/jenkins/basic_1.txt deleted file mode 100644 index ae72e76b2f..0000000000 --- a/tests/script/jenkins/basic_1.txt +++ /dev/null @@ -1,85 +0,0 @@ -./test.sh -f general/field/2.sim -./test.sh -f general/field/3.sim -./test.sh -f general/field/4.sim -./test.sh -f general/field/5.sim -./test.sh -f general/field/6.sim -./test.sh -f general/field/bigint.sim -./test.sh -f general/field/binary.sim -./test.sh -f general/field/bool.sim -./test.sh -f general/field/single.sim -./test.sh -f general/field/smallint.sim -./test.sh -f general/field/tinyint.sim - -./test.sh -f general/http/autocreate.sim -./test.sh -f general/http/chunked.sim -./test.sh -f general/http/gzip.sim -./test.sh -f general/http/restful.sim -./test.sh -f general/http/restful_insert.sim -./test.sh -f general/http/restful_limit.sim -./test.sh -f general/http/restful_full.sim -./test.sh -f general/http/prepare.sim -./test.sh -f general/http/telegraf.sim -./test.sh -f general/http/grafana_bug.sim -./test.sh -f general/http/grafana.sim - -./test.sh -f general/insert/basic.sim -./test.sh -f general/insert/insert_drop.sim -./test.sh -f general/insert/query_block1_memory.sim -./test.sh -f general/insert/query_block2_memory.sim -./test.sh -f general/insert/query_block1_file.sim -./test.sh -f general/insert/query_block2_file.sim -./test.sh -f general/insert/query_file_memory.sim -./test.sh -f general/insert/query_multi_file.sim -./test.sh -f general/insert/tcp.sim - -./test.sh -f general/parser/alter.sim -./test.sh -f general/parser/alter1.sim -./test.sh -f general/parser/alter_stable.sim -./test.sh -f general/parser/auto_create_tb.sim -./test.sh -f general/parser/auto_create_tb_drop_tb.sim -./test.sh -f general/parser/col_arithmetic_operation.sim -./test.sh -f general/parser/columnValue.sim -./test.sh -f general/parser/commit.sim -./test.sh -f general/parser/create_db.sim -./test.sh -f general/parser/create_mt.sim -./test.sh -f general/parser/create_tb.sim -./test.sh -f general/parser/dbtbnameValidate.sim -./test.sh -f general/parser/import_commit1.sim -./test.sh -f general/parser/import_commit2.sim -./test.sh -f general/parser/import_commit3.sim -./test.sh -f general/parser/insert_tb.sim -./test.sh -f general/parser/first_last.sim -./test.sh -f general/parser/lastrow.sim -./test.sh -f general/parser/nchar.sim -./test.sh -f general/parser/null_char.sim -./test.sh -f general/parser/single_row_in_tb.sim -./test.sh -f general/parser/select_from_cache_disk.sim -./test.sh -f general/parser/mixed_blocks.sim -./test.sh -f general/parser/selectResNum.sim -./test.sh -f general/parser/limit.sim -./test.sh -f general/parser/limit1.sim -./test.sh -f general/parser/limit1_tblocks100.sim -./test.sh -f general/parser/select_across_vnodes.sim -./test.sh -f general/parser/slimit1.sim -./test.sh -f general/parser/tbnameIn.sim -./test.sh -f general/parser/projection_limit_offset.sim -./test.sh -f general/parser/limit2.sim -./test.sh -f general/parser/fill.sim -./test.sh -f general/parser/fill_stb.sim -./test.sh -f general/parser/where.sim -./test.sh -f general/parser/slimit.sim -./test.sh -f general/parser/select_with_tags.sim -./test.sh -f general/parser/interp.sim -./test.sh -f general/parser/tags_dynamically_specifiy.sim -./test.sh -f general/parser/groupby.sim -./test.sh -f general/parser/set_tag_vals.sim -./test.sh -f general/parser/tags_filter.sim -./test.sh -f general/parser/slimit_alter_tags.sim -./test.sh -f general/parser/join.sim -./test.sh -f general/parser/join_multivnode.sim -./test.sh -f general/parser/binary_escapeCharacter.sim -./test.sh -f general/parser/repeatAlter.sim -./test.sh -f general/parser/union.sim -./test.sh -f general/parser/topbot.sim -./test.sh -f general/db/nosuchfile.sim -./test.sh -f general/parser/function.sim \ No newline at end of file diff --git a/tests/script/jenkins/basic_2.txt b/tests/script/jenkins/basic_2.txt deleted file mode 100644 index 5a2a6f4062..0000000000 --- a/tests/script/jenkins/basic_2.txt +++ /dev/null @@ -1,74 +0,0 @@ -cd ../../../debug; cmake .. -cd ../../../debug; make - -./test.sh -f general/tag/3.sim -./test.sh -f general/tag/4.sim -./test.sh -f general/tag/5.sim -./test.sh -f general/tag/6.sim -./test.sh -f general/tag/add.sim -./test.sh -f general/tag/bigint.sim -./test.sh -f general/tag/binary_binary.sim -./test.sh -f general/tag/binary.sim -./test.sh -f general/tag/bool_binary.sim -./test.sh -f general/tag/bool_int.sim -./test.sh -f general/tag/bool.sim -./test.sh -f general/tag/change.sim -./test.sh -f general/tag/column.sim -./test.sh -f general/tag/commit.sim -./test.sh -f general/tag/create.sim -./test.sh -f general/tag/delete.sim -./test.sh -f general/tag/double.sim -./test.sh -f general/tag/filter.sim -./test.sh -f general/tag/float.sim -./test.sh -f general/tag/int_binary.sim -./test.sh -f general/tag/int_float.sim -./test.sh -f general/tag/int.sim -./test.sh -f general/tag/set.sim -./test.sh -f general/tag/smallint.sim -./test.sh -f general/tag/tinyint.sim -./test.sh -f general/wal/sync.sim -./test.sh -f general/wal/kill.sim -./test.sh -f general/wal/maxtables.sim - -./test.sh -f general/user/authority.sim -./test.sh -f general/user/monitor.sim -./test.sh -f general/user/pass_alter.sim -./test.sh -f general/user/pass_len.sim -./test.sh -f general/user/user_create.sim -./test.sh -f general/user/user_len.sim - -./test.sh -f general/vector/metrics_field.sim -./test.sh -f general/vector/metrics_mix.sim -./test.sh -f general/vector/metrics_query.sim -./test.sh -f general/vector/metrics_tag.sim -./test.sh -f general/vector/metrics_time.sim -./test.sh -f general/vector/multi.sim -./test.sh -f general/vector/single.sim -./test.sh -f general/vector/table_field.sim -./test.sh -f general/vector/table_mix.sim -./test.sh -f general/vector/table_query.sim -./test.sh -f general/vector/table_time.sim - -./test.sh -f unique/account/account_create.sim -./test.sh -f unique/account/account_delete.sim -./test.sh -f unique/account/account_len.sim -./test.sh -f unique/account/authority.sim -./test.sh -f unique/account/basic.sim -./test.sh -f unique/account/paras.sim -./test.sh -f unique/account/pass_alter.sim -./test.sh -f unique/account/pass_len.sim -./test.sh -f unique/account/usage.sim -./test.sh -f unique/account/user_create.sim -./test.sh -f unique/account/user_len.sim - -./test.sh -f unique/big/balance.sim -./test.sh -f unique/big/maxvnodes.sim -./test.sh -f unique/big/tcp.sim - -./test.sh -f unique/cluster/alter.sim -./test.sh -f unique/cluster/balance1.sim -./test.sh -f unique/cluster/balance2.sim -./test.sh -f unique/cluster/balance3.sim -./test.sh -f unique/cluster/cache.sim -./test.sh -f unique/cluster/vgroup100.sim - diff --git a/tests/script/jenkins/basic_3.txt b/tests/script/jenkins/basic_3.txt deleted file mode 100644 index f53b1b763a..0000000000 --- a/tests/script/jenkins/basic_3.txt +++ /dev/null @@ -1,58 +0,0 @@ - -./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim -#./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim -./test.sh -f unique/arbitrator/dn3_mn1_full_createTableFail.sim -./test.sh -f unique/arbitrator/dn3_mn1_multiCreateDropTable.sim -#./test.sh -f unique/arbitrator/dn3_mn1_nw_disable_timeout_autoDropDnode.sim -#./test.sh -f unique/arbitrator/dn3_mn1_replica2_wal1_AddDelDnode.sim -./test.sh -f unique/arbitrator/dn3_mn1_replica_change_dropDnod.sim -./test.sh -f unique/arbitrator/dn3_mn1_replica_change.sim -#./test.sh -f unique/arbitrator/dn3_mn1_stopDnode_timeout.sim -# lower the priority while file corruption -#./test.sh -f unique/arbitrator/dn3_mn1_vnode_change.sim -#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_offline.sim -#./test.sh -f unique/arbitrator/dn3_mn1_vnode_corruptFile_online.sim -#./test.sh -f unique/arbitrator/dn3_mn1_vnode_createErrData_online.sim -./test.sh -f unique/arbitrator/dn3_mn1_vnode_noCorruptFile_offline.sim -./test.sh -f unique/arbitrator/dn3_mn1_vnode_delDir.sim -./test.sh -f unique/arbitrator/dn3_mn1_r2_vnode_delDir.sim -./test.sh -f unique/arbitrator/dn3_mn1_r3_vnode_delDir.sim -./test.sh -f unique/arbitrator/dn3_mn1_vnode_nomaster.sim -./test.sh -f unique/arbitrator/dn3_mn2_killDnode.sim - -./test.sh -f unique/arbitrator/offline_replica2_alterTable_online.sim -./test.sh -f unique/arbitrator/offline_replica2_alterTag_online.sim -./test.sh -f unique/arbitrator/offline_replica2_createTable_online.sim -./test.sh -f unique/arbitrator/offline_replica2_dropDb_online.sim -./test.sh -f unique/arbitrator/offline_replica2_dropTable_online.sim -./test.sh -f unique/arbitrator/offline_replica3_alterTable_online.sim -./test.sh -f unique/arbitrator/offline_replica3_alterTag_online.sim -./test.sh -f unique/arbitrator/offline_replica3_createTable_online.sim -./test.sh -f unique/arbitrator/offline_replica3_dropDb_online.sim -./test.sh -f unique/arbitrator/offline_replica3_dropTable_online.sim -./test.sh -f unique/arbitrator/replica_changeWithArbitrator.sim -./test.sh -f unique/arbitrator/sync_replica2_alterTable_add.sim -./test.sh -f unique/arbitrator/sync_replica2_alterTable_drop.sim - -./test.sh -f unique/arbitrator/sync_replica2_dropDb.sim -./test.sh -f unique/arbitrator/sync_replica2_dropTable.sim -./test.sh -f unique/arbitrator/sync_replica3_alterTable_add.sim -./test.sh -f unique/arbitrator/sync_replica3_alterTable_drop.sim -./test.sh -f unique/arbitrator/sync_replica3_dropDb.sim -./test.sh -f unique/arbitrator/sync_replica3_dropTable.sim - -./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeDir.sim -./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir.sim -./test.sh -f unique/migrate/mn2_vn2_repl2_rmMnodeVnodeDir_stopAll_starAll.sim -./test.sh -f unique/migrate/mn2_vn2_repl2_rmVnodeDir.sim - -./test.sh -f unique/stable/balance_replica1.sim -./test.sh -f unique/stable/dnode2_stop.sim -./test.sh -f unique/stable/dnode2.sim -./test.sh -f unique/stable/dnode3.sim -./test.sh -f unique/stable/replica2_dnode4.sim -./test.sh -f unique/stable/replica2_vnode3.sim -./test.sh -f unique/stable/replica3_dnode6.sim -./test.sh -f unique/stable/replica3_vnode3.sim - - diff --git a/tests/script/jenkins/basic_4.txt b/tests/script/jenkins/basic_4.txt deleted file mode 100644 index 5a7d23df71..0000000000 --- a/tests/script/jenkins/basic_4.txt +++ /dev/null @@ -1,46 +0,0 @@ - -./test.sh -f unique/http/admin.sim -./test.sh -f unique/http/opentsdb.sim - -./test.sh -f unique/import/replica2.sim -./test.sh -f unique/import/replica3.sim - -./test.sh -f general/alter/cached_schema_after_alter.sim -./test.sh -f general/alter/count.sim -./test.sh -f general/alter/dnode.sim -./test.sh -f general/alter/import.sim -./test.sh -f general/alter/insert1.sim -./test.sh -f general/alter/insert2.sim -./test.sh -f general/alter/metrics.sim -./test.sh -f general/alter/table.sim - -./test.sh -f general/cache/new_metrics.sim -./test.sh -f general/cache/restart_metrics.sim -./test.sh -f general/cache/restart_table.sim - -./test.sh -f general/connection/connection.sim - -./test.sh -f general/column/commit.sim -./test.sh -f general/column/metrics.sim -./test.sh -f general/column/table.sim - -./test.sh -f general/compress/commitlog.sim -./test.sh -f general/compress/compress.sim -./test.sh -f general/compress/compress2.sim -./test.sh -f general/compress/uncompress.sim - -./test.sh -f general/stable/disk.sim -./test.sh -f general/stable/dnode3.sim -./test.sh -f general/stable/metrics.sim -./test.sh -f general/stable/refcount.sim -./test.sh -f general/stable/show.sim -./test.sh -f general/stable/values.sim -./test.sh -f general/stable/vnode3.sim - -./test.sh -f unique/column/replica3.sim -./test.sh -f issue/TD-2713.sim -./test.sh -f general/parser/select_distinct_tag.sim -./test.sh -f unique/mnode/mgmt30.sim -./test.sh -f issue/TD-2677.sim -./test.sh -f issue/TD-2680.sim -./test.sh -f unique/dnode/lossdata.sim \ No newline at end of file diff --git a/tests/script/jenkins/basic_5.txt b/tests/script/jenkins/basic_5.txt deleted file mode 100644 index f89be9499e..0000000000 --- a/tests/script/jenkins/basic_5.txt +++ /dev/null @@ -1,19 +0,0 @@ -./test.sh -f unique/dnode/alternativeRole.sim -./test.sh -f unique/dnode/balance1.sim -./test.sh -f unique/dnode/balance2.sim -./test.sh -f unique/dnode/balance3.sim -./test.sh -f unique/dnode/balancex.sim -./test.sh -f unique/dnode/offline1.sim -./test.sh -f unique/dnode/offline2.sim - -./test.sh -f general/stream/metrics_del.sim -./test.sh -f general/stream/metrics_replica1_vnoden.sim -./test.sh -f general/stream/restart_stream.sim -./test.sh -f general/stream/stream_3.sim -./test.sh -f general/stream/stream_restart.sim -./test.sh -f general/stream/table_del.sim -./test.sh -f general/stream/table_replica1_vnoden.sim - -./test.sh -f general/connection/test_old_data.sim -./test.sh -f unique/dnode/datatrans_3node.sim -./test.sh -f unique/dnode/datatrans_3node_2.sim \ No newline at end of file diff --git a/tests/script/jenkins/basic_6.txt b/tests/script/jenkins/basic_6.txt deleted file mode 100644 index 9156360a9f..0000000000 --- a/tests/script/jenkins/basic_6.txt +++ /dev/null @@ -1,37 +0,0 @@ -./test.sh -f unique/dnode/reason.sim -./test.sh -f unique/dnode/remove1.sim -./test.sh -f unique/dnode/remove2.sim -./test.sh -f unique/dnode/vnode_clean.sim - -./test.sh -f unique/db/commit.sim -./test.sh -f unique/db/delete.sim -./test.sh -f unique/db/delete_part.sim -./test.sh -f unique/db/replica_add12.sim -./test.sh -f unique/db/replica_add13.sim -./test.sh -f unique/db/replica_add23.sim -./test.sh -f unique/db/replica_reduce21.sim -./test.sh -f unique/db/replica_reduce32.sim -./test.sh -f unique/db/replica_reduce31.sim -./test.sh -f unique/db/replica_part.sim - -./test.sh -f unique/vnode/many.sim -./test.sh -f unique/vnode/replica2_basic2.sim -./test.sh -f unique/vnode/replica2_repeat.sim -./test.sh -f unique/vnode/replica3_basic.sim -./test.sh -f unique/vnode/replica3_repeat.sim -./test.sh -f unique/vnode/replica3_vgroup.sim - -./test.sh -f unique/dnode/monitor.sim -./test.sh -f unique/dnode/monitor_bug.sim -./test.sh -f unique/dnode/simple.sim -./test.sh -f unique/dnode/data1.sim -./test.sh -f unique/dnode/m2.sim -./test.sh -f unique/dnode/m3.sim -./test.sh -f unique/dnode/offline3.sim -./test.sh -f general/wal/kill.sim -./test.sh -f general/wal/maxtables.sim - -./test.sh -f general/import/basic.sim -./test.sh -f general/import/commit.sim -./test.sh -f general/import/large.sim -./test.sh -f general/import/replica1.sim \ No newline at end of file diff --git a/tests/script/jenkins/basic_7.txt b/tests/script/jenkins/basic_7.txt deleted file mode 100644 index d951e0a48d..0000000000 --- a/tests/script/jenkins/basic_7.txt +++ /dev/null @@ -1,83 +0,0 @@ - -./test.sh -f general/compute/avg.sim -./test.sh -f general/compute/bottom.sim -./test.sh -f general/compute/count.sim -./test.sh -f general/compute/diff.sim -./test.sh -f general/compute/diff2.sim -./test.sh -f general/compute/first.sim -./test.sh -f general/compute/interval.sim -./test.sh -f general/compute/last.sim -./test.sh -f general/compute/leastsquare.sim -./test.sh -f general/compute/max.sim -./test.sh -f general/compute/min.sim -./test.sh -f general/compute/null.sim -./test.sh -f general/compute/percentile.sim -./test.sh -f general/compute/stddev.sim -./test.sh -f general/compute/sum.sim -./test.sh -f general/compute/top.sim - -./test.sh -f general/db/alter_option.sim -./test.sh -f general/db/alter_tables_d2.sim -./test.sh -f general/db/alter_tables_v1.sim -./test.sh -f general/db/alter_tables_v4.sim -./test.sh -f general/db/alter_vgroups.sim -./test.sh -f general/db/basic.sim -./test.sh -f general/db/basic1.sim -./test.sh -f general/db/basic2.sim -./test.sh -f general/db/basic3.sim -./test.sh -f general/db/basic4.sim -./test.sh -f general/db/basic5.sim -./test.sh -f general/db/delete_reuse1.sim -./test.sh -f general/db/delete_reuse2.sim -./test.sh -f general/db/delete_reusevnode.sim -./test.sh -f general/db/delete_reusevnode2.sim -./test.sh -f general/db/delete_writing1.sim -./test.sh -f general/db/delete_writing2.sim -./test.sh -f general/db/delete.sim -./test.sh -f general/db/len.sim -./test.sh -f general/db/repeat.sim -./test.sh -f general/db/tables.sim -./test.sh -f general/db/vnodes.sim -./test.sh -f general/db/topic1.sim -./test.sh -f general/db/topic2.sim -./test.sh -f general/table/autocreate.sim -./test.sh -f general/table/basic1.sim -./test.sh -f general/table/basic2.sim -./test.sh -f general/table/basic3.sim -./test.sh -f general/table/bigint.sim -./test.sh -f general/table/binary.sim -./test.sh -f general/table/bool.sim -./test.sh -f general/table/column_name.sim -./test.sh -f general/table/column_num.sim -./test.sh -f general/table/column_value.sim -./test.sh -f general/table/column2.sim -./test.sh -f general/table/date.sim -./test.sh -f general/table/db.table.sim -./test.sh -f general/table/delete_reuse1.sim -./test.sh -f general/table/delete_reuse2.sim -./test.sh -f general/table/delete_writing.sim -./test.sh -f general/table/describe.sim -./test.sh -f general/table/double.sim -./test.sh -f general/table/fill.sim -./test.sh -f general/table/float.sim -./test.sh -f general/table/int.sim -./test.sh -f general/table/limit.sim -./test.sh -f general/table/smallint.sim -./test.sh -f general/table/table_len.sim -./test.sh -f general/table/table.sim -./test.sh -f general/table/tinyint.sim -./test.sh -f general/table/vgroup.sim -./test.sh -f general/table/createmulti.sim - -./test.sh -f unique/mnode/mgmt20.sim -./test.sh -f unique/mnode/mgmt21.sim -./test.sh -f unique/mnode/mgmt22.sim -./test.sh -f unique/mnode/mgmt23.sim -./test.sh -f unique/mnode/mgmt24.sim -./test.sh -f unique/mnode/mgmt25.sim -./test.sh -f unique/mnode/mgmt26.sim -./test.sh -f unique/mnode/mgmt33.sim -./test.sh -f unique/mnode/mgmt34.sim -./test.sh -f unique/mnode/mgmtr2.sim - -./test.sh -f unique/arbitrator/insert_duplicationTs.sim \ No newline at end of file diff --git a/tests/test-all.sh b/tests/test-all.sh index db9d6523a0..75ec2bc563 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -31,6 +31,7 @@ function dohavecore(){ fi fi } + function runSimCaseOneByOne { while read -r line; do if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then @@ -61,7 +62,11 @@ function runSimCaseOneByOne { done < $1 } function runSimCaseOneByOnefq { - while read -r line; do + + start=`sed -n "/$1-start/=" jenkins/basic.txt` + end=`sed -n "/$1-end/=" jenkins/basic.txt` + for ((i=$start;i<=$end;i++)) ; do + line=`sed -n "$i"p jenkins/basic.txt` if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then case=`echo $line | grep sim$ |awk '{print $NF}'` @@ -92,9 +97,9 @@ function runSimCaseOneByOnefq { fi end_time=`date +%s` echo execution time of $case was `expr $end_time - $start_time`s. | tee -a out.log - dohavecore 1 + dohavecore $2 fi - done < $1 + done } function runPyCaseOneByOne { @@ -126,8 +131,17 @@ function runPyCaseOneByOne { fi done < $1 } -function runPyCaseOneByOnefq { - while read -r line; do +function runPyCaseOneByOnefq() { + cd $tests_dir/pytest + if [[ $1 =~ full ]] ; then + start=1 + end=`sed -n '$=' fulltest.sh` + else + start=`sed -n "/$1-start/=" fulltest.sh` + end=`sed -n "/$1-end/=" fulltest.sh` + fi + for ((i=$start;i<=$end;i++)) ; do + line=`sed -n "$i"p fulltest.sh` if [[ $line =~ ^python.* ]]; then if [[ $line != *sleep* ]]; then @@ -152,9 +166,9 @@ function runPyCaseOneByOnefq { else $line > /dev/null 2>&1 fi - dohavecore 1 + dohavecore $2 fi - done < $1 + done } totalFailed=0 @@ -176,38 +190,38 @@ if [ "$2" != "jdbc" ] && [ "$2" != "python" ] && [ "$2" != "unit" ]; then runSimCaseOneByOne jenkins/basic.txt elif [ "$1" == "b1" ]; then echo "### run TSIM b1 test ###" - runSimCaseOneByOne jenkins/basic_1.txt - runSimCaseOneByOne jenkins/basic_4.txt - runSimCaseOneByOne jenkins/basic_5.txt - runSimCaseOneByOne jenkins/basic_6.txt - runSimCaseOneByOne jenkins/basic_7.txt + runSimCaseOneByOnefq b1 0 + runSimCaseOneByOnefq b4 0 + runSimCaseOneByOnefq b5 0 + runSimCaseOneByOnefq b6 0 + runSimCaseOneByOnefq b7 0 elif [ "$1" == "b2" ]; then echo "### run TSIM b2 test ###" - runSimCaseOneByOne jenkins/basic_2.txt + runSimCaseOneByOnefq b2 0 elif [ "$1" == "b3" ]; then echo "### run TSIM b3 test ###" - runSimCaseOneByOne jenkins/basic_3.txt + runSimCaseOneByOnefq b3 0 elif [ "$1" == "b1fq" ]; then echo "### run TSIM b1 test ###" - runSimCaseOneByOnefq jenkins/basic_1.txt + runSimCaseOneByOnefq b1 1 elif [ "$1" == "b2fq" ]; then echo "### run TSIM b2 test ###" - runSimCaseOneByOnefq jenkins/basic_2.txt + runSimCaseOneByOnefq b2 1 elif [ "$1" == "b3fq" ]; then echo "### run TSIM b3 test ###" - runSimCaseOneByOnefq jenkins/basic_3.txt + runSimCaseOneByOnefq b3 1 elif [ "$1" == "b4fq" ]; then echo "### run TSIM b4 test ###" - runSimCaseOneByOnefq jenkins/basic_4.txt + runSimCaseOneByOnefq b4 1 elif [ "$1" == "b5fq" ]; then echo "### run TSIM b5 test ###" - runSimCaseOneByOnefq jenkins/basic_5.txt + runSimCaseOneByOnefq b5 1 elif [ "$1" == "b6fq" ]; then echo "### run TSIM b6 test ###" - runSimCaseOneByOnefq jenkins/basic_6.txt + runSimCaseOneByOnefq b6 1 elif [ "$1" == "b7fq" ]; then echo "### run TSIM b7 test ###" - runSimCaseOneByOnefq jenkins/basic_7.txt + runSimCaseOneByOnefq b7 1 elif [ "$1" == "smoke" ] || [ -z "$1" ]; then echo "### run TSIM smoke test ###" runSimCaseOneByOne basicSuite.sim @@ -268,19 +282,19 @@ if [ "$2" != "sim" ] && [ "$2" != "jdbc" ] && [ "$2" != "unit" ]; then runPyCaseOneByOne fulltest.sh elif [ "$1" == "pytestfq" ]; then echo "### run Python full test ###" - runPyCaseOneByOnefq fulltest.sh + runPyCaseOneByOnefq full 0 elif [ "$1" == "p1" ]; then echo "### run Python_1 test ###" - runPyCaseOneByOnefq pytest_1.sh + runPyCaseOneByOnefq p1 1 elif [ "$1" == "p2" ]; then echo "### run Python_2 test ###" - runPyCaseOneByOnefq pytest_2.sh + runPyCaseOneByOnefq p2 1 elif [ "$1" == "p3" ]; then echo "### run Python_3 test ###" - runPyCaseOneByOnefq pytest_3.sh + runPyCaseOneByOnefq p3 1 elif [ "$1" == "p4" ]; then echo "### run Python_4 test ###" - runPyCaseOneByOnefq pytest_4.sh + runPyCaseOneByOnefq p4 1 elif [ "$1" == "b2" ] || [ "$1" == "b3" ]; then exit $(($totalFailed + $totalPyFailed)) elif [ "$1" == "smoke" ] || [ -z "$1" ]; then From 4c64997447fe45210b00e5ef50ca28f4d8f03771 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 17 Mar 2021 13:02:51 +0800 Subject: [PATCH 41/89] add case --- tests/pytest/fulltest.sh | 1 + tests/script/jenkins/basic.txt | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 506d469b2f..84a52d81a9 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -294,5 +294,6 @@ python3 ./test.py -f query/queryFillTest.py python3 ./test.py -f alter/alter_debugFlag.py python3 ./test.py -f query/queryBetweenAnd.py python3 ./test.py -f tag_lite/alter_tag.py +python3 test.py -f tools/taosdemoTestSampleData.py #======================p4-end=============== \ No newline at end of file diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index d0bd7179e5..33489b50ff 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -420,5 +420,9 @@ cd ../../../debug; make ./test.sh -f unique/mnode/mgmtr2.sim ./test.sh -f unique/arbitrator/insert_duplicationTs.sim +./test.sh -f general/parser/join_manyblocks.sim +./test.sh -f general/parser/stableOp.sim +./test.sh -f general/parser/timestamp.sim +./test.sh -f general/parser/sliding.sim #======================s7-end=============== From 8286820a1cd75b7fb627767d1aa759740271adab Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 17 Mar 2021 13:15:09 +0800 Subject: [PATCH 42/89] [td-225]remove unused keywords. --- src/inc/ttokendef.h | 12 +- src/query/inc/sql.y | 4 +- src/query/src/qTokenizer.c | 2 - src/query/src/sql.c | 1604 ++++++++++----------- tests/script/general/parser/create_mt.sim | 6 +- tests/script/general/parser/create_tb.sim | 8 +- 6 files changed, 811 insertions(+), 825 deletions(-) diff --git a/src/inc/ttokendef.h b/src/inc/ttokendef.h index 31e38c1b50..91c08fa26a 100644 --- a/src/inc/ttokendef.h +++ b/src/inc/ttokendef.h @@ -197,13 +197,11 @@ #define TK_PREV 178 #define TK_LINEAR 179 #define TK_IMPORT 180 -#define TK_METRIC 181 -#define TK_TBNAME 182 -#define TK_JOIN 183 -#define TK_METRICS 184 -#define TK_INSERT 185 -#define TK_INTO 186 -#define TK_VALUES 187 +#define TK_TBNAME 181 +#define TK_JOIN 182 +#define TK_INSERT 183 +#define TK_INTO 184 +#define TK_VALUES 185 #define TK_SPACE 300 diff --git a/src/query/inc/sql.y b/src/query/inc/sql.y index 7d704e03b4..7f6aa1ca5f 100644 --- a/src/query/inc/sql.y +++ b/src/query/inc/sql.y @@ -838,6 +838,4 @@ cmd ::= KILL QUERY INTEGER(X) COLON(Z) INTEGER(Y). {X.n += (Z.n + Y.n); s %fallback ID ABORT AFTER ASC ATTACH BEFORE BEGIN CASCADE CLUSTER CONFLICT COPY DATABASE DEFERRED DELIMITERS DESC DETACH EACH END EXPLAIN FAIL FOR GLOB IGNORE IMMEDIATE INITIALLY INSTEAD LIKE MATCH KEY OF OFFSET RAISE REPLACE RESTRICT ROW STATEMENT TRIGGER VIEW ALL - NOW IPTOKEN SEMI NONE PREV LINEAR IMPORT - METRIC TBNAME JOIN METRICS STABLE NULL INSERT INTO VALUES. - \ No newline at end of file + NOW IPTOKEN SEMI NONE PREV LINEAR IMPORT TBNAME JOIN STABLE NULL INSERT INTO VALUES. \ No newline at end of file diff --git a/src/query/src/qTokenizer.c b/src/query/src/qTokenizer.c index 63ec2bd342..013eaaf2a9 100644 --- a/src/query/src/qTokenizer.c +++ b/src/query/src/qTokenizer.c @@ -206,10 +206,8 @@ static SKeyword keywordTable[] = { {"PREV", TK_PREV}, {"LINEAR", TK_LINEAR}, {"IMPORT", TK_IMPORT}, - {"METRIC", TK_METRIC}, {"TBNAME", TK_TBNAME}, {"JOIN", TK_JOIN}, - {"METRICS", TK_METRICS}, {"STABLE", TK_STABLE}, {"FILE", TK_FILE}, {"VNODES", TK_VNODES}, diff --git a/src/query/src/sql.c b/src/query/src/sql.c index 1aafe75c32..98304d636f 100644 --- a/src/query/src/sql.c +++ b/src/query/src/sql.c @@ -97,28 +97,28 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 265 +#define YYNOCODE 263 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SStrToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SCreatedTableInfo yy96; - SFromInfo* yy162; - tSqlExpr* yy178; - SCreateAcctInfo yy187; - SArray* yy285; - TAOS_FIELD yy295; - SQuerySqlNode* yy342; - tVariant yy362; - SIntervalVal yy376; - SLimitVal yy438; - int yy460; - SCreateTableSql* yy470; - SSubclauseInfo* yy513; - SSessionWindowVal yy523; - int64_t yy525; - SCreateDbInfo yy526; + SLimitVal yy18; + SFromInfo* yy70; + SSessionWindowVal yy87; + SCreateDbInfo yy94; + int yy116; + SSubclauseInfo* yy141; + tSqlExpr* yy170; + SCreateTableSql* yy194; + tVariant yy218; + SIntervalVal yy220; + SCreatedTableInfo yy252; + SQuerySqlNode* yy254; + SCreateAcctInfo yy419; + SArray* yy429; + TAOS_FIELD yy451; + int64_t yy481; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -130,7 +130,7 @@ typedef union { #define YYFALLBACK 1 #define YYNSTATE 313 #define YYNRULE 265 -#define YYNTOKEN 188 +#define YYNTOKEN 186 #define YY_MAX_SHIFT 312 #define YY_MIN_SHIFTREDUCE 502 #define YY_MAX_SHIFTREDUCE 766 @@ -217,152 +217,152 @@ static const YYACTIONTYPE yy_action[] = { /* 80 */ 57, 54, 969, 550, 255, 220, 46, 45, 276, 916, /* 90 */ 44, 43, 42, 503, 504, 505, 506, 507, 508, 509, /* 100 */ 510, 511, 512, 513, 514, 515, 311, 628, 84, 230, - /* 110 */ 69, 916, 296, 47, 48, 30, 51, 52, 1013, 30, - /* 120 */ 213, 41, 549, 50, 260, 55, 53, 57, 54, 1012, + /* 110 */ 69, 916, 1013, 47, 48, 30, 51, 52, 296, 30, + /* 120 */ 213, 41, 549, 50, 260, 55, 53, 57, 54, 64, /* 130 */ 550, 306, 714, 46, 45, 286, 285, 44, 43, 42, - /* 140 */ 47, 49, 904, 51, 52, 224, 1011, 213, 41, 667, + /* 140 */ 47, 49, 904, 51, 52, 224, 1012, 213, 41, 65, /* 150 */ 50, 260, 55, 53, 57, 54, 216, 916, 902, 913, /* 160 */ 46, 45, 222, 912, 44, 43, 42, 23, 274, 305, /* 170 */ 304, 273, 272, 271, 303, 270, 302, 301, 300, 269, /* 180 */ 299, 298, 876, 139, 864, 865, 866, 867, 868, 869, /* 190 */ 870, 871, 872, 873, 874, 875, 877, 878, 51, 52, - /* 200 */ 815, 197, 213, 41, 165, 50, 260, 55, 53, 57, - /* 210 */ 54, 198, 18, 81, 226, 46, 45, 283, 282, 44, - /* 220 */ 43, 42, 212, 727, 928, 25, 718, 671, 721, 189, + /* 200 */ 815, 139, 213, 41, 165, 50, 260, 55, 53, 57, + /* 210 */ 54, 1011, 18, 81, 226, 46, 45, 283, 282, 44, + /* 220 */ 43, 42, 212, 727, 928, 25, 718, 68, 721, 189, /* 230 */ 724, 223, 212, 727, 278, 190, 718, 276, 721, 203, /* 240 */ 724, 117, 116, 188, 899, 900, 29, 903, 257, 233, - /* 250 */ 77, 44, 43, 42, 209, 210, 237, 236, 259, 139, - /* 260 */ 23, 104, 305, 304, 209, 210, 296, 303, 79, 302, - /* 270 */ 301, 300, 73, 299, 298, 884, 132, 30, 882, 883, - /* 280 */ 36, 70, 225, 885, 824, 887, 888, 886, 165, 889, - /* 290 */ 890, 55, 53, 57, 54, 182, 309, 308, 125, 46, - /* 300 */ 45, 1026, 239, 44, 43, 42, 102, 107, 30, 196, - /* 310 */ 261, 73, 96, 106, 112, 115, 105, 914, 217, 36, - /* 320 */ 674, 913, 109, 5, 155, 56, 78, 30, 243, 33, - /* 330 */ 154, 91, 86, 90, 30, 56, 173, 169, 726, 245, - /* 340 */ 30, 68, 171, 168, 120, 119, 118, 12, 726, 279, - /* 350 */ 183, 83, 913, 80, 725, 28, 46, 45, 266, 816, - /* 360 */ 44, 43, 42, 165, 725, 1, 153, 652, 280, 716, - /* 370 */ 649, 913, 650, 901, 651, 284, 695, 696, 913, 664, - /* 380 */ 720, 288, 723, 241, 913, 680, 24, 31, 686, 134, - /* 390 */ 687, 747, 60, 728, 20, 19, 211, 19, 227, 228, - /* 400 */ 719, 61, 722, 185, 638, 717, 730, 64, 31, 263, - /* 410 */ 640, 265, 639, 31, 60, 82, 60, 179, 95, 94, - /* 420 */ 186, 14, 13, 62, 101, 100, 67, 65, 627, 187, - /* 430 */ 16, 15, 656, 654, 657, 655, 114, 113, 130, 128, - /* 440 */ 6, 193, 194, 192, 177, 191, 181, 915, 979, 131, - /* 450 */ 978, 214, 975, 974, 215, 287, 936, 39, 961, 944, - /* 460 */ 946, 133, 960, 929, 244, 137, 129, 150, 911, 149, - /* 470 */ 242, 909, 679, 246, 151, 204, 653, 247, 258, 256, - /* 480 */ 66, 152, 827, 268, 63, 926, 37, 140, 175, 34, - /* 490 */ 248, 253, 277, 823, 1031, 92, 58, 141, 254, 142, - /* 500 */ 1030, 1028, 156, 281, 1025, 98, 1024, 1022, 157, 845, - /* 510 */ 35, 32, 38, 176, 252, 144, 812, 108, 810, 110, - /* 520 */ 111, 808, 807, 229, 167, 805, 804, 803, 250, 802, - /* 530 */ 801, 800, 170, 172, 797, 795, 793, 791, 789, 174, - /* 540 */ 40, 71, 74, 249, 962, 297, 103, 289, 290, 291, - /* 550 */ 292, 293, 294, 295, 307, 199, 766, 221, 231, 232, - /* 560 */ 267, 765, 234, 235, 764, 752, 200, 195, 238, 87, - /* 570 */ 88, 243, 75, 8, 262, 659, 72, 806, 681, 121, - /* 580 */ 206, 135, 122, 799, 160, 123, 159, 846, 158, 161, - /* 590 */ 162, 164, 163, 798, 684, 124, 880, 790, 2, 136, - /* 600 */ 4, 145, 143, 146, 147, 76, 148, 251, 892, 688, - /* 610 */ 138, 26, 264, 729, 9, 10, 27, 7, 11, 21, - /* 620 */ 731, 22, 85, 591, 83, 587, 585, 584, 583, 580, - /* 630 */ 553, 275, 93, 89, 31, 59, 630, 97, 99, 629, + /* 250 */ 77, 44, 43, 42, 209, 210, 237, 236, 259, 901, + /* 260 */ 23, 197, 305, 304, 209, 210, 225, 303, 78, 302, + /* 270 */ 301, 300, 73, 299, 298, 884, 104, 30, 882, 883, + /* 280 */ 36, 296, 720, 885, 723, 887, 888, 886, 667, 889, + /* 290 */ 890, 55, 53, 57, 54, 132, 309, 308, 125, 46, + /* 300 */ 45, 914, 239, 44, 43, 42, 102, 107, 30, 196, + /* 310 */ 664, 73, 96, 106, 112, 115, 105, 24, 217, 36, + /* 320 */ 674, 913, 109, 5, 155, 56, 261, 79, 243, 33, + /* 330 */ 154, 91, 86, 90, 30, 56, 173, 169, 726, 30, + /* 340 */ 70, 30, 171, 168, 120, 119, 118, 12, 726, 279, + /* 350 */ 211, 83, 913, 80, 725, 824, 46, 45, 245, 165, + /* 360 */ 44, 43, 42, 198, 725, 816, 671, 652, 182, 165, + /* 370 */ 649, 719, 650, 722, 651, 280, 1, 153, 913, 716, + /* 380 */ 284, 61, 288, 913, 183, 913, 241, 695, 696, 680, + /* 390 */ 31, 686, 687, 134, 6, 60, 20, 747, 227, 228, + /* 400 */ 728, 19, 638, 62, 19, 263, 31, 640, 265, 31, + /* 410 */ 639, 60, 82, 28, 60, 717, 266, 95, 94, 14, + /* 420 */ 13, 67, 730, 627, 185, 101, 100, 179, 16, 15, + /* 430 */ 979, 656, 654, 657, 655, 114, 113, 130, 128, 186, + /* 440 */ 187, 193, 194, 192, 177, 191, 181, 1026, 915, 978, + /* 450 */ 214, 975, 974, 215, 287, 131, 39, 936, 944, 946, + /* 460 */ 133, 137, 929, 244, 129, 150, 961, 960, 911, 909, + /* 470 */ 149, 679, 246, 151, 204, 152, 653, 250, 258, 827, + /* 480 */ 140, 66, 141, 268, 37, 63, 175, 926, 34, 277, + /* 490 */ 248, 823, 253, 142, 1031, 58, 92, 1030, 1028, 256, + /* 500 */ 156, 143, 281, 1025, 98, 1024, 1022, 254, 157, 845, + /* 510 */ 35, 32, 38, 252, 176, 812, 108, 810, 110, 111, + /* 520 */ 808, 807, 229, 167, 805, 804, 803, 802, 801, 800, + /* 530 */ 170, 172, 797, 795, 793, 791, 789, 174, 247, 242, + /* 540 */ 71, 74, 249, 962, 40, 297, 103, 289, 290, 291, + /* 550 */ 292, 293, 294, 295, 199, 221, 307, 766, 231, 232, + /* 560 */ 267, 765, 234, 235, 764, 200, 238, 87, 88, 752, + /* 570 */ 195, 243, 75, 8, 262, 806, 72, 659, 681, 135, + /* 580 */ 76, 121, 159, 846, 160, 161, 158, 162, 164, 122, + /* 590 */ 163, 799, 2, 123, 880, 124, 798, 790, 684, 144, + /* 600 */ 147, 145, 146, 4, 136, 148, 892, 206, 251, 26, + /* 610 */ 688, 138, 9, 10, 729, 27, 7, 11, 21, 731, + /* 620 */ 22, 85, 264, 591, 587, 83, 585, 584, 583, 580, + /* 630 */ 553, 275, 93, 89, 31, 630, 59, 97, 629, 99, /* 640 */ 626, 575, 573, 565, 571, 567, 569, 563, 561, 594, - /* 650 */ 593, 592, 590, 589, 588, 586, 582, 581, 60, 519, - /* 660 */ 551, 517, 770, 769, 769, 769, 769, 769, 769, 769, + /* 650 */ 593, 592, 590, 589, 588, 586, 582, 581, 60, 551, + /* 660 */ 519, 517, 770, 769, 769, 769, 769, 769, 769, 769, /* 670 */ 769, 769, 769, 769, 126, 127, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 192, 1, 191, 192, 211, 192, 192, 195, 196, 9, - /* 10 */ 189, 190, 253, 13, 14, 192, 16, 17, 192, 253, - /* 20 */ 20, 21, 253, 23, 24, 25, 26, 27, 28, 263, - /* 30 */ 237, 262, 263, 33, 34, 253, 253, 37, 38, 39, - /* 40 */ 13, 14, 234, 16, 17, 262, 263, 20, 21, 1, - /* 50 */ 23, 24, 25, 26, 27, 28, 235, 9, 253, 233, - /* 60 */ 33, 34, 236, 211, 37, 38, 39, 14, 254, 16, - /* 70 */ 17, 250, 259, 20, 21, 1, 23, 24, 25, 26, - /* 80 */ 27, 28, 259, 9, 261, 211, 33, 34, 79, 237, + /* 0 */ 190, 1, 189, 190, 209, 190, 190, 193, 194, 9, + /* 10 */ 187, 188, 251, 13, 14, 190, 16, 17, 190, 251, + /* 20 */ 20, 21, 251, 23, 24, 25, 26, 27, 28, 261, + /* 30 */ 235, 260, 261, 33, 34, 251, 251, 37, 38, 39, + /* 40 */ 13, 14, 232, 16, 17, 260, 261, 20, 21, 1, + /* 50 */ 23, 24, 25, 26, 27, 28, 233, 9, 251, 231, + /* 60 */ 33, 34, 234, 209, 37, 38, 39, 14, 252, 16, + /* 70 */ 17, 248, 257, 20, 21, 1, 23, 24, 25, 26, + /* 80 */ 27, 28, 257, 9, 259, 209, 33, 34, 79, 235, /* 90 */ 37, 38, 39, 45, 46, 47, 48, 49, 50, 51, - /* 100 */ 52, 53, 54, 55, 56, 57, 58, 5, 198, 61, - /* 110 */ 110, 237, 81, 13, 14, 192, 16, 17, 253, 192, - /* 120 */ 20, 21, 1, 23, 24, 25, 26, 27, 28, 253, - /* 130 */ 9, 211, 105, 33, 34, 33, 34, 37, 38, 39, - /* 140 */ 13, 14, 232, 16, 17, 67, 253, 20, 21, 37, - /* 150 */ 23, 24, 25, 26, 27, 28, 233, 237, 0, 236, - /* 160 */ 33, 34, 67, 236, 37, 38, 39, 88, 89, 90, + /* 100 */ 52, 53, 54, 55, 56, 57, 58, 5, 196, 61, + /* 110 */ 110, 235, 251, 13, 14, 190, 16, 17, 81, 190, + /* 120 */ 20, 21, 1, 23, 24, 25, 26, 27, 28, 109, + /* 130 */ 9, 209, 105, 33, 34, 33, 34, 37, 38, 39, + /* 140 */ 13, 14, 230, 16, 17, 67, 251, 20, 21, 129, + /* 150 */ 23, 24, 25, 26, 27, 28, 231, 235, 0, 234, + /* 160 */ 33, 34, 67, 234, 37, 38, 39, 88, 89, 90, /* 170 */ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, - /* 180 */ 101, 102, 210, 192, 212, 213, 214, 215, 216, 217, - /* 190 */ 218, 219, 220, 221, 222, 223, 224, 225, 16, 17, - /* 200 */ 197, 253, 20, 21, 201, 23, 24, 25, 26, 27, - /* 210 */ 28, 253, 44, 198, 136, 33, 34, 139, 140, 37, - /* 220 */ 38, 39, 1, 2, 235, 104, 5, 115, 7, 61, - /* 230 */ 9, 136, 1, 2, 139, 67, 5, 79, 7, 250, - /* 240 */ 9, 73, 74, 75, 229, 230, 231, 232, 257, 135, - /* 250 */ 259, 37, 38, 39, 33, 34, 142, 143, 37, 192, - /* 260 */ 88, 76, 90, 91, 33, 34, 81, 95, 238, 97, - /* 270 */ 98, 99, 104, 101, 102, 210, 192, 192, 213, 214, - /* 280 */ 112, 251, 192, 218, 197, 220, 221, 222, 201, 224, - /* 290 */ 225, 25, 26, 27, 28, 253, 64, 65, 66, 33, - /* 300 */ 34, 237, 134, 37, 38, 39, 62, 63, 192, 141, - /* 310 */ 15, 104, 68, 69, 70, 71, 72, 227, 233, 112, - /* 320 */ 105, 236, 78, 62, 63, 104, 259, 192, 113, 68, - /* 330 */ 69, 70, 71, 72, 192, 104, 62, 63, 117, 255, - /* 340 */ 192, 198, 68, 69, 70, 71, 72, 104, 117, 233, - /* 350 */ 253, 108, 236, 110, 133, 104, 33, 34, 107, 197, - /* 360 */ 37, 38, 39, 201, 133, 199, 200, 2, 233, 1, - /* 370 */ 5, 236, 7, 230, 9, 233, 124, 125, 236, 109, - /* 380 */ 5, 233, 7, 105, 236, 105, 116, 109, 105, 109, - /* 390 */ 105, 105, 109, 105, 109, 109, 60, 109, 33, 34, - /* 400 */ 5, 109, 7, 253, 105, 37, 111, 109, 109, 105, - /* 410 */ 105, 105, 105, 109, 109, 109, 109, 253, 137, 138, - /* 420 */ 253, 137, 138, 131, 137, 138, 104, 129, 106, 253, - /* 430 */ 137, 138, 5, 5, 7, 7, 76, 77, 62, 63, - /* 440 */ 104, 253, 253, 253, 253, 253, 253, 237, 228, 192, - /* 450 */ 228, 228, 228, 228, 228, 228, 192, 252, 260, 192, - /* 460 */ 192, 192, 260, 235, 235, 192, 60, 192, 235, 239, - /* 470 */ 193, 192, 117, 256, 192, 256, 111, 118, 122, 126, - /* 480 */ 128, 192, 192, 192, 130, 249, 192, 248, 192, 192, - /* 490 */ 256, 256, 192, 192, 192, 192, 127, 247, 121, 246, - /* 500 */ 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - /* 510 */ 192, 192, 192, 192, 120, 244, 192, 192, 192, 192, - /* 520 */ 192, 192, 192, 192, 192, 192, 192, 192, 119, 192, - /* 530 */ 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, - /* 540 */ 132, 193, 193, 193, 193, 103, 87, 86, 50, 83, - /* 550 */ 85, 54, 84, 82, 79, 193, 5, 193, 144, 5, - /* 560 */ 193, 5, 144, 5, 5, 89, 193, 193, 135, 198, - /* 570 */ 198, 113, 109, 104, 107, 105, 114, 193, 105, 194, - /* 580 */ 1, 104, 194, 193, 203, 194, 207, 209, 208, 206, - /* 590 */ 204, 202, 205, 193, 105, 194, 226, 193, 199, 109, - /* 600 */ 195, 243, 245, 242, 241, 104, 240, 104, 226, 105, - /* 610 */ 104, 109, 107, 105, 123, 123, 109, 104, 104, 104, - /* 620 */ 111, 104, 76, 9, 108, 5, 5, 5, 5, 5, - /* 630 */ 80, 15, 138, 76, 109, 16, 5, 138, 138, 5, + /* 180 */ 101, 102, 208, 190, 210, 211, 212, 213, 214, 215, + /* 190 */ 216, 217, 218, 219, 220, 221, 222, 223, 16, 17, + /* 200 */ 195, 190, 20, 21, 199, 23, 24, 25, 26, 27, + /* 210 */ 28, 251, 44, 196, 136, 33, 34, 139, 140, 37, + /* 220 */ 38, 39, 1, 2, 233, 104, 5, 196, 7, 61, + /* 230 */ 9, 136, 1, 2, 139, 67, 5, 79, 7, 248, + /* 240 */ 9, 73, 74, 75, 227, 228, 229, 230, 255, 135, + /* 250 */ 257, 37, 38, 39, 33, 34, 142, 143, 37, 228, + /* 260 */ 88, 251, 90, 91, 33, 34, 190, 95, 257, 97, + /* 270 */ 98, 99, 104, 101, 102, 208, 76, 190, 211, 212, + /* 280 */ 112, 81, 5, 216, 7, 218, 219, 220, 37, 222, + /* 290 */ 223, 25, 26, 27, 28, 190, 64, 65, 66, 33, + /* 300 */ 34, 225, 134, 37, 38, 39, 62, 63, 190, 141, + /* 310 */ 109, 104, 68, 69, 70, 71, 72, 116, 231, 112, + /* 320 */ 105, 234, 78, 62, 63, 104, 15, 236, 113, 68, + /* 330 */ 69, 70, 71, 72, 190, 104, 62, 63, 117, 190, + /* 340 */ 249, 190, 68, 69, 70, 71, 72, 104, 117, 231, + /* 350 */ 60, 108, 234, 110, 133, 195, 33, 34, 253, 199, + /* 360 */ 37, 38, 39, 251, 133, 195, 115, 2, 251, 199, + /* 370 */ 5, 5, 7, 7, 9, 231, 197, 198, 234, 1, + /* 380 */ 231, 109, 231, 234, 251, 234, 105, 124, 125, 105, + /* 390 */ 109, 105, 105, 109, 104, 109, 109, 105, 33, 34, + /* 400 */ 105, 109, 105, 131, 109, 105, 109, 105, 105, 109, + /* 410 */ 105, 109, 109, 104, 109, 37, 107, 137, 138, 137, + /* 420 */ 138, 104, 111, 106, 251, 137, 138, 251, 137, 138, + /* 430 */ 226, 5, 5, 7, 7, 76, 77, 62, 63, 251, + /* 440 */ 251, 251, 251, 251, 251, 251, 251, 235, 235, 226, + /* 450 */ 226, 226, 226, 226, 226, 190, 250, 190, 190, 190, + /* 460 */ 190, 190, 233, 233, 60, 190, 258, 258, 233, 190, + /* 470 */ 237, 117, 254, 190, 254, 190, 111, 119, 122, 190, + /* 480 */ 246, 128, 245, 190, 190, 130, 190, 247, 190, 190, + /* 490 */ 254, 190, 254, 244, 190, 127, 190, 190, 190, 126, + /* 500 */ 190, 243, 190, 190, 190, 190, 190, 121, 190, 190, + /* 510 */ 190, 190, 190, 120, 190, 190, 190, 190, 190, 190, + /* 520 */ 190, 190, 190, 190, 190, 190, 190, 190, 190, 190, + /* 530 */ 190, 190, 190, 190, 190, 190, 190, 190, 118, 191, + /* 540 */ 191, 191, 191, 191, 132, 103, 87, 86, 50, 83, + /* 550 */ 85, 54, 84, 82, 191, 191, 79, 5, 144, 5, + /* 560 */ 191, 5, 144, 5, 5, 191, 135, 196, 196, 89, + /* 570 */ 191, 113, 109, 104, 107, 191, 114, 105, 105, 104, + /* 580 */ 104, 192, 205, 207, 201, 204, 206, 202, 200, 192, + /* 590 */ 203, 191, 197, 192, 224, 192, 191, 191, 105, 242, + /* 600 */ 239, 241, 240, 193, 109, 238, 224, 1, 104, 109, + /* 610 */ 105, 104, 123, 123, 105, 109, 104, 104, 104, 111, + /* 620 */ 104, 76, 107, 9, 5, 108, 5, 5, 5, 5, + /* 630 */ 80, 15, 138, 76, 109, 5, 16, 138, 5, 138, /* 640 */ 105, 5, 5, 5, 5, 5, 5, 5, 5, 5, - /* 650 */ 5, 5, 5, 5, 5, 5, 5, 5, 109, 60, - /* 660 */ 80, 59, 0, 264, 264, 264, 264, 264, 264, 264, - /* 670 */ 264, 264, 264, 264, 21, 21, 264, 264, 264, 264, - /* 680 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 690 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 700 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 710 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 720 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 730 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 740 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 750 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 760 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 770 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 780 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 790 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 800 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 810 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 820 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 830 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 840 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 850 */ 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, - /* 860 */ 264, 264, 264, 264, + /* 650 */ 5, 5, 5, 5, 5, 5, 5, 5, 109, 80, + /* 660 */ 60, 59, 0, 262, 262, 262, 262, 262, 262, 262, + /* 670 */ 262, 262, 262, 262, 21, 21, 262, 262, 262, 262, + /* 680 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 690 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 700 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 710 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 720 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 730 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 740 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 750 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 760 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 770 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 780 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 790 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 800 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 810 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 820 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 830 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 840 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 850 */ 262, 262, 262, 262, 262, 262, 262, 262, 262, 262, + /* 860 */ 262, 262, }; #define YY_SHIFT_COUNT (312) #define YY_SHIFT_MIN (0) @@ -371,58 +371,58 @@ static const unsigned short int yy_shift_ofst[] = { /* 0 */ 168, 79, 79, 172, 172, 9, 221, 231, 74, 74, /* 10 */ 74, 74, 74, 74, 74, 74, 74, 0, 48, 231, /* 20 */ 365, 365, 365, 365, 121, 207, 74, 74, 74, 158, - /* 30 */ 74, 74, 185, 9, 31, 31, 676, 676, 676, 231, + /* 30 */ 74, 74, 200, 9, 37, 37, 676, 676, 676, 231, /* 40 */ 231, 231, 231, 231, 231, 231, 231, 231, 231, 231, /* 50 */ 231, 231, 231, 231, 231, 231, 231, 231, 231, 365, /* 60 */ 365, 102, 102, 102, 102, 102, 102, 102, 74, 74, - /* 70 */ 112, 74, 207, 207, 74, 74, 74, 252, 252, 270, + /* 70 */ 251, 74, 207, 207, 74, 74, 74, 263, 263, 201, /* 80 */ 207, 74, 74, 74, 74, 74, 74, 74, 74, 74, /* 90 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, /* 100 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, /* 110 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, /* 120 */ 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, - /* 130 */ 74, 406, 406, 406, 355, 355, 355, 406, 355, 406, - /* 140 */ 352, 354, 369, 356, 353, 377, 394, 409, 359, 408, - /* 150 */ 406, 406, 406, 442, 9, 9, 406, 406, 459, 461, - /* 160 */ 498, 466, 465, 497, 468, 471, 442, 406, 475, 475, - /* 170 */ 406, 475, 406, 475, 406, 676, 676, 27, 100, 127, + /* 130 */ 74, 404, 404, 404, 354, 354, 354, 404, 354, 404, + /* 140 */ 353, 355, 368, 356, 373, 386, 393, 358, 420, 412, + /* 150 */ 404, 404, 404, 442, 9, 9, 404, 404, 459, 461, + /* 160 */ 498, 466, 465, 497, 468, 471, 442, 404, 477, 477, + /* 170 */ 404, 477, 404, 477, 404, 676, 676, 27, 100, 127, /* 180 */ 100, 100, 53, 182, 266, 266, 266, 266, 244, 261, /* 190 */ 274, 323, 323, 323, 323, 78, 114, 214, 214, 243, - /* 200 */ 95, 232, 278, 215, 280, 283, 285, 286, 288, 375, - /* 210 */ 395, 368, 336, 295, 292, 298, 299, 304, 305, 306, - /* 220 */ 307, 251, 281, 284, 287, 322, 293, 427, 428, 360, - /* 230 */ 376, 551, 414, 554, 556, 418, 558, 559, 476, 433, - /* 240 */ 458, 467, 469, 462, 470, 463, 473, 477, 489, 490, - /* 250 */ 501, 579, 503, 504, 506, 502, 491, 507, 492, 508, - /* 260 */ 513, 509, 514, 467, 515, 505, 517, 516, 546, 614, - /* 270 */ 620, 621, 622, 623, 624, 550, 616, 557, 494, 525, - /* 280 */ 525, 619, 499, 500, 525, 631, 634, 535, 525, 636, + /* 200 */ 95, 232, 281, 215, 284, 286, 287, 292, 295, 277, + /* 210 */ 366, 378, 290, 311, 272, 20, 297, 300, 302, 303, + /* 220 */ 305, 309, 280, 282, 288, 317, 291, 426, 427, 359, + /* 230 */ 375, 552, 414, 554, 556, 418, 558, 559, 480, 431, + /* 240 */ 458, 467, 469, 462, 472, 463, 473, 475, 493, 495, + /* 250 */ 476, 606, 504, 505, 507, 500, 489, 506, 490, 509, + /* 260 */ 512, 508, 513, 467, 514, 515, 516, 517, 545, 614, + /* 270 */ 619, 621, 622, 623, 624, 550, 616, 557, 494, 525, + /* 280 */ 525, 620, 499, 501, 525, 630, 633, 535, 525, 636, /* 290 */ 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, - /* 300 */ 647, 648, 649, 650, 651, 652, 549, 580, 653, 654, - /* 310 */ 599, 602, 662, + /* 300 */ 647, 648, 649, 650, 651, 652, 549, 579, 653, 654, + /* 310 */ 600, 602, 662, }; #define YY_REDUCE_COUNT (176) -#define YY_REDUCE_MIN (-241) -#define YY_REDUCE_MAX (405) +#define YY_REDUCE_MIN (-239) +#define YY_REDUCE_MAX (410) static const short yy_reduce_ofst[] = { - /* 0 */ -179, -28, -28, 65, 65, 15, -231, -217, -174, -177, - /* 10 */ -9, -77, 85, 116, 135, 142, 148, -186, -189, -234, - /* 20 */ -207, -148, -126, -80, 84, -11, -187, 67, -192, -90, - /* 30 */ 90, -73, 3, 143, 87, 162, 30, 166, -188, -241, - /* 40 */ -218, -195, -135, -124, -107, -52, -42, 42, 97, 150, - /* 50 */ 164, 167, 176, 188, 189, 190, 191, 192, 193, 64, - /* 60 */ 210, 220, 222, 223, 224, 225, 226, 227, 257, 264, - /* 70 */ 205, 267, 228, 229, 268, 269, 273, 198, 202, 230, - /* 80 */ 233, 275, 279, 282, 289, 290, 291, 294, 296, 297, - /* 90 */ 300, 301, 302, 303, 308, 309, 310, 311, 312, 313, - /* 100 */ 314, 315, 316, 317, 318, 319, 320, 321, 324, 325, - /* 110 */ 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, + /* 0 */ -177, -26, -26, 67, 67, 17, -229, -215, -172, -175, + /* 10 */ -7, -75, 87, 118, 144, 149, 151, -184, -187, -232, + /* 20 */ -205, -146, -124, -78, 105, -9, -185, 11, -190, -88, + /* 30 */ 76, -71, 5, 31, 160, 170, 91, 179, -186, -239, + /* 40 */ -216, -193, -139, -105, -40, 10, 112, 117, 133, 173, + /* 50 */ 176, 188, 189, 190, 191, 192, 193, 194, 195, 212, + /* 60 */ 213, 204, 223, 224, 225, 226, 227, 228, 265, 267, + /* 70 */ 206, 268, 229, 230, 269, 270, 271, 208, 209, 233, + /* 80 */ 235, 275, 279, 283, 285, 289, 293, 294, 296, 298, + /* 90 */ 299, 301, 304, 306, 307, 308, 310, 312, 313, 314, + /* 100 */ 315, 316, 318, 319, 320, 321, 322, 324, 325, 326, + /* 110 */ 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, /* 120 */ 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, - /* 130 */ 347, 277, 348, 349, 217, 219, 234, 350, 235, 351, - /* 140 */ 236, 239, 250, 253, 357, 271, 358, 361, 363, 366, - /* 150 */ 362, 364, 367, 370, 371, 372, 373, 374, 378, 380, - /* 160 */ 379, 381, 383, 386, 387, 389, 382, 384, 385, 388, - /* 170 */ 390, 391, 400, 401, 404, 399, 405, + /* 130 */ 347, 348, 349, 350, 218, 220, 236, 351, 238, 352, + /* 140 */ 240, 234, 237, 249, 258, 357, 360, 362, 361, 367, + /* 150 */ 363, 364, 369, 370, 371, 372, 374, 379, 376, 380, + /* 160 */ 377, 383, 381, 385, 387, 388, 382, 384, 389, 397, + /* 170 */ 400, 401, 405, 403, 406, 395, 410, }; static const YYACTIONTYPE yy_default[] = { /* 0 */ 767, 879, 825, 891, 813, 822, 1019, 1019, 767, 767, @@ -657,10 +657,8 @@ static const YYCODETYPE yyFallback[] = { 1, /* PREV => ID */ 1, /* LINEAR => ID */ 1, /* IMPORT => ID */ - 1, /* METRIC => ID */ 1, /* TBNAME => ID */ 1, /* JOIN => ID */ - 1, /* METRICS => ID */ 1, /* INSERT => ID */ 1, /* INTO => ID */ 1, /* VALUES => ID */ @@ -931,89 +929,87 @@ static const char *const yyTokenName[] = { /* 178 */ "PREV", /* 179 */ "LINEAR", /* 180 */ "IMPORT", - /* 181 */ "METRIC", - /* 182 */ "TBNAME", - /* 183 */ "JOIN", - /* 184 */ "METRICS", - /* 185 */ "INSERT", - /* 186 */ "INTO", - /* 187 */ "VALUES", - /* 188 */ "error", - /* 189 */ "program", - /* 190 */ "cmd", - /* 191 */ "dbPrefix", - /* 192 */ "ids", - /* 193 */ "cpxName", - /* 194 */ "ifexists", - /* 195 */ "alter_db_optr", - /* 196 */ "alter_topic_optr", - /* 197 */ "acct_optr", - /* 198 */ "ifnotexists", - /* 199 */ "db_optr", - /* 200 */ "topic_optr", - /* 201 */ "pps", - /* 202 */ "tseries", - /* 203 */ "dbs", - /* 204 */ "streams", - /* 205 */ "storage", - /* 206 */ "qtime", - /* 207 */ "users", - /* 208 */ "conns", - /* 209 */ "state", - /* 210 */ "keep", - /* 211 */ "tagitemlist", - /* 212 */ "cache", - /* 213 */ "replica", - /* 214 */ "quorum", - /* 215 */ "days", - /* 216 */ "minrows", - /* 217 */ "maxrows", - /* 218 */ "blocks", - /* 219 */ "ctime", - /* 220 */ "wal", - /* 221 */ "fsync", - /* 222 */ "comp", - /* 223 */ "prec", - /* 224 */ "update", - /* 225 */ "cachelast", - /* 226 */ "partitions", - /* 227 */ "typename", - /* 228 */ "signed", - /* 229 */ "create_table_args", - /* 230 */ "create_stable_args", - /* 231 */ "create_table_list", - /* 232 */ "create_from_stable", - /* 233 */ "columnlist", - /* 234 */ "tagNamelist", - /* 235 */ "select", - /* 236 */ "column", - /* 237 */ "tagitem", - /* 238 */ "selcollist", - /* 239 */ "from", - /* 240 */ "where_opt", - /* 241 */ "interval_opt", - /* 242 */ "session_option", - /* 243 */ "fill_opt", - /* 244 */ "sliding_opt", - /* 245 */ "groupby_opt", - /* 246 */ "orderby_opt", - /* 247 */ "having_opt", - /* 248 */ "slimit_opt", - /* 249 */ "limit_opt", - /* 250 */ "union", - /* 251 */ "sclp", - /* 252 */ "distinct", - /* 253 */ "expr", - /* 254 */ "as", - /* 255 */ "tablelist", - /* 256 */ "tmvar", - /* 257 */ "sortlist", - /* 258 */ "sortitem", - /* 259 */ "item", - /* 260 */ "sortorder", - /* 261 */ "grouplist", - /* 262 */ "exprlist", - /* 263 */ "expritem", + /* 181 */ "TBNAME", + /* 182 */ "JOIN", + /* 183 */ "INSERT", + /* 184 */ "INTO", + /* 185 */ "VALUES", + /* 186 */ "error", + /* 187 */ "program", + /* 188 */ "cmd", + /* 189 */ "dbPrefix", + /* 190 */ "ids", + /* 191 */ "cpxName", + /* 192 */ "ifexists", + /* 193 */ "alter_db_optr", + /* 194 */ "alter_topic_optr", + /* 195 */ "acct_optr", + /* 196 */ "ifnotexists", + /* 197 */ "db_optr", + /* 198 */ "topic_optr", + /* 199 */ "pps", + /* 200 */ "tseries", + /* 201 */ "dbs", + /* 202 */ "streams", + /* 203 */ "storage", + /* 204 */ "qtime", + /* 205 */ "users", + /* 206 */ "conns", + /* 207 */ "state", + /* 208 */ "keep", + /* 209 */ "tagitemlist", + /* 210 */ "cache", + /* 211 */ "replica", + /* 212 */ "quorum", + /* 213 */ "days", + /* 214 */ "minrows", + /* 215 */ "maxrows", + /* 216 */ "blocks", + /* 217 */ "ctime", + /* 218 */ "wal", + /* 219 */ "fsync", + /* 220 */ "comp", + /* 221 */ "prec", + /* 222 */ "update", + /* 223 */ "cachelast", + /* 224 */ "partitions", + /* 225 */ "typename", + /* 226 */ "signed", + /* 227 */ "create_table_args", + /* 228 */ "create_stable_args", + /* 229 */ "create_table_list", + /* 230 */ "create_from_stable", + /* 231 */ "columnlist", + /* 232 */ "tagNamelist", + /* 233 */ "select", + /* 234 */ "column", + /* 235 */ "tagitem", + /* 236 */ "selcollist", + /* 237 */ "from", + /* 238 */ "where_opt", + /* 239 */ "interval_opt", + /* 240 */ "session_option", + /* 241 */ "fill_opt", + /* 242 */ "sliding_opt", + /* 243 */ "groupby_opt", + /* 244 */ "orderby_opt", + /* 245 */ "having_opt", + /* 246 */ "slimit_opt", + /* 247 */ "limit_opt", + /* 248 */ "union", + /* 249 */ "sclp", + /* 250 */ "distinct", + /* 251 */ "expr", + /* 252 */ "as", + /* 253 */ "tablelist", + /* 254 */ "tmvar", + /* 255 */ "sortlist", + /* 256 */ "sortitem", + /* 257 */ "item", + /* 258 */ "sortorder", + /* 259 */ "grouplist", + /* 260 */ "exprlist", + /* 261 */ "expritem", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1406,52 +1402,52 @@ static void yy_destructor( ** inside the C code. */ /********* Begin destructor definitions ***************************************/ - case 210: /* keep */ - case 211: /* tagitemlist */ - case 233: /* columnlist */ - case 234: /* tagNamelist */ - case 243: /* fill_opt */ - case 245: /* groupby_opt */ - case 246: /* orderby_opt */ - case 257: /* sortlist */ - case 261: /* grouplist */ + case 208: /* keep */ + case 209: /* tagitemlist */ + case 231: /* columnlist */ + case 232: /* tagNamelist */ + case 241: /* fill_opt */ + case 243: /* groupby_opt */ + case 244: /* orderby_opt */ + case 255: /* sortlist */ + case 259: /* grouplist */ { -taosArrayDestroy((yypminor->yy285)); +taosArrayDestroy((yypminor->yy429)); } break; - case 231: /* create_table_list */ + case 229: /* create_table_list */ { -destroyCreateTableSql((yypminor->yy470)); +destroyCreateTableSql((yypminor->yy194)); } break; - case 235: /* select */ + case 233: /* select */ { -destroyQuerySqlNode((yypminor->yy342)); +destroyQuerySqlNode((yypminor->yy254)); } break; - case 238: /* selcollist */ - case 251: /* sclp */ - case 262: /* exprlist */ + case 236: /* selcollist */ + case 249: /* sclp */ + case 260: /* exprlist */ { -tSqlExprListDestroy((yypminor->yy285)); +tSqlExprListDestroy((yypminor->yy429)); } break; - case 240: /* where_opt */ - case 247: /* having_opt */ - case 253: /* expr */ - case 263: /* expritem */ + case 238: /* where_opt */ + case 245: /* having_opt */ + case 251: /* expr */ + case 261: /* expritem */ { -tSqlExprDestroy((yypminor->yy178)); +tSqlExprDestroy((yypminor->yy170)); } break; - case 250: /* union */ + case 248: /* union */ { -destroyAllSelectClause((yypminor->yy513)); +destroyAllSelectClause((yypminor->yy141)); } break; - case 258: /* sortitem */ + case 256: /* sortitem */ { -tVariantDestroy(&(yypminor->yy362)); +tVariantDestroy(&(yypminor->yy218)); } break; /********* End destructor definitions *****************************************/ @@ -1745,271 +1741,271 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 189, -1 }, /* (0) program ::= cmd */ - { 190, -2 }, /* (1) cmd ::= SHOW DATABASES */ - { 190, -2 }, /* (2) cmd ::= SHOW TOPICS */ - { 190, -2 }, /* (3) cmd ::= SHOW MNODES */ - { 190, -2 }, /* (4) cmd ::= SHOW DNODES */ - { 190, -2 }, /* (5) cmd ::= SHOW ACCOUNTS */ - { 190, -2 }, /* (6) cmd ::= SHOW USERS */ - { 190, -2 }, /* (7) cmd ::= SHOW MODULES */ - { 190, -2 }, /* (8) cmd ::= SHOW QUERIES */ - { 190, -2 }, /* (9) cmd ::= SHOW CONNECTIONS */ - { 190, -2 }, /* (10) cmd ::= SHOW STREAMS */ - { 190, -2 }, /* (11) cmd ::= SHOW VARIABLES */ - { 190, -2 }, /* (12) cmd ::= SHOW SCORES */ - { 190, -2 }, /* (13) cmd ::= SHOW GRANTS */ - { 190, -2 }, /* (14) cmd ::= SHOW VNODES */ - { 190, -3 }, /* (15) cmd ::= SHOW VNODES IPTOKEN */ - { 191, 0 }, /* (16) dbPrefix ::= */ - { 191, -2 }, /* (17) dbPrefix ::= ids DOT */ - { 193, 0 }, /* (18) cpxName ::= */ - { 193, -2 }, /* (19) cpxName ::= DOT ids */ - { 190, -5 }, /* (20) cmd ::= SHOW CREATE TABLE ids cpxName */ - { 190, -4 }, /* (21) cmd ::= SHOW CREATE DATABASE ids */ - { 190, -3 }, /* (22) cmd ::= SHOW dbPrefix TABLES */ - { 190, -5 }, /* (23) cmd ::= SHOW dbPrefix TABLES LIKE ids */ - { 190, -3 }, /* (24) cmd ::= SHOW dbPrefix STABLES */ - { 190, -5 }, /* (25) cmd ::= SHOW dbPrefix STABLES LIKE ids */ - { 190, -3 }, /* (26) cmd ::= SHOW dbPrefix VGROUPS */ - { 190, -4 }, /* (27) cmd ::= SHOW dbPrefix VGROUPS ids */ - { 190, -5 }, /* (28) cmd ::= DROP TABLE ifexists ids cpxName */ - { 190, -5 }, /* (29) cmd ::= DROP STABLE ifexists ids cpxName */ - { 190, -4 }, /* (30) cmd ::= DROP DATABASE ifexists ids */ - { 190, -4 }, /* (31) cmd ::= DROP TOPIC ifexists ids */ - { 190, -3 }, /* (32) cmd ::= DROP DNODE ids */ - { 190, -3 }, /* (33) cmd ::= DROP USER ids */ - { 190, -3 }, /* (34) cmd ::= DROP ACCOUNT ids */ - { 190, -2 }, /* (35) cmd ::= USE ids */ - { 190, -3 }, /* (36) cmd ::= DESCRIBE ids cpxName */ - { 190, -5 }, /* (37) cmd ::= ALTER USER ids PASS ids */ - { 190, -5 }, /* (38) cmd ::= ALTER USER ids PRIVILEGE ids */ - { 190, -4 }, /* (39) cmd ::= ALTER DNODE ids ids */ - { 190, -5 }, /* (40) cmd ::= ALTER DNODE ids ids ids */ - { 190, -3 }, /* (41) cmd ::= ALTER LOCAL ids */ - { 190, -4 }, /* (42) cmd ::= ALTER LOCAL ids ids */ - { 190, -4 }, /* (43) cmd ::= ALTER DATABASE ids alter_db_optr */ - { 190, -4 }, /* (44) cmd ::= ALTER TOPIC ids alter_topic_optr */ - { 190, -4 }, /* (45) cmd ::= ALTER ACCOUNT ids acct_optr */ - { 190, -6 }, /* (46) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ - { 192, -1 }, /* (47) ids ::= ID */ - { 192, -1 }, /* (48) ids ::= STRING */ - { 194, -2 }, /* (49) ifexists ::= IF EXISTS */ - { 194, 0 }, /* (50) ifexists ::= */ - { 198, -3 }, /* (51) ifnotexists ::= IF NOT EXISTS */ - { 198, 0 }, /* (52) ifnotexists ::= */ - { 190, -3 }, /* (53) cmd ::= CREATE DNODE ids */ - { 190, -6 }, /* (54) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ - { 190, -5 }, /* (55) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ - { 190, -5 }, /* (56) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ - { 190, -5 }, /* (57) cmd ::= CREATE USER ids PASS ids */ - { 201, 0 }, /* (58) pps ::= */ - { 201, -2 }, /* (59) pps ::= PPS INTEGER */ - { 202, 0 }, /* (60) tseries ::= */ - { 202, -2 }, /* (61) tseries ::= TSERIES INTEGER */ - { 203, 0 }, /* (62) dbs ::= */ - { 203, -2 }, /* (63) dbs ::= DBS INTEGER */ - { 204, 0 }, /* (64) streams ::= */ - { 204, -2 }, /* (65) streams ::= STREAMS INTEGER */ - { 205, 0 }, /* (66) storage ::= */ - { 205, -2 }, /* (67) storage ::= STORAGE INTEGER */ - { 206, 0 }, /* (68) qtime ::= */ - { 206, -2 }, /* (69) qtime ::= QTIME INTEGER */ - { 207, 0 }, /* (70) users ::= */ - { 207, -2 }, /* (71) users ::= USERS INTEGER */ - { 208, 0 }, /* (72) conns ::= */ - { 208, -2 }, /* (73) conns ::= CONNS INTEGER */ - { 209, 0 }, /* (74) state ::= */ - { 209, -2 }, /* (75) state ::= STATE ids */ - { 197, -9 }, /* (76) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ - { 210, -2 }, /* (77) keep ::= KEEP tagitemlist */ - { 212, -2 }, /* (78) cache ::= CACHE INTEGER */ - { 213, -2 }, /* (79) replica ::= REPLICA INTEGER */ - { 214, -2 }, /* (80) quorum ::= QUORUM INTEGER */ - { 215, -2 }, /* (81) days ::= DAYS INTEGER */ - { 216, -2 }, /* (82) minrows ::= MINROWS INTEGER */ - { 217, -2 }, /* (83) maxrows ::= MAXROWS INTEGER */ - { 218, -2 }, /* (84) blocks ::= BLOCKS INTEGER */ - { 219, -2 }, /* (85) ctime ::= CTIME INTEGER */ - { 220, -2 }, /* (86) wal ::= WAL INTEGER */ - { 221, -2 }, /* (87) fsync ::= FSYNC INTEGER */ - { 222, -2 }, /* (88) comp ::= COMP INTEGER */ - { 223, -2 }, /* (89) prec ::= PRECISION STRING */ - { 224, -2 }, /* (90) update ::= UPDATE INTEGER */ - { 225, -2 }, /* (91) cachelast ::= CACHELAST INTEGER */ - { 226, -2 }, /* (92) partitions ::= PARTITIONS INTEGER */ - { 199, 0 }, /* (93) db_optr ::= */ - { 199, -2 }, /* (94) db_optr ::= db_optr cache */ - { 199, -2 }, /* (95) db_optr ::= db_optr replica */ - { 199, -2 }, /* (96) db_optr ::= db_optr quorum */ - { 199, -2 }, /* (97) db_optr ::= db_optr days */ - { 199, -2 }, /* (98) db_optr ::= db_optr minrows */ - { 199, -2 }, /* (99) db_optr ::= db_optr maxrows */ - { 199, -2 }, /* (100) db_optr ::= db_optr blocks */ - { 199, -2 }, /* (101) db_optr ::= db_optr ctime */ - { 199, -2 }, /* (102) db_optr ::= db_optr wal */ - { 199, -2 }, /* (103) db_optr ::= db_optr fsync */ - { 199, -2 }, /* (104) db_optr ::= db_optr comp */ - { 199, -2 }, /* (105) db_optr ::= db_optr prec */ - { 199, -2 }, /* (106) db_optr ::= db_optr keep */ - { 199, -2 }, /* (107) db_optr ::= db_optr update */ - { 199, -2 }, /* (108) db_optr ::= db_optr cachelast */ - { 200, -1 }, /* (109) topic_optr ::= db_optr */ - { 200, -2 }, /* (110) topic_optr ::= topic_optr partitions */ - { 195, 0 }, /* (111) alter_db_optr ::= */ - { 195, -2 }, /* (112) alter_db_optr ::= alter_db_optr replica */ - { 195, -2 }, /* (113) alter_db_optr ::= alter_db_optr quorum */ - { 195, -2 }, /* (114) alter_db_optr ::= alter_db_optr keep */ - { 195, -2 }, /* (115) alter_db_optr ::= alter_db_optr blocks */ - { 195, -2 }, /* (116) alter_db_optr ::= alter_db_optr comp */ - { 195, -2 }, /* (117) alter_db_optr ::= alter_db_optr wal */ - { 195, -2 }, /* (118) alter_db_optr ::= alter_db_optr fsync */ - { 195, -2 }, /* (119) alter_db_optr ::= alter_db_optr update */ - { 195, -2 }, /* (120) alter_db_optr ::= alter_db_optr cachelast */ - { 196, -1 }, /* (121) alter_topic_optr ::= alter_db_optr */ - { 196, -2 }, /* (122) alter_topic_optr ::= alter_topic_optr partitions */ - { 227, -1 }, /* (123) typename ::= ids */ - { 227, -4 }, /* (124) typename ::= ids LP signed RP */ - { 227, -2 }, /* (125) typename ::= ids UNSIGNED */ - { 228, -1 }, /* (126) signed ::= INTEGER */ - { 228, -2 }, /* (127) signed ::= PLUS INTEGER */ - { 228, -2 }, /* (128) signed ::= MINUS INTEGER */ - { 190, -3 }, /* (129) cmd ::= CREATE TABLE create_table_args */ - { 190, -3 }, /* (130) cmd ::= CREATE TABLE create_stable_args */ - { 190, -3 }, /* (131) cmd ::= CREATE STABLE create_stable_args */ - { 190, -3 }, /* (132) cmd ::= CREATE TABLE create_table_list */ - { 231, -1 }, /* (133) create_table_list ::= create_from_stable */ - { 231, -2 }, /* (134) create_table_list ::= create_table_list create_from_stable */ - { 229, -6 }, /* (135) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ - { 230, -10 }, /* (136) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ - { 232, -10 }, /* (137) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ - { 232, -13 }, /* (138) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ - { 234, -3 }, /* (139) tagNamelist ::= tagNamelist COMMA ids */ - { 234, -1 }, /* (140) tagNamelist ::= ids */ - { 229, -5 }, /* (141) create_table_args ::= ifnotexists ids cpxName AS select */ - { 233, -3 }, /* (142) columnlist ::= columnlist COMMA column */ - { 233, -1 }, /* (143) columnlist ::= column */ - { 236, -2 }, /* (144) column ::= ids typename */ - { 211, -3 }, /* (145) tagitemlist ::= tagitemlist COMMA tagitem */ - { 211, -1 }, /* (146) tagitemlist ::= tagitem */ - { 237, -1 }, /* (147) tagitem ::= INTEGER */ - { 237, -1 }, /* (148) tagitem ::= FLOAT */ - { 237, -1 }, /* (149) tagitem ::= STRING */ - { 237, -1 }, /* (150) tagitem ::= BOOL */ - { 237, -1 }, /* (151) tagitem ::= NULL */ - { 237, -2 }, /* (152) tagitem ::= MINUS INTEGER */ - { 237, -2 }, /* (153) tagitem ::= MINUS FLOAT */ - { 237, -2 }, /* (154) tagitem ::= PLUS INTEGER */ - { 237, -2 }, /* (155) tagitem ::= PLUS FLOAT */ - { 235, -13 }, /* (156) select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ - { 235, -3 }, /* (157) select ::= LP select RP */ - { 250, -1 }, /* (158) union ::= select */ - { 250, -4 }, /* (159) union ::= union UNION ALL select */ - { 190, -1 }, /* (160) cmd ::= union */ - { 235, -2 }, /* (161) select ::= SELECT selcollist */ - { 251, -2 }, /* (162) sclp ::= selcollist COMMA */ - { 251, 0 }, /* (163) sclp ::= */ - { 238, -4 }, /* (164) selcollist ::= sclp distinct expr as */ - { 238, -2 }, /* (165) selcollist ::= sclp STAR */ - { 254, -2 }, /* (166) as ::= AS ids */ - { 254, -1 }, /* (167) as ::= ids */ - { 254, 0 }, /* (168) as ::= */ - { 252, -1 }, /* (169) distinct ::= DISTINCT */ - { 252, 0 }, /* (170) distinct ::= */ - { 239, -2 }, /* (171) from ::= FROM tablelist */ - { 239, -4 }, /* (172) from ::= FROM LP union RP */ - { 255, -2 }, /* (173) tablelist ::= ids cpxName */ - { 255, -3 }, /* (174) tablelist ::= ids cpxName ids */ - { 255, -4 }, /* (175) tablelist ::= tablelist COMMA ids cpxName */ - { 255, -5 }, /* (176) tablelist ::= tablelist COMMA ids cpxName ids */ - { 256, -1 }, /* (177) tmvar ::= VARIABLE */ - { 241, -4 }, /* (178) interval_opt ::= INTERVAL LP tmvar RP */ - { 241, -6 }, /* (179) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ - { 241, 0 }, /* (180) interval_opt ::= */ - { 242, 0 }, /* (181) session_option ::= */ - { 242, -7 }, /* (182) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ - { 243, 0 }, /* (183) fill_opt ::= */ - { 243, -6 }, /* (184) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ - { 243, -4 }, /* (185) fill_opt ::= FILL LP ID RP */ - { 244, -4 }, /* (186) sliding_opt ::= SLIDING LP tmvar RP */ - { 244, 0 }, /* (187) sliding_opt ::= */ - { 246, 0 }, /* (188) orderby_opt ::= */ - { 246, -3 }, /* (189) orderby_opt ::= ORDER BY sortlist */ - { 257, -4 }, /* (190) sortlist ::= sortlist COMMA item sortorder */ - { 257, -2 }, /* (191) sortlist ::= item sortorder */ - { 259, -2 }, /* (192) item ::= ids cpxName */ - { 260, -1 }, /* (193) sortorder ::= ASC */ - { 260, -1 }, /* (194) sortorder ::= DESC */ - { 260, 0 }, /* (195) sortorder ::= */ - { 245, 0 }, /* (196) groupby_opt ::= */ - { 245, -3 }, /* (197) groupby_opt ::= GROUP BY grouplist */ - { 261, -3 }, /* (198) grouplist ::= grouplist COMMA item */ - { 261, -1 }, /* (199) grouplist ::= item */ - { 247, 0 }, /* (200) having_opt ::= */ - { 247, -2 }, /* (201) having_opt ::= HAVING expr */ - { 249, 0 }, /* (202) limit_opt ::= */ - { 249, -2 }, /* (203) limit_opt ::= LIMIT signed */ - { 249, -4 }, /* (204) limit_opt ::= LIMIT signed OFFSET signed */ - { 249, -4 }, /* (205) limit_opt ::= LIMIT signed COMMA signed */ - { 248, 0 }, /* (206) slimit_opt ::= */ - { 248, -2 }, /* (207) slimit_opt ::= SLIMIT signed */ - { 248, -4 }, /* (208) slimit_opt ::= SLIMIT signed SOFFSET signed */ - { 248, -4 }, /* (209) slimit_opt ::= SLIMIT signed COMMA signed */ - { 240, 0 }, /* (210) where_opt ::= */ - { 240, -2 }, /* (211) where_opt ::= WHERE expr */ - { 253, -3 }, /* (212) expr ::= LP expr RP */ - { 253, -1 }, /* (213) expr ::= ID */ - { 253, -3 }, /* (214) expr ::= ID DOT ID */ - { 253, -3 }, /* (215) expr ::= ID DOT STAR */ - { 253, -1 }, /* (216) expr ::= INTEGER */ - { 253, -2 }, /* (217) expr ::= MINUS INTEGER */ - { 253, -2 }, /* (218) expr ::= PLUS INTEGER */ - { 253, -1 }, /* (219) expr ::= FLOAT */ - { 253, -2 }, /* (220) expr ::= MINUS FLOAT */ - { 253, -2 }, /* (221) expr ::= PLUS FLOAT */ - { 253, -1 }, /* (222) expr ::= STRING */ - { 253, -1 }, /* (223) expr ::= NOW */ - { 253, -1 }, /* (224) expr ::= VARIABLE */ - { 253, -1 }, /* (225) expr ::= BOOL */ - { 253, -4 }, /* (226) expr ::= ID LP exprlist RP */ - { 253, -4 }, /* (227) expr ::= ID LP STAR RP */ - { 253, -3 }, /* (228) expr ::= expr IS NULL */ - { 253, -4 }, /* (229) expr ::= expr IS NOT NULL */ - { 253, -3 }, /* (230) expr ::= expr LT expr */ - { 253, -3 }, /* (231) expr ::= expr GT expr */ - { 253, -3 }, /* (232) expr ::= expr LE expr */ - { 253, -3 }, /* (233) expr ::= expr GE expr */ - { 253, -3 }, /* (234) expr ::= expr NE expr */ - { 253, -3 }, /* (235) expr ::= expr EQ expr */ - { 253, -5 }, /* (236) expr ::= expr BETWEEN expr AND expr */ - { 253, -3 }, /* (237) expr ::= expr AND expr */ - { 253, -3 }, /* (238) expr ::= expr OR expr */ - { 253, -3 }, /* (239) expr ::= expr PLUS expr */ - { 253, -3 }, /* (240) expr ::= expr MINUS expr */ - { 253, -3 }, /* (241) expr ::= expr STAR expr */ - { 253, -3 }, /* (242) expr ::= expr SLASH expr */ - { 253, -3 }, /* (243) expr ::= expr REM expr */ - { 253, -3 }, /* (244) expr ::= expr LIKE expr */ - { 253, -5 }, /* (245) expr ::= expr IN LP exprlist RP */ - { 262, -3 }, /* (246) exprlist ::= exprlist COMMA expritem */ - { 262, -1 }, /* (247) exprlist ::= expritem */ - { 263, -1 }, /* (248) expritem ::= expr */ - { 263, 0 }, /* (249) expritem ::= */ - { 190, -3 }, /* (250) cmd ::= RESET QUERY CACHE */ - { 190, -7 }, /* (251) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ - { 190, -7 }, /* (252) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ - { 190, -7 }, /* (253) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ - { 190, -7 }, /* (254) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ - { 190, -8 }, /* (255) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ - { 190, -9 }, /* (256) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ - { 190, -7 }, /* (257) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ - { 190, -7 }, /* (258) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ - { 190, -7 }, /* (259) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ - { 190, -7 }, /* (260) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ - { 190, -8 }, /* (261) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ - { 190, -3 }, /* (262) cmd ::= KILL CONNECTION INTEGER */ - { 190, -5 }, /* (263) cmd ::= KILL STREAM INTEGER COLON INTEGER */ - { 190, -5 }, /* (264) cmd ::= KILL QUERY INTEGER COLON INTEGER */ + { 187, -1 }, /* (0) program ::= cmd */ + { 188, -2 }, /* (1) cmd ::= SHOW DATABASES */ + { 188, -2 }, /* (2) cmd ::= SHOW TOPICS */ + { 188, -2 }, /* (3) cmd ::= SHOW MNODES */ + { 188, -2 }, /* (4) cmd ::= SHOW DNODES */ + { 188, -2 }, /* (5) cmd ::= SHOW ACCOUNTS */ + { 188, -2 }, /* (6) cmd ::= SHOW USERS */ + { 188, -2 }, /* (7) cmd ::= SHOW MODULES */ + { 188, -2 }, /* (8) cmd ::= SHOW QUERIES */ + { 188, -2 }, /* (9) cmd ::= SHOW CONNECTIONS */ + { 188, -2 }, /* (10) cmd ::= SHOW STREAMS */ + { 188, -2 }, /* (11) cmd ::= SHOW VARIABLES */ + { 188, -2 }, /* (12) cmd ::= SHOW SCORES */ + { 188, -2 }, /* (13) cmd ::= SHOW GRANTS */ + { 188, -2 }, /* (14) cmd ::= SHOW VNODES */ + { 188, -3 }, /* (15) cmd ::= SHOW VNODES IPTOKEN */ + { 189, 0 }, /* (16) dbPrefix ::= */ + { 189, -2 }, /* (17) dbPrefix ::= ids DOT */ + { 191, 0 }, /* (18) cpxName ::= */ + { 191, -2 }, /* (19) cpxName ::= DOT ids */ + { 188, -5 }, /* (20) cmd ::= SHOW CREATE TABLE ids cpxName */ + { 188, -4 }, /* (21) cmd ::= SHOW CREATE DATABASE ids */ + { 188, -3 }, /* (22) cmd ::= SHOW dbPrefix TABLES */ + { 188, -5 }, /* (23) cmd ::= SHOW dbPrefix TABLES LIKE ids */ + { 188, -3 }, /* (24) cmd ::= SHOW dbPrefix STABLES */ + { 188, -5 }, /* (25) cmd ::= SHOW dbPrefix STABLES LIKE ids */ + { 188, -3 }, /* (26) cmd ::= SHOW dbPrefix VGROUPS */ + { 188, -4 }, /* (27) cmd ::= SHOW dbPrefix VGROUPS ids */ + { 188, -5 }, /* (28) cmd ::= DROP TABLE ifexists ids cpxName */ + { 188, -5 }, /* (29) cmd ::= DROP STABLE ifexists ids cpxName */ + { 188, -4 }, /* (30) cmd ::= DROP DATABASE ifexists ids */ + { 188, -4 }, /* (31) cmd ::= DROP TOPIC ifexists ids */ + { 188, -3 }, /* (32) cmd ::= DROP DNODE ids */ + { 188, -3 }, /* (33) cmd ::= DROP USER ids */ + { 188, -3 }, /* (34) cmd ::= DROP ACCOUNT ids */ + { 188, -2 }, /* (35) cmd ::= USE ids */ + { 188, -3 }, /* (36) cmd ::= DESCRIBE ids cpxName */ + { 188, -5 }, /* (37) cmd ::= ALTER USER ids PASS ids */ + { 188, -5 }, /* (38) cmd ::= ALTER USER ids PRIVILEGE ids */ + { 188, -4 }, /* (39) cmd ::= ALTER DNODE ids ids */ + { 188, -5 }, /* (40) cmd ::= ALTER DNODE ids ids ids */ + { 188, -3 }, /* (41) cmd ::= ALTER LOCAL ids */ + { 188, -4 }, /* (42) cmd ::= ALTER LOCAL ids ids */ + { 188, -4 }, /* (43) cmd ::= ALTER DATABASE ids alter_db_optr */ + { 188, -4 }, /* (44) cmd ::= ALTER TOPIC ids alter_topic_optr */ + { 188, -4 }, /* (45) cmd ::= ALTER ACCOUNT ids acct_optr */ + { 188, -6 }, /* (46) cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ + { 190, -1 }, /* (47) ids ::= ID */ + { 190, -1 }, /* (48) ids ::= STRING */ + { 192, -2 }, /* (49) ifexists ::= IF EXISTS */ + { 192, 0 }, /* (50) ifexists ::= */ + { 196, -3 }, /* (51) ifnotexists ::= IF NOT EXISTS */ + { 196, 0 }, /* (52) ifnotexists ::= */ + { 188, -3 }, /* (53) cmd ::= CREATE DNODE ids */ + { 188, -6 }, /* (54) cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ + { 188, -5 }, /* (55) cmd ::= CREATE DATABASE ifnotexists ids db_optr */ + { 188, -5 }, /* (56) cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ + { 188, -5 }, /* (57) cmd ::= CREATE USER ids PASS ids */ + { 199, 0 }, /* (58) pps ::= */ + { 199, -2 }, /* (59) pps ::= PPS INTEGER */ + { 200, 0 }, /* (60) tseries ::= */ + { 200, -2 }, /* (61) tseries ::= TSERIES INTEGER */ + { 201, 0 }, /* (62) dbs ::= */ + { 201, -2 }, /* (63) dbs ::= DBS INTEGER */ + { 202, 0 }, /* (64) streams ::= */ + { 202, -2 }, /* (65) streams ::= STREAMS INTEGER */ + { 203, 0 }, /* (66) storage ::= */ + { 203, -2 }, /* (67) storage ::= STORAGE INTEGER */ + { 204, 0 }, /* (68) qtime ::= */ + { 204, -2 }, /* (69) qtime ::= QTIME INTEGER */ + { 205, 0 }, /* (70) users ::= */ + { 205, -2 }, /* (71) users ::= USERS INTEGER */ + { 206, 0 }, /* (72) conns ::= */ + { 206, -2 }, /* (73) conns ::= CONNS INTEGER */ + { 207, 0 }, /* (74) state ::= */ + { 207, -2 }, /* (75) state ::= STATE ids */ + { 195, -9 }, /* (76) acct_optr ::= pps tseries storage streams qtime dbs users conns state */ + { 208, -2 }, /* (77) keep ::= KEEP tagitemlist */ + { 210, -2 }, /* (78) cache ::= CACHE INTEGER */ + { 211, -2 }, /* (79) replica ::= REPLICA INTEGER */ + { 212, -2 }, /* (80) quorum ::= QUORUM INTEGER */ + { 213, -2 }, /* (81) days ::= DAYS INTEGER */ + { 214, -2 }, /* (82) minrows ::= MINROWS INTEGER */ + { 215, -2 }, /* (83) maxrows ::= MAXROWS INTEGER */ + { 216, -2 }, /* (84) blocks ::= BLOCKS INTEGER */ + { 217, -2 }, /* (85) ctime ::= CTIME INTEGER */ + { 218, -2 }, /* (86) wal ::= WAL INTEGER */ + { 219, -2 }, /* (87) fsync ::= FSYNC INTEGER */ + { 220, -2 }, /* (88) comp ::= COMP INTEGER */ + { 221, -2 }, /* (89) prec ::= PRECISION STRING */ + { 222, -2 }, /* (90) update ::= UPDATE INTEGER */ + { 223, -2 }, /* (91) cachelast ::= CACHELAST INTEGER */ + { 224, -2 }, /* (92) partitions ::= PARTITIONS INTEGER */ + { 197, 0 }, /* (93) db_optr ::= */ + { 197, -2 }, /* (94) db_optr ::= db_optr cache */ + { 197, -2 }, /* (95) db_optr ::= db_optr replica */ + { 197, -2 }, /* (96) db_optr ::= db_optr quorum */ + { 197, -2 }, /* (97) db_optr ::= db_optr days */ + { 197, -2 }, /* (98) db_optr ::= db_optr minrows */ + { 197, -2 }, /* (99) db_optr ::= db_optr maxrows */ + { 197, -2 }, /* (100) db_optr ::= db_optr blocks */ + { 197, -2 }, /* (101) db_optr ::= db_optr ctime */ + { 197, -2 }, /* (102) db_optr ::= db_optr wal */ + { 197, -2 }, /* (103) db_optr ::= db_optr fsync */ + { 197, -2 }, /* (104) db_optr ::= db_optr comp */ + { 197, -2 }, /* (105) db_optr ::= db_optr prec */ + { 197, -2 }, /* (106) db_optr ::= db_optr keep */ + { 197, -2 }, /* (107) db_optr ::= db_optr update */ + { 197, -2 }, /* (108) db_optr ::= db_optr cachelast */ + { 198, -1 }, /* (109) topic_optr ::= db_optr */ + { 198, -2 }, /* (110) topic_optr ::= topic_optr partitions */ + { 193, 0 }, /* (111) alter_db_optr ::= */ + { 193, -2 }, /* (112) alter_db_optr ::= alter_db_optr replica */ + { 193, -2 }, /* (113) alter_db_optr ::= alter_db_optr quorum */ + { 193, -2 }, /* (114) alter_db_optr ::= alter_db_optr keep */ + { 193, -2 }, /* (115) alter_db_optr ::= alter_db_optr blocks */ + { 193, -2 }, /* (116) alter_db_optr ::= alter_db_optr comp */ + { 193, -2 }, /* (117) alter_db_optr ::= alter_db_optr wal */ + { 193, -2 }, /* (118) alter_db_optr ::= alter_db_optr fsync */ + { 193, -2 }, /* (119) alter_db_optr ::= alter_db_optr update */ + { 193, -2 }, /* (120) alter_db_optr ::= alter_db_optr cachelast */ + { 194, -1 }, /* (121) alter_topic_optr ::= alter_db_optr */ + { 194, -2 }, /* (122) alter_topic_optr ::= alter_topic_optr partitions */ + { 225, -1 }, /* (123) typename ::= ids */ + { 225, -4 }, /* (124) typename ::= ids LP signed RP */ + { 225, -2 }, /* (125) typename ::= ids UNSIGNED */ + { 226, -1 }, /* (126) signed ::= INTEGER */ + { 226, -2 }, /* (127) signed ::= PLUS INTEGER */ + { 226, -2 }, /* (128) signed ::= MINUS INTEGER */ + { 188, -3 }, /* (129) cmd ::= CREATE TABLE create_table_args */ + { 188, -3 }, /* (130) cmd ::= CREATE TABLE create_stable_args */ + { 188, -3 }, /* (131) cmd ::= CREATE STABLE create_stable_args */ + { 188, -3 }, /* (132) cmd ::= CREATE TABLE create_table_list */ + { 229, -1 }, /* (133) create_table_list ::= create_from_stable */ + { 229, -2 }, /* (134) create_table_list ::= create_table_list create_from_stable */ + { 227, -6 }, /* (135) create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ + { 228, -10 }, /* (136) create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ + { 230, -10 }, /* (137) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ + { 230, -13 }, /* (138) create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ + { 232, -3 }, /* (139) tagNamelist ::= tagNamelist COMMA ids */ + { 232, -1 }, /* (140) tagNamelist ::= ids */ + { 227, -5 }, /* (141) create_table_args ::= ifnotexists ids cpxName AS select */ + { 231, -3 }, /* (142) columnlist ::= columnlist COMMA column */ + { 231, -1 }, /* (143) columnlist ::= column */ + { 234, -2 }, /* (144) column ::= ids typename */ + { 209, -3 }, /* (145) tagitemlist ::= tagitemlist COMMA tagitem */ + { 209, -1 }, /* (146) tagitemlist ::= tagitem */ + { 235, -1 }, /* (147) tagitem ::= INTEGER */ + { 235, -1 }, /* (148) tagitem ::= FLOAT */ + { 235, -1 }, /* (149) tagitem ::= STRING */ + { 235, -1 }, /* (150) tagitem ::= BOOL */ + { 235, -1 }, /* (151) tagitem ::= NULL */ + { 235, -2 }, /* (152) tagitem ::= MINUS INTEGER */ + { 235, -2 }, /* (153) tagitem ::= MINUS FLOAT */ + { 235, -2 }, /* (154) tagitem ::= PLUS INTEGER */ + { 235, -2 }, /* (155) tagitem ::= PLUS FLOAT */ + { 233, -13 }, /* (156) select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ + { 233, -3 }, /* (157) select ::= LP select RP */ + { 248, -1 }, /* (158) union ::= select */ + { 248, -4 }, /* (159) union ::= union UNION ALL select */ + { 188, -1 }, /* (160) cmd ::= union */ + { 233, -2 }, /* (161) select ::= SELECT selcollist */ + { 249, -2 }, /* (162) sclp ::= selcollist COMMA */ + { 249, 0 }, /* (163) sclp ::= */ + { 236, -4 }, /* (164) selcollist ::= sclp distinct expr as */ + { 236, -2 }, /* (165) selcollist ::= sclp STAR */ + { 252, -2 }, /* (166) as ::= AS ids */ + { 252, -1 }, /* (167) as ::= ids */ + { 252, 0 }, /* (168) as ::= */ + { 250, -1 }, /* (169) distinct ::= DISTINCT */ + { 250, 0 }, /* (170) distinct ::= */ + { 237, -2 }, /* (171) from ::= FROM tablelist */ + { 237, -4 }, /* (172) from ::= FROM LP union RP */ + { 253, -2 }, /* (173) tablelist ::= ids cpxName */ + { 253, -3 }, /* (174) tablelist ::= ids cpxName ids */ + { 253, -4 }, /* (175) tablelist ::= tablelist COMMA ids cpxName */ + { 253, -5 }, /* (176) tablelist ::= tablelist COMMA ids cpxName ids */ + { 254, -1 }, /* (177) tmvar ::= VARIABLE */ + { 239, -4 }, /* (178) interval_opt ::= INTERVAL LP tmvar RP */ + { 239, -6 }, /* (179) interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ + { 239, 0 }, /* (180) interval_opt ::= */ + { 240, 0 }, /* (181) session_option ::= */ + { 240, -7 }, /* (182) session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ + { 241, 0 }, /* (183) fill_opt ::= */ + { 241, -6 }, /* (184) fill_opt ::= FILL LP ID COMMA tagitemlist RP */ + { 241, -4 }, /* (185) fill_opt ::= FILL LP ID RP */ + { 242, -4 }, /* (186) sliding_opt ::= SLIDING LP tmvar RP */ + { 242, 0 }, /* (187) sliding_opt ::= */ + { 244, 0 }, /* (188) orderby_opt ::= */ + { 244, -3 }, /* (189) orderby_opt ::= ORDER BY sortlist */ + { 255, -4 }, /* (190) sortlist ::= sortlist COMMA item sortorder */ + { 255, -2 }, /* (191) sortlist ::= item sortorder */ + { 257, -2 }, /* (192) item ::= ids cpxName */ + { 258, -1 }, /* (193) sortorder ::= ASC */ + { 258, -1 }, /* (194) sortorder ::= DESC */ + { 258, 0 }, /* (195) sortorder ::= */ + { 243, 0 }, /* (196) groupby_opt ::= */ + { 243, -3 }, /* (197) groupby_opt ::= GROUP BY grouplist */ + { 259, -3 }, /* (198) grouplist ::= grouplist COMMA item */ + { 259, -1 }, /* (199) grouplist ::= item */ + { 245, 0 }, /* (200) having_opt ::= */ + { 245, -2 }, /* (201) having_opt ::= HAVING expr */ + { 247, 0 }, /* (202) limit_opt ::= */ + { 247, -2 }, /* (203) limit_opt ::= LIMIT signed */ + { 247, -4 }, /* (204) limit_opt ::= LIMIT signed OFFSET signed */ + { 247, -4 }, /* (205) limit_opt ::= LIMIT signed COMMA signed */ + { 246, 0 }, /* (206) slimit_opt ::= */ + { 246, -2 }, /* (207) slimit_opt ::= SLIMIT signed */ + { 246, -4 }, /* (208) slimit_opt ::= SLIMIT signed SOFFSET signed */ + { 246, -4 }, /* (209) slimit_opt ::= SLIMIT signed COMMA signed */ + { 238, 0 }, /* (210) where_opt ::= */ + { 238, -2 }, /* (211) where_opt ::= WHERE expr */ + { 251, -3 }, /* (212) expr ::= LP expr RP */ + { 251, -1 }, /* (213) expr ::= ID */ + { 251, -3 }, /* (214) expr ::= ID DOT ID */ + { 251, -3 }, /* (215) expr ::= ID DOT STAR */ + { 251, -1 }, /* (216) expr ::= INTEGER */ + { 251, -2 }, /* (217) expr ::= MINUS INTEGER */ + { 251, -2 }, /* (218) expr ::= PLUS INTEGER */ + { 251, -1 }, /* (219) expr ::= FLOAT */ + { 251, -2 }, /* (220) expr ::= MINUS FLOAT */ + { 251, -2 }, /* (221) expr ::= PLUS FLOAT */ + { 251, -1 }, /* (222) expr ::= STRING */ + { 251, -1 }, /* (223) expr ::= NOW */ + { 251, -1 }, /* (224) expr ::= VARIABLE */ + { 251, -1 }, /* (225) expr ::= BOOL */ + { 251, -4 }, /* (226) expr ::= ID LP exprlist RP */ + { 251, -4 }, /* (227) expr ::= ID LP STAR RP */ + { 251, -3 }, /* (228) expr ::= expr IS NULL */ + { 251, -4 }, /* (229) expr ::= expr IS NOT NULL */ + { 251, -3 }, /* (230) expr ::= expr LT expr */ + { 251, -3 }, /* (231) expr ::= expr GT expr */ + { 251, -3 }, /* (232) expr ::= expr LE expr */ + { 251, -3 }, /* (233) expr ::= expr GE expr */ + { 251, -3 }, /* (234) expr ::= expr NE expr */ + { 251, -3 }, /* (235) expr ::= expr EQ expr */ + { 251, -5 }, /* (236) expr ::= expr BETWEEN expr AND expr */ + { 251, -3 }, /* (237) expr ::= expr AND expr */ + { 251, -3 }, /* (238) expr ::= expr OR expr */ + { 251, -3 }, /* (239) expr ::= expr PLUS expr */ + { 251, -3 }, /* (240) expr ::= expr MINUS expr */ + { 251, -3 }, /* (241) expr ::= expr STAR expr */ + { 251, -3 }, /* (242) expr ::= expr SLASH expr */ + { 251, -3 }, /* (243) expr ::= expr REM expr */ + { 251, -3 }, /* (244) expr ::= expr LIKE expr */ + { 251, -5 }, /* (245) expr ::= expr IN LP exprlist RP */ + { 260, -3 }, /* (246) exprlist ::= exprlist COMMA expritem */ + { 260, -1 }, /* (247) exprlist ::= expritem */ + { 261, -1 }, /* (248) expritem ::= expr */ + { 261, 0 }, /* (249) expritem ::= */ + { 188, -3 }, /* (250) cmd ::= RESET QUERY CACHE */ + { 188, -7 }, /* (251) cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ + { 188, -7 }, /* (252) cmd ::= ALTER TABLE ids cpxName DROP COLUMN ids */ + { 188, -7 }, /* (253) cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ + { 188, -7 }, /* (254) cmd ::= ALTER TABLE ids cpxName DROP TAG ids */ + { 188, -8 }, /* (255) cmd ::= ALTER TABLE ids cpxName CHANGE TAG ids ids */ + { 188, -9 }, /* (256) cmd ::= ALTER TABLE ids cpxName SET TAG ids EQ tagitem */ + { 188, -7 }, /* (257) cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ + { 188, -7 }, /* (258) cmd ::= ALTER STABLE ids cpxName DROP COLUMN ids */ + { 188, -7 }, /* (259) cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ + { 188, -7 }, /* (260) cmd ::= ALTER STABLE ids cpxName DROP TAG ids */ + { 188, -8 }, /* (261) cmd ::= ALTER STABLE ids cpxName CHANGE TAG ids ids */ + { 188, -3 }, /* (262) cmd ::= KILL CONNECTION INTEGER */ + { 188, -5 }, /* (263) cmd ::= KILL STREAM INTEGER COLON INTEGER */ + { 188, -5 }, /* (264) cmd ::= KILL QUERY INTEGER COLON INTEGER */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2256,13 +2252,13 @@ static void yy_reduce( break; case 43: /* cmd ::= ALTER DATABASE ids alter_db_optr */ case 44: /* cmd ::= ALTER TOPIC ids alter_topic_optr */ yytestcase(yyruleno==44); -{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy526, &t);} +{ SStrToken t = {0}; setCreateDbInfo(pInfo, TSDB_SQL_ALTER_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy94, &t);} break; case 45: /* cmd ::= ALTER ACCOUNT ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy187);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-1].minor.yy0, NULL, &yymsp[0].minor.yy419);} break; case 46: /* cmd ::= ALTER ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy187);} +{ setCreateAcctSql(pInfo, TSDB_SQL_ALTER_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy419);} break; case 47: /* ids ::= ID */ case 48: /* ids ::= STRING */ yytestcase(yyruleno==48); @@ -2284,11 +2280,11 @@ static void yy_reduce( { setDCLSqlElems(pInfo, TSDB_SQL_CREATE_DNODE, 1, &yymsp[0].minor.yy0);} break; case 54: /* cmd ::= CREATE ACCOUNT ids PASS ids acct_optr */ -{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy187);} +{ setCreateAcctSql(pInfo, TSDB_SQL_CREATE_ACCT, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy419);} break; case 55: /* cmd ::= CREATE DATABASE ifnotexists ids db_optr */ case 56: /* cmd ::= CREATE TOPIC ifnotexists ids topic_optr */ yytestcase(yyruleno==56); -{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy526, &yymsp[-2].minor.yy0);} +{ setCreateDbInfo(pInfo, TSDB_SQL_CREATE_DB, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy94, &yymsp[-2].minor.yy0);} break; case 57: /* cmd ::= CREATE USER ids PASS ids */ { setCreateUserSql(pInfo, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);} @@ -2317,20 +2313,20 @@ static void yy_reduce( break; case 76: /* acct_optr ::= pps tseries storage streams qtime dbs users conns state */ { - yylhsminor.yy187.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; - yylhsminor.yy187.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; - yylhsminor.yy187.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; - yylhsminor.yy187.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; - yylhsminor.yy187.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; - yylhsminor.yy187.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy187.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; - yylhsminor.yy187.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; - yylhsminor.yy187.stat = yymsp[0].minor.yy0; + yylhsminor.yy419.maxUsers = (yymsp[-2].minor.yy0.n>0)?atoi(yymsp[-2].minor.yy0.z):-1; + yylhsminor.yy419.maxDbs = (yymsp[-3].minor.yy0.n>0)?atoi(yymsp[-3].minor.yy0.z):-1; + yylhsminor.yy419.maxTimeSeries = (yymsp[-7].minor.yy0.n>0)?atoi(yymsp[-7].minor.yy0.z):-1; + yylhsminor.yy419.maxStreams = (yymsp[-5].minor.yy0.n>0)?atoi(yymsp[-5].minor.yy0.z):-1; + yylhsminor.yy419.maxPointsPerSecond = (yymsp[-8].minor.yy0.n>0)?atoi(yymsp[-8].minor.yy0.z):-1; + yylhsminor.yy419.maxStorage = (yymsp[-6].minor.yy0.n>0)?strtoll(yymsp[-6].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy419.maxQueryTime = (yymsp[-4].minor.yy0.n>0)?strtoll(yymsp[-4].minor.yy0.z, NULL, 10):-1; + yylhsminor.yy419.maxConnections = (yymsp[-1].minor.yy0.n>0)?atoi(yymsp[-1].minor.yy0.z):-1; + yylhsminor.yy419.stat = yymsp[0].minor.yy0; } - yymsp[-8].minor.yy187 = yylhsminor.yy187; + yymsp[-8].minor.yy419 = yylhsminor.yy419; break; case 77: /* keep ::= KEEP tagitemlist */ -{ yymsp[-1].minor.yy285 = yymsp[0].minor.yy285; } +{ yymsp[-1].minor.yy429 = yymsp[0].minor.yy429; } break; case 78: /* cache ::= CACHE INTEGER */ case 79: /* replica ::= REPLICA INTEGER */ yytestcase(yyruleno==79); @@ -2350,234 +2346,234 @@ static void yy_reduce( { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } break; case 93: /* db_optr ::= */ -{setDefaultCreateDbOption(&yymsp[1].minor.yy526); yymsp[1].minor.yy526.dbType = TSDB_DB_TYPE_DEFAULT;} +{setDefaultCreateDbOption(&yymsp[1].minor.yy94); yymsp[1].minor.yy94.dbType = TSDB_DB_TYPE_DEFAULT;} break; case 94: /* db_optr ::= db_optr cache */ -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.cacheBlockSize = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 95: /* db_optr ::= db_optr replica */ case 112: /* alter_db_optr ::= alter_db_optr replica */ yytestcase(yyruleno==112); -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.replica = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 96: /* db_optr ::= db_optr quorum */ case 113: /* alter_db_optr ::= alter_db_optr quorum */ yytestcase(yyruleno==113); -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.quorum = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 97: /* db_optr ::= db_optr days */ -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.daysPerFile = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 98: /* db_optr ::= db_optr minrows */ -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.minRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 99: /* db_optr ::= db_optr maxrows */ -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.maxRowsPerBlock = strtod(yymsp[0].minor.yy0.z, NULL); } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 100: /* db_optr ::= db_optr blocks */ case 115: /* alter_db_optr ::= alter_db_optr blocks */ yytestcase(yyruleno==115); -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.numOfBlocks = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 101: /* db_optr ::= db_optr ctime */ -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.commitTime = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 102: /* db_optr ::= db_optr wal */ case 117: /* alter_db_optr ::= alter_db_optr wal */ yytestcase(yyruleno==117); -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.walLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 103: /* db_optr ::= db_optr fsync */ case 118: /* alter_db_optr ::= alter_db_optr fsync */ yytestcase(yyruleno==118); -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.fsyncPeriod = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 104: /* db_optr ::= db_optr comp */ case 116: /* alter_db_optr ::= alter_db_optr comp */ yytestcase(yyruleno==116); -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.compressionLevel = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 105: /* db_optr ::= db_optr prec */ -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.precision = yymsp[0].minor.yy0; } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.precision = yymsp[0].minor.yy0; } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 106: /* db_optr ::= db_optr keep */ case 114: /* alter_db_optr ::= alter_db_optr keep */ yytestcase(yyruleno==114); -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.keep = yymsp[0].minor.yy285; } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.keep = yymsp[0].minor.yy429; } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 107: /* db_optr ::= db_optr update */ case 119: /* alter_db_optr ::= alter_db_optr update */ yytestcase(yyruleno==119); -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.update = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 108: /* db_optr ::= db_optr cachelast */ case 120: /* alter_db_optr ::= alter_db_optr cachelast */ yytestcase(yyruleno==120); -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.cachelast = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 109: /* topic_optr ::= db_optr */ case 121: /* alter_topic_optr ::= alter_db_optr */ yytestcase(yyruleno==121); -{ yylhsminor.yy526 = yymsp[0].minor.yy526; yylhsminor.yy526.dbType = TSDB_DB_TYPE_TOPIC; } - yymsp[0].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[0].minor.yy94; yylhsminor.yy94.dbType = TSDB_DB_TYPE_TOPIC; } + yymsp[0].minor.yy94 = yylhsminor.yy94; break; case 110: /* topic_optr ::= topic_optr partitions */ case 122: /* alter_topic_optr ::= alter_topic_optr partitions */ yytestcase(yyruleno==122); -{ yylhsminor.yy526 = yymsp[-1].minor.yy526; yylhsminor.yy526.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[-1].minor.yy526 = yylhsminor.yy526; +{ yylhsminor.yy94 = yymsp[-1].minor.yy94; yylhsminor.yy94.partitions = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[-1].minor.yy94 = yylhsminor.yy94; break; case 111: /* alter_db_optr ::= */ -{ setDefaultCreateDbOption(&yymsp[1].minor.yy526); yymsp[1].minor.yy526.dbType = TSDB_DB_TYPE_DEFAULT;} +{ setDefaultCreateDbOption(&yymsp[1].minor.yy94); yymsp[1].minor.yy94.dbType = TSDB_DB_TYPE_DEFAULT;} break; case 123: /* typename ::= ids */ { yymsp[0].minor.yy0.type = 0; - tSetColumnType (&yylhsminor.yy295, &yymsp[0].minor.yy0); + tSetColumnType (&yylhsminor.yy451, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy295 = yylhsminor.yy295; + yymsp[0].minor.yy451 = yylhsminor.yy451; break; case 124: /* typename ::= ids LP signed RP */ { - if (yymsp[-1].minor.yy525 <= 0) { + if (yymsp[-1].minor.yy481 <= 0) { yymsp[-3].minor.yy0.type = 0; - tSetColumnType(&yylhsminor.yy295, &yymsp[-3].minor.yy0); + tSetColumnType(&yylhsminor.yy451, &yymsp[-3].minor.yy0); } else { - yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy525; // negative value of name length - tSetColumnType(&yylhsminor.yy295, &yymsp[-3].minor.yy0); + yymsp[-3].minor.yy0.type = -yymsp[-1].minor.yy481; // negative value of name length + tSetColumnType(&yylhsminor.yy451, &yymsp[-3].minor.yy0); } } - yymsp[-3].minor.yy295 = yylhsminor.yy295; + yymsp[-3].minor.yy451 = yylhsminor.yy451; break; case 125: /* typename ::= ids UNSIGNED */ { yymsp[-1].minor.yy0.type = 0; yymsp[-1].minor.yy0.n = ((yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z); - tSetColumnType (&yylhsminor.yy295, &yymsp[-1].minor.yy0); + tSetColumnType (&yylhsminor.yy451, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy295 = yylhsminor.yy295; + yymsp[-1].minor.yy451 = yylhsminor.yy451; break; case 126: /* signed ::= INTEGER */ -{ yylhsminor.yy525 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } - yymsp[0].minor.yy525 = yylhsminor.yy525; +{ yylhsminor.yy481 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } + yymsp[0].minor.yy481 = yylhsminor.yy481; break; case 127: /* signed ::= PLUS INTEGER */ -{ yymsp[-1].minor.yy525 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } +{ yymsp[-1].minor.yy481 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; case 128: /* signed ::= MINUS INTEGER */ -{ yymsp[-1].minor.yy525 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} +{ yymsp[-1].minor.yy481 = -strtol(yymsp[0].minor.yy0.z, NULL, 10);} break; case 132: /* cmd ::= CREATE TABLE create_table_list */ -{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy470;} +{ pInfo->type = TSDB_SQL_CREATE_TABLE; pInfo->pCreateTableInfo = yymsp[0].minor.yy194;} break; case 133: /* create_table_list ::= create_from_stable */ { SCreateTableSql* pCreateTable = calloc(1, sizeof(SCreateTableSql)); pCreateTable->childTableInfo = taosArrayInit(4, sizeof(SCreatedTableInfo)); - taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy96); + taosArrayPush(pCreateTable->childTableInfo, &yymsp[0].minor.yy252); pCreateTable->type = TSQL_CREATE_TABLE_FROM_STABLE; - yylhsminor.yy470 = pCreateTable; + yylhsminor.yy194 = pCreateTable; } - yymsp[0].minor.yy470 = yylhsminor.yy470; + yymsp[0].minor.yy194 = yylhsminor.yy194; break; case 134: /* create_table_list ::= create_table_list create_from_stable */ { - taosArrayPush(yymsp[-1].minor.yy470->childTableInfo, &yymsp[0].minor.yy96); - yylhsminor.yy470 = yymsp[-1].minor.yy470; + taosArrayPush(yymsp[-1].minor.yy194->childTableInfo, &yymsp[0].minor.yy252); + yylhsminor.yy194 = yymsp[-1].minor.yy194; } - yymsp[-1].minor.yy470 = yylhsminor.yy470; + yymsp[-1].minor.yy194 = yylhsminor.yy194; break; case 135: /* create_table_args ::= ifnotexists ids cpxName LP columnlist RP */ { - yylhsminor.yy470 = tSetCreateTableInfo(yymsp[-1].minor.yy285, NULL, NULL, TSQL_CREATE_TABLE); - setSqlInfo(pInfo, yylhsminor.yy470, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy194 = tSetCreateTableInfo(yymsp[-1].minor.yy429, NULL, NULL, TSQL_CREATE_TABLE); + setSqlInfo(pInfo, yylhsminor.yy194, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-4].minor.yy0, &yymsp[-5].minor.yy0); } - yymsp[-5].minor.yy470 = yylhsminor.yy470; + yymsp[-5].minor.yy194 = yylhsminor.yy194; break; case 136: /* create_stable_args ::= ifnotexists ids cpxName LP columnlist RP TAGS LP columnlist RP */ { - yylhsminor.yy470 = tSetCreateTableInfo(yymsp[-5].minor.yy285, yymsp[-1].minor.yy285, NULL, TSQL_CREATE_STABLE); - setSqlInfo(pInfo, yylhsminor.yy470, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy194 = tSetCreateTableInfo(yymsp[-5].minor.yy429, yymsp[-1].minor.yy429, NULL, TSQL_CREATE_STABLE); + setSqlInfo(pInfo, yylhsminor.yy194, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy470 = yylhsminor.yy470; + yymsp[-9].minor.yy194 = yylhsminor.yy194; break; case 137: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName TAGS LP tagitemlist RP */ { yymsp[-5].minor.yy0.n += yymsp[-4].minor.yy0.n; yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; - yylhsminor.yy96 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy285, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); + yylhsminor.yy252 = createNewChildTableInfo(&yymsp[-5].minor.yy0, NULL, yymsp[-1].minor.yy429, &yymsp[-8].minor.yy0, &yymsp[-9].minor.yy0); } - yymsp[-9].minor.yy96 = yylhsminor.yy96; + yymsp[-9].minor.yy252 = yylhsminor.yy252; break; case 138: /* create_from_stable ::= ifnotexists ids cpxName USING ids cpxName LP tagNamelist RP TAGS LP tagitemlist RP */ { yymsp[-8].minor.yy0.n += yymsp[-7].minor.yy0.n; yymsp[-11].minor.yy0.n += yymsp[-10].minor.yy0.n; - yylhsminor.yy96 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy285, yymsp[-1].minor.yy285, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); + yylhsminor.yy252 = createNewChildTableInfo(&yymsp[-8].minor.yy0, yymsp[-5].minor.yy429, yymsp[-1].minor.yy429, &yymsp[-11].minor.yy0, &yymsp[-12].minor.yy0); } - yymsp[-12].minor.yy96 = yylhsminor.yy96; + yymsp[-12].minor.yy252 = yylhsminor.yy252; break; case 139: /* tagNamelist ::= tagNamelist COMMA ids */ -{taosArrayPush(yymsp[-2].minor.yy285, &yymsp[0].minor.yy0); yylhsminor.yy285 = yymsp[-2].minor.yy285; } - yymsp[-2].minor.yy285 = yylhsminor.yy285; +{taosArrayPush(yymsp[-2].minor.yy429, &yymsp[0].minor.yy0); yylhsminor.yy429 = yymsp[-2].minor.yy429; } + yymsp[-2].minor.yy429 = yylhsminor.yy429; break; case 140: /* tagNamelist ::= ids */ -{yylhsminor.yy285 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy285, &yymsp[0].minor.yy0);} - yymsp[0].minor.yy285 = yylhsminor.yy285; +{yylhsminor.yy429 = taosArrayInit(4, sizeof(SStrToken)); taosArrayPush(yylhsminor.yy429, &yymsp[0].minor.yy0);} + yymsp[0].minor.yy429 = yylhsminor.yy429; break; case 141: /* create_table_args ::= ifnotexists ids cpxName AS select */ { - yylhsminor.yy470 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy342, TSQL_CREATE_STREAM); - setSqlInfo(pInfo, yylhsminor.yy470, NULL, TSDB_SQL_CREATE_TABLE); + yylhsminor.yy194 = tSetCreateTableInfo(NULL, NULL, yymsp[0].minor.yy254, TSQL_CREATE_STREAM); + setSqlInfo(pInfo, yylhsminor.yy194, NULL, TSDB_SQL_CREATE_TABLE); yymsp[-3].minor.yy0.n += yymsp[-2].minor.yy0.n; setCreatedTableName(pInfo, &yymsp[-3].minor.yy0, &yymsp[-4].minor.yy0); } - yymsp[-4].minor.yy470 = yylhsminor.yy470; + yymsp[-4].minor.yy194 = yylhsminor.yy194; break; case 142: /* columnlist ::= columnlist COMMA column */ -{taosArrayPush(yymsp[-2].minor.yy285, &yymsp[0].minor.yy295); yylhsminor.yy285 = yymsp[-2].minor.yy285; } - yymsp[-2].minor.yy285 = yylhsminor.yy285; +{taosArrayPush(yymsp[-2].minor.yy429, &yymsp[0].minor.yy451); yylhsminor.yy429 = yymsp[-2].minor.yy429; } + yymsp[-2].minor.yy429 = yylhsminor.yy429; break; case 143: /* columnlist ::= column */ -{yylhsminor.yy285 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy285, &yymsp[0].minor.yy295);} - yymsp[0].minor.yy285 = yylhsminor.yy285; +{yylhsminor.yy429 = taosArrayInit(4, sizeof(TAOS_FIELD)); taosArrayPush(yylhsminor.yy429, &yymsp[0].minor.yy451);} + yymsp[0].minor.yy429 = yylhsminor.yy429; break; case 144: /* column ::= ids typename */ { - tSetColumnInfo(&yylhsminor.yy295, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy295); + tSetColumnInfo(&yylhsminor.yy451, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy451); } - yymsp[-1].minor.yy295 = yylhsminor.yy295; + yymsp[-1].minor.yy451 = yylhsminor.yy451; break; case 145: /* tagitemlist ::= tagitemlist COMMA tagitem */ -{ yylhsminor.yy285 = tVariantListAppend(yymsp[-2].minor.yy285, &yymsp[0].minor.yy362, -1); } - yymsp[-2].minor.yy285 = yylhsminor.yy285; +{ yylhsminor.yy429 = tVariantListAppend(yymsp[-2].minor.yy429, &yymsp[0].minor.yy218, -1); } + yymsp[-2].minor.yy429 = yylhsminor.yy429; break; case 146: /* tagitemlist ::= tagitem */ -{ yylhsminor.yy285 = tVariantListAppend(NULL, &yymsp[0].minor.yy362, -1); } - yymsp[0].minor.yy285 = yylhsminor.yy285; +{ yylhsminor.yy429 = tVariantListAppend(NULL, &yymsp[0].minor.yy218, -1); } + yymsp[0].minor.yy429 = yylhsminor.yy429; break; case 147: /* tagitem ::= INTEGER */ case 148: /* tagitem ::= FLOAT */ yytestcase(yyruleno==148); case 149: /* tagitem ::= STRING */ yytestcase(yyruleno==149); case 150: /* tagitem ::= BOOL */ yytestcase(yyruleno==150); -{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy362, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy362 = yylhsminor.yy362; +{ toTSDBType(yymsp[0].minor.yy0.type); tVariantCreate(&yylhsminor.yy218, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy218 = yylhsminor.yy218; break; case 151: /* tagitem ::= NULL */ -{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy362, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy362 = yylhsminor.yy362; +{ yymsp[0].minor.yy0.type = 0; tVariantCreate(&yylhsminor.yy218, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy218 = yylhsminor.yy218; break; case 152: /* tagitem ::= MINUS INTEGER */ case 153: /* tagitem ::= MINUS FLOAT */ yytestcase(yyruleno==153); @@ -2587,56 +2583,56 @@ static void yy_reduce( yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = yymsp[0].minor.yy0.type; toTSDBType(yymsp[-1].minor.yy0.type); - tVariantCreate(&yylhsminor.yy362, &yymsp[-1].minor.yy0); + tVariantCreate(&yylhsminor.yy218, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy362 = yylhsminor.yy362; + yymsp[-1].minor.yy218 = yylhsminor.yy218; break; case 156: /* select ::= SELECT selcollist from where_opt interval_opt session_option fill_opt sliding_opt groupby_opt orderby_opt having_opt slimit_opt limit_opt */ { - yylhsminor.yy342 = tSetQuerySqlNode(&yymsp[-12].minor.yy0, yymsp[-11].minor.yy285, yymsp[-10].minor.yy162, yymsp[-9].minor.yy178, yymsp[-4].minor.yy285, yymsp[-3].minor.yy285, &yymsp[-8].minor.yy376, &yymsp[-7].minor.yy523, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy285, &yymsp[0].minor.yy438, &yymsp[-1].minor.yy438); + yylhsminor.yy254 = tSetQuerySqlNode(&yymsp[-12].minor.yy0, yymsp[-11].minor.yy429, yymsp[-10].minor.yy70, yymsp[-9].minor.yy170, yymsp[-4].minor.yy429, yymsp[-3].minor.yy429, &yymsp[-8].minor.yy220, &yymsp[-7].minor.yy87, &yymsp[-5].minor.yy0, yymsp[-6].minor.yy429, &yymsp[0].minor.yy18, &yymsp[-1].minor.yy18); } - yymsp[-12].minor.yy342 = yylhsminor.yy342; + yymsp[-12].minor.yy254 = yylhsminor.yy254; break; case 157: /* select ::= LP select RP */ -{yymsp[-2].minor.yy342 = yymsp[-1].minor.yy342;} +{yymsp[-2].minor.yy254 = yymsp[-1].minor.yy254;} break; case 158: /* union ::= select */ -{ yylhsminor.yy513 = setSubclause(NULL, yymsp[0].minor.yy342); } - yymsp[0].minor.yy513 = yylhsminor.yy513; +{ yylhsminor.yy141 = setSubclause(NULL, yymsp[0].minor.yy254); } + yymsp[0].minor.yy141 = yylhsminor.yy141; break; case 159: /* union ::= union UNION ALL select */ -{ yylhsminor.yy513 = appendSelectClause(yymsp[-3].minor.yy513, yymsp[0].minor.yy342); } - yymsp[-3].minor.yy513 = yylhsminor.yy513; +{ yylhsminor.yy141 = appendSelectClause(yymsp[-3].minor.yy141, yymsp[0].minor.yy254); } + yymsp[-3].minor.yy141 = yylhsminor.yy141; break; case 160: /* cmd ::= union */ -{ setSqlInfo(pInfo, yymsp[0].minor.yy513, NULL, TSDB_SQL_SELECT); } +{ setSqlInfo(pInfo, yymsp[0].minor.yy141, NULL, TSDB_SQL_SELECT); } break; case 161: /* select ::= SELECT selcollist */ { - yylhsminor.yy342 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy285, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + yylhsminor.yy254 = tSetQuerySqlNode(&yymsp[-1].minor.yy0, yymsp[0].minor.yy429, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); } - yymsp[-1].minor.yy342 = yylhsminor.yy342; + yymsp[-1].minor.yy254 = yylhsminor.yy254; break; case 162: /* sclp ::= selcollist COMMA */ -{yylhsminor.yy285 = yymsp[-1].minor.yy285;} - yymsp[-1].minor.yy285 = yylhsminor.yy285; +{yylhsminor.yy429 = yymsp[-1].minor.yy429;} + yymsp[-1].minor.yy429 = yylhsminor.yy429; break; case 163: /* sclp ::= */ case 188: /* orderby_opt ::= */ yytestcase(yyruleno==188); -{yymsp[1].minor.yy285 = 0;} +{yymsp[1].minor.yy429 = 0;} break; case 164: /* selcollist ::= sclp distinct expr as */ { - yylhsminor.yy285 = tSqlExprListAppend(yymsp[-3].minor.yy285, yymsp[-1].minor.yy178, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); + yylhsminor.yy429 = tSqlExprListAppend(yymsp[-3].minor.yy429, yymsp[-1].minor.yy170, yymsp[-2].minor.yy0.n? &yymsp[-2].minor.yy0:0, yymsp[0].minor.yy0.n?&yymsp[0].minor.yy0:0); } - yymsp[-3].minor.yy285 = yylhsminor.yy285; + yymsp[-3].minor.yy429 = yylhsminor.yy429; break; case 165: /* selcollist ::= sclp STAR */ { tSqlExpr *pNode = tSqlExprCreateIdValue(NULL, TK_ALL); - yylhsminor.yy285 = tSqlExprListAppend(yymsp[-1].minor.yy285, pNode, 0, 0); + yylhsminor.yy429 = tSqlExprListAppend(yymsp[-1].minor.yy429, pNode, 0, 0); } - yymsp[-1].minor.yy285 = yylhsminor.yy285; + yymsp[-1].minor.yy429 = yylhsminor.yy429; break; case 166: /* as ::= AS ids */ { yymsp[-1].minor.yy0 = yymsp[0].minor.yy0; } @@ -2653,35 +2649,35 @@ static void yy_reduce( yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 171: /* from ::= FROM tablelist */ -{yymsp[-1].minor.yy162 = yymsp[0].minor.yy285;} +{yymsp[-1].minor.yy70 = yymsp[0].minor.yy429;} break; case 172: /* from ::= FROM LP union RP */ -{yymsp[-3].minor.yy162 = yymsp[-1].minor.yy513;} +{yymsp[-3].minor.yy70 = yymsp[-1].minor.yy141;} break; case 173: /* tablelist ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy285 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy429 = setTableNameList(NULL, &yymsp[-1].minor.yy0, NULL); } - yymsp[-1].minor.yy285 = yylhsminor.yy285; + yymsp[-1].minor.yy429 = yylhsminor.yy429; break; case 174: /* tablelist ::= ids cpxName ids */ { toTSDBType(yymsp[-2].minor.yy0.type); toTSDBType(yymsp[0].minor.yy0.type); yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy285 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy429 = setTableNameList(NULL, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy285 = yylhsminor.yy285; + yymsp[-2].minor.yy429 = yylhsminor.yy429; break; case 175: /* tablelist ::= tablelist COMMA ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - yylhsminor.yy285 = setTableNameList(yymsp[-3].minor.yy285, &yymsp[-1].minor.yy0, NULL); + yylhsminor.yy429 = setTableNameList(yymsp[-3].minor.yy429, &yymsp[-1].minor.yy0, NULL); } - yymsp[-3].minor.yy285 = yylhsminor.yy285; + yymsp[-3].minor.yy429 = yylhsminor.yy429; break; case 176: /* tablelist ::= tablelist COMMA ids cpxName ids */ { @@ -2689,35 +2685,35 @@ static void yy_reduce( toTSDBType(yymsp[0].minor.yy0.type); yymsp[-2].minor.yy0.n += yymsp[-1].minor.yy0.n; - yylhsminor.yy285 = setTableNameList(yymsp[-4].minor.yy285, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); + yylhsminor.yy429 = setTableNameList(yymsp[-4].minor.yy429, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } - yymsp[-4].minor.yy285 = yylhsminor.yy285; + yymsp[-4].minor.yy429 = yylhsminor.yy429; break; case 177: /* tmvar ::= VARIABLE */ {yylhsminor.yy0 = yymsp[0].minor.yy0;} yymsp[0].minor.yy0 = yylhsminor.yy0; break; case 178: /* interval_opt ::= INTERVAL LP tmvar RP */ -{yymsp[-3].minor.yy376.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy376.offset.n = 0;} +{yymsp[-3].minor.yy220.interval = yymsp[-1].minor.yy0; yymsp[-3].minor.yy220.offset.n = 0;} break; case 179: /* interval_opt ::= INTERVAL LP tmvar COMMA tmvar RP */ -{yymsp[-5].minor.yy376.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy376.offset = yymsp[-1].minor.yy0;} +{yymsp[-5].minor.yy220.interval = yymsp[-3].minor.yy0; yymsp[-5].minor.yy220.offset = yymsp[-1].minor.yy0;} break; case 180: /* interval_opt ::= */ -{memset(&yymsp[1].minor.yy376, 0, sizeof(yymsp[1].minor.yy376));} +{memset(&yymsp[1].minor.yy220, 0, sizeof(yymsp[1].minor.yy220));} break; case 181: /* session_option ::= */ -{yymsp[1].minor.yy523.col.n = 0; yymsp[1].minor.yy523.gap.n = 0;} +{yymsp[1].minor.yy87.col.n = 0; yymsp[1].minor.yy87.gap.n = 0;} break; case 182: /* session_option ::= SESSION LP ids cpxName COMMA tmvar RP */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - yymsp[-6].minor.yy523.col = yymsp[-4].minor.yy0; - yymsp[-6].minor.yy523.gap = yymsp[-1].minor.yy0; + yymsp[-6].minor.yy87.col = yymsp[-4].minor.yy0; + yymsp[-6].minor.yy87.gap = yymsp[-1].minor.yy0; } break; case 183: /* fill_opt ::= */ -{ yymsp[1].minor.yy285 = 0; } +{ yymsp[1].minor.yy429 = 0; } break; case 184: /* fill_opt ::= FILL LP ID COMMA tagitemlist RP */ { @@ -2725,14 +2721,14 @@ static void yy_reduce( toTSDBType(yymsp[-3].minor.yy0.type); tVariantCreate(&A, &yymsp[-3].minor.yy0); - tVariantListInsert(yymsp[-1].minor.yy285, &A, -1, 0); - yymsp[-5].minor.yy285 = yymsp[-1].minor.yy285; + tVariantListInsert(yymsp[-1].minor.yy429, &A, -1, 0); + yymsp[-5].minor.yy429 = yymsp[-1].minor.yy429; } break; case 185: /* fill_opt ::= FILL LP ID RP */ { toTSDBType(yymsp[-1].minor.yy0.type); - yymsp[-3].minor.yy285 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); + yymsp[-3].minor.yy429 = tVariantListAppendToken(NULL, &yymsp[-1].minor.yy0, -1); } break; case 186: /* sliding_opt ::= SLIDING LP tmvar RP */ @@ -2742,226 +2738,226 @@ static void yy_reduce( {yymsp[1].minor.yy0.n = 0; yymsp[1].minor.yy0.z = NULL; yymsp[1].minor.yy0.type = 0; } break; case 189: /* orderby_opt ::= ORDER BY sortlist */ -{yymsp[-2].minor.yy285 = yymsp[0].minor.yy285;} +{yymsp[-2].minor.yy429 = yymsp[0].minor.yy429;} break; case 190: /* sortlist ::= sortlist COMMA item sortorder */ { - yylhsminor.yy285 = tVariantListAppend(yymsp[-3].minor.yy285, &yymsp[-1].minor.yy362, yymsp[0].minor.yy460); + yylhsminor.yy429 = tVariantListAppend(yymsp[-3].minor.yy429, &yymsp[-1].minor.yy218, yymsp[0].minor.yy116); } - yymsp[-3].minor.yy285 = yylhsminor.yy285; + yymsp[-3].minor.yy429 = yylhsminor.yy429; break; case 191: /* sortlist ::= item sortorder */ { - yylhsminor.yy285 = tVariantListAppend(NULL, &yymsp[-1].minor.yy362, yymsp[0].minor.yy460); + yylhsminor.yy429 = tVariantListAppend(NULL, &yymsp[-1].minor.yy218, yymsp[0].minor.yy116); } - yymsp[-1].minor.yy285 = yylhsminor.yy285; + yymsp[-1].minor.yy429 = yylhsminor.yy429; break; case 192: /* item ::= ids cpxName */ { toTSDBType(yymsp[-1].minor.yy0.type); yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; - tVariantCreate(&yylhsminor.yy362, &yymsp[-1].minor.yy0); + tVariantCreate(&yylhsminor.yy218, &yymsp[-1].minor.yy0); } - yymsp[-1].minor.yy362 = yylhsminor.yy362; + yymsp[-1].minor.yy218 = yylhsminor.yy218; break; case 193: /* sortorder ::= ASC */ -{ yymsp[0].minor.yy460 = TSDB_ORDER_ASC; } +{ yymsp[0].minor.yy116 = TSDB_ORDER_ASC; } break; case 194: /* sortorder ::= DESC */ -{ yymsp[0].minor.yy460 = TSDB_ORDER_DESC;} +{ yymsp[0].minor.yy116 = TSDB_ORDER_DESC;} break; case 195: /* sortorder ::= */ -{ yymsp[1].minor.yy460 = TSDB_ORDER_ASC; } +{ yymsp[1].minor.yy116 = TSDB_ORDER_ASC; } break; case 196: /* groupby_opt ::= */ -{ yymsp[1].minor.yy285 = 0;} +{ yymsp[1].minor.yy429 = 0;} break; case 197: /* groupby_opt ::= GROUP BY grouplist */ -{ yymsp[-2].minor.yy285 = yymsp[0].minor.yy285;} +{ yymsp[-2].minor.yy429 = yymsp[0].minor.yy429;} break; case 198: /* grouplist ::= grouplist COMMA item */ { - yylhsminor.yy285 = tVariantListAppend(yymsp[-2].minor.yy285, &yymsp[0].minor.yy362, -1); + yylhsminor.yy429 = tVariantListAppend(yymsp[-2].minor.yy429, &yymsp[0].minor.yy218, -1); } - yymsp[-2].minor.yy285 = yylhsminor.yy285; + yymsp[-2].minor.yy429 = yylhsminor.yy429; break; case 199: /* grouplist ::= item */ { - yylhsminor.yy285 = tVariantListAppend(NULL, &yymsp[0].minor.yy362, -1); + yylhsminor.yy429 = tVariantListAppend(NULL, &yymsp[0].minor.yy218, -1); } - yymsp[0].minor.yy285 = yylhsminor.yy285; + yymsp[0].minor.yy429 = yylhsminor.yy429; break; case 200: /* having_opt ::= */ case 210: /* where_opt ::= */ yytestcase(yyruleno==210); case 249: /* expritem ::= */ yytestcase(yyruleno==249); -{yymsp[1].minor.yy178 = 0;} +{yymsp[1].minor.yy170 = 0;} break; case 201: /* having_opt ::= HAVING expr */ case 211: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==211); -{yymsp[-1].minor.yy178 = yymsp[0].minor.yy178;} +{yymsp[-1].minor.yy170 = yymsp[0].minor.yy170;} break; case 202: /* limit_opt ::= */ case 206: /* slimit_opt ::= */ yytestcase(yyruleno==206); -{yymsp[1].minor.yy438.limit = -1; yymsp[1].minor.yy438.offset = 0;} +{yymsp[1].minor.yy18.limit = -1; yymsp[1].minor.yy18.offset = 0;} break; case 203: /* limit_opt ::= LIMIT signed */ case 207: /* slimit_opt ::= SLIMIT signed */ yytestcase(yyruleno==207); -{yymsp[-1].minor.yy438.limit = yymsp[0].minor.yy525; yymsp[-1].minor.yy438.offset = 0;} +{yymsp[-1].minor.yy18.limit = yymsp[0].minor.yy481; yymsp[-1].minor.yy18.offset = 0;} break; case 204: /* limit_opt ::= LIMIT signed OFFSET signed */ -{ yymsp[-3].minor.yy438.limit = yymsp[-2].minor.yy525; yymsp[-3].minor.yy438.offset = yymsp[0].minor.yy525;} +{ yymsp[-3].minor.yy18.limit = yymsp[-2].minor.yy481; yymsp[-3].minor.yy18.offset = yymsp[0].minor.yy481;} break; case 205: /* limit_opt ::= LIMIT signed COMMA signed */ -{ yymsp[-3].minor.yy438.limit = yymsp[0].minor.yy525; yymsp[-3].minor.yy438.offset = yymsp[-2].minor.yy525;} +{ yymsp[-3].minor.yy18.limit = yymsp[0].minor.yy481; yymsp[-3].minor.yy18.offset = yymsp[-2].minor.yy481;} break; case 208: /* slimit_opt ::= SLIMIT signed SOFFSET signed */ -{yymsp[-3].minor.yy438.limit = yymsp[-2].minor.yy525; yymsp[-3].minor.yy438.offset = yymsp[0].minor.yy525;} +{yymsp[-3].minor.yy18.limit = yymsp[-2].minor.yy481; yymsp[-3].minor.yy18.offset = yymsp[0].minor.yy481;} break; case 209: /* slimit_opt ::= SLIMIT signed COMMA signed */ -{yymsp[-3].minor.yy438.limit = yymsp[0].minor.yy525; yymsp[-3].minor.yy438.offset = yymsp[-2].minor.yy525;} +{yymsp[-3].minor.yy18.limit = yymsp[0].minor.yy481; yymsp[-3].minor.yy18.offset = yymsp[-2].minor.yy481;} break; case 212: /* expr ::= LP expr RP */ -{yylhsminor.yy178 = yymsp[-1].minor.yy178; yylhsminor.yy178->token.z = yymsp[-2].minor.yy0.z; yylhsminor.yy178->token.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = yymsp[-1].minor.yy170; yylhsminor.yy170->token.z = yymsp[-2].minor.yy0.z; yylhsminor.yy170->token.n = (yymsp[0].minor.yy0.z - yymsp[-2].minor.yy0.z + 1);} + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 213: /* expr ::= ID */ -{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} - yymsp[0].minor.yy178 = yylhsminor.yy178; +{ yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_ID);} + yymsp[0].minor.yy170 = yylhsminor.yy170; break; case 214: /* expr ::= ID DOT ID */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ID);} + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 215: /* expr ::= ID DOT STAR */ -{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{ yymsp[-2].minor.yy0.n += (1+yymsp[0].minor.yy0.n); yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[-2].minor.yy0, TK_ALL);} + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 216: /* expr ::= INTEGER */ -{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} - yymsp[0].minor.yy178 = yylhsminor.yy178; +{ yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_INTEGER);} + yymsp[0].minor.yy170 = yylhsminor.yy170; break; case 217: /* expr ::= MINUS INTEGER */ case 218: /* expr ::= PLUS INTEGER */ yytestcase(yyruleno==218); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} - yymsp[-1].minor.yy178 = yylhsminor.yy178; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_INTEGER; yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_INTEGER);} + yymsp[-1].minor.yy170 = yylhsminor.yy170; break; case 219: /* expr ::= FLOAT */ -{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} - yymsp[0].minor.yy178 = yylhsminor.yy178; +{ yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_FLOAT);} + yymsp[0].minor.yy170 = yylhsminor.yy170; break; case 220: /* expr ::= MINUS FLOAT */ case 221: /* expr ::= PLUS FLOAT */ yytestcase(yyruleno==221); -{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} - yymsp[-1].minor.yy178 = yylhsminor.yy178; +{ yymsp[-1].minor.yy0.n += yymsp[0].minor.yy0.n; yymsp[-1].minor.yy0.type = TK_FLOAT; yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[-1].minor.yy0, TK_FLOAT);} + yymsp[-1].minor.yy170 = yylhsminor.yy170; break; case 222: /* expr ::= STRING */ -{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} - yymsp[0].minor.yy178 = yylhsminor.yy178; +{ yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_STRING);} + yymsp[0].minor.yy170 = yylhsminor.yy170; break; case 223: /* expr ::= NOW */ -{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } - yymsp[0].minor.yy178 = yylhsminor.yy178; +{ yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_NOW); } + yymsp[0].minor.yy170 = yylhsminor.yy170; break; case 224: /* expr ::= VARIABLE */ -{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} - yymsp[0].minor.yy178 = yylhsminor.yy178; +{ yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_VARIABLE);} + yymsp[0].minor.yy170 = yylhsminor.yy170; break; case 225: /* expr ::= BOOL */ -{ yylhsminor.yy178 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} - yymsp[0].minor.yy178 = yylhsminor.yy178; +{ yylhsminor.yy170 = tSqlExprCreateIdValue(&yymsp[0].minor.yy0, TK_BOOL);} + yymsp[0].minor.yy170 = yylhsminor.yy170; break; case 226: /* expr ::= ID LP exprlist RP */ -{ yylhsminor.yy178 = tSqlExprCreateFunction(yymsp[-1].minor.yy285, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy178 = yylhsminor.yy178; +{ yylhsminor.yy170 = tSqlExprCreateFunction(yymsp[-1].minor.yy429, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy170 = yylhsminor.yy170; break; case 227: /* expr ::= ID LP STAR RP */ -{ yylhsminor.yy178 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } - yymsp[-3].minor.yy178 = yylhsminor.yy178; +{ yylhsminor.yy170 = tSqlExprCreateFunction(NULL, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, yymsp[-3].minor.yy0.type); } + yymsp[-3].minor.yy170 = yylhsminor.yy170; break; case 228: /* expr ::= expr IS NULL */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, NULL, TK_ISNULL);} - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, NULL, TK_ISNULL);} + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 229: /* expr ::= expr IS NOT NULL */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-3].minor.yy178, NULL, TK_NOTNULL);} - yymsp[-3].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-3].minor.yy170, NULL, TK_NOTNULL);} + yymsp[-3].minor.yy170 = yylhsminor.yy170; break; case 230: /* expr ::= expr LT expr */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_LT);} - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_LT);} + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 231: /* expr ::= expr GT expr */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_GT);} - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_GT);} + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 232: /* expr ::= expr LE expr */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_LE);} - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_LE);} + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 233: /* expr ::= expr GE expr */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_GE);} - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_GE);} + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 234: /* expr ::= expr NE expr */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_NE);} - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_NE);} + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 235: /* expr ::= expr EQ expr */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_EQ);} - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_EQ);} + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 236: /* expr ::= expr BETWEEN expr AND expr */ -{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy178); yylhsminor.yy178 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy178, yymsp[-2].minor.yy178, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy178, TK_LE), TK_AND);} - yymsp[-4].minor.yy178 = yylhsminor.yy178; +{ tSqlExpr* X2 = tSqlExprClone(yymsp[-4].minor.yy170); yylhsminor.yy170 = tSqlExprCreate(tSqlExprCreate(yymsp[-4].minor.yy170, yymsp[-2].minor.yy170, TK_GE), tSqlExprCreate(X2, yymsp[0].minor.yy170, TK_LE), TK_AND);} + yymsp[-4].minor.yy170 = yylhsminor.yy170; break; case 237: /* expr ::= expr AND expr */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_AND);} - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_AND);} + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 238: /* expr ::= expr OR expr */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_OR); } - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_OR); } + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 239: /* expr ::= expr PLUS expr */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_PLUS); } - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_PLUS); } + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 240: /* expr ::= expr MINUS expr */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_MINUS); } - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_MINUS); } + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 241: /* expr ::= expr STAR expr */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_STAR); } - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_STAR); } + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 242: /* expr ::= expr SLASH expr */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_DIVIDE);} - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_DIVIDE);} + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 243: /* expr ::= expr REM expr */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_REM); } - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_REM); } + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 244: /* expr ::= expr LIKE expr */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-2].minor.yy178, yymsp[0].minor.yy178, TK_LIKE); } - yymsp[-2].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-2].minor.yy170, yymsp[0].minor.yy170, TK_LIKE); } + yymsp[-2].minor.yy170 = yylhsminor.yy170; break; case 245: /* expr ::= expr IN LP exprlist RP */ -{yylhsminor.yy178 = tSqlExprCreate(yymsp[-4].minor.yy178, (tSqlExpr*)yymsp[-1].minor.yy285, TK_IN); } - yymsp[-4].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = tSqlExprCreate(yymsp[-4].minor.yy170, (tSqlExpr*)yymsp[-1].minor.yy429, TK_IN); } + yymsp[-4].minor.yy170 = yylhsminor.yy170; break; case 246: /* exprlist ::= exprlist COMMA expritem */ -{yylhsminor.yy285 = tSqlExprListAppend(yymsp[-2].minor.yy285,yymsp[0].minor.yy178,0, 0);} - yymsp[-2].minor.yy285 = yylhsminor.yy285; +{yylhsminor.yy429 = tSqlExprListAppend(yymsp[-2].minor.yy429,yymsp[0].minor.yy170,0, 0);} + yymsp[-2].minor.yy429 = yylhsminor.yy429; break; case 247: /* exprlist ::= expritem */ -{yylhsminor.yy285 = tSqlExprListAppend(0,yymsp[0].minor.yy178,0, 0);} - yymsp[0].minor.yy285 = yylhsminor.yy285; +{yylhsminor.yy429 = tSqlExprListAppend(0,yymsp[0].minor.yy170,0, 0);} + yymsp[0].minor.yy429 = yylhsminor.yy429; break; case 248: /* expritem ::= expr */ -{yylhsminor.yy178 = yymsp[0].minor.yy178;} - yymsp[0].minor.yy178 = yylhsminor.yy178; +{yylhsminor.yy170 = yymsp[0].minor.yy170;} + yymsp[0].minor.yy170 = yylhsminor.yy170; break; case 250: /* cmd ::= RESET QUERY CACHE */ { setDCLSqlElems(pInfo, TSDB_SQL_RESET_CACHE, 0);} @@ -2969,7 +2965,7 @@ static void yy_reduce( case 251: /* cmd ::= ALTER TABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy285, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy429, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; @@ -2987,7 +2983,7 @@ static void yy_reduce( case 253: /* cmd ::= ALTER TABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy285, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy429, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; @@ -3022,7 +3018,7 @@ static void yy_reduce( toTSDBType(yymsp[-2].minor.yy0.type); SArray* A = tVariantListAppendToken(NULL, &yymsp[-2].minor.yy0, -1); - A = tVariantListAppend(A, &yymsp[0].minor.yy362, -1); + A = tVariantListAppend(A, &yymsp[0].minor.yy218, -1); SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-6].minor.yy0, NULL, A, TSDB_ALTER_TABLE_UPDATE_TAG_VAL, -1); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); @@ -3031,7 +3027,7 @@ static void yy_reduce( case 257: /* cmd ::= ALTER STABLE ids cpxName ADD COLUMN columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy285, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy429, NULL, TSDB_ALTER_TABLE_ADD_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; @@ -3049,7 +3045,7 @@ static void yy_reduce( case 259: /* cmd ::= ALTER STABLE ids cpxName ADD TAG columnlist */ { yymsp[-4].minor.yy0.n += yymsp[-3].minor.yy0.n; - SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy285, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); + SAlterTableInfo* pAlterTable = tSetAlterTableInfo(&yymsp[-4].minor.yy0, yymsp[0].minor.yy429, NULL, TSDB_ALTER_TABLE_ADD_TAG_COLUMN, TSDB_SUPER_TABLE); setSqlInfo(pInfo, pAlterTable, NULL, TSDB_SQL_ALTER_TABLE); } break; diff --git a/tests/script/general/parser/create_mt.sim b/tests/script/general/parser/create_mt.sim index 830b72f93f..ae1629dce9 100644 --- a/tests/script/general/parser/create_mt.sim +++ b/tests/script/general/parser/create_mt.sim @@ -126,8 +126,7 @@ $tb_ = table $tbs = tables $db_ = database $dbs = databases -$mt_ = metric -$mts = metrics +$ses = session $int = int $bint = bigint $binary = binary @@ -145,8 +144,7 @@ sql_error create table $mt (ts timestamp, col1 int) tags ( $tb_ int) sql_error create table $mt (ts timestamp, col1 int) tags ( $tbs int) sql_error create table $mt (ts timestamp, col1 int) tags ( $db_ int) sql_error create table $mt (ts timestamp, col1 int) tags ( $dbs int) -sql_error create table $mt (ts timestamp, col1 int) tags ( $mt_ int) -sql_error create table $mt (ts timestamp, col1 int) tags ( $mts int) +sql_error create table $mt (ts timestamp, col1 int) tags ( $ses int) sql_error create table $mt (ts timestamp, col1 int) tags ( $int int) sql_error create table $mt (ts timestamp, col1 int) tags ( $bint int) sql_error create table $mt (ts timestamp, col1 int) tags ( $binary int) diff --git a/tests/script/general/parser/create_tb.sim b/tests/script/general/parser/create_tb.sim index d30a1392ef..eb6e4f71c3 100644 --- a/tests/script/general/parser/create_tb.sim +++ b/tests/script/general/parser/create_tb.sim @@ -90,8 +90,7 @@ $tb_ = table $tbs = tables $db_ = database $dbs = databases -$mt_ = metric -$mts = metrics +$ses = session $int = int $bint = bigint $binary = binary @@ -105,9 +104,8 @@ $nchar = nchar sql_error create table $tb (ts timestamp, $tb_ int) sql_error create table $tb (ts timestamp, $tbs int) sql_error create table $tb (ts timestamp, $db_ int) -sql_error create table $tb (ts timestamp, $dbs int) -sql_error create table $tb (ts timestamp, $mt_ int) -sql_error create table $tb (ts timestamp, $mts int) +sql_error create table $tb (ts timestamp, $dbs int) +sql_error create table $tb (ts timestamp, $ses int) sql_error create table $tb (ts timestamp, $int int) sql_error create table $tb (ts timestamp, $bint int) sql_error create table $tb (ts timestamp, $binary int) From ea82920d84a31a8d1e92107b7dc27bc89d9620bc Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 17 Mar 2021 13:36:54 +0800 Subject: [PATCH 43/89] remove duplicate case --- tests/pytest/fulltest.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 84a52d81a9..409d684d01 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -156,7 +156,6 @@ python3 ./test.py -f update/bug_td2279.py #======================p2-end=============== #======================p3-start=============== -python3 ./test.py -f insert/randomNullCommit.py # user python3 ./test.py -f user/user_create.py @@ -275,7 +274,6 @@ python3 ./test.py -f functions/function_twa.py -r 1 python3 ./test.py -f functions/function_twa_test2.py python3 ./test.py -f functions/function_stddev_td2555.py python3 ./test.py -f insert/metadataUpdate.py -python3 ./test.py -f tools/taosdemoTest2.py python3 ./test.py -f query/last_cache.py python3 ./test.py -f query/last_row_cache.py python3 ./test.py -f account/account_create.py @@ -290,7 +288,6 @@ python3 ./test.py -f query/filterAllUnsignedIntTypes.py python3 ./test.py -f functions/function_percentile2.py python3 ./test.py -f insert/boundary2.py -python3 ./test.py -f query/queryFillTest.py python3 ./test.py -f alter/alter_debugFlag.py python3 ./test.py -f query/queryBetweenAnd.py python3 ./test.py -f tag_lite/alter_tag.py From 137405ba613619da0a3925995ba3e4864baa0719 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 17 Mar 2021 13:50:55 +0800 Subject: [PATCH 44/89] fix erros --- tests/script/jenkins/basic.txt | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 33489b50ff..55c88a2891 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -1,7 +1,7 @@ cd ../../../debug; cmake .. cd ../../../debug; make -#======================s1-start=============== +#======================b1-start=============== ./test.sh -f general/field/2.sim ./test.sh -f general/field/3.sim @@ -89,8 +89,8 @@ cd ../../../debug; make ./test.sh -f general/db/nosuchfile.sim ./test.sh -f general/parser/function.sim -#======================s1-end=============== -#======================s2-start=============== +#======================b1-end=============== +#======================b2-start=============== ./test.sh -f general/tag/3.sim ./test.sh -f general/tag/4.sim @@ -163,8 +163,8 @@ cd ../../../debug; make ./test.sh -f unique/cluster/cache.sim ./test.sh -f unique/cluster/vgroup100.sim -#======================s2-end=============== -#======================s3-start=============== +#======================b2-end=============== +#======================b3-start=============== ./test.sh -f unique/arbitrator/check_cluster_cfg_para.sim #./test.sh -f unique/arbitrator/dn2_mn1_cache_file_sync.sim @@ -222,8 +222,8 @@ cd ../../../debug; make ./test.sh -f unique/stable/replica3_dnode6.sim ./test.sh -f unique/stable/replica3_vnode3.sim -#======================s3-end=============== -#======================s4-start=============== +#======================b3-end=============== +#======================b4-start=============== ./test.sh -f unique/http/admin.sim ./test.sh -f unique/http/opentsdb.sim @@ -271,8 +271,8 @@ cd ../../../debug; make ./test.sh -f issue/TD-2680.sim ./test.sh -f unique/dnode/lossdata.sim -#======================s4-end=============== -#======================s5-start=============== +#======================b4-end=============== +#======================b5-start=============== ./test.sh -f unique/dnode/alternativeRole.sim ./test.sh -f unique/dnode/balance1.sim @@ -294,8 +294,8 @@ cd ../../../debug; make ./test.sh -f unique/dnode/datatrans_3node.sim ./test.sh -f unique/dnode/datatrans_3node_2.sim -#======================s5-end=============== -#======================s6-start=============== +#======================b5-end=============== +#======================b6-start=============== ./test.sh -f unique/dnode/reason.sim ./test.sh -f unique/dnode/remove1.sim @@ -335,8 +335,8 @@ cd ../../../debug; make ./test.sh -f general/import/large.sim ./test.sh -f general/import/replica1.sim -#======================s6-end=============== -#======================s7-start=============== +#======================b6-end=============== +#======================b7-start=============== ./test.sh -f general/compute/avg.sim ./test.sh -f general/compute/bottom.sim @@ -425,4 +425,4 @@ cd ../../../debug; make ./test.sh -f general/parser/timestamp.sim ./test.sh -f general/parser/sliding.sim -#======================s7-end=============== +#======================b7-end=============== From 39a51beef14cd9ddadb4ba94f21153f6d44c3108 Mon Sep 17 00:00:00 2001 From: Elias Soong Date: Wed, 17 Mar 2021 13:53:55 +0800 Subject: [PATCH 45/89] [TD-3336] : update description about "make install" and start service. --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 489b6d0a4e..6ad9d4a97f 100644 --- a/README.md +++ b/README.md @@ -176,18 +176,18 @@ option "-c test/cfg" specifies the system configuration file directory. # Installing After building successfully, TDengine can be installed by: ```bash -make install +sudo make install ``` -Users can find more information about directories installed on the system in the [directory and files](https://www.taosdata.com/en/documentation/administrator/#Directory-and-Files) section. It should be noted that installing from source code does not configure service management for TDengine. +Users can find more information about directories installed on the system in the [directory and files](https://www.taosdata.com/en/documentation/administrator/#Directory-and-Files) section. Since version 2.0, installing from source code will also configure service management for TDengine. Users can also choose to [install from packages](https://www.taosdata.com/en/getting-started/#Install-from-Package) for it. To start the service after installation, in a terminal, use: -```cmd -taosd +```bash +sudo systemctl start taosd ``` Then users can use the [TDengine shell](https://www.taosdata.com/en/getting-started/#TDengine-Shell) to connect the TDengine server. In a terminal, use: -```cmd +```bash taos ``` From 4478f3496bc1513d83d5eacc5f81acebc5b7ce2e Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 17 Mar 2021 14:01:13 +0800 Subject: [PATCH 46/89] abort pervious build --- Jenkinsfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e7603b578b..d8c9666828 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,13 +24,7 @@ def abortPreviousBuilds() { build.doKill() //doTerm(),doKill(),doTerm() } } -//abort previous build -abortPreviousBuilds() -def abort_previous(){ - def buildNumber = env.BUILD_NUMBER as int - if (buildNumber > 1) milestone(buildNumber - 1) - milestone(buildNumber) -} + def pre_test(){ catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { sh ''' From 8930b00ead4177a3b127f237f4c269fbfdcd9c7a Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 17 Mar 2021 14:19:03 +0800 Subject: [PATCH 47/89] inc coreverage of operation --- tests/pytest/functions/function_operations.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/pytest/functions/function_operations.py b/tests/pytest/functions/function_operations.py index e703147b67..162aa3eb65 100644 --- a/tests/pytest/functions/function_operations.py +++ b/tests/pytest/functions/function_operations.py @@ -92,14 +92,16 @@ class TDTestCase: col_list = [ 'col1' , 'col2' , 'col3' , 'col4' , 'col5' , 'col6' , 'col7' , 'col8' , 'col9' , 'col11' , 'col12' , 'col13' , 'col14' , '1' , '1.1' , 'NULL' ] op_list = [ '+' , '-' , '*' , '/' , '%' ] err_list = [ 'col7' , 'col8' , 'col9' , 'NULL' ] + order_lsit = [ ' order by ts ', ' order by ts desc ', ' order by ts asc '] for i in col_list : for j in col_list : for k in op_list : - sql = " select %s %s %s from test1 " % ( i , k , j ) - if i in err_list or j in err_list: - tdSql.error(sql) - else: - tdSql.query(sql) + for l in order_lsit : + sql = " select %s %s %s from test1 %s" % ( i , k , j , l ) + if i in err_list or j in err_list: + tdSql.error(sql) + else: + tdSql.query(sql) def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) From 4e34b78dcdec327aedb7c923dfc93f066304678d Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 17 Mar 2021 14:24:55 +0800 Subject: [PATCH 48/89] add stage after build --- Jenkinsfile | 11 +++++++++++ tests/pytest/functions/function_operations.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d8c9666828..685fde662d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -267,6 +267,17 @@ pipeline { } } } + stage('after_build'){ + agent{label 'master'} + when { + changeRequest() + } + steps { + sh''' + df -h + ''' + } + } } post { success { diff --git a/tests/pytest/functions/function_operations.py b/tests/pytest/functions/function_operations.py index 162aa3eb65..4f126371b9 100644 --- a/tests/pytest/functions/function_operations.py +++ b/tests/pytest/functions/function_operations.py @@ -92,7 +92,7 @@ class TDTestCase: col_list = [ 'col1' , 'col2' , 'col3' , 'col4' , 'col5' , 'col6' , 'col7' , 'col8' , 'col9' , 'col11' , 'col12' , 'col13' , 'col14' , '1' , '1.1' , 'NULL' ] op_list = [ '+' , '-' , '*' , '/' , '%' ] err_list = [ 'col7' , 'col8' , 'col9' , 'NULL' ] - order_lsit = [ ' order by ts ', ' order by ts desc ', ' order by ts asc '] + order_lsit = [ ' order by ts ', ' order by ts desc ', ' order by ts asc'] for i in col_list : for j in col_list : for k in op_list : From 683b1282b8a5b5f544104d8a291fba90958de3d6 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 17 Mar 2021 14:28:36 +0800 Subject: [PATCH 49/89] abort build --- Jenkinsfile | 8 +++++++- tests/pytest/functions/function_operations.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 685fde662d..a78851fd90 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -24,7 +24,13 @@ def abortPreviousBuilds() { build.doKill() //doTerm(),doKill(),doTerm() } } - +//abort previous build +abortPreviousBuilds() +def abort_previous(){ + def buildNumber = env.BUILD_NUMBER as int + if (buildNumber > 1) milestone(buildNumber - 1) + milestone(buildNumber) +} def pre_test(){ catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') { sh ''' diff --git a/tests/pytest/functions/function_operations.py b/tests/pytest/functions/function_operations.py index 4f126371b9..162aa3eb65 100644 --- a/tests/pytest/functions/function_operations.py +++ b/tests/pytest/functions/function_operations.py @@ -92,7 +92,7 @@ class TDTestCase: col_list = [ 'col1' , 'col2' , 'col3' , 'col4' , 'col5' , 'col6' , 'col7' , 'col8' , 'col9' , 'col11' , 'col12' , 'col13' , 'col14' , '1' , '1.1' , 'NULL' ] op_list = [ '+' , '-' , '*' , '/' , '%' ] err_list = [ 'col7' , 'col8' , 'col9' , 'NULL' ] - order_lsit = [ ' order by ts ', ' order by ts desc ', ' order by ts asc'] + order_lsit = [ ' order by ts ', ' order by ts desc ', ' order by ts asc '] for i in col_list : for j in col_list : for k in op_list : From 1df23b1885991c445c4d75f6eae6aa74b93f1141 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 17 Mar 2021 14:49:56 +0800 Subject: [PATCH 50/89] change --- Jenkinsfile | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a78851fd90..9a4515278a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -273,18 +273,7 @@ pipeline { } } } - stage('after_build'){ - agent{label 'master'} - when { - changeRequest() - } - steps { - sh''' - df -h - ''' - } - } - } + post { success { emailext ( From 87c1726c72699bace2ca31c21c6a592163377354 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 17 Mar 2021 14:53:17 +0800 Subject: [PATCH 51/89] change --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9a4515278a..e7603b578b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -273,7 +273,7 @@ pipeline { } } } - + } post { success { emailext ( From be171d7787bc53d5b1d79632de4976d09498ef9a Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Wed, 17 Mar 2021 15:02:51 +0800 Subject: [PATCH 52/89] [TD-3332]: vnode report status if not closing instead of not ready --- src/vnode/src/vnodeMgmt.c | 4 ++-- src/vnode/src/vnodeStatus.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/vnode/src/vnodeMgmt.c b/src/vnode/src/vnodeMgmt.c index 8469ab12c1..71d9bc07f5 100644 --- a/src/vnode/src/vnodeMgmt.c +++ b/src/vnode/src/vnodeMgmt.c @@ -128,7 +128,7 @@ static void vnodeBuildVloadMsg(SVnodeObj *pVnode, SStatusMsg *pStatus) { int64_t compStorage = 0; int64_t pointsWritten = 0; - if (!vnodeInReadyStatus(pVnode)) return; + if (vnodeInClosingStatus(pVnode)) return; if (pStatus->openVnodes >= TSDB_MAX_VNODES) return; if (pVnode->tsdb) { @@ -194,4 +194,4 @@ void vnodeSetAccess(SVgroupAccess *pAccess, int32_t numOfVnodes) { vnodeRelease(pVnode); } } -} \ No newline at end of file +} diff --git a/src/vnode/src/vnodeStatus.c b/src/vnode/src/vnodeStatus.c index 6889843530..64da8a4ad1 100644 --- a/src/vnode/src/vnodeStatus.c +++ b/src/vnode/src/vnodeStatus.c @@ -153,6 +153,18 @@ bool vnodeInReadyOrUpdatingStatus(SVnodeObj* pVnode) { return in; } +bool vnodeInClosingStatus(SVnodeObj* pVnode) { + bool in = false; + pthread_mutex_lock(&pVnode->statusMutex); + + if (pVnode->status == TAOS_VN_STATUS_CLOSING) { + in = true; + } + + pthread_mutex_unlock(&pVnode->statusMutex); + return in; +} + bool vnodeInResetStatus(SVnodeObj* pVnode) { bool in = false; pthread_mutex_lock(&pVnode->statusMutex); From ba79d022ce71ac91a34b7ace3272d5d5286ffe77 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 17 Mar 2021 15:16:11 +0800 Subject: [PATCH 53/89] rebalance --- tests/pytest/handle_crash_gen_val_log.sh | 2 +- tests/script/jenkins/basic.txt | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/pytest/handle_crash_gen_val_log.sh b/tests/pytest/handle_crash_gen_val_log.sh index 502c859dad..55c10639d7 100755 --- a/tests/pytest/handle_crash_gen_val_log.sh +++ b/tests/pytest/handle_crash_gen_val_log.sh @@ -16,7 +16,7 @@ TOP_DIR=`pwd` TAOSD_DIR=`find . -name "taosd"|grep -v community|head -n1` nohup $TAOSD_DIR >/dev/null & cd - -./crash_gen.sh --valgrind -p -t 10 -s 500 -b 4 +./crash_gen.sh --valgrind -p -t 10 -s 1000 -b 4 pidof taosd|xargs kill -9 grep 'start to execute\|ERROR SUMMARY' valgrind.err|grep -v 'grep'|uniq|tee crash_gen_mem_err.log diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 55c88a2891..356e318eb4 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -157,9 +157,6 @@ cd ../../../debug; make ./test.sh -f unique/big/tcp.sim ./test.sh -f unique/cluster/alter.sim -./test.sh -f unique/cluster/balance1.sim -./test.sh -f unique/cluster/balance2.sim -./test.sh -f unique/cluster/balance3.sim ./test.sh -f unique/cluster/cache.sim ./test.sh -f unique/cluster/vgroup100.sim @@ -293,6 +290,9 @@ cd ../../../debug; make ./test.sh -f general/connection/test_old_data.sim ./test.sh -f unique/dnode/datatrans_3node.sim ./test.sh -f unique/dnode/datatrans_3node_2.sim +./test.sh -f general/db/alter_tables_d2.sim +./test.sh -f general/db/alter_tables_v1.sim +./test.sh -f general/db/alter_tables_v4.sim #======================b5-end=============== #======================b6-start=============== @@ -334,6 +334,9 @@ cd ../../../debug; make ./test.sh -f general/import/commit.sim ./test.sh -f general/import/large.sim ./test.sh -f general/import/replica1.sim +./test.sh -f unique/cluster/balance1.sim +./test.sh -f unique/cluster/balance2.sim +./test.sh -f unique/cluster/balance3.sim #======================b6-end=============== #======================b7-start=============== @@ -356,9 +359,6 @@ cd ../../../debug; make ./test.sh -f general/compute/top.sim ./test.sh -f general/db/alter_option.sim -./test.sh -f general/db/alter_tables_d2.sim -./test.sh -f general/db/alter_tables_v1.sim -./test.sh -f general/db/alter_tables_v4.sim ./test.sh -f general/db/alter_vgroups.sim ./test.sh -f general/db/basic.sim ./test.sh -f general/db/basic1.sim From b34948c200ecbb7dde4e75817dd02a5ac0369dd8 Mon Sep 17 00:00:00 2001 From: Elias Soong Date: Wed, 17 Mar 2021 15:36:04 +0800 Subject: [PATCH 54/89] [TD-2639] : clarify estimation of memory requirement. --- documentation20/cn/11.administrator/docs.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/documentation20/cn/11.administrator/docs.md b/documentation20/cn/11.administrator/docs.md index 52a0da6551..027828d903 100644 --- a/documentation20/cn/11.administrator/docs.md +++ b/documentation20/cn/11.administrator/docs.md @@ -14,6 +14,8 @@ Memory Size = maxVgroupsPerDb * (blocks * cache + 10MB) + numOfTables * (tagSize 示例:假设是 4 核机器,cache 是缺省大小 16M, blocks 是缺省值 6,假设有 10 万张表,标签总长度是 256 字节,则总的内存需求为:4 \* (16 \* 6 + 10) + 100000 \* (0.25 + 0.5) / 1000 = 499M。 +注意:从这个公式计算得到的内存容量,应理解为系统的“必要需求”,而不是“内存总数”。在实际运行的生产系统中,由于操作系统缓存、资源管理调度等方面的需要,内存规划应当在计算结果的基础上保留一定冗余,以维持系统状态和系统性能的稳定性。 + 实际运行的系统往往会根据数据特点的不同,将数据存放在不同的 DB 里。因此做规划时,也需要考虑。 如果内存充裕,可以加大 Blocks 的配置,这样更多数据将保存在内存里,提高查询速度。 From cf721d477b7156b67d9db850bcdce48e282bfbb8 Mon Sep 17 00:00:00 2001 From: Elias Soong Date: Wed, 17 Mar 2021 15:41:36 +0800 Subject: [PATCH 55/89] [TD-2639] : clarify "now" function usage when insert multi-rows. --- documentation20/cn/12.taos-sql/docs.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/documentation20/cn/12.taos-sql/docs.md b/documentation20/cn/12.taos-sql/docs.md index c89dbda7a0..02352357e1 100644 --- a/documentation20/cn/12.taos-sql/docs.md +++ b/documentation20/cn/12.taos-sql/docs.md @@ -331,7 +331,8 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic ```mysql INSERT INTO tb_name VALUES (field1_value1, ...) (field1_value2, ...) ...; ``` - 向表tb_name中插入多条记录 + 向表tb_name中插入多条记录 + **注意**:在使用“插入多条记录”方式写入数据时,不能把第一列的时间戳取值都设为now,否则会导致语句中的多条记录使用相同的时间戳,于是就可能出现相互覆盖以致这些数据行无法全部被正确保存。 - **按指定的列插入多条记录** ```mysql From 34565eff16aa6dadb3643dc9b1e48d747c9ea5db Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 17 Mar 2021 07:47:51 +0000 Subject: [PATCH 56/89] add some log for debug --- src/query/src/queryMain.c | 4 ++-- src/sync/src/syncRetrieve.c | 44 ++++++++++++++++++------------------- src/vnode/src/vnodeMain.c | 4 ++-- src/vnode/src/vnodeStatus.c | 2 ++ src/vnode/src/vnodeSync.c | 6 ++--- src/wal/src/walWrite.c | 2 +- 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/query/src/queryMain.c b/src/query/src/queryMain.c index d35d4a5ff8..1c839e4cfe 100644 --- a/src/query/src/queryMain.c +++ b/src/query/src/queryMain.c @@ -430,7 +430,7 @@ void qQueryMgmtNotifyClosed(void* pQMgmt) { } SQueryMgmt* pQueryMgmt = pQMgmt; - qDebug("vgId:%d, set querymgmt closed, wait for all queries cancelled", pQueryMgmt->vgId); + qInfo("vgId:%d, set querymgmt closed, wait for all queries cancelled", pQueryMgmt->vgId); pthread_mutex_lock(&pQueryMgmt->lock); pQueryMgmt->closed = true; @@ -445,7 +445,7 @@ void qQueryMgmtReOpen(void *pQMgmt) { } SQueryMgmt *pQueryMgmt = pQMgmt; - qDebug("vgId:%d, set querymgmt reopen", pQueryMgmt->vgId); + qInfo("vgId:%d, set querymgmt reopen", pQueryMgmt->vgId); pthread_mutex_lock(&pQueryMgmt->lock); pQueryMgmt->closed = false; diff --git a/src/sync/src/syncRetrieve.c b/src/sync/src/syncRetrieve.c index be4073760d..18af7bd686 100644 --- a/src/sync/src/syncRetrieve.c +++ b/src/sync/src/syncRetrieve.c @@ -29,7 +29,7 @@ static int32_t syncGetWalVersion(SSyncNode *pNode, SSyncPeer *pPeer) { uint64_t fver, wver; int32_t code = (*pNode->getVersionFp)(pNode->vgId, &fver, &wver); if (code != 0) { - sDebug("%s, vnode is commiting while retrieve, last wver:%" PRIu64, pPeer->id, pPeer->lastWalVer); + sInfo("%s, vnode is commiting while retrieve, last wver:%" PRIu64, pPeer->id, pPeer->lastWalVer); return -1; } @@ -41,12 +41,12 @@ static bool syncIsWalModified(SSyncNode *pNode, SSyncPeer *pPeer) { uint64_t fver, wver; int32_t code = (*pNode->getVersionFp)(pNode->vgId, &fver, &wver); if (code != 0) { - sDebug("%s, vnode is commiting while retrieve, last wver:%" PRIu64, pPeer->id, pPeer->lastWalVer); + sInfo("%s, vnode is commiting while retrieve, last wver:%" PRIu64, pPeer->id, pPeer->lastWalVer); return true; } if (wver != pPeer->lastWalVer) { - sDebug("%s, wal is modified while retrieve, wver:%" PRIu64 ", last:%" PRIu64, pPeer->id, wver, pPeer->lastWalVer); + sInfo("%s, wal is modified while retrieve, wver:%" PRIu64 ", last:%" PRIu64, pPeer->id, wver, pPeer->lastWalVer); return true; } @@ -57,7 +57,7 @@ static int32_t syncGetFileVersion(SSyncNode *pNode, SSyncPeer *pPeer) { uint64_t fver, wver; int32_t code = (*pNode->getVersionFp)(pNode->vgId, &fver, &wver); if (code != 0) { - sDebug("%s, vnode is commiting while get fver for retrieve, last fver:%" PRIu64, pPeer->id, pPeer->lastFileVer); + sInfo("%s, vnode is commiting while get fver for retrieve, last fver:%" PRIu64, pPeer->id, pPeer->lastFileVer); return -1; } @@ -69,13 +69,13 @@ static bool syncAreFilesModified(SSyncNode *pNode, SSyncPeer *pPeer) { uint64_t fver, wver; int32_t code = (*pNode->getVersionFp)(pNode->vgId, &fver, &wver); if (code != 0) { - sDebug("%s, vnode is commiting while retrieve, last fver:%" PRIu64, pPeer->id, pPeer->lastFileVer); + sInfo("%s, vnode is commiting while retrieve, last fver:%" PRIu64, pPeer->id, pPeer->lastFileVer); pPeer->fileChanged = 1; return true; } if (fver != pPeer->lastFileVer) { - sDebug("%s, files are modified while retrieve, fver:%" PRIu64 ", last:%" PRIu64, pPeer->id, fver, pPeer->lastFileVer); + sInfo("%s, files are modified while retrieve, fver:%" PRIu64 ", last:%" PRIu64, pPeer->id, fver, pPeer->lastFileVer); pPeer->fileChanged = 1; return true; } @@ -143,13 +143,13 @@ static int32_t syncReadOneWalRecord(int32_t sfd, SWalHead *pHead) { } if (ret == 0) { - sDebug("sfd:%d, read to the end of file, ret:%d", sfd, ret); + sInfo("sfd:%d, read to the end of file, ret:%d", sfd, ret); return 0; } if (ret != sizeof(SWalHead)) { // file is not at end yet, it shall be reloaded - sDebug("sfd:%d, a partial wal head is read out, ret:%d", sfd, ret); + sInfo("sfd:%d, a partial wal head is read out, ret:%d", sfd, ret); return 0; } @@ -163,7 +163,7 @@ static int32_t syncReadOneWalRecord(int32_t sfd, SWalHead *pHead) { if (ret != pHead->len) { // file is not at end yet, it shall be reloaded - sDebug("sfd:%d, a partial wal conetnt is read out, ret:%d", sfd, ret); + sInfo("sfd:%d, a partial wal conetnt is read out, ret:%d", sfd, ret); return 0; } @@ -184,7 +184,7 @@ static int64_t syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversi return -1; } - sDebug("%s, retrieve last wal:%s, offset:%" PRId64 " fver:%" PRIu64, pPeer->id, name, offset, fversion); + sInfo("%s, retrieve last wal:%s, offset:%" PRId64 " fver:%" PRIu64, pPeer->id, name, offset, fversion); SWalHead *pHead = malloc(SYNC_MAX_SIZE); int64_t bytes = 0; @@ -198,7 +198,7 @@ static int64_t syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversi if (code == 0) { code = bytes; - sDebug("%s, read to the end of wal, bytes:%" PRId64, pPeer->id, bytes); + sInfo("%s, read to the end of wal, bytes:%" PRId64, pPeer->id, bytes); break; } @@ -217,7 +217,7 @@ static int64_t syncRetrieveLastWal(SSyncPeer *pPeer, char *name, uint64_t fversi if (pHead->version >= fversion && fversion > 0) { code = 0; - sDebug("%s, retrieve wal finished, hver:%" PRIu64 " fver:%" PRIu64, pPeer->id, pHead->version, fversion); + sInfo("%s, retrieve wal finished, hver:%" PRIu64 " fver:%" PRIu64, pPeer->id, pHead->version, fversion); break; } } @@ -237,7 +237,7 @@ static int64_t syncProcessLastWal(SSyncPeer *pPeer, char *wname, int64_t index) // get full path to wal file snprintf(fname, sizeof(fname), "%s/%s", pNode->path, wname); - sDebug("%s, start to retrieve last wal:%s", pPeer->id, fname); + sInfo("%s, start to retrieve last wal:%s", pPeer->id, fname); while (1) { if (syncAreFilesModified(pNode, pPeer)) return -1; @@ -245,7 +245,7 @@ static int64_t syncProcessLastWal(SSyncPeer *pPeer, char *wname, int64_t index) int64_t bytes = syncRetrieveLastWal(pPeer, fname, fversion, offset); if (bytes < 0) { - sDebug("%s, failed to retrieve last wal, bytes:%" PRId64, pPeer->id, bytes); + sInfo("%s, failed to retrieve last wal, bytes:%" PRId64, pPeer->id, bytes); return bytes; } @@ -257,13 +257,13 @@ static int64_t syncProcessLastWal(SSyncPeer *pPeer, char *wname, int64_t index) if (fversion == 0) { pPeer->sstatus = TAOS_SYNC_STATUS_CACHE; // start to forward pkt fversion = nodeVersion; // must read data to fversion - sDebug("%s, set sstatus:%s and fver:%" PRIu64, pPeer->id, syncStatus[pPeer->sstatus], fversion); + sInfo("%s, set sstatus:%s and fver:%" PRIu64, pPeer->id, syncStatus[pPeer->sstatus], fversion); } } // if all data up to fversion is read out, it is over if (pPeer->sversion >= fversion && fversion > 0) { - sDebug("%s, data up to fver:%" PRIu64 " has been read out, bytes:%" PRId64 " sver:%" PRIu64, pPeer->id, fversion, bytes, + sInfo("%s, data up to fver:%" PRIu64 " has been read out, bytes:%" PRId64 " sver:%" PRIu64, pPeer->id, fversion, bytes, pPeer->sversion); return 0; } @@ -277,7 +277,7 @@ static int64_t syncProcessLastWal(SSyncPeer *pPeer, char *wname, int64_t index) // if bytes > 0, file is updated, or fversion is not reached but file still open, read again once = 1; offset += bytes; - sDebug("%s, continue retrieve last wal, bytes:%" PRId64 " offset:%" PRId64 " sver:%" PRIu64 " fver:%" PRIu64, pPeer->id, + sInfo("%s, continue retrieve last wal, bytes:%" PRId64 " offset:%" PRId64 " sver:%" PRIu64 " fver:%" PRIu64, pPeer->id, bytes, offset, pPeer->sversion, fversion); } @@ -303,7 +303,7 @@ static int64_t syncRetrieveWal(SSyncPeer *pPeer) { if (wname[0] == 0) { // no wal file code = 0; - sDebug("%s, no wal file anymore", pPeer->id); + sInfo("%s, no wal file anymore", pPeer->id); break; } @@ -320,12 +320,12 @@ static int64_t syncRetrieveWal(SSyncPeer *pPeer) { struct stat fstat; if (stat(fname, &fstat) < 0) { code = -1; - sDebug("%s, failed to stat wal:%s for retrieve since %s, code:0x%" PRIx64, pPeer->id, fname, strerror(errno), code); + sInfo("%s, failed to stat wal:%s for retrieve since %s, code:0x%" PRIx64, pPeer->id, fname, strerror(errno), code); break; } size = fstat.st_size; - sDebug("%s, retrieve wal:%s size:%d", pPeer->id, fname, size); + sInfo("%s, retrieve wal:%s size:%d", pPeer->id, fname, size); int32_t sfd = open(fname, O_RDONLY | O_BINARY); if (sfd < 0) { @@ -374,7 +374,7 @@ static int32_t syncRetrieveFirstPkt(SSyncPeer *pPeer) { sError("%s, failed to send sync-data msg since %s, tranId:%u", pPeer->id, strerror(errno), msg.tranId); return -1; } - sDebug("%s, send sync-data msg to peer, tranId:%u", pPeer->id, msg.tranId); + sInfo("%s, send sync-data msg to peer, tranId:%u", pPeer->id, msg.tranId); SSyncRsp rsp; if (taosReadMsg(pPeer->syncFd, &rsp, sizeof(SSyncRsp)) != sizeof(SSyncRsp)) { @@ -382,7 +382,7 @@ static int32_t syncRetrieveFirstPkt(SSyncPeer *pPeer) { return -1; } - sDebug("%s, recv sync-data rsp from peer, tranId:%u rsp-tranId:%u", pPeer->id, msg.tranId, rsp.tranId); + sInfo("%s, recv sync-data rsp from peer, tranId:%u rsp-tranId:%u", pPeer->id, msg.tranId, rsp.tranId); return 0; } diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index 42b9c024c9..d25cf10774 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -482,7 +482,7 @@ static int32_t vnodeProcessTsdbStatus(void *arg, int32_t status, int32_t eno) { if (status == TSDB_STATUS_COMMIT_START) { pVnode->isCommiting = 1; pVnode->cversion = pVnode->version; - vDebug("vgId:%d, start commit, fver:%" PRIu64 " vver:%" PRIu64, pVnode->vgId, pVnode->fversion, pVnode->version); + vInfo("vgId:%d, start commit, fver:%" PRIu64 " vver:%" PRIu64, pVnode->vgId, pVnode->fversion, pVnode->version); if (!vnodeInInitStatus(pVnode)) { return walRenew(pVnode->wal); } @@ -493,7 +493,7 @@ static int32_t vnodeProcessTsdbStatus(void *arg, int32_t status, int32_t eno) { pVnode->isCommiting = 0; pVnode->isFull = 0; pVnode->fversion = pVnode->cversion; - vDebug("vgId:%d, commit over, fver:%" PRIu64 " vver:%" PRIu64, pVnode->vgId, pVnode->fversion, pVnode->version); + vInfo("vgId:%d, commit over, fver:%" PRIu64 " vver:%" PRIu64, pVnode->vgId, pVnode->fversion, pVnode->version); if (!vnodeInInitStatus(pVnode)) { walRemoveOneOldFile(pVnode->wal); } diff --git a/src/vnode/src/vnodeStatus.c b/src/vnode/src/vnodeStatus.c index 6889843530..1344e1c167 100644 --- a/src/vnode/src/vnodeStatus.c +++ b/src/vnode/src/vnodeStatus.c @@ -109,6 +109,8 @@ bool vnodeSetResetStatus(SVnodeObj* pVnode) { taosMsleep(1); } + vInfo("vgId:%d, set to reset status", pVnode->vgId); + // release local resources only after cutting off outside connections qQueryMgmtNotifyClosed(pVnode->qMgmt); vnodeWaitReadCompleted(pVnode); diff --git a/src/vnode/src/vnodeSync.c b/src/vnode/src/vnodeSync.c index a45eae9b16..929dd15926 100644 --- a/src/vnode/src/vnodeSync.c +++ b/src/vnode/src/vnodeSync.c @@ -91,7 +91,7 @@ void vnodeStartSyncFile(int32_t vgId) { return; } - vDebug("vgId:%d, datafile will be synced", vgId); + vInfo("vgId:%d, datafile will be synced", vgId); vnodeSetResetStatus(pVnode); vnodeRelease(pVnode); @@ -147,7 +147,7 @@ int32_t vnodeGetVersion(int32_t vgId, uint64_t *fver, uint64_t *wver) { int32_t code = 0; if (pVnode->isCommiting) { - vDebug("vgId:%d, vnode is commiting while get version", vgId); + vInfo("vgId:%d, vnode is commiting while get version", vgId); code = -1; } else { *fver = pVnode->fversion; @@ -168,7 +168,7 @@ int32_t vnodeResetVersion(int32_t vgId, uint64_t fver) { pVnode->fversion = fver; pVnode->version = fver; walResetVersion(pVnode->wal, fver); - vDebug("vgId:%d, version reset to %" PRIu64, vgId, fver); + vInfo("vgId:%d, version reset to %" PRIu64, vgId, fver); vnodeRelease(pVnode); return 0; diff --git a/src/wal/src/walWrite.c b/src/wal/src/walWrite.c index 51b770d346..4368ddd7d3 100644 --- a/src/wal/src/walWrite.c +++ b/src/wal/src/walWrite.c @@ -455,7 +455,7 @@ uint64_t walGetVersion(twalh param) { void walResetVersion(twalh param, uint64_t newVer) { SWal *pWal = param; if (pWal == 0) return; - wDebug("vgId:%d, version reset from %" PRIu64 " to %" PRIu64, pWal->vgId, pWal->version, newVer); + wInfo("vgId:%d, version reset from %" PRIu64 " to %" PRIu64, pWal->vgId, pWal->version, newVer); pWal->version = newVer; } \ No newline at end of file From ee17eab632563c2cc55da796fd3f661a7c3c82c7 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Wed, 17 Mar 2021 15:58:49 +0800 Subject: [PATCH 57/89] rebalance --- tests/script/jenkins/basic.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 356e318eb4..ce770aee56 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -88,6 +88,7 @@ cd ../../../debug; make ./test.sh -f general/parser/topbot.sim ./test.sh -f general/db/nosuchfile.sim ./test.sh -f general/parser/function.sim +./test.sh -f unique/cluster/vgroup100.sim #======================b1-end=============== #======================b2-start=============== @@ -152,13 +153,12 @@ cd ../../../debug; make ./test.sh -f unique/account/user_create.sim ./test.sh -f unique/account/user_len.sim -./test.sh -f unique/big/balance.sim ./test.sh -f unique/big/maxvnodes.sim ./test.sh -f unique/big/tcp.sim ./test.sh -f unique/cluster/alter.sim ./test.sh -f unique/cluster/cache.sim -./test.sh -f unique/cluster/vgroup100.sim + #======================b2-end=============== #======================b3-start=============== @@ -424,5 +424,6 @@ cd ../../../debug; make ./test.sh -f general/parser/stableOp.sim ./test.sh -f general/parser/timestamp.sim ./test.sh -f general/parser/sliding.sim +./test.sh -f unique/big/balance.sim #======================b7-end=============== From fcf6a1cf1f068bbc19cff6a6bffd493396d1b942 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 17 Mar 2021 16:08:55 +0800 Subject: [PATCH 58/89] [TD-3320]: fix sync coredump --- src/tsdb/src/tsdbSync.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/tsdb/src/tsdbSync.c b/src/tsdb/src/tsdbSync.c index 6b8483e4a6..ee545fbabc 100644 --- a/src/tsdb/src/tsdbSync.c +++ b/src/tsdb/src/tsdbSync.c @@ -677,13 +677,13 @@ static int32_t tsdbRecvDFileSetInfo(SSyncH *pSynch) { static int tsdbReload(STsdbRepo *pRepo, bool isMfChanged) { // TODO: may need to stop and restart stream - if (isMfChanged) { - tsdbCloseMeta(pRepo); - tsdbFreeMeta(pRepo->tsdbMeta); - pRepo->tsdbMeta = tsdbNewMeta(REPO_CFG(pRepo)); - tsdbOpenMeta(pRepo); - tsdbLoadMetaCache(pRepo, true); - } + // if (isMfChanged) { + tsdbCloseMeta(pRepo); + tsdbFreeMeta(pRepo->tsdbMeta); + pRepo->tsdbMeta = tsdbNewMeta(REPO_CFG(pRepo)); + tsdbOpenMeta(pRepo); + tsdbLoadMetaCache(pRepo, true); + // } tsdbUnRefMemTable(pRepo, pRepo->mem); tsdbUnRefMemTable(pRepo, pRepo->imem); From 785645eef4b4592ea5ce0f2dd8cc037c6266d020 Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Wed, 17 Mar 2021 16:26:37 +0800 Subject: [PATCH 59/89] [TD-3337]: [balance] fix pVgroup->pDb NULL pointer crash --- src/balance/src/bnMain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/balance/src/bnMain.c b/src/balance/src/bnMain.c index 236b22afaf..3055f77e81 100644 --- a/src/balance/src/bnMain.c +++ b/src/balance/src/bnMain.c @@ -425,7 +425,7 @@ static bool bnMonitorVgroups() { while (1) { pIter = mnodeGetNextVgroup(pIter, &pVgroup); - if (pVgroup == NULL) break; + if (pVgroup == NULL || pVgroup->pDb == NULL) break; int32_t dbReplica = pVgroup->pDb->cfg.replications; int32_t vgReplica = pVgroup->numOfVnodes; @@ -721,4 +721,4 @@ int32_t bnAlterDnode(struct SDnodeObj *pSrcDnode, int32_t vnodeId, int32_t dnode mnodeDecDnodeRef(pDestDnode); return code; -} \ No newline at end of file +} From 363bacbe76b6711113c6ee84931925e858b2fce4 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Wed, 17 Mar 2021 17:42:39 +0800 Subject: [PATCH 60/89] fix bug --- src/client/src/tscAsync.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscAsync.c b/src/client/src/tscAsync.c index 5cba897b30..87f6058cec 100644 --- a/src/client/src/tscAsync.c +++ b/src/client/src/tscAsync.c @@ -281,7 +281,7 @@ void tscQueueAsyncError(void(*fp), void *param, int32_t code) { } static void tscAsyncResultCallback(SSchedMsg *pMsg) { - SSqlObj* pSql = pMsg->ahandle; + SSqlObj* pSql = (SSqlObj*)taosAcquireRef(tscObjRef, (int64_t)pMsg->ahandle); if (pSql == NULL || pSql->signature != pSql) { tscDebug("%p SqlObj is freed, not add into queue async res", pSql); return; @@ -292,23 +292,26 @@ static void tscAsyncResultCallback(SSchedMsg *pMsg) { SSqlRes *pRes = &pSql->res; if (pSql->fp == NULL || pSql->fetchFp == NULL){ + taosReleaseRef(tscObjRef, pSql->self); return; } pSql->fp = pSql->fetchFp; (*pSql->fp)(pSql->param, pSql, pRes->code); + taosReleaseRef(tscObjRef, pSql->self); } void tscAsyncResultOnError(SSqlObj* pSql) { SSchedMsg schedMsg = {0}; schedMsg.fp = tscAsyncResultCallback; - schedMsg.ahandle = pSql; + schedMsg.ahandle = (void *)pSql->self; schedMsg.thandle = (void *)1; schedMsg.msg = 0; taosScheduleTask(tscQhandle, &schedMsg); } + int tscSendMsgToServer(SSqlObj *pSql); void tscTableMetaCallBack(void *param, TAOS_RES *res, int code) { From 1e3f28cfb3a1edd9229ac3759dcef737c9b4afdb Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 17 Mar 2021 11:19:05 +0000 Subject: [PATCH 61/89] hotfix for mxkz --- src/tsdb/src/tsdbMeta.c | 6 +++--- src/tsdb/src/tsdbSync.c | 40 ++++++++++++++++++++-------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/tsdb/src/tsdbMeta.c b/src/tsdb/src/tsdbMeta.c index cdde2bc91f..824f69608e 100644 --- a/src/tsdb/src/tsdbMeta.c +++ b/src/tsdb/src/tsdbMeta.c @@ -213,9 +213,9 @@ void *tsdbGetTableTagVal(const void* pTable, int32_t colId, int16_t type, int16_ char *val = tdGetKVRowValOfCol(((STable*)pTable)->tagVal, colId); assert(type == pCol->type && bytes == pCol->bytes); - if (val != NULL && IS_VAR_DATA_TYPE(type)) { - assert(varDataLen(val) < pCol->bytes); - } + // if (val != NULL && IS_VAR_DATA_TYPE(type)) { + // assert(varDataLen(val) < pCol->bytes); + // } return val; } diff --git a/src/tsdb/src/tsdbSync.c b/src/tsdb/src/tsdbSync.c index 6b8483e4a6..e30dfed86a 100644 --- a/src/tsdb/src/tsdbSync.c +++ b/src/tsdb/src/tsdbSync.c @@ -152,14 +152,14 @@ static int32_t tsdbSyncSendMeta(SSyncH *pSynch) { return -1; } - int32_t writeLen = (int32_t)mf.info.size; - tsdbInfo("vgId:%d, metafile:%s will be sent, size:%d", REPO_ID(pRepo), mf.f.aname, writeLen); + int64_t writeLen = mf.info.size; + tsdbInfo("vgId:%d, metafile:%s will be sent, size:%" PRId64, REPO_ID(pRepo), mf.f.aname, writeLen); - int32_t ret = (int32_t)taosSendFile(pSynch->socketFd, TSDB_FILE_FD(&mf), 0, writeLen); + int64_t ret = taosSendFile(pSynch->socketFd, TSDB_FILE_FD(&mf), 0, writeLen); if (ret != writeLen) { terrno = TAOS_SYSTEM_ERROR(errno); - tsdbError("vgId:%d, failed to send metafile since %s, ret:%d writeLen:%d", REPO_ID(pRepo), tstrerror(terrno), ret, - writeLen); + tsdbError("vgId:%d, failed to send metafile since %s, ret:%" PRId64 " writeLen:%" PRId64, REPO_ID(pRepo), + tstrerror(terrno), ret, writeLen); tsdbCloseMFile(&mf); return -1; } @@ -217,18 +217,18 @@ static int32_t tsdbSyncRecvMeta(SSyncH *pSynch) { tsdbInfo("vgId:%d, metafile:%s is created", REPO_ID(pRepo), mf.f.aname); - int32_t readLen = (int32_t)pSynch->pmf->info.size; - int32_t ret = taosCopyFds(pSynch->socketFd, TSDB_FILE_FD(&mf), readLen); + int64_t readLen = pSynch->pmf->info.size; + int64_t ret = taosCopyFds(pSynch->socketFd, TSDB_FILE_FD(&mf), readLen); if (ret != readLen) { terrno = TAOS_SYSTEM_ERROR(errno); - tsdbError("vgId:%d, failed to recv metafile since %s, ret:%d readLen:%d", REPO_ID(pRepo), tstrerror(terrno), ret, - readLen); + tsdbError("vgId:%d, failed to recv metafile since %s, ret:%" PRId64 " readLen:%" PRId64, REPO_ID(pRepo), + tstrerror(terrno), ret, readLen); tsdbCloseMFile(&mf); tsdbRemoveMFile(&mf); return -1; } - tsdbInfo("vgId:%d, metafile is received, size:%d", REPO_ID(pRepo), readLen); + tsdbInfo("vgId:%d, metafile is received, size:%" PRId64, REPO_ID(pRepo), readLen); mf.info = pSynch->pmf->info; tsdbCloseMFile(&mf); @@ -463,12 +463,12 @@ static int32_t tsdbSyncRecvDFileSetArray(SSyncH *pSynch) { tsdbInfo("vgId:%d, file:%s will be received, osize:%" PRIu64 " rsize:%" PRIu64, REPO_ID(pRepo), pDFile->f.aname, pDFile->info.size, pRDFile->info.size); - int32_t writeLen = (int32_t)pRDFile->info.size; - int32_t ret = taosCopyFds(pSynch->socketFd, pDFile->fd, writeLen); + int64_t writeLen = pRDFile->info.size; + int64_t ret = taosCopyFds(pSynch->socketFd, pDFile->fd, writeLen); if (ret != writeLen) { terrno = TAOS_SYSTEM_ERROR(errno); - tsdbError("vgId:%d, failed to recv file:%s since %s, ret:%d writeLen:%d", REPO_ID(pRepo), pDFile->f.aname, - tstrerror(terrno), ret, writeLen); + tsdbError("vgId:%d, failed to recv file:%s since %s, ret:%" PRId64 " writeLen:%" PRId64, REPO_ID(pRepo), + pDFile->f.aname, tstrerror(terrno), ret, writeLen); tsdbCloseDFileSet(&fset); tsdbRemoveDFileSet(&fset); return -1; @@ -476,7 +476,7 @@ static int32_t tsdbSyncRecvDFileSetArray(SSyncH *pSynch) { // Update new file info pDFile->info = pRDFile->info; - tsdbInfo("vgId:%d, file:%s is received, size:%d", REPO_ID(pRepo), pDFile->f.aname, writeLen); + tsdbInfo("vgId:%d, file:%s is received, size:%" PRId64, REPO_ID(pRepo), pDFile->f.aname, writeLen); } tsdbCloseDFileSet(&fset); @@ -575,14 +575,14 @@ static int32_t tsdbSyncSendDFileSet(SSyncH *pSynch, SDFileSet *pSet) { return -1; } - int32_t writeLen = (int32_t)df.info.size; - tsdbInfo("vgId:%d, file:%s will be sent, size:%d", REPO_ID(pRepo), df.f.aname, writeLen); + int64_t writeLen = df.info.size; + tsdbInfo("vgId:%d, file:%s will be sent, size:%" PRId64, REPO_ID(pRepo), df.f.aname, writeLen); - int32_t ret = (int32_t)taosSendFile(pSynch->socketFd, TSDB_FILE_FD(&df), 0, writeLen); + int64_t ret = taosSendFile(pSynch->socketFd, TSDB_FILE_FD(&df), 0, writeLen); if (ret != writeLen) { terrno = TAOS_SYSTEM_ERROR(errno); - tsdbError("vgId:%d, failed to send file:%s since %s, ret:%d writeLen:%d", REPO_ID(pRepo), df.f.aname, - tstrerror(terrno), ret, writeLen); + tsdbError("vgId:%d, failed to send file:%s since %s, ret:%" PRId64 " writeLen:%" PRId64, REPO_ID(pRepo), + df.f.aname, tstrerror(terrno), ret, writeLen); tsdbCloseDFile(&df); return -1; } From 000eac74214aa6482c0e8a93b359802950eface1 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 17 Mar 2021 13:43:21 +0000 Subject: [PATCH 62/89] TD-3354 --- src/sync/src/syncRetrieve.c | 2 +- src/util/inc/tsocket.h | 2 +- src/util/src/tsocket.c | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/sync/src/syncRetrieve.c b/src/sync/src/syncRetrieve.c index be4073760d..57472851df 100644 --- a/src/sync/src/syncRetrieve.c +++ b/src/sync/src/syncRetrieve.c @@ -334,7 +334,7 @@ static int64_t syncRetrieveWal(SSyncPeer *pPeer) { break; } - code = (int32_t)taosSendFile(pPeer->syncFd, sfd, NULL, size); + code = taosSendFile(pPeer->syncFd, sfd, NULL, size); close(sfd); if (code < 0) { sError("%s, failed to send wal:%s for retrieve since %s, code:0x%" PRIx64, pPeer->id, fname, strerror(errno), code); diff --git a/src/util/inc/tsocket.h b/src/util/inc/tsocket.h index 35b591b61e..b4f5516959 100644 --- a/src/util/inc/tsocket.h +++ b/src/util/inc/tsocket.h @@ -28,7 +28,7 @@ int32_t taosReadn(SOCKET sock, char *buffer, int32_t len); int32_t taosWriteMsg(SOCKET fd, void *ptr, int32_t nbytes); int32_t taosReadMsg(SOCKET fd, void *ptr, int32_t nbytes); int32_t taosNonblockwrite(SOCKET fd, char *ptr, int32_t nbytes); -int32_t taosCopyFds(SOCKET sfd, int32_t dfd, int64_t len); +int64_t taosCopyFds(SOCKET sfd, int32_t dfd, int64_t len); int32_t taosSetNonblocking(SOCKET sock, int32_t on); SOCKET taosOpenUdpSocket(uint32_t localIp, uint16_t localPort); diff --git a/src/util/src/tsocket.c b/src/util/src/tsocket.c index e075876867..8911b7e8ee 100644 --- a/src/util/src/tsocket.c +++ b/src/util/src/tsocket.c @@ -465,36 +465,36 @@ void tinet_ntoa(char *ipstr, uint32_t ip) { #define COPY_SIZE 32768 // sendfile shall be used -int32_t taosCopyFds(SOCKET sfd, int32_t dfd, int64_t len) { +int64_t taosCopyFds(SOCKET sfd, int32_t dfd, int64_t len) { int64_t leftLen; - int32_t readLen, writeLen; + int64_t readLen, writeLen; char temp[COPY_SIZE]; leftLen = len; while (leftLen > 0) { if (leftLen < COPY_SIZE) - readLen = (int32_t)leftLen; + readLen = leftLen; else readLen = COPY_SIZE; // 4K - int32_t retLen = taosReadMsg(sfd, temp, (int32_t)readLen); + int64_t retLen = taosReadMsg(sfd, temp, (int32_t)readLen); if (readLen != retLen) { - uError("read error, readLen:%d retLen:%d len:%" PRId64 " leftLen:%" PRId64 ", reason:%s", readLen, retLen, len, - leftLen, strerror(errno)); + uError("read error, readLen:%" PRId64 " retLen:%" PRId64 " len:%" PRId64 " leftLen:%" PRId64 ", reason:%s", + readLen, retLen, len, leftLen, strerror(errno)); return -1; } writeLen = taosWriteMsg(dfd, temp, readLen); if (readLen != writeLen) { - uError("copy error, readLen:%d writeLen:%d len:%" PRId64 " leftLen:%" PRId64 ", reason:%s", readLen, writeLen, - len, leftLen, strerror(errno)); + uError("copy error, readLen:%" PRId64 " writeLen:%" PRId64 " len:%" PRId64 " leftLen:%" PRId64 ", reason:%s", + readLen, writeLen, len, leftLen, strerror(errno)); return -1; } leftLen -= readLen; } - return (int32_t)len; + return len; } From 3f312f8bf49d931b8f245b3ffd0a539a2aafd264 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 17 Mar 2021 23:15:18 +0800 Subject: [PATCH 63/89] Feature/sangshuduo/td 3317 taosdemo interlace (#5476) * [TD-3316] : add testcase for taosdemo limit and offset. check offset 0. * [TD-3316] : add testcase for taosdemo limit and offset. fix sample file import bug. * [TD-3316] : add test case for limit and offset. fix sample data issue. * [TD-3327] : fix taosdemo segfault when import data from sample data file. * [TD-3317] : make taosdemo support interlace mode. json parameter rows_per_tbl support. * [TD-3317] : support interlace mode. refactor * [TD-3317] : support interlace mode. refactor * [TD-3317] : support interlace mode insertion. refactor. * [TD-3317] : support interlace mode insertion. change json file. * [TD-3317] : support interlace mode insertion. fix multithread create table regression. * [TD-3317] : support interlace mode insertion. working but not perfect. * [TD-3317] : support interlace mode insertion. rename lowaTest with taosdemoTestWithJson Co-authored-by: Shuduo Sang --- src/kit/taosdemo/insert-interlace.json | 58 ++ src/kit/taosdemo/taosdemo.c | 782 +++++++++++++----- tests/pytest/fulltest.sh | 6 +- tests/pytest/tools/insert-interlace.json | 58 ++ .../tools/insert-tblimit-tboffset0.json | 1 - .../tools/insert-tblimit1-tboffset.json | 59 ++ tests/pytest/tools/insert.json | 91 +- tests/pytest/tools/taosdemoTestInterlace.py | 68 ++ tests/pytest/tools/taosdemoTestLimitOffset.py | 9 + .../{lowaTest.py => taosdemoTestWithJson.py} | 0 10 files changed, 874 insertions(+), 258 deletions(-) create mode 100644 src/kit/taosdemo/insert-interlace.json create mode 100644 tests/pytest/tools/insert-interlace.json create mode 100644 tests/pytest/tools/insert-tblimit1-tboffset.json create mode 100644 tests/pytest/tools/taosdemoTestInterlace.py rename tests/pytest/tools/{lowaTest.py => taosdemoTestWithJson.py} (100%) diff --git a/src/kit/taosdemo/insert-interlace.json b/src/kit/taosdemo/insert-interlace.json new file mode 100644 index 0000000000..b05c1ee312 --- /dev/null +++ b/src/kit/taosdemo/insert-interlace.json @@ -0,0 +1,58 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 5000, + "rows_per_tbl": 50, + "num_of_records_per_req": 100, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 365, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 10, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 200, + "multi_thread_write_one_tbl": "no", + "rows_per_tbl": 20, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], + "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + }] + }] +} diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index b03f47bfaf..846eea5062 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -60,9 +60,12 @@ extern char configDir[]; #define QUERY_JSON_NAME "query.json" #define SUBSCRIBE_JSON_NAME "subscribe.json" -#define INSERT_MODE 0 -#define QUERY_MODE 1 -#define SUBSCRIBE_MODE 2 +enum TEST_MODE { + INSERT_TEST, // 0 + QUERY_TEST, // 1 + SUBSCRIBE_TEST, // 2 + INVAID_TEST +}; #define MAX_SQL_SIZE 65536 #define BUFFER_SIZE (65536*2) @@ -109,6 +112,12 @@ enum MODE { MODE_BUT }; +typedef enum enum_INSERT_MODE { + PROGRESSIVE_INSERT_MODE, + INTERLACE_INSERT_MODE, + INVALID_INSERT_MODE +} INSERT_MODE; + enum QUERY_TYPE { NO_INSERT_TYPE, INSERT_TYPE, @@ -148,7 +157,8 @@ enum _show_stables_index { TSDB_SHOW_STABLES_TID_INDEX, TSDB_SHOW_STABLES_VGID_INDEX, TSDB_MAX_SHOW_STABLES -}; +}; + enum _describe_table_index { TSDB_DESCRIBE_METRIC_FIELD_INDEX, TSDB_DESCRIBE_METRIC_TYPE_INDEX, @@ -188,6 +198,7 @@ typedef struct SArguments_S { int num_of_CPR; int num_of_threads; int insert_interval; + int rows_per_tbl; int num_of_RPR; int max_sql_len; int num_of_tables; @@ -197,6 +208,8 @@ typedef struct SArguments_S { int disorderRange; int method_of_delete; char ** arg_list; + int64_t totalInsertRows; + int64_t totalAffectedRows; } SArguments; typedef struct SColumn_S { @@ -379,8 +392,9 @@ typedef struct SThreadInfo_S { char db_name[MAX_DB_NAME_SIZE+1]; char fp[4096]; char tb_prefix[MAX_TB_NAME_SIZE]; - int start_table_id; - int end_table_id; + int start_table_from; + int end_table_to; + int ntables; int data_of_rate; uint64_t start_time; char* cols; @@ -531,6 +545,7 @@ SArguments g_args = { 10, // num_of_CPR 10, // num_of_connections/thread 0, // insert_interval + 0, // rows_per_tbl; 100, // num_of_RPR TSDB_PAYLOAD_SIZE, // max_sql_len 10000, // num_of_tables @@ -553,7 +568,8 @@ static FILE * g_fpOfInsertResult = NULL; do { if (g_args.debug_print || g_args.verbose_print) \ fprintf(stderr, "DEBG: "fmt, __VA_ARGS__); } while(0) #define verbosePrint(fmt, ...) \ - do { if (g_args.verbose_print) fprintf(stderr, "VERB: "fmt, __VA_ARGS__); } while(0) + do { if (g_args.verbose_print) \ + fprintf(stderr, "VERB: "fmt, __VA_ARGS__); } while(0) /////////////////////////////////////////////////// @@ -652,6 +668,8 @@ void parse_args(int argc, char *argv[], SArguments *arguments) { arguments->num_of_threads = atoi(argv[++i]); } else if (strcmp(argv[i], "-i") == 0) { arguments->insert_interval = atoi(argv[++i]); + } else if (strcmp(argv[i], "-B") == 0) { + arguments->rows_per_tbl = atoi(argv[++i]); } else if (strcmp(argv[i], "-r") == 0) { arguments->num_of_RPR = atoi(argv[++i]); } else if (strcmp(argv[i], "-t") == 0) { @@ -1299,33 +1317,45 @@ static void printfInsertMetaToFile(FILE* fp) { fprintf(fp, " columnCount: %d\n ", g_Dbs.db[i].superTbls[j].columnCount); for (int k = 0; k < g_Dbs.db[i].superTbls[j].columnCount; k++) { //printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].columns[k].dataType, g_Dbs.db[i].superTbls[j].columns[k].dataLen); - if ((0 == strncasecmp(g_Dbs.db[i].superTbls[j].columns[k].dataType, "binary", 6)) || (0 == strncasecmp(g_Dbs.db[i].superTbls[j].columns[k].dataType, "nchar", 5))) { - fprintf(fp, "column[%d]:%s(%d) ", k, g_Dbs.db[i].superTbls[j].columns[k].dataType, g_Dbs.db[i].superTbls[j].columns[k].dataLen); + if ((0 == strncasecmp( + g_Dbs.db[i].superTbls[j].columns[k].dataType, + "binary", strlen("binary"))) + || (0 == strncasecmp(g_Dbs.db[i].superTbls[j].columns[k].dataType, + "nchar", strlen("nchar")))) { + fprintf(fp, "column[%d]:%s(%d) ", k, + g_Dbs.db[i].superTbls[j].columns[k].dataType, + g_Dbs.db[i].superTbls[j].columns[k].dataLen); } else { fprintf(fp, "column[%d]:%s ", k, g_Dbs.db[i].superTbls[j].columns[k].dataType); } } fprintf(fp, "\n"); - - fprintf(fp, " tagCount: %d\n ", g_Dbs.db[i].superTbls[j].tagCount); + + fprintf(fp, " tagCount: %d\n ", + g_Dbs.db[i].superTbls[j].tagCount); for (int k = 0; k < g_Dbs.db[i].superTbls[j].tagCount; k++) { //printf("dataType:%s, dataLen:%d\t", g_Dbs.db[i].superTbls[j].tags[k].dataType, g_Dbs.db[i].superTbls[j].tags[k].dataLen); - if ((0 == strncasecmp(g_Dbs.db[i].superTbls[j].tags[k].dataType, "binary", 6)) || (0 == strncasecmp(g_Dbs.db[i].superTbls[j].tags[k].dataType, "nchar", 5))) { - fprintf(fp, "tag[%d]:%s(%d) ", k, g_Dbs.db[i].superTbls[j].tags[k].dataType, g_Dbs.db[i].superTbls[j].tags[k].dataLen); + if ((0 == strncasecmp(g_Dbs.db[i].superTbls[j].tags[k].dataType, + "binary", strlen("binary"))) + || (0 == strncasecmp(g_Dbs.db[i].superTbls[j].tags[k].dataType, + "nchar", strlen("nchar")))) { + fprintf(fp, "tag[%d]:%s(%d) ", k, g_Dbs.db[i].superTbls[j].tags[k].dataType, + g_Dbs.db[i].superTbls[j].tags[k].dataLen); } else { fprintf(fp, "tag[%d]:%s ", k, g_Dbs.db[i].superTbls[j].tags[k].dataType); - } + } } fprintf(fp, "\n"); } fprintf(fp, "\n"); } - SHOW_PARSE_RESULT_END_TO_FILE(fp); + SHOW_PARSE_RESULT_END_TO_FILE(fp); } static void printfQueryMeta() { - SHOW_PARSE_RESULT_START(); - printf("host: \033[33m%s:%u\033[0m\n", g_queryInfo.host, g_queryInfo.port); + SHOW_PARSE_RESULT_START(); + printf("host: \033[33m%s:%u\033[0m\n", + g_queryInfo.host, g_queryInfo.port); printf("user: \033[33m%s\033[0m\n", g_queryInfo.user); printf("password: \033[33m%s\033[0m\n", g_queryInfo.password); printf("database name: \033[33m%s\033[0m\n", g_queryInfo.dbName); @@ -1336,7 +1366,7 @@ static void printfQueryMeta() { printf("concurrent: \033[33m%d\033[0m\n", g_queryInfo.superQueryInfo.concurrent); printf("sqlCount: \033[33m%d\033[0m\n", g_queryInfo.superQueryInfo.sqlCount); - if (SUBSCRIBE_MODE == g_args.test_mode) { + if (SUBSCRIBE_TEST == g_args.test_mode) { printf("mod: \033[33m%d\033[0m\n", g_queryInfo.superQueryInfo.subscribeMode); printf("interval: \033[33m%d\033[0m\n", g_queryInfo.superQueryInfo.subscribeInterval); printf("restart: \033[33m%d\033[0m\n", g_queryInfo.superQueryInfo.subscribeRestart); @@ -1353,7 +1383,7 @@ static void printfQueryMeta() { printf("childTblCount: \033[33m%d\033[0m\n", g_queryInfo.subQueryInfo.childTblCount); printf("stable name: \033[33m%s\033[0m\n", g_queryInfo.subQueryInfo.sTblName); - if (SUBSCRIBE_MODE == g_args.test_mode) { + if (SUBSCRIBE_TEST == g_args.test_mode) { printf("mod: \033[33m%d\033[0m\n", g_queryInfo.subQueryInfo.subscribeMode); printf("interval: \033[33m%d\033[0m\n", g_queryInfo.subQueryInfo.subscribeInterval); printf("restart: \033[33m%d\033[0m\n", g_queryInfo.subQueryInfo.subscribeRestart); @@ -1515,15 +1545,19 @@ static int getDbFromServer(TAOS * taos, SDbInfo** dbInfos) { return -1; } - tstrncpy(dbInfos[count]->name, (char *)row[TSDB_SHOW_DB_NAME_INDEX], fields[TSDB_SHOW_DB_NAME_INDEX].bytes); - xFormatTimestamp(dbInfos[count]->create_time, *(int64_t*)row[TSDB_SHOW_DB_CREATED_TIME_INDEX], TSDB_TIME_PRECISION_MILLI); + tstrncpy(dbInfos[count]->name, (char *)row[TSDB_SHOW_DB_NAME_INDEX], + fields[TSDB_SHOW_DB_NAME_INDEX].bytes); + xFormatTimestamp(dbInfos[count]->create_time, + *(int64_t*)row[TSDB_SHOW_DB_CREATED_TIME_INDEX], + TSDB_TIME_PRECISION_MILLI); dbInfos[count]->ntables = *((int32_t *)row[TSDB_SHOW_DB_NTABLES_INDEX]); dbInfos[count]->vgroups = *((int32_t *)row[TSDB_SHOW_DB_VGROUPS_INDEX]); dbInfos[count]->replica = *((int16_t *)row[TSDB_SHOW_DB_REPLICA_INDEX]); dbInfos[count]->quorum = *((int16_t *)row[TSDB_SHOW_DB_QUORUM_INDEX]); dbInfos[count]->days = *((int16_t *)row[TSDB_SHOW_DB_DAYS_INDEX]); - tstrncpy(dbInfos[count]->keeplist, (char *)row[TSDB_SHOW_DB_KEEP_INDEX], fields[TSDB_SHOW_DB_KEEP_INDEX].bytes); + tstrncpy(dbInfos[count]->keeplist, (char *)row[TSDB_SHOW_DB_KEEP_INDEX], + fields[TSDB_SHOW_DB_KEEP_INDEX].bytes); dbInfos[count]->cache = *((int32_t *)row[TSDB_SHOW_DB_CACHE_INDEX]); dbInfos[count]->blocks = *((int32_t *)row[TSDB_SHOW_DB_BLOCKS_INDEX]); dbInfos[count]->minrows = *((int32_t *)row[TSDB_SHOW_DB_MINROWS_INDEX]); @@ -1537,8 +1571,9 @@ static int getDbFromServer(TAOS * taos, SDbInfo** dbInfos) { (char *)row[TSDB_SHOW_DB_PRECISION_INDEX], fields[TSDB_SHOW_DB_PRECISION_INDEX].bytes); dbInfos[count]->update = *((int8_t *)row[TSDB_SHOW_DB_UPDATE_INDEX]); - tstrncpy(dbInfos[count]->status, (char *)row[TSDB_SHOW_DB_STATUS_INDEX], fields[TSDB_SHOW_DB_STATUS_INDEX].bytes); - + tstrncpy(dbInfos[count]->status, (char *)row[TSDB_SHOW_DB_STATUS_INDEX], + fields[TSDB_SHOW_DB_STATUS_INDEX].bytes); + count++; if (count > MAX_DATABASE_COUNT) { fprintf(stderr, "The database count overflow than %d\n", MAX_DATABASE_COUNT); @@ -1593,8 +1628,10 @@ static void printfQuerySystemInfo(TAOS * taos) { struct tm* lt; time(&t); lt = localtime(&t); - snprintf(filename, MAX_QUERY_SQL_LENGTH, "querySystemInfo-%d-%d-%d %d:%d:%d", lt->tm_year+1900, lt->tm_mon, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec); - + snprintf(filename, MAX_QUERY_SQL_LENGTH, "querySystemInfo-%d-%d-%d %d:%d:%d", + lt->tm_year+1900, lt->tm_mon, lt->tm_mday, lt->tm_hour, lt->tm_min, + lt->tm_sec); + // show variables res = taos_query(taos, "show variables;"); //getResult(res, filename); @@ -1604,7 +1641,7 @@ static void printfQuerySystemInfo(TAOS * taos) { res = taos_query(taos, "show dnodes;"); xDumpResultToFile(filename, res); //getResult(res, filename); - + // show databases res = taos_query(taos, "show databases;"); SDbInfo** dbInfos = (SDbInfo **)calloc(MAX_DATABASE_COUNT, sizeof(SDbInfo *)); @@ -1621,7 +1658,7 @@ static void printfQuerySystemInfo(TAOS * taos) { for (int i = 0; i < dbCount; i++) { // printf database info printfDbInfoForQueryToFile(filename, dbInfos[i], i); - + // show db.vgroups snprintf(buffer, MAX_QUERY_SQL_LENGTH, "show %s.vgroups;", dbInfos[i]->name); res = taos_query(taos, buffer); @@ -1639,9 +1676,9 @@ static void printfQuerySystemInfo(TAOS * taos) { } -void ERROR_EXIT(const char *msg) { perror(msg); exit(-1); } +static void ERROR_EXIT(const char *msg) { perror(msg); exit(-1); } -int postProceSql(char* host, uint16_t port, char* sqlstr) +static int postProceSql(char* host, uint16_t port, char* sqlstr) { char *req_fmt = "POST %s HTTP/1.1\r\nHost: %s:%d\r\nAccept: */*\r\nAuthorization: Basic %s\r\nContent-Length: %d\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n%s"; @@ -2346,7 +2383,8 @@ static int createDatabases() { } printf("\ncreate database %s success!\n\n", g_Dbs.db[i].dbName); - debugPrint("%s() %d supertbl count:%d\n", __func__, __LINE__, g_Dbs.db[i].superTblCount); + debugPrint("%s() %d supertbl count:%d\n", + __func__, __LINE__, g_Dbs.db[i].superTblCount); for (int j = 0; j < g_Dbs.db[i].superTblCount; j++) { // describe super table, if exists sprintf(command, "describe %s.%s;", g_Dbs.db[i].dbName, @@ -2395,8 +2433,12 @@ static void* createTable(void *sarg) int len = 0; int batchNum = 0; - //printf("Creating table from %d to %d\n", winfo->start_table_id, winfo->end_table_id); - for (int i = winfo->start_table_id; i <= winfo->end_table_id; i++) { + + verbosePrint("%s() LN%d: Creating table from %d to %d\n", + __func__, __LINE__, + winfo->start_table_from, winfo->end_table_to); + + for (int i = winfo->start_table_from; i <= winfo->end_table_to; i++) { if (0 == g_Dbs.use_metric) { snprintf(buffer, buff_len, "create table if not exists %s.%s%d %s;", @@ -2451,7 +2493,7 @@ static void* createTable(void *sarg) int64_t currentPrintTime = taosGetTimestampMs(); if (currentPrintTime - lastPrintTime > 30*1000) { printf("thread[%d] already create %d - %d tables\n", - winfo->threadID, winfo->start_table_id, i); + winfo->threadID, winfo->start_table_from, i); lastPrintTime = currentPrintTime; } } @@ -2467,7 +2509,7 @@ static void* createTable(void *sarg) return NULL; } -int startMultiThreadCreateChildTable( +static int startMultiThreadCreateChildTable( char* cols, int threads, int startFrom, int ntables, char* db_name, SSuperTable* superTblInfo) { pthread_t *pids = malloc(threads * sizeof(pthread_t)); @@ -2491,7 +2533,6 @@ int startMultiThreadCreateChildTable( int b = 0; b = ntables % threads; - int last = startFrom; for (int i = 0; i < threads; i++) { threadInfo *t_info = infos + i; t_info->threadID = i; @@ -2510,9 +2551,11 @@ int startMultiThreadCreateChildTable( free(infos); return -1; } - t_info->start_table_id = last; - t_info->end_table_id = i < b ? last + a : last + a - 1; - last = t_info->end_table_id + 1; + + t_info->start_table_from = startFrom; + t_info->ntables = iend_table_to = i < b ? startFrom + a : startFrom + a - 1; + startFrom = t_info->end_table_to + 1; t_info->use_metric = 1; t_info->cols = cols; t_info->minDelay = INT16_MAX; @@ -2599,7 +2642,7 @@ static void createChildTables() { /* Read 10000 lines at most. If more than 10000 lines, continue to read after using */ -int readTagFromCsvFileToMem(SSuperTable * superTblInfo) { +static int readTagFromCsvFileToMem(SSuperTable * superTblInfo) { size_t n = 0; ssize_t readLen = 0; char * line = NULL; @@ -2669,7 +2712,6 @@ int readSampleFromJsonFileToMem(SSuperTable * superTblInfo) { return 0; } - /* Read 10000 lines at most. If more than 10000 lines, continue to read after using */ @@ -2716,7 +2758,8 @@ static int readSampleFromCsvFileToMem( continue; } - verbosePrint("readLen=%ld stb->lenOfOneRow=%d getRows=%d\n", readLen, superTblInfo->lenOfOneRow, getRows); + verbosePrint("readLen=%ld stb->lenOfOneRow=%d getRows=%d\n", readLen, + superTblInfo->lenOfOneRow, getRows); memcpy(superTblInfo->sampleDataBuf + getRows * superTblInfo->lenOfOneRow, line, readLen); @@ -2958,6 +3001,16 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { goto PARSE_OVER; } + cJSON* rowsPerTbl = cJSON_GetObjectItem(root, "rows_per_tbl"); + if (rowsPerTbl && rowsPerTbl->type == cJSON_Number) { + g_args.rows_per_tbl = rowsPerTbl->valueint; + } else if (!rowsPerTbl) { + g_args.rows_per_tbl = 0; // 0 means progressive mode, > 0 mean interlace mode. max value is less or equ num_of_records_per_req + } else { + fprintf(stderr, "ERROR: failed to read json, rows_per_tbl input mistake\n"); + goto PARSE_OVER; + } + cJSON* maxSqlLen = cJSON_GetObjectItem(root, "max_sql_len"); if (maxSqlLen && maxSqlLen->type == cJSON_Number) { g_args.max_sql_len = maxSqlLen->valueint; @@ -3005,7 +3058,9 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { int dbSize = cJSON_GetArraySize(dbs); if (dbSize > MAX_DB_COUNT) { - printf("ERROR: failed to read json, databases size overflow, max database is %d\n", MAX_DB_COUNT); + fprintf(stderr, + "ERROR: failed to read json, databases size overflow, max database is %d\n", + MAX_DB_COUNT); goto PARSE_OVER; } @@ -3202,7 +3257,9 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { int stbSize = cJSON_GetArraySize(stables); if (stbSize > MAX_SUPER_TABLE_COUNT) { - printf("ERROR: failed to read json, databases size overflow, max database is %d\n", MAX_SUPER_TABLE_COUNT); + fprintf(stderr, + "ERROR: failed to read json, databases size overflow, max database is %d\n", + MAX_SUPER_TABLE_COUNT); goto PARSE_OVER; } @@ -3429,6 +3486,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { printf("ERROR: failed to read json, multiThreadWriteOneTbl not found\n"); goto PARSE_OVER; } + cJSON* rowsPerTbl = cJSON_GetObjectItem(stbInfo, "rows_per_tbl"); if (rowsPerTbl && rowsPerTbl->type == cJSON_Number) { g_Dbs.db[i].superTbls[j].rowsPerTbl = rowsPerTbl->valueint; @@ -3768,7 +3826,9 @@ static bool getMetaFromQueryJsonFile(cJSON* root) { } cJSON* subkeepProgress = cJSON_GetObjectItem(subQuery, "keepProgress"); - if (subkeepProgress && subkeepProgress->type == cJSON_String && subkeepProgress->valuestring != NULL) { + if (subkeepProgress && + subkeepProgress->type == cJSON_String + && subkeepProgress->valuestring != NULL) { if (0 == strcmp("yes", subkeepProgress->valuestring)) { g_queryInfo.subQueryInfo.subscribeKeepProgress = 1; } else if (0 == strcmp("no", subkeepProgress->valuestring)) { @@ -3859,27 +3919,27 @@ static bool getInfoFromJsonFile(char* file) { cJSON* filetype = cJSON_GetObjectItem(root, "filetype"); if (filetype && filetype->type == cJSON_String && filetype->valuestring != NULL) { if (0 == strcasecmp("insert", filetype->valuestring)) { - g_args.test_mode = INSERT_MODE; + g_args.test_mode = INSERT_TEST; } else if (0 == strcasecmp("query", filetype->valuestring)) { - g_args.test_mode = QUERY_MODE; + g_args.test_mode = QUERY_TEST; } else if (0 == strcasecmp("subscribe", filetype->valuestring)) { - g_args.test_mode = SUBSCRIBE_MODE; + g_args.test_mode = SUBSCRIBE_TEST; } else { printf("ERROR: failed to read json, filetype not support\n"); goto PARSE_OVER; } } else if (!filetype) { - g_args.test_mode = INSERT_MODE; + g_args.test_mode = INSERT_TEST; } else { printf("ERROR: failed to read json, filetype not found\n"); goto PARSE_OVER; } - if (INSERT_MODE == g_args.test_mode) { + if (INSERT_TEST == g_args.test_mode) { ret = getMetaFromInsertJsonFile(root); - } else if (QUERY_MODE == g_args.test_mode) { + } else if (QUERY_TEST == g_args.test_mode) { ret = getMetaFromQueryJsonFile(root); - } else if (SUBSCRIBE_MODE == g_args.test_mode) { + } else if (SUBSCRIBE_TEST == g_args.test_mode) { ret = getMetaFromQueryJsonFile(root); } else { printf("ERROR: input json file type error! please input correct file type: insert or query or subscribe\n"); @@ -4125,13 +4185,34 @@ static int execInsert(threadInfo *winfo, char *buffer, int k) return affectedRows; } -static int generateDataBuffer(int32_t tableSeq, - threadInfo *pThreadInfo, char *buffer, - int64_t insertRows, - int64_t startFrom, int64_t startTime, int *pSampleUsePos) +static void getTableName(char *pTblName, threadInfo* pThreadInfo, int tableSeq) { SSuperTable* superTblInfo = pThreadInfo->superTblInfo; + if (superTblInfo) { + if ((superTblInfo->childTblOffset >= 0) + && (superTblInfo->childTblLimit > 0)) { + snprintf(pTblName, TSDB_TABLE_NAME_LEN, "%s", + superTblInfo->childTblName + (tableSeq - superTblInfo->childTblOffset) * TSDB_TABLE_NAME_LEN); + } else { + verbosePrint("%s() LN%d: from=%d count=%d seq=%d\n", + __func__, __LINE__, pThreadInfo->start_table_from, + pThreadInfo->ntables, tableSeq); + snprintf(pTblName, TSDB_TABLE_NAME_LEN, "%s", + superTblInfo->childTblName + tableSeq * TSDB_TABLE_NAME_LEN); + } + } else { + snprintf(pTblName, TSDB_TABLE_NAME_LEN, "%s%d", + superTblInfo?superTblInfo->childTblPrefix:g_args.tb_prefix, tableSeq); + } +} + +static int generateDataTail(char *tableName, int32_t tableSeq, + threadInfo* pThreadInfo, + SSuperTable* superTblInfo, + int batch, char* buffer, int64_t insertRows, + int64_t startFrom, uint64_t startTime, int *pSamplePos, int *dataLen) { + int len = 0; int ncols_per_record = 1; // count first col ts if (superTblInfo == NULL) { @@ -4142,91 +4223,21 @@ static int generateDataBuffer(int32_t tableSeq, } } - assert(buffer != NULL); + verbosePrint("%s() LN%d batch=%d\n", __func__, __LINE__, batch); - char *pChildTblName; - - pChildTblName = calloc(TSDB_TABLE_NAME_LEN, 1); - if (NULL == pChildTblName) { - fprintf(stderr, "failed to alloc memory %d\n", TSDB_TABLE_NAME_LEN); - return -1; - } - - if (superTblInfo && (superTblInfo->childTblOffset >= 0) - && (superTblInfo->childTblLimit > 0)) { - snprintf(pChildTblName, TSDB_TABLE_NAME_LEN, "%s", - superTblInfo->childTblName + (tableSeq - superTblInfo->childTblOffset) * TSDB_TABLE_NAME_LEN); - } else { - snprintf(pChildTblName, TSDB_TABLE_NAME_LEN, "%s%d", - superTblInfo?superTblInfo->childTblPrefix:g_args.tb_prefix, tableSeq); - } - - memset(buffer, 0, superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len); - - char *pstr = buffer; - - if (superTblInfo) { - if (AUTO_CREATE_SUBTBL == superTblInfo->autoCreateTable) { - char* tagsValBuf = NULL; - if (0 == superTblInfo->tagSource) { - tagsValBuf = generateTagVaulesForStb(superTblInfo); - } else { - tagsValBuf = getTagValueFromTagSample( - superTblInfo, - tableSeq % superTblInfo->tagSampleCount); - } - if (NULL == tagsValBuf) { - free(pChildTblName); - fprintf(stderr, "tag buf failed to allocate memory\n"); - return -1; - } - - pstr += snprintf(pstr, - superTblInfo->maxSqlLen, - "insert into %s.%s using %s.%s tags %s values", - pThreadInfo->db_name, - pChildTblName, - pThreadInfo->db_name, - superTblInfo->sTblName, - tagsValBuf); - tmfree(tagsValBuf); - } else if (TBL_ALREADY_EXISTS == superTblInfo->childTblExists) { - pstr += snprintf(pstr, - superTblInfo->maxSqlLen, - "insert into %s.%s values", - pThreadInfo->db_name, - superTblInfo->childTblName + tableSeq * TSDB_TABLE_NAME_LEN); - } else { - pstr += snprintf(pstr, - (superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len), - "insert into %s.%s values", - pThreadInfo->db_name, - pChildTblName); - } - } else { - pstr += snprintf(pstr, - g_args.max_sql_len, - "insert into %s.%s values", - pThreadInfo->db_name, - pChildTblName); - } - - int k; - int len = 0; - - verbosePrint("%s() LN%d num_of_RPR=%d\n", __func__, __LINE__, g_args.num_of_RPR); - for (k = 0; k < g_args.num_of_RPR;) { + int k = 0; + for (k = 0; k < batch;) { if (superTblInfo) { int retLen = 0; if (0 == strncasecmp(superTblInfo->dataSource, "sample", strlen("sample"))) { retLen = getRowDataFromSample( - pstr + len, + buffer + len, superTblInfo->maxSqlLen - len, startTime + superTblInfo->timeStampStep * startFrom, superTblInfo, - pSampleUsePos); + pSamplePos); } else if (0 == strncasecmp(superTblInfo->dataSource, "rand", strlen("rand"))) { int rand_num = rand_tinyint() % 100; @@ -4234,13 +4245,13 @@ static int generateDataBuffer(int32_t tableSeq, && rand_num < superTblInfo->disorderRatio) { int64_t d = startTime - taosRandom() % superTblInfo->disorderRange; retLen = generateRowData( - pstr + len, + buffer + len, superTblInfo->maxSqlLen - len, d, superTblInfo); } else { retLen = generateRowData( - pstr + len, + buffer + len, superTblInfo->maxSqlLen - len, startTime + superTblInfo->timeStampStep * startFrom, superTblInfo); @@ -4248,7 +4259,6 @@ static int generateDataBuffer(int32_t tableSeq, } if (retLen < 0) { - free(pChildTblName); return -1; } @@ -4277,28 +4287,288 @@ static int generateDataBuffer(int32_t tableSeq, lenOfBinary); } - pstr += sprintf(pstr, " %s", data); - if (len + pstr - buffer >= (g_args.max_sql_len - 256)) { // too long + buffer += sprintf(buffer, " %s", data); + if (strlen(buffer) >= (g_args.max_sql_len - 256)) { // too long k++; break; } } - verbosePrint("%s() LN%d len=%d k=%d \nbuffer=%s\n", __func__, __LINE__, len, k, buffer); + verbosePrint("%s() LN%d len=%d k=%d \nbuffer=%s\n", + __func__, __LINE__, len, k, buffer); k++; startFrom ++; - if (startFrom >= insertRows) + if (startFrom >= insertRows) { break; + } } - if (pChildTblName) - free(pChildTblName); - + *dataLen = len; return k; } +static int generateSQLHead(char *tableName, int32_t tableSeq, threadInfo* pThreadInfo, SSuperTable* superTblInfo, char *buffer) +{ + int len; + if (superTblInfo) { + if (AUTO_CREATE_SUBTBL == superTblInfo->autoCreateTable) { + char* tagsValBuf = NULL; + if (0 == superTblInfo->tagSource) { + tagsValBuf = generateTagVaulesForStb(superTblInfo); + } else { + tagsValBuf = getTagValueFromTagSample( + superTblInfo, + tableSeq % superTblInfo->tagSampleCount); + } + if (NULL == tagsValBuf) { + fprintf(stderr, "tag buf failed to allocate memory\n"); + return -1; + } + + len = snprintf(buffer, + superTblInfo->maxSqlLen, + "insert into %s.%s using %s.%s tags %s values", + pThreadInfo->db_name, + tableName, + pThreadInfo->db_name, + superTblInfo->sTblName, + tagsValBuf); + tmfree(tagsValBuf); + } else if (TBL_ALREADY_EXISTS == superTblInfo->childTblExists) { + len = snprintf(buffer, + superTblInfo->maxSqlLen, + "insert into %s.%s values", + pThreadInfo->db_name, + superTblInfo->childTblName + tableSeq * TSDB_TABLE_NAME_LEN); + } else { + len = snprintf(buffer, + (superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len), + "insert into %s.%s values", + pThreadInfo->db_name, + tableName); + } + } else { + len = snprintf(buffer, + g_args.max_sql_len, + "insert into %s.%s values", + pThreadInfo->db_name, + tableName); + } + + return len; +} + +static int generateDataBuffer(char *pTblName, + int32_t tableSeq, + threadInfo *pThreadInfo, char *buffer, + int64_t insertRows, + int64_t startFrom, int64_t startTime, int *pSamplePos) +{ + SSuperTable* superTblInfo = pThreadInfo->superTblInfo; + + int ncols_per_record = 1; // count first col ts + + if (superTblInfo == NULL) { + int datatypeSeq = 0; + while(g_args.datatype[datatypeSeq]) { + datatypeSeq ++; + ncols_per_record ++; + } + } + + assert(buffer != NULL); + + memset(buffer, 0, superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len); + + char *pstr = buffer; + + int headLen = generateSQLHead(pTblName, tableSeq, pThreadInfo, superTblInfo, buffer); + pstr += headLen; + + int k; + int dataLen; + k = generateDataTail(pTblName, tableSeq, pThreadInfo, superTblInfo, + g_args.num_of_RPR, pstr, insertRows, startFrom, startTime, + pSamplePos, &dataLen); + return k; +} + +static void* syncWriteInterlace(threadInfo *pThreadInfo) { + printf("### CBD: interlace write\n"); + + SSuperTable* superTblInfo = pThreadInfo->superTblInfo; + + char* buffer = calloc(superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len, 1); + if (NULL == buffer) { + fprintf(stderr, "Failed to alloc %d Bytes, reason:%s\n", + superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len, + strerror(errno)); + return NULL; + } + + int insertMode; + char tableName[TSDB_TABLE_NAME_LEN]; + + int rowsPerTbl = superTblInfo?superTblInfo->rowsPerTbl:g_args.rows_per_tbl; + + if (rowsPerTbl > 0) { + insertMode = INTERLACE_INSERT_MODE; + } else { + insertMode = PROGRESSIVE_INSERT_MODE; + } + + // rows per table need be less than insert batch + if (rowsPerTbl > g_args.num_of_RPR) + rowsPerTbl = g_args.num_of_RPR; + + pThreadInfo->totalInsertRows = 0; + pThreadInfo->totalAffectedRows = 0; + + int64_t insertRows = (superTblInfo)?superTblInfo->insertRows:g_args.num_of_DPT; + int insert_interval = superTblInfo?superTblInfo->insertInterval:g_args.insert_interval; + uint64_t st = 0; + uint64_t et = 0xffffffff; + + int64_t lastPrintTime = taosGetTimestampMs(); + int64_t startTs = taosGetTimestampUs(); + int64_t endTs; + + int tableSeq = pThreadInfo->start_table_from; + + debugPrint("%s() LN%d: start_table_from=%d ntables=%d insertRows=%"PRId64"\n", + __func__, __LINE__, pThreadInfo->start_table_from, + pThreadInfo->ntables, insertRows); + + int64_t startTime = pThreadInfo->start_time; + + int batchPerTblTimes; + int prevBatchPerTbl, lastBatchPerTbl; + + if (pThreadInfo->ntables == 1) { + batchPerTblTimes = 1; + lastBatchPerTbl = rowsPerTbl; + prevBatchPerTbl = rowsPerTbl; + } else if (rowsPerTbl > 0) { + batchPerTblTimes = g_args.num_of_RPR / rowsPerTbl; + lastBatchPerTbl = g_args.num_of_RPR % rowsPerTbl; + + if (lastBatchPerTbl > 0) + batchPerTblTimes += 1; + else + lastBatchPerTbl = rowsPerTbl; + prevBatchPerTbl = rowsPerTbl; + } else { + batchPerTblTimes = 1; + prevBatchPerTbl = g_args.num_of_RPR; + lastBatchPerTbl = g_args.num_of_RPR; + } + + while(pThreadInfo->totalInsertRows < pThreadInfo->ntables * insertRows) { + if (insert_interval) { + st = taosGetTimestampUs(); + } + // generate data + memset(buffer, 0, superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len); + + char *pstr = buffer; + int recGenerated = 0; + + for (int i = 0; i < batchPerTblTimes; i ++) { + if (insertMode == INTERLACE_INSERT_MODE) { + if (tableSeq == pThreadInfo->start_table_from + pThreadInfo->ntables) { + // turn to first table + tableSeq = pThreadInfo->start_table_from; + } + } + getTableName(tableName, pThreadInfo, tableSeq); + + int headLen; + if (i == 0) { + headLen = generateSQLHead(tableName, tableSeq, pThreadInfo, superTblInfo, pstr); + } else { + headLen = snprintf(pstr, TSDB_TABLE_NAME_LEN, "%s.%s values", + pThreadInfo->db_name, + tableName); + } + + // generate data buffer + verbosePrint("%s() LN%d i=%d buffer:\n%s\n", + __func__, __LINE__, i, buffer); + + pstr += headLen; + int dataLen = 0; + + int batchPerTbl; + if (i == batchPerTblTimes - 1) { + batchPerTbl = lastBatchPerTbl; + } else { + batchPerTbl = prevBatchPerTbl; + } + + verbosePrint("%s() LN%d batchPerTbl = %d\n", + __func__, __LINE__, batchPerTbl); + int numOfRecGenerated = generateDataTail( + tableName, tableSeq, pThreadInfo, superTblInfo, + batchPerTbl, pstr, insertRows, 0, + startTime + pThreadInfo->totalInsertRows * superTblInfo->timeStampStep, + &(pThreadInfo->samplePos), &dataLen); + verbosePrint("%s() LN%d numOfRecGenerated= %d\n", + __func__, __LINE__, numOfRecGenerated); + pstr += dataLen; + recGenerated += numOfRecGenerated; + + tableSeq ++; + } + verbosePrint("%s() LN%d buffer:\n%s\n", + __func__, __LINE__, buffer); + pThreadInfo->totalInsertRows += recGenerated; + + int affectedRows = execInsert(pThreadInfo, buffer, recGenerated); + if (affectedRows < 0) + goto free_and_statistics_interlace; + + pThreadInfo->totalAffectedRows += affectedRows; + + endTs = taosGetTimestampUs(); + int64_t delay = endTs - startTs; + if (delay > pThreadInfo->maxDelay) pThreadInfo->maxDelay = delay; + if (delay < pThreadInfo->minDelay) pThreadInfo->minDelay = delay; + pThreadInfo->cntDelay++; + pThreadInfo->totalDelay += delay; + + int64_t currentPrintTime = taosGetTimestampMs(); + if (currentPrintTime - lastPrintTime > 30*1000) { + printf("thread[%d] has currently inserted rows: %"PRId64 ", affected rows: %"PRId64 "\n", + pThreadInfo->threadID, + pThreadInfo->totalInsertRows, + pThreadInfo->totalAffectedRows); + lastPrintTime = currentPrintTime; + } + + if (insert_interval) { + et = taosGetTimestampUs(); + + if (insert_interval > ((et - st)/1000) ) { + int sleep_time = insert_interval - (et -st)/1000; + verbosePrint("%s() LN%d sleep: %d ms for insert interval\n", + __func__, __LINE__, sleep_time); + taosMsleep(sleep_time); // ms + } + } + } + +free_and_statistics_interlace: + tmfree(buffer); + + printf("====thread[%d] completed total inserted rows: %"PRId64 ", total affected rows: %"PRId64 "====\n", + pThreadInfo->threadID, + pThreadInfo->totalInsertRows, + pThreadInfo->totalAffectedRows); + return NULL; +} + // sync insertion /* 1 thread: 100 tables * 2000 rows/s @@ -4307,10 +4577,9 @@ static int generateDataBuffer(int32_t tableSeq, 2 taosinsertdata , 1 thread: 10 tables * 20000 rows/s */ -static void* syncWrite(void *sarg) { +static void* syncWriteProgressive(threadInfo *pThreadInfo) { - threadInfo *winfo = (threadInfo *)sarg; - SSuperTable* superTblInfo = winfo->superTblInfo; + SSuperTable* superTblInfo = pThreadInfo->superTblInfo; char* buffer = calloc(superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len, 1); if (NULL == buffer) { @@ -4324,19 +4593,18 @@ static void* syncWrite(void *sarg) { int64_t startTs = taosGetTimestampUs(); int64_t endTs; - int insert_interval = superTblInfo?superTblInfo->insertInterval: - g_args.insert_interval; + int insert_interval = superTblInfo?superTblInfo->insertInterval:g_args.insert_interval; uint64_t st = 0; uint64_t et = 0xffffffff; - winfo->totalInsertRows = 0; - winfo->totalAffectedRows = 0; + pThreadInfo->totalInsertRows = 0; + pThreadInfo->totalAffectedRows = 0; - winfo->samplePos = 0; + pThreadInfo->samplePos = 0; - for (uint32_t tableSeq = winfo->start_table_id; tableSeq <= winfo->end_table_id; + for (uint32_t tableSeq = pThreadInfo->start_table_from; tableSeq <= pThreadInfo->end_table_to; tableSeq ++) { - int64_t start_time = winfo->start_time; + int64_t start_time = pThreadInfo->start_time; int64_t insertRows = (superTblInfo)?superTblInfo->insertRows:g_args.num_of_DPT; verbosePrint("%s() LN%d insertRows=%"PRId64"\n", __func__, __LINE__, insertRows); @@ -4346,34 +4614,39 @@ static void* syncWrite(void *sarg) { st = taosGetTimestampUs(); } - int generated = generateDataBuffer(tableSeq, winfo, buffer, insertRows, - i, start_time, &(winfo->samplePos)); + char tableName[TSDB_TABLE_NAME_LEN]; + getTableName(tableName, pThreadInfo, tableSeq); + verbosePrint("%s() LN%d: tid=%d seq=%d tableName=%s\n", + __func__, __LINE__, + pThreadInfo->threadID, tableSeq, tableName); + + int generated = generateDataBuffer(tableName, tableSeq, pThreadInfo, buffer, insertRows, + i, start_time, &(pThreadInfo->samplePos)); if (generated > 0) i += generated; else goto free_and_statistics_2; - int affectedRows = execInsert(winfo, buffer, generated); + int affectedRows = execInsert(pThreadInfo, buffer, generated); if (affectedRows < 0) goto free_and_statistics_2; - - winfo->totalInsertRows += generated; - winfo->totalAffectedRows += affectedRows; + pThreadInfo->totalInsertRows += generated; + pThreadInfo->totalAffectedRows += affectedRows; endTs = taosGetTimestampUs(); int64_t delay = endTs - startTs; - if (delay > winfo->maxDelay) winfo->maxDelay = delay; - if (delay < winfo->minDelay) winfo->minDelay = delay; - winfo->cntDelay++; - winfo->totalDelay += delay; + if (delay > pThreadInfo->maxDelay) pThreadInfo->maxDelay = delay; + if (delay < pThreadInfo->minDelay) pThreadInfo->minDelay = delay; + pThreadInfo->cntDelay++; + pThreadInfo->totalDelay += delay; int64_t currentPrintTime = taosGetTimestampMs(); if (currentPrintTime - lastPrintTime > 30*1000) { printf("thread[%d] has currently inserted rows: %"PRId64 ", affected rows: %"PRId64 "\n", - winfo->threadID, - winfo->totalInsertRows, - winfo->totalAffectedRows); + pThreadInfo->threadID, + pThreadInfo->totalInsertRows, + pThreadInfo->totalAffectedRows); lastPrintTime = currentPrintTime; } @@ -4391,10 +4664,11 @@ static void* syncWrite(void *sarg) { } } // num_of_DPT - if ((tableSeq == winfo->end_table_id) && superTblInfo && + if ((tableSeq == pThreadInfo->ntables - 1) && superTblInfo && (0 == strncasecmp( superTblInfo->dataSource, "sample", strlen("sample")))) { - printf("%s() LN%d samplePos=%d\n", __func__, __LINE__, winfo->samplePos); + printf("%s() LN%d samplePos=%d\n", + __func__, __LINE__, pThreadInfo->samplePos); } } // tableSeq @@ -4402,12 +4676,28 @@ free_and_statistics_2: tmfree(buffer); printf("====thread[%d] completed total inserted rows: %"PRId64 ", total affected rows: %"PRId64 "====\n", - winfo->threadID, - winfo->totalInsertRows, - winfo->totalAffectedRows); + pThreadInfo->threadID, + pThreadInfo->totalInsertRows, + pThreadInfo->totalAffectedRows); return NULL; } +static void* syncWrite(void *sarg) { + + threadInfo *winfo = (threadInfo *)sarg; + SSuperTable* superTblInfo = winfo->superTblInfo; + + int rowsPerTbl = superTblInfo?superTblInfo->rowsPerTbl:g_args.rows_per_tbl; + + if (rowsPerTbl > 0) { + // interlace mode + return syncWriteInterlace(winfo); + } else { + // progressive mode + return syncWriteProgressive(winfo); + } +} + void callBack(void *param, TAOS_RES *res, int code) { threadInfo* winfo = (threadInfo*)param; SSuperTable* superTblInfo = winfo->superTblInfo; @@ -4423,13 +4713,14 @@ void callBack(void *param, TAOS_RES *res, int code) { char *buffer = calloc(1, winfo->superTblInfo->maxSqlLen); char *data = calloc(1, MAX_DATA_SIZE); char *pstr = buffer; - pstr += sprintf(pstr, "insert into %s.%s%d values", winfo->db_name, winfo->tb_prefix, winfo->start_table_id); + pstr += sprintf(pstr, "insert into %s.%s%d values", winfo->db_name, winfo->tb_prefix, + winfo->start_table_from); // if (winfo->counter >= winfo->superTblInfo->insertRows) { if (winfo->counter >= g_args.num_of_RPR) { - winfo->start_table_id++; + winfo->start_table_from++; winfo->counter = 0; } - if (winfo->start_table_id > winfo->end_table_id) { + if (winfo->start_table_from > winfo->end_table_to) { tsem_post(&winfo->lock_sem); free(buffer); free(data); @@ -4553,7 +4844,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, &start_time, strlen(superTblInfo->startTimestamp), timePrec, 0)) { - printf("ERROR to parse time!\n"); + fprintf(stderr, "ERROR to parse time!\n"); exit(-1); } } @@ -4563,12 +4854,12 @@ static void startMultiThreadInsertData(int threads, char* db_name, double start = getCurrentTime(); - int last; + int startFrom; if ((superTblInfo) && (superTblInfo->childTblOffset >= 0)) - last = superTblInfo->childTblOffset; + startFrom = superTblInfo->childTblOffset; else - last = 0; + startFrom = 0; // read sample data from file first if ((superTblInfo) && (0 == strncasecmp(superTblInfo->dataSource, @@ -4609,6 +4900,55 @@ static void startMultiThreadInsertData(int threads, char* db_name, taos_close(taos); } + // read sample data from file first + if ((superTblInfo) && (0 == strncasecmp(superTblInfo->dataSource, + "sample", strlen("sample")))) { + if (0 != prepareSampleDataForSTable(superTblInfo)) { + fprintf(stderr, "prepare sample data for stable failed!\n"); + exit(-1); + } + } + + + TAOS* taos = taos_connect( + g_Dbs.host, g_Dbs.user, + g_Dbs.password, db_name, g_Dbs.port); + if (NULL == taos) { + fprintf(stderr, "connect to server fail , reason: %s\n", + taos_errstr(NULL)); + exit(-1); + } + + if (superTblInfo) { + + int limit, offset; + if (superTblInfo && (superTblInfo->childTblOffset >= 0) + && (superTblInfo->childTblLimit > 0)) { + limit = superTblInfo->childTblLimit; + offset = superTblInfo->childTblOffset; + } else { + limit = superTblInfo->childTblCount; + offset = 0; + } + + superTblInfo->childTblName = (char*)calloc(1, + limit * TSDB_TABLE_NAME_LEN); + if (superTblInfo->childTblName == NULL) { + fprintf(stderr, "alloc memory failed!"); + taos_close(taos); + exit(-1); + } + + int childTblCount; + getChildNameOfSuperTableWithLimitAndOffset( + taos, + db_name, superTblInfo->sTblName, + &superTblInfo->childTblName, &childTblCount, + limit, + offset); + } + taos_close(taos); + for (int i = 0; i < threads; i++) { threadInfo *t_info = infos + i; t_info->threadID = i; @@ -4625,7 +4965,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, g_Dbs.host, g_Dbs.user, g_Dbs.password, db_name, g_Dbs.port); if (NULL == t_info->taos) { - printf("connect to server fail from insert sub thread, reason: %s\n", + fprintf(stderr, "connect to server fail from insert sub thread, reason: %s\n", taos_errstr(NULL)); exit(-1); } @@ -4635,12 +4975,13 @@ static void startMultiThreadInsertData(int threads, char* db_name, if ((NULL == superTblInfo) || (0 == superTblInfo->multiThreadWriteOneTbl)) { - t_info->start_table_id = last; - t_info->end_table_id = i < b ? last + a : last + a - 1; - last = t_info->end_table_id + 1; + t_info->start_table_from = startFrom; + t_info->ntables = iend_table_to = i < b ? startFrom + a : startFrom + a - 1; + startFrom = t_info->end_table_to + 1; } else { - t_info->start_table_id = 0; - t_info->end_table_id = superTblInfo->childTblCount - 1; + t_info->start_table_from = 0; + t_info->ntables = superTblInfo->childTblCount; t_info->start_time = t_info->start_time + rand_int() % 10000 - rand_tinyint(); } @@ -4671,6 +5012,9 @@ static void startMultiThreadInsertData(int threads, char* db_name, if (superTblInfo) { superTblInfo->totalAffectedRows += t_info->totalAffectedRows; superTblInfo->totalInsertRows += t_info->totalInsertRows; + } else { + g_args.totalAffectedRows += t_info->totalAffectedRows; + g_args.totalInsertRows += t_info->totalInsertRows; } totalDelay += t_info->totalDelay; @@ -4698,6 +5042,18 @@ static void startMultiThreadInsertData(int threads, char* db_name, superTblInfo->totalAffectedRows, threads, db_name, superTblInfo->sTblName, superTblInfo->totalInsertRows/ t); + } else { + printf("Spent %.4f seconds to insert rows: %"PRId64", affected rows: %"PRId64" with %d thread(s) into %s %2.f records/second\n\n", + t, g_args.totalInsertRows, + g_args.totalAffectedRows, + threads, db_name, + g_args.totalInsertRows / t); + fprintf(g_fpOfInsertResult, + "Spent %.4f seconds to insert rows: %"PRId64", affected rows: %"PRId64" with %d thread(s) into %s %2.f records/second\n\n", + t, g_args.totalInsertRows, + g_args.totalAffectedRows, + threads, db_name, + g_args.totalInsertRows / t); } printf("insert delay, avg: %10.6fms, max: %10.6fms, min: %10.6fms\n\n", @@ -4720,7 +5076,7 @@ void *readTable(void *sarg) { char *tb_prefix = rinfo->tb_prefix; FILE *fp = fopen(rinfo->fp, "a"); if (NULL == fp) { - printf("fopen %s fail, reason:%s.\n", rinfo->fp, strerror(errno)); + fprintf(stderr, "fopen %s fail, reason:%s.\n", rinfo->fp, strerror(errno)); return NULL; } @@ -4732,7 +5088,7 @@ void *readTable(void *sarg) { num_of_DPT = g_args.num_of_DPT; // } - int num_of_tables = rinfo->end_table_id - rinfo->start_table_id + 1; + int num_of_tables = rinfo->ntables; // rinfo->end_table_to - rinfo->start_table_from + 1; int totalData = num_of_DPT * num_of_tables; bool do_aggreFunc = g_Dbs.do_aggreFunc; @@ -4794,7 +5150,7 @@ void *readMetric(void *sarg) { } int num_of_DPT = rinfo->superTblInfo->insertRows; - int num_of_tables = rinfo->end_table_id - rinfo->start_table_id + 1; + int num_of_tables = rinfo->ntables; // rinfo->end_table_to - rinfo->start_table_from + 1; int totalData = num_of_DPT * num_of_tables; bool do_aggreFunc = g_Dbs.do_aggreFunc; @@ -4842,7 +5198,8 @@ void *readMetric(void *sarg) { } t = getCurrentTime() - t; - fprintf(fp, "| Speed: %12.2f(per s) | Latency: %.4f(ms) |\n", num_of_tables * num_of_DPT / t, t * 1000); + fprintf(fp, "| Speed: %12.2f(per s) | Latency: %.4f(ms) |\n", + num_of_tables * num_of_DPT / t, t * 1000); printf("select %10s took %.6f second(s)\n\n", aggreFunc[j], t); taos_free_result(pSql); @@ -4956,7 +5313,7 @@ void *superQueryProcess(void *sarg) { while (1) { if (g_queryInfo.superQueryInfo.rate && (et - st) < (int64_t)g_queryInfo.superQueryInfo.rate*1000) { taosMsleep(g_queryInfo.superQueryInfo.rate*1000 - (et - st)); // ms - //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, winfo->start_table_id, winfo->end_table_id); + //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, winfo->start_table_from, winfo->end_table_to); } st = taosGetTimestampUs(); @@ -5020,13 +5377,14 @@ static void *subQueryProcess(void *sarg) { int64_t st = 0; int64_t et = (int64_t)g_queryInfo.subQueryInfo.rate*1000; while (1) { - if (g_queryInfo.subQueryInfo.rate && (et - st) < (int64_t)g_queryInfo.subQueryInfo.rate*1000) { + if (g_queryInfo.subQueryInfo.rate + && (et - st) < (int64_t)g_queryInfo.subQueryInfo.rate*1000) { taosMsleep(g_queryInfo.subQueryInfo.rate*1000 - (et - st)); // ms - //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, winfo->start_table_id, winfo->end_table_id); + //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, winfo->start_table_from, winfo->end_table_to); } st = taosGetTimestampUs(); - for (int i = winfo->start_table_id; i <= winfo->end_table_id; i++) { + for (int i = winfo->start_table_from; i <= winfo->end_table_to; i++) { for (int j = 0; j < g_queryInfo.subQueryInfo.sqlCount; j++) { memset(sqlstr,0,sizeof(sqlstr)); replaceSubTblName(g_queryInfo.subQueryInfo.sql[j], sqlstr, i); @@ -5042,8 +5400,8 @@ static void *subQueryProcess(void *sarg) { et = taosGetTimestampUs(); printf("####thread[%"PRId64"] complete all sqls to allocate all sub-tables[%d - %d] once queries duration:%.4fs\n\n", taosGetSelfPthreadId(), - winfo->start_table_id, - winfo->end_table_id, + winfo->start_table_from, + winfo->end_table_to, (double)(et - st)/1000000.0); } return NULL; @@ -5081,7 +5439,8 @@ static int queryTestProcess() { pthread_t *pids = NULL; threadInfo *infos = NULL; //==== create sub threads for query from specify table - if (g_queryInfo.superQueryInfo.sqlCount > 0 && g_queryInfo.superQueryInfo.concurrent > 0) { + if (g_queryInfo.superQueryInfo.sqlCount > 0 + && g_queryInfo.superQueryInfo.concurrent > 0) { pids = malloc(g_queryInfo.superQueryInfo.concurrent * sizeof(pthread_t)); infos = malloc(g_queryInfo.superQueryInfo.concurrent * sizeof(threadInfo)); @@ -5139,14 +5498,15 @@ static int queryTestProcess() { b = ntables % threads; } - int last = 0; + int startFrom = 0; for (int i = 0; i < threads; i++) { threadInfo *t_info = infosOfSub + i; t_info->threadID = i; - t_info->start_table_id = last; - t_info->end_table_id = i < b ? last + a : last + a - 1; - last = t_info->end_table_id + 1; + t_info->start_table_from = startFrom; + t_info->ntables = iend_table_to = i < b ? startFrom + a : startFrom + a - 1; + startFrom = t_info->end_table_to + 1; t_info->taos = taos; pthread_create(pidsOfSub + i, NULL, subQueryProcess, t_info); } @@ -5222,7 +5582,7 @@ void *subSubscribeProcess(void *sarg) { do { //if (g_queryInfo.superQueryInfo.rate && (et - st) < g_queryInfo.superQueryInfo.rate*1000) { // taosMsleep(g_queryInfo.superQueryInfo.rate*1000 - (et - st)); // ms - // //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, winfo->start_table_id, winfo->end_table_id); + // //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, winfo->start_table_from, winfo->end_table_to); //} //st = taosGetTimestampMs(); @@ -5288,7 +5648,7 @@ void *superSubscribeProcess(void *sarg) { do { //if (g_queryInfo.superQueryInfo.rate && (et - st) < g_queryInfo.superQueryInfo.rate*1000) { // taosMsleep(g_queryInfo.superQueryInfo.rate*1000 - (et - st)); // ms - // //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, winfo->start_table_id, winfo->end_table_id); + // //printf("========sleep duration:%"PRId64 "========inserted rows:%d, table range:%d - %d\n", (1000 - (et - st)), i, winfo->start_table_from, winfo->end_table_to); //} //st = taosGetTimestampMs(); @@ -5417,13 +5777,15 @@ static int subscribeTestProcess() { b = ntables % threads; } - int last = 0; + int startFrom = 0; for (int i = 0; i < threads; i++) { threadInfo *t_info = infosOfSub + i; t_info->threadID = i; - t_info->start_table_id = last; - t_info->end_table_id = i < b ? last + a : last + a - 1; + t_info->start_table_from = startFrom; + t_info->ntables = iend_table_to = i < b ? startFrom + a : startFrom + a - 1; + startFrom = t_info->end_table_to + 1; t_info->taos = taos; pthread_create(pidsOfSub + i, NULL, subSubscribeProcess, t_info); } @@ -5665,14 +6027,14 @@ void querySqlFile(TAOS* taos, char* sqlFile) } static void testMetaFile() { - if (INSERT_MODE == g_args.test_mode) { + if (INSERT_TEST == g_args.test_mode) { if (g_Dbs.cfgDir[0]) taos_options(TSDB_OPTION_CONFIGDIR, g_Dbs.cfgDir); insertTestProcess(); - } else if (QUERY_MODE == g_args.test_mode) { + } else if (QUERY_TEST == g_args.test_mode) { if (g_queryInfo.cfgDir[0]) taos_options(TSDB_OPTION_CONFIGDIR, g_queryInfo.cfgDir); queryTestProcess(); - } else if (SUBSCRIBE_MODE == g_args.test_mode) { + } else if (SUBSCRIBE_TEST == g_args.test_mode) { if (g_queryInfo.cfgDir[0]) taos_options(TSDB_OPTION_CONFIGDIR, g_queryInfo.cfgDir); subscribeTestProcess(); @@ -5689,16 +6051,18 @@ static void queryResult() { pthread_t read_id; threadInfo *rInfo = malloc(sizeof(threadInfo)); rInfo->start_time = 1500000000000; // 2017-07-14 10:40:00.000 - rInfo->start_table_id = 0; + rInfo->start_table_from = 0; //rInfo->do_aggreFunc = g_Dbs.do_aggreFunc; if (g_args.use_metric) { - rInfo->end_table_id = g_Dbs.db[0].superTbls[0].childTblCount - 1; + rInfo->ntables = g_Dbs.db[0].superTbls[0].childTblCount; + rInfo->end_table_to = g_Dbs.db[0].superTbls[0].childTblCount - 1; rInfo->superTblInfo = &g_Dbs.db[0].superTbls[0]; strcpy(rInfo->tb_prefix, g_Dbs.db[0].superTbls[0].childTblPrefix); } else { - rInfo->end_table_id = g_args.num_of_tables -1; + rInfo->ntables = g_args.num_of_tables; + rInfo->end_table_to = g_args.num_of_tables -1; strcpy(rInfo->tb_prefix, g_args.tb_prefix); } @@ -5729,7 +6093,7 @@ static void queryResult() { static void testCmdLine() { - g_args.test_mode = INSERT_MODE; + g_args.test_mode = INSERT_TEST; insertTestProcess(); if (g_Dbs.insert_only) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 409d684d01..46a1abf12c 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -231,12 +231,13 @@ python3 test.py -f query/queryInterval.py python3 test.py -f query/queryFillTest.py # tools -python3 test.py -f tools/lowaTest.py python3 test.py -f tools/taosdemoTest.py python3 test.py -f tools/taosdemoTestWithoutMetric.py +python3 test.py -f tools/taosdemoTestWithJson.py python3 test.py -f tools/taosdemoTestLimitOffset.py python3 test.py -f tools/taosdumpTest.py python3 test.py -f tools/taosdemoTest2.py +python3 test.py -f tools/taosdemoTestSampleData.py # subscribe python3 test.py -f subscribe/singlemeter.py @@ -291,6 +292,5 @@ python3 ./test.py -f insert/boundary2.py python3 ./test.py -f alter/alter_debugFlag.py python3 ./test.py -f query/queryBetweenAnd.py python3 ./test.py -f tag_lite/alter_tag.py -python3 test.py -f tools/taosdemoTestSampleData.py -#======================p4-end=============== \ No newline at end of file +#======================p4-end=============== diff --git a/tests/pytest/tools/insert-interlace.json b/tests/pytest/tools/insert-interlace.json new file mode 100644 index 0000000000..a2ff2c001c --- /dev/null +++ b/tests/pytest/tools/insert-interlace.json @@ -0,0 +1,58 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 5000, + "rows_per_tbl": 50, + "num_of_records_per_req": 100, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 365, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 9, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 250, + "multi_thread_write_one_tbl": "no", + "rows_per_tbl": 80, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "INT", "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/insert-tblimit-tboffset0.json b/tests/pytest/tools/insert-tblimit-tboffset0.json index 302744cab9..7dcb2e0527 100644 --- a/tests/pytest/tools/insert-tblimit-tboffset0.json +++ b/tests/pytest/tools/insert-tblimit-tboffset0.json @@ -44,7 +44,6 @@ "childtable_offset": 0, "multi_thread_write_one_tbl": "no", "number_of_tbl_in_one_sql": 0, - "rows_per_tbl": 100, "max_sql_len": 1024000, "disorder_ratio": 0, "disorder_range": 1000, diff --git a/tests/pytest/tools/insert-tblimit1-tboffset.json b/tests/pytest/tools/insert-tblimit1-tboffset.json new file mode 100644 index 0000000000..a33dc22d5d --- /dev/null +++ b/tests/pytest/tools/insert-tblimit1-tboffset.json @@ -0,0 +1,59 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "result_file": "./insert_res.txt", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 100, + "max_sql_len": 1024000, + "databases": [{ + "dbinfo": { + "name": "db", + "drop": "yes", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", + "keep": 365, + "minRows": 100, + "maxRows": 4096, + "comp":2, + "walLevel":1, + "cachelast":0, + "quorum":1, + "fsync":3000, + "update": 0 + }, + "super_tables": [{ + "name": "stb", + "child_table_exists":"no", + "childtable_count": 100, + "childtable_prefix": "stb_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rows": 1000, + "childtable_limit": 1, + "childtable_offset": 50, + "multi_thread_write_one_tbl": "no", + "number_of_tbl_in_one_sql": 0, + "max_sql_len": 1024000, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT", "count":1}] + }] + }] +} diff --git a/tests/pytest/tools/insert.json b/tests/pytest/tools/insert.json index c3fa78076b..51e9dcc820 100644 --- a/tests/pytest/tools/insert.json +++ b/tests/pytest/tools/insert.json @@ -1,50 +1,51 @@ { "filetype":"insert", "cfgdir": "/etc/taos", - "host": "127.0.0.1", - "port": 6030, - "user": "root", - "password": "taosdata", - "thread_count": 1, - "databases": [{ - "dbinfo": { - "name": "db01", - "replica": 1, - "days": 10, - "cache": 16, - "blocks": 8, - "precision": "ms", + "host": "127.0.0.1", + "port": 6030, + "user": "root", + "password": "taosdata", + "thread_count": 4, + "thread_count_create_tbl": 4, + "databases": [{ + "dbinfo": { + "name": "db01", + "replica": 1, + "days": 10, + "cache": 16, + "blocks": 8, + "precision": "ms", "update": 0, - "maxtablesPerVnode": 1000 - }, - "super_tables": [{ - "name": "stb01", - "childtable_count": 100, - "childtable_prefix": "stb01_", - "auto_create_table": "no", - "data_source": "rand", - "insert_mode": "taosc", - "insert_rate": 0, - "insert_rows": 1000, - "timestamp_step": 1000, - "start_timestamp": "2020-10-01 00:00:00.000", - "sample_format": "csv", - "sample_file": "/home/data/sample.csv", - "tags_file": "", - "columns": [{ - "type": "SMALLINT" - }, { - "type": "BOOL" - }, { - "type": "BINARY", - "len": 6 - }], - "tags": [{ - "type": "INT" - },{ - "type": "BINARY", - "len": 4 - }] - }] - }] + "maxtablesPerVnode": 1000 + }, + "super_tables": [{ + "name": "stb01", + "childtable_count": 100, + "childtable_prefix": "stb01_", + "auto_create_table": "no", + "data_source": "rand", + "insert_mode": "taosc", + "insert_rate": 0, + "insert_rows": 1000, + "timestamp_step": 1000, + "start_timestamp": "2020-10-01 00:00:00.000", + "sample_format": "csv", + "sample_file": "/home/data/sample.csv", + "tags_file": "", + "columns": [{ + "type": "SMALLINT" + }, { + "type": "BOOL" + }, { + "type": "BINARY", + "len": 6 + }], + "tags": [{ + "type": "INT" + },{ + "type": "BINARY", + "len": 4 + }] + }] + }] } diff --git a/tests/pytest/tools/taosdemoTestInterlace.py b/tests/pytest/tools/taosdemoTestInterlace.py new file mode 100644 index 0000000000..9ceb8c5cbb --- /dev/null +++ b/tests/pytest/tools/taosdemoTestInterlace.py @@ -0,0 +1,68 @@ +################################################################### +# 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.numberOfTables = 10000 + self.numberOfRecords = 100 + + 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 run(self): + tdSql.prepare() + buildPath = self.getBuildPath() + if (buildPath == ""): + tdLog.exit("taosd not found!") + else: + tdLog.info("taosd found in %s" % buildPath) + binPath = buildPath+ "/build/bin/" + os.system("%staosdemo -f tools/insert-interlace.json" % binPath) + + tdSql.execute("use db") + tdSql.query("select count(tbname) from db.stb") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 33000) + + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/tools/taosdemoTestLimitOffset.py b/tests/pytest/tools/taosdemoTestLimitOffset.py index 69a81b166b..bce41e1c75 100644 --- a/tests/pytest/tools/taosdemoTestLimitOffset.py +++ b/tests/pytest/tools/taosdemoTestLimitOffset.py @@ -68,6 +68,15 @@ class TDTestCase: tdSql.query("select count(*) from db.stb") tdSql.checkData(0, 0, 20000) + os.system("%staosdemo -f tools/insert-tblimit1-tboffset.json" % binPath) + + tdSql.execute("reset query cache") + tdSql.execute("use db") + tdSql.query("select count(tbname) from db.stb") + tdSql.checkData(0, 0, 100) + tdSql.query("select count(*) from db.stb") + tdSql.checkData(0, 0, 1000) + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) diff --git a/tests/pytest/tools/lowaTest.py b/tests/pytest/tools/taosdemoTestWithJson.py similarity index 100% rename from tests/pytest/tools/lowaTest.py rename to tests/pytest/tools/taosdemoTestWithJson.py From 199e61ec54c1999593fdeab3d9e9ff536692174b Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 18 Mar 2021 09:41:26 +0800 Subject: [PATCH 64/89] Feature/sangshuduo/td 3317 taosdemo interlace (#5477) * [TD-3316] : add testcase for taosdemo limit and offset. check offset 0. * [TD-3316] : add testcase for taosdemo limit and offset. fix sample file import bug. * [TD-3316] : add test case for limit and offset. fix sample data issue. * [TD-3327] : fix taosdemo segfault when import data from sample data file. * [TD-3317] : make taosdemo support interlace mode. json parameter rows_per_tbl support. * [TD-3317] : support interlace mode. refactor * [TD-3317] : support interlace mode. refactor * [TD-3317] : support interlace mode insertion. refactor. * [TD-3317] : support interlace mode insertion. change json file. * [TD-3317] : support interlace mode insertion. fix multithread create table regression. * [TD-3317] : support interlace mode insertion. working but not perfect. * [TD-3317] : support interlace mode insertion. rename lowaTest with taosdemoTestWithJson * [TD-3317] : support interlace mode insertion. perfect Co-authored-by: Shuduo Sang --- src/kit/taosdemo/insert-interlace.json | 11 +-- src/kit/taosdemo/taosdemo.c | 132 ++++++++++++------------- 2 files changed, 67 insertions(+), 76 deletions(-) diff --git a/src/kit/taosdemo/insert-interlace.json b/src/kit/taosdemo/insert-interlace.json index b05c1ee312..0f54f008fb 100644 --- a/src/kit/taosdemo/insert-interlace.json +++ b/src/kit/taosdemo/insert-interlace.json @@ -9,8 +9,7 @@ "thread_count_create_tbl": 4, "result_file": "./insert_res.txt", "confirm_parameter_prompt": "no", - "insert_interval": 5000, - "rows_per_tbl": 50, + "insert_interval": 1000, "num_of_records_per_req": 100, "max_sql_len": 1024000, "databases": [{ @@ -35,12 +34,12 @@ "super_tables": [{ "name": "stb", "child_table_exists":"no", - "childtable_count": 10, + "childtable_count": 100, "childtable_prefix": "stb_", "auto_create_table": "no", "data_source": "rand", "insert_mode": "taosc", - "insert_rows": 200, + "insert_rows": 1000, "multi_thread_write_one_tbl": "no", "rows_per_tbl": 20, "max_sql_len": 1024000, @@ -51,8 +50,8 @@ "sample_format": "csv", "sample_file": "./sample.csv", "tags_file": "", - "columns": [{"type": "INT"}, {"type": "DOUBLE", "count":10}, {"type": "BINARY", "len": 16, "count":3}, {"type": "BINARY", "len": 32, "count":6}], - "tags": [{"type": "TINYINT", "count":2}, {"type": "BINARY", "len": 16, "count":5}] + "columns": [{"type": "INT"}], + "tags": [{"type": "TINYINT", "count":1}] }] }] } diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 846eea5062..83195ca15d 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -4444,110 +4444,102 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) { int64_t startTime = pThreadInfo->start_time; int batchPerTblTimes; - int prevBatchPerTbl, lastBatchPerTbl; + int batchPerTbl; - if (pThreadInfo->ntables == 1) { - batchPerTblTimes = 1; - lastBatchPerTbl = rowsPerTbl; - prevBatchPerTbl = rowsPerTbl; - } else if (rowsPerTbl > 0) { + if ((rowsPerTbl > 0) && (pThreadInfo->ntables > 1)) { batchPerTblTimes = g_args.num_of_RPR / rowsPerTbl; - lastBatchPerTbl = g_args.num_of_RPR % rowsPerTbl; - - if (lastBatchPerTbl > 0) - batchPerTblTimes += 1; - else - lastBatchPerTbl = rowsPerTbl; - prevBatchPerTbl = rowsPerTbl; + batchPerTbl = rowsPerTbl; } else { batchPerTblTimes = 1; - prevBatchPerTbl = g_args.num_of_RPR; - lastBatchPerTbl = g_args.num_of_RPR; + batchPerTbl = g_args.num_of_RPR; } + int generatedRecPerTbl = 0; while(pThreadInfo->totalInsertRows < pThreadInfo->ntables * insertRows) { - if (insert_interval) { + if (insert_interval) { st = taosGetTimestampUs(); - } - // generate data - memset(buffer, 0, superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len); + } + // generate data + memset(buffer, 0, superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len); - char *pstr = buffer; - int recGenerated = 0; + char *pstr = buffer; + int recGenerated = 0; - for (int i = 0; i < batchPerTblTimes; i ++) { - if (insertMode == INTERLACE_INSERT_MODE) { - if (tableSeq == pThreadInfo->start_table_from + pThreadInfo->ntables) { - // turn to first table - tableSeq = pThreadInfo->start_table_from; - } - } - getTableName(tableName, pThreadInfo, tableSeq); + for (int i = 0; i < batchPerTblTimes; i ++) { + getTableName(tableName, pThreadInfo, tableSeq); - int headLen; - if (i == 0) { + int headLen; + if (i == 0) { headLen = generateSQLHead(tableName, tableSeq, pThreadInfo, superTblInfo, pstr); - } else { + } else { headLen = snprintf(pstr, TSDB_TABLE_NAME_LEN, "%s.%s values", pThreadInfo->db_name, tableName); - } + } - // generate data buffer - verbosePrint("%s() LN%d i=%d buffer:\n%s\n", + // generate data buffer + verbosePrint("%s() LN%d i=%d buffer:\n%s\n", __func__, __LINE__, i, buffer); - pstr += headLen; - int dataLen = 0; + pstr += headLen; + int dataLen = 0; - int batchPerTbl; - if (i == batchPerTblTimes - 1) { - batchPerTbl = lastBatchPerTbl; - } else { - batchPerTbl = prevBatchPerTbl; - } - - verbosePrint("%s() LN%d batchPerTbl = %d\n", - __func__, __LINE__, batchPerTbl); - int numOfRecGenerated = generateDataTail( + printf("%s() LN%d i=%d batchPerTblTimes=%d batchPerTbl = %d\n", + __func__, __LINE__, i, batchPerTblTimes, batchPerTbl); + int numOfRecGenerated = generateDataTail( tableName, tableSeq, pThreadInfo, superTblInfo, batchPerTbl, pstr, insertRows, 0, startTime + pThreadInfo->totalInsertRows * superTblInfo->timeStampStep, &(pThreadInfo->samplePos), &dataLen); - verbosePrint("%s() LN%d numOfRecGenerated= %d\n", + verbosePrint("%s() LN%d numOfRecGenerated= %d\n", __func__, __LINE__, numOfRecGenerated); - pstr += dataLen; - recGenerated += numOfRecGenerated; + pstr += dataLen; + recGenerated += numOfRecGenerated; - tableSeq ++; + tableSeq ++; + if (insertMode == INTERLACE_INSERT_MODE) { + if (tableSeq == pThreadInfo->start_table_from + pThreadInfo->ntables) { + // turn to first table + tableSeq = pThreadInfo->start_table_from; + generatedRecPerTbl += numOfRecGenerated; + } } - verbosePrint("%s() LN%d buffer:\n%s\n", - __func__, __LINE__, buffer); - pThreadInfo->totalInsertRows += recGenerated; - int affectedRows = execInsert(pThreadInfo, buffer, recGenerated); - if (affectedRows < 0) + int remainRows = insertRows - generatedRecPerTbl; + if (batchPerTbl > remainRows) + batchPerTbl = remainRows; + + if ((g_args.num_of_RPR - recGenerated) < batchPerTbl) + break; + } + pThreadInfo->totalInsertRows += recGenerated; + printf("%s() LN%d recGenerated=%d totalInsertRows=%"PRId64" buffer:\n%s\n", + __func__, __LINE__, recGenerated, + pThreadInfo->totalInsertRows, buffer); + + int affectedRows = execInsert(pThreadInfo, buffer, recGenerated); + if (affectedRows < 0) goto free_and_statistics_interlace; - pThreadInfo->totalAffectedRows += affectedRows; + pThreadInfo->totalAffectedRows += affectedRows; - endTs = taosGetTimestampUs(); - int64_t delay = endTs - startTs; - if (delay > pThreadInfo->maxDelay) pThreadInfo->maxDelay = delay; - if (delay < pThreadInfo->minDelay) pThreadInfo->minDelay = delay; - pThreadInfo->cntDelay++; - pThreadInfo->totalDelay += delay; + endTs = taosGetTimestampUs(); + int64_t delay = endTs - startTs; + if (delay > pThreadInfo->maxDelay) pThreadInfo->maxDelay = delay; + if (delay < pThreadInfo->minDelay) pThreadInfo->minDelay = delay; + pThreadInfo->cntDelay++; + pThreadInfo->totalDelay += delay; - int64_t currentPrintTime = taosGetTimestampMs(); - if (currentPrintTime - lastPrintTime > 30*1000) { - printf("thread[%d] has currently inserted rows: %"PRId64 ", affected rows: %"PRId64 "\n", + int64_t currentPrintTime = taosGetTimestampMs(); + if (currentPrintTime - lastPrintTime > 30*1000) { + printf("thread[%d] has currently inserted rows: %"PRId64 ", affected rows: %"PRId64 "\n", pThreadInfo->threadID, pThreadInfo->totalInsertRows, pThreadInfo->totalAffectedRows); - lastPrintTime = currentPrintTime; - } + lastPrintTime = currentPrintTime; + } - if (insert_interval) { + if (insert_interval) { et = taosGetTimestampUs(); if (insert_interval > ((et - st)/1000) ) { @@ -4556,7 +4548,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) { __func__, __LINE__, sleep_time); taosMsleep(sleep_time); // ms } - } + } } free_and_statistics_interlace: From 282d1c10f254d391cc4693451bf2f7f926ba375e Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Thu, 18 Mar 2021 11:18:51 +0800 Subject: [PATCH 65/89] [TD-3318]add case for stddev --- tests/pytest/functions/function_stddev.py | 6 +++++- tests/test-all.sh | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/pytest/functions/function_stddev.py b/tests/pytest/functions/function_stddev.py index afc59ac83d..3ff2b82bf6 100644 --- a/tests/pytest/functions/function_stddev.py +++ b/tests/pytest/functions/function_stddev.py @@ -118,7 +118,11 @@ class TDTestCase: if i == 1 or i == 5 or i == 6 or i == 7 or i == 9 or i == 8 :continue tdSql.query('select stddev(c%d),stddev(c%d) from s group by c%d' %( i+1 , i+1 , i+1 ) ) - + #add for TD-3318 + tdSql.execute('create table t1(ts timestamp, k int, b binary(12));') + tdSql.execute("insert into t1 values(now, 1, 'abc');") + tdLog.info("select stddev(k) from t1 where b <> 'abc' interval(1s);") + tdSql.query("select stddev(k) from t1 where b <> 'abc' interval(1s);") def stop(self): diff --git a/tests/test-all.sh b/tests/test-all.sh index b617dd2f07..c8546f591a 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -29,7 +29,7 @@ function dohavecore(){ proc=`echo $corefile|cut -d "_" -f3` if [ -n "$corefile" ];then echo 'taosd or taos has generated core' - tar -zcvPf $corepath'taos_'`date "+%Y_%m_%d_%H_%M_%S"`.tar.gz /usr/local/taos/ + tar -zcPf $corepath'taos_'`date "+%Y_%m_%d_%H_%M_%S"`.tar.gz if [[ $1 == 1 ]];then echo '\n'|gdb /usr/local/taos/bin/$proc $core_file -ex "bt 10" -ex quit exit 8 From 53496c7844b0377153d284a6f89e694d82ba71e3 Mon Sep 17 00:00:00 2001 From: liuyq-617 Date: Thu, 18 Mar 2021 11:21:56 +0800 Subject: [PATCH 66/89] fix --- tests/test-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-all.sh b/tests/test-all.sh index c8546f591a..dcc2b61f43 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -29,7 +29,7 @@ function dohavecore(){ proc=`echo $corefile|cut -d "_" -f3` if [ -n "$corefile" ];then echo 'taosd or taos has generated core' - tar -zcPf $corepath'taos_'`date "+%Y_%m_%d_%H_%M_%S"`.tar.gz + tar -zcPf $corepath'taos_'`date "+%Y_%m_%d_%H_%M_%S"`.tar.gz /usr/local/taos/ if [[ $1 == 1 ]];then echo '\n'|gdb /usr/local/taos/bin/$proc $core_file -ex "bt 10" -ex quit exit 8 From 9f00cd82bbe7190bd734e22e62c05d0bf1531bd1 Mon Sep 17 00:00:00 2001 From: Elias Soong Date: Thu, 18 Mar 2021 14:39:34 +0800 Subject: [PATCH 67/89] [TD-3352] : move "quick run" section into "install" part. --- README.md | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 6ad9d4a97f..97ac9dffeb 100644 --- a/README.md +++ b/README.md @@ -160,24 +160,13 @@ mkdir debug && cd debug cmake .. && cmake --build . ``` -# Quick Run - -# Quick Run -To quickly start a TDengine server after building, run the command below in terminal: -```bash -./build/bin/taosd -c test/cfg -``` -In another terminal, use the TDengine shell to connect the server: -```bash -./build/bin/taos -c test/cfg -``` -option "-c test/cfg" specifies the system configuration file directory. - # Installing + After building successfully, TDengine can be installed by: ```bash sudo make install ``` + Users can find more information about directories installed on the system in the [directory and files](https://www.taosdata.com/en/documentation/administrator/#Directory-and-Files) section. Since version 2.0, installing from source code will also configure service management for TDengine. Users can also choose to [install from packages](https://www.taosdata.com/en/getting-started/#Install-from-Package) for it. @@ -193,6 +182,20 @@ taos If TDengine shell connects the server successfully, welcome messages and version info are printed. Otherwise, an error message is shown. +## Quick Run + +If you don't want to run TDengine as a service, you can run it in current shell. For example, to quickly start a TDengine server after building, run the command below in terminal: +```bash +./build/bin/taosd -c test/cfg +``` + +In another terminal, use the TDengine shell to connect the server: +```bash +./build/bin/taos -c test/cfg +``` + +option "-c test/cfg" specifies the system configuration file directory. + # Try TDengine It is easy to run SQL commands from TDengine shell which is the same as other SQL databases. ```sql From 2d8c6952398900567c5d2e8b8ad6b91f58741f0b Mon Sep 17 00:00:00 2001 From: Elias Soong Date: Thu, 18 Mar 2021 14:47:39 +0800 Subject: [PATCH 68/89] [TD-3363] : fix typo. --- documentation20/cn/13.faq/docs.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/documentation20/cn/13.faq/docs.md b/documentation20/cn/13.faq/docs.md index d3169d507a..e2285b29e2 100644 --- a/documentation20/cn/13.faq/docs.md +++ b/documentation20/cn/13.faq/docs.md @@ -16,13 +16,13 @@ ## 1. TDengine2.0之前的版本升级到2.0及以上的版本应该注意什么?☆☆☆ -2.0版本在之前版本的基础上,进行了完全的重构,配置文件和数据文件是不兼容的。在升级之前务必进行如下操作: +2.0版在之前版本的基础上,进行了完全的重构,配置文件和数据文件是不兼容的。在升级之前务必进行如下操作: -1. 删除配置文件,执行 sudo rm -rf /etc/taos/taos.cfg -2. 删除日志文件,执行 sudo rm -rf /var/log/taos/ -3. 确保数据已经不再需要的前提下,删除数据文件,执行 sudo rm -rf /var/lib/taos/ -4. 安装最新稳定版本的TDengine -5. 如果数据需要迁移数据或者数据文件损坏,请联系涛思数据官方技术支持团队,进行协助解决 +1. 删除配置文件,执行 `sudo rm -rf /etc/taos/taos.cfg` +2. 删除日志文件,执行 `sudo rm -rf /var/log/taos/` +3. 确保数据已经不再需要的前提下,删除数据文件,执行 `sudo rm -rf /var/lib/taos/` +4. 安装最新稳定版本的 TDengine +5. 如果需要迁移数据或者数据文件损坏,请联系涛思数据官方技术支持团队,进行协助解决 ## 2. Windows平台下JDBCDriver找不到动态链接库,怎么办? From 7447a8c562854d16a9fdb943b965e2f281b44bb9 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Thu, 18 Mar 2021 15:24:36 +0800 Subject: [PATCH 69/89] [td-3361]: nchar tag filter caused client crash. --- src/client/src/tscSQLParser.c | 14 +++++++++++--- tests/script/general/parser/topbot.sim | 9 +++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 8b2998c0e7..3b65d0625f 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -4138,13 +4138,21 @@ static int32_t validateTagCondExpr(SSqlCmd* pCmd, tExprNode *p) { } int32_t retVal = TSDB_CODE_SUCCESS; + + int32_t bufLen = 0; + if (IS_NUMERIC_TYPE(vVariant->nType)) { + bufLen = 60; // The maximum length of string that a number is converted to. + } else { + bufLen = vVariant->nLen + 1; + } + if (schemaType == TSDB_DATA_TYPE_BINARY) { - char *tmp = calloc(1, vVariant->nLen + TSDB_NCHAR_SIZE); + char *tmp = calloc(1, bufLen * TSDB_NCHAR_SIZE); retVal = tVariantDump(vVariant, tmp, schemaType, false); free(tmp); } else if (schemaType == TSDB_DATA_TYPE_NCHAR) { // pRight->value.nLen + 1 is larger than the actual nchar string length - char *tmp = calloc(1, (vVariant->nLen + 1) * TSDB_NCHAR_SIZE); + char *tmp = calloc(1, bufLen * TSDB_NCHAR_SIZE); retVal = tVariantDump(vVariant, tmp, schemaType, false); free(tmp); } else { @@ -4155,7 +4163,7 @@ static int32_t validateTagCondExpr(SSqlCmd* pCmd, tExprNode *p) { if (retVal != TSDB_CODE_SUCCESS) { return invalidSqlErrMsg(tscGetErrorMsgPayload(pCmd), msg2); } - }while (0); + } while (0); return TSDB_CODE_SUCCESS; } diff --git a/tests/script/general/parser/topbot.sim b/tests/script/general/parser/topbot.sim index 80a122238e..e23bbf6724 100644 --- a/tests/script/general/parser/topbot.sim +++ b/tests/script/general/parser/topbot.sim @@ -316,4 +316,13 @@ if $data13 != @20-02-02 01:01:01.000@ then return -1 endi +print ===============================>td-3361 +sql create table ttm1(ts timestamp, k int) tags(a nchar(12)); +sql create table ttm1_t1 using ttm1 tags('abcdef') +sql insert into ttm1_t1 values(now, 1) +sql select * from ttm1 where a=123456789012 +if $row != 0 then + return -1 +endi + system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From e4e46768a64c3be441a31f64d983c8b07289e47f Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Thu, 18 Mar 2021 15:50:55 +0800 Subject: [PATCH 70/89] [TD-3353]: solve race condition coredump --- src/inc/tsdb.h | 30 ++++++++++-- src/query/src/qExecutor.c | 2 +- src/tsdb/inc/tsdbMemTable.h | 23 ++-------- src/tsdb/src/tsdbMemTable.c | 92 +++++++++++++++++-------------------- src/tsdb/src/tsdbRead.c | 18 ++++---- 5 files changed, 82 insertions(+), 83 deletions(-) diff --git a/src/inc/tsdb.h b/src/inc/tsdb.h index 09444bb8e4..493bdbe5de 100644 --- a/src/inc/tsdb.h +++ b/src/inc/tsdb.h @@ -25,6 +25,8 @@ #include "tdataformat.h" #include "tname.h" #include "hash.h" +#include "tlockfree.h" +#include "tlist.h" #ifdef __cplusplus extern "C" { @@ -172,10 +174,32 @@ typedef struct STsdbQueryCond { int32_t type; // data block load type: } STsdbQueryCond; +typedef struct STableData STableData; +typedef struct { + T_REF_DECLARE() + SRWLatch latch; + TSKEY keyFirst; + TSKEY keyLast; + int64_t numOfRows; + int32_t maxTables; + STableData **tData; + SList * actList; + SList * extraBuffList; + SList * bufBlockList; + int64_t pointsAdd; // TODO + int64_t storageAdd; // TODO +} SMemTable; + +typedef struct { + SMemTable* mem; + SMemTable* imem; + SMemTable mtable; + SMemTable* omem; +} SMemSnapshot; + typedef struct SMemRef { - int32_t ref; - void * mem; - void * imem; + int32_t ref; + SMemSnapshot snapshot; } SMemRef; typedef struct SDataBlockInfo { diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 54bc72b307..59e04c9cac 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -1840,7 +1840,7 @@ static void doFreeQueryHandle(SQueryRuntimeEnv* pRuntimeEnv) { pRuntimeEnv->pQueryHandle = NULL; SMemRef* pMemRef = &pQuery->memRef; - assert(pMemRef->ref == 0 && pMemRef->imem == NULL && pMemRef->mem == NULL); + assert(pMemRef->ref == 0 && pMemRef->snapshot.imem == NULL && pMemRef->snapshot.mem == NULL); } static void teardownQueryRuntimeEnv(SQueryRuntimeEnv *pRuntimeEnv) { diff --git a/src/tsdb/inc/tsdbMemTable.h b/src/tsdb/inc/tsdbMemTable.h index bd64ed4a52..6046274af4 100644 --- a/src/tsdb/inc/tsdbMemTable.h +++ b/src/tsdb/inc/tsdbMemTable.h @@ -31,29 +31,14 @@ typedef struct { SSkipListIterator *pIter; } SCommitIter; -typedef struct { +struct STableData { uint64_t uid; TSKEY keyFirst; TSKEY keyLast; int64_t numOfRows; SSkipList* pData; T_REF_DECLARE() -} STableData; - -typedef struct { - T_REF_DECLARE() - SRWLatch latch; - TSKEY keyFirst; - TSKEY keyLast; - int64_t numOfRows; - int32_t maxTables; - STableData** tData; - SList* actList; - SList* extraBuffList; - SList* bufBlockList; - int64_t pointsAdd; // TODO - int64_t storageAdd; // TODO -} SMemTable; +}; enum { TSDB_UPDATE_META, TSDB_DROP_META }; @@ -77,8 +62,8 @@ typedef struct { int tsdbRefMemTable(STsdbRepo* pRepo, SMemTable* pMemTable); int tsdbUnRefMemTable(STsdbRepo* pRepo, SMemTable* pMemTable); -int tsdbTakeMemSnapshot(STsdbRepo* pRepo, SMemTable** pMem, SMemTable** pIMem, SArray* pATable); -void tsdbUnTakeMemSnapShot(STsdbRepo* pRepo, SMemTable* pMem, SMemTable* pIMem); +int tsdbTakeMemSnapshot(STsdbRepo* pRepo, SMemSnapshot* pSnapshot, SArray* pATable); +void tsdbUnTakeMemSnapShot(STsdbRepo* pRepo, SMemSnapshot* pSnapshot); void* tsdbAllocBytes(STsdbRepo* pRepo, int bytes); int tsdbAsyncCommit(STsdbRepo* pRepo); int tsdbLoadDataFromCache(STable* pTable, SSkipListIterator* pIter, TSKEY maxKey, int maxRowsToRead, SDataCols* pCols, diff --git a/src/tsdb/src/tsdbMemTable.c b/src/tsdb/src/tsdbMemTable.c index 6818f2ed14..20ec426018 100644 --- a/src/tsdb/src/tsdbMemTable.c +++ b/src/tsdb/src/tsdbMemTable.c @@ -124,88 +124,80 @@ int tsdbUnRefMemTable(STsdbRepo *pRepo, SMemTable *pMemTable) { return 0; } -int tsdbTakeMemSnapshot(STsdbRepo *pRepo, SMemTable **pMem, SMemTable **pIMem, SArray *pATable) { - SMemTable *tmem; +int tsdbTakeMemSnapshot(STsdbRepo *pRepo, SMemSnapshot *pSnapshot, SArray *pATable) { + memset(pSnapshot, 0, sizeof(*pSnapshot)); - // Get snap object if (tsdbLockRepo(pRepo) < 0) return -1; - tmem = pRepo->mem; - *pIMem = pRepo->imem; - tsdbRefMemTable(pRepo, tmem); - tsdbRefMemTable(pRepo, *pIMem); + pSnapshot->omem = pRepo->mem; + pSnapshot->imem = pRepo->imem; + tsdbRefMemTable(pRepo, pRepo->mem); + tsdbRefMemTable(pRepo, pRepo->imem); if (tsdbUnlockRepo(pRepo) < 0) return -1; - // Copy mem objects and ref needed STableData - if (tmem) { - taosRLockLatch(&(tmem->latch)); + if (pSnapshot->omem) { + taosRLockLatch(&(pSnapshot->omem->latch)); - *pMem = (SMemTable *)calloc(1, sizeof(**pMem)); - if (*pMem == NULL) { + pSnapshot->mem = &(pSnapshot->mtable); + + pSnapshot->mem->tData = (STableData **)calloc(pSnapshot->omem->maxTables, sizeof(STableData *)); + if (pSnapshot->mem->tData == NULL) { terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; - taosRUnLockLatch(&(tmem->latch)); - tsdbUnRefMemTable(pRepo, tmem); - tsdbUnRefMemTable(pRepo, *pIMem); - *pMem = NULL; - *pIMem = NULL; + taosRUnLockLatch(&(pSnapshot->omem->latch)); + tsdbUnRefMemTable(pRepo, pSnapshot->omem); + tsdbUnRefMemTable(pRepo, pSnapshot->imem); + pSnapshot->mem = NULL; + pSnapshot->imem = NULL; + pSnapshot->omem = NULL; return -1; } - (*pMem)->tData = (STableData **)calloc(tmem->maxTables, sizeof(STableData *)); - if ((*pMem)->tData == NULL) { - terrno = TSDB_CODE_TDB_OUT_OF_MEMORY; - taosRUnLockLatch(&(tmem->latch)); - free(*pMem); - tsdbUnRefMemTable(pRepo, tmem); - tsdbUnRefMemTable(pRepo, *pIMem); - *pMem = NULL; - *pIMem = NULL; - return -1; - } - - (*pMem)->keyFirst = tmem->keyFirst; - (*pMem)->keyLast = tmem->keyLast; - (*pMem)->numOfRows = tmem->numOfRows; - (*pMem)->maxTables = tmem->maxTables; + pSnapshot->mem->keyFirst = pSnapshot->omem->keyFirst; + pSnapshot->mem->keyLast = pSnapshot->omem->keyLast; + pSnapshot->mem->numOfRows = pSnapshot->omem->numOfRows; + pSnapshot->mem->maxTables = pSnapshot->omem->maxTables; for (size_t i = 0; i < taosArrayGetSize(pATable); i++) { STable * pTable = *(STable **)taosArrayGet(pATable, i); int32_t tid = TABLE_TID(pTable); - STableData *pTableData = (tid < tmem->maxTables) ? tmem->tData[tid] : NULL; + STableData *pTableData = (tid < pSnapshot->omem->maxTables) ? pSnapshot->omem->tData[tid] : NULL; if ((pTableData == NULL) || (TABLE_UID(pTable) != pTableData->uid)) continue; - (*pMem)->tData[tid] = tmem->tData[tid]; - T_REF_INC(tmem->tData[tid]); + pSnapshot->mem->tData[tid] = pTableData; + T_REF_INC(pTableData); } - taosRUnLockLatch(&(tmem->latch)); + taosRUnLockLatch(&(pSnapshot->omem->latch)); } - tsdbUnRefMemTable(pRepo, tmem); - - tsdbDebug("vgId:%d take memory snapshot, pMem %p pIMem %p", REPO_ID(pRepo), *pMem, *pIMem); + tsdbDebug("vgId:%d take memory snapshot, pMem %p pIMem %p", REPO_ID(pRepo), pSnapshot->omem, pSnapshot->imem); return 0; } -void tsdbUnTakeMemSnapShot(STsdbRepo *pRepo, SMemTable *pMem, SMemTable *pIMem) { - tsdbDebug("vgId:%d untake memory snapshot, pMem %p pIMem %p", REPO_ID(pRepo), pMem, pIMem); +void tsdbUnTakeMemSnapShot(STsdbRepo *pRepo, SMemSnapshot *pSnapshot) { + tsdbDebug("vgId:%d untake memory snapshot, pMem %p pIMem %p", REPO_ID(pRepo), pSnapshot->omem, pSnapshot->imem); - if (pMem != NULL) { - for (size_t i = 0; i < pMem->maxTables; i++) { - STableData *pTableData = pMem->tData[i]; + if (pSnapshot->mem) { + ASSERT(pSnapshot->omem != NULL); + + for (size_t i = 0; i < pSnapshot->mem->maxTables; i++) { + STableData *pTableData = pSnapshot->mem->tData[i]; if (pTableData) { tsdbFreeTableData(pTableData); } } - free(pMem->tData); - free(pMem); + tfree(pSnapshot->mem->tData); + + tsdbUnRefMemTable(pRepo, pSnapshot->omem); } - if (pIMem != NULL) { - tsdbUnRefMemTable(pRepo, pIMem); - } + tsdbUnRefMemTable(pRepo, pSnapshot->imem); + + pSnapshot->mem = NULL; + pSnapshot->imem = NULL; + pSnapshot->omem = NULL; } void *tsdbAllocBytes(STsdbRepo *pRepo, int bytes) { diff --git a/src/tsdb/src/tsdbRead.c b/src/tsdb/src/tsdbRead.c index 7b7c244ba8..3426fe86c2 100644 --- a/src/tsdb/src/tsdbRead.c +++ b/src/tsdb/src/tsdbRead.c @@ -194,7 +194,7 @@ static void tsdbMayTakeMemSnapshot(STsdbQueryHandle* pQueryHandle, SArray* psTab SMemRef* pMemRef = pQueryHandle->pMemRef; if (pQueryHandle->pMemRef->ref++ == 0) { - tsdbTakeMemSnapshot(pQueryHandle->pTsdb, (SMemTable**)&(pMemRef->mem), (SMemTable**)&(pMemRef->imem), psTable); + tsdbTakeMemSnapshot(pQueryHandle->pTsdb, &(pMemRef->snapshot), psTable); } taosArrayDestroy(psTable); @@ -208,9 +208,7 @@ static void tsdbMayUnTakeMemSnapshot(STsdbQueryHandle* pQueryHandle) { } if (--pMemRef->ref == 0) { - tsdbUnTakeMemSnapShot(pQueryHandle->pTsdb, pMemRef->mem, pMemRef->imem); - pMemRef->mem = NULL; - pMemRef->imem = NULL; + tsdbUnTakeMemSnapShot(pQueryHandle->pTsdb, &(pMemRef->snapshot)); } pQueryHandle->pMemRef = NULL; @@ -229,10 +227,10 @@ int64_t tsdbGetNumOfRowsInMemTable(TsdbQueryHandleT* pHandle) { if (pMemRef == NULL) { return rows; } STableData* pMem = NULL; - STableData* pIMem = NULL; + STableData* pIMem = NULL; - SMemTable *pMemT = (SMemTable *)(pMemRef->mem); - SMemTable *pIMemT = (SMemTable *)(pMemRef->imem); + SMemTable* pMemT = pMemRef->snapshot.mem; + SMemTable* pIMemT = pMemRef->snapshot.imem; if (pMemT && pCheckInfo->tableId.tid < pMemT->maxTables) { pMem = pMemT->tData[pCheckInfo->tableId.tid]; @@ -605,7 +603,7 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh int32_t order = pHandle->order; // no data in buffer, abort - if (pHandle->pMemRef->mem == NULL && pHandle->pMemRef->imem == NULL) { + if (pHandle->pMemRef->snapshot.mem == NULL && pHandle->pMemRef->snapshot.imem == NULL) { return false; } @@ -614,8 +612,8 @@ static bool initTableMemIterator(STsdbQueryHandle* pHandle, STableCheckInfo* pCh STableData* pMem = NULL; STableData* pIMem = NULL; - SMemTable* pMemT = pHandle->pMemRef->mem; - SMemTable* pIMemT = pHandle->pMemRef->imem; + SMemTable* pMemT = pHandle->pMemRef->snapshot.mem; + SMemTable* pIMemT = pHandle->pMemRef->snapshot.imem; if (pMemT && pCheckInfo->tableId.tid < pMemT->maxTables) { pMem = pMemT->tData[pCheckInfo->tableId.tid]; From 1f61557cbd79981ff66fab05bd4c967defe919b5 Mon Sep 17 00:00:00 2001 From: Elias Soong Date: Thu, 18 Mar 2021 15:56:26 +0800 Subject: [PATCH 71/89] [TD-2639] : improve expression of some sentences. --- documentation20/cn/03.architecture/docs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation20/cn/03.architecture/docs.md b/documentation20/cn/03.architecture/docs.md index 26d8bc55c2..87553fa8ad 100644 --- a/documentation20/cn/03.architecture/docs.md +++ b/documentation20/cn/03.architecture/docs.md @@ -145,7 +145,7 @@ TDengine 建议用数据采集点的名字(如上表中的D1001)来做表名。 在TDengine的设计里,**表用来代表一个具体的数据采集点,超级表用来代表一组相同类型的数据采集点集合**。当为某个具体数据采集点创建表时,用户使用超级表的定义做模板,同时指定该具体采集点(表)的标签值。与传统的关系型数据库相比,表(一个数据采集点)是带有静态标签的,而且这些标签可以事后增加、删除、修改。**一张超级表包含有多张表,这些表具有相同的时序数据schema,但带有不同的标签值**。 -当对多个具有相同数据类型的数据采集点进行聚合操作时,TDengine将先把满足标签过滤条件的表从超级表的中查找出来,然后再扫描这些表的时序数据,进行聚合操作,这样能将需要扫描的数据集大幅减少,从而大幅提高聚合计算的性能。 +当对多个具有相同数据类型的数据采集点进行聚合操作时,TDengine会先把满足标签过滤条件的表从超级表中找出来,然后再扫描这些表的时序数据,进行聚合操作,这样需要扫描的数据集会大幅减少,从而显著提高聚合计算的性能。 ## 集群与基本逻辑单元 From fdc0febbe6e9cf8d41f50fcaae51ba8ff48d1120 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 18 Mar 2021 16:00:55 +0800 Subject: [PATCH 72/89] [TD-3355]: Fix invalid table id problem caused by idpool --- src/mnode/inc/mnodeVgroup.h | 2 +- src/mnode/src/mnodeSdb.c | 2 +- src/mnode/src/mnodeTable.c | 36 ++++++++++++++++++++++++++++++------ src/mnode/src/mnodeVgroup.c | 27 ++++++++++++++++++++------- src/util/inc/tidpool.h | 2 +- src/util/src/tidpool.c | 24 ++++++++++++++++++++---- 6 files changed, 73 insertions(+), 20 deletions(-) diff --git a/src/mnode/inc/mnodeVgroup.h b/src/mnode/inc/mnodeVgroup.h index 2067ad04cc..02dc42a1f8 100644 --- a/src/mnode/inc/mnodeVgroup.h +++ b/src/mnode/inc/mnodeVgroup.h @@ -44,7 +44,7 @@ void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle); void mnodeAlterVgroup(SVgObj *pVgroup, void *ahandle); int32_t mnodeGetAvailableVgroup(struct SMnodeMsg *pMsg, SVgObj **pVgroup, int32_t *sid); -void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SCTableObj *pTable); +int32_t mnodeAddTableIntoVgroup(SVgObj *pVgroup, SCTableObj *pTable); void mnodeRemoveTableFromVgroup(SVgObj *pVgroup, SCTableObj *pTable); void mnodeSendDropVnodeMsg(int32_t vgId, SRpcEpSet *epSet, void *ahandle); void mnodeSendCreateVgroupMsg(SVgObj *pVgroup, void *ahandle); diff --git a/src/mnode/src/mnodeSdb.c b/src/mnode/src/mnodeSdb.c index 319b16e62a..7810c9f91e 100644 --- a/src/mnode/src/mnodeSdb.c +++ b/src/mnode/src/mnodeSdb.c @@ -552,7 +552,7 @@ static int32_t sdbInsertHash(SSdbTable *pTable, SSdbRow *pRow) { int32_t code = (*pTable->fpInsert)(pRow); if (code != TSDB_CODE_SUCCESS) { - sdbError("vgId:1, sdb:%s, failed to insert key:%s to hash, remove it", pTable->name, + sdbError("vgId:1, sdb:%s, failed to perform insert action for key:%s, remove it", pTable->name, sdbGetRowStr(pTable, pRow->pObj)); sdbDeleteHash(pTable, pRow); } diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 1378847d0b..65b0408a8f 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -108,10 +108,12 @@ static int32_t mnodeChildTableActionDestroy(SSdbRow *pRow) { static int32_t mnodeChildTableActionInsert(SSdbRow *pRow) { SCTableObj *pTable = pRow->pObj; + int32_t code = 0; SVgObj *pVgroup = mnodeGetVgroup(pTable->vgId); if (pVgroup == NULL) { mError("ctable:%s, not in vgId:%d", pTable->info.tableId, pTable->vgId); + code = -1; } SDbObj *pDb = NULL; @@ -119,6 +121,7 @@ static int32_t mnodeChildTableActionInsert(SSdbRow *pRow) { pDb = mnodeGetDb(pVgroup->dbName); if (pDb == NULL) { mError("ctable:%s, vgId:%d not in db:%s", pTable->info.tableId, pVgroup->vgId, pVgroup->dbName); + code = -1; } } @@ -127,6 +130,7 @@ static int32_t mnodeChildTableActionInsert(SSdbRow *pRow) { pAcct = mnodeGetAcct(pDb->acct); if (pAcct == NULL) { mError("ctable:%s, acct:%s not exists", pTable->info.tableId, pDb->acct); + code = -1; } } @@ -139,6 +143,7 @@ static int32_t mnodeChildTableActionInsert(SSdbRow *pRow) { if (pAcct) pAcct->acctInfo.numOfTimeSeries += (pTable->superTable->numOfColumns - 1); } else { mError("table:%s:%p, correspond stable not found suid:%" PRIu64, pTable->info.tableId, pTable, pTable->suid); + code = -1; } } else { grantAdd(TSDB_GRANT_TIMESERIES, pTable->numOfColumns - 1); @@ -146,18 +151,31 @@ static int32_t mnodeChildTableActionInsert(SSdbRow *pRow) { } if (pDb) mnodeAddTableIntoDb(pDb); - if (pVgroup) mnodeAddTableIntoVgroup(pVgroup, pTable); + if (pVgroup) { + if (mnodeAddTableIntoVgroup(pVgroup, pTable) != 0) { + mError("table:%s, vgId:%d tid:%d, failed to perform insert action, uid:%" PRIu64 " suid:%" PRIu64, + pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid, pTable->suid); + code = -1; + } + } mnodeDecVgroupRef(pVgroup); mnodeDecDbRef(pDb); mnodeDecAcctRef(pAcct); - return TSDB_CODE_SUCCESS; + if (code == 0) { + mTrace("table:%s, vgId:%d tid:%d, perform insert action, uid:%" PRIu64 " suid:%" PRIu64, pTable->info.tableId, + pTable->vgId, pTable->tid, pTable->uid, pTable->suid); + } + + return code; } static int32_t mnodeChildTableActionDelete(SSdbRow *pRow) { SCTableObj *pTable = pRow->pObj; if (pTable->vgId == 0) { + mError("table:%s, vgId:%d tid:%d, failed to perform delete action, uid:%" PRIu64 " suid:%" PRIu64, + pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid, pTable->suid); return TSDB_CODE_MND_VGROUP_NOT_EXIST; } @@ -188,6 +206,8 @@ static int32_t mnodeChildTableActionDelete(SSdbRow *pRow) { mnodeDecDbRef(pDb); mnodeDecAcctRef(pAcct); + mTrace("table:%s, vgId:%d tid:%d, perform delete action, uid:%" PRIu64 " suid:%" PRIu64, pTable->info.tableId, + pTable->vgId, pTable->tid, pTable->uid, pTable->suid); return TSDB_CODE_SUCCESS; } @@ -399,13 +419,13 @@ static void mnodeAddTableIntoStable(SSTableObj *pStable, SCTableObj *pCtable) { if (pStable->vgHash == NULL) { pStable->vgHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK); - mDebug("table:%s, create hash:%p", pStable->info.tableId, pStable->vgHash); + mDebug("stable:%s, create vgId hash:%p", pStable->info.tableId, pStable->vgHash); } if (pStable->vgHash != NULL) { if (taosHashGet(pStable->vgHash, &pCtable->vgId, sizeof(pCtable->vgId)) == NULL) { taosHashPut(pStable->vgHash, &pCtable->vgId, sizeof(pCtable->vgId), &pCtable->vgId, sizeof(pCtable->vgId)); - mDebug("table:%s, vgId:%d is put into stable hash:%p, sizeOfVgList:%d", pStable->info.tableId, pCtable->vgId, + mDebug("stable:%s, vgId:%d is put into stable vgId hash:%p, sizeOfVgList:%d", pStable->info.tableId, pCtable->vgId, pStable->vgHash, taosHashGetSize(pStable->vgHash)); } } @@ -443,19 +463,21 @@ static int32_t mnodeSuperTableActionDestroy(SSdbRow *pRow) { static int32_t mnodeSuperTableActionInsert(SSdbRow *pRow) { SSTableObj *pStable = pRow->pObj; - SDbObj *pDb = mnodeGetDbByTableName(pStable->info.tableId); + SDbObj * pDb = mnodeGetDbByTableName(pStable->info.tableId); if (pDb != NULL && pDb->status == TSDB_DB_STATUS_READY) { mnodeAddSuperTableIntoDb(pDb); } mnodeDecDbRef(pDb); taosHashPut(tsSTableUidHash, &pStable->uid, sizeof(int64_t), &pStable, sizeof(int64_t)); + + mTrace("stable:%s, perform insert action, uid:%" PRIu64, pStable->info.tableId, pStable->uid); return TSDB_CODE_SUCCESS; } static int32_t mnodeSuperTableActionDelete(SSdbRow *pRow) { SSTableObj *pStable = pRow->pObj; - SDbObj *pDb = mnodeGetDbByTableName(pStable->info.tableId); + SDbObj * pDb = mnodeGetDbByTableName(pStable->info.tableId); if (pDb != NULL) { mnodeRemoveSuperTableFromDb(pDb); mnodeDropAllChildTablesInStable((SSTableObj *)pStable); @@ -463,6 +485,8 @@ static int32_t mnodeSuperTableActionDelete(SSdbRow *pRow) { mnodeDecDbRef(pDb); taosHashRemove(tsSTableUidHash, &pStable->uid, sizeof(int64_t)); + + mTrace("stable:%s, perform delete action, uid:%" PRIu64, pStable->info.tableId, pStable->uid); return TSDB_CODE_SUCCESS; } diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index 008a655597..ef45936eaa 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -443,6 +443,7 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi mDebug("msg:%p, app:%p db:%s, no enough sid in vgId:%d", pMsg, pMsg->rpcMsg.ahandle, pDb->name, pVgroup->vgId); continue; } + mTrace("vgId:%d, alloc tid:%d", pVgroup->vgId, sid); *pSid = sid; *ppVgroup = pVgroup; @@ -507,6 +508,7 @@ int32_t mnodeGetAvailableVgroup(SMnodeMsg *pMsg, SVgObj **ppVgroup, int32_t *pSi pDb->vgListIndex = 0; pthread_mutex_unlock(&pDb->mutex); + mTrace("vgId:%d, alloc tid:%d", pVgroup->vgId, sid); return TSDB_CODE_SUCCESS; } @@ -832,26 +834,37 @@ static int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, v return numOfRows; } -void mnodeAddTableIntoVgroup(SVgObj *pVgroup, SCTableObj *pTable) { +int32_t mnodeAddTableIntoVgroup(SVgObj *pVgroup, SCTableObj *pTable) { int32_t idPoolSize = taosIdPoolMaxSize(pVgroup->idPool); if (pTable->tid > idPoolSize) { mnodeAllocVgroupIdPool(pVgroup); } if (pTable->tid >= 1) { - taosIdPoolMarkStatus(pVgroup->idPool, pTable->tid); - pVgroup->numOfTables++; - // The create vgroup message may be received later than the create table message - // and the writing order in sdb is therefore uncertain - // which will cause the reference count of the vgroup to be incorrect when restarting - // mnodeIncVgroupRef(pVgroup); + if (taosIdPoolMarkStatus(pVgroup->idPool, pTable->tid)) { + pVgroup->numOfTables++; + mTrace("table:%s, vgId:%d tid:%d, mark tid used, uid:%" PRIu64, pTable->info.tableId, pTable->vgId, pTable->tid, + pTable->uid); + // The create vgroup message may be received later than the create table message + // and the writing order in sdb is therefore uncertain + // which will cause the reference count of the vgroup to be incorrect when restarting + // mnodeIncVgroupRef(pVgroup); + } else { + mError("table:%s, vgId:%d tid:%d, failed to mark tid, uid:%" PRIu64, pTable->info.tableId, pTable->vgId, + pTable->tid, pTable->uid); + return -1; + } } + + return 0; } void mnodeRemoveTableFromVgroup(SVgObj *pVgroup, SCTableObj *pTable) { if (pTable->tid >= 1) { taosFreeId(pVgroup->idPool, pTable->tid); pVgroup->numOfTables--; + mTrace("table:%s, vgId:%d tid:%d, put tid back uid:%" PRIu64, pTable->info.tableId, pTable->vgId, pTable->tid, + pTable->uid); // The create vgroup message may be received later than the create table message // and the writing order in sdb is therefore uncertain // which will cause the reference count of the vgroup to be incorrect when restarting diff --git a/src/util/inc/tidpool.h b/src/util/inc/tidpool.h index bf35251631..e4439439ce 100644 --- a/src/util/inc/tidpool.h +++ b/src/util/inc/tidpool.h @@ -34,7 +34,7 @@ void taosIdPoolCleanUp(void *handle); int taosIdPoolNumOfUsed(void *handle); -void taosIdPoolMarkStatus(void *handle, int id); +bool taosIdPoolMarkStatus(void *handle, int id); #ifdef __cplusplus } diff --git a/src/util/src/tidpool.c b/src/util/src/tidpool.c index 53d81bb542..3955960539 100644 --- a/src/util/src/tidpool.c +++ b/src/util/src/tidpool.c @@ -104,10 +104,16 @@ void taosIdPoolCleanUp(void *handle) { int taosIdPoolNumOfUsed(void *handle) { id_pool_t *pIdPool = handle; - return pIdPool->maxId - pIdPool->numOfFree; + + pthread_mutex_lock(&pIdPool->mutex); + int ret = pIdPool->maxId - pIdPool->numOfFree; + pthread_mutex_unlock(&pIdPool->mutex); + + return ret; } -void taosIdPoolMarkStatus(void *handle, int id) { +bool taosIdPoolMarkStatus(void *handle, int id) { + bool ret = false; id_pool_t *pIdPool = handle; pthread_mutex_lock(&pIdPool->mutex); @@ -115,9 +121,14 @@ void taosIdPoolMarkStatus(void *handle, int id) { if (!pIdPool->freeList[slot]) { pIdPool->freeList[slot] = true; pIdPool->numOfFree--; + ret = true; + } else { + ret = false; + uError("pool:%p, id:%d is already used by other obj", pIdPool, id); } pthread_mutex_unlock(&pIdPool->mutex); + return ret; } int taosUpdateIdPool(id_pool_t *handle, int maxId) { @@ -147,6 +158,11 @@ int taosUpdateIdPool(id_pool_t *handle, int maxId) { } int taosIdPoolMaxSize(void *handle) { - id_pool_t *pIdPool = (id_pool_t*)handle; - return pIdPool->maxId; + id_pool_t *pIdPool = (id_pool_t *)handle; + + pthread_mutex_lock(&pIdPool->mutex); + int ret = pIdPool->maxId; + pthread_mutex_unlock(&pIdPool->mutex); + + return ret; } \ No newline at end of file From 681c314b44c53af19c556ac002228d381af2a4ea Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 18 Mar 2021 09:40:07 +0000 Subject: [PATCH 73/89] TD-3355 --- src/mnode/inc/mnodeVgroup.h | 2 +- src/mnode/src/mnodeTable.c | 25 +++++++++++-------------- src/mnode/src/mnodeVgroup.c | 4 ++-- src/util/src/tidpool.c | 1 - 4 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/mnode/inc/mnodeVgroup.h b/src/mnode/inc/mnodeVgroup.h index 02dc42a1f8..e052cdb83c 100644 --- a/src/mnode/inc/mnodeVgroup.h +++ b/src/mnode/inc/mnodeVgroup.h @@ -44,7 +44,7 @@ void mnodeDropVgroup(SVgObj *pVgroup, void *ahandle); void mnodeAlterVgroup(SVgObj *pVgroup, void *ahandle); int32_t mnodeGetAvailableVgroup(struct SMnodeMsg *pMsg, SVgObj **pVgroup, int32_t *sid); -int32_t mnodeAddTableIntoVgroup(SVgObj *pVgroup, SCTableObj *pTable); +int32_t mnodeAddTableIntoVgroup(SVgObj *pVgroup, SCTableObj *pTable, bool needCheck); void mnodeRemoveTableFromVgroup(SVgObj *pVgroup, SCTableObj *pTable); void mnodeSendDropVnodeMsg(int32_t vgId, SRpcEpSet *epSet, void *ahandle); void mnodeSendCreateVgroupMsg(SVgObj *pVgroup, void *ahandle); diff --git a/src/mnode/src/mnodeTable.c b/src/mnode/src/mnodeTable.c index 65b0408a8f..39eca8819d 100644 --- a/src/mnode/src/mnodeTable.c +++ b/src/mnode/src/mnodeTable.c @@ -152,7 +152,7 @@ static int32_t mnodeChildTableActionInsert(SSdbRow *pRow) { if (pDb) mnodeAddTableIntoDb(pDb); if (pVgroup) { - if (mnodeAddTableIntoVgroup(pVgroup, pTable) != 0) { + if (mnodeAddTableIntoVgroup(pVgroup, pTable, pRow->pMsg == NULL) != 0) { mError("table:%s, vgId:%d tid:%d, failed to perform insert action, uid:%" PRIu64 " suid:%" PRIu64, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid, pTable->suid); code = -1; @@ -1912,15 +1912,14 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) { pMsg->rpcMsg.handle); if (pMsg->pBatchMasterMsg) { - ++pMsg->pBatchMasterMsg->successed; - if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received - >= pMsg->pBatchMasterMsg->expected) { - dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, code); - } + ++pMsg->pBatchMasterMsg->successed; + if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received >= pMsg->pBatchMasterMsg->expected) { + dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, code); + } - mnodeDestroySubMsg(pMsg); + mnodeDestroySubMsg(pMsg); - return TSDB_CODE_MND_ACTION_IN_PROGRESS; + return TSDB_CODE_MND_ACTION_IN_PROGRESS; } dnodeSendRpcMWriteRsp(pMsg, TSDB_CODE_SUCCESS); @@ -1935,9 +1934,8 @@ static int32_t mnodeDoCreateChildTableCb(SMnodeMsg *pMsg, int32_t code) { if (pMsg->pBatchMasterMsg) { ++pMsg->pBatchMasterMsg->received; pMsg->pBatchMasterMsg->code = code; - if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received - >= pMsg->pBatchMasterMsg->expected) { - dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, code); + if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received >= pMsg->pBatchMasterMsg->expected) { + dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, code); } mnodeDestroySubMsg(pMsg); @@ -2686,9 +2684,8 @@ static void mnodeProcessCreateChildTableRsp(SRpcMsg *rpcMsg) { if (pMsg->pBatchMasterMsg) { ++pMsg->pBatchMasterMsg->successed; - if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received - >= pMsg->pBatchMasterMsg->expected) { - dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, rpcMsg->code); + if (pMsg->pBatchMasterMsg->successed + pMsg->pBatchMasterMsg->received >= pMsg->pBatchMasterMsg->expected) { + dnodeSendRpcMWriteRsp(pMsg->pBatchMasterMsg, rpcMsg->code); } mnodeDestroySubMsg(pMsg); diff --git a/src/mnode/src/mnodeVgroup.c b/src/mnode/src/mnodeVgroup.c index ef45936eaa..fdbf7ae398 100644 --- a/src/mnode/src/mnodeVgroup.c +++ b/src/mnode/src/mnodeVgroup.c @@ -834,14 +834,14 @@ static int32_t mnodeRetrieveVgroups(SShowObj *pShow, char *data, int32_t rows, v return numOfRows; } -int32_t mnodeAddTableIntoVgroup(SVgObj *pVgroup, SCTableObj *pTable) { +int32_t mnodeAddTableIntoVgroup(SVgObj *pVgroup, SCTableObj *pTable, bool needCheck) { int32_t idPoolSize = taosIdPoolMaxSize(pVgroup->idPool); if (pTable->tid > idPoolSize) { mnodeAllocVgroupIdPool(pVgroup); } if (pTable->tid >= 1) { - if (taosIdPoolMarkStatus(pVgroup->idPool, pTable->tid)) { + if (taosIdPoolMarkStatus(pVgroup->idPool, pTable->tid) || !needCheck) { pVgroup->numOfTables++; mTrace("table:%s, vgId:%d tid:%d, mark tid used, uid:%" PRIu64, pTable->info.tableId, pTable->vgId, pTable->tid, pTable->uid); diff --git a/src/util/src/tidpool.c b/src/util/src/tidpool.c index 3955960539..bd3f774543 100644 --- a/src/util/src/tidpool.c +++ b/src/util/src/tidpool.c @@ -124,7 +124,6 @@ bool taosIdPoolMarkStatus(void *handle, int id) { ret = true; } else { ret = false; - uError("pool:%p, id:%d is already used by other obj", pIdPool, id); } pthread_mutex_unlock(&pIdPool->mutex); From 7610e8111d637d8a77babc050ccb4680f0918d89 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 18 Mar 2021 17:43:09 +0800 Subject: [PATCH 74/89] Feature/sangshuduo/td 3317 taosdemo interlace (#5485) * [TD-3316] : add testcase for taosdemo limit and offset. check offset 0. * [TD-3316] : add testcase for taosdemo limit and offset. fix sample file import bug. * [TD-3316] : add test case for limit and offset. fix sample data issue. * [TD-3327] : fix taosdemo segfault when import data from sample data file. * [TD-3317] : make taosdemo support interlace mode. json parameter rows_per_tbl support. * [TD-3317] : support interlace mode. refactor * [TD-3317] : support interlace mode. refactor * [TD-3317] : support interlace mode insertion. refactor. * [TD-3317] : support interlace mode insertion. change json file. * [TD-3317] : support interlace mode insertion. fix multithread create table regression. * [TD-3317] : support interlace mode insertion. working but not perfect. * [TD-3317] : support interlace mode insertion. rename lowaTest with taosdemoTestWithJson * [TD-3317] : support interlace mode insertion. perfect * [TD-3317] : support interlace mode insertion. cleanup. * [TD-3317] : support interlace mode insertion. adjust algorithm of loop times. Co-authored-by: Shuduo Sang --- src/kit/taosdemo/taosdemo.c | 378 ++++++++++++++++++++---------------- 1 file changed, 211 insertions(+), 167 deletions(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 83195ca15d..355f738885 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -567,12 +567,19 @@ static FILE * g_fpOfInsertResult = NULL; #define debugPrint(fmt, ...) \ do { if (g_args.debug_print || g_args.verbose_print) \ fprintf(stderr, "DEBG: "fmt, __VA_ARGS__); } while(0) + #define verbosePrint(fmt, ...) \ do { if (g_args.verbose_print) \ fprintf(stderr, "VERB: "fmt, __VA_ARGS__); } while(0) +#define errorPrint(fmt, ...) \ + do { fprintf(stderr, "ERROR: "fmt, __VA_ARGS__); } while(0) + + /////////////////////////////////////////////////// +static void ERROR_EXIT(const char *msg) { perror(msg); exit(-1); } + void printHelp() { char indent[10] = " "; printf("%s%s%s%s\n", indent, "-f", indent, @@ -645,7 +652,7 @@ void parse_args(int argc, char *argv[], SArguments *arguments) { } else if (strcmp(argv[i], "-c") == 0) { char *configPath = argv[++i]; if (wordexp(configPath, &full_path, 0) != 0) { - fprintf(stderr, "Invalid path %s\n", configPath); + errorPrint( "Invalid path %s\n", configPath); return; } taos_options(TSDB_OPTION_CONFIGDIR, full_path.we_wordv[0]); @@ -694,8 +701,8 @@ void parse_args(int argc, char *argv[], SArguments *arguments) { && strcasecmp(argv[i], "DOUBLE") && strcasecmp(argv[i], "BINARY") && strcasecmp(argv[i], "NCHAR")) { - fprintf(stderr, "Invalid data_type!\n"); printHelp(); + ERROR_EXIT( "Invalid data_type!\n"); exit(EXIT_FAILURE); } sptr[0] = argv[i]; @@ -715,8 +722,8 @@ void parse_args(int argc, char *argv[], SArguments *arguments) { && strcasecmp(token, "DOUBLE") && strcasecmp(token, "BINARY") && strcasecmp(token, "NCHAR")) { - fprintf(stderr, "Invalid data_type!\n"); printHelp(); + ERROR_EXIT("Invalid data_type!\n"); exit(EXIT_FAILURE); } sptr[index++] = token; @@ -771,8 +778,8 @@ void parse_args(int argc, char *argv[], SArguments *arguments) { printHelp(); exit(0); } else { - fprintf(stderr, "wrong options\n"); printHelp(); + ERROR_EXIT("ERROR: wrong options\n"); exit(EXIT_FAILURE); } } @@ -858,7 +865,7 @@ static int queryDbExec(TAOS *taos, char *command, int type) { if (code != 0) { debugPrint("%s() LN%d - command: %s\n", __func__, __LINE__, command); - fprintf(stderr, "Failed to run %s, reason: %s\n", command, taos_errstr(res)); + errorPrint( "Failed to run %s, reason: %s\n", command, taos_errstr(res)); taos_free_result(res); //taos_close(taos); return -1; @@ -884,13 +891,13 @@ static void getResult(TAOS_RES *res, char* resultFileName) { if (resultFileName[0] != 0) { fp = fopen(resultFileName, "at"); if (fp == NULL) { - fprintf(stderr, "failed to open result file: %s, result will not save to file\n", resultFileName); + errorPrint("%s() LN%d, failed to open result file: %s, result will not save to file\n", __func__, __LINE__, resultFileName); } } char* databuf = (char*) calloc(1, 100*1024*1024); if (databuf == NULL) { - fprintf(stderr, "failed to malloc, warning: save result to file slowly!\n"); + errorPrint("%s() LN%d, failed to malloc, warning: save result to file slowly!\n", __func__, __LINE__); if (fp) fclose(fp); return ; @@ -1484,7 +1491,7 @@ static int xDumpResultToFile(const char* fname, TAOS_RES* tres) { FILE* fp = fopen(fname, "at"); if (fp == NULL) { - fprintf(stderr, "ERROR: failed to open file: %s\n", fname); + errorPrint("%s() LN%d, failed to open file: %s\n", __func__, __LINE__, fname); return -1; } @@ -1529,7 +1536,7 @@ static int getDbFromServer(TAOS * taos, SDbInfo** dbInfos) { int32_t code = taos_errno(res); if (code != 0) { - fprintf(stderr, "failed to run , reason: %s\n", taos_errstr(res)); + errorPrint( "failed to run , reason: %s\n", taos_errstr(res)); return -1; } @@ -1541,7 +1548,7 @@ static int getDbFromServer(TAOS * taos, SDbInfo** dbInfos) { dbInfos[count] = (SDbInfo *)calloc(1, sizeof(SDbInfo)); if (dbInfos[count] == NULL) { - fprintf(stderr, "failed to allocate memory for some dbInfo[%d]\n", count); + errorPrint( "failed to allocate memory for some dbInfo[%d]\n", count); return -1; } @@ -1576,7 +1583,7 @@ static int getDbFromServer(TAOS * taos, SDbInfo** dbInfos) { count++; if (count > MAX_DATABASE_COUNT) { - fprintf(stderr, "The database count overflow than %d\n", MAX_DATABASE_COUNT); + errorPrint( "The database count overflow than %d\n", MAX_DATABASE_COUNT); break; } } @@ -1590,7 +1597,7 @@ static void printfDbInfoForQueryToFile(char* filename, SDbInfo* dbInfos, int ind FILE *fp = fopen(filename, "at"); if (fp == NULL) { - fprintf(stderr, "failed to open file: %s\n", filename); + errorPrint( "failed to open file: %s\n", filename); return; } @@ -1646,7 +1653,7 @@ static void printfQuerySystemInfo(TAOS * taos) { res = taos_query(taos, "show databases;"); SDbInfo** dbInfos = (SDbInfo **)calloc(MAX_DATABASE_COUNT, sizeof(SDbInfo *)); if (dbInfos == NULL) { - fprintf(stderr, "failed to allocate memory\n"); + errorPrint("%s() LN%d, failed to allocate memory\n", __func__, __LINE__); return; } int dbCount = getDbFromServer(taos, dbInfos); @@ -1676,8 +1683,6 @@ static void printfQuerySystemInfo(TAOS * taos) { } -static void ERROR_EXIT(const char *msg) { perror(msg); exit(-1); } - static int postProceSql(char* host, uint16_t port, char* sqlstr) { char *req_fmt = "POST %s HTTP/1.1\r\nHost: %s:%d\r\nAccept: */*\r\nAuthorization: Basic %s\r\nContent-Length: %d\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n%s"; @@ -1725,9 +1730,9 @@ static int postProceSql(char* host, uint16_t port, char* sqlstr) sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) { #ifdef WINDOWS - fprintf(stderr, "Could not create socket : %d" , WSAGetLastError()); + errorPrint( "Could not create socket : %d" , WSAGetLastError()); #endif - debugPrint("%s() LN%d sockfd=%d\n", __func__, __LINE__, sockfd); + debugPrint("%s() LN%d, sockfd=%d\n", __func__, __LINE__, sockfd); free(request_buf); ERROR_EXIT("ERROR opening socket"); } @@ -1847,7 +1852,7 @@ static int postProceSql(char* host, uint16_t port, char* sqlstr) static char* getTagValueFromTagSample(SSuperTable* stbInfo, int tagUsePos) { char* dataBuf = (char*)calloc(TSDB_MAX_SQL_LEN+1, 1); if (NULL == dataBuf) { - printf("calloc failed! size:%d\n", TSDB_MAX_SQL_LEN+1); + errorPrint("%s() LN%d, calloc failed! size:%d\n", __func__, __LINE__, TSDB_MAX_SQL_LEN+1); return NULL; } @@ -2140,7 +2145,7 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName, int childTblCount = 10000; superTbls->childTblName = (char*)calloc(1, childTblCount * TSDB_TABLE_NAME_LEN); if (superTbls->childTblName == NULL) { - fprintf(stderr, "alloc memory failed!"); + errorPrint("%s() LN%d, alloc memory failed!\n", __func__, __LINE__); return -1; } getAllChildNameOfSuperTable(taos, dbName, @@ -2279,7 +2284,7 @@ static int createSuperTable(TAOS * taos, char* dbName, SSuperTable* superTbls, verbosePrint("%s() LN%d: %s\n", __func__, __LINE__, command); if (0 != queryDbExec(taos, command, NO_INSERT_TYPE)) { - fprintf(stderr, "create supertable %s failed!\n\n", + errorPrint( "create supertable %s failed!\n\n", superTbls->sTblName); return -1; } @@ -2293,7 +2298,7 @@ static int createDatabases() { int ret = 0; taos = taos_connect(g_Dbs.host, g_Dbs.user, g_Dbs.password, NULL, g_Dbs.port); if (taos == NULL) { - fprintf(stderr, "Failed to connect to TDengine, reason:%s\n", taos_errstr(NULL)); + errorPrint( "Failed to connect to TDengine, reason:%s\n", taos_errstr(NULL)); return -1; } char command[BUFFER_SIZE] = "\0"; @@ -2378,7 +2383,7 @@ static int createDatabases() { debugPrint("%s() %d command: %s\n", __func__, __LINE__, command); if (0 != queryDbExec(taos, command, NO_INSERT_TYPE)) { taos_close(taos); - fprintf(stderr, "\ncreate database %s failed!\n\n", g_Dbs.db[i].dbName); + errorPrint( "\ncreate database %s failed!\n\n", g_Dbs.db[i].dbName); return -1; } printf("\ncreate database %s success!\n\n", g_Dbs.db[i].dbName); @@ -2427,7 +2432,7 @@ static void* createTable(void *sarg) char *buffer = calloc(buff_len, 1); if (buffer == NULL) { - fprintf(stderr, "Memory allocated failed!"); + errorPrint("%s() LN%d, Memory allocated failed!\n", __func__, __LINE__); exit(-1); } @@ -2485,7 +2490,7 @@ static void* createTable(void *sarg) len = 0; verbosePrint("%s() LN%d %s\n", __func__, __LINE__, buffer); if (0 != queryDbExec(winfo->taos, buffer, NO_INSERT_TYPE)){ - fprintf(stderr, "queryDbExec() failed. buffer:\n%s\n", buffer); + errorPrint( "queryDbExec() failed. buffer:\n%s\n", buffer); free(buffer); return NULL; } @@ -2501,7 +2506,7 @@ static void* createTable(void *sarg) if (0 != len) { verbosePrint("%s() %d buffer: %s\n", __func__, __LINE__, buffer); if (0 != queryDbExec(winfo->taos, buffer, NO_INSERT_TYPE)) { - fprintf(stderr, "queryDbExec() failed. buffer:\n%s\n", buffer); + errorPrint( "queryDbExec() failed. buffer:\n%s\n", buffer); } } @@ -2546,7 +2551,7 @@ static int startMultiThreadCreateChildTable( db_name, g_Dbs.port); if (t_info->taos == NULL) { - fprintf(stderr, "Failed to connect to TDengine, reason:%s\n", taos_errstr(NULL)); + errorPrint( "Failed to connect to TDengine, reason:%s\n", taos_errstr(NULL)); free(pids); free(infos); return -1; @@ -2724,7 +2729,7 @@ static int readSampleFromCsvFileToMem( FILE* fp = fopen(superTblInfo->sampleFile, "r"); if (fp == NULL) { - fprintf(stderr, "Failed to open sample file: %s, reason:%s\n", + errorPrint( "Failed to open sample file: %s, reason:%s\n", superTblInfo->sampleFile, strerror(errno)); return -1; } @@ -2736,7 +2741,7 @@ static int readSampleFromCsvFileToMem( readLen = tgetline(&line, &n, fp); if (-1 == readLen) { if(0 != fseek(fp, 0, SEEK_SET)) { - fprintf(stderr, "Failed to fseek file: %s, reason:%s\n", + errorPrint( "Failed to fseek file: %s, reason:%s\n", superTblInfo->sampleFile, strerror(errno)); fclose(fp); return -1; @@ -2805,8 +2810,8 @@ static bool getColumnAndTagTypeFromInsertJsonFile(cJSON* stbInfo, SSuperTable* s int columnSize = cJSON_GetArraySize(columns); if (columnSize > MAX_COLUMN_COUNT) { - printf("ERROR: failed to read json, column size overflow, max column size is %d\n", - MAX_COLUMN_COUNT); + errorPrint("%s() LN%d, failed to read json, column size overflow, max column size is %d\n", + __func__, __LINE__, MAX_COLUMN_COUNT); goto PARSE_OVER; } @@ -2824,7 +2829,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(cJSON* stbInfo, SSuperTable* s if (countObj && countObj->type == cJSON_Number) { count = countObj->valueint; } else if (countObj && countObj->type != cJSON_Number) { - printf("ERROR: failed to read json, column count not found\n"); + errorPrint("%s() LN%d, failed to read json, column count not found\n", __func__, __LINE__); goto PARSE_OVER; } else { count = 1; @@ -2834,7 +2839,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(cJSON* stbInfo, SSuperTable* s memset(&columnCase, 0, sizeof(StrColumn)); cJSON *dataType = cJSON_GetObjectItem(column, "type"); if (!dataType || dataType->type != cJSON_String || dataType->valuestring == NULL) { - printf("ERROR: failed to read json, column type not found\n"); + errorPrint("%s() LN%d: failed to read json, column type not found\n", __func__, __LINE__); goto PARSE_OVER; } //tstrncpy(superTbls->columns[k].dataType, dataType->valuestring, MAX_TB_NAME_SIZE); @@ -2844,7 +2849,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(cJSON* stbInfo, SSuperTable* s if (dataLen && dataLen->type == cJSON_Number) { columnCase.dataLen = dataLen->valueint; } else if (dataLen && dataLen->type != cJSON_Number) { - printf("ERROR: failed to read json, column len not found\n"); + debugPrint("%s() LN%d: failed to read json, column len not found\n", __func__, __LINE__); goto PARSE_OVER; } else { columnCase.dataLen = 8; @@ -2863,13 +2868,13 @@ static bool getColumnAndTagTypeFromInsertJsonFile(cJSON* stbInfo, SSuperTable* s // tags cJSON *tags = cJSON_GetObjectItem(stbInfo, "tags"); if (!tags || tags->type != cJSON_Array) { - printf("ERROR: failed to read json, tags not found\n"); + debugPrint("%s() LN%d, failed to read json, tags not found\n", __func__, __LINE__); goto PARSE_OVER; } int tagSize = cJSON_GetArraySize(tags); if (tagSize > MAX_TAG_COUNT) { - printf("ERROR: failed to read json, tags size overflow, max tag size is %d\n", MAX_TAG_COUNT); + debugPrint("%s() LN%d, failed to read json, tags size overflow, max tag size is %d\n", __func__, __LINE__, MAX_TAG_COUNT); goto PARSE_OVER; } @@ -2991,47 +2996,47 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { goto PARSE_OVER; } - cJSON* gInsertInterval = cJSON_GetObjectItem(root, "insert_interval"); - if (gInsertInterval && gInsertInterval->type == cJSON_Number) { - g_args.insert_interval = gInsertInterval->valueint; - } else if (!gInsertInterval) { - g_args.insert_interval = 0; - } else { - fprintf(stderr, "ERROR: failed to read json, insert_interval input mistake\n"); - goto PARSE_OVER; - } - - cJSON* rowsPerTbl = cJSON_GetObjectItem(root, "rows_per_tbl"); - if (rowsPerTbl && rowsPerTbl->type == cJSON_Number) { - g_args.rows_per_tbl = rowsPerTbl->valueint; - } else if (!rowsPerTbl) { - g_args.rows_per_tbl = 0; // 0 means progressive mode, > 0 mean interlace mode. max value is less or equ num_of_records_per_req - } else { - fprintf(stderr, "ERROR: failed to read json, rows_per_tbl input mistake\n"); - goto PARSE_OVER; - } + cJSON* gInsertInterval = cJSON_GetObjectItem(root, "insert_interval"); + if (gInsertInterval && gInsertInterval->type == cJSON_Number) { + g_args.insert_interval = gInsertInterval->valueint; + } else if (!gInsertInterval) { + g_args.insert_interval = 0; + } else { + errorPrint("%s() LN%d, failed to read json, insert_interval input mistake\n", __func__, __LINE__); + goto PARSE_OVER; + } - cJSON* maxSqlLen = cJSON_GetObjectItem(root, "max_sql_len"); - if (maxSqlLen && maxSqlLen->type == cJSON_Number) { - g_args.max_sql_len = maxSqlLen->valueint; - } else if (!maxSqlLen) { - g_args.max_sql_len = TSDB_PAYLOAD_SIZE; - } else { - fprintf(stderr, "ERROR: failed to read json, max_sql_len input mistake\n"); - goto PARSE_OVER; - } + cJSON* rowsPerTbl = cJSON_GetObjectItem(root, "rows_per_tbl"); + if (rowsPerTbl && rowsPerTbl->type == cJSON_Number) { + g_args.rows_per_tbl = rowsPerTbl->valueint; + } else if (!rowsPerTbl) { + g_args.rows_per_tbl = 0; // 0 means progressive mode, > 0 mean interlace mode. max value is less or equ num_of_records_per_req + } else { + errorPrint("%s() LN%d, failed to read json, rows_per_tbl input mistake\n", __func__, __LINE__); + goto PARSE_OVER; + } + + cJSON* maxSqlLen = cJSON_GetObjectItem(root, "max_sql_len"); + if (maxSqlLen && maxSqlLen->type == cJSON_Number) { + g_args.max_sql_len = maxSqlLen->valueint; + } else if (!maxSqlLen) { + g_args.max_sql_len = TSDB_PAYLOAD_SIZE; + } else { + errorPrint("%s() LN%d, failed to read json, max_sql_len input mistake\n", __func__, __LINE__); + goto PARSE_OVER; + } - cJSON* numRecPerReq = cJSON_GetObjectItem(root, "num_of_records_per_req"); - if (numRecPerReq && numRecPerReq->type == cJSON_Number) { - g_args.num_of_RPR = numRecPerReq->valueint; - } else if (!numRecPerReq) { - g_args.num_of_RPR = 100; - } else { - printf("ERROR: failed to read json, num_of_records_per_req not found\n"); - goto PARSE_OVER; - } - + cJSON* numRecPerReq = cJSON_GetObjectItem(root, "num_of_records_per_req"); + if (numRecPerReq && numRecPerReq->type == cJSON_Number) { + g_args.num_of_RPR = numRecPerReq->valueint; + } else if (!numRecPerReq) { + g_args.num_of_RPR = 100; + } else { + errorPrint("%s() LN%d, failed to read json, num_of_records_per_req not found\n", __func__, __LINE__); + goto PARSE_OVER; + } + cJSON *answerPrompt = cJSON_GetObjectItem(root, "confirm_parameter_prompt"); // yes, no, if (answerPrompt && answerPrompt->type == cJSON_String @@ -3058,7 +3063,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { int dbSize = cJSON_GetArraySize(dbs); if (dbSize > MAX_DB_COUNT) { - fprintf(stderr, + errorPrint( "ERROR: failed to read json, databases size overflow, max database is %d\n", MAX_DB_COUNT); goto PARSE_OVER; @@ -3257,7 +3262,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { int stbSize = cJSON_GetArraySize(stables); if (stbSize > MAX_SUPER_TABLE_COUNT) { - fprintf(stderr, + errorPrint( "ERROR: failed to read json, databases size overflow, max database is %d\n", MAX_SUPER_TABLE_COUNT); goto PARSE_OVER; @@ -3384,9 +3389,11 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { cJSON *ts = cJSON_GetObjectItem(stbInfo, "start_timestamp"); if (ts && ts->type == cJSON_String && ts->valuestring != NULL) { - tstrncpy(g_Dbs.db[i].superTbls[j].startTimestamp, ts->valuestring, MAX_DB_NAME_SIZE); + tstrncpy(g_Dbs.db[i].superTbls[j].startTimestamp, + ts->valuestring, MAX_DB_NAME_SIZE); } else if (!ts) { - tstrncpy(g_Dbs.db[i].superTbls[j].startTimestamp, "now", MAX_DB_NAME_SIZE); + tstrncpy(g_Dbs.db[i].superTbls[j].startTimestamp, + "now", MAX_DB_NAME_SIZE); } else { printf("ERROR: failed to read json, start_timestamp not found\n"); goto PARSE_OVER; @@ -3493,7 +3500,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { } else if (!rowsPerTbl) { g_Dbs.db[i].superTbls[j].rowsPerTbl = 0; // 0 means progressive mode, > 0 mean interlace mode. max value is less or equ num_of_records_per_req } else { - fprintf(stderr, "ERROR: failed to read json, rowsPerTbl input mistake\n"); + errorPrint("%s() LN%d, failed to read json, rowsPerTbl input mistake\n", __func__, __LINE__); goto PARSE_OVER; } @@ -3523,7 +3530,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { } else if (!insertRows) { g_Dbs.db[i].superTbls[j].insertRows = 0x7FFFFFFFFFFFFFFF; } else { - fprintf(stderr, "failed to read json, insert_rows input mistake"); + errorPrint("%s() LN%d, failed to read json, insert_rows input mistake\n", __func__, __LINE__); goto PARSE_OVER; } @@ -3535,7 +3542,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { __func__, __LINE__, g_args.insert_interval); g_Dbs.db[i].superTbls[j].insertInterval = g_args.insert_interval; } else { - fprintf(stderr, "failed to read json, insert_interval input mistake"); + errorPrint("%s() LN%d, failed to read json, insert_interval input mistake\n", __func__, __LINE__); goto PARSE_OVER; } @@ -3942,7 +3949,7 @@ static bool getInfoFromJsonFile(char* file) { } else if (SUBSCRIBE_TEST == g_args.test_mode) { ret = getMetaFromQueryJsonFile(root); } else { - printf("ERROR: input json file type error! please input correct file type: insert or query or subscribe\n"); + errorPrint("%s() LN%d, input json file type error! please input correct file type: insert or query or subscribe\n", __func__, __LINE__); goto PARSE_OVER; } @@ -4024,14 +4031,14 @@ static int generateRowData(char* dataBuf, int maxLen, int64_t timestamp, SSuper if ((0 == strncasecmp(stbInfo->columns[i].dataType, "binary", 6)) || (0 == strncasecmp(stbInfo->columns[i].dataType, "nchar", 5))) { if (stbInfo->columns[i].dataLen > TSDB_MAX_BINARY_LEN) { - printf("binary or nchar length overflow, max size:%u\n", + errorPrint( "binary or nchar length overflow, max size:%u\n", (uint32_t)TSDB_MAX_BINARY_LEN); return (-1); } char* buf = (char*)calloc(stbInfo->columns[i].dataLen+1, 1); if (NULL == buf) { - printf("calloc failed! size:%d\n", stbInfo->columns[i].dataLen); + errorPrint( "calloc failed! size:%d\n", stbInfo->columns[i].dataLen); return (-1); } rand_string(buf, stbInfo->columns[i].dataLen); @@ -4063,7 +4070,7 @@ static int generateRowData(char* dataBuf, int maxLen, int64_t timestamp, SSuper } else if (0 == strncasecmp(stbInfo->columns[i].dataType, "timestamp", 9)) { dataLen += snprintf(dataBuf + dataLen, maxLen - dataLen, "%"PRId64", ", rand_bigint()); } else { - printf("No support data type: %s\n", stbInfo->columns[i].dataType); + errorPrint( "No support data type: %s\n", stbInfo->columns[i].dataType); return (-1); } } @@ -4138,7 +4145,8 @@ static int prepareSampleDataForSTable(SSuperTable *superTblInfo) { sampleDataBuf = calloc( superTblInfo->lenOfOneRow * MAX_SAMPLES_ONCE_FROM_FILE, 1); if (sampleDataBuf == NULL) { - fprintf(stderr, "Failed to calloc %d Bytes, reason:%s\n", + errorPrint("%s() LN%d, Failed to calloc %d Bytes, reason:%s\n", + __func__, __LINE__, superTblInfo->lenOfOneRow * MAX_SAMPLES_ONCE_FROM_FILE, strerror(errno)); return -1; @@ -4148,7 +4156,7 @@ static int prepareSampleDataForSTable(SSuperTable *superTblInfo) { int ret = readSampleFromCsvFileToMem(superTblInfo); if (0 != ret) { - fprintf(stderr, "read sample from csv file failed.\n"); + errorPrint("%s() LN%d, read sample from csv file failed.\n", __func__, __LINE__); tmfree(sampleDataBuf); superTblInfo->sampleDataBuf = NULL; return -1; @@ -4157,29 +4165,26 @@ static int prepareSampleDataForSTable(SSuperTable *superTblInfo) { return 0; } -static int execInsert(threadInfo *winfo, char *buffer, int k) +static int execInsert(threadInfo *pThreadInfo, char *buffer, int k) { int affectedRows; - SSuperTable* superTblInfo = winfo->superTblInfo; + SSuperTable* superTblInfo = pThreadInfo->superTblInfo; + verbosePrint("[%d] %s() LN%d %s\n", pThreadInfo->threadID, + __func__, __LINE__, buffer); if (superTblInfo) { if (0 == strncasecmp(superTblInfo->insertMode, "taosc", strlen("taosc"))) { - verbosePrint("%s() LN%d %s\n", __func__, __LINE__, buffer); - affectedRows = queryDbExec(winfo->taos, buffer, INSERT_TYPE); + affectedRows = queryDbExec(pThreadInfo->taos, buffer, INSERT_TYPE); } else { - verbosePrint("%s() LN%d %s\n", __func__, __LINE__, buffer); - int retCode = postProceSql(g_Dbs.host, g_Dbs.port, buffer); - - if (0 != retCode) { + if (0 != postProceSql(g_Dbs.host, g_Dbs.port, buffer)) { affectedRows = -1; - printf("========restful return fail, threadID[%d]\n", winfo->threadID); + printf("========restful return fail, threadID[%d]\n", pThreadInfo->threadID); } else { affectedRows = k; } } } else { - verbosePrint("%s() LN%d %s\n", __func__, __LINE__, buffer); - affectedRows = queryDbExec(winfo->taos, buffer, 1); + affectedRows = queryDbExec(pThreadInfo->taos, buffer, 1); } return affectedRows; @@ -4195,8 +4200,9 @@ static void getTableName(char *pTblName, threadInfo* pThreadInfo, int tableSeq) superTblInfo->childTblName + (tableSeq - superTblInfo->childTblOffset) * TSDB_TABLE_NAME_LEN); } else { - verbosePrint("%s() LN%d: from=%d count=%d seq=%d\n", - __func__, __LINE__, pThreadInfo->start_table_from, + verbosePrint("[%d] %s() LN%d: from=%d count=%d seq=%d\n", + pThreadInfo->threadID, __func__, __LINE__, + pThreadInfo->start_table_from, pThreadInfo->ntables, tableSeq); snprintf(pTblName, TSDB_TABLE_NAME_LEN, "%s", superTblInfo->childTblName + tableSeq * TSDB_TABLE_NAME_LEN); @@ -4323,7 +4329,7 @@ static int generateSQLHead(char *tableName, int32_t tableSeq, threadInfo* pThrea tableSeq % superTblInfo->tagSampleCount); } if (NULL == tagsValBuf) { - fprintf(stderr, "tag buf failed to allocate memory\n"); + errorPrint("%s() LN%d, tag buf failed to allocate memory\n", __func__, __LINE__); return -1; } @@ -4396,13 +4402,14 @@ static int generateDataBuffer(char *pTblName, } static void* syncWriteInterlace(threadInfo *pThreadInfo) { - printf("### CBD: interlace write\n"); + debugPrint("[%d] %s() LN%d: ### interlace write\n", + pThreadInfo->threadID, __func__, __LINE__); SSuperTable* superTblInfo = pThreadInfo->superTblInfo; char* buffer = calloc(superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len, 1); if (NULL == buffer) { - fprintf(stderr, "Failed to alloc %d Bytes, reason:%s\n", + errorPrint( "Failed to alloc %d Bytes, reason:%s\n", superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len, strerror(errno)); return NULL; @@ -4437,8 +4444,8 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) { int tableSeq = pThreadInfo->start_table_from; - debugPrint("%s() LN%d: start_table_from=%d ntables=%d insertRows=%"PRId64"\n", - __func__, __LINE__, pThreadInfo->start_table_from, + debugPrint("[%d] %s() LN%d: start_table_from=%d ntables=%d insertRows=%"PRId64"\n", + pThreadInfo->threadID, __func__, __LINE__, pThreadInfo->start_table_from, pThreadInfo->ntables, insertRows); int64_t startTime = pThreadInfo->start_time; @@ -4446,80 +4453,111 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) { int batchPerTblTimes; int batchPerTbl; + assert(pThreadInfo->ntables > 0); + + if (rowsPerTbl > g_args.num_of_RPR) + rowsPerTbl = g_args.num_of_RPR; + + batchPerTbl = rowsPerTbl; if ((rowsPerTbl > 0) && (pThreadInfo->ntables > 1)) { - batchPerTblTimes = g_args.num_of_RPR / rowsPerTbl; - batchPerTbl = rowsPerTbl; + batchPerTblTimes = + (g_args.num_of_RPR / (rowsPerTbl * pThreadInfo->ntables)) + 1; } else { batchPerTblTimes = 1; - batchPerTbl = g_args.num_of_RPR; } int generatedRecPerTbl = 0; + bool flagSleep = true; + int sleepTimeTotal = 0; while(pThreadInfo->totalInsertRows < pThreadInfo->ntables * insertRows) { - if (insert_interval) { + if ((flagSleep) && (insert_interval)) { st = taosGetTimestampUs(); + flagSleep = false; } // generate data memset(buffer, 0, superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len); char *pstr = buffer; - int recGenerated = 0; + int recOfBatch = 0; for (int i = 0; i < batchPerTblTimes; i ++) { getTableName(tableName, pThreadInfo, tableSeq); int headLen; if (i == 0) { - headLen = generateSQLHead(tableName, tableSeq, pThreadInfo, superTblInfo, pstr); + headLen = generateSQLHead(tableName, tableSeq, pThreadInfo, + superTblInfo, pstr); } else { - headLen = snprintf(pstr, TSDB_TABLE_NAME_LEN, "%s.%s values", + headLen = snprintf(pstr, TSDB_TABLE_NAME_LEN, "%s.%s values", pThreadInfo->db_name, tableName); } // generate data buffer - verbosePrint("%s() LN%d i=%d buffer:\n%s\n", - __func__, __LINE__, i, buffer); + verbosePrint("[%d] %s() LN%d i=%d buffer:\n%s\n", + pThreadInfo->threadID, __func__, __LINE__, i, buffer); pstr += headLen; int dataLen = 0; - printf("%s() LN%d i=%d batchPerTblTimes=%d batchPerTbl = %d\n", - __func__, __LINE__, i, batchPerTblTimes, batchPerTbl); - int numOfRecGenerated = generateDataTail( - tableName, tableSeq, pThreadInfo, superTblInfo, - batchPerTbl, pstr, insertRows, 0, - startTime + pThreadInfo->totalInsertRows * superTblInfo->timeStampStep, - &(pThreadInfo->samplePos), &dataLen); - verbosePrint("%s() LN%d numOfRecGenerated= %d\n", - __func__, __LINE__, numOfRecGenerated); + debugPrint("[%d] %s() LN%d i=%d batchPerTblTimes=%d batchPerTbl = %d\n", + pThreadInfo->threadID, __func__, __LINE__, + i, batchPerTblTimes, batchPerTbl); + generateDataTail( + tableName, tableSeq, pThreadInfo, superTblInfo, + batchPerTbl, pstr, insertRows, 0, + startTime + sleepTimeTotal + + pThreadInfo->totalInsertRows * superTblInfo->timeStampStep, + &(pThreadInfo->samplePos), &dataLen); pstr += dataLen; - recGenerated += numOfRecGenerated; + recOfBatch += batchPerTbl; + pThreadInfo->totalInsertRows += batchPerTbl; + debugPrint("[%d] %s() LN%d batchPerTbl=%d recOfBatch=%d\n", + pThreadInfo->threadID, __func__, __LINE__, + batchPerTbl, recOfBatch); tableSeq ++; if (insertMode == INTERLACE_INSERT_MODE) { if (tableSeq == pThreadInfo->start_table_from + pThreadInfo->ntables) { // turn to first table tableSeq = pThreadInfo->start_table_from; - generatedRecPerTbl += numOfRecGenerated; + generatedRecPerTbl += batchPerTbl; + flagSleep = true; + if (generatedRecPerTbl >= insertRows) + break; + + if (pThreadInfo->ntables * batchPerTbl < g_args.num_of_RPR) + break; } } int remainRows = insertRows - generatedRecPerTbl; - if (batchPerTbl > remainRows) + if ((remainRows > 0) && (batchPerTbl > remainRows)) batchPerTbl = remainRows; - if ((g_args.num_of_RPR - recGenerated) < batchPerTbl) + debugPrint("[%d] %s() LN%d generatedRecPerTbl=%d insertRows=%"PRId64"\n", + pThreadInfo->threadID, __func__, __LINE__, + generatedRecPerTbl, insertRows); + + if ((g_args.num_of_RPR - recOfBatch) < batchPerTbl) break; } - pThreadInfo->totalInsertRows += recGenerated; - printf("%s() LN%d recGenerated=%d totalInsertRows=%"PRId64" buffer:\n%s\n", - __func__, __LINE__, recGenerated, - pThreadInfo->totalInsertRows, buffer); - int affectedRows = execInsert(pThreadInfo, buffer, recGenerated); - if (affectedRows < 0) + debugPrint("[%d] %s() LN%d recOfBatch=%d totalInsertRows=%"PRId64"\n", + pThreadInfo->threadID, __func__, __LINE__, recOfBatch, + pThreadInfo->totalInsertRows); + verbosePrint("[%d] %s() LN%d, buffer=%s\n", + pThreadInfo->threadID, __func__, __LINE__, buffer); + + int affectedRows = execInsert(pThreadInfo, buffer, recOfBatch); + verbosePrint("[%d] %s() LN%d affectedRows=%d\n", pThreadInfo->threadID, + __func__, __LINE__, affectedRows); + if (affectedRows < 0) { + errorPrint("[%d] %s() LN%d execInsert affected rows: %d\n%s\n", + pThreadInfo->threadID, __func__, __LINE__, + affectedRows, buffer); goto free_and_statistics_interlace; + } pThreadInfo->totalAffectedRows += affectedRows; @@ -4539,15 +4577,16 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) { lastPrintTime = currentPrintTime; } - if (insert_interval) { - et = taosGetTimestampUs(); + if ((insert_interval) && flagSleep) { + et = taosGetTimestampUs(); - if (insert_interval > ((et - st)/1000) ) { - int sleep_time = insert_interval - (et -st)/1000; - verbosePrint("%s() LN%d sleep: %d ms for insert interval\n", - __func__, __LINE__, sleep_time); - taosMsleep(sleep_time); // ms - } + if (insert_interval > ((et - st)/1000) ) { + int sleepTime = insert_interval - (et -st)/1000; +// verbosePrint("%s() LN%d sleep: %d ms for insert interval\n", +// __func__, __LINE__, sleepTime); + taosMsleep(sleepTime); // ms + sleepTimeTotal += insert_interval; + } } } @@ -4570,12 +4609,13 @@ free_and_statistics_interlace: 2 taosinsertdata , 1 thread: 10 tables * 20000 rows/s */ static void* syncWriteProgressive(threadInfo *pThreadInfo) { + debugPrint("%s() LN%d: ### progressive write\n", __func__, __LINE__); SSuperTable* superTblInfo = pThreadInfo->superTblInfo; char* buffer = calloc(superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len, 1); if (NULL == buffer) { - fprintf(stderr, "Failed to alloc %d Bytes, reason:%s\n", + errorPrint( "Failed to alloc %d Bytes, reason:%s\n", superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len, strerror(errno)); return NULL; @@ -4821,7 +4861,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, } else if (0 == strncasecmp(precision, "us", 2)) { timePrec = TSDB_TIME_PRECISION_MICRO; } else { - fprintf(stderr, "No support precision: %s\n", precision); + errorPrint( "No support precision: %s\n", precision); exit(-1); } } @@ -4831,15 +4871,15 @@ static void startMultiThreadInsertData(int threads, char* db_name, if (0 == strncasecmp(superTblInfo->startTimestamp, "now", 3)) { start_time = taosGetTimestamp(timePrec); } else { - if (TSDB_CODE_SUCCESS != taosParseTime( - superTblInfo->startTimestamp, - &start_time, - strlen(superTblInfo->startTimestamp), - timePrec, 0)) { - fprintf(stderr, "ERROR to parse time!\n"); - exit(-1); - } - } + if (TSDB_CODE_SUCCESS != taosParseTime( + superTblInfo->startTimestamp, + &start_time, + strlen(superTblInfo->startTimestamp), + timePrec, 0)) { + errorPrint("%s() LN%d, failed to parse time!\n", __func__, __LINE__); + exit(-1); + } + } } else { start_time = 1500000000000; } @@ -4857,7 +4897,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, if ((superTblInfo) && (0 == strncasecmp(superTblInfo->dataSource, "sample", strlen("sample")))) { if (0 != prepareSampleDataForSTable(superTblInfo)) { - fprintf(stderr, "prepare sample data for stable failed!\n"); + errorPrint("%s() LN%d, prepare sample data for stable failed!\n", __func__, __LINE__); exit(-1); } } @@ -4869,15 +4909,15 @@ static void startMultiThreadInsertData(int threads, char* db_name, g_Dbs.host, g_Dbs.user, g_Dbs.password, db_name, g_Dbs.port); if (NULL == taos) { - fprintf(stderr, "connect to server fail , reason: %s\n", - taos_errstr(NULL)); + errorPrint("%s() LN%d, connect to server fail , reason: %s\n", + __func__, __LINE__, taos_errstr(NULL)); exit(-1); } superTblInfo->childTblName = (char*)calloc(1, superTblInfo->childTblLimit * TSDB_TABLE_NAME_LEN); if (superTblInfo->childTblName == NULL) { - fprintf(stderr, "alloc memory failed!"); + errorPrint("%s() LN%d, alloc memory failed!\n", __func__, __LINE__); taos_close(taos); exit(-1); } @@ -4896,7 +4936,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, if ((superTblInfo) && (0 == strncasecmp(superTblInfo->dataSource, "sample", strlen("sample")))) { if (0 != prepareSampleDataForSTable(superTblInfo)) { - fprintf(stderr, "prepare sample data for stable failed!\n"); + errorPrint("%s() LN%d, prepare sample data for stable failed!\n", __func__, __LINE__); exit(-1); } } @@ -4906,8 +4946,8 @@ static void startMultiThreadInsertData(int threads, char* db_name, g_Dbs.host, g_Dbs.user, g_Dbs.password, db_name, g_Dbs.port); if (NULL == taos) { - fprintf(stderr, "connect to server fail , reason: %s\n", - taos_errstr(NULL)); + errorPrint("%s() LN%d, connect to server fail , reason: %s\n", + __func__, __LINE__, taos_errstr(NULL)); exit(-1); } @@ -4926,7 +4966,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, superTblInfo->childTblName = (char*)calloc(1, limit * TSDB_TABLE_NAME_LEN); if (superTblInfo->childTblName == NULL) { - fprintf(stderr, "alloc memory failed!"); + errorPrint("%s() LN%d, alloc memory failed!\n", __func__, __LINE__); taos_close(taos); exit(-1); } @@ -4957,7 +4997,7 @@ static void startMultiThreadInsertData(int threads, char* db_name, g_Dbs.host, g_Dbs.user, g_Dbs.password, db_name, g_Dbs.port); if (NULL == t_info->taos) { - fprintf(stderr, "connect to server fail from insert sub thread, reason: %s\n", + errorPrint( "connect to server fail from insert sub thread, reason: %s\n", taos_errstr(NULL)); exit(-1); } @@ -5001,6 +5041,10 @@ static void startMultiThreadInsertData(int threads, char* db_name, tsem_destroy(&(t_info->lock_sem)); taos_close(t_info->taos); + debugPrint("%s() LN%d, [%d] totalInsert=%"PRId64" totalAffected=%"PRId64"\n", + __func__, __LINE__, + t_info->threadID, t_info->totalInsertRows, + t_info->totalAffectedRows); if (superTblInfo) { superTblInfo->totalAffectedRows += t_info->totalAffectedRows; superTblInfo->totalInsertRows += t_info->totalInsertRows; @@ -5068,7 +5112,7 @@ void *readTable(void *sarg) { char *tb_prefix = rinfo->tb_prefix; FILE *fp = fopen(rinfo->fp, "a"); if (NULL == fp) { - fprintf(stderr, "fopen %s fail, reason:%s.\n", rinfo->fp, strerror(errno)); + errorPrint( "fopen %s fail, reason:%s.\n", rinfo->fp, strerror(errno)); return NULL; } @@ -5102,7 +5146,7 @@ void *readTable(void *sarg) { int32_t code = taos_errno(pSql); if (code != 0) { - fprintf(stderr, "Failed to query:%s\n", taos_errstr(pSql)); + errorPrint( "Failed to query:%s\n", taos_errstr(pSql)); taos_free_result(pSql); taos_close(taos); fclose(fp); @@ -5178,7 +5222,7 @@ void *readMetric(void *sarg) { int32_t code = taos_errno(pSql); if (code != 0) { - fprintf(stderr, "Failed to query:%s\n", taos_errstr(pSql)); + errorPrint( "Failed to query:%s\n", taos_errstr(pSql)); taos_free_result(pSql); taos_close(taos); fclose(fp); @@ -5216,7 +5260,7 @@ static int insertTestProcess() { debugPrint("%d result file: %s\n", __LINE__, g_Dbs.resultFile); g_fpOfInsertResult = fopen(g_Dbs.resultFile, "a"); if (NULL == g_fpOfInsertResult) { - fprintf(stderr, "Failed to open %s for save result\n", g_Dbs.resultFile); + errorPrint( "Failed to open %s for save result\n", g_Dbs.resultFile); return -1; } @@ -5407,7 +5451,7 @@ static int queryTestProcess() { NULL, g_queryInfo.port); if (taos == NULL) { - fprintf(stderr, "Failed to connect to TDengine, reason:%s\n", taos_errstr(NULL)); + errorPrint( "Failed to connect to TDengine, reason:%s\n", taos_errstr(NULL)); exit(-1); } @@ -5707,7 +5751,7 @@ static int subscribeTestProcess() { g_queryInfo.dbName, g_queryInfo.port); if (taos == NULL) { - fprintf(stderr, "Failed to connect to TDengine, reason:%s\n", taos_errstr(NULL)); + errorPrint( "Failed to connect to TDengine, reason:%s\n", taos_errstr(NULL)); exit(-1); } @@ -6065,7 +6109,7 @@ static void queryResult() { g_Dbs.db[0].dbName, g_Dbs.port); if (rInfo->taos == NULL) { - fprintf(stderr, "Failed to connect to TDengine, reason:%s\n", taos_errstr(NULL)); + errorPrint( "Failed to connect to TDengine, reason:%s\n", taos_errstr(NULL)); free(rInfo); exit(-1); } From 9e257230780a2f8406ef0c978e0ef5da6bc21e36 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Thu, 18 Mar 2021 17:48:33 +0800 Subject: [PATCH 75/89] remove last_cache.py from full test --- tests/pytest/fulltest.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index 46a1abf12c..d6849dea7d 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -275,7 +275,7 @@ python3 ./test.py -f functions/function_twa.py -r 1 python3 ./test.py -f functions/function_twa_test2.py python3 ./test.py -f functions/function_stddev_td2555.py python3 ./test.py -f insert/metadataUpdate.py -python3 ./test.py -f query/last_cache.py +#python3 ./test.py -f query/last_cache.py python3 ./test.py -f query/last_row_cache.py python3 ./test.py -f account/account_create.py python3 ./test.py -f alter/alter_table.py From 9122ca3b1d4b91ec939572b8cb9d75423ea378ca Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 18 Mar 2021 09:56:04 +0000 Subject: [PATCH 76/89] TD-3367 --- src/vnode/src/vnodeMain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vnode/src/vnodeMain.c b/src/vnode/src/vnodeMain.c index d25cf10774..ded39e67cc 100644 --- a/src/vnode/src/vnodeMain.c +++ b/src/vnode/src/vnodeMain.c @@ -147,7 +147,7 @@ static int32_t vnodeAlterImp(SVnodeObj *pVnode, SCreateVnodeMsg *pVnodeCfg) { vDebug("vgId:%d, tsdbchanged:%d syncchanged:%d while alter vnode", pVnode->vgId, tsdbCfgChanged, syncCfgChanged); - if (tsdbCfgChanged || syncCfgChanged) { + if (/*tsdbCfgChanged || */syncCfgChanged) { // vnode in non-ready state and still needs to return success instead of TSDB_CODE_VND_INVALID_STATUS // dbCfgVersion can be corrected by status msg if (!vnodeSetUpdatingStatus(pVnode)) { From a9ea81aaee54415406307b398c643c29533d333c Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Thu, 18 Mar 2021 18:13:44 +0800 Subject: [PATCH 77/89] update docker cluster script --- tests/pytest/cluster/clusterEnvSetup/basic.py | 39 +++++++++++----- .../clusterEnvSetup/buildClusterEnv.sh | 45 ++++++++++--------- .../clusterEnvSetup/cleanClusterEnv.sh | 39 ++++++++++++++++ 3 files changed, 92 insertions(+), 31 deletions(-) create mode 100755 tests/pytest/cluster/clusterEnvSetup/cleanClusterEnv.sh diff --git a/tests/pytest/cluster/clusterEnvSetup/basic.py b/tests/pytest/cluster/clusterEnvSetup/basic.py index d9b8e9ce4a..eb39051898 100644 --- a/tests/pytest/cluster/clusterEnvSetup/basic.py +++ b/tests/pytest/cluster/clusterEnvSetup/basic.py @@ -18,13 +18,15 @@ import argparse class BuildDockerCluser: - def __init__(self, hostName, user, password, configDir, numOfNodes, clusterVersion): + def __init__(self, hostName, user, password, configDir, numOfNodes, clusterVersion, dockerDir, removeFlag): self.hostName = hostName self.user = user self.password = password self.configDir = configDir self.numOfNodes = numOfNodes - self.clusterVersion = clusterVersion + self.clusterVersion = clusterVersion + self.dockerDir = dockerDir + self.removeFlag = removeFlag def getConnection(self): self.conn = taos.connect( @@ -42,14 +44,17 @@ class BuildDockerCluser: print("start arbitrator") os.system("docker exec -d $(docker ps|grep tdnode1|awk '{print $1}') tarbitrator") - def run(self): + def run(self): if self.numOfNodes < 2 or self.numOfNodes > 5: print("the number of nodes must be between 2 and 5") - exit(0) - os.system("./buildClusterEnv.sh -n %d -v %s" % (self.numOfNodes, self.clusterVersion)) + exit(0) + print("remove Flag value %s" % self.removeFlag) + if self.removeFlag == False: + os.system("./cleanClusterEnv.sh -d %s" % self.dockerDir) + os.system("./buildClusterEnv.sh -n %d -v %s -d %s" % (self.numOfNodes, self.clusterVersion, self.dockerDir)) self.getConnection() self.createDondes() - self.startArbitrator() + self.startArbitrator() parser = argparse.ArgumentParser() parser.add_argument( @@ -91,10 +96,24 @@ parser.add_argument( '-v', '--version', action='store', - default='2.0.14.1', + default='2.0.17.1', type=str, - help='the version of the cluster to be build, Default is 2.0.14.1') + help='the version of the cluster to be build, Default is 2.0.17.1') +parser.add_argument( + '-d', + '--docker-dir', + action='store', + default='/data', + type=str, + help='the data dir for docker, default is /data') +parser.add_argument( + '--flag', + action='store_true', + help='remove docker containers flag, default: True') args = parser.parse_args() -cluster = BuildDockerCluser(args.host, args.user, args.password, args.config_dir, args.num_of_nodes, args.version) -cluster.run() \ No newline at end of file +cluster = BuildDockerCluser(args.host, args.user, args.password, args.config_dir, args.num_of_nodes, args.version, args.docker_dir, args.flag) +cluster.run() + +# usage 1: python3 basic.py -n 2 --flag (flag is True) +# usage 2: python3 basic.py -n 2 (flag should be False when it is not specified) \ No newline at end of file diff --git a/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh b/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh index 968cdd1c1c..992ed8b8fb 100755 --- a/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh +++ b/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh @@ -1,18 +1,19 @@ #!/bin/bash echo "Executing buildClusterEnv.sh" -DOCKER_DIR=/data CURR_DIR=`pwd` -if [ $# != 4 ]; then +if [ $# != 6 ]; then echo "argument list need input : " echo " -n numOfNodes" - echo " -v version" + echo " -v version" + echo " -d docker dir" exit 1 fi NUM_OF_NODES= VERSION= -while getopts "n:v:" arg +DOCKER_DIR= +while getopts "n:v:d:" arg do case $arg in n) @@ -20,6 +21,9 @@ do ;; v) VERSION=$OPTARG + ;; + d) + DOCKER_DIR=$OPTARG ;; ?) echo "unkonwn argument" @@ -31,29 +35,28 @@ function addTaoscfg { for i in {1..5} do touch /data/node$i/cfg/taos.cfg - echo 'firstEp tdnode1:6030' > /data/node$i/cfg/taos.cfg - echo 'fqdn tdnode'$i >> /data/node$i/cfg/taos.cfg - echo 'arbitrator tdnode1:6042' >> /data/node$i/cfg/taos.cfg + echo 'firstEp tdnode1:6030' > $DOCKER_DIR/node$i/cfg/taos.cfg + echo 'fqdn tdnode'$i >> $DOCKER_DIR/node$i/cfg/taos.cfg + echo 'arbitrator tdnode1:6042' >> $DOCKER_DIR/node$i/cfg/taos.cfg done } function createDIR { for i in {1..5} do - mkdir -p /data/node$i/data - mkdir -p /data/node$i/log - mkdir -p /data/node$i/cfg - mkdir -p /data/node$i/core + mkdir -p $DOCKER_DIR/node$i/data + mkdir -p $DOCKER_DIR/node$i/log + mkdir -p $DOCKER_DIR/node$i/cfg + mkdir -p $DOCKER_DIR/node$i/core done } -function cleanEnv { +function cleanEnv { + echo "Clean up docker environment" for i in {1..5} - do - echo /data/node$i/data/* - rm -rf /data/node$i/data/* - echo /data/node$i/log/* - rm -rf /data/node$i/log/* + do + rm -rf $DOCKER_DIR/node$i/data/* + rm -rf $DOCKER_DIR/node$i/log/* done } @@ -98,19 +101,19 @@ function clusterUp { if [ $NUM_OF_NODES -eq 2 ]; then echo "create 2 dnodes" - PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION docker-compose up -d + PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz TARBITRATORPKG=TDengine-arbitrator-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION docker-compose up -d fi if [ $NUM_OF_NODES -eq 3 ]; then - PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION docker-compose -f docker-compose.yml -f node3.yml up -d + PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz TARBITRATORPKG=TDengine-arbitrator-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION docker-compose -f docker-compose.yml -f node3.yml up -d fi if [ $NUM_OF_NODES -eq 4 ]; then - PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION docker-compose -f docker-compose.yml -f node3.yml -f node4.yml up -d + PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz TARBITRATORPKG=TDengine-arbitrator-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION docker-compose -f docker-compose.yml -f node3.yml -f node4.yml up -d fi if [ $NUM_OF_NODES -eq 5 ]; then - PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION docker-compose -f docker-compose.yml -f node3.yml -f node4.yml -f node5.yml up -d + PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz TARBITRATORPKG=TDengine-arbitrator-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION docker-compose -f docker-compose.yml -f node3.yml -f node4.yml -f node5.yml up -d fi echo "docker compose finish" diff --git a/tests/pytest/cluster/clusterEnvSetup/cleanClusterEnv.sh b/tests/pytest/cluster/clusterEnvSetup/cleanClusterEnv.sh new file mode 100755 index 0000000000..006db3f4eb --- /dev/null +++ b/tests/pytest/cluster/clusterEnvSetup/cleanClusterEnv.sh @@ -0,0 +1,39 @@ +#!/bin/bash +echo "Executing cleanClusterEnv.sh" +CURR_DIR=`pwd` + +if [ $# != 2 ]; then + echo "argument list need input : " + echo " -d docker dir" + exit 1 +fi + +DOCKER_DIR= +while getopts "d:" arg +do + case $arg in + d) + DOCKER_DIR=$OPTARG + ;; + ?) + echo "unkonwn argument" + ;; + esac +done + +function removeDockerContainers { + cd $DOCKER_DIR + docker-compose down --remove-orphans +} + +function cleanEnv { + echo "Clean up docker environment" + for i in {1..5} + do + rm -rf $DOCKER_DIR/node$i/data/* + rm -rf $DOCKER_DIR/node$i/log/* + done +} + +removeDockerContainers +cleanEnv \ No newline at end of file From 388887efaa6245f8435cfbc03f3cb24bc976b9d7 Mon Sep 17 00:00:00 2001 From: Elias Soong Date: Thu, 18 Mar 2021 18:20:59 +0800 Subject: [PATCH 78/89] [TD-2354] : need reboot to take effect when alter CACHELAST option. --- documentation20/cn/12.taos-sql/docs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation20/cn/12.taos-sql/docs.md b/documentation20/cn/12.taos-sql/docs.md index 02352357e1..2248b11987 100644 --- a/documentation20/cn/12.taos-sql/docs.md +++ b/documentation20/cn/12.taos-sql/docs.md @@ -125,7 +125,7 @@ TDengine缺省的时间戳是毫秒精度,但通过修改配置参数enableMic ```mysql ALTER DATABASE db_name CACHELAST 0; ``` - CACHELAST 参数控制是否在内存中缓存数据子表的 last_row。缺省值为 0,取值范围 [0, 1]。其中 0 表示不启用、1 表示启用。(从 2.0.11 版本开始支持) + CACHELAST 参数控制是否在内存中缓存数据子表的 last_row。缺省值为 0,取值范围 [0, 1]。其中 0 表示不启用、1 表示启用。(从 2.0.11 版本开始支持,修改后需要重启服务器生效。) **Tips**: 以上所有参数修改后都可以用show databases来确认是否修改成功。 From e9ff56e37fd509b05181a441c71ac4adfebe7928 Mon Sep 17 00:00:00 2001 From: tomchon Date: Thu, 18 Mar 2021 18:54:36 +0800 Subject: [PATCH 79/89] [TD-2943] --- packaging/tools/remove.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index 2f2660d446..e63889aff1 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -213,10 +213,10 @@ fi if echo $osinfo | grep -qwi "ubuntu" ; then # echo "this is ubuntu system" - ${csudo} rm -f /var/lib/dpkg/info/tdengine* || : + ${csudo} dpkg --force-all -P tdengine || : elif echo $osinfo | grep -qwi "debian" ; then # echo "this is debian system" - ${csudo} rm -f /var/lib/dpkg/info/tdengine* || : + ${csudo} dpkg --force-all -P tdengine || : elif echo $osinfo | grep -qwi "centos" ; then # echo "this is centos system" ${csudo} rpm -e --noscripts tdengine || : From 624a9191ceeb49afe68eb7bf90d522d4d6d5027b Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 18 Mar 2021 19:17:19 +0800 Subject: [PATCH 80/89] [TD-3357] : fix child table count if exists. (#5488) Co-authored-by: Shuduo Sang --- src/kit/taosdemo/taosdemo.c | 81 ++++++++++++++++++++----------------- 1 file changed, 45 insertions(+), 36 deletions(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 355f738885..46f9a52afe 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -101,8 +101,8 @@ typedef enum CREATE_SUB_TALBE_MOD_EN { } CREATE_SUB_TALBE_MOD_EN; typedef enum TALBE_EXISTS_EN { - TBL_ALREADY_EXISTS, TBL_NO_EXISTS, + TBL_ALREADY_EXISTS, TBL_EXISTS_BUTT } TALBE_EXISTS_EN; @@ -2401,8 +2401,11 @@ static int createDatabases() { &g_Dbs.db[i].superTbls[j], g_Dbs.use_metric); } else { g_Dbs.db[i].superTbls[j].superTblExists = TBL_ALREADY_EXISTS; - ret = getSuperTableFromServer(taos, g_Dbs.db[i].dbName, + + if (g_Dbs.db[i].superTbls[j].childTblExists != TBL_ALREADY_EXISTS) { + ret = getSuperTableFromServer(taos, g_Dbs.db[i].dbName, &g_Dbs.db[i].superTbls[j]); + } } if (0 != ret) { @@ -2794,9 +2797,10 @@ void readSampleFromFileToMem(SSuperTable * supterTblInfo) { } } */ -static bool getColumnAndTagTypeFromInsertJsonFile(cJSON* stbInfo, SSuperTable* superTbls) { +static bool getColumnAndTagTypeFromInsertJsonFile( + cJSON* stbInfo, SSuperTable* superTbls) { bool ret = false; - + // columns cJSON *columns = cJSON_GetObjectItem(stbInfo, "columns"); if (columns && columns->type != cJSON_Array) { @@ -2807,7 +2811,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(cJSON* stbInfo, SSuperTable* s superTbls->tagCount = 0; return true; } - + int columnSize = cJSON_GetArraySize(columns); if (columnSize > MAX_COLUMN_COUNT) { errorPrint("%s() LN%d, failed to read json, column size overflow, max column size is %d\n", @@ -2819,7 +2823,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(cJSON* stbInfo, SSuperTable* s int index = 0; StrColumn columnCase; - //superTbls->columnCount = columnSize; + //superTbls->columnCount = columnSize; for (int k = 0; k < columnSize; ++k) { cJSON* column = cJSON_GetArrayItem(columns, k); if (column == NULL) continue; @@ -2827,7 +2831,7 @@ static bool getColumnAndTagTypeFromInsertJsonFile(cJSON* stbInfo, SSuperTable* s count = 1; cJSON* countObj = cJSON_GetObjectItem(column, "count"); if (countObj && countObj->type == cJSON_Number) { - count = countObj->valueint; + count = countObj->valueint; } else if (countObj && countObj->type != cJSON_Number) { errorPrint("%s() LN%d, failed to read json, column count not found\n", __func__, __LINE__); goto PARSE_OVER; @@ -2844,25 +2848,26 @@ static bool getColumnAndTagTypeFromInsertJsonFile(cJSON* stbInfo, SSuperTable* s } //tstrncpy(superTbls->columns[k].dataType, dataType->valuestring, MAX_TB_NAME_SIZE); tstrncpy(columnCase.dataType, dataType->valuestring, MAX_TB_NAME_SIZE); - + cJSON* dataLen = cJSON_GetObjectItem(column, "len"); if (dataLen && dataLen->type == cJSON_Number) { - columnCase.dataLen = dataLen->valueint; + columnCase.dataLen = dataLen->valueint; } else if (dataLen && dataLen->type != cJSON_Number) { debugPrint("%s() LN%d: failed to read json, column len not found\n", __func__, __LINE__); goto PARSE_OVER; } else { columnCase.dataLen = 8; } - + for (int n = 0; n < count; ++n) { - tstrncpy(superTbls->columns[index].dataType, columnCase.dataType, MAX_TB_NAME_SIZE); - superTbls->columns[index].dataLen = columnCase.dataLen; + tstrncpy(superTbls->columns[index].dataType, + columnCase.dataType, MAX_TB_NAME_SIZE); + superTbls->columns[index].dataLen = columnCase.dataLen; index++; } - } - superTbls->columnCount = index; - + } + superTbls->columnCount = index; + count = 1; index = 0; // tags @@ -2877,16 +2882,16 @@ static bool getColumnAndTagTypeFromInsertJsonFile(cJSON* stbInfo, SSuperTable* s debugPrint("%s() LN%d, failed to read json, tags size overflow, max tag size is %d\n", __func__, __LINE__, MAX_TAG_COUNT); goto PARSE_OVER; } - - //superTbls->tagCount = tagSize; + + //superTbls->tagCount = tagSize; for (int k = 0; k < tagSize; ++k) { cJSON* tag = cJSON_GetArrayItem(tags, k); if (tag == NULL) continue; - + count = 1; cJSON* countObj = cJSON_GetObjectItem(tag, "count"); if (countObj && countObj->type == cJSON_Number) { - count = countObj->valueint; + count = countObj->valueint; } else if (countObj && countObj->type != cJSON_Number) { printf("ERROR: failed to read json, column count not found\n"); goto PARSE_OVER; @@ -2902,23 +2907,23 @@ static bool getColumnAndTagTypeFromInsertJsonFile(cJSON* stbInfo, SSuperTable* s goto PARSE_OVER; } tstrncpy(columnCase.dataType, dataType->valuestring, MAX_TB_NAME_SIZE); - + cJSON* dataLen = cJSON_GetObjectItem(tag, "len"); if (dataLen && dataLen->type == cJSON_Number) { - columnCase.dataLen = dataLen->valueint; + columnCase.dataLen = dataLen->valueint; } else if (dataLen && dataLen->type != cJSON_Number) { printf("ERROR: failed to read json, column len not found\n"); goto PARSE_OVER; } else { columnCase.dataLen = 0; - } - + } + for (int n = 0; n < count; ++n) { tstrncpy(superTbls->tags[index].dataType, columnCase.dataType, MAX_TB_NAME_SIZE); - superTbls->tags[index].dataLen = columnCase.dataLen; + superTbls->tags[index].dataLen = columnCase.dataLen; index++; } - } + } superTbls->tagCount = index; ret = true; @@ -3103,8 +3108,10 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { } cJSON *precision = cJSON_GetObjectItem(dbinfo, "precision"); - if (precision && precision->type == cJSON_String && precision->valuestring != NULL) { - tstrncpy(g_Dbs.db[i].dbCfg.precision, precision->valuestring, MAX_DB_NAME_SIZE); + if (precision && precision->type == cJSON_String + && precision->valuestring != NULL) { + tstrncpy(g_Dbs.db[i].dbCfg.precision, precision->valuestring, + MAX_DB_NAME_SIZE); } else if (!precision) { //tstrncpy(g_Dbs.db[i].dbCfg.precision, "ms", MAX_DB_NAME_SIZE); memset(g_Dbs.db[i].dbCfg.precision, 0, MAX_DB_NAME_SIZE); @@ -3330,13 +3337,13 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { } else if (!childTblExists) { g_Dbs.db[i].superTbls[j].childTblExists = TBL_NO_EXISTS; } else { - printf("ERROR: failed to read json, child_table_exists not found\n"); + errorPrint("%s() LN%d, failed to read json, child_table_exists not found\n", __func__, __LINE__); goto PARSE_OVER; } cJSON* count = cJSON_GetObjectItem(stbInfo, "childtable_count"); if (!count || count->type != cJSON_Number || 0 >= count->valueint) { - printf("ERROR: failed to read json, childtable_count not found\n"); + errorPrint("%s() LN%d, failed to read json, childtable_count not found\n", __func__, __LINE__); goto PARSE_OVER; } g_Dbs.db[i].superTbls[j].childTblCount = count->valueint; @@ -3349,7 +3356,7 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { } else if (!dataSource) { tstrncpy(g_Dbs.db[i].superTbls[j].dataSource, "rand", MAX_DB_NAME_SIZE); } else { - printf("ERROR: failed to read json, data_source not found\n"); + errorPrint("%s() LN%d, failed to read json, data_source not found\n", __func__, __LINE__); goto PARSE_OVER; } @@ -3546,12 +3553,14 @@ static bool getMetaFromInsertJsonFile(cJSON* root) { goto PARSE_OVER; } - if (NO_CREATE_SUBTBL == g_Dbs.db[i].superTbls[j].autoCreateTable +/* CBD if (NO_CREATE_SUBTBL == g_Dbs.db[i].superTbls[j].autoCreateTable || (TBL_ALREADY_EXISTS == g_Dbs.db[i].superTbls[j].childTblExists)) { continue; } + */ - int retVal = getColumnAndTagTypeFromInsertJsonFile(stbInfo, &g_Dbs.db[i].superTbls[j]); + int retVal = getColumnAndTagTypeFromInsertJsonFile( + stbInfo, &g_Dbs.db[i].superTbls[j]); if (false == retVal) { goto PARSE_OVER; } @@ -4500,7 +4509,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) { pstr += headLen; int dataLen = 0; - debugPrint("[%d] %s() LN%d i=%d batchPerTblTimes=%d batchPerTbl = %d\n", + verbosePrint("[%d] %s() LN%d i=%d batchPerTblTimes=%d batchPerTbl = %d\n", pThreadInfo->threadID, __func__, __LINE__, i, batchPerTblTimes, batchPerTbl); generateDataTail( @@ -4512,7 +4521,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) { pstr += dataLen; recOfBatch += batchPerTbl; pThreadInfo->totalInsertRows += batchPerTbl; - debugPrint("[%d] %s() LN%d batchPerTbl=%d recOfBatch=%d\n", + verbosePrint("[%d] %s() LN%d batchPerTbl=%d recOfBatch=%d\n", pThreadInfo->threadID, __func__, __LINE__, batchPerTbl, recOfBatch); @@ -4535,7 +4544,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) { if ((remainRows > 0) && (batchPerTbl > remainRows)) batchPerTbl = remainRows; - debugPrint("[%d] %s() LN%d generatedRecPerTbl=%d insertRows=%"PRId64"\n", + verbosePrint("[%d] %s() LN%d generatedRecPerTbl=%d insertRows=%"PRId64"\n", pThreadInfo->threadID, __func__, __LINE__, generatedRecPerTbl, insertRows); @@ -4543,7 +4552,7 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) { break; } - debugPrint("[%d] %s() LN%d recOfBatch=%d totalInsertRows=%"PRId64"\n", + verbosePrint("[%d] %s() LN%d recOfBatch=%d totalInsertRows=%"PRId64"\n", pThreadInfo->threadID, __func__, __LINE__, recOfBatch, pThreadInfo->totalInsertRows); verbosePrint("[%d] %s() LN%d, buffer=%s\n", From d8f1b34f5664fcfb4bec08b2ac18a46ea7057e02 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Thu, 18 Mar 2021 21:33:52 +0800 Subject: [PATCH 81/89] [TD-3356] : fix bug regarding limit offset with exist child table. (#5495) Co-authored-by: Shuduo Sang --- src/kit/taosdemo/taosdemo.c | 54 +++++++++---------------------------- 1 file changed, 13 insertions(+), 41 deletions(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 46f9a52afe..2647d32ef5 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -2044,7 +2044,8 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos, //printf("==== sub table name: %s\n", pTblName); count++; if (count >= childTblCount - 1) { - char *tmp = realloc(childTblName, (size_t)childTblCount*1.5*TSDB_TABLE_NAME_LEN+1); + char *tmp = realloc(childTblName, + (size_t)childTblCount*1.5*TSDB_TABLE_NAME_LEN+1); if (tmp != NULL) { childTblName = tmp; childTblCount = (int)(childTblCount*1.5); @@ -2052,14 +2053,15 @@ static int getChildNameOfSuperTableWithLimitAndOffset(TAOS * taos, (size_t)((childTblCount-count)*TSDB_TABLE_NAME_LEN)); } else { // exit, if allocate more memory failed - printf("realloc fail for save child table name of %s.%s\n", dbName, sTblName); + errorPrint("%s() LN%d, realloc fail for save child table name of %s.%s\n", + __func__, __LINE__, dbName, sTblName); tmfree(childTblName); taos_free_result(res); taos_close(taos); exit(-1); } } - pTblName = childTblName + count * TSDB_TABLE_NAME_LEN; + pTblName = childTblName + count * TSDB_TABLE_NAME_LEN; } *childTblCountOfSuperTbl = count; @@ -2140,6 +2142,7 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName, calcRowLen(superTbls); +/* if (TBL_ALREADY_EXISTS == superTbls->childTblExists) { //get all child table name use cmd: select tbname from superTblName; int childTblCount = 10000; @@ -2153,6 +2156,7 @@ static int getSuperTableFromServer(TAOS * taos, char* dbName, &superTbls->childTblName, &superTbls->childTblCount); } + */ return 0; } @@ -4356,7 +4360,7 @@ static int generateSQLHead(char *tableName, int32_t tableSeq, threadInfo* pThrea superTblInfo->maxSqlLen, "insert into %s.%s values", pThreadInfo->db_name, - superTblInfo->childTblName + tableSeq * TSDB_TABLE_NAME_LEN); + tableName); } else { len = snprintf(buffer, (superTblInfo?superTblInfo->maxSqlLen:g_args.max_sql_len), @@ -4561,10 +4565,10 @@ static void* syncWriteInterlace(threadInfo *pThreadInfo) { int affectedRows = execInsert(pThreadInfo, buffer, recOfBatch); verbosePrint("[%d] %s() LN%d affectedRows=%d\n", pThreadInfo->threadID, __func__, __LINE__, affectedRows); - if (affectedRows < 0) { - errorPrint("[%d] %s() LN%d execInsert affected rows: %d\n%s\n", + if ((affectedRows < 0) || (recOfBatch != affectedRows)) { + errorPrint("[%d] %s() LN%d execInsert insert %d, affected rows: %d\n%s\n", pThreadInfo->threadID, __func__, __LINE__, - affectedRows, buffer); + recOfBatch, affectedRows, buffer); goto free_and_statistics_interlace; } @@ -4885,10 +4889,9 @@ static void startMultiThreadInsertData(int threads, char* db_name, &start_time, strlen(superTblInfo->startTimestamp), timePrec, 0)) { - errorPrint("%s() LN%d, failed to parse time!\n", __func__, __LINE__); - exit(-1); + ERROR_EXIT("failed to parse time!\n"); } - } + } } else { start_time = 1500000000000; } @@ -4911,36 +4914,6 @@ static void startMultiThreadInsertData(int threads, char* db_name, } } - if (superTblInfo && (superTblInfo->childTblOffset >= 0) - && (superTblInfo->childTblLimit > 0)) { - - TAOS* taos = taos_connect( - g_Dbs.host, g_Dbs.user, - g_Dbs.password, db_name, g_Dbs.port); - if (NULL == taos) { - errorPrint("%s() LN%d, connect to server fail , reason: %s\n", - __func__, __LINE__, taos_errstr(NULL)); - exit(-1); - } - - superTblInfo->childTblName = (char*)calloc(1, - superTblInfo->childTblLimit * TSDB_TABLE_NAME_LEN); - if (superTblInfo->childTblName == NULL) { - errorPrint("%s() LN%d, alloc memory failed!\n", __func__, __LINE__); - taos_close(taos); - exit(-1); - } - int childTblCount; - - getChildNameOfSuperTableWithLimitAndOffset( - taos, - db_name, superTblInfo->sTblName, - &superTblInfo->childTblName, &childTblCount, - superTblInfo->childTblLimit, - superTblInfo->childTblOffset); - taos_close(taos); - } - // read sample data from file first if ((superTblInfo) && (0 == strncasecmp(superTblInfo->dataSource, "sample", strlen("sample")))) { @@ -4950,7 +4923,6 @@ static void startMultiThreadInsertData(int threads, char* db_name, } } - TAOS* taos = taos_connect( g_Dbs.host, g_Dbs.user, g_Dbs.password, db_name, g_Dbs.port); From bee74151bbb4151193dee3add5519dc96689513b Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Thu, 18 Mar 2021 22:31:27 +0800 Subject: [PATCH 82/89] fix compile error --- src/util/src/tsocket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/src/tsocket.c b/src/util/src/tsocket.c index 8911b7e8ee..b33cdb8b80 100644 --- a/src/util/src/tsocket.c +++ b/src/util/src/tsocket.c @@ -485,7 +485,7 @@ int64_t taosCopyFds(SOCKET sfd, int32_t dfd, int64_t len) { return -1; } - writeLen = taosWriteMsg(dfd, temp, readLen); + writeLen = taosWriteMsg(dfd, temp, (int32_t)readLen); if (readLen != writeLen) { uError("copy error, readLen:%" PRId64 " writeLen:%" PRId64 " len:%" PRId64 " leftLen:%" PRId64 ", reason:%s", From 153a489e129935592527131ae48b61e3b78a5732 Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Fri, 19 Mar 2021 09:38:34 +0800 Subject: [PATCH 83/89] [TD-3365]: add test case for query filter on tag type --- tests/pytest/query/filter.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/pytest/query/filter.py b/tests/pytest/query/filter.py index f107985f15..ceaca993b1 100644 --- a/tests/pytest/query/filter.py +++ b/tests/pytest/query/filter.py @@ -28,18 +28,18 @@ class TDTestCase: print("==============step1") tdSql.execute( - "create table if not exists st (ts timestamp, tagtype int, name nchar(16)) tags(dev nchar(50))") + "create table if not exists st (ts timestamp, tagtype int, name nchar(16), col4 binary(16)) tags(dev nchar(50), tag2 binary(16))") tdSql.execute( - 'CREATE TABLE if not exists dev_001 using st tags("dev_01")') + 'CREATE TABLE if not exists dev_001 using st tags("dev_01", "tag_01")') tdSql.execute( - 'CREATE TABLE if not exists dev_002 using st tags("dev_02")') + 'CREATE TABLE if not exists dev_002 using st tags("dev_02", "tag_02")') print("==============step2") tdSql.execute( - """INSERT INTO dev_001(ts, tagtype, name) VALUES('2020-05-13 10:00:00.000', 1, 'first'),('2020-05-13 10:00:00.001', 2, 'second'), - ('2020-05-13 10:00:00.002', 3, 'third') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first'), ('2020-05-13 10:00:00.004', 2, 'second'), - ('2020-05-13 10:00:00.005', 3, 'third')""") + """INSERT INTO dev_001 VALUES('2020-05-13 10:00:00.000', 1, 'first', 'binary1'),('2020-05-13 10:00:00.001', 2, 'second', 'binary2'), + ('2020-05-13 10:00:00.002', 3, 'third' , 'binary3') dev_002 VALUES('2020-05-13 10:00:00.003', 1, 'first', 'binary4'), ('2020-05-13 10:00:00.004', 2, 'second', 'binary5'), + ('2020-05-13 10:00:00.005', 3, 'third', 'binary6')""") # > for timestamp type tdSql.query("select * from db.st where ts > '2020-05-13 10:00:00.002'") @@ -85,6 +85,9 @@ class TDTestCase: tdSql.query("select * from db.st where name = 'first'") tdSql.checkRows(2) + tdSql.error("select * from db.st where col1 = 1231231") + tdSql.error("select * from db.st where name = 1231231") + # <> for timestamp type tdSql.query("select * from db.st where ts <> '2020-05-13 10:00:00.002'") # tdSql.checkRows(4) @@ -105,6 +108,10 @@ class TDTestCase: tdSql.query("select * from db.st where name like '_econd'") tdSql.checkRows(2) + # for tag + tdSql.error("select * from db.st where dev=1") + tdSql.error("select * from db.st where tag2=1") + def stop(self): tdSql.close() tdLog.success("%s successfully executed" % __file__) From 5586c23906338f800881f3c524e594ad9a5c05e6 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 19 Mar 2021 10:07:27 +0800 Subject: [PATCH 84/89] [td-3361]: fix crash caused by nchar type filter. --- src/client/src/tscSQLParser.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 3b65d0625f..ab13251c64 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -3092,18 +3092,26 @@ static int32_t doExtractColumnFilterInfo(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, } int32_t retVal = TSDB_CODE_SUCCESS; + + int32_t bufLen = 0; + if (IS_NUMERIC_TYPE(pRight->value.nType)) { + bufLen = 60; + } else { + bufLen = pRight->value.nLen + 1; + } + if (pExpr->tokenId == TK_LE || pExpr->tokenId == TK_LT) { retVal = tVariantDump(&pRight->value, (char*)&pColumnFilter->upperBndd, colType, false); // TK_GT,TK_GE,TK_EQ,TK_NE are based on the pColumn->lowerBndd } else if (colType == TSDB_DATA_TYPE_BINARY) { - pColumnFilter->pz = (int64_t)calloc(1, pRight->value.nLen + TSDB_NCHAR_SIZE); + pColumnFilter->pz = (int64_t)calloc(1, bufLen * TSDB_NCHAR_SIZE); pColumnFilter->len = pRight->value.nLen; retVal = tVariantDump(&pRight->value, (char*)pColumnFilter->pz, colType, false); } else if (colType == TSDB_DATA_TYPE_NCHAR) { // pRight->value.nLen + 1 is larger than the actual nchar string length - pColumnFilter->pz = (int64_t)calloc(1, (pRight->value.nLen + 1) * TSDB_NCHAR_SIZE); + pColumnFilter->pz = (int64_t)calloc(1, bufLen * TSDB_NCHAR_SIZE); retVal = tVariantDump(&pRight->value, (char*)pColumnFilter->pz, colType, false); size_t len = twcslen((wchar_t*)pColumnFilter->pz); pColumnFilter->len = len * TSDB_NCHAR_SIZE; From 22698b8db09bba18d2cd97048f3fd84edbbe10b1 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Fri, 19 Mar 2021 10:51:55 +0800 Subject: [PATCH 85/89] [td-225]update the output column index. --- src/client/src/tscSQLParser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index ab13251c64..b724ee5750 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -2223,7 +2223,7 @@ int32_t addExprAndResultField(SSqlCmd* pCmd, SQueryInfo* pQueryInfo, int32_t col bool multiColOutput = taosArrayGetSize(pItem->pNode->pParam) > 1; setResultColName(name, pItem, cvtFunc.originFuncId, &pParamElem->pNode->colInfo, multiColOutput); - if (setExprInfoForFunctions(pCmd, pQueryInfo, pSchema, cvtFunc, name, colIndex + i, &index, finalResult) != 0) { + if (setExprInfoForFunctions(pCmd, pQueryInfo, pSchema, cvtFunc, name, colIndex++, &index, finalResult) != 0) { return TSDB_CODE_TSC_INVALID_SQL; } } From ae73ff2074736bc0ef95232f37699588cede955a Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Fri, 19 Mar 2021 11:12:06 +0800 Subject: [PATCH 86/89] update docker cluster script --- .../clusterEnvSetup/buildClusterEnv.sh | 10 +++++----- .../clusterEnvSetup/docker-compose.yml | 20 ++++++++++--------- .../pytest/cluster/clusterEnvSetup/node3.yml | 11 +++++----- .../pytest/cluster/clusterEnvSetup/node4.yml | 15 +++++++------- .../pytest/cluster/clusterEnvSetup/node5.yml | 11 +++++----- 5 files changed, 36 insertions(+), 31 deletions(-) diff --git a/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh b/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh index 992ed8b8fb..f6199649cd 100755 --- a/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh +++ b/tests/pytest/cluster/clusterEnvSetup/buildClusterEnv.sh @@ -34,7 +34,7 @@ done function addTaoscfg { for i in {1..5} do - touch /data/node$i/cfg/taos.cfg + touch $DOCKER_DIR/node$i/cfg/taos.cfg echo 'firstEp tdnode1:6030' > $DOCKER_DIR/node$i/cfg/taos.cfg echo 'fqdn tdnode'$i >> $DOCKER_DIR/node$i/cfg/taos.cfg echo 'arbitrator tdnode1:6042' >> $DOCKER_DIR/node$i/cfg/taos.cfg @@ -101,19 +101,19 @@ function clusterUp { if [ $NUM_OF_NODES -eq 2 ]; then echo "create 2 dnodes" - PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz TARBITRATORPKG=TDengine-arbitrator-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION docker-compose up -d + PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz TARBITRATORPKG=TDengine-arbitrator-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION DATADIR=$DOCKER_DIR docker-compose up -d fi if [ $NUM_OF_NODES -eq 3 ]; then - PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz TARBITRATORPKG=TDengine-arbitrator-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION docker-compose -f docker-compose.yml -f node3.yml up -d + PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz TARBITRATORPKG=TDengine-arbitrator-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION DATADIR=$DOCKER_DIR docker-compose -f docker-compose.yml -f node3.yml up -d fi if [ $NUM_OF_NODES -eq 4 ]; then - PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz TARBITRATORPKG=TDengine-arbitrator-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION docker-compose -f docker-compose.yml -f node3.yml -f node4.yml up -d + PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz TARBITRATORPKG=TDengine-arbitrator-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION DATADIR=$DOCKER_DIR docker-compose -f docker-compose.yml -f node3.yml -f node4.yml up -d fi if [ $NUM_OF_NODES -eq 5 ]; then - PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz TARBITRATORPKG=TDengine-arbitrator-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION docker-compose -f docker-compose.yml -f node3.yml -f node4.yml -f node5.yml up -d + PACKAGE=TDengine-server-$VERSION-Linux-x64.tar.gz TARBITRATORPKG=TDengine-arbitrator-$VERSION-Linux-x64.tar.gz DIR=TDengine-server-$VERSION DIR2=TDengine-arbitrator-$VERSION VERSION=$VERSION DATADIR=$DOCKER_DIR docker-compose -f docker-compose.yml -f node3.yml -f node4.yml -f node5.yml up -d fi echo "docker compose finish" diff --git a/tests/pytest/cluster/clusterEnvSetup/docker-compose.yml b/tests/pytest/cluster/clusterEnvSetup/docker-compose.yml index cb35abd9a1..80cd859cdf 100644 --- a/tests/pytest/cluster/clusterEnvSetup/docker-compose.yml +++ b/tests/pytest/cluster/clusterEnvSetup/docker-compose.yml @@ -9,6 +9,7 @@ services: - TARBITRATORPKG=${TARBITRATORPKG} - EXTRACTDIR=${DIR} - EXTRACTDIR2=${DIR2} + - DATADIR=${DATADIR} image: 'tdengine:${VERSION}' container_name: 'tdnode1' cap_add: @@ -32,19 +33,19 @@ services: volumes: # bind data directory - type: bind - source: /data/node1/data + source: ${DATADIR}/node1/data target: /var/lib/taos # bind log directory - type: bind - source: /data/node1/log + source: ${DATADIR}/node1/log target: /var/log/taos # bind configuration - type: bind - source: /data/node1/cfg + source: ${DATADIR}/node1/cfg target: /etc/taos # bind core dump path - type: bind - source: /data/node1/core + source: ${DATADIR}/node1/core target: /coredump - type: bind source: /data @@ -61,6 +62,7 @@ services: args: - PACKAGE=${PACKAGE} - EXTRACTDIR=${DIR} + - DATADIR=${DATADIR} image: 'tdengine:${VERSION}' container_name: 'tdnode2' cap_add: @@ -84,22 +86,22 @@ services: volumes: # bind data directory - type: bind - source: /data/node2/data + source: ${DATADIR}/node2/data target: /var/lib/taos # bind log directory - type: bind - source: /data/node2/log + source: ${DATADIR}/node2/log target: /var/log/taos # bind configuration - type: bind - source: /data/node2/cfg + source: ${DATADIR}/node2/cfg target: /etc/taos # bind core dump path - type: bind - source: /data/node2/core + source: ${DATADIR}/node2/core target: /coredump - type: bind - source: /data + source: ${DATADIR} target: /root hostname: tdnode2 networks: diff --git a/tests/pytest/cluster/clusterEnvSetup/node3.yml b/tests/pytest/cluster/clusterEnvSetup/node3.yml index 4f4f3a6f99..93044d24af 100644 --- a/tests/pytest/cluster/clusterEnvSetup/node3.yml +++ b/tests/pytest/cluster/clusterEnvSetup/node3.yml @@ -7,6 +7,7 @@ services: args: - PACKAGE=${PACKAGE} - EXTRACTDIR=${DIR} + - DATADIR=${DATADIR} image: 'tdengine:${VERSION}' container_name: 'tdnode3' cap_add: @@ -30,22 +31,22 @@ services: volumes: # bind data directory - type: bind - source: /data/node3/data + source: ${DATADIR}/node3/data target: /var/lib/taos # bind log directory - type: bind - source: /data/node3/log + source: ${DATADIR}/node3/log target: /var/log/taos # bind configuration - type: bind - source: /data/node3/cfg + source: ${DATADIR}/node3/cfg target: /etc/taos # bind core dump path - type: bind - source: /data/node3/core + source: ${DATADIR}/node3/core target: /coredump - type: bind - source: /data + source: ${DATADIR} target: /root hostname: tdnode3 networks: diff --git a/tests/pytest/cluster/clusterEnvSetup/node4.yml b/tests/pytest/cluster/clusterEnvSetup/node4.yml index c82a174cb8..1fc603b3b5 100644 --- a/tests/pytest/cluster/clusterEnvSetup/node4.yml +++ b/tests/pytest/cluster/clusterEnvSetup/node4.yml @@ -7,6 +7,7 @@ services: args: - PACKAGE=${PACKAGE} - EXTRACTDIR=${DIR} + - DATADIR=${DATADIR} image: 'tdengine:${VERSION}' container_name: 'tdnode4' cap_add: @@ -30,23 +31,23 @@ services: volumes: # bind data directory - type: bind - source: /data/node4/data + source: ${DATADIR}/node4/data target: /var/lib/taos # bind log directory - type: bind - source: /data/node4/log + source: ${DATADIR}/node4/log target: /var/log/taos # bind configuration - type: bind - source: /data/node4/cfg + source: ${DATADIR}/node4/cfg target: /etc/taos - # bind core dump path + # bind core dump path - type: bind - source: /data/node4/core + source: ${DATADIR}/node4/core target: /coredump - type: bind - source: /data - target: /root + source: ${DATADIR} + target: /root hostname: tdnode4 networks: taos_update_net: diff --git a/tests/pytest/cluster/clusterEnvSetup/node5.yml b/tests/pytest/cluster/clusterEnvSetup/node5.yml index 2e37e47512..5e3aba3b76 100644 --- a/tests/pytest/cluster/clusterEnvSetup/node5.yml +++ b/tests/pytest/cluster/clusterEnvSetup/node5.yml @@ -7,6 +7,7 @@ services: args: - PACKAGE=${PACKAGE} - EXTRACTDIR=${DIR} + - DATADIR=${DATADIR} image: 'tdengine:${VERSION}' container_name: 'tdnode5' cap_add: @@ -30,22 +31,22 @@ services: volumes: # bind data directory - type: bind - source: /data/node5/data + source: ${DATADIR}/node5/data target: /var/lib/taos # bind log directory - type: bind - source: /data/node5/log + source: ${DATADIR}/node5/log target: /var/log/taos # bind configuration - type: bind - source: /data/node5/cfg + source: ${DATADIR}/node5/cfg target: /etc/taos # bind core dump path - type: bind - source: /data/node5/core + source: ${DATADIR}/node5/core target: /coredump - type: bind - source: /data + source: ${DATADIR} target: /root hostname: tdnode5 networks: From d5bacb71c604c3e1754dcfc58dc50ca5c2180c1a Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Fri, 19 Mar 2021 11:51:13 +0800 Subject: [PATCH 87/89] [TD-3369] : fix taosdemo invalid write valgrind reports. (#5496) --- src/kit/taosdemo/taosdemo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index 2647d32ef5..13926e0712 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -997,7 +997,7 @@ void rand_string(char *str, int size) { if (size > 0) { //--size; int n; - for (n = 0; n < size; n++) { + for (n = 0; n < size - 1; n++) { int key = rand_tinyint() % (int)(sizeof(charset) - 1); str[n] = charset[key]; } From e9ea8814ecdab7611d26a381a1398ab38bd14c39 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 19 Mar 2021 05:30:31 +0000 Subject: [PATCH 88/89] TD-3372 --- src/inc/tp.h | 2 +- src/mnode/src/mnodeDb.c | 2 +- src/vnode/inc/vnodeInt.h | 2 +- src/vnode/src/vnodeWrite.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/inc/tp.h b/src/inc/tp.h index b0b787bf68..1d6570898e 100644 --- a/src/inc/tp.h +++ b/src/inc/tp.h @@ -22,7 +22,7 @@ extern "C" { int32_t tpInit(); void tpCleanUp(); -void tpUpdateTs(int32_t *seq, void *pMsg); +void tpUpdateTs(int32_t vgId, int64_t *seq, void *pMsg); #ifdef __cplusplus } diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index fcc88db740..b1c88ca718 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -55,7 +55,7 @@ int32_t mnodeProcessAlterDbMsg(SMnodeMsg *pMsg); #ifndef _TOPIC int32_t tpInit() { return 0; } void tpCleanUp() {} -void tpUpdateTs(int32_t *seq, void *pMsg) {} +void tpUpdateTs(int32_t vgId, int64_t *seq, void *pMsg) {} #endif static void mnodeDestroyDb(SDbObj *pDb) { diff --git a/src/vnode/inc/vnodeInt.h b/src/vnode/inc/vnodeInt.h index 91ddf5076b..4aa07196a7 100644 --- a/src/vnode/inc/vnodeInt.h +++ b/src/vnode/inc/vnodeInt.h @@ -40,7 +40,7 @@ typedef struct { int32_t queuedWMsg; int32_t queuedRMsg; int32_t flowctrlLevel; - int32_t sequence; // for topic + int64_t sequence; // for topic int8_t status; int8_t role; int8_t accessState; diff --git a/src/vnode/src/vnodeWrite.c b/src/vnode/src/vnodeWrite.c index 4b2616c7aa..9e95288423 100644 --- a/src/vnode/src/vnodeWrite.c +++ b/src/vnode/src/vnodeWrite.c @@ -142,7 +142,7 @@ static int32_t vnodeProcessSubmitMsg(SVnodeObj *pVnode, void *pCont, SRspRet *pR vTrace("vgId:%d, submit msg is processed", pVnode->vgId); if (pVnode->dbType == TSDB_DB_TYPE_TOPIC && pVnode->role == TAOS_SYNC_ROLE_MASTER) { - tpUpdateTs(&pVnode->sequence, pCont); + tpUpdateTs(pVnode->vgId, &pVnode->sequence, pCont); } // save insert result into item From 4afccbd0a59cca682158059036b549560eef585c Mon Sep 17 00:00:00 2001 From: Ping Xiao Date: Fri, 19 Mar 2021 13:36:30 +0800 Subject: [PATCH 89/89] [TD-3365]: update test case --- tests/pytest/query/filter.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/pytest/query/filter.py b/tests/pytest/query/filter.py index ceaca993b1..6d2ffbc8b1 100644 --- a/tests/pytest/query/filter.py +++ b/tests/pytest/query/filter.py @@ -85,8 +85,11 @@ class TDTestCase: tdSql.query("select * from db.st where name = 'first'") tdSql.checkRows(2) - tdSql.error("select * from db.st where col1 = 1231231") - tdSql.error("select * from db.st where name = 1231231") + tdSql.query("select * from db.st where col4 = 1231231") + tdSql.checkRows(0) + + tdSql.query("select * from db.st where name = 1231231") + tdSql.checkRows(0) # <> for timestamp type tdSql.query("select * from db.st where ts <> '2020-05-13 10:00:00.002'") @@ -109,8 +112,11 @@ class TDTestCase: tdSql.checkRows(2) # for tag - tdSql.error("select * from db.st where dev=1") - tdSql.error("select * from db.st where tag2=1") + tdSql.query("select * from db.st where dev=1") + tdSql.checkRows(0) + + tdSql.query("select * from db.st where tag2=1") + tdSql.checkRows(0) def stop(self): tdSql.close()